From 247b04763faf9e635f6a3c564a0979f0e7414008 Mon Sep 17 00:00:00 2001 From: Relintai Date: Tue, 16 Jul 2024 21:00:57 +0200 Subject: [PATCH] Improvements to the filesystem dock. --- editor/filesystem_dock.cpp | 26 ++++++++++++++++++++------ editor/filesystem_dock.h | 2 ++ editor/settings_config_dialog.cpp | 2 ++ 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index db467cfea..4dd1d1b63 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -402,6 +402,9 @@ void FileSystemDock::_notification(int p_what) { set_file_list_display_mode(FileSystemDock::FILE_LIST_DISPLAY_LIST); + SplitMode new_split_mode = SplitMode(int(EditorSettings::get_singleton()->get("docks/filesystem/split_mode"))); + set_split_mode(new_split_mode); + _update_display_mode(); if (EditorFileSystem::get_singleton()->is_scanning()) { @@ -2107,6 +2110,17 @@ void FileSystemDock::set_bottom_panel_tool_button(ToolButton *fs_button) { bottom_panel_tool_button = fs_button; } +void FileSystemDock::on_editor_save_and_restart() { + SplitMode new_split_mode = SplitMode(int(EditorSettings::get_singleton()->get("docks/filesystem/split_mode"))); + if (new_split_mode != split_mode) { + set_split_mode(new_split_mode); + + if (split_box->get_split_offset() < 100 * EDSCALE) { + split_box->set_split_offset(100 * EDSCALE); + } + } +} + Variant FileSystemDock::get_drag_data_fw(const Point2 &p_point, Control *p_from) { bool all_favorites = true; bool all_not_favorites = true; @@ -2904,7 +2918,12 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) { #endif ED_SHORTCUT("filesystem_dock/open_search", TTR("Focus the search box"), KEY_MASK_CMD | KEY_F); - bool wide = static_cast(static_cast(EDITOR_GET("docks/filesystem/dock_mode"))); + dock_mode = static_cast(static_cast(EDITOR_GET("docks/filesystem/dock_mode"))); + applied_dock_mode = static_cast(static_cast(EDITOR_GET("docks/filesystem/dock_mode"))); + + split_mode = static_cast(static_cast(EDITOR_GET("docks/filesystem/split_mode"))); + + bool wide = split_mode == SPLIT_MODE_VERTICAL; VBoxContainer *top_vbc = memnew(VBoxContainer); add_child(top_vbc); @@ -3113,11 +3132,9 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) { if (wide) { display_mode = DISPLAY_MODE_SPLIT; old_display_mode = DISPLAY_MODE_SPLIT; - split_mode = SPLIT_MODE_VERTICAL; } else { display_mode = DISPLAY_MODE_TREE_ONLY; old_display_mode = DISPLAY_MODE_TREE_ONLY; - split_mode = SPLIT_MODE_HORIZONTAL; } set_split_mode(split_mode); @@ -3129,9 +3146,6 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) { file_list_display_mode = FILE_LIST_DISPLAY_THUMBNAILS; always_show_folders = false; - - dock_mode = DOCK_MODE_DOCK; - applied_dock_mode = DOCK_MODE_DOCK; } FileSystemDock::~FileSystemDock() { diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h index eece72ca7..e1d2f8d84 100644 --- a/editor/filesystem_dock.h +++ b/editor/filesystem_dock.h @@ -391,6 +391,8 @@ public: void ensure_visible(); void set_bottom_panel_tool_button(ToolButton *fs_button); + void on_editor_save_and_restart(); + FileSystemDock(EditorNode *p_editor); ~FileSystemDock(); }; diff --git a/editor/settings_config_dialog.cpp b/editor/settings_config_dialog.cpp index 2dd9004ad..57538fa5a 100644 --- a/editor/settings_config_dialog.cpp +++ b/editor/settings_config_dialog.cpp @@ -53,6 +53,7 @@ #include "editor_property_name_processor.h" #include "editor_scale.h" #include "editor_settings.h" +#include "filesystem_dock.h" #include "scene/gui/box_container.h" #include "scene/gui/button.h" #include "scene/gui/label.h" @@ -403,6 +404,7 @@ void EditorSettingsDialog::_focus_current_search_box() { } void EditorSettingsDialog::_editor_restart() { + EditorNode::get_singleton()->get_filesystem_dock()->on_editor_save_and_restart(); EditorNode::get_singleton()->save_all_scenes(); EditorNode::get_singleton()->restart_editor(); }