From ac5e2a219b98cc62f4865dc458d03857baf44750 Mon Sep 17 00:00:00 2001 From: Chris Cranford Date: Fri, 5 Jul 2024 21:27:06 -0400 Subject: [PATCH] GH-484 Show enum, bitfield, class icons in variable panel --- src/editor/component_panels/variables_panel.cpp | 2 +- src/script/variable.cpp | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/editor/component_panels/variables_panel.cpp b/src/editor/component_panels/variables_panel.cpp index 06dead3f..f41fbf82 100644 --- a/src/editor/component_panels/variables_panel.cpp +++ b/src/editor/component_panels/variables_panel.cpp @@ -58,7 +58,7 @@ void OrchestratorScriptVariablesComponentPanel::_create_variable_item(TreeItem* item->set_button_disabled(0, index, true); } - item->add_button(0, SceneUtils::get_editor_icon(p_variable->get_variable_type_name()), 2); + item->add_button(0, SceneUtils::get_class_icon(p_variable->get_variable_type_name()), 2); if (!p_variable->get_description().is_empty()) { diff --git a/src/script/variable.cpp b/src/script/variable.cpp index e5d0cbeb..1ebae662 100644 --- a/src/script/variable.cpp +++ b/src/script/variable.cpp @@ -347,6 +347,13 @@ String OScriptVariable::get_variable_type_name() const if (_info.type == Variant::NIL) return "Variant"; + if (_info.hint == PROPERTY_HINT_ENUM || _info.usage & PROPERTY_USAGE_CLASS_IS_ENUM) + return "Enum"; + else if (_info.hint == PROPERTY_HINT_FLAGS || _info.usage & PROPERTY_USAGE_CLASS_IS_BITFIELD) + return "Enum"; + else if (_info.type == Variant::OBJECT && !_info.class_name.is_empty() && !_info.class_name.contains(".")) + return _info.class_name; + return Variant::get_type_name(_info.type); }