mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-11-14 06:23:55 +01:00
[ASE File read] Fix freeze when selecting a tag with linked frame outside the tag range.
This commit is contained in:
parent
dbc6a49e05
commit
933dab87ec
@ -50,7 +50,9 @@ function ase_cel(_layer, _data, _file) constructor {
|
|||||||
|
|
||||||
} else if(type == 1) {
|
} else if(type == 1) {
|
||||||
var frTarget = data[$ "Frame position"];
|
var frTarget = data[$ "Frame position"];
|
||||||
var cel = layerTarget.getCel(frTarget);
|
// print($"Get frame {frTarget}")
|
||||||
|
|
||||||
|
var cel = layerTarget.getCelRaw(frTarget);
|
||||||
if(!cel) return noone;
|
if(!cel) return noone;
|
||||||
return cel.getSurface();
|
return cel.getSurface();
|
||||||
|
|
||||||
@ -61,6 +63,19 @@ function ase_cel(_layer, _data, _file) constructor {
|
|||||||
|
|
||||||
return noone;
|
return noone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function toStr() {
|
||||||
|
return {
|
||||||
|
type: data[$ "Cel type"],
|
||||||
|
link: data[$ "Frame position"]
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function toString() {
|
||||||
|
var st = json_stringify(toStr());
|
||||||
|
|
||||||
|
return $"[ase cel] {st}";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function ase_layer(name, type = 0) constructor {
|
function ase_layer(name, type = 0) constructor {
|
||||||
@ -71,16 +86,27 @@ function ase_layer(name, type = 0) constructor {
|
|||||||
|
|
||||||
static setFrameCel = function(index, cel) { cels[index] = cel; }
|
static setFrameCel = function(index, cel) { cels[index] = cel; }
|
||||||
|
|
||||||
static getCel = function(index = CURRENT_FRAME) {
|
static getCelRaw = function(index = CURRENT_FRAME) {
|
||||||
var ind;
|
ind = safe_mod(index, array_length(cels));
|
||||||
|
return array_safe_get_fast(cels, ind);
|
||||||
|
}
|
||||||
|
|
||||||
|
static getCel = function(index = CURRENT_FRAME) {
|
||||||
|
if(tag == noone) return getCelRaw(index);
|
||||||
|
|
||||||
if(tag != noone) {
|
|
||||||
var st = tag[$ "Frame start"];
|
var st = tag[$ "Frame start"];
|
||||||
var ed = tag[$ "Frame end"];
|
var ed = tag[$ "Frame end"];
|
||||||
ind = st + safe_mod(index, ed - st + 1);
|
var ind = st + safe_mod(index, ed - st + 1);
|
||||||
} else
|
|
||||||
ind = safe_mod(index, array_length(cels));
|
|
||||||
|
|
||||||
return array_safe_get_fast(cels, ind);
|
return array_safe_get_fast(cels, ind);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function toString() {
|
||||||
|
var st = json_stringify({
|
||||||
|
type,
|
||||||
|
cels : array_map(cels, function(cel) /*=>*/ {return cel.toStr()}),
|
||||||
|
});
|
||||||
|
|
||||||
|
return $"[ase layer] {st}";
|
||||||
|
}
|
||||||
}
|
}
|
@ -107,6 +107,7 @@ function Node_ASE_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) const
|
|||||||
var _yy = by + ui(4) + i * hh;
|
var _yy = by + ui(4) + i * hh;
|
||||||
var tag = tags[i];
|
var tag = tags[i];
|
||||||
|
|
||||||
|
var _tagName = tag[$ "Name"];
|
||||||
var cc = tag[$ "Color"];
|
var cc = tag[$ "Color"];
|
||||||
var st = tag[$ "Frame start"];
|
var st = tag[$ "Frame start"];
|
||||||
var ed = tag[$ "Frame end"];
|
var ed = tag[$ "Frame end"];
|
||||||
@ -137,11 +138,8 @@ function Node_ASE_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) const
|
|||||||
if(_hover && point_in_rectangle(_m[0], _m[1], _x + 8, _yy, _x + _w - 8, _yy + hh)) {
|
if(_hover && point_in_rectangle(_m[0], _m[1], _x + 8, _yy, _x + _w - 8, _yy + hh)) {
|
||||||
draw_sprite_stretched_add(THEME.ui_panel, 0, _x + 8, _tgy, _w - 16, _tgh, c_white, 0.1);
|
draw_sprite_stretched_add(THEME.ui_panel, 0, _x + 8, _tgy, _w - 16, _tgh, c_white, 0.1);
|
||||||
|
|
||||||
if(mouse_press(mb_left, _focus)) {
|
if(mouse_press(mb_left, _focus))
|
||||||
var _currTag = getInputData(2);
|
inputs[2].setValue(current_tag == _tagName? "" : _tagName);
|
||||||
var _tagName = tag[$ "Name"];
|
|
||||||
inputs[2].setValue(_currTag == _tagName? "" : _tagName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
draw_set_text(f_p1, fa_left, fa_center, COLORS._main_text);
|
draw_set_text(f_p1, fa_left, fa_center, COLORS._main_text);
|
||||||
@ -370,14 +368,15 @@ function Node_ASE_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) const
|
|||||||
blend_temp_surface = temp_surface[2];
|
blend_temp_surface = temp_surface[2];
|
||||||
|
|
||||||
for( var i = 0, n = array_length(layers); i < n; i++ ) {
|
for( var i = 0, n = array_length(layers); i < n; i++ ) {
|
||||||
|
// print($"{i}: {layers[i]}");
|
||||||
|
|
||||||
layers[i].tag = tag;
|
layers[i].tag = tag;
|
||||||
var cel = layers[i].getCel(CURRENT_FRAME - _tag_delay);
|
var cel = layers[i].getCel(CURRENT_FRAME - _tag_delay);
|
||||||
if(!cel) continue;
|
if(!cel) continue;
|
||||||
if(!array_safe_get_fast(vis, i, true)) continue;
|
if(!array_safe_get_fast(vis, i, true)) continue;
|
||||||
|
|
||||||
var _inSurf = cel.getSurface();
|
var _inSurf = cel.getSurface();
|
||||||
if(!is_surface(_inSurf))
|
if(!is_surface(_inSurf)) continue;
|
||||||
continue;
|
|
||||||
|
|
||||||
var xx = cel.data[$ "X"];
|
var xx = cel.data[$ "X"];
|
||||||
var yy = cel.data[$ "Y"];
|
var yy = cel.data[$ "Y"];
|
||||||
|
Loading…
Reference in New Issue
Block a user