- Add support for custom node.

This commit is contained in:
Tanasart 2023-09-22 17:01:56 +02:00
parent 8a811a84a5
commit b681ca3b88
21 changed files with 287 additions and 108 deletions

View file

@ -208,6 +208,7 @@
{"name":"biterator","order":2,"path":"folders/VCT/biterator.yy",},
{"name":"widget","order":3,"path":"folders/VCT/widget.yy",},
{"name":"widgets","order":5,"path":"folders/widgets.yy",},
{"name":"sprite","order":42,"path":"folders/functions/sprite.yy",},
],
"ResourceOrderSettings": [
{"name":"s_node_corner","order":16,"path":"sprites/s_node_corner/s_node_corner.yy",},

View file

@ -247,6 +247,7 @@
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"biterator","folderPath":"folders/VCT/biterator.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"widget","folderPath":"folders/VCT/widget.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"widgets","folderPath":"folders/widgets.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"sprite","folderPath":"folders/functions/sprite.yy",},
],
"IncludedFiles": [
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"ApolloHelp.html","ConfigValues":{"Itch":{"CopyToMask":"0",},},"CopyToMask":-1,"filePath":"datafiles",},
@ -261,6 +262,7 @@
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"Addons.zip","CopyToMask":-1,"filePath":"datafiles/data",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"Assets.zip","CopyToMask":-1,"filePath":"datafiles/data",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"Collections.zip","CopyToMask":-1,"filePath":"datafiles/data",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"Nodes.zip","CopyToMask":-1,"filePath":"datafiles/data",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"icon.png","CopyToMask":-1,"filePath":"datafiles/data",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"layouts.zip","CopyToMask":-1,"filePath":"datafiles/data",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"Horizontal.json","CopyToMask":-1,"filePath":"datafiles/data/layouts",},
@ -284,7 +286,6 @@
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"UI.json","CopyToMask":-1,"filePath":"datafiles/data/locale/sample locale",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"words.json","CopyToMask":-1,"filePath":"datafiles/data/locale/sample locale",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"nodes.json","CopyToMask":-1,"filePath":"datafiles/data",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"info.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Custom",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"default.zip","CopyToMask":-1,"filePath":"datafiles/data/themes",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"FiraCode-Medium.ttf","CopyToMask":-1,"filePath":"datafiles/data/themes/default/fonts",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"fonts.json","CopyToMask":-1,"filePath":"datafiles/data/themes/default/fonts",},
@ -1365,6 +1366,7 @@
{"id":{"name":"pcx_parse","path":"scripts/pcx_parse/pcx_parse.yy",},},
{"id":{"name":"node_9slice","path":"scripts/node_9slice/node_9slice.yy",},},
{"id":{"name":"fd_rectangle_add_velocity_surface","path":"scripts/fd_rectangle_add_velocity_surface/fd_rectangle_add_velocity_surface.yy",},},
{"id":{"name":"sprite_add_functions","path":"scripts/sprite_add_functions/sprite_add_functions.yy",},},
{"id":{"name":"BBMOD_Vec2","path":"scripts/BBMOD_Vec2/BBMOD_Vec2.yy",},},
{"id":{"name":"sh_grid_hex","path":"shaders/sh_grid_hex/sh_grid_hex.yy",},},
{"id":{"name":"s_node_lua_surface","path":"sprites/s_node_lua_surface/s_node_lua_surface.yy",},},

BIN
datafiles/data/Nodes.zip Normal file

Binary file not shown.

View file

@ -126,7 +126,7 @@ event_inherited();
setPage(NODE_PAGE_DEFAULT);
#endregion
function buildNode(_node, _param = "") { #region
function buildNode(_node, _param = {}) { #region
if(!_node) {
instance_destroy();
instance_destroy(o_dialog_menubox);
@ -708,7 +708,7 @@ event_inherited();
__txtx("add_node_equation_enter", "Press Enter to create equation node."));
if(keyboard_check_pressed(vk_enter))
buildNode(ALL_NODES[? "Node_Equation"], eq);
buildNode(ALL_NODES[? "Node_Equation"], { query: eq } );
return hh;
}
@ -723,10 +723,10 @@ event_inherited();
for(var i = 0; i < amo; i++) {
var s_res = search_list[| i];
var _node = noone, _param = "";
var _node = noone, _param = {};
if(is_array(s_res)) {
_node = s_res[0];
_param = s_res[1];
_param.query = s_res[1];
} else
_node = s_res;
@ -814,10 +814,10 @@ event_inherited();
for(var i = 0; i < amo; i++) {
var s_res = search_list[| i];
var _node = noone, _param = "";
var _node = noone, _param = {};
if(is_array(s_res)) {
_node = s_res[0];
_param = s_res[1];
_param.query = s_res[1];
} else
_node = s_res;

View file

@ -1,9 +1,8 @@
function Node_create_Custom(_x, _y, _group = noone, _param = {}) {
if(!struct_has(_param, "path")) return noone;
var path = _param.path;
var node = new Node_Custom(_x, _y, _group);
node.setPath(path);
if(!node.setPath(_param.path)) return noone;
return node;
}
@ -11,45 +10,76 @@ function Node_create_Custom_path(_x, _y, path) {
if(!file_exists(path)) return noone;
var node = new Node_Custom(_x, _y, PANEL_GRAPH.getCurrentContext());
node.setPath(path);
if(!node.setPath(path)) return noone;
return node;
}
function Node_Custom(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
name = "Custom";
path = "";
info = {};
shader = {
vs: noone,
fs: noone,
};
inputs[| 0] = nodeValue("Base Texture", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone);
input_index_map = ds_map_create();
output_index_map = ds_map_create();
outputs[| 0] = nodeValue("Output", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone );
surface_in_index = 0;
surface_out_index = 0;
static setPath = function(path) {
self.path = path;
}
static createNewInput = function() {
var index = ds_list_size(inputs);
inputs[| index] = nodeValue("Uniform", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0 )
.setVisible(true, true);
}
static onValueUpdate = function(index) { #region
var _refresh = index == 0 || index == 1 ||
(index >= input_fix_len && (index - input_fix_len) % data_length != 2);
static setPath = function(_path) {
var _info = _path + "/info.json";
if(!file_exists(_info)) return false;
if(_refresh) {
refreshShader();
refreshDynamicInput();
info = json_load_struct(_info);
path = _path;
name = info.name;
setDisplayName(name);
shader.vs = d3d11_shader_compile_vs($"{path}/{info.shader_vs}", "main", "vs_4_0");
if(!d3d11_shader_exists(shader.vs)) noti_warning(d3d11_get_error_string());
shader.fs = d3d11_shader_compile_ps($"{path}/{info.shader_fs}", "main", "ps_4_0");
if(!d3d11_shader_exists(shader.fs)) noti_warning(d3d11_get_error_string());
ds_list_clear(inputs);
ds_list_clear(outputs);
for( var i = 0, n = array_length(info.inputs); i < n; i++ ) {
var _input = info.inputs[i];
inputs[| i] = nodeValue(_input.name, self, JUNCTION_CONNECT.input, value_type_from_string(_input.type), _input.value)
.setVisible(_input.show_in_inspector, _input.show_in_graph);
input_index_map[? _input.name] = i;
for( var j = 0, m = array_length(_input.flags); j < m; j++ ) {
switch(_input.flags[j]) {
case "SURFACE_IN" : surface_in_index = i; break;
}
}
}
} #endregion
for( var i = 0, n = array_length(info.outputs); i < n; i++ ) {
var _output = info.outputs[i];
outputs[| i] = nodeValue(_output.name, self, JUNCTION_CONNECT.output, value_type_from_string(_output.type), _output.value)
.setVisible(_output.show_in_graph);
output_index_map[? _output.name] = i;
for( var j = 0, m = array_length(_output.flags); j < m; j++ ) {
switch(_output.flags[j]) {
case "SURFACE_OUT" : surface_out_index = i; break;
}
}
}
}
static processData = function(_output, _data, _output_index, _array_index = 0) { #region
var _surf = _data[2];
if(!is_surface(_surf)) return noone;
if(!d3d11_shader_exists(shader.vs)) return noone;
if(!d3d11_shader_exists(shader.fs)) return noone;
_output = surface_verify(_output, surface_get_width_safe(_surf), surface_get_height_safe(_surf));
var _surf = _data[surface_in_index];
_output = surface_verify(_output, surface_get_width_safe(_surf), surface_get_height_safe(_surf));
surface_set_target(_output);
DRAW_CLEAR
@ -64,43 +94,42 @@ function Node_Custom(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) co
var _buffer = buffer_create(1, buffer_grow, 1);
var _cbSize = 0;
for( var i = input_fix_len, n = array_length(_data); i < n; i += data_length ) {
var _arg_name = _data[i + 0];
var _arg_type = _data[i + 1];
var _arg_valu = _data[i + 2];
for( var i = 0, n = array_length(info.uniforms); i < n; i++ ) {
var _u = info.uniforms[i];
var _index = input_index_map[? _u.input_name];
if(_arg_name == "") continue;
var _uname = _u.name;
var _utype = _u.type;
var _value = _data[_index];
var _uni = shader_get_uniform(shader.fs, _arg_name);
switch(_arg_type) {
switch(_utype) {
case 1 :
d3d11_cbuffer_add_int(1);
_cbSize++;
buffer_write(_buffer, buffer_s32, _arg_valu);
buffer_write(_buffer, buffer_s32, _value);
break;
case 0 :
d3d11_cbuffer_add_float(1);
_cbSize++;
buffer_write(_buffer, buffer_f32, _arg_valu);
buffer_write(_buffer, buffer_f32, _value);
break;
case 2 :
case 3 :
case 4 :
case 5 :
case 6 :
if(is_array(_arg_valu)) {
d3d11_cbuffer_add_float(array_length(_arg_valu));
_cbSize += array_length(_arg_valu);
if(is_array(_value)) {
d3d11_cbuffer_add_float(array_length(_value));
_cbSize += array_length(_value);
for( var j = 0, m = array_length(_arg_valu); j < m; j++ )
buffer_write(_buffer, buffer_f32, _arg_valu[j]);
for( var j = 0, m = array_length(_value); j < m; j++ )
buffer_write(_buffer, buffer_f32, _value[j]);
}
break;
case 8 :
var _clr = colToVec4(_arg_valu);
var _clr = colToVec4(_value);
d3d11_cbuffer_add_float(4);
_cbSize += 4;
@ -108,8 +137,8 @@ function Node_Custom(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) co
buffer_write(_buffer, buffer_f32, _clr[i]);
break;
case 7 :
if(is_surface(_arg_valu))
d3d11_texture_set_stage_ps(sampler_slot, surface_get_texture(_arg_valu));
if(is_surface(_value))
d3d11_texture_set_stage_ps(sampler_slot, surface_get_texture(_value));
sampler_slot++;
break;
}
@ -133,9 +162,68 @@ function Node_Custom(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) co
return _output;
} #endregion
}
function __initNodeCustom(list) { #region
var root = DIRECTORY + "Nodes";
if(!directory_exists(root)) directory_create(root);
static postConnect = function() {
refreshShader();
refreshDynamicInput();
root += "/Custom";
if(!directory_exists(root)) directory_create(root);
var _l = root + "/version";
if(file_exists(_l)) {
var res = json_load_struct(_l);
if(!is_struct(res) || !struct_has(res, "version") || res.version != BUILD_NUMBER)
zip_unzip("data/Nodes.zip", root);
} else
zip_unzip("data/Nodes.zip", root);
json_save_struct(_l, { version: BUILD_NUMBER });
var f = file_find_first(root + "/*", fa_directory);
while (f != "") {
var _dir_raw = $"{root}/{f}";
f = file_find_next();
if(!directory_exists(_dir_raw)) continue;
var _dir = _dir_raw + "/";
var _info = json_load_struct(_dir + "info.json");
if(_info == noone) continue;
var _spr = sprite_add_center(_dir + _info.icon);
var _n = new NodeObject(_info.name, _spr, "Node_Custom", [ 0, Node_create_Custom, { path: _dir_raw } ], _info.tags);
_n.tooltip = _info.tooltip;
var _tol = _dir + _info.tooltip_spr;
if(file_exists(_tol)) _n.tooltip_spr = sprite_add(_tol, 0, false, false, 0, 0);
ds_list_add(list, _n);
if(_info.category != noone) {
var _cat = _info.location[0];
var _grp = _info.location[1];
var _ins = true;
for( var i = 0, n = ds_list_size(NODE_CATEGORY); i < n; i++ ) {
if(NODE_CATEGORY[| i].name != _cat) continue;
var _list = NODE_CATEGORY[| i].list;
var j = 0;
for( var m = ds_list_size(_list); j < m; j++ )
if(_list[| j] == _grp) break;
ds_list_insert(_list, j + 1, _n);
_ins = false;
break;
}
if(_ins) {
ds_list_add(_list, _grp);
ds_list_add(_list, _n);
}
}
}
}
file_find_close();
} #endregion

View file

@ -107,10 +107,10 @@
globalvar VERSION, SAVE_VERSION, VERSION_STRING, BUILD_NUMBER;
VERSION = 11522;
VERSION = 11523;
SAVE_VERSION = 11500;
VERSION_STRING = "1.15.2.2";
BUILD_NUMBER = 11522;
VERSION_STRING = "1.15.2.3";
BUILD_NUMBER = 11523;
globalvar APPEND_MAP;
APPEND_MAP = ds_map_create();

View file

@ -20,7 +20,7 @@
static getName = function() { return name; /*__txt_node_name(node, name); */ }
static getTooltip = function() { return tooltip; /*__txt_node_tooltip(node, tooltip); */ }
static build = function(_x = 0, _y = 0, _group = PANEL_GRAPH.getCurrentContext(), _param = "") {
static build = function(_x = 0, _y = 0, _group = PANEL_GRAPH.getCurrentContext(), _param = {}) {
var _n = [];
for( var i = 0, n = array_length(nodes); i < n; i++ ) {
var __n = nodes[i];

View file

@ -1,4 +1,4 @@
function Node_create_Blend(_x, _y, _group = noone, _param = "") {
function Node_create_Blend(_x, _y, _group = noone, _param = {}) {
var node = new Node_Blend(_x, _y, _group);
return node;
}

View file

@ -9,16 +9,16 @@ enum COMPARE_OPERATOR {
lesserEqual,
}
function Node_create_Compare(_x, _y, _group = noone, _param = "") {
var node = new Node_Compare(_x, _y, _group);
function Node_create_Compare(_x, _y, _group = noone, _param = {}) {
var query = struct_try_get(_param, "query", "");
var node = new Node_Compare(_x, _y, _group);
switch(_param) {
switch(query) {
case "equal" : node.inputs[| 0].setValue(COMPARE_OPERATOR.equal); break;
case "greater" : node.inputs[| 0].setValue(COMPARE_OPERATOR.greater); break;
case "lesser" : node.inputs[| 0].setValue(COMPARE_OPERATOR.lesser); break;
}
//ds_list_add(PANEL_GRAPH.nodes_list, node);
return node;
}

View file

@ -1,16 +1,17 @@
function Node_create_Equation(_x, _y, _group = noone, _param = "") { #region
var node = new Node_Equation(_x, _y, _group);
if(_param == "") return node;
function Node_create_Equation(_x, _y, _group = noone, _param = {}) { #region
var query = struct_try_get(_param, "query", "");
var node = new Node_Equation(_x, _y, _group);
if(query == "") return node;
node.inputs[| 0].setValue(_param);
node.inputs[| 0].setValue(query);
var ind = 1;
var amo = string_length(_param);
var amo = string_length(query);
var str = "";
var pres = global.EQUATION_PRES;
var vars = [];
for( var ind = 1; ind <= amo; ind++ ) {
var ch = string_char_at(_param, ind);
var ch = string_char_at(query, ind);
if(ds_map_exists(pres, ch) || ch == "(" || ch == ")") {
if(str != "" && str != toNumber(str))
array_push_unique(vars, str);

View file

@ -8,10 +8,11 @@ enum LOGIC_OPERATOR {
lxor
}
function Node_create_Logic(_x, _y, _group = noone, _param = "") {
var node = new Node_Logic(_x, _y, _group);
function Node_create_Logic(_x, _y, _group = noone, _param = {}) {
var query = struct_try_get(_param, "query", "");
var node = new Node_Logic(_x, _y, _group);
switch(_param) {
switch(query) {
case "and" : node.inputs[| 0].setValue(LOGIC_OPERATOR.land); break;
case "or" : node.inputs[| 0].setValue(LOGIC_OPERATOR.lor); break;
case "not" : node.inputs[| 0].setValue(LOGIC_OPERATOR.lnot); break;
@ -20,7 +21,6 @@ function Node_create_Logic(_x, _y, _group = noone, _param = "") {
case "xor" : node.inputs[| 0].setValue(LOGIC_OPERATOR.lxor); break;
}
//ds_list_add(PANEL_GRAPH.nodes_list, node);
return node;
}

View file

@ -20,10 +20,11 @@ enum MATH_OPERATOR {
abs
}
function Node_create_Math(_x, _y, _group = noone, _param = "") {
var node = new Node_Math(_x, _y, _group);
function Node_create_Math(_x, _y, _group = noone, _param = {}) {
var query = struct_try_get(_param, "query", "");
var node = new Node_Math(_x, _y, _group);
switch(_param) {
switch(query) {
case "add" : node.inputs[| 0].setValue(MATH_OPERATOR.add); break;
case "subtract" : node.inputs[| 0].setValue(MATH_OPERATOR.subtract); break;
case "multiply" : node.inputs[| 0].setValue(MATH_OPERATOR.multiply); break;
@ -45,7 +46,6 @@ function Node_create_Math(_x, _y, _group = noone, _param = "") {
case "abs" : node.inputs[| 0].setValue(MATH_OPERATOR.abs); break;
}
//ds_list_add(PANEL_GRAPH.nodes_list, node);
return node;
}

View file

@ -31,19 +31,21 @@ function Node_Path_L_System(_x, _y, _group = noone) : Node(_x, _y, _group) const
inputs[| 6] = nodeValue("Starting angle", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 90)
.setDisplay(VALUE_DISPLAY.rotation);
inputs[| 7] = nodeValue("Seed", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, irandom_range(100000, 999999));
setIsDynamicInput(2);
static createNewInput = function() {
static createNewInput = function() { #region
var index = ds_list_size(inputs);
inputs[| index + 0] = nodeValue("Name " + string(index - input_fix_len), self, JUNCTION_CONNECT.input, VALUE_TYPE.text, "" );
inputs[| index + 1] = nodeValue("Rule " + string(index - input_fix_len), self, JUNCTION_CONNECT.input, VALUE_TYPE.text, "" );
}
} #endregion
if(!LOADING && !APPENDING) createNewInput();
outputs[| 0] = nodeValue("Path", self, JUNCTION_CONNECT.output, VALUE_TYPE.pathnode, self);
rule_renderer = new Inspector_Custom_Renderer(function(_x, _y, _w, _m, _hover, _focus) {
rule_renderer = new Inspector_Custom_Renderer(function(_x, _y, _w, _m, _hover, _focus) { #region
rule_renderer.x = _x;
rule_renderer.y = _y;
rule_renderer.w = _w;
@ -75,11 +77,11 @@ function Node_Path_L_System(_x, _y, _group = noone) : Node(_x, _y, _group) const
}
return hh;
});
}); #endregion
input_display_list = [
["Origin", false], 2, 6,
["Properties", false], 0, 1,
["Properties", false], 0, 1, 7,
["Rules", false], 3, 4, rule_renderer, 5,
];
lines = [];
@ -87,7 +89,7 @@ function Node_Path_L_System(_x, _y, _group = noone) : Node(_x, _y, _group) const
current_length = 0;
boundary = new BoundingBox();
static refreshDynamicInput = function() {
static refreshDynamicInput = function() { #region
var _l = ds_list_create();
for( var i = 0; i < input_fix_len; i++ )
@ -110,7 +112,7 @@ function Node_Path_L_System(_x, _y, _group = noone) : Node(_x, _y, _group) const
inputs = _l;
createNewInput();
}
} #endregion
static onValueUpdate = function(index) {
if(LOADING || APPENDING) return;
@ -118,7 +120,7 @@ function Node_Path_L_System(_x, _y, _group = noone) : Node(_x, _y, _group) const
refreshDynamicInput();
}
static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) {
static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) { #region
inputs[| 2].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny);
draw_set_color(COLORS._main_accent);
@ -138,7 +140,7 @@ function Node_Path_L_System(_x, _y, _group = noone) : Node(_x, _y, _group) const
draw_line(x0, y0, x1, y1);
}
}
} #endregion
static getLineCount = function() { return array_length(lines); }
static getSegmentCount = function() { return 1; }
@ -150,7 +152,7 @@ function Node_Path_L_System(_x, _y, _group = noone) : Node(_x, _y, _group) const
return getWeightRatio(_dist / current_length, _ind);
}
static getWeightRatio = function (_rat, _ind = 0) {
static getWeightRatio = function (_rat, _ind = 0) { #region
var _p0 = lines[_ind][0];
var _p1 = lines[_ind][1];
@ -158,9 +160,9 @@ function Node_Path_L_System(_x, _y, _group = noone) : Node(_x, _y, _group) const
if(!is_array(_p1) || array_length(_p1) < 2) return 1;
return lerp(_p0[2], _p1[2], _rat);
}
} #endregion
static getPointRatio = function(_rat, _ind = 0) {
static getPointRatio = function(_rat, _ind = 0) { #region
var _p0 = lines[_ind][0];
var _p1 = lines[_ind][1];
@ -171,7 +173,7 @@ function Node_Path_L_System(_x, _y, _group = noone) : Node(_x, _y, _group) const
var _y = lerp(_p0[1], _p1[1], _rat);
return new __vec2( _x, _y );
}
} #endregion
static getPointDistance = function(_dist, _ind = 0) {
return getPointRatio(_dist / current_length, _ind);
@ -179,14 +181,16 @@ function Node_Path_L_System(_x, _y, _group = noone) : Node(_x, _y, _group) const
static getBoundary = function() { return boundary; }
function update() {
function update() { #region
var _len = inputs[| 0].getValue();
var _ang = inputs[| 1].getValue();
var _pos = inputs[| 2].getValue();
var _itr = inputs[| 3].getValue();
var _san = inputs[| 6].getValue();
var _sad = inputs[| 7].getValue();
lines = [];
random_set_seed(_sad);
current_length = _len;
if(ds_list_size(inputs) < input_fix_len + 2) return;
@ -278,7 +282,7 @@ function Node_Path_L_System(_x, _y, _group = noone) : Node(_x, _y, _group) const
boundary.addPoint(lines[i][0][0], lines[i][0][1], lines[i][1][0], lines[i][1][1]);
outputs[| 0].setValue(self);
}
} #endregion
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
var bbox = drawGetBbox(xx, yy, _s);

View file

@ -5,14 +5,13 @@ function NodeObject(_name, _spr, _node, _create, tags = []) constructor { #regio
createNode = _create;
self.tags = tags;
tooltip = "";
deprecated = false;
tooltip = "";
tooltip_spr = noone;
deprecated = false;
var pth = DIRECTORY + "Nodes/tooltip/" + node + ".png";
if(file_exists(pth))
tooltip_spr = sprite_add(pth, 0, false, false, 0, 0);
else
tooltip_spr = noone;
new_node = false;
if(struct_has(global.NODE_GUIDE, node)) {
@ -35,8 +34,15 @@ function NodeObject(_name, _spr, _node, _create, tags = []) constructor { #regio
static getName = function() { return name; /*__txt_node_name(node, name); */ }
static getTooltip = function() { return tooltip; /*__txt_node_tooltip(node, tooltip); */ }
static build = function(_x = 0, _y = 0, _group = PANEL_GRAPH.getCurrentContext(), _param = "") {
var _node = createNode[0]? new createNode[1](_x, _y, _group, _param) : createNode[1](_x, _y, _group, _param);
static build = function(_x = 0, _y = 0, _group = PANEL_GRAPH.getCurrentContext(), _param = {}) {
var _node;
var _buildCon = createNode[0];
if(array_length(createNode) > 2)
_param = struct_append(_param, createNode[2]);
if(_buildCon) _node = new createNode[1](_x, _y, _group, _param);
else _node = createNode[1](_x, _y, _group, _param);
if(!_node) return noone;
_node.clearInputCache();
@ -677,9 +683,13 @@ function NodeObject(_name, _spr, _node, _create, tags = []) constructor { #regio
#endregion
var actions = ds_list_create();
addNodeCatagory("Actions", actions);
addNodeCatagory("Action", actions);
__initNodeActions(actions);
var customs = ds_list_create();
addNodeCatagory("Custom", customs);
__initNodeCustom(customs);
//var vct = ds_list_create();
//addNodeCatagory("VCT", vct);
// addNodeObject(vct, "Biterator", s_node_print, "Node_Biterator", [1, Node_Biterator]);

View file

@ -1,8 +1,8 @@
function Node_create_Scale_Algo(_x, _y, _group = noone, _param = "") {
var node = new Node_Scale_Algo(_x, _y, _group);
//ds_list_add(PANEL_GRAPH.nodes_list, node);
function Node_create_Scale_Algo(_x, _y, _group = noone, _param = {}) {
var query = struct_try_get(_param, "query", "");
var node = new Node_Scale_Algo(_x, _y, _group);
switch(_param) {
switch(query) {
case "scale2x" : node.inputs[| 1].setValue(0); break;
case "scale3x" : node.inputs[| 1].setValue(1); break;
}

View file

@ -6,11 +6,11 @@ enum STAT_OPERATOR {
_min
}
function Node_create_Statistic(_x, _y, _group = noone, _param = "") {
var node = new Node_Statistic(_x, _y, _group);
//ds_list_add(PANEL_GRAPH.nodes_list, node);
function Node_create_Statistic(_x, _y, _group = noone, _param = {}) {
var query = struct_try_get(_param, "query", "");
var node = new Node_Statistic(_x, _y, _group);
switch(_param) {
switch(query) {
case "sum" : node.inputs[| 0].setValue(STAT_OPERATOR._sum); break;
case "mean" :
case "average" : node.inputs[| 0].setValue(STAT_OPERATOR._average); break;

View file

@ -241,6 +241,47 @@ function value_type_directional(f, t) { #region
return false;
} #endregion
function value_type_from_string(str) { #region
switch(str) {
case "integer" : return VALUE_TYPE.integer;
case "float" : return VALUE_TYPE.float;
case "boolean" : return VALUE_TYPE.boolean;
case "color" : return VALUE_TYPE.color;
case "surface" : return VALUE_TYPE.surface;
case "path" : return VALUE_TYPE.path;
case "curve" : return VALUE_TYPE.curve;
case "text" : return VALUE_TYPE.text;
case "object" : return VALUE_TYPE.object;
case "node" : return VALUE_TYPE.node;
case "d3object" : return VALUE_TYPE.d3object;
case "any" : return VALUE_TYPE.any;
case "pathnode" : return VALUE_TYPE.pathnode;
case "particle" : return VALUE_TYPE.particle;
case "rigid" : return VALUE_TYPE.rigid;
case "fdomain" : return VALUE_TYPE.fdomain;
case "struct" : return VALUE_TYPE.struct;
case "strands" : return VALUE_TYPE.strands;
case "mesh" : return VALUE_TYPE.mesh;
case "trigger" : return VALUE_TYPE.trigger;
case "atlas" : return VALUE_TYPE.atlas;
case "d3vertex" : return VALUE_TYPE.d3vertex;
case "gradient" : return VALUE_TYPE.gradient;
case "armature" : return VALUE_TYPE.armature;
case "buffer" : return VALUE_TYPE.buffer;
case "pbBox" : return VALUE_TYPE.pbBox;
case "d3Mesh" : return VALUE_TYPE.d3Mesh;
case "d3Light" : return VALUE_TYPE.d3Light;
case "d3Camera" : return VALUE_TYPE.d3Camera;
case "d3Scene" : return VALUE_TYPE.d3Scene;
case "d3Material" : return VALUE_TYPE.d3Material;
case "dynaSurface" : return VALUE_TYPE.dynaSurface;
case "PCXnode" : return VALUE_TYPE.PCXnode;
case "action" : return VALUE_TYPE.action;
}
return VALUE_TYPE.any;
} #endregion
function typeArray(_type) { #region
switch(_type) {
case VALUE_DISPLAY.range :

View file

@ -0,0 +1,11 @@
function sprite_add_center(path) {
if(!file_exists(path)) return noone;
var _s = sprite_add(path, 0, 0, 0, 0, 0);
var _sw = sprite_get_width(_s);
var _sh = sprite_get_height(_s);
sprite_set_offset(_s, _sw / 2, _sh / 2);
return _s;
}

View file

@ -0,0 +1,11 @@
{
"resourceType": "GMScript",
"resourceVersion": "1.0",
"name": "sprite_add_functions",
"isCompatibility": false,
"isDnD": false,
"parent": {
"name": "sprite",
"path": "folders/functions/sprite.yy",
},
}

View file

@ -11,6 +11,16 @@ function struct_override(original, override) {
return original;
}
function struct_append(original, append) {
var args = variable_struct_get_names(append);
for( var i = 0, n = array_length(args); i < n; i++ ) {
original[$ args[i]] = append[$ args[i]];
}
return original;
}
function struct_try_get(struct, key, def = 0) {
gml_pragma("forceinline");
if(struct[$ key] != undefined) return struct[$ key];