diff options
Diffstat (limited to 'platform')
39 files changed, 540 insertions, 393 deletions
diff --git a/platform/android/display_server_android.cpp b/platform/android/display_server_android.cpp index 1fcc3d4a5c..af8829324b 100644 --- a/platform/android/display_server_android.cpp +++ b/platform/android/display_server_android.cpp @@ -334,13 +334,6 @@ bool DisplayServerAndroid::can_any_window_draw() const { return true; } -void DisplayServerAndroid::alert(const String &p_alert, const String &p_title) { - GodotJavaWrapper *godot_java = OS_Android::get_singleton()->get_godot_java(); - ERR_FAIL_COND(!godot_java); - - godot_java->alert(p_alert, p_title); -} - void DisplayServerAndroid::process_events() { Input::get_singleton()->flush_accumulated_events(); } @@ -361,7 +354,7 @@ Vector<String> DisplayServerAndroid::get_rendering_drivers_func() { DisplayServer *DisplayServerAndroid::create_func(const String &p_rendering_driver, DisplayServer::WindowMode p_mode, DisplayServer::VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error) { DisplayServer *ds = memnew(DisplayServerAndroid(p_rendering_driver, p_mode, p_vsync_mode, p_flags, p_resolution, r_error)); if (r_error != OK) { - ds->alert("Your video card driver does not support any of the supported Vulkan versions.", "Unable to initialize Video driver"); + OS::get_singleton()->alert("Your video card driver does not support any of the supported Vulkan versions.", "Unable to initialize Video driver"); } return ds; } diff --git a/platform/android/display_server_android.h b/platform/android/display_server_android.h index 46745f8030..9b9f5e99f6 100644 --- a/platform/android/display_server_android.h +++ b/platform/android/display_server_android.h @@ -204,8 +204,6 @@ public: virtual void window_set_vsync_mode(DisplayServer::VSyncMode p_vsync_mode, WindowID p_window = MAIN_WINDOW_ID) override; virtual DisplayServer::VSyncMode window_get_vsync_mode(WindowID p_vsync_mode) const override; - virtual void alert(const String &p_alert, const String &p_title) override; - virtual void process_events() override; void process_accelerometer(const Vector3 &p_accelerometer); diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index 956b59ce80..1795bbe523 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -1817,12 +1817,12 @@ public: MutexLock lock(device_lock); - EditorProgress ep("run", "Running on " + devices[p_device].name, 3); + EditorProgress ep("run", vformat(TTR("Running on %s"), devices[p_device].name), 3); String adb = get_adb_path(); // Export_temp APK. - if (ep.step("Exporting APK...", 0)) { + if (ep.step(TTR("Exporting APK..."), 0)) { return ERR_SKIP; } @@ -1857,7 +1857,7 @@ public: String package_name = p_preset->get("package/unique_name"); if (remove_prev) { - if (ep.step("Uninstalling...", 1)) { + if (ep.step(TTR("Uninstalling..."), 1)) { CLEANUP_AND_RETURN(ERR_SKIP); } @@ -1874,7 +1874,7 @@ public: } print_line("Installing to device (please wait...): " + devices[p_device].name); - if (ep.step("Installing to device, please wait...", 2)) { + if (ep.step(TTR("Installing to device, please wait..."), 2)) { CLEANUP_AND_RETURN(ERR_SKIP); } @@ -1889,7 +1889,7 @@ public: err = OS::get_singleton()->execute(adb, args, &output, &rv, true); print_verbose(output); if (err || rv != 0) { - EditorNode::add_io_error("Could not install to device: " + output); + EditorNode::add_io_error(vformat(TTR("Could not install to device: %s"), output)); CLEANUP_AND_RETURN(ERR_CANT_CREATE); } @@ -1945,7 +1945,7 @@ public: } } - if (ep.step("Running on device...", 3)) { + if (ep.step(TTR("Running on device..."), 3)) { CLEANUP_AND_RETURN(ERR_SKIP); } args.clear(); @@ -1967,7 +1967,7 @@ public: err = OS::get_singleton()->execute(adb, args, &output, &rv, true); print_verbose(output); if (err || rv != 0) { - EditorNode::add_io_error("Could not execute on device."); + EditorNode::add_io_error(TTR("Could not execute on device.")); CLEANUP_AND_RETURN(ERR_CANT_CREATE); } @@ -2068,6 +2068,8 @@ public: if (!installed_android_build_template) { r_missing_templates = !exists_export_template("android_source.zip", &err); err += TTR("Android build template not installed in the project. Install it from the Project menu.") + "\n"; + } else { + r_missing_templates = false; } valid = installed_android_build_template && !r_missing_templates; @@ -2324,7 +2326,7 @@ public: String apksigner = get_apksigner_path(); print_verbose("Starting signing of the " + export_label + " binary using " + apksigner); if (!FileAccess::exists(apksigner)) { - EditorNode::add_io_error("'apksigner' could not be found.\nPlease check the command is available in the Android SDK build-tools directory.\nThe resulting " + export_label + " is unsigned."); + EditorNode::add_io_error(vformat(TTR("'apksigner' could not be found.\nPlease check the command is available in the Android SDK build-tools directory.\nThe resulting %s is unsigned."), export_label)); return OK; } @@ -2342,7 +2344,7 @@ public: user = EditorSettings::get_singleton()->get("export/android/debug_keystore_user"); } - if (ep.step("Signing debug " + export_label + "...", 104)) { + if (ep.step(vformat(TTR("Signing debug %s..."), export_label), 104)) { return ERR_SKIP; } @@ -2351,13 +2353,13 @@ public: password = release_password; user = release_username; - if (ep.step("Signing release " + export_label + "...", 104)) { + if (ep.step(vformat(TTR("Signing release %s..."), export_label), 104)) { return ERR_SKIP; } } if (!FileAccess::exists(keystore)) { - EditorNode::add_io_error("Could not find keystore, unable to export."); + EditorNode::add_io_error(TTR("Could not find keystore, unable to export.")); return ERR_FILE_CANT_OPEN; } @@ -2381,11 +2383,11 @@ public: OS::get_singleton()->execute(apksigner, args, &output, &retval, true); print_verbose(output); if (retval) { - EditorNode::add_io_error("'apksigner' returned with error #" + itos(retval)); + EditorNode::add_io_error(vformat(TTR("'apksigner' returned with error #%d"), retval)); return ERR_CANT_CREATE; } - if (ep.step("Verifying " + export_label + "...", 105)) { + if (ep.step(vformat(TTR("Verifying %s..."), export_label), 105)) { return ERR_SKIP; } @@ -2401,7 +2403,7 @@ public: OS::get_singleton()->execute(apksigner, args, &output, &retval, true); print_verbose(output); if (retval) { - EditorNode::add_io_error("'apksigner' verification of " + export_label + " failed."); + EditorNode::add_io_error(vformat(TTR("'apksigner' verification of %s failed."), export_label)); return ERR_CANT_CREATE; } @@ -2464,7 +2466,7 @@ public: String src_apk; Error err; - EditorProgress ep("export", "Exporting for Android", 105, true); + EditorProgress ep("export", TTR("Exporting for Android"), 105, true); bool use_custom_build = bool(p_preset->get("custom_template/use_custom_build")); bool p_give_internet = p_flags & (DEBUG_FLAG_DUMB_CLIENT | DEBUG_FLAG_REMOTE_DEBUG); @@ -2513,7 +2515,7 @@ public: return ERR_UNCONFIGURED; } if (export_format > EXPORT_FORMAT_AAB || export_format < EXPORT_FORMAT_APK) { - EditorNode::add_io_error("Unsupported export format!\n"); + EditorNode::add_io_error(TTR("Unsupported export format!\n")); return ERR_UNCONFIGURED; //TODO: is this the right error? } @@ -2543,7 +2545,7 @@ public: String project_name = get_project_name(p_preset->get("package/name")); err = _create_project_name_strings_files(p_preset, project_name); //project name localization. if (err != OK) { - EditorNode::add_io_error("Unable to overwrite res://android/build/res/*.xml files with project name"); + EditorNode::add_io_error(TTR("Unable to overwrite res://android/build/res/*.xml files with project name")); } // Copies the project icon files into the appropriate Gradle project directory. _copy_icons_to_gradle_project(p_preset, processed_splash_config_xml, splash_image, splash_bg_color_image, main_image, foreground, background); @@ -2559,7 +2561,7 @@ public: user_data.debug = p_debug; err = export_project_files(p_preset, rename_and_store_file_in_gradle_project, &user_data, copy_gradle_so); if (err != OK) { - EditorNode::add_io_error("Could not export project files to gradle project\n"); + EditorNode::add_io_error(TTR("Could not export project files to gradle project\n")); return err; } if (user_data.libs.size() > 0) { @@ -2572,7 +2574,7 @@ public: print_verbose("Saving apk expansion file.."); err = save_apk_expansion_file(p_preset, p_path); if (err != OK) { - EditorNode::add_io_error("Could not write expansion package file!"); + EditorNode::add_io_error(TTR("Could not write expansion package file!")); return err; } } @@ -2659,7 +2661,7 @@ public: String release_username = p_preset->get("keystore/release_user"); String release_password = p_preset->get("keystore/release_password"); if (!FileAccess::exists(release_keystore)) { - EditorNode::add_io_error("Could not find keystore, unable to export."); + EditorNode::add_io_error(TTR("Could not find keystore, unable to export.")); return ERR_FILE_CANT_OPEN; } @@ -2723,7 +2725,7 @@ public: src_apk = find_export_template("android_release.apk"); } if (src_apk == "") { - EditorNode::add_io_error("Package not found: " + src_apk); + EditorNode::add_io_error(vformat(TTR("Package not found: %s"), src_apk)); return ERR_FILE_NOT_FOUND; } } @@ -2735,13 +2737,13 @@ public: FileAccess *src_f = nullptr; zlib_filefunc_def io = zipio_create_io_from_file(&src_f); - if (ep.step("Creating APK...", 0)) { + if (ep.step(TTR("Creating APK..."), 0)) { return ERR_SKIP; } unzFile pkg = unzOpen2(src_apk.utf8().get_data(), &io); if (!pkg) { - EditorNode::add_io_error("Could not find template APK to export:\n" + src_apk); + EditorNode::add_io_error(vformat(TTR("Could not find template APK to export:\n%s"), src_apk)); return ERR_FILE_NOT_FOUND; } @@ -2869,12 +2871,11 @@ public: if (!invalid_abis.is_empty()) { String unsupported_arch = String(", ").join(invalid_abis); - EditorNode::add_io_error("Missing libraries in the export template for the selected architectures: " + unsupported_arch + ".\n" + - "Please build a template with all required libraries, or uncheck the missing architectures in the export preset."); + EditorNode::add_io_error(vformat(TTR("Missing libraries in the export template for the selected architectures: %s.\nPlease build a template with all required libraries, or uncheck the missing architectures in the export preset."), unsupported_arch)); CLEANUP_AND_RETURN(ERR_FILE_NOT_FOUND); } - if (ep.step("Adding files...", 1)) { + if (ep.step(TTR("Adding files..."), 1)) { CLEANUP_AND_RETURN(ERR_SKIP); } err = OK; @@ -2888,7 +2889,7 @@ public: if (apk_expansion) { err = save_apk_expansion_file(p_preset, p_path); if (err != OK) { - EditorNode::add_io_error("Could not write expansion package file!"); + EditorNode::add_io_error(TTR("Could not write expansion package file!")); return err; } } else { @@ -2901,7 +2902,7 @@ public: if (err != OK) { unzClose(pkg); - EditorNode::add_io_error("Could not export project files"); + EditorNode::add_io_error(TTR("Could not export project files")); CLEANUP_AND_RETURN(ERR_SKIP); } @@ -2931,13 +2932,13 @@ public: // If we're not signing the apk, then the next step should be the last. const int next_step = should_sign ? 103 : 105; - if (ep.step("Aligning APK...", next_step)) { + if (ep.step(TTR("Aligning APK..."), next_step)) { CLEANUP_AND_RETURN(ERR_SKIP); } unzFile tmp_unaligned = unzOpen2(tmp_unaligned_path.utf8().get_data(), &io); if (!tmp_unaligned) { - EditorNode::add_io_error("Could not unzip temporary unaligned APK."); + EditorNode::add_io_error(TTR("Could not unzip temporary unaligned APK.")); CLEANUP_AND_RETURN(ERR_FILE_NOT_FOUND); } diff --git a/platform/android/java/app/gradle.properties b/platform/android/java/app/gradle.properties new file mode 100644 index 0000000000..19587bd81f --- /dev/null +++ b/platform/android/java/app/gradle.properties @@ -0,0 +1,25 @@ +# Godot custom build Gradle settings. +# These properties apply when running custom build from the Godot editor. +# NOTE: This should be kept in sync with 'godot/platform/android/java/gradle.properties' except +# where otherwise specified. + +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html + +android.enableJetifier=true +android.useAndroidX=true + +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx4536m + +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true + +org.gradle.warning.mode=all + +# Enable resource optimizations for release build. +# NOTE: This is turned off for template release build in order to support the build legacy process. +android.enableResourceOptimizations=true diff --git a/platform/android/java/build.gradle b/platform/android/java/build.gradle index ee24a46d9f..87bb2ea218 100644 --- a/platform/android/java/build.gradle +++ b/platform/android/java/build.gradle @@ -115,7 +115,7 @@ task zipCustomBuild(type: Zip) { doFirst { logger.lifecycle("Generating Godot custom build template") } - from(fileTree(dir: 'app', excludes: ['**/build/**', '**/.gradle/**', '**/*.iml']), fileTree(dir: '.', includes: ['gradle.properties', 'gradlew', 'gradlew.bat', 'gradle/**'])) + from(fileTree(dir: 'app', excludes: ['**/build/**', '**/.gradle/**', '**/*.iml']), fileTree(dir: '.', includes: ['gradlew', 'gradlew.bat', 'gradle/**'])) include '**/*' archiveFileName = 'android_source.zip' destinationDirectory = file(binDir) diff --git a/platform/android/java/gradle.properties b/platform/android/java/gradle.properties index 6b3b62a9da..b51a19a005 100644 --- a/platform/android/java/gradle.properties +++ b/platform/android/java/gradle.properties @@ -1,4 +1,6 @@ # Project-wide Gradle settings. +# NOTE: This should be kept in sync with 'godot/platform/android/java/app/gradle.properties' except +# where otherwise specified. # IDE (e.g. Android Studio) users: # Gradle settings configured through the IDE *will override* @@ -20,3 +22,7 @@ org.gradle.jvmargs=-Xmx4536m # org.gradle.parallel=true org.gradle.warning.mode=all + +# Disable resource optimizations for template release build. +# NOTE: This is turned on for custom build in order to improve the release build. +android.enableResourceOptimizations=false diff --git a/platform/android/java/lib/src/com/google/android/vending/licensing/Obfuscator.java b/platform/android/java/lib/src/com/google/android/vending/licensing/Obfuscator.java index 008c150a8e..05b452d0c1 100644 --- a/platform/android/java/lib/src/com/google/android/vending/licensing/Obfuscator.java +++ b/platform/android/java/lib/src/com/google/android/vending/licensing/Obfuscator.java @@ -20,7 +20,7 @@ package com.google.android.vending.licensing; * Interface used as part of a {@link Policy} to allow application authors to obfuscate * licensing data that will be stored into a SharedPreferences file. * <p> - * Any transformation scheme must be reversable. Implementing classes may optionally implement an + * Any transformation scheme must be reversible. Implementing classes may optionally implement an * integrity check to further prevent modification to preference data. Implementing classes * should use device-specific information as a key in the obfuscation algorithm to prevent * obfuscated preferences from being shared among devices. diff --git a/platform/android/java_class_wrapper.cpp b/platform/android/java_class_wrapper.cpp index ed6b5c3e14..49891cd739 100644 --- a/platform/android/java_class_wrapper.cpp +++ b/platform/android/java_class_wrapper.cpp @@ -41,13 +41,13 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method, ERR_FAIL_COND_V(env == nullptr, false); MethodInfo *method = nullptr; - for (List<MethodInfo>::Element *E = M->get().front(); E; E = E->next()) { - if (!p_instance && !E->get()._static) { + for (MethodInfo &E : M->get()) { + if (!p_instance && !E._static) { r_error.error = Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL; continue; } - int pc = E->get().param_types.size(); + int pc = E.param_types.size(); if (pc > p_argcount) { r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS; r_error.argument = pc; @@ -58,7 +58,7 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method, r_error.argument = pc; continue; } - uint32_t *ptypes = E->get().param_types.ptrw(); + uint32_t *ptypes = E.param_types.ptrw(); bool valid = true; for (int i = 0; i < pc; i++) { @@ -107,7 +107,7 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method, if (Object::cast_to<JavaObject>(ref.ptr())) { Ref<JavaObject> jo = ref; //could be faster - jclass c = env->FindClass(E->get().param_sigs[i].operator String().utf8().get_data()); + jclass c = env->FindClass(E.param_sigs[i].operator String().utf8().get_data()); if (!c || !env->IsInstanceOf(jo->instance, c)) { arg_expected = Variant::OBJECT; } else { @@ -138,7 +138,7 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method, if (!valid) continue; - method = &E->get(); + method = &E; break; } @@ -474,8 +474,8 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method, } break; } - for (List<jobject>::Element *E = to_free.front(); E; E = E->next()) { - env->DeleteLocalRef(E->get()); + for (jobject &E : to_free) { + env->DeleteLocalRef(E); } return success; diff --git a/platform/android/java_godot_lib_jni.cpp b/platform/android/java_godot_lib_jni.cpp index 583d3342a0..ce7a49e53c 100644 --- a/platform/android/java_godot_lib_jni.cpp +++ b/platform/android/java_godot_lib_jni.cpp @@ -438,8 +438,8 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_calldeferred(JNIEnv * env->DeleteLocalRef(obj); }; - static_assert(VARIANT_ARG_MAX == 5, "This code needs to be updated if VARIANT_ARG_MAX != 5"); - obj->call_deferred(str_method, args[0], args[1], args[2], args[3], args[4]); + static_assert(VARIANT_ARG_MAX == 8, "This code needs to be updated if VARIANT_ARG_MAX != 8"); + obj->call_deferred(str_method, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]); // something env->PopLocalFrame(nullptr); } diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp index 222976d948..792a390e36 100644 --- a/platform/android/os_android.cpp +++ b/platform/android/os_android.cpp @@ -71,6 +71,13 @@ public: virtual ~AndroidLogger() {} }; +void OS_Android::alert(const String &p_alert, const String &p_title) { + GodotJavaWrapper *godot_java = OS_Android::get_singleton()->get_godot_java(); + ERR_FAIL_COND(!godot_java); + + godot_java->alert(p_alert, p_title); +} + void OS_Android::initialize_core() { OS_Unix::initialize_core(); diff --git a/platform/android/os_android.h b/platform/android/os_android.h index 1e89e9211d..38f0f3edc7 100644 --- a/platform/android/os_android.h +++ b/platform/android/os_android.h @@ -86,6 +86,8 @@ public: virtual bool request_permissions() override; virtual Vector<String> get_granted_permissions() const override; + virtual void alert(const String &p_alert, const String &p_title) override; + virtual Error open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path = false) override; virtual String get_name() const override; diff --git a/platform/iphone/api/api.cpp b/platform/iphone/api/api.cpp new file mode 100644 index 0000000000..a23791fe1c --- /dev/null +++ b/platform/iphone/api/api.cpp @@ -0,0 +1,48 @@ +/*************************************************************************/ +/* api.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#include "api.h" + +#if defined(IPHONE_ENABLED) + +void register_iphone_api() { + godot_ios_plugins_initialize(); +} + +void unregister_iphone_api() { + godot_ios_plugins_deinitialize(); +} + +#else + +void register_iphone_api() {} +void unregister_iphone_api() {} + +#endif diff --git a/platform/iphone/api/api.h b/platform/iphone/api/api.h new file mode 100644 index 0000000000..c6570da7ec --- /dev/null +++ b/platform/iphone/api/api.h @@ -0,0 +1,42 @@ +/*************************************************************************/ +/* api.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#ifndef IPHONE_API_H +#define IPHONE_API_H + +#if defined(IPHONE_ENABLED) +extern void godot_ios_plugins_initialize(); +extern void godot_ios_plugins_deinitialize(); +#endif + +void register_iphone_api(); +void unregister_iphone_api(); + +#endif // IPHONE_API_H diff --git a/platform/iphone/display_server_iphone.h b/platform/iphone/display_server_iphone.h index 6f64130b23..8ba7a69a4f 100644 --- a/platform/iphone/display_server_iphone.h +++ b/platform/iphone/display_server_iphone.h @@ -119,8 +119,6 @@ public: virtual bool has_feature(Feature p_feature) const override; virtual String get_name() const override; - virtual void alert(const String &p_alert, const String &p_title = "ALERT!") override; - virtual int get_screen_count() const override; virtual Point2i screen_get_position(int p_screen = SCREEN_OF_MAIN_WINDOW) const override; virtual Size2i screen_get_size(int p_screen = SCREEN_OF_MAIN_WINDOW) const override; diff --git a/platform/iphone/display_server_iphone.mm b/platform/iphone/display_server_iphone.mm index bd95e2c703..b4f0a32027 100644 --- a/platform/iphone/display_server_iphone.mm +++ b/platform/iphone/display_server_iphone.mm @@ -320,12 +320,6 @@ String DisplayServerIPhone::get_name() const { return "iPhone"; } -void DisplayServerIPhone::alert(const String &p_alert, const String &p_title) { - const CharString utf8_alert = p_alert.utf8(); - const CharString utf8_title = p_title.utf8(); - iOS::alert(utf8_alert.get_data(), utf8_title.get_data()); -} - int DisplayServerIPhone::get_screen_count() const { return 1; } diff --git a/platform/iphone/godot_view_gesture_recognizer.h b/platform/iphone/godot_view_gesture_recognizer.h index 48b2d5ffad..61438ef22f 100644 --- a/platform/iphone/godot_view_gesture_recognizer.h +++ b/platform/iphone/godot_view_gesture_recognizer.h @@ -28,7 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -// GLViewGestureRecognizer allows iOS gestures to work currectly by +// GLViewGestureRecognizer allows iOS gestures to work correctly by // emulating UIScrollView's UIScrollViewDelayedTouchesBeganGestureRecognizer. // It catches all gestures incoming to UIView and delays them for 150ms // (the same value used by UIScrollViewDelayedTouchesBeganGestureRecognizer) diff --git a/platform/iphone/os_iphone.h b/platform/iphone/os_iphone.h index f4ff909adf..248369369d 100644 --- a/platform/iphone/os_iphone.h +++ b/platform/iphone/os_iphone.h @@ -45,9 +45,6 @@ #include "platform/iphone/vulkan_context_iphone.h" #endif -extern void godot_ios_plugins_initialize(); -extern void godot_ios_plugins_deinitialize(); - class OSIPhone : public OS_Unix { private: static HashMap<String, void *> dynamic_symbol_lookup_table; @@ -92,13 +89,12 @@ public: void start(); + virtual void alert(const String &p_alert, const String &p_title = "ALERT!") override; + virtual Error open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path = false) override; virtual Error close_dynamic_library(void *p_library_handle) override; virtual Error get_dynamic_library_symbol_handle(void *p_library_handle, const String p_name, void *&p_symbol_handle, bool p_optional = false) override; - virtual void alert(const String &p_alert, - const String &p_title = "ALERT!") override; - virtual String get_name() const override; virtual String get_model_name() const override; diff --git a/platform/iphone/os_iphone.mm b/platform/iphone/os_iphone.mm index 1f08901082..a999929cc4 100644 --- a/platform/iphone/os_iphone.mm +++ b/platform/iphone/os_iphone.mm @@ -114,6 +114,12 @@ OSIPhone::OSIPhone(String p_data_dir) { OSIPhone::~OSIPhone() {} +void OSIPhone::alert(const String &p_alert, const String &p_title) { + const CharString utf8_alert = p_alert.utf8(); + const CharString utf8_title = p_title.utf8(); + iOS::alert(utf8_alert.get_data(), utf8_title.get_data()); +} + void OSIPhone::initialize_core() { OS_Unix::initialize_core(); @@ -139,8 +145,6 @@ void OSIPhone::deinitialize_modules() { if (ios) { memdelete(ios); } - - godot_ios_plugins_deinitialize(); } void OSIPhone::set_main_loop(MainLoop *p_main_loop) { @@ -177,8 +181,6 @@ bool OSIPhone::iterate() { } void OSIPhone::start() { - godot_ios_plugins_initialize(); - Main::start(); if (joypad_iphone) { @@ -221,12 +223,6 @@ Error OSIPhone::get_dynamic_library_symbol_handle(void *p_library_handle, const return OS_Unix::get_dynamic_library_symbol_handle(p_library_handle, p_name, p_symbol_handle, p_optional); } -void OSIPhone::alert(const String &p_alert, const String &p_title) { - const CharString utf8_alert = p_alert.utf8(); - const CharString utf8_title = p_title.utf8(); - iOS::alert(utf8_alert.get_data(), utf8_title.get_data()); -} - String OSIPhone::get_name() const { return "iOS"; }; diff --git a/platform/javascript/display_server_javascript.cpp b/platform/javascript/display_server_javascript.cpp index 5e2b089c7f..8df81bb8cc 100644 --- a/platform/javascript/display_server_javascript.cpp +++ b/platform/javascript/display_server_javascript.cpp @@ -659,10 +659,6 @@ void DisplayServerJavaScript::send_window_event_callback(int p_notification) { } } -void DisplayServerJavaScript::alert(const String &p_alert, const String &p_title) { - godot_js_display_alert(p_alert.utf8().get_data()); -} - void DisplayServerJavaScript::set_icon(const Ref<Image> &p_icon) { ERR_FAIL_COND(p_icon.is_null()); Ref<Image> icon = p_icon; diff --git a/platform/javascript/display_server_javascript.h b/platform/javascript/display_server_javascript.h index f8acf30854..bf5e229c9a 100644 --- a/platform/javascript/display_server_javascript.h +++ b/platform/javascript/display_server_javascript.h @@ -109,7 +109,6 @@ public: bool check_size_force_redraw(); // from DisplayServer - virtual void alert(const String &p_alert, const String &p_title = "ALERT!") override; virtual bool has_feature(Feature p_feature) const override; virtual String get_name() const override; diff --git a/platform/javascript/js/libs/audio.worklet.js b/platform/javascript/js/libs/audio.worklet.js index 6b3f80c6a9..866f845139 100644 --- a/platform/javascript/js/libs/audio.worklet.js +++ b/platform/javascript/js/libs/audio.worklet.js @@ -115,7 +115,7 @@ class GodotProcessor extends AudioWorkletProcessor { this.input = new RingBuffer(p_data[1], avail_in); this.output = new RingBuffer(p_data[2], avail_out); } else if (p_cmd === 'stop') { - this.runing = false; + this.running = false; this.output = null; this.input = null; } diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp index 260bfad7a5..76102d941b 100644 --- a/platform/javascript/os_javascript.cpp +++ b/platform/javascript/os_javascript.cpp @@ -47,6 +47,10 @@ #include "godot_js.h" +void OS_JavaScript::alert(const String &p_alert, const String &p_title) { + godot_js_display_alert(p_alert.utf8().get_data()); +} + // Lifecycle void OS_JavaScript::initialize() { OS_Unix::initialize_core(); @@ -111,8 +115,8 @@ Error OS_JavaScript::execute(const String &p_path, const List<String> &p_argumen Error OS_JavaScript::create_process(const String &p_path, const List<String> &p_arguments, ProcessID *r_child_id) { Array args; - for (const List<String>::Element *E = p_arguments.front(); E; E = E->next()) { - args.push_back(E->get()); + for (const String &E : p_arguments) { + args.push_back(E); } String json_args = Variant(args).to_json_string(); int failed = godot_js_os_execute(json_args.utf8().get_data()); diff --git a/platform/javascript/os_javascript.h b/platform/javascript/os_javascript.h index 81bb9c5f3d..efac2dbca7 100644 --- a/platform/javascript/os_javascript.h +++ b/platform/javascript/os_javascript.h @@ -89,6 +89,9 @@ public: String get_user_data_dir() const override; bool is_userfs_persistent() const override; + + void alert(const String &p_alert, const String &p_title = "ALERT!") override; + Error open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path) override; void resume_audio(); diff --git a/platform/linuxbsd/display_server_x11.cpp b/platform/linuxbsd/display_server_x11.cpp index 8f0742041c..4a32dd9646 100644 --- a/platform/linuxbsd/display_server_x11.cpp +++ b/platform/linuxbsd/display_server_x11.cpp @@ -136,70 +136,6 @@ String DisplayServerX11::get_name() const { return "X11"; } -void DisplayServerX11::alert(const String &p_alert, const String &p_title) { - const char *message_programs[] = { "zenity", "kdialog", "Xdialog", "xmessage" }; - - String path = OS::get_singleton()->get_environment("PATH"); - Vector<String> path_elems = path.split(":", false); - String program; - - for (int i = 0; i < path_elems.size(); i++) { - for (uint64_t k = 0; k < sizeof(message_programs) / sizeof(char *); k++) { - String tested_path = path_elems[i].plus_file(message_programs[k]); - - if (FileAccess::exists(tested_path)) { - program = tested_path; - break; - } - } - - if (program.length()) { - break; - } - } - - List<String> args; - - if (program.ends_with("zenity")) { - args.push_back("--error"); - args.push_back("--width"); - args.push_back("500"); - args.push_back("--title"); - args.push_back(p_title); - args.push_back("--text"); - args.push_back(p_alert); - } - - if (program.ends_with("kdialog")) { - args.push_back("--error"); - args.push_back(p_alert); - args.push_back("--title"); - args.push_back(p_title); - } - - if (program.ends_with("Xdialog")) { - args.push_back("--title"); - args.push_back(p_title); - args.push_back("--msgbox"); - args.push_back(p_alert); - args.push_back("0"); - args.push_back("0"); - } - - if (program.ends_with("xmessage")) { - args.push_back("-center"); - args.push_back("-title"); - args.push_back(p_title); - args.push_back(p_alert); - } - - if (program.length()) { - OS::get_singleton()->execute(program, args); - } else { - print_line(p_alert); - } -} - void DisplayServerX11::_update_real_mouse_position(const WindowData &wd) { Window root_return, child_return; int root_x, root_y, win_x, win_y; @@ -871,7 +807,9 @@ DisplayServer::WindowID DisplayServerX11::create_sub_window(WindowMode p_mode, V void DisplayServerX11::show_window(WindowID p_id) { _THREAD_SAFE_METHOD_ - WindowData &wd = windows[p_id]; + const WindowData &wd = windows[p_id]; + + DEBUG_LOG_X11("show_window: %lu (%u) \n", wd.x11_window, p_id); XMapWindow(x11_display, wd.x11_window); } @@ -1095,6 +1033,8 @@ void DisplayServerX11::window_set_transient(WindowID p_window, WindowID p_parent WindowID prev_parent = wd_window.transient_parent; ERR_FAIL_COND(prev_parent == p_parent); + DEBUG_LOG_X11("window_set_transient: %lu (%u), prev_parent=%u, parent=%u\n", wd_window.x11_window, p_window, prev_parent, p_parent); + ERR_FAIL_COND_MSG(wd_window.on_top, "Windows with the 'on top' can't become transient."); if (p_parent == INVALID_WINDOW_ID) { //remove transient @@ -1109,10 +1049,10 @@ void DisplayServerX11::window_set_transient(WindowID p_window, WindowID p_parent XSetTransientForHint(x11_display, wd_window.x11_window, None); - // Set focus to parent sub window to avoid losing all focus with nested menus. + // Set focus to parent sub window to avoid losing all focus when closing a nested sub-menu. // RevertToPointerRoot is used to make sure we don't lose all focus in case // a subwindow and its parent are both destroyed. - if (wd_window.menu_type && !wd_window.no_focus) { + if (wd_window.menu_type && !wd_window.no_focus && wd_window.focused) { if (!wd_parent.no_focus) { XSetInputFocus(x11_display, wd_parent.x11_window, RevertToPointerRoot, CurrentTime); } @@ -2227,7 +2167,7 @@ void DisplayServerX11::_handle_key_event(WindowID p_window, XKeyEvent *p_event, // still works in half the cases. (won't handle deadkeys) // For more complex input methods (deadkeys and more advanced) // you have to use XmbLookupString (??). - // So.. then you have to chosse which of both results + // So then you have to choose which of both results // you want to keep. // This is a real bizarreness and cpu waster. @@ -3673,8 +3613,8 @@ Vector<String> DisplayServerX11::get_rendering_drivers_func() { DisplayServer *DisplayServerX11::create_func(const String &p_rendering_driver, WindowMode p_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error) { DisplayServer *ds = memnew(DisplayServerX11(p_rendering_driver, p_mode, p_vsync_mode, p_flags, p_resolution, r_error)); if (r_error != OK) { - ds->alert("Your video card driver does not support any of the supported Vulkan versions.\n" - "Please update your drivers or if you have a very old or integrated GPU upgrade it.", + OS::get_singleton()->alert("Your video card driver does not support any of the supported Vulkan versions.\n" + "Please update your drivers or if you have a very old or integrated GPU upgrade it.", "Unable to initialize Video driver"); } return ds; @@ -3972,8 +3912,8 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode } if (!_refresh_device_info()) { - alert("Your system does not support XInput 2.\n" - "Please upgrade your distribution.", + OS::get_singleton()->alert("Your system does not support XInput 2.\n" + "Please upgrade your distribution.", "Unable to initialize XInput"); r_error = ERR_UNAVAILABLE; return; diff --git a/platform/linuxbsd/display_server_x11.h b/platform/linuxbsd/display_server_x11.h index 29c15ca2ba..052c6d6b7b 100644 --- a/platform/linuxbsd/display_server_x11.h +++ b/platform/linuxbsd/display_server_x11.h @@ -280,8 +280,6 @@ public: virtual bool has_feature(Feature p_feature) const override; virtual String get_name() const override; - virtual void alert(const String &p_alert, const String &p_title = "ALERT!") override; - virtual void mouse_set_mode(MouseMode p_mode) override; virtual MouseMode mouse_get_mode() const override; diff --git a/platform/linuxbsd/os_linuxbsd.cpp b/platform/linuxbsd/os_linuxbsd.cpp index 8cd6ec43c6..08630be8b0 100644 --- a/platform/linuxbsd/os_linuxbsd.cpp +++ b/platform/linuxbsd/os_linuxbsd.cpp @@ -51,6 +51,70 @@ #include <sys/types.h> #include <unistd.h> +void OS_LinuxBSD::alert(const String &p_alert, const String &p_title) { + const char *message_programs[] = { "zenity", "kdialog", "Xdialog", "xmessage" }; + + String path = get_environment("PATH"); + Vector<String> path_elems = path.split(":", false); + String program; + + for (int i = 0; i < path_elems.size(); i++) { + for (uint64_t k = 0; k < sizeof(message_programs) / sizeof(char *); k++) { + String tested_path = path_elems[i].plus_file(message_programs[k]); + + if (FileAccess::exists(tested_path)) { + program = tested_path; + break; + } + } + + if (program.length()) { + break; + } + } + + List<String> args; + + if (program.ends_with("zenity")) { + args.push_back("--error"); + args.push_back("--width"); + args.push_back("500"); + args.push_back("--title"); + args.push_back(p_title); + args.push_back("--text"); + args.push_back(p_alert); + } + + if (program.ends_with("kdialog")) { + args.push_back("--error"); + args.push_back(p_alert); + args.push_back("--title"); + args.push_back(p_title); + } + + if (program.ends_with("Xdialog")) { + args.push_back("--title"); + args.push_back(p_title); + args.push_back("--msgbox"); + args.push_back(p_alert); + args.push_back("0"); + args.push_back("0"); + } + + if (program.ends_with("xmessage")) { + args.push_back("-center"); + args.push_back("-title"); + args.push_back(p_title); + args.push_back(p_alert); + } + + if (program.length()) { + execute(program, args); + } else { + print_line(p_alert); + } +} + void OS_LinuxBSD::initialize() { crash_handler.initialize(); @@ -387,7 +451,7 @@ Error OS_LinuxBSD::move_to_trash(const String &p_path) { DirAccess *dir_access = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); Error err = dir_access->make_dir_recursive(trash_path); - // Issue an error if trash can is not created proprely. + // Issue an error if trash can is not created properly. ERR_FAIL_COND_V_MSG(err != OK, err, "Could not create the trash path \"" + trash_path + "\""); err = dir_access->make_dir_recursive(trash_path + "/files"); ERR_FAIL_COND_V_MSG(err != OK, err, "Could not create the trash path \"" + trash_path + "\"/files"); diff --git a/platform/linuxbsd/os_linuxbsd.h b/platform/linuxbsd/os_linuxbsd.h index b6cf93c551..1e06587322 100644 --- a/platform/linuxbsd/os_linuxbsd.h +++ b/platform/linuxbsd/os_linuxbsd.h @@ -90,6 +90,8 @@ public: virtual String get_unique_id() const override; + virtual void alert(const String &p_alert, const String &p_title = "ALERT!") override; + virtual bool _check_internal_feature_support(const String &p_feature) override; void run(); diff --git a/platform/osx/detect.py b/platform/osx/detect.py index 317e79d0ea..2393f2ea10 100644 --- a/platform/osx/detect.py +++ b/platform/osx/detect.py @@ -24,6 +24,7 @@ def get_opts(): return [ ("osxcross_sdk", "OSXCross SDK version", "darwin16"), ("MACOS_SDK_PATH", "Path to the macOS SDK", ""), + ("VULKAN_SDK_PATH", "Path to the Vulkan SDK", ""), BoolVariable( "use_static_mvk", "Link MoltenVK statically as Level-0 driver (better portability) or use Vulkan ICD loader (enables" @@ -190,7 +191,7 @@ def configure(env): env.Append(CPPDEFINES=["VULKAN_ENABLED"]) env.Append(LINKFLAGS=["-framework", "Metal", "-framework", "QuartzCore", "-framework", "IOSurface"]) if env["use_static_mvk"]: - env.Append(LINKFLAGS=["-framework", "MoltenVK"]) + env.Append(LINKFLAGS=["-L$VULKAN_SDK_PATH/MoltenVK/MoltenVK.xcframework/macos-arm64_x86_64/", "-lMoltenVK"]) env["builtin_vulkan"] = False elif not env["builtin_vulkan"]: env.Append(LIBS=["vulkan"]) diff --git a/platform/osx/display_server_osx.h b/platform/osx/display_server_osx.h index c7b9e411b8..6b1b777224 100644 --- a/platform/osx/display_server_osx.h +++ b/platform/osx/display_server_osx.h @@ -60,6 +60,10 @@ class DisplayServerOSX : public DisplayServer { _THREAD_SAFE_CLASS_ public: + void _send_event(NSEvent *p_event); + NSMenu *_get_dock_menu() const; + void _menu_callback(id p_sender); + #if defined(OPENGL_ENABLED) ContextGL_OSX *context_gles2; #endif @@ -163,7 +167,6 @@ public: String rendering_driver; - id delegate; id autoreleasePool; CGEventSourceRef eventSource; @@ -207,7 +210,6 @@ public: virtual void global_menu_remove_item(const String &p_menu_root, int p_idx) override; virtual void global_menu_clear(const String &p_menu_root) override; - virtual void alert(const String &p_alert, const String &p_title = "ALERT!") override; virtual Error dialog_show(String p_title, String p_description, Vector<String> p_buttons, const Callable &p_callback) override; virtual Error dialog_input_text(String p_title, String p_description, String p_partial, const Callable &p_callback) override; diff --git a/platform/osx/display_server_osx.mm b/platform/osx/display_server_osx.mm index dec6da42fe..73aa013701 100644 --- a/platform/osx/display_server_osx.mm +++ b/platform/osx/display_server_osx.mm @@ -105,46 +105,6 @@ static NSCursor *_cursorFromSelector(SEL selector, SEL fallback = nil) { } /*************************************************************************/ -/* GodotApplication */ -/*************************************************************************/ - -@interface GodotApplication : NSApplication -@end - -@implementation GodotApplication - -- (void)sendEvent:(NSEvent *)event { - // special case handling of command-period, which is traditionally a special - // shortcut in macOS and doesn't arrive at our regular keyDown handler. - if ([event type] == NSEventTypeKeyDown) { - if (([event modifierFlags] & NSEventModifierFlagCommand) && [event keyCode] == 0x2f) { - Ref<InputEventKey> k; - k.instantiate(); - - _get_key_modifier_state([event modifierFlags], k); - k->set_window_id(DisplayServerOSX::INVALID_WINDOW_ID); - k->set_pressed(true); - k->set_keycode(KEY_PERIOD); - k->set_physical_keycode(KEY_PERIOD); - k->set_echo([event isARepeat]); - - Input::get_singleton()->accumulate_input_event(k); - } - } - - // From http://cocoadev.com/index.pl?GameKeyboardHandlingAlmost - // This works around an AppKit bug, where key up events while holding - // down the command key don't get sent to the key window. - if ([event type] == NSEventTypeKeyUp && ([event modifierFlags] & NSEventModifierFlagCommand)) { - [[self keyWindow] sendEvent:event]; - } else { - [super sendEvent:event]; - } -} - -@end - -/*************************************************************************/ /* GlobalMenuItem */ /*************************************************************************/ @@ -161,121 +121,6 @@ static NSCursor *_cursorFromSelector(SEL selector, SEL fallback = nil) { @end /*************************************************************************/ -/* GodotApplicationDelegate */ -/*************************************************************************/ - -@interface GodotApplicationDelegate : NSObject -- (void)forceUnbundledWindowActivationHackStep1; -- (void)forceUnbundledWindowActivationHackStep2; -- (void)forceUnbundledWindowActivationHackStep3; -@end - -@implementation GodotApplicationDelegate - -- (void)forceUnbundledWindowActivationHackStep1 { - // Step1: Switch focus to macOS Dock. - // Required to perform step 2, TransformProcessType will fail if app is already the in focus. - for (NSRunningApplication *app in [NSRunningApplication runningApplicationsWithBundleIdentifier:@"com.apple.dock"]) { - [app activateWithOptions:NSApplicationActivateIgnoringOtherApps]; - break; - } - [self performSelector:@selector(forceUnbundledWindowActivationHackStep2) withObject:nil afterDelay:0.02]; -} - -- (void)forceUnbundledWindowActivationHackStep2 { - // Step 2: Register app as foreground process. - ProcessSerialNumber psn = { 0, kCurrentProcess }; - (void)TransformProcessType(&psn, kProcessTransformToForegroundApplication); - [self performSelector:@selector(forceUnbundledWindowActivationHackStep3) withObject:nil afterDelay:0.02]; -} - -- (void)forceUnbundledWindowActivationHackStep3 { - // Step 3: Switch focus back to app window. - [[NSRunningApplication currentApplication] activateWithOptions:NSApplicationActivateIgnoringOtherApps]; -} - -- (void)applicationDidFinishLaunching:(NSNotification *)notice { - NSString *nsappname = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"]; - if (nsappname == nil) { - // If executable is not a bundled, macOS WindowServer won't register and activate app window correctly (menu and title bar are grayed out and input ignored). - [self performSelector:@selector(forceUnbundledWindowActivationHackStep1) withObject:nil afterDelay:0.02]; - } -} - -- (void)applicationDidResignActive:(NSNotification *)notification { - if (OS_OSX::get_singleton()->get_main_loop()) { - OS_OSX::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_APPLICATION_FOCUS_OUT); - } -} - -- (void)applicationDidBecomeActive:(NSNotification *)notification { - if (OS_OSX::get_singleton()->get_main_loop()) { - OS_OSX::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_APPLICATION_FOCUS_IN); - } -} - -- (void)globalMenuCallback:(id)sender { - if (![sender representedObject]) { - return; - } - - GlobalMenuItem *value = [sender representedObject]; - - if (value) { - if (value->checkable) { - if ([sender state] == NSControlStateValueOff) { - [sender setState:NSControlStateValueOn]; - } else { - [sender setState:NSControlStateValueOff]; - } - } - - if (value->callback != Callable()) { - Variant tag = value->meta; - Variant *tagp = &tag; - Variant ret; - Callable::CallError ce; - value->callback.call((const Variant **)&tagp, 1, ret, ce); - } - } -} - -- (NSMenu *)applicationDockMenu:(NSApplication *)sender { - return DS_OSX->dock_menu; -} - -- (BOOL)application:(NSApplication *)sender openFile:(NSString *)filename { - // Note: may be called called before main loop init! - char *utfs = strdup([filename UTF8String]); - ((OS_OSX *)(OS_OSX::get_singleton()))->open_with_filename.parse_utf8(utfs); - free(utfs); - -#ifdef TOOLS_ENABLED - // Open new instance - if (OS_OSX::get_singleton()->get_main_loop()) { - List<String> args; - args.push_back(((OS_OSX *)(OS_OSX::get_singleton()))->open_with_filename); - String exec = OS::get_singleton()->get_executable_path(); - OS::get_singleton()->create_process(exec, args); - } -#endif - return YES; -} - -- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender { - DS_OSX->_send_window_event(DS_OSX->windows[DisplayServerOSX::MAIN_WINDOW_ID], DisplayServerOSX::WINDOW_EVENT_CLOSE_REQUEST); - return NSTerminateCancel; -} - -- (void)showAbout:(id)sender { - if (OS_OSX::get_singleton()->get_main_loop()) { - OS_OSX::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_ABOUT); - } -} - -@end - -/*************************************************************************/ /* GodotWindowDelegate */ /*************************************************************************/ @@ -1983,26 +1828,6 @@ void DisplayServerOSX::global_menu_clear(const String &p_menu_root) { } } -void DisplayServerOSX::alert(const String &p_alert, const String &p_title) { - _THREAD_SAFE_METHOD_ - - NSAlert *window = [[NSAlert alloc] init]; - NSString *ns_title = [NSString stringWithUTF8String:p_title.utf8().get_data()]; - NSString *ns_alert = [NSString stringWithUTF8String:p_alert.utf8().get_data()]; - - [window addButtonWithTitle:@"OK"]; - [window setMessageText:ns_title]; - [window setInformativeText:ns_alert]; - [window setAlertStyle:NSAlertStyleWarning]; - - id key_window = [[NSApplication sharedApplication] keyWindow]; - [window runModal]; - [window release]; - if (key_window) { - [key_window makeKeyAndOrderFront:nil]; - } -} - Error DisplayServerOSX::dialog_show(String p_title, String p_description, Vector<String> p_buttons, const Callable &p_callback) { _THREAD_SAFE_METHOD_ @@ -3375,6 +3200,56 @@ void DisplayServerOSX::_release_pressed_events() { } } +NSMenu *DisplayServerOSX::_get_dock_menu() const { + return dock_menu; +} + +void DisplayServerOSX::_menu_callback(id p_sender) { + if (![p_sender representedObject]) { + return; + } + + GlobalMenuItem *value = [p_sender representedObject]; + + if (value) { + if (value->checkable) { + if ([p_sender state] == NSControlStateValueOff) { + [p_sender setState:NSControlStateValueOn]; + } else { + [p_sender setState:NSControlStateValueOff]; + } + } + + if (value->callback != Callable()) { + Variant tag = value->meta; + Variant *tagp = &tag; + Variant ret; + Callable::CallError ce; + value->callback.call((const Variant **)&tagp, 1, ret, ce); + } + } +} + +void DisplayServerOSX::_send_event(NSEvent *p_event) { + // special case handling of command-period, which is traditionally a special + // shortcut in macOS and doesn't arrive at our regular keyDown handler. + if ([p_event type] == NSEventTypeKeyDown) { + if (([p_event modifierFlags] & NSEventModifierFlagCommand) && [p_event keyCode] == 0x2f) { + Ref<InputEventKey> k; + k.instantiate(); + + _get_key_modifier_state([p_event modifierFlags], k); + k->set_window_id(DisplayServerOSX::INVALID_WINDOW_ID); + k->set_pressed(true); + k->set_keycode(KEY_PERIOD); + k->set_physical_keycode(KEY_PERIOD); + k->set_echo([p_event isARepeat]); + + Input::get_singleton()->accumulate_input_event(k); + } + } +} + void DisplayServerOSX::_process_key_events() { Ref<InputEventKey> k; for (int i = 0; i < key_event_pos; i++) { @@ -3615,7 +3490,7 @@ ObjectID DisplayServerOSX::window_get_attached_instance_id(WindowID p_window) co DisplayServer *DisplayServerOSX::create_func(const String &p_rendering_driver, WindowMode p_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error) { DisplayServer *ds = memnew(DisplayServerOSX(p_rendering_driver, p_mode, p_vsync_mode, p_flags, p_resolution, r_error)); if (r_error != OK) { - ds->alert("Your video card driver does not support any of the supported Metal versions.", "Unable to initialize Video driver"); + OS::get_singleton()->alert("Your video card driver does not support any of the supported Metal versions.", "Unable to initialize Video driver"); } return ds; } @@ -3785,12 +3660,6 @@ DisplayServerOSX::DisplayServerOSX(const String &p_rendering_driver, WindowMode CGEventSourceSetLocalEventsSuppressionInterval(eventSource, 0.0); - // Implicitly create shared NSApplication instance - [GodotApplication sharedApplication]; - - // In case we are unbundled, make us a proper UI application - [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; - keyboard_layout_dirty = true; displays_arrangement_dirty = true; displays_scale_dirty = true; @@ -3804,9 +3673,6 @@ DisplayServerOSX::DisplayServerOSX(const String &p_rendering_driver, WindowMode // Register to be notified on displays arrangement changes CGDisplayRegisterReconfigurationCallback(displays_arrangement_changed, nullptr); - // Menu bar setup must go between sharedApplication above and - // finishLaunching below, in order to properly emulate the behavior - // of NSApplicationMain NSMenuItem *menu_item; NSString *title; @@ -3846,32 +3712,10 @@ DisplayServerOSX::DisplayServerOSX(const String &p_rendering_driver, WindowMode title = [NSString stringWithFormat:NSLocalizedString(@"Quit %@", nil), nsappname]; [apple_menu addItemWithTitle:title action:@selector(terminate:) keyEquivalent:@"q"]; - // Setup menu bar - NSMenu *main_menu = [[[NSMenu alloc] initWithTitle:@""] autorelease]; + // Add items to the menu bar + NSMenu *main_menu = [NSApp mainMenu]; menu_item = [main_menu addItemWithTitle:@"" action:nil keyEquivalent:@""]; [main_menu setSubmenu:apple_menu forItem:menu_item]; - [NSApp setMainMenu:main_menu]; - - [NSApp finishLaunching]; - - delegate = [[GodotApplicationDelegate alloc] init]; - ERR_FAIL_COND(!delegate); - [NSApp setDelegate:delegate]; - - //process application:openFile: event - while (true) { - NSEvent *event = [NSApp - nextEventMatchingMask:NSEventMaskAny - untilDate:[NSDate distantPast] - inMode:NSDefaultRunLoopMode - dequeue:YES]; - - if (event == nil) { - break; - } - - [NSApp sendEvent:event]; - } //!!!!!!!!!!!!!!!!!!!!!!!!!! //TODO - do Vulkan and GLES2 support checks, driver selection and fallback @@ -3924,8 +3768,6 @@ DisplayServerOSX::DisplayServerOSX(const String &p_rendering_driver, WindowMode RendererCompositorRD::make_current(); } #endif - - [NSApp activateIgnoringOtherApps:YES]; } DisplayServerOSX::~DisplayServerOSX() { diff --git a/platform/osx/export/export.cpp b/platform/osx/export/export.cpp index ea34b8a24e..131c4b821e 100644 --- a/platform/osx/export/export.cpp +++ b/platform/osx/export/export.cpp @@ -178,6 +178,7 @@ void EditorExportPlatformOSX::get_export_options(List<ExportOption> *r_options) r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/calendars"), false)); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/photos_library"), false)); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/apple_events"), false)); + r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/debugging"), false)); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/app_sandbox/enabled"), false)); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/app_sandbox/network_server"), false)); @@ -845,6 +846,10 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p ent_f->store_line("<key>com.apple.security.automation.apple-events</key>"); ent_f->store_line("<true/>"); } + if ((bool)p_preset->get("codesign/entitlements/debugging")) { + ent_f->store_line("<key>com.apple.security.get-task-allow</key>"); + ent_f->store_line("<true/>"); + } if ((bool)p_preset->get("codesign/entitlements/app_sandbox/enabled")) { ent_f->store_line("<key>com.apple.security.app-sandbox</key>"); diff --git a/platform/osx/joypad_osx.cpp b/platform/osx/joypad_osx.cpp index 126ebc1908..d778271350 100644 --- a/platform/osx/joypad_osx.cpp +++ b/platform/osx/joypad_osx.cpp @@ -286,8 +286,9 @@ bool JoypadOSX::configure_joypad(IOHIDDeviceRef p_device_ref, joypad *p_joy) { } if ((!refCF) || (!CFStringGetCString((CFStringRef)refCF, c_name, sizeof(c_name), kCFStringEncodingUTF8))) { name = "Unidentified Joypad"; + } else { + name = c_name; } - name = c_name; int id = input->get_unused_joy_id(); ERR_FAIL_COND_V(id == -1, false); diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h index d57940775d..37d30add78 100644 --- a/platform/osx/os_osx.h +++ b/platform/osx/os_osx.h @@ -72,6 +72,8 @@ protected: public: virtual String get_name() const override; + virtual void alert(const String &p_alert, const String &p_title = "ALERT!") override; + virtual Error open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path = false) override; virtual MainLoop *get_main_loop() const override; diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index b65d84d900..c458a0264a 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -41,6 +41,137 @@ #include <mach-o/dyld.h> #include <os/log.h> +#define DS_OSX ((DisplayServerOSX *)(DisplayServerOSX::get_singleton())) + +/*************************************************************************/ +/* GodotApplication */ +/*************************************************************************/ + +@interface GodotApplication : NSApplication +@end + +@implementation GodotApplication + +- (void)sendEvent:(NSEvent *)event { + if (DS_OSX) { + DS_OSX->_send_event(event); + } + + // From http://cocoadev.com/index.pl?GameKeyboardHandlingAlmost + // This works around an AppKit bug, where key up events while holding + // down the command key don't get sent to the key window. + if ([event type] == NSEventTypeKeyUp && ([event modifierFlags] & NSEventModifierFlagCommand)) { + [[self keyWindow] sendEvent:event]; + } else { + [super sendEvent:event]; + } +} + +@end + +/*************************************************************************/ +/* GodotApplicationDelegate */ +/*************************************************************************/ + +@interface GodotApplicationDelegate : NSObject +- (void)forceUnbundledWindowActivationHackStep1; +- (void)forceUnbundledWindowActivationHackStep2; +- (void)forceUnbundledWindowActivationHackStep3; +@end + +@implementation GodotApplicationDelegate + +- (void)forceUnbundledWindowActivationHackStep1 { + // Step1: Switch focus to macOS Dock. + // Required to perform step 2, TransformProcessType will fail if app is already the in focus. + for (NSRunningApplication *app in [NSRunningApplication runningApplicationsWithBundleIdentifier:@"com.apple.dock"]) { + [app activateWithOptions:NSApplicationActivateIgnoringOtherApps]; + break; + } + [self performSelector:@selector(forceUnbundledWindowActivationHackStep2) + withObject:nil + afterDelay:0.02]; +} + +- (void)forceUnbundledWindowActivationHackStep2 { + // Step 2: Register app as foreground process. + ProcessSerialNumber psn = { 0, kCurrentProcess }; + (void)TransformProcessType(&psn, kProcessTransformToForegroundApplication); + [self performSelector:@selector(forceUnbundledWindowActivationHackStep3) withObject:nil afterDelay:0.02]; +} + +- (void)forceUnbundledWindowActivationHackStep3 { + // Step 3: Switch focus back to app window. + [[NSRunningApplication currentApplication] activateWithOptions:NSApplicationActivateIgnoringOtherApps]; +} + +- (void)applicationDidFinishLaunching:(NSNotification *)notice { + NSString *nsappname = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"]; + if (nsappname == nil) { + // If executable is not a bundled, macOS WindowServer won't register and activate app window correctly (menu and title bar are grayed out and input ignored). + [self performSelector:@selector(forceUnbundledWindowActivationHackStep1) withObject:nil afterDelay:0.02]; + } +} + +- (void)applicationDidResignActive:(NSNotification *)notification { + if (OS::get_singleton()->get_main_loop()) { + OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_APPLICATION_FOCUS_OUT); + } +} + +- (void)applicationDidBecomeActive:(NSNotification *)notification { + if (OS::get_singleton()->get_main_loop()) { + OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_APPLICATION_FOCUS_IN); + } +} + +- (void)globalMenuCallback:(id)sender { + if (DS_OSX) { + return DS_OSX->_menu_callback(sender); + } +} + +- (NSMenu *)applicationDockMenu:(NSApplication *)sender { + if (DS_OSX) { + return DS_OSX->_get_dock_menu(); + } else { + return nullptr; + } +} + +- (BOOL)application:(NSApplication *)sender openFile:(NSString *)filename { + // Note: may be called called before main loop init! + char *utfs = strdup([filename UTF8String]); + ((OS_OSX *)OS_OSX::get_singleton())->open_with_filename.parse_utf8(utfs); + free(utfs); + +#ifdef TOOLS_ENABLED + // Open new instance + if (OS_OSX::get_singleton()->get_main_loop()) { + List<String> args; + args.push_back(((OS_OSX *)OS_OSX::get_singleton())->open_with_filename); + String exec = OS_OSX::get_singleton()->get_executable_path(); + OS_OSX::get_singleton()->create_process(exec, args); + } +#endif + return YES; +} + +- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender { + if (DS_OSX) { + DS_OSX->_send_window_event(DS_OSX->windows[DisplayServerOSX::MAIN_WINDOW_ID], DisplayServerOSX::WINDOW_EVENT_CLOSE_REQUEST); + } + return NSTerminateCancel; +} + +- (void)showAbout:(id)sender { + if (OS_OSX::get_singleton()->get_main_loop()) { + OS_OSX::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_ABOUT); + } +} + +@end + /*************************************************************************/ /* OSXTerminalLogger */ /*************************************************************************/ @@ -119,6 +250,24 @@ String OS_OSX::get_unique_id() const { return serial_number; } +void OS_OSX::alert(const String &p_alert, const String &p_title) { + NSAlert *window = [[NSAlert alloc] init]; + NSString *ns_title = [NSString stringWithUTF8String:p_title.utf8().get_data()]; + NSString *ns_alert = [NSString stringWithUTF8String:p_alert.utf8().get_data()]; + + [window addButtonWithTitle:@"OK"]; + [window setMessageText:ns_title]; + [window setInformativeText:ns_alert]; + [window setAlertStyle:NSAlertStyleWarning]; + + id key_window = [[NSApplication sharedApplication] keyWindow]; + [window runModal]; + [window release]; + if (key_window) { + [key_window makeKeyAndOrderFront:nil]; + } +} + void OS_OSX::initialize_core() { OS_Unix::initialize_core(); @@ -220,7 +369,7 @@ String OS_OSX::get_cache_path() const { if (get_environment("XDG_CACHE_HOME").is_absolute_path()) { return get_environment("XDG_CACHE_HOME"); } else { - WARN_PRINT_ONCE("`XDG_CACHE_HOME` is a relative path. Ignoring its value and falling back to `$HOME/Libary/Caches` or `get_config_path()` per the XDG Base Directory specification."); + WARN_PRINT_ONCE("`XDG_CACHE_HOME` is a relative path. Ignoring its value and falling back to `$HOME/Library/Caches` or `get_config_path()` per the XDG Base Directory specification."); } } if (has_environment("HOME")) { @@ -372,6 +521,41 @@ OS_OSX::OS_OSX() { #endif DisplayServerOSX::register_osx_driver(); + + // Implicitly create shared NSApplication instance + [GodotApplication sharedApplication]; + + // In case we are unbundled, make us a proper UI application + [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; + + // Menu bar setup must go between sharedApplication above and + // finishLaunching below, in order to properly emulate the behavior + // of NSApplicationMain + + NSMenu *main_menu = [[[NSMenu alloc] initWithTitle:@""] autorelease]; + [NSApp setMainMenu:main_menu]; + [NSApp finishLaunching]; + + id delegate = [[GodotApplicationDelegate alloc] init]; + ERR_FAIL_COND(!delegate); + [NSApp setDelegate:delegate]; + + //process application:openFile: event + while (true) { + NSEvent *event = [NSApp + nextEventMatchingMask:NSEventMaskAny + untilDate:[NSDate distantPast] + inMode:NSDefaultRunLoopMode + dequeue:YES]; + + if (event == nil) { + break; + } + + [NSApp sendEvent:event]; + } + + [NSApp activateIgnoringOtherApps:YES]; } bool OS_OSX::_check_internal_feature_support(const String &p_feature) { diff --git a/platform/windows/detect.py b/platform/windows/detect.py index 7772ba2dbe..287ece1d29 100644 --- a/platform/windows/detect.py +++ b/platform/windows/detect.py @@ -152,7 +152,7 @@ def setup_msvc_auto(env): env["TARGET_ARCH"] = None if env["bits"] != "default": env["TARGET_ARCH"] = {"32": "x86", "64": "x86_64"}[env["bits"]] - if env.has_key("msvc_version"): + if "msvc_version" in env: env["MSVC_VERSION"] = env["msvc_version"] env.Tool("msvc") env.Tool("mssdk") # we want the MS SDK @@ -171,7 +171,6 @@ def setup_mingw(env): """Set up env for use with mingw""" # Nothing to do here print("Using MinGW") - pass def configure_msvc(env, manual_msvc_config): diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp index 4f64809abc..4be95487b8 100644 --- a/platform/windows/display_server_windows.cpp +++ b/platform/windows/display_server_windows.cpp @@ -79,10 +79,6 @@ String DisplayServerWindows::get_name() const { return "Windows"; } -void DisplayServerWindows::alert(const String &p_alert, const String &p_title) { - MessageBoxW(nullptr, (LPCWSTR)(p_alert.utf16().get_data()), (LPCWSTR)(p_title.utf16().get_data()), MB_OK | MB_ICONEXCLAMATION | MB_TASKMODAL); -} - void DisplayServerWindows::_set_mouse_mode_impl(MouseMode p_mode) { if (p_mode == MOUSE_MODE_CAPTURED || p_mode == MOUSE_MODE_CONFINED || p_mode == MOUSE_MODE_CONFINED_HIDDEN) { // Mouse is grabbed (captured or confined). @@ -2449,7 +2445,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA } else { mb->set_button_index(MOUSE_BUTTON_WHEEL_DOWN); } - + mb->set_factor(fabs((double)motion / (double)WHEEL_DELTA)); } break; case WM_MOUSEHWHEEL: { mb->set_pressed(true); @@ -2460,11 +2456,10 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA if (motion < 0) { mb->set_button_index(MOUSE_BUTTON_WHEEL_LEFT); - mb->set_factor(fabs((double)motion / (double)WHEEL_DELTA)); } else { mb->set_button_index(MOUSE_BUTTON_WHEEL_RIGHT); - mb->set_factor(fabs((double)motion / (double)WHEEL_DELTA)); } + mb->set_factor(fabs((double)motion / (double)WHEEL_DELTA)); } break; case WM_XBUTTONDOWN: { mb->set_pressed(true); @@ -3358,8 +3353,8 @@ Vector<String> DisplayServerWindows::get_rendering_drivers_func() { DisplayServer *DisplayServerWindows::create_func(const String &p_rendering_driver, WindowMode p_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error) { DisplayServer *ds = memnew(DisplayServerWindows(p_rendering_driver, p_mode, p_vsync_mode, p_flags, p_resolution, r_error)); if (r_error != OK) { - ds->alert("Your video card driver does not support any of the supported Vulkan versions.\n" - "Please update your drivers or if you have a very old or integrated GPU upgrade it.", + OS::get_singleton()->alert("Your video card driver does not support any of the supported Vulkan versions.\n" + "Please update your drivers or if you have a very old or integrated GPU upgrade it.", "Unable to initialize Video driver"); } return ds; diff --git a/platform/windows/display_server_windows.h b/platform/windows/display_server_windows.h index aa1d42d6ed..06014fbabe 100644 --- a/platform/windows/display_server_windows.h +++ b/platform/windows/display_server_windows.h @@ -442,8 +442,6 @@ public: virtual bool has_feature(Feature p_feature) const override; virtual String get_name() const override; - virtual void alert(const String &p_alert, const String &p_title = "ALERT!") override; - virtual void mouse_set_mode(MouseMode p_mode) override; virtual MouseMode mouse_get_mode() const override; diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 56d673afc3..2c8afaf7de 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -165,6 +165,10 @@ BOOL WINAPI HandlerRoutine(_In_ DWORD dwCtrlType) { } } +void OS_Windows::alert(const String &p_alert, const String &p_title) { + MessageBoxW(nullptr, (LPCWSTR)(p_alert.utf16().get_data()), (LPCWSTR)(p_title.utf16().get_data()), MB_OK | MB_ICONEXCLAMATION | MB_TASKMODAL); +} + void OS_Windows::initialize_debugging() { SetConsoleCtrlHandler(HandlerRoutine, TRUE); } @@ -407,8 +411,8 @@ String OS_Windows::_quote_command_line_argument(const String &p_text) const { Error OS_Windows::execute(const String &p_path, const List<String> &p_arguments, String *r_pipe, int *r_exitcode, bool read_stderr, Mutex *p_pipe_mutex) { String path = p_path.replace("/", "\\"); String command = _quote_command_line_argument(path); - for (const List<String>::Element *E = p_arguments.front(); E; E = E->next()) { - command += " " + _quote_command_line_argument(E->get()); + for (const String &E : p_arguments) { + command += " " + _quote_command_line_argument(E); } if (r_pipe) { @@ -463,8 +467,8 @@ Error OS_Windows::execute(const String &p_path, const List<String> &p_arguments, Error OS_Windows::create_process(const String &p_path, const List<String> &p_arguments, ProcessID *r_child_id) { String path = p_path.replace("/", "\\"); String command = _quote_command_line_argument(path); - for (const List<String>::Element *E = p_arguments.front(); E; E = E->next()) { - command += " " + _quote_command_line_argument(E->get()); + for (const String &E : p_arguments) { + command += " " + _quote_command_line_argument(E); } ProcessInfo pi; diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h index 8f9ef254f1..ea0c263b78 100644 --- a/platform/windows/os_windows.h +++ b/platform/windows/os_windows.h @@ -108,6 +108,8 @@ protected: Map<ProcessID, ProcessInfo> *process_map; public: + virtual void alert(const String &p_alert, const String &p_title = "ALERT!") override; + virtual Error open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path = false) override; virtual Error close_dynamic_library(void *p_library_handle) override; virtual Error get_dynamic_library_symbol_handle(void *p_library_handle, const String p_name, void *&p_symbol_handle, bool p_optional = false) override; |