[Inspector Panel] Struct widget now pretty-print string.

This commit is contained in:
Tanasart 2024-09-05 11:08:50 +07:00
parent e26b141841
commit c0c9e11600
2 changed files with 31 additions and 1 deletions

View File

@ -987,7 +987,10 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
extract_node = "Node_Path";
break;
// case VALUE_TYPE.any :
case VALUE_TYPE.struct :
editWidget = new outputStructBox();
break;
default :
editWidget = new outputBox();
break;

View File

@ -24,3 +24,30 @@ function outputBox() : widget() constructor {
static clone = function() { return new outputBox(); }
}
function outputStructBox() : widget() constructor {
static trigger = function() { }
static drawParam = function(params) {
setParam(params);
return draw(params.x, params.y, params.w, params.data);
}
static draw = function(_x, _y, _w, _value) {
x = _x;
y = _y;
w = _w;
draw_set_text(font, fa_left, fa_top, COLORS._main_text_sub);
var _txt = json_stringify(_value, true);
var _sh = string_height_ext(_txt, -1, w - ui(16)) + ui(16);
draw_sprite_stretched_ext(THEME.ui_panel_bg, 1, _x, _y, _w, _sh, COLORS._main_icon_light);
draw_text_ext_add(_x + ui(8), _y + ui(8), _txt, -1, _w - ui(16));
return _sh;
}
static clone = function() { return new outputBox(); }
}