From 03a061651f7772347a1b19cb66a6985ee86adb5e Mon Sep 17 00:00:00 2001 From: Tanasart Date: Tue, 29 Oct 2024 09:03:29 +0700 Subject: [PATCH] Add the ability to expose node metadata (name, position) as junction. --- scripts/globals/globals.gml | 2 +- scripts/nodeValue_drawer/nodeValue_drawer.gml | 2 +- scripts/node_armature/node_armature.gml | 107 +++++++++--------- .../node_armature_bind/node_armature_bind.gml | 62 +++++----- scripts/node_collection/node_collection.gml | 2 +- scripts/node_data/node_data.gml | 89 +++++++++++++-- scripts/node_mesh_warp/node_mesh_warp.gml | 1 - .../node_rigid_object/node_rigid_object.gml | 64 +++++------ scripts/node_tiler/node_tiler.gml | 6 +- .../node_tiler_tileset/node_tiler_tileset.gml | 9 +- scripts/node_value/node_value.gml | 83 +++++++------- scripts/node_value_types/node_value_types.gml | 7 +- .../panel_custom_inspector.gml | 22 +++- scripts/panel_inspector/panel_inspector.gml | 34 ++++-- 14 files changed, 302 insertions(+), 188 deletions(-) diff --git a/scripts/globals/globals.gml b/scripts/globals/globals.gml index 3be21f01c..3de27b2c1 100644 --- a/scripts/globals/globals.gml +++ b/scripts/globals/globals.gml @@ -42,7 +42,7 @@ LATEST_VERSION = 1_18_00_0; VERSION = 1_18_01_0; SAVE_VERSION = 1_18_02_0; - VERSION_STRING = MAC? "1.18.003m" : "1.18.3.006"; + VERSION_STRING = MAC? "1.18.003m" : "1.18.3.007"; BUILD_NUMBER = 1_18_01_0; HOTKEYS = ds_map_create(); diff --git a/scripts/nodeValue_drawer/nodeValue_drawer.gml b/scripts/nodeValue_drawer/nodeValue_drawer.gml index be123b17e..1e937874f 100644 --- a/scripts/nodeValue_drawer/nodeValue_drawer.gml +++ b/scripts/nodeValue_drawer/nodeValue_drawer.gml @@ -19,7 +19,7 @@ function drawWidget(xx, yy, ww, _m, jun, global_var = true, _hover = false, _foc var xc = xx + ww / 2; var _font = viewMode == INSP_VIEW_MODE.spacious? f_p1 : f_p2; var breakLine = viewMode == INSP_VIEW_MODE.spacious || jun.expUse; - var lb_h = line_get_height(_font) + ui(6); + var lb_h = line_get_height(_font, 6); var lb_y = yy + lb_h / 2; var _name = jun.getName(); diff --git a/scripts/node_armature/node_armature.gml b/scripts/node_armature/node_armature.gml index 00f05c40e..92f88af45 100644 --- a/scripts/node_armature/node_armature.gml +++ b/scripts/node_armature/node_armature.gml @@ -4,7 +4,7 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo //newInput(0, nodeValue_Int("Axis", self, 0)); - bone_renderer = new Inspector_Custom_Renderer(function(_x, _y, _w, _m, _hover, _focus) { #region + bone_renderer = new Inspector_Custom_Renderer(function(_x, _y, _w, _m, _hover, _focus) { var _b = attributes.bones; if(_b == noone) return 0; var amo = _b.childCount(); @@ -121,13 +121,13 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo } return bh; - }); #endregion + }); input_display_list = [ bone_renderer, ]; - static createBone = function(parent, distance, direction) { #region + static createBone = function(parent, distance, direction) { recordAction(ACTION_TYPE.struct_modify, attributes.bones, attributes.bones.serialize()); var bone = new __Bone(parent, distance, direction,,, self); @@ -136,28 +136,28 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo if(parent == attributes.bones) bone.parent_anchor = false; return bone; - } #endregion + } newOutput(0, nodeValue_Output("Armature", self, VALUE_TYPE.armature, noone)); #region ++++ attributes ++++ - attributes.bones = new __Bone(,,,,, self); - attributes.bones.name = "Main"; - attributes.bones.is_main = true; - attributes.bones.node = self; - - attributes.display_name = true; - attributes.display_bone = 0; - - array_push(attributeEditors, "Display"); - array_push(attributeEditors, ["Display name", function() { return attributes.display_name; }, - new checkBox(function() { - attributes.display_name = !attributes.display_name; - })]); - array_push(attributeEditors, ["Display bone", function() { return attributes.display_bone; }, - new scrollBox(["Octahedral", "Stick"], function(ind) { - attributes.display_bone = ind; - })]); + attributes.bones = new __Bone(,,,,, self); + attributes.bones.name = "Main"; + attributes.bones.is_main = true; + attributes.bones.node = self; + + attributes.display_name = true; + attributes.display_bone = 0; + + array_push(attributeEditors, "Display"); + array_push(attributeEditors, ["Display name", function() { return attributes.display_name; }, + new checkBox(function() { + attributes.display_name = !attributes.display_name; + })]); + array_push(attributeEditors, ["Display bone", function() { return attributes.display_bone; }, + new scrollBox(["Octahedral", "Stick"], function(ind) { + attributes.display_bone = ind; + })]); #endregion tools = [ @@ -185,7 +185,7 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo moving = false; scaling = false; - 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 mx = (_mx - _x) / _s; var my = (_my - _y) / _s; @@ -194,7 +194,7 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo var _b = attributes.bones; - if(builder_bone != noone) { #region + if(builder_bone != noone) { anchor_selecting = _b.draw(attributes, false, _x, _y, _s, _mx, _my, anchor_selecting); var dir = point_direction(builder_sx, builder_sy, smx, smy); @@ -263,8 +263,8 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo } triggerRender(); - #endregion - } else if(ik_dragging != noone) { #region + + } else if(ik_dragging != noone) { anchor_selecting = _b.draw(attributes, active * 0b100, _x, _y, _s, _mx, _my, anchor_selecting, ik_dragging); if(anchor_selecting != noone && anchor_selecting[1] == 2) { @@ -309,10 +309,10 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo } triggerRender(); - #endregion + } - if(isUsingTool("Move")) { #region + if(isUsingTool("Move")) { _b.draw(attributes, false, _x, _y, _s, _mx, _my); var bbox = _b.bbox(); @@ -358,8 +358,8 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo draw_rectangle(x0, y0, x1, y1, true); draw_set_alpha(1); } - #endregion - } else if(isUsingTool("Scale")) { #region + + } else if(isUsingTool("Scale")) { _b.draw(attributes, false, _x, _y, _s, _mx, _my); var bbox = _b.bbox(); @@ -425,8 +425,8 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo recordAction(ACTION_TYPE.struct_modify, attributes.bones, attributes.bones.serialize()); } } - #endregion - } else if(isUsingTool("Add bones")) { #region // builder + + } else if(isUsingTool("Add bones")) { // builder if(builder_bone == noone) anchor_selecting = _b.draw(attributes, active * 0b111, _x, _y, _s, _mx, _my, anchor_selecting); @@ -470,8 +470,8 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo draw_sprite_ext(THEME.bone_tool_add, 1, _mx + 24, _my + 24, 1, 1, 0, c_white, 1); } else if(anchor_selecting[1] == 2) draw_sprite_ext(THEME.bone_tool_add, 0, _mx + 24, _my + 24, 1, 1, 0, c_white, 1); - #endregion - } else if(isUsingTool("Remove bones")) { #region //remover + + } else if(isUsingTool("Remove bones")) { //remover anchor_selecting = _b.draw(attributes, active * 0b100, _x, _y, _s, _mx, _my, anchor_selecting); if(anchor_selecting != noone && anchor_selecting[1] == 2 && anchor_selecting[0].parent != noone && mouse_press(mb_left, active)) { @@ -492,8 +492,8 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo if(anchor_selecting != noone) draw_sprite_ext(THEME.bone_tool_remove, 1, _mx + 24, _my + 24, 1, 1, 0, c_white, 1); - #endregion - } else if(isUsingTool("Detach bones")) { #region //detach + + } else if(isUsingTool("Detach bones")) { //detach if(builder_bone == noone) anchor_selecting = _b.draw(attributes, active * 0b100, _x, _y, _s, _mx, _my, anchor_selecting); @@ -514,16 +514,16 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo builder_my = my; UNDO_HOLDING = true; } - #endregion - } else if(isUsingTool("IK")) { #region //IK + + } else if(isUsingTool("IK")) { //IK if(ik_dragging == noone) anchor_selecting = _b.draw(attributes, active * 0b100, _x, _y, _s, _mx, _my, anchor_selecting); if(anchor_selecting != noone && anchor_selecting[1] == 2 && mouse_press(mb_left, active)) { ik_dragging = anchor_selecting[0]; } - #endregion - } else { #region //mover + + } else { //mover if(builder_bone == noone) anchor_selecting = _b.draw(attributes, active * 0b111, _x, _y, _s, _mx, _my, anchor_selecting); @@ -555,17 +555,17 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo UNDO_HOLDING = true; } - #endregion + } - } #endregion + } static step = function() {} - static update = function(frame = CURRENT_FRAME) { #region + static update = function(frame = CURRENT_FRAME) { outputs[0].setValue(attributes.bones); - } #endregion + } - static getPreviewBoundingBox = function() { #region + static getPreviewBoundingBox = function() { var minx = 9999999; var miny = 9999999; var maxx = -9999999; @@ -596,25 +596,24 @@ function Node_Armature(_x, _y, _group = noone) : Node(_x, _y, _group) constructo if(minx == 9999999) return noone; return BBOX().fromPoints(minx, miny, maxx, maxy); - } #endregion + } - static attributeSerialize = function() { return {}; } - static attributeDeserialize = function(attr) {} - - static doSerialize = function(_map) { #region + static doSerialize = function(_map) { _map.bones = attributes.bones.serialize(); - } #endregion + } - static postDeserialize = function() { #region + // static attributeDeserialize = function() {} + + static postDeserialize = function() { if(!struct_has(load_map, "bones")) return; attributes.bones = new __Bone(,,,,, self); attributes.bones.deserialize(load_map.bones, self); attributes.bones.connect(); - } #endregion + } - static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region + static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { var bbox = drawGetBbox(xx, yy, _s); draw_sprite_fit(s_node_armature_create, 0, bbox.xc, bbox.yc, bbox.w, bbox.h); - } #endregion + } } diff --git a/scripts/node_armature_bind/node_armature_bind.gml b/scripts/node_armature_bind/node_armature_bind.gml index 94b5dd70c..4c018831d 100644 --- a/scripts/node_armature_bind/node_armature_bind.gml +++ b/scripts/node_armature_bind/node_armature_bind.gml @@ -64,7 +64,7 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr layer_dragging = noone; layer_remove = -1; - layer_renderer = new Inspector_Custom_Renderer(function(_x, _y, _w, _m, _hover, _focus) { #region + layer_renderer = new Inspector_Custom_Renderer(function(_x, _y, _w, _m, _hover, _focus) { ds_map_clear(surfMap); var index = -1; @@ -84,7 +84,7 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr surfMap[? _id] = [ [ index, _surf ] ]; } - #region draw bones + #region draw bones var _b = bone; if(_b == noone) return 0; var amo = _b.childCount(); @@ -333,7 +333,7 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr } #endregion - if(layer_dragging != noone && mouse_release(mb_left)) { #region + if(layer_dragging != noone && mouse_release(mb_left)) { if(layer_dragging != hoverIndex && hoverIndex != noone) { var index = input_fix_len + layer_dragging * data_length; var targt = input_fix_len + hoverIndex * data_length; @@ -362,11 +362,11 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr } layer_dragging = noone; - } #endregion + } layer_renderer.h = bh + ui(40) + sh; return layer_renderer.h; - #endregion + }); input_display_list = [ 1, 2, @@ -441,12 +441,12 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr bone = noone; surface_selecting = noone; - static getInputIndex = function(index) { #region + static getInputIndex = function(index) { if(index < input_fix_len) return index; return input_fix_len + (index - input_fix_len) * data_length; - } #endregion + } - static setBone = function() { #region + static setBone = function() { ds_map_clear(boneMap); var _b = getInputData(1); @@ -467,9 +467,9 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr } ds_stack_destroy(_bst); - } #endregion + } - 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 dim = getInputData(0); var _bind = getInputData(2); @@ -499,7 +499,7 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr var y0 = _y; var y1 = _y + hh * _s; - if(surf_dragging > -1) { #region + if(surf_dragging > -1) { var _surf = current_data[surf_dragging + 0]; var _tran = current_data[surf_dragging + 1]; var _aang = current_data[surf_dragging + 2]; @@ -564,7 +564,7 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr surf_dragging = -1; UNDO_HOLDING = false; } - } #endregion + } var hovering = noone; var hovering_type = noone; @@ -574,7 +574,7 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr var amo = (array_length(inputs) - input_fix_len) / data_length; var anchors = array_create(array_length(inputs)); - for(var i = 0; i < amo; i++) { #region + for(var i = 0; i < amo; i++) { var index = input_fix_len + i * data_length; var _surf = array_safe_get_fast(current_data, index); if(!_surf || is_array(_surf)) continue; @@ -632,9 +632,9 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr rot: _rot, } - } #endregion + } - for(var i = 0; i < amo; i++) { #region + for(var i = 0; i < amo; i++) { var vis = array_safe_get_fast(_vis, i); var sel = array_safe_get_fast(_sel, i); if(!vis) continue; @@ -675,7 +675,7 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr hovering = index; hovering_type = NODE_COMPOSE_DRAG.move; } - } #endregion + } if(mouse_press(mb_left, active)) surface_selecting = hovering; @@ -704,7 +704,7 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr draw_line(a.d3[0], a.d3[1], a.d2[0], a.d2[1]); } - if(hovering != noone && hovering_type != noone && mouse_press(mb_left, active)) { #region + if(hovering != noone && hovering_type != noone && mouse_press(mb_left, active)) { var _tran = current_data[hovering + 1]; var _aang = current_data[hovering + 2]; var _asca = current_data[hovering + 3]; @@ -731,15 +731,15 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr dragging_mx = (a.d0[0] + a.d3[0]) / 2; dragging_my = (a.d0[1] + a.d3[1]) / 2; } - } #endregion + } if(layer_remove > -1) { deleteLayer(layer_remove); layer_remove = -1; } - } #endregion + } - static step = function() { #region + static step = function() { var _dim_type = getSingleValue(1); inputs[2].setVisible(_dim_type == COMPOSE_OUTPUT_SCALING.constant); @@ -747,9 +747,9 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr inputs[i + 3].setVisible(current_data[i + 2]); inputs[i + 5].setVisible(current_data[i + 4]); } - } #endregion + } - static processData = function(_outSurf, _data, _output_index, _array_index) { #region + static processData = function(_outSurf, _data, _output_index, _array_index) { if(_output_index == 1) return atlas_data; if(_output_index == 2) return bind_data; if(_output_index == 0 && _array_index == 0) { @@ -853,9 +853,9 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr surface_reset_shader(); return _outSurf; - } #endregion + } - static resetTransform = function(surfIndex) { #region + static resetTransform = function(surfIndex) { var _bind = getInputData(2); var use_data = _bind != noone; @@ -876,17 +876,17 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr var _tr = [ _cx - _anc.x, _cy - _anc.y, _rot, 1, 1 ]; inputs[surfIndex + 1].setValue(_tr); - } #endregion + } - static attributeSerialize = function() { #region + static attributeSerialize = function() { var att = {}; att.layer_visible = attributes.layer_visible; att.layer_selectable = attributes.layer_selectable; return att; - } #endregion + } - static attributeDeserialize = function(attr) { #region + static attributeDeserialize = function(attr) { struct_append(attributes, attr); if(struct_has(attributes, "use_project_dimension") && !struct_has(attr, "use_project_dimension")) @@ -897,10 +897,10 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr if(struct_has(attr, "layer_selectable")) attributes.layer_selectable = attr.layer_selectable; - } #endregion + } - static doApplyDeserialize = function() { #region + static doApplyDeserialize = function() { setBone(); - } #endregion + } } diff --git a/scripts/node_collection/node_collection.gml b/scripts/node_collection/node_collection.gml index e45ab2975..0dd1125c8 100644 --- a/scripts/node_collection/node_collection.gml +++ b/scripts/node_collection/node_collection.gml @@ -611,7 +611,7 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc static attributeSerialize = function() { sortIO(); - var _attr = variable_clone(attributes); + var _attr = {}; _attr.custom_input_list = []; for( var i = custom_input_index, n = array_length(inputs); i < n; i++ ) { diff --git a/scripts/node_data/node_data.gml b/scripts/node_data/node_data.gml index 2d651ca01..af1142aca 100644 --- a/scripts/node_data/node_data.gml +++ b/scripts/node_data/node_data.gml @@ -208,6 +208,16 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor { input_button_length = array_length(input_buttons); }); + junc_meta = [ + nodeValue_Output("Name", self, VALUE_TYPE.text, ""), + nodeValue_Output("Position", self, VALUE_TYPE.float, [ 0, 0 ]) + .setDisplay(VALUE_DISPLAY.vector), + ]; + + for( var i = 0, n = array_length(junc_meta); i < n; i++ ) { + junc_meta[i].index = i; + junc_meta[i].tags = VALUE_TAG.matadata; + } #endregion #region --- attributes ---- @@ -215,15 +225,17 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor { attributes.node_width = 0; attributes.node_height = 0; attributes.annotation = ""; + attributes.outp_meta = false; attributeEditors = [ "Display", - ["Annotation", function() { return attributes.annotation; }, new textArea(TEXTBOX_INPUT.text, function(val) { attributes.annotation = val; }) ], - ["Params Width", function() { return attributes.node_param_width; }, new textBox(TEXTBOX_INPUT.number, function(val) { attributes.node_param_width = val; refreshNodeDisplay(); }) ], + ["Annotation", function() /*=>*/ {return attributes.annotation}, new textArea(TEXTBOX_INPUT.text, function(val) /*=>*/ { attributes.annotation = val; }) ], + ["Params Width", function() /*=>*/ {return attributes.node_param_width}, new textBox(TEXTBOX_INPUT.number, function(val) /*=>*/ { attributes.node_param_width = val; refreshNodeDisplay(); }) ], - "Node update", - ["Auto update", function() { return attributes.update_graph; }, new checkBox(function() { attributes.update_graph = !attributes.update_graph; }) ], - ["Update trigger", function() { return attributes.show_update_trigger; }, new checkBox(function() { attributes.show_update_trigger = !attributes.show_update_trigger; }) ], + "Node", + ["Auto update", function() /*=>*/ {return attributes.update_graph}, new checkBox(function() /*=>*/ { attributes.update_graph = !attributes.update_graph; }) ], + ["Update trigger", function() /*=>*/ {return attributes.show_update_trigger}, new checkBox(function() /*=>*/ { attributes.show_update_trigger = !attributes.show_update_trigger; }) ], + ["Output metadata", function() /*=>*/ {return attributes.outp_meta}, new checkBox(function() /*=>*/ { attributes.outp_meta = !attributes.outp_meta; setHeight(); }) ], ]; bufferStore = {}; @@ -584,6 +596,10 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor { if(is_3D == NODE_3D.polygon) USE_DEPTH = true; if(is_simulation) PROJECT.animator.is_simulating = true; + if(attributes.outp_meta) { + junc_meta[0].setValue(getDisplayName()); + junc_meta[1].setValue([ x, y ]); + } } static doStepBegin = function() {} @@ -718,6 +734,13 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor { _ho += junction_draw_hei_y * _byp.visible; } + if(attributes.outp_meta) { + for( var i = 0; i < array_length(junc_meta); i++ ) { + if(!junc_meta[i].isVisible()) continue; + _ho += junction_draw_hei_y; + } + } + h = max(min_h, _prev_surf * 128, _hi, _ho); if(attributes.node_height) h = max(h, attributes.node_height); @@ -1333,6 +1356,16 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor { ry += junction_draw_hei_y * jun.visible; } + for( var i = 0, n = array_length(junc_meta); i < n; i++ ) { + var jun = junc_meta[i]; + + jun.x = _ox; jun.rx = rx; + jun.y = _oy; jun.ry = ry; + + _oy += junction_draw_hei_y * jun.isVisible() * _s; + ry += junction_draw_hei_y * jun.isVisible(); + } + if(SHOW_PARAM) h = h_param; onPreDraw(_x, _y, _s, _iy, _oy); @@ -1549,6 +1582,15 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor { if(updatedOutTrigger.drawJunction(_s, _mx, _my)) hover = updatedOutTrigger; } + if(attributes.outp_meta) { + for(var i = 0; i < array_length(junc_meta); i++) { // outputs + var jun = junc_meta[i]; + + if(!jun.isVisible()) continue; + if(jun.drawJunction(_s, _mx, _my)) hover = jun; + } + } + onDrawJunctions(_x, _y, _mx, _my, _s); return hover; @@ -1589,6 +1631,15 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor { if(updatedOutTrigger.drawJunction_fast(_s, _mx, _my)) hover = updatedOutTrigger; } + if(attributes.outp_meta) { + for(var i = 0; i < array_length(junc_meta); i++) { // outputs + var jun = junc_meta[i]; + + if(!jun.isVisible()) continue; + if(jun.drawJunction_fast(_s, _mx, _my)) hover = jun; + } + } + onDrawJunctions(_x, _y, _mx, _my, _s); return hover; @@ -1652,6 +1703,17 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor { if(jun == noone || !jun.visible) continue; jun.drawName(_s, _mx, _my); } + + if(attributes.outp_meta) { + for(var i = 0; i < array_length(junc_meta); i++) { + var jun = junc_meta[i]; + + if(!jun.isVisible()) continue; + jun.drawNameBG(_s); + jun.drawName(_s, _mx, _my); + } + } + } if(hasInspector1Update() && PANEL_GRAPH.pHOVER && point_in_circle(_mx, _my, inspectInput1.x, inspectInput1.y, 10)) { @@ -2235,7 +2297,8 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor { _map.show_parameter = show_parameter; } - _map.attri = attributeSerialize(); + var _attr = attributeSerialize(); + _map.attri = struct_append(attributes, _attr); if(is_dynamic_input) { _map.input_fix_len = input_fix_len; @@ -2258,7 +2321,12 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor { array_push(_trigger, updatedInTrigger.serialize(scale, preset)); array_push(_trigger, updatedOutTrigger.serialize(scale, preset)); + var _outMeta = []; + for(var i = 0; i < array_length(junc_meta); i++) + _outData[i] = junc_meta[i].serialize(scale, preset); + _map.inspectInputs = _trigger; + _map.outputMeta = _outMeta; _map.renamed = renamed; _map.buffer = {}; @@ -2273,7 +2341,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor { return _map; } - static attributeSerialize = function() { return attributes; } + static attributeSerialize = function() { return {}; } static doSerialize = function(_map) {} static processSerialize = function(_map) {} @@ -2433,6 +2501,13 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor { if(array_length(insInp) > 3) updatedOutTrigger.applyDeserialize(insInp[3], load_scale, preset); } + if(struct_has(load_map, "outputMeta")) { + var _outMeta = load_map.outputMeta; + + for(var i = 0; i < min(array_length(_outMeta), array_length(junc_meta)); i++) + junc_meta[i].applyDeserialize(_outMeta[i], load_scale, preset); + } + //print($"Applying deserialzie for {name} complete"); doApplyDeserialize(); diff --git a/scripts/node_mesh_warp/node_mesh_warp.gml b/scripts/node_mesh_warp/node_mesh_warp.gml index 1e42dddd6..d75962632 100644 --- a/scripts/node_mesh_warp/node_mesh_warp.gml +++ b/scripts/node_mesh_warp/node_mesh_warp.gml @@ -751,7 +751,6 @@ function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) static attributeSerialize = function() { var att = {}; - struct_append(att, attributes); var pinList = []; for( var j = 0; j < array_length(mesh_data.points); j++ ) { diff --git a/scripts/node_rigid_object/node_rigid_object.gml b/scripts/node_rigid_object/node_rigid_object.gml index cfa8cdc00..e966c5c5b 100644 --- a/scripts/node_rigid_object/node_rigid_object.gml +++ b/scripts/node_rigid_object/node_rigid_object.gml @@ -97,11 +97,11 @@ function Node_Rigid_Object(_x, _y, _group = noone) : Node(_x, _y, _group) constr anchor_drag_mx = -1; anchor_drag_my = -1; - static getPreviewValues = function() { #region + static getPreviewValues = function() { return getInputData(6); - } #endregion + } - static generateAllMesh = function() { #region + static generateAllMesh = function() { var _tex = getInputData(6); if(is_array(_tex)) { @@ -110,9 +110,9 @@ function Node_Rigid_Object(_x, _y, _group = noone) : Node(_x, _y, _group) constr } else generateMesh(); doUpdate(); - } #endregion + } - static drawOverlayPreviewSingle = function(_i, _x, _y, _s, _pr_x, _pr_y, _tex_s) { #region + static drawOverlayPreviewSingle = function(_i, _x, _y, _s, _pr_x, _pr_y, _tex_s) { var meshes = attributes.mesh; var _shp = getInputData(5); @@ -151,9 +151,9 @@ function Node_Rigid_Object(_x, _y, _group = noone) : Node(_x, _y, _group) constr } draw_surface_ext_safe(_tex, _pr_x, _pr_y, _s, _s, 0, c_white, 0.5); - } #endregion + } - static drawOverlayPreview = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { #region + static drawOverlayPreview = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { var _pos = getInputData(7); var _tex = getInputData(6); @@ -167,9 +167,9 @@ function Node_Rigid_Object(_x, _y, _group = noone) : Node(_x, _y, _group) constr drawOverlayPreviewSingle(0, _x, _y, _s, _pr_x, _pr_y, _tex); return inputs[7].drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny); - } #endregion + } - 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 gr = is_instanceof(group, Node_Rigid_Group)? group : noone; if(inline_context != noone) gr = inline_context; @@ -289,9 +289,9 @@ function Node_Rigid_Object(_x, _y, _group = noone) : Node(_x, _y, _group) constr var a = inputs[7].drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny); active &= !a; return active; - } #endregion + } - static generateMesh = function(index = 0) { #region + static generateMesh = function(index = 0) { var _tex = getInputData(6); var _exp = getInputData(10); var _pix = getInputData(11); @@ -432,9 +432,9 @@ function Node_Rigid_Object(_x, _y, _group = noone) : Node(_x, _y, _group) constr meshes[index] = mesh; attributes.mesh = meshes; - } #endregion + } - static removeColinear = function(mesh) { #region + static removeColinear = function(mesh) { var len = array_length(mesh), _side = 0; var remSt = []; var tolerance = 5; @@ -461,9 +461,9 @@ function Node_Rigid_Object(_x, _y, _group = noone) : Node(_x, _y, _group) constr } return mesh; - } #endregion + } - static removeConcave = function(mesh) { #region + static removeConcave = function(mesh) { var len = array_length(mesh); if(len <= 3) return; @@ -528,9 +528,9 @@ function Node_Rigid_Object(_x, _y, _group = noone) : Node(_x, _y, _group) constr } return mesh; - } #endregion + } - static fixtureCreate = function(fixture, object, dx = 0, dy = 0) { #region + static fixtureCreate = function(fixture, object, dx = 0, dy = 0) { var _mov = getInputData(0); var _den = getInputData(1); var _cnt_frc = getInputData(2); @@ -552,9 +552,9 @@ function Node_Rigid_Object(_x, _y, _group = noone) : Node(_x, _y, _group) constr array_push(object.fixture, physics_fixture_bind_ext(fixture, object, dx, dy)); physics_fixture_delete(fixture); - } #endregion + } - static spawn = function(index = 0, object = noone) { #region + static spawn = function(index = 0, object = noone) { var _shp = getInputData(5); var _tex = getInputData(6); var _spos = getInputData(7); @@ -682,15 +682,15 @@ function Node_Rigid_Object(_x, _y, _group = noone) : Node(_x, _y, _group) constr } return object; - } #endregion + } - static update = function(frame = CURRENT_FRAME) { #region + static update = function(frame = CURRENT_FRAME) { if(IS_FIRST_FRAME) reset(); outputs[0].setValue(object); - } #endregion + } - static step = function() { #region + static step = function() { var _shp = getInputData(5); inputs[ 9].setVisible(_shp == 2); @@ -707,9 +707,9 @@ function Node_Rigid_Object(_x, _y, _group = noone) : Node(_x, _y, _group) constr for( var i = array_length(meshes); i < array_length(_tex); i++ ) newMesh(i); } - } #endregion + } - static reset = function() { #region + static reset = function() { var _tex = getInputData(6); for( var i = 0, n = array_length(object); i < n; i++ ) { @@ -726,9 +726,9 @@ function Node_Rigid_Object(_x, _y, _group = noone) : Node(_x, _y, _group) constr object[i] = spawn(i); } else object = [ spawn() ]; - } #endregion + } - static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region + static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { if(!previewable) return; var bbox = drawGetBbox(xx, yy, _s); @@ -742,21 +742,21 @@ function Node_Rigid_Object(_x, _y, _group = noone) : Node(_x, _y, _group) constr var aa = 0.5 + 0.5 * renderActive; if(!isHighlightingInGraph()) aa *= 0.25; draw_surface_bbox(_tex, bbox,, aa); - } #endregion + } - static attributeSerialize = function() { #region + static attributeSerialize = function() { var att = {}; var mesh = struct_try_get(attributes, "mesh", []); att.mesh = json_stringify(mesh); return att; - } #endregion + } - static attributeDeserialize = function(attr) { #region + static attributeDeserialize = function(attr) { struct_append(attributes, attr); if(struct_has(attr, "mesh")) attributes.mesh = json_parse(attr.mesh); - } #endregion + } } \ No newline at end of file diff --git a/scripts/node_tiler/node_tiler.gml b/scripts/node_tiler/node_tiler.gml index cf3a49d9e..4e11d91d0 100644 --- a/scripts/node_tiler/node_tiler.gml +++ b/scripts/node_tiler/node_tiler.gml @@ -372,9 +372,11 @@ function Node_Tile_Drawer(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// static attributeSerialize = function() { - attributes.canvas = surface_encode(canvas_surface); + var _attr = { + canvas : surface_encode(canvas_surface), + } - return attributes; + return _attr; } static attributeDeserialize = function(attr) { diff --git a/scripts/node_tiler_tileset/node_tiler_tileset.gml b/scripts/node_tiler_tileset/node_tiler_tileset.gml index 2432ca9e7..32e7948ee 100644 --- a/scripts/node_tiler_tileset/node_tiler_tileset.gml +++ b/scripts/node_tiler_tileset/node_tiler_tileset.gml @@ -381,7 +381,14 @@ function Node_Tile_Tileset(_x, _y, _group = noone) : Node(_x, _y, _group) constr draw_sprite_uniform(THEME.cross, 0, _sx + _sw / 2, _sy + _sh / 2, 1, COLORS._main_icon, _aa); if(_shov) { - if(is(object_selecting, tiler_rule)) { + if(object_selecting == noone) { + if(mouse_press(mb_left, _focus)) { + brush.brush_indices = [[[ -1, 0 ]]]; + brush.brush_width = 1; + brush.brush_height = 1; + } + + } else if(is(object_selecting, tiler_rule)) { TOOLTIP = "Set Rule selector"; if(mouse_press(mb_left, _focus)) { diff --git a/scripts/node_value/node_value.gml b/scripts/node_value/node_value.gml index bb9a7d944..d8478230e 100644 --- a/scripts/node_value/node_value.gml +++ b/scripts/node_value/node_value.gml @@ -241,6 +241,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru #region ---- serialization ---- con_node = -1; con_index = -1; + con_tag = 0; #endregion /////============= META ============= @@ -2117,23 +2118,23 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru if(connect_type == CONNECT_TYPE.output) return _map; - _map.name = name; - _map.on_end = on_end; - _map.loop_range = loop_range; - _map.unit = unit.mode; - _map.sep_axis = sep_axis; - _map.shift_x = draw_line_shift_x; - _map.shift_y = draw_line_shift_y; - _map.is_modified= is_modified; + _map.name = name; + _map.on_end = on_end; + _map.loop_range = loop_range; + _map.unit = unit.mode; + _map.sep_axis = sep_axis; + _map.shift_x = draw_line_shift_x; + _map.shift_y = draw_line_shift_y; + _map.is_modified = is_modified; + + _map.from_node = -1; + _map.from_index = -1; + _map.from_tag = 0; if(!preset && value_from) { _map.from_node = value_from.node.node_id; - - if(value_from.tags != 0) _map.from_index = value_from.tags; - else _map.from_index = value_from.index; - } else { - _map.from_node = -1; - _map.from_index = -1; + _map.from_index = value_from.index; + _map.from_tag = value_from.tags; } _map.global_use = expUse; @@ -2196,8 +2197,9 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru } if(!preset) { - con_node = struct_try_get(_map, "from_node", -1); + con_node = struct_try_get(_map, "from_node", -1) con_index = struct_try_get(_map, "from_index", -1); + con_tag = struct_try_get(_map, "from_tag", -1); } if(struct_has(_map, "display_data")) { @@ -2247,30 +2249,35 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru if(log) log_warning("LOAD", $"[Connect] Reconnecting {node.name} to {_nd.name}", node); - if(con_index == VALUE_TAG.updateInTrigger) return setFrom(_nd.updatedInTrigger); - if(con_index == VALUE_TAG.updateOutTrigger) return setFrom(_nd.updatedOutTrigger); - - if(con_index < _ol) { - var _set = setFrom(_nd.outputs[con_index], false, true); - if(_set) return true; + switch(con_tag) { + case VALUE_TAG.updateInTrigger : return setFrom(_nd.updatedInTrigger); + case VALUE_TAG.updateOutTrigger : return setFrom(_nd.updatedOutTrigger); + case VALUE_TAG.matadata : return setFrom(_nd.junc_meta[con_index]); - if(_set == -1) log_warning("LOAD", $"[Connect] Connection conflict {node.name} to {_nd.name} : Not connectable.", node); - else if(_set == -2) log_warning("LOAD", $"[Connect] Connection conflict {node.name} to {_nd.name} : Condition not met.", node); - - return false; - } - - if(con_index >= 1000) { //connect bypass - var _inp = array_safe_get_fast(_nd.inputs, con_index - 1000, noone); - if(_inp == noone) return false; - - var _set = setFrom(_inp.bypass_junc, false, true); - if(_set) return true; - - if(_set == -1) log_warning("LOAD", $"[Connect] Connection conflict {node.name} to {_nd.name} (bypass) : Not connectable.", node); - else if(_set == -2) log_warning("LOAD", $"[Connect] Connection conflict {node.name} to {_nd.name} (bypass) : Condition not met.", node); - - return false; + default : + if(con_index < _ol) { + var _set = setFrom(_nd.outputs[con_index], false, true); + if(_set) return true; + + if(_set == -1) log_warning("LOAD", $"[Connect] Connection conflict {node.name} to {_nd.name} : Not connectable.", node); + else if(_set == -2) log_warning("LOAD", $"[Connect] Connection conflict {node.name} to {_nd.name} : Condition not met.", node); + + return false; + } + + if(con_index >= 1000) { //connect bypass + var _inp = array_safe_get_fast(_nd.inputs, con_index - 1000, noone); + if(_inp == noone) return false; + + var _set = setFrom(_inp.bypass_junc, false, true); + if(_set) return true; + + if(_set == -1) log_warning("LOAD", $"[Connect] Connection conflict {node.name} to {_nd.name} (bypass) : Not connectable.", node); + else if(_set == -2) log_warning("LOAD", $"[Connect] Connection conflict {node.name} to {_nd.name} (bypass) : Condition not met.", node); + + return false; + } + break; } log_warning("LOAD", $"[Connect] Connection conflict {node.name} to {_nd.name} : Output not exist [{con_index}].", node); diff --git a/scripts/node_value_types/node_value_types.gml b/scripts/node_value_types/node_value_types.gml index b5919c322..ba9d51826 100644 --- a/scripts/node_value_types/node_value_types.gml +++ b/scripts/node_value_types/node_value_types.gml @@ -141,9 +141,10 @@ enum VALUE_UNIT { } enum VALUE_TAG { - updateInTrigger = -2, - updateOutTrigger = -3, - none = 0 + updateInTrigger = -2, + updateOutTrigger = -3, + matadata = -4, + none = 0, } enum LINE_STYLE { diff --git a/scripts/panel_custom_inspector/panel_custom_inspector.gml b/scripts/panel_custom_inspector/panel_custom_inspector.gml index 1e51500a7..74d232369 100644 --- a/scripts/panel_custom_inspector/panel_custom_inspector.gml +++ b/scripts/panel_custom_inspector/panel_custom_inspector.gml @@ -7,16 +7,28 @@ function Panel_Custom_Inspector(_title, _inspector) : PanelContent() constructor inspector = _inspector; inspector.popupPanel = self; + sc_content = new scrollPane(w - ui(padding + padding), h - ui(title_height + padding + 40), function(_y, _m) { + draw_clear_alpha(COLORS.panel_bg_clear, 1); + var _wdh = inspector.draw(0, _y, sc_content.surface_w, [ mx, my ], pHOVER, pFOCUS, self); + return _wdh; + }); + + function onResize() { + var pd = in_dialog? ui(2) : ui(8); + sc_content.resize(w - pd * 2, h - pd * 2); + } + function drawContent(panel) { draw_clear_alpha(COLORS.panel_bg_clear, 0); - var pd = in_dialog? ui(0) : ui(8); + var pd = in_dialog? ui(2) : ui(8); inspector.panel = self; - inspector.rx = x; - inspector.ry = y; - inspector.fixHeight = h - pd * 2; + inspector.rx = x + pd; + inspector.ry = y + pd; + inspector.fixHeight = sc_content.surface_h; - var _wdh = inspector.draw(pd, pd, w - pd * 2, [ mx, my ], pHOVER, pFOCUS, self); + sc_content.setFocusHover(pFOCUS, pHOVER); + sc_content.draw(pd, pd, mx - pd, my - pd); } static onClose = function() { diff --git a/scripts/panel_inspector/panel_inspector.gml b/scripts/panel_inspector/panel_inspector.gml index ca667dccd..8773dc912 100644 --- a/scripts/panel_inspector/panel_inspector.gml +++ b/scripts/panel_inspector/panel_inspector.gml @@ -609,6 +609,7 @@ function Panel_Inspector() : PanelContent() constructor { var wx1 = con_w - ui(8); var ww = max(ui(180), con_w / 3); var wx0 = wx1 - ww; + var font = viewMode == INSP_VIEW_MODE.spacious? f_p1 : f_p2; for( var i = 0, n = array_length(_inspecting.attributeEditors); i < n; i++ ) { var edt = _inspecting.attributeEditors[i]; @@ -633,28 +634,33 @@ function Panel_Inspector() : PanelContent() constructor { var _att_name = edt[0]; var _att_val = edt[1](); var _att_wid = edt[2]; + var _att_h = viewMode == INSP_VIEW_MODE.spacious? hg : line_get_height(font, 8); + _att_wid.font = font; _att_wid.setFocusHover(pFOCUS, pHOVER); if(instanceof(_att_wid) == "buttonClass") { _att_wid.text = _att_name; - _att_wid.draw(ui(8), yy, con_w - ui(16), hg, _m); + _att_wid.draw(ui(8), yy, con_w - ui(16), _att_h, _m); if(_att_wid.inBBOX(_m)) contentPane.hover_content = true; - yy += hg + ui(8); - hh += hg + ui(8); + yy += _att_h + ui(8); + hh += _att_h + ui(8); continue; } - draw_set_text(f_p1, fa_left, fa_center, COLORS._main_text); - draw_text_add(ui(8), yy + hg / 2, _att_name); + draw_set_text(font, fa_left, fa_center, COLORS._main_text); + draw_text_add(ui(8), yy + _att_h / 2, _att_name); - var _param = new widgetParam(wx0, yy, ww, hg, _att_val, {}, _m, x + contentPane.x, y + contentPane.y); - _param.s = hg; + var _param = new widgetParam(wx0, yy, ww, _att_h, _att_val, {}, _m, x + contentPane.x, y + contentPane.y); + _param.s = _att_h; + _param.font = font; + var _wh = _att_wid.drawParam(_param); - var _hg = max(hg, _wh); if(_att_wid.inBBOX(_m)) contentPane.hover_content = true; + + var _hg = max(_att_h, _wh); yy += _hg + ui(8); hh += _hg + ui(8); } @@ -701,7 +707,9 @@ function Panel_Inspector() : PanelContent() constructor { var jun = noone; var amoIn = is_array(_inspecting.input_display_list)? array_length(_inspecting.input_display_list) : array_length(_inspecting.inputs); var amoOut = is_array(_inspecting.output_display_list)? array_length(_inspecting.output_display_list) : array_length(_inspecting.outputs); - var amo = inspectGroup == 0? amoIn + 1 + amoOut : amoIn; + var amoMeta = _inspecting.attributes.outp_meta? array_length(_inspecting.junc_meta) : 0; + + var amo = inspectGroup == 0? amoIn + 1 + amoOut + amoMeta : amoIn; var color_picker_index = 0; var pickers = []; @@ -726,7 +734,7 @@ function Panel_Inspector() : PanelContent() constructor { draw_text_add(xc, yy + ui(8 + 16), __txt("Outputs")); continue; - } else { // outputs + } else if(i < amoIn + 1 + amoOut) { // outputs var _oi = i - amoIn - 1; var _dsl = _inspecting.output_display_list; var _dsp = array_safe_get_fast(_dsl, _oi); @@ -734,7 +742,11 @@ function Panel_Inspector() : PanelContent() constructor { if(!is_array(_dsl)) jun = array_safe_get_fast(_inspecting.outputs, _oi); else if(is_real(_dsp)) jun = array_safe_get_fast(_inspecting.outputs, _dsp); else jun = _dsp; - } + + } else { // metadata + jun = _inspecting.junc_meta[i - (amoIn + 1 + amoOut)]; + + } if(is_instanceof(jun, Inspector_Spacer)) { // SPACER var _hh = ui(jun.h);