mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-12-25 06:26:42 +01:00
Compress pixel composer project file
This commit is contained in:
parent
5d3a1f7835
commit
e82a50e5e3
7 changed files with 32 additions and 25 deletions
|
@ -196,6 +196,7 @@
|
||||||
node = Node_create_WAV_File_Read_path(PANEL_GRAPH.mouse_grid_x, PANEL_GRAPH.mouse_grid_y, p);
|
node = Node_create_WAV_File_Read_path(PANEL_GRAPH.mouse_grid_x, PANEL_GRAPH.mouse_grid_y, p);
|
||||||
break;
|
break;
|
||||||
case ".pxc" :
|
case ".pxc" :
|
||||||
|
case ".cpxc" :
|
||||||
LOAD_PATH(p);
|
LOAD_PATH(p);
|
||||||
break;
|
break;
|
||||||
case ".pxcc" :
|
case ".pxcc" :
|
||||||
|
@ -219,6 +220,7 @@
|
||||||
#region version
|
#region version
|
||||||
version_check = -1;
|
version_check = -1;
|
||||||
version_latest = 0;
|
version_latest = 0;
|
||||||
|
|
||||||
//if(os_is_network_connected()) {
|
//if(os_is_network_connected()) {
|
||||||
// var version = "https://gist.githubusercontent.com/Ttanasart-pt/d9eefbda84a78863c122b8b155bc0cda/raw/version.txt";
|
// var version = "https://gist.githubusercontent.com/Ttanasart-pt/d9eefbda84a78863c122b8b155bc0cda/raw/version.txt";
|
||||||
// version_check = http_get(version);
|
// version_check = http_get(version);
|
||||||
|
@ -401,7 +403,7 @@
|
||||||
path = string_replace_all(path, "\n", "");
|
path = string_replace_all(path, "\n", "");
|
||||||
path = string_replace_all(path, "\"", "");
|
path = string_replace_all(path, "\"", "");
|
||||||
|
|
||||||
if(file_exists_empty(path) && filename_ext(path) == ".pxc")
|
if(file_exists_empty(path) && (filename_ext(path) == ".pxc" || filename_ext(path) == ".cpxc"))
|
||||||
PROGRAM_ARGUMENTS._path = path;
|
PROGRAM_ARGUMENTS._path = path;
|
||||||
|
|
||||||
} else
|
} else
|
||||||
|
|
|
@ -100,7 +100,7 @@ _HOVERING_ELEMENT = noone;
|
||||||
string_lead_zero(current_day, 2) + "T" +
|
string_lead_zero(current_day, 2) + "T" +
|
||||||
string_lead_zero(current_hour, 2) +
|
string_lead_zero(current_hour, 2) +
|
||||||
string_lead_zero(current_minute, 2) +
|
string_lead_zero(current_minute, 2) +
|
||||||
string_lead_zero(current_second, 2) + ".pxc";
|
string_lead_zero(current_second, 2) + filename_ext(PROJECT.path);
|
||||||
|
|
||||||
try { SAVE_AT(PROJECT, loc + fname, "Autosaved "); }
|
try { SAVE_AT(PROJECT, loc + fname, "Autosaved "); }
|
||||||
catch(e) { print(exception_print(e)); }
|
catch(e) { print(exception_print(e)); }
|
||||||
|
|
|
@ -89,3 +89,11 @@ function buffer_setPixel(buffer, _w, _h, _x, _y, _c) { #region
|
||||||
buffer_seek(buffer, buffer_seek_start, (_w * _y + _x) * 4);
|
buffer_seek(buffer, buffer_seek_start, (_w * _y + _x) * 4);
|
||||||
buffer_write(buffer, buffer_u32, _c);
|
buffer_write(buffer, buffer_u32, _c);
|
||||||
} #endregion
|
} #endregion
|
||||||
|
|
||||||
|
function buffer_compress_string(str) { #region
|
||||||
|
var _len = string_length(str);
|
||||||
|
var buffer = buffer_create(1, buffer_grow, 1);
|
||||||
|
|
||||||
|
buffer_write(buffer, buffer_string, str);
|
||||||
|
return buffer_compress(buffer, 0, buffer_get_size(buffer));
|
||||||
|
} #endregion
|
|
@ -23,6 +23,7 @@ function FileObject(_name, _path) constructor { #region
|
||||||
type = FILE_TYPE.assets;
|
type = FILE_TYPE.assets;
|
||||||
break;
|
break;
|
||||||
case ".pxc" :
|
case ".pxc" :
|
||||||
|
case ".cpxc" :
|
||||||
type = FILE_TYPE.project;
|
type = FILE_TYPE.project;
|
||||||
break;
|
break;
|
||||||
} #endregion
|
} #endregion
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
function LOAD(safe = false) { #region
|
function LOAD(safe = false) { #region
|
||||||
if(DEMO) return false;
|
if(DEMO) return false;
|
||||||
|
|
||||||
var path = get_open_filename("Pixel Composer PROJECT (.pxc)|*.pxc", "");
|
var path = get_open_filename("Pixel Composer project (.pxc)|*.pxc;*.cpxc", "");
|
||||||
key_release();
|
key_release();
|
||||||
if(path == "") return;
|
if(path == "") return;
|
||||||
if(filename_ext(path) != ".json" && filename_ext(path) != ".pxc") return;
|
if(filename_ext(path) != ".json" && filename_ext(path) != ".pxc") return;
|
||||||
|
@ -71,7 +71,7 @@ function LOAD_AT(path, readonly = false, override = false) { #region
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(filename_ext(path) != ".json" && filename_ext(path) != ".pxc") {
|
if(filename_ext(path) != ".json" && filename_ext(path) != ".pxc" && filename_ext(path) != ".cpxc") {
|
||||||
log_warning("LOAD", "File not a valid PROJECT");
|
log_warning("LOAD", "File not a valid PROJECT");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -102,10 +102,19 @@ function LOAD_AT(path, readonly = false, override = false) { #region
|
||||||
printIf(log, $" > Create temp : {(get_timer() - t1) / 1000} ms"); t1 = get_timer();
|
printIf(log, $" > Create temp : {(get_timer() - t1) / 1000} ms"); t1 = get_timer();
|
||||||
|
|
||||||
var _load_content;
|
var _load_content;
|
||||||
|
var _ext = filename_ext(path);
|
||||||
|
var s;
|
||||||
|
|
||||||
|
if(_ext == ".pxc") {
|
||||||
var f = file_text_open_read(path);
|
var f = file_text_open_read(path);
|
||||||
var s = file_text_read_all(f);
|
s = file_text_read_all(f);
|
||||||
file_text_close(f);
|
file_text_close(f);
|
||||||
|
|
||||||
|
} else if(_ext == ".cpxc") {
|
||||||
|
var b = buffer_decompress(buffer_load(path));
|
||||||
|
s = buffer_read(b, buffer_string);
|
||||||
|
}
|
||||||
|
|
||||||
_load_content = json_parse(s);
|
_load_content = json_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();
|
||||||
|
|
|
@ -21,21 +21,6 @@ function Node_Wrap_Area(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
||||||
attribute_surface_depth();
|
attribute_surface_depth();
|
||||||
attribute_interpolation();
|
attribute_interpolation();
|
||||||
|
|
||||||
attributes[? "initalset"] = false;
|
|
||||||
|
|
||||||
static onValueFromUpdate = function(index) { #region
|
|
||||||
if(index == 0 && attributes[? "initalset"] == false) {
|
|
||||||
var _surf = getInputData(0);
|
|
||||||
if(!is_surface(_surf)) return;
|
|
||||||
|
|
||||||
var _sw = surface_get_width_safe(_surf);
|
|
||||||
var _sh = surface_get_height_safe(_surf);
|
|
||||||
|
|
||||||
inputs[| 1].setValue([ _sw / 2, _sh / 2, _sw / 2, _sh / 2, AREA_SHAPE.rectangle ]);
|
|
||||||
attributes[? "initalset"] = true;
|
|
||||||
}
|
|
||||||
} if(!LOADING && !APPENDING) run_in(1, function() { onValueFromUpdate(0); }) #endregion
|
|
||||||
|
|
||||||
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
|
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
|
||||||
inputs[| 1].drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny);
|
inputs[| 1].drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny);
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,11 +94,11 @@ function SAVE(project = PROJECT) { #region
|
||||||
function SAVE_AS(project = PROJECT) { #region
|
function SAVE_AS(project = PROJECT) { #region
|
||||||
if(DEMO) return false;
|
if(DEMO) return false;
|
||||||
|
|
||||||
var path = get_save_filename("Pixel Composer project (.pxc)|*.pxc", "");
|
var path = get_save_filename("Pixel Composer project (.pxc)|*.pxc|Compressed Pixel Composer project (.cpxc)|*.cpxc", "");
|
||||||
key_release();
|
key_release();
|
||||||
if(path == "") return false;
|
if(path == "") return false;
|
||||||
|
|
||||||
if(filename_ext(path) != ".pxc")
|
if(filename_ext(path) != ".pxc" && filename_ext(path) != ".cpxc")
|
||||||
path += ".pxc";
|
path += ".pxc";
|
||||||
|
|
||||||
if(file_exists_empty(path))
|
if(file_exists_empty(path))
|
||||||
|
@ -119,7 +119,9 @@ function SAVE_AT(project = PROJECT, path = "", log = "save at ") { #region
|
||||||
// path = $"{filename_dir(path)}/[{VERSION_STRING}] {filename_name(path)}";
|
// path = $"{filename_dir(path)}/[{VERSION_STRING}] {filename_name(path)}";
|
||||||
|
|
||||||
if(file_exists_empty(path)) file_delete(path);
|
if(file_exists_empty(path)) file_delete(path);
|
||||||
file_text_write_all(path, save_serialize(project));
|
var _ext = filename_ext(path);
|
||||||
|
if(_ext == ".pxc") file_text_write_all(path, save_serialize(project));
|
||||||
|
else if(_ext == ".cpxc") buffer_save(buffer_compress_string(save_serialize(project)), path);
|
||||||
|
|
||||||
SAVING = false;
|
SAVING = false;
|
||||||
project.readonly = false;
|
project.readonly = false;
|
||||||
|
|
Loading…
Reference in a new issue