summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBogdan Inculet <inculet.bogdan@gmail.com>2024-02-17 06:06:09 +0200
committerBogdan Inculet <inculet.bogdan@gmail.com>2024-10-15 22:28:53 +0300
commitfb58ea6c89ff3f9e970e436982c76e96adccdefc (patch)
treeabbca6bcf33292a8775b97ca57ccb77750ddbe95
parentaf77100e394dcaca609b15bef815ed17475e51ed (diff)
downloadredot-engine-fb58ea6c89ff3f9e970e436982c76e96adccdefc.tar.gz
Fixed Remote Nodes missing custom icons
-rw-r--r--editor/debugger/editor_debugger_tree.cpp5
-rw-r--r--editor/editor_node.cpp10
-rw-r--r--scene/debugger/scene_debugger.cpp16
3 files changed, 28 insertions, 3 deletions
diff --git a/editor/debugger/editor_debugger_tree.cpp b/editor/debugger/editor_debugger_tree.cpp
index c4d7899b2d..a900842651 100644
--- a/editor/debugger/editor_debugger_tree.cpp
+++ b/editor/debugger/editor_debugger_tree.cpp
@@ -277,11 +277,14 @@ Variant EditorDebuggerTree::get_drag_data(const Point2 &p_point) {
}
String path = selected->get_text(0);
+ const int icon_size = get_theme_constant(SNAME("class_icon_size"), EditorStringName(Editor));
HBoxContainer *hb = memnew(HBoxContainer);
TextureRect *tf = memnew(TextureRect);
tf->set_texture(selected->get_icon(0));
- tf->set_stretch_mode(TextureRect::STRETCH_KEEP_CENTERED);
+ tf->set_custom_minimum_size(Size2(icon_size, icon_size));
+ tf->set_stretch_mode(TextureRect::STRETCH_KEEP_ASPECT_CENTERED);
+ tf->set_expand_mode(TextureRect::EXPAND_IGNORE_SIZE);
hb->add_child(tf);
Label *label = memnew(Label(path));
hb->add_child(label);
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 95b3c30d1b..dd6c88ef25 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -4771,7 +4771,13 @@ Ref<Texture2D> EditorNode::_get_class_or_script_icon(const String &p_class, cons
// Look for the native base type in the editor theme. This is relevant for
// scripts extending other scripts and for built-in classes.
String script_class_name = p_script->get_language()->get_global_class_name(p_script->get_path());
- String base_type = ScriptServer::get_global_class_native_base(script_class_name);
+ String base_type;
+ if (script_class_name.is_empty()) {
+ base_type = p_script->get_instance_base_type();
+ } else {
+ base_type = ScriptServer::get_global_class_native_base(script_class_name);
+ }
+
if (theme.is_valid() && theme->has_icon(base_type, EditorStringName(EditorIcons))) {
return theme->get_icon(base_type, EditorStringName(EditorIcons));
}
@@ -4836,6 +4842,8 @@ Ref<Texture2D> EditorNode::get_class_icon(const String &p_class, const String &p
Ref<Script> scr;
if (ScriptServer::is_global_class(p_class)) {
scr = EditorNode::get_editor_data().script_class_load_script(p_class);
+ } else if (ResourceLoader::exists(p_class)) { // If the script is not a class_name we check if the script resource exists.
+ scr = ResourceLoader::load(p_class);
}
return _get_class_or_script_icon(p_class, scr, p_fallback, true);
diff --git a/scene/debugger/scene_debugger.cpp b/scene/debugger/scene_debugger.cpp
index 07c32eef13..22e5238fae 100644
--- a/scene/debugger/scene_debugger.cpp
+++ b/scene/debugger/scene_debugger.cpp
@@ -535,7 +535,21 @@ SceneDebuggerTree::SceneDebuggerTree(Node *p_root) {
}
}
}
- nodes.push_back(RemoteNode(count, n->get_name(), n->get_class(), n->get_instance_id(), n->get_scene_file_path(), view_flags));
+
+ String class_name;
+ ScriptInstance *script_instance = n->get_script_instance();
+ if (script_instance) {
+ Ref<Script> script = script_instance->get_script();
+ if (script.is_valid()) {
+ class_name = script->get_global_name();
+
+ if (class_name.is_empty()) {
+ // If there is no class_name in this script we just take the script path.
+ class_name = script->get_path();
+ }
+ }
+ }
+ nodes.push_back(RemoteNode(count, n->get_name(), class_name.is_empty() ? n->get_class() : class_name, n->get_instance_id(), n->get_scene_file_path(), view_flags));
}
}