Made ColorPicker save it's presets while in editor.
Made ColorPicker save it's presets while in editor.
This commit is contained in:
parent
2c7908739a
commit
4980ae5632
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user