Pixel-Composer/objects/o_main/Other_2.gml

125 lines
3.9 KiB
Plaintext
Raw Normal View History

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-04-21 19:08:10 +02:00
globalvar DIRECTORY, APP_DIRECTORY, PRESIST_PREF;
2023-03-07 14:29:47 +01:00
DIRECTORY = "";
2023-04-21 19:08:10 +02:00
PRESIST_PREF = {};
2023-03-07 14:29:47 +01:00
2023-04-21 19:08:10 +02:00
if(OS == os_windows) {
APP_DIRECTORY = environment_get_variable("userprofile") + "\\AppData\\Local\\PixelComposer\\";
} else if(OS == os_macosx) {
2023-03-22 08:29:29 +01:00
var home_dir = environment_get_variable("HOME");
if(string(home_dir) == "0")
log_message("DIRECTORY", "Directory not found.");
else
2023-04-21 19:08:10 +02:00
APP_DIRECTORY = string(home_dir) + "/PixelComposer/";
2023-03-22 08:29:29 +01:00
}
2023-04-21 19:08:10 +02:00
show_debug_message("App directory: " + string(APP_DIRECTORY));
if(!directory_exists(APP_DIRECTORY)) directory_create(APP_DIRECTORY);
var perstPath = APP_DIRECTORY + "persistPreference.json";
if(file_exists(perstPath)) {
PRESIST_PREF = json_load_struct(perstPath);
DIRECTORY = struct_has(PRESIST_PREF, "path")? PRESIST_PREF.path : "";
}
show_debug_message("Env directory: " + string(DIRECTORY));
var dir_valid = DIRECTORY != "" && directory_exists(DIRECTORY);
var tmp = file_text_open_write(DIRECTORY + "val_check.txt");
if(tmp == -1) {
dir_valid = false;
print("WARNING: Inaccessible 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) DIRECTORY = APP_DIRECTORY;
PRESIST_PREF.path = DIRECTORY;
json_save_struct(perstPath, PRESIST_PREF);
2023-11-01 08:10:25 +01:00
directory_verify(DIRECTORY);
2023-11-05 04:19:19 +01:00
directory_set_current_working(DIRECTORY);
2023-02-14 02:51:14 +01:00
METADATA = __getdefaultMetaData();
2023-04-21 19:08:10 +02:00
#endregion
#region Set up
2023-05-07 20:55:13 +02:00
var t = current_time;
2023-03-22 08:29:29 +01:00
PREF_LOAD();
2023-06-17 14:30:49 +02:00
var dir = string(DIRECTORY) + "log";
if(!directory_exists(dir))
directory_create(dir);
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();
2023-10-24 02:09:04 +02:00
log_message("SESSION", "> init Theme"); __initTheme();
log_message("SESSION", "> init Locale"); __initLocale();
2023-10-14 08:00:35 +02:00
log_message("SESSION", "> init Font"); loadFonts();
log_message("SESSION", "> init Project"); __initProject();
2023-08-02 19:11:57 +02:00
log_message("SESSION", "> init Action"); __initAction();
2023-05-07 20:55:13 +02:00
log_message("SESSION", "> init SurfaceFormat"); __initSurfaceFormat();
log_message("SESSION", "> init Collection"); __initCollection();
log_message("SESSION", "> init Assets"); __initAssets();
log_message("SESSION", "> init Presets"); __initPresets();
log_message("SESSION", "> init FontFolder"); __initFontFolder();
log_message("SESSION", "> init Lua"); __initLua();
log_message("SESSION", "> init NodeData"); __initNodeData();
log_message("SESSION", "> init Nodes"); __initNodes();
log_message("SESSION", "> init SteamUGC"); __initSteamUGC();
log_message("SESSION", "> init Addon"); __initAddon();
log_message("SESSION", "> init Palette"); __initPalette();
log_message("SESSION", "> init Gradient"); __initGradient();
2022-11-22 14:25:39 +01:00
2023-10-28 10:53:11 +02:00
log_message("SESSION", "> init Ins Renderer"); __initInstanceRenderer();
2022-11-22 14:25:39 +01:00
setPanel();
2023-05-07 20:55:13 +02:00
loadAddon();
2023-02-14 02:51:14 +01:00
if(file_exists("icon.png"))
file_copy("icon.png", DIRECTORY + "icon.png");
environment_set_variable("IMGUI_DIALOG_WIDTH", string(800));
2023-02-14 07:37:13 +01:00
var cmd = ".pxc=\"" + string(program_directory) + "PixelComposer.exe\"";
shell_execute_async("assoc", cmd);
2023-04-09 21:24:16 +02:00
2023-02-14 07:37:13 +01:00
var cmd = ".pxcc=\"" + string(program_directory) + "PixelComposer.exe\"";
shell_execute_async("assoc", cmd);
2023-05-07 20:55:13 +02:00
2023-05-24 15:02:17 +02:00
//print($"Setup time: {(current_time - t)/1000}s");
2022-01-13 05:24:03 +01:00
#endregion
#region parameter
alarm[1] = 2;
2023-02-14 02:51:14 +01:00
2022-01-13 05:24:03 +01:00
if(parameter_count() > 1) {
var path = parameter_string(1);
2023-02-14 02:51:14 +01:00
if(path == "--crashed") {
2023-11-05 04:19:19 +01:00
if(PREFERENCES.show_crash_dialog) dialogCall(o_dialog_crashed);
2023-02-14 02:51:14 +01:00
} else {
path = string_replace_all(path, "\n", "");
path = string_replace_all(path, "\"", "");
2022-11-21 06:38:44 +01:00
2023-02-14 02:51:14 +01:00
if(file_exists(path) && filename_ext(path) == ".pxc") {
file_open_parameter = path;
alarm[2] = 3;
}
2022-01-13 05:24:03 +01:00
}
}
2023-02-14 02:51:14 +01:00
#endregion
#region lua
//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 =====");