From 2f8f36c4aee5c364c57b4950101f33c59fc75035 Mon Sep 17 00:00:00 2001 From: Tanasart Date: Sat, 18 Nov 2023 09:47:11 +0700 Subject: [PATCH] - Reduce the amount of data unpacking on start. --- PixelComposer.resource_order | 1 + PixelComposer.yyp | 1 + objects/o_dialog_preset/Create_0.gml | 3 +- objects/o_main/Other_2.gml | 9 +- objects/o_main/Step_0.gml | 2 +- objects/o_main/Step_1.gml | 3 +- scripts/__initAddon/__initAddon.gml | 17 +- scripts/__node_custom/__node_custom.gml | 12 +- scripts/action_loader/action_loader.gml | 14 +- scripts/assets_data/assets_data.gml | 11 +- scripts/collection_data/collection_data.gml | 11 +- scripts/font_data/font_data.gml | 3 +- scripts/gameframe/gameframe.gml | 10 +- scripts/gif_reader/gif_reader.gml | 919 +++++++++--------- scripts/locale_data/locale_data.gml | 6 +- .../node_action_object/node_action_object.gml | 4 +- scripts/node_guide/node_guide.gml | 5 +- scripts/node_image_gif/node_image_gif.gml | 21 +- scripts/node_pc_balls/node_pc_balls.gml | 84 +- scripts/node_value/node_value.gml | 2 +- scripts/panel_function/panel_function.gml | 10 +- .../panel_node_data_gen.gml | 3 +- scripts/preferences/preferences.gml | 2 +- scripts/preset_data/preset_data.gml | 18 +- scripts/sprite_loader/sprite_loader.gml | 41 +- .../surface_functions/surface_functions.gml | 8 +- scripts/version_checker/version_checker.gml | 9 + scripts/version_checker/version_checker.yy | 11 + 28 files changed, 588 insertions(+), 652 deletions(-) create mode 100644 scripts/version_checker/version_checker.gml create mode 100644 scripts/version_checker/version_checker.yy diff --git a/PixelComposer.resource_order b/PixelComposer.resource_order index f3633fe18..c6ea3cc8d 100644 --- a/PixelComposer.resource_order +++ b/PixelComposer.resource_order @@ -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",}, diff --git a/PixelComposer.yyp b/PixelComposer.yyp index df6ddc0f6..4c8b5c853 100644 --- a/PixelComposer.yyp +++ b/PixelComposer.yyp @@ -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",},}, diff --git a/objects/o_dialog_preset/Create_0.gml b/objects/o_dialog_preset/Create_0.gml index e6bf6f124..26a161635 100644 --- a/objects/o_dialog_preset/Create_0.gml +++ b/objects/o_dialog_preset/Create_0.gml @@ -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); diff --git a/objects/o_main/Other_2.gml b/objects/o_main/Other_2.gml index 9f51964ee..63bed6964 100644 --- a/objects/o_main/Other_2.gml +++ b/objects/o_main/Other_2.gml @@ -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")) diff --git a/objects/o_main/Step_0.gml b/objects/o_main/Step_0.gml index 1bb39d885..730f210d8 100644 --- a/objects/o_main/Step_0.gml +++ b/objects/o_main/Step_0.gml @@ -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]; diff --git a/objects/o_main/Step_1.gml b/objects/o_main/Step_1.gml index 4b025df56..5f56f173a 100644 --- a/objects/o_main/Step_1.gml +++ b/objects/o_main/Step_1.gml @@ -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) + "-" + diff --git a/scripts/__initAddon/__initAddon.gml b/scripts/__initAddon/__initAddon.gml index b9303cda6..3da9ffcf1 100644 --- a/scripts/__initAddon/__initAddon.gml +++ b/scripts/__initAddon/__initAddon.gml @@ -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); diff --git a/scripts/__node_custom/__node_custom.gml b/scripts/__node_custom/__node_custom.gml index e91355c4c..ae4bddd0a 100644 --- a/scripts/__node_custom/__node_custom.gml +++ b/scripts/__node_custom/__node_custom.gml @@ -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); diff --git a/scripts/action_loader/action_loader.gml b/scripts/action_loader/action_loader.gml index c58541617..6b7ba7593 100644 --- a/scripts/action_loader/action_loader.gml +++ b/scripts/action_loader/action_loader.gml @@ -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 \ No newline at end of file diff --git a/scripts/assets_data/assets_data.gml b/scripts/assets_data/assets_data.gml index ed3e49617..877bc6a3c 100644 --- a/scripts/assets_data/assets_data.gml +++ b/scripts/assets_data/assets_data.gml @@ -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"]); diff --git a/scripts/collection_data/collection_data.gml b/scripts/collection_data/collection_data.gml index 3c429ddbc..042224a33 100644 --- a/scripts/collection_data/collection_data.gml +++ b/scripts/collection_data/collection_data.gml @@ -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(); } diff --git a/scripts/font_data/font_data.gml b/scripts/font_data/font_data.gml index 5f2b616f7..65750b1e9 100644 --- a/scripts/font_data/font_data.gml +++ b/scripts/font_data/font_data.gml @@ -1,5 +1,4 @@ function __initFontFolder() { var root = DIRECTORY + "Fonts"; - if(!directory_exists(root)) - directory_create(root); + directory_verify(root); } \ No newline at end of file diff --git a/scripts/gameframe/gameframe.gml b/scripts/gameframe/gameframe.gml index 5f8b1e97f..074ab17ae 100644 --- a/scripts/gameframe/gameframe.gml +++ b/scripts/gameframe/gameframe.gml @@ -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); diff --git a/scripts/gif_reader/gif_reader.gml b/scripts/gif_reader/gif_reader.gml index 0bc7235f6..a633e13b0 100644 --- a/scripts/gif_reader/gif_reader.gml +++ b/scripts/gif_reader/gif_reader.gml @@ -20,186 +20,210 @@ mt_haxe_io_BytesOutput.superClass = mt_haxe_io_Output; #endregion -function gif_std_enum_toString() { - return gif_std_Std_stringify(self); -} -function gif_std_enum_getIndex() { - return __enumIndex__; -} +function gif_std_enum_toString() { return gif_std_Std_stringify(self); } +function gif_std_enum_getIndex() { return __enumIndex__; } #region Gif - function Gif() constructor { + function Gif() constructor { #region static frames = undefined; - static width = undefined; + static width = undefined; static height = undefined; - static loops = undefined; - static destroy = function() { - var __g = 0; + static loops = undefined; + static destroy = function() { #region + var __g = 0; var __g1 = self.frames; - var len = array_length(__g1); + var len = array_length(__g1); while (__g < len) { var _frame = __g1[__g]; __g++; _frame.destroy(); } - } + } #endregion reader_data = undefined; - static readBegin = function(_gif_buffer) { + static readBegin = function(_gif_buffer) { #region var _n = buffer_get_size(_gif_buffer); var _bytes = new gif_std_haxe_io_Bytes(array_create(_n, 0)); - var _i = 0; - for (var __g1 = _n; _i < __g1; _i++) { + + for (var _i = 0; _i < _n; _i++) { var _v = buffer_peek(_gif_buffer, _i, buffer_u8); _bytes.b[@_i] = (_v & 255); } - var _input = new haxe_io_BytesInput(_bytes, 0, _n); + + var _input = new haxe_io_BytesInput(_bytes, 0, _n); reader_data = new GifReader(_input); reader_data.readBegin(); - } + } #endregion - static reading = function() { + static reading = function() { #region var res = reader_data.reading(self); if(res) readComplete(); return res; - } + } #endregion - static readComplete = function() { - width = reader_data.logicalScreenDescriptor.width; + static readComplete = function() { #region + width = reader_data.logicalScreenDescriptor.width; height = reader_data.logicalScreenDescriptor.height; + var _gce = undefined; var _globalColorTable = undefined; + if (reader_data.globalColorTable != undefined) _globalColorTable = _Gif_GifTools_colorTableToVector(reader_data.globalColorTable, reader_data.logicalScreenDescriptor.globalColorTableSize); - var __break = false; - var __g = 0; + + var __g = 0; var __g1 = reader_data.blocks; + var __break = false; + while (__g < array_length(__g1)) { var _block = __g1[__g]; __g++; - switch (_block.__enumIndex__/* format_gif_Block */) { - case 0/* BFrame */: - var _f = _block.frame; + + switch (_block.__enumIndex__) { // format_gif_Block + case 0 : // BFrame + var _f = _block.frame; var _gf = new GifFrame(); var _transparentIndex = -1; + if (_gce != undefined) { _gf.delay = _gce.delay; if (_gce.hasTransparentColor) _transparentIndex = _gce.transparentIndex; - switch (_gce.disposalMethod.__enumIndex__/* format_gif_DisposalMethod */) { + switch (_gce.disposalMethod.__enumIndex__) { // format_gif_DisposalMethod case 2/* FILL_BACKGROUND */: _gf.disposalMethod = 1; break; case 3/* RENDER_PREVIOUS */: _gf.disposalMethod = 2; break; } } + _gf.x = _f.x; _gf.y = _f.y; - _gf.width = _f.width; + _gf.width = _f.width; _gf.height = _f.height; + var _colorTable = _globalColorTable; if (_f.colorTable != undefined) _colorTable = _Gif_GifTools_colorTableToVector(_f.colorTable, _f.localColorTableSize); + var _buf = buffer_create(_f.width * _f.height * 4, buffer_fixed, 1); var _i = 0; for (var __g3 = array_length(_f.pixels.b); _i < __g3; _i++) { var _col = _f.pixels.b[_i]; if (_col == _transparentIndex) buffer_write(_buf, buffer_s32, 0); else buffer_write(_buf, buffer_s32, _colorTable[_col]); } + _gf.buffer = _buf; var _sf = surface_create_valid(_f.width, _f.height); - gif_std_gml_io__Buffer_BufferImpl_setSurface(_buf, _sf, 0); + buffer_set_surface(_buf, _sf, 0); _gf.surface = _sf; _gce = undefined; - gif_std_gml_internal_ArrayImpl_push(self.frames, _gf); + + array_push(self.frames, _gf); break; - case 1/* BExtension */: + + case 1 : // BExtension var __g4 = _block.extension; - switch (__g4.__enumIndex__/* format_gif_Extension */) { - case 3/* EApplicationExtension */: + + switch (__g4.__enumIndex__) { // format_gif_Extension + case 3 : // EApplicationExtension var __g5 = __g4.ext; - if (__g5.__enumIndex__/* format_gif_ApplicationExtension */ == 0/* AENetscapeLooping */) { + if (__g5.__enumIndex__ /* format_gif_ApplicationExtension */ == 0 /* AENetscapeLooping */) { var _n = __g5.loops; self.loops = _n; } break; - case 0/* EGraphicControl */: _gce = __g4.gce; break; + case 0 : // EGraphicControl + _gce = __g4.gce; + break; } break; - case 2/* BEOF */: __break = true; break; + case 2 : // BEOF + __break = true; + break; } if (__break) break; } - } + } #endregion self.loops = -1; self.height = 0; self.width = 0; self.frames = []; static __class__ = mt_Gif; - } + } #endregion + mt_Gif.i_constructor = Gif; - function sprite_add_gif(_path, _return_func, _error_message = "") { + function sprite_add_gif(_path, _return_func, _error_message = "") { #region if (false) throw _error_message; var _buf = buffer_load(_path); var _gif = new Gif(); _gif.readBegin(_buf); ds_list_add(GIF_READER, [_gif, _buf, _return_func] ); - } + } #endregion - function __gif_sprite_builder(_gif) constructor { + function __gif_sprite_builder(_gif) constructor { #region gif = _gif; _sf = surface_create_valid(gif.width, gif.height); - //show_debug_message("gif creation: width = " + string(_gif.width)); + //show_debug_message($"gif creation: {gif.width}, {gif.height}"); + _restoreBuf = -1; - _spr = -1; - spr_size = 0; - _white32 = Gif_white32; + _spr = -1; + spr_size = 0; + _white32 = Gif_white32; + if (_white32 == -1) { var _ws = surface_create_valid(32, 32); + surface_set_target(_ws); - draw_clear(16777215); + draw_clear(c_white); surface_reset_target(); + _white32 = sprite_create_from_surface(_ws, 0, 0, surface_get_width_safe(_ws), surface_get_height_safe(_ws), false, false, 0, 0); surface_free(_ws); + Gif_white32 = _white32; } + __color = draw_get_color(); __alpha = draw_get_alpha(); - draw_set_color(16777215); + draw_set_color(c_white); draw_set_alpha(1); - _firstDelay = 0; - __g = 0; - __g1 = gif.frames; - amo = array_length(__g1); - static building = function() { + _firstDelay = 0; + __g = 0; + __g1 = gif.frames; + amo = array_length(__g1); + + static building = function() { #region var _frame = __g1[__g++]; + if (_frame.disposalMethod == 2) { if (_restoreBuf == -1) _restoreBuf = buffer_create(gif.width * gif.height * 4, buffer_fixed, 1); - gif_std_gml_io__Buffer_BufferImpl_getSurface(_restoreBuf, _sf, 0); + buffer_get_surface(_restoreBuf, _sf, 0); } surface_copy(_sf, _frame.x, _frame.y, _frame.surface); - if (_spr == -1) { - _spr = sprite_create_from_surface(_sf, 0, 0, surface_get_width_safe(_sf), surface_get_height_safe(_sf), false, false, 0, 0); - } else { - //spr_size = sprite_get_width(_spr) * sprite_get_height(_spr) * sprite_get_number(_spr); - //show_debug_message(string(spr_size)); - sprite_add_from_surface(_spr, _sf, 0, 0, surface_get_width_safe(_sf), surface_get_height_safe(_sf), false, false); - } - + var _sw = surface_get_width_safe(_sf); + var _sh = surface_get_height_safe(_sf); + if (_spr == -1) _spr = sprite_create_from_surface(_sf, 0, 0, _sw, _sh, false, false, 0, 0); + else sprite_add_from_surface(_spr, _sf, 0, 0, _sw, _sh, false, false); + var _fdelay = _frame.delay; if (_firstDelay <= 0 && _fdelay > 0) _firstDelay = _fdelay; + switch (_frame.disposalMethod) { - case 2: gif_std_gml_io__Buffer_BufferImpl_setSurface(_restoreBuf, _sf, 0); break; + case 2: + buffer_set_surface(_restoreBuf, _sf, 0); + break; case 1: surface_set_target(_sf); - var _mode = bm_subtract; - gpu_set_blendmode(_mode); - draw_sprite_stretched(_white32, 0, _frame.x, _frame.y, _frame.width, _frame.height); - var _mode1 = bm_normal; - gpu_set_blendmode(_mode1); + var _mode = bm_subtract; + gpu_set_blendmode(_mode); + draw_sprite_stretched(_white32, 0, _frame.x, _frame.y, _frame.width, _frame.height); + + var _mode1 = bm_normal; + gpu_set_blendmode(_mode1); surface_reset_target(); break; } @@ -210,124 +234,132 @@ function gif_std_enum_getIndex() { } return false; - } + } #endregion - static buildComplete = function() { + static buildComplete = function() { #region if (_firstDelay > 0) sprite_set_speed(_spr, 100 / _firstDelay, spritespeed_framespersecond); + draw_set_color(__color); draw_set_alpha(__alpha); if (_restoreBuf != -1) buffer_delete(_restoreBuf); gif.destroy(); surface_free(_sf); - } - } + } #endregion + } #endregion - function __gif_create_sprite(_gif) { + function __gif_create_sprite(_gif) { #region var _sf = surface_create_valid(_gif.width, _gif.height); //show_debug_message("gif creation: width = " + string(_gif.width)); var _restoreBuf = -1; - var _spr = -1; - var spr_size = 0; - var _white32 = Gif_white32; + var _spr = -1; + var spr_size = 0; + var _white32 = Gif_white32; + if (_white32 == -1) { var _ws = surface_create_valid(32, 32); + surface_set_target(_ws); - draw_clear(16777215); + draw_clear(c_white); surface_reset_target(); + _white32 = sprite_create_from_surface(_ws, 0, 0, surface_get_width_safe(_ws), surface_get_height_safe(_ws), false, false, 0, 0); surface_free(_ws); Gif_white32 = _white32; } + var __color = draw_get_color(); var __alpha = draw_get_alpha(); - draw_set_color(16777215); + draw_set_color(c_white); draw_set_alpha(1); + var _firstDelay = 0; - var __g = 0; var __g1 = _gif.frames; - var amo = array_length(__g1); + var amo = array_length(__g1); + for( var __g = 0; __g < amo; __g++ ) { var _frame = __g1[__g]; if (_frame.disposalMethod == 2) { if (_restoreBuf == -1) _restoreBuf = buffer_create(_gif.width * _gif.height * 4, buffer_fixed, 1); - gif_std_gml_io__Buffer_BufferImpl_getSurface(_restoreBuf, _sf, 0); + buffer_get_surface(_restoreBuf, _sf, 0); } surface_copy(_sf, _frame.x, _frame.y, _frame.surface); if (_spr == -1) { _spr = sprite_create_from_surface(_sf, 0, 0, surface_get_width_safe(_sf), surface_get_height_safe(_sf), false, false, 0, 0); } else { - //spr_size = sprite_get_width(_spr) * sprite_get_height(_spr) * sprite_get_number(_spr); - //show_debug_message(string(spr_size)); + //show_debug_message(sprite_get_width(_spr) * sprite_get_height(_spr) * sprite_get_number(_spr)); sprite_add_from_surface(_spr, _sf, 0, 0, surface_get_width_safe(_sf), surface_get_height_safe(_sf), false, false); } - + var _fdelay = _frame.delay; if (_firstDelay <= 0 && _fdelay > 0) _firstDelay = _fdelay; + switch (_frame.disposalMethod) { - case 2: gif_std_gml_io__Buffer_BufferImpl_setSurface(_restoreBuf, _sf, 0); break; + case 2: + buffer_set_surface(_restoreBuf, _sf, 0); + break; case 1: surface_set_target(_sf); - var _mode = bm_subtract; - gpu_set_blendmode(_mode); - draw_sprite_stretched(_white32, 0, _frame.x, _frame.y, _frame.width, _frame.height); - var _mode1 = bm_normal; - gpu_set_blendmode(_mode1); + var _mode = bm_subtract; + gpu_set_blendmode(_mode); + draw_sprite_stretched(_white32, 0, _frame.x, _frame.y, _frame.width, _frame.height); + + var _mode1 = bm_normal; + gpu_set_blendmode(_mode1); surface_reset_target(); break; } } + if (_firstDelay > 0) sprite_set_speed(_spr, 100 / _firstDelay, spritespeed_framespersecond); + draw_set_color(__color); draw_set_alpha(__alpha); + if (_restoreBuf != -1) buffer_delete(_restoreBuf); _gif.destroy(); surface_free(_sf); + return _spr; - } -#endregion + } #endregion -#region GifFrame - function GifFrame() constructor { - static delay = undefined; + function GifFrame() constructor { #region + static delay = undefined; static surface = undefined; - static buffer = undefined; - /* static */x = undefined; - /* static */y = undefined; - static width = undefined; - static height = undefined; + static buffer = undefined; + /* static */x = undefined; + /* static */y = undefined; + static width = undefined; + static height = undefined; static disposalMethod = undefined; + static destroy = function() { - if (surface_exists(self.surface)) { + if (surface_exists(self.surface)) surface_free(self.surface); - } buffer_delete(self.buffer); } + self.disposalMethod = 0; self.delay = 0; static __class__ = mt_GifFrame; - } - mt_GifFrame.i_constructor = GifFrame; -#endregion - -#region _Gif.GifTools - function _Gif_GifTools_colorTableToVector(_pal, _num) { + } mt_GifFrame.i_constructor = GifFrame; #endregion + + function _Gif_GifTools_colorTableToVector(_pal, _num) { #region var _r, _g, _b; - var _p = 0; - var _a = 255; - var _this1 = array_create(_num, undefined); - var _vec = _this1; - var _i = 0; - for (var __g1 = _num; _i < __g1; _i++) { + var _p = 0; + var _a = 255; + var _vec = array_create(_num, undefined); + + for (var _i = 0; _i < _num; _i++) { _r = _pal.b[_p]; _g = _pal.b[_p + 1]; _b = _pal.b[_p + 2]; var _val = ((((_a << 24) | (_b << 16)) | (_g << 8)) | _r); - _vec[@_i] = _val; + _vec[@ _i] = _val; _p += 3; } return _vec; - } + } #endregion #endregion #region GifReader @@ -336,28 +368,31 @@ function gif_std_enum_getIndex() { block_index = 0; blocks = []; - static readBegin = function() { - var _b = 71; - if (self.i.readByte() != _b) throw string("Invalid header"); - var _b = 73; - if (self.i.readByte() != _b) throw string("Invalid header"); - var _b = 70; - if (self.i.readByte() != _b) throw string("Invalid header"); - var _gifVer = self.i.readString(3); + static readBegin = function() { #region + if (self.i.readByte() != 71) throw string("Invalid header"); + if (self.i.readByte() != 73) throw string("Invalid header"); + if (self.i.readByte() != 70) throw string("Invalid header"); + + var _gifVer = self.i.readString(3); var _version = format_gif_Version_GIF89a; + switch (_gifVer) { case "87a": _version = format_gif_Version_GIF87a; break; case "89a": _version = format_gif_Version_GIF89a; break; default: _version = format_gif_Version_Unknown(_gifVer); } - var _width = self.i.readUInt16(); + + var _width = self.i.readUInt16(); var _height = self.i.readUInt16(); var _packedField = self.i.readByte(); - var _bgIndex = self.i.readByte(); + var _bgIndex = self.i.readByte(); + var _pixelAspectRatio = self.i.readByte(); - if (_pixelAspectRatio != 0) _pixelAspectRatio = (_pixelAspectRatio + 15) / 64; else _pixelAspectRatio = 1; + if (_pixelAspectRatio != 0) _pixelAspectRatio = (_pixelAspectRatio + 15) / 64; + else _pixelAspectRatio = 1; + var _lsd = { - width: _width, + width: _width, height: _height, hasGlobalColorTable: (_packedField & 128) == 128, colorResolution: ((((_packedField & 112) & $FFFFFFFF) >> 4)), @@ -366,22 +401,24 @@ function gif_std_enum_getIndex() { backgroundColorIndex: _bgIndex, pixelAspectRatio: _pixelAspectRatio } + var _gct = undefined; if (_lsd.hasGlobalColorTable) _gct = self.readColorTable(_lsd.globalColorTableSize); version = _version; logicalScreenDescriptor = _lsd; globalColorTable = _gct; - } - static reading = function(_gif) { + } #endregion + + static reading = function(_gif) { #region var _b = self.readBlock(); blocks[@ block_index++] = _b; if (_b == format_gif_Block_BEOF) return true; return false; - } + } #endregion - static readBlock = function() { + static readBlock = function() { #region var _blockID = self.i.readByte(); switch (_blockID) { case 44: return self.readImage(); @@ -389,19 +426,21 @@ function gif_std_enum_getIndex() { case 59: return format_gif_Block_BEOF; } return format_gif_Block_BEOF; - } - static readImage = function() { - var _x = self.i.readUInt16(); - var _y = self.i.readUInt16(); - var _width = self.i.readUInt16(); + } #endregion + + static readImage = function() { #region + var _x = self.i.readUInt16(); + var _y = self.i.readUInt16(); + var _width = self.i.readUInt16(); var _height = self.i.readUInt16(); var _packed = self.i.readByte(); + + var _sorted = (_packed & 32) == 32; + var _interlaced = (_packed & 64) == 64; var _localColorTable = (_packed & 128) == 128; - var _interlaced = (_packed & 64) == 64; - var _sorted = (_packed & 32) == 32; var _localColorTableSize = (2 << (_packed & 7)); - var _lct = undefined; - if (_localColorTable) _lct = self.readColorTable(_localColorTableSize); + var _lct = _localColorTable? self.readColorTable(_localColorTableSize) : undefined; + return format_gif_Block_BFrame({ x: _x, y: _y, @@ -414,31 +453,33 @@ function gif_std_enum_getIndex() { pixels: self.readPixels(_width, _height, _interlaced), colorTable: _lct }); - } - static readPixels = function(_width, _height, _interlaced) { - var _input = self.i; - var _pixelsCount = _width * _height; - var _pixels = new gif_std_haxe_io_Bytes(array_create(_pixelsCount, 0)); - var _minCodeSize = _input.readByte(); - var _blockSize = _input.readByte() - 1; - var _bits = _input.readByte(); - var _bitsCount = 8; - var _clearCode = (1 << _minCodeSize); - var _eoiCode = _clearCode + 1; - var _codeSize = _minCodeSize + 1; + } #endregion + + static readPixels = function(_width, _height, _interlaced) { #region + var _input = self.i; + var _pixelsCount = _width * _height; + var _pixels = new gif_std_haxe_io_Bytes(array_create(_pixelsCount, 0)); + var _minCodeSize = _input.readByte(); + var _blockSize = _input.readByte() - 1; + var _bits = _input.readByte(); + var _bitsCount = 8; + var _clearCode = (1 << _minCodeSize); + var _eoiCode = _clearCode + 1; + var _codeSize = _minCodeSize + 1; var _codeSizeLimit = (1 << _codeSize); - var _codeMask = _codeSizeLimit - 1; - var _baseDict = []; - var _i = 0; - for (var __g1 = _clearCode; _i < __g1; _i++) { + var _codeMask = _codeSizeLimit - 1; + var _baseDict = []; + + for (var _i = 0; _i < _clearCode; _i++) _baseDict[@_i] = [_i]; - } - var _dict = []; + + var _dict = []; var _dictLen = _clearCode + 2; + var _code = 0; + var _i = 0; var _newRecord; - var _i = 0; - var _code = 0; var _last; + while (_i < _pixelsCount) { _last = _code; while (_bitsCount < _codeSize) { @@ -446,85 +487,103 @@ function gif_std_enum_getIndex() { _bits |= (_input.readByte() << _bitsCount); _bitsCount += 8; _blockSize--; - if (_blockSize == 0) _blockSize = _input.readByte(); + if (_blockSize == 0) + _blockSize = _input.readByte(); } + _code = (_bits & _codeMask); _bits = _bits >> _codeSize; _bitsCount -= _codeSize; if (_code == _clearCode) { - _dict = gif_std_gml_internal_ArrayImpl_copy(_baseDict); - _dictLen = _clearCode + 2; + _dict = gif_std_gml_internal_ArrayImpl_copy(_baseDict); + _dictLen = _clearCode + 2; _codeSize = _minCodeSize + 1; _codeSizeLimit = (1 << _codeSize); _codeMask = _codeSizeLimit - 1; continue; } + if (_code == _eoiCode) break; if (_code < _dictLen) { if (_last != _clearCode) { _newRecord = gif_std_gml_internal_ArrayImpl_copy(_dict[_last]); - gif_std_gml_internal_ArrayImpl_push(_newRecord, _dict[_code][0]); + array_push(_newRecord, _dict[_code][0]); _dict[@_dictLen++] = _newRecord; } } else { - if (_code != _dictLen) throw string("Invalid LZW code. Excepted: " + string(_dictLen) + ", got: " + string(_code)); + if (_code != _dictLen) throw string($"Invalid LZW code. Excepted: {_dictLen}, got: {_code}"); + _newRecord = gif_std_gml_internal_ArrayImpl_copy(_dict[_last]); - gif_std_gml_internal_ArrayImpl_push(_newRecord, _newRecord[0]); + array_push(_newRecord, _newRecord[0]); _dict[@_dictLen++] = _newRecord; } + _newRecord = _dict[_code]; + var __g = 0; while (__g < array_length(_newRecord)) { var _item = _newRecord[__g]; __g++; - _pixels.b[@_i++] = (_item & 255); + _pixels.b[@ _i++] = (_item & 255); } + if (_dictLen == _codeSizeLimit && _codeSize < 12) { _codeSize++; _codeSizeLimit = (1 << _codeSize); - _codeMask = _codeSizeLimit - 1; + _codeMask = _codeSizeLimit - 1; } } + while (_blockSize > 0) { _input.readByte(); _blockSize--; - if (_blockSize == 0) _blockSize = _input.readByte(); + if (_blockSize == 0) + _blockSize = _input.readByte(); } + while (_i < _pixelsCount) { _pixels.b[@_i++] = 0; } + if (_interlaced) { var _buffer1 = new gif_std_haxe_io_Bytes(array_create(_pixelsCount, 0)); - var _offset = self.deinterlace(_pixels, _buffer1, 8, 0, 0, _width, _height); + var _offset = self.deinterlace(_pixels, _buffer1, 8, 0, 0, _width, _height); _offset = self.deinterlace(_pixels, _buffer1, 8, 4, _offset, _width, _height); _offset = self.deinterlace(_pixels, _buffer1, 4, 2, _offset, _width, _height); + self.deinterlace(_pixels, _buffer1, 2, 1, _offset, _width, _height); _pixels = _buffer1; } + return _pixels; - } - static deinterlace = function(_input, _output, _step, _y, _offset, _width, _height) { + } #endregion + + static deinterlace = function(_input, _output, _step, _y, _offset, _width, _height) { #region while (_y < _height) { array_copy(_output.b, _y * _width, _input.b, _offset, _width); _offset += _width; - _y += _step; + _y += _step; } return _offset; - } - static readExtension = function() { + } #endregion + + static readExtension = function() { #region var _subId = self.i.readByte(); switch (_subId) { case 249: if (self.i.readByte() != 4) throw string("Incorrect Graphic Control Extension block size!"); + var _packed = self.i.readByte(); var _disposalMethod; + switch ((_packed & 28) >> 2) { - case 2: _disposalMethod = format_gif_DisposalMethod_FILL_BACKGROUND; break; - case 3: _disposalMethod = format_gif_DisposalMethod_RENDER_PREVIOUS; break; - case 1: _disposalMethod = format_gif_DisposalMethod_NO_ACTION; break; - case 0: _disposalMethod = format_gif_DisposalMethod_UNSPECIFIED; break; + case 2: _disposalMethod = format_gif_DisposalMethod_FILL_BACKGROUND; break; + case 3: _disposalMethod = format_gif_DisposalMethod_RENDER_PREVIOUS; break; + case 1: _disposalMethod = format_gif_DisposalMethod_NO_ACTION; break; + case 0: _disposalMethod = format_gif_DisposalMethod_UNSPECIFIED; break; default: _disposalMethod = format_gif_DisposalMethod_UNDEFINED(((_packed & 28) >> 2)); } + var _delay = self.i.readUInt16(); var _b = format_gif_Block_BExtension(format_gif_Extension_EGraphicControl({ disposalMethod: _disposalMethod, @@ -533,28 +592,34 @@ function gif_std_enum_getIndex() { delay: _delay, transparentIndex: self.i.readByte() })); + self.i.readByte(); return _b; + case 1: if (self.i.readByte() != 12) throw string("Incorrect size of Plain Text Extension introducer block."); - var _textGridX = self.i.readUInt16(); - var _textGridY = self.i.readUInt16(); - var _textGridWidth = self.i.readUInt16(); + + var _textGridX = self.i.readUInt16(); + var _textGridY = self.i.readUInt16(); + var _textGridWidth = self.i.readUInt16(); var _textGridHeight = self.i.readUInt16(); - var _charCellWidth = self.i.readByte(); + var _charCellWidth = self.i.readByte(); var _charCellHeight = self.i.readByte(); var _textForegroundColorIndex = self.i.readByte(); var _textBackgroundColorIndex = self.i.readByte(); + var _buffer1 = new haxe_io_BytesOutput(); - var _bytes = new gif_std_haxe_io_Bytes(array_create(255, 0)); + var _bytes = new gif_std_haxe_io_Bytes(array_create(255, 0)); + for (var _len = self.i.readByte(); _len != 0; _len = self.i.readByte()) { self.i.readBytes(_bytes, 0, _len); _buffer1.writeBytes(_bytes, 0, _len); } + _buffer1.flush(); _bytes = new gif_std_haxe_io_Bytes(_buffer1.data); _buffer1.close(); - var __this = _bytes; + return format_gif_Block_BExtension(format_gif_Extension_EText({ textGridX: _textGridX, textGridY: _textGridY, @@ -564,64 +629,83 @@ function gif_std_enum_getIndex() { charCellHeight: _charCellHeight, textForegroundColorIndex: _textForegroundColorIndex, textBackgroundColorIndex: _textBackgroundColorIndex, - text: haxe_io__Bytes_BytesImpl_getString(__this.b, 0, array_length(__this.b)) + text: haxe_io__Bytes_BytesImpl_getString(_bytes.b, 0, array_length(_bytes.b)) })); + case 254: var _buffer1 = new haxe_io_BytesOutput(); - var _bytes = new gif_std_haxe_io_Bytes(array_create(255, 0)); + var _bytes = new gif_std_haxe_io_Bytes(array_create(255, 0)); + for (var _len = self.i.readByte(); _len != 0; _len = self.i.readByte()) { self.i.readBytes(_bytes, 0, _len); _buffer1.writeBytes(_bytes, 0, _len); } + _buffer1.flush(); _bytes = new gif_std_haxe_io_Bytes(_buffer1.data); _buffer1.close(); - var __this = _bytes; - return format_gif_Block_BExtension(format_gif_Extension_EComment(haxe_io__Bytes_BytesImpl_getString(__this.b, 0, array_length(__this.b)))); - case 255: return self.readApplicationExtension(); + + return format_gif_Block_BExtension(format_gif_Extension_EComment(haxe_io__Bytes_BytesImpl_getString(_bytes.b, 0, array_length(_bytes.b)))); + + case 255: + return self.readApplicationExtension(); + default: var _buffer1 = new haxe_io_BytesOutput(); - var _bytes = new gif_std_haxe_io_Bytes(array_create(255, 0)); + var _bytes = new gif_std_haxe_io_Bytes(array_create(255, 0)); + for (var _len = self.i.readByte(); _len != 0; _len = self.i.readByte()) { self.i.readBytes(_bytes, 0, _len); _buffer1.writeBytes(_bytes, 0, _len); } + _buffer1.flush(); _bytes = new gif_std_haxe_io_Bytes(_buffer1.data); _buffer1.close(); return format_gif_Block_BExtension(format_gif_Extension_EUnknown(_subId, _bytes)); } - } - static readApplicationExtension = function() { + } #endregion + + static readApplicationExtension = function() { #region if (self.i.readByte() != 11) throw string("Incorrect size of Application Extension introducer block."); - var _name = self.i.readString(8); + + var _name = self.i.readString(8); var _version = self.i.readString(3); var _buffer1 = new haxe_io_BytesOutput(); - var _bytes = new gif_std_haxe_io_Bytes(array_create(255, 0)); + var _bytes = new gif_std_haxe_io_Bytes(array_create(255, 0)); + for (var _len = self.i.readByte(); _len != 0; _len = self.i.readByte()) { self.i.readBytes(_bytes, 0, _len); _buffer1.writeBytes(_bytes, 0, _len); } + _buffer1.flush(); _bytes = new gif_std_haxe_io_Bytes(_buffer1.data); _buffer1.close(); - var _data = _bytes; - if (_name == "NETSCAPE" && _version == "2.0" && _data.b[0] == 1) return format_gif_Block_BExtension(format_gif_Extension_EApplicationExtension(format_gif_ApplicationExtension_AENetscapeLooping((_data.b[1] | (_data.b[2] << 8))))); - return format_gif_Block_BExtension(format_gif_Extension_EApplicationExtension(format_gif_ApplicationExtension_AEUnknown(_name, _version, _data))); - } - static readColorTable = function(_size) { + + if (_name == "NETSCAPE" && _version == "2.0" && _bytes.b[0] == 1) + return format_gif_Block_BExtension(format_gif_Extension_EApplicationExtension(format_gif_ApplicationExtension_AENetscapeLooping((_bytes.b[1] | (_bytes.b[2] << 8))))); + return format_gif_Block_BExtension(format_gif_Extension_EApplicationExtension(format_gif_ApplicationExtension_AEUnknown(_name, _version, _bytes))); + } #endregion + + static readColorTable = function(_size) { #region _size *= 3; var _output = new gif_std_haxe_io_Bytes(array_create(_size, 0)); + for (var _c = 0; _c < _size; _c += 3) { var _v = self.i.readByte(); _output.b[@_c] = (_v & 255); + var _v1 = self.i.readByte(); _output.b[@_c + 1] = (_v1 & 255); + var _v2 = self.i.readByte(); _output.b[@_c + 2] = (_v2 & 255); } + return _output; - } + } #endregion + self.i = _i; _i.bigEndian = false; static __class__ = mt_GifReader; @@ -632,39 +716,49 @@ function gif_std_enum_getIndex() { #region gif_std.Std function gif_std_Std_stringify(_value) { if (_value == undefined) return "null"; - if (is_string(_value)) return _value; + if (is_string(_value)) return _value; + var _n, _i, _s; + if (is_struct(_value)) { var _e = variable_struct_get(_value, "__enum__"); if (_e == undefined) return string(_value); + var _ects = _e._constructor; if (_ects != undefined) { _i = _value.__enumIndex__; - if (_i >= 0 && _i < array_length(_ects)) _s = _ects[_i]; else _s = "?"; + _s = (_i >= 0 && _i < array_length(_ects))? _ects[_i] : "?"; } else { _s = instanceof(_value); - if (string_copy(_s, 1, 3) == "mc_") _s = string_delete(_s, 1, 3); + if (string_copy(_s, 1, 3) == "mc_") + _s = string_delete(_s, 1, 3); + _n = string_length(_e.name); - if (string_copy(_s, 1, _n) == _e.name) _s = string_delete(_s, 1, _n + 1); + if (string_copy(_s, 1, _n) == _e.name) + _s = string_delete(_s, 1, _n + 1); } + _s += "("; + var _fields = _value.__enumParams__; _n = array_length(_fields); + for (_i = -1; ++_i < _n; _s += gif_std_Std_stringify(variable_struct_get(_value, _fields[_i]))) { if (_i > 0) _s += ", "; } + return _s + ")"; } + if (is_real(_value)) { _s = string(_value); + if (os_browser != -1) { _n = string_length(_s); _i = _n; while (_i > 0) { switch (string_ord_at(_s, _i)) { - case 48: - _i--; - continue; + case 48: _i--; continue; case 46: _i--; break; } break; @@ -674,308 +768,277 @@ function gif_std_enum_getIndex() { _i = _n; while (_i > 0) { switch (string_byte_at(_s, _i)) { - case 48: - _i--; - continue; + case 48: _i--; continue; case 46: _i--; break; } break; } } + return string_copy(_s, 1, _i); } + return string(_value); } #endregion -#region format.gif.Block - function mc_format_gif_Block() constructor { +#region format.gif + function mc_format_gif_Block() constructor { #region static getIndex = method(undefined, gif_std_enum_getIndex); static toString = method(undefined, gif_std_enum_toString); static __enum__ = mt_format_gif_Block; - } + } #endregion - function mc_format_gif_Block_BFrame() : mc_format_gif_Block() constructor { + function mc_format_gif_Block_BFrame() : mc_format_gif_Block() constructor { #region static __enumParams__ = ["frame"]; - static __enumIndex__ = 0; - } + static __enumIndex__ = 0; + } #endregion - function format_gif_Block_BFrame(_frame) { + function format_gif_Block_BFrame(_frame) { #region var this = new mc_format_gif_Block_BFrame(); this.frame = _frame; return this; - } + } #endregion - function mc_format_gif_Block_BExtension() : mc_format_gif_Block() constructor { + function mc_format_gif_Block_BExtension() : mc_format_gif_Block() constructor { #region static __enumParams__ = ["extension"]; - static __enumIndex__ = 1; - } + static __enumIndex__ = 1; + } #endregion - function format_gif_Block_BExtension(_extension) { + function format_gif_Block_BExtension(_extension) { #region var this = new mc_format_gif_Block_BExtension(); this.extension = _extension; return this; - } + } #endregion - function mc_format_gif_Block_BEOF() : mc_format_gif_Block() constructor { + function mc_format_gif_Block_BEOF() : mc_format_gif_Block() constructor { #region static __enumParams__ = []; - static __enumIndex__ = 2; - } + static __enumIndex__ = 2; + } #endregion + globalvar format_gif_Block_BEOF; format_gif_Block_BEOF = new mc_format_gif_Block_BEOF(); -#endregion -#region format.gif.Extension - function mc_format_gif_Extension() constructor { + function mc_format_gif_Extension() constructor { #region static getIndex = method(undefined, gif_std_enum_getIndex); static toString = method(undefined, gif_std_enum_toString); static __enum__ = mt_format_gif_Extension; - } + } #endregion - function mc_format_gif_Extension_EGraphicControl() : mc_format_gif_Extension() constructor { + function mc_format_gif_Extension_EGraphicControl() : mc_format_gif_Extension() constructor { #region static __enumParams__ = ["gce"]; - static __enumIndex__ = 0; - } + static __enumIndex__ = 0; + } #endregion - function format_gif_Extension_EGraphicControl(_gce) { + function format_gif_Extension_EGraphicControl(_gce) { #region var this = new mc_format_gif_Extension_EGraphicControl(); this.gce = _gce; return this; - } + } #endregion - function mc_format_gif_Extension_EComment() : mc_format_gif_Extension() constructor { + function mc_format_gif_Extension_EComment() : mc_format_gif_Extension() constructor { #region static __enumParams__ = ["text"]; - static __enumIndex__ = 1; - } + static __enumIndex__ = 1; + } #endregion - function format_gif_Extension_EComment(_text) { - var this = new mc_format_gif_Extension_EComment(); + function format_gif_Extension_EComment(_text) { #region + var this = new mc_format_gif_Extension_EComment(); this.text = _text; return this; - } + } #endregion - function mc_format_gif_Extension_EText() : mc_format_gif_Extension() constructor { + function mc_format_gif_Extension_EText() : mc_format_gif_Extension() constructor { #region static __enumParams__ = ["pte"]; - static __enumIndex__ = 2; - } + static __enumIndex__ = 2; + } #endregion - function format_gif_Extension_EText(_pte) { + function format_gif_Extension_EText(_pte) { #region var this = new mc_format_gif_Extension_EText(); this.pte = _pte; return this; - } + } #endregion - function mc_format_gif_Extension_EApplicationExtension() : mc_format_gif_Extension() constructor { + function mc_format_gif_Extension_EApplicationExtension() : mc_format_gif_Extension() constructor { #region static __enumParams__ = ["ext"]; - static __enumIndex__ = 3; - } + static __enumIndex__ = 3; + } #endregion - function format_gif_Extension_EApplicationExtension(_ext) { + function format_gif_Extension_EApplicationExtension(_ext) { #region var this = new mc_format_gif_Extension_EApplicationExtension(); this.ext = _ext; return this; - } + } #endregion - function mc_format_gif_Extension_EUnknown() : mc_format_gif_Extension() constructor { + function mc_format_gif_Extension_EUnknown() : mc_format_gif_Extension() constructor { #region static __enumParams__ = ["id", "data"]; - static __enumIndex__ = 4; - } + static __enumIndex__ = 4; + } #endregion - function format_gif_Extension_EUnknown(_id, _data) { - var this = new mc_format_gif_Extension_EUnknown(); - this.id = _id; + function format_gif_Extension_EUnknown(_id, _data) { #region + var this = new mc_format_gif_Extension_EUnknown(); + this.id = _id; this.data = _data; return this; - } -#endregion + } #endregion -#region format.gif.ApplicationExtension - function mc_format_gif_ApplicationExtension() constructor { + function mc_format_gif_ApplicationExtension() constructor { #region static getIndex = method(undefined, gif_std_enum_getIndex); static toString = method(undefined, gif_std_enum_toString); static __enum__ = mt_format_gif_ApplicationExtension; - } + } #endregion - function mc_format_gif_ApplicationExtension_AENetscapeLooping() : mc_format_gif_ApplicationExtension() constructor { + function mc_format_gif_ApplicationExtension_AENetscapeLooping() : mc_format_gif_ApplicationExtension() constructor { #region static __enumParams__ = ["loops"]; - static __enumIndex__ = 0; - } + static __enumIndex__ = 0; + } #endregion - function format_gif_ApplicationExtension_AENetscapeLooping(_loops) { - var this = new mc_format_gif_ApplicationExtension_AENetscapeLooping(); + function format_gif_ApplicationExtension_AENetscapeLooping(_loops) { #region + var this = new mc_format_gif_ApplicationExtension_AENetscapeLooping(); this.loops = _loops; return this; - } + } #endregion - function mc_format_gif_ApplicationExtension_AEUnknown() : mc_format_gif_ApplicationExtension() constructor { + function mc_format_gif_ApplicationExtension_AEUnknown() : mc_format_gif_ApplicationExtension() constructor { #region static __enumParams__ = ["name", "version", "data"]; - static __enumIndex__ = 1; - } + static __enumIndex__ = 1; + } #endregion - function format_gif_ApplicationExtension_AEUnknown(_name, _version, _data) { - var this = new mc_format_gif_ApplicationExtension_AEUnknown(); - this.name = _name; + function format_gif_ApplicationExtension_AEUnknown(_name, _version, _data) { #region + var this = new mc_format_gif_ApplicationExtension_AEUnknown(); + this.name = _name; this.version = _version; - this.data = _data; + this.data = _data; return this; - } -#endregion - -#region format.gif.Version - function mc_format_gif_Version() constructor { + } #endregion + + function mc_format_gif_Version() constructor { #region static getIndex = method(undefined, gif_std_enum_getIndex); static toString = method(undefined, gif_std_enum_toString); static __enum__ = mt_format_gif_Version; - } + } #endregion - function mc_format_gif_Version_GIF87a() : mc_format_gif_Version() constructor { + function mc_format_gif_Version_GIF87a() : mc_format_gif_Version() constructor { #region static __enumParams__ = []; - static __enumIndex__ = 0; - } + static __enumIndex__ = 0; + } #endregion + globalvar format_gif_Version_GIF87a; format_gif_Version_GIF87a = new mc_format_gif_Version_GIF87a(); - - function mc_format_gif_Version_GIF89a() : mc_format_gif_Version() constructor { + + function mc_format_gif_Version_GIF89a() : mc_format_gif_Version() constructor { #region static __enumParams__ = []; - static __enumIndex__ = 1; - } + static __enumIndex__ = 1; + } #endregion + globalvar format_gif_Version_GIF89a; format_gif_Version_GIF89a = new mc_format_gif_Version_GIF89a(); - function mc_format_gif_Version_Unknown() : mc_format_gif_Version() constructor { + function mc_format_gif_Version_Unknown() : mc_format_gif_Version() constructor { #region static __enumParams__ = ["version"]; - static __enumIndex__ = 2; - } + static __enumIndex__ = 2; + } #endregion - function format_gif_Version_Unknown(_version) { + function format_gif_Version_Unknown(_version) { #region var this = new mc_format_gif_Version_Unknown(); this.version = _version; return this; - } -#endregion - -#region format.gif.DisposalMethod - function mc_format_gif_DisposalMethod() constructor { + } #endregion + + function mc_format_gif_DisposalMethod() constructor { #region static getIndex = method(undefined, gif_std_enum_getIndex); static toString = method(undefined, gif_std_enum_toString); static __enum__ = mt_format_gif_DisposalMethod; - } + } #endregion - function mc_format_gif_DisposalMethod_UNSPECIFIED() : mc_format_gif_DisposalMethod() constructor { + function mc_format_gif_DisposalMethod_UNSPECIFIED() : mc_format_gif_DisposalMethod() constructor { #region static __enumParams__ = []; - static __enumIndex__ = 0; - } + static __enumIndex__ = 0; + } #endregion + globalvar format_gif_DisposalMethod_UNSPECIFIED; format_gif_DisposalMethod_UNSPECIFIED = new mc_format_gif_DisposalMethod_UNSPECIFIED(); - - function mc_format_gif_DisposalMethod_NO_ACTION() : mc_format_gif_DisposalMethod() constructor { + + function mc_format_gif_DisposalMethod_NO_ACTION() : mc_format_gif_DisposalMethod() constructor { #region static __enumParams__ = []; - static __enumIndex__ = 1; - } + static __enumIndex__ = 1; + } #endregion + globalvar format_gif_DisposalMethod_NO_ACTION; format_gif_DisposalMethod_NO_ACTION = new mc_format_gif_DisposalMethod_NO_ACTION(); - - function mc_format_gif_DisposalMethod_FILL_BACKGROUND() : mc_format_gif_DisposalMethod() constructor { + + function mc_format_gif_DisposalMethod_FILL_BACKGROUND() : mc_format_gif_DisposalMethod() constructor { #region static __enumParams__ = []; - static __enumIndex__ = 2; - } + static __enumIndex__ = 2; + } #endregion + globalvar format_gif_DisposalMethod_FILL_BACKGROUND; format_gif_DisposalMethod_FILL_BACKGROUND = new mc_format_gif_DisposalMethod_FILL_BACKGROUND(); - function mc_format_gif_DisposalMethod_RENDER_PREVIOUS() : mc_format_gif_DisposalMethod() constructor { + function mc_format_gif_DisposalMethod_RENDER_PREVIOUS() : mc_format_gif_DisposalMethod() constructor { #region static __enumParams__ = []; - static __enumIndex__ = 3; - } + static __enumIndex__ = 3; + } #endregion + globalvar format_gif_DisposalMethod_RENDER_PREVIOUS; format_gif_DisposalMethod_RENDER_PREVIOUS = new mc_format_gif_DisposalMethod_RENDER_PREVIOUS(); - function mc_format_gif_DisposalMethod_UNDEFINED() : mc_format_gif_DisposalMethod() constructor { + function mc_format_gif_DisposalMethod_UNDEFINED() : mc_format_gif_DisposalMethod() constructor { #region static __enumParams__ = ["index"]; - static __enumIndex__ = 4; - } + static __enumIndex__ = 4; + } #endregion - function format_gif_DisposalMethod_UNDEFINED(_index) { - var this = new mc_format_gif_DisposalMethod_UNDEFINED(); + function format_gif_DisposalMethod_UNDEFINED(_index) { #region + var this = new mc_format_gif_DisposalMethod_UNDEFINED(); this.index = _index; return this; - } + } #endregion + #endregion -#region gif_std.haxe.class - function gif_std_haxe_class(_id, _name) constructor { - static superClass = undefined; +#region gif.std + function gif_std_haxe_class(_id, _name) constructor { #region + static superClass = undefined; static i_constructor = undefined; - static marker = undefined; - static index = undefined; - static name = undefined; + static marker = undefined; + static index = undefined; + static name = undefined; + self.superClass = undefined; - self.marker = gif_std_haxe_type_markerValue; - self.index = _id; - self.name = _name; + self.marker = gif_std_haxe_type_markerValue; + self.index = _id; + self.name = _name; + static __class__ = "class"; - } - mt_gif_std_haxe_class.i_constructor = gif_std_haxe_class; -#endregion + } mt_gif_std_haxe_class.i_constructor = gif_std_haxe_class; #endregion -#region gif_std.haxe.enum - function gif_std_haxe_enum(_id, _name, _constructor) constructor { + function gif_std_haxe_enum(_id, _name, _constructor) constructor { #region static _constructor = undefined; - static marker = undefined; - static index = undefined; - static name = undefined; + static marker = undefined; + static index = undefined; + static name = undefined; + if (false) throw argument[2]; - self.marker = gif_std_haxe_type_markerValue; - self.index = _id; - self.name = _name; + + self.marker = gif_std_haxe_type_markerValue; + self.index = _id; + self.name = _name; self._constructor = _constructor; + static __class__ = "enum"; - } - mt_gif_std_haxe_enum.i_constructor = gif_std_haxe_enum; -#endregion + } mt_gif_std_haxe_enum.i_constructor = gif_std_haxe_enum; #endregion -#region gif_std.gml.internal.ArrayImpl - function gif_std_gml_internal_ArrayImpl_push(_arr, _val) { - var _i = array_length(_arr); - _arr[@_i] = _val; - return _i; - } - - function gif_std_gml_internal_ArrayImpl_copy(_arr) { - var _out; + function gif_std_gml_internal_ArrayImpl_copy(_arr) { #region + var _out = []; var _len = array_length(_arr); - if (_len > 0) { - _out = []; + + if (_len > 0) array_copy(_out, 0, _arr, 0, _len); - } else _out = []; + return _out; - } -#endregion + } #endregion -#region gif_std.gml.io._Buffer.BufferImpl - function gif_std_gml_io__Buffer_BufferImpl_bufferSurfaceFunctionsHave3args_init() { - var _rt = GM_runtime_version; - if (string_pos("2.3.0.", _rt) == 1) return false; - if (string_pos("23.1.1.", _rt) != 1) return true; - var _buildStr = string_delete(_rt, 1, string_length("23.1.1.")); - if (string_digits(_buildStr) != _buildStr) return true; - var _buildNum = real(_buildStr); - return _buildNum >= 186; - } - - function gif_std_gml_io__Buffer_BufferImpl_getSetSurface_init(_fn) { - var _ctx = { fn: _fn } - if (gif_std_gml_io__Buffer_BufferImpl_bufferSurfaceFunctionsHave3args) return method(_ctx, function(_buf, _surf, _offset) { - self.fn(_buf, _surf, _offset); - }); else return method(_ctx, function(_buf, _surf, _offset) { - self.fn(_buf, _surf, 0, _offset, 0); - }); - } -#endregion - -#region gif_std.haxe.io.Bytes - function gif_std_haxe_io_Bytes(_b) constructor { + function gif_std_haxe_io_Bytes(_b) constructor { #region static b = undefined; - self.b = _b; + self.b = _b; static __class__ = mt_gif_std_haxe_io_Bytes; - } - mt_gif_std_haxe_io_Bytes.i_constructor = gif_std_haxe_io_Bytes; + } mt_gif_std_haxe_io_Bytes.i_constructor = gif_std_haxe_io_Bytes; #endregion #endregion -#region haxe.io._Bytes.BytesImpl - function haxe_io__Bytes_BytesImpl_getString(_d, _pos, _len) { +#region haxe.io + function haxe_io__Bytes_BytesImpl_getString(_d, _pos, _len) { #region var _b = haxe_io__Bytes_BytesImpl_buffer; buffer_seek(_b, buffer_seek_start, 0); while (--_len >= 0) { @@ -984,16 +1047,14 @@ function gif_std_enum_getIndex() { buffer_write(_b, buffer_u8, 0); buffer_seek(_b, buffer_seek_start, 0); return buffer_read(_b, buffer_string); - } -#endregion + } #endregion -#region haxe.io.Input - function haxe_io_Input_new() { + function haxe_io_Input_new() { #region self.bigEndian = false; self.dataPos = 0; - } + } #endregion - function haxe_io_Input() constructor { + function haxe_io_Input() constructor { #region static data = undefined; static dataPos = undefined; static dataLen = undefined; @@ -1004,33 +1065,32 @@ function gif_std_enum_getIndex() { static readString = method(undefined, haxe_io_Input_readString); method(self, haxe_io_Input_new)(); static __class__ = mt_haxe_io_Input; - } - mt_haxe_io_Input.i_constructor = haxe_io_Input; + } mt_haxe_io_Input.i_constructor = haxe_io_Input; #endregion - function haxe_io_Input_readByte() { + function haxe_io_Input_readByte() { #region var _d = self.data; return _d[self.dataPos++]; - } + } #endregion - function haxe_io_Input_readUInt16() { + function haxe_io_Input_readUInt16() { #region var _d = self.data; var _p = self.dataPos; var _c1 = _d[_p++]; var _c2 = _d[_p++]; self.dataPos = _p; if (self.bigEndian) return ((_c1 << 8) | _c2); else return (_c1 | (_c2 << 8)); - } + } #endregion - function haxe_io_Input_readBytes(_to, _pos, _len) { + function haxe_io_Input_readBytes(_to, _pos, _len) { #region var _start = self.dataPos; var _avail = self.dataLen - _start; if (_len > _avail) _len = _avail; array_copy(_to.b, _pos, self.data, _start, _len); self.dataPos = _start + _len; return _len; - } + } #endregion - function haxe_io_Input_readString(_count) { + function haxe_io_Input_readString(_count) { #region var _pos = self.dataPos; var _data = self.data; var _maxLen = self.dataLen - _pos; @@ -1042,11 +1102,9 @@ function gif_std_enum_getIndex() { buffer_seek(_buf, buffer_seek_start, 0); self.dataPos = _pos; return buffer_read(_buf, buffer_string); - } -#endregion + } #endregion -#region haxe.io.BytesInput - function haxe_io_BytesInput(_sourceBytes, _sourcePos, _sourceLen) constructor { + function haxe_io_BytesInput(_sourceBytes, _sourcePos, _sourceLen) constructor { #region static data = undefined; static dataPos = undefined; static dataLen = undefined; @@ -1058,23 +1116,20 @@ function gif_std_enum_getIndex() { _sourcePos ??= 0; if (false) throw argument[2]; method(self, haxe_io_Input_new)(); - if (_sourceLen == undefined) _sourceLen = array_length(_sourceBytes.b) - _sourcePos; + _sourceLen ??= array_length(_sourceBytes.b) - _sourcePos; self.data = _sourceBytes.b; self.dataPos = _sourcePos; self.dataLen = _sourceLen; static __class__ = mt_haxe_io_BytesInput; - } - mt_haxe_io_BytesInput.i_constructor = haxe_io_BytesInput; -#endregion + } mt_haxe_io_BytesInput.i_constructor = haxe_io_BytesInput; #endregion -#region haxe.io.Output - function haxe_io_Output_new() { + function haxe_io_Output_new() { #region self.dataLen = 32; self.dataPos = 0; self.data = array_create(32); - } + } #endregion - function haxe_io_Output() constructor { + function haxe_io_Output() constructor { #region static data = undefined; static dataPos = undefined; static dataLen = undefined; @@ -1083,18 +1138,13 @@ function gif_std_enum_getIndex() { static writeBytes = method(undefined, haxe_io_Output_writeBytes); method(self, haxe_io_Output_new)(); static __class__ = mt_haxe_io_Output; - } - mt_haxe_io_Output.i_constructor = haxe_io_Output; + } mt_haxe_io_Output.i_constructor = haxe_io_Output; #endregion - function haxe_io_Output_flush() { - - } + function haxe_io_Output_flush() {} - function haxe_io_Output_close() { - - } + function haxe_io_Output_close() {} - function haxe_io_Output_writeBytes(_b, _pos, _len) { + function haxe_io_Output_writeBytes(_b, _pos, _len) { #region var _bd = _b.b; var _p0 = self.dataPos; var _p1 = _p0 + _len; @@ -1112,29 +1162,24 @@ function gif_std_enum_getIndex() { array_copy(_d, _p0, _bd, _pos, _len); self.dataPos = _p1; return _len; - } -#endregion + } #endregion -#region haxe.io.BytesOutput - function haxe_io_BytesOutput() constructor { - static data = undefined; - static dataPos = undefined; - static dataLen = undefined; - static flush = method(undefined, haxe_io_Output_flush); - static close = method(undefined, haxe_io_Output_close); + function haxe_io_BytesOutput() constructor { #region + static data = undefined; + static dataPos = undefined; + static dataLen = undefined; + static flush = method(undefined, haxe_io_Output_flush); + static close = method(undefined, haxe_io_Output_close); static writeBytes = method(undefined, haxe_io_Output_writeBytes); + method(self, haxe_io_Output_new)(); - static __class__ = mt_haxe_io_BytesOutput; - } - mt_haxe_io_BytesOutput.i_constructor = haxe_io_BytesOutput; + + static __class__ = mt_haxe_io_BytesOutput; + } mt_haxe_io_BytesOutput.i_constructor = haxe_io_BytesOutput; #endregion #endregion // Gif: globalvar Gif_white32; Gif_white32 = -1; -// gif_std.gml.io._Buffer.BufferImpl: -globalvar gif_std_gml_io__Buffer_BufferImpl_bufferSurfaceFunctionsHave3args; gif_std_gml_io__Buffer_BufferImpl_bufferSurfaceFunctionsHave3args = gif_std_gml_io__Buffer_BufferImpl_bufferSurfaceFunctionsHave3args_init(); -globalvar gif_std_gml_io__Buffer_BufferImpl_getSurface; gif_std_gml_io__Buffer_BufferImpl_getSurface = gif_std_gml_io__Buffer_BufferImpl_getSetSurface_init(method(undefined, buffer_get_surface)); -globalvar gif_std_gml_io__Buffer_BufferImpl_setSurface; gif_std_gml_io__Buffer_BufferImpl_setSurface = gif_std_gml_io__Buffer_BufferImpl_getSetSurface_init(method(undefined, buffer_set_surface)); // haxe.io._Bytes.BytesImpl: globalvar haxe_io__Bytes_BytesImpl_buffer; haxe_io__Bytes_BytesImpl_buffer = buffer_create(128, buffer_grow, 1); // haxe.io.Input: diff --git a/scripts/locale_data/locale_data.gml b/scripts/locale_data/locale_data.gml index 5fbdbf7b1..b579e93c2 100644 --- a/scripts/locale_data/locale_data.gml +++ b/scripts/locale_data/locale_data.gml @@ -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(); } diff --git a/scripts/node_action_object/node_action_object.gml b/scripts/node_action_object/node_action_object.gml index 4d59afacf..79d177b52 100644 --- a/scripts/node_action_object/node_action_object.gml +++ b/scripts/node_action_object/node_action_object.gml @@ -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); diff --git a/scripts/node_guide/node_guide.gml b/scripts/node_guide/node_guide.gml index be8a892e1..b8aefe1d6 100644 --- a/scripts/node_guide/node_guide.gml +++ b/scripts/node_guide/node_guide.gml @@ -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); diff --git a/scripts/node_image_gif/node_image_gif.gml b/scripts/node_image_gif/node_image_gif.gml index 5d7a78437..8a35670ac 100644 --- a/scripts/node_image_gif/node_image_gif.gml +++ b/scripts/node_image_gif/node_image_gif.gml @@ -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 } \ No newline at end of file diff --git a/scripts/node_pc_balls/node_pc_balls.gml b/scripts/node_pc_balls/node_pc_balls.gml index 9ebdc2084..30e3c7066 100644 --- a/scripts/node_pc_balls/node_pc_balls.gml +++ b/scripts/node_pc_balls/node_pc_balls.gml @@ -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; } diff --git a/scripts/node_value/node_value.gml b/scripts/node_value/node_value.gml index 6940e86e7..1cae2e947 100644 --- a/scripts/node_value/node_value.gml +++ b/scripts/node_value/node_value.gml @@ -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; diff --git a/scripts/panel_function/panel_function.gml b/scripts/panel_function/panel_function.gml index 5ce8bfebe..11c8a9687 100644 --- a/scripts/panel_function/panel_function.gml +++ b/scripts/panel_function/panel_function.gml @@ -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"; diff --git a/scripts/panel_node_data_gen/panel_node_data_gen.gml b/scripts/panel_node_data_gen/panel_node_data_gen.gml index 8d6b5db41..da6138274 100644 --- a/scripts/panel_node_data_gen/panel_node_data_gen.gml +++ b/scripts/panel_node_data_gen/panel_node_data_gen.gml @@ -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 = {}; diff --git a/scripts/preferences/preferences.gml b/scripts/preferences/preferences.gml index 415476fd5..73e2e3517 100644 --- a/scripts/preferences/preferences.gml +++ b/scripts/preferences/preferences.gml @@ -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); } diff --git a/scripts/preset_data/preset_data.gml b/scripts/preset_data/preset_data.gml index a14a1bfe0..d77131c39 100644 --- a/scripts/preset_data/preset_data.gml +++ b/scripts/preset_data/preset_data.gml @@ -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"]); diff --git a/scripts/sprite_loader/sprite_loader.gml b/scripts/sprite_loader/sprite_loader.gml index d05c4c0d0..db0bc0243 100644 --- a/scripts/sprite_loader/sprite_loader.gml +++ b/scripts/sprite_loader/sprite_loader.gml @@ -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])}]"); } -} \ No newline at end of file +} #endregion \ No newline at end of file diff --git a/scripts/surface_functions/surface_functions.gml b/scripts/surface_functions/surface_functions.gml index c9677db41..33422e9ec 100644 --- a/scripts/surface_functions/surface_functions.gml +++ b/scripts/surface_functions/surface_functions.gml @@ -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); } diff --git a/scripts/version_checker/version_checker.gml b/scripts/version_checker/version_checker.gml new file mode 100644 index 000000000..241846776 --- /dev/null +++ b/scripts/version_checker/version_checker.gml @@ -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; +} \ No newline at end of file diff --git a/scripts/version_checker/version_checker.yy b/scripts/version_checker/version_checker.yy new file mode 100644 index 000000000..cb6f91ccd --- /dev/null +++ b/scripts/version_checker/version_checker.yy @@ -0,0 +1,11 @@ +{ + "resourceType": "GMScript", + "resourceVersion": "1.0", + "name": "version_checker", + "isCompatibility": false, + "isDnD": false, + "parent": { + "name": "files", + "path": "folders/functions/files.yy", + }, +} \ No newline at end of file