Add editor setting to keep bottom panel state on play and stop game

This commit is contained in:
Hilderin 2024-04-22 19:22:06 -04:00
parent 7abe0c6014
commit 76205d4276
6 changed files with 29 additions and 19 deletions

View file

@ -912,15 +912,15 @@
<member name="run/auto_save/save_before_running" type="bool" setter="" getter="">
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.)
</member>
<member name="run/bottom_panel/action_on_play" type="int" setter="" getter="">
The action to execute on the bottom panel when running the project.
</member>
<member name="run/bottom_panel/action_on_stop" type="int" setter="" getter="">
The action to execute on the bottom panel when stopping the project.
</member>
<member name="run/output/always_clear_output_on_play" type="bool" setter="" getter="">
If [code]true[/code], the editor will clear the Output panel when running the project.
</member>
<member name="run/output/always_close_output_on_stop" type="bool" setter="" getter="">
If [code]true[/code], the editor will collapse the Output panel when stopping the project.
</member>
<member name="run/output/always_open_output_on_play" type="bool" setter="" getter="">
If [code]true[/code], the editor will expand the Output panel when running the project.
</member>
<member name="run/output/font_size" type="int" setter="" getter="">
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]).
</member>

View file

@ -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>(EditorDebuggerServer::create(p_uri.substr(0, p_uri.find("://") + 3)));
const Error err = server->start(p_uri);
if (err != OK) {

View file

@ -1008,7 +1008,6 @@ void ScriptEditorDebugger::start(Ref<RemoteDebuggerPeer> 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"));

View file

@ -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() {

View file

@ -140,6 +140,17 @@ public:
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<String> args;

View file

@ -815,11 +815,13 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> 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);