diff --git a/PixelComposer.resource_order b/PixelComposer.resource_order index d3f77472f..e7db69350 100644 --- a/PixelComposer.resource_order +++ b/PixelComposer.resource_order @@ -1427,6 +1427,7 @@ {"name":"sh_de_corner","order":6,"path":"shaders/sh_de_corner/sh_de_corner.yy",}, {"name":"sh_de_stray","order":7,"path":"shaders/sh_de_stray/sh_de_stray.yy",}, {"name":"sh_default","order":6,"path":"shaders/sh_default/sh_default.yy",}, + {"name":"sh_dialog_palette_selector","order":7,"path":"shaders/sh_dialog_palette_selector/sh_dialog_palette_selector.yy",}, {"name":"sh_diffuse_flow","order":1,"path":"shaders/sh_diffuse_flow/sh_diffuse_flow.yy",}, {"name":"sh_diffuse_post","order":2,"path":"shaders/sh_diffuse_post/sh_diffuse_post.yy",}, {"name":"sh_dilate","order":4,"path":"shaders/sh_dilate/sh_dilate.yy",}, diff --git a/PixelComposer.yyp b/PixelComposer.yyp index 702c71add..77cdcd062 100644 --- a/PixelComposer.yyp +++ b/PixelComposer.yyp @@ -2069,6 +2069,7 @@ {"id":{"name":"sh_de_corner","path":"shaders/sh_de_corner/sh_de_corner.yy",},}, {"id":{"name":"sh_de_stray","path":"shaders/sh_de_stray/sh_de_stray.yy",},}, {"id":{"name":"sh_default","path":"shaders/sh_default/sh_default.yy",},}, + {"id":{"name":"sh_dialog_palette_selector","path":"shaders/sh_dialog_palette_selector/sh_dialog_palette_selector.yy",},}, {"id":{"name":"sh_diffuse_dissipate","path":"shaders/sh_diffuse_dissipate/sh_diffuse_dissipate.yy",},}, {"id":{"name":"sh_diffuse_flow","path":"shaders/sh_diffuse_flow/sh_diffuse_flow.yy",},}, {"id":{"name":"sh_diffuse_post","path":"shaders/sh_diffuse_post/sh_diffuse_post.yy",},}, diff --git a/objects/o_dialog_color_selector/Create_0.gml b/objects/o_dialog_color_selector/Create_0.gml index 7d2b41153..42ff71d92 100644 --- a/objects/o_dialog_color_selector/Create_0.gml +++ b/objects/o_dialog_color_selector/Create_0.gml @@ -34,55 +34,57 @@ event_inherited(); #region presets preset_selecting = -1; - sp_preset_w = ui(240 - 32 - 16); - sp_preset_size = ui(24); - click_block = false; + pal_padding = ui(9); + sp_preset_w = ui(240) - pal_padding * 2 - ui(8); + sp_preset_size = ui(20); + click_block = false; - sp_presets = new scrollPane(sp_preset_w, dialog_h - ui(62), function(_y, _m) { - var ww = sp_preset_w - ui(40); - var hh = ui(32); - var _gs = sp_preset_size; - var yy = _y + ui(8); - var _hover = sHOVER && sp_presets.hover; - var _height, pre_amo; + 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 ww = sp_presets.surface_w; + var _gs = sp_preset_size; + var hh = ui(24); + var nh = ui(20); + var pd = ui(6); + var _ww = ww - pd * 2; + var _bh = nh + _gs + pd; + + var _hover = sHOVER && sp_presets.hover; + var _height, pre_amo, _palRes; + + var yy = _y; + var col = max(1, floor(_ww / _gs)), row; + for(var i = -1; i < array_length(PALETTES); i++) { var pal = i == -1? { - name: "project", - palette: PROJECT.attributes.palette, - path: "" + name : "project", + palette : PROJECT.attributes.palette, + path : "" } : PALETTES[i]; + pre_amo = array_length(pal.palette); - var col = floor(ww / _gs); - var row = ceil(pre_amo / col); + row = ceil(pre_amo / col); + _height = preset_selecting == i? nh + row * _gs + pd : _bh; - if(preset_selecting == i) - _height = ui(28) + row * _gs + ui(12); - else - _height = ui(56); + var isHover = _hover && point_in_rectangle(_m[0], _m[1], 0, yy, ww, yy + _height); - var isHover = _hover && point_in_rectangle(_m[0], _m[1], ui(4), yy, ui(4) + sp_preset_w - ui(16), yy + _height); - - draw_sprite_stretched(THEME.ui_panel_bg, 3, ui(4), yy, sp_preset_w - ui(16), _height); + draw_sprite_stretched(THEME.ui_panel_bg, 3, 0, yy, ww, _height); if(isHover) { - draw_sprite_stretched_ext(THEME.ui_panel_fg, 1, ui(4), yy, sp_preset_w - ui(16), _height, COLORS._main_accent, 1); + draw_sprite_stretched_ext(THEME.ui_panel_fg, 1, 0, yy, ww, _height, COLORS._main_accent, 1); sp_presets.hover_content = true; } - var x0 = ui(16) + (i == -1) * ui(8 + 6); var cc = i == preset_selecting? COLORS._main_accent : COLORS._main_text_sub; draw_set_text(f_p2, fa_left, fa_top, cc); - draw_text(x0, yy + ui(8), pal.name); - if(i == -1) { - draw_set_color(cc); - draw_circle_prec(ui(16) + ui(4), yy + ui(16), ui(4), false); - } + draw_text_add(pd, yy + ui(2), pal.name); + + if(i == -1) { draw_set_color(cc); draw_circle_prec(ww - ui(10), yy + ui(10), ui(4), false); } if(preset_selecting == i) - var _palRes = drawPaletteGrid(pal.palette, ui(16), yy + ui(28), ww, _gs, { color : selector.current_color, mx : _m[0], my : _m[1] }); + _palRes = drawPaletteGrid(pal.palette, pd, yy + nh, _ww, _gs, { color : selector.current_color, mx : _m[0], my : _m[1] }); else - drawPalette(pal.palette, ui(16), yy + ui(28), ww, ui(20)); + drawPalette(pal.palette, pd, yy + nh, _ww, _gs); if(!click_block && mouse_click(mb_left, interactable && sFOCUS)) { if(preset_selecting == i && _hover && _palRes.hoverIndex > noone) { @@ -95,20 +97,18 @@ event_inherited(); } } - if(isHover) { - if(i >= 0 && mouse_press(mb_right, interactable && sFOCUS)) { - 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(); - }), - ]); - } + if(isHover && i >= 0 && mouse_press(mb_right, interactable && sFOCUS)) { + 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(); + }), + ]); } yy += _height + ui(4); diff --git a/objects/o_dialog_color_selector/Draw_64.gml b/objects/o_dialog_color_selector/Draw_64.gml index 847a156b9..5b4160565 100644 --- a/objects/o_dialog_color_selector/Draw_64.gml +++ b/objects/o_dialog_color_selector/Draw_64.gml @@ -35,10 +35,10 @@ if !ready exit; #endregion #region palette - draw_sprite_stretched(THEME.ui_panel_bg, 1, presets_x + ui(16), dialog_y + ui(44), ui(240 - 32), dialog_h - ui(60)); + draw_sprite_stretched(THEME.ui_panel_bg, 1, presets_x + pal_padding, dialog_y + ui(48), ui(240) - pal_padding * 2, dialog_h - ui(48) - pal_padding); sp_presets.setFocusHover(sFOCUS, sHOVER); - sp_presets.draw(presets_x + ui(24), dialog_y + ui(44)); + sp_presets.draw(presets_x + pal_padding + ui(4), dialog_y + ui(48) + ui(4)); var bx = presets_x + presets_w - ui(44); var by = dialog_y + ui(12); diff --git a/objects/o_dialog_gradient/Create_0.gml b/objects/o_dialog_gradient/Create_0.gml index 4dd83d838..7c4566944 100644 --- a/objects/o_dialog_gradient/Create_0.gml +++ b/objects/o_dialog_gradient/Create_0.gml @@ -3,7 +3,7 @@ event_inherited(); #region data dialog_w = ui(1068); - dialog_h = ui(476); + dialog_h = ui(468); title_height = 52; name = __txtx("gradient_editor_title", "Gradient editor"); @@ -23,7 +23,7 @@ event_inherited(); if(!interactable) return; if(key_selecting == noone) return; setKeyPosition(key_selecting, val / 100); - }, function() { removeKeyOverlap(key_selecting); }) + }, function() { removeKeyOverlap(key_selecting); }).setLabel(__txt("Position")); setColor = function(color) { if(key_selecting == noone) return; @@ -87,28 +87,37 @@ event_inherited(); #region preset hovering_name = ""; - sp_preset_w = ui(240 - 32 - 16); - sp_presets = new scrollPane(sp_preset_w, dialog_h - ui(62), function(_y, _m) { - var ww = sp_preset_w - ui(40); - var hh = ui(32); - var yy = _y + ui(8); - var hg = ui(52); - var _hover = sHOVER && sp_presets.hover; + + 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 ww = sp_presets.surface_w; + var _gs = ui(16); + var hh = ui(24); + var nh = ui(20); + var pd = ui(6); + var _ww = ww - pd * 2; + var hg = nh + _gs + pd; + var yy = _y; + + var _hover = sHOVER && sp_presets.hover; + for(var i = 0; i < array_length(GRADIENTS); i++) { var _gradient = GRADIENTS[i]; - var isHover = point_in_rectangle(_m[0], _m[1], ui(4), yy, ui(4) + sp_preset_w - ui(16), yy + hg); + var isHover = point_in_rectangle(_m[0], _m[1], 0, yy, ww, yy + hg); - draw_sprite_stretched(THEME.ui_panel_bg, 3, ui(4), yy, sp_preset_w - ui(16), hg); + draw_sprite_stretched(THEME.ui_panel_bg, 3, 0, yy, ww, hg); if(_hover && isHover) { sp_presets.hover_content = true; - draw_sprite_stretched_ext(THEME.node_active, 1, ui(4), yy, sp_preset_w - ui(16), hg, COLORS._main_accent, 1); + draw_sprite_stretched_ext(THEME.node_active, 1, 0, yy, ww, hg, COLORS._main_accent, 1); } draw_set_text(f_p2, fa_left, fa_top, COLORS._main_text_sub); - draw_text(ui(16), yy + ui(8), _gradient.name); - _gradient.gradient.draw(ui(16), yy + ui(28), ww, ui(16)); + draw_text_add(pd, yy + ui(2), _gradient.name); + _gradient.gradient.draw(pd, yy + nh, _ww, _gs); if(_hover && isHover) { if(mouse_press(mb_left, interactable && sFOCUS)) { @@ -147,56 +156,55 @@ event_inherited(); #region palette palette_selecting = -1; - sp_palette_w = ui(240 - 32 - 16); - sp_palette_size = ui(24); - click_block = true; + sp_palette_w = ui(240) - pal_padding * 2 - ui(8); + sp_palette_size = ui(20); + click_block = true; - sp_palettes = new scrollPane(sp_palette_w, dialog_h - ui(62), function(_y, _m) { - var ww = sp_palette_w - ui(40); - var hh = ui(32); - var _gs = sp_palette_size; - var yy = _y + ui(8); - var _height, pre_amo; - var _hover = sHOVER && sp_palettes.hover; + sp_palettes = new scrollPane(sp_palette_w, dialog_h - ui(48 + 8) - pal_padding, function(_y, _m) { draw_clear_alpha(COLORS.panel_bg_clear, 0); + var ww = sp_palettes.surface_w; + var _gs = sp_palette_size; + var hh = ui(24); + var nh = ui(20); + var pd = ui(6); + var _ww = ww - pd * 2; + var _bh = nh + _gs + pd; + var yy = _y; + + var _height, pre_amo, _palRes; + var _hover = sHOVER && sp_palettes.hover; + var col = max(1, floor(_ww / _gs)), row; + for(var i = -1; i < array_length(PALETTES); i++) { var pal = i == -1? { - name: "project", - palette: PROJECT.attributes.palette, - path: "" + name : "project", + palette : PROJECT.attributes.palette, + path : "" } : PALETTES[i]; pre_amo = array_length(pal.palette); - var col = floor(ww / _gs); - var row = ceil(pre_amo / col); + row = ceil(pre_amo / col); + _height = palette_selecting == i? nh + row * _gs + pd : _bh; - if(palette_selecting == i) - _height = ui(28) + row * _gs + ui(12); - else - _height = ui(56); + var isHover = _hover && point_in_rectangle(_m[0], _m[1], 0, yy, ww, yy + _height); - var isHover = _hover && point_in_rectangle(_m[0], _m[1], ui(4), yy, ui(4) + sp_palette_w - ui(16), yy + _height); - - draw_sprite_stretched(THEME.ui_panel_bg, 3, ui(4), yy, sp_palette_w - ui(16), _height); + draw_sprite_stretched(THEME.ui_panel_bg, 3, 0, yy, ww, _height); if(isHover) { sp_palettes.hover_content = true; - draw_sprite_stretched_ext(THEME.node_active, 1, ui(4), yy, sp_palette_w - ui(16), _height, COLORS._main_accent, 1); + draw_sprite_stretched_ext(THEME.node_active, 1, 0, yy, ww, _height, COLORS._main_accent, 1); } - var x0 = ui(16) + (i == -1) * ui(8 + 6); var cc = i == palette_selecting? COLORS._main_accent : COLORS._main_text_sub; draw_set_text(f_p2, fa_left, fa_top, cc); - draw_text(x0, yy + ui(8), pal.name); - if(i == -1) { - draw_set_color(cc); - draw_circle_prec(ui(16) + ui(4), yy + ui(16), ui(4), false); - } + draw_text_add(pd, yy + ui(2), pal.name); - if(palette_selecting == i) - var _palRes = drawPaletteGrid(pal.palette, ui(16), yy + ui(28), ww, _gs, { mx : _m[0], my : _m[1] }); + if(i == -1) { draw_set_color(cc); draw_circle_prec(ww - ui(10), yy + ui(10), ui(4), false); } + + if(palette_selecting == i) + _palRes = drawPaletteGrid(pal.palette, pd, yy + nh, _ww, _gs, { mx : _m[0], my : _m[1] }); else - drawPalette(pal.palette, ui(16), yy + ui(28), ww, ui(20)); + drawPalette(pal.palette, pd, yy + nh, _ww, _gs); if(!click_block && mouse_click(mb_left, interactable && sFOCUS)) { if(palette_selecting == i && _hover && _palRes.hoverIndex > noone) { @@ -212,20 +220,18 @@ event_inherited(); } } - if(isHover) { - if(i >= 0 && mouse_press(mb_right, interactable && sFOCUS)) { - 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(); - }), - ]); - } + if(isHover && i >= 0 && mouse_press(mb_right, interactable && sFOCUS)) { + 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(); + }), + ]); } yy += _height + ui(4); diff --git a/objects/o_dialog_gradient/Draw_64.gml b/objects/o_dialog_gradient/Draw_64.gml index 1b6ad516b..16f059dcf 100644 --- a/objects/o_dialog_gradient/Draw_64.gml +++ b/objects/o_dialog_gradient/Draw_64.gml @@ -40,10 +40,10 @@ if !ready exit; #endregion #region presets - draw_sprite_stretched(THEME.ui_panel_bg, 1, presets_x + ui(16), dialog_y + ui(44), ui(240 - 32), dialog_h - ui(60)); + draw_sprite_stretched(THEME.ui_panel_bg, 1, presets_x + pal_padding, dialog_y + ui(48), ui(240) - pal_padding * 2, dialog_h - ui(48) - pal_padding); sp_presets.setFocusHover(sFOCUS, sHOVER); - sp_presets.draw(presets_x + ui(16 + 8), dialog_y + ui(44)); + sp_presets.draw(presets_x + pal_padding + ui(4), dialog_y + ui(48) + ui(4)); var bx = presets_x + presets_w - ui(44); var by = dialog_y + ui(12); @@ -79,10 +79,10 @@ if !ready exit; #endregion #region palette - draw_sprite_stretched(THEME.ui_panel_bg, 1, palette_x + ui(16), dialog_y + ui(44), ui(240 - 32), dialog_h - ui(60)); + draw_sprite_stretched(THEME.ui_panel_bg, 1, palette_x + pal_padding, dialog_y + ui(48), ui(240) - pal_padding * 2, dialog_h - ui(48) - pal_padding); sp_palettes.setFocusHover(sFOCUS, sHOVER); - sp_palettes.draw(palette_x + ui(16 + 8), dialog_y + ui(44)); + sp_palettes.draw(palette_x + pal_padding + ui(4), dialog_y + ui(48) + ui(4)); var bx = palette_x + palette_w - ui(44); var by = dialog_y + ui(12); @@ -201,18 +201,16 @@ if !ready exit; var op_x = content_x + ui(20); var op_y = gr_y + gr_h + ui(12); - draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text_sub); - draw_text(op_x, op_y + TEXTBOX_HEIGHT / 2, __txt("Position")) - var txt = key_selecting? key_selecting.time * 100 : 0; sl_position.setFocusHover(sFOCUS, sHOVER); sl_position.register(); - sl_position.draw(op_x + ui(100), op_y, ui(content_w - 140), TEXTBOX_HEIGHT, txt, mouse_ui); + sl_position.setFont(f_p2); + sl_position.draw(op_x, op_y, ui(content_w - 40), ui(24), txt, mouse_ui); #endregion #region selector var col_x = content_x + ui(20); - var col_y = dialog_y + ui(136); + var col_y = dialog_y + ui(128); if(palette_selecting > -1) selector.palette = PALETTES[palette_selecting].palette; diff --git a/objects/o_dialog_palette/Create_0.gml b/objects/o_dialog_palette/Create_0.gml index 23db2b69f..94beff338 100644 --- a/objects/o_dialog_palette/Create_0.gml +++ b/objects/o_dialog_palette/Create_0.gml @@ -10,8 +10,9 @@ event_inherited(); name = __txtx("palette_editor_title", "Palette editor"); palette = 0; - index_selecting = 0; - index_dragging = -1; + index_sel_start = 0; + index_selecting = [ 0, 0 ]; + index_dragging = noone; interactable = true; drop_target = noone; @@ -20,9 +21,11 @@ event_inherited(); index_drag_w = 0; index_drag_w_to = 0; index_drag_h = 0; index_drag_h_to = 0; + palette_positions = {} + setColor = function(color) { - if(index_selecting == -1 || palette == 0) return; - palette[index_selecting] = color; + if(index_selecting[1] == 0 || palette == 0) return; + palette[index_selecting[0]] = color; if(onApply == noone) return; onApply(palette); @@ -35,6 +38,8 @@ event_inherited(); previous_palette = c_black; + selection_surface = surface_create(1, 1); + function setDefault(pal) { setPalette(pal); previous_palette = array_clone(pal); @@ -53,47 +58,59 @@ event_inherited(); function setPalette(pal) { palette = pal; - index_selecting = 0; - if(array_length(palette) > 0) + index_selecting = [ 0, 0 ]; + if(!array_empty(palette)) selector.setColor(palette[0]); + + palette_positions = {}; } #endregion #region presets hovering_name = ""; - sp_preset_w = ui(240 - 32 - 16); - sp_presets = new scrollPane(sp_preset_w, dialog_h - ui(62), function(_y, _m) { - var ww = sp_preset_w - ui(40); - var hh = ui(32); - var yy = _y + ui(8); - var hg = ui(52); + 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 ww = sp_presets.surface_w; + var _gs = ui(20); + var hh = ui(24); + var nh = ui(20); + var pd = ui(6); + var _ww = ww - pd * 2; + var hg = nh + _gs + pd; + + var yy = _y; + for(var i = -1; i < array_length(PALETTES); i++) { var pal = i == -1? { - name: "project", - palette: PROJECT.attributes.palette, - path: "" + name : "project", + palette : PROJECT.attributes.palette, + path : "" } : PALETTES[i]; - var isHover = sHOVER && sp_presets.hover && point_in_rectangle(_m[0], _m[1], ui(4), yy, ui(4) + sp_preset_w - ui(16), yy + hg); - draw_sprite_stretched(THEME.ui_panel_bg, 3, ui(4), yy, sp_preset_w - ui(16), hg); + + var isHover = sHOVER && sp_presets.hover && point_in_rectangle(_m[0], _m[1], 0, yy, ww, yy + hg); + draw_sprite_stretched(THEME.ui_panel_bg, 3, 0, yy, ww, hg); + if(isHover) { sp_presets.hover_content = true; - draw_sprite_stretched_ext(THEME.node_active, 1, ui(4), yy, sp_preset_w - ui(16), hg, COLORS._main_accent, 1); + draw_sprite_stretched_ext(THEME.node_active, 1, 0, yy, ww, hg, COLORS._main_accent, 1); } draw_set_text(f_p2, fa_left, fa_top, COLORS._main_text_sub); - draw_text(ui(16), yy + ui(8), pal.name); - drawPalette(pal.palette, ui(16), yy + ui(28), ww, ui(16)); + draw_text_add(pd, yy + ui(2), pal.name); + drawPalette(pal.palette, pd, yy + nh, _ww, _gs); if(isHover) { if(mouse_press(mb_left, interactable && sFOCUS)) { palette = array_clone(pal.palette); onApply(palette); - index_selecting = 0; - selector.setColor(palette[index_selecting], false); + index_selecting = [ 0, 0 ]; + selector.setColor(palette[0], false); } if(i >= 0 && mouse_press(mb_right, interactable && sFOCUS)) { diff --git a/objects/o_dialog_palette/Destroy_0.gml b/objects/o_dialog_palette/Destroy_0.gml new file mode 100644 index 000000000..023b98114 --- /dev/null +++ b/objects/o_dialog_palette/Destroy_0.gml @@ -0,0 +1 @@ +surface_free_safe(selection_surface); \ No newline at end of file diff --git a/objects/o_dialog_palette/Draw_64.gml b/objects/o_dialog_palette/Draw_64.gml index 79348d690..b7b30365b 100644 --- a/objects/o_dialog_palette/Draw_64.gml +++ b/objects/o_dialog_palette/Draw_64.gml @@ -34,10 +34,10 @@ if palette == 0 exit; #endregion #region presets - draw_sprite_stretched(THEME.ui_panel_bg, 1, presets_x + ui(16), dialog_y + ui(44), ui(240 - 32), dialog_h - ui(60)); + draw_sprite_stretched(THEME.ui_panel_bg, 1, presets_x + pal_padding, dialog_y + ui(48), ui(240) - pal_padding * 2, dialog_h - ui(48) - pal_padding); sp_presets.setFocusHover(sFOCUS, sHOVER); - sp_presets.draw(presets_x + ui(24), dialog_y + ui(44)); + sp_presets.draw(presets_x + pal_padding + ui(4), dialog_y + ui(48) + ui(4)); var bx = presets_x + presets_w - ui(44); var by = dialog_y + ui(12); @@ -76,21 +76,7 @@ if palette == 0 exit; #endregion #region palette - var pl_x = content_x + ui(60); - var pl_y = dialog_y + ui(54); - var pl_w = content_w - ui(154); - var pl_h = ui(24); - - var max_col = 8; - var col = min(array_length(palette), max_col); - var row = ceil(array_length(palette) / col); - var ww = round(pl_w / col); - var hh = (pl_h + ui(6)) * row; - dialog_h = ui(408) + hh; - - draw_sprite_stretched(THEME.textbox, 3, pl_x - ui(6), pl_y - ui(6), pl_w + ui(12), hh + ui(6)); - draw_sprite_stretched(THEME.textbox, 0, pl_x - ui(6), pl_y - ui(6), pl_w + ui(12), hh + ui(6)); - + #region tools var bx = content_x + content_w - ui(50); var by = dialog_y + ui(16); @@ -114,99 +100,228 @@ if palette == 0 exit; bx -= ui(32); #endregion + var pl_x = content_x + ui(60); + var pl_y = dialog_y + ui(54); + var pl_w = content_w - ui(154); + var hh = ui(24); + + var pd = ui(0); + var _len = array_length(palette); + + var min_col = 8; + var col = min(_len, min_col); + var row = ceil(_len / col); + if(row > 8) { + col = 16; + row = ceil(_len / col); + } + + var ww = pl_w / col; + var pl_h = hh * row; + + dialog_h = ui(408) + pl_h; + + var pdd = ui(6); + var pl_sx = pl_x - pdd; + var pl_sy = pl_y - pdd; + var pl_sw = pl_w + pdd * 2; + var pl_sh = pl_h + pdd * 2; + + draw_sprite_stretched(THEME.textbox, 3, pl_sx, pl_sy, pl_sw, pl_sh); + draw_sprite_stretched(THEME.textbox, 0, pl_sx, pl_sy, pl_sw, pl_sh); + + selection_surface = surface_verify(selection_surface, pl_sw, pl_sh); + var hover = -1, hvx, hvy; - var _pd = ui(5); + + var _pw = ceil(ww - pd * 2); + var _ph = ceil(hh - pd * 2); + + 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++) for(var j = 0; j < col; j++) { var index = i * col + j; - if(index >= array_length(palette)) break; + if(index >= _len) break; var _p = palette[index]; var _pa = _color_get_alpha(_p); var _kx = pl_x + j * ww; - var _ky = pl_y + i * (pl_h + ui(6)); + var _ky = pl_y + i * hh; - var _px = _kx + ui(2); - var _py = _ky; - var _pw = ww - ui(4); - var _ph = pl_h; + var _px = floor(_kx + pd); + var _py = floor(_ky + pd); - if(index == index_dragging) { - index_drag_x_to = _px; - index_drag_y_to = _py; - index_drag_w_to = _pw; - index_drag_h_to = _ph; - continue; + var _k = string(_p); + var _ii = 0; + while(struct_has(_clrRep, _k)) { + _k = $"{_p}{_ii}"; + _ii++; } - if(_pa < 1) { - draw_sprite_stretched_ext(THEME.palette_mask, 1, _px, _py, _pw, _ph - ui(8), _p, 1); - draw_sprite_stretched_ext(THEME.palette_mask, 1, _px, _py + _ph - ui(6), _pw, ui(6), c_black, 1); - draw_sprite_stretched_ext(THEME.palette_mask, 1, _px, _py + _ph - ui(6), _pw * _pa, ui(6), c_white, 1); - } else - draw_sprite_stretched_ext(THEME.palette_mask, 1, _px, _py, _pw, _ph, _p, 1); - - if(index == index_selecting) - draw_sprite_stretched_ext(THEME.palette_selecting, 0, _px - _pd, _py - _pd, _pw + _pd * 2, _ph + _pd * 2, c_white, 1); + _clrRep[$ _k] = 1; - if(sHOVER && point_in_rectangle(mouse_mx, mouse_my, _kx, _ky, _kx + ww, _ky + pl_h)) { + if(struct_has(ppos, _k)) { + ppos[$ _k][0] = ppos[$ _k][0] == 0? _px : lerp_float(ppos[$ _k][0], _px, 4); + ppos[$ _k][1] = ppos[$ _k][1] == 0? _py : lerp_float(ppos[$ _k][1], _py, 4); + } else { + ppos[$ _k] = [ _px, _py ]; + } + + var _pdx = ppos[$ _k][0]; + var _pdy = ppos[$ _k][1]; + + 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; + if(index == _len - 1) _ind = 9; + } + } + + _palInd[index] = _ind; + drawColor(_p, _pdx, _pdy, _pw, _ph, _ind); + + if(sHOVER && point_in_rectangle(mouse_mx, mouse_my, _kx, _ky, _kx + ww, _ky + hh)) { hover = index; hvx = _kx; hvy = _ky; + + if(index >= index_selecting[0] && index < index_selecting[0] + index_selecting[1] + && !point_in_rectangle(mouse_mx, mouse_my, _kx + 4, _ky + 4, _kx + ww - 8, _ky + hh - 8)) + + _hedge = true; } } - if(index_dragging > -1) { - index_drag_x = index_drag_x == 0? index_drag_x_to : lerp_float(index_drag_x, index_drag_x_to, 5); - index_drag_y = index_drag_y == 0? index_drag_y_to : lerp_float(index_drag_y, index_drag_y_to, 5); - index_drag_w = index_drag_w == 0? index_drag_w_to : lerp_float(index_drag_w, index_drag_w_to, 5); - index_drag_h = index_drag_h == 0? index_drag_h_to : lerp_float(index_drag_h, index_drag_h_to, 5); - - _px = index_drag_x; - _py = index_drag_y; - _pw = index_drag_w; - _ph = index_drag_h; - _p = palette[index_dragging]; - _pa = _color_get_alpha(_p); - - if(_pa < 1) { - draw_sprite_stretched_ext(THEME.palette_mask, 1, _px, _py, _pw, _ph - ui(8), _p, 1); - draw_sprite_stretched_ext(THEME.palette_mask, 1, _px, _py + _ph - ui(6), _pw, ui(6), c_black, 1); - draw_sprite_stretched_ext(THEME.palette_mask, 1, _px, _py + _ph - ui(6), _pw * _pa, ui(6), c_white, 1); - } else - draw_sprite_stretched_ext(THEME.palette_mask, 1, _px, _py, _pw, _ph, _p, 1); - draw_sprite_stretched_ext(THEME.palette_selecting, 0, _px - _pd, _py - _pd, _pw + _pd * 2, _ph + _pd * 2, c_white, 1); - - if(hover > -1 && hover != index_dragging) { - draw_set_color(COLORS.dialog_palette_divider); - var sx = hvx; - if(hover >= index_dragging) sx += ww; + surface_set_target(selection_surface); + DRAW_CLEAR + for(var i = 0; i < row; i++) + for(var j = 0; j < col; j++) { + var index = i * col + j; + if(index >= _len) break; - var tt = palette[index_dragging]; + if(index >= index_selecting[0] && index < index_selecting[0] + index_selecting[1]) { + var _p = palette[index]; - array_delete(palette, index_dragging, 1); - array_insert(palette, hover, tt); - index_selecting = hover; - index_dragging = hover; + var _px = ppos[$ _p][0] - pl_sx; + var _py = ppos[$ _p][1] - pl_sy; + drawColor(_p, _px, _py, _pw, _ph, _palInd[index]); + } + } + surface_reset_target(); + + shader_set(sh_dialog_palette_selector); + shader_set_f("dimension", pl_sw, pl_sh); + shader_set_i("edge", _hedge && !mouse_click(mb_left)); + shader_set_color("edgeColor", COLORS._main_accent); + + draw_surface(selection_surface, pl_sx, pl_sy); + shader_reset(); + + if(index_dragging != noone) { + if(hover > -1 && hover != index_dragging) { + + var prea = []; + var cont = []; + var posa = []; + + var _0 = index_selecting[0]; + var _1 = index_selecting[0] + index_selecting[1]; + var _2 = array_length(palette); + + 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]); + } + + var _shf = clamp(hover - index_dragging, -index_selecting[0], _2 - (index_selecting[0] + index_selecting[1])); + var _pal = []; + + if(_shf < 0) { + for (var i = 0, n = array_length(prea) + _shf; i < n; i++) array_push(_pal, prea[i]); + for (var i = 0, n = array_length(cont); i < n; i++) array_push(_pal, cont[i]); + 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; + + } else if(_shf > 0) { + for (var i = 0, n = array_length(prea); i < n; i++) array_push(_pal, prea[i]); + for (var i = 0, n = _shf; i < n; i++) array_push(_pal, posa[i]); + 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; + + } + + index_selecting[0] += _shf; + index_dragging = hover; onApply(palette); } - if(mouse_release(mb_left)) - index_dragging = -1; + if(mouse_release(mb_left)) { + index_selecting = [ 0, 0 ]; + index_dragging = noone; + } + } else { index_drag_x = 0; index_drag_y = 0; index_drag_w = 0; index_drag_h = 0; - } - if(mouse_press(mb_left, sFOCUS) && hover > -1) { - index_selecting = hover; - if(interactable) - index_dragging = hover; - selector.setColor(palette[hover]); + if(hover > -1) { + + if(mouse_press(mb_left, sFOCUS)) { + + if(interactable) { + if(_hedge) index_dragging = hover; + else { + index_selecting = [ hover, 1 ]; + selector.setColor(palette[hover]); + } + + } else if(!interactable) { + index_selecting = [ hover, 1 ]; + selector.setColor(palette[hover]); + } + + index_sel_start = hover; + + } else if(mouse_click(mb_left, sFOCUS)) { + + if(hover > index_sel_start) { + index_selecting[0] = index_sel_start; + index_selecting[1] = hover - index_sel_start + 1; + + } else if(hover < index_sel_start) { + index_selecting[0] = hover; + index_selecting[1] = index_sel_start - hover + 1; + + } else { + index_selecting[0] = hover; + index_selecting[1] = 1; + } + } + } } var bx = content_x + content_w - ui(50); @@ -214,8 +329,9 @@ if palette == 0 exit; if(array_length(palette) > 1) { if(buttonInstant(THEME.button_hide, bx, by, ui(28), ui(28), mouse_ui, interactable && sFOCUS, sHOVER, "", THEME.minus) == 2) { - array_delete(palette, index_selecting, 1); - index_selecting = clamp(index_selecting - 1, 0, array_length(palette) - 1); + array_delete(palette, index_selecting[0], index_selecting[1]); + index_selecting = [ 0, 0 ]; + onApply(palette); } } else { @@ -224,8 +340,9 @@ if palette == 0 exit; bx -= ui(32); if(buttonInstant(THEME.button_hide, bx, by, ui(28), ui(28), mouse_ui, interactable && sFOCUS, sHOVER, "", THEME.add) == 2) { - index_selecting = array_length(palette); palette[array_length(palette)] = c_black; + index_selecting = [ array_length(palette), 1 ]; + onApply(palette); } @@ -244,7 +361,7 @@ if palette == 0 exit; #region selector var col_x = content_x + ui(20); - var col_y = dialog_y + ui(70) + hh; + var col_y = dialog_y + ui(70) + pl_h; selector.draw(col_x, col_y, sFOCUS, sHOVER); #endregion diff --git a/objects/o_dialog_palette/o_dialog_palette.yy b/objects/o_dialog_palette/o_dialog_palette.yy index 29a133335..0a5bf20bb 100644 --- a/objects/o_dialog_palette/o_dialog_palette.yy +++ b/objects/o_dialog_palette/o_dialog_palette.yy @@ -6,6 +6,7 @@ {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":64,"eventType":8,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":1,"eventType":3,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":75,"eventType":8,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, + {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":1,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, ], "managed":true, "name":"o_dialog_palette", diff --git a/scripts/buttonColor/buttonColor.gml b/scripts/buttonColor/buttonColor.gml index 2a9c8e768..e3dd55506 100644 --- a/scripts/buttonColor/buttonColor.gml +++ b/scripts/buttonColor/buttonColor.gml @@ -201,19 +201,20 @@ function buttonColor(_onApply, dialog = noone) : widget() constructor { } #endregion } -function drawColor(color, _x, _y, _w, _h) { +function drawColor(color, _x, _y, _w, _h, _ind = 1) { + if(is_real(color)) - draw_sprite_stretched_ext(THEME.palette_mask, 1, _x, _y, _w, _h, color, 1); + draw_sprite_stretched_ext(THEME.palette_mask, _ind, _x, _y, _w, _h, color, 1); else if(is_int64(color)) { var _a = _color_get_alpha(color); if(_a == 1) { - draw_sprite_stretched_ext(THEME.palette_mask, 1, _x, _y, _w, _h, color, 1); + draw_sprite_stretched_ext(THEME.palette_mask, _ind, _x, _y, _w, _h, color, 1); } else { - draw_sprite_stretched_ext(THEME.palette_mask, 1, _x, _y, _w, _h - ui(8), color, 1); + draw_sprite_stretched_ext(THEME.palette_mask, _ind, _x, _y, _w, _h - ui(8), color, 1); - draw_sprite_stretched_ext(THEME.palette_mask, 1, _x, _y + _h - ui(6), _w, ui(6), c_black, 1); - draw_sprite_stretched_ext(THEME.palette_mask, 1, _x, _y + _h - ui(6), _w * _a, ui(6), c_white, 1); + draw_sprite_stretched_ext(THEME.palette_mask, 0, _x, _y + _h - ui(6), _w, ui(6), c_black, 1); + draw_sprite_stretched_ext(THEME.palette_mask, 0, _x, _y + _h - ui(6), _w * _a, ui(6), c_white, 1); } } } \ No newline at end of file diff --git a/scripts/buttonPalette/buttonPalette.gml b/scripts/buttonPalette/buttonPalette.gml index cc7892486..16649f967 100644 --- a/scripts/buttonPalette/buttonPalette.gml +++ b/scripts/buttonPalette/buttonPalette.gml @@ -227,7 +227,7 @@ function drawPalette(_pal, _x, _y, _w, _h, _a = 1) { #region function drawPaletteGrid(_pal, _x, _y, _w, _gs = 24, params = {}) { #region var c_color = struct_try_get(params, "color", -1); - var _stretch = struct_try_get(params, "stretch", false); + var _stretch = struct_try_get(params, "stretch", true); var _mx = struct_try_get(params, "mx", -1); var _my = struct_try_get(params, "my", -1); diff --git a/scripts/globals/globals.gml b/scripts/globals/globals.gml index 5199f7a35..3def27fdf 100644 --- a/scripts/globals/globals.gml +++ b/scripts/globals/globals.gml @@ -39,7 +39,7 @@ LATEST_VERSION = 11700; VERSION = 11780; SAVE_VERSION = 11700; - VERSION_STRING = "1.17.9.004"; + VERSION_STRING = "1.17.9.005"; BUILD_NUMBER = 11780; HOTKEYS = ds_map_create(); diff --git a/scripts/panel_gradient/panel_gradient.gml b/scripts/panel_gradient/panel_gradient.gml index 297cc71ff..74e1c5c69 100644 --- a/scripts/panel_gradient/panel_gradient.gml +++ b/scripts/panel_gradient/panel_gradient.gml @@ -18,7 +18,7 @@ function Panel_Gradient() : PanelContent() constructor { var pd = ui(6); var gw = (ww + ui(8)) / col; - var hg = ui(26); + var hg = ui(40); var yy = _y; for(var i = 0; i < row; i++) { @@ -26,23 +26,20 @@ function Panel_Gradient() : PanelContent() constructor { var ind = i * col + j; if(ind >= amo) break; - var gww = gw - ui(8); - var xx = j * gw; + var xx = j * gw; + var gww = gw - ui(8); + var _py = yy + ui(18); + var _ph = hg - ui(18 + 4); var preset = GRADIENTS[ind]; var isHover = pHOVER && point_in_rectangle(_m[0], _m[1], xx, max(0, yy), xx + gww, min(sp_gradient.h, yy + hg)); draw_sprite_stretched(THEME.ui_panel_bg, 3, xx, yy, gww, hg); - preset.gradient.draw(xx, yy, gww, hg); - draw_set_text(f_p2, fa_left, fa_center, c_white); + preset.gradient.draw(xx + ui(4), _py, gww - ui(8), _ph); + draw_set_text(f_p3, fa_left, fa_top, COLORS._main_text_sub); + draw_text_add(xx + pd, yy + ui(2), preset.name); - if(_color_get_light(preset.gradient.keys[0].value) > 0.5) { - draw_set_color(c_black); - draw_text(xx + pd, yy + hg / 2, preset.name); - } else - draw_text_add(xx + pd, yy + hg / 2, preset.name); - - draw_sprite_stretched_add(THEME.ui_panel_fg, 1, xx, yy, gww, hg, c_white, 0.3); + draw_sprite_stretched_add(THEME.ui_panel_fg, 1, xx + ui(4), _py, gww - ui(8), _ph, c_white, 0.3); if(isHover) { sp_gradient.hover_content = true; draw_sprite_stretched_ext(THEME.ui_panel_fg, 1, xx, yy, gww, hg, COLORS._main_accent, 1); diff --git a/scripts/panel_palette/panel_palette.gml b/scripts/panel_palette/panel_palette.gml index 070eb48f3..518b44e43 100644 --- a/scripts/panel_palette/panel_palette.gml +++ b/scripts/panel_palette/panel_palette.gml @@ -104,7 +104,7 @@ function Panel_Palette() : PanelContent() constructor { var right_clicked = false; var pd = view_label? lerp(ui(4), ui(10), (grid_size - ui(8)) / (ui(32) - ui(8))) : ui(3); var param = { color: cur, stretch : PREFERENCES.palette_stretch, mx : _m[0], my : _m[1] }; - var _font = grid_size > ui(12)? f_p2 : f_p3; + var _font = f_p3; for(var i = 0; i < array_length(PALETTES); i++) { var preset = PALETTES[i]; diff --git a/shaders/sh_dialog_palette_selector/sh_dialog_palette_selector.fsh b/shaders/sh_dialog_palette_selector/sh_dialog_palette_selector.fsh new file mode 100644 index 000000000..00e6054b7 --- /dev/null +++ b/shaders/sh_dialog_palette_selector/sh_dialog_palette_selector.fsh @@ -0,0 +1,45 @@ +varying vec2 v_vTexcoord; +varying vec4 v_vColour; + +uniform vec2 dimension; +uniform int edge; +uniform vec4 edgeColor; + +vec2 tx; + +float samp(float x, float y) { + vec4 a = texture2D( gm_BaseTexture, v_vTexcoord + vec2(x, y) * tx ); + return a.a; +} + +void main() { + tx = 1. / dimension; + + float a0 = samp(-1., -1.); + float a1 = samp( 0., -2.); + float a2 = samp( 1., -1.); + + float a3 = samp(-2., 0.); + float a4 = samp( 0., 0.); + float a5 = samp( 2., 0.); + + float a6 = samp(-1., 1.); + float a7 = samp( 0., 2.); + float a8 = samp( 1., 1.); + + gl_FragColor = texture2D( gm_BaseTexture, v_vTexcoord ); + + if(a4 == 0.) return; + + if(a0 < 1. || a1 < 1. || a2 < 1. || a3 < 1. || a5 < 1. || a6 < 1. || a7 < 1. || a8 < 1.) { + gl_FragColor.rgb = edge == 1? edgeColor.rgb : vec3(1.); + + float b0 = samp(-1., 0.); + float b1 = samp( 1., 0.); + float b2 = samp( 0., -1.); + float b3 = samp( 0., 1.); + + if(b0 < 1. || b1 < 1. || b2 < 1. || b3 < 1.) + gl_FragColor.rgb = vec3(0.); + } +} diff --git a/shaders/sh_dialog_palette_selector/sh_dialog_palette_selector.vsh b/shaders/sh_dialog_palette_selector/sh_dialog_palette_selector.vsh new file mode 100644 index 000000000..3900c20f4 --- /dev/null +++ b/shaders/sh_dialog_palette_selector/sh_dialog_palette_selector.vsh @@ -0,0 +1,19 @@ +// +// Simple passthrough vertex shader +// +attribute vec3 in_Position; // (x,y,z) +//attribute vec3 in_Normal; // (x,y,z) unused in this shader. +attribute vec4 in_Colour; // (r,g,b,a) +attribute vec2 in_TextureCoord; // (u,v) + +varying vec2 v_vTexcoord; +varying vec4 v_vColour; + +void main() +{ + vec4 object_space_pos = vec4( in_Position.x, in_Position.y, in_Position.z, 1.0); + gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * object_space_pos; + + v_vColour = in_Colour; + v_vTexcoord = in_TextureCoord; +} diff --git a/shaders/sh_dialog_palette_selector/sh_dialog_palette_selector.yy b/shaders/sh_dialog_palette_selector/sh_dialog_palette_selector.yy new file mode 100644 index 000000000..1973d572c --- /dev/null +++ b/shaders/sh_dialog_palette_selector/sh_dialog_palette_selector.yy @@ -0,0 +1,12 @@ +{ + "$GMShader":"", + "%Name":"sh_dialog_palette_selector", + "name":"sh_dialog_palette_selector", + "parent":{ + "name":"color_selector", + "path":"folders/dialog/color_selector.yy", + }, + "resourceType":"GMShader", + "resourceVersion":"2.0", + "type":1, +} \ No newline at end of file