mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-12-25 14:36:13 +01:00
86 lines
No EOL
2 KiB
Text
86 lines
No EOL
2 KiB
Text
function dialogCall(_dia, _x = noone, _y = noone, param = {}, create = false) {
|
|
if(_x == noone) _x = WIN_SW / 2;
|
|
if(_y == noone) _y = WIN_SH / 2;
|
|
|
|
var dia = !create && instance_exists(_dia)? instance_find(_dia, 0) : instance_create_depth(_x, _y, 0, _dia);
|
|
|
|
dia.x = _x;
|
|
dia.y = _y;
|
|
dia.xstart = _x;
|
|
dia.ystart = _y;
|
|
dia.resetPosition();
|
|
|
|
var args = variable_struct_get_names(param);
|
|
for( var i = 0; i < array_length(args); i++ )
|
|
variable_instance_set(dia, args[i], variable_struct_get(param, args[i]));
|
|
|
|
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();
|
|
|
|
setFocus(dia.id, "Dialog");
|
|
return dia;
|
|
}
|
|
|
|
function menuCall(_x = mouse_mx + ui(4), _y = mouse_my + ui(4), menu = [], align = fa_left) {
|
|
var dia = dialogCall(o_dialog_menubox, _x, _y);
|
|
dia.setMenu(menu, align);
|
|
return dia;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
function menuItem(name, func, spr = noone, hotkey = noone, toggle = noone) {
|
|
return new MenuItem(name, func, spr, hotkey, toggle);
|
|
}
|
|
function MenuItem(name, func, spr = noone, hotkey = noone, toggle = noone) constructor {
|
|
active = true;
|
|
self.name = name;
|
|
self.func = func;
|
|
self.spr = spr;
|
|
self.hotkey = hotkey;
|
|
self.toggle = toggle;
|
|
|
|
isShelf = false;
|
|
|
|
static setIsShelf = function() {
|
|
isShelf = true;
|
|
return self;
|
|
}
|
|
|
|
static setActive = function(active) {
|
|
self.active = active;
|
|
return self;
|
|
}
|
|
|
|
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;
|
|
} |