[Array] Creating array of mixed types will output array of any type.

This commit is contained in:
Tanasart 2025-01-28 09:20:58 +07:00
parent 5e940692fa
commit caa1e57cd6
7 changed files with 28 additions and 19 deletions

View file

@ -257,8 +257,9 @@
{"name":"palette mixer","order":2,"path":"folders/shader/UI/palette mixer.yy",}, {"name":"palette mixer","order":2,"path":"folders/shader/UI/palette mixer.yy",},
{"name":"sprites","order":336,"path":"folders/sprites.yy",}, {"name":"sprites","order":336,"path":"folders/sprites.yy",},
{"name":"bs","order":3,"path":"folders/sprites/bs.yy",}, {"name":"bs","order":3,"path":"folders/sprites/bs.yy",},
{"name":"font","order":1,"path":"folders/sprites/font.yy",},
{"name":"gameframe","order":4,"path":"folders/sprites/gameframe.yy",}, {"name":"gameframe","order":4,"path":"folders/sprites/gameframe.yy",},
{"name":"meta","order":1,"path":"folders/sprites/meta.yy",}, {"name":"meta","order":2,"path":"folders/sprites/meta.yy",},
{"name":"misc","order":5,"path":"folders/sprites/misc.yy",}, {"name":"misc","order":5,"path":"folders/sprites/misc.yy",},
{"name":"nodes","order":6,"path":"folders/sprites/nodes.yy",}, {"name":"nodes","order":6,"path":"folders/sprites/nodes.yy",},
{"name":"profiler","order":8,"path":"folders/sprites/profiler.yy",}, {"name":"profiler","order":8,"path":"folders/sprites/profiler.yy",},
@ -1862,7 +1863,6 @@
{"name":"s_biterator_tab_inactive","order":11,"path":"sprites/s_biterator_tab_inactive/s_biterator_tab_inactive.yy",}, {"name":"s_biterator_tab_inactive","order":11,"path":"sprites/s_biterator_tab_inactive/s_biterator_tab_inactive.yy",},
{"name":"s_biterator_toggler","order":13,"path":"sprites/s_biterator_toggler/s_biterator_toggler.yy",}, {"name":"s_biterator_toggler","order":13,"path":"sprites/s_biterator_toggler/s_biterator_toggler.yy",},
{"name":"s_bone_constrain","order":33,"path":"sprites/s_bone_constrain/s_bone_constrain.yy",}, {"name":"s_bone_constrain","order":33,"path":"sprites/s_bone_constrain/s_bone_constrain.yy",},
{"name":"s_empty","order":9,"path":"sprites/s_empty/s_empty.yy",},
{"name":"s_fade_up","order":2,"path":"sprites/s_fade_up/s_fade_up.yy",}, {"name":"s_fade_up","order":2,"path":"sprites/s_fade_up/s_fade_up.yy",},
{"name":"s_filter_log_level","order":5,"path":"sprites/s_filter_log_level/s_filter_log_level.yy",}, {"name":"s_filter_log_level","order":5,"path":"sprites/s_filter_log_level/s_filter_log_level.yy",},
{"name":"s_filter_node_inspector","order":4,"path":"sprites/s_filter_node_inspector/s_filter_node_inspector.yy",}, {"name":"s_filter_node_inspector","order":4,"path":"sprites/s_filter_node_inspector/s_filter_node_inspector.yy",},

Binary file not shown.

View file

@ -100,7 +100,7 @@ event_inherited();
meta_filter = []; meta_filter = [];
sp_sample = new scrollPane(x1 - x0 - ui(12), y1 - y0 - 1, function(_y, _m) { sp_sample = new scrollPane(x1 - x0 - ui(12), y1 - y0 - 1, function(_y, _m) {
draw_clear_alpha(COLORS.panel_bg_clear, 0); draw_clear_alpha(COLORS.panel_bg_clear, 1);
var txt = pages[project_page]; var txt = pages[project_page];
var list, _group_label; var list, _group_label;
@ -287,9 +287,7 @@ event_inherited();
draw_set_text(f_p2, fa_center, fa_top, COLORS._main_text); draw_set_text(f_p2, fa_center, fa_top, COLORS._main_text);
name_height = max(name_height, string_height_ext(_name, -1, grid_width) + ui(8)); name_height = max(name_height, string_height_ext(_name, -1, grid_width) + ui(8));
BLEND_ALPHA draw_text_ext_add(tx, ty - ui(2), _name, -1, grid_width);
draw_text_ext(tx, ty - ui(2), _name, -1, grid_width);
BLEND_NORMAL
if(++_cur_col >= col) { if(++_cur_col >= col) {
if(name_height) { if(name_height) {

View file

@ -15,13 +15,15 @@ function Node_Array(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
var bw = _w / 2 - ui(4); var bw = _w / 2 - ui(4);
var bh = ui(36); var bh = ui(36);
if(buttonTextIconInstant(true, THEME.button_hide_fill, _x, _y + ui(8), bw, bh, _m, _focus, _hover, "", THEME.add, __txt("Add"), COLORS._main_value_positive) == 2) { var by = _y + ui(8);
if(buttonTextIconInstant(true, THEME.button_hide_fill, _x, by, bw, bh, _m, _focus, _hover, "", THEME.add, __txt("Add"), COLORS._main_value_positive) == 2) {
attributes.size = max(attributes.size, (array_length(inputs) - input_fix_len) / data_length ) + 1; attributes.size = max(attributes.size, (array_length(inputs) - input_fix_len) / data_length ) + 1;
onInputResize(); onInputResize();
} }
var bx = _x + _w - bw;
var act = attributes.size > 0; var act = attributes.size > 0;
if(buttonTextIconInstant(act, THEME.button_hide_fill, _x + _w - bw, _y + ui(8), bw, bh, _m, _focus, _hover, "", THEME.minus, __txt("Remove"), COLORS._main_value_negative) == 2) { if(buttonTextIconInstant(act, THEME.button_hide_fill, bx, by, bw, bh, _m, _focus, _hover, "", THEME.minus, __txt("Remove"), COLORS._main_value_negative) == 2) {
attributes.size--; attributes.size--;
onInputResize(); onInputResize();
} }
@ -111,8 +113,6 @@ function Node_Array(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
} }
} }
// w = _typ == VALUE_TYPE.surface? 128 : 96;
refreshDynamicInput(); refreshDynamicInput();
} }
@ -144,16 +144,27 @@ function Node_Array(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
var res = []; var res = [];
var ind = 0; var ind = 0;
var _set = _typ == VALUE_TYPE.any;
var _setT = VALUE_TYPE.any;
for( var i = input_fix_len; i < array_length(inputs); i++ ) { for( var i = input_fix_len; i < array_length(inputs); i++ ) {
var val = getInputData(i); var val = getInputData(i);
if(is_array(val) && spd) array_append(res, val); if(is_array(val) && spd) array_append(res, val);
else array_push(res, val); else array_push(res, val);
if(_typ == VALUE_TYPE.any && inputs[i].value_from) if(inputs[i].value_from == noone) continue;
outputs[0].setType(inputs[i].value_from.type);
if(_set) {
_setT = inputs[i].value_from.type;
_set = false;
} else if(_setT != inputs[i].value_from.type)
_setT = VALUE_TYPE.any;
} }
if(_typ == VALUE_TYPE.any) outputs[0].setType(_setT);
outputs[0].setValue(res); outputs[0].setValue(res);
} }

View file

@ -66,9 +66,6 @@ function NodeObject(_name, _node, _tooltip = "") constructor {
author = ""; author = "";
license = ""; license = "";
_fn = registerFunctionLite("New node", name, function(n) /*=>*/ { PANEL_GRAPH.createNodeHotkey(n); }, [ nodeName ]);
_fn.spr = spr;
static init = function() { static init = function() {
if(IS_CMD) return; if(IS_CMD) return;
@ -84,6 +81,9 @@ function NodeObject(_name, _node, _tooltip = "") constructor {
static setSpr = function(_spr) { spr = _spr; return self; } static setSpr = function(_spr) { spr = _spr; return self; }
static setTooltip = function(_tool) { tooltip = _tool; return self; } static setTooltip = function(_tool) { tooltip = _tool; return self; }
static setParam = function(_par) { createParam = _par; return self; } static setParam = function(_par) { createParam = _par; return self; }
_fn = registerFunctionLite("New node", name, function(n) /*=>*/ { PANEL_GRAPH.createNodeHotkey(n); }, [ nodeName ]);
_fn.spr = spr;
static setBuild = function(_fn) { createFn = method(self, _fn); usecreateFn = true; return self; } static setBuild = function(_fn) { createFn = method(self, _fn); usecreateFn = true; return self; }
static setIO = function(t) { static setIO = function(t) {

View file

@ -1159,7 +1159,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
if(type == VALUE_TYPE.text) return display_type == VALUE_DISPLAY.text_array? value : string_real(value); if(type == VALUE_TYPE.text) return display_type == VALUE_DISPLAY.text_array? value : string_real(value);
if(typeNumeric(typeFrom) && type == VALUE_TYPE.color) return value >= 1? value : make_color_rgb(value * 255, value * 255, value * 255); if(typeNumeric(typeFrom) && type == VALUE_TYPE.color) return value;
if(typeFrom == VALUE_TYPE.boolean && type == VALUE_TYPE.text) return value? "true" : "false"; if(typeFrom == VALUE_TYPE.boolean && type == VALUE_TYPE.text) return value? "true" : "false";