mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2025-03-04 06:34:48 +01:00
[Palette] Fix jittering when a palette contain duplicate colors.
This commit is contained in:
parent
8beb6fbb89
commit
374f885d9c
9 changed files with 179 additions and 158 deletions
|
@ -600,6 +600,7 @@
|
|||
{"name":"dynaDraw_circle_fill_gradient","order":2,"path":"scripts/dynaDraw_circle_fill_gradient/dynaDraw_circle_fill_gradient.yy",},
|
||||
{"name":"dynaDraw_circle_fill","order":1,"path":"scripts/dynaDraw_circle_fill/dynaDraw_circle_fill.yy",},
|
||||
{"name":"dynaDraw_circle_outline","order":3,"path":"scripts/dynaDraw_circle_outline/dynaDraw_circle_outline.yy",},
|
||||
{"name":"dynaDraw_line","order":10,"path":"scripts/dynaDraw_line/dynaDraw_line.yy",},
|
||||
{"name":"dynaDraw_polygon_fill_gradient","order":8,"path":"scripts/dynaDraw_polygon_fill_gradient/dynaDraw_polygon_fill_gradient.yy",},
|
||||
{"name":"dynaDraw_polygon_fill","order":7,"path":"scripts/dynaDraw_polygon_fill/dynaDraw_polygon_fill.yy",},
|
||||
{"name":"dynaDraw_polygon_outline","order":9,"path":"scripts/dynaDraw_polygon_outline/dynaDraw_polygon_outline.yy",},
|
||||
|
@ -2080,7 +2081,6 @@
|
|||
{"name":"s_node_feedback","order":3,"path":"sprites/s_node_feedback/s_node_feedback.yy",},
|
||||
{"name":"s_node_fft","order":4,"path":"sprites/s_node_fft/s_node_fft.yy",},
|
||||
{"name":"s_node_filter_array","order":28,"path":"sprites/s_node_filter_array/s_node_filter_array.yy",},
|
||||
{"name":"dynaDraw_line","order":10,"path":"scripts/dynaDraw_line/dynaDraw_line.yy",},
|
||||
{"name":"s_node_find_pixel","order":10,"path":"sprites/s_node_find_pixel/s_node_find_pixel.yy",},
|
||||
{"name":"s_node_flip_add_collider","order":1,"path":"sprites/s_node_flip_add_collider/s_node_flip_add_collider.yy",},
|
||||
{"name":"s_node_flip_apply_force","order":13,"path":"sprites/s_node_flip_apply_force/s_node_flip_apply_force.yy",},
|
||||
|
|
|
@ -1317,7 +1317,11 @@
|
|||
{"$GMIncludedFile":"","%Name":"Canvas.png","CopyToMask":-1,"filePath":"datafiles/data/Welcome files/Templates","name":"Canvas.png","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
{"$GMIncludedFile":"","%Name":"Canvas.pxc","CopyToMask":-1,"filePath":"datafiles/data/Welcome files/Templates","name":"Canvas.pxc","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
{"$GMIncludedFile":"","%Name":"Welcome files.zip","CopyToMask":-1,"filePath":"datafiles/data/Welcome files","name":"Welcome files.zip","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
{"$GMIncludedFile":"","%Name":"dllcredits.txt","ConfigValues":{"Itch":{"CopyToMask":"0",},},"CopyToMask":0,"filePath":"datafiles","name":"dllcredits.txt","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
{"$GMIncludedFile":"","%Name":"dllcredits.txt","ConfigValues":{
|
||||
"Itch":{
|
||||
"CopyToMask":"0",
|
||||
},
|
||||
},"CopyToMask":0,"filePath":"datafiles","name":"dllcredits.txt","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
{"$GMIncludedFile":"","%Name":"dlltest1.dll","CopyToMask":-1,"filePath":"datafiles","name":"dlltest1.dll","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
{"$GMIncludedFile":"","%Name":"ffmpeg.exe","CopyToMask":-1,"filePath":"datafiles/ffmpeg/bin","name":"ffmpeg.exe","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
{"$GMIncludedFile":"","%Name":"LICENSE","CopyToMask":-1,"filePath":"datafiles/ffmpeg","name":"LICENSE","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
|
@ -1336,7 +1340,11 @@
|
|||
{"$GMIncludedFile":"","%Name":"mf.dll","CopyToMask":-1,"filePath":"datafiles","name":"mf.dll","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
{"$GMIncludedFile":"","%Name":"mfcore.dll","CopyToMask":-1,"filePath":"datafiles","name":"mfcore.dll","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
{"$GMIncludedFile":"","%Name":"mfplat.dll","CopyToMask":-1,"filePath":"datafiles","name":"mfplat.dll","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
{"$GMIncludedFile":"","%Name":"PixelComposer_profile-2.provisionprofile","ConfigValues":{"Itch":{"CopyToMask":"2",},},"CopyToMask":-1,"filePath":"datafiles","name":"PixelComposer_profile-2.provisionprofile","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
{"$GMIncludedFile":"","%Name":"PixelComposer_profile-2.provisionprofile","ConfigValues":{
|
||||
"Itch":{
|
||||
"CopyToMask":"2",
|
||||
},
|
||||
},"CopyToMask":-1,"filePath":"datafiles","name":"PixelComposer_profile-2.provisionprofile","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
{"$GMIncludedFile":"","%Name":"data.win","CopyToMask":-1,"filePath":"datafiles/report","name":"data.win","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
{"$GMIncludedFile":"","%Name":"execute_shell_simple_ext_x64.dll","CopyToMask":-1,"filePath":"datafiles/report","name":"execute_shell_simple_ext_x64.dll","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
{"$GMIncludedFile":"","%Name":"options.ini","CopyToMask":-1,"filePath":"datafiles/report","name":"options.ini","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
|
@ -1643,7 +1651,6 @@
|
|||
{"id":{"name":"canvas_tool_outline","path":"scripts/canvas_tool_outline/canvas_tool_outline.yy",},},
|
||||
{"id":{"name":"canvas_tool_resize","path":"scripts/canvas_tool_resize/canvas_tool_resize.yy",},},
|
||||
{"id":{"name":"canvas_tool_selection_brush","path":"scripts/canvas_tool_selection_brush/canvas_tool_selection_brush.yy",},},
|
||||
{"id":{"name":"dynaDraw_line","path":"scripts/dynaDraw_line/dynaDraw_line.yy",},},
|
||||
{"id":{"name":"canvas_tool_selection_freeform","path":"scripts/canvas_tool_selection_freeform/canvas_tool_selection_freeform.yy",},},
|
||||
{"id":{"name":"canvas_tool_selection_magic","path":"scripts/canvas_tool_selection_magic/canvas_tool_selection_magic.yy",},},
|
||||
{"id":{"name":"canvas_tool_selection_shape","path":"scripts/canvas_tool_selection_shape/canvas_tool_selection_shape.yy",},},
|
||||
|
@ -1750,6 +1757,7 @@
|
|||
{"id":{"name":"dynaDraw_circle_fill_gradient","path":"scripts/dynaDraw_circle_fill_gradient/dynaDraw_circle_fill_gradient.yy",},},
|
||||
{"id":{"name":"dynaDraw_circle_fill","path":"scripts/dynaDraw_circle_fill/dynaDraw_circle_fill.yy",},},
|
||||
{"id":{"name":"dynaDraw_circle_outline","path":"scripts/dynaDraw_circle_outline/dynaDraw_circle_outline.yy",},},
|
||||
{"id":{"name":"dynaDraw_line","path":"scripts/dynaDraw_line/dynaDraw_line.yy",},},
|
||||
{"id":{"name":"dynaDraw_polygon_fill_gradient","path":"scripts/dynaDraw_polygon_fill_gradient/dynaDraw_polygon_fill_gradient.yy",},},
|
||||
{"id":{"name":"dynaDraw_polygon_fill","path":"scripts/dynaDraw_polygon_fill/dynaDraw_polygon_fill.yy",},},
|
||||
{"id":{"name":"dynaDraw_polygon_outline","path":"scripts/dynaDraw_polygon_outline/dynaDraw_polygon_outline.yy",},},
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -55,7 +55,6 @@
|
|||
dialog_drag_mx = 0;
|
||||
dialog_drag_my = 0;
|
||||
mouse_draggable = true;
|
||||
|
||||
passthrough = false;
|
||||
|
||||
function doDrag() {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/// @description init
|
||||
if !ready exit;
|
||||
draggable = true;
|
||||
|
||||
#region dropper
|
||||
selector.interactable = interactable;
|
||||
|
@ -101,7 +102,11 @@ if !ready exit;
|
|||
var bx = content_x + content_w - ui(50);
|
||||
var by = dialog_y + ui(16);
|
||||
|
||||
if(buttonInstant(THEME.button_hide_fill, bx, by, ui(28), ui(28), mouse_ui, _hov, _foc, __txtx("gradient_editor_key_blend", "Key blending"), THEME.grad_blend) == 2) {
|
||||
var t = __txtx("gradient_editor_key_blend", "Key blending");
|
||||
var b = buttonInstant(THEME.button_hide_fill, bx, by, ui(28), ui(28), mouse_ui, _hov, _foc, t, THEME.gradient_keys_blend, 0, COLORS._main_icon_light);
|
||||
draggable &= !b;
|
||||
|
||||
if(b == 2) {
|
||||
menuCall("gradient_window_blend_menu", [
|
||||
menuItem(__txtx("gradient_editor_blend_hard", "Solid"), function() { gradient.type = 1; onApply(gradient); }),
|
||||
menuItem(__txtx("gradient_editor_blend_RGB", "RGB"), function() { gradient.type = 0; onApply(gradient); }),
|
||||
|
@ -111,7 +116,11 @@ if !ready exit;
|
|||
}
|
||||
bx -= ui(32);
|
||||
|
||||
if(buttonInstant(THEME.button_hide_fill, bx, by, ui(28), ui(28), mouse_ui, _hov, _foc, __txtx("gradient_editor_reverse", "Reverse"), THEME.reverse) == 2) {
|
||||
var t = __txtx("gradient_editor_reverse", "Reverse");
|
||||
var b = buttonInstant(THEME.button_hide_fill, bx, by, ui(28), ui(28), mouse_ui, _hov, _foc, t, THEME.gradient_keys_reverse, 0, COLORS._main_icon_light);
|
||||
draggable &= !b;
|
||||
|
||||
if(b == 2) {
|
||||
for( var i = 0, n = array_length(gradient.keys); i < n; i++ )
|
||||
gradient.keys[i].time = 1 - gradient.keys[i].time;
|
||||
gradient.keys = array_reverse(gradient.keys);
|
||||
|
@ -119,7 +128,11 @@ if !ready exit;
|
|||
}
|
||||
bx -= ui(32);
|
||||
|
||||
if(buttonInstant(THEME.button_hide_fill, bx, by, ui(28), ui(28), mouse_ui, _hov, _foc, __txt("Distribute"), THEME.obj_distribute_h) == 2) {
|
||||
var t = __txt("Distribute");
|
||||
var b = buttonInstant(THEME.button_hide_fill, bx, by, ui(28), ui(28), mouse_ui, _hov, _foc, t, THEME.gradient_keys_distribute, 0, COLORS._main_icon_light);
|
||||
draggable &= !b;
|
||||
|
||||
if(b == 2) {
|
||||
var _stp = 1 / (array_length(gradient.keys) - (gradient.type != 1));
|
||||
|
||||
for( var i = 0, n = array_length(gradient.keys); i < n; i++ )
|
||||
|
@ -152,7 +165,7 @@ if !ready exit;
|
|||
_k._hover = lerp_float(_k._hover, _hov, 5);
|
||||
|
||||
var _kw = ui(12);
|
||||
var _kh = lerp(ui(24), ui(32), _k._hover);
|
||||
var _kh = lerp(ui(12), ui(32), _k._hover);
|
||||
|
||||
var _kdx = _kx - _kw / 2;
|
||||
var _kdy = _ky - _kh / 2;
|
||||
|
@ -161,11 +174,11 @@ if !ready exit;
|
|||
draw_sprite_stretched_ext(THEME.prop_gradient, 0, _kdx, _kdy, _kw, _kh, _c, _aa);
|
||||
|
||||
if(key_selecting == _k || key_dragging == _k) {
|
||||
draw_sprite_stretched_ext(THEME.prop_gradient, 1, _kdx, _kdy, _kw, _kh, COLORS._main_accent, _aa);
|
||||
draw_sprite_stretched_ext(THEME.prop_gradient, 1, _kdx, _kdy, _kw, _kh, _color_get_light(_c) < 0.75? c_white : c_black, _aa);
|
||||
draw_sprite_stretched_ext(THEME.prop_gradient, 2, _kdx, _kdy, _kw, _kh, COLORS._main_accent, _aa);
|
||||
|
||||
} else {
|
||||
if(_color_get_light(_c) < 0.75) draw_sprite_stretched_ext(THEME.prop_gradient, 1, _kdx, _kdy, _kw, _kh, c_white, _aa);
|
||||
else draw_sprite_stretched_ext(THEME.prop_gradient, 1, _kdx, _kdy, _kw, _kh, c_black, _aa);
|
||||
draw_sprite_stretched_ext(THEME.prop_gradient, 2, _kdx, _kdy, _kw, _kh, _color_get_light(_c) < 0.75? c_white : c_black, _aa);
|
||||
}
|
||||
|
||||
if(_hov) hover = _k;
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
/// @description init
|
||||
event_inherited();
|
||||
|
||||
function __PaletteColor(_color = c_black) constructor {
|
||||
color = _color;
|
||||
x = 0;
|
||||
y = 0;
|
||||
}
|
||||
|
||||
#region data
|
||||
dialog_w = ui(812);
|
||||
dialog_h = ui(440);
|
||||
|
@ -9,6 +15,7 @@ event_inherited();
|
|||
|
||||
name = __txtx("palette_editor_title", "Palette editor");
|
||||
palette = 0;
|
||||
paletteObject = [];
|
||||
|
||||
index_sel_start = 0;
|
||||
index_selecting = [ 0, 0 ];
|
||||
|
@ -27,14 +34,15 @@ event_inherited();
|
|||
|
||||
palette_positions = {}
|
||||
|
||||
setColor = function(color) {
|
||||
setColor = function(c) /*=>*/ {
|
||||
if(index_selecting[1] != 1 || palette == 0) return;
|
||||
|
||||
palette[index_selecting[0]] = color;
|
||||
var _ind = index_selecting[0];
|
||||
palette[_ind] = c;
|
||||
paletteObject[_ind].color = c;
|
||||
|
||||
if(onApply == noone) return;
|
||||
onApply(palette);
|
||||
}
|
||||
if(onApply != noone) onApply(palette);
|
||||
};
|
||||
|
||||
onApply = noone;
|
||||
selector = new colorSelector(setColor);
|
||||
|
@ -42,33 +50,12 @@ event_inherited();
|
|||
selector.discretize_pal = false;
|
||||
|
||||
previous_palette = c_black;
|
||||
|
||||
selection_surface = surface_create(1, 1);
|
||||
|
||||
function setDefault(pal) {
|
||||
setPalette(pal);
|
||||
previous_palette = array_clone(pal);
|
||||
}
|
||||
|
||||
b_cancel = button(function() {
|
||||
onApply(previous_palette);
|
||||
instance_destroy();
|
||||
}).setIcon(THEME.undo, 0, COLORS._main_icon)
|
||||
b_cancel = button(function() /*=>*/ { onApply(previous_palette); instance_destroy(); }).setIcon(THEME.undo, 0, COLORS._main_icon)
|
||||
.setTooltip(__txtx("dialog_revert_and_exit", "Revert and exit"));
|
||||
b_apply = button(function() /*=>*/ { onApply(palette); instance_destroy(); }).setIcon(THEME.accept, 0, COLORS._main_icon_dark);
|
||||
|
||||
b_apply = button(function() {
|
||||
onApply(palette);
|
||||
instance_destroy();
|
||||
}).setIcon(THEME.accept, 0, COLORS._main_icon_dark);
|
||||
|
||||
function setPalette(pal) {
|
||||
palette = pal;
|
||||
index_selecting = [ 0, 0 ];
|
||||
if(!array_empty(palette))
|
||||
selector.setColor(palette[0]);
|
||||
|
||||
palette_positions = {};
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region presets
|
||||
|
@ -76,10 +63,10 @@ event_inherited();
|
|||
|
||||
pal_padding = ui(9);
|
||||
sp_preset_w = ui(240) - pal_padding * 2 - ui(8);
|
||||
|
||||
sp_presets = new scrollPane(sp_preset_w, dialog_h - ui(48 + 8) - pal_padding, function(_y, _m) {
|
||||
draw_clear_alpha(COLORS.panel_bg_clear, 0);
|
||||
|
||||
var _foc = interactable && sFOCUS;
|
||||
var ww = sp_presets.surface_w;
|
||||
var _gs = ui(20);
|
||||
var hh = ui(24);
|
||||
|
@ -110,20 +97,17 @@ event_inherited();
|
|||
drawPalette(pal.palette, pd, yy + nh, _ww, _gs);
|
||||
|
||||
if(isHover) {
|
||||
if(mouse_press(mb_left, interactable && sFOCUS)) {
|
||||
palette = array_clone(pal.palette);
|
||||
if(mouse_press(mb_left, _foc)) {
|
||||
setPalette(array_clone(pal.palette));
|
||||
onApply(palette);
|
||||
|
||||
index_selecting = [ 0, 0 ];
|
||||
selector.setColor(palette[0], false);
|
||||
}
|
||||
|
||||
if(i >= 0 && mouse_press(mb_right, interactable && sFOCUS)) {
|
||||
if(i >= 0 && mouse_press(mb_right, _foc)) {
|
||||
hovering = pal;
|
||||
|
||||
menuCall("palette_window_preset_menu", [
|
||||
menuItem(__txtx("palette_editor_set_default", "Set as default"), function() { PROJECT.setPalette(array_clone(hovering.palette)); }),
|
||||
menuItem(__txtx("palette_editor_delete", "Delete palette"), function() { file_delete(hovering.path); __initPalette(); }),
|
||||
menuItem(__txtx("palette_editor_set_default", "Set as default"), function() /*=>*/ { PROJECT.setPalette(array_clone(hovering.palette)); }),
|
||||
menuItem(__txtx("palette_editor_delete", "Delete palette"), function() /*=>*/ { file_delete(hovering.path); __initPalette(); }),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -135,27 +119,49 @@ event_inherited();
|
|||
return hh;
|
||||
});
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region tools
|
||||
#region functions
|
||||
function refreshPaletteObject() {
|
||||
if(palette == 0) return;
|
||||
|
||||
paletteObject = array_verify_ext(paletteObject, array_length(palette), function() /*=>*/ {return new __PaletteColor()});
|
||||
for( var i = 0, n = array_length(palette); i < n; i++ ) paletteObject[i].color = palette[i];
|
||||
}
|
||||
|
||||
function refreshPalette() {
|
||||
palette = [];
|
||||
for( var i = 0, n = array_length(paletteObject); i < n; i++ )
|
||||
palette[i] = paletteObject[i].color;
|
||||
|
||||
onApply(palette);
|
||||
}
|
||||
|
||||
function sortPalette(sortFunc) {
|
||||
if(index_selecting[1] < 2)
|
||||
array_sort(palette, sortFunc);
|
||||
else {
|
||||
if(index_selecting[1] < 2) { array_sort(paletteObject, sortFunc); refreshPalette(); return; }
|
||||
|
||||
var _arr = array_create(index_selecting[1]);
|
||||
for(var i = 0; i < index_selecting[1]; i++)
|
||||
_arr[i] = palette[index_selecting[0] + i];
|
||||
_arr[i] = paletteObject[index_selecting[0] + i];
|
||||
array_sort(_arr, sortFunc);
|
||||
|
||||
for(var i = 0; i < index_selecting[1]; i++)
|
||||
palette[index_selecting[0] + i] = _arr[i];
|
||||
}
|
||||
onApply(palette);
|
||||
}
|
||||
#endregion
|
||||
paletteObject[index_selecting[0] + i] = _arr[i];
|
||||
|
||||
refreshPalette();
|
||||
}
|
||||
|
||||
function setDefault(pal) { setPalette(pal); previous_palette = array_clone(pal); }
|
||||
|
||||
function setPalette(pal) {
|
||||
palette = pal;
|
||||
index_selecting = [ 0, 0 ];
|
||||
palette_positions = {};
|
||||
|
||||
if(!array_empty(palette)) selector.setColor(palette[0]);
|
||||
refreshPaletteObject();
|
||||
}
|
||||
|
||||
#region action
|
||||
function onResize() { sp_presets.resize(sp_preset_w, dialog_h - ui(62)); }
|
||||
function checkMouse() {}
|
||||
#endregion
|
|
@ -1,13 +1,11 @@
|
|||
/// @description init
|
||||
if !ready exit;
|
||||
if palette == 0 exit;
|
||||
draggable = true;
|
||||
|
||||
#region dropper
|
||||
selector.interactable = interactable;
|
||||
if(selector.dropper_active) {
|
||||
selector.drawDropper(self);
|
||||
exit;
|
||||
}
|
||||
if(selector.dropper_active) { selector.drawDropper(self); exit; }
|
||||
#endregion
|
||||
|
||||
#region base UI
|
||||
|
@ -43,7 +41,8 @@ if palette == 0 exit;
|
|||
var by = dialog_y + ui(12);
|
||||
var bs = ui(28);
|
||||
|
||||
if(buttonInstant(THEME.button_hide_fill, bx, by, bs, bs, mouse_ui, sHOVER, sFOCUS, __txtx("add_preset", "Add to preset"), THEME.add_20) == 2) {
|
||||
var b = buttonInstant(THEME.button_hide_fill, bx, by, bs, bs, mouse_ui, sHOVER, sFOCUS, __txtx("add_preset", "Add to preset"), THEME.add_20);
|
||||
if(b == 2) {
|
||||
var dia = dialogCall(o_dialog_file_name, mouse_mx + ui(8), mouse_my + ui(8));
|
||||
dia.onModify = function (txt) {
|
||||
var file = file_text_open_write(txt + ".hex");
|
||||
|
@ -63,14 +62,12 @@ if palette == 0 exit;
|
|||
}
|
||||
bx -= ui(32);
|
||||
|
||||
if(buttonInstant(THEME.button_hide_fill, bx, by, bs, bs, mouse_ui, sHOVER, sFOCUS, __txt("Refresh"), THEME.refresh_20) == 2)
|
||||
__initPalette();
|
||||
var b = buttonInstant(THEME.button_hide_fill, bx, by, bs, bs, mouse_ui, sHOVER, sFOCUS, __txt("Refresh"), THEME.refresh_20);
|
||||
if(b == 2) __initPalette();
|
||||
bx -= ui(32);
|
||||
|
||||
if(buttonInstant(THEME.button_hide_fill, bx, by, bs, bs, mouse_ui, sHOVER, sFOCUS, __txtx("color_selector_open_palette", "Open palette folder"), THEME.path_open_20) == 2) {
|
||||
var _realpath = DIRECTORY + "Palettes";
|
||||
shellOpenExplorer(_realpath)
|
||||
}
|
||||
var b = buttonInstant(THEME.button_hide_fill, bx, by, bs, bs, mouse_ui, sHOVER, sFOCUS, __txtx("color_selector_open_palette", "Open palette folder"), THEME.path_open_20);
|
||||
if(b == 2) shellOpenExplorer(DIRECTORY + "Palettes")
|
||||
draw_sprite_ui_uniform(THEME.path_open_20, 1, bx + bs / 2, by + bs / 2, 1, c_white);
|
||||
bx -= ui(32);
|
||||
#endregion
|
||||
|
@ -84,37 +81,45 @@ if palette == 0 exit;
|
|||
|
||||
var _txt = index_selecting[1] < 2? __txtx("palette_editor_sort", "Sort palette") : __txtx("palette_editor_sort_selected", "Sort selected");
|
||||
var b = buttonInstant(THEME.button_hide_fill, bx, by, ui(28), ui(28), mouse_ui, sHOVER, interactable && sFOCUS, _txt, THEME.sort, 0, bc);
|
||||
if(b) mouse_draggable = false;
|
||||
if(b) {
|
||||
mouse_draggable = false;
|
||||
draggable = false;
|
||||
}
|
||||
|
||||
if(b == 2) {
|
||||
menuCall("palette_window_sort_menu", [
|
||||
menuItem(__txtx("palette_editor_sort_brighter", "Brighter"), function() { sortPalette(__sortBright); }),
|
||||
menuItem(__txtx("palette_editor_sort_darker", "Darker"), function() { sortPalette(__sortDark); }),
|
||||
menuItem(__txtx("palette_editor_sort_brighter", "Brighter"), function() /*=>*/ {return sortPalette(function(a,b) /*=>*/ {return __sortBright(a.color, b.color)})}),
|
||||
menuItem(__txtx("palette_editor_sort_darker", "Darker"), function() /*=>*/ {return sortPalette(function(a,b) /*=>*/ {return __sortDark(a.color, b.color)})}),
|
||||
-1,
|
||||
menuItem(__txtx("palette_editor_sort_hue", "Hue"), function() { sortPalette(__sortHue); }),
|
||||
menuItem(__txtx("palette_editor_sort_sat", "Saturation"), function() { sortPalette(__sortSat); }),
|
||||
menuItem(__txtx("palette_editor_sort_val", "Value"), function() { sortPalette(__sortVal); }),
|
||||
menuItem(__txtx("palette_editor_sort_hue", "Hue"), function() /*=>*/ {return sortPalette(function(a,b) /*=>*/ {return __sortHue(a.color, b.color)})}),
|
||||
menuItem(__txtx("palette_editor_sort_sat", "Saturation"), function() /*=>*/ {return sortPalette(function(a,b) /*=>*/ {return __sortSat(a.color, b.color)})}),
|
||||
menuItem(__txtx("palette_editor_sort_val", "Value"), function() /*=>*/ {return sortPalette(function(a,b) /*=>*/ {return __sortVal(a.color, b.color)})}),
|
||||
], bx + ui(32), by, fa_left, palette);
|
||||
}
|
||||
bx -= ui(32);
|
||||
|
||||
var _txt = index_selecting[1] < 2? __txtx("palette_editor_reverse", "Reverse palette") : __txtx("palette_editor_reverse_selected", "Reverse selected");
|
||||
var b = buttonInstant(THEME.button_hide_fill, bx, by, ui(28), ui(28), mouse_ui, sHOVER, interactable && sFOCUS, _txt, THEME.reverse, 0, bc);
|
||||
if(b) mouse_draggable = false;
|
||||
if(b == 2) {
|
||||
if(b) {
|
||||
mouse_draggable = false;
|
||||
draggable = false;
|
||||
}
|
||||
|
||||
if(b == 2) {
|
||||
if(index_selecting[1] < 2)
|
||||
palette = array_reverse(palette);
|
||||
paletteObject = array_reverse(paletteObject);
|
||||
|
||||
else {
|
||||
var _arr = array_create(index_selecting[1]);
|
||||
for(var i = 0; i < index_selecting[1]; i++)
|
||||
_arr[i] = palette[index_selecting[0] + i];
|
||||
_arr[i] = paletteObject[index_selecting[0] + i];
|
||||
_arr = array_reverse(_arr);
|
||||
|
||||
for(var i = 0; i < index_selecting[1]; i++)
|
||||
palette[index_selecting[0] + i] = _arr[i];
|
||||
paletteObject[index_selecting[0] + i] = _arr[i];
|
||||
}
|
||||
|
||||
onApply(palette);
|
||||
refreshPalette();
|
||||
}
|
||||
bx -= ui(32);
|
||||
#endregion
|
||||
|
@ -158,10 +163,8 @@ if palette == 0 exit;
|
|||
|
||||
var _spx = pl_x - pdd;
|
||||
var _spy = pl_y - pdd;
|
||||
var ppos = palette_positions;
|
||||
|
||||
var _hedge = false;
|
||||
var _clrRep = {};
|
||||
var _palInd = [];
|
||||
|
||||
for(var i = 0; i < row; i++)
|
||||
|
@ -169,44 +172,33 @@ if palette == 0 exit;
|
|||
var index = i * col + j;
|
||||
if(index >= _len) break;
|
||||
|
||||
var _p = palette[index];
|
||||
var _pa = _color_get_alpha(_p);
|
||||
var _p = paletteObject[index];
|
||||
|
||||
var _kx = pl_x + j * ww;
|
||||
var _ky = pl_y + i * hh;
|
||||
|
||||
var _px = floor(_kx + pd);
|
||||
var _py = floor(_ky + pd);
|
||||
var _px = floor(_kx + pd) - dialog_x;
|
||||
var _py = floor(_ky + pd) - dialog_y;
|
||||
|
||||
_p.x = _p.x == 0? _px : lerp_float(_p.x, _px, 4);
|
||||
_p.y = _p.y == 0? _py : lerp_float(_p.y, _py, 4);
|
||||
|
||||
var _k = string(_p);
|
||||
var _ii = 0;
|
||||
var _selecting = index >= index_selecting[0] && index < index_selecting[0] + index_selecting[1];
|
||||
|
||||
while(struct_has(_clrRep, _k)) {
|
||||
_k = $"{_p}{_ii}";
|
||||
_ii++;
|
||||
}
|
||||
|
||||
_clrRep[$ _k] = 1;
|
||||
|
||||
if(struct_has(ppos, _k)) {
|
||||
ppos[$ _k][0] = (ppos[$ _k][0] == 0 || !_selecting)? _px - dialog_x : lerp_float(ppos[$ _k][0], _px - dialog_x, 4);
|
||||
ppos[$ _k][1] = (ppos[$ _k][1] == 0 || !_selecting)? _py - dialog_y : lerp_float(ppos[$ _k][1], _py - dialog_y, 4);
|
||||
} else {
|
||||
ppos[$ _k] = [ _px - dialog_x, _py - dialog_y ];
|
||||
}
|
||||
|
||||
var _pdx = dialog_x + ppos[$ _k][0];
|
||||
var _pdy = dialog_y + ppos[$ _k][1];
|
||||
var _pdx = dialog_x + _p.x;
|
||||
var _pdy = dialog_y + _p.y;
|
||||
|
||||
var _ind = 0;
|
||||
|
||||
if(row == 1) {
|
||||
if(j == 0) _ind = 2;
|
||||
else if(j == col - 1) _ind = 3;
|
||||
|
||||
} else {
|
||||
if(index == 0) _ind = 6;
|
||||
else if(i == 0 && j == col - 1) _ind = 7;
|
||||
else if(i == row - 2) {
|
||||
if(j == col - 1 && _len - 1 < index + col) _ind = 9;
|
||||
|
||||
} else if(i == row - 1) {
|
||||
if(j == 0) _ind = 8;
|
||||
if(j == col - 1) _ind = 7;
|
||||
|
@ -215,7 +207,7 @@ if palette == 0 exit;
|
|||
}
|
||||
|
||||
_palInd[index] = _ind;
|
||||
drawColor(_p, _pdx, _pdy, _pw, _ph, true, _ind);
|
||||
drawColor(_p.color, _pdx, _pdy, _pw, _ph, true, _ind);
|
||||
|
||||
if(sHOVER && point_in_rectangle(mouse_mx, mouse_my, _kx, _ky, _kx + ww, _ky + hh)) {
|
||||
hover = index;
|
||||
|
@ -235,11 +227,11 @@ if palette == 0 exit;
|
|||
if(index >= _len) break;
|
||||
|
||||
if(index >= index_selecting[0] && index < index_selecting[0] + index_selecting[1]) {
|
||||
var _p = palette[index];
|
||||
var _px = dialog_x + ppos[$ _p][0] - pl_sx;
|
||||
var _py = dialog_y + ppos[$ _p][1] - pl_sy;
|
||||
var _p = paletteObject[index];
|
||||
var _px = dialog_x + _p.x - pl_sx;
|
||||
var _py = dialog_y + _p.y - pl_sy;
|
||||
|
||||
drawColor(_p, _px, _py, _pw, _ph, true, _palInd[index]);
|
||||
drawColor(_p.color, _px, _py, _pw, _ph, true, _palInd[index]);
|
||||
}
|
||||
}
|
||||
surface_reset_target();
|
||||
|
@ -261,12 +253,12 @@ if palette == 0 exit;
|
|||
|
||||
var _0 = index_selecting[0];
|
||||
var _1 = index_selecting[0] + index_selecting[1];
|
||||
var _2 = array_length(palette);
|
||||
var _2 = array_length(paletteObject);
|
||||
|
||||
for(var i = 0; i < _2; i++) {
|
||||
if(i < _0) array_push(prea, palette[i]);
|
||||
else if(i < _1) array_push(cont, palette[i]);
|
||||
else array_push(posa, palette[i]);
|
||||
if(i < _0) array_push(prea, paletteObject[i]);
|
||||
else if(i < _1) array_push(cont, paletteObject[i]);
|
||||
else array_push(posa, paletteObject[i]);
|
||||
}
|
||||
|
||||
var _shf = clamp(hover - index_dragging, -index_selecting[0], _2 - (index_selecting[0] + index_selecting[1]));
|
||||
|
@ -278,7 +270,7 @@ if palette == 0 exit;
|
|||
for (var i = array_length(prea) + _shf, n = array_length(prea); i < n; i++) array_push(_pal, prea[i]);
|
||||
for (var i = 0, n = array_length(posa); i < n; i++) array_push(_pal, posa[i]);
|
||||
|
||||
palette = _pal;
|
||||
paletteObject = _pal;
|
||||
|
||||
} else if(_shf > 0) {
|
||||
for (var i = 0, n = array_length(prea); i < n; i++) array_push(_pal, prea[i]);
|
||||
|
@ -286,13 +278,13 @@ if palette == 0 exit;
|
|||
for (var i = 0, n = array_length(cont); i < n; i++) array_push(_pal, cont[i]);
|
||||
for (var i = _shf, n = array_length(posa); i < n; i++) array_push(_pal, posa[i]);
|
||||
|
||||
palette = _pal;
|
||||
paletteObject = _pal;
|
||||
|
||||
}
|
||||
|
||||
index_selecting[0] += _shf;
|
||||
index_dragging = hover;
|
||||
onApply(palette);
|
||||
refreshPalette();
|
||||
}
|
||||
|
||||
if(mouse_release(mb_left)) {
|
||||
|
@ -356,35 +348,38 @@ if palette == 0 exit;
|
|||
|
||||
var bx = content_x + content_w - ui(50);
|
||||
var by = pl_y - ui(2);
|
||||
var _foc = interactable && sFOCUS;
|
||||
|
||||
if(array_length(palette) > 1) {
|
||||
if(buttonInstant(THEME.button_hide_fill, bx, by, ui(28), ui(28), mouse_ui, sHOVER, interactable && sFOCUS, "", THEME.minus) == 2) {
|
||||
if(buttonInstant(THEME.button_hide_fill, bx, by, ui(28), ui(28), mouse_ui, sHOVER, _foc, "", THEME.minus) == 2) {
|
||||
array_delete(palette, index_selecting[0], index_selecting[1]);
|
||||
if(array_empty(palette))
|
||||
palette = [ c_black ];
|
||||
if(array_empty(palette)) palette = [ c_black ];
|
||||
index_selecting = [ 0, 0 ];
|
||||
|
||||
refreshPaletteObject();
|
||||
onApply(palette);
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
draw_sprite_ui_uniform(THEME.minus, 0, bx + ui(14), by + ui(14), 1, COLORS._main_icon, 0.5);
|
||||
}
|
||||
|
||||
bx -= ui(32);
|
||||
if(buttonInstant(THEME.button_hide_fill, bx, by, ui(28), ui(28), mouse_ui, sHOVER, interactable && sFOCUS, "", THEME.add) == 2) {
|
||||
if(buttonInstant(THEME.button_hide_fill, bx, by, ui(28), ui(28), mouse_ui, sHOVER, _foc, "", THEME.add) == 2) {
|
||||
palette[array_length(palette)] = c_black;
|
||||
index_selecting = [ array_length(palette), 1 ];
|
||||
|
||||
refreshPaletteObject();
|
||||
onApply(palette);
|
||||
}
|
||||
|
||||
bx = content_x + ui(18);
|
||||
if(buttonInstant(THEME.button_hide_fill, bx, by, ui(28), ui(28), mouse_ui, sHOVER, interactable && sFOCUS, __txtx("palette_editor_load", "Load palette file") + " (.hex)", THEME.file) == 2) {
|
||||
if(buttonInstant(THEME.button_hide_fill, bx, by, ui(28), ui(28), mouse_ui, sHOVER, _foc, __txtx("palette_editor_load", "Load palette file") + " (.hex)", THEME.file) == 2) {
|
||||
var path = get_open_filename_pxc("HEX palette|*.hex", "");
|
||||
key_release();
|
||||
|
||||
if(isPaletteFile(path)) {
|
||||
palette = loadPalette(path);
|
||||
refreshPaletteObject();
|
||||
|
||||
onApply(palette);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,8 +43,8 @@
|
|||
LATEST_VERSION = 1_18_00_0;
|
||||
VERSION = 1_18_08_0;
|
||||
SAVE_VERSION = 1_18_09_0;
|
||||
VERSION_STRING = MAC? "1.18.003m" : "1.18.9.003";
|
||||
BUILD_NUMBER = 118080.003;
|
||||
VERSION_STRING = MAC? "1.18.003m" : "1.18.9.004";
|
||||
BUILD_NUMBER = 118080.004;
|
||||
PREF_VERSION = 1_17_1;
|
||||
|
||||
var _vsp = string_split(VERSION_STRING, ".");
|
||||
|
|
Loading…
Add table
Reference in a new issue