2023-02-28 09:43:01 +01:00
|
|
|
function Node_ASE_layer(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
2023-01-25 06:49:00 +01:00
|
|
|
name = "ASE Layer";
|
2023-01-17 08:11:55 +01:00
|
|
|
update_on_frame = true;
|
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
inputs[| 0] = nodeValue("ASE data", self, JUNCTION_CONNECT.input, VALUE_TYPE.object, noone)
|
|
|
|
.setVisible(false, true)
|
|
|
|
.rejectArray();
|
2023-01-17 08:11:55 +01:00
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
inputs[| 1] = nodeValue("Use cel dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false)
|
|
|
|
.rejectArray();
|
2023-01-17 08:11:55 +01:00
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
|
2023-01-17 08:11:55 +01:00
|
|
|
|
|
|
|
layer_object = noone;
|
|
|
|
_name = "";
|
|
|
|
|
2023-11-23 08:28:04 +01:00
|
|
|
static onValueFromUpdate = function(index) { findLayer(); }
|
2023-01-17 08:11:55 +01:00
|
|
|
|
2023-11-23 08:28:04 +01:00
|
|
|
static findLayer = function() { #region
|
2023-10-02 08:57:44 +02:00
|
|
|
var data = getInputData(0);
|
2023-01-17 08:11:55 +01:00
|
|
|
if(data == noone) return;
|
|
|
|
|
|
|
|
var layer_index = 0;
|
|
|
|
layer_object = noone;
|
|
|
|
|
2023-07-25 20:12:40 +02:00
|
|
|
for( var i = 0, n = array_length(data.layers); i < n; i++ ) {
|
2023-03-02 07:59:14 +01:00
|
|
|
if(data.layers[i].name != display_name) continue;
|
2023-01-17 08:11:55 +01:00
|
|
|
|
|
|
|
layer_object = data.layers[i];
|
|
|
|
break;
|
|
|
|
}
|
2023-11-23 08:28:04 +01:00
|
|
|
} #endregion
|
2023-01-17 08:11:55 +01:00
|
|
|
|
2023-11-23 08:28:04 +01:00
|
|
|
static update = function(frame = CURRENT_FRAME) { #region
|
2023-10-02 08:57:44 +02:00
|
|
|
var data = getInputData(0);
|
2023-01-17 08:11:55 +01:00
|
|
|
if(data == noone) return;
|
|
|
|
|
2023-03-02 07:59:14 +01:00
|
|
|
if(_name != display_name) {
|
|
|
|
_name = display_name;
|
2023-01-17 08:11:55 +01:00
|
|
|
findLayer();
|
|
|
|
}
|
|
|
|
|
|
|
|
if(layer_object == noone) return;
|
2023-10-09 16:07:33 +02:00
|
|
|
var cel = layer_object.getCel(CURRENT_FRAME - data._tag_delay);
|
2023-01-17 08:11:55 +01:00
|
|
|
|
2023-10-02 08:57:44 +02:00
|
|
|
var celDim = getInputData(1);
|
2023-01-17 08:11:55 +01:00
|
|
|
var ww = data.content[? "Width"];
|
|
|
|
var hh = data.content[? "Height"];
|
|
|
|
var cw = cel? cel.data[? "Width"] : 1;
|
|
|
|
var ch = cel? cel.data[? "Height"] : 1;
|
|
|
|
|
2023-05-16 21:28:16 +02:00
|
|
|
var surf = outputs[| 0].getValue();
|
2023-01-17 08:11:55 +01:00
|
|
|
if(celDim) surf = surface_verify(surf, cw, ch);
|
|
|
|
else surf = surface_verify(surf, ww, hh);
|
|
|
|
outputs[| 0].setValue(surf);
|
|
|
|
|
|
|
|
if(cel == 0) {
|
|
|
|
surface_set_target(surf);
|
2023-03-19 09:17:39 +01:00
|
|
|
DRAW_CLEAR
|
2023-01-17 08:11:55 +01:00
|
|
|
surface_reset_target();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var _inSurf = cel.getSurface();
|
|
|
|
|
|
|
|
var xx = celDim? 0 : cel.data[? "X"];
|
|
|
|
var yy = celDim? 0 : cel.data[? "Y"];
|
|
|
|
|
|
|
|
surface_set_target(surf);
|
2023-03-19 09:17:39 +01:00
|
|
|
DRAW_CLEAR
|
2023-02-14 05:32:32 +01:00
|
|
|
BLEND_OVERRIDE;
|
2023-03-19 09:17:39 +01:00
|
|
|
draw_surface_safe(_inSurf, xx, yy);
|
2023-02-14 05:32:32 +01:00
|
|
|
BLEND_NORMAL;
|
2023-01-17 08:11:55 +01:00
|
|
|
surface_reset_target();
|
2023-11-23 08:28:04 +01:00
|
|
|
} #endregion
|
2023-01-17 08:11:55 +01:00
|
|
|
}
|