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();
|
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) {
|
||||||
if (err == ERR_INVALID_PARAMETER && platform_string == "android") {
|
if (err == ERR_INVALID_PARAMETER && platform_string == "android") {
|
||||||
return prepare_error_response(p_params, DAP::ErrorType::MISSING_DEVICE);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Error EditorNode::run_play_native(int p_idx, int p_platform) {
|
Error EditorNode::run_play_native(int p_id) {
|
||||||
return run_native->run_native(p_idx, p_platform);
|
return run_native->run_native(p_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorNode::run_play() {
|
void EditorNode::run_play() {
|
||||||
|
|
|
@ -914,7 +914,7 @@ public:
|
||||||
|
|
||||||
bool ensure_main_scene(bool p_from_native);
|
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();
|
||||||
void run_play_current();
|
void run_play_current();
|
||||||
void run_play_custom(const String &p_custom);
|
void run_play_custom(const String &p_custom);
|
||||||
|
|
|
@ -37,53 +37,27 @@
|
||||||
|
|
||||||
void EditorRunNative::_notification(int p_what) {
|
void EditorRunNative::_notification(int p_what) {
|
||||||
switch (p_what) {
|
switch (p_what) {
|
||||||
case NOTIFICATION_ENTER_TREE: {
|
case NOTIFICATION_THEME_CHANGED: {
|
||||||
for (int i = 0; i < EditorExport::get_singleton()->get_export_platform_count(); i++) {
|
remote_debug->set_icon(get_theme_icon(SNAME("PlayRemote"), SNAME("EditorIcons")));
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case NOTIFICATION_PROCESS: {
|
case NOTIFICATION_PROCESS: {
|
||||||
bool changed = EditorExport::get_singleton()->poll_export_platforms() || first;
|
bool changed = EditorExport::get_singleton()->poll_export_platforms() || first;
|
||||||
|
|
||||||
if (changed) {
|
if (changed) {
|
||||||
for (KeyValue<int, MenuButton *> &E : menus) {
|
remote_debug->get_popup()->clear();
|
||||||
Ref<EditorExportPlatform> eep = EditorExport::get_singleton()->get_export_platform(E.key);
|
for (int i = 0; i < EditorExport::get_singleton()->get_export_platform_count(); i++) {
|
||||||
MenuButton *mb = E.value;
|
Ref<EditorExportPlatform> eep = EditorExport::get_singleton()->get_export_platform(i);
|
||||||
int dc = eep->get_options_count();
|
if (eep.is_null()) {
|
||||||
|
continue;
|
||||||
if (dc == 0) {
|
}
|
||||||
mb->hide();
|
int dc = MIN(eep->get_options_count(), 9000);
|
||||||
} else {
|
if (dc > 0) {
|
||||||
mb->get_popup()->clear();
|
remote_debug->get_popup()->add_icon_item(eep->get_run_icon(), eep->get_name(), -1);
|
||||||
mb->show();
|
remote_debug->get_popup()->set_item_disabled(-1, true);
|
||||||
if (dc == 1) {
|
for (int j = 0; j < dc; j++) {
|
||||||
mb->set_tooltip_text(eep->get_option_tooltip(0));
|
remote_debug->get_popup()->add_icon_item(eep->get_option_icon(j), eep->get_option_label(j), 10000 * i + j);
|
||||||
} else {
|
remote_debug->get_popup()->set_item_tooltip(-1, eep->get_option_tooltip(j));
|
||||||
mb->set_tooltip_text(eep->get_options_tooltip());
|
remote_debug->get_popup()->set_item_indent(-1, 2);
|
||||||
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));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,25 +68,22 @@ void EditorRunNative::_notification(int p_what) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Error EditorRunNative::run_native(int p_idx, int p_platform) {
|
Error EditorRunNative::run_native(int p_id) {
|
||||||
if (!EditorNode::get_singleton()->ensure_main_scene(true)) {
|
if (p_id < 0) {
|
||||||
resume_idx = p_idx;
|
|
||||||
resume_platform = p_platform;
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<EditorExportPlatform> eep = EditorExport::get_singleton()->get_export_platform(p_platform);
|
int platform = p_id / 10000;
|
||||||
ERR_FAIL_COND_V(eep.is_null(), ERR_UNAVAILABLE);
|
int idx = p_id % 10000;
|
||||||
|
|
||||||
if (p_idx == -1) {
|
if (!EditorNode::get_singleton()->ensure_main_scene(true)) {
|
||||||
if (eep->get_options_count() == 1) {
|
resume_id = p_id;
|
||||||
menus[p_platform]->get_popup()->hide();
|
return OK;
|
||||||
p_idx = 0;
|
|
||||||
} else {
|
|
||||||
return ERR_INVALID_PARAMETER;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ref<EditorExportPlatform> eep = EditorExport::get_singleton()->get_export_platform(platform);
|
||||||
|
ERR_FAIL_COND_V(eep.is_null(), ERR_UNAVAILABLE);
|
||||||
|
|
||||||
Ref<EditorExportPreset> preset;
|
Ref<EditorExportPreset> preset;
|
||||||
|
|
||||||
for (int i = 0; i < EditorExport::get_singleton()->get_export_preset_count(); i++) {
|
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();
|
eep->clear_messages();
|
||||||
Error err = eep->run(preset, p_idx, flags);
|
Error err = eep->run(preset, idx, flags);
|
||||||
result_dialog_log->clear();
|
result_dialog_log->clear();
|
||||||
if (eep->fill_log_messages(result_dialog_log, err)) {
|
if (eep->fill_log_messages(result_dialog_log, err)) {
|
||||||
if (eep->get_worst_message_type() >= EditorExportPlatform::EXPORT_MESSAGE_ERROR) {
|
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() {
|
void EditorRunNative::resume_run_native() {
|
||||||
run_native(resume_idx, resume_platform);
|
run_native(resume_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorRunNative::_bind_methods() {
|
void EditorRunNative::_bind_methods() {
|
||||||
|
@ -174,6 +145,13 @@ bool EditorRunNative::is_deploy_debug_remote_enabled() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorRunNative::EditorRunNative() {
|
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 = memnew(AcceptDialog);
|
||||||
result_dialog->set_title(TTR("Project Run"));
|
result_dialog->set_title(TTR("Project Run"));
|
||||||
result_dialog_log = memnew(RichTextLabel);
|
result_dialog_log = memnew(RichTextLabel);
|
||||||
|
@ -184,6 +162,4 @@ EditorRunNative::EditorRunNative() {
|
||||||
result_dialog->hide();
|
result_dialog->hide();
|
||||||
|
|
||||||
set_process(true);
|
set_process(true);
|
||||||
resume_idx = 0;
|
|
||||||
resume_platform = 0;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,18 +42,17 @@ class EditorRunNative : public HBoxContainer {
|
||||||
RichTextLabel *result_dialog_log = nullptr;
|
RichTextLabel *result_dialog_log = nullptr;
|
||||||
AcceptDialog *result_dialog = nullptr;
|
AcceptDialog *result_dialog = nullptr;
|
||||||
|
|
||||||
HashMap<int, MenuButton *> menus;
|
MenuButton *remote_debug = nullptr;
|
||||||
bool first = true;
|
bool first = true;
|
||||||
|
|
||||||
int resume_idx;
|
int resume_id = -1;
|
||||||
int resume_platform;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
void _notification(int p_what);
|
void _notification(int p_what);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Error run_native(int p_idx, int p_platform);
|
Error run_native(int p_id);
|
||||||
bool is_deploy_debug_remote_enabled() const;
|
bool is_deploy_debug_remote_enabled() const;
|
||||||
|
|
||||||
void resume_run_native();
|
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