diff --git a/src/editor/graph/graph_node.cpp b/src/editor/graph/graph_node.cpp index 9510d58f..b1763dd1 100644 --- a/src/editor/graph/graph_node.cpp +++ b/src/editor/graph/graph_node.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include @@ -306,15 +307,21 @@ void OrchestratorGraphNode::_update_titlebar() { Ref icon_texture; if (!_node->get_icon().is_empty()) - icon_texture = SceneUtils::get_editor_icon(_node->get_icon()); + { + if (_node->get_icon().begins_with("res://")) + icon_texture = ResourceLoader::get_singleton()->load(_node->get_icon()); + else + icon_texture = SceneUtils::get_editor_icon(_node->get_icon()); + } TextureRect* rect = Object::cast_to(titlebar->get_child(0)); if (!rect && icon_texture.is_valid()) { // Add node's icon to the UI rect = memnew(TextureRect); - rect->set_custom_minimum_size(Vector2(0, 24)); rect->set_stretch_mode(TextureRect::STRETCH_KEEP_ASPECT_CENTERED); + rect->set_expand_mode(TextureRect::EXPAND_FIT_WIDTH_PROPORTIONAL); + rect->set_size(Vector2(24, 24)); rect->set_texture(icon_texture); // Add the icon and move it to the start of the HBox. diff --git a/src/script/nodes/utilities/comment.cpp b/src/script/nodes/utilities/comment.cpp index 0d9bf350..74a7e14a 100644 --- a/src/script/nodes/utilities/comment.cpp +++ b/src/script/nodes/utilities/comment.cpp @@ -16,11 +16,14 @@ // #include "comment.h" +#include "common/string_utils.h" + void OScriptNodeComment::_get_property_list(List* r_list) const { const String movement_modes = "Group Movement,Comment"; r_list->push_back(PropertyInfo(Variant::STRING, "title")); + r_list->push_back(PropertyInfo(Variant::STRING, "icon", PROPERTY_HINT_FILE)); r_list->push_back(PropertyInfo(Variant::BOOL, "align_center")); r_list->push_back(PropertyInfo(Variant::COLOR, "background_color")); r_list->push_back(PropertyInfo(Variant::INT, "font_size", PROPERTY_HINT_RANGE, "0,64")); @@ -60,6 +63,11 @@ bool OScriptNodeComment::_get(const StringName& p_name, Variant& r_value) const r_value = _title; return true; } + else if (p_name.match("icon")) + { + r_value = _icon; + return true; + } return false; } @@ -101,6 +109,12 @@ bool OScriptNodeComment::_set(const StringName& p_name, const Variant& p_value) _notify_pins_changed(); return true; } + else if (p_name.match("icon")) + { + _icon = p_value; + _notify_pins_changed(); + return true; + } return false; } @@ -119,5 +133,5 @@ String OScriptNodeComment::get_node_title() const String OScriptNodeComment::get_icon() const { - return "VisualShaderNodeComment"; + return StringUtils::default_if_empty(_icon, "VisualShaderNodeComment"); } diff --git a/src/script/nodes/utilities/comment.h b/src/script/nodes/utilities/comment.h index 2afc52d7..1916952f 100644 --- a/src/script/nodes/utilities/comment.h +++ b/src/script/nodes/utilities/comment.h @@ -28,6 +28,7 @@ class OScriptNodeComment : public OScriptNode protected: String _comments; String _title{ "Comment" }; + String _icon; bool _align_center{ false }; Color _background_color{ 0.6, 0.6, 0.6, 0.05 }; Color _text_color{ 1.0, 1.0, 1.0, 1.0 };