Skip to content

Commit

Permalink
Merge pull request #92648 from stephen-berry/GODOT-92513
Browse files Browse the repository at this point in the history
Consistently display script icons for nodes in connect dialog's scene tree editor
  • Loading branch information
akien-mga committed Jun 10, 2024
2 parents 3d9ee2d + 823b48f commit 3092b0c
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions editor/gui/scene_tree_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,23 +232,27 @@ void SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) {
item->set_icon(0, icon);
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) {
Color accent = get_theme_color(SNAME("accent_color"), EditorStringName(Editor));

Ref<Script> scr = p_node->get_script();
if (!scr.is_null() && EditorNode::get_singleton()->get_object_custom_type_base(p_node) != scr) {
//has script
item->add_button(0, get_editor_theme_icon(SNAME("Script")), BUTTON_SCRIPT);
} else {
//has no script (or script is a custom type)
bool has_custom_script = scr.is_valid() && EditorNode::get_singleton()->get_object_custom_type_base(p_node) == scr;
if (scr.is_null() || has_custom_script) {
_set_item_custom_color(item, get_theme_color(SNAME("font_disabled_color"), EditorStringName(Editor)));
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;
}

Expand Down

0 comments on commit 3092b0c

Please sign in to comment.