2023-01-25 06:49:00 +01:00
|
|
|
function draw_tooltip_text(txt) {
|
2023-08-11 21:08:02 +02:00
|
|
|
if(string_length(txt) > 1024)
|
|
|
|
txt = string_copy(txt, 1, 1024) + "...";
|
|
|
|
|
2023-01-25 06:49:00 +01:00
|
|
|
draw_set_text(f_p0, fa_left, fa_top, COLORS._main_text);
|
|
|
|
|
2023-02-21 04:48:50 +01:00
|
|
|
var tw = min(WIN_W - ui(32), string_width(txt));
|
|
|
|
var th = string_height_ext(txt, -1, tw);
|
2023-01-25 06:49:00 +01:00
|
|
|
|
|
|
|
var mx = min(mouse_mx + ui(16), WIN_W - (tw + ui(16)));
|
|
|
|
var my = min(mouse_my + ui(16), WIN_H - (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));
|
2023-06-05 19:41:01 +02:00
|
|
|
draw_text_line(mx + ui(8), my + ui(8), txt, -1, tw);
|
2023-01-25 06:49:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function draw_tooltip_color(clr) {
|
|
|
|
if(is_array(clr)) {
|
|
|
|
draw_tooltip_palette(clr);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var ww = ui(32);
|
|
|
|
var hh = ui(32);
|
|
|
|
|
|
|
|
var mx = min(mouse_mx + ui(16), WIN_W - (ww + ui(16)));
|
|
|
|
var my = min(mouse_my + ui(16), WIN_H - (hh + ui(16)));
|
|
|
|
|
|
|
|
draw_sprite_stretched(THEME.textbox, 3, mx, my, ww + ui(16), hh + ui(16));
|
|
|
|
draw_sprite_stretched(THEME.textbox, 0, mx, my, ww + ui(16), hh + ui(16));
|
|
|
|
|
|
|
|
draw_set_color(clr);
|
|
|
|
draw_rectangle(mx + ui(8), my + ui(8), mx + ui(ww + 8), my + ui(hh + 8), false);
|
|
|
|
}
|
|
|
|
|
|
|
|
function draw_tooltip_palette(clr) {
|
|
|
|
var ww = min(ui(160), ui(32) * array_length(clr));
|
|
|
|
var hh = ui(32);
|
|
|
|
|
|
|
|
var mx = min(mouse_mx + ui(16), WIN_W - (ww + ui(16)));
|
|
|
|
var my = min(mouse_my + ui(16), WIN_H - (hh + ui(16)));
|
|
|
|
|
|
|
|
draw_sprite_stretched(THEME.textbox, 3, mx, my, ww + ui(16), hh + ui(16));
|
|
|
|
draw_sprite_stretched(THEME.textbox, 0, mx, my, ww + ui(16), hh + ui(16));
|
|
|
|
|
|
|
|
drawPalette(clr, mx + ui(8), my + ui(8), ui(ww), ui(hh));
|
|
|
|
}
|
|
|
|
|
2023-03-02 07:59:14 +01:00
|
|
|
function draw_tooltip_gradient(clr) {
|
2023-03-07 14:29:47 +01:00
|
|
|
var ww = ui(160);
|
2023-03-02 07:59:14 +01:00
|
|
|
var hh = ui(32);
|
|
|
|
|
|
|
|
var mx = min(mouse_mx + ui(16), WIN_W - (ww + ui(16)));
|
|
|
|
var my = min(mouse_my + ui(16), WIN_H - (hh + ui(16)));
|
|
|
|
|
|
|
|
draw_sprite_stretched(THEME.textbox, 3, mx, my, ww + ui(16), hh + ui(16));
|
|
|
|
draw_sprite_stretched(THEME.textbox, 0, mx, my, ww + ui(16), hh + ui(16));
|
|
|
|
|
|
|
|
clr.draw(mx + ui(8), my + ui(8), ui(ww), ui(hh));
|
|
|
|
}
|
|
|
|
|
2023-02-14 13:44:46 +01:00
|
|
|
function draw_tooltip_surface_array(surf) {
|
2023-10-12 07:07:24 +02:00
|
|
|
if(!is_array(surf) || array_empty(surf)) return;
|
|
|
|
|
2023-10-06 11:51:11 +02:00
|
|
|
if(is_instanceof(surf[0], SurfaceAtlas)) {
|
|
|
|
draw_tooltip_atlas(surf);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-02-14 13:44:46 +01:00
|
|
|
var amo = array_length(surf);
|
|
|
|
var col = ceil(sqrt(amo));
|
|
|
|
var row = ceil(amo / col);
|
|
|
|
|
|
|
|
var nn = min(ui(64), ui(320) / col);
|
|
|
|
var sw = nn;
|
|
|
|
var sh = nn;
|
|
|
|
|
|
|
|
var ww = sw * col;
|
|
|
|
var hh = sh * row;
|
|
|
|
|
|
|
|
var mx = min(mouse_mx + ui(16), WIN_W - (ww + ui(16)));
|
|
|
|
var my = min(mouse_my + ui(16), WIN_H - (hh + ui(16)));
|
|
|
|
|
|
|
|
draw_sprite_stretched(THEME.textbox, 3, mx, my, ww + ui(16), hh + ui(16));
|
|
|
|
draw_sprite_stretched(THEME.textbox, 0, mx, my, ww + ui(16), hh + ui(16));
|
|
|
|
|
|
|
|
for( var ind = 0; ind < amo; ind++ ) {
|
|
|
|
if(!is_surface(surf[ind])) continue;
|
|
|
|
|
|
|
|
var i = floor(ind / col);
|
2023-02-20 10:16:31 +01:00
|
|
|
var j = safe_mod(ind, col);
|
2023-02-14 13:44:46 +01:00
|
|
|
|
2023-09-08 21:37:36 +02:00
|
|
|
var sw = surface_get_width_safe(surf[ind]);
|
|
|
|
var sh = surface_get_height_safe(surf[ind]);
|
2023-02-14 13:44:46 +01:00
|
|
|
var ss = nn / max(sw, sh);
|
|
|
|
var cx = mx + ui(8) + j * nn + nn / 2;
|
|
|
|
var cy = my + ui(8) + i * nn + nn / 2;
|
|
|
|
|
2023-03-19 09:17:39 +01:00
|
|
|
draw_surface_ext_safe(surf[ind], cx - sw * ss / 2, cy - sh * ss / 2, ss, ss, 0, c_white, 1);
|
2023-02-14 13:44:46 +01:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-25 06:49:00 +01:00
|
|
|
function draw_tooltip_surface(surf) {
|
2023-02-14 13:44:46 +01:00
|
|
|
if(is_array(surf)) {
|
|
|
|
draw_tooltip_surface_array(array_spread(surf))
|
|
|
|
return;
|
|
|
|
}
|
2023-10-06 11:51:11 +02:00
|
|
|
|
|
|
|
if(is_instanceof(surf, SurfaceAtlas)) {
|
|
|
|
draw_tooltip_atlas(surf);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-01-25 06:49:00 +01:00
|
|
|
if(!is_surface(surf)) return;
|
|
|
|
|
2023-09-08 21:37:36 +02:00
|
|
|
var sw = surface_get_width_safe(surf);
|
|
|
|
var sh = surface_get_height_safe(surf);
|
2023-01-25 06:49:00 +01:00
|
|
|
|
|
|
|
var ss = min(ui(128) / sw, ui(128) / sh);
|
|
|
|
|
|
|
|
var ww = sw * ss;
|
|
|
|
var hh = sh * ss;
|
|
|
|
|
|
|
|
var mx = min(mouse_mx + ui(16), WIN_W - (ww + ui(16)));
|
|
|
|
var my = min(mouse_my + ui(16), WIN_H - (hh + ui(16)));
|
|
|
|
|
|
|
|
draw_sprite_stretched(THEME.textbox, 3, 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);
|
2023-05-28 20:00:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function draw_tooltip_atlas(atlas) {
|
|
|
|
if(!is_array(atlas)) atlas = [ atlas ];
|
|
|
|
|
|
|
|
var amo = array_length(atlas);
|
|
|
|
var ww = ui(160);
|
|
|
|
var hh = amo * ui(48 + 8) - ui(8);
|
|
|
|
|
2023-07-30 19:56:53 +02:00
|
|
|
if(amo && is_array(atlas[0])) return;
|
|
|
|
|
2023-05-28 20:00:51 +02:00
|
|
|
var mx = min(mouse_mx + ui(16), WIN_W - (ww + ui(16)));
|
|
|
|
var my = min(mouse_my + ui(16), WIN_H - (hh + ui(16)));
|
|
|
|
|
|
|
|
draw_sprite_stretched(THEME.textbox, 3, mx, my, ww + ui(16), hh + ui(16));
|
|
|
|
draw_sprite_stretched(THEME.textbox, 0, mx, my, ww + ui(16), hh + ui(16));
|
|
|
|
|
|
|
|
var sx = mx + ui(8);
|
|
|
|
var sy = my + ui(8);
|
|
|
|
|
|
|
|
for( var i = 0; i < amo; i++ ) {
|
|
|
|
var _y = sy + i * ui(48 + 8);
|
|
|
|
|
|
|
|
var atl = atlas[i];
|
2023-10-06 11:51:11 +02:00
|
|
|
var surf = atl.getSurface();
|
2023-05-28 20:00:51 +02:00
|
|
|
|
|
|
|
if(!is_surface(surf)) continue;
|
|
|
|
|
2023-09-08 21:37:36 +02:00
|
|
|
var sw = surface_get_width_safe(surf);
|
|
|
|
var sh = surface_get_height_safe(surf);
|
2023-05-28 20:00:51 +02:00
|
|
|
|
|
|
|
var ss = min(ui(48) / sw, ui(48) / sh);
|
|
|
|
draw_surface_ext_safe(surf, sx, _y, ss, ss);
|
|
|
|
|
|
|
|
draw_set_color(COLORS._main_icon);
|
|
|
|
draw_rectangle(sx, _y, sx + ui(48), _y + ui(48), 1);
|
|
|
|
|
|
|
|
draw_set_text(f_p3, fa_left, fa_top, COLORS._main_text_sub);
|
2023-09-28 15:10:41 +02:00
|
|
|
draw_text_add(sx + ui( 56), _y + ui( 0), __txt("Position"));
|
|
|
|
draw_text_add(sx + ui( 56), _y + ui(16), __txt("Rotation"));
|
|
|
|
draw_text_add(sx + ui( 56), _y + ui(32), __txt("Scale"));
|
2023-05-28 20:00:51 +02:00
|
|
|
|
|
|
|
draw_set_text(f_p3, fa_right, fa_top, COLORS._main_text);
|
2023-10-06 11:51:11 +02:00
|
|
|
draw_text_add(sx + ui(160), _y + ui( 0), $"{atl.x}, {atl.y}");
|
2023-05-28 20:00:51 +02:00
|
|
|
draw_text_add(sx + ui(160), _y + ui(16), atl.rotation);
|
2023-10-06 11:51:11 +02:00
|
|
|
draw_text_add(sx + ui(160), _y + ui(32), $"{atl.sx}, {atl.sy}");
|
2023-05-28 20:00:51 +02:00
|
|
|
}
|
2023-06-24 22:12:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function draw_tooltip_buffer(buff) {
|
2023-07-29 10:10:48 +02:00
|
|
|
var txt = buffer_get_string(buff, false, 400);
|
2023-07-21 12:40:20 +02:00
|
|
|
var len = string_length(txt);
|
|
|
|
|
|
|
|
if(len > 400) txt = string_copy(txt, 1, 400);
|
|
|
|
|
|
|
|
draw_set_text(f_code, fa_left, fa_top, COLORS._main_text);
|
|
|
|
|
|
|
|
var tw = min(string_width(" ") * 40, string_width(txt));
|
|
|
|
var th = string_height_ext(txt, -1, tw);
|
|
|
|
if(len > 400)
|
|
|
|
th += string_height(" ");
|
|
|
|
|
|
|
|
var mx = min(mouse_mx + ui(16), WIN_W - (tw + ui(16)));
|
|
|
|
var my = min(mouse_my + ui(16), WIN_H - (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_text_line(mx + ui(8), my + ui(8), txt, -1, tw);
|
|
|
|
|
|
|
|
if(len > 400) {
|
|
|
|
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)");
|
|
|
|
}
|
2023-01-25 06:49:00 +01:00
|
|
|
}
|