mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2025-01-24 20:08:04 +01:00
pcx nested array
This commit is contained in:
parent
4827d3fb18
commit
0bc7087229
11 changed files with 1430 additions and 112 deletions
|
@ -1,4 +1,4 @@
|
|||
// 2024-04-23 16:12:42
|
||||
// 2024-04-24 07:47:39
|
||||
global.loop_nodes = [ "Node_Iterate", "Node_Iterate_Each" ];
|
||||
|
||||
#macro INAME internalName == ""? name : internalName
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// 2024-04-23 11:32:21
|
||||
// 2024-04-24 07:47:31
|
||||
global.loop_nodes = [ "Node_Iterate", "Node_Iterate_Each" ];
|
||||
|
||||
#macro INAME internalName == ""? name : internalName
|
||||
|
@ -938,6 +938,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
|
|||
|
||||
static refreshNodeDisplay = function() { #region
|
||||
INLINE
|
||||
if(IS_PLAYING) return;
|
||||
|
||||
updateIO();
|
||||
setHeight();
|
||||
|
|
239
#backups/scripts/node_number/node_number.gml.backup0
Normal file
239
#backups/scripts/node_number/node_number.gml.backup0
Normal file
|
@ -0,0 +1,239 @@
|
|||
// 2024-04-24 08:14:38
|
||||
function Node_Number(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
||||
name = "Number";
|
||||
color = COLORS.node_blend_number;
|
||||
|
||||
setDimension(96, 32 + 24 * 1);
|
||||
|
||||
wd_slider = slider(0, 1, 0.01, function(val) { inputs[| 0].setValue(val); } );
|
||||
wd_slider.spr = THEME.node_slider;
|
||||
|
||||
slider_value = -1;
|
||||
slider_surface = -1;
|
||||
slider_dragging = false;
|
||||
slider_mx = 0;
|
||||
slider_sx = 0;
|
||||
slider_m = 0;
|
||||
|
||||
rotator_surface = -1;
|
||||
rotator_dragging = false;
|
||||
rotator_s = 0;
|
||||
rotator_p = 0;
|
||||
rotator_m = 0;
|
||||
|
||||
inputs[| 0] = nodeValue("Value", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0)
|
||||
.setVisible(true, true);
|
||||
|
||||
inputs[| 1] = nodeValue("Integer", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false);
|
||||
|
||||
inputs[| 2] = nodeValue("Display", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
|
||||
.setDisplay(VALUE_DISPLAY.enum_scroll, { data: [ "Number", "Slider", "Rotator" ], update_hover: false });
|
||||
|
||||
inputs[| 3] = nodeValue("Range", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 1 ])
|
||||
.setDisplay(VALUE_DISPLAY.range);
|
||||
|
||||
inputs[| 4] = nodeValue("Step", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.01)
|
||||
|
||||
inputs[| 5] = nodeValue("Clamp to range", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true);
|
||||
|
||||
outputs[| 0] = nodeValue("Number", self, JUNCTION_CONNECT.output, VALUE_TYPE.float, 0);
|
||||
|
||||
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { #region
|
||||
var __ax = getInputData(0);
|
||||
if(is_array(__ax)) return;
|
||||
|
||||
inputs[| 0].drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny);
|
||||
} #endregion
|
||||
|
||||
static step = function() { #region
|
||||
var int = getInputData(1);
|
||||
var disp = getInputData(2);
|
||||
|
||||
if(!show_parameter) setDimension(96, 56, false);
|
||||
|
||||
switch(disp) {
|
||||
case 0 :
|
||||
inputs[| 3].setVisible(false);
|
||||
inputs[| 4].setVisible(false);
|
||||
inputs[| 5].setVisible(false);
|
||||
break;
|
||||
case 1 :
|
||||
if(inputs[| 0].isLeaf() && !show_parameter) setDimension(160, 96, false);
|
||||
|
||||
inputs[| 3].setVisible(true);
|
||||
inputs[| 4].setVisible(true);
|
||||
inputs[| 5].setVisible(true);
|
||||
break;
|
||||
case 2 :
|
||||
if(inputs[| 0].isLeaf() && !show_parameter) setDimension(128, 128, false);
|
||||
|
||||
inputs[| 3].setVisible(false);
|
||||
inputs[| 4].setVisible(false);
|
||||
inputs[| 5].setVisible(false);
|
||||
break;
|
||||
}
|
||||
|
||||
for( var i = 0; i < 1; i++ ) {
|
||||
inputs[| i].setType(int? VALUE_TYPE.integer : VALUE_TYPE.float);
|
||||
inputs[| i].editWidget.setSlidable(int? 0.1 : 0.01);
|
||||
}
|
||||
|
||||
outputs[| 0].setType(int? VALUE_TYPE.integer : VALUE_TYPE.float);
|
||||
} #endregion
|
||||
|
||||
static processNumber = function(_val, _int) {
|
||||
if(is_string(_val)) return _int? round(toNumber(_val)) : toNumber(_val);
|
||||
if(is_numeric(_val)) return _int? round(_val) : _val;
|
||||
|
||||
if(is_array(_val)) {
|
||||
for (var i = 0, n = array_length(_val); i < n; i++)
|
||||
_val[i] = processNumber(_val[i], _int);
|
||||
}
|
||||
|
||||
return _val;
|
||||
}
|
||||
|
||||
static update = function() { #region
|
||||
var _dat = getInputData(0);
|
||||
var _int = getInputData(1);
|
||||
|
||||
var _res = processNumber(_dat, _int);
|
||||
outputs[| 0].setValue(_res);
|
||||
} #endregion
|
||||
|
||||
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region
|
||||
var bbox = drawGetBbox(xx, yy, _s);
|
||||
var val = getInputData(0);
|
||||
var _int = getInputData(1);
|
||||
var disp = getInputData(2);
|
||||
var rang = getInputData(3);
|
||||
var stp = getInputData(4);
|
||||
var cmp = getInputData(5);
|
||||
var _col = getColor();
|
||||
|
||||
if(disp == 0 || inputs[| 0].value_from != noone || bbox.h < line_get_height(f_p2)) {
|
||||
draw_set_text(f_sdf, fa_center, fa_center, COLORS._main_text);
|
||||
draw_text_bbox(bbox, string(val));
|
||||
return;
|
||||
}
|
||||
|
||||
switch(disp) {
|
||||
|
||||
case 1 : #region
|
||||
draw_set_text(f_sdf, fa_center, fa_center, _col);
|
||||
draw_text_transformed(bbox.xc, bbox.y0 + 16 * _s, string(_int? round(val) : val), _s * 0.5, _s * 0.5, 0);
|
||||
|
||||
var sl_w = bbox.w - 8 * _s;
|
||||
var sl_h = _s * 40;
|
||||
|
||||
var sl_x0 = bbox.x0 + 4 * _s;
|
||||
var sl_x1 = sl_x0 + sl_w;
|
||||
var sl_y0 = (bbox.y0 + (24 * _s) + bbox.y1) / 2 - sl_h / 2;
|
||||
var sl_y1 = sl_y0 + sl_h;
|
||||
|
||||
var c0 = (draggable && !slider_dragging)? colorMultiply(CDEF.main_grey, _col) : colorMultiply(CDEF.main_white, _col);
|
||||
var c1 = colorMultiply(CDEF.main_dkgrey, _col);
|
||||
|
||||
var _minn = rang[0];
|
||||
var _maxx = rang[1];
|
||||
|
||||
slider_surface = surface_verify(slider_surface, sl_w, sl_h);
|
||||
slider_value = slider_value == -1? val : lerp_float(slider_value, val, 2.5);
|
||||
|
||||
surface_set_shader(slider_surface, sh_ui_slider);
|
||||
shader_set_color("c0", c0);
|
||||
shader_set_color("c1", c1);
|
||||
shader_set_dim("dimension", slider_surface);
|
||||
shader_set_f("mouseProg", animation_curve_eval(ac_ripple, slider_m));
|
||||
shader_set_f("prog", clamp((slider_value - _minn) / (_maxx - _minn), 0.1, 0.9));
|
||||
|
||||
draw_sprite_stretched(s_fx_pixel, 0, 0, 0, sl_w, sl_h);
|
||||
surface_reset_shader();
|
||||
|
||||
draw_surface(slider_surface, sl_x0, sl_y0);
|
||||
|
||||
if(slider_dragging) {
|
||||
slider_m = lerp_float(slider_m, 1, 4);
|
||||
|
||||
var _valM = (_mx - sl_x0) / (sl_x1 - sl_x0);
|
||||
var _valL = lerp(_minn, _maxx, _valM);
|
||||
_valL = value_snap(_valL, stp);
|
||||
if(cmp) _valL = clamp(_valL, _minn, _maxx);
|
||||
|
||||
if(inputs[| 0].setValue(_valL))
|
||||
UNDO_HOLDING = true;
|
||||
|
||||
if(mouse_release(mb_left)) {
|
||||
slider_dragging = false;
|
||||
UNDO_HOLDING = false;
|
||||
}
|
||||
} else
|
||||
slider_m = lerp_float(slider_m, 0, 5);
|
||||
|
||||
if(_hover && point_in_rectangle(_mx, _my, sl_x0, sl_y0, sl_x1, sl_y1)) {
|
||||
if(mouse_press(mb_left, _focus) && is_real(val)) {
|
||||
slider_dragging = true;
|
||||
slider_mx = _mx;
|
||||
slider_sx = val;
|
||||
}
|
||||
|
||||
draggable = false;
|
||||
}
|
||||
|
||||
break; #endregion
|
||||
|
||||
case 2 : #region
|
||||
var _ss = min(bbox.w, bbox.h);
|
||||
var c0 = (draggable && !rotator_dragging)? colorMultiply(CDEF.main_grey, _col) : colorMultiply(CDEF.main_white, _col);
|
||||
var c1 = colorMultiply(CDEF.main_dkgrey, _col);
|
||||
var _dst = point_distance(_mx, _my, bbox.xc, bbox.yc);
|
||||
var _x0 = bbox.xc - _ss / 2;
|
||||
var _y0 = bbox.yc - _ss / 2;
|
||||
|
||||
rotator_surface = surface_verify(rotator_surface, _ss, _ss);
|
||||
|
||||
surface_set_shader(rotator_surface, sh_ui_rotator);
|
||||
shader_set_color("c0", c0);
|
||||
shader_set_color("c1", c1);
|
||||
shader_set_f("angle", degtorad(val));
|
||||
shader_set_f("mouse", (_mx - _x0) / _ss, (_my - _y0) / _ss);
|
||||
shader_set_f("mouseProg", animation_curve_eval(ac_ripple, rotator_m));
|
||||
|
||||
draw_sprite_stretched(s_fx_pixel, 0, 0, 0, _ss, _ss);
|
||||
surface_reset_shader();
|
||||
|
||||
draw_surface(rotator_surface, _x0, _y0);
|
||||
|
||||
if(rotator_dragging) {
|
||||
rotator_m = lerp_float(rotator_m, 1, 4);
|
||||
var dir = point_direction(bbox.xc, bbox.yc, _mx, _my);
|
||||
var dx = angle_difference(dir, rotator_p);
|
||||
rotator_p = dir;
|
||||
|
||||
if(inputs[| 0].setValue(val + dx))
|
||||
UNDO_HOLDING = true;
|
||||
|
||||
if(mouse_release(mb_left)) {
|
||||
rotator_dragging = false;
|
||||
UNDO_HOLDING = false;
|
||||
}
|
||||
} else
|
||||
rotator_m = lerp_float(rotator_m, 0, 5);
|
||||
|
||||
if(_hover && point_in_circle(_mx, _my, bbox.xc, bbox.yc, _ss / 2)) {
|
||||
if(mouse_press(mb_left, _focus) && is_real(val)) {
|
||||
rotator_dragging = true;
|
||||
rotator_s = val;
|
||||
rotator_p = point_direction(bbox.xc, bbox.yc, _mx, _my);
|
||||
}
|
||||
|
||||
draggable = false;
|
||||
}
|
||||
|
||||
draw_set_text(f_sdf, fa_center, fa_center, colorMultiply(CDEF.main_white, _col));
|
||||
draw_text_transformed(bbox.xc, bbox.yc, _int? string(round(val)) : string_format(val, -1, 2), _s * .5, _s * .5, 0);
|
||||
break; #endregion
|
||||
}
|
||||
} #endregion
|
||||
|
||||
}
|
240
#backups/scripts/node_number/node_number.gml.backup1
Normal file
240
#backups/scripts/node_number/node_number.gml.backup1
Normal file
|
@ -0,0 +1,240 @@
|
|||
// 2024-04-24 08:13:56
|
||||
function Node_Number(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
||||
name = "Number";
|
||||
color = COLORS.node_blend_number;
|
||||
|
||||
setDimension(96, 32 + 24 * 1);
|
||||
|
||||
wd_slider = slider(0, 1, 0.01, function(val) { inputs[| 0].setValue(val); } );
|
||||
wd_slider.spr = THEME.node_slider;
|
||||
|
||||
slider_value = -1;
|
||||
slider_surface = -1;
|
||||
slider_dragging = false;
|
||||
slider_mx = 0;
|
||||
slider_sx = 0;
|
||||
slider_m = 0;
|
||||
|
||||
rotator_surface = -1;
|
||||
rotator_dragging = false;
|
||||
rotator_s = 0;
|
||||
rotator_p = 0;
|
||||
rotator_m = 0;
|
||||
|
||||
inputs[| 0] = nodeValue("Value", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0)
|
||||
.setVisible(true, true);
|
||||
|
||||
inputs[| 1] = nodeValue("Integer", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false);
|
||||
|
||||
inputs[| 2] = nodeValue("Display", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
|
||||
.setDisplay(VALUE_DISPLAY.enum_scroll, { data: [ "Number", "Slider", "Rotator" ], update_hover: false });
|
||||
|
||||
inputs[| 3] = nodeValue("Range", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 1 ])
|
||||
.setDisplay(VALUE_DISPLAY.range);
|
||||
|
||||
inputs[| 4] = nodeValue("Step", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.01)
|
||||
|
||||
inputs[| 5] = nodeValue("Clamp to range", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true);
|
||||
|
||||
outputs[| 0] = nodeValue("Number", self, JUNCTION_CONNECT.output, VALUE_TYPE.float, 0);
|
||||
|
||||
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { #region
|
||||
var __ax = getInputData(0);
|
||||
if(is_array(__ax)) return;
|
||||
|
||||
inputs[| 0].drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny);
|
||||
} #endregion
|
||||
|
||||
static step = function() { #region
|
||||
var int = getInputData(1);
|
||||
var disp = getInputData(2);
|
||||
|
||||
if(!show_parameter) setDimension(96, 56, false);
|
||||
|
||||
switch(disp) {
|
||||
case 0 :
|
||||
inputs[| 3].setVisible(false);
|
||||
inputs[| 4].setVisible(false);
|
||||
inputs[| 5].setVisible(false);
|
||||
break;
|
||||
case 1 :
|
||||
if(inputs[| 0].isLeaf() && !show_parameter) setDimension(160, 96, false);
|
||||
|
||||
inputs[| 3].setVisible(true);
|
||||
inputs[| 4].setVisible(true);
|
||||
inputs[| 5].setVisible(true);
|
||||
break;
|
||||
case 2 :
|
||||
if(inputs[| 0].isLeaf() && !show_parameter) setDimension(128, 128, false);
|
||||
|
||||
inputs[| 3].setVisible(false);
|
||||
inputs[| 4].setVisible(false);
|
||||
inputs[| 5].setVisible(false);
|
||||
break;
|
||||
}
|
||||
|
||||
for( var i = 0; i < 1; i++ ) {
|
||||
inputs[| i].setType(int? VALUE_TYPE.integer : VALUE_TYPE.float);
|
||||
inputs[| i].editWidget.setSlidable(int? 0.1 : 0.01);
|
||||
}
|
||||
|
||||
outputs[| 0].setType(int? VALUE_TYPE.integer : VALUE_TYPE.float);
|
||||
} #endregion
|
||||
|
||||
static processNumber = function(_val, _int) {
|
||||
if(is_string(_val)) return _int? round(toNumber(_val)) : toNumber(_val);
|
||||
if(is_numeric(_val)) return _int? round(_val) : _val;
|
||||
|
||||
if(is_array(_val)) {
|
||||
for (var i = 0, n = array_length(_val); i < n; i++)
|
||||
_val[i] = processNumber(_val[i], _int);
|
||||
}
|
||||
|
||||
return _val;
|
||||
}
|
||||
|
||||
static update = function() { #region
|
||||
var _dat = getInputData(0);
|
||||
var _int = getInputData(1);
|
||||
|
||||
print(_dat);
|
||||
var _res = processNumber(_dat, _int);
|
||||
outputs[| 0].setValue(_res);
|
||||
} #endregion
|
||||
|
||||
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region
|
||||
var bbox = drawGetBbox(xx, yy, _s);
|
||||
var val = getInputData(0);
|
||||
var _int = getInputData(1);
|
||||
var disp = getInputData(2);
|
||||
var rang = getInputData(3);
|
||||
var stp = getInputData(4);
|
||||
var cmp = getInputData(5);
|
||||
var _col = getColor();
|
||||
|
||||
if(disp == 0 || inputs[| 0].value_from != noone || bbox.h < line_get_height(f_p2)) {
|
||||
draw_set_text(f_sdf, fa_center, fa_center, COLORS._main_text);
|
||||
draw_text_bbox(bbox, string(val));
|
||||
return;
|
||||
}
|
||||
|
||||
switch(disp) {
|
||||
|
||||
case 1 : #region
|
||||
draw_set_text(f_sdf, fa_center, fa_center, _col);
|
||||
draw_text_transformed(bbox.xc, bbox.y0 + 16 * _s, string(_int? round(val) : val), _s * 0.5, _s * 0.5, 0);
|
||||
|
||||
var sl_w = bbox.w - 8 * _s;
|
||||
var sl_h = _s * 40;
|
||||
|
||||
var sl_x0 = bbox.x0 + 4 * _s;
|
||||
var sl_x1 = sl_x0 + sl_w;
|
||||
var sl_y0 = (bbox.y0 + (24 * _s) + bbox.y1) / 2 - sl_h / 2;
|
||||
var sl_y1 = sl_y0 + sl_h;
|
||||
|
||||
var c0 = (draggable && !slider_dragging)? colorMultiply(CDEF.main_grey, _col) : colorMultiply(CDEF.main_white, _col);
|
||||
var c1 = colorMultiply(CDEF.main_dkgrey, _col);
|
||||
|
||||
var _minn = rang[0];
|
||||
var _maxx = rang[1];
|
||||
|
||||
slider_surface = surface_verify(slider_surface, sl_w, sl_h);
|
||||
slider_value = slider_value == -1? val : lerp_float(slider_value, val, 2.5);
|
||||
|
||||
surface_set_shader(slider_surface, sh_ui_slider);
|
||||
shader_set_color("c0", c0);
|
||||
shader_set_color("c1", c1);
|
||||
shader_set_dim("dimension", slider_surface);
|
||||
shader_set_f("mouseProg", animation_curve_eval(ac_ripple, slider_m));
|
||||
shader_set_f("prog", clamp((slider_value - _minn) / (_maxx - _minn), 0.1, 0.9));
|
||||
|
||||
draw_sprite_stretched(s_fx_pixel, 0, 0, 0, sl_w, sl_h);
|
||||
surface_reset_shader();
|
||||
|
||||
draw_surface(slider_surface, sl_x0, sl_y0);
|
||||
|
||||
if(slider_dragging) {
|
||||
slider_m = lerp_float(slider_m, 1, 4);
|
||||
|
||||
var _valM = (_mx - sl_x0) / (sl_x1 - sl_x0);
|
||||
var _valL = lerp(_minn, _maxx, _valM);
|
||||
_valL = value_snap(_valL, stp);
|
||||
if(cmp) _valL = clamp(_valL, _minn, _maxx);
|
||||
|
||||
if(inputs[| 0].setValue(_valL))
|
||||
UNDO_HOLDING = true;
|
||||
|
||||
if(mouse_release(mb_left)) {
|
||||
slider_dragging = false;
|
||||
UNDO_HOLDING = false;
|
||||
}
|
||||
} else
|
||||
slider_m = lerp_float(slider_m, 0, 5);
|
||||
|
||||
if(_hover && point_in_rectangle(_mx, _my, sl_x0, sl_y0, sl_x1, sl_y1)) {
|
||||
if(mouse_press(mb_left, _focus) && is_real(val)) {
|
||||
slider_dragging = true;
|
||||
slider_mx = _mx;
|
||||
slider_sx = val;
|
||||
}
|
||||
|
||||
draggable = false;
|
||||
}
|
||||
|
||||
break; #endregion
|
||||
|
||||
case 2 : #region
|
||||
var _ss = min(bbox.w, bbox.h);
|
||||
var c0 = (draggable && !rotator_dragging)? colorMultiply(CDEF.main_grey, _col) : colorMultiply(CDEF.main_white, _col);
|
||||
var c1 = colorMultiply(CDEF.main_dkgrey, _col);
|
||||
var _dst = point_distance(_mx, _my, bbox.xc, bbox.yc);
|
||||
var _x0 = bbox.xc - _ss / 2;
|
||||
var _y0 = bbox.yc - _ss / 2;
|
||||
|
||||
rotator_surface = surface_verify(rotator_surface, _ss, _ss);
|
||||
|
||||
surface_set_shader(rotator_surface, sh_ui_rotator);
|
||||
shader_set_color("c0", c0);
|
||||
shader_set_color("c1", c1);
|
||||
shader_set_f("angle", degtorad(val));
|
||||
shader_set_f("mouse", (_mx - _x0) / _ss, (_my - _y0) / _ss);
|
||||
shader_set_f("mouseProg", animation_curve_eval(ac_ripple, rotator_m));
|
||||
|
||||
draw_sprite_stretched(s_fx_pixel, 0, 0, 0, _ss, _ss);
|
||||
surface_reset_shader();
|
||||
|
||||
draw_surface(rotator_surface, _x0, _y0);
|
||||
|
||||
if(rotator_dragging) {
|
||||
rotator_m = lerp_float(rotator_m, 1, 4);
|
||||
var dir = point_direction(bbox.xc, bbox.yc, _mx, _my);
|
||||
var dx = angle_difference(dir, rotator_p);
|
||||
rotator_p = dir;
|
||||
|
||||
if(inputs[| 0].setValue(val + dx))
|
||||
UNDO_HOLDING = true;
|
||||
|
||||
if(mouse_release(mb_left)) {
|
||||
rotator_dragging = false;
|
||||
UNDO_HOLDING = false;
|
||||
}
|
||||
} else
|
||||
rotator_m = lerp_float(rotator_m, 0, 5);
|
||||
|
||||
if(_hover && point_in_circle(_mx, _my, bbox.xc, bbox.yc, _ss / 2)) {
|
||||
if(mouse_press(mb_left, _focus) && is_real(val)) {
|
||||
rotator_dragging = true;
|
||||
rotator_s = val;
|
||||
rotator_p = point_direction(bbox.xc, bbox.yc, _mx, _my);
|
||||
}
|
||||
|
||||
draggable = false;
|
||||
}
|
||||
|
||||
draw_set_text(f_sdf, fa_center, fa_center, colorMultiply(CDEF.main_white, _col));
|
||||
draw_text_transformed(bbox.xc, bbox.yc, _int? string(round(val)) : string_format(val, -1, 2), _s * .5, _s * .5, 0);
|
||||
break; #endregion
|
||||
}
|
||||
} #endregion
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
// 2024-04-23 17:16:51
|
||||
// 2024-04-24 08:43:01
|
||||
#region ---- global names ----
|
||||
global.junctionEndName = [ "Hold", "Loop", "Ping pong", "Wrap" ];
|
||||
|
||||
|
@ -1599,12 +1599,17 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
|
|||
} #endregion
|
||||
|
||||
static valueExpressionProcess = function(value) { #region
|
||||
if(is_array(value)) {
|
||||
for (var i = 0, n = array_length(value); i < n; i++)
|
||||
value[i] = valueExpressionProcess(value[i]);
|
||||
return value;
|
||||
}
|
||||
|
||||
switch(type) {
|
||||
case VALUE_TYPE.float :
|
||||
case VALUE_TYPE.integer :
|
||||
if(!is_numeric(value))
|
||||
return toNumber(value);
|
||||
break;
|
||||
return is_numeric(value)? value : toNumber(value);
|
||||
|
||||
case VALUE_TYPE.boolean :
|
||||
return bool(value);
|
||||
}
|
||||
|
@ -1636,6 +1641,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
|
|||
}
|
||||
|
||||
var val = _getValue(_time, applyUnit, arrIndex, log);
|
||||
|
||||
if(!accept_array && array_get_depth(val) > def_depth) {
|
||||
noti_warning($"{name} does not accept array data.",, node);
|
||||
return 0;
|
||||
|
@ -1663,25 +1669,6 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
|
|||
return val;
|
||||
} #endregion
|
||||
|
||||
static arrayBalance = function(val) { #region // Balance array (generate uniform array from single values)
|
||||
if(!is_array(def_val))
|
||||
return val;
|
||||
|
||||
if(isDynamicArray())
|
||||
return val;
|
||||
|
||||
if(isArray(val))
|
||||
return val;
|
||||
|
||||
if(!is_array(val))
|
||||
return array_create(def_length, val);
|
||||
|
||||
if(array_length(val) < def_length)
|
||||
array_resize(val, def_length);
|
||||
|
||||
return val;
|
||||
} #endregion
|
||||
|
||||
static _getValue = function(_time = CURRENT_FRAME, applyUnit = true, arrIndex = 0, log = false) { #region
|
||||
|
||||
getValueRecursive(self.__curr_get_val, _time);
|
||||
|
@ -1694,15 +1681,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
|
|||
if(connect_type == JUNCTION_CONNECT.output)
|
||||
return val;
|
||||
|
||||
if(expUse) { #region expression
|
||||
if(is_array(val)) {
|
||||
for( var i = 0, n = array_length(val); i < n; i++ )
|
||||
val[i] = valueExpressionProcess(val[i]);
|
||||
} else
|
||||
val = valueExpressionProcess(val);
|
||||
return arrayBalance(val);
|
||||
|
||||
} #endregion
|
||||
if(expUse) return arrayBalance(valueExpressionProcess(val));
|
||||
|
||||
if(typ == VALUE_TYPE.surface && (type == VALUE_TYPE.integer || type == VALUE_TYPE.float)) { #region Dimension conversion
|
||||
if(is_array(val)) {
|
||||
|
@ -1799,6 +1778,25 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
|
|||
}
|
||||
} #endregion
|
||||
|
||||
static arrayBalance = function(val) { #region
|
||||
if(!is_array(def_val))
|
||||
return val;
|
||||
|
||||
if(isDynamicArray())
|
||||
return val;
|
||||
|
||||
if(isArray(val))
|
||||
return val;
|
||||
|
||||
if(!is_array(val))
|
||||
return array_create(def_length, val);
|
||||
|
||||
if(array_length(val) < def_length)
|
||||
array_resize(val, def_length);
|
||||
|
||||
return val;
|
||||
} #endregion
|
||||
|
||||
static __getAnimValue = function(_time = CURRENT_FRAME) { #region
|
||||
|
||||
if(value_tag == "dimension" && node.attributes.use_project_dimension)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// 2024-04-23 17:05:58
|
||||
// 2024-04-24 08:42:22
|
||||
#region ---- global names ----
|
||||
global.junctionEndName = [ "Hold", "Loop", "Ping pong", "Wrap" ];
|
||||
|
||||
|
@ -1599,12 +1599,17 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
|
|||
} #endregion
|
||||
|
||||
static valueExpressionProcess = function(value) { #region
|
||||
if(is_array(value)) {
|
||||
for (var i = 0, n = array_length(value); i < n; i++)
|
||||
value[i] = valueExpressionProcess(value[i]);
|
||||
return value;
|
||||
}
|
||||
|
||||
switch(type) {
|
||||
case VALUE_TYPE.float :
|
||||
case VALUE_TYPE.integer :
|
||||
if(!is_numeric(value))
|
||||
return toNumber(value);
|
||||
break;
|
||||
return is_numeric(value)? value : toNumber(value);
|
||||
|
||||
case VALUE_TYPE.boolean :
|
||||
return bool(value);
|
||||
}
|
||||
|
@ -1636,6 +1641,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
|
|||
}
|
||||
|
||||
var val = _getValue(_time, applyUnit, arrIndex, log);
|
||||
|
||||
if(!accept_array && array_get_depth(val) > def_depth) {
|
||||
noti_warning($"{name} does not accept array data.",, node);
|
||||
return 0;
|
||||
|
@ -1663,25 +1669,6 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
|
|||
return val;
|
||||
} #endregion
|
||||
|
||||
static arrayBalance = function(val) { #region // Balance array (generate uniform array from single values)
|
||||
if(!is_array(def_val))
|
||||
return val;
|
||||
|
||||
if(isDynamicArray())
|
||||
return val;
|
||||
|
||||
if(isArray(val))
|
||||
return val;
|
||||
|
||||
if(!is_array(val))
|
||||
return array_create(def_length, val);
|
||||
|
||||
if(array_length(val) < def_length)
|
||||
array_resize(val, def_length);
|
||||
|
||||
return val;
|
||||
} #endregion
|
||||
|
||||
static _getValue = function(_time = CURRENT_FRAME, applyUnit = true, arrIndex = 0, log = false) { #region
|
||||
|
||||
getValueRecursive(self.__curr_get_val, _time);
|
||||
|
@ -1694,15 +1681,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
|
|||
if(connect_type == JUNCTION_CONNECT.output)
|
||||
return val;
|
||||
|
||||
if(expUse) { #region expression
|
||||
if(is_array(val)) {
|
||||
for( var i = 0, n = array_length(val); i < n; i++ )
|
||||
val[i] = valueExpressionProcess(val[i]);
|
||||
} else
|
||||
val = valueExpressionProcess(val);
|
||||
return arrayBalance(val);
|
||||
|
||||
} #endregion
|
||||
if(expUse) return arrayBalance(valueExpressionProcess(val));
|
||||
|
||||
if(typ == VALUE_TYPE.surface && (type == VALUE_TYPE.integer || type == VALUE_TYPE.float)) { #region Dimension conversion
|
||||
if(is_array(val)) {
|
||||
|
@ -1799,6 +1778,25 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
|
|||
}
|
||||
} #endregion
|
||||
|
||||
static arrayBalance = function(val) { #region
|
||||
if(!is_array(def_val))
|
||||
return val;
|
||||
|
||||
if(isDynamicArray())
|
||||
return val;
|
||||
|
||||
if(isArray(val))
|
||||
return val;
|
||||
|
||||
if(!is_array(val))
|
||||
return array_create(def_length, val);
|
||||
|
||||
if(array_length(val) < def_length)
|
||||
array_resize(val, def_length);
|
||||
|
||||
return val;
|
||||
} #endregion
|
||||
|
||||
static __getAnimValue = function(_time = CURRENT_FRAME) { #region
|
||||
|
||||
if(value_tag == "dimension" && node.attributes.use_project_dimension)
|
||||
|
|
418
#backups/scripts/pcx_parse/pcx_parse.gml.backup0
Normal file
418
#backups/scripts/pcx_parse/pcx_parse.gml.backup0
Normal file
|
@ -0,0 +1,418 @@
|
|||
// 2024-04-24 07:58:26
|
||||
#region symbols
|
||||
global.LOG_EXPRESSION = false;
|
||||
|
||||
global.EQUATION_PRES = ds_map_create();
|
||||
global.EQUATION_PRES[? "+"] = 1;
|
||||
global.EQUATION_PRES[? "-"] = 1;
|
||||
global.EQUATION_PRES[? "∸"] = 9; //unary negative
|
||||
global.EQUATION_PRES[? "*"] = 2;
|
||||
global.EQUATION_PRES[? "/"] = 2;
|
||||
global.EQUATION_PRES[? "%"] = 2;
|
||||
global.EQUATION_PRES[? "$"] = 3; //power
|
||||
|
||||
global.EQUATION_PRES[? "&"] = 5;
|
||||
global.EQUATION_PRES[? "|"] = 4;
|
||||
global.EQUATION_PRES[? "^"] = 3;
|
||||
global.EQUATION_PRES[? "<"] = 3;
|
||||
global.EQUATION_PRES[? "»"] = 6;
|
||||
global.EQUATION_PRES[? "«"] = 6;
|
||||
global.EQUATION_PRES[? "~"] = 9;
|
||||
|
||||
global.EQUATION_PRES[? "="] = -99;
|
||||
global.EQUATION_PRES[? "⊕"] = -99; //+=
|
||||
global.EQUATION_PRES[? "⊖"] = -99; //-=
|
||||
global.EQUATION_PRES[? "⊗"] = -99; //*=
|
||||
global.EQUATION_PRES[? "⊘"] = -99; ///=
|
||||
|
||||
global.EQUATION_PRES[? "⩵"] = -1; //==
|
||||
global.EQUATION_PRES[? "≠"] = -1; //!=
|
||||
global.EQUATION_PRES[? "<"] = 0;
|
||||
global.EQUATION_PRES[? ">"] = 0;
|
||||
global.EQUATION_PRES[? "≤"] = 0;
|
||||
global.EQUATION_PRES[? "≥"] = 0;
|
||||
|
||||
global.EQUATION_PRES[? "@"] = 5; //array accerssor symbol
|
||||
|
||||
#endregion
|
||||
|
||||
#region parser
|
||||
function functionStringClean(fx) { #region
|
||||
static __BRACKETS = [ "(", "[", "," ];
|
||||
|
||||
var ch = "", ind = 0, len = string_length(fx);
|
||||
var _fx = "", str = false;
|
||||
var _prevSym = true;
|
||||
|
||||
while(ind++ <= len) {
|
||||
ch = string_char_at(fx, ind);
|
||||
|
||||
if(ch == " ") {
|
||||
if(str) _fx += ch;
|
||||
} else {
|
||||
if(ch == "-" && _prevSym)
|
||||
_fx += $"0∸";
|
||||
else
|
||||
_fx += ch;
|
||||
|
||||
_prevSym = ds_map_exists(global.EQUATION_PRES, ch) || array_exists(__BRACKETS, ch);
|
||||
}
|
||||
|
||||
if(ch == "\"")
|
||||
str = !str;
|
||||
}
|
||||
|
||||
fx = _fx;
|
||||
|
||||
fx = string_replace_all(fx, "\n", "");
|
||||
fx = string_replace_all(fx, "**", "$");
|
||||
fx = string_replace_all(fx, "<<", "«");
|
||||
fx = string_replace_all(fx, ">>", "»");
|
||||
|
||||
fx = string_replace_all(fx, "==", "⩵");
|
||||
fx = string_replace_all(fx, "!=", "≠");
|
||||
fx = string_replace_all(fx, "<>", "≠");
|
||||
fx = string_replace_all(fx, ">=", "≥");
|
||||
fx = string_replace_all(fx, "<=", "≤");
|
||||
|
||||
fx = string_replace_all(fx, "++", "⊕1");
|
||||
fx = string_replace_all(fx, "--", "⊖1");
|
||||
|
||||
fx = string_replace_all(fx, "+=", "⊕");
|
||||
fx = string_replace_all(fx, "-=", "⊖");
|
||||
fx = string_replace_all(fx, "*=", "⊗");
|
||||
fx = string_replace_all(fx, "/=", "⊘");
|
||||
|
||||
fx = string_replace_all(fx, "]", ",]");
|
||||
|
||||
fx = string_trim(fx);
|
||||
|
||||
return fx;
|
||||
} #endregion
|
||||
|
||||
function functionStrip(fx) { #region
|
||||
var el_st = 1;
|
||||
var el_ed = 1;
|
||||
|
||||
for( var i = 1; i <= string_length(fx); i++ ) {
|
||||
var cch = string_char_at(fx, i);
|
||||
if(cch == "(") {
|
||||
el_st = i + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for( var i = string_length(fx); i >= 1; i-- ) {
|
||||
var cch = string_char_at(fx, i);
|
||||
if(cch == ")") {
|
||||
el_ed = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return string_copy(fx, el_st, el_ed - el_st)
|
||||
} #endregion
|
||||
|
||||
function evaluateFunctionList(fx) { #region
|
||||
fx = string_replace_all(fx, "{", "\n{\n");
|
||||
fx = string_replace_all(fx, "}", "\n}\n");
|
||||
|
||||
var fxs = string_split(fx, "\n", true);
|
||||
|
||||
var flist = new __funcList();
|
||||
|
||||
var call_st = ds_stack_create();
|
||||
var blok_st = ds_stack_create();
|
||||
ds_stack_push(call_st, flist);
|
||||
|
||||
for( var i = 0, n = array_length(fxs); i < n; i++ ) {
|
||||
var _fx = functionStringClean(fxs[i]);
|
||||
//print($"Eval line {i}: {_fx} [stack size = {ds_stack_size(call_st)}]");
|
||||
|
||||
if(_fx == "" || _fx == "{") continue;
|
||||
if(_fx == "}") {
|
||||
ds_stack_pop(call_st);
|
||||
continue;
|
||||
}
|
||||
|
||||
var _fx_sp = string_split(_fx, "(");
|
||||
var _cmd = string_trim(_fx_sp[0]);
|
||||
var _cond = functionStrip(_fx);
|
||||
|
||||
switch(_cmd) {
|
||||
case "if":
|
||||
var con_if = new __funcIf();
|
||||
con_if.condition = evaluateFunctionTree(_cond);
|
||||
ds_stack_top(call_st).addFunction(con_if);
|
||||
ds_stack_push(call_st, con_if.if_true);
|
||||
ds_stack_push(blok_st, con_if);
|
||||
continue;
|
||||
|
||||
case "elseif":
|
||||
var con_if = ds_stack_pop(blok_st);
|
||||
var con_elif = new __funcIf();
|
||||
con_elif.condition = evaluateFunctionTree(_cond);
|
||||
|
||||
con_if.if_false.addFunction(con_elif);
|
||||
ds_stack_push(call_st, con_elif.if_true);
|
||||
ds_stack_push(blok_st, con_elif);
|
||||
continue;
|
||||
|
||||
case "else":
|
||||
var con_if = ds_stack_pop(blok_st);
|
||||
|
||||
ds_stack_push(call_st, con_if.if_false);
|
||||
continue;
|
||||
|
||||
case "for":
|
||||
|
||||
var con_for = new __funcFor();
|
||||
var cond = string_splice(_cond, ":");
|
||||
if(array_length(cond) == 2) {
|
||||
con_for.itr_array = true;
|
||||
con_for.cond_arr = evaluateFunctionTree(cond[1]);
|
||||
|
||||
cond[0] = string_trim(cond[0]);
|
||||
var _itr = string_split(cond[0], ",");
|
||||
if(array_length(_itr) == 1)
|
||||
con_for.cond_iter = cond[0];
|
||||
else if(array_length(_itr) == 2) {
|
||||
con_for.cond_indx = string_trim(_itr[0]);
|
||||
con_for.cond_iter = string_trim(_itr[1]);
|
||||
}
|
||||
} else if(array_length(cond) == 3) {
|
||||
con_for.itr_array = false;
|
||||
con_for.cond_init = evaluateFunctionTree(cond[0]);
|
||||
con_for.cond_iter = evaluateFunctionTree(cond[1]);
|
||||
con_for.cond_term = evaluateFunctionTree(cond[2]);
|
||||
}
|
||||
ds_stack_top(call_st).addFunction(con_for);
|
||||
ds_stack_push(call_st, con_for.action);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(ds_stack_empty(call_st)) {
|
||||
print("Block stack empty, how?");
|
||||
} else {
|
||||
var _top = ds_stack_top(call_st);
|
||||
_top.addFunction(evaluateFunctionTree(_fx));
|
||||
}
|
||||
}
|
||||
|
||||
ds_stack_destroy(call_st);
|
||||
ds_stack_destroy(blok_st);
|
||||
|
||||
return flist;
|
||||
} #endregion
|
||||
|
||||
function evaluateFunctionTree(fx) { #region //////////////////////////////////////////// STATEMENT PARSER ////////////////////////////////////////////
|
||||
static __BRACKETS = [ "(", ")", "[", "]", "]" ];
|
||||
|
||||
var pres = global.EQUATION_PRES;
|
||||
var vl = ds_stack_create();
|
||||
var op = ds_stack_create();
|
||||
var last_push = "";
|
||||
|
||||
fx = functionStringClean(fx);
|
||||
var len = string_length(fx);
|
||||
var l = 1;
|
||||
var ch = "";
|
||||
var cch = "";
|
||||
var _ch = "";
|
||||
var in_str = false;
|
||||
|
||||
printIf(global.LOG_EXPRESSION, $"===== Evaluating function: {fx} =====");
|
||||
|
||||
while(l <= len) {
|
||||
ch = string_char_at(fx, l);
|
||||
|
||||
printIf(global.LOG_EXPRESSION, $"\n\n>>>>>>>>> Analyzing {ch}");
|
||||
|
||||
if(ds_map_exists(pres, ch)) { //symbol is operator
|
||||
last_push = "op";
|
||||
|
||||
if(ds_stack_empty(op)) ds_stack_push(op, ch);
|
||||
else {
|
||||
var _top = ds_stack_top(op);
|
||||
if(_top == "(" || ds_map_exists(global.PCX_FUNCTIONS, _top) || pres[? ch] > pres[? _top]) {
|
||||
ds_stack_push(op, ch);
|
||||
} else {
|
||||
while(pres[? ch] <= pres[? ds_stack_top(op)] && !ds_stack_empty(op))
|
||||
ds_stack_push(vl, buildFuncTree(ds_stack_pop(op), vl));
|
||||
ds_stack_push(op, ch);
|
||||
}
|
||||
}
|
||||
|
||||
l++;
|
||||
} else if (ch == "(") {
|
||||
if(last_push == "fn") ds_stack_push(op, [ "〚", ds_stack_size(vl) ]);
|
||||
else ds_stack_push(op, ch);
|
||||
last_push = "op";
|
||||
l++;
|
||||
} else if (ch == ")") {
|
||||
while(!ds_stack_empty(op)) {
|
||||
var _top = ds_stack_pop(op);
|
||||
if(_top == "(") break;
|
||||
if(is_array(_top) && _top[0] == "〚") {
|
||||
var arr = [];
|
||||
while(ds_stack_size(vl) > _top[1])
|
||||
array_insert(arr, 0, ds_stack_pop(vl));
|
||||
|
||||
ds_stack_push(vl, new __funcTree(ds_stack_pop(op), arr));
|
||||
break;
|
||||
}
|
||||
|
||||
ds_stack_push(vl, buildFuncTree(_top, vl));
|
||||
}
|
||||
|
||||
last_push = "vl";
|
||||
l++;
|
||||
} else if (ch == "[") {
|
||||
if(last_push == "vl") { // Get array member | a[1]
|
||||
ds_stack_push(op, "@");
|
||||
ds_stack_push(op, ch);
|
||||
} else // Create array member | a = [1]
|
||||
ds_stack_push(op, [ "{", ds_stack_size(vl) ]);
|
||||
|
||||
last_push = "op";
|
||||
l++;
|
||||
} else if (ch == "]") {
|
||||
while(!ds_stack_empty(op)) {
|
||||
var _top = ds_stack_pop(op);
|
||||
if(_top == "[") break;
|
||||
if(is_array(_top) && _top[0] == "{") {
|
||||
var arr = [];
|
||||
while(ds_stack_size(vl) > _top[1])
|
||||
array_insert(arr, 0, ds_stack_pop(vl));
|
||||
|
||||
ds_stack_push(vl, new __funcTree("【", arr));
|
||||
break;
|
||||
}
|
||||
|
||||
ds_stack_push(vl, buildFuncTree(_top, vl));
|
||||
}
|
||||
|
||||
last_push = "vl";
|
||||
l++;
|
||||
} else if (ch == ",") {
|
||||
while(!ds_stack_empty(op)) {
|
||||
var _top = ds_stack_top(op);
|
||||
if(_top == "[" || _top == "(") break;
|
||||
if(is_array(_top) && (_top[0] == "{" || _top[0] == "〚")) break;
|
||||
|
||||
var _top = ds_stack_pop(op);
|
||||
ds_stack_push(vl, buildFuncTree(_top, vl));
|
||||
}
|
||||
|
||||
last_push = "op";
|
||||
l++;
|
||||
} else {
|
||||
var vsl = "";
|
||||
|
||||
while(l <= len) {
|
||||
cch = string_char_at(fx, l);
|
||||
if(ds_map_exists(pres, cch) || array_exists(__BRACKETS, cch)) break;
|
||||
if(cch == ",")
|
||||
break;
|
||||
|
||||
vsl += cch;
|
||||
l++;
|
||||
}
|
||||
|
||||
if(vsl == "") continue;
|
||||
|
||||
if(ds_map_exists(global.PCX_FUNCTIONS, vsl)) { //function
|
||||
ds_stack_push(op, vsl);
|
||||
last_push = "fn";
|
||||
} else {
|
||||
vsl = string_trim(vsl);
|
||||
|
||||
switch(vsl) {
|
||||
case "e" : ds_stack_push(vl, 2.7182818284); break;
|
||||
case "pi": ds_stack_push(vl, pi); break;
|
||||
default : ds_stack_push(vl, isNumber(vsl)? toNumber(vsl) : vsl); break;
|
||||
}
|
||||
|
||||
last_push = "vl";
|
||||
}
|
||||
}
|
||||
|
||||
printIf(global.LOG_EXPRESSION, $"\n\tvl = {ds_stack_to_array(vl)}\n\top = {ds_stack_to_array(op)}");
|
||||
|
||||
_ch = ch;
|
||||
}
|
||||
|
||||
while(!ds_stack_empty(op))
|
||||
ds_stack_push(vl, buildFuncTree(ds_stack_pop(op), vl));
|
||||
|
||||
var tree = ds_stack_empty(vl)? noone : ds_stack_pop(vl);
|
||||
|
||||
ds_stack_destroy(op);
|
||||
ds_stack_destroy(vl);
|
||||
|
||||
if(!is_struct(tree))
|
||||
tree = new __funcTree("", tree);
|
||||
|
||||
printIf(global.LOG_EXPRESSION, tree);
|
||||
printIf(global.LOG_EXPRESSION, "");
|
||||
|
||||
return tree;
|
||||
} #endregion
|
||||
|
||||
function buildFuncTree(operator, vl) { #region
|
||||
if(ds_stack_empty(vl)) return noone;
|
||||
|
||||
if(ds_map_exists(global.PCX_FUNCTIONS, operator)) {
|
||||
if(ds_stack_empty(vl))
|
||||
return noone;
|
||||
|
||||
var _v1 = ds_stack_pop(vl);
|
||||
return new __funcTree(operator, _v1);
|
||||
}
|
||||
|
||||
switch(operator) {
|
||||
case "@":
|
||||
var _v1 = ds_stack_pop(vl);
|
||||
var _v2 = ds_stack_pop(vl);
|
||||
return new __funcTree(operator, _v2, _v1);
|
||||
|
||||
case "-":
|
||||
case "∸":
|
||||
|
||||
case "+": //binary operators
|
||||
case "*":
|
||||
case "$":
|
||||
case "/":
|
||||
case "%":
|
||||
|
||||
case "|":
|
||||
case "&":
|
||||
case "^":
|
||||
case "»":
|
||||
case "«":
|
||||
|
||||
case "=":
|
||||
case "⩵":
|
||||
case "≠":
|
||||
case "≤":
|
||||
case "≥":
|
||||
case "<":
|
||||
case ">":
|
||||
|
||||
case "⊕":
|
||||
case "⊖":
|
||||
case "⊗":
|
||||
case "⊘":
|
||||
|
||||
if(ds_stack_size(vl) >= 2) {
|
||||
var _v1 = ds_stack_pop(vl);
|
||||
var _v2 = ds_stack_pop(vl);
|
||||
return new __funcTree(operator, _v2, _v1);
|
||||
}
|
||||
|
||||
default: return new __funcTree(operator, ds_stack_pop(vl));
|
||||
}
|
||||
|
||||
return noone;
|
||||
} #endregion
|
||||
#endregion
|
418
#backups/scripts/pcx_parse/pcx_parse.gml.backup1
Normal file
418
#backups/scripts/pcx_parse/pcx_parse.gml.backup1
Normal file
|
@ -0,0 +1,418 @@
|
|||
// 2024-04-24 07:54:27
|
||||
#region symbols
|
||||
global.LOG_EXPRESSION = true;
|
||||
|
||||
global.EQUATION_PRES = ds_map_create();
|
||||
global.EQUATION_PRES[? "+"] = 1;
|
||||
global.EQUATION_PRES[? "-"] = 1;
|
||||
global.EQUATION_PRES[? "∸"] = 9; //unary negative
|
||||
global.EQUATION_PRES[? "*"] = 2;
|
||||
global.EQUATION_PRES[? "/"] = 2;
|
||||
global.EQUATION_PRES[? "%"] = 2;
|
||||
global.EQUATION_PRES[? "$"] = 3; //power
|
||||
|
||||
global.EQUATION_PRES[? "&"] = 5;
|
||||
global.EQUATION_PRES[? "|"] = 4;
|
||||
global.EQUATION_PRES[? "^"] = 3;
|
||||
global.EQUATION_PRES[? "<"] = 3;
|
||||
global.EQUATION_PRES[? "»"] = 6;
|
||||
global.EQUATION_PRES[? "«"] = 6;
|
||||
global.EQUATION_PRES[? "~"] = 9;
|
||||
|
||||
global.EQUATION_PRES[? "="] = -99;
|
||||
global.EQUATION_PRES[? "⊕"] = -99; //+=
|
||||
global.EQUATION_PRES[? "⊖"] = -99; //-=
|
||||
global.EQUATION_PRES[? "⊗"] = -99; //*=
|
||||
global.EQUATION_PRES[? "⊘"] = -99; ///=
|
||||
|
||||
global.EQUATION_PRES[? "⩵"] = -1; //==
|
||||
global.EQUATION_PRES[? "≠"] = -1; //!=
|
||||
global.EQUATION_PRES[? "<"] = 0;
|
||||
global.EQUATION_PRES[? ">"] = 0;
|
||||
global.EQUATION_PRES[? "≤"] = 0;
|
||||
global.EQUATION_PRES[? "≥"] = 0;
|
||||
|
||||
global.EQUATION_PRES[? "@"] = 5; //array accerssor symbol
|
||||
|
||||
#endregion
|
||||
|
||||
#region parser
|
||||
function functionStringClean(fx) { #region
|
||||
static __BRACKETS = [ "(", "[", "," ];
|
||||
|
||||
var ch = "", ind = 0, len = string_length(fx);
|
||||
var _fx = "", str = false;
|
||||
var _prevSym = true;
|
||||
|
||||
while(ind++ <= len) {
|
||||
ch = string_char_at(fx, ind);
|
||||
|
||||
if(ch == " ") {
|
||||
if(str) _fx += ch;
|
||||
} else {
|
||||
if(ch == "-" && _prevSym)
|
||||
_fx += $"0∸";
|
||||
else
|
||||
_fx += ch;
|
||||
|
||||
_prevSym = ds_map_exists(global.EQUATION_PRES, ch) || array_exists(__BRACKETS, ch);
|
||||
}
|
||||
|
||||
if(ch == "\"")
|
||||
str = !str;
|
||||
}
|
||||
|
||||
fx = _fx;
|
||||
|
||||
fx = string_replace_all(fx, "\n", "");
|
||||
fx = string_replace_all(fx, "**", "$");
|
||||
fx = string_replace_all(fx, "<<", "«");
|
||||
fx = string_replace_all(fx, ">>", "»");
|
||||
|
||||
fx = string_replace_all(fx, "==", "⩵");
|
||||
fx = string_replace_all(fx, "!=", "≠");
|
||||
fx = string_replace_all(fx, "<>", "≠");
|
||||
fx = string_replace_all(fx, ">=", "≥");
|
||||
fx = string_replace_all(fx, "<=", "≤");
|
||||
|
||||
fx = string_replace_all(fx, "++", "⊕1");
|
||||
fx = string_replace_all(fx, "--", "⊖1");
|
||||
|
||||
fx = string_replace_all(fx, "+=", "⊕");
|
||||
fx = string_replace_all(fx, "-=", "⊖");
|
||||
fx = string_replace_all(fx, "*=", "⊗");
|
||||
fx = string_replace_all(fx, "/=", "⊘");
|
||||
|
||||
fx = string_replace_all(fx, "]", ",]");
|
||||
|
||||
fx = string_trim(fx);
|
||||
|
||||
return fx;
|
||||
} #endregion
|
||||
|
||||
function functionStrip(fx) { #region
|
||||
var el_st = 1;
|
||||
var el_ed = 1;
|
||||
|
||||
for( var i = 1; i <= string_length(fx); i++ ) {
|
||||
var cch = string_char_at(fx, i);
|
||||
if(cch == "(") {
|
||||
el_st = i + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for( var i = string_length(fx); i >= 1; i-- ) {
|
||||
var cch = string_char_at(fx, i);
|
||||
if(cch == ")") {
|
||||
el_ed = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return string_copy(fx, el_st, el_ed - el_st)
|
||||
} #endregion
|
||||
|
||||
function evaluateFunctionList(fx) { #region
|
||||
fx = string_replace_all(fx, "{", "\n{\n");
|
||||
fx = string_replace_all(fx, "}", "\n}\n");
|
||||
|
||||
var fxs = string_split(fx, "\n", true);
|
||||
|
||||
var flist = new __funcList();
|
||||
|
||||
var call_st = ds_stack_create();
|
||||
var blok_st = ds_stack_create();
|
||||
ds_stack_push(call_st, flist);
|
||||
|
||||
for( var i = 0, n = array_length(fxs); i < n; i++ ) {
|
||||
var _fx = functionStringClean(fxs[i]);
|
||||
//print($"Eval line {i}: {_fx} [stack size = {ds_stack_size(call_st)}]");
|
||||
|
||||
if(_fx == "" || _fx == "{") continue;
|
||||
if(_fx == "}") {
|
||||
ds_stack_pop(call_st);
|
||||
continue;
|
||||
}
|
||||
|
||||
var _fx_sp = string_split(_fx, "(");
|
||||
var _cmd = string_trim(_fx_sp[0]);
|
||||
var _cond = functionStrip(_fx);
|
||||
|
||||
switch(_cmd) {
|
||||
case "if":
|
||||
var con_if = new __funcIf();
|
||||
con_if.condition = evaluateFunctionTree(_cond);
|
||||
ds_stack_top(call_st).addFunction(con_if);
|
||||
ds_stack_push(call_st, con_if.if_true);
|
||||
ds_stack_push(blok_st, con_if);
|
||||
continue;
|
||||
|
||||
case "elseif":
|
||||
var con_if = ds_stack_pop(blok_st);
|
||||
var con_elif = new __funcIf();
|
||||
con_elif.condition = evaluateFunctionTree(_cond);
|
||||
|
||||
con_if.if_false.addFunction(con_elif);
|
||||
ds_stack_push(call_st, con_elif.if_true);
|
||||
ds_stack_push(blok_st, con_elif);
|
||||
continue;
|
||||
|
||||
case "else":
|
||||
var con_if = ds_stack_pop(blok_st);
|
||||
|
||||
ds_stack_push(call_st, con_if.if_false);
|
||||
continue;
|
||||
|
||||
case "for":
|
||||
|
||||
var con_for = new __funcFor();
|
||||
var cond = string_splice(_cond, ":");
|
||||
if(array_length(cond) == 2) {
|
||||
con_for.itr_array = true;
|
||||
con_for.cond_arr = evaluateFunctionTree(cond[1]);
|
||||
|
||||
cond[0] = string_trim(cond[0]);
|
||||
var _itr = string_split(cond[0], ",");
|
||||
if(array_length(_itr) == 1)
|
||||
con_for.cond_iter = cond[0];
|
||||
else if(array_length(_itr) == 2) {
|
||||
con_for.cond_indx = string_trim(_itr[0]);
|
||||
con_for.cond_iter = string_trim(_itr[1]);
|
||||
}
|
||||
} else if(array_length(cond) == 3) {
|
||||
con_for.itr_array = false;
|
||||
con_for.cond_init = evaluateFunctionTree(cond[0]);
|
||||
con_for.cond_iter = evaluateFunctionTree(cond[1]);
|
||||
con_for.cond_term = evaluateFunctionTree(cond[2]);
|
||||
}
|
||||
ds_stack_top(call_st).addFunction(con_for);
|
||||
ds_stack_push(call_st, con_for.action);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(ds_stack_empty(call_st)) {
|
||||
print("Block stack empty, how?");
|
||||
} else {
|
||||
var _top = ds_stack_top(call_st);
|
||||
_top.addFunction(evaluateFunctionTree(_fx));
|
||||
}
|
||||
}
|
||||
|
||||
ds_stack_destroy(call_st);
|
||||
ds_stack_destroy(blok_st);
|
||||
|
||||
return flist;
|
||||
} #endregion
|
||||
|
||||
function evaluateFunctionTree(fx) { #region //////////////////////////////////////////// STATEMENT PARSER ////////////////////////////////////////////
|
||||
static __BRACKETS = [ "(", ")", "[", "]", "]" ];
|
||||
|
||||
var pres = global.EQUATION_PRES;
|
||||
var vl = ds_stack_create();
|
||||
var op = ds_stack_create();
|
||||
var last_push = "";
|
||||
|
||||
fx = functionStringClean(fx);
|
||||
var len = string_length(fx);
|
||||
var l = 1;
|
||||
var ch = "";
|
||||
var cch = "";
|
||||
var _ch = "";
|
||||
var in_str = false;
|
||||
|
||||
printIf(global.LOG_EXPRESSION, $"===== Evaluating function: {fx} =====");
|
||||
|
||||
while(l <= len) {
|
||||
ch = string_char_at(fx, l);
|
||||
|
||||
printIf(global.LOG_EXPRESSION, $"\n\n>>>>>>>>> Analyzing {ch}");
|
||||
|
||||
if(ds_map_exists(pres, ch)) { //symbol is operator
|
||||
last_push = "op";
|
||||
|
||||
if(ds_stack_empty(op)) ds_stack_push(op, ch);
|
||||
else {
|
||||
var _top = ds_stack_top(op);
|
||||
if(_top == "(" || ds_map_exists(global.PCX_FUNCTIONS, _top) || pres[? ch] > pres[? _top]) {
|
||||
ds_stack_push(op, ch);
|
||||
} else {
|
||||
while(pres[? ch] <= pres[? ds_stack_top(op)] && !ds_stack_empty(op))
|
||||
ds_stack_push(vl, buildFuncTree(ds_stack_pop(op), vl));
|
||||
ds_stack_push(op, ch);
|
||||
}
|
||||
}
|
||||
|
||||
l++;
|
||||
} else if (ch == "(") {
|
||||
if(last_push == "fn") ds_stack_push(op, [ "〚", ds_stack_size(vl) ]);
|
||||
else ds_stack_push(op, ch);
|
||||
last_push = "op";
|
||||
l++;
|
||||
} else if (ch == ")") {
|
||||
while(!ds_stack_empty(op)) {
|
||||
var _top = ds_stack_pop(op);
|
||||
if(_top == "(") break;
|
||||
if(is_array(_top) && _top[0] == "〚") {
|
||||
var arr = [];
|
||||
while(ds_stack_size(vl) > _top[1])
|
||||
array_insert(arr, 0, ds_stack_pop(vl));
|
||||
|
||||
ds_stack_push(vl, new __funcTree(ds_stack_pop(op), arr));
|
||||
break;
|
||||
}
|
||||
|
||||
ds_stack_push(vl, buildFuncTree(_top, vl));
|
||||
}
|
||||
|
||||
last_push = "vl";
|
||||
l++;
|
||||
} else if (ch == "[") {
|
||||
if(last_push == "vl") { // Get array member | a[1]
|
||||
ds_stack_push(op, "@");
|
||||
ds_stack_push(op, ch);
|
||||
} else // Create array member | a = [1]
|
||||
ds_stack_push(op, [ "{", ds_stack_size(vl) ]);
|
||||
|
||||
last_push = "op";
|
||||
l++;
|
||||
} else if (ch == "]") {
|
||||
while(!ds_stack_empty(op)) {
|
||||
var _top = ds_stack_pop(op);
|
||||
if(_top == "[") break;
|
||||
if(is_array(_top) && _top[0] == "{") {
|
||||
var arr = [];
|
||||
while(ds_stack_size(vl) > _top[1])
|
||||
array_insert(arr, 0, ds_stack_pop(vl));
|
||||
|
||||
ds_stack_push(vl, new __funcTree("【", arr));
|
||||
break;
|
||||
}
|
||||
|
||||
ds_stack_push(vl, buildFuncTree(_top, vl));
|
||||
}
|
||||
|
||||
last_push = "vl";
|
||||
l++;
|
||||
} else if (ch == ",") {
|
||||
while(!ds_stack_empty(op)) {
|
||||
var _top = ds_stack_top(op);
|
||||
if(_top == "[" || _top == "(") break;
|
||||
if(is_array(_top) && (_top[0] == "{" || _top[0] == "〚")) break;
|
||||
|
||||
var _top = ds_stack_pop(op);
|
||||
ds_stack_push(vl, buildFuncTree(_top, vl));
|
||||
}
|
||||
|
||||
last_push = "op";
|
||||
l++;
|
||||
} else {
|
||||
var vsl = "";
|
||||
|
||||
while(l <= len) {
|
||||
cch = string_char_at(fx, l);
|
||||
if(ds_map_exists(pres, cch) || array_exists(__BRACKETS, cch)) break;
|
||||
if(cch == ",")
|
||||
break;
|
||||
|
||||
vsl += cch;
|
||||
l++;
|
||||
}
|
||||
|
||||
if(vsl == "") continue;
|
||||
|
||||
if(ds_map_exists(global.PCX_FUNCTIONS, vsl)) { //function
|
||||
ds_stack_push(op, vsl);
|
||||
last_push = "fn";
|
||||
} else {
|
||||
vsl = string_trim(vsl);
|
||||
|
||||
switch(vsl) {
|
||||
case "e" : ds_stack_push(vl, 2.7182818284); break;
|
||||
case "pi": ds_stack_push(vl, pi); break;
|
||||
default : ds_stack_push(vl, isNumber(vsl)? toNumber(vsl) : vsl); break;
|
||||
}
|
||||
|
||||
last_push = "vl";
|
||||
}
|
||||
}
|
||||
|
||||
printIf(global.LOG_EXPRESSION, $"\n\tvl = {ds_stack_to_array(vl)}\n\top = {ds_stack_to_array(op)}");
|
||||
|
||||
_ch = ch;
|
||||
}
|
||||
|
||||
while(!ds_stack_empty(op))
|
||||
ds_stack_push(vl, buildFuncTree(ds_stack_pop(op), vl));
|
||||
|
||||
var tree = ds_stack_empty(vl)? noone : ds_stack_pop(vl);
|
||||
|
||||
ds_stack_destroy(op);
|
||||
ds_stack_destroy(vl);
|
||||
|
||||
if(!is_struct(tree))
|
||||
tree = new __funcTree("", tree);
|
||||
|
||||
printIf(global.LOG_EXPRESSION, tree);
|
||||
printIf(global.LOG_EXPRESSION, "");
|
||||
|
||||
return tree;
|
||||
} #endregion
|
||||
|
||||
function buildFuncTree(operator, vl) { #region
|
||||
if(ds_stack_empty(vl)) return noone;
|
||||
|
||||
if(ds_map_exists(global.PCX_FUNCTIONS, operator)) {
|
||||
if(ds_stack_empty(vl))
|
||||
return noone;
|
||||
|
||||
var _v1 = ds_stack_pop(vl);
|
||||
return new __funcTree(operator, _v1);
|
||||
}
|
||||
|
||||
switch(operator) {
|
||||
case "@":
|
||||
var _v1 = ds_stack_pop(vl);
|
||||
var _v2 = ds_stack_pop(vl);
|
||||
return new __funcTree(operator, _v2, _v1);
|
||||
|
||||
case "-":
|
||||
case "∸":
|
||||
|
||||
case "+": //binary operators
|
||||
case "*":
|
||||
case "$":
|
||||
case "/":
|
||||
case "%":
|
||||
|
||||
case "|":
|
||||
case "&":
|
||||
case "^":
|
||||
case "»":
|
||||
case "«":
|
||||
|
||||
case "=":
|
||||
case "⩵":
|
||||
case "≠":
|
||||
case "≤":
|
||||
case "≥":
|
||||
case "<":
|
||||
case ">":
|
||||
|
||||
case "⊕":
|
||||
case "⊖":
|
||||
case "⊗":
|
||||
case "⊘":
|
||||
|
||||
if(ds_stack_size(vl) >= 2) {
|
||||
var _v1 = ds_stack_pop(vl);
|
||||
var _v2 = ds_stack_pop(vl);
|
||||
return new __funcTree(operator, _v2, _v1);
|
||||
}
|
||||
|
||||
default: return new __funcTree(operator, ds_stack_pop(vl));
|
||||
}
|
||||
|
||||
return noone;
|
||||
} #endregion
|
||||
#endregion
|
|
@ -1,9 +1,8 @@
|
|||
function Node_Number(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
|
||||
function Node_Number(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
||||
name = "Number";
|
||||
color = COLORS.node_blend_number;
|
||||
|
||||
setDimension(96, 32 + 24 * 1);
|
||||
display_output = 0;
|
||||
|
||||
wd_slider = slider(0, 1, 0.01, function(val) { inputs[| 0].setValue(val); } );
|
||||
wd_slider.spr = THEME.node_slider;
|
||||
|
@ -34,7 +33,7 @@ function Node_Number(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) co
|
|||
|
||||
inputs[| 4] = nodeValue("Step", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.01)
|
||||
|
||||
inputs[| 5] = nodeValue("Clamp to range", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true)
|
||||
inputs[| 5] = nodeValue("Clamp to range", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true);
|
||||
|
||||
outputs[| 0] = nodeValue("Number", self, JUNCTION_CONNECT.output, VALUE_TYPE.float, 0);
|
||||
|
||||
|
@ -81,16 +80,24 @@ function Node_Number(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) co
|
|||
outputs[| 0].setType(int? VALUE_TYPE.integer : VALUE_TYPE.float);
|
||||
} #endregion
|
||||
|
||||
static processData = function(_output, _data, _output_index, _array_index = 0) { #region
|
||||
var _dat = _data[0];
|
||||
var _int = _data[1];
|
||||
static processNumber = function(_val, _int) {
|
||||
if(is_string(_val)) return _int? round(toNumber(_val)) : toNumber(_val);
|
||||
if(is_numeric(_val)) return _int? round(_val) : _val;
|
||||
|
||||
if(is_array(_dat)) return _dat;
|
||||
if(!is_numeric(_dat)) _dat = real(_dat);
|
||||
if(_int) _dat = round(_dat);
|
||||
if(is_array(_val)) {
|
||||
for (var i = 0, n = array_length(_val); i < n; i++)
|
||||
_val[i] = processNumber(_val[i], _int);
|
||||
}
|
||||
|
||||
display_output = _dat;
|
||||
return _dat;
|
||||
return _val;
|
||||
}
|
||||
|
||||
static update = function() { #region
|
||||
var _dat = getInputData(0);
|
||||
var _int = getInputData(1);
|
||||
|
||||
var _res = processNumber(_dat, _int);
|
||||
outputs[| 0].setValue(_res);
|
||||
} #endregion
|
||||
|
||||
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region
|
||||
|
@ -113,7 +120,7 @@ function Node_Number(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) co
|
|||
|
||||
case 1 : #region
|
||||
draw_set_text(f_sdf, fa_center, fa_center, _col);
|
||||
draw_text_transformed(bbox.xc, bbox.y0 + 16 * _s, _int? round(val) : val, _s * 0.5, _s * 0.5, 0);
|
||||
draw_text_transformed(bbox.xc, bbox.y0 + 16 * _s, string(_int? round(val) : val), _s * 0.5, _s * 0.5, 0);
|
||||
|
||||
var sl_w = bbox.w - 8 * _s;
|
||||
var sl_h = _s * 40;
|
||||
|
@ -173,6 +180,7 @@ function Node_Number(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) co
|
|||
}
|
||||
|
||||
break; #endregion
|
||||
|
||||
case 2 : #region
|
||||
var _ss = min(bbox.w, bbox.h);
|
||||
var c0 = (draggable && !rotator_dragging)? colorMultiply(CDEF.main_grey, _col) : colorMultiply(CDEF.main_white, _col);
|
||||
|
@ -222,7 +230,7 @@ function Node_Number(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) co
|
|||
}
|
||||
|
||||
draw_set_text(f_sdf, fa_center, fa_center, colorMultiply(CDEF.main_white, _col));
|
||||
draw_text_transformed(bbox.xc, bbox.yc, _int? round(val) : string_format(val, -1, 2), _s * .5, _s * .5, 0);
|
||||
draw_text_transformed(bbox.xc, bbox.yc, _int? string(round(val)) : string_format(val, -1, 2), _s * .5, _s * .5, 0);
|
||||
break; #endregion
|
||||
}
|
||||
} #endregion
|
||||
|
|
|
@ -1598,12 +1598,17 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
|
|||
} #endregion
|
||||
|
||||
static valueExpressionProcess = function(value) { #region
|
||||
if(is_array(value)) {
|
||||
for (var i = 0, n = array_length(value); i < n; i++)
|
||||
value[i] = valueExpressionProcess(value[i]);
|
||||
return value;
|
||||
}
|
||||
|
||||
switch(type) {
|
||||
case VALUE_TYPE.float :
|
||||
case VALUE_TYPE.integer :
|
||||
if(!is_numeric(value))
|
||||
return toNumber(value);
|
||||
break;
|
||||
return is_numeric(value)? value : toNumber(value);
|
||||
|
||||
case VALUE_TYPE.boolean :
|
||||
return bool(value);
|
||||
}
|
||||
|
@ -1635,6 +1640,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
|
|||
}
|
||||
|
||||
var val = _getValue(_time, applyUnit, arrIndex, log);
|
||||
|
||||
if(!accept_array && array_get_depth(val) > def_depth) {
|
||||
noti_warning($"{name} does not accept array data.",, node);
|
||||
return 0;
|
||||
|
@ -1662,25 +1668,6 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
|
|||
return val;
|
||||
} #endregion
|
||||
|
||||
static arrayBalance = function(val) { #region // Balance array (generate uniform array from single values)
|
||||
if(!is_array(def_val))
|
||||
return val;
|
||||
|
||||
if(isDynamicArray())
|
||||
return val;
|
||||
|
||||
if(isArray(val))
|
||||
return val;
|
||||
|
||||
if(!is_array(val))
|
||||
return array_create(def_length, val);
|
||||
|
||||
if(array_length(val) < def_length)
|
||||
array_resize(val, def_length);
|
||||
|
||||
return val;
|
||||
} #endregion
|
||||
|
||||
static _getValue = function(_time = CURRENT_FRAME, applyUnit = true, arrIndex = 0, log = false) { #region
|
||||
|
||||
getValueRecursive(self.__curr_get_val, _time);
|
||||
|
@ -1693,15 +1680,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
|
|||
if(connect_type == JUNCTION_CONNECT.output)
|
||||
return val;
|
||||
|
||||
if(expUse) { #region expression
|
||||
if(is_array(val)) {
|
||||
for( var i = 0, n = array_length(val); i < n; i++ )
|
||||
val[i] = valueExpressionProcess(val[i]);
|
||||
} else
|
||||
val = valueExpressionProcess(val);
|
||||
return arrayBalance(val);
|
||||
|
||||
} #endregion
|
||||
if(expUse) return arrayBalance(valueExpressionProcess(val));
|
||||
|
||||
if(typ == VALUE_TYPE.surface && (type == VALUE_TYPE.integer || type == VALUE_TYPE.float)) { #region Dimension conversion
|
||||
if(is_array(val)) {
|
||||
|
@ -1798,6 +1777,25 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
|
|||
}
|
||||
} #endregion
|
||||
|
||||
static arrayBalance = function(val) { #region
|
||||
if(!is_array(def_val))
|
||||
return val;
|
||||
|
||||
if(isDynamicArray())
|
||||
return val;
|
||||
|
||||
if(isArray(val))
|
||||
return val;
|
||||
|
||||
if(!is_array(val))
|
||||
return array_create(def_length, val);
|
||||
|
||||
if(array_length(val) < def_length)
|
||||
array_resize(val, def_length);
|
||||
|
||||
return val;
|
||||
} #endregion
|
||||
|
||||
static __getAnimValue = function(_time = CURRENT_FRAME) { #region
|
||||
|
||||
if(value_tag == "dimension" && node.attributes.use_project_dimension)
|
||||
|
|
|
@ -225,7 +225,7 @@
|
|||
while(l <= len) {
|
||||
ch = string_char_at(fx, l);
|
||||
|
||||
printIf(global.LOG_EXPRESSION, $"Analyzing {ch}");
|
||||
printIf(global.LOG_EXPRESSION, $"\n\n>>>>>>>>> Analyzing {ch}");
|
||||
|
||||
if(ds_map_exists(pres, ch)) { //symbol is operator
|
||||
last_push = "op";
|
||||
|
@ -336,7 +336,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
printIf(global.LOG_EXPRESSION, $"\tvl = {ds_stack_to_array(vl)}\n\top = {ds_stack_to_array(op)}");
|
||||
printIf(global.LOG_EXPRESSION, $"\n\tvl = {ds_stack_to_array(vl)}\n\top = {ds_stack_to_array(op)}");
|
||||
|
||||
_ch = ch;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue