From 76205d4276f61b49b793a6df4b03c5f7eddd88c3 Mon Sep 17 00:00:00 2001
From: Hilderin <81109165+Hilderin@users.noreply.github.com>
Date: Mon, 22 Apr 2024 19:22:06 -0400
Subject: [PATCH] Add editor setting to keep bottom panel state on play and
stop game
---
doc/classes/EditorSettings.xml | 12 ++++++------
editor/debugger/editor_debugger_node.cpp | 6 +-----
editor/debugger/script_editor_debugger.cpp | 1 -
editor/editor_node.cpp | 12 +++++++-----
editor/editor_node.h | 11 +++++++++++
editor/editor_settings.cpp | 6 ++++--
6 files changed, 29 insertions(+), 19 deletions(-)
diff --git a/doc/classes/EditorSettings.xml b/doc/classes/EditorSettings.xml
index 93a7b09fce15..c419c067da17 100644
--- a/doc/classes/EditorSettings.xml
+++ b/doc/classes/EditorSettings.xml
@@ -912,14 +912,14 @@
If [code]true[/code], saves all scenes and scripts automatically before running the project. Setting this to [code]false[/code] prevents the editor from saving if there are no changes which can speed up the project startup slightly, but it makes it possible to run a project that has unsaved changes. (Unsaved changes will not be visible in the running project.)
-
- If [code]true[/code], the editor will clear the Output panel when running the project.
+
+ The action to execute on the bottom panel when running the project.
-
- If [code]true[/code], the editor will collapse the Output panel when stopping the project.
+
+ The action to execute on the bottom panel when stopping the project.
-
- If [code]true[/code], the editor will expand the Output panel when running the project.
+
+ If [code]true[/code], the editor will clear the Output panel when running the project.
The size of the font in the [b]Output[/b] panel at the bottom of the editor. This setting does not impact the font size of the script editor (see [member interface/editor/code_font_size]).
diff --git a/editor/debugger/editor_debugger_node.cpp b/editor/debugger/editor_debugger_node.cpp
index b7719f6c973b..a3843a8565bf 100644
--- a/editor/debugger/editor_debugger_node.cpp
+++ b/editor/debugger/editor_debugger_node.cpp
@@ -268,11 +268,7 @@ Error EditorDebuggerNode::start(const String &p_uri) {
}
stop(true);
current_uri = p_uri;
- if (EDITOR_GET("run/output/always_open_output_on_play")) {
- EditorNode::get_bottom_panel()->make_item_visible(EditorNode::get_log());
- } else {
- EditorNode::get_bottom_panel()->make_item_visible(this);
- }
+
server = Ref(EditorDebuggerServer::create(p_uri.substr(0, p_uri.find("://") + 3)));
const Error err = server->start(p_uri);
if (err != OK) {
diff --git a/editor/debugger/script_editor_debugger.cpp b/editor/debugger/script_editor_debugger.cpp
index 2b880274f88c..73b5ca5f9eaa 100644
--- a/editor/debugger/script_editor_debugger.cpp
+++ b/editor/debugger/script_editor_debugger.cpp
@@ -1008,7 +1008,6 @@ void ScriptEditorDebugger::start(Ref p_peer) {
set_process(true);
camera_override = CameraOverride::OVERRIDE_NONE;
- tabs->set_current_tab(0);
_set_reason_text(TTR("Debug session started."), MESSAGE_SUCCESS);
_update_buttons_state();
emit_signal(SNAME("started"));
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 5b24fb1559b7..5255c27e67fe 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -4391,17 +4391,19 @@ void EditorNode::_project_run_started() {
log->clear();
}
- if (bool(EDITOR_GET("run/output/always_open_output_on_play"))) {
+ int action_on_play = EDITOR_GET("run/bottom_panel/action_on_play");
+ if (action_on_play == ACTION_ON_PLAY_OPEN_OUTPUT) {
bottom_panel->make_item_visible(log);
+ } else if (action_on_play == ACTION_ON_PLAY_OPEN_DEBUGGER) {
+ bottom_panel->make_item_visible(EditorDebuggerNode::get_singleton());
}
}
void EditorNode::_project_run_stopped() {
- if (!bool(EDITOR_GET("run/output/always_close_output_on_stop"))) {
- return;
+ int action_on_stop = EDITOR_GET("run/bottom_panel/action_on_stop");
+ if (action_on_stop == ACTION_ON_STOP_CLOSE_BUTTOM_PANEL) {
+ bottom_panel->hide_bottom_panel();
}
-
- bottom_panel->make_item_visible(log, false);
}
void EditorNode::notify_all_debug_sessions_exited() {
diff --git a/editor/editor_node.h b/editor/editor_node.h
index ad0a7ec5e084..355b9762c2f5 100644
--- a/editor/editor_node.h
+++ b/editor/editor_node.h
@@ -140,6 +140,17 @@ class EditorNode : public Node {
SCENE_NAME_CASING_KEBAB_CASE,
};
+ enum ActionOnPlay {
+ ACTION_ON_PLAY_DO_NOTHING,
+ ACTION_ON_PLAY_OPEN_OUTPUT,
+ ACTION_ON_PLAY_OPEN_DEBUGGER,
+ };
+
+ enum ActionOnStop {
+ ACTION_ON_STOP_DO_NOTHING,
+ ACTION_ON_STOP_CLOSE_BUTTOM_PANEL,
+ };
+
struct ExecuteThreadArgs {
String path;
List args;
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index ca6be130f9d6..206307d87ddb 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -815,11 +815,13 @@ void EditorSettings::_load_defaults(Ref p_extra_config) {
// Auto save
_initial_set("run/auto_save/save_before_running", true);
+ // Bottom panel
+ EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "run/bottom_panel/action_on_play", EditorNode::ACTION_ON_PLAY_OPEN_OUTPUT, "Do Nothing,Open Output,Open Debugger")
+ EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "run/bottom_panel/action_on_stop", EditorNode::ACTION_ON_STOP_DO_NOTHING, "Do Nothing,Close Bottom Panel")
+
// Output
EDITOR_SETTING(Variant::INT, PROPERTY_HINT_RANGE, "run/output/font_size", 13, "8,48,1")
_initial_set("run/output/always_clear_output_on_play", true);
- _initial_set("run/output/always_open_output_on_play", true);
- _initial_set("run/output/always_close_output_on_stop", false);
// Platform
_initial_set("run/platforms/linuxbsd/prefer_wayland", false);