summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaulb23 <p_batty@hotmail.co.uk>2018-06-10 13:06:24 +0100
committerPaulb23 <p_batty@hotmail.co.uk>2018-06-13 18:21:44 +0100
commit8f7e791ab65536b53889c3d0de8ec9268d658a7d (patch)
treef4fd8af462e119cba0400a7aa6f249cfbe5419db
parentea5512fc25bd2db55c2bf7f5e1d76a8c3f1ce051 (diff)
Theme saving no longer hard coded
-rw-r--r--editor/editor_settings.cpp45
1 files changed, 11 insertions, 34 deletions
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index eb6dd626f9..98bdef2fc1 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -607,40 +607,17 @@ void EditorSettings::_load_default_text_editor_theme() {
bool EditorSettings::_save_text_editor_theme(String p_file) {
String theme_section = "color_theme";
Ref<ConfigFile> cf = memnew(ConfigFile); // hex is better?
- cf->set_value(theme_section, "background_color", ((Color)get("text_editor/highlighting/background_color")).to_html());
- cf->set_value(theme_section, "completion_background_color", ((Color)get("text_editor/highlighting/completion_background_color")).to_html());
- cf->set_value(theme_section, "completion_selected_color", ((Color)get("text_editor/highlighting/completion_selected_color")).to_html());
- cf->set_value(theme_section, "completion_existing_color", ((Color)get("text_editor/highlighting/completion_existing_color")).to_html());
- cf->set_value(theme_section, "completion_scroll_color", ((Color)get("text_editor/highlighting/completion_scroll_color")).to_html());
- cf->set_value(theme_section, "completion_font_color", ((Color)get("text_editor/highlighting/completion_font_color")).to_html());
- cf->set_value(theme_section, "caret_color", ((Color)get("text_editor/highlighting/caret_color")).to_html());
- cf->set_value(theme_section, "caret_background_color", ((Color)get("text_editor/highlighting/caret_background_color")).to_html());
- cf->set_value(theme_section, "line_number_color", ((Color)get("text_editor/highlighting/line_number_color")).to_html());
- cf->set_value(theme_section, "text_color", ((Color)get("text_editor/highlighting/text_color")).to_html());
- cf->set_value(theme_section, "text_selected_color", ((Color)get("text_editor/highlighting/text_selected_color")).to_html());
- cf->set_value(theme_section, "keyword_color", ((Color)get("text_editor/highlighting/keyword_color")).to_html());
- cf->set_value(theme_section, "base_type_color", ((Color)get("text_editor/highlighting/base_type_color")).to_html());
- cf->set_value(theme_section, "engine_type_color", ((Color)get("text_editor/highlighting/engine_type_color")).to_html());
- cf->set_value(theme_section, "function_color", ((Color)get("text_editor/highlighting/function_color")).to_html());
- cf->set_value(theme_section, "member_variable_color", ((Color)get("text_editor/highlighting/member_variable_color")).to_html());
- cf->set_value(theme_section, "comment_color", ((Color)get("text_editor/highlighting/comment_color")).to_html());
- cf->set_value(theme_section, "string_color", ((Color)get("text_editor/highlighting/string_color")).to_html());
- cf->set_value(theme_section, "number_color", ((Color)get("text_editor/highlighting/number_color")).to_html());
- cf->set_value(theme_section, "symbol_color", ((Color)get("text_editor/highlighting/symbol_color")).to_html());
- cf->set_value(theme_section, "selection_color", ((Color)get("text_editor/highlighting/selection_color")).to_html());
- cf->set_value(theme_section, "brace_mismatch_color", ((Color)get("text_editor/highlighting/brace_mismatch_color")).to_html());
- cf->set_value(theme_section, "current_line_color", ((Color)get("text_editor/highlighting/current_line_color")).to_html());
- cf->set_value(theme_section, "line_length_guideline_color", ((Color)get("text_editor/highlighting/line_length_guideline_color")).to_html());
- cf->set_value(theme_section, "mark_color", ((Color)get("text_editor/highlighting/mark_color")).to_html());
- cf->set_value(theme_section, "breakpoint_color", ((Color)get("text_editor/highlighting/breakpoint_color")).to_html());
- cf->set_value(theme_section, "code_folding_color", ((Color)get("text_editor/highlighting/code_folding_color")).to_html());
- cf->set_value(theme_section, "word_highlighted_color", ((Color)get("text_editor/highlighting/word_highlighted_color")).to_html());
- cf->set_value(theme_section, "search_result_color", ((Color)get("text_editor/highlighting/search_result_color")).to_html());
- cf->set_value(theme_section, "search_result_border_color", ((Color)get("text_editor/highlighting/search_result_border_color")).to_html());
-
- //GDScript highlighter
- cf->set_value(theme_section, "gdscript/function_definition_color", ((Color)get("text_editor/highlighting/gdscript/function_definition_color")).to_html());
- cf->set_value(theme_section, "gdscript/node_path_color", ((Color)get("text_editor/highlighting/gdscript/node_path_color")).to_html());
+
+ List<String> keys;
+ props.get_key_list(&keys);
+ keys.sort();
+
+ for (const List<String>::Element *E = keys.front(); E; E = E->next()) {
+ String key = E->get();
+ if (key.begins_with("text_editor/highlighting/") && key.find("color") >= 0) {
+ cf->set_value(theme_section, key.replace("text_editor/highlighting/", ""), ((Color)props[key].variant).to_html());
+ }
+ }
Error err = cf->save(p_file);