From 6ad43757adbfad0163e639e8425aeaddc6e38018 Mon Sep 17 00:00:00 2001 From: volzhs Date: Sat, 6 Jan 2018 20:40:43 +0900 Subject: [PATCH] Fix editor settings weird behavior --- editor/editor_settings.cpp | 31 ++++++++----- editor/editor_settings.h | 8 +++- editor/editor_themes.cpp | 91 +++++++++++++------------------------- 3 files changed, 58 insertions(+), 72 deletions(-) diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index be03e24eeef..bcdd2322600 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -54,7 +54,18 @@ Ref EditorSettings::singleton = NULL; // Properties -bool EditorSettings::_set(const StringName &p_name, const Variant &p_value, bool p_emit_signal) { +bool EditorSettings::_set(const StringName &p_name, const Variant &p_value) { + + _THREAD_SAFE_METHOD_ + + bool changed = _set_only(p_name, p_value); + if (changed) { + emit_signal("settings_changed"); + } + return true; +} + +bool EditorSettings::_set_only(const StringName &p_name, const Variant &p_value) { _THREAD_SAFE_METHOD_ @@ -73,7 +84,7 @@ bool EditorSettings::_set(const StringName &p_name, const Variant &p_value, bool add_shortcut(name, sc); } - return true; + return false; } bool changed = false; @@ -102,10 +113,7 @@ bool EditorSettings::_set(const StringName &p_name, const Variant &p_value, bool } } - if (changed && p_emit_signal) { - emit_signal("settings_changed"); - } - return true; + return changed; } bool EditorSettings::_get(const StringName &p_name, Variant &r_ret) const { @@ -370,6 +378,8 @@ void EditorSettings::_load_defaults(Ref p_extra_config) { _initial_set("text_editor/theme/font", ""); hints["text_editor/theme/font"] = PropertyInfo(Variant::STRING, "text_editor/theme/font", PROPERTY_HINT_GLOBAL_FILE, "*.font,*.tres,*.res"); _initial_set("text_editor/completion/auto_brace_complete", false); + _initial_set("text_editor/completion/put_callhint_tooltip_below_current_line", true); + _initial_set("text_editor/completion/callhint_tooltip_offset", Vector2()); _initial_set("text_editor/files/restore_scripts_on_load", true); _initial_set("text_editor/completion/complete_file_paths", true); _initial_set("text_editor/files/maximum_recent_files", 20); @@ -988,8 +998,7 @@ void EditorSettings::set_initial_value(const StringName &p_setting, const Varian if (!props.has(p_setting)) return; - props[p_setting].initial = p_value; - props[p_setting].has_default_value = true; + _initial_set(p_setting, p_value); } Variant _EDITOR_DEF(const String &p_setting, const Variant &p_default) { @@ -1174,8 +1183,10 @@ void EditorSettings::list_text_editor_themes() { void EditorSettings::load_text_editor_theme() { if (get("text_editor/theme/color_theme") == "Default" || get("text_editor/theme/color_theme") == "Adaptive" || get("text_editor/theme/color_theme") == "Custom") { - _load_default_text_editor_theme(); // sorry for "Settings changed" console spam - return; + if (get("text_editor/theme/color_theme") == "Default") { + _load_default_text_editor_theme(); + } + return; // sorry for "Settings changed" console spam } String theme_path = get_text_editor_themes_dir().plus_file((String)get("text_editor/theme/color_theme") + ".tet"); diff --git a/editor/editor_settings.h b/editor/editor_settings.h index 0a20212ccd5..5fc49de0a74 100644 --- a/editor/editor_settings.h +++ b/editor/editor_settings.h @@ -111,7 +111,8 @@ private: bool save_changed_setting; bool optimize_save; //do not save stuff that came from config but was not set from engine - bool _set(const StringName &p_name, const Variant &p_value, bool p_emit_signal = true); + bool _set(const StringName &p_name, const Variant &p_value); + bool _set_only(const StringName &p_name, const Variant &p_value); bool _get(const StringName &p_name, Variant &r_ret) const; void _initial_set(const StringName &p_name, const Variant &p_value); void _get_property_list(List *p_list) const; @@ -146,7 +147,10 @@ public: void raise_order(const String &p_setting); void set_initial_value(const StringName &p_setting, const Variant &p_value); void set_manually(const StringName &p_setting, const Variant &p_value, bool p_emit_signal = false) { - _set(p_setting, p_value, p_emit_signal); + if (p_emit_signal) + _set(p_setting, p_value); + else + _set_only(p_setting, p_value); } bool property_can_revert(const String &p_setting); Variant property_get_revert(const String &p_setting); diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index ea114472a8f..0ebcef8e5e8 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -1063,67 +1063,38 @@ Ref create_editor_theme(const Ref p_theme) { EditorSettings *setting = EditorSettings::get_singleton(); String text_editor_color_theme = setting->get("text_editor/theme/color_theme"); if (text_editor_color_theme == "Adaptive") { - setting->set_manually("text_editor/highlighting/symbol_color", symbol_color); - setting->set_manually("text_editor/highlighting/keyword_color", keyword_color); - setting->set_manually("text_editor/highlighting/base_type_color", basetype_color); - setting->set_manually("text_editor/highlighting/engine_type_color", type_color); - setting->set_manually("text_editor/highlighting/comment_color", comment_color); - setting->set_manually("text_editor/highlighting/string_color", string_color); - setting->set_manually("text_editor/highlighting/background_color", background_color); - setting->set_manually("text_editor/highlighting/completion_background_color", completion_background_color); - setting->set_manually("text_editor/highlighting/completion_selected_color", completion_selected_color); - setting->set_manually("text_editor/highlighting/completion_existing_color", completion_existing_color); - setting->set_manually("text_editor/highlighting/completion_scroll_color", completion_scroll_color); - setting->set_manually("text_editor/highlighting/completion_font_color", completion_font_color); - setting->set_manually("text_editor/highlighting/text_color", text_color); - setting->set_manually("text_editor/highlighting/line_number_color", line_number_color); - setting->set_manually("text_editor/highlighting/caret_color", caret_color); - setting->set_manually("text_editor/highlighting/caret_background_color", caret_background_color); - setting->set_manually("text_editor/highlighting/text_selected_color", text_selected_color); - setting->set_manually("text_editor/highlighting/selection_color", selection_color); - setting->set_manually("text_editor/highlighting/brace_mismatch_color", brace_mismatch_color); - setting->set_manually("text_editor/highlighting/current_line_color", current_line_color); - setting->set_manually("text_editor/highlighting/line_length_guideline_color", line_length_guideline_color); - setting->set_manually("text_editor/highlighting/word_highlighted_color", word_highlighted_color); - setting->set_manually("text_editor/highlighting/number_color", number_color); - setting->set_manually("text_editor/highlighting/function_color", function_color); - setting->set_manually("text_editor/highlighting/member_variable_color", member_variable_color); - setting->set_manually("text_editor/highlighting/mark_color", mark_color); - setting->set_manually("text_editor/highlighting/breakpoint_color", breakpoint_color); - setting->set_manually("text_editor/highlighting/code_folding_color", code_folding_color); - setting->set_manually("text_editor/highlighting/search_result_color", search_result_color); - setting->set_manually("text_editor/highlighting/search_result_border_color", search_result_border_color); + setting->set_initial_value("text_editor/highlighting/symbol_color", symbol_color); + setting->set_initial_value("text_editor/highlighting/keyword_color", keyword_color); + setting->set_initial_value("text_editor/highlighting/base_type_color", basetype_color); + setting->set_initial_value("text_editor/highlighting/engine_type_color", type_color); + setting->set_initial_value("text_editor/highlighting/comment_color", comment_color); + setting->set_initial_value("text_editor/highlighting/string_color", string_color); + setting->set_initial_value("text_editor/highlighting/background_color", background_color); + setting->set_initial_value("text_editor/highlighting/completion_background_color", completion_background_color); + setting->set_initial_value("text_editor/highlighting/completion_selected_color", completion_selected_color); + setting->set_initial_value("text_editor/highlighting/completion_existing_color", completion_existing_color); + setting->set_initial_value("text_editor/highlighting/completion_scroll_color", completion_scroll_color); + setting->set_initial_value("text_editor/highlighting/completion_font_color", completion_font_color); + setting->set_initial_value("text_editor/highlighting/text_color", text_color); + setting->set_initial_value("text_editor/highlighting/line_number_color", line_number_color); + setting->set_initial_value("text_editor/highlighting/caret_color", caret_color); + setting->set_initial_value("text_editor/highlighting/caret_background_color", caret_background_color); + setting->set_initial_value("text_editor/highlighting/text_selected_color", text_selected_color); + setting->set_initial_value("text_editor/highlighting/selection_color", selection_color); + setting->set_initial_value("text_editor/highlighting/brace_mismatch_color", brace_mismatch_color); + setting->set_initial_value("text_editor/highlighting/current_line_color", current_line_color); + setting->set_initial_value("text_editor/highlighting/line_length_guideline_color", line_length_guideline_color); + setting->set_initial_value("text_editor/highlighting/word_highlighted_color", word_highlighted_color); + setting->set_initial_value("text_editor/highlighting/number_color", number_color); + setting->set_initial_value("text_editor/highlighting/function_color", function_color); + setting->set_initial_value("text_editor/highlighting/member_variable_color", member_variable_color); + setting->set_initial_value("text_editor/highlighting/mark_color", mark_color); + setting->set_initial_value("text_editor/highlighting/breakpoint_color", breakpoint_color); + setting->set_initial_value("text_editor/highlighting/code_folding_color", code_folding_color); + setting->set_initial_value("text_editor/highlighting/search_result_color", search_result_color); + setting->set_initial_value("text_editor/highlighting/search_result_border_color", search_result_border_color); } else if (text_editor_color_theme == "Default") { - setting->set_manually("text_editor/highlighting/symbol_color", Color::html("badfff")); - setting->set_manually("text_editor/highlighting/keyword_color", Color::html("ffffb3")); - setting->set_manually("text_editor/highlighting/base_type_color", Color::html("a4ffd4")); - setting->set_manually("text_editor/highlighting/engine_type_color", Color::html("83d3ff")); - setting->set_manually("text_editor/highlighting/comment_color", Color::html("676767")); - setting->set_manually("text_editor/highlighting/string_color", Color::html("ef6ebe")); - setting->set_manually("text_editor/highlighting/background_color", Color::html("3b000000")); - setting->set_manually("text_editor/highlighting/completion_background_color", Color::html("2C2A32")); - setting->set_manually("text_editor/highlighting/completion_selected_color", Color::html("434244")); - setting->set_manually("text_editor/highlighting/completion_existing_color", Color::html("21dfdfdf")); - setting->set_manually("text_editor/highlighting/completion_scroll_color", Color::html("ffffff")); - setting->set_manually("text_editor/highlighting/completion_font_color", Color::html("aaaaaa")); - setting->set_manually("text_editor/highlighting/text_color", Color::html("aaaaaa")); - setting->set_manually("text_editor/highlighting/line_number_color", Color::html("66aaaaaa")); - setting->set_manually("text_editor/highlighting/caret_color", Color::html("aaaaaa")); - setting->set_manually("text_editor/highlighting/caret_background_color", Color::html("000000")); - setting->set_manually("text_editor/highlighting/text_selected_color", Color::html("000000")); - setting->set_manually("text_editor/highlighting/selection_color", Color::html("6ca9c2")); - setting->set_manually("text_editor/highlighting/brace_mismatch_color", Color(1, 0.2, 0.2)); - setting->set_manually("text_editor/highlighting/current_line_color", Color(0.3, 0.5, 0.8, 0.15)); - setting->set_manually("text_editor/highlighting/line_length_guideline_color", Color(0.3, 0.5, 0.8, 0.1)); - setting->set_manually("text_editor/highlighting/word_highlighted_color", Color(0.8, 0.9, 0.9, 0.15)); - setting->set_manually("text_editor/highlighting/number_color", Color::html("EB9532")); - setting->set_manually("text_editor/highlighting/function_color", Color::html("66a2ce")); - setting->set_manually("text_editor/highlighting/member_variable_color", Color::html("e64e59")); - setting->set_manually("text_editor/highlighting/mark_color", Color(1.0, 0.4, 0.4, 0.4)); - setting->set_manually("text_editor/highlighting/breakpoint_color", Color(0.8, 0.8, 0.4, 0.2)); - setting->set_manually("text_editor/highlighting/code_folding_color", Color(0.8, 0.8, 0.8, 0.8)); - setting->set_manually("text_editor/highlighting/search_result_color", Color(0.05, 0.25, 0.05, 1)); - setting->set_manually("text_editor/highlighting/search_result_border_color", Color(0.1, 0.45, 0.1, 1)); + setting->load_text_editor_theme(); } return theme;