Pixel-Composer/objects/o_main/Step_1.gml

213 lines
5.2 KiB
Text
Raw Normal View History

2022-01-13 05:24:03 +01:00
/// @description init
global.__debug_runner++;
2023-07-14 20:34:35 +02:00
global.cache_call = 0;
global.cache_hit = 0;
HOVERING_ELEMENT = _HOVERING_ELEMENT;
2023-05-03 21:42:17 +02:00
_HOVERING_ELEMENT = noone;
2023-03-28 06:58:28 +02:00
#region minimize
2023-12-18 04:40:21 +01:00
if(winMan_isMinimized()) {
if(!minimized) game_set_speed(1, gamespeed_fps);
minimized = true;
exit;
} else if(!minimized)
window_preminimize_rect = [ window_get_x(), window_get_y(), window_get_width(), window_get_height() ];
2023-03-28 06:58:28 +02:00
if(minimized) {
2023-10-31 05:30:42 +01:00
game_set_speed(PREFERENCES.ui_framerate, gamespeed_fps);
2023-12-18 04:40:21 +01:00
window_set_rectangle(window_preminimize_rect[0], window_preminimize_rect[1], window_preminimize_rect[2], window_preminimize_rect[3]);
2023-03-28 06:58:28 +02:00
minimized = false;
}
#endregion
2022-01-13 05:24:03 +01:00
#region window
//if(keyboard_check_pressed(vk_f12)) DEBUG = !DEBUG;
if(_cursor != CURSOR) {
window_set_cursor(CURSOR);
_cursor = CURSOR;
}
2023-11-05 04:19:19 +01:00
2022-01-13 05:24:03 +01:00
CURSOR = cr_default;
#endregion
#region focus
2023-08-12 09:41:13 +02:00
if(mouse_release(mb_any)) DIALOG_CLICK = true;
2022-01-13 05:24:03 +01:00
HOVER = noone;
2023-08-12 09:41:13 +02:00
with(_p_dialog) checkMouse();
2022-01-13 05:24:03 +01:00
2023-11-08 08:38:04 +01:00
if(PANEL_MAIN != 0) PANEL_MAIN.stepBegin();
2023-02-28 09:43:01 +01:00
2022-01-13 05:24:03 +01:00
DIALOG_DEPTH_HOVER = 0;
2023-08-12 09:41:13 +02:00
2023-02-28 09:43:01 +01:00
with(_p_dialog) checkFocus();
with(_p_dialog) checkDepth();
2022-01-13 05:24:03 +01:00
2023-02-28 09:43:01 +01:00
with(_p_dialog) doDrag();
with(_p_dialog) doResize();
2022-01-13 05:24:03 +01:00
#endregion
2023-02-15 10:43:24 +01:00
#region auto save
AUTO_SAVE_TIMER += delta_time / 1_000_000;
2023-10-31 05:30:42 +01:00
if(PROJECT.modified && PREFERENCES.auto_save_time > 0 && AUTO_SAVE_TIMER > PREFERENCES.auto_save_time) {
2023-02-15 10:43:24 +01:00
AUTO_SAVE_TIMER = 0;
2023-03-08 12:14:01 +01:00
var loc = DIRECTORY + "Autosave/";
directory_verify(loc);
2023-02-15 10:43:24 +01:00
2023-07-06 19:49:16 +02:00
var fname = string_replace(filename_name(PROJECT.path), filename_ext(PROJECT.path), "") +
2023-02-15 10:43:24 +01:00
"_autosave" + string(current_year) + "-" +
string_lead_zero(current_month, 2) + "-" +
string_lead_zero(current_day, 2) + "T" +
string_lead_zero(current_hour, 2) +
string_lead_zero(current_minute, 2) +
string_lead_zero(current_second, 2) + ".pxc";
2023-07-06 19:49:16 +02:00
try { SAVE_AT(PROJECT, loc + fname, "Autosaved "); }
2023-05-08 10:50:42 +02:00
catch(e) { print(exception_print(e)); }
2023-02-15 10:43:24 +01:00
}
#endregion
2023-11-26 13:16:38 +01:00
#region animation & render
2023-03-28 06:58:28 +02:00
DEF_SURFACE_RESET();
2023-12-25 12:51:12 +01:00
if(!PROJECT.safeMode&& UPDATE_RENDER_ORDER) {
ResetAllNodesRender();
NodeTopoSort();
}
if(LIVE_UPDATE)
Render();
else if(!PROJECT.safeMode) {
2023-11-01 08:10:25 +01:00
UPDATE_RENDER_ORDER = false;
2023-11-08 08:38:04 +01:00
2023-11-01 08:10:25 +01:00
if(PROJECT.active) {
2024-01-19 09:33:37 +01:00
PROJECT.animator.is_simulating = false;
2023-11-08 08:38:04 +01:00
array_foreach(PROJECT.nodeArray, function(_node) { if(!_node.active) return; _node.stepBegin(); });
2023-11-04 13:22:52 +01:00
if(IS_PLAYING || IS_RENDERING) {
2023-11-01 08:10:25 +01:00
if(PROJECT.animator.frame_progress) {
__addon_preAnim();
2023-11-25 08:54:35 +01:00
2024-01-19 09:33:37 +01:00
if(IS_FIRST_FRAME)
2023-11-01 08:10:25 +01:00
ResetAllNodesRender();
Render(true);
2023-11-30 03:18:25 +01:00
2023-11-01 08:10:25 +01:00
__addon_postAnim();
}
PROJECT.animator.frame_progress = false;
} else {
if(UPDATE & RENDER_TYPE.full)
Render();
else if(UPDATE & RENDER_TYPE.partial)
Render(true);
2023-07-23 21:15:45 +02:00
}
2023-04-23 16:47:33 +02:00
}
2023-03-12 02:28:21 +01:00
}
2023-07-23 21:15:45 +02:00
2022-12-10 05:06:01 +01:00
UPDATE = RENDER_TYPE.none;
2022-01-13 05:24:03 +01:00
#endregion
#region clicks
DOUBLE_CLICK = false;
2022-12-10 05:06:01 +01:00
if(mouse_press(mb_left)) {
2022-01-13 05:24:03 +01:00
if(dc_check > 0) {
2023-07-17 19:58:33 +02:00
if(point_distance(mouse_mx, mouse_my, DOUBLE_CLICK_POS[0], DOUBLE_CLICK_POS[1]) < 8)
DOUBLE_CLICK = true;
2022-01-13 05:24:03 +01:00
dc_check = 0;
2023-07-17 19:58:33 +02:00
} else {
2023-10-31 05:30:42 +01:00
dc_check = PREFERENCES.double_click_delay;
2023-07-17 19:58:33 +02:00
DOUBLE_CLICK_POS = [ mouse_mx, mouse_my ];
}
2022-01-13 05:24:03 +01:00
}
2022-12-12 09:08:03 +01:00
dc_check -= DELTA_TIME;
2022-01-13 05:24:03 +01:00
#endregion
#region step
if(array_length(action_last_frame) > 0) {
ds_stack_push(UNDO_STACK, action_last_frame);
ds_stack_clear(REDO_STACK);
}
action_last_frame = [];
2022-11-18 03:20:31 +01:00
#endregion
2022-12-22 03:09:55 +01:00
#region modifiers
2023-02-14 02:51:14 +01:00
if(CTRL == KEYBOARD_STATUS.up)
CTRL = KEYBOARD_STATUS.idle;
if(SHIFT == KEYBOARD_STATUS.up)
SHIFT = KEYBOARD_STATUS.idle;
if(ALT == KEYBOARD_STATUS.up)
ALT = KEYBOARD_STATUS.idle;
if(CTRL == KEYBOARD_STATUS.pressing && !keyboard_check(vk_control))
CTRL = KEYBOARD_STATUS.up;
if(SHIFT == KEYBOARD_STATUS.pressing && !keyboard_check(vk_shift))
SHIFT = KEYBOARD_STATUS.up;
if(ALT == KEYBOARD_STATUS.pressing && !keyboard_check(vk_alt))
ALT = KEYBOARD_STATUS.up;
2022-12-22 03:09:55 +01:00
if(CTRL == KEYBOARD_STATUS.down)
CTRL = KEYBOARD_STATUS.pressing;
2023-02-14 02:51:14 +01:00
2022-12-22 03:09:55 +01:00
if(SHIFT == KEYBOARD_STATUS.down)
2023-02-14 02:51:14 +01:00
SHIFT = KEYBOARD_STATUS.pressing;
2022-12-22 03:09:55 +01:00
if(ALT == KEYBOARD_STATUS.down)
2023-02-14 02:51:14 +01:00
ALT = KEYBOARD_STATUS.pressing;
2022-12-22 03:09:55 +01:00
if(keyboard_check_pressed(vk_control))
2023-02-14 02:51:14 +01:00
CTRL = KEYBOARD_STATUS.down;
2022-12-22 03:09:55 +01:00
if(keyboard_check_pressed(vk_shift))
SHIFT = KEYBOARD_STATUS.down;
if(keyboard_check_pressed(vk_alt))
2023-02-14 02:51:14 +01:00
ALT = KEYBOARD_STATUS.down;
2022-12-22 03:09:55 +01:00
if(keyboard_check_released(vk_control))
2023-02-14 02:51:14 +01:00
CTRL = KEYBOARD_STATUS.up;
2022-12-22 03:09:55 +01:00
if(keyboard_check_released(vk_shift))
SHIFT = KEYBOARD_STATUS.up;
if(keyboard_check_released(vk_alt))
2023-02-14 02:51:14 +01:00
ALT = KEYBOARD_STATUS.up;
2022-12-23 04:45:52 +01:00
#endregion
#region mouse wrap
MOUSE_WRAPPING = max(0, MOUSE_WRAPPING - 1);
if(MOUSE_WRAP) {
2022-12-27 04:00:50 +01:00
var _pad = 2;
2023-01-25 06:49:00 +01:00
if(mouse_mx < _pad) {
window_mouse_set(window_get_width() - _pad, mouse_my);
2022-12-23 04:45:52 +01:00
MOUSE_WRAPPING = 2;
2023-01-25 06:49:00 +01:00
} else if(mouse_mx > window_get_width() - _pad) {
window_mouse_set(_pad, mouse_my);
2022-12-23 04:45:52 +01:00
MOUSE_WRAPPING = 2;
}
2023-01-25 06:49:00 +01:00
if(mouse_my < _pad) {
window_mouse_set(mouse_mx, window_get_height() - _pad);
2022-12-23 04:45:52 +01:00
MOUSE_WRAPPING = 2;
2023-01-25 06:49:00 +01:00
} else if(mouse_my > window_get_height() - _pad) {
window_mouse_set(mouse_mx, _pad);
2022-12-23 04:45:52 +01:00
MOUSE_WRAPPING = 2;
}
}
MOUSE_WRAP = false;
2023-07-14 20:34:35 +02:00
#endregion
2024-01-25 08:24:02 +01:00
#region depth
if(_use_depth != USE_DEPTH) {
_use_depth = USE_DEPTH;
surface_depth_disable(!USE_DEPTH);
}
USE_DEPTH = false;
#endregion
2023-07-25 20:12:40 +02:00
//if(global.cache_call) print($"CACHE called: {global.cache_call} | hit: {global.cache_hit} ({global.cache_hit / global.cache_call * 100}%)");