2022-01-13 05:24:03 +01:00
/// @description main directory, parameter
2023-03-13 10:45:56 +01:00
//print("===== Game Start Begin =====");
2023-03-07 14:29:47 +01:00
2022-01-13 05:24:03 +01:00
#region directory
2023-11-19 09:05:42 +01:00
globalvar DIRECTORY, APP_DIRECTORY, APP_LOCATION, PRESIST_PREF;
2023-03-07 14:29:47 +01:00
DIRECTORY = "";
2024-12-11 03:07:22 +01:00
PRESIST_PREF = { path: "" };
2023-03-07 14:29:47 +01:00
2023-12-13 11:09:06 +01:00
APP_DIRECTORY = env_user();
2024-09-13 08:25:00 +02:00
APP_DIRECTORY = string_replace_all(APP_DIRECTORY, "\\", "/");
2023-12-01 05:49:44 +01:00
show_debug_message($"App directory: {APP_DIRECTORY}");
2023-04-21 19:08:10 +02:00
2023-11-18 03:47:11 +01:00
directory_verify(APP_DIRECTORY);
2023-04-21 19:08:10 +02:00
var perstPath = APP_DIRECTORY + "persistPreference.json";
2023-12-08 03:50:09 +01:00
if(file_exists_empty(perstPath)) {
2023-12-11 09:59:58 +01:00
struct_override(PRESIST_PREF, json_load_struct(perstPath));
2024-12-11 03:07:22 +01:00
DIRECTORY = struct_has(PRESIST_PREF, "path")? PRESIST_PREF.path : "";
2023-04-21 19:08:10 +02:00
}
2023-12-05 13:49:18 +01:00
if(DIRECTORY != "") {
var _ch = string_char_last(DIRECTORY);
2024-09-10 04:16:50 +02:00
if(_ch != "\\" && _ch != "/") DIRECTORY += "/";
2023-12-05 13:49:18 +01:00
show_debug_message($"Env directory: {DIRECTORY}");
var dir_valid = DIRECTORY != "" && directory_exists(DIRECTORY);
var tmp = file_text_open_write(DIRECTORY + "val_check.txt");
2023-04-21 19:08:10 +02:00
2023-12-05 13:49:18 +01:00
if(tmp == -1) {
dir_valid = false;
show_message($"WARNING: Inaccessible main directory ({DIRECTORY}) this may be caused by non existing folder, or Pixel Composer has no permission to open the folder.");
} else {
file_text_close(tmp);
file_delete($"{DIRECTORY}val_check.txt");
}
if(!dir_valid) {
show_debug_message("Invalid directory revert back to default %APPDATA%");
DIRECTORY = APP_DIRECTORY;
}
} else
2023-12-01 05:49:44 +01:00
DIRECTORY = APP_DIRECTORY;
2023-04-21 19:08:10 +02:00
2024-09-10 04:16:50 +02:00
PREFERENCES_DIR = $"{DIRECTORY}Preferences/{PREF_VERSION}/";
2023-11-01 08:10:25 +01:00
directory_verify(DIRECTORY);
2024-09-27 06:17:37 +02:00
directory_verify($"{DIRECTORY}Cache");
2023-02-14 02:51:14 +01:00
2023-11-19 09:05:42 +01:00
APP_LOCATION = program_directory;
2024-09-13 09:43:09 +02:00
if(OS == os_macosx) APP_LOCATION = string_replace(APP_LOCATION, "/Contents/MacOS/", "/Contents/Resources/");
if(RUN_IDE) APP_LOCATION = "D:/Project/MakhamDev/LTS-PixelComposer/PixelComposer/datafiles/";
2024-09-10 06:36:30 +02:00
2023-12-01 05:49:44 +01:00
print($"===================== WORKING DIRECTORIES =====================\n\t{working_directory}\n\t{DIRECTORY}");
2024-09-13 08:25:00 +02:00
directory_verify($"{DIRECTORY}log");
2023-04-21 19:08:10 +02:00
#endregion
#region Set up
2024-12-07 10:35:29 +01:00
var t = get_timer();
2024-06-30 11:18:48 +02:00
PREF_LOAD(); log_message("SESSION", $"> init Preferences | complete in {get_timer() - t}"); t = get_timer();
2024-08-20 10:15:53 +02:00
if(!IS_CMD) { __initLocale(); log_message("SESSION", $"> init Locale | complete in {get_timer() - t}"); t = get_timer(); }
2024-08-19 06:16:12 +02:00
if(!IS_CMD) { __initHotKey(); log_message("SESSION", $"> init Hotkeys | complete in {get_timer() - t}"); t = get_timer(); }
__fnInit();
2023-03-22 08:29:29 +01:00
2022-01-25 04:05:30 +01:00
log_clear();
2022-01-13 05:24:03 +01:00
log_newline();
log_message("SESSION", "Begin");
log_message("DIRECTORY", DIRECTORY);
2023-02-14 02:51:14 +01:00
2023-10-14 08:00:35 +02:00
PREF_APPLY();
2024-02-15 14:23:26 +01:00
var t0 = get_timer();
var t = get_timer();
var _lua = PROGRAM_ARGUMENTS._lua;
2023-12-11 09:59:58 +01:00
2024-04-09 05:32:00 +02:00
__initKeys()
2024-02-12 10:25:23 +01:00
__initPatreon(); log_message("SESSION", $"> init Patreon | complete in {get_timer() - t}"); t = get_timer();
if(!IS_CMD) { __initTheme(); log_message("SESSION", $"> init Theme | complete in {get_timer() - t}"); t = get_timer(); }
if(!IS_CMD) { loadFonts(); log_message("SESSION", $"> init Font | complete in {get_timer() - t}"); t = get_timer(); }
2024-02-15 14:23:26 +01:00
if(!IS_CMD) { __initProject(); log_message("SESSION", $"> init Project | complete in {get_timer() - t}"); t = get_timer(); }
2024-02-12 10:25:23 +01:00
if(!IS_CMD) { __initAction(); log_message("SESSION", $"> init Action | complete in {get_timer() - t}"); t = get_timer(); }
__initSurfaceFormat(); log_message("SESSION", $"> init SurfaceFormat | complete in {get_timer() - t}"); t = get_timer();
if(!IS_CMD) { __initCollection(); log_message("SESSION", $"> init Collection | complete in {get_timer() - t}"); t = get_timer(); }
if(!IS_CMD) { __initAssets(); log_message("SESSION", $"> init Assets | complete in {get_timer() - t}"); t = get_timer(); }
if(!IS_CMD) { __initPresets(); log_message("SESSION", $"> init Presets | complete in {get_timer() - t}"); t = get_timer(); }
2024-02-15 14:23:26 +01:00
if(!IS_CMD) { __initFontFolder(); log_message("SESSION", $"> init FontFolder | complete in {get_timer() - t}"); t = get_timer(); }
if(_lua) { __initLua(); log_message("SESSION", $"> init Lua | complete in {get_timer() - t}"); t = get_timer(); }
2024-02-12 10:25:23 +01:00
if(!IS_CMD) { __initNodeData(); log_message("SESSION", $"> init NodeData | complete in {get_timer() - t}"); t = get_timer(); }
__initNodes(); log_message("SESSION", $"> init Nodes | complete in {get_timer() - t}"); t = get_timer();
if(!IS_CMD) { __initSteamUGC(); log_message("SESSION", $"> init SteamUGC | complete in {get_timer() - t}"); t = get_timer(); }
if(!IS_CMD) { __initAddon(); log_message("SESSION", $"> init Addon | complete in {get_timer() - t}"); t = get_timer(); }
if(!IS_CMD) { __initPalette(); log_message("SESSION", $"> init Palette | complete in {get_timer() - t}"); t = get_timer(); }
if(!IS_CMD) { __initGradient(); log_message("SESSION", $"> init Gradient | complete in {get_timer() - t}"); t = get_timer(); }
2024-03-02 10:08:44 +01:00
if(!IS_CMD) { __initPen(); log_message("SESSION", $"> init Pen | complete in {get_timer() - t}"); t = get_timer(); }
2023-12-11 09:59:58 +01:00
2024-02-12 10:25:23 +01:00
if(!IS_CMD) { loadAddon(); log_message("SESSION", $"> init Addons | complete in {get_timer() - t}"); t = get_timer(); }
2023-12-11 09:59:58 +01:00
2024-02-12 10:25:23 +01:00
if(!IS_CMD) { LOAD_SAMPLE(); log_message("SESSION", $"> init sample | complete in {get_timer() - t}"); t = get_timer(); }
if(!IS_CMD) { INIT_FOLDERS(); log_message("SESSION", $"> init folders | complete in {get_timer() - t}"); t = get_timer(); }
if(!IS_CMD) { RECENT_LOAD(); log_message("SESSION", $"> init recents | complete in {get_timer() - t}"); t = get_timer(); }
2023-12-11 09:59:58 +01:00
log_message("SESSION", $">> Initialization complete in {get_timer() - t0}");
2023-10-28 10:53:11 +02:00
2024-02-12 10:25:23 +01:00
if(!IS_CMD) {
__initPanel();
2024-04-08 07:13:46 +02:00
2024-02-12 10:25:23 +01:00
if(file_exists_empty("icon.png"))
file_copy("icon.png", DIRECTORY + "icon.png");
2024-11-14 07:31:57 +01:00
var _prg_path = $"{program_directory}PixelComposer.exe";
2024-09-13 08:25:00 +02:00
// var cmd = ".pxc=\"" + string(program_directory) + "PixelComposer.exe\"";
// shell_execute_async("assoc", cmd);
2023-04-09 21:24:16 +02:00
2024-09-13 08:25:00 +02:00
// var cmd = ".pxcc=\"" + string(program_directory) + "PixelComposer.exe\"";
// shell_execute_async("assoc", cmd);
2024-11-14 07:31:57 +01:00
// shell_execute_async("reg", "ADD HKCU\\Software\\Classes\\pxc");
// shell_execute_async("reg", "ADD HKCU\\Software\\Classes\\pxc /v \"URL Protocol\" /t REG_SZ");
// shell_execute_async("reg", "ADD HKCU\\Software\\Classes\\pxc\\shell");
// shell_execute_async("reg", "ADD HKCU\\Software\\Classes\\pxc\\shell\\open");
// shell_execute_async("reg", $"DELETE HKCU\\Software\\Classes\\pxc\\shell\\open\\command");
// shell_execute_async("reg", $"ADD HKCU\\Software\\Classes\\pxc\\shell\\open\\command /t REG_SZ /d \"{_prg_path} -m %1\"");
2024-02-12 10:25:23 +01:00
}
2023-05-07 20:55:13 +02:00
2023-11-18 11:49:25 +01:00
directory_set_current_working(DIRECTORY);
2022-01-13 05:24:03 +01:00
#endregion
2023-02-14 02:51:14 +01:00
#region lua
2024-09-19 04:35:25 +02:00
lua_error_handler = _lua_error;
2023-03-07 14:29:47 +01:00
#endregion
2023-03-13 10:45:56 +01:00
//print("===== Game Start End =====");