[Preference] Sections are now collapsible.

This commit is contained in:
Tanasart 2025-01-05 11:47:16 +07:00
parent 3cae43cf66
commit 6e98b274e6
13 changed files with 239 additions and 137 deletions

View file

@ -704,7 +704,7 @@ event_inherited();
if(is_undefined(_node)) continue; if(is_undefined(_node)) continue;
if(is_instanceof(_node, NodeObject)) { if(is_instanceof(_node, NodeObject)) {
if(_node.patreon && !IS_PATREON) continue; if(_node.patreon && !IS_PATREON) continue;
if(is_global && !_node.show_in_global) continue; if(is_global && !_node.show_in_global) continue;
} }
if(is_string(_node)) { if(is_string(_node)) {

View file

@ -14,9 +14,16 @@ event_inherited();
selector = new colorSelector(); selector = new colorSelector();
drop_target = noone; drop_target = noone;
function setApply(_onApply) {
onApply = _onApply;
selector.onApply = _onApply;
return self;
}
function setDefault(color) { function setDefault(color) {
selector.setColor(color); selector.setColor(color);
previous_color = color; previous_color = color;
return self;
} }
b_cancel = button(function() { b_cancel = button(function() {

View file

@ -48,7 +48,8 @@ event_inherited();
page[4] = __txt("Hotkeys"); page[4] = __txt("Hotkeys");
section_current = ""; section_current = "";
sections = array_create(array_length(page)); sections = array_create(array_length(page));
collapsed = {};
sp_page = new scrollPane(page_width - ui(4), panel_height, function(_y, _m, _r) { sp_page = new scrollPane(page_width - ui(4), panel_height, function(_y, _m, _r) {
draw_clear_alpha(COLORS.panel_bg_clear, 1); draw_clear_alpha(COLORS.panel_bg_clear, 1);
@ -187,7 +188,7 @@ event_inherited();
)); ));
ds_list_add(pref_global, new __Panel_Linear_Setting_Item_Preference( ds_list_add(pref_global, new __Panel_Linear_Setting_Item_Preference(
__txtx("pref_save_backups", "Backup saves"), __txtx("pref_save_backups", "Backup save(s) amount"),
"save_backup", "save_backup",
new textBox(TEXTBOX_INPUT.number, function(val) /*=>*/ { PREFERENCES.save_backup = max(0, val); PREF_SAVE(); }) new textBox(TEXTBOX_INPUT.number, function(val) /*=>*/ { PREFERENCES.save_backup = max(0, val); PREF_SAVE(); })
)); ));
@ -553,7 +554,7 @@ event_inherited();
)); ));
ds_list_add(pref_node, new __Panel_Linear_Setting_Item_Preference( ds_list_add(pref_node, new __Panel_Linear_Setting_Item_Preference(
__txtx("pref_node_3d_preview", "Preview surface size"), __txtx("pref_node_3d_preview", "3D Preview resolution"),
"node_3d_preview_size", "node_3d_preview_size",
new textBox(TEXTBOX_INPUT.number, function(val) /*=>*/ { PREFERENCES.node_3d_preview_size = clamp(val, 16, 1024); PREF_SAVE(); }) new textBox(TEXTBOX_INPUT.number, function(val) /*=>*/ { PREFERENCES.node_3d_preview_size = clamp(val, 16, 1024); PREF_SAVE(); })
)); ));
@ -570,25 +571,27 @@ event_inherited();
themes = []; themes = [];
var f = file_find_first(DIRECTORY + "Themes/*", fa_directory); var f = file_find_first(DIRECTORY + "Themes/*", fa_directory);
while(f != "") { while(f != "") {
var _file = f;
var _path = $"{DIRECTORY}Themes/{f}"; var _path = $"{DIRECTORY}Themes/{f}";
if(directory_exists(_path)) { f = file_find_next();
var _metaPath = _path + "/meta.json";
if(!file_exists_empty(_metaPath)) {
var _item = new scrollItem(f, THEME.circle, 0, COLORS._main_accent);
_item.tooltip = "Theme made for earlier version.";
array_push(themes, _item);
} else {
var _meta = json_load_struct(_metaPath);
var _item = new scrollItem(_meta.name, _meta.version >= VERSION? noone : THEME.circle, 0, COLORS._main_accent);
_item.data = f;
if(_meta.version < VERSION) if(!directory_exists(_path)) continue;
_item.tooltip = "Theme made for earlier version.";
array_push(themes, _item); var _metaPath = $"{_path}/meta.json";
}
if(!file_exists_empty(_metaPath)) {
var _item = new scrollItem(_file, THEME.circle, 0, COLORS._main_accent)
.setTooltip("Theme made for earlier version.");
array_push(themes, _item);
continue;
} }
f = file_find_next(); var _meta = json_load_struct(_metaPath);
var _item = new scrollItem(_meta.name, _meta.version >= VERSION? noone : THEME.circle, 0, COLORS._main_accent);
_item.data = _file;
if(_meta.version < VERSION) _item.tooltip = "Theme made for earlier version.";
array_push(themes, _item);
} }
file_find_close(); file_find_close();
@ -607,84 +610,134 @@ event_inherited();
sp_colors = new scrollPane(panel_width, panel_height - ui(40), function(_y, _m, _r) { sp_colors = new scrollPane(panel_width, panel_height - ui(40), function(_y, _m, _r) {
draw_clear_alpha(COLORS.panel_bg_clear_inner, 1); draw_clear_alpha(COLORS.panel_bg_clear_inner, 1);
var ww = sp_colors.surface_w;
var hh = 0; var hh = 0;
var th = line_get_height(font);
var x1 = sp_colors.surface_w; var x1 = sp_colors.surface_w;
var yy = _y + ui(8); var yy = _y + ui(8);
var padd = ui(6); var padx = ui(8);
var pady = ui(6);
var th = line_get_height(font);
var ind = 0; var ind = 0;
var cp = ui(0) var cp = ui(0)
var cw = ui(100); var cw = ui(100);
var ch = th - cp * 2; var ch = th - cp * 2;
var cx = x1 - cw - ui(8); var cx = x1 - cw - padx * 2 - ui(8);
var category = ""; var category = "";
var sect = []; var group_labels = [];
var sectH = ui(24);
var sect = [];
var psect = ""; var psect = "";
var _search_text = string_lower(search_text);
for( var i = 0, n = array_length(COLOR_KEYS); i < n; i++ ) { for( var i = 0, n = array_length(COLOR_KEYS); i < n; i++ ) {
var key = COLOR_KEYS[i]; var key = COLOR_KEYS[i];
var val = variable_struct_get(COLORS, key); var val = COLORS[$ key];
if(search_text != "" && string_pos(string_lower(search_text), string_lower(key)) == 0)
continue;
if(_search_text != "" && string_pos(_search_text, string_lower(key)) == 0) continue;
if(is_array(val)) continue; if(is_array(val)) continue;
var spl = string_splice(key, "_"); var spl = string_splice(key, "_");
var cat = spl[0] == ""? spl[1] : spl[0]; var cat = spl[0] == ""? spl[1] : spl[0];
if(cat != category) { if(cat != category) {
category = cat; category = cat;
var _sect = string_title(category); var _sect = string_title(category);
var _coll = struct_try_get(collapsed, cat, 0);
draw_set_text(f_p1, fa_left, fa_top, COLORS._main_text_sub);
draw_text_add(ui(8), yy - ui(4), _sect);
array_push(sect, [ _sect, sp_colors, hh + ui(12) ]); array_push(sect, [ _sect, sp_colors, hh + ui(12) ]);
if(yy >= 0 && section_current == "") array_push(group_labels, { y: yy, text: _sect, key: cat });
section_current = psect;
if(yy >= 0 && section_current == "") section_current = psect;
psect = _sect; psect = _sect;
yy += string_height(category) + ui(8); yy += sectH + ui(!_coll * 4 + 4);
hh += string_height(category) + ui(8); hh += sectH + ui(!_coll * 4 + 4);
ind = 0; ind = 0;
} }
if(ind % 2 == 0) draw_sprite_stretched_ext(THEME.ui_panel_bg, 0, 0, yy - padd, sp_colors.surface_w, th + padd * 2, COLORS.dialog_preference_prop_bg, 1); if(struct_try_get(collapsed, cat, 0)) continue;
if(ind % 2) draw_sprite_stretched_ext(THEME.ui_panel_bg, 0, padx, yy - pady, ww - padx * 2, th + pady * 2, COLORS.dialog_preference_prop_bg, .75);
var keyStr = string_replace_all(key, "_", " "); var keyStr = string_replace_all(key, "_", " ");
keyStr = string_replace(keyStr, cat + " ", ""); keyStr = string_replace(keyStr, cat + " ", "");
keyStr = string_title(keyStr); keyStr = string_title(keyStr);
draw_set_text(font, fa_left, fa_center, COLORS._main_text); draw_set_text(font, fa_left, fa_center, COLORS._main_text);
draw_text_add(ui(24), yy + th / 2, keyStr); draw_text_add(ui(32), yy + th / 2, keyStr);
var b = buttonInstant(THEME.button_def, cx, yy + cp, cw, ch, _m, sHOVER, sFOCUS && sp_colors.hover); var b = buttonInstant(THEME.button_def, cx, yy + cp, cw, ch, _m, sHOVER, sFOCUS && sp_colors.hover);
draw_sprite_stretched_ext(THEME.palette_mask, 1, cx + ui(2), yy + ui(2), cw - ui(4), ch - ui(4), val, 1); draw_sprite_stretched_ext(THEME.palette_mask, 1, cx + ui(2), yy + ui(2), cw - ui(4), ch - ui(4), val, 1);
if(b) sp_colors.hover_content = true; if(b) sp_colors.hover_content = true;
if(b == 2) { if(b == 2) {
var dialog = dialogCall(o_dialog_color_selector, WIN_W / 2, WIN_H / 2); color_selector_key = key;
dialog.setDefault(val);
self.key = key;
dialog.onApply = function(color) {
COLORS[$ key] = color;
overrideColor(key);
};
dialog.selector.onApply = dialog.onApply; var clrSelect = dialogCall(o_dialog_color_selector)
.setDefault(val)
.setApply(function(color) /*=>*/ { COLORS[$ color_selector_key] = color; overrideColor(color_selector_key); });
addChildren(dialog); addChildren(clrSelect);
} }
yy += th + padd + ui(6); yy += th + pady * 2;
hh += th + padd + ui(6); hh += th + pady * 2;
ind++; ind++;
} }
sections[page_current] = sect; #region section label
var len = array_length(group_labels);
if(len && group_labels[0].y < 0) {
gpu_set_blendmode(bm_subtract);
draw_set_color(c_white);
draw_rectangle(0, 0, ww, sectH + ui(8 + 4), false);
gpu_set_blendmode(bm_normal);
}
return hh; var _cAll = 0;
for( var i = 0; i < len; i++ ) {
var lb = group_labels[i];
var _name = lb.text;
var _key = lb.key;
var _coll = struct_try_get(collapsed, _key, 0);
var _yy = max(lb.y, i == len - 1? ui(8) : min(ui(8), group_labels[i + 1].y - ui(32)));
var _hv = sHOVER && point_in_rectangle(_m[0], _m[1], 0, _yy, ww, _yy + sectH);
var _tc = CDEF.main_ltgrey;
BLEND_OVERRIDE
draw_sprite_stretched_ext(THEME.s_box_r5_clr, 0, padx, _yy, ww - padx * 2, sectH, _hv? COLORS.panel_inspector_group_hover : COLORS.panel_inspector_group_bg, 1);
if(_hv && sFOCUS) {
if(DOUBLE_CLICK) {
_cAll = _coll? -1 : 1;
} else if(mouse_press(mb_left)) {
if(_coll) struct_set(collapsed, _key, 0);
else struct_set(collapsed, _key, 1);
}
}
BLEND_NORMAL
draw_sprite_ui(THEME.arrow, _coll? 0 : 3, padx + ui(16), _yy + sectH / 2, 1, 1, 0, _tc, 1);
draw_set_text(f_p2, fa_left, fa_center, _tc);
draw_text_add(padx + ui(28), _yy + sectH / 2, _name);
}
if(_cAll == 1) { for( var i = 0; i < len; i++ ) struct_set(collapsed, group_labels[i].key, 0); }
else if(_cAll == -1) { for( var i = 0; i < len; i++ ) struct_set(collapsed, group_labels[i].key, 1); }
sections[page_current] = sect;
#endregion
return hh + ui(16);
}); });
function overrideColor(key) { function overrideColor(key) {
@ -872,60 +925,63 @@ event_inherited();
var th = line_get_height(font, 6); var th = line_get_height(font, 6);
var x1 = sp_pref.surface_w; var x1 = sp_pref.surface_w;
var yy = _y + ui(8); var yy = _y + ui(8);
var padd = ui(6); var padx = ui(8);
var pady = ui(6);
var ind = 0; var ind = 0;
var _search_text = string_lower(search_text);
for(var i = 0; i < ds_list_size(current_list); i++) { for(var i = 0; i < ds_list_size(current_list); i++) {
var _pref = current_list[| i]; var _pref = current_list[| i];
if(is_string(_pref)) continue; if(is_string(_pref)) continue;
if(search_text != "" && string_pos(_search_text, string_lower(_pref.name)) == 0) continue;
if(search_text != "" && string_pos(string_lower(search_text), string_lower(_pref.name)) == 0)
continue;
_pref.editWidget.register(sp_pref); _pref.editWidget.register(sp_pref);
} }
var sect = []; var group_labels = [];
var sectH = ui(24);
var sect = [];
var psect = ""; var psect = "";
for(var i = 0; i < ds_list_size(current_list); i++) { for(var i = 0; i < ds_list_size(current_list); i++) {
var _pref = current_list[| i]; var _pref = current_list[| i];
if(is_string(_pref)) { if(is_string(_pref)) {
draw_set_text(f_p1, fa_left, fa_top, COLORS._main_text_sub); var _coll = struct_try_get(collapsed, _pref, 0);
draw_text_add(ui(8), yy, _pref);
array_push(sect, [ _pref, sp_pref, hh + ui(12) ]); array_push(sect, [ _pref, sp_pref, hh + ui(12) ]);
if(yy >= 0 && section_current == "") array_push(group_labels, { y: yy, text: _pref, key: _pref });
section_current = psect;
if(yy >= 0 && section_current == "") section_current = psect;
psect = _pref; psect = _pref;
yy += string_height(_pref) + ui(8); yy += sectH + ui(!_coll * 4 + 4);
hh += string_height(_pref) + ui(8); hh += sectH + ui(!_coll * 4 + 4);
ind = 0; ind = 0;
continue; continue;
} }
if(struct_try_get(collapsed, psect, 0)) continue;
var name = _pref.name; var name = _pref.name;
var data = _pref.data(); var data = _pref.data();
if(search_text != "" && string_pos(string_lower(search_text), string_lower(name)) == 0) if(search_text != "" && string_pos(_search_text, string_lower(name)) == 0) continue;
continue;
if(ind % 2 == 0) draw_sprite_stretched_ext(THEME.ui_panel_bg, 0, 0, yy - padd, ww, max(_pref.editWidget.h, th) + padd * 2, COLORS.dialog_preference_prop_bg, 1); if(ind % 2) draw_sprite_stretched_ext(THEME.ui_panel_bg, 0, padx, yy - pady, ww - padx * 2, max(_pref.editWidget.h, th) + pady * 2, COLORS.dialog_preference_prop_bg, .75);
if(goto_item == _pref) { if(goto_item == _pref) {
if(goto_item_highlight == 2) sp_pref.setScroll(-hh); if(goto_item_highlight == 2) sp_pref.setScroll(-hh);
if(goto_item_highlight == 0) goto_item = noone; if(goto_item_highlight == 0) goto_item = noone;
draw_sprite_stretched_add(THEME.ui_panel_bg, 0, 0, yy - padd, ww, max(_pref.editWidget.h, th) + padd * 2, COLORS._main_accent, min(1, goto_item_highlight) * 0.5); draw_sprite_stretched_add(THEME.ui_panel_bg, 0, padx, yy - pady, ww - padx * 2, max(_pref.editWidget.h, th) + pady * 2, COLORS._main_accent, min(1, goto_item_highlight) * 0.5);
} }
draw_set_text(font, fa_left, fa_center, COLORS._main_text); draw_set_text(font, fa_left, fa_center, COLORS._main_text);
draw_text_add(ui(24), yy + th / 2, name); draw_text_add(padx + ui(24), yy + th / 2, name);
if(_pref.is_patreon) { if(_pref.is_patreon) {
var spr_x = ui(20); var spr_x = padx + ui(20);
var spr_y = yy + ui(4); var spr_y = yy + ui(4);
BLEND_SUBTRACT BLEND_SUBTRACT
@ -945,7 +1001,7 @@ event_inherited();
if(is_instanceof(_pref.editWidget, textBox)) widget_w = _pref.editWidget.input == TEXTBOX_INPUT.text? ui(400) : widget_w; if(is_instanceof(_pref.editWidget, textBox)) widget_w = _pref.editWidget.input == TEXTBOX_INPUT.text? ui(400) : widget_w;
else if(is_instanceof(_pref.editWidget, folderArrayBox)) widget_w = ui(400); else if(is_instanceof(_pref.editWidget, folderArrayBox)) widget_w = ui(400);
var widget_x = x1 - ui(4) - widget_w; var widget_x = x1 - padx - ui(4) - widget_w;
var widget_y = yy; var widget_y = yy;
if(_pref.getDefault != noone) if(_pref.getDefault != noone)
@ -962,7 +1018,7 @@ event_inherited();
if(_pref.getDefault != noone) { if(_pref.getDefault != noone) {
var _defVal = is_method(_pref.getDefault)? _pref.getDefault() : _pref.getDefault; var _defVal = is_method(_pref.getDefault)? _pref.getDefault() : _pref.getDefault;
var _bs = ui(32); var _bs = ui(32);
var _bx = x1 - ui(4) - _bs; var _bx = x1 - padx - ui(4) - _bs;
var _by = yy + wdh / 2 - _bs / 2; var _by = yy + wdh / 2 - _bs / 2;
if(isEqual(data, _defVal)) if(isEqual(data, _defVal))
@ -973,12 +1029,59 @@ event_inherited();
} }
} }
yy += wdh + padd + ui(6); yy += wdh + pady + ui(6);
hh += wdh + padd + ui(6); hh += wdh + pady + ui(6);
ind++; ind++;
} }
sections[page_current] = sect; #region section label
var len = array_length(group_labels);
if(len && group_labels[0].y < 0) {
gpu_set_blendmode(bm_subtract);
draw_set_color(c_white);
draw_rectangle(0, 0, ww, sectH + ui(8 + 4), false);
gpu_set_blendmode(bm_normal);
}
var _cAll = 0;
for( var i = 0; i < len; i++ ) {
var lb = group_labels[i];
var _name = lb.text;
var _key = lb.key;
var _coll = struct_try_get(collapsed, _key, 0);
var _yy = max(lb.y, i == len - 1? ui(8) : min(ui(8), group_labels[i + 1].y - ui(32)));
var _hv = sHOVER && point_in_rectangle(_m[0], _m[1], 0, _yy, ww, _yy + sectH);
var _tc = CDEF.main_ltgrey;
BLEND_OVERRIDE
draw_sprite_stretched_ext(THEME.s_box_r5_clr, 0, padx, _yy, ww - padx * 2, sectH, _hv? COLORS.panel_inspector_group_hover : COLORS.panel_inspector_group_bg, 1);
if(_hv && sFOCUS) {
if(DOUBLE_CLICK) {
_cAll = _coll? -1 : 1;
} else if(mouse_press(mb_left)) {
if(_coll) struct_set(collapsed, _key, 0);
else struct_set(collapsed, _key, 1);
}
}
BLEND_NORMAL
draw_sprite_ui(THEME.arrow, _coll? 0 : 3, padx + ui(16), _yy + sectH / 2, 1, 1, 0, _tc, 1);
draw_set_text(f_p2, fa_left, fa_center, _tc);
draw_text_add(padx + ui(28), _yy + sectH / 2, _name);
}
if(_cAll == 1) { for( var i = 0; i < len; i++ ) struct_set(collapsed, group_labels[i].key, 0); }
else if(_cAll == -1) { for( var i = 0; i < len; i++ ) struct_set(collapsed, group_labels[i].key, 1); }
sections[page_current] = sect;
#endregion
goto_item_highlight = lerp_float(goto_item_highlight, 0, 30); goto_item_highlight = lerp_float(goto_item_highlight, 0, 30);
return hh; return hh;

View file

@ -68,7 +68,7 @@ if !ready exit;
} else if(page_current == 3) { } else if(page_current == 3) {
var _w = ui(200); var _w = ui(200);
var _h = TEXTBOX_HEIGHT; var _h = ui(32);
var _x = dialog_x + dialog_w - ui(8); var _x = dialog_x + dialog_w - ui(8);
var bx = _x - ui(48); var bx = _x - ui(48);

View file

@ -8,13 +8,12 @@ function buttonColor(_onApply, dialog = noone) : widget() constructor {
hover_wid = ui(24); hover_wid = ui(24);
onColorPick = function() { onColorPick = function() {
var dialog = dialogCall(o_dialog_color_selector, WIN_W / 2, WIN_H / 2); var dialog = dialogCall(o_dialog_color_selector)
.setApply(onApply);
dialog.selector.dropper_active = true; dialog.selector.dropper_active = true;
dialog.selector.dropper_close = true; dialog.selector.dropper_close = true;
dialog.drop_target = self; dialog.drop_target = self;
dialog.selector.onApply = onApply;
dialog.onApply = onApply;
} }
is_picking = false; is_picking = false;
@ -45,11 +44,10 @@ function buttonColor(_onApply, dialog = noone) : widget() constructor {
} }
static trigger = function() { static trigger = function() {
var dialog = dialogCall(o_dialog_color_selector, WIN_W / 2, WIN_H / 2); var dialog = dialogCall(o_dialog_color_selector)
.setDefault(is_array(current_color)? array_safe_get(current_color, 0, 0) : current_color)
.setApply(apply);
dialog.setDefault(is_array(current_color)? array_safe_get(current_color, 0, 0) : current_color);
dialog.selector.onApply = apply;
dialog.onApply = apply;
dialog.interactable = interactable; dialog.interactable = interactable;
dialog.drop_target = self; dialog.drop_target = self;

View file

@ -25,17 +25,16 @@ function buttonGradient(_onApply, dialog = noone) : widget() constructor {
dialog.interactable = interactable; dialog.interactable = interactable;
dialog.drop_target = self; dialog.drop_target = self;
if(parentDialog) if(parentDialog) parentDialog.addChildren(dialog);
parentDialog.addChildren(dialog);
} }
static triggerSingle = function(_index) { static triggerSingle = function(_index) {
edit_color_index = _index; edit_color_index = _index;
var dialog = dialogCall(o_dialog_color_selector, WIN_W / 2, WIN_H / 2); var dialog = dialogCall(o_dialog_color_selector)
dialog.setDefault(edit_color_index.value); .setDefault(edit_color_index.value)
dialog.selector.onApply = editColor; .setApply(editColor);
dialog.onApply = editColor;
dialog.interactable = interactable; dialog.interactable = interactable;
} }

View file

@ -28,10 +28,10 @@ function buttonPalette(_onApply, dialog = noone) : widget() constructor {
edit_color_index = _index; edit_color_index = _index;
current_palette = array_clone(current_palette); current_palette = array_clone(current_palette);
var dialog = dialogCall(o_dialog_color_selector, WIN_W / 2, WIN_H / 2); var dialog = dialogCall(o_dialog_color_selector)
dialog.setDefault(current_palette[edit_color_index]); .setDefault(current_palette[edit_color_index])
dialog.selector.onApply = editColor; .setApply(editColor);
dialog.onApply = editColor;
dialog.interactable = interactable; dialog.interactable = interactable;
} }

View file

@ -30,45 +30,46 @@ function _loadColor(theme = "default", replace = false) {
var clrs = json_load_struct(path); var clrs = json_load_struct(path);
if(!struct_has(clrs, "values")) { print("Load color error"); return; } if(!struct_has(clrs, "values")) { print("Load color error"); return; }
////- Value (parameters)
var valkeys = variable_struct_get_names(clrs.values); var valkeys = variable_struct_get_names(clrs.values);
if(replace) THEME_VALUE = clrs.values;
else struct_override(THEME_VALUE, clrs.values);
////- Colors
var defkeys = variable_struct_get_names(clrs.define); var defkeys = variable_struct_get_names(clrs.define);
var clrkeys = variable_struct_get_names(clrs.colors); var clrkeys = variable_struct_get_names(clrs.colors);
var arrkeys = variable_struct_get_names(clrs.array); var arrkeys = variable_struct_get_names(clrs.array);
if(replace) THEME_VALUE = clrs.values; var override = file_exists_empty(pathO)? json_load_struct(pathO) : {};
else struct_override(THEME_VALUE, clrs.values);
COLOR_KEYS = defkeys;
array_sort(COLOR_KEYS, true);
for( var i = 0, n = array_length(clrkeys); i < n; i++ ) { for( var i = 0, n = array_length(clrkeys); i < n; i++ ) {
var key = clrkeys[i]; var key = clrkeys[i];
var str = struct_get(clrs.colors, key); var str = struct_has(override, key)? override[$ key] : clrs.colors[$ key];
CDEF[$ key] = color_from_rgb(str); CDEF[$ key] = color_from_rgb(str);
} }
for( var i = 0, n = array_length(defkeys); i < n; i++ ) { for( var i = 0, n = array_length(defkeys); i < n; i++ ) {
var key = defkeys[i]; var key = defkeys[i];
var def = struct_get(clrs.define, key); var def = struct_has(override, key)? override[$ key] : clrs.define[$ key];
var c = c_white; var c = c_white;
if(is_array(def)) c = merge_color(struct_get(CDEF, def[0]), struct_get(CDEF, def[1]), def[2]); if(is_array(def)) c = merge_color(CDEF[$ def[0]], CDEF[$ def[1]], def[2]);
else c = struct_has(CDEF, def)? struct_get(CDEF, def) : color_from_rgb(def); else c = struct_has(CDEF, def)? CDEF[$ def] : color_from_rgb(def);
COLORS[$ key] = c; COLORS[$ key] = c;
} }
for( var i = 0, n = array_length(arrkeys); i < n; i++ ) { for( var i = 0, n = array_length(arrkeys); i < n; i++ ) {
var key = arrkeys[i]; var key = arrkeys[i];
var def = struct_get(clrs.array, key); var def = struct_has(override, key)? override[$ key] : clrs.array[$ key];
var c = array_create(array_length(def)); var c = array_create(array_length(def));
for( var j = 0; j < array_length(def); j++ ) for( var j = 0; j < array_length(def); j++ )
c[j] = struct_has(CDEF, def[j])? struct_get(CDEF, def[j]) : color_from_rgb(def[j]); c[j] = struct_has(CDEF, def[j])? CDEF[$ def[j]] : color_from_rgb(def[j]);
COLORS[$ key] = c; COLORS[$ key] = c;
} }
if(file_exists_empty(pathO)) struct_override(COLORS, json_load_struct(pathO));
} }

View file

@ -40,11 +40,9 @@ function dialogPanelCall(_panel, _x = noone, _y = noone, params = {}) {
} }
function colorSelectorCall(defColor, onApply) { function colorSelectorCall(defColor, onApply) {
var dialog = dialogCall(o_dialog_color_selector); var dialog = dialogCall(o_dialog_color_selector)
.setDefault(defColor)
dialog.setDefault(defColor); .setApply(onApply);
dialog.selector.onApply = onApply;
dialog.onApply = onApply;
return dialog; return dialog;
} }

View file

@ -110,13 +110,13 @@ function Node_Colors_Replace(_x, _y, _group = noone) : Node_Processor(_x, _y, _g
_x2 -= ui(32 + 4); _x2 -= ui(32 + 4);
by = _y0 + ss / 2 - ui(32) / 2; by = _y0 + ss / 2 - ui(32) / 2;
if(buttonInstant(THEME.button_hide, bx, by, ui(32), ui(32), _m, _hover, _focus,, THEME.color_picker_dropper,, c_white) == 2) { if(buttonInstant(THEME.button_hide, bx, by, ui(32), ui(32), _m, _hover, _focus,, THEME.color_picker_dropper,, c_white) == 2) {
var dialog = dialogCall(o_dialog_color_selector, WIN_W / 2, WIN_H / 2); var dialog = dialogCall(o_dialog_color_selector)
.setApply(setColor);
dialog.selector.dropper_active = true; dialog.selector.dropper_active = true;
dialog.selector.dropper_close = true; dialog.selector.dropper_close = true;
palette_select = [ i, i ]; palette_select = [ i, i ];
dialog.selector.onApply = setColor;
dialog.onApply = setColor;
} }
bx = _x2 - ui(32); bx = _x2 - ui(32);
@ -170,10 +170,9 @@ function Node_Colors_Replace(_x, _y, _group = noone) : Node_Processor(_x, _y, _g
palette_selecting = 2; palette_selecting = 2;
palette_select = [ _mn, _mx ]; palette_select = [ _mn, _mx ];
var dialog = dialogCall(o_dialog_color_selector, WIN_W / 2, WIN_H / 2); var dialog = dialogCall(o_dialog_color_selector)
dialog.setDefault(_to[palette_select[0]]); .setDefault(_to[palette_select[0]])
dialog.selector.onApply = setColor; .setApply(setColor);
dialog.onApply = setColor;
} }
} }

View file

@ -165,10 +165,9 @@ function Node_MK_Flare(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
if(_hov && mouse_press(mb_left, _focus)) { if(_hov && mouse_press(mb_left, _focus)) {
flare_color_editing = i; flare_color_editing = i;
var dialog = dialogCall(o_dialog_color_selector, WIN_W / 2, WIN_H / 2); var dialog = dialogCall(o_dialog_color_selector)
dialog.selector.onApply = edit_flare_color; .setDefault(_flare.blend)
dialog.onApply = edit_flare_color; .setApply(edit_flare_color);
dialog.setDefault(_flare.blend);
} }
_ffx += _ffw + ui(4); _ffx += _ffw + ui(4);

View file

@ -1334,10 +1334,10 @@ function Panel_Animation() : PanelContent() constructor {
break; break;
default : default :
var dialog = dialogCall(o_dialog_color_selector, WIN_W / 2, WIN_H / 2); var dialog = dialogCall(o_dialog_color_selector)
dialog.setDefault(keyframe.value); .setDefault(keyframe.value)
dialog.selector.onApply = function(val) { __keyframe_editing.value = val; }; .setApply(function(val) /*=>*/ { __keyframe_editing.value = val; });
dialog.onApply = function(val) { __keyframe_editing.value = val; };
dialog.drop_target = _wid; dialog.drop_target = _wid;
} }
break; break;

View file

@ -371,10 +371,9 @@ function Panel_Palette_Mixer() : PanelContent() constructor {
if(DOUBLE_CLICK) { if(DOUBLE_CLICK) {
node_selecting = node_hovering; node_selecting = node_hovering;
var dialog = dialogCall(o_dialog_color_selector, WIN_W / 2, WIN_H / 2); var dialog = dialogCall(o_dialog_color_selector)
dialog.selector.onApply = setColor; .setDefault(node_selecting.color)
dialog.onApply = setColor; .setApply(setColor);
dialog.setDefault(node_selecting.color);
save_palette_mixer(palette_data); save_palette_mixer(palette_data);
} }
@ -458,10 +457,9 @@ function Panel_Palette_Mixer() : PanelContent() constructor {
array_push(palette_data.nodes, _node); array_push(palette_data.nodes, _node);
node_selecting = _node; node_selecting = _node;
var dialog = dialogCall(o_dialog_color_selector, WIN_W / 2, WIN_H / 2); var dialog = dialogCall(o_dialog_color_selector)
dialog.selector.onApply = setColor; .setDefault(node_selecting.color)
dialog.onApply = setColor; .setApply(setColor);
dialog.setDefault(node_selecting.color);
save_palette_mixer(palette_data); save_palette_mixer(palette_data);
} }