2023-02-28 09:43:01 +01:00
|
|
|
function dialogCall(_dia, _x = noone, _y = noone, param = {}, create = false) {
|
2022-11-01 03:06:03 +01:00
|
|
|
if(_x == noone) _x = WIN_SW / 2;
|
|
|
|
if(_y == noone) _y = WIN_SH / 2;
|
|
|
|
|
2023-02-28 09:43:01 +01:00
|
|
|
var dia = !create && instance_exists(_dia)? instance_find(_dia, 0) : instance_create_depth(_x, _y, 0, _dia);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
dia.x = _x;
|
|
|
|
dia.y = _y;
|
2023-01-25 06:49:00 +01:00
|
|
|
dia.xstart = _x;
|
|
|
|
dia.ystart = _y;
|
|
|
|
dia.resetPosition();
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-09-21 06:09:40 +02:00
|
|
|
var args = variable_struct_get_names(param);
|
2023-03-12 02:28:21 +01:00
|
|
|
for( var i = 0; i < array_length(args); i++ )
|
2022-09-21 06:09:40 +02:00
|
|
|
variable_instance_set(dia, args[i], variable_struct_get(param, args[i]));
|
2023-03-12 02:28:21 +01:00
|
|
|
|
|
|
|
setFocus(dia.id, "Dialog");
|
|
|
|
return dia;
|
|
|
|
}
|
|
|
|
|
|
|
|
function dialogPanelCall(_panel, _x = noone, _y = noone) {
|
|
|
|
if(_x == noone) _x = WIN_SW / 2;
|
|
|
|
if(_y == noone) _y = WIN_SH / 2;
|
|
|
|
|
|
|
|
var dia = instance_create_depth(_x, _y, 0, o_dialog_panel);
|
|
|
|
dia.setContent(_panel);
|
|
|
|
|
|
|
|
dia.x = _x;
|
|
|
|
dia.y = _y;
|
|
|
|
dia.xstart = _x;
|
|
|
|
dia.ystart = _y;
|
|
|
|
dia.resetPosition();
|
2022-09-21 06:09:40 +02:00
|
|
|
|
2023-01-25 06:49:00 +01:00
|
|
|
setFocus(dia.id, "Dialog");
|
2022-12-10 05:06:01 +01:00
|
|
|
return dia;
|
|
|
|
}
|
|
|
|
|
2023-02-23 07:02:19 +01:00
|
|
|
function menuCall(_x = mouse_mx + ui(4), _y = mouse_my + ui(4), menu = [], align = fa_left) {
|
2022-12-10 05:06:01 +01:00
|
|
|
var dia = dialogCall(o_dialog_menubox, _x, _y);
|
2023-02-23 07:02:19 +01:00
|
|
|
dia.setMenu(menu, align);
|
2022-01-13 05:24:03 +01:00
|
|
|
return dia;
|
2023-02-17 11:31:33 +01:00
|
|
|
}
|
|
|
|
|
2023-02-19 02:13:19 +01:00
|
|
|
function submenuCall(_x, _y, _depth, menu = []) {
|
|
|
|
var dia = instance_create_depth(_x - ui(4), _y, _depth - 1, o_dialog_menubox);
|
|
|
|
dia.setMenu(menu);
|
|
|
|
return dia;
|
|
|
|
}
|
|
|
|
|
2023-03-12 02:28:21 +01:00
|
|
|
function menuItem(name, func, spr = noone, hotkey = noone, toggle = noone) {
|
|
|
|
return new MenuItem(name, func, spr, hotkey, toggle);
|
2023-02-19 02:13:19 +01:00
|
|
|
}
|
2023-03-12 02:28:21 +01:00
|
|
|
function MenuItem(name, func, spr = noone, hotkey = noone, toggle = noone) constructor {
|
2023-02-19 02:13:19 +01:00
|
|
|
active = true;
|
2023-02-17 11:31:33 +01:00
|
|
|
self.name = name;
|
|
|
|
self.func = func;
|
|
|
|
self.spr = spr;
|
|
|
|
self.hotkey = hotkey;
|
2023-03-12 02:28:21 +01:00
|
|
|
self.toggle = toggle;
|
2023-02-19 02:13:19 +01:00
|
|
|
|
|
|
|
isShelf = false;
|
|
|
|
|
|
|
|
static setIsShelf = function() {
|
|
|
|
isShelf = true;
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2023-03-02 07:59:14 +01:00
|
|
|
static setActive = function(active) {
|
|
|
|
self.active = active;
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2023-02-19 02:13:19 +01:00
|
|
|
static deactivate = function() {
|
|
|
|
active = false;
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function menuItemGroup(name, group) {
|
|
|
|
return new MenuItemGroup(name, group);
|
|
|
|
}
|
|
|
|
function MenuItemGroup(name, group) constructor {
|
|
|
|
active = true;
|
|
|
|
self.name = name;
|
|
|
|
self.group = group;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|