diff --git a/editor/export/editor_export.cpp b/editor/export/editor_export.cpp index aeb49661691..2e34685d75f 100644 --- a/editor/export/editor_export.cpp +++ b/editor/export/editor_export.cpp @@ -111,8 +111,13 @@ void EditorExport::save_presets() { save_timer->start(); } +void EditorExport::emit_presets_runnable_changed() { + emit_signal(_export_presets_runnable_updated); +} + void EditorExport::_bind_methods() { - ADD_SIGNAL(MethodInfo("export_presets_updated")); + ADD_SIGNAL(MethodInfo(_export_presets_updated)); + ADD_SIGNAL(MethodInfo(_export_presets_runnable_updated)); } void EditorExport::add_export_platform(const Ref &p_platform) { @@ -136,6 +141,7 @@ void EditorExport::add_export_preset(const Ref &p_preset, in } else { export_presets.insert(p_at_pos, p_preset); } + emit_presets_runnable_changed(); } int EditorExport::get_export_preset_count() const { @@ -150,6 +156,7 @@ Ref EditorExport::get_export_preset(int p_idx) { void EditorExport::remove_export_preset(int p_idx) { export_presets.remove_at(p_idx); save_presets(); + emit_presets_runnable_changed(); } void EditorExport::add_export_plugin(const Ref &p_plugin) { @@ -382,6 +389,10 @@ bool EditorExport::poll_export_platforms() { return changed; } +void EditorExport::connect_presets_runnable_updated(const Callable &p_target) { + connect(_export_presets_runnable_updated, p_target); +} + EditorExport::EditorExport() { save_timer = memnew(Timer); add_child(save_timer); @@ -390,6 +401,7 @@ EditorExport::EditorExport() { save_timer->connect("timeout", callable_mp(this, &EditorExport::_save)); _export_presets_updated = "export_presets_updated"; + _export_presets_runnable_updated = "export_presets_runnable_updated"; singleton = this; set_process(true); diff --git a/editor/export/editor_export.h b/editor/export/editor_export.h index 55dee0c468c..f8cb90dc39e 100644 --- a/editor/export/editor_export.h +++ b/editor/export/editor_export.h @@ -41,7 +41,8 @@ class EditorExport : public Node { Vector> export_presets; Vector> export_plugins; - StringName _export_presets_updated; + static inline StringName _export_presets_updated; + static inline StringName _export_presets_runnable_updated; Timer *save_timer = nullptr; bool block_save = false; @@ -54,6 +55,7 @@ class EditorExport : public Node { protected: friend class EditorExportPreset; void save_presets(); + void emit_presets_runnable_changed(); void _notification(int p_what); static void _bind_methods(); @@ -77,6 +79,7 @@ public: void load_config(); void update_export_presets(); bool poll_export_platforms(); + void connect_presets_runnable_updated(const Callable &p_target); EditorExport(); ~EditorExport(); diff --git a/editor/export/editor_export_preset.cpp b/editor/export/editor_export_preset.cpp index 8c3b6693e39..6fc2228bee8 100644 --- a/editor/export/editor_export_preset.cpp +++ b/editor/export/editor_export_preset.cpp @@ -221,6 +221,7 @@ String EditorExportPreset::get_name() const { void EditorExportPreset::set_runnable(bool p_enable) { runnable = p_enable; + EditorExport::singleton->emit_presets_runnable_changed(); EditorExport::singleton->save_presets(); } diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp index 52cb366d9f5..d0db7b2e6c3 100644 --- a/platform/android/export/export_plugin.cpp +++ b/platform/android/export/export_plugin.cpp @@ -294,7 +294,7 @@ void EditorExportPlatformAndroid::_check_for_changes_poll_thread(void *ud) { // Check for devices updates String adb = get_adb_path(); - if (FileAccess::exists(adb)) { + if (ea->has_runnable_preset.is_set() && FileAccess::exists(adb)) { String devices; List args; args.push_back("devices"); @@ -426,6 +426,25 @@ void EditorExportPlatformAndroid::_check_for_changes_poll_thread(void *ud) { OS::get_singleton()->execute(adb, args); } } + +void EditorExportPlatformAndroid::_update_preset_status() { + const int preset_count = EditorExport::get_singleton()->get_export_preset_count(); + bool has_runnable = false; + + for (int i = 0; i < preset_count; i++) { + const Ref &preset = EditorExport::get_singleton()->get_export_preset(i); + if (preset->get_platform() == this && preset->is_runnable()) { + has_runnable = true; + break; + } + } + + if (has_runnable) { + has_runnable_preset.set(); + } else { + has_runnable_preset.clear(); + } +} #endif String EditorExportPlatformAndroid::get_project_name(const String &p_name) const { @@ -808,6 +827,15 @@ bool EditorExportPlatformAndroid::_uses_vulkan() { return uses_vulkan; } +void EditorExportPlatformAndroid::_notification(int p_what) { +#ifndef ANDROID_ENABLED + if (p_what == NOTIFICATION_POSTINITIALIZE) { + ERR_FAIL_NULL(EditorExport::get_singleton()); + EditorExport::get_singleton()->connect_presets_runnable_updated(callable_mp(this, &EditorExportPlatformAndroid::_update_preset_status)); + } +#endif +} + void EditorExportPlatformAndroid::_get_permissions(const Ref &p_preset, bool p_give_internet, Vector &r_permissions) { const char **aperms = android_perms; while (*aperms) { @@ -3574,6 +3602,7 @@ EditorExportPlatformAndroid::EditorExportPlatformAndroid() { android_plugins_changed.set(); #endif // DISABLE_DEPRECATED #ifndef ANDROID_ENABLED + _update_preset_status(); check_for_changes_thread.start(_check_for_changes_poll_thread, this); #endif } diff --git a/platform/android/export/export_plugin.h b/platform/android/export/export_plugin.h index abc462a6911..e25655c6cca 100644 --- a/platform/android/export/export_plugin.h +++ b/platform/android/export/export_plugin.h @@ -98,8 +98,10 @@ class EditorExportPlatformAndroid : public EditorExportPlatform { #ifndef ANDROID_ENABLED Thread check_for_changes_thread; SafeFlag quit_request; + SafeFlag has_runnable_preset; static void _check_for_changes_poll_thread(void *ud); + void _update_preset_status(); #endif String get_project_name(const String &p_name) const; @@ -187,10 +189,12 @@ class EditorExportPlatformAndroid : public EditorExportPlatform { static bool _uses_vulkan(); +protected: + void _notification(int p_what); + public: typedef Error (*EditorExportSaveFunction)(void *p_userdata, const String &p_path, const Vector &p_data, int p_file, int p_total, const Vector &p_enc_in_filters, const Vector &p_enc_ex_filters, const Vector &p_key); -public: virtual void get_preset_features(const Ref &p_preset, List *r_features) const override; virtual void get_export_options(List *r_options) const override; diff --git a/platform/ios/export/export_plugin.cpp b/platform/ios/export/export_plugin.cpp index f518d7607b1..ea2b23cfb9e 100644 --- a/platform/ios/export/export_plugin.cpp +++ b/platform/ios/export/export_plugin.cpp @@ -124,6 +124,14 @@ String EditorExportPlatformIOS::get_export_option_warning(const EditorExportPres return String(); } +void EditorExportPlatformIOS::_notification(int p_what) { +#ifdef MACOS_ENABLED + if (p_what == NOTIFICATION_POSTINITIALIZE) { + EditorExport::get_singleton()->connect_presets_runnable_updated(callable_mp(this, &EditorExportPlatformIOS::_update_preset_status)); + } +#endif +} + bool EditorExportPlatformIOS::get_export_option_visibility(const EditorExportPreset *p_preset, const String &p_option) const { return true; } @@ -2234,7 +2242,7 @@ void EditorExportPlatformIOS::_check_for_changes_poll_thread(void *ud) { // Enum real devices (via ios_deploy, pre Xcode 15). String idepl = EDITOR_GET("export/ios/ios_deploy"); - if (!idepl.is_empty()) { + if (ea->has_runnable_preset.is_set() && !idepl.is_empty()) { String devices; List args; args.push_back("-c"); @@ -2272,7 +2280,7 @@ void EditorExportPlatformIOS::_check_for_changes_poll_thread(void *ud) { } // Enum simulators. - if (_check_xcode_install() && (FileAccess::exists("/usr/bin/xcrun") || FileAccess::exists("/bin/xcrun"))) { + if (ea->has_runnable_preset.is_set() && _check_xcode_install() && (FileAccess::exists("/usr/bin/xcrun") || FileAccess::exists("/bin/xcrun"))) { { String devices; List args; @@ -2310,7 +2318,7 @@ void EditorExportPlatformIOS::_check_for_changes_poll_thread(void *ud) { } // Enum simulators. - { + if (ea->has_runnable_preset.is_set()) { String devices; List args; args.push_back("simctl"); @@ -2379,6 +2387,25 @@ void EditorExportPlatformIOS::_check_for_changes_poll_thread(void *ud) { } } } + +void EditorExportPlatformIOS::_update_preset_status() { + const int preset_count = EditorExport::get_singleton()->get_export_preset_count(); + bool has_runnable = false; + + for (int i = 0; i < preset_count; i++) { + const Ref &preset = EditorExport::get_singleton()->get_export_preset(i); + if (preset->get_platform() == this && preset->is_runnable()) { + has_runnable = true; + break; + } + } + + if (has_runnable) { + has_runnable_preset.set(); + } else { + has_runnable_preset.clear(); + } +} #endif Error EditorExportPlatformIOS::run(const Ref &p_preset, int p_device, int p_debug_flags) { @@ -2643,6 +2670,7 @@ EditorExportPlatformIOS::EditorExportPlatformIOS() { plugins_changed.set(); devices_changed.set(); #ifdef MACOS_ENABLED + _update_preset_status(); check_for_changes_thread.start(_check_for_changes_poll_thread, this); #endif } diff --git a/platform/ios/export/export_plugin.h b/platform/ios/export/export_plugin.h index edbe566dab8..197f27da763 100644 --- a/platform/ios/export/export_plugin.h +++ b/platform/ios/export/export_plugin.h @@ -81,9 +81,11 @@ class EditorExportPlatformIOS : public EditorExportPlatform { #ifdef MACOS_ENABLED Thread check_for_changes_thread; SafeFlag quit_request; + SafeFlag has_runnable_preset; static bool _check_xcode_install(); static void _check_for_changes_poll_thread(void *ud); + void _update_preset_status(); #endif typedef Error (*FileHandler)(String p_file, void *p_userdata); @@ -152,6 +154,8 @@ protected: virtual bool get_export_option_visibility(const EditorExportPreset *p_preset, const String &p_option) const override; virtual String get_export_option_warning(const EditorExportPreset *p_preset, const StringName &p_name) const override; + void _notification(int p_what); + public: virtual String get_name() const override { return "iOS"; } virtual String get_os_name() const override { return "iOS"; }