Pixel-Composer/objects/o_main/Create_0.gml

373 lines
8.8 KiB
Plaintext
Raw Normal View History

2022-01-13 05:24:03 +01:00
/// @description init
#region log
var path = "log_temp.txt";
2024-05-19 07:55:09 +02:00
var file = file_text_open_append(path);
file_text_write_string(file, $"[MESSAGE] {_log_template()}session begin\n");
file_text_close(file);
2023-01-25 06:49:00 +01:00
gpu_set_tex_mip_enable(mip_off);
2023-02-14 02:51:14 +01:00
gc_enable(true);
gc_target_frame_time(100);
2022-01-13 05:24:03 +01:00
#endregion
#region window & IO
window_set_min_width(960);
window_set_min_height(600);
2024-02-06 13:53:08 +01:00
draw_set_circle_precision(64);
2023-12-18 04:40:21 +01:00
winManInit();
2023-02-21 07:38:25 +01:00
2024-02-06 13:53:08 +01:00
depth = 0;
win_wp = WIN_W;
win_hp = WIN_H;
win_resize = false;
2023-10-20 12:32:43 +02:00
room_width = WIN_W;
2022-01-13 05:24:03 +01:00
room_height = WIN_H;
DIALOG_DEPTH_HOVER = 0;
2024-02-06 13:53:08 +01:00
UPDATE = RENDER_TYPE.none;
CURSOR = cr_default;
2024-03-24 04:58:08 +01:00
CURSOR_LOCK = false;
2024-03-26 04:03:45 +01:00
CURSOR_IS_LOCK = false;
2024-03-24 04:58:08 +01:00
CURSOR_LOCK_X = 0;
CURSOR_LOCK_Y = 0;
2024-02-06 13:53:08 +01:00
TOOLTIP = "";
DRAGGING = noone;
KEYBOARD_STRING = "";
2023-10-02 10:45:30 +02:00
2023-06-01 10:32:21 +02:00
RENDER_QUEUE = new Queue();
2023-10-02 10:45:30 +02:00
RENDER_ORDER = [];
2022-01-13 05:24:03 +01:00
2023-04-09 21:24:16 +02:00
globalvar AUTO_SAVE_TIMER;
AUTO_SAVE_TIMER = 0;
2024-02-06 13:53:08 +01:00
_cursor = CURSOR;
2022-01-13 05:24:03 +01:00
dc_check = 0;
2022-12-12 09:08:03 +01:00
kb_time = 0;
kb_hold = false;
kb_hkey = 0;
2022-01-13 05:24:03 +01:00
kd_ctrl = 0;
kd_shift = 0;
kd_alt = 0;
2024-03-29 05:20:49 +01:00
fpss = array_create(10);
fpsr = 0;
2024-03-24 04:58:08 +01:00
_cursor_lock = false;
2024-02-25 11:02:10 +01:00
watcher_surface = surface_create(1, 1);
2023-03-11 01:40:17 +01:00
panelInit();
2024-02-06 13:53:08 +01:00
addHotkey("", "New file", "N", MOD_KEY.ctrl, NEW);
2023-02-14 02:51:14 +01:00
if(!DEMO) {
2024-02-06 13:53:08 +01:00
addHotkey("", "Save", "S", MOD_KEY.ctrl, SAVE);
addHotkey("", "Save as", "S", MOD_KEY.ctrl | MOD_KEY.shift, SAVE_AS);
addHotkey("", "Save all", "S", MOD_KEY.ctrl | MOD_KEY.alt, SAVE_ALL);
addHotkey("", "Open", "O", MOD_KEY.ctrl, LOAD);
2023-02-14 02:51:14 +01:00
}
2022-01-13 05:24:03 +01:00
2024-02-06 13:53:08 +01:00
addHotkey("", "Undo", "Z", MOD_KEY.ctrl, UNDO);
addHotkey("", "Redo", "Z", MOD_KEY.ctrl | MOD_KEY.shift, REDO);
2022-11-14 03:16:15 +01:00
2024-02-06 13:53:08 +01:00
addHotkey("", "Full panel", "`", MOD_KEY.none, set_focus_fullscreen);
addHotkey("", "Reset layout", vk_f10, MOD_KEY.ctrl, resetPanel);
2023-02-23 07:02:19 +01:00
2024-02-06 13:53:08 +01:00
addHotkey("", "Open notification", vk_f12, MOD_KEY.none, function() { dialogPanelCall(new Panel_Notification()); });
2022-01-13 05:24:03 +01:00
2024-02-06 13:53:08 +01:00
addHotkey("", "Fullscreen", vk_f11, MOD_KEY.none, global_fullscreen);
addHotkey("", "Render all", vk_f5, MOD_KEY.none, global_render_all);
2023-07-06 19:49:16 +02:00
2024-02-06 13:53:08 +01:00
addHotkey("", "Close file", "Q", MOD_KEY.ctrl, global_project_close);
addHotkey("", "Close program", vk_f4, MOD_KEY.alt, window_close);
addHotkey("", "Reload theme", vk_f10, MOD_KEY.ctrl | MOD_KEY.shift, global_theme_reload);
2023-05-08 19:14:30 +02:00
globalvar HOTKEY_MOD, HOTKEY_BLOCK;
2024-02-06 13:53:08 +01:00
HOTKEY_MOD = 0;
2023-05-08 19:14:30 +02:00
HOTKEY_BLOCK = false;
2024-05-19 07:55:09 +02:00
2022-01-13 05:24:03 +01:00
#endregion
2023-04-23 16:47:33 +02:00
#region Loader
2023-05-03 21:42:17 +02:00
globalvar GIF_READER;
2023-04-23 16:47:33 +02:00
2022-01-13 05:24:03 +01:00
GIF_READER = ds_list_create();
gif_complete_st = ds_stack_create();
#endregion
2023-01-25 06:49:00 +01:00
#region tunnel
globalvar TUNNELS_IN, TUNNELS_IN_MAP, TUNNELS_OUT;
2023-04-09 21:24:16 +02:00
TUNNELS_IN = ds_map_create();
2023-01-25 06:49:00 +01:00
TUNNELS_IN_MAP = ds_map_create();
2023-04-09 21:24:16 +02:00
TUNNELS_OUT = ds_map_create();
2023-01-25 06:49:00 +01:00
#endregion
2023-04-23 16:47:33 +02:00
#region add on callback
globalvar ANIMATION_PRE, ANIMATION_POST;
ANIMATION_PRE = [];
ANIMATION_POST = [];
function __addon_preAnim() {
2023-07-25 20:12:40 +02:00
for( var i = 0, n = array_length(ANIMATION_PRE); i < n; i++ )
2023-04-23 16:47:33 +02:00
ANIMATION_PRE[i]();
}
function __addon_postAnim() {
2023-07-25 20:12:40 +02:00
for( var i = 0, n = array_length(ANIMATION_POST); i < n; i++ )
2023-04-23 16:47:33 +02:00
ANIMATION_POST[i]();
}
#endregion
2022-01-13 05:24:03 +01:00
#region file drop
2023-03-08 12:14:01 +01:00
if(OS == os_windows) {
file_dropper_init();
} else if(OS == os_macosx) {
file_dnd_set_hwnd(window_handle());
file_dnd_set_enabled(true);
_file_dnd_filelist = "";
file_dnd_filelist = "";
file_dnd_pattern = "*.*";
file_dnd_allowfiles = true;
file_dnd_allowdirs = true;
file_dnd_allowmulti = true;
}
2024-07-01 06:23:46 +02:00
globalvar FILE_IS_DROPPING, FILE_DROPPING_X, FILE_DROPPING_Y, FILE_DROPPING, FILE_DROPPED;
2022-01-13 05:24:03 +01:00
2024-07-01 06:23:46 +02:00
FILE_IS_DROPPING = false;
FILE_DROPPING_X = 0;
FILE_DROPPING_Y = 0;
FILE_DROPPING = [];
FILE_DROPPED = false;
2022-01-13 05:24:03 +01:00
#endregion
#region undo
action_last_frame = [];
#endregion
#region version
version_check = -1;
version_latest = 0;
2024-04-01 13:32:13 +02:00
2023-04-09 21:24:16 +02:00
//if(os_is_network_connected()) {
// var version = "https://gist.githubusercontent.com/Ttanasart-pt/d9eefbda84a78863c122b8b155bc0cda/raw/version.txt";
// version_check = http_get(version);
//}
2022-01-13 05:24:03 +01:00
#endregion
#region parameter
2023-03-28 06:58:28 +02:00
minimized = false;
2022-09-27 06:37:28 +02:00
_modified = false;
2022-11-18 03:20:31 +01:00
#endregion
#region dialog
2023-07-12 16:28:32 +02:00
globalvar DIALOGS, WIDGET_TAB_BLOCK;
2022-11-18 03:20:31 +01:00
DIALOGS = ds_list_create();
2023-07-12 16:28:32 +02:00
WIDGET_TAB_BLOCK = false;
2023-11-06 12:08:59 +01:00
2023-11-08 08:38:04 +01:00
instance_create(0, 0, o_dialog_textbox_autocomplete);
instance_create(0, 0, o_dialog_textbox_function_guide);
2023-01-25 06:49:00 +01:00
#endregion
2023-06-04 12:38:40 +02:00
#region async
globalvar PORT_MAP, NETWORK_SERVERS, NETWORK_CLIENTS;
2023-08-04 13:12:32 +02:00
globalvar IMAGE_FETCH_MAP;
2023-06-04 12:38:40 +02:00
2023-01-25 06:49:00 +01:00
global.FILE_LOAD_ASYNC = ds_map_create();
2023-06-04 12:38:40 +02:00
PORT_MAP = ds_map_create();
NETWORK_SERVERS = ds_map_create();
NETWORK_CLIENTS = ds_map_create();
2023-08-04 13:12:32 +02:00
IMAGE_FETCH_MAP = ds_map_create();
2023-06-04 12:38:40 +02:00
asyncInit();
2023-11-22 05:17:13 +01:00
network_set_config(network_config_use_non_blocking_socket, 0);
2023-02-14 02:51:14 +01:00
#endregion
#region steam
globalvar STEAM_ENABLED, STEAM_APP_ID, STEAM_USER_ID, STEAM_USERNAME, STEAM_AVATAR;
2023-02-14 02:51:14 +01:00
globalvar STEAM_UGC_ITEM_UPLOADING, STEAM_UGC_ITEM_ID, STEAM_UGC_ITEM_FILE, STEAM_UGC_UPDATE_HANDLE;
globalvar STEAM_UGC_ITEM_AVATAR;
2023-02-15 10:04:49 +01:00
globalvar STEAM_UGC_SUBMIT_ID, STEAM_UGC_UPDATE_MAP, STEAM_UGC_PUBLISH_ID, STEAM_UGC_UPDATE, STEAM_UGC_TYPE;
2023-02-17 11:31:33 +01:00
globalvar STEAM_SUB_ID;
2023-02-15 10:04:49 +01:00
enum STEAM_UGC_FILE_TYPE {
collection,
project,
node_preset
}
2023-02-14 02:51:14 +01:00
2023-02-15 10:04:49 +01:00
STEAM_UGC_TYPE = STEAM_UGC_FILE_TYPE.collection;
2023-02-17 11:31:33 +01:00
STEAM_SUB_ID = 0;
STEAM_USER_ID = 0;
2023-02-14 02:51:14 +01:00
STEAM_USERNAME = "";
STEAM_AVATAR = 0;
steam_avatar_id = "";
2023-02-14 02:51:14 +01:00
STEAM_UGC_UPDATE_HANDLE = 0;
STEAM_UGC_ITEM_ID = 0;
STEAM_UGC_PUBLISH_ID = 0;
STEAM_UGC_SUBMIT_ID = 0;
STEAM_UGC_ITEM_UPLOADING = false;
STEAM_ENABLED = steam_initialised();
STEAM_UGC_UPDATE = false;
STEAM_UGC_UPDATE_MAP = ds_map_create();
STEAM_UGC_ITEM_AVATAR = true;
2023-02-14 02:51:14 +01:00
if(STEAM_ENABLED) {
STEAM_APP_ID = steam_get_app_id();
STEAM_USER_ID = steam_get_user_account_id();
STEAM_USERNAME = steam_get_persona_name();
steam_avatar_id = steam_get_user_avatar(steam_get_user_steam_id(), steam_user_avatar_size_large);
2023-02-14 02:51:14 +01:00
steam_set_warning_message_hook();
}
2023-03-26 07:13:36 +02:00
#endregion
2023-06-17 14:30:49 +02:00
#region physics
2023-04-10 20:02:59 +02:00
physics_world_update_iterations(100);
2023-05-08 19:14:30 +02:00
#endregion
2023-06-17 14:30:49 +02:00
2023-07-23 20:21:35 +02:00
#region color selector
globalvar NODE_DROPPER_TARGET, NODE_DROPPER_TARGET_CAN, NODE_COLOR_SHOW_PALETTE;
NODE_DROPPER_TARGET = noone;
2023-06-17 14:30:49 +02:00
NODE_DROPPER_TARGET_CAN = false;
2023-07-23 20:21:35 +02:00
NODE_COLOR_SHOW_PALETTE = false;
2023-07-30 13:56:22 +02:00
#endregion
2023-11-22 10:21:50 +01:00
#region draw
#endregion
#region 3D
2024-01-25 08:24:02 +01:00
globalvar USE_DEPTH;
_use_depth = noone;
USE_DEPTH = false;
set3DGlobalPreview();
#endregion
2023-07-30 13:56:22 +02:00
#region debug
global.__debug_runner = 0;
2023-11-26 13:16:38 +01:00
__debug_animator_counter = 0;
2023-12-24 12:06:44 +01:00
2023-12-29 14:30:54 +01:00
//instance_create(0, 0, o_video_banner, { title: "Trail effect" });
//instance_create_depth(0, 0, -32000, FLIP_Domain);
//instance_create_depth(0, 0, -32000, FLIP_Domain);
2024-02-11 13:22:20 +01:00
#endregion
2024-02-15 14:23:26 +01:00
#region server
globalvar TCP_SERVER, TCP_PORT, TCP_CLIENTS;
TCP_SERVER = false;
TCP_PORT = noone;
TCP_CLIENTS = [];
#endregion
2024-02-11 13:22:20 +01:00
#region arguments
2024-02-12 10:25:23 +01:00
#macro IS_CMD PROGRAM_ARGUMENTS._cmd
2024-02-11 13:22:20 +01:00
alarm[1] = 2;
2024-02-15 14:23:26 +01:00
globalvar PROGRAM_ARGUMENTS, CLI_EXPORT_AMOUNT;
2024-02-11 14:53:33 +01:00
PROGRAM_ARGUMENTS = {
2024-02-15 14:23:26 +01:00
_path : "",
2024-02-12 13:59:43 +01:00
_cmd : false,
_run : false,
2024-02-15 14:23:26 +01:00
_rendering : false,
2024-02-12 13:59:43 +01:00
_exporting : [],
_persist : false,
2024-02-15 14:23:26 +01:00
_trusted: false,
_lua: true,
2024-02-11 14:53:33 +01:00
};
2024-02-15 14:23:26 +01:00
CLI_EXPORT_AMOUNT = 0;
2024-02-11 13:22:20 +01:00
var paramCount = parameter_count();
2024-02-12 10:25:23 +01:00
var paramType = "_path";
2024-02-15 14:23:26 +01:00
var useTCP = false;
2024-02-11 13:22:20 +01:00
for( var i = 0; i < paramCount; i++ ) {
var param = parameter_string(i);
2024-02-12 13:59:43 +01:00
//print($" >>> params {i}: {param}");
2024-02-11 13:22:20 +01:00
2024-02-15 14:23:26 +01:00
if(string_starts_with(param, "-")) {
2024-02-11 13:22:20 +01:00
switch(param) {
2024-02-15 14:23:26 +01:00
case "-c" :
2024-02-11 13:22:20 +01:00
case "--crashed" :
if(PREFERENCES.show_crash_dialog)
run_in(1, function() { dialogCall(o_dialog_crashed); });
break;
2024-02-15 14:23:26 +01:00
case "-h" :
case "--headless" :
2024-02-12 10:25:23 +01:00
PROGRAM_ARGUMENTS._cmd = true;
break;
2024-02-15 14:23:26 +01:00
case "-p" :
case "--persist" :
PROGRAM_ARGUMENTS._persist = true;
break;
case "-t" :
case "--trusted" :
PROGRAM_ARGUMENTS._trusted = true;
break;
case "-s" :
case "--server" :
PROGRAM_ARGUMENTS._persist = true;
useTCP = true;
break;
case "-sl" :
case "--skiplua" :
PROGRAM_ARGUMENTS._lua = false;
break;
default :
paramType = string_trim(param, ["-"]);
break;
2024-02-11 13:22:20 +01:00
}
2024-02-12 10:25:23 +01:00
} else if(paramType == "_path") {
2024-02-11 13:22:20 +01:00
var path = param;
path = string_replace_all(path, "\n", "");
path = string_replace_all(path, "\"", "");
2024-02-15 14:23:26 +01:00
2024-06-03 09:34:59 +02:00
if(path_is_project(path))
2024-02-12 10:25:23 +01:00
PROGRAM_ARGUMENTS._path = path;
2024-02-11 13:22:20 +01:00
2024-02-15 14:23:26 +01:00
} else
PROGRAM_ARGUMENTS[$ paramType] = cmd_path(param);
2024-02-11 13:22:20 +01:00
}
2024-02-15 14:23:26 +01:00
if(IS_CMD) {
draw_enable_drawevent(false);
log_console($"Running PixelComposer {VERSION_STRING}");
2024-02-11 13:22:20 +01:00
2024-02-15 14:23:26 +01:00
PROGRAM_ARGUMENTS._run = true;
PROGRAM_ARGUMENTS._rendering = true;
2024-02-11 13:22:20 +01:00
}
2024-02-11 14:53:33 +01:00
2024-02-15 14:23:26 +01:00
if(file_exists_empty(PROGRAM_ARGUMENTS._path)) {
run_in(1, function() { load_file_path(PROGRAM_ARGUMENTS._path); });
} else if(IS_CMD)
game_end();
if(useTCP && struct_has(PROGRAM_ARGUMENTS, "port")) {
TCP_PORT = PROGRAM_ARGUMENTS.port;
TCP_SERVER = network_create_server_raw(network_socket_tcp, TCP_PORT, 32);
log_console($"Open port: {TCP_PORT}");
}
2023-06-17 14:30:49 +02:00
#endregion