Merge pull request #15458 from volzhs/fix-editor-settings-1

Fix editor setting value is back to default
This commit is contained in:
Rémi Verschelde 2018-01-08 10:55:09 +01:00 committed by GitHub
commit 8f814e44bc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 67 additions and 34 deletions

View file

@ -992,13 +992,17 @@ void EditorSettings::raise_order(const String &p_setting) {
props[p_setting].order = ++last_order;
}
void EditorSettings::set_initial_value(const StringName &p_setting, const Variant &p_value) {
void EditorSettings::set_initial_value(const StringName &p_setting, const Variant &p_value, bool update_current) {
_THREAD_SAFE_METHOD_
if (!props.has(p_setting))
return;
_initial_set(p_setting, p_value);
props[p_setting].initial = p_value;
props[p_setting].has_default_value = true;
if (update_current) {
set(p_setting, p_value);
}
}
Variant _EDITOR_DEF(const String &p_setting, const Variant &p_default) {

View file

@ -145,7 +145,7 @@ public:
bool has_setting(const String &p_setting) const;
void erase(const String &p_setting);
void raise_order(const String &p_setting);
void set_initial_value(const StringName &p_setting, const Variant &p_value);
void set_initial_value(const StringName &p_setting, const Variant &p_value, bool update_current = false);
void set_manually(const StringName &p_setting, const Variant &p_value, bool p_emit_signal = false) {
if (p_emit_signal)
_set(p_setting, p_value);

View file

@ -1063,38 +1063,67 @@ Ref<Theme> create_editor_theme(const Ref<Theme> 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_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);
setting->set_initial_value("text_editor/highlighting/symbol_color", symbol_color, true);
setting->set_initial_value("text_editor/highlighting/keyword_color", keyword_color, true);
setting->set_initial_value("text_editor/highlighting/base_type_color", basetype_color, true);
setting->set_initial_value("text_editor/highlighting/engine_type_color", type_color, true);
setting->set_initial_value("text_editor/highlighting/comment_color", comment_color, true);
setting->set_initial_value("text_editor/highlighting/string_color", string_color, true);
setting->set_initial_value("text_editor/highlighting/background_color", background_color, true);
setting->set_initial_value("text_editor/highlighting/completion_background_color", completion_background_color, true);
setting->set_initial_value("text_editor/highlighting/completion_selected_color", completion_selected_color, true);
setting->set_initial_value("text_editor/highlighting/completion_existing_color", completion_existing_color, true);
setting->set_initial_value("text_editor/highlighting/completion_scroll_color", completion_scroll_color, true);
setting->set_initial_value("text_editor/highlighting/completion_font_color", completion_font_color, true);
setting->set_initial_value("text_editor/highlighting/text_color", text_color, true);
setting->set_initial_value("text_editor/highlighting/line_number_color", line_number_color, true);
setting->set_initial_value("text_editor/highlighting/caret_color", caret_color, true);
setting->set_initial_value("text_editor/highlighting/caret_background_color", caret_background_color, true);
setting->set_initial_value("text_editor/highlighting/text_selected_color", text_selected_color, true);
setting->set_initial_value("text_editor/highlighting/selection_color", selection_color, true);
setting->set_initial_value("text_editor/highlighting/brace_mismatch_color", brace_mismatch_color, true);
setting->set_initial_value("text_editor/highlighting/current_line_color", current_line_color, true);
setting->set_initial_value("text_editor/highlighting/line_length_guideline_color", line_length_guideline_color, true);
setting->set_initial_value("text_editor/highlighting/word_highlighted_color", word_highlighted_color, true);
setting->set_initial_value("text_editor/highlighting/number_color", number_color, true);
setting->set_initial_value("text_editor/highlighting/function_color", function_color, true);
setting->set_initial_value("text_editor/highlighting/member_variable_color", member_variable_color, true);
setting->set_initial_value("text_editor/highlighting/mark_color", mark_color, true);
setting->set_initial_value("text_editor/highlighting/breakpoint_color", breakpoint_color, true);
setting->set_initial_value("text_editor/highlighting/code_folding_color", code_folding_color, true);
setting->set_initial_value("text_editor/highlighting/search_result_color", search_result_color, true);
setting->set_initial_value("text_editor/highlighting/search_result_border_color", search_result_border_color, true);
} else if (text_editor_color_theme == "Default") {
setting->load_text_editor_theme();
setting->set_initial_value("text_editor/highlighting/symbol_color", Color::html("badfff"), true);
setting->set_initial_value("text_editor/highlighting/keyword_color", Color::html("ffffb3"), true);
setting->set_initial_value("text_editor/highlighting/base_type_color", Color::html("a4ffd4"), true);
setting->set_initial_value("text_editor/highlighting/engine_type_color", Color::html("83d3ff"), true);
setting->set_initial_value("text_editor/highlighting/comment_color", Color::html("676767"), true);
setting->set_initial_value("text_editor/highlighting/string_color", Color::html("ef6ebe"), true);
setting->set_initial_value("text_editor/highlighting/background_color", Color::html("3b000000"), true);
setting->set_initial_value("text_editor/highlighting/completion_background_color", Color::html("2C2A32"), true);
setting->set_initial_value("text_editor/highlighting/completion_selected_color", Color::html("434244"), true);
setting->set_initial_value("text_editor/highlighting/completion_existing_color", Color::html("21dfdfdf"), true);
setting->set_initial_value("text_editor/highlighting/completion_scroll_color", Color::html("ffffff"), true);
setting->set_initial_value("text_editor/highlighting/completion_font_color", Color::html("aaaaaa"), true);
setting->set_initial_value("text_editor/highlighting/text_color", Color::html("aaaaaa"), true);
setting->set_initial_value("text_editor/highlighting/line_number_color", Color::html("66aaaaaa"), true);
setting->set_initial_value("text_editor/highlighting/caret_color", Color::html("aaaaaa"), true);
setting->set_initial_value("text_editor/highlighting/caret_background_color", Color::html("000000"), true);
setting->set_initial_value("text_editor/highlighting/text_selected_color", Color::html("000000"), true);
setting->set_initial_value("text_editor/highlighting/selection_color", Color::html("6ca9c2"), true);
setting->set_initial_value("text_editor/highlighting/brace_mismatch_color", Color(1, 0.2, 0.2), true);
setting->set_initial_value("text_editor/highlighting/current_line_color", Color(0.3, 0.5, 0.8, 0.15), true);
setting->set_initial_value("text_editor/highlighting/line_length_guideline_color", Color(0.3, 0.5, 0.8, 0.1), true);
setting->set_initial_value("text_editor/highlighting/word_highlighted_color", Color(0.8, 0.9, 0.9, 0.15), true);
setting->set_initial_value("text_editor/highlighting/number_color", Color::html("EB9532"), true);
setting->set_initial_value("text_editor/highlighting/function_color", Color::html("66a2ce"), true);
setting->set_initial_value("text_editor/highlighting/member_variable_color", Color::html("e64e59"), true);
setting->set_initial_value("text_editor/highlighting/mark_color", Color(1.0, 0.4, 0.4, 0.4), true);
setting->set_initial_value("text_editor/highlighting/breakpoint_color", Color(0.8, 0.8, 0.4, 0.2), true);
setting->set_initial_value("text_editor/highlighting/code_folding_color", Color(0.8, 0.8, 0.8, 0.8), true);
setting->set_initial_value("text_editor/highlighting/search_result_color", Color(0.05, 0.25, 0.05, 1), true);
setting->set_initial_value("text_editor/highlighting/search_result_border_color", Color(0.1, 0.45, 0.1, 1), true);
}
return theme;