mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2025-01-24 20:08:04 +01:00
palette mixer
This commit is contained in:
parent
8cdda076c6
commit
12e5eeb0e1
7 changed files with 302 additions and 62 deletions
|
@ -119,9 +119,9 @@
|
|||
{"name":"atlas","order":2,"path":"folders/nodes/icons/value/atlas.yy",},
|
||||
{"name":"bool","order":3,"path":"folders/nodes/icons/value/bool.yy",},
|
||||
{"name":"color","order":4,"path":"folders/nodes/icons/value/color.yy",},
|
||||
{"name":"path","order":29,"path":"folders/nodes/icons/value/path.yy",},
|
||||
{"name":"mesh","order":5,"path":"folders/nodes/icons/value/mesh.yy",},
|
||||
{"name":"number","order":6,"path":"folders/nodes/icons/value/number.yy",},
|
||||
{"name":"path","order":29,"path":"folders/nodes/icons/value/path.yy",},
|
||||
{"name":"struct","order":9,"path":"folders/nodes/icons/value/struct.yy",},
|
||||
{"name":"surface","order":7,"path":"folders/nodes/icons/value/surface.yy",},
|
||||
{"name":"texts","order":8,"path":"folders/nodes/icons/value/texts.yy",},
|
||||
|
@ -157,6 +157,7 @@
|
|||
{"name":"find_boundary","order":7,"path":"folders/shader/misc/find_boundary.yy",},
|
||||
{"name":"Flag","order":3,"path":"folders/shader/MK effects/Flag.yy",},
|
||||
{"name":"Tile","order":4,"path":"folders/shader/MK effects/Tile.yy",},
|
||||
{"name":"atlas expand","order":2,"path":"folders/shader/UI/atlas expand.yy",},
|
||||
],
|
||||
"ResourceOrderSettings":[
|
||||
{"name":"ac_disappear","order":2,"path":"animcurves/ac_disappear/ac_disappear.yy",},
|
||||
|
|
|
@ -228,9 +228,9 @@
|
|||
{"$GMFolder":"","%Name":"atlas","folderPath":"folders/nodes/icons/value/atlas.yy","name":"atlas","resourceType":"GMFolder","resourceVersion":"2.0",},
|
||||
{"$GMFolder":"","%Name":"bool","folderPath":"folders/nodes/icons/value/bool.yy","name":"bool","resourceType":"GMFolder","resourceVersion":"2.0",},
|
||||
{"$GMFolder":"","%Name":"color","folderPath":"folders/nodes/icons/value/color.yy","name":"color","resourceType":"GMFolder","resourceVersion":"2.0",},
|
||||
{"$GMFolder":"","%Name":"path","folderPath":"folders/nodes/icons/value/path.yy","name":"path","resourceType":"GMFolder","resourceVersion":"2.0",},
|
||||
{"$GMFolder":"","%Name":"mesh","folderPath":"folders/nodes/icons/value/mesh.yy","name":"mesh","resourceType":"GMFolder","resourceVersion":"2.0",},
|
||||
{"$GMFolder":"","%Name":"number","folderPath":"folders/nodes/icons/value/number.yy","name":"number","resourceType":"GMFolder","resourceVersion":"2.0",},
|
||||
{"$GMFolder":"","%Name":"path","folderPath":"folders/nodes/icons/value/path.yy","name":"path","resourceType":"GMFolder","resourceVersion":"2.0",},
|
||||
{"$GMFolder":"","%Name":"struct","folderPath":"folders/nodes/icons/value/struct.yy","name":"struct","resourceType":"GMFolder","resourceVersion":"2.0",},
|
||||
{"$GMFolder":"","%Name":"surface","folderPath":"folders/nodes/icons/value/surface.yy","name":"surface","resourceType":"GMFolder","resourceVersion":"2.0",},
|
||||
{"$GMFolder":"","%Name":"texts","folderPath":"folders/nodes/icons/value/texts.yy","name":"texts","resourceType":"GMFolder","resourceVersion":"2.0",},
|
||||
|
@ -295,6 +295,7 @@
|
|||
{"$GMFolder":"","%Name":"sprites","folderPath":"folders/shader/sprites.yy","name":"sprites","resourceType":"GMFolder","resourceVersion":"2.0",},
|
||||
{"$GMFolder":"","%Name":"transition","folderPath":"folders/shader/transition.yy","name":"transition","resourceType":"GMFolder","resourceVersion":"2.0",},
|
||||
{"$GMFolder":"","%Name":"UI","folderPath":"folders/shader/UI.yy","name":"UI","resourceType":"GMFolder","resourceVersion":"2.0",},
|
||||
{"$GMFolder":"","%Name":"atlas expand","folderPath":"folders/shader/UI/atlas expand.yy","name":"atlas expand","resourceType":"GMFolder","resourceVersion":"2.0",},
|
||||
{"$GMFolder":"","%Name":"sprites","folderPath":"folders/sprites.yy","name":"sprites","resourceType":"GMFolder","resourceVersion":"2.0",},
|
||||
{"$GMFolder":"","%Name":"bs","folderPath":"folders/sprites/bs.yy","name":"bs","resourceType":"GMFolder","resourceVersion":"2.0",},
|
||||
{"$GMFolder":"","%Name":"gameframe","folderPath":"folders/sprites/gameframe.yy","name":"gameframe","resourceType":"GMFolder","resourceVersion":"2.0",},
|
||||
|
|
Binary file not shown.
|
@ -25,8 +25,11 @@ event_inherited();
|
|||
anchor = ANCHOR.left | ANCHOR.top;
|
||||
node_menu_selecting = noone;
|
||||
|
||||
display_grid_size = ui(64);
|
||||
display_list_size = ui(28);
|
||||
display_grid_size = ui(64);
|
||||
display_grid_size_to = display_grid_size;
|
||||
|
||||
display_list_size = ui(28);
|
||||
display_list_size_to = display_list_size;
|
||||
|
||||
is_global = PANEL_GRAPH.getCurrentContext() == noone;
|
||||
|
||||
|
@ -550,9 +553,10 @@ event_inherited();
|
|||
yy += curr_height;
|
||||
|
||||
if(sHOVER && key_mod_press(CTRL)) {
|
||||
if(mouse_wheel_down()) display_grid_size = clamp(display_grid_size - ui(8), ui(32), ui(128));
|
||||
if(mouse_wheel_up()) display_grid_size = clamp(display_grid_size + ui(8), ui(32), ui(128));
|
||||
if(mouse_wheel_down()) display_grid_size_to = clamp(display_grid_size_to - ui(8), ui(32), ui(128));
|
||||
if(mouse_wheel_up()) display_grid_size_to = clamp(display_grid_size_to + ui(8), ui(32), ui(128));
|
||||
}
|
||||
display_grid_size = lerp_float(display_grid_size, display_grid_size_to, 3);
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -656,8 +660,9 @@ event_inherited();
|
|||
}
|
||||
|
||||
if(sHOVER && key_mod_press(CTRL)) {
|
||||
if(mouse_wheel_down()) display_list_size = clamp(display_list_size - ui(4), ui(16), ui(64));
|
||||
if(mouse_wheel_up()) display_list_size = clamp(display_list_size + ui(4), ui(16), ui(64));
|
||||
if(mouse_wheel_down()) display_list_size_to = clamp(display_list_size_to - ui(4), ui(16), ui(64));
|
||||
if(mouse_wheel_up()) display_list_size_to = clamp(display_list_size_to + ui(4), ui(16), ui(64));
|
||||
display_list_size = lerp_float(display_list_size, display_list_size_to, 3);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
|
|
@ -99,4 +99,17 @@ function __initPalette() {
|
|||
file = file_find_next();
|
||||
}
|
||||
file_find_close();
|
||||
}
|
||||
}
|
||||
|
||||
#region palette generate
|
||||
function palette_string_hex(palette, alpha = true) {
|
||||
var _str = "";
|
||||
|
||||
for (var i = 0, n = array_length(palette); i < n; i++) {
|
||||
var _c = palette[i];
|
||||
_str += $"{color_get_hex(_c, alpha)}\n";
|
||||
}
|
||||
|
||||
return _str;
|
||||
}
|
||||
#endregion
|
|
@ -5,7 +5,8 @@ function Panel_Palette() : PanelContent() constructor {
|
|||
w = ui(320);
|
||||
h = ui(480);
|
||||
|
||||
grid_size = ui(16);
|
||||
grid_size = ui(16);
|
||||
grid_size_to = ui(16);
|
||||
|
||||
color_dragging = noone;
|
||||
|
||||
|
@ -23,9 +24,10 @@ function Panel_Palette() : PanelContent() constructor {
|
|||
var cur = CURRENT_COLOR;
|
||||
|
||||
if(pHOVER && key_mod_press(CTRL)) {
|
||||
if(mouse_wheel_down()) grid_size = clamp(grid_size - ui(4), ui(8), ui(32));
|
||||
if(mouse_wheel_up()) grid_size = clamp(grid_size + ui(4), ui(8), ui(32));
|
||||
if(mouse_wheel_down()) grid_size_to = clamp(grid_size_to - ui(4), ui(8), ui(32));
|
||||
if(mouse_wheel_up()) grid_size_to = clamp(grid_size_to + ui(4), ui(8), ui(32));
|
||||
}
|
||||
grid_size = lerp_float(grid_size, grid_size_to, 3);
|
||||
|
||||
for(var i = 0; i < array_length(PALETTES); i++) {
|
||||
var preset = PALETTES[i];
|
||||
|
|
|
@ -6,7 +6,9 @@ function Panel_Palette_Mixer() : PanelContent() constructor {
|
|||
w = ui(320);
|
||||
h = ui(400);
|
||||
|
||||
content = surface_create(1, 1);
|
||||
connect_surf = surface_create(1, 1);
|
||||
content_surf = surface_create(1, 1);
|
||||
|
||||
var _def = load_palette_mixer();
|
||||
palette_data = _def != noone? _def : {
|
||||
nodes: [
|
||||
|
@ -16,19 +18,23 @@ function Panel_Palette_Mixer() : PanelContent() constructor {
|
|||
connections: [
|
||||
[ 0, 1 ],
|
||||
],
|
||||
blends: [],
|
||||
};
|
||||
|
||||
palette = [];
|
||||
|
||||
var _mx = 0, _my = 0;
|
||||
for (var i = 0, n = array_length(palette_data.nodes); i < n; i++) {
|
||||
var _node = palette_data.nodes[i];
|
||||
_mx += _node.x;
|
||||
_my += _node.y;
|
||||
}
|
||||
static centerView = function() {
|
||||
var _mx = 0, _my = 0;
|
||||
for (var i = 0, n = array_length(palette_data.nodes); i < n; i++) {
|
||||
var _node = palette_data.nodes[i];
|
||||
_mx += _node.x;
|
||||
_my += _node.y;
|
||||
}
|
||||
|
||||
mixer_x = n? -_mx / n : 0;
|
||||
mixer_y = n? -_my / n : 0;
|
||||
} centerView();
|
||||
|
||||
mixer_x = n? -_mx / n : 0;
|
||||
mixer_y = n? -_my / n : 0;
|
||||
mixer_s = 1;
|
||||
|
||||
mixer_dragging = false;
|
||||
|
@ -38,6 +44,7 @@ function Panel_Palette_Mixer() : PanelContent() constructor {
|
|||
mixer_drag_sy = 0;
|
||||
|
||||
node_size = ui(PREFERENCES.panel_menu_palette_node_size);
|
||||
node_size_to = node_size;
|
||||
node_hovering = noone;
|
||||
node_dragging = noone;
|
||||
node_drag_mx = 0;
|
||||
|
@ -46,8 +53,11 @@ function Panel_Palette_Mixer() : PanelContent() constructor {
|
|||
node_drag_sy = 0;
|
||||
node_selecting = noone;
|
||||
|
||||
blnd_hovering = noone;
|
||||
|
||||
conn_hovering = noone;
|
||||
connection_drag = noone;
|
||||
conn_menu_ctx = noone;
|
||||
|
||||
pr_palette = ds_priority_create();
|
||||
|
||||
|
@ -62,43 +72,78 @@ function Panel_Palette_Mixer() : PanelContent() constructor {
|
|||
|
||||
var _palettes = palette_data.nodes;
|
||||
var _connections = palette_data.connections;
|
||||
var _blends = palette_data.blends;
|
||||
|
||||
if(!in_dialog) draw_sprite_stretched(THEME.ui_panel_bg, 1, 0, 0, w, h);
|
||||
|
||||
#region blend points
|
||||
for (var i = 0, n = array_length(_blends); i < n; i++) {
|
||||
var _b = _blends[i];
|
||||
|
||||
var _fr = _palettes[_b.from];
|
||||
var _to = _palettes[_b.to];
|
||||
var _rt = _b.amount;
|
||||
|
||||
_b.x = lerp(_fr.x, _to.x, _rt);
|
||||
_b.y = lerp(_fr.y, _to.y, _rt);
|
||||
_b.color = merge_color(_fr.color, _to.color, _rt);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region palette
|
||||
var pal_s = ui(16);
|
||||
var pal_w = w - padding - padding;
|
||||
var pal_w = in_dialog? w - padding * 2 : w - ui(16 * 2);
|
||||
|
||||
var col = floor(pal_w / pal_s);
|
||||
var row = ceil(array_length(_palettes) / col);
|
||||
|
||||
var pal_h = pal_s * row;
|
||||
var pal_x = padding;
|
||||
var pal_y = h - padding - pal_h;
|
||||
var pal_x = in_dialog? padding : ui(16);
|
||||
var pal_y = in_dialog? h - pal_h - padding : h - pal_h - ui(16);
|
||||
|
||||
draw_sprite_stretched(THEME.button_def, 0, pal_x - ui(8), pal_y - ui(8), pal_w + ui(16), pal_h + ui(16));
|
||||
var pbg_x = pal_x - ui(8);
|
||||
var pbg_y = pal_y - ui(8);
|
||||
var pbg_w = pal_w + ui(16);
|
||||
var pbg_h = pal_h + ui(16);
|
||||
|
||||
draw_sprite_stretched(THEME.button_def, 0, pbg_x, pbg_y, pbg_w, pbg_h);
|
||||
|
||||
if(pHOVER && point_in_rectangle(mx, my, pbg_x, pbg_x, pbg_w, pbg_h)) {
|
||||
|
||||
draw_sprite_stretched_ext(THEME.button_def, 3, pbg_x, pbg_y, pbg_w, pbg_h, c_white, 0.5);
|
||||
if(mouse_press(mb_right)) {
|
||||
////////////////////////////////////////////
|
||||
}
|
||||
}
|
||||
|
||||
ds_priority_clear(pr_palette);
|
||||
for (var i = 0, n = array_length(_palettes); i < n; i++)
|
||||
ds_priority_add(pr_palette, _palettes[i], _palettes[i].y * 10000 + _palettes[i].x);
|
||||
ds_priority_add(pr_palette, _palettes[i].color, _palettes[i].y * 10000 + _palettes[i].x);
|
||||
|
||||
for (var i = 0, n = array_length(_blends); i < n; i++)
|
||||
ds_priority_add(pr_palette, _blends[i].color, _blends[i].y * 10000 + _blends[i].x);
|
||||
|
||||
var _ind = 0;
|
||||
palette = [];
|
||||
for (var i = 0, n = array_length(_palettes); i < n; i++) {
|
||||
var pal = ds_priority_delete_min(pr_palette);
|
||||
palette[i] = pal.color;
|
||||
}
|
||||
while(!ds_priority_empty(pr_palette))
|
||||
palette[_ind++] = ds_priority_delete_min(pr_palette);
|
||||
|
||||
var _ppw = pal_w - ui(24 + 8);
|
||||
var _ppx = pal_x + ui(24 + 8);
|
||||
|
||||
var _pw = pal_s;
|
||||
var _ph = pal_s;
|
||||
var amo = array_length(palette);
|
||||
var col = floor(pal_w / _pw);
|
||||
var col = floor(_ppw / _pw);
|
||||
var row = ceil(amo / col);
|
||||
var cx = -1, cy = -1;
|
||||
var _pd = ui(5);
|
||||
var _h = row * _ph;
|
||||
_pw = pal_w / col;
|
||||
_pw = _ppw / col;
|
||||
|
||||
for(var i = 0; i < array_length(palette); i++) {
|
||||
draw_set_color(palette[i]);
|
||||
var _x0 = pal_x + safe_mod(i, col) * _pw;
|
||||
var _x0 = _ppx + safe_mod(i, col) * _pw;
|
||||
var _y0 = pal_y + floor(i / col) * _ph;
|
||||
|
||||
draw_rectangle(_x0, _y0 + 1, _x0 + _pw, _y0 + _ph, false);
|
||||
|
@ -127,17 +172,43 @@ function Panel_Palette_Mixer() : PanelContent() constructor {
|
|||
}
|
||||
|
||||
if(cx) draw_sprite_stretched_ext(THEME.palette_selecting, 0, cx - _pd, cy + 1 - _pd, _pw + _pd * 2, _ph + _pd * 2);
|
||||
|
||||
var _bx = pal_x;
|
||||
var _by = pal_y;
|
||||
var _bs = ui(24);
|
||||
|
||||
if(buttonInstant(THEME.button_hide, _bx, _by, _bs, pal_h, [ mx, my ], pFOCUS, pHOVER, "", THEME.hamburger_s) == 2) {
|
||||
// DRAGGING = { type: "Palette", data: palette }
|
||||
// MESSAGE = DRAGGING;
|
||||
|
||||
menuCall("",,, [
|
||||
menuItem("Save palette as...", function() {
|
||||
var _path = get_save_filename_pxc("Hex paleete|*.hex", "Palette");
|
||||
if(_path != "") {
|
||||
var _str = palette_string_hex(palette, false);
|
||||
file_text_write_all(_path, _str);
|
||||
|
||||
var noti = log_message("PALETTE", $"Export palette complete.", THEME.noti_icon_tick, COLORS._main_value_positive, false);
|
||||
noti.path = _path;
|
||||
noti.setOnClick(function() { shellOpenExplorer(self.path); }, "Open in explorer", THEME.explorer);
|
||||
}
|
||||
}),
|
||||
]);
|
||||
}
|
||||
#endregion
|
||||
|
||||
var px = padding;
|
||||
var py = padding;
|
||||
var pw = w - padding - padding;
|
||||
var ph = h - padding - padding - pal_h - ui(16);
|
||||
if(in_dialog) ph -= ui(4);
|
||||
|
||||
draw_sprite_stretched(THEME.ui_panel_bg, 1, px - ui(8), py - ui(8), pw + ui(16), ph + ui(16));
|
||||
if(in_dialog)
|
||||
draw_sprite_stretched(THEME.ui_panel_bg, 1, px - ui(8), py - ui(8), pw + ui(16), ph + ui(16 - 4));
|
||||
else
|
||||
ph -= ui(8);
|
||||
|
||||
content = surface_verify(content, pw, ph);
|
||||
connect_surf = surface_verify(connect_surf, pw, ph);
|
||||
content_surf = surface_verify(content_surf, pw, ph);
|
||||
|
||||
var _mx_x = pw / 2 + mixer_x;
|
||||
var _mx_y = ph / 2 + mixer_y;
|
||||
|
@ -149,7 +220,7 @@ function Panel_Palette_Mixer() : PanelContent() constructor {
|
|||
var _mmy = my - py - _mx_y;
|
||||
|
||||
#region draw mixer
|
||||
surface_set_target(content)
|
||||
surface_set_target(connect_surf)
|
||||
DRAW_CLEAR
|
||||
|
||||
var _gs = node_size;
|
||||
|
@ -157,11 +228,13 @@ function Panel_Palette_Mixer() : PanelContent() constructor {
|
|||
var _ind = noone;
|
||||
var _hov = node_hovering;
|
||||
var _con_hover = conn_hovering;
|
||||
var _bln_hover = blnd_hovering;
|
||||
var _con_rat = 0;
|
||||
var _pHover = pHOVER && point_in_rectangle(mx, my, px, py, px + pw, py + ph);
|
||||
|
||||
node_hovering = noone;
|
||||
conn_hovering = noone;
|
||||
blnd_hovering = noone;
|
||||
|
||||
for (var i = 0, n = array_length(_connections); i < n; i++) {
|
||||
var conn = _connections[i];
|
||||
|
@ -175,9 +248,15 @@ function Panel_Palette_Mixer() : PanelContent() constructor {
|
|||
var _toy = round(_mx_y + _to.y);
|
||||
|
||||
var _hv = _hov == noone && _con_hover == i;
|
||||
if(!key_mod_press(SHIFT)) {
|
||||
draw_set_alpha(0.75);
|
||||
draw_line_width_color(_frx, _fry, _tox, _toy, (_hv? 8 : 4) + 2, c_white, c_white);
|
||||
draw_set_alpha(1);
|
||||
}
|
||||
|
||||
draw_line_width_color(_frx, _fry, _tox, _toy, _hv? 8 : 4, _fr.color, _to.color);
|
||||
|
||||
if(distance_to_line(_msx, _msy, _frx, _fry, _tox, _toy) < 6) {
|
||||
if(_pHover && _bln_hover == noone && distance_to_line(_msx, _msy, _frx, _fry, _tox, _toy) < 6) {
|
||||
conn_hovering = i;
|
||||
|
||||
var _d0 = point_distance(_frx, _fry, _msx, _msy);
|
||||
|
@ -186,6 +265,27 @@ function Panel_Palette_Mixer() : PanelContent() constructor {
|
|||
}
|
||||
}
|
||||
|
||||
var _bs = node_size * 0.75;
|
||||
for (var i = 0, n = array_length(_blends); i < n; i++) {
|
||||
var _blend = _blends[i];
|
||||
|
||||
var _c = _blend.color;
|
||||
var _px = round(_mx_x + _blend.x);
|
||||
var _py = round(_mx_y + _blend.y);
|
||||
var _hv = _pHover && point_in_rectangle(_msx, _msy, _px - _bs / 2, _py - _bs / 2, _px + _bs / 2, _py + _bs / 2);
|
||||
|
||||
draw_sprite_stretched_ext(THEME.menu_button_mask, 0, _px - _bs / 2, _py - _bs / 2, _bs, _bs, _c, 1);
|
||||
|
||||
if(key_mod_press(SHIFT))
|
||||
continue;
|
||||
|
||||
BLEND_ADD
|
||||
draw_sprite_stretched_ext(THEME.menu_button_mask, 1, _px - _bs / 2, _py - _bs / 2, _bs, _bs, c_white, 0.25 + 0.5 * (_bln_hover == i));
|
||||
BLEND_NORMAL
|
||||
|
||||
if(_hv) blnd_hovering = i;
|
||||
}
|
||||
|
||||
if(connection_drag >= 0) {
|
||||
var _fr = _palettes[connection_drag];
|
||||
|
||||
|
@ -200,6 +300,10 @@ function Panel_Palette_Mixer() : PanelContent() constructor {
|
|||
} else
|
||||
draw_line_width_color(_frx, _fry, _msx, _msy, 8, _fr.color, _fr.color);
|
||||
}
|
||||
surface_reset_target();
|
||||
|
||||
surface_set_target(content_surf)
|
||||
DRAW_CLEAR
|
||||
|
||||
for (var i = 0, n = array_length(_palettes); i < n; i++) {
|
||||
var pal = _palettes[i];
|
||||
|
@ -209,15 +313,18 @@ function Panel_Palette_Mixer() : PanelContent() constructor {
|
|||
var _py = round(_mx_y + pal.y);
|
||||
var _hv = _pHover && point_in_rectangle(_msx, _msy, _px - _gs2, _py - _gs2, _px + _gs2, _py + _gs2);
|
||||
|
||||
draw_sprite_stretched(THEME.button_def, _hov == pal, _px - _gs2, _py - _gs2, _gs, _gs);
|
||||
if(!key_mod_press(SHIFT))
|
||||
draw_sprite_stretched(THEME.button_def, _hov == pal, _px - _gs2, _py - _gs2, _gs, _gs);
|
||||
draw_sprite_stretched_ext(THEME.menu_button_mask, 0, _px - _gs2 + 2, _py - _gs2 + 2, _gs - 4, _gs - 4, _c, 1);
|
||||
|
||||
if(key_mod_press(SHIFT)) continue;
|
||||
|
||||
BLEND_ADD
|
||||
draw_sprite_stretched_ext(THEME.button_def, 3, _px - _gs2 + 2, _py - _gs2 + 2, _gs - 4, _gs - 4, c_white, 0.25);
|
||||
draw_sprite_stretched_ext(THEME.menu_button_mask, 1, _px - _gs2 + 2, _py - _gs2 + 2, _gs - 4, _gs - 4, c_white, 0.25);
|
||||
BLEND_NORMAL
|
||||
|
||||
if(pal == node_selecting)
|
||||
draw_sprite_stretched_ext(THEME.button_def, 3, _px - _gs2, _py - _gs2, _gs, _gs, COLORS._main_accent, 1);
|
||||
draw_sprite_stretched_ext(THEME.menu_button_mask, 1, _px - _gs2, _py - _gs2, _gs, _gs, COLORS._main_accent, 1);
|
||||
|
||||
if(_hv) {
|
||||
node_hovering = pal;
|
||||
|
@ -251,18 +358,45 @@ function Panel_Palette_Mixer() : PanelContent() constructor {
|
|||
if(mouse_press(mb_right))
|
||||
connection_drag = _ind;
|
||||
|
||||
} else if(blnd_hovering != noone) {
|
||||
|
||||
if(mouse_click(mb_left)) {
|
||||
node_selecting = noone;
|
||||
CURRENT_COLOR = palette_data.blends[blnd_hovering].color;
|
||||
}
|
||||
|
||||
if(mouse_press(mb_right)) {
|
||||
conn_menu_ctx = [ blnd_hovering ];
|
||||
|
||||
menuCall(,,, [
|
||||
menuItem("Delete Blend point", function() { array_delete(palette_data.blends, conn_menu_ctx[0], 1); } ),
|
||||
]);
|
||||
}
|
||||
|
||||
} else if(conn_hovering != noone) {
|
||||
var conn = palette_data.connections[conn_hovering];
|
||||
var _fr = _palettes[conn[0]];
|
||||
var _to = _palettes[conn[1]];
|
||||
|
||||
var _cc = merge_color(_fr.color, _to.color, _con_rat);
|
||||
var _xx = lerp(_fr.x, _to.x, _con_rat);
|
||||
var _yy = lerp(_fr.y, _to.y, _con_rat);
|
||||
var _gs = ui(16);
|
||||
|
||||
_xx = round(_mx_x + _xx);
|
||||
_yy = round(_mx_y + _yy);
|
||||
|
||||
draw_sprite_stretched_ext(THEME.menu_button_mask, 0, _xx - _gs / 2, _yy - _gs / 2, _gs, _gs, _cc, 1);
|
||||
|
||||
BLEND_ADD
|
||||
draw_sprite_stretched_ext(THEME.button_def, 3, _xx - _gs / 2, _yy - _gs / 2, _gs, _gs, c_white, 0.25);
|
||||
BLEND_NORMAL
|
||||
|
||||
if(DOUBLE_CLICK) {
|
||||
var conn = palette_data.connections[conn_hovering];
|
||||
var _fr = _palettes[conn[0]];
|
||||
var _to = _palettes[conn[1]];
|
||||
|
||||
var _cc = merge_color(_fr.color, _to.color, _con_rat);
|
||||
var _node = {
|
||||
color : _cc,
|
||||
x : lerp(_fr.x, _to.x, _con_rat),
|
||||
y : lerp(_fr.y, _to.y, _con_rat)
|
||||
x : _xx - _mx_x,
|
||||
y : _yy - _mx_y,
|
||||
};
|
||||
|
||||
var _idx = array_length(palette_data.nodes);
|
||||
|
@ -277,11 +411,25 @@ function Panel_Palette_Mixer() : PanelContent() constructor {
|
|||
save_palette_mixer(palette_data);
|
||||
}
|
||||
|
||||
} else {
|
||||
if(_pHover && mouse_press(mb_left))
|
||||
if(mouse_click(mb_left)) {
|
||||
node_selecting = noone;
|
||||
CURRENT_COLOR = _cc;
|
||||
}
|
||||
|
||||
if(mouse_press(mb_right)) {
|
||||
conn_menu_ctx = [ conn[0], conn[1], _con_rat ];
|
||||
|
||||
menuCall(,,, [
|
||||
menuItem("New Blend point", function() { array_push(palette_data.blends, { from : conn_menu_ctx[0], to : conn_menu_ctx[1], amount : conn_menu_ctx[2] }) } ),
|
||||
]);
|
||||
}
|
||||
|
||||
} else if(_pHover) {
|
||||
|
||||
if(mouse_press(mb_left))
|
||||
node_selecting = noone;
|
||||
|
||||
if(_pHover && DOUBLE_CLICK) {
|
||||
if(DOUBLE_CLICK) {
|
||||
var _node = { color : cola(c_black), x : value_snap(_mmx, 8), y : value_snap(_mmy, 8) };
|
||||
array_push(palette_data.nodes, _node);
|
||||
node_selecting = _node;
|
||||
|
@ -293,6 +441,23 @@ function Panel_Palette_Mixer() : PanelContent() constructor {
|
|||
|
||||
save_palette_mixer(palette_data);
|
||||
}
|
||||
|
||||
if(mouse_press(mb_right)) {
|
||||
menuCall(,,, [
|
||||
menuItem("Center view", function() { centerView(); } ),
|
||||
-1,
|
||||
menuItem("Save mixed...", function() {
|
||||
var _path = get_save_filename_pxc("JSON|*.json", "New mixed");
|
||||
if(_path != "") save_palette_mixer(palette_data, _path);
|
||||
}),
|
||||
menuItem("Load mixed...", function() {
|
||||
var _path = get_open_filename_pxc("JSON|*.json", "");
|
||||
if(_path != "") palette_data = load_palette_mixer(_path);
|
||||
}),
|
||||
-1,
|
||||
menuItem("Clear palette", function() { palette_data = { nodes: [], connections: [], blends: [], } }, THEME.cross),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
if(connection_drag >= 0) {
|
||||
|
@ -338,7 +503,8 @@ function Panel_Palette_Mixer() : PanelContent() constructor {
|
|||
if(node_selecting) {
|
||||
node_selecting.color = CURRENT_COLOR;
|
||||
|
||||
if(keyboard_check_pressed(vk_delete)) {
|
||||
if(keyboard_check_pressed(vk_delete)) { /////////////////// NODE DELETE
|
||||
|
||||
var _delId = array_find(_palettes, node_selecting);
|
||||
|
||||
array_delete(_palettes, _delId, 1);
|
||||
|
@ -354,6 +520,17 @@ function Panel_Palette_Mixer() : PanelContent() constructor {
|
|||
}
|
||||
}
|
||||
|
||||
for (var i = array_length(_blends) - 1; i >= 0; i--) {
|
||||
var _blend = _blends[i];
|
||||
|
||||
if(_blend.from == _delId || _blend.to == _delId)
|
||||
array_delete(palette_data.connections, i, 1);
|
||||
else {
|
||||
if(_blend.from > _delId) _blend.from--;
|
||||
if(_blend.to > _delId) _blend.to--;
|
||||
}
|
||||
}
|
||||
|
||||
save_palette_mixer(palette_data);
|
||||
}
|
||||
}
|
||||
|
@ -371,7 +548,17 @@ function Panel_Palette_Mixer() : PanelContent() constructor {
|
|||
surface_reset_target();
|
||||
#endregion
|
||||
|
||||
draw_surface(content, px, py);
|
||||
shader_set(sh_FXAA);
|
||||
gpu_set_tex_filter(true);
|
||||
shader_set_f("dimension", pw, ph);
|
||||
shader_set_f("cornerDis", 0.5);
|
||||
shader_set_f("mixAmo", 1);
|
||||
|
||||
draw_surface(connect_surf, px, py);
|
||||
gpu_set_tex_filter(false);
|
||||
shader_reset();
|
||||
|
||||
draw_surface(content_surf, px, py);
|
||||
|
||||
if(_pHover && mouse_press(mb_middle)) {
|
||||
mixer_dragging = true;
|
||||
|
@ -390,34 +577,65 @@ function Panel_Palette_Mixer() : PanelContent() constructor {
|
|||
}
|
||||
|
||||
draw_set_text(f_p2, fa_right, fa_bottom, COLORS._main_text_sub);
|
||||
if(node_hovering)
|
||||
draw_text(px + pw, py + ph + ui(4), $"Node #{color_get_hex(node_hovering.color)}");
|
||||
var _gs = ui(16);
|
||||
var _nhx = px + pw - _gs;
|
||||
var _nhy = py + ph + ui(4);
|
||||
var _cc = noone;
|
||||
var _txt = "";
|
||||
|
||||
if(node_hovering) {
|
||||
_cc = node_hovering.color;
|
||||
_txt = $"Node #{color_get_hex(node_hovering.color)}";
|
||||
|
||||
else if(conn_hovering >= 0) {
|
||||
} else if(blnd_hovering >= 0) {
|
||||
_cc = palette_data.blends[blnd_hovering].color;
|
||||
_txt = $"Blend point #{color_get_hex(_cc)}";
|
||||
|
||||
} else if(conn_hovering >= 0) {
|
||||
var conn = palette_data.connections[conn_hovering];
|
||||
var _fr = _palettes[conn[0]];
|
||||
var _to = _palettes[conn[1]];
|
||||
_cc = merge_color(_fr.color, _to.color, _con_rat);
|
||||
_txt = $"Connection #{color_get_hex(_fr.color)} - #{color_get_hex(_to.color)} [{round(_con_rat * 100)}%]";
|
||||
|
||||
draw_text(px + pw, py + ph + ui(4), $"Connection #{color_get_hex(_fr.color)} - #{color_get_hex(_to.color)} [{round(_con_rat * 100)}%]");
|
||||
}
|
||||
|
||||
if(_cc != noone) {
|
||||
draw_sprite_stretched_ext(THEME.menu_button_mask, 0, _nhx, _nhy - _gs, _gs, _gs, _cc, 1);
|
||||
BLEND_ADD
|
||||
draw_sprite_stretched_ext(THEME.button_def, 3, _nhx, _nhy - _gs, _gs, _gs, c_white, 0.25);
|
||||
BLEND_NORMAL
|
||||
|
||||
draw_text(_nhx - ui(4), _nhy, _txt);
|
||||
}
|
||||
|
||||
if(pHOVER && key_mod_press(CTRL)) {
|
||||
if(mouse_wheel_down()) node_size_to = clamp(node_size_to - ui(4), ui(12), ui(64));
|
||||
if(mouse_wheel_up()) node_size_to = clamp(node_size_to + ui(4), ui(12), ui(64));
|
||||
}
|
||||
node_size = lerp_float(node_size, node_size_to, 3);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function save_palette_mixer(data) {
|
||||
function save_palette_mixer(data, path = "") {
|
||||
var _dirr = $"{DIRECTORY}/Palettes/Mixer";
|
||||
directory_verify(_dirr);
|
||||
|
||||
var _path = _dirr + "/current.json";
|
||||
var _path = path == ""? _dirr + "/current.json" : path;
|
||||
|
||||
json_save_struct(_path, data);
|
||||
}
|
||||
|
||||
function load_palette_mixer() {
|
||||
function load_palette_mixer(path = "") {
|
||||
var _dirr = $"{DIRECTORY}/Palettes/Mixer";
|
||||
directory_verify(_dirr);
|
||||
|
||||
var _path = _dirr + "/current.json";
|
||||
var _path = path == ""? _dirr + "/current.json" : path;
|
||||
if(!file_exists(_path)) return noone;
|
||||
|
||||
return json_load_struct(_path);
|
||||
var _str = json_load_struct(_path);
|
||||
if(!struct_has(_str, "blends")) _str.blends = [];
|
||||
|
||||
return _str;
|
||||
}
|
Loading…
Reference in a new issue