Pixel-Composer/objects/o_main/Step_0.gml

146 lines
3.6 KiB
Text
Raw Normal View History

2022-01-13 05:24:03 +01:00
/// @description init
2023-12-18 04:40:21 +01:00
if(winMan_isMinimized()) exit;
winManStep();
2023-03-28 06:58:28 +02:00
2023-03-07 14:29:47 +01:00
//print("===== Step start =====");
2024-03-31 05:36:11 +02:00
if(PROJECT.active && !PROJECT.safeMode) { //node step
PROJECT.step();
2023-12-25 12:51:12 +01:00
LIVE_UPDATE = false;
2023-01-25 06:49:00 +01:00
2023-11-08 08:38:04 +01:00
try {
if(PANEL_MAIN != 0) PANEL_MAIN.step();
array_foreach(PROJECT.allNodes, function(_node) /*=>*/ {
2023-11-29 03:04:28 +01:00
if(!_node.active) return;
_node.triggerCheck();
_node.step();
});
2023-11-08 08:38:04 +01:00
} catch(e) {
noti_warning("Step error: " + exception_print(e));
}
2024-05-15 12:42:54 +02:00
PROJECT.postStep();
2024-05-15 12:42:54 +02:00
IS_SAVING = false;
}
2022-01-13 05:24:03 +01:00
#region hotkey
2023-05-08 19:14:30 +02:00
if(!instance_exists(o_dialog_preference) && !HOTKEY_BLOCK) {
2023-04-21 19:08:10 +02:00
if(ds_map_exists(HOTKEYS, "")) {
var l = HOTKEYS[? ""];
2024-08-13 13:17:45 +02:00
for(var i = 0, n = ds_list_size(l); i < n; i++) {
2023-04-21 19:08:10 +02:00
var hotkey = l[| i];
if(hotkey.key == 0 && hotkey.modi == MOD_KEY.none) continue;
2022-01-13 05:24:03 +01:00
2024-08-13 13:17:45 +02:00
if(key_press(hotkey.key, hotkey.modi))
2023-04-21 19:08:10 +02:00
hotkey.action();
2022-01-13 05:24:03 +01:00
}
}
2023-12-12 08:20:05 +01:00
2023-04-21 19:08:10 +02:00
if(ds_map_exists(HOTKEYS, FOCUS_STR)) {
var list = HOTKEYS[? FOCUS_STR];
2024-08-13 13:17:45 +02:00
for(var i = 0, n = ds_list_size(list); i < n; i++) {
var hotkey = list[| i];
2023-04-21 19:08:10 +02:00
if(hotkey.key == 0 && hotkey.modi == MOD_KEY.none) continue;
2024-08-13 13:17:45 +02:00
if(key_press(hotkey.key, hotkey.modi))
2023-04-21 19:08:10 +02:00
hotkey.action();
2022-01-13 05:24:03 +01:00
}
}
}
2023-05-08 19:14:30 +02:00
HOTKEY_BLOCK = false;
2022-01-13 05:24:03 +01:00
#endregion
#region GIF builder
2022-01-13 05:24:03 +01:00
for( var i = 0; i < ds_list_size(GIF_READER); i++ ) {
var _reader = GIF_READER[| i];
var _reading = _reader[0].reading();
if(_reading) {
var ret = _reader[2];
ret(new __gif_sprite_builder(_reader[0]));
ds_stack_push(gif_complete_st, i);
}
}
while(!ds_stack_empty(gif_complete_st)) {
var i = ds_stack_pop(gif_complete_st);
buffer_delete(GIF_READER[| i][1]);
delete GIF_READER[| i][0];
ds_list_delete(GIF_READER, i);
}
#endregion
2022-09-21 06:09:40 +02:00
#region file drop
2024-07-01 06:23:46 +02:00
if(OS == os_macosx) {
2023-03-08 12:14:01 +01:00
file_dnd_set_files(file_dnd_pattern, file_dnd_allowfiles, file_dnd_allowdirs, file_dnd_allowmulti);
file_dnd_filelist = file_dnd_get_files();
if(file_dnd_filelist != "" && _file_dnd_filelist != file_dnd_filelist) {
var path = string_trim(file_dnd_filelist);
load_file_path(string_splice(path, "\n"));
}
_file_dnd_filelist = file_dnd_filelist;
2022-09-21 06:09:40 +02:00
}
2022-09-27 06:37:28 +02:00
#endregion
#region window
2023-07-06 19:49:16 +02:00
if(_modified != PROJECT.modified) {
_modified = PROJECT.modified;
2023-02-14 02:51:14 +01:00
var cap = "";
2023-11-01 08:10:25 +01:00
if(PROJECT.safeMode) cap += "[SAFE MODE] ";
if(PROJECT.readonly) cap += "[READ ONLY] ";
2023-07-06 19:49:16 +02:00
cap += PROJECT.path + (PROJECT.modified? "*" : "") + " - Pixel Composer";
2023-02-14 02:51:14 +01:00
window_set_caption(cap);
2022-09-27 06:37:28 +02:00
}
2022-11-03 11:44:49 +01:00
#endregion
#region notification
if(!ds_list_empty(WARNING)) {
var rem = ds_stack_create();
for( var i = 0; i < ds_list_size(WARNING); i++ ) {
var w = WARNING[| i];
if(--w.life <= 0)
ds_stack_push(rem, w);
}
while(!ds_stack_empty(rem)) {
ds_list_delete(WARNING, ds_stack_pop(rem));
}
ds_stack_destroy(rem);
}
2023-02-14 02:51:14 +01:00
#endregion
#region steam
steam_update();
if(STEAM_ENABLED) {
if (steam_is_screenshot_requested()) {
2024-05-07 10:54:34 +02:00
var file = $"PixelComposer_{seed_random(6)}.png";
2023-02-14 02:51:14 +01:00
screen_save(file);
steam_send_screenshot(file, window_get_width(), window_get_height());
}
if (steam_avatar_id > 0 && STEAM_AVATAR == 0) {
var _l_dims = steam_image_get_size(steam_avatar_id);
var _buff_size = _l_dims[0] * _l_dims[1] * 4;
var _l_cols = buffer_create(_buff_size, buffer_fixed, 1);
var _l_ok = steam_image_get_rgba(steam_avatar_id, _l_cols, _buff_size);
if(_l_ok) {
var _l_surf = surface_create(_l_dims[0], _l_dims[1]);
buffer_set_surface(_l_cols, _l_surf, 0);
STEAM_AVATAR = sprite_create_from_surface(_l_surf, 0, 0, _l_dims[0], _l_dims[1], false, false, 0, 0);
surface_free(_l_surf);
}
buffer_delete(_l_cols);
}
2023-02-14 02:51:14 +01:00
}
#endregion