2023-10-31 05:30:42 +01:00
#region preference
2023-11-18 07:49:50 +01:00
globalvar PREFERENCES, PREFERENCES_DEF, HOTKEYS_DATA;
PREFERENCES = {};
HOTKEYS_DATA = {};
2023-10-31 05:30:42 +01:00
2024-04-04 13:56:19 +02:00
#region ////////////////////////////////////////////////////////////////////// GENERAL UI //////////////////////////////////////////////////////////////////////
2023-10-31 05:30:42 +01:00
2024-04-04 13:56:19 +02:00
PREFERENCES.display_scaling = 1;
PREFERENCES.window_width = 1600;
PREFERENCES.window_height = 800;
PREFERENCES.window_maximize = false;
2024-05-07 08:09:38 +02:00
PREFERENCES.window_monitor = "";
2024-04-04 13:56:19 +02:00
PREFERENCES.theme = "default";
PREFERENCES.local = "en";
PREFERENCES.font_overwrite = "";
PREFERENCES.ui_framerate = 120;
PREFERENCES.path_resolution = 32;
PREFERENCES.move_directory = false;
PREFERENCES.notification_time = 180;
PREFERENCES.notify_load_version = true;
PREFERENCES.show_crash_dialog = false;
PREFERENCES.test_mode = false;
PREFERENCES.auto_save_time = 300;
PREFERENCES.use_legacy_exception = false;
2024-02-04 07:33:42 +01:00
2024-04-04 13:56:19 +02:00
PREFERENCES.caret_blink = 0.75;
PREFERENCES.textbox_shake = 0;
PREFERENCES.textbox_particle = 0;
#endregion
#region ////////////////////////////////////////////////////////////////////////// IO //////////////////////////////////////////////////////////////////////////
PREFERENCES.double_click_delay = 0.25;
PREFERENCES.mouse_wheel_speed = 1.00;
PREFERENCES.keyboard_repeat_start = 0.50;
PREFERENCES.keyboard_repeat_speed = 0.10;
#endregion
2023-10-31 05:30:42 +01:00
2024-04-04 13:56:19 +02:00
#region ///////////////////////////////////////////////////////////////////////// DIALOG ////////////////////////////////////////////////////////////////////////
PREFERENCES.node_recents_amount = 20;
PREFERENCES.show_splash = true;
PREFERENCES.splash_expand_recent = false;
2023-10-31 05:30:42 +01:00
2024-04-04 13:56:19 +02:00
PREFERENCES.dialog_add_node_grouping = true;
PREFERENCES.dialog_add_node_view = 0;
2023-10-31 05:30:42 +01:00
2024-04-04 13:56:19 +02:00
PREFERENCES.dialog_add_node_w = 532;
PREFERENCES.dialog_add_node_h = 400;
PREFERENCES.add_node_remember = true;
2024-05-16 15:28:45 +02:00
PREFERENCES.file_explorer_view = FILE_EXPLORER_VIEW.list;
2023-10-31 05:30:42 +01:00
2024-04-04 13:56:19 +02:00
#endregion
2023-10-31 05:30:42 +01:00
2024-04-04 13:56:19 +02:00
#region //////////////////////////////////////////////////////////////////////// PANEL /////////////////////////////////////////////////////////////////////////
2023-10-31 05:30:42 +01:00
2024-04-04 13:56:19 +02:00
PREFERENCES.panel_layout_file = "Vertical";
2023-10-31 05:30:42 +01:00
2024-04-04 13:56:19 +02:00
PREFERENCES.panel_graph_dragging = MOD_KEY.alt;
PREFERENCES.panel_graph_group_require_shift = true;
2023-10-31 05:30:42 +01:00
2024-04-04 13:56:19 +02:00
PREFERENCES.panel_preview_dragging = MOD_KEY.alt;
PREFERENCES.panel_preview_show_real_fps = false;
2023-10-31 05:30:42 +01:00
2024-04-04 13:56:19 +02:00
PREFERENCES.panel_menu_resource_monitor = false;
PREFERENCES.panel_menu_right_control = os_type == os_windows;
2023-10-31 05:30:42 +01:00
2024-05-19 15:11:45 +02:00
PREFERENCES.panel_menu_palette_node_size = 20;
2024-04-04 13:56:19 +02:00
PREFERENCES.inspector_focus_on_double_click = true;
PREFERENCES.inspector_view_default = 1;
PREFERENCES.node_show_render_status = false;
PREFERENCES.node_show_time = true;
PREFERENCES.expand_hover = false;
PREFERENCES.graph_zoom_smoooth = 4;
PREFERENCES.graph_open_group_in_tab = false;
PREFERENCES.connection_line_width = 2;
PREFERENCES.connection_line_sample = 1;
PREFERENCES.connection_line_corner = 8;
PREFERENCES.connection_line_aa = 2;
PREFERENCES.connection_line_transition = true;
PREFERENCES.connection_line_highlight = 0;
PREFERENCES.connection_line_highlight_fade = 0.75;
PREFERENCES.connection_line_highlight_all = false;
PREFERENCES.curve_connection_line = 1;
PREFERENCES.collection_animated = true;
PREFERENCES.collection_preview_speed = 60;
PREFERENCES.collection_scale = 1;
PREFERENCES.pan_mouse_key = mb_middle;
#endregion
#region //////////////////////////////////////////////////////////////////////// WIDGET ////////////////////////////////////////////////////////////////////////
2023-10-31 05:30:42 +01:00
2024-04-04 13:56:19 +02:00
PREFERENCES.widget_autocomplete_delay = 500;
PREFERENCES.alt_picker = true;
2023-10-31 05:30:42 +01:00
2024-04-04 13:56:19 +02:00
#endregion
2023-10-31 05:30:42 +01:00
2024-04-04 13:56:19 +02:00
#region //////////////////////////////////////////////////////////////////////// NODES /////////////////////////////////////////////////////////////////////////
2023-10-31 05:30:42 +01:00
2024-04-04 13:56:19 +02:00
PREFERENCES.node_param_show = false;
PREFERENCES.node_param_width = 192;
2024-05-01 14:28:15 +02:00
PREFERENCES.node_3d_preview_size = 256;
2023-10-31 15:24:54 +01:00
2024-04-04 13:56:19 +02:00
#endregion
2023-11-14 14:29:11 +01:00
2024-04-04 13:56:19 +02:00
#region //////////////////////////////////////////////////////////////////////// MISC //////////////////////////////////////////////////////////////////////////
2023-11-14 14:29:11 +01:00
2024-04-04 13:56:19 +02:00
PREFERENCES.save_file_minify = true;
PREFERENCES.render_all_export = true;
PREFERENCES.clear_temp_on_close = true;
2023-11-01 08:10:25 +01:00
2024-04-04 13:56:19 +02:00
PREFERENCES.show_supporter_icon = true;
2023-12-05 04:28:49 +01:00
2024-04-04 13:56:19 +02:00
#endregion
2023-12-18 04:40:21 +01:00
2024-04-04 13:56:19 +02:00
#region //////////////////////////////////////////////////////////////////////// PATHS /////////////////////////////////////////////////////////////////////////
2024-03-14 14:35:19 +01:00
2024-04-10 05:02:23 +02:00
PREFERENCES.temp_path = "%DIR%/temp/";
PREFERENCES.ImageMagick_path = "%APP%/imagemagick/";
PREFERENCES.webp_path = "%APP%/webp/";
PREFERENCES.gifski_path = "%APP%/gifski/";
PREFERENCES.ffmpeg_path = "%APP%/ffmpeg/";
2024-05-16 09:42:34 +02:00
PREFERENCES.file_explorer = "";
2024-05-16 15:28:45 +02:00
PREFERENCES.dialog_path = "";
2024-05-16 09:42:34 +02:00
2024-04-10 05:02:23 +02:00
PREFERENCES.versions = {};
2024-03-27 11:51:14 +01:00
2024-04-04 13:56:19 +02:00
#endregion
2024-03-31 05:36:11 +02:00
2023-10-31 15:24:54 +01:00
PREFERENCES_DEF = variable_clone(PREFERENCES);
2022-01-13 05:24:03 +01:00
#endregion
2024-05-17 05:19:11 +02:00
#region project attributes
globalvar PROJECT_ATTRIBUTES;
PROJECT_ATTRIBUTES = {}
PROJECT_ATTRIBUTES.strict = false;
PROJECT_ATTRIBUTES.surface_dimension = [ 32, 32 ];
PROJECT_ATTRIBUTES.palette = [ cola(c_white), cola(c_black) ];
PROJECT_ATTRIBUTES.palette_fix = false;
#endregion
2022-01-13 05:24:03 +01:00
#region recent files
2023-03-05 07:16:44 +01:00
globalvar RECENT_FILES, RECENT_FILE_DATA;
RECENT_FILES = ds_list_create();
RECENT_FILE_DATA = ds_list_create();
2022-01-13 05:24:03 +01:00
function RECENT_SAVE() {
var map = ds_map_create();
var l = ds_list_create();
ds_list_copy(l, RECENT_FILES);
ds_map_add_list(map, "Recents", l);
var path = DIRECTORY + "recent.json";
var file = file_text_open_write(path);
2023-02-14 02:51:14 +01:00
file_text_write_string(file, json_encode_minify(map));
2022-01-13 05:24:03 +01:00
file_text_close(file);
ds_map_destroy(map);
}
function RECENT_LOAD() {
var path = DIRECTORY + "recent.json";
2023-12-08 03:50:09 +01:00
if(!file_exists_empty(path)) return;
2022-01-13 05:24:03 +01:00
var file = file_text_open_read(path);
var load_str = "";
while(!file_text_eof(file)) {
load_str += file_text_readln(file);
}
file_text_close(file);
var map = json_decode(load_str);
if(ds_map_exists(map, "Recents")) {
2023-01-17 08:11:55 +01:00
var l = map[? "Recents"];
ds_list_clear(RECENT_FILES);
2022-01-13 05:24:03 +01:00
2023-01-17 08:11:55 +01:00
for(var i = 0; i < ds_list_size(l); i++) {
2023-12-08 03:50:09 +01:00
if(!file_exists_empty(l[| i])) continue;
2023-01-17 08:11:55 +01:00
ds_list_add(RECENT_FILES, l[| i]);
2022-01-13 05:24:03 +01:00
}
}
2023-03-05 07:16:44 +01:00
RECENT_REFRESH();
}
function RECENT_REFRESH() {
for( var i = 0; i < ds_list_size(RECENT_FILE_DATA); i++ ) {
var d = RECENT_FILE_DATA[| i];
if(sprite_exists(d.spr)) sprite_delete(d.spr);
if(surface_exists(d.thumbnail)) surface_free(d.thumbnail);
}
ds_list_clear(RECENT_FILE_DATA);
for( var i = 0; i < ds_list_size(RECENT_FILES); i++ ) {
var p = RECENT_FILES[| i];
RECENT_FILE_DATA[| i] = new FileObject(filename_name_only(p), p);
}
2022-01-13 05:24:03 +01:00
}
#endregion
#region save load
2023-12-24 12:06:44 +01:00
function PREF_SAVE() { #region
2024-02-12 10:25:23 +01:00
if(IS_CMD) return;
2023-10-31 05:30:42 +01:00
var map = {};
2022-01-13 05:24:03 +01:00
2023-10-31 05:30:42 +01:00
var save_l = [];
2022-01-13 05:24:03 +01:00
for(var j = 0; j < ds_list_size(HOTKEY_CONTEXT); j++) {
var ll = HOTKEYS[? HOTKEY_CONTEXT[| j]];
2023-10-31 05:30:42 +01:00
for(var i = 0; i < ds_list_size(ll); i++)
array_push(save_l, ll[| i].serialize());
2022-01-13 05:24:03 +01:00
}
2023-10-31 05:30:42 +01:00
map.key = save_l;
2023-02-14 02:51:14 +01:00
2023-11-28 06:50:54 +01:00
PREFERENCES.window_maximize = window_is_maximized;
PREFERENCES.window_width = max(960, window_minimize_size[0]);
PREFERENCES.window_height = max(600, window_minimize_size[1]);
2024-05-07 08:09:38 +02:00
PREFERENCES.window_monitor = window_monitor;
2022-01-13 05:24:03 +01:00
2023-10-31 05:30:42 +01:00
map.preferences = PREFERENCES;
2023-03-21 03:01:53 +01:00
2024-05-17 05:19:11 +02:00
json_save_struct(DIRECTORY + "keys.json", map);
json_save_struct(DIRECTORY + "Nodes/fav.json", global.FAV_NODES);
json_save_struct(DIRECTORY + "Nodes/recent.json", global.RECENT_NODES);
json_save_struct(DIRECTORY + "key_nodes.json", HOTKEYS_CUSTOM);
json_save_struct(DIRECTORY + "default_project.json", PROJECT_ATTRIBUTES);
2023-12-24 12:06:44 +01:00
} #endregion
2022-01-13 05:24:03 +01:00
2023-12-24 12:06:44 +01:00
function PREF_LOAD() { #region
2022-01-13 05:24:03 +01:00
var path = DIRECTORY + "keys.json";
2023-12-08 03:50:09 +01:00
if(!file_exists_empty(path)) return;
2022-01-13 05:24:03 +01:00
2023-12-08 02:28:22 +01:00
var map = json_load_struct(path);
if(array_empty(variable_struct_get_names(map))) return;
2023-11-18 07:49:50 +01:00
HOTKEYS_DATA = {};
2022-01-13 05:24:03 +01:00
2023-11-18 07:49:50 +01:00
for(var i = 0; i < array_length(map.key); i++) {
var key_list = map.key[i];
2023-10-31 05:30:42 +01:00
var _context = is_struct(key_list)? key_list.context : key_list[0];
var name = is_struct(key_list)? key_list.name : key_list[1];
2023-11-18 07:49:50 +01:00
HOTKEYS_DATA[$ $"{_context}_{name}"] = key_list;
2022-01-13 05:24:03 +01:00
}
2023-10-31 05:30:42 +01:00
struct_override(PREFERENCES, map.preferences);
2022-01-13 05:24:03 +01:00
2023-10-31 05:30:42 +01:00
if(!directory_exists($"{DIRECTORY}Themes/{PREFERENCES.theme}"))
PREFERENCES.theme = "default";
2023-10-04 07:21:45 +02:00
var f = json_load_struct(DIRECTORY + "key_nodes.json");
2024-04-13 07:32:04 +02:00
struct_override_nested(HOTKEYS_CUSTOM, f);
2023-10-08 15:12:20 +02:00
2023-11-19 09:05:42 +01:00
LOCALE_DEF = PREFERENCES.local == "en";
2023-12-11 09:59:58 +01:00
THEME_DEF = PREFERENCES.theme == "default";
FONT_DEF = PREFERENCES.theme == "default" && PREFERENCES.local == "en" && PREFERENCES.display_scaling == 1;
2023-11-01 08:10:25 +01:00
directory_verify(filepath_resolve(PREFERENCES.temp_path));
2023-12-01 05:49:44 +01:00
if(PREFERENCES.move_directory) directory_set_current_working(DIRECTORY);
2024-05-17 05:19:11 +02:00
var f = json_load_struct(DIRECTORY + "default_project.json");
struct_override(PROJECT_ATTRIBUTES, f);
2023-12-24 12:06:44 +01:00
} #endregion
2023-01-25 06:49:00 +01:00
2023-12-24 12:06:44 +01:00
function PREF_APPLY() { #region
2023-10-31 05:30:42 +01:00
if(PREFERENCES.double_click_delay > 1)
PREFERENCES.double_click_delay /= 60;
2023-02-14 02:51:14 +01:00
2023-10-31 05:30:42 +01:00
TESTING = struct_try_get(PREFERENCES, "test_mode", false);
2023-12-24 12:06:44 +01:00
if(TESTING) {
log_message("PREFERENCE", "Test mode enabled");
instance_create_depth(0, 0, 0, addon_key_displayer);
}
2022-09-27 06:37:28 +02:00
2023-10-31 05:30:42 +01:00
if(PREFERENCES.use_legacy_exception) resetException();
else setException();
2023-02-19 02:13:19 +01:00
2023-03-21 12:50:08 +01:00
if(OS != os_macosx && !LOADING) {
2024-05-07 08:09:38 +02:00
var _monitors = display_measure_all();
var _monitor = noone;
if(is_array(_monitors))
for( var i = 0, n = array_length(_monitors); i < n; i++ ) {
var _m = _monitors[i];
if(!is_array(_m) || array_length(_m) < 10) continue;
2023-11-18 03:47:11 +01:00
2024-05-07 08:09:38 +02:00
if(PREFERENCES.window_monitor == _m[9])
_monitor = _m;
2023-02-23 07:02:19 +01:00
}
2024-05-07 08:09:38 +02:00
var ww = PREFERENCES.window_width;
var hh = PREFERENCES.window_height;
window_minimize_size = [ ww, hh ];
if(is_array(_monitor) && array_length(_monitor) >= 8)
window_set_rectangle(_monitor[0] + _monitor[2] / 2 - ww / 2, _monitor[1] + _monitor[3] / 2 - hh / 2, ww, hh);
else
window_set_rectangle(display_get_width() / 2 - ww / 2, display_get_height() / 2 - hh / 2, ww, hh);
if(PREFERENCES.window_maximize)
winMan_Maximize();
gameframe_set_shadow(true);
2022-01-13 05:24:03 +01:00
}
2023-11-28 06:50:54 +01:00
window_refresh();
2023-10-31 05:30:42 +01:00
game_set_speed(PREFERENCES.ui_framerate, gamespeed_fps);
2023-01-25 06:49:00 +01:00
2023-10-31 05:30:42 +01:00
var grav = struct_try_get(PREFERENCES, "physics_gravity", [ 0, 10 ]);
2024-03-31 05:36:11 +02:00
physics_world_gravity(array_safe_get_fast(grav, 0, 0), array_safe_get_fast(grav, 1, 10));
2023-12-24 12:06:44 +01:00
} #endregion
2022-01-13 05:24:03 +01:00
#endregion