2024-05-11 04:56:08 +02:00
|
|
|
function tooltipHotkey(text, context = "", name = "") constructor {
|
2024-04-03 10:01:26 +02:00
|
|
|
self.text = text;
|
2024-04-05 05:50:03 +02:00
|
|
|
self.hotkey = find_hotkey(context, name);
|
|
|
|
|
2024-06-30 11:18:48 +02:00
|
|
|
keyStr = hotkey? key_get_name(hotkey.key, hotkey.modi) : "";
|
2024-04-03 10:01:26 +02:00
|
|
|
|
2024-05-11 04:56:08 +02:00
|
|
|
static setKey = function(key) { keyStr = key; return self; }
|
|
|
|
|
2024-04-03 10:01:26 +02:00
|
|
|
static drawTooltip = function() {
|
2024-07-05 07:06:49 +02:00
|
|
|
if(keyStr == "") { draw_tooltip_text(text); return; }
|
|
|
|
|
2024-08-27 05:30:03 +02:00
|
|
|
draw_set_font(f_p1);
|
2024-04-05 05:50:03 +02:00
|
|
|
var _w1 = string_width(text);
|
|
|
|
|
|
|
|
draw_set_font(f_p1);
|
|
|
|
var _w2 = string_width(keyStr);
|
|
|
|
|
2024-09-12 05:27:42 +02:00
|
|
|
var tw = min(__win_tw - ui(32), _w1 + ui(24) + _w2);
|
2024-04-05 05:50:03 +02:00
|
|
|
var th = string_height_ext(text, -1, tw);
|
|
|
|
|
2024-09-12 05:27:42 +02:00
|
|
|
var mx = min(__mouse_tx + ui(16), __win_tw - (tw + ui(16)));
|
|
|
|
var my = min(__mouse_ty + ui(16), __win_th - (th + ui(16)));
|
2024-04-05 05:50:03 +02:00
|
|
|
|
|
|
|
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));
|
|
|
|
|
2024-08-27 05:30:03 +02:00
|
|
|
draw_set_text(f_p1, fa_left, fa_top, COLORS._main_text);
|
2024-04-05 05:50:03 +02:00
|
|
|
draw_set_color(COLORS._main_text);
|
|
|
|
draw_text_line(mx + ui(8), my + ui(8), text, -1, tw);
|
2024-04-03 10:01:26 +02:00
|
|
|
|
2024-05-19 07:55:09 +02:00
|
|
|
var _hx = mx + tw + ui(6);
|
|
|
|
var _hy = my + th / 2 + ui(10);
|
2024-05-25 10:07:11 +02:00
|
|
|
hotkey_draw(keyStr, _hx, _hy);
|
2024-04-03 10:01:26 +02:00
|
|
|
}
|
2024-08-13 13:17:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function tooltipHotkey_assign(text, hotkey = "") constructor {
|
|
|
|
self.text = text;
|
|
|
|
self.hotkey = hotkey;
|
|
|
|
|
|
|
|
static drawTooltip = function() {
|
|
|
|
var _uns = text == noone;
|
|
|
|
var _txt = _uns? [ __txt("Unassigned") ] : text;
|
|
|
|
|
|
|
|
draw_set_font(f_p1);
|
|
|
|
var _w1 = string_width(hotkey);
|
|
|
|
|
2024-08-27 05:30:03 +02:00
|
|
|
draw_set_font(f_p1);
|
2024-08-13 13:17:45 +02:00
|
|
|
var _w2 = 0;
|
|
|
|
var th = 0;
|
|
|
|
|
|
|
|
for (var i = 0, n = array_length(_txt); i < n; i++) {
|
|
|
|
var _t = _txt[i];
|
|
|
|
var _ts = is_string(_t)? _t : _t.name;
|
|
|
|
|
|
|
|
_w2 = max(_w2, string_width(_ts));
|
|
|
|
th += string_height(_ts);
|
|
|
|
}
|
|
|
|
|
2024-09-12 05:27:42 +02:00
|
|
|
var tw = min(__win_tw - ui(32), _w1 + ui(24) + _w2);
|
|
|
|
var mx = min(__mouse_tx + ui(16), __win_tw - (tw + ui(16)));
|
|
|
|
var my = min(__mouse_ty + ui(16), __win_th - (th + ui(16)));
|
2024-08-13 13:17:45 +02:00
|
|
|
|
|
|
|
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));
|
|
|
|
|
|
|
|
var txy = my + ui(8);
|
|
|
|
|
2024-08-27 05:30:03 +02:00
|
|
|
draw_set_text(f_p1, fa_left, fa_top, _uns? COLORS._main_text_sub : COLORS._main_text);
|
2024-08-13 13:17:45 +02:00
|
|
|
for (var i = 0, n = array_length(_txt); i < n; i++) {
|
|
|
|
var _t = _txt[i];
|
|
|
|
var _ts = is_string(_t)? _t : _t.name;
|
|
|
|
|
|
|
|
draw_text(mx + ui(8), txy, _ts);
|
|
|
|
txy += string_height(_ts);
|
|
|
|
}
|
|
|
|
|
|
|
|
var _hx = mx + tw + ui(6);
|
|
|
|
var _hy = my + line_get_height() / 2 + ui(10);
|
|
|
|
hotkey_draw(hotkey, _hx, _hy);
|
|
|
|
}
|
2024-04-03 10:01:26 +02:00
|
|
|
}
|