|
@@ -96,9 +96,7 @@ jobject GodotJavaWrapper::get_member_object(const char *p_name, const char *p_cl
|
|
|
if (p_env == nullptr) {
|
|
|
p_env = get_jni_env();
|
|
|
}
|
|
|
-
|
|
|
- ERR_FAIL_COND_V(p_env == nullptr, nullptr);
|
|
|
-
|
|
|
+ ERR_FAIL_NULL_V(p_env, nullptr);
|
|
|
jfieldID fid = p_env->GetStaticFieldID(godot_class, p_name, p_class);
|
|
|
return p_env->GetStaticObjectField(godot_class, fid);
|
|
|
} else {
|
|
@@ -109,8 +107,7 @@ jobject GodotJavaWrapper::get_member_object(const char *p_name, const char *p_cl
|
|
|
jobject GodotJavaWrapper::get_class_loader() {
|
|
|
if (_get_class_loader) {
|
|
|
JNIEnv *env = get_jni_env();
|
|
|
- ERR_FAIL_COND_V(env == nullptr, nullptr);
|
|
|
-
|
|
|
+ ERR_FAIL_NULL_V(env, nullptr);
|
|
|
return env->CallObjectMethod(activity, _get_class_loader);
|
|
|
} else {
|
|
|
return nullptr;
|
|
@@ -122,8 +119,7 @@ GodotJavaViewWrapper *GodotJavaWrapper::get_godot_view() {
|
|
|
return _godot_view;
|
|
|
}
|
|
|
JNIEnv *env = get_jni_env();
|
|
|
- ERR_FAIL_COND_V(env == nullptr, nullptr);
|
|
|
-
|
|
|
+ ERR_FAIL_NULL_V(env, nullptr);
|
|
|
jmethodID godot_view_getter = env->GetMethodID(godot_class, "getRenderView", "()Lorg/godotengine/godot/GodotRenderView;");
|
|
|
_godot_view = new GodotJavaViewWrapper(env->CallObjectMethod(godot_instance, godot_view_getter));
|
|
|
return _godot_view;
|
|
@@ -134,8 +130,7 @@ void GodotJavaWrapper::on_video_init(JNIEnv *p_env) {
|
|
|
if (p_env == nullptr) {
|
|
|
p_env = get_jni_env();
|
|
|
}
|
|
|
- ERR_FAIL_COND(p_env == nullptr);
|
|
|
-
|
|
|
+ ERR_FAIL_NULL(p_env);
|
|
|
p_env->CallVoidMethod(godot_instance, _on_video_init);
|
|
|
}
|
|
|
}
|
|
@@ -154,7 +149,7 @@ void GodotJavaWrapper::on_godot_main_loop_started(JNIEnv *p_env) {
|
|
|
if (p_env == nullptr) {
|
|
|
p_env = get_jni_env();
|
|
|
}
|
|
|
- ERR_FAIL_COND(p_env == nullptr);
|
|
|
+ ERR_FAIL_NULL(p_env);
|
|
|
p_env->CallVoidMethod(godot_instance, _on_godot_main_loop_started);
|
|
|
}
|
|
|
}
|
|
@@ -164,8 +159,7 @@ void GodotJavaWrapper::restart(JNIEnv *p_env) {
|
|
|
if (p_env == nullptr) {
|
|
|
p_env = get_jni_env();
|
|
|
}
|
|
|
- ERR_FAIL_COND(p_env == nullptr);
|
|
|
-
|
|
|
+ ERR_FAIL_NULL(p_env);
|
|
|
p_env->CallVoidMethod(godot_instance, _restart);
|
|
|
}
|
|
|
}
|
|
@@ -175,8 +169,7 @@ void GodotJavaWrapper::force_quit(JNIEnv *p_env) {
|
|
|
if (p_env == nullptr) {
|
|
|
p_env = get_jni_env();
|
|
|
}
|
|
|
- ERR_FAIL_COND(p_env == nullptr);
|
|
|
-
|
|
|
+ ERR_FAIL_NULL(p_env);
|
|
|
p_env->CallVoidMethod(godot_instance, _finish);
|
|
|
}
|
|
|
}
|
|
@@ -184,8 +177,7 @@ void GodotJavaWrapper::force_quit(JNIEnv *p_env) {
|
|
|
void GodotJavaWrapper::set_keep_screen_on(bool p_enabled) {
|
|
|
if (_set_keep_screen_on) {
|
|
|
JNIEnv *env = get_jni_env();
|
|
|
- ERR_FAIL_COND(env == nullptr);
|
|
|
-
|
|
|
+ ERR_FAIL_NULL(env);
|
|
|
env->CallVoidMethod(godot_instance, _set_keep_screen_on, p_enabled);
|
|
|
}
|
|
|
}
|
|
@@ -193,8 +185,7 @@ void GodotJavaWrapper::set_keep_screen_on(bool p_enabled) {
|
|
|
void GodotJavaWrapper::alert(const String &p_message, const String &p_title) {
|
|
|
if (_alert) {
|
|
|
JNIEnv *env = get_jni_env();
|
|
|
- ERR_FAIL_COND(env == nullptr);
|
|
|
-
|
|
|
+ ERR_FAIL_NULL(env);
|
|
|
jstring jStrMessage = env->NewStringUTF(p_message.utf8().get_data());
|
|
|
jstring jStrTitle = env->NewStringUTF(p_title.utf8().get_data());
|
|
|
env->CallVoidMethod(godot_instance, _alert, jStrMessage, jStrTitle);
|
|
@@ -203,24 +194,21 @@ void GodotJavaWrapper::alert(const String &p_message, const String &p_title) {
|
|
|
|
|
|
int GodotJavaWrapper::get_gles_version_code() {
|
|
|
JNIEnv *env = get_jni_env();
|
|
|
- ERR_FAIL_COND_V(env == nullptr, 0);
|
|
|
-
|
|
|
+ ERR_FAIL_NULL_V(env, 0);
|
|
|
if (_get_GLES_version_code) {
|
|
|
return env->CallIntMethod(godot_instance, _get_GLES_version_code);
|
|
|
}
|
|
|
-
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
bool GodotJavaWrapper::has_get_clipboard() {
|
|
|
- return _get_clipboard != 0;
|
|
|
+ return _get_clipboard != nullptr;
|
|
|
}
|
|
|
|
|
|
String GodotJavaWrapper::get_clipboard() {
|
|
|
if (_get_clipboard) {
|
|
|
JNIEnv *env = get_jni_env();
|
|
|
- ERR_FAIL_COND_V(env == nullptr, String());
|
|
|
-
|
|
|
+ ERR_FAIL_NULL_V(env, String());
|
|
|
jstring s = (jstring)env->CallObjectMethod(godot_instance, _get_clipboard);
|
|
|
return jstring_to_string(s, env);
|
|
|
} else {
|
|
@@ -231,8 +219,7 @@ String GodotJavaWrapper::get_clipboard() {
|
|
|
String GodotJavaWrapper::get_input_fallback_mapping() {
|
|
|
if (_get_input_fallback_mapping) {
|
|
|
JNIEnv *env = get_jni_env();
|
|
|
- ERR_FAIL_COND_V(env == nullptr, String());
|
|
|
-
|
|
|
+ ERR_FAIL_NULL_V(env, String());
|
|
|
jstring fallback_mapping = (jstring)env->CallObjectMethod(godot_instance, _get_input_fallback_mapping);
|
|
|
return jstring_to_string(fallback_mapping, env);
|
|
|
} else {
|
|
@@ -241,28 +228,26 @@ String GodotJavaWrapper::get_input_fallback_mapping() {
|
|
|
}
|
|
|
|
|
|
bool GodotJavaWrapper::has_set_clipboard() {
|
|
|
- return _set_clipboard != 0;
|
|
|
+ return _set_clipboard != nullptr;
|
|
|
}
|
|
|
|
|
|
void GodotJavaWrapper::set_clipboard(const String &p_text) {
|
|
|
if (_set_clipboard) {
|
|
|
JNIEnv *env = get_jni_env();
|
|
|
- ERR_FAIL_COND(env == nullptr);
|
|
|
-
|
|
|
+ ERR_FAIL_NULL(env);
|
|
|
jstring jStr = env->NewStringUTF(p_text.utf8().get_data());
|
|
|
env->CallVoidMethod(godot_instance, _set_clipboard, jStr);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
bool GodotJavaWrapper::has_has_clipboard() {
|
|
|
- return _has_clipboard != 0;
|
|
|
+ return _has_clipboard != nullptr;
|
|
|
}
|
|
|
|
|
|
bool GodotJavaWrapper::has_clipboard() {
|
|
|
if (_has_clipboard) {
|
|
|
JNIEnv *env = get_jni_env();
|
|
|
- ERR_FAIL_COND_V(env == nullptr, false);
|
|
|
-
|
|
|
+ ERR_FAIL_NULL_V(env, false);
|
|
|
return env->CallBooleanMethod(godot_instance, _has_clipboard);
|
|
|
} else {
|
|
|
return false;
|
|
@@ -272,8 +257,7 @@ bool GodotJavaWrapper::has_clipboard() {
|
|
|
bool GodotJavaWrapper::request_permission(const String &p_name) {
|
|
|
if (_request_permission) {
|
|
|
JNIEnv *env = get_jni_env();
|
|
|
- ERR_FAIL_COND_V(env == nullptr, false);
|
|
|
-
|
|
|
+ ERR_FAIL_NULL_V(env, false);
|
|
|
jstring jStrName = env->NewStringUTF(p_name.utf8().get_data());
|
|
|
return env->CallBooleanMethod(godot_instance, _request_permission, jStrName);
|
|
|
} else {
|
|
@@ -284,8 +268,7 @@ bool GodotJavaWrapper::request_permission(const String &p_name) {
|
|
|
bool GodotJavaWrapper::request_permissions() {
|
|
|
if (_request_permissions) {
|
|
|
JNIEnv *env = get_jni_env();
|
|
|
- ERR_FAIL_COND_V(env == nullptr, false);
|
|
|
-
|
|
|
+ ERR_FAIL_NULL_V(env, false);
|
|
|
return env->CallBooleanMethod(godot_instance, _request_permissions);
|
|
|
} else {
|
|
|
return false;
|
|
@@ -296,14 +279,12 @@ Vector<String> GodotJavaWrapper::get_granted_permissions() const {
|
|
|
Vector<String> permissions_list;
|
|
|
if (_get_granted_permissions) {
|
|
|
JNIEnv *env = get_jni_env();
|
|
|
- ERR_FAIL_COND_V(env == nullptr, permissions_list);
|
|
|
-
|
|
|
+ ERR_FAIL_NULL_V(env, permissions_list);
|
|
|
jobject permissions_object = env->CallObjectMethod(godot_instance, _get_granted_permissions);
|
|
|
jobjectArray *arr = reinterpret_cast<jobjectArray *>(&permissions_object);
|
|
|
|
|
|
- int i = 0;
|
|
|
jsize len = env->GetArrayLength(*arr);
|
|
|
- for (i = 0; i < len; i++) {
|
|
|
+ for (int i = 0; i < len; i++) {
|
|
|
jstring jstr = (jstring)env->GetObjectArrayElement(*arr, i);
|
|
|
String str = jstring_to_string(jstr, env);
|
|
|
permissions_list.push_back(str);
|
|
@@ -316,8 +297,7 @@ Vector<String> GodotJavaWrapper::get_granted_permissions() const {
|
|
|
void GodotJavaWrapper::init_input_devices() {
|
|
|
if (_init_input_devices) {
|
|
|
JNIEnv *env = get_jni_env();
|
|
|
- ERR_FAIL_COND(env == nullptr);
|
|
|
-
|
|
|
+ ERR_FAIL_NULL(env);
|
|
|
env->CallVoidMethod(godot_instance, _init_input_devices);
|
|
|
}
|
|
|
}
|
|
@@ -325,8 +305,7 @@ void GodotJavaWrapper::init_input_devices() {
|
|
|
jobject GodotJavaWrapper::get_surface() {
|
|
|
if (_get_surface) {
|
|
|
JNIEnv *env = get_jni_env();
|
|
|
- ERR_FAIL_COND_V(env == nullptr, nullptr);
|
|
|
-
|
|
|
+ ERR_FAIL_NULL_V(env, nullptr);
|
|
|
return env->CallObjectMethod(godot_instance, _get_surface);
|
|
|
} else {
|
|
|
return nullptr;
|
|
@@ -336,8 +315,7 @@ jobject GodotJavaWrapper::get_surface() {
|
|
|
bool GodotJavaWrapper::is_activity_resumed() {
|
|
|
if (_is_activity_resumed) {
|
|
|
JNIEnv *env = get_jni_env();
|
|
|
- ERR_FAIL_COND_V(env == nullptr, false);
|
|
|
-
|
|
|
+ ERR_FAIL_NULL_V(env, false);
|
|
|
return env->CallBooleanMethod(godot_instance, _is_activity_resumed);
|
|
|
} else {
|
|
|
return false;
|
|
@@ -347,8 +325,7 @@ bool GodotJavaWrapper::is_activity_resumed() {
|
|
|
void GodotJavaWrapper::vibrate(int p_duration_ms) {
|
|
|
if (_vibrate) {
|
|
|
JNIEnv *env = get_jni_env();
|
|
|
- ERR_FAIL_COND(env == nullptr);
|
|
|
-
|
|
|
+ ERR_FAIL_NULL(env);
|
|
|
env->CallVoidMethod(godot_instance, _vibrate, p_duration_ms);
|
|
|
}
|
|
|
}
|
|
@@ -356,8 +333,7 @@ void GodotJavaWrapper::vibrate(int p_duration_ms) {
|
|
|
void GodotJavaWrapper::create_new_godot_instance(List<String> args) {
|
|
|
if (_create_new_godot_instance) {
|
|
|
JNIEnv *env = get_jni_env();
|
|
|
- ERR_FAIL_COND(env == nullptr);
|
|
|
-
|
|
|
+ ERR_FAIL_NULL(env);
|
|
|
jobjectArray jargs = env->NewObjectArray(args.size(), env->FindClass("java/lang/String"), env->NewStringUTF(""));
|
|
|
for (int i = 0; i < args.size(); i++) {
|
|
|
env->SetObjectArrayElement(jargs, i, env->NewStringUTF(args[i].utf8().get_data()));
|