- Reduce the amount of data unpacking on start.

This commit is contained in:
Tanasart 2023-11-18 09:47:11 +07:00
parent 6e73ae5855
commit 2f8f36c4ae
28 changed files with 588 additions and 652 deletions

View file

@ -1164,6 +1164,7 @@
{"name":"widget","order":25,"path":"scripts/widget/widget.yy",},
{"name":"node_VFX_effect_vortex","order":6,"path":"scripts/node_VFX_effect_vortex/node_VFX_effect_vortex.yy",},
{"name":"s_node_skew","order":11,"path":"sprites/s_node_skew/s_node_skew.yy",},
{"name":"version_checker","order":11,"path":"scripts/version_checker/version_checker.yy",},
{"name":"s_node_feedback_input","order":10,"path":"sprites/s_node_feedback_input/s_node_feedback_input.yy",},
{"name":"s_node_path_builder","order":9,"path":"sprites/s_node_path_builder/s_node_path_builder.yy",},
{"name":"Obj_FirebaseFirestore_Document_Listener","order":4,"path":"objects/Obj_FirebaseFirestore_Document_Listener/Obj_FirebaseFirestore_Document_Listener.yy",},

View file

@ -1852,6 +1852,7 @@
{"id":{"name":"widget","path":"scripts/widget/widget.yy",},},
{"id":{"name":"node_VFX_effect_vortex","path":"scripts/node_VFX_effect_vortex/node_VFX_effect_vortex.yy",},},
{"id":{"name":"s_node_skew","path":"sprites/s_node_skew/s_node_skew.yy",},},
{"id":{"name":"version_checker","path":"scripts/version_checker/version_checker.yy",},},
{"id":{"name":"s_node_feedback_input","path":"sprites/s_node_feedback_input/s_node_feedback_input.yy",},},
{"id":{"name":"s_node_path_builder","path":"sprites/s_node_path_builder/s_node_path_builder.yy",},},
{"id":{"name":"Obj_FirebaseFirestore_Document_Listener","path":"objects/Obj_FirebaseFirestore_Document_Listener/Obj_FirebaseFirestore_Document_Listener.yy",},},

View file

@ -61,8 +61,7 @@ event_inherited();
function newPresetFromNode(name) {
if(node == noone) return;
var dir = $"{DIRECTORY}Presets/{instanceof(node)}/";
if(!directory_exists(dir))
directory_create(dir);
directory_verify(dir);
var pth = dir + name + ".json";
var map = node.serialize(true, true);

View file

@ -17,7 +17,7 @@
}
show_debug_message("App directory: " + string(APP_DIRECTORY));
if(!directory_exists(APP_DIRECTORY)) directory_create(APP_DIRECTORY);
directory_verify(APP_DIRECTORY);
var perstPath = APP_DIRECTORY + "persistPreference.json";
if(file_exists(perstPath)) {
@ -45,6 +45,8 @@
directory_set_current_working(DIRECTORY);
METADATA = __getdefaultMetaData();
//print($"===================== WORKING DIRECTORIES =====================\n\t{working_directory}\n\t{DIRECTORY}");
#endregion
#region Set up
@ -52,8 +54,7 @@
PREF_LOAD();
var dir = string(DIRECTORY) + "log";
if(!directory_exists(dir))
directory_create(dir);
directory_verify(dir);
log_clear();
log_newline();
@ -83,7 +84,7 @@
log_message("SESSION", "> init Ins Renderer"); __initInstanceRenderer();
setPanel();
__initPanel();
loadAddon();
if(file_exists("icon.png"))

View file

@ -51,7 +51,7 @@ if(PROJECT.active && !PROJECT.safeMode) {
HOTKEY_BLOCK = false;
#endregion
#region coroutine
#region GIF builder
for( var i = 0; i < ds_list_size(GIF_READER); i++ ) {
var _reader = GIF_READER[| i];

View file

@ -60,8 +60,7 @@ _HOVERING_ELEMENT = noone;
if(PROJECT.modified && PREFERENCES.auto_save_time > 0 && AUTO_SAVE_TIMER > PREFERENCES.auto_save_time) {
AUTO_SAVE_TIMER = 0;
var loc = DIRECTORY + "Autosave/";
if(!directory_exists(loc))
directory_create(loc);
directory_verify(loc);
var fname = string_replace(filename_name(PROJECT.path), filename_ext(PROJECT.path), "") +
"_autosave" + string(current_year) + "-" +

View file

@ -1,13 +1,8 @@
function __addonDefault(root) {
var _l = root + "/version";
if(file_exists(_l)) {
var res = json_load_struct(_l);
if(res.version == BUILD_NUMBER) return;
if(check_version($"{root}/version")) {
log_message("THEME", "unzipping default addon to DIRECTORY.");
zip_unzip("data/Addons.zip", root);
}
json_save_struct(_l, { version: BUILD_NUMBER });
log_message("THEME", "unzipping default addon to DIRECTORY.");
zip_unzip("data/Addons.zip", root);
}
function __initAddon() {
@ -16,11 +11,7 @@ function __initAddon() {
ADDONS = [];
ADDONS_ON_START = [];
if(!directory_exists(dirPath)) {
directory_create(dirPath);
return;
}
directory_verify(dirPath);
__addonDefault(dirPath);
var f = file_find_first(dirPath + "\\*", fa_directory);

View file

@ -166,19 +166,13 @@ function Node_Custom(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) co
function __initNodeCustom(list) { #region
var root = DIRECTORY + "Nodes";
if(!directory_exists(root)) directory_create(root);
directory_verify(root);
root += "/Custom";
if(!directory_exists(root)) directory_create(root);
directory_verify(root);
var _l = root + "/version";
if(file_exists(_l)) {
var res = json_load_struct(_l);
if(!is_struct(res) || !struct_has(res, "version") || res.version != BUILD_NUMBER)
zip_unzip("data/Nodes.zip", root);
} else
if(check_version($"{root}/version"))
zip_unzip("data/Nodes.zip", root);
json_save_struct(_l, { version: BUILD_NUMBER });
var f = file_find_first(root + "/*", fa_directory);

View file

@ -5,19 +5,9 @@
global.ACTIONS = [];
var root = DIRECTORY + "Actions";
if(!directory_exists(root))
directory_create(root);
directory_verify(root);
zip_unzip("data/Actions.zip", DIRECTORY);
return;
var _l = root + "/version";
if(file_exists(_l)) {
var res = json_load_struct(_l);
if(!is_struct(res) || !struct_has(res, "version") || res.version != BUILD_NUMBER)
zip_unzip("data/Actions.zip", DIRECTORY);
} else
if(check_version($"{root}/version"))
zip_unzip("data/Actions.zip", DIRECTORY);
json_save_struct(_l, { version: BUILD_NUMBER });
}
#endregion

View file

@ -6,17 +6,10 @@
ds_map_clear(global.ASSET_MAP);
var root = DIRECTORY + "Assets";
if(!directory_exists(root))
directory_create(root);
directory_verify(root);
var _l = root + "/version";
if(file_exists(_l)) {
var res = json_load_struct(_l);
if(!is_struct(res) || !struct_has(res, "version") || res.version != BUILD_NUMBER)
zip_unzip("data/Assets.zip", root);
} else
if(check_version($"{root}/version"))
zip_unzip("data/Assets.zip", root);
json_save_struct(_l, { version: BUILD_NUMBER });
global.ASSETS = new DirectoryObject("Assets", root);
global.ASSETS.scan([".png"]);

View file

@ -5,17 +5,10 @@ function __initCollection() {
COLLECTIONS = -1;
var root = DIRECTORY + "Collections";
if(!directory_exists(root))
directory_create(root);
directory_verify(root);
var _l = root + "/version";
if(file_exists(_l)) {
var res = json_load_struct(_l);
if(!is_struct(res) || !struct_has(res, "version") || res.version != BUILD_NUMBER)
zip_unzip("data/Collections.zip", root);
} else
if(check_version($"{root}/version"))
zip_unzip("data/Collections.zip", root);
json_save_struct(_l, { version: BUILD_NUMBER });
refreshCollections();
}

View file

@ -1,5 +1,4 @@
function __initFontFolder() {
var root = DIRECTORY + "Fonts";
if(!directory_exists(root))
directory_create(root);
directory_verify(root);
}

View file

@ -551,10 +551,10 @@ function gameframe_button_add_defaults() {
function gameframe_tools_rect__new(_x, _y, _w, _h) {
// gameframe_tools_rect__new(...:int)->gameframe_tools_rect
if (_x == undefined) _x = 0;
if (_y == undefined) _y = 0;
if (_w == undefined) _w = 0;
if (_h == undefined) _h = 0;
_x ??= 0;
_y ??= 0;
_w ??= 0;
_h ??= 0;
if (false) show_debug_message(argument[3]);
return [/* x: */_x, /* y: */_y, /* width: */_w, /* height: */_h];
}
@ -674,7 +674,7 @@ function gameframe_restore(__force) {
/// gameframe_restore(_force:bool = false)
/// @param {bool} [_force=false]
/// @returns {void}
if (__force == undefined) __force = false;
__force ??= false;
if (false) show_debug_message(argument[0]);
if (window_get_fullscreen()) {
window_set_fullscreen(false);

File diff suppressed because it is too large Load diff

View file

@ -8,9 +8,9 @@
var lfile = $"data/locale/en.zip";
var root = $"{DIRECTORY}Locale";
if(!directory_exists(root))
directory_create(root);
zip_unzip(lfile, root);
directory_verify(root);
if(check_version($"{root}/version"))
zip_unzip(lfile, root);
loadLocale();
}

View file

@ -100,10 +100,10 @@
function __initNodeActions(list) {
var root = $"{DIRECTORY}Actions";
if(!directory_exists(root)) directory_create(root);
directory_verify(root);
root += "/Nodes";
if(!directory_exists(root)) directory_create(root);
directory_verify(root);
var f = file_find_first(root + "/*", 0);

View file

@ -9,7 +9,8 @@ function __generate_node_data() { #region
NODE_EXTRACT = true;
var dir = DIRECTORY + "Nodes/";
if(!directory_exists(dir)) directory_create(dir);
directory_verify(dir);
var data = {};
var junc = {};
var locale = {};
@ -122,7 +123,7 @@ function __generate_node_data() { #region
global.NODE_RELATION = {};
var _dir = DIRECTORY + "Nodes/Related";
if(!directory_exists(_dir)) return;
directory_verify(_dir);
var f = file_find_first(_dir + "/*.json", fa_none);

View file

@ -1,4 +1,4 @@
function Node_create_Image_gif(_x, _y, _group = noone) {
function Node_create_Image_gif(_x, _y, _group = noone) { #region
var path = "";
if(!LOADING && !APPENDING && !CLONING) {
path = get_open_filename(".gif", "");
@ -11,9 +11,9 @@ function Node_create_Image_gif(_x, _y, _group = noone) {
node.doUpdate();
return node;
}
} #endregion
function Node_create_Image_gif_path(_x, _y, path) {
function Node_create_Image_gif_path(_x, _y, path) { #region
if(!file_exists(path)) return noone;
var node = new Node_Image_gif(_x, _y, PANEL_GRAPH.getCurrentContext());
@ -21,7 +21,7 @@ function Node_create_Image_gif_path(_x, _y, path) {
node.doUpdate();
return node;
}
} #endregion
function Node_Image_gif(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "Image GIF";
@ -131,6 +131,8 @@ function Node_Image_gif(_x, _y, _group = noone) : Node(_x, _y, _group) construct
if(loading == 2 && spr_builder != noone && spr_builder.building()) {
surfaces = [];
spr = spr_builder._spr;
print($"{spr}: {sprite_get_width(spr)}, {sprite_get_height(spr)}");
triggerRender();
loading = 0;
@ -207,12 +209,11 @@ function Node_Image_gif(_x, _y, _group = noone) : Node(_x, _y, _group) construct
surface_reset_shader();
} #endregion
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region
if(loading) draw_sprite_ui(THEME.loading, 0, xx + w * _s / 2, yy + h * _s / 2, _s, _s, current_time / 2, COLORS._main_icon, 1);
}
} #endregion
static onDestroy = function() {
if(sprite_exists(spr))
sprite_flush(spr);
}
static onDestroy = function() { #region
if(sprite_exists(spr)) sprite_flush(spr);
} #endregion
}

View file

@ -1,96 +1,16 @@
function Node_PC_Balls(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
name = "Pixel Cloud";
shader = sh_pixel_cloud;
uniform_sed = shader_get_uniform(shader, "seed");
uniform_str = shader_get_uniform(shader, "strength");
uniform_dis = shader_get_uniform(shader, "dist");
uniform_map_use = shader_get_uniform(shader, "useMap");
uniform_map = shader_get_sampler_index(shader, "strengthMap");
uniform_grad_blend = shader_get_uniform(shader, "gradient_blend");
uniform_grad = shader_get_uniform(shader, "gradient_color");
uniform_grad_time = shader_get_uniform(shader, "gradient_time");
uniform_grad_key = shader_get_uniform(shader, "gradient_keys");
uniform_alpha = shader_get_uniform(shader, "alpha_curve");
uniform_alamo = shader_get_uniform(shader, "curve_amount");
uniform_rnd = shader_get_uniform(shader, "randomAmount");
inputs[| 0] = nodeValue("Surface in", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, 0);
inputs[| 1] = nodeValue("Seed", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, irandom(100000));
inputs[| 2] = nodeValue("Strength", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.1)
.setDisplay(VALUE_DISPLAY.slider, { range: [ 0, 2, 0.01] });
inputs[| 3] = nodeValue("Strength map", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, 0);
inputs[| 4] = nodeValue("Color over lifetime", self, JUNCTION_CONNECT.input, VALUE_TYPE.gradient, new gradientObject(c_white) );
inputs[| 5] = nodeValue("Distance", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1);
inputs[| 6] = nodeValue("Alpha over lifetime", self, JUNCTION_CONNECT.input, VALUE_TYPE.curve, CURVE_DEF_11);
inputs[| 7] = nodeValue("Random blending", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.1)
.setDisplay(VALUE_DISPLAY.slider);
inputs[| 8] = nodeValue("Active", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true);
active_index = 8;
input_display_list = [ 8,
["Input", true], 0, 1,
["Movement", false], 5, 2, 3,
["Color", true], 4, 6, 7,
]
input_display_list = [ ];
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
attribute_surface_depth();
static processData = function(_outSurf, _data, _output_index, _array_index) {
var _sed = _data[1];
var _str = _data[2];
var _map = _data[3];
var _gra = _data[4];
var _dis = _data[5];
var _alp = _data[6];
var _rnd = _data[7];
var _grad = _gra.toArray();
var _grad_color = _grad[0];
var _grad_time = _grad[1];
surface_set_target(_outSurf);
DRAW_CLEAR
BLEND_OVERRIDE;
shader_set(shader);
shader_set_uniform_f(uniform_sed, _sed);
shader_set_uniform_f(uniform_str, _str);
shader_set_uniform_f(uniform_dis, _dis);
if(is_surface(_map)) {
shader_set_uniform_i(uniform_map_use, 1);
texture_set_stage(uniform_map, surface_get_texture(_map));
} else {
shader_set_uniform_i(uniform_map_use, 0);
}
shader_set_uniform_i(uniform_grad_blend, _gra.type);
shader_set_uniform_f_array_safe(uniform_grad, _grad_color);
shader_set_uniform_f_array_safe(uniform_grad_time, _grad_time);
shader_set_uniform_i(uniform_grad_key, array_length(_gra.keys));
shader_set_uniform_f_array_safe(uniform_alpha, _alp);
shader_set_uniform_i(uniform_alamo, array_length(_alp));
shader_set_uniform_f(uniform_rnd, _rnd);
draw_surface_safe(_data[0], 0, 0);
shader_reset();
BLEND_NORMAL;
surface_reset_target();
var _sed = _data[0];
return _outSurf;
}

View file

@ -1675,7 +1675,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
} #endregion
static arrayLength = function(val = undefined) { #region
if(val == undefined) val = getValue();
val ??= getValue();
if(!isArray(val))
return -1;

View file

@ -121,13 +121,17 @@
PANEL_MAIN.refresh();
}
function __initPanel() {
if(check_version($"{DIRECTORY}layouts/version"))
zip_unzip("data/Layouts.zip", DIRECTORY);
setPanel();
}
function setPanel() {
globalvar CURRENT_PANEL;
panelObjectInit();
//if(!directory_exists(DIRECTORY + "layouts"))
zip_unzip("data/Layouts.zip", DIRECTORY);
var file = $"{DIRECTORY}layouts/{PREFERENCES.panel_layout_file}.json";
if(!file_exists(file))
file = DIRECTORY + "layouts/Horizontal.json";

View file

@ -38,7 +38,8 @@ function Panel_Node_Data_Gen() : PanelContent() constructor {
NODE_EXTRACT = true;
dir = DIRECTORY + "Nodes/";
if(!directory_exists(dir)) directory_create(dir);
directory_verify(dir);
data = {};
junc = {};
locale = {};

View file

@ -218,7 +218,7 @@
} else {
var ww = PREFERENCES.window_width;
var hh = PREFERENCES.window_height;
window_set_position(display_get_width() / 2 - ww / 2, display_get_height() / 2 - hh / 2);
window_set_size(ww, hh);
}

View file

@ -4,21 +4,11 @@
function __initPresets() {
ds_map_clear(global.PRESETS_MAP);
var root = DIRECTORY + "Presets";
if(!directory_exists(root))
directory_create(root);
var _l = root + "/version";
var _preset_path = "data/Preset.zip";
if(file_exists(_preset_path)) {
if(file_exists(_l)) {
var res = json_load_struct(_l);
if(!is_struct(res) || !struct_has(res, "version") || res.version != BUILD_NUMBER)
zip_unzip(_preset_path, root);
} else
zip_unzip(_preset_path, root);
}
json_save_struct(_l, { version: BUILD_NUMBER });
var root = DIRECTORY + "Presets";
directory_verify(root);
if(check_version($"{root}/version") && file_exists(_preset_path))
zip_unzip(_preset_path, root);
global.PRESETS = new DirectoryObject("Presets", root);
global.PRESETS.scan([".json"]);

View file

@ -1,27 +1,25 @@
function __initTheme() {
function __initTheme() { #region
var root = DIRECTORY + "Themes";
if(!directory_exists(root))
directory_create(root);
var _l = root + "/version";
if(file_exists(_l))
var res = json_load_struct(_l);
json_save_struct(_l, { version: BUILD_NUMBER });
log_message("THEME", $"unzipping default theme to {root}.");
zip_unzip("data/themes/default.zip", root);
directory_verify(root);
if(check_version($"{root}/version")) {
log_message("THEME", $"unzipping default theme to {root}.");
zip_unzip("data/themes/default.zip", root);
}
loadGraphic(PREFERENCES.theme);
loadColor(PREFERENCES.theme);
}
print($">>>>>>>>>>>>>>>>>>>>>>>>>>>>>> OBJECT CHECK: {THEME.ui_panel_bg} <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
} #endregion
function _sprite_path(rel, theme) {
function _sprite_path(rel, theme) { #region
INLINE
return $"{DIRECTORY}themes/{theme}/graphics/{string_replace_all(rel, "./", "")}";
}
} #endregion
function _sprite_load_from_struct(str, theme, key) {
function _sprite_load_from_struct(str, theme, key) { #region
INLINE
var path = _sprite_path(str.path, theme);
@ -42,17 +40,17 @@ function _sprite_load_from_struct(str, theme, key) {
else log_message("THEME", $"Load sprite {path} failed.");
}
return s;
}
} #endregion
function __getGraphicList() {
function __getGraphicList() { #region
INLINE
var path = _sprite_path("./graphics.json", "default");
var s = file_read_all(path);
return json_try_parse(s);
}
} #endregion
function loadGraphic(theme = "default") {
function loadGraphic(theme = "default") { #region
var sprDef = __getGraphicList();
var _metaP = $"{DIRECTORY}Themes/{theme}/meta.json";
if(!file_exists(_metaP))
@ -78,9 +76,6 @@ function loadGraphic(theme = "default") {
for( var i = 0, n = array_length(graphics); i < n; i++ ) {
var key = graphics[i];
//if(struct_has(THEME, key) && sprite_exists(THEME[$ key]))
// sprite_delete(THEME[$ key]);
if(struct_has(sprStr, key)) {
str = sprStr[$ key];
@ -91,7 +86,5 @@ function loadGraphic(theme = "default") {
str = sprDef[$ key];
THEME[$ key] = _sprite_load_from_struct(str, "default", key);
}
//print($"{key}: {THEME[$ key]} [{sprite_exists(THEME[$ key])}]");
}
}
} #endregion

View file

@ -179,7 +179,7 @@ function is_surface(s) {
INLINE
if(is_instanceof(s, dynaSurf) || is_instanceof(s, SurfaceAtlas)) return true;
if(is_real(s) && s > 0 && surface_exists(s)) return true;
if(is_numeric(s) && s > 0 && surface_exists(s)) return true;
return false;
}
@ -198,7 +198,7 @@ function surface_get_pixel(surface, _x, _y) {
var f = surface_get_format(surface);
var px = surface_getpixel(surface, _x, _y);
if(is_real(px)) return px;
if(is_numeric(px)) return px;
return round(px[0] * (255 * power(256, 0))) + round(px[1] * (255 * power(256, 1))) + round(px[2] * (255 * power(256, 2)));
}
@ -208,7 +208,7 @@ function surface_get_pixel_ext(surface, _x, _y) {
if(!is_surface(surface)) return;
var px = surface_getpixel_ext(surface, _x, _y);
if(is_real(px)) return px;
if(is_numeric(px)) return px;
return round(px[0] * (255 * power(256, 0))) + round(px[1] * (255 * power(256, 1))) + round(px[2] * (255 * power(256, 2))) + round(px[3] * (255 * power(256, 3)));
}
@ -424,7 +424,7 @@ function surface_copy_size(dest, source, format = noone) {
function surface_valid_size(s) {
INLINE
if(!is_real(s)) return 1;
if(!is_numeric(s)) return 1;
if(is_infinity(s)) return 1;
return clamp(s, 1, 8196);
}

View file

@ -0,0 +1,9 @@
function check_version(path) {
if(!file_exists(path)) {
json_save_struct(path, { version: BUILD_NUMBER });
return true;
}
var res = json_load_struct(path);
return struct_try_get(res, "version") != BUILD_NUMBER;
}

View file

@ -0,0 +1,11 @@
{
"resourceType": "GMScript",
"resourceVersion": "1.0",
"name": "version_checker",
"isCompatibility": false,
"isDnD": false,
"parent": {
"name": "files",
"path": "folders/functions/files.yy",
},
}