- [Shift Array, Array Range] Is now array processor.

This commit is contained in:
Tanasart 2024-07-11 13:35:32 +07:00
parent 8658db47c9
commit a7e0f92c28
7 changed files with 54 additions and 66 deletions

View File

@ -1,4 +1,4 @@
function Node_Array_Range(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { function Node_Array_Range(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
name = "Array Range"; name = "Array Range";
setDimension(96, 48); setDimension(96, 48);
@ -13,10 +13,10 @@ function Node_Array_Range(_x, _y, _group = noone) : Node(_x, _y, _group) constru
outputs[| 0] = nodeValue("Array", self, JUNCTION_CONNECT.output, VALUE_TYPE.float, []); outputs[| 0] = nodeValue("Array", self, JUNCTION_CONNECT.output, VALUE_TYPE.float, []);
static update = function(frame = CURRENT_FRAME) { static processData = function(_outSurf, _data, _output_index, _array_index) {
var st = getInputData(0); var st = _data[0];
var ed = getInputData(1); var ed = _data[1];
var stp = getInputData(2); var stp = _data[2];
var arr = []; var arr = [];
if(st == ed) { if(st == ed) {
@ -28,14 +28,14 @@ function Node_Array_Range(_x, _y, _group = noone) : Node(_x, _y, _group) constru
array_push(arr, st + i * stp); array_push(arr, st + i * stp);
} }
outputs[| 0].setValue(arr); return arr;
} }
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
draw_set_text(f_sdf, fa_center, fa_center, COLORS._main_text); draw_set_text(f_sdf, fa_center, fa_center, COLORS._main_text);
var str = getInputData(0); var str = getSingleValue(0);
var edd = getInputData(1); var edd = getSingleValue(1);
var stp = getInputData(2); var stp = getSingleValue(2);
var arr = outputs[| 0].getValue(); var arr = outputs[| 0].getValue();
var str = ""; var str = "";
@ -49,7 +49,6 @@ function Node_Array_Range(_x, _y, _group = noone) : Node(_x, _y, _group) constru
} }
var bbox = drawGetBbox(xx, yy, _s); var bbox = drawGetBbox(xx, yy, _s);
var ss = string_scale(str, bbox.w, bbox.h); draw_text_bbox(bbox, str);
draw_text_transformed(bbox.xc, bbox.yc, str, ss, ss, 0);
} }
} }

View File

@ -22,7 +22,6 @@ function Node_Array_Reverse(_x, _y, _group = noone) : Node(_x, _y, _group) const
} }
_arr = array_reverse(_arr); _arr = array_reverse(_arr);
outputs[| 0].setValue(_arr); outputs[| 0].setValue(_arr);
} }

View File

@ -1,22 +1,23 @@
function Node_Array_Shift(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { function Node_Array_Shift(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
name = "Array Shift"; name = "Array Shift";
setDimension(96, 32 + 24); setDimension(96, 32 + 24);
inputs[| 0] = nodeValue("Array", self, JUNCTION_CONNECT.input, VALUE_TYPE.any, 0) inputs[| 0] = nodeValue("Array", self, JUNCTION_CONNECT.input, VALUE_TYPE.any, 0)
.setArrayDepth(99)
.setVisible(true, true); .setVisible(true, true);
inputs[| 1] = nodeValue("Shift", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0) inputs[| 1] = nodeValue("Shift", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
outputs[| 0] = nodeValue("Array", self, JUNCTION_CONNECT.output, VALUE_TYPE.any, 0); outputs[| 0] = nodeValue("Array", self, JUNCTION_CONNECT.output, VALUE_TYPE.any, 0);
static update = function(frame = CURRENT_FRAME) { static processData = function(_outSurf, _data, _output_index, _array_index) {
var _arr = getInputData(0); var _arr = _data[0];
var _shf = getInputData(1); var _shf = _data[1];
inputs[| 0].setType(VALUE_TYPE.any); inputs[| 0].setType(VALUE_TYPE.any);
outputs[| 0].setType(VALUE_TYPE.any); outputs[| 0].setType(VALUE_TYPE.any);
if(!is_array(_arr)) return; if(!is_array(_arr)) return [];
if(inputs[| 0].value_from != noone) { if(inputs[| 0].value_from != noone) {
var type = inputs[| 0].value_from.type; var type = inputs[| 0].value_from.type;
@ -28,7 +29,7 @@ function Node_Array_Shift(_x, _y, _group = noone) : Node(_x, _y, _group) constru
for( var i = 0, n = array_length(_arr); i < n; i++ ) for( var i = 0, n = array_length(_arr); i < n; i++ )
arr[i] = array_safe_get(_arr, i - _shf,, ARRAY_OVERFLOW.loop); arr[i] = array_safe_get(_arr, i - _shf,, ARRAY_OVERFLOW.loop);
outputs[| 0].setValue(arr); return arr;
} }
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {

View File

@ -1,4 +1,4 @@
function Node_Array_Split(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { #region function Node_Array_Split(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "Array Split"; name = "Array Split";
setDimension(96, 0); setDimension(96, 0);
@ -55,5 +55,4 @@ function Node_Array_Split(_x, _y, _group = noone) : Node(_x, _y, _group) constru
_ind++; _ind++;
} }
} }
}
} #endregion

View File

@ -3,6 +3,7 @@ function Node_Display_Text(_x, _y, _group = noone) : Node(_x, _y, _group) constr
setDimension(16, 16); setDimension(16, 16);
bg_spr = THEME.node_frame_bg; bg_spr = THEME.node_frame_bg;
previewable = false;
size_dragging = false; size_dragging = false;
size_dragging_w = w; size_dragging_w = w;
@ -61,7 +62,7 @@ function Node_Display_Text(_x, _y, _group = noone) : Node(_x, _y, _group) constr
mm_press = 0; mm_press = 0;
mm_release = 0; mm_release = 0;
static move = function(_x, _y, _s) { #region static move = function(_x, _y, _s) {
if(x == _x && y == _y) return; if(x == _x && y == _y) return;
if(!LOADING) PROJECT.modified = true; if(!LOADING) PROJECT.modified = true;
@ -70,9 +71,9 @@ function Node_Display_Text(_x, _y, _group = noone) : Node(_x, _y, _group) constr
if(inputs[| 5].setValue([ _x, _y ])) if(inputs[| 5].setValue([ _x, _y ]))
UNDO_HOLDING = true; UNDO_HOLDING = true;
} #endregion }
static button_reactive_update = function() { #region static button_reactive_update = function() {
ml_press = lerp_float(ml_press , 0, 5); ml_press = lerp_float(ml_press , 0, 5);
ml_release = lerp_float(ml_release, 0, 5); ml_release = lerp_float(ml_release, 0, 5);
ml_double = lerp_float(ml_double, 0, 5); ml_double = lerp_float(ml_double, 0, 5);
@ -88,9 +89,9 @@ function Node_Display_Text(_x, _y, _group = noone) : Node(_x, _y, _group) constr
if(mouse_release(mb_right)) mr_release = 2; if(mouse_release(mb_right)) mr_release = 2;
if(mouse_press(mb_middle)) mm_press = 2; if(mouse_press(mb_middle)) mm_press = 2;
if(mouse_release(mb_middle)) mm_release = 2; if(mouse_release(mb_middle)) mm_release = 2;
} #endregion }
static button_reactive = function(key) { #region static button_reactive = function(key) {
switch(key) { switch(key) {
case "left_mouse_click" : return clamp(ml_press, 0, 1); case "left_mouse_click" : return clamp(ml_press, 0, 1);
case "left_mouse_double_click" : return clamp(ml_double, 0, 1); case "left_mouse_double_click" : return clamp(ml_double, 0, 1);
@ -127,9 +128,9 @@ function Node_Display_Text(_x, _y, _group = noone) : Node(_x, _y, _group) constr
if(string_length(key) == 1) return keyboard_check(ord(string_upper(key))); if(string_length(key) == 1) return keyboard_check(ord(string_upper(key)));
return 0; return 0;
} #endregion }
static draw_text_style = function(_x, _y, txt, _s, _mx, _my) { #region static draw_text_style = function(_x, _y, txt, _s, _mx, _my) {
var _tx = _x; var _tx = _x;
var index = 1; var index = 1;
var _len = string_length(txt); var _len = string_length(txt);
@ -261,9 +262,9 @@ function Node_Display_Text(_x, _y, _group = noone) : Node(_x, _y, _group) constr
} }
return width; return width;
} #endregion }
static string_raw = function(txt) { #region static string_raw = function(txt) {
var index = 1; var index = 1;
var _len = string_length(txt); var _len = string_length(txt);
var _ch = ""; var _ch = "";
@ -307,9 +308,9 @@ function Node_Display_Text(_x, _y, _group = noone) : Node(_x, _y, _group) constr
} }
return ss; return ss;
} #endregion }
static line_update = function(txt, line_width = -1) { #region static line_update = function(txt, line_width = -1) {
_prev_text = txt; _prev_text = txt;
_lines = []; _lines = [];
@ -344,13 +345,13 @@ function Node_Display_Text(_x, _y, _group = noone) : Node(_x, _y, _group) constr
} }
if(ss != "") array_push(_lines, ss); if(ss != "") array_push(_lines, ss);
} #endregion }
static onValueUpdate = function(index = 0) { #region static onValueUpdate = function(index = 0) {
if(index == 1 || index == 4) line_update(getInputData(1), getInputData(4)); if(index == 1 || index == 4) line_update(getInputData(1), getInputData(4));
} #endregion }
static preDraw = function(_x, _y, _s) { #region static preDraw = function(_x, _y, _s) {
var xx = (x - 3) * _s + _x; var xx = (x - 3) * _s + _x;
var yy = y * _s + _y; var yy = y * _s + _y;
var jun; var jun;
@ -373,9 +374,9 @@ function Node_Display_Text(_x, _y, _group = noone) : Node(_x, _y, _group) constr
jun.y = _iny; jun.y = _iny;
_iny += junction_draw_hei_y * _s; _iny += junction_draw_hei_y * _s;
} }
} #endregion }
static drawNodeBase = function(xx, yy, mx, my, _s) { #region static drawNodeBase = function(xx, yy, mx, my, _s) {
var color = getInputData(0); var color = getInputData(0);
var txt = getInputData(1); var txt = getInputData(1);
if(txt == "") txt = "..." if(txt == "") txt = "..."
@ -437,9 +438,9 @@ function Node_Display_Text(_x, _y, _group = noone) : Node(_x, _y, _group) constr
draw_scale = _s; draw_scale = _s;
w = ww + 8; w = ww + 8;
h = hh + 8; h = hh + 8;
} #endregion }
static drawJunctions = function(_x, _y, _mx, _my, _s) { #region static drawJunctions = function(_x, _y, _mx, _my, _s) {
if(!active) return; if(!active) return;
var hover = noone; var hover = noone;
@ -448,14 +449,14 @@ function Node_Display_Text(_x, _y, _group = noone) : Node(_x, _y, _group) constr
for(var i = 0, n = array_length(inputDisplayList); i < n; i++) { for(var i = 0, n = array_length(inputDisplayList); i < n; i++) {
var jun = inputDisplayList[i]; var jun = inputDisplayList[i];
if(jun.drawJunction_fast(_s * 4, _mx, _my)) if(jun.drawJunction_fast(_s, _mx, _my))
hover = jun; hover = jun;
} }
return hover; return hover;
} #endregion }
static drawNode = function(_x, _y, _mx, _my, _s) { #region static drawNode = function(_x, _y, _mx, _my, _s) {
x = smooth? lerp_float(x, pos_x, 4) : pos_x; x = smooth? lerp_float(x, pos_x, 4) : pos_x;
y = smooth? lerp_float(y, pos_y, 4) : pos_y; y = smooth? lerp_float(y, pos_y, 4) : pos_y;
@ -471,5 +472,5 @@ function Node_Display_Text(_x, _y, _group = noone) : Node(_x, _y, _group) constr
drawNodeBase(xx, yy, _mx, _my, _s); drawNodeBase(xx, yy, _mx, _my, _s);
return drawJunctions(xx, yy, _mx, _my, _s); return drawJunctions(xx, yy, _mx, _my, _s);
} #endregion }
} }

View File

@ -323,20 +323,9 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
return self; return self;
} }
static rejectArray = function() { #region static rejectArray = function() { accept_array = false; return self; }
accept_array = false; static setArrayDepth = function(aDepth) { array_depth = aDepth; return self; }
return self; static setArrayDynamic = function() { dynamic_array = true; return self; }
} #endregion
static setArrayDepth = function(aDepth) { #region
array_depth = aDepth;
return self;
} #endregion
static setArrayDynamic = function() { #region
dynamic_array = true;
return self;
} #endregion
static rejectArrayProcess = function() { #region static rejectArrayProcess = function() { #region
process_array = false; process_array = false;