Consistently display script icons for nodes in connect dialog's scene tree editor

This commit is contained in:
Stephen Berry 2024-06-01 10:27:01 -04:00 committed by Rémi Verschelde
parent 32eba1ee17
commit 823b48ffa5
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 14 additions and 10 deletions

View File

@ -232,23 +232,27 @@ void SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) {
item->set_icon(0, icon); item->set_icon(0, icon);
item->set_metadata(0, p_node->get_path()); item->set_metadata(0, p_node->get_path());
if (connecting_signal) {
// Add script icons for all scripted nodes.
Ref<Script> scr = p_node->get_script();
if (scr.is_valid()) {
item->add_button(0, get_editor_theme_icon(SNAME("Script")), BUTTON_SCRIPT);
if (EditorNode::get_singleton()->get_object_custom_type_base(p_node) == scr) {
// Disable button on custom scripts (pure visual cue).
item->set_button_disabled(0, item->get_button_count(0) - 1, true);
}
}
}
if (connect_to_script_mode) { if (connect_to_script_mode) {
Color accent = get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); Color accent = get_theme_color(SNAME("accent_color"), EditorStringName(Editor));
Ref<Script> scr = p_node->get_script(); Ref<Script> scr = p_node->get_script();
if (!scr.is_null() && EditorNode::get_singleton()->get_object_custom_type_base(p_node) != scr) { bool has_custom_script = scr.is_valid() && EditorNode::get_singleton()->get_object_custom_type_base(p_node) == scr;
//has script if (scr.is_null() || has_custom_script) {
item->add_button(0, get_editor_theme_icon(SNAME("Script")), BUTTON_SCRIPT);
} else {
//has no script (or script is a custom type)
_set_item_custom_color(item, get_theme_color(SNAME("font_disabled_color"), EditorStringName(Editor))); _set_item_custom_color(item, get_theme_color(SNAME("font_disabled_color"), EditorStringName(Editor)));
item->set_selectable(0, false); item->set_selectable(0, false);
if (!scr.is_null()) { // make sure to mark the script if a custom type
item->add_button(0, get_editor_theme_icon(SNAME("Script")), BUTTON_SCRIPT);
item->set_button_disabled(0, item->get_button_count(0) - 1, true);
}
accent.a *= 0.7; accent.a *= 0.7;
} }