Pixel-Composer/objects/o_main/Create_0.gml

310 lines
7.8 KiB
Text
Raw Normal View History

2022-01-13 05:24:03 +01:00
/// @description init
#region log
var path = "log_temp.txt";
var f = file_text_open_append(path);
var t = _log_template();
2022-01-13 05:24:03 +01:00
file_text_write_string(f, "[MESSAGE] " + t + "session begin" + "\n");
file_text_close(f);
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
2023-03-08 12:14:01 +01:00
if(OS == os_windows) {
gameframe_init();
gameframe_set_cursor = false;
2023-03-24 09:32:08 +01:00
gameframe_caption_height_normal = ui(40);
gameframe_caption_height_maximized = ui(40);
2023-03-29 15:02:03 +02:00
gameframe_button_array = [
game_frame_button_create("", s_kenney, 0, function() {}),
2023-03-08 12:14:01 +01:00
game_frame_button_create("", s_kenney, 0, function() {}),
];
2023-03-11 01:40:17 +01:00
} else if(OS == os_macosx)
2023-03-08 12:14:01 +01:00
mac_window_init();
2023-02-21 07:38:25 +01:00
2022-01-13 05:24:03 +01:00
depth = 0;
win_wp = WIN_W;
win_hp = WIN_H;
2023-03-11 06:40:34 +01:00
win_resize = false;
room_width = WIN_W;
2022-01-13 05:24:03 +01:00
room_height = WIN_H;
draw_set_circle_precision(64);
DIALOG_DEPTH_HOVER = 0;
2023-03-25 12:27:04 +01:00
UPDATE = RENDER_TYPE.none;
CURSOR = cr_default;
TOOLTIP = "";
DRAGGING = noone;
2022-12-12 09:08:03 +01:00
KEYBOARD_STRING = "";
2023-06-01 10:32:21 +02:00
RENDER_QUEUE = new Queue();
2022-01-13 05:24:03 +01:00
2023-04-09 21:24:16 +02:00
globalvar AUTO_SAVE_TIMER;
AUTO_SAVE_TIMER = 0;
2022-01-13 05:24:03 +01:00
_cursor = CURSOR;
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
2023-03-11 01:40:17 +01:00
panelInit();
2023-01-25 06:49:00 +01:00
//show_debug_overlay(true);
2022-11-18 03:20:31 +01:00
//display_set_timing_method(tm_sleep);
2022-11-03 11:44:49 +01:00
2022-01-13 05:24:03 +01:00
addHotkey("", "New file", "N", MOD_KEY.ctrl, NEW);
2023-02-14 02:51:14 +01:00
if(!DEMO) {
2023-02-28 09:43:01 +01:00
addHotkey("", "Save", "S", MOD_KEY.ctrl, SAVE );
addHotkey("", "Save as", "S", MOD_KEY.ctrl | MOD_KEY.shift, SAVE_AS );
2023-07-06 19:49:16 +02:00
addHotkey("", "Save all", "S", MOD_KEY.ctrl | MOD_KEY.alt, SAVE_ALL );
2023-02-14 02:51:14 +01:00
addHotkey("", "Open", "O", MOD_KEY.ctrl, function() { LOAD(); });
}
2022-01-13 05:24:03 +01:00
addHotkey("", "Undo", "Z", MOD_KEY.ctrl, function() { UNDO(); });
addHotkey("", "Redo", "Z", MOD_KEY.ctrl | MOD_KEY.shift, function() { REDO(); });
2023-02-14 02:51:14 +01:00
addHotkey("", "Full panel", "`", MOD_KEY.none, set_focus_fullscreen);
2023-03-12 02:28:21 +01:00
addHotkey("", "Open notification", vk_f12, MOD_KEY.none, function() { dialogPanelCall(new Panel_Notification()); });
2022-11-14 03:16:15 +01:00
2023-02-23 07:02:19 +01:00
addHotkey("", "Fullscreen", vk_f11, MOD_KEY.none, function() {
if(gameframe_is_fullscreen_window())
gameframe_set_fullscreen(0);
else
gameframe_set_fullscreen(2);
});
2022-01-13 05:24:03 +01:00
addHotkey("", "Render all", vk_f5, MOD_KEY.none, function() {
UPDATE |= RENDER_TYPE.full;
2022-01-13 05:24:03 +01:00
});
2023-07-06 19:49:16 +02:00
addHotkey("", "Close file", "Q", MOD_KEY.ctrl, function() { PANEL_GRAPH.close(); });
addHotkey("", "Close program", vk_f4, MOD_KEY.alt, window_close);
2023-05-08 19:14:30 +02:00
globalvar HOTKEY_MOD, HOTKEY_BLOCK;
2022-01-13 05:24:03 +01:00
HOTKEY_MOD = 0;
2023-05-08 19:14:30 +02:00
HOTKEY_BLOCK = false;
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;
}
2022-12-16 09:18:09 +01:00
drop_path = [];
2022-01-13 05:24:03 +01:00
2022-12-16 09:18:09 +01:00
function load_file_path(path) {
2023-02-14 02:51:14 +01:00
if(!is_array(path)) path = [ path ];
2022-12-16 09:18:09 +01:00
if(array_length(path) == 0) return;
2023-02-14 02:51:14 +01:00
2023-03-19 09:17:39 +01:00
var type = "others";
if(array_length(path) == 1 && directory_exists(path[0]))
type = "image";
2023-07-25 20:12:40 +02:00
for( var i = 0, n = array_length(path); i < n; i++ ) {
2023-01-25 06:49:00 +01:00
var p = path[i];
2023-02-14 02:51:14 +01:00
var ext = string_lower(filename_ext(p));
2022-01-13 05:24:03 +01:00
switch(ext) {
case ".png" :
case ".jpg" :
case ".jpeg" :
2023-03-19 09:17:39 +01:00
type = "image";
2022-01-13 05:24:03 +01:00
break;
}
2023-01-25 06:49:00 +01:00
}
var is_multi = type == "image" && (array_length(path) > 1 || directory_exists(path[0]));
if(is_multi) {
with(dialogCall(o_dialog_add_multiple_images, WIN_W / 2, WIN_H / 2))
setPath(path);
} else {
PANEL_GRAPH.onStepBegin();
var node = noone;
2023-07-25 20:12:40 +02:00
for( var i = 0, n = array_length(path); i < n; i++ ) {
2023-01-25 06:49:00 +01:00
var p = path[i];
2023-02-14 02:51:14 +01:00
var ext = string_lower(filename_ext(p));
2023-01-25 06:49:00 +01:00
switch(ext) {
case ".txt" :
node = Node_create_Text_File_Read_path(PANEL_GRAPH.mouse_grid_x, PANEL_GRAPH.mouse_grid_y, p);
break;
case ".csv" :
node = Node_create_CSV_File_Read_path(PANEL_GRAPH.mouse_grid_x, PANEL_GRAPH.mouse_grid_y, p);
break;
case ".json" :
node = Node_create_Json_File_Read_path(PANEL_GRAPH.mouse_grid_x, PANEL_GRAPH.mouse_grid_y, p);
break;
case ".ase" :
case ".aseprite" :
node = Node_create_ASE_File_Read_path(PANEL_GRAPH.mouse_grid_x, PANEL_GRAPH.mouse_grid_y, p);
break;
case ".png" :
case ".jpg" :
case ".jpeg" :
node = Node_create_Image_path(PANEL_GRAPH.mouse_grid_x, PANEL_GRAPH.mouse_grid_y, p);
break;
2023-03-24 09:32:08 +01:00
case ".gif" :
2023-01-25 06:49:00 +01:00
node = Node_create_Image_gif_path(PANEL_GRAPH.mouse_grid_x, PANEL_GRAPH.mouse_grid_y, p);
break;
case ".obj" :
node = Node_create_3D_Obj_path(PANEL_GRAPH.mouse_grid_x, PANEL_GRAPH.mouse_grid_y, p);
break;
2023-05-16 21:28:16 +02:00
case ".wav" :
node = Node_create_WAV_File_Read_path(PANEL_GRAPH.mouse_grid_x, PANEL_GRAPH.mouse_grid_y, p);
break;
2023-01-25 06:49:00 +01:00
case ".pxc" :
LOAD_PATH(p);
break;
2023-03-24 09:32:08 +01:00
case ".pxcc" :
APPEND(p);
break;
2023-01-25 06:49:00 +01:00
}
PANEL_GRAPH.mouse_grid_y += 160;
}
2022-12-16 09:18:09 +01:00
if(node)
PANEL_GRAPH.toCenterNode();
2022-01-13 05:24:03 +01:00
}
}
#endregion
#region undo
action_last_frame = [];
#endregion
#region version
version_check = -1;
version_latest = 0;
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
file_open_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-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-02-14 02:51:14 +01:00
#endregion
#region steam
globalvar STEAM_ENABLED, STEAM_APP_ID, STEAM_USER_ID, STEAM_USERNAME;
globalvar STEAM_UGC_ITEM_UPLOADING, STEAM_UGC_ITEM_ID, STEAM_UGC_ITEM_FILE, STEAM_UGC_UPDATE_HANDLE;
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_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();
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_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
#region 3D
set3DGlobalPreview();
#endregion
2023-07-30 13:56:22 +02:00
#region debug
2023-07-31 20:06:44 +02:00
//instance_create_depth(0, 0, 0, addon_key_displayer);
2023-06-17 14:30:49 +02:00
#endregion