diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2017-11-08 16:21:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-08 16:21:02 +0100 |
commit | b5e8cd3c706839cbc39e3b6bbb717b1b0b50549c (patch) | |
tree | f62f4a0bc92b1e6a91608167573217baadf04bb6 /editor | |
parent | 77345916c53d6ac1cf0c51e9624e923ed8f32455 (diff) | |
parent | 0781649456a23a9c2f72a97938df38b750fe7019 (diff) |
Merge pull request #12718 from GodotExplorer/export-editor-theme
Create new theme from the current editor
Diffstat (limited to 'editor')
-rw-r--r-- | editor/plugins/theme_editor_plugin.cpp | 16 | ||||
-rw-r--r-- | editor/plugins/theme_editor_plugin.h | 3 |
2 files changed, 11 insertions, 8 deletions
diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp index 02ead3aee8..7f956b01ff 100644 --- a/editor/plugins/theme_editor_plugin.cpp +++ b/editor/plugins/theme_editor_plugin.cpp @@ -427,7 +427,9 @@ void ThemeEditor::_dialog_cbk() { void ThemeEditor::_theme_menu_cbk(int p_option) { - if (p_option == POPUP_CREATE_EMPTY || p_option == POPUP_CREATE_EDITOR_EMPTY) { + if (p_option == POPUP_CREATE_EMPTY || p_option == POPUP_CREATE_EDITOR_EMPTY || p_option == POPUP_IMPORT_EDITOR_THEME) { + + bool import = (p_option == POPUP_IMPORT_EDITOR_THEME); Ref<Theme> base_theme; @@ -449,21 +451,21 @@ void ThemeEditor::_theme_menu_cbk(int p_option) { base_theme->get_icon_list(type, &icons); for (List<StringName>::Element *E = icons.front(); E; E = E->next()) { - theme->set_icon(E->get(), type, Ref<Texture>()); + theme->set_icon(E->get(), type, import ? base_theme->get_icon(E->get(), type) : Ref<Texture>()); } List<StringName> shaders; base_theme->get_shader_list(type, &shaders); for (List<StringName>::Element *E = shaders.front(); E; E = E->next()) { - theme->set_shader(E->get(), type, Ref<Shader>()); + theme->set_shader(E->get(), type, import ? base_theme->get_shader(E->get(), type) : Ref<Shader>()); } List<StringName> styleboxs; base_theme->get_stylebox_list(type, &styleboxs); for (List<StringName>::Element *E = styleboxs.front(); E; E = E->next()) { - theme->set_stylebox(E->get(), type, Ref<StyleBox>()); + theme->set_stylebox(E->get(), type, import ? base_theme->get_stylebox(E->get(), type) : Ref<StyleBox>()); } List<StringName> fonts; @@ -477,14 +479,14 @@ void ThemeEditor::_theme_menu_cbk(int p_option) { base_theme->get_color_list(type, &colors); for (List<StringName>::Element *E = colors.front(); E; E = E->next()) { - theme->set_color(E->get(), type, Color()); + theme->set_color(E->get(), type, import ? base_theme->get_color(E->get(), type) : Color()); } List<StringName> constants; base_theme->get_constant_list(type, &constants); for (List<StringName>::Element *E = constants.front(); E; E = E->next()) { - theme->set_constant(E->get(), type, base_theme->get_constant(type, E->get())); + theme->set_constant(E->get(), type, base_theme->get_constant(E->get(), type)); } } } @@ -639,7 +641,7 @@ ThemeEditor::ThemeEditor() { theme_menu->get_popup()->add_separator(); theme_menu->get_popup()->add_item(TTR("Create Empty Template"), POPUP_CREATE_EMPTY); theme_menu->get_popup()->add_item(TTR("Create Empty Editor Template"), POPUP_CREATE_EDITOR_EMPTY); - + theme_menu->get_popup()->add_item(TTR("Create From Current Editor Theme"), POPUP_IMPORT_EDITOR_THEME); add_child(theme_menu); theme_menu->set_position(Vector2(3, 3) * EDSCALE); theme_menu->get_popup()->connect("id_pressed", this, "_theme_menu_cbk"); diff --git a/editor/plugins/theme_editor_plugin.h b/editor/plugins/theme_editor_plugin.h index 16b2da94d1..4d46282ba1 100644 --- a/editor/plugins/theme_editor_plugin.h +++ b/editor/plugins/theme_editor_plugin.h @@ -69,7 +69,8 @@ class ThemeEditor : public Control { POPUP_REMOVE, POPUP_CLASS_REMOVE, POPUP_CREATE_EMPTY, - POPUP_CREATE_EDITOR_EMPTY + POPUP_CREATE_EDITOR_EMPTY, + POPUP_IMPORT_EDITOR_THEME }; int popup_mode; |