diff --git a/scripts/gif_reader/gif_reader.gml b/scripts/gif_reader/gif_reader.gml index a633e13b0..fe28eb4b0 100644 --- a/scripts/gif_reader/gif_reader.gml +++ b/scripts/gif_reader/gif_reader.gml @@ -369,9 +369,9 @@ function gif_std_enum_getIndex() { return __enumIndex__; } blocks = []; 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"); + if (self.i.readByte() != 71) throw string("Gif loader: Invalid header"); + if (self.i.readByte() != 73) throw string("Gif loader: Invalid header"); + if (self.i.readByte() != 70) throw string("Gif loader: Invalid header"); var _gifVer = self.i.readString(3); var _version = format_gif_Version_GIF89a; diff --git a/scripts/node_image/node_image.gml b/scripts/node_image/node_image.gml index 6d187ee86..679b689b7 100644 --- a/scripts/node_image/node_image.gml +++ b/scripts/node_image/node_image.gml @@ -1,4 +1,4 @@ -function Node_create_Image(_x, _y, _group = noone) { +function Node_create_Image(_x, _y, _group = noone) { #region var path = ""; if(!LOADING && !APPENDING && !CLONING) { path = get_open_filename("image|*.png;*.jpg", ""); @@ -10,16 +10,16 @@ function Node_create_Image(_x, _y, _group = noone) { node.inputs[| 0].setValue(path); node.doUpdate(); return node; -} +} #endregion -function Node_create_Image_path(_x, _y, path) { +function Node_create_Image_path(_x, _y, path) { #region if(!file_exists_empty(path)) return noone; var node = new Node_Image(_x, _y, PANEL_GRAPH.getCurrentContext()); node.inputs[| 0].setValue(path); node.doUpdate(); return node; -} +} #endregion function Node_Image(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { name = "Image"; @@ -43,7 +43,7 @@ function Node_Image(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { first_update = false; - on_drop_file = function(path) { + on_drop_file = function(path) { #region inputs[| 0].setValue(path); if(updatePaths(path)) { @@ -52,9 +52,9 @@ function Node_Image(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { } return false; - } + } #endregion - function updatePaths(path) { + function updatePaths(path) { #region path = try_get_path(path); if(path == -1) return false; @@ -76,22 +76,27 @@ function Node_Image(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { first_update = true; path_current = path; + if(spr == -1) { + noti_warning($"Image node: File not a valid image."); + return false; + } + return true; } return false; - } + } #endregion insp1UpdateTooltip = __txt("Refresh"); insp1UpdateIcon = [ THEME.refresh, 1, COLORS._main_value_positive ]; - static onInspector1Update = function() { + static onInspector1Update = function() { #region var path = getInputData(0); if(path == "") return; updatePaths(path); update(); - } + } #endregion - static update = function(frame = CURRENT_FRAME) { + static update = function(frame = CURRENT_FRAME) { #region var path = getInputData(0); var pad = getInputData(1); if(path == "") return; @@ -131,5 +136,5 @@ function Node_Image(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { _splice.inputs[| 3].setValue([ amo, 1 ]); _splice.inspector1Update(); } - } + } #endregion } \ No newline at end of file diff --git a/scripts/node_image_animated/node_image_animated.gml b/scripts/node_image_animated/node_image_animated.gml index 85f00cd79..09bb3a213 100644 --- a/scripts/node_image_animated/node_image_animated.gml +++ b/scripts/node_image_animated/node_image_animated.gml @@ -123,7 +123,14 @@ function Node_Image_Animated(_x, _y, _group = noone) : Node(_x, _y, _group) cons case ".png" : case ".jpg" : case ".jpeg" : - array_push(spr, sprite_add(path, 1, false, false, 0, 0)); + var _spr = sprite_add(path, 1, false, false, 0, 0); + + if(_spr == -1) { + noti_warning($"Image node: File not a valid image."); + return false; + } + + array_push(spr, _spr); break; } } diff --git a/scripts/node_image_sequence/node_image_sequence.gml b/scripts/node_image_sequence/node_image_sequence.gml index 2c8f77c6b..2e9c49f53 100644 --- a/scripts/node_image_sequence/node_image_sequence.gml +++ b/scripts/node_image_sequence/node_image_sequence.gml @@ -1,4 +1,4 @@ -function Node_create_Image_Sequence(_x, _y, _group = noone) { +function Node_create_Image_Sequence(_x, _y, _group = noone) { #region var path = ""; if(!LOADING && !APPENDING && !CLONING) { path = get_open_filenames_compat("image|*.png;*.jpg", ""); @@ -11,14 +11,14 @@ function Node_create_Image_Sequence(_x, _y, _group = noone) { node.inputs[| 0].setValue(paths); node.doUpdate(); return node; -} +} #endregion -function Node_create_Image_Sequence_path(_x, _y, _path) { +function Node_create_Image_Sequence_path(_x, _y, _path) { #region var node = new Node_Image_Sequence(_x, _y, PANEL_GRAPH.getCurrentContext()); node.inputs[| 0].setValue(_path); node.doUpdate(); return node; -} +} #endregion enum CANVAS_SIZE { individual, @@ -63,7 +63,7 @@ function Node_Image_Sequence(_x, _y, _group = noone) : Node(_x, _y, _group) cons path_loaded = []; - on_drop_file = function(path) { + on_drop_file = function(path) { #region if(directory_exists(path)) { with(dialogCall(o_dialog_drag_folder, WIN_W / 2, WIN_H / 2)) { dir_paths = path; @@ -81,19 +81,19 @@ function Node_Image_Sequence(_x, _y, _group = noone) : Node(_x, _y, _group) cons } return false; - } + } #endregion insp1UpdateTooltip = __txt("Refresh"); insp1UpdateIcon = [ THEME.refresh, 1, COLORS._main_value_positive ]; - static onInspector1Update = function() { + static onInspector1Update = function() { #region var path = getInputData(0); if(path == "") return; updatePaths(path); update(); - } + } #endregion - function updatePaths(paths) { + function updatePaths(paths) { #region for(var i = 0; i < array_length(spr); i++) { if(spr[i] && sprite_exists(spr[i])) sprite_delete(spr[i]); @@ -113,7 +113,14 @@ function Node_Image_Sequence(_x, _y, _group = noone) : Node(_x, _y, _group) cons case ".png" : case ".jpg" : case ".jpeg" : - array_push(spr, sprite_add(path, 1, false, false, 0, 0)); + var _spr = sprite_add(path, 1, false, false, 0, 0); + + if(_spr == -1) { + noti_warning($"Image node: File not a valid image."); + return false; + } + + array_push(spr, _spr); break; } } @@ -121,9 +128,9 @@ function Node_Image_Sequence(_x, _y, _group = noone) : Node(_x, _y, _group) cons outputs[| 1].setValue(paths); return true; - } + } #endregion - static update = function(frame = CURRENT_FRAME) { + static update = function(frame = CURRENT_FRAME) { #region var path = getInputData(0); if(path == "") return; if(!is_array(path)) path = [ path ]; @@ -219,5 +226,5 @@ function Node_Image_Sequence(_x, _y, _group = noone) : Node(_x, _y, _group) cons } outputs[| 0].setValue(surfs); - } + } #endregion } \ No newline at end of file