tooltip for playing animation

This commit is contained in:
Tanasart 2024-04-03 15:01:26 +07:00
parent f878ff994f
commit 1cfffc033c
8 changed files with 63 additions and 31 deletions

View file

@ -1102,6 +1102,7 @@
{"name":"safe_operation","order":6,"path":"scripts/safe_operation/safe_operation.yy",}, {"name":"safe_operation","order":6,"path":"scripts/safe_operation/safe_operation.yy",},
{"name":"sample_projects","order":6,"path":"scripts/sample_projects/sample_projects.yy",}, {"name":"sample_projects","order":6,"path":"scripts/sample_projects/sample_projects.yy",},
{"name":"save_function","order":1,"path":"scripts/save_function/save_function.yy",}, {"name":"save_function","order":1,"path":"scripts/save_function/save_function.yy",},
{"name":"tooltip_hotkey","order":2,"path":"scripts/tooltip_hotkey/tooltip_hotkey.yy",},
{"name":"scrollBox","order":2,"path":"scripts/scrollBox/scrollBox.yy",}, {"name":"scrollBox","order":2,"path":"scripts/scrollBox/scrollBox.yy",},
{"name":"scrollPane","order":3,"path":"scripts/scrollPane/scrollPane.yy",}, {"name":"scrollPane","order":3,"path":"scripts/scrollPane/scrollPane.yy",},
{"name":"shell_functions","order":20,"path":"scripts/shell_functions/shell_functions.yy",}, {"name":"shell_functions","order":20,"path":"scripts/shell_functions/shell_functions.yy",},
@ -1313,7 +1314,6 @@
{"name":"sh_grid_tri","order":3,"path":"shaders/sh_grid_tri/sh_grid_tri.yy",}, {"name":"sh_grid_tri","order":3,"path":"shaders/sh_grid_tri/sh_grid_tri.yy",},
{"name":"sh_herringbone_tile","order":5,"path":"shaders/sh_herringbone_tile/sh_herringbone_tile.yy",}, {"name":"sh_herringbone_tile","order":5,"path":"shaders/sh_herringbone_tile/sh_herringbone_tile.yy",},
{"name":"sh_image_trace","order":34,"path":"shaders/sh_image_trace/sh_image_trace.yy",}, {"name":"sh_image_trace","order":34,"path":"shaders/sh_image_trace/sh_image_trace.yy",},
{"name":"sh_mask_invert","order":20,"path":"shaders/sh_mask_invert/sh_mask_invert.yy",},
{"name":"sh_invert","order":17,"path":"shaders/sh_invert/sh_invert.yy",}, {"name":"sh_invert","order":17,"path":"shaders/sh_invert/sh_invert.yy",},
{"name":"sh_kuwahara_ani","order":37,"path":"shaders/sh_kuwahara_ani/sh_kuwahara_ani.yy",}, {"name":"sh_kuwahara_ani","order":37,"path":"shaders/sh_kuwahara_ani/sh_kuwahara_ani.yy",},
{"name":"sh_kuwahara","order":36,"path":"shaders/sh_kuwahara/sh_kuwahara.yy",}, {"name":"sh_kuwahara","order":36,"path":"shaders/sh_kuwahara/sh_kuwahara.yy",},
@ -1323,6 +1323,7 @@
{"name":"sh_lovify","order":2,"path":"shaders/sh_lovify/sh_lovify.yy",}, {"name":"sh_lovify","order":2,"path":"shaders/sh_lovify/sh_lovify.yy",},
{"name":"sh_lum2alpha","order":16,"path":"shaders/sh_lum2alpha/sh_lum2alpha.yy",}, {"name":"sh_lum2alpha","order":16,"path":"shaders/sh_lum2alpha/sh_lum2alpha.yy",},
{"name":"sh_mask_expand","order":31,"path":"shaders/sh_mask_expand/sh_mask_expand.yy",}, {"name":"sh_mask_expand","order":31,"path":"shaders/sh_mask_expand/sh_mask_expand.yy",},
{"name":"sh_mask_invert","order":20,"path":"shaders/sh_mask_invert/sh_mask_invert.yy",},
{"name":"sh_mask_modify","order":2,"path":"shaders/sh_mask_modify/sh_mask_modify.yy",}, {"name":"sh_mask_modify","order":2,"path":"shaders/sh_mask_modify/sh_mask_modify.yy",},
{"name":"sh_mesh_generation","order":3,"path":"shaders/sh_mesh_generation/sh_mesh_generation.yy",}, {"name":"sh_mesh_generation","order":3,"path":"shaders/sh_mesh_generation/sh_mesh_generation.yy",},
{"name":"sh_mirror_mask","order":8,"path":"shaders/sh_mirror_mask/sh_mirror_mask.yy",}, {"name":"sh_mirror_mask","order":8,"path":"shaders/sh_mirror_mask/sh_mirror_mask.yy",},

View file

@ -1579,6 +1579,7 @@
{"id":{"name":"safe_operation","path":"scripts/safe_operation/safe_operation.yy",},}, {"id":{"name":"safe_operation","path":"scripts/safe_operation/safe_operation.yy",},},
{"id":{"name":"sample_projects","path":"scripts/sample_projects/sample_projects.yy",},}, {"id":{"name":"sample_projects","path":"scripts/sample_projects/sample_projects.yy",},},
{"id":{"name":"save_function","path":"scripts/save_function/save_function.yy",},}, {"id":{"name":"save_function","path":"scripts/save_function/save_function.yy",},},
{"id":{"name":"tooltip_hotkey","path":"scripts/tooltip_hotkey/tooltip_hotkey.yy",},},
{"id":{"name":"scrollBox","path":"scripts/scrollBox/scrollBox.yy",},}, {"id":{"name":"scrollBox","path":"scripts/scrollBox/scrollBox.yy",},},
{"id":{"name":"scrollPane","path":"scripts/scrollPane/scrollPane.yy",},}, {"id":{"name":"scrollPane","path":"scripts/scrollPane/scrollPane.yy",},},
{"id":{"name":"shader_functions","path":"scripts/shader_functions/shader_functions.yy",},}, {"id":{"name":"shader_functions","path":"scripts/shader_functions/shader_functions.yy",},},
@ -1828,7 +1829,6 @@
{"id":{"name":"sh_herringbone_tile","path":"shaders/sh_herringbone_tile/sh_herringbone_tile.yy",},}, {"id":{"name":"sh_herringbone_tile","path":"shaders/sh_herringbone_tile/sh_herringbone_tile.yy",},},
{"id":{"name":"sh_image_trace","path":"shaders/sh_image_trace/sh_image_trace.yy",},}, {"id":{"name":"sh_image_trace","path":"shaders/sh_image_trace/sh_image_trace.yy",},},
{"id":{"name":"sh_interpret_number","path":"shaders/sh_interpret_number/sh_interpret_number.yy",},}, {"id":{"name":"sh_interpret_number","path":"shaders/sh_interpret_number/sh_interpret_number.yy",},},
{"id":{"name":"sh_mask_invert","path":"shaders/sh_mask_invert/sh_mask_invert.yy",},},
{"id":{"name":"sh_invert","path":"shaders/sh_invert/sh_invert.yy",},}, {"id":{"name":"sh_invert","path":"shaders/sh_invert/sh_invert.yy",},},
{"id":{"name":"sh_kuwahara_ani","path":"shaders/sh_kuwahara_ani/sh_kuwahara_ani.yy",},}, {"id":{"name":"sh_kuwahara_ani","path":"shaders/sh_kuwahara_ani/sh_kuwahara_ani.yy",},},
{"id":{"name":"sh_kuwahara","path":"shaders/sh_kuwahara/sh_kuwahara.yy",},}, {"id":{"name":"sh_kuwahara","path":"shaders/sh_kuwahara/sh_kuwahara.yy",},},
@ -1838,6 +1838,7 @@
{"id":{"name":"sh_lovify","path":"shaders/sh_lovify/sh_lovify.yy",},}, {"id":{"name":"sh_lovify","path":"shaders/sh_lovify/sh_lovify.yy",},},
{"id":{"name":"sh_lum2alpha","path":"shaders/sh_lum2alpha/sh_lum2alpha.yy",},}, {"id":{"name":"sh_lum2alpha","path":"shaders/sh_lum2alpha/sh_lum2alpha.yy",},},
{"id":{"name":"sh_mask_expand","path":"shaders/sh_mask_expand/sh_mask_expand.yy",},}, {"id":{"name":"sh_mask_expand","path":"shaders/sh_mask_expand/sh_mask_expand.yy",},},
{"id":{"name":"sh_mask_invert","path":"shaders/sh_mask_invert/sh_mask_invert.yy",},},
{"id":{"name":"sh_mask_modify","path":"shaders/sh_mask_modify/sh_mask_modify.yy",},}, {"id":{"name":"sh_mask_modify","path":"shaders/sh_mask_modify/sh_mask_modify.yy",},},
{"id":{"name":"sh_mask","path":"shaders/sh_mask/sh_mask.yy",},}, {"id":{"name":"sh_mask","path":"shaders/sh_mask/sh_mask.yy",},},
{"id":{"name":"sh_mesh_generation","path":"shaders/sh_mesh_generation/sh_mesh_generation.yy",},}, {"id":{"name":"sh_mesh_generation","path":"shaders/sh_mesh_generation/sh_mesh_generation.yy",},},

View file

@ -1,4 +1,4 @@
function draw_tooltip_text(txt) { function draw_tooltip_text(txt) { #region
if(string_length(txt) > 1024) if(string_length(txt) > 1024)
txt = string_copy(txt, 1, 1024) + "..."; txt = string_copy(txt, 1, 1024) + "...";
@ -13,9 +13,9 @@ function draw_tooltip_text(txt) {
draw_sprite_stretched(THEME.textbox, 3, mx, my, tw + ui(16), th + ui(16)); draw_sprite_stretched(THEME.textbox, 3, mx, my, tw + ui(16), th + ui(16));
draw_sprite_stretched(THEME.textbox, 0, mx, my, tw + ui(16), th + ui(16)); draw_sprite_stretched(THEME.textbox, 0, mx, my, tw + ui(16), th + ui(16));
draw_text_line(mx + ui(8), my + ui(8), txt, -1, tw); draw_text_line(mx + ui(8), my + ui(8), txt, -1, tw);
} } #endregion
function draw_tooltip_color(clr) { function draw_tooltip_color(clr) { #region
if(is_array(clr)) { if(is_array(clr)) {
draw_tooltip_palette(clr); draw_tooltip_palette(clr);
return; return;
@ -32,9 +32,9 @@ function draw_tooltip_color(clr) {
draw_set_color(clr); draw_set_color(clr);
draw_rectangle(mx + ui(8), my + ui(8), mx + ui(ww + 8), my + ui(hh + 8), false); draw_rectangle(mx + ui(8), my + ui(8), mx + ui(ww + 8), my + ui(hh + 8), false);
} } #endregion
function draw_tooltip_palette(clr) { function draw_tooltip_palette(clr) { #region
if(array_empty(clr)) return; if(array_empty(clr)) return;
var ph = ui(32); var ph = ui(32);
@ -58,9 +58,9 @@ function draw_tooltip_palette(clr) {
drawPalette(clr[i], mx + ui(8), _y, ui(ww), ph); drawPalette(clr[i], mx + ui(8), _y, ui(ww), ph);
_y += ph; _y += ph;
} }
} } #endregion
function draw_tooltip_gradient(clr) { function draw_tooltip_gradient(clr) { #region
var gh = ui(32); var gh = ui(32);
if(!is_array(clr)) clr = [ clr ]; if(!is_array(clr)) clr = [ clr ];
@ -78,9 +78,9 @@ function draw_tooltip_gradient(clr) {
clr[i].draw(mx + ui(8), _y, ui(ww), gh); clr[i].draw(mx + ui(8), _y, ui(ww), gh);
_y += gh; _y += gh;
} }
} } #endregion
function draw_tooltip_surface_array(surf) { function draw_tooltip_surface_array(surf) { #region
if(!is_array(surf) || array_empty(surf)) return; if(!is_array(surf) || array_empty(surf)) return;
if(is_instanceof(surf[0], SurfaceAtlas)) { if(is_instanceof(surf[0], SurfaceAtlas)) {
@ -121,9 +121,9 @@ function draw_tooltip_surface_array(surf) {
draw_set_color(COLORS._main_icon); draw_set_color(COLORS._main_icon);
draw_rectangle(cx - sw * ss / 2, cy - sh * ss / 2, cx + sw * ss / 2 - 1, cy + sh * ss / 2 - 1, true); draw_rectangle(cx - sw * ss / 2, cy - sh * ss / 2, cx + sw * ss / 2 - 1, cy + sh * ss / 2 - 1, true);
} }
} } #endregion
function draw_tooltip_surface(surf) { function draw_tooltip_surface(surf) { #region
if(is_array(surf)) { if(is_array(surf)) {
draw_tooltip_surface_array(array_spread(surf)) draw_tooltip_surface_array(array_spread(surf))
return; return;
@ -151,9 +151,9 @@ function draw_tooltip_surface(surf) {
draw_sprite_stretched(THEME.textbox, 0, mx, my, ww + ui(16), hh + ui(16)); draw_sprite_stretched(THEME.textbox, 0, mx, my, ww + ui(16), hh + ui(16));
draw_surface_ext_safe(surf, mx + ui(8), my + ui(8), ss, ss); draw_surface_ext_safe(surf, mx + ui(8), my + ui(8), ss, ss);
} } #endregion
function draw_tooltip_sprite(spr) { function draw_tooltip_sprite(spr) { #region
if(!sprite_exists(spr)) return; if(!sprite_exists(spr)) return;
var sw = sprite_get_width(spr); var sw = sprite_get_width(spr);
@ -176,9 +176,9 @@ function draw_tooltip_sprite(spr) {
for( var i = 0; i < sn; i++ ) for( var i = 0; i < sn; i++ )
draw_sprite_ext(spr, i, sx + i * (sw * ss + 2), sy, ss, ss, 0, c_white, 1); draw_sprite_ext(spr, i, sx + i * (sw * ss + 2), sy, ss, ss, 0, c_white, 1);
} } #endregion
function draw_tooltip_atlas(atlas) { function draw_tooltip_atlas(atlas) { #region
if(!is_array(atlas)) atlas = [ atlas ]; if(!is_array(atlas)) atlas = [ atlas ];
var amo = array_length(atlas); var amo = array_length(atlas);
@ -223,9 +223,9 @@ function draw_tooltip_atlas(atlas) {
draw_text_add(sx + ui(160), _y + ui(16), atl.rotation); draw_text_add(sx + ui(160), _y + ui(16), atl.rotation);
draw_text_add(sx + ui(160), _y + ui(32), $"{atl.sx}, {atl.sy}"); draw_text_add(sx + ui(160), _y + ui(32), $"{atl.sx}, {atl.sy}");
} }
} } #endregion
function draw_tooltip_buffer(buff) { function draw_tooltip_buffer(buff) { #region
var txt = buffer_get_string(buff, false, 400); var txt = buffer_get_string(buff, false, 400);
var len = string_length(txt); var len = string_length(txt);
@ -249,4 +249,4 @@ function draw_tooltip_buffer(buff) {
draw_set_text(f_code, fa_left, fa_bottom, COLORS._main_text_sub); draw_set_text(f_code, fa_left, fa_bottom, COLORS._main_text_sub);
draw_text(mx + ui(8), my + th + ui(8), $"...({buffer_get_size(buff)} bytes)"); draw_text(mx + ui(8), my + th + ui(8), $"...({buffer_get_size(buff)} bytes)");
} }
} } #endregion

View file

@ -54,6 +54,16 @@
"Move Target": new hotkeySimple("T"), "Move Target": new hotkeySimple("T"),
}, },
}; };
function getToolHotkey(_group, _key, _def = "") {
INLINE
if(!struct_has(HOTKEYS_CUSTOM, _group)) return _def;
var _grp = HOTKEYS_CUSTOM[$ _group];
if(!struct_has(_grp, _key)) return _def;
return _grp[$ _key].key;
}
#endregion #endregion
#region hotkeys #region hotkeys
@ -110,16 +120,15 @@
if(_context == "") ds_list_insert(HOTKEYS[? _context], 0, key); if(_context == "") ds_list_insert(HOTKEYS[? _context], 0, key);
else ds_list_add(HOTKEYS[? _context], key); else ds_list_add(HOTKEYS[? _context], key);
} }
#endregion
#region functions function getHotkey(context, name) {
function getHotkey(_group, _key, _def = "") { if(!ds_map_exists(HOTKEYS, context)) return noone;
INLINE
if(!struct_has(HOTKEYS_CUSTOM, _group)) return _def; for(var i = 0; i < ds_list_size(HOTKEYS[? context]); i++) {
var hotkey = HOTKEYS[? _context][| i];
if(hotkey.name == name) return hotkey;
}
var _grp = HOTKEYS_CUSTOM[$ _group]; return noone;
if(!struct_has(_grp, _key)) return _def;
return _grp[$ _key].key;
} }
#endregion #endregion

View file

@ -11,7 +11,7 @@ function NodeTool(name, spr, context = instanceof(other)) constructor {
static checkHotkey = function() { static checkHotkey = function() {
INLINE INLINE
return getHotkey(ctx, name); return getToolHotkey(ctx, name);
} }
static getName = function(index = 0) { static getName = function(index = 0) {

View file

@ -174,7 +174,7 @@ function Panel_Animation() : PanelContent() constructor {
function() { PROJECT.animator.stop(); } function() { PROJECT.animator.stop(); }
], ],
[ [
function() { return PROJECT.animator.is_playing? __txt("Pause") : __txt("Play"); }, function() { return PROJECT.animator.is_playing? __txt("Pause") : __txt("Play from current (Shift + Space)"); },
function() { return !PROJECT.animator.is_playing; }, function() { return !PROJECT.animator.is_playing; },
function() { return PROJECT.animator.is_playing? COLORS._main_accent : COLORS._main_icon; }, function() { return PROJECT.animator.is_playing? COLORS._main_accent : COLORS._main_icon; },
function() { if(PROJECT.animator.is_playing) PROJECT.animator.pause(); else PROJECT.animator.resume(); } function() { if(PROJECT.animator.is_playing) PROJECT.animator.pause(); else PROJECT.animator.resume(); }

View file

@ -0,0 +1,8 @@
function tooltipHotkey(text, context, name) constructor {
self.text = text;
self.hotkey = getHotkey(context, name);
static drawTooltip = function() {
}
}

View file

@ -0,0 +1,13 @@
{
"$GMScript":"",
"%Name":"tooltip_hotkey",
"isCompatibility":false,
"isDnD":false,
"name":"tooltip_hotkey",
"parent":{
"name":"tooltip",
"path":"folders/functions/tooltip.yy",
},
"resourceType":"GMScript",
"resourceVersion":"2.0",
}