| 
									
										
										
										
											2024-01-30 17:35:46 +01:00
										 |  |  | /**************************************************************************/ | 
					
						
							|  |  |  | /*  quick_settings_dialog.cpp                                             */ | 
					
						
							|  |  |  | /**************************************************************************/ | 
					
						
							|  |  |  | /*                         This file is part of:                          */ | 
					
						
							|  |  |  | /*                             GODOT ENGINE                               */ | 
					
						
							|  |  |  | /*                        https://godotengine.org                         */ | 
					
						
							|  |  |  | /**************************************************************************/ | 
					
						
							|  |  |  | /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ | 
					
						
							|  |  |  | /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur.                  */ | 
					
						
							|  |  |  | /*                                                                        */ | 
					
						
							|  |  |  | /* Permission is hereby granted, free of charge, to any person obtaining  */ | 
					
						
							|  |  |  | /* a copy of this software and associated documentation files (the        */ | 
					
						
							|  |  |  | /* "Software"), to deal in the Software without restriction, including    */ | 
					
						
							|  |  |  | /* without limitation the rights to use, copy, modify, merge, publish,    */ | 
					
						
							|  |  |  | /* distribute, sublicense, and/or sell copies of the Software, and to     */ | 
					
						
							|  |  |  | /* permit persons to whom the Software is furnished to do so, subject to  */ | 
					
						
							|  |  |  | /* the following conditions:                                              */ | 
					
						
							|  |  |  | /*                                                                        */ | 
					
						
							|  |  |  | /* The above copyright notice and this permission notice shall be         */ | 
					
						
							|  |  |  | /* included in all copies or substantial portions of the Software.        */ | 
					
						
							|  |  |  | /*                                                                        */ | 
					
						
							|  |  |  | /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,        */ | 
					
						
							|  |  |  | /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF     */ | 
					
						
							|  |  |  | /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ | 
					
						
							|  |  |  | /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY   */ | 
					
						
							|  |  |  | /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,   */ | 
					
						
							|  |  |  | /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE      */ | 
					
						
							|  |  |  | /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                 */ | 
					
						
							|  |  |  | /**************************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "quick_settings_dialog.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "core/config/project_settings.h"
 | 
					
						
							| 
									
										
										
										
											2024-08-15 15:00:47 +08:00
										 |  |  | #include "core/string/translation_server.h"
 | 
					
						
							| 
									
										
										
										
											2024-01-30 17:35:46 +01:00
										 |  |  | #include "editor/editor_settings.h"
 | 
					
						
							|  |  |  | #include "editor/editor_string_names.h"
 | 
					
						
							|  |  |  | #include "editor/themes/editor_scale.h"
 | 
					
						
							|  |  |  | #include "scene/gui/box_container.h"
 | 
					
						
							|  |  |  | #include "scene/gui/button.h"
 | 
					
						
							|  |  |  | #include "scene/gui/label.h"
 | 
					
						
							|  |  |  | #include "scene/gui/option_button.h"
 | 
					
						
							|  |  |  | #include "scene/gui/panel_container.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void QuickSettingsDialog::_fetch_setting_values() { | 
					
						
							| 
									
										
										
										
											2024-08-02 12:40:27 -07:00
										 |  |  | #ifndef ANDROID_ENABLED
 | 
					
						
							| 
									
										
										
										
											2024-01-30 17:35:46 +01:00
										 |  |  | 	editor_languages.clear(); | 
					
						
							| 
									
										
										
										
											2024-08-02 12:40:27 -07:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2024-01-30 17:35:46 +01:00
										 |  |  | 	editor_themes.clear(); | 
					
						
							|  |  |  | 	editor_scales.clear(); | 
					
						
							|  |  |  | 	editor_network_modes.clear(); | 
					
						
							| 
									
										
										
										
											2024-03-22 22:44:45 +01:00
										 |  |  | 	editor_directory_naming_conventions.clear(); | 
					
						
							| 
									
										
										
										
											2024-01-30 17:35:46 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		List<PropertyInfo> editor_settings_properties; | 
					
						
							|  |  |  | 		EditorSettings::get_singleton()->get_property_list(&editor_settings_properties); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		for (const PropertyInfo &pi : editor_settings_properties) { | 
					
						
							|  |  |  | 			if (pi.name == "interface/editor/editor_language") { | 
					
						
							| 
									
										
										
										
											2024-08-02 12:40:27 -07:00
										 |  |  | #ifndef ANDROID_ENABLED
 | 
					
						
							| 
									
										
										
										
											2024-01-30 17:35:46 +01:00
										 |  |  | 				editor_languages = pi.hint_string.split(","); | 
					
						
							| 
									
										
										
										
											2024-08-02 12:40:27 -07:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2024-01-30 17:35:46 +01:00
										 |  |  | 			} else if (pi.name == "interface/theme/preset") { | 
					
						
							|  |  |  | 				editor_themes = pi.hint_string.split(","); | 
					
						
							|  |  |  | 			} else if (pi.name == "interface/editor/display_scale") { | 
					
						
							|  |  |  | 				editor_scales = pi.hint_string.split(","); | 
					
						
							|  |  |  | 			} else if (pi.name == "network/connection/network_mode") { | 
					
						
							|  |  |  | 				editor_network_modes = pi.hint_string.split(","); | 
					
						
							| 
									
										
										
										
											2024-03-22 22:44:45 +01:00
										 |  |  | 			} else if (pi.name == "project_manager/directory_naming_convention") { | 
					
						
							|  |  |  | 				editor_directory_naming_conventions = pi.hint_string.split(","); | 
					
						
							| 
									
										
										
										
											2024-01-30 17:35:46 +01:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void QuickSettingsDialog::_update_current_values() { | 
					
						
							| 
									
										
										
										
											2024-08-02 12:40:27 -07:00
										 |  |  | #ifndef ANDROID_ENABLED
 | 
					
						
							| 
									
										
										
										
											2024-01-30 17:35:46 +01:00
										 |  |  | 	// Language options.
 | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		const String current_lang = EDITOR_GET("interface/editor/editor_language"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		for (int i = 0; i < editor_languages.size(); i++) { | 
					
						
							|  |  |  | 			const String &lang_value = editor_languages[i]; | 
					
						
							|  |  |  | 			if (current_lang == lang_value) { | 
					
						
							|  |  |  | 				language_option_button->set_text(current_lang); | 
					
						
							|  |  |  | 				language_option_button->select(i); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2024-08-02 12:40:27 -07:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2024-01-30 17:35:46 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// Theme options.
 | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		const String current_theme = EDITOR_GET("interface/theme/preset"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		for (int i = 0; i < editor_themes.size(); i++) { | 
					
						
							|  |  |  | 			const String &theme_value = editor_themes[i]; | 
					
						
							|  |  |  | 			if (current_theme == theme_value) { | 
					
						
							|  |  |  | 				theme_option_button->set_text(current_theme); | 
					
						
							|  |  |  | 				theme_option_button->select(i); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				custom_theme_label->set_visible(current_theme == "Custom"); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// Scale options.
 | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		const int current_scale = EDITOR_GET("interface/editor/display_scale"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		for (int i = 0; i < editor_scales.size(); i++) { | 
					
						
							|  |  |  | 			const String &scale_value = editor_scales[i]; | 
					
						
							|  |  |  | 			if (current_scale == i) { | 
					
						
							|  |  |  | 				scale_option_button->set_text(scale_value); | 
					
						
							|  |  |  | 				scale_option_button->select(i); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// Network mode options.
 | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		const int current_network_mode = EDITOR_GET("network/connection/network_mode"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		for (int i = 0; i < editor_network_modes.size(); i++) { | 
					
						
							|  |  |  | 			const String &network_mode_value = editor_network_modes[i]; | 
					
						
							|  |  |  | 			if (current_network_mode == i) { | 
					
						
							|  |  |  | 				network_mode_option_button->set_text(network_mode_value); | 
					
						
							|  |  |  | 				network_mode_option_button->select(i); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2024-03-22 22:44:45 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// 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); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2024-01-30 17:35:46 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void QuickSettingsDialog::_add_setting_control(const String &p_text, Control *p_control) { | 
					
						
							|  |  |  | 	HBoxContainer *container = memnew(HBoxContainer); | 
					
						
							|  |  |  | 	settings_list->add_child(container); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Label *label = memnew(Label(p_text)); | 
					
						
							|  |  |  | 	label->set_h_size_flags(Control::SIZE_EXPAND_FILL); | 
					
						
							|  |  |  | 	container->add_child(label); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	p_control->set_h_size_flags(Control::SIZE_EXPAND_FILL); | 
					
						
							|  |  |  | 	p_control->set_stretch_ratio(2.0); | 
					
						
							|  |  |  | 	container->add_child(p_control); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-02 12:40:27 -07:00
										 |  |  | #ifndef ANDROID_ENABLED
 | 
					
						
							| 
									
										
										
										
											2024-01-30 17:35:46 +01:00
										 |  |  | void QuickSettingsDialog::_language_selected(int p_id) { | 
					
						
							|  |  |  | 	const String selected_language = language_option_button->get_item_metadata(p_id); | 
					
						
							|  |  |  | 	_set_setting_value("interface/editor/editor_language", selected_language, true); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2024-08-02 12:40:27 -07:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2024-01-30 17:35:46 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | void QuickSettingsDialog::_theme_selected(int p_id) { | 
					
						
							|  |  |  | 	const String selected_theme = theme_option_button->get_item_text(p_id); | 
					
						
							|  |  |  | 	_set_setting_value("interface/theme/preset", selected_theme); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	custom_theme_label->set_visible(selected_theme == "Custom"); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void QuickSettingsDialog::_scale_selected(int p_id) { | 
					
						
							|  |  |  | 	_set_setting_value("interface/editor/display_scale", p_id, true); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void QuickSettingsDialog::_network_mode_selected(int p_id) { | 
					
						
							|  |  |  | 	_set_setting_value("network/connection/network_mode", p_id); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-22 22:44:45 +01:00
										 |  |  | void QuickSettingsDialog::_directory_naming_convention_selected(int p_id) { | 
					
						
							|  |  |  | 	_set_setting_value("project_manager/directory_naming_convention", p_id); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-30 17:35:46 +01:00
										 |  |  | 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(); | 
					
						
							|  |  |  | 	EditorSettings::get_singleton()->save(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (p_restart_required) { | 
					
						
							|  |  |  | 		restart_required_label->show(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if (!restart_required_button) { | 
					
						
							|  |  |  | 			restart_required_button = add_button(TTR("Restart Now"), !GLOBAL_GET("gui/common/swap_cancel_ok")); | 
					
						
							| 
									
										
										
										
											2024-05-14 09:40:21 +02:00
										 |  |  | 			restart_required_button->connect(SceneStringName(pressed), callable_mp(this, &QuickSettingsDialog::_request_restart)); | 
					
						
							| 
									
										
										
										
											2024-01-30 17:35:46 +01:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void QuickSettingsDialog::_request_restart() { | 
					
						
							|  |  |  | 	emit_signal("restart_required"); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void QuickSettingsDialog::update_size_limits(const Size2 &p_max_popup_size) { | 
					
						
							| 
									
										
										
										
											2024-08-02 12:40:27 -07:00
										 |  |  | #ifndef ANDROID_ENABLED
 | 
					
						
							| 
									
										
										
										
											2024-01-30 17:35:46 +01:00
										 |  |  | 	language_option_button->get_popup()->set_max_size(p_max_popup_size); | 
					
						
							| 
									
										
										
										
											2024-08-02 12:40:27 -07:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2024-01-30 17:35:46 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void QuickSettingsDialog::_notification(int p_what) { | 
					
						
							|  |  |  | 	switch (p_what) { | 
					
						
							|  |  |  | 		case NOTIFICATION_THEME_CHANGED: { | 
					
						
							| 
									
										
										
										
											2024-05-14 15:50:53 +02:00
										 |  |  | 			settings_list_panel->add_theme_style_override(SceneStringName(panel), get_theme_stylebox(SNAME("Background"), EditorStringName(EditorStyles))); | 
					
						
							| 
									
										
										
										
											2024-01-30 17:35:46 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-14 15:57:29 +02:00
										 |  |  | 			restart_required_label->add_theme_color_override(SceneStringName(font_color), get_theme_color(SNAME("warning_color"), EditorStringName(Editor))); | 
					
						
							|  |  |  | 			custom_theme_label->add_theme_color_override(SceneStringName(font_color), get_theme_color(SNAME("font_placeholder_color"), EditorStringName(Editor))); | 
					
						
							| 
									
										
										
										
											2024-01-30 17:35:46 +01:00
										 |  |  | 		} break; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		case NOTIFICATION_VISIBILITY_CHANGED: { | 
					
						
							|  |  |  | 			if (is_visible()) { | 
					
						
							|  |  |  | 				_update_current_values(); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} break; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void QuickSettingsDialog::_bind_methods() { | 
					
						
							|  |  |  | 	ADD_SIGNAL(MethodInfo("restart_required")); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | QuickSettingsDialog::QuickSettingsDialog() { | 
					
						
							|  |  |  | 	set_title(TTR("Quick Settings")); | 
					
						
							|  |  |  | 	set_ok_button_text(TTR("Close")); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	VBoxContainer *main_vbox = memnew(VBoxContainer); | 
					
						
							|  |  |  | 	add_child(main_vbox); | 
					
						
							|  |  |  | 	main_vbox->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// Settings grid.
 | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		_fetch_setting_values(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		settings_list_panel = memnew(PanelContainer); | 
					
						
							|  |  |  | 		main_vbox->add_child(settings_list_panel); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		settings_list = memnew(VBoxContainer); | 
					
						
							|  |  |  | 		settings_list_panel->add_child(settings_list); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-02 12:40:27 -07:00
										 |  |  | #ifndef ANDROID_ENABLED
 | 
					
						
							| 
									
										
										
										
											2024-01-30 17:35:46 +01:00
										 |  |  | 		// Language options.
 | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			language_option_button = memnew(OptionButton); | 
					
						
							|  |  |  | 			language_option_button->set_fit_to_longest_item(false); | 
					
						
							| 
									
										
										
										
											2024-05-14 14:21:31 +02:00
										 |  |  | 			language_option_button->connect(SceneStringName(item_selected), callable_mp(this, &QuickSettingsDialog::_language_selected)); | 
					
						
							| 
									
										
										
										
											2024-01-30 17:35:46 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			for (int i = 0; i < editor_languages.size(); i++) { | 
					
						
							|  |  |  | 				const String &lang_value = editor_languages[i]; | 
					
						
							|  |  |  | 				String lang_name = TranslationServer::get_singleton()->get_locale_name(lang_value); | 
					
						
							|  |  |  | 				language_option_button->add_item(vformat("[%s] %s", lang_value, lang_name), i); | 
					
						
							|  |  |  | 				language_option_button->set_item_metadata(i, lang_value); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			_add_setting_control(TTR("Language"), language_option_button); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2024-08-02 12:40:27 -07:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2024-01-30 17:35:46 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		// Theme options.
 | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			theme_option_button = memnew(OptionButton); | 
					
						
							|  |  |  | 			theme_option_button->set_fit_to_longest_item(false); | 
					
						
							| 
									
										
										
										
											2024-05-14 14:21:31 +02:00
										 |  |  | 			theme_option_button->connect(SceneStringName(item_selected), callable_mp(this, &QuickSettingsDialog::_theme_selected)); | 
					
						
							| 
									
										
										
										
											2024-01-30 17:35:46 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			for (int i = 0; i < editor_themes.size(); i++) { | 
					
						
							|  |  |  | 				const String &theme_value = editor_themes[i]; | 
					
						
							|  |  |  | 				theme_option_button->add_item(theme_value, i); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			_add_setting_control(TTR("Interface Theme"), theme_option_button); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			custom_theme_label = memnew(Label(TTR("Custom preset can be further configured in the editor."))); | 
					
						
							|  |  |  | 			custom_theme_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_RIGHT); | 
					
						
							|  |  |  | 			custom_theme_label->set_custom_minimum_size(Size2(220, 0) * EDSCALE); | 
					
						
							|  |  |  | 			custom_theme_label->set_autowrap_mode(TextServer::AUTOWRAP_WORD); | 
					
						
							|  |  |  | 			custom_theme_label->set_h_size_flags(Control::SIZE_EXPAND_FILL); | 
					
						
							|  |  |  | 			custom_theme_label->set_stretch_ratio(2.0); | 
					
						
							|  |  |  | 			custom_theme_label->hide(); | 
					
						
							|  |  |  | 			settings_list->add_child(custom_theme_label); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// Scale options.
 | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			scale_option_button = memnew(OptionButton); | 
					
						
							|  |  |  | 			scale_option_button->set_fit_to_longest_item(false); | 
					
						
							| 
									
										
										
										
											2024-05-14 14:21:31 +02:00
										 |  |  | 			scale_option_button->connect(SceneStringName(item_selected), callable_mp(this, &QuickSettingsDialog::_scale_selected)); | 
					
						
							| 
									
										
										
										
											2024-01-30 17:35:46 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			for (int i = 0; i < editor_scales.size(); i++) { | 
					
						
							|  |  |  | 				const String &scale_value = editor_scales[i]; | 
					
						
							|  |  |  | 				scale_option_button->add_item(scale_value, i); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			_add_setting_control(TTR("Display Scale"), scale_option_button); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// Network mode options.
 | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			network_mode_option_button = memnew(OptionButton); | 
					
						
							|  |  |  | 			network_mode_option_button->set_fit_to_longest_item(false); | 
					
						
							| 
									
										
										
										
											2024-05-14 14:21:31 +02:00
										 |  |  | 			network_mode_option_button->connect(SceneStringName(item_selected), callable_mp(this, &QuickSettingsDialog::_network_mode_selected)); | 
					
						
							| 
									
										
										
										
											2024-01-30 17:35:46 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			for (int i = 0; i < editor_network_modes.size(); i++) { | 
					
						
							|  |  |  | 				const String &network_mode_value = editor_network_modes[i]; | 
					
						
							|  |  |  | 				network_mode_option_button->add_item(network_mode_value, i); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			_add_setting_control(TTR("Network Mode"), network_mode_option_button); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-22 22:44:45 +01:00
										 |  |  | 		// 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); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-30 17:35:46 +01:00
										 |  |  | 		_update_current_values(); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// Restart required panel.
 | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		restart_required_label = memnew(Label(TTR("Settings changed! The project manager must be restarted for changes to take effect."))); | 
					
						
							|  |  |  | 		restart_required_label->set_custom_minimum_size(Size2(560, 0) * EDSCALE); | 
					
						
							|  |  |  | 		restart_required_label->set_autowrap_mode(TextServer::AUTOWRAP_WORD); | 
					
						
							|  |  |  | 		restart_required_label->set_h_size_flags(Control::SIZE_EXPAND_FILL); | 
					
						
							|  |  |  | 		restart_required_label->hide(); | 
					
						
							|  |  |  | 		main_vbox->add_child(restart_required_label); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } |