save compress

This commit is contained in:
Tanasart 2024-11-24 08:33:57 +07:00
parent ef8270fc1e
commit af24f73622
7 changed files with 26 additions and 18 deletions

View file

@ -180,6 +180,12 @@ event_inherited();
new checkBox(function() /*=>*/ { PREFERENCES.save_file_minify = !PREFERENCES.save_file_minify; PREF_SAVE(); }) new checkBox(function() /*=>*/ { PREFERENCES.save_file_minify = !PREFERENCES.save_file_minify; PREF_SAVE(); })
)); ));
ds_list_add(pref_global, new __Panel_Linear_Setting_Item_Preference(
__txtx("pref_save_file_compress", "Compress save file"),
"save_compress",
new checkBox(function() /*=>*/ { PREFERENCES.save_compress = !PREFERENCES.save_compress; PREF_SAVE(); })
));
ds_list_add(pref_global, new __Panel_Linear_Setting_Item_Preference( ds_list_add(pref_global, new __Panel_Linear_Setting_Item_Preference(
__txtx("pref_save_backups", "Backup saves"), __txtx("pref_save_backups", "Backup saves"),
"save_backup", "save_backup",

View file

@ -44,7 +44,7 @@
LATEST_VERSION = 1_18_00_0; LATEST_VERSION = 1_18_00_0;
VERSION = 1_18_04_0; VERSION = 1_18_04_0;
SAVE_VERSION = 1_18_04_0; SAVE_VERSION = 1_18_04_0;
VERSION_STRING = MAC? "1.18.003m" : "1.18.5.003"; VERSION_STRING = MAC? "1.18.003m" : "1.18.5.004";
BUILD_NUMBER = 1_18_04_1; BUILD_NUMBER = 1_18_04_1;
HOTKEYS = ds_map_create(); HOTKEYS = ds_map_create();

View file

@ -126,16 +126,19 @@ function LOAD_AT(path, params = new __loadParams()) {
var _ext = filename_ext_raw(path); var _ext = filename_ext_raw(path);
var s; var s;
if(_ext == "pxc") { var bf = buffer_load(path);
var f = file_text_open_read(path); var bc = buffer_decompress(bf);
s = file_text_read_all(f);
file_text_close(f);
} else if(_ext == "cpxc") { if(bc == -1) {
var b = buffer_decompress(buffer_load(path)); s = buffer_read(bf, buffer_string);
s = buffer_read(b, buffer_string);
} else {
s = buffer_read(bc, buffer_string);
buffer_delete(bc);
} }
buffer_delete(bf);
_load_content = json_try_parse(s); _load_content = json_try_parse(s);
printIf(log, $" > Load struct : {(get_timer() - t1) / 1000} ms"); t1 = get_timer(); printIf(log, $" > Load struct : {(get_timer() - t1) / 1000} ms"); t1 = get_timer();

View file

@ -2243,7 +2243,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
var _attr = attributeSerialize(); var _attr = attributeSerialize();
var attri = struct_append(variable_clone(attributes), _attr); var attri = struct_append(variable_clone(attributes), _attr);
#region attribute stripping #region attribute stripping // TODO : make it an array
if(struct_try_get(attri, "color_depth") == 3) struct_remove(attri, "color_depth"); if(struct_try_get(attri, "color_depth") == 3) struct_remove(attri, "color_depth");
if(struct_try_get(attri, "interpolate") == 1) struct_remove(attri, "interpolate"); if(struct_try_get(attri, "interpolate") == 1) struct_remove(attri, "interpolate");
if(struct_try_get(attri, "oversample") == 1) struct_remove(attri, "oversample"); if(struct_try_get(attri, "oversample") == 1) struct_remove(attri, "oversample");

View file

@ -2201,12 +2201,8 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
draw_line_shift_y = struct_try_get(_map, "shift_y", 0); draw_line_shift_y = struct_try_get(_map, "shift_y", 0);
is_modified = struct_try_get(_map, "is_modified", false); is_modified = struct_try_get(_map, "is_modified", false);
if(struct_has(_map, "attri")) { if(struct_has(_map, "attri"))
var _lattr = _map.attri; struct_append(attributes, _map.attri);
_lattr.mapped = struct_try_get(_lattr, "mapped", 0);
struct_append(attri, _lattr);
}
if(struct_has(_map, "linked")) if(struct_has(_map, "linked"))
display_data.linked = _map.linked; display_data.linked = _map.linked;

View file

@ -51,6 +51,7 @@
PREFERENCES.keyboard_double_delay = 0.25; PREFERENCES.keyboard_double_delay = 0.25;
PREFERENCES.file_watcher_delay = 0.1; PREFERENCES.file_watcher_delay = 0.1;
#endregion #endregion
#region ///////////////////////////////////////////////////////////////////////// DIALOG //////////////////////////////////////////////////////////////////////// #region ///////////////////////////////////////////////////////////////////////// DIALOG ////////////////////////////////////////////////////////////////////////
@ -141,6 +142,7 @@
PREFERENCES.save_file_minify = true; PREFERENCES.save_file_minify = true;
PREFERENCES.save_backup = 1; PREFERENCES.save_backup = 1;
PREFERENCES.save_layout = false; PREFERENCES.save_layout = false;
PREFERENCES.save_compress = true;
#endregion #endregion

View file

@ -22,6 +22,7 @@ function SERIALIZE_PROJECT(project = PROJECT) {
function SET_PATH(project, path) { function SET_PATH(project, path) {
if(path == "") { if(path == "") {
project.readonly = false; project.readonly = false;
} else if(!project.readonly) { } else if(!project.readonly) {
ds_list_remove(RECENT_FILES, path); ds_list_remove(RECENT_FILES, path);
ds_list_insert(RECENT_FILES, 0, path); ds_list_insert(RECENT_FILES, 0, path);
@ -29,7 +30,6 @@ function SET_PATH(project, path) {
ds_list_delete(RECENT_FILES, ds_list_size(RECENT_FILES) - 1); ds_list_delete(RECENT_FILES, ds_list_size(RECENT_FILES) - 1);
RECENT_SAVE(); RECENT_SAVE();
RECENT_REFRESH(); RECENT_REFRESH();
//project.path = filename_name(path);
} }
project.path = path; project.path = path;
@ -88,9 +88,10 @@ function SAVE_AT(project = PROJECT, path = "", log = "save at ") {
if(file_exists_empty(path)) file_delete(path); if(file_exists_empty(path)) file_delete(path);
var _ext = filename_ext_raw(path); var _ext = filename_ext_raw(path);
var _prj = SERIALIZE_PROJECT(project); var _prj = SERIALIZE_PROJECT(project);
var _cmp = PREFERENCES.save_compress;
if(_ext == "pxc") file_text_write_all(path, _prj); if(_cmp) buffer_save(buffer_compress_string(_prj), path);
else if(_ext == "cpxc") buffer_save(buffer_compress_string(_prj), path); else file_text_write_all(path, _prj);
SAVING = false; SAVING = false;
project.readonly = false; project.readonly = false;