- Improve project loading speed.

This commit is contained in:
Tanasart 2023-11-13 13:11:52 +07:00
parent 97882cc902
commit 1573e3d1a6
15 changed files with 71 additions and 42 deletions

Binary file not shown.

View file

@ -40,7 +40,7 @@ gameframe_button_array = [];
path = DIRECTORY + "log/crash_log.txt"; path = DIRECTORY + "log/crash_log.txt";
if(!file_exists(path)) game_end(1); if(!file_exists(path)) game_end(1);
crash_content = file_text_read_all(path); crash_content = file_read_all(path);
log_surface = surface_create(1, 1); log_surface = surface_create(1, 1);
log_y = 0; log_y = 0;
log_y_to = 0; log_y_to = 0;

View file

@ -64,11 +64,8 @@ event_inherited();
for(var i = 0; i < ds_list_size(global.ASSETS.subDir); i++) { for(var i = 0; i < ds_list_size(global.ASSETS.subDir); i++) {
var _w = folderPane.surface_w - ui(16); var _w = folderPane.surface_w - ui(16);
var _hover = sHOVER && folderPane.hover; var _hover = sHOVER && folderPane.hover;
var _clr = {
selecting : COLORS.assetbox_current_bg
}
var hg = global.ASSETS.subDir[| i].draw(self, ui(8), _y + 8, _m, _w, _hover, sFOCUS, global.ASSETS, _clr); var hg = global.ASSETS.subDir[| i].draw(self, ui(8), _y + 8, _m, _w, _hover, sFOCUS, global.ASSETS);
hh += hg; hh += hg;
_y += hg; _y += hg;
} }

View file

@ -20,8 +20,8 @@
draw_set_text(f_p0b, fa_left, fa_top, COLORS._main_text); draw_set_text(f_p0b, fa_left, fa_top, COLORS._main_text);
draw_text(dialog_x + ui(16), dialog_y + ui(16), __txt("Assets")); draw_text(dialog_x + ui(16), dialog_y + ui(16), __txt("Assets"));
draw_sprite_stretched(THEME.ui_panel_inner_bg, 0, dialog_x + ui(16), dialog_y + ui(48), folderW - ui(24), dialog_h - ui(64)); draw_sprite_stretched(THEME.ui_panel_bg, 1, dialog_x + ui(16), dialog_y + ui(48), folderW - ui(24), dialog_h - ui(64));
draw_sprite_stretched(THEME.ui_panel_inner_bg, 0, dialog_x + ui(12) + folderW, dialog_y + ui(16), dialog_w - ui(28) - folderW, dialog_h - ui(32)); draw_sprite_stretched(THEME.ui_panel_bg, 1, dialog_x + ui(12) + folderW, dialog_y + ui(16), dialog_w - ui(28) - folderW, dialog_h - ui(32));
var dx0 = dialog_x + ui(16) + folderW - ui(8); var dx0 = dialog_x + ui(16) + folderW - ui(8);
var dx1 = dialog_x + ui(16) + folderW; var dx1 = dialog_x + ui(16) + folderW;

View file

@ -275,7 +275,7 @@ function __part(_node) constructor {
ss = surf[ind]; ss = surf[ind];
break; break;
} }
} else if(arr_type == 3) ss = ss[_index]; } else if(arr_type == 3) ss = array_safe_get(ss, _index);
var surface = is_instanceof(ss, SurfaceAtlas)? ss.getSurface() : node.surface_cache[$ ss]; var surface = is_instanceof(ss, SurfaceAtlas)? ss.getSurface() : node.surface_cache[$ ss];
@ -320,6 +320,12 @@ function __part(_node) constructor {
return [x, y]; return [x, y];
} #endregion } #endregion
static clone = function() { #region
var _p = new __part(node);
struct_override(_p, self);
return _p;
} #endregion
} }
#region helper #region helper

View file

@ -68,7 +68,7 @@ function Node_VFX_Spawner_Base(_x, _y, _group = noone) : Node(_x, _y, _group) co
.rejectArray(); .rejectArray();
inputs[| 22] = nodeValue("Surface array", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0, "Whether to select image from an array in order, at random, or treat array as animation." ) inputs[| 22] = nodeValue("Surface array", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0, "Whether to select image from an array in order, at random, or treat array as animation." )
.setDisplay(VALUE_DISPLAY.enum_scroll, [ "Random", "Order", "Animation", "Array" ]) .setDisplay(VALUE_DISPLAY.enum_scroll, [ "Random", "Order", "Animation" ])
.setVisible(false); .setVisible(false);
inputs[| 23] = nodeValue("Animation speed", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 1, 1 ] ) inputs[| 23] = nodeValue("Animation speed", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 1, 1 ] )

View file

@ -212,10 +212,8 @@ function DirectoryObject(name, path) constructor {
} }
} }
if(ds_list_empty(subDir)) if(ds_list_empty(subDir)) draw_sprite_ui_uniform(THEME.folder_content, parent.context == self, _x + ui(16), _y + hg / 2 - 1, 1, COLORS.collection_folder_empty);
draw_sprite_ui_uniform(THEME.folder_content, parent.context == self, _x + ui(16), _y + hg / 2 - 1, 1, COLORS.collection_folder_empty); else draw_sprite_ui_uniform(THEME.folder_content, open, _x + ui(16), _y + hg / 2 - 1, 1, COLORS.collection_folder_nonempty);
else
draw_sprite_ui_uniform(THEME.folder_content, open, _x + ui(16), _y + hg / 2 - 1, 1, COLORS.collection_folder_nonempty);
draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text_inner); draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text_inner);
draw_text(_x + ui(32), _y + hg / 2, name); draw_text(_x + ui(32), _y + hg / 2, name);

View file

@ -98,7 +98,7 @@ function loadFonts() {
return; return;
} }
var s = file_text_read_all(path); var s = file_read_all(path);
var fontDef = json_try_parse(s); var fontDef = json_try_parse(s);
f_h1 = _font_load_from_struct(fontDef, "h1", _f_h1); f_h1 = _font_load_from_struct(fontDef, "h1", _f_h1);

View file

@ -1,20 +1,28 @@
function json_encode_minify(map) { function json_encode_minify(map) {
gml_pragma("forceinline");
return json_minify(json_encode(map)); return json_minify(json_encode(map));
} }
function json_stringify_minify(map) { function json_stringify_minify(map) {
gml_pragma("forceinline");
return json_minify(json_stringify(map)); return json_minify(json_stringify(map));
} }
function json_load(path) { function json_load(path) {
gml_pragma("forceinline");
if(!file_exists(path)) return noone; if(!file_exists(path)) return noone;
var s = file_text_read_all(path); var s = file_read_all(path);
var js = json_decode(s); var js = json_decode(s);
return js; return js;
} }
function json_save(path, map) { function json_save(path, map) {
gml_pragma("forceinline");
var s = json_encode_minify(map); var s = json_encode_minify(map);
var f = file_text_open_write(path); var f = file_text_open_write(path);
@ -23,14 +31,18 @@ function json_save(path, map) {
} }
function json_load_struct(path) { function json_load_struct(path) {
gml_pragma("forceinline");
if(!file_exists(path)) return noone; if(!file_exists(path)) return noone;
var s = file_text_read_all(path); var s = file_read_all(path);
var js = json_try_parse(s); var js = json_try_parse(s);
return js; return js;
} }
function json_save_struct(path, struct, pretty = false) { function json_save_struct(path, struct, pretty = false) {
gml_pragma("forceinline");
var s; var s;
if(pretty) if(pretty)

View file

@ -80,7 +80,6 @@ function __LOAD_PATH(path, readonly = false, override = false) {
if(file_exists(temp_file_path)) file_delete(temp_file_path); if(file_exists(temp_file_path)) file_delete(temp_file_path);
file_copy(path, temp_file_path); file_copy(path, temp_file_path);
//ALWAYS_FULL = false;
PROJECT.readonly = readonly; PROJECT.readonly = readonly;
SET_PATH(PROJECT, path); SET_PATH(PROJECT, path);

View file

@ -40,33 +40,44 @@ function Node_VFX_Override(_x, _y, _group = noone) : Node(_x, _y, _group) constr
var _alp = getInputData(5); var _alp = getInputData(5);
var _srf = getInputData(6); var _srf = getInputData(6);
var nParts = array_create(array_length(parts));
var _a_pos = is_array(_pos);
var _a_sca = is_array(_sca);
var _a_rot = is_array(_rot);
var _a_col = is_array(_col);
var _a_alp = is_array(_alp);
var _a_srf = is_array(_srf);
var _l_pos = array_length(_pos);
var _l_sca = array_length(_sca);
var _l_rot = array_length(_rot);
var _l_col = array_length(_col);
var _l_alp = array_length(_alp);
var _l_srf = array_length(_srf);
for( var i = 0, n = array_length(parts); i < n; i++ ) { for( var i = 0, n = array_length(parts); i < n; i++ ) {
var part = parts[i]; var nPart = parts[i].clone();
if(is_array(_pos) && array_length(_pos) > i && is_array(_pos[i])) { if(_a_pos && _l_pos > i && is_array(_pos[i])) {
part.x = _pos[i][0]; nPart.x = _pos[i][0];
part.y = _pos[i][1]; nPart.y = _pos[i][1];
} }
if(is_array(_sca) && array_length(_sca) > i && is_array(_sca[i])) { if(_a_sca && _l_sca > i && is_array(_sca[i])) {
part.scx = _sca[i][0]; nPart.scx = _sca[i][0];
part.scy = _sca[i][1]; nPart.scy = _sca[i][1];
} }
if(is_array(_rot) && array_length(_rot) > i ) if(_a_rot && _l_rot > i) nPart.rot = array_safe_get(_rot, i);
part.rot = array_safe_get(_rot, i); if(_a_col && _l_col > i) nPart.blend = array_safe_get(_col, i);
if(_a_alp && _l_alp > i) nPart.alp = array_safe_get(_alp, i);
if(_a_srf && _l_srf > i) nPart.surf = array_safe_get(_srf, i);
if(is_array(_col) && array_length(_col) > i ) nParts[i] = nPart;
part.blend = array_safe_get(_col, i);
if(is_array(_alp) && array_length(_alp) > i )
part.alp = array_safe_get(_alp, i);
if(is_array(_srf) && array_length(_srf) > i )
part.surf = array_safe_get(_srf, i);
} }
outputs[| 0].setValue(parts); outputs[| 0].setValue(nParts);
} }
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {

View file

@ -5,6 +5,8 @@ function Node_Particle(_x, _y, _group = noone) : Node_VFX_Spawner_Base(_x, _y, _
onSurfaceSize = function() { return getInputData(input_len, DEF_SURF); }; onSurfaceSize = function() { return getInputData(input_len, DEF_SURF); };
inputs[| 3].setDisplay(VALUE_DISPLAY.area, { onSurfaceSize }); inputs[| 3].setDisplay(VALUE_DISPLAY.area, { onSurfaceSize });
inputs[| 22].setDisplay(VALUE_DISPLAY.enum_scroll, [ "Random", "Order", "Animation", "Array" ]);
inputs[| input_len + 0] = nodeValue("Output dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, DEF_SURF) inputs[| input_len + 0] = nodeValue("Output dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, DEF_SURF)
.setDisplay(VALUE_DISPLAY.vector); .setDisplay(VALUE_DISPLAY.vector);

View file

@ -73,7 +73,7 @@ function Node_Text_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) cons
case ".txt": case ".txt":
outputs[| 1].setValue(path); outputs[| 1].setValue(path);
content = file_text_read_all(path); content = file_read_all(path);
if(path_current == "") if(path_current == "")
first_update = true; first_update = true;

View file

@ -48,7 +48,7 @@ function __getGraphicList() {
INLINE INLINE
var path = _sprite_path("./graphics.json", "default"); var path = _sprite_path("./graphics.json", "default");
var s = file_text_read_all(path); var s = file_read_all(path);
return json_try_parse(s); return json_try_parse(s);
} }
@ -71,7 +71,7 @@ function loadGraphic(theme = "default") {
return; return;
} }
var s = file_text_read_all(path); var s = file_read_all(path);
var graphics = variable_struct_get_names(sprDef); var graphics = variable_struct_get_names(sprDef);
var sprStr = json_try_parse(s); var sprStr = json_try_parse(s);
var str; var str;

View file

@ -1,13 +1,15 @@
function file_text_read_all(path) { function file_read_all(path) {
gml_pragma("forceinline");
var f = file_text_open_read(path); var f = file_text_open_read(path);
var s = ""; var s = file_text_read_all(f);
while(!file_text_eof(f))
s += string(file_text_readln(f));
file_text_close(f); file_text_close(f);
return s; return s;
} }
function file_text_read_all_lines(path) { function file_text_read_all_lines(path) {
gml_pragma("forceinline");
var f = file_text_open_read(path); var f = file_text_open_read(path);
var s = []; var s = [];
while(!file_text_eof(f)) while(!file_text_eof(f))
@ -17,6 +19,8 @@ function file_text_read_all_lines(path) {
} }
function file_text_write_all(path, str) { function file_text_write_all(path, str) {
gml_pragma("forceinline");
if(file_exists(path)) file_delete(path); if(file_exists(path)) file_delete(path);
var f = file_text_open_write(path); var f = file_text_open_write(path);