- [Blend] Fix warning popup when input is empty in tile mode.

This commit is contained in:
Tanasart 2024-07-25 16:43:51 +07:00
parent b02dfa5d57
commit a5810b9345
8 changed files with 52 additions and 30 deletions

View file

@ -20,7 +20,7 @@
static getName = function() { return name; } static getName = function() { return name; }
static getTooltip = function() { return tooltip; } static getTooltip = function() { return tooltip; }
static build = function(_x = 0, _y = 0, _group = PANEL_GRAPH.getCurrentContext(), _param = {}) { #region static build = function(_x = 0, _y = 0, _group = PANEL_GRAPH.getCurrentContext(), _param = {}) {
var _n = {}; var _n = {};
for( var i = 0, n = array_length(nodes); i < n; i++ ) { for( var i = 0, n = array_length(nodes); i < n; i++ ) {
@ -40,6 +40,7 @@
var _setVal = _setVals[j]; var _setVal = _setVals[j];
var _input = is_string(_setVal.index)? _node.inputMap[? _setVal.index] : _node.inputs[| _setVal.index]; var _input = is_string(_setVal.index)? _node.inputMap[? _setVal.index] : _node.inputs[| _setVal.index];
if(_input == undefined) continue; if(_input == undefined) continue;
if(!value_type_direct_settable(_input.type)) continue;
if(struct_has(_setVal, "value")) _input.setValue(_setVal.value); if(struct_has(_setVal, "value")) _input.setValue(_setVal.value);
if(struct_has(_setVal, "unit")) _input.unit.setMode(_setVal.unit); if(struct_has(_setVal, "unit")) _input.unit.setMode(_setVal.unit);
@ -51,6 +52,7 @@
var _key = _keys[j]; var _key = _keys[j];
var _input = _node.inputs[| _key]; var _input = _node.inputs[| _key];
if(_input == undefined) continue; if(_input == undefined) continue;
if(!value_type_direct_settable(_input.type)) continue;
var _setVal = _setVals[$ _key]; var _setVal = _setVals[$ _key];
@ -76,14 +78,14 @@
} }
return _n; return _n;
} #endregion }
static serialize = function() { #region static serialize = function() {
var map = { name, tooltip, nodes, connections, tags }; var map = { name, tooltip, nodes, connections, tags };
return map; return map;
} #endregion }
static deserialize = function(path) { #region static deserialize = function(path) {
var map = json_load_struct(path); var map = json_load_struct(path);
name = struct_try_get(map, "name", ""); name = struct_try_get(map, "name", "");
@ -107,7 +109,7 @@
} }
return self; return self;
} #endregion }
} }
function NodeAction_create() : NodeAction() constructor { function NodeAction_create() : NodeAction() constructor {
@ -118,21 +120,22 @@
static build = function() { PANEL_GRAPH.createAction(); } static build = function() { PANEL_GRAPH.createAction(); }
} }
function __initNodeActions(list) { function __initNodeActions() {
var root = $"{DIRECTORY}Actions"; var root = $"{DIRECTORY}Actions";
directory_verify(root); directory_verify(root);
root += "/Nodes"; root += "/Nodes";
directory_verify(root); directory_verify(root);
ds_list_add(list, new NodeAction_create()); ds_list_clear(NODE_ACTION_LIST);
ds_list_add(NODE_ACTION_LIST, new NodeAction_create());
var f = file_find_first(root + "/*", 0); var f = file_find_first(root + "/*", 0);
while (f != "") { while (f != "") {
if(filename_ext(f) == ".json") { if(filename_ext(f) == ".json") {
var _c = new NodeAction().deserialize($"{root}/{f}"); var _c = new NodeAction().deserialize($"{root}/{f}");
ds_list_add(list, _c); ds_list_add(NODE_ACTION_LIST, _c);
if(_c.location != noone) { if(_c.location != noone) {
var _cat = array_safe_get(_c.location, 0, ""); var _cat = array_safe_get(_c.location, 0, "");

View file

@ -93,7 +93,7 @@ function Node_Blend(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) con
drag_mx = 0; drag_mx = 0;
drag_my = 0; drag_my = 0;
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { #region static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
var _surf = outputs[| 0].getValue(); var _surf = outputs[| 0].getValue();
if(is_array(_surf)) _surf = array_safe_get_fast(_surf, preview_index); if(is_array(_surf)) _surf = array_safe_get_fast(_surf, preview_index);
if(is_struct(_surf)) return; if(is_struct(_surf)) return;
@ -145,9 +145,9 @@ function Node_Blend(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) con
} }
} else } else
draw_rectangle(_rx, _ry, _rx + _rw, _ry + _rh, true); draw_rectangle(_rx, _ry, _rx + _rw, _ry + _rh, true);
} #endregion }
static step = function() { #region static step = function() {
var _back = getSingleValue(0); var _back = getSingleValue(0);
var _fore = getSingleValue(1); var _fore = getSingleValue(1);
var _fill = getSingleValue(5); var _fill = getSingleValue(5);
@ -160,9 +160,9 @@ function Node_Blend(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) con
inputs[| 7].setVisible(_outp == 4); inputs[| 7].setVisible(_outp == 4);
inputs[| 14].setVisible(_fill == 0 && !_atlas); inputs[| 14].setVisible(_fill == 0 && !_atlas);
} #endregion }
static processData = function(_outSurf, _data, _output_index, _array_index) { #region static processData = function(_outSurf, _data, _output_index, _array_index) {
var _back = _data[0]; var _back = _data[0];
var _fore = _data[1]; var _fore = _data[1];
var _type = _data[2]; var _type = _data[2];
@ -264,12 +264,12 @@ function Node_Blend(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) con
} else if(_fill == NODE_BLEND_FILL.stretch) { } else if(_fill == NODE_BLEND_FILL.stretch) {
surface_set_shader(_foreDraw, noone,, BLEND.over); surface_set_shader(_foreDraw, noone,, BLEND.over);
draw_surface_stretched(_fore, 0, 0, ww, hh); draw_surface_stretched_safe(_fore, 0, 0, ww, hh);
surface_reset_shader(); surface_reset_shader();
} else if(_fill == NODE_BLEND_FILL.tile) { } else if(_fill == NODE_BLEND_FILL.tile) {
surface_set_shader(_foreDraw, noone,, BLEND.over); surface_set_shader(_foreDraw, noone,, BLEND.over);
draw_surface_tiled(_fore, 0, 0); draw_surface_tiled_safe(_fore);
surface_reset_shader(); surface_reset_shader();
} }
@ -296,5 +296,5 @@ function Node_Blend(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) con
} }
return _outSurf; return _outSurf;
} #endregion }
} }

View file

@ -27,7 +27,7 @@ function Node_Frame(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
tb_name.hide = true; tb_name.hide = true;
tb_name.align = fa_center; tb_name.align = fa_center;
name_height = 16; name_height = 18;
draw_x0 = 0; draw_x0 = 0;
draw_y0 = 0; draw_y0 = 0;
@ -121,7 +121,7 @@ function Node_Frame(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
draw_sprite_stretched_ext(nm_spr, 0, draw_x0, draw_y0, _w, name_height, color, alpha * .75); draw_sprite_stretched_ext(nm_spr, 0, draw_x0, draw_y0, _w, name_height, color, alpha * .75);
draw_set_text(f_p2, fa_center, fa_bottom, COLORS._main_text); draw_set_text(f_p2, fa_center, fa_bottom, COLORS._main_text);
draw_text_cut((draw_x0 + draw_x1) / 2, draw_y0 + name_height + 2, txt, _w - 4); draw_text_cut((draw_x0 + draw_x1) / 2, draw_y0 + name_height + 1, txt, _w - 4);
if(point_in_rectangle(_mx, _my, draw_x0, draw_y0, draw_x0 + _w, draw_y0 + name_height)) { if(point_in_rectangle(_mx, _my, draw_x0, draw_y0, draw_x0 + _w, draw_y0 + name_height)) {
if(PANEL_GRAPH.pFOCUS && DOUBLE_CLICK) if(PANEL_GRAPH.pFOCUS && DOUBLE_CLICK)

View file

@ -1051,9 +1051,10 @@ function __initNodes() {
// addNodeObject(node, "DLL", s_node_gui_out, "Node_DLL", [1, Node_DLL]).setVersion(11750); // addNodeObject(node, "DLL", s_node_gui_out, "Node_DLL", [1, Node_DLL]).setVersion(11750);
#endregion #endregion
var actions = ds_list_create(); globalvar NODE_ACTION_LIST;
addNodeCatagory("Action", actions); NODE_ACTION_LIST = ds_list_create();
__initNodeActions(actions); addNodeCatagory("Action", NODE_ACTION_LIST);
__initNodeActions();
var customs = ds_list_create(); var customs = ds_list_create();
addNodeCatagory("Custom", customs); addNodeCatagory("Custom", customs);

View file

@ -44,7 +44,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
} }
if(struct_has(node, "inputMap")) { if(struct_has(node, "inputMap")) {
if(_connect == JUNCTION_CONNECT.input) node.inputMap[? internalName] = self; if(_connect == JUNCTION_CONNECT.input) node.inputMap[? internalName] = self;
else if(_connect == JUNCTION_CONNECT.output) node.outputMap[? internalName] = self; else if(_connect == JUNCTION_CONNECT.output) node.outputMap[? internalName] = self;
} }
@ -1541,14 +1541,14 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
return true; return true;
} #endregion } #endregion
static getString = function() { #region static getString = function() {
var val = showValue(); var val = showValue();
if(type == VALUE_TYPE.text) return val; if(type == VALUE_TYPE.text) return val;
return json_beautify(val); return json_beautify(val);
} #endregion }
static setString = function(str) { #region static setString = function(str) {
if(connect_type == JUNCTION_CONNECT.output) return; if(connect_type == JUNCTION_CONNECT.output) return;
if(type == VALUE_TYPE.text) { setValue(str); return; } if(type == VALUE_TYPE.text) { setValue(str); return; }
@ -1558,7 +1558,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
_dat = [ _dat ]; _dat = [ _dat ];
setValue(_dat); setValue(_dat);
} #endregion }
/////=========== CONNECT =========== /////=========== CONNECT ===========

View file

@ -370,6 +370,20 @@ function value_type_from_string(str) {
return VALUE_TYPE.any; return VALUE_TYPE.any;
} }
function value_type_direct_settable(type) {
switch(type) {
case VALUE_TYPE.integer :
case VALUE_TYPE.float :
case VALUE_TYPE.boolean :
case VALUE_TYPE.color :
case VALUE_TYPE.path :
case VALUE_TYPE.text :
return true;
}
return false;
}
function typeArray(_type) { function typeArray(_type) {
switch(_type) { switch(_type) {
case VALUE_DISPLAY.range : case VALUE_DISPLAY.range :

View file

@ -73,6 +73,8 @@ function Panel_Action_Create() : PanelContent() constructor {
if(spr) surface_save(spr, $"{DIRECTORY}Actions/Nodes/{name}.png"); if(spr) surface_save(spr, $"{DIRECTORY}Actions/Nodes/{name}.png");
close(); close();
__initNodeActions();
}); });
b_create.text = __txtx("new_action_create", "Create"); b_create.text = __txtx("new_action_create", "Create");
@ -113,6 +115,8 @@ function Panel_Action_Create() : PanelContent() constructor {
for(var j = 0; j < ds_list_size(_n.inputs); j++) { for(var j = 0; j < ds_list_size(_n.inputs); j++) {
var _in = _n.inputs[| j]; var _in = _n.inputs[| j];
if(!value_type_direct_settable(_in.type)) continue;
var _vali = _val[$ j]; var _vali = _val[$ j];
var _ttg = false; var _ttg = false;
@ -201,7 +205,7 @@ function Panel_Action_Create() : PanelContent() constructor {
_vals[$ j] = {}; _vals[$ j] = {};
if(_in.value_from == noone || !struct_has(_nmap, _in.value_from.node.node_id)) { if(_in.value_from == noone || !struct_has(_nmap, _in.value_from.node.node_id)) {
var _vl = _in.getValue(); var _vl = _in.getValue(, false);
if(!isEqual(_vl, _in.def_val)) if(!isEqual(_vl, _in.def_val))
_vals[$ j].value = _vl; _vals[$ j].value = _vl;
continue; continue;

View file

@ -52,7 +52,7 @@
__channel_pos(surface); __channel_pos(surface);
} #endregion } #endregion
function draw_surface_tiled_safe(surface, _x, _y) { #region function draw_surface_tiled_safe(surface, _x = 0, _y = 0) { #region
INLINE INLINE
if(is_struct(surface)) { if(is_struct(surface)) {
@ -69,7 +69,7 @@
__channel_pos(surface); __channel_pos(surface);
} #endregion } #endregion
function draw_surface_tiled_ext_safe(surface, _x, _y, _xs = 1, _ys = 1, _rot = 0, _col = c_white, _alpha = 1) { #region function draw_surface_tiled_ext_safe(surface, _x = 0, _y = 0, _xs = 1, _ys = 1, _rot = 0, _col = c_white, _alpha = 1) { #region
INLINE INLINE
if(is_struct(surface)) { if(is_struct(surface)) {