- [Inspector Panel] Fix paste not working with some value.

This commit is contained in:
Tanasart 2024-06-12 09:46:02 +07:00
parent 4cb9bb5360
commit 08435332a6
3 changed files with 18 additions and 43 deletions

View file

@ -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

View file

@ -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 ===========

View file

@ -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