From 9bba747d3415e152db251f4eab043401403d068e Mon Sep 17 00:00:00 2001 From: Tanasart Date: Thu, 19 Sep 2024 12:36:57 +0700 Subject: [PATCH] small things --- scripts/buttonColor/buttonColor.gml | 16 ++-- scripts/node_2d_light/node_2d_light.gml | 1 + scripts/node_line/node_line.gml | 75 +++++++++++++++---- scripts/node_value/node_value.gml | 2 +- scripts/panel_graph/panel_graph.gml | 2 +- .../panel_notification/panel_notification.gml | 2 +- scripts/panel_presets/panel_presets.gml | 2 +- shaders/sh_curve/sh_curve.fsh | 2 +- shaders/sh_curve_hsv/sh_curve_hsv.fsh | 2 +- 9 files changed, 72 insertions(+), 32 deletions(-) diff --git a/scripts/buttonColor/buttonColor.gml b/scripts/buttonColor/buttonColor.gml index e64f07db8..fa3e8d1db 100644 --- a/scripts/buttonColor/buttonColor.gml +++ b/scripts/buttonColor/buttonColor.gml @@ -140,14 +140,9 @@ function buttonColor(_onApply, dialog = noone) : widget() constructor { var _htg = ui(12); var _bcc = COLORS._main_icon; - if(ihover && hover_hex > 0) { - var _dis = false; - if(ihover && point_in_rectangle(_m[0], _m[1], _bx + _bww, _y, _bx + _bw, _y + _h)) { + if(hover_hex > 0) { + if(ihover && point_in_rectangle(_m[0], _m[1], _bx + _bw - ui(24), _y, _bx + _bw, _y + _h)) { _htg = _bw - _bh; - _dis = true; - } - - if(_dis && point_in_rectangle(_m[0], _m[1], _bx + _bw - ui(24), _y, _bx + _bw, _y + _h)) { _baa = 1.; if(mouse_press(mb_left, iactive)) { @@ -162,16 +157,15 @@ function buttonColor(_onApply, dialog = noone) : widget() constructor { if(mouse_click(mb_left, iactive)) _bcc = COLORS._main_icon_light; } - } - - hover_wid = lerp_float(hover_wid, _htg, 5); - if(hover_hex > 0) { + draw_set_text(f_p1, fa_right, fa_center, COLORS._main_text_sub); draw_text_add(_bx + _bw - ui(28), _y + _h / 2 + ui(1), color_get_hex(current_color)); draw_sprite_ext(interactable && key_mod_press(SHIFT)? THEME.paste_20 : THEME.copy_20, 0, _bcx, _bcy, 1, 1, 0, _bcc, _baa); } + hover_wid = lerp_float(hover_wid, _htg, 5); + var _a = _color_get_alpha(current_color); if(_a == 1) { draw_sprite_stretched_ext(THEME.palette_mask, 1, _bx, _by, _bww, _bh, current_color, 1); diff --git a/scripts/node_2d_light/node_2d_light.gml b/scripts/node_2d_light/node_2d_light.gml index d2816da49..418818cc6 100644 --- a/scripts/node_2d_light/node_2d_light.gml +++ b/scripts/node_2d_light/node_2d_light.gml @@ -88,6 +88,7 @@ function Node_2D_light(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) var hv = inputs[2].drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny); _hov |= bool(hv); var hv = inputs[3].drawOverlay(hover, active, px, py, _s, _mx, _my, _snx, _sny); _hov |= bool(hv); break; + case LIGHT_SHAPE_2D.line : case LIGHT_SHAPE_2D.line_asym : case LIGHT_SHAPE_2D.spot : diff --git a/scripts/node_line/node_line.gml b/scripts/node_line/node_line.gml index 18e3357c1..1fdfbe286 100644 --- a/scripts/node_line/node_line.gml +++ b/scripts/node_line/node_line.gml @@ -60,7 +60,7 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons newInput(26, nodeValue_Bool("Clamp range", self, false )); - newInput(27, nodeValue_Enum_Scroll("Data Type", self, 1, [ "None", "Path", "Segments" ])); + newInput(27, nodeValue_Enum_Scroll("Data Type", self, 1, [ "None", "Path", "Segments", "Two points" ])); newInput(28, nodeValue_Vector("Segments", self, [[]])) .setArrayDepth(2); @@ -71,9 +71,15 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons newInput(31, nodeValue_Padding("Padding", self, [ 0, 0, 0, 0 ])) + newInput(32, nodeValue_Vec2("Start Point", self, [ 0, 0.5 ])) + .setUnitRef(function(index) /*=>*/ {return getDimension(index)}, VALUE_UNIT.reference); + + newInput(33, nodeValue_Vec2("End Point", self, [ 1, 0.5 ])) + .setUnitRef(function(index) /*=>*/ {return getDimension(index)}, VALUE_UNIT.reference); + input_display_list = [ ["Output", true], 0, 1, 30, 31, - ["Line data", false], 27, 6, 7, 28, 19, 2, 20, + ["Line data", false], 27, 6, 7, 28, 32, 33, 19, 2, 20, ["Line settings", false], 17, 3, 11, 12, 8, 25, 9, 26, 13, 14, ["Wiggle", false], 4, 5, ["Render", false], 10, 24, 15, 16, @@ -110,10 +116,18 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons y1 = _y + y1 * _s; draw_line(x0, y0, x1, y1); - - // draw_circle(x0, y0, 4, false); } } + + var _dtype = getInputData(27); + var _hov = false; + + if(_dtype == 3) { + var hv = inputs[32].drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny); _hov |= bool(hv); + var hv = inputs[33].drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny); _hov |= bool(hv); + } + + return _hov; } static step = function() { @@ -134,15 +148,26 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons inputs[ 2].setVisible(!_flen); inputs[20].setVisible( _flen); + var _pat = getInputData( 7); var _dtype = getInputData(27); + var _segs = getInputData(28); var _pbbox = getInputData(30); + if(_dtype == 1 && _pat == noone) + _dtype = 0; + + if(_dtype == 2 && (array_invalid(_segs) || array_invalid(_segs[0]))) + _dtype = 0; + inputs[ 6].setVisible(_dtype == 0); inputs[ 7].setVisible(_dtype == 1, _dtype == 1); inputs[28].setVisible(_dtype == 2, _dtype == 2); - inputs[30].setVisible(_dtype); - inputs[31].setVisible(_dtype && _pbbox); + inputs[30].setVisible( _dtype == 1 || _dtype == 2); + inputs[31].setVisible((_dtype == 1 || _dtype == 2) && _pbbox); + + inputs[32].setVisible(_dtype == 3); + inputs[33].setVisible(_dtype == 3); } static onValueUpdate = function(index = 0) { @@ -191,12 +216,18 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons var _pbbox = _data[30]; var _ppadd = _data[31]; + + var _pnt0 = _data[32]; + var _pnt1 = _data[33]; #endregion - /////// Guard clauses + /////// Check data - if(_dtype == 1 && _pat == noone) return _outData; - if(_dtype == 2 && (array_invalid(_segs) || array_invalid(_segs[0]))) return _outData; + if(_dtype == 1 && _pat == noone) + _dtype = 0; + + if(_dtype == 2 && (array_invalid(_segs) || array_invalid(_segs[0]))) + _dtype = 0; /////// Data @@ -228,13 +259,25 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons switch(_dtype) { case 0 : - _ang = (_ang % 360 + 360) % 360; - + case 3 : var x0, y0, x1, y1; - var _0 = point_rectangle_overlap(_dim[0], _dim[1], (_ang + 180) % 360); - var _1 = point_rectangle_overlap(_dim[0], _dim[1], _ang); - x0 = _0[0]; y0 = _0[1]; - x1 = _1[0]; y1 = _1[1]; + + if(_dtype == 0) { + _ang = (_ang % 360 + 360) % 360; + + var _0 = point_rectangle_overlap(_dim[0], _dim[1], (_ang + 180) % 360); + var _1 = point_rectangle_overlap(_dim[0], _dim[1], _ang); + x0 = _0[0]; + y0 = _0[1]; + x1 = _1[0]; + y1 = _1[1]; + + } else if(_dtype == 3) { + x0 = _pnt0[0]; + y0 = _pnt0[1]; + x1 = _pnt1[0]; + y1 = _pnt1[1]; + } var _l = point_distance(x0, y0, x1, y1); var _d = point_direction(x0, y0, x1, y1); @@ -480,6 +523,8 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons if(_pbbox) _surfDim = [ max(1, maxx - minx + _ppadd[0] + _ppadd[2]), max(1, maxy - miny + _ppadd[1] + _ppadd[3]) ]; break; + + } /////// Draw diff --git a/scripts/node_value/node_value.gml b/scripts/node_value/node_value.gml index 659d064c3..7a9f6529b 100644 --- a/scripts/node_value/node_value.gml +++ b/scripts/node_value/node_value.gml @@ -1285,7 +1285,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru arr[@ 1] = self; } - if(!expUse || !expTree.validate()) return; + if(!expUse || expTree == noone || !expTree.validate()) return; if(global.EVALUATE_HEAD == self) { noti_warning($"Expression evaluation error : recursive call detected."); diff --git a/scripts/panel_graph/panel_graph.gml b/scripts/panel_graph/panel_graph.gml index b04115941..4af54b328 100644 --- a/scripts/panel_graph/panel_graph.gml +++ b/scripts/panel_graph/panel_graph.gml @@ -2284,7 +2284,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor { var y1 = y0 + hh; draw_sprite_stretched( THEME.ui_panel_bg, 3, x0, y0, ww, hh); - draw_sprite_stretched_add(THEME.ui_panel, 1, x0, y0, ww, hh, c_white, 0.25); + // draw_sprite_stretched_add(THEME.ui_panel, 1, x0, y0, ww, hh, c_white, 0.1); draw_sprite_stretched( THEME.button_hide_fill, 1, x0 + pd, y0 + pd, tw, th); tb_search.font = f_p2; diff --git a/scripts/panel_notification/panel_notification.gml b/scripts/panel_notification/panel_notification.gml index f322f0c82..5e046b614 100644 --- a/scripts/panel_notification/panel_notification.gml +++ b/scripts/panel_notification/panel_notification.gml @@ -45,7 +45,7 @@ function Panel_Notification() : PanelContent() constructor { sp_noti = new scrollPane(w - ui(padding + padding), h - ui(padding + padding), function(_y, _m) { draw_clear_alpha(COLORS.panel_bg_clear_inner, 1); - var hh = 32; + var hh = ui(8); var yy = _y; var txw = sp_noti.surface_w - ui(48); if(show_time) txw -= ui(68); diff --git a/scripts/panel_presets/panel_presets.gml b/scripts/panel_presets/panel_presets.gml index c555fc4bf..a935e39a2 100644 --- a/scripts/panel_presets/panel_presets.gml +++ b/scripts/panel_presets/panel_presets.gml @@ -76,7 +76,7 @@ function Panel_Presets(_node) : PanelContent() constructor { function onResize() { sc_presets.resize(w - ui(padding + padding), h - ui(padding + padding) - ui(28)); } sc_presets = new scrollPane(w - ui(padding + padding), h - ui(padding + padding) - ui(28), function(_y, _m) { - draw_clear_alpha(COLORS.panel_bg_clear, 0); + draw_clear_alpha(COLORS.panel_bg_clear_inner, 1); var _ww = sc_presets.surface_w; var _h = 0; diff --git a/shaders/sh_curve/sh_curve.fsh b/shaders/sh_curve/sh_curve.fsh index 77b126980..e7c3f7821 100644 --- a/shaders/sh_curve/sh_curve.fsh +++ b/shaders/sh_curve/sh_curve.fsh @@ -1,6 +1,6 @@ #ifdef _YY_HLSL11_ - #define CURVE_MAX 1024 + #define CURVE_MAX 256 #else #define CURVE_MAX 256 #endif diff --git a/shaders/sh_curve_hsv/sh_curve_hsv.fsh b/shaders/sh_curve_hsv/sh_curve_hsv.fsh index 6729bb904..f7a69b21f 100644 --- a/shaders/sh_curve_hsv/sh_curve_hsv.fsh +++ b/shaders/sh_curve_hsv/sh_curve_hsv.fsh @@ -1,6 +1,6 @@ #ifdef _YY_HLSL11_ - #define CURVE_MAX 1024 + #define CURVE_MAX 256 #else #define CURVE_MAX 256 #endif