Move remote debug buttons to a single menu.
This commit is contained in:
parent
60d031777b
commit
5406b001ca
|
@ -213,7 +213,7 @@ Dictionary DebugAdapterParser::req_launch(const Dictionary &p_params) const {
|
|||
}
|
||||
|
||||
EditorNode *editor = EditorNode::get_singleton();
|
||||
Error err = platform_string == "android" ? editor->run_play_native(device, idx) : editor->run_play_native(-1, idx);
|
||||
Error err = platform_string == "android" ? editor->run_play_native(device * 10000 + idx) : editor->run_play_native(idx);
|
||||
if (err) {
|
||||
if (err == ERR_INVALID_PARAMETER && platform_string == "android") {
|
||||
return prepare_error_response(p_params, DAP::ErrorType::MISSING_DEVICE);
|
||||
|
|
|
@ -5067,8 +5067,8 @@ bool EditorNode::ensure_main_scene(bool p_from_native) {
|
|||
return true;
|
||||
}
|
||||
|
||||
Error EditorNode::run_play_native(int p_idx, int p_platform) {
|
||||
return run_native->run_native(p_idx, p_platform);
|
||||
Error EditorNode::run_play_native(int p_id) {
|
||||
return run_native->run_native(p_id);
|
||||
}
|
||||
|
||||
void EditorNode::run_play() {
|
||||
|
|
|
@ -914,7 +914,7 @@ public:
|
|||
|
||||
bool ensure_main_scene(bool p_from_native);
|
||||
|
||||
Error run_play_native(int p_idx, int p_platform);
|
||||
Error run_play_native(int p_id);
|
||||
void run_play();
|
||||
void run_play_current();
|
||||
void run_play_custom(const String &p_custom);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -42,18 +42,17 @@ class EditorRunNative : public HBoxContainer {
|
|||
RichTextLabel *result_dialog_log = nullptr;
|
||||
AcceptDialog *result_dialog = nullptr;
|
||||
|
||||
HashMap<int, MenuButton *> menus;
|
||||
MenuButton *remote_debug = nullptr;
|
||||
bool first = true;
|
||||
|
||||
int resume_idx;
|
||||
int resume_platform;
|
||||
int resume_id = -1;
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
void _notification(int p_what);
|
||||
|
||||
public:
|
||||
Error run_native(int p_idx, int p_platform);
|
||||
Error run_native(int p_id);
|
||||
bool is_deploy_debug_remote_enabled() const;
|
||||
|
||||
void resume_run_native();
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="16" height="16"><path d="m12.998 2.548-9.996.005a2.006 2.006 0 0 0-2.006 2v4.61c0 1.107.898 2.003 2.006 2.003h3.996v.9h-1.68v.381H3.001v2h2.315v.38h5.366v-.38H13v-2.004h-2.315v-.378H9.004v-.9h3.994a2.006 2.006 0 0 0 2.006-2.003v-4.61c0-1.106-.9-2.003-2.006-2.003zm-7.496 1.31 5 3-5 3z" style="fill:#e0e0e0;fill-opacity:1"/></svg>
|
After Width: | Height: | Size: 398 B |
Loading…
Reference in New Issue