diff --git a/scripts/node_blur/node_blur.gml b/scripts/node_blur/node_blur.gml index ab85fb125..d259b5594 100644 --- a/scripts/node_blur/node_blur.gml +++ b/scripts/node_blur/node_blur.gml @@ -2,8 +2,10 @@ function Node_Blur(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons name = "Blur"; newInput(0, nodeValue_Surface("Surface in", self)); + newInput(1, nodeValue_Int("Size", self, 3)) - .setDisplay(VALUE_DISPLAY.slider, { range: [ 1, 32, 0.1 ] }); + .setValidator(VV_min(0)) + .setUnitRef(function(index) /*=>*/ {return getDimension(index)}); newInput(2, nodeValue_Enum_Scroll("Oversample mode", self, 0, [ "Empty", "Clamp", "Repeat" ])) .setTooltip("How to deal with pixel outside the surface.\n - Empty: Use empty pixel\n - Clamp: Repeat edge pixel\n - Repeat: Repeat texture."); @@ -45,11 +47,11 @@ function Node_Blur(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons attribute_oversample(); surface_blur_init(); - static step = function() { #region + static step = function() { __step_mask_modifier(); - } #endregion + } - static processData = function(_outSurf, _data, _output_index, _array_index) { #region + static processData = function(_outSurf, _data, _output_index, _array_index) { var _surf = _data[0]; var _size = min(128, _data[1]); var _clamp = struct_try_get(attributes, "oversample"); @@ -121,5 +123,5 @@ function Node_Blur(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons _outSurf = channel_apply(_data[0], _outSurf, _data[8]); return _outSurf; - } #endregion + } } \ No newline at end of file diff --git a/scripts/node_value/node_value.gml b/scripts/node_value/node_value.gml index 219cf1ac8..3222b3c9a 100644 --- a/scripts/node_value/node_value.gml +++ b/scripts/node_value/node_value.gml @@ -334,9 +334,6 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru if(editWidget) { editWidget.unit = unit; editWidget.onSurfaceSize = ref; - - if(is_instanceof(editWidget, textBox)) - editWidget.side_button = unit.triggerButton; } unit.reference = ref; diff --git a/scripts/node_value_int/node_value_int.gml b/scripts/node_value_int/node_value_int.gml index 2a9ec2e45..945c0088b 100644 --- a/scripts/node_value_int/node_value_int.gml +++ b/scripts/node_value_int/node_value_int.gml @@ -4,6 +4,12 @@ function __NodeValue_Int(_name, _node, _value, _tooltip = "") : NodeValue(_name, /////============== GET ============= + static valueProcess = function(value, nodeFrom = undefined, applyUnit = true, arrIndex = 0) { + if(validator != noone) value = validator.validate(value); + value = applyUnit? unit.apply(value, arrIndex) : value; + return round(value); + } + static getValue = function(_time = CURRENT_FRAME, applyUnit = true, arrIndex = 0, useCache = false, log = false) { //// Get value getValueRecursive(self.__curr_get_val, _time); var val = __curr_get_val[0]; @@ -14,9 +20,7 @@ function __NodeValue_Int(_name, _node, _value, _tooltip = "") : NodeValue(_name, if(typ != VALUE_TYPE.surface) { if(typ == VALUE_TYPE.text) val = toNumber(val); - if(validator != noone) val = validator.validate(val); - - return val; + return valueProcess(val, nod, applyUnit); } // Dimension conversion @@ -39,8 +43,10 @@ function __NodeValue_Int(_name, _node, _value, _tooltip = "") : NodeValue(_name, if(eqSize) return _osZ; return sArr; + } else if (is_surface(val)) return [ surface_get_width_safe(val), surface_get_height_safe(val) ]; + return [ 1, 1 ]; } diff --git a/scripts/node_value_types/node_value_types.gml b/scripts/node_value_types/node_value_types.gml index 6b71886bf..1482f5f12 100644 --- a/scripts/node_value_types/node_value_types.gml +++ b/scripts/node_value_types/node_value_types.gml @@ -503,6 +503,7 @@ function nodeValueUnit(_nodeValue) constructor { _nodeValue.unitConvert(mode); _nodeValue.node.doUpdate(); }); + triggerButton.icon_blend = COLORS._main_icon_light; triggerButton.icon = THEME.unit_ref; triggerButton.tooltip = new tooltipSelector("Unit", ["Pixel", "Fraction"]); @@ -520,7 +521,6 @@ function nodeValueUnit(_nodeValue) constructor { static draw = function(_x, _y, _w, _h, _m) { triggerButton.icon_index = mode; triggerButton.tooltip.index = mode; - triggerButton.draw(_x, _y, _w, _h, _m, THEME.button_hide); } @@ -555,8 +555,9 @@ function nodeValueUnit(_nodeValue) constructor { for( var i = 0, n = array_length(value); i < n; i++ ) _val[i] = value[i] * base; return _val; - - } else if(is_array(value)) { + } + + if(is_array(value)) { if(inv) { base = [ base[0] == 0? 0 : 1 / array_safe_get(base, 0), @@ -598,6 +599,11 @@ function nodeValueUnit(_nodeValue) constructor { return _val; } + + } else { + base = array_safe_get(base, 0, 1); + if(inv) base = base == 0? 0 : 1 / base; + return value * base; } return value; diff --git a/scripts/textBox/textBox.gml b/scripts/textBox/textBox.gml index 4f9bff430..81e2d242a 100644 --- a/scripts/textBox/textBox.gml +++ b/scripts/textBox/textBox.gml @@ -13,6 +13,7 @@ function textBox(_input, _onModify) : textInput(_input, _onModify) constructor { precision = 5; padding = ui(8); + unit = noone; suffix = ""; no_empty = true; @@ -473,6 +474,12 @@ function textBox(_input, _onModify) : textInput(_input, _onModify) constructor { _w -= _bs + ui(4); } + if(unit != noone && unit.reference != noone) { + unit.triggerButton.setFocusHover(iactive, ihover); + unit.draw(_x + _w - _bs, _y + _h / 2 - _bs / 2, _bs, _bs, _m); + _w -= _bs + ui(4); + } + if(_w - _bs > ui(100) && side_button) { side_button.setFocusHover(active, hover); side_button.draw(_x + _w - _bs, _y + _h / 2 - _bs / 2, _bs, _bs, _m, THEME.button_hide);