- [Pack Sprite] Fix error when packing array containing invalid surfaces.

This commit is contained in:
Tanasart 2024-07-03 16:39:19 +07:00
parent 94853648c7
commit 6d352c7c71
2 changed files with 15 additions and 6 deletions

View File

@ -58,17 +58,21 @@ function Node_Pack_Sprites(_x, _y, _group = noone) : Node(_x, _y, _group) constr
if(!is_array(_inpt) || array_length(_inpt) == 0) return;
var _rects = [];
var _rects = [], _ind = 0;
for( var i = 0, n = array_length(_inpt); i < n; i++ ) {
var s = _inpt[i];
if(!is_surface(s)) continue;
_rects[i] = new SurfaceAtlas(s);
_rects[i].w = surface_get_width_safe(s) + _spac * 2;
_rects[i].h = surface_get_height_safe(s) + _spac * 2;
_rects[_ind] = new SurfaceAtlas(s);
_rects[_ind].w = surface_get_width_safe(s) + _spac * 2;
_rects[_ind].h = surface_get_height_safe(s) + _spac * 2;
_ind++;
}
array_resize(_rects, _ind);
var pack;
switch(_algo) {

View File

@ -1095,9 +1095,11 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
#region ++++++++++++ interaction ++++++++++++
if(mouse_on_graph && pHOVER) {
if(mouse_press(mb_left, _focus)) nodes_select_anchor = noone;
#region select
var _anc = nodes_select_anchor;
if(mouse_press(mb_left, _focus)) _anc = noone;
if(NODE_DROPPER_TARGET != noone && node_hovering) {
node_hovering.draw_droppable = true;
if(mouse_press(mb_left, NODE_DROPPER_TARGET_CAN)) {
@ -1160,13 +1162,16 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
if(!hover_selected)
nodes_selecting = [ node_hovering ];
nodes_select_anchor = nodes_select_anchor == node_hovering? noone : node_hovering;
if(array_length(nodes_selecting) > 1)
_anc = nodes_select_anchor == node_hovering? noone : node_hovering;
}
if(WIDGET_CURRENT) WIDGET_CURRENT.deactivate();
array_foreach(nodes_selecting, function(node) { bringNodeToFront(node); });
}
}
nodes_select_anchor = _anc;
#endregion
if(mouse_press(mb_right, _focus)) { #region