From 8041dc6a5519f5967d5b5fbb0ceaf63aa2d2a747 Mon Sep 17 00:00:00 2001 From: kobewi Date: Fri, 22 Mar 2024 22:44:45 +0100 Subject: [PATCH] Make project naming setting available in project manager --- editor/project_manager.cpp | 2 +- .../project_manager/quick_settings_dialog.cpp | 34 +++++++++++++++++++ .../project_manager/quick_settings_dialog.h | 3 ++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index b7dce1a224c..52d7b14b655 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -385,7 +385,7 @@ void ProjectManager::_dim_window() { // Quick settings. void ProjectManager::_show_quick_settings() { - quick_settings_dialog->popup_centered(Size2(600, 200) * EDSCALE); + quick_settings_dialog->popup_centered(Size2(640, 200) * EDSCALE); } void ProjectManager::_restart_confirmed() { diff --git a/editor/project_manager/quick_settings_dialog.cpp b/editor/project_manager/quick_settings_dialog.cpp index 05e8523518e..ee53bd79276 100644 --- a/editor/project_manager/quick_settings_dialog.cpp +++ b/editor/project_manager/quick_settings_dialog.cpp @@ -47,6 +47,7 @@ void QuickSettingsDialog::_fetch_setting_values() { editor_themes.clear(); editor_scales.clear(); editor_network_modes.clear(); + editor_directory_naming_conventions.clear(); { List editor_settings_properties; @@ -61,6 +62,8 @@ void QuickSettingsDialog::_fetch_setting_values() { editor_scales = pi.hint_string.split(","); } else if (pi.name == "network/connection/network_mode") { editor_network_modes = pi.hint_string.split(","); + } else if (pi.name == "project_manager/directory_naming_convention") { + editor_directory_naming_conventions = pi.hint_string.split(","); } } } @@ -120,6 +123,19 @@ void QuickSettingsDialog::_update_current_values() { } } } + + // Project directory naming options. + { + const int current_directory_naming = EDITOR_GET("project_manager/directory_naming_convention"); + + for (int i = 0; i < editor_directory_naming_conventions.size(); i++) { + const String &directory_naming_value = editor_directory_naming_conventions[i]; + if (current_directory_naming == i) { + directory_naming_convention_button->set_text(directory_naming_value); + directory_naming_convention_button->select(i); + } + } + } } void QuickSettingsDialog::_add_setting_control(const String &p_text, Control *p_control) { @@ -155,6 +171,10 @@ void QuickSettingsDialog::_network_mode_selected(int p_id) { _set_setting_value("network/connection/network_mode", p_id); } +void QuickSettingsDialog::_directory_naming_convention_selected(int p_id) { + _set_setting_value("project_manager/directory_naming_convention", p_id); +} + void QuickSettingsDialog::_set_setting_value(const String &p_setting, const Variant &p_value, bool p_restart_required) { EditorSettings::get_singleton()->set(p_setting, p_value); EditorSettings::get_singleton()->notify_changes(); @@ -284,6 +304,20 @@ QuickSettingsDialog::QuickSettingsDialog() { _add_setting_control(TTR("Network Mode"), network_mode_option_button); } + // Project directory naming options. + { + directory_naming_convention_button = memnew(OptionButton); + directory_naming_convention_button->set_fit_to_longest_item(false); + directory_naming_convention_button->connect(SceneStringName(item_selected), callable_mp(this, &QuickSettingsDialog::_directory_naming_convention_selected)); + + for (int i = 0; i < editor_directory_naming_conventions.size(); i++) { + const String &directory_naming_convention = editor_directory_naming_conventions[i]; + directory_naming_convention_button->add_item(directory_naming_convention, i); + } + + _add_setting_control(TTR("Directory Naming Convention"), directory_naming_convention_button); + } + _update_current_values(); #ifdef ANDROID_ENABLED diff --git a/editor/project_manager/quick_settings_dialog.h b/editor/project_manager/quick_settings_dialog.h index c4c4e601c93..7a039969347 100644 --- a/editor/project_manager/quick_settings_dialog.h +++ b/editor/project_manager/quick_settings_dialog.h @@ -47,6 +47,7 @@ class QuickSettingsDialog : public AcceptDialog { Vector editor_themes; Vector editor_scales; Vector editor_network_modes; + Vector editor_directory_naming_conventions; void _fetch_setting_values(); void _update_current_values(); @@ -60,6 +61,7 @@ class QuickSettingsDialog : public AcceptDialog { OptionButton *theme_option_button = nullptr; OptionButton *scale_option_button = nullptr; OptionButton *network_mode_option_button = nullptr; + OptionButton *directory_naming_convention_button = nullptr; Label *custom_theme_label = nullptr; @@ -67,6 +69,7 @@ class QuickSettingsDialog : public AcceptDialog { void _theme_selected(int p_id); void _scale_selected(int p_id); void _network_mode_selected(int p_id); + void _directory_naming_convention_selected(int p_id); void _set_setting_value(const String &p_setting, const Variant &p_value, bool p_restart_required = false); Label *restart_required_label = nullptr;