Debugger: Save options in project metadata

Fixes #19542.
This commit is contained in:
Rémi Verschelde 2020-11-17 13:03:37 +01:00
parent 386ee52978
commit 090361f3c9
No known key found for this signature in database
GPG key ID: C3336907360768E1
2 changed files with 27 additions and 10 deletions

View file

@ -232,6 +232,9 @@ void EditorDebuggerNode::_notification(int p_what) {
tabs->add_theme_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox("DebuggerPanel", "EditorStyles")); tabs->add_theme_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox("DebuggerPanel", "EditorStyles"));
} }
} break; } break;
case NOTIFICATION_READY: {
_update_debug_options();
} break;
default: default:
break; break;
} }
@ -385,7 +388,7 @@ void EditorDebuggerNode::set_script_debug_button(MenuButton *p_button) {
p->add_shortcut(ED_GET_SHORTCUT("debugger/break"), DEBUG_BREAK); p->add_shortcut(ED_GET_SHORTCUT("debugger/break"), DEBUG_BREAK);
p->add_shortcut(ED_GET_SHORTCUT("debugger/continue"), DEBUG_CONTINUE); p->add_shortcut(ED_GET_SHORTCUT("debugger/continue"), DEBUG_CONTINUE);
p->add_separator(); p->add_separator();
p->add_check_shortcut(ED_GET_SHORTCUT("debugger/keep_debugger_open"), DEBUG_SHOW_KEEP_OPEN); p->add_check_shortcut(ED_GET_SHORTCUT("debugger/keep_debugger_open"), DEBUG_KEEP_DEBUGGER_OPEN);
p->add_check_shortcut(ED_GET_SHORTCUT("debugger/debug_with_external_editor"), DEBUG_WITH_EXTERNAL_EDITOR); p->add_check_shortcut(ED_GET_SHORTCUT("debugger/debug_with_external_editor"), DEBUG_WITH_EXTERNAL_EDITOR);
p->connect("id_pressed", callable_mp(this, &EditorDebuggerNode::_menu_option)); p->connect("id_pressed", callable_mp(this, &EditorDebuggerNode::_menu_option));
@ -425,20 +428,33 @@ void EditorDebuggerNode::_menu_option(int p_id) {
case DEBUG_CONTINUE: { case DEBUG_CONTINUE: {
debug_continue(); debug_continue();
} break; } break;
case DEBUG_KEEP_DEBUGGER_OPEN: {
case DEBUG_SHOW_KEEP_OPEN: { bool ischecked = script_menu->get_popup()->is_item_checked(script_menu->get_popup()->get_item_index(DEBUG_KEEP_DEBUGGER_OPEN));
bool visible = script_menu->get_popup()->is_item_checked(script_menu->get_popup()->get_item_index(DEBUG_SHOW_KEEP_OPEN)); hide_on_stop = ischecked;
hide_on_stop = visible; script_menu->get_popup()->set_item_checked(script_menu->get_popup()->get_item_index(DEBUG_KEEP_DEBUGGER_OPEN), !ischecked);
script_menu->get_popup()->set_item_checked(script_menu->get_popup()->get_item_index(DEBUG_SHOW_KEEP_OPEN), !visible); EditorSettings::get_singleton()->set_project_metadata("debug_options", "keep_debugger_open", !ischecked);
} break; } break;
case DEBUG_WITH_EXTERNAL_EDITOR: { case DEBUG_WITH_EXTERNAL_EDITOR: {
bool checked = !script_menu->get_popup()->is_item_checked(script_menu->get_popup()->get_item_index(DEBUG_WITH_EXTERNAL_EDITOR)); bool ischecked = script_menu->get_popup()->is_item_checked(script_menu->get_popup()->get_item_index(DEBUG_WITH_EXTERNAL_EDITOR));
debug_with_external_editor = checked; debug_with_external_editor = !ischecked;
script_menu->get_popup()->set_item_checked(script_menu->get_popup()->get_item_index(DEBUG_WITH_EXTERNAL_EDITOR), checked); script_menu->get_popup()->set_item_checked(script_menu->get_popup()->get_item_index(DEBUG_WITH_EXTERNAL_EDITOR), !ischecked);
EditorSettings::get_singleton()->set_project_metadata("debug_options", "debug_with_external_editor", !ischecked);
} break; } break;
} }
} }
void EditorDebuggerNode::_update_debug_options() {
bool keep_debugger_open = EditorSettings::get_singleton()->get_project_metadata("debug_options", "keep_debugger_open", false);
bool debug_with_external_editor = EditorSettings::get_singleton()->get_project_metadata("debug_options", "debug_with_external_editor", false);
if (keep_debugger_open) {
_menu_option(DEBUG_KEEP_DEBUGGER_OPEN);
}
if (debug_with_external_editor) {
_menu_option(DEBUG_WITH_EXTERNAL_EDITOR);
}
}
void EditorDebuggerNode::_paused() { void EditorDebuggerNode::_paused() {
const bool paused = EditorNode::get_singleton()->get_pause_button()->is_pressed(); const bool paused = EditorNode::get_singleton()->get_pause_button()->is_pressed();
_for_all(tabs, [&](ScriptEditorDebugger *dbg) { _for_all(tabs, [&](ScriptEditorDebugger *dbg) {

View file

@ -60,7 +60,7 @@ private:
DEBUG_STEP, DEBUG_STEP,
DEBUG_BREAK, DEBUG_BREAK,
DEBUG_CONTINUE, DEBUG_CONTINUE,
DEBUG_SHOW_KEEP_OPEN, DEBUG_KEEP_DEBUGGER_OPEN,
DEBUG_WITH_EXTERNAL_EDITOR, DEBUG_WITH_EXTERNAL_EDITOR,
}; };
@ -133,6 +133,7 @@ protected:
void _paused(); void _paused();
void _break_state_changed(); void _break_state_changed();
void _menu_option(int p_id); void _menu_option(int p_id);
void _update_debug_options();
protected: protected:
void _notification(int p_what); void _notification(int p_what);