2023-05-03 21:42:17 +02:00
|
|
|
#region context menu
|
|
|
|
globalvar CONTEXT_MENU_CALLBACK;
|
|
|
|
CONTEXT_MENU_CALLBACK = ds_map_create();
|
|
|
|
|
2023-05-04 20:00:56 +02:00
|
|
|
function menuCall(menu_id = "", _x = mouse_mx + ui(4), _y = mouse_my + ui(4), menu = [], align = fa_left, context = noone) {
|
2023-05-03 21:42:17 +02:00
|
|
|
var dia = dialogCall(o_dialog_menubox, _x, _y);
|
|
|
|
if(menu_id != "" && ds_map_exists(CONTEXT_MENU_CALLBACK, menu_id)) {
|
|
|
|
var callbacks = CONTEXT_MENU_CALLBACK[? menu_id];
|
|
|
|
|
2023-07-25 20:12:40 +02:00
|
|
|
for( var i = 0, n = array_length(callbacks); i < n; i++ )
|
2023-05-03 21:42:17 +02:00
|
|
|
array_append(menu, callbacks[i].populate());
|
|
|
|
}
|
|
|
|
|
2023-05-08 19:14:30 +02:00
|
|
|
dia.menu_id = menu_id;
|
2023-05-04 20:00:56 +02:00
|
|
|
dia.context = context;
|
2023-05-03 21:42:17 +02:00
|
|
|
dia.setMenu(menu, align);
|
|
|
|
return dia;
|
|
|
|
}
|
2023-12-20 14:02:49 +01:00
|
|
|
|
|
|
|
function pieMenuCall(menu_id = "", _x = mouse_mx, _y = mouse_my, menu = [], context = noone) {
|
|
|
|
var dia = instance_create(_x, _y, o_pie_menu);
|
|
|
|
if(menu_id != "" && ds_map_exists(CONTEXT_MENU_CALLBACK, menu_id)) {
|
|
|
|
var callbacks = CONTEXT_MENU_CALLBACK[? menu_id];
|
|
|
|
|
|
|
|
for( var i = 0, n = array_length(callbacks); i < n; i++ )
|
|
|
|
array_append(menu, callbacks[i].populate());
|
|
|
|
}
|
|
|
|
|
|
|
|
dia.menu_id = menu_id;
|
|
|
|
dia.context = context;
|
|
|
|
dia.setMenu(menu);
|
|
|
|
return dia;
|
|
|
|
}
|
2023-05-03 21:42:17 +02:00
|
|
|
|
2023-05-04 20:00:56 +02:00
|
|
|
function submenuCall(_data, menu = []) {
|
|
|
|
var dia = instance_create_depth(_data.x - ui(4), _data.y, _data.depth - 1, o_dialog_menubox);
|
2023-05-07 20:55:13 +02:00
|
|
|
dia.context = _data.context;
|
2023-05-03 21:42:17 +02:00
|
|
|
dia.setMenu(menu);
|
2023-05-07 20:55:13 +02:00
|
|
|
|
|
|
|
if(_data.x - ui(4) + dia.dialog_w > WIN_W - ui(2))
|
|
|
|
dia.dialog_x = _data._x - dia.dialog_w + ui(4);
|
|
|
|
|
2023-05-03 21:42:17 +02:00
|
|
|
return dia;
|
|
|
|
}
|
2023-05-04 20:00:56 +02:00
|
|
|
|
2024-05-22 04:46:29 +02:00
|
|
|
function fileNameCall(path, onModify, _x = mouse_mx + 8, _y = mouse_my + 8) {
|
|
|
|
var dia = dialogCall(o_dialog_file_name, _x, _y);
|
|
|
|
dia.onModify = onModify;
|
|
|
|
dia.path = string_trim_end(path, [ "\\", "/" ]) + "/";
|
|
|
|
|
|
|
|
return dia;
|
|
|
|
}
|
|
|
|
|
2023-12-19 14:30:34 +01:00
|
|
|
function menuItem(name, func, spr = noone, hotkey = noone, toggle = noone, params = {}) {
|
2023-11-08 08:38:04 +01:00
|
|
|
INLINE
|
2023-12-19 14:30:34 +01:00
|
|
|
return new MenuItem(name, func, spr, hotkey, toggle, params);
|
2023-05-03 21:42:17 +02:00
|
|
|
}
|
2023-05-04 20:00:56 +02:00
|
|
|
|
2023-12-19 14:30:34 +01:00
|
|
|
function MenuItem(name, func, spr = noone, hotkey = noone, toggle = noone, params = {}) constructor {
|
2023-05-03 21:42:17 +02:00
|
|
|
active = true;
|
|
|
|
self.name = name;
|
|
|
|
self.func = func;
|
|
|
|
self.spr = spr;
|
|
|
|
self.hotkey = hotkey;
|
|
|
|
self.toggle = toggle;
|
2023-12-19 14:30:34 +01:00
|
|
|
self.params = params;
|
2023-11-01 08:10:25 +01:00
|
|
|
color = c_white;
|
2024-04-08 07:13:46 +02:00
|
|
|
|
|
|
|
isShelf = false;
|
|
|
|
shelfObject = noone;
|
2023-11-01 08:10:25 +01:00
|
|
|
|
|
|
|
shiftMenu = noone;
|
|
|
|
|
2023-05-03 21:42:17 +02:00
|
|
|
static setIsShelf = function() {
|
2023-11-08 08:38:04 +01:00
|
|
|
INLINE
|
2023-05-03 21:42:17 +02:00
|
|
|
isShelf = true;
|
|
|
|
return self;
|
|
|
|
}
|
2023-11-01 08:10:25 +01:00
|
|
|
|
2023-05-03 21:42:17 +02:00
|
|
|
static setActive = function(active) {
|
2023-11-08 08:38:04 +01:00
|
|
|
INLINE
|
2023-05-03 21:42:17 +02:00
|
|
|
self.active = active;
|
|
|
|
return self;
|
|
|
|
}
|
2023-11-01 08:10:25 +01:00
|
|
|
|
2023-05-03 21:42:17 +02:00
|
|
|
static setColor = function(color) {
|
2023-11-08 08:38:04 +01:00
|
|
|
INLINE
|
2023-05-03 21:42:17 +02:00
|
|
|
self.color = color;
|
|
|
|
return self;
|
|
|
|
}
|
2023-11-01 08:10:25 +01:00
|
|
|
|
|
|
|
static setShiftMenu = function(shiftMenu) {
|
2023-11-08 08:38:04 +01:00
|
|
|
INLINE
|
2023-11-01 08:10:25 +01:00
|
|
|
self.shiftMenu = shiftMenu;
|
|
|
|
return self;
|
|
|
|
}
|
2023-05-03 21:42:17 +02:00
|
|
|
|
|
|
|
static deactivate = function() {
|
2023-11-08 08:38:04 +01:00
|
|
|
INLINE
|
2023-05-03 21:42:17 +02:00
|
|
|
active = false;
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function menuItemGroup(name, group) {
|
|
|
|
return new MenuItemGroup(name, group);
|
|
|
|
}
|
2023-10-07 09:09:18 +02:00
|
|
|
|
2023-05-03 21:42:17 +02:00
|
|
|
function MenuItemGroup(name, group) constructor {
|
|
|
|
active = true;
|
|
|
|
self.name = name;
|
|
|
|
self.group = group;
|
2023-10-14 08:00:35 +02:00
|
|
|
|
|
|
|
spacing = ui(36);
|
2023-05-03 21:42:17 +02:00
|
|
|
}
|
|
|
|
#endregion
|