diff options
Diffstat (limited to 'editor/editor_settings.cpp')
-rw-r--r-- | editor/editor_settings.cpp | 79 |
1 files changed, 71 insertions, 8 deletions
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index f230a9b435..52ff7e3c19 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -31,18 +31,22 @@ #include "editor_settings.h" #include "core/config/project_settings.h" +#include "core/input/input_event.h" #include "core/input/input_map.h" +#include "core/input/shortcut.h" #include "core/io/certs_compressed.gen.h" -#include "core/io/config_file.h" #include "core/io/dir_access.h" #include "core/io/file_access.h" #include "core/io/ip.h" #include "core/io/resource_loader.h" #include "core/io/resource_saver.h" +#include "core/object/class_db.h" #include "core/os/keyboard.h" #include "core/os/os.h" +#include "core/string/translation.h" #include "core/version.h" #include "editor/editor_node.h" +#include "editor/editor_paths.h" #include "editor/editor_translation.h" #include "scene/main/node.h" #include "scene/main/scene_tree.h" @@ -59,6 +63,7 @@ bool EditorSettings::_set(const StringName &p_name, const Variant &p_value) { bool changed = _set_only(p_name, p_value); if (changed) { + changed_settings.insert(p_name); emit_signal(SNAME("settings_changed")); } return true; @@ -415,6 +420,8 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { #else EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "interface/editor/font_hinting", 0, "Auto (Light),None,Light,Normal") #endif + EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "interface/editor/font_subpixel_positioning", 1, "Disabled,Auto,One half of a pixel,One quarter of a pixel") + EDITOR_SETTING(Variant::STRING, PROPERTY_HINT_GLOBAL_FILE, "interface/editor/main_font", "", "*.ttf,*.otf") EDITOR_SETTING(Variant::STRING, PROPERTY_HINT_GLOBAL_FILE, "interface/editor/main_font_bold", "", "*.ttf,*.otf") EDITOR_SETTING(Variant::STRING, PROPERTY_HINT_GLOBAL_FILE, "interface/editor/code_font", "", "*.ttf,*.otf") @@ -547,6 +554,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { _initial_set("text_editor/behavior/files/autosave_interval_secs", 0); _initial_set("text_editor/behavior/files/restore_scripts_on_load", true); _initial_set("text_editor/behavior/files/convert_indent_on_save", true); + _initial_set("text_editor/behavior/files/auto_reload_scripts_on_external_change", false); // Script list _initial_set("text_editor/script_list/show_members_overview", true); @@ -579,6 +587,9 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { // Use a similar color to the 2D editor selection. EDITOR_SETTING_USAGE(Variant::COLOR, PROPERTY_HINT_NONE, "editors/3d/selection_box_color", Color(1.0, 0.5, 0), "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED) + _initial_set("editors/3d_gizmos/gizmo_colors/instantiated", Color(0.7, 0.7, 0.7, 0.6)); + _initial_set("editors/3d_gizmos/gizmo_colors/joint", Color(0.5, 0.8, 1)); + _initial_set("editors/3d_gizmos/gizmo_colors/shape", Color(0.5, 0.7, 1)); // If a line is a multiple of this, it uses the primary grid color. // Use a power of 2 value by default as it's more common to use powers of 2 in level design. @@ -702,6 +713,9 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { // SSL EDITOR_SETTING(Variant::STRING, PROPERTY_HINT_GLOBAL_FILE, "network/ssl/editor_ssl_certificates", _SYSTEM_CERTS_PATH, "*.crt,*.pem") + // Profiler + _initial_set("debugger/profiler_frame_history_size", 600); + /* Extra config */ EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "project_manager/sorting_order", 0, "Name,Path,Last Edited") @@ -741,7 +755,7 @@ void EditorSettings::_load_godot2_text_editor_theme() { _initial_set("text_editor/theme/highlighting/completion_background_color", Color(0.17, 0.16, 0.2)); _initial_set("text_editor/theme/highlighting/completion_selected_color", Color(0.26, 0.26, 0.27)); _initial_set("text_editor/theme/highlighting/completion_existing_color", Color(0.87, 0.87, 0.87, 0.13)); - _initial_set("text_editor/theme/highlighting/completion_scroll_color", Color(1, 1, 1)); + _initial_set("text_editor/theme/highlighting/completion_scroll_color", Color(1, 1, 1, 0.29)); _initial_set("text_editor/theme/highlighting/completion_font_color", Color(0.67, 0.67, 0.67)); _initial_set("text_editor/theme/highlighting/text_color", Color(0.67, 0.67, 0.67)); _initial_set("text_editor/theme/highlighting/line_number_color", Color(0.67, 0.67, 0.67, 0.4)); @@ -845,7 +859,7 @@ void EditorSettings::create() { singleton->setup_language(); singleton->setup_network(); - singleton->load_favorites(); + singleton->load_favorites_and_recent_dirs(); singleton->list_text_editor_themes(); return; @@ -935,10 +949,34 @@ void EditorSettings::save() { if (err != OK) { ERR_PRINT("Error saving editor settings to " + singleton->config_file_path); } else { + singleton->changed_settings.clear(); print_verbose("EditorSettings: Save OK!"); } } +Array EditorSettings::get_changed_settings() const { + Array arr; + for (const String &setting : changed_settings) { + arr.push_back(setting); + } + + return arr; +} + +bool EditorSettings::check_changed_settings_in_group(const String &p_setting_prefix) const { + for (const String &setting : changed_settings) { + if (setting.begins_with(p_setting_prefix)) { + return true; + } + } + + return false; +} + +void EditorSettings::mark_setting_changed(const String &p_setting) { + changed_settings.insert(p_setting); +} + void EditorSettings::destroy() { if (!singleton.ptr()) { return; @@ -1103,7 +1141,13 @@ Variant EditorSettings::get_project_metadata(const String &p_section, const Stri void EditorSettings::set_favorites(const Vector<String> &p_favorites) { favorites = p_favorites; - FileAccess *f = FileAccess::open(get_project_settings_dir().plus_file("favorites"), FileAccess::WRITE); + String favorites_file; + if (Engine::get_singleton()->is_project_manager_hint()) { + favorites_file = EditorPaths::get_singleton()->get_config_dir().plus_file("favorite_dirs"); + } else { + favorites_file = get_project_settings_dir().plus_file("favorites"); + } + FileAccess *f = FileAccess::open(favorites_file, FileAccess::WRITE); if (f) { for (int i = 0; i < favorites.size(); i++) { f->store_line(favorites[i]); @@ -1118,7 +1162,13 @@ Vector<String> EditorSettings::get_favorites() const { void EditorSettings::set_recent_dirs(const Vector<String> &p_recent_dirs) { recent_dirs = p_recent_dirs; - FileAccess *f = FileAccess::open(get_project_settings_dir().plus_file("recent_dirs"), FileAccess::WRITE); + String recent_dirs_file; + if (Engine::get_singleton()->is_project_manager_hint()) { + recent_dirs_file = EditorPaths::get_singleton()->get_config_dir().plus_file("recent_dirs"); + } else { + recent_dirs_file = get_project_settings_dir().plus_file("recent_dirs"); + } + FileAccess *f = FileAccess::open(recent_dirs_file, FileAccess::WRITE); if (f) { for (int i = 0; i < recent_dirs.size(); i++) { f->store_line(recent_dirs[i]); @@ -1131,8 +1181,17 @@ Vector<String> EditorSettings::get_recent_dirs() const { return recent_dirs; } -void EditorSettings::load_favorites() { - FileAccess *f = FileAccess::open(get_project_settings_dir().plus_file("favorites"), FileAccess::READ); +void EditorSettings::load_favorites_and_recent_dirs() { + String favorites_file; + String recent_dirs_file; + if (Engine::get_singleton()->is_project_manager_hint()) { + favorites_file = EditorPaths::get_singleton()->get_config_dir().plus_file("favorite_dirs"); + recent_dirs_file = EditorPaths::get_singleton()->get_config_dir().plus_file("recent_dirs"); + } else { + favorites_file = get_project_settings_dir().plus_file("favorites"); + recent_dirs_file = get_project_settings_dir().plus_file("recent_dirs"); + } + FileAccess *f = FileAccess::open(favorites_file, FileAccess::READ); if (f) { String line = f->get_line().strip_edges(); while (!line.is_empty()) { @@ -1142,7 +1201,7 @@ void EditorSettings::load_favorites() { memdelete(f); } - f = FileAccess::open(get_project_settings_dir().plus_file("recent_dirs"), FileAccess::READ); + f = FileAccess::open(recent_dirs_file, FileAccess::READ); if (f) { String line = f->get_line().strip_edges(); while (!line.is_empty()) { @@ -1594,6 +1653,10 @@ void EditorSettings::_bind_methods() { ClassDB::bind_method(D_METHOD("set_builtin_action_override", "name", "actions_list"), &EditorSettings::set_builtin_action_override); + ClassDB::bind_method(D_METHOD("check_changed_settings_in_group", "setting_prefix"), &EditorSettings::check_changed_settings_in_group); + ClassDB::bind_method(D_METHOD("get_changed_settings"), &EditorSettings::get_changed_settings); + ClassDB::bind_method(D_METHOD("mark_setting_changed", "setting"), &EditorSettings::mark_setting_changed); + ADD_SIGNAL(MethodInfo("settings_changed")); BIND_CONSTANT(NOTIFICATION_EDITOR_SETTINGS_CHANGED); |