From c0c9e1160039983ae0ff377e77637aa8e169c61b Mon Sep 17 00:00:00 2001 From: Tanasart Date: Thu, 5 Sep 2024 11:08:50 +0700 Subject: [PATCH] [Inspector Panel] Struct widget now pretty-print string. --- scripts/node_value/node_value.gml | 5 ++++- scripts/outputBox/outputBox.gml | 27 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/scripts/node_value/node_value.gml b/scripts/node_value/node_value.gml index 4e36e88bd..0b88d9137 100644 --- a/scripts/node_value/node_value.gml +++ b/scripts/node_value/node_value.gml @@ -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; diff --git a/scripts/outputBox/outputBox.gml b/scripts/outputBox/outputBox.gml index 635967e27..c596fd950 100644 --- a/scripts/outputBox/outputBox.gml +++ b/scripts/outputBox/outputBox.gml @@ -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(); } +}