Make project naming setting available in project manager

This commit is contained in:
kobewi 2024-03-22 22:44:45 +01:00
parent 04a530f91f
commit 8041dc6a55
3 changed files with 38 additions and 1 deletions

View file

@ -385,7 +385,7 @@ void ProjectManager::_dim_window() {
// Quick settings. // Quick settings.
void ProjectManager::_show_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() { void ProjectManager::_restart_confirmed() {

View file

@ -47,6 +47,7 @@ void QuickSettingsDialog::_fetch_setting_values() {
editor_themes.clear(); editor_themes.clear();
editor_scales.clear(); editor_scales.clear();
editor_network_modes.clear(); editor_network_modes.clear();
editor_directory_naming_conventions.clear();
{ {
List<PropertyInfo> editor_settings_properties; List<PropertyInfo> editor_settings_properties;
@ -61,6 +62,8 @@ void QuickSettingsDialog::_fetch_setting_values() {
editor_scales = pi.hint_string.split(","); editor_scales = pi.hint_string.split(",");
} else if (pi.name == "network/connection/network_mode") { } else if (pi.name == "network/connection/network_mode") {
editor_network_modes = pi.hint_string.split(","); 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) { 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); _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) { 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()->set(p_setting, p_value);
EditorSettings::get_singleton()->notify_changes(); EditorSettings::get_singleton()->notify_changes();
@ -284,6 +304,20 @@ QuickSettingsDialog::QuickSettingsDialog() {
_add_setting_control(TTR("Network Mode"), network_mode_option_button); _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(); _update_current_values();
#ifdef ANDROID_ENABLED #ifdef ANDROID_ENABLED

View file

@ -47,6 +47,7 @@ class QuickSettingsDialog : public AcceptDialog {
Vector<String> editor_themes; Vector<String> editor_themes;
Vector<String> editor_scales; Vector<String> editor_scales;
Vector<String> editor_network_modes; Vector<String> editor_network_modes;
Vector<String> editor_directory_naming_conventions;
void _fetch_setting_values(); void _fetch_setting_values();
void _update_current_values(); void _update_current_values();
@ -60,6 +61,7 @@ class QuickSettingsDialog : public AcceptDialog {
OptionButton *theme_option_button = nullptr; OptionButton *theme_option_button = nullptr;
OptionButton *scale_option_button = nullptr; OptionButton *scale_option_button = nullptr;
OptionButton *network_mode_option_button = nullptr; OptionButton *network_mode_option_button = nullptr;
OptionButton *directory_naming_convention_button = nullptr;
Label *custom_theme_label = nullptr; Label *custom_theme_label = nullptr;
@ -67,6 +69,7 @@ class QuickSettingsDialog : public AcceptDialog {
void _theme_selected(int p_id); void _theme_selected(int p_id);
void _scale_selected(int p_id); void _scale_selected(int p_id);
void _network_mode_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); void _set_setting_value(const String &p_setting, const Variant &p_value, bool p_restart_required = false);
Label *restart_required_label = nullptr; Label *restart_required_label = nullptr;