2022-01-13 05:24:03 +01:00
|
|
|
/// @description init
|
|
|
|
#region draw
|
2022-11-03 11:44:49 +01:00
|
|
|
var yy = dialog_y;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-01-04 02:30:04 +01:00
|
|
|
draw_sprite_stretched(THEME.textbox, 3, dialog_x, dialog_y, dialog_w, dialog_h);
|
2023-02-19 02:13:19 +01:00
|
|
|
//if(show_icon)
|
|
|
|
// draw_sprite_stretched(THEME.textbox_code, 0, dialog_x, dialog_y, ui(36), dialog_h);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
for(var i = 0; i < array_length(menu); i++) {
|
2023-01-25 06:49:00 +01:00
|
|
|
var _menuItem = menu[i];
|
|
|
|
|
2023-02-19 02:13:19 +01:00
|
|
|
if(_menuItem == -1) {
|
|
|
|
var bx = dialog_x + ui(8);
|
|
|
|
var bw = dialog_w - ui(16);
|
|
|
|
draw_sprite_stretched(THEME.menu_separator, 0, bx, yy, bw, ui(6));
|
2022-11-03 11:44:49 +01:00
|
|
|
yy += ui(8);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
2023-02-19 02:13:19 +01:00
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
var _h = hght;
|
2023-02-19 02:13:19 +01:00
|
|
|
var label = _menuItem.name;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-02-19 02:13:19 +01:00
|
|
|
if(instanceof(_menuItem) == "MenuItemGroup")
|
2022-01-13 05:24:03 +01:00
|
|
|
_h += hght;
|
2023-01-25 06:49:00 +01:00
|
|
|
|
2023-02-19 02:13:19 +01:00
|
|
|
var hoverable = _menuItem.active && sHOVER;
|
2023-01-25 06:49:00 +01:00
|
|
|
if(hoverable && point_in_rectangle(mouse_mx, mouse_my, dialog_x, yy + 1, dialog_x + dialog_w, yy + _h - 1))
|
|
|
|
selecting = i;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-01-25 06:49:00 +01:00
|
|
|
if(selecting == i) {
|
2023-02-19 02:13:19 +01:00
|
|
|
draw_sprite_stretched_ext(THEME.textbox, 3, dialog_x, yy, dialog_w, _h, COLORS.dialog_menubox_highlight, 0.75);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-02-19 02:13:19 +01:00
|
|
|
if(instanceof(_menuItem) == "MenuItem" && sFOCUS && (mouse_release(mb_left) || keyboard_check_released(vk_enter))) {
|
|
|
|
var res = _menuItem.func(dialog_x + dialog_w, yy, depth, _menuItem.name);
|
|
|
|
if(_menuItem.isShelf) ds_list_add(children, res);
|
|
|
|
else instance_destroy(o_dialog_menubox);
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-19 02:13:19 +01:00
|
|
|
if(instanceof(_menuItem) == "MenuItemGroup") {
|
|
|
|
var _submenus = _menuItem.group;
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_set_text(f_p1, fa_center, fa_center, COLORS._main_text_sub);
|
2023-02-19 02:13:19 +01:00
|
|
|
draw_set_alpha(_menuItem.active * 0.5 + 0.5);
|
2022-11-22 14:25:39 +01:00
|
|
|
draw_text(dialog_x + dialog_w / 2, yy + hght / 2, label);
|
|
|
|
draw_set_alpha(1);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-01-25 06:49:00 +01:00
|
|
|
var amo = array_length(_submenus);
|
2022-11-03 11:44:49 +01:00
|
|
|
var _w = (amo - 1) / 2 * (hght + ui(4));
|
2022-01-13 05:24:03 +01:00
|
|
|
var _sx = dialog_x + dialog_w / 2 - _w;
|
|
|
|
|
|
|
|
for(var j = 0; j < amo; j++) {
|
2023-01-25 06:49:00 +01:00
|
|
|
var _submenu = _submenus[j];
|
2023-02-19 02:13:19 +01:00
|
|
|
var _bx = _sx + j * (hght + ui(4));
|
|
|
|
var _by = yy + hght + hght / 2 - ui(4);
|
|
|
|
var _spr = noone, _ind = 0;
|
|
|
|
var _sprs = _submenu[0];
|
|
|
|
var _tlp = array_safe_get(_submenu, 2, "");
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-01-25 06:49:00 +01:00
|
|
|
if(is_array(_sprs)) {
|
|
|
|
_spr = _sprs[0];
|
|
|
|
_ind = _sprs[1];
|
2022-09-23 13:28:42 +02:00
|
|
|
} else {
|
2023-01-25 06:49:00 +01:00
|
|
|
_spr = _sprs;
|
2022-09-23 13:28:42 +02:00
|
|
|
_ind = 0;
|
|
|
|
}
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-11-03 11:44:49 +01:00
|
|
|
if(sHOVER && point_in_rectangle(mouse_mx, mouse_my, _bx - ui(14), _by - ui(14), _bx + ui(14), _by + ui(14))) {
|
2023-01-25 06:49:00 +01:00
|
|
|
if(_tlp != "") TOOLTIP = _tlp;
|
2023-01-04 02:30:04 +01:00
|
|
|
draw_sprite_stretched_ext(THEME.textbox, 3, _bx - ui(14), _by - ui(14), ui(28), ui(28), COLORS.dialog_menubox_highlight, 1);
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_sprite_stretched_ext(THEME.textbox, 1, _bx - ui(14), _by - ui(14), ui(28), ui(28), COLORS.dialog_menubox_highlight, 1);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-12-10 05:06:01 +01:00
|
|
|
if(mouse_press(mb_left, sFOCUS)) {
|
2023-01-25 06:49:00 +01:00
|
|
|
_submenu[1]();
|
2022-11-01 03:06:03 +01:00
|
|
|
instance_destroy(o_dialog_menubox);
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-03 11:44:49 +01:00
|
|
|
draw_sprite_ui_uniform(_spr, _ind, _bx, _by);
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
} else {
|
2023-02-19 02:13:19 +01:00
|
|
|
var tx = dialog_x + show_icon * ui(32) + ui(16);
|
|
|
|
|
|
|
|
if(_menuItem.spr != noone) {
|
|
|
|
var spr = is_array(_menuItem.spr)? _menuItem.spr[0] : _menuItem.spr;
|
|
|
|
var ind = is_array(_menuItem.spr)? _menuItem.spr[1] : 0;
|
|
|
|
draw_sprite_ui(spr, ind, dialog_x + ui(24), yy + hght / 2,,,, COLORS._main_icon, 0.75);
|
|
|
|
}
|
|
|
|
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text);
|
2023-02-19 02:13:19 +01:00
|
|
|
draw_set_alpha(_menuItem.active * 0.5 + 0.5);
|
|
|
|
draw_text(tx, yy + hght / 2, label);
|
2022-11-22 14:25:39 +01:00
|
|
|
draw_set_alpha(1);
|
2023-02-19 02:13:19 +01:00
|
|
|
|
|
|
|
if(_menuItem.isShelf) {
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_sprite_ui_uniform(THEME.arrow, 0, dialog_x + dialog_w - ui(20), yy + hght / 2, 1, COLORS._main_icon);
|
2023-02-19 02:13:19 +01:00
|
|
|
} else if(_menuItem.hotkey != noone) {
|
|
|
|
var _key = find_hotkey(_menuItem.hotkey[0], _menuItem.hotkey[1]);
|
2022-11-01 03:06:03 +01:00
|
|
|
if(_key) {
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_set_text(f_p1, fa_right, fa_center, COLORS._main_text_sub);
|
2022-11-03 11:44:49 +01:00
|
|
|
draw_text(dialog_x + dialog_w - ui(16), yy + hght / 2, key_get_name(_key.key, _key.modi));
|
2022-11-01 03:06:03 +01:00
|
|
|
}
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
yy += _h;
|
|
|
|
}
|
2023-01-04 02:30:04 +01:00
|
|
|
|
2023-01-25 06:49:00 +01:00
|
|
|
if(sFOCUS) {
|
|
|
|
if(keyboard_check_pressed(vk_up)) {
|
|
|
|
selecting--;
|
|
|
|
if(selecting < 0) selecting = array_length(menu) - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(keyboard_check_pressed(vk_down))
|
|
|
|
selecting = (selecting + 1) % array_length(menu);
|
|
|
|
|
|
|
|
if(keyboard_check_pressed(vk_escape))
|
|
|
|
instance_destroy();
|
|
|
|
}
|
|
|
|
|
2023-01-04 02:30:04 +01:00
|
|
|
draw_sprite_stretched(THEME.textbox, 1, dialog_x, dialog_y, dialog_w, dialog_h);
|
2022-01-13 05:24:03 +01:00
|
|
|
#endregion
|