summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDualMatrix <piet.goris@gmail.com>2018-09-24 16:28:18 +0200
committerDualMatrix <piet.goris@gmail.com>2018-09-24 19:32:36 +0200
commit4980ae5632d0dad381fedb7e6313e9ccef4c0c98 (patch)
treecbe750e45eb02858b81f7d4bb4df7b0220ad6356
parent2c7908739a9508cdd725fdd3175477f4d048ea26 (diff)
Made ColorPicker save it's presets while in editor.
Made ColorPicker save it's presets while in editor.
-rw-r--r--scene/gui/color_picker.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp
index 537a16fbc3..03eee9c6d8 100644
--- a/scene/gui/color_picker.cpp
+++ b/scene/gui/color_picker.cpp
@@ -33,6 +33,11 @@
#include "core/os/input.h"
#include "core/os/keyboard.h"
#include "core/os/os.h"
+
+#ifdef TOOLS_ENABLED
+#include "editor_settings.h"
+#endif
+
#include "scene/gui/separator.h"
#include "scene/main/viewport.h"
@@ -52,6 +57,16 @@ void ColorPicker::_notification(int p_what) {
bt_add_preset->set_icon(get_icon("add_preset"));
_update_color();
+
+#ifdef TOOLS_ENABLED
+ if (Engine::get_singleton()->is_editor_hint()) {
+ PoolColorArray saved_presets = EditorSettings::get_singleton()->get_project_metadata("color_picker", "presets", PoolColorArray());
+
+ for (int i = 0; i < saved_presets.size(); i++) {
+ add_preset(saved_presets[i]);
+ }
+ }
+#endif
} break;
case NOTIFICATION_PARENTED: {
@@ -186,9 +201,22 @@ void ColorPicker::_update_presets() {
preset->draw_texture_rect(get_icon("preset_bg", "ColorPicker"), Rect2(Point2(), preset_size), true);
+#ifdef TOOLS_ENABLED
+ if (Engine::get_singleton()->is_editor_hint()) {
+ PoolColorArray arr_to_save = PoolColorArray();
+
+ for (int i = 0; i < presets.size(); i++) {
+ preset->draw_rect(Rect2(Point2(size.width * i, 0), size), presets[i]);
+ arr_to_save.insert(i, presets[i]);
+ }
+
+ EditorSettings::get_singleton()->set_project_metadata("color_picker", "presets", arr_to_save);
+ }
+#else
for (int i = 0; i < presets.size(); i++) {
preset->draw_rect(Rect2(Point2(size.width * i, 0), size), presets[i]);
}
+#endif
}
void ColorPicker::_text_type_toggled() {