Browse Source

Fix tool script button color overriding custom type color

Also adds a small note on the tooltip noting the custom type.

(cherry picked from commit 65cc721eb94ee67315bacc9caadb0d36ff221b13)
Micky 3 years ago
parent
commit
b21a3418f4
1 changed files with 6 additions and 5 deletions
  1. 6 5
      editor/scene_tree_editor.cpp

+ 6 - 5
editor/scene_tree_editor.cpp

@@ -344,17 +344,18 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent, bool p_scroll
 		Ref<Script> script = p_node->get_script();
 		if (!script.is_null()) {
 			String additional_notes;
+			Color button_color = Color(1, 1, 1);
 			// Can't set tooltip after adding button, need to do it before.
 			if (script->is_tool()) {
 				additional_notes += "\n" + TTR("This script is currently running in the editor.");
+				button_color = get_color("accent_color", "Editor");
 			}
-			item->add_button(0, get_icon("Script", "EditorIcons"), BUTTON_SCRIPT, false, TTR("Open Script:") + " " + script->get_path() + additional_notes);
 			if (EditorNode::get_singleton()->get_object_custom_type_base(p_node) == script) {
-				item->set_button_color(0, item->get_button_count(0) - 1, Color(1, 1, 1, 0.5));
-			}
-			if (script->is_tool()) {
-				item->set_button_color(0, item->get_button_count(0) - 1, get_color("accent_color", "Editor"));
+				additional_notes += "\n" + TTR("This script is a custom type.");
+				button_color.a = 0.5;
 			}
+			item->add_button(0, get_icon("Script", "EditorIcons"), BUTTON_SCRIPT, false, TTR("Open Script:") + " " + script->get_path() + additional_notes);
+			item->set_button_color(0, item->get_button_count(0) - 1, button_color);
 		}
 
 		if (p_node->is_class("CanvasItem")) {