From 08435332a6ccfa77b1c60c934ec2fef465d590f0 Mon Sep 17 00:00:00 2001 From: Tanasart Date: Wed, 12 Jun 2024 09:46:02 +0700 Subject: [PATCH] - [Inspector Panel] Fix paste not working with some value. --- scripts/node_data/node_data.gml | 2 +- scripts/node_value/node_value.gml | 52 ++++++--------------- scripts/panel_inspector/panel_inspector.gml | 7 ++- 3 files changed, 18 insertions(+), 43 deletions(-) diff --git a/scripts/node_data/node_data.gml b/scripts/node_data/node_data.gml index 214f7f069..8c5947ce3 100644 --- a/scripts/node_data/node_data.gml +++ b/scripts/node_data/node_data.gml @@ -1674,7 +1674,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor { draw_droppable = false; } - if(bg_spr_add) draw_sprite_stretched_add(bg_spr, 1, xx, yy, w * _s, h * _s, c_white, 0.15); + if(bg_spr_add) draw_sprite_stretched_add(bg_spr, 1, xx, yy, w * _s, h * _s, c_white, 0.1); return _s > 0.5? drawJunctions(xx, yy, _mx, _my, _s) : drawJunctions_fast(xx, yy, _mx, _my, _s); } #endregion diff --git a/scripts/node_value/node_value.gml b/scripts/node_value/node_value.gml index 2fb123333..e31d34463 100644 --- a/scripts/node_value/node_value.gml +++ b/scripts/node_value/node_value.gml @@ -1305,11 +1305,6 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru return val; } #endregion - static getShowString = function() { #region - var val = showValue(); - return string_real(val); - } #endregion - static unitConvert = function(mode) { #region var _v = animator.values; @@ -1552,42 +1547,23 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru return true; } #endregion + static getString = function() { #region + var val = showValue(); + + if(type == VALUE_TYPE.text) return val; + return json_beautify(val); + } #endregion + static setString = function(str) { #region if(connect_type == JUNCTION_CONNECT.output) return; - var _o = animator.getValue(); + if(type == VALUE_TYPE.text) { setValue(str); return; } - if(string_pos(",", str) > 0) { - string_replace(str, "[", ""); - string_replace(str, "]", ""); - - var ss = str, pos, val = [], ind = 0; - - while(string_length(ss) > 0) { - pos = string_pos(",", ss); - - if(pos == 0) { - val[ind++] = toNumber(ss); - ss = ""; - } else { - val[ind++] = toNumber(string_copy(ss, 1, pos - 1)); - ss = string_copy(ss, pos + 1, string_length(ss) - pos); - } - } - - var _t = typeArray(display_type); - if(_t) { - if(array_length(_o) == array_length(val) || _t == 2) - setValue(val); - } else if(array_length(val) > 0) { - setValue(val[0]); - } - } else { - if(is_array(_o)) { - setValue(array_create(array_length(_o), toNumber(str))); - } else { - setValue(toNumber(str)); - } - } + var _dat = json_try_parse(str); + + if(typeArray(display_type) && !is_array(_dat)) + _dat = [ _dat ]; + + setValue(_dat); } #endregion /////=========== CONNECT =========== diff --git a/scripts/panel_inspector/panel_inspector.gml b/scripts/panel_inspector/panel_inspector.gml index 51b103d00..c940a88b5 100644 --- a/scripts/panel_inspector/panel_inspector.gml +++ b/scripts/panel_inspector/panel_inspector.gml @@ -175,8 +175,8 @@ function Panel_Inspector() : PanelContent() constructor { menu_junc_expression_dis = menuItem(__txtx("panel_inspector_disable_expression", "Disable expression"), function() { __dialog_junction.expUse = false; }); menu_junc_extract = menuItem(__txtx("panel_inspector_extract_single", "Extract to node"), function() { __dialog_junction.extractNode(); }); - menu_junc_copy = menuItem(__txt("Copy"), function() { clipboard_set_text(__dialog_junction.getShowString()); }, THEME.copy, ["Inspector", "Copy property"]); - menu_junc_paste = menuItem(__txt("Paste"), function() { __dialog_junction.setString(clipboard_get_text()); }, THEME.paste, ["Inspector", "Paste property"]); + menu_junc_copy = menuItem(__txt("Copy"), function() { clipboard_set_text(__dialog_junction.getString()); }, THEME.copy, ["Inspector", "Copy property"]); + menu_junc_paste = menuItem(__txt("Paste"), function() { __dialog_junction.setString(clipboard_get_text()); }, THEME.paste, ["Inspector", "Paste property"]); function setSelectingItemColor(color) { if(__dialog_junction == noone) return; @@ -884,12 +884,11 @@ function Panel_Inspector() : PanelContent() constructor { function propSelectCopy() { #region if(!prop_selecting) return; - clipboard_set_text(prop_selecting.getShowString()); + clipboard_set_text(prop_selecting.getString()); } #endregion function propSelectPaste() { #region if(!prop_selecting) return; - prop_selecting.setString(clipboard_get_text()); } #endregion