diff options
Diffstat (limited to 'editor/editor_run_native.cpp')
-rw-r--r-- | editor/editor_run_native.cpp | 94 |
1 files changed, 35 insertions, 59 deletions
diff --git a/editor/editor_run_native.cpp b/editor/editor_run_native.cpp index eab4e08cec..49723aa169 100644 --- a/editor/editor_run_native.cpp +++ b/editor/editor_run_native.cpp @@ -37,53 +37,27 @@ void EditorRunNative::_notification(int p_what) { switch (p_what) { - case NOTIFICATION_ENTER_TREE: { - for (int i = 0; i < EditorExport::get_singleton()->get_export_platform_count(); i++) { - Ref<EditorExportPlatform> eep = EditorExport::get_singleton()->get_export_platform(i); - if (eep.is_null()) { - continue; - } - Ref<ImageTexture> icon = eep->get_run_icon(); - if (!icon.is_null()) { - Ref<Image> im = icon->get_image(); - im = im->duplicate(); - im->clear_mipmaps(); - if (!im->is_empty()) { - im->resize(16 * EDSCALE, 16 * EDSCALE); - Ref<ImageTexture> small_icon = ImageTexture::create_from_image(im); - MenuButton *mb = memnew(MenuButton); - mb->get_popup()->connect("id_pressed", callable_mp(this, &EditorRunNative::run_native).bind(i)); - mb->connect("pressed", callable_mp(this, &EditorRunNative::run_native).bind(-1, i)); - mb->set_icon(small_icon); - add_child(mb); - menus[i] = mb; - } - } - } + case NOTIFICATION_THEME_CHANGED: { + remote_debug->set_icon(get_theme_icon(SNAME("PlayRemote"), SNAME("EditorIcons"))); } break; - case NOTIFICATION_PROCESS: { bool changed = EditorExport::get_singleton()->poll_export_platforms() || first; if (changed) { - for (KeyValue<int, MenuButton *> &E : menus) { - Ref<EditorExportPlatform> eep = EditorExport::get_singleton()->get_export_platform(E.key); - MenuButton *mb = E.value; - int dc = eep->get_options_count(); - - if (dc == 0) { - mb->hide(); - } else { - mb->get_popup()->clear(); - mb->show(); - if (dc == 1) { - mb->set_tooltip_text(eep->get_option_tooltip(0)); - } else { - mb->set_tooltip_text(eep->get_options_tooltip()); - for (int i = 0; i < dc; i++) { - mb->get_popup()->add_icon_item(eep->get_option_icon(i), eep->get_option_label(i)); - mb->get_popup()->set_item_tooltip(-1, eep->get_option_tooltip(i)); - } + remote_debug->get_popup()->clear(); + for (int i = 0; i < EditorExport::get_singleton()->get_export_platform_count(); i++) { + Ref<EditorExportPlatform> eep = EditorExport::get_singleton()->get_export_platform(i); + if (eep.is_null()) { + continue; + } + int dc = MIN(eep->get_options_count(), 9000); + if (dc > 0) { + remote_debug->get_popup()->add_icon_item(eep->get_run_icon(), eep->get_name(), -1); + remote_debug->get_popup()->set_item_disabled(-1, true); + for (int j = 0; j < dc; j++) { + remote_debug->get_popup()->add_icon_item(eep->get_option_icon(j), eep->get_option_label(j), 10000 * i + j); + remote_debug->get_popup()->set_item_tooltip(-1, eep->get_option_tooltip(j)); + remote_debug->get_popup()->set_item_indent(-1, 2); } } } @@ -94,25 +68,22 @@ void EditorRunNative::_notification(int p_what) { } } -Error EditorRunNative::run_native(int p_idx, int p_platform) { - if (!EditorNode::get_singleton()->ensure_main_scene(true)) { - resume_idx = p_idx; - resume_platform = p_platform; +Error EditorRunNative::run_native(int p_id) { + if (p_id < 0) { return OK; } - Ref<EditorExportPlatform> eep = EditorExport::get_singleton()->get_export_platform(p_platform); - ERR_FAIL_COND_V(eep.is_null(), ERR_UNAVAILABLE); + int platform = p_id / 10000; + int idx = p_id % 10000; - if (p_idx == -1) { - if (eep->get_options_count() == 1) { - menus[p_platform]->get_popup()->hide(); - p_idx = 0; - } else { - return ERR_INVALID_PARAMETER; - } + if (!EditorNode::get_singleton()->ensure_main_scene(true)) { + resume_id = p_id; + return OK; } + Ref<EditorExportPlatform> eep = EditorExport::get_singleton()->get_export_platform(platform); + ERR_FAIL_COND_V(eep.is_null(), ERR_UNAVAILABLE); + Ref<EditorExportPreset> preset; for (int i = 0; i < EditorExport::get_singleton()->get_export_preset_count(); i++) { @@ -151,7 +122,7 @@ Error EditorRunNative::run_native(int p_idx, int p_platform) { } eep->clear_messages(); - Error err = eep->run(preset, p_idx, flags); + Error err = eep->run(preset, idx, flags); result_dialog_log->clear(); if (eep->fill_log_messages(result_dialog_log, err)) { if (eep->get_worst_message_type() >= EditorExportPlatform::EXPORT_MESSAGE_ERROR) { @@ -162,7 +133,7 @@ Error EditorRunNative::run_native(int p_idx, int p_platform) { } void EditorRunNative::resume_run_native() { - run_native(resume_idx, resume_platform); + run_native(resume_id); } void EditorRunNative::_bind_methods() { @@ -174,6 +145,13 @@ bool EditorRunNative::is_deploy_debug_remote_enabled() const { } EditorRunNative::EditorRunNative() { + remote_debug = memnew(MenuButton); + remote_debug->get_popup()->connect("id_pressed", callable_mp(this, &EditorRunNative::run_native)); + remote_debug->set_icon(get_theme_icon(SNAME("PlayRemote"), SNAME("EditorIcons"))); + remote_debug->set_tooltip_text(TTR("Remote Debug")); + + add_child(remote_debug); + result_dialog = memnew(AcceptDialog); result_dialog->set_title(TTR("Project Run")); result_dialog_log = memnew(RichTextLabel); @@ -184,6 +162,4 @@ EditorRunNative::EditorRunNative() { result_dialog->hide(); set_process(true); - resume_idx = 0; - resume_platform = 0; } |