From 04aaa860391a8d874cbe17abf983f362be06f019 Mon Sep 17 00:00:00 2001 From: Hakim Date: Thu, 16 May 2024 22:16:30 +0200 Subject: [PATCH] Disable remote debug button when there are no runnable presets --- editor/editor_run_native.cpp | 18 +++++++++++++----- platform/web/export/export_plugin.cpp | 7 +++++-- platform/web/export/export_plugin.h | 1 + 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/editor/editor_run_native.cpp b/editor/editor_run_native.cpp index 4eb3f07c470..5c50231623d 100644 --- a/editor/editor_run_native.cpp +++ b/editor/editor_run_native.cpp @@ -35,7 +35,6 @@ #include "editor/export/editor_export.h" #include "editor/export/editor_export_platform.h" #include "editor/themes/editor_scale.h" -#include "scene/resources/image_texture.h" void EditorRunNative::_notification(int p_what) { switch (p_what) { @@ -49,17 +48,26 @@ void EditorRunNative::_notification(int p_what) { if (changed) { PopupMenu *popup = remote_debug->get_popup(); popup->clear(); - for (int i = 0; i < EditorExport::get_singleton()->get_export_platform_count(); i++) { - Ref eep = EditorExport::get_singleton()->get_export_platform(i); + for (int i = 0; i < EditorExport::get_singleton()->get_export_preset_count(); i++) { + Ref preset = EditorExport::get_singleton()->get_export_preset(i); + Ref eep = preset->get_platform(); if (eep.is_null()) { continue; } + int platform_idx = -1; + for (int j = 0; j < EditorExport::get_singleton()->get_export_platform_count(); j++) { + if (eep->get_name() == EditorExport::get_singleton()->get_export_platform(j)->get_name()) { + platform_idx = j; + } + } int dc = MIN(eep->get_options_count(), 9000); - if (dc > 0) { + bool needs_templates; + String error; + if (dc > 0 && preset->is_runnable() && eep->can_export(preset, error, needs_templates)) { popup->add_icon_item(eep->get_run_icon(), eep->get_name(), -1); popup->set_item_disabled(-1, true); for (int j = 0; j < dc; j++) { - popup->add_icon_item(eep->get_option_icon(j), eep->get_option_label(j), 10000 * i + j); + popup->add_icon_item(eep->get_option_icon(j), eep->get_option_label(j), 10000 * platform_idx + j); popup->set_item_tooltip(-1, eep->get_option_tooltip(j)); popup->set_item_indent(-1, 2); } diff --git a/platform/web/export/export_plugin.cpp b/platform/web/export/export_plugin.cpp index 0bf3927e147..06dfe7d6460 100644 --- a/platform/web/export/export_plugin.cpp +++ b/platform/web/export/export_plugin.cpp @@ -585,17 +585,20 @@ bool EditorExportPlatformWeb::poll_export() { } } + int prev = menu_options; + menu_options = preset.is_valid(); HTTPServerState prev_server_state = server_state; server_state = HTTP_SERVER_STATE_OFF; if (server->is_listening()) { - if (preset.is_null()) { + if (preset.is_null() || menu_options == 0) { server->stop(); } else { server_state = HTTP_SERVER_STATE_ON; + menu_options += 1; } } - return server_state != prev_server_state; + return server_state != prev_server_state || menu_options != prev; } Ref EditorExportPlatformWeb::get_option_icon(int p_index) const { diff --git a/platform/web/export/export_plugin.h b/platform/web/export/export_plugin.h index 9d3a1a78619..d3d2083a233 100644 --- a/platform/web/export/export_plugin.h +++ b/platform/web/export/export_plugin.h @@ -58,6 +58,7 @@ class EditorExportPlatformWeb : public EditorExportPlatform { HTTPServerState server_state = HTTP_SERVER_STATE_OFF; Ref server; + int menu_options = 0; String _get_template_name(bool p_extension, bool p_thread_support, bool p_debug) const { String name = "web";