Преглед на файлове

Revert "Add script class categories to EditorInspector."

This reverts commit 8a02f221b468056345b7506a463a8c8b529bfb29.

This caused regression #43491.
Rémi Verschelde преди 4 години
родител
ревизия
755ee76871
променени са 3 файла, в които са добавени 5 реда и са изтрити 102 реда
  1. 3 101
      editor/editor_inspector.cpp
  2. 0 1
      editor/editor_inspector.h
  3. 2 0
      editor/editor_node.cpp

+ 3 - 101
editor/editor_inspector.cpp

@@ -1480,9 +1480,9 @@ void EditorInspector::update_tree() {
 	String group_base;
 	VBoxContainer *category_vbox = NULL;
 
-	List<PropertyInfo> plist;
+	List<PropertyInfo>
+			plist;
 	object->get_property_list(&plist, true);
-	_update_script_class_properties(*object, plist);
 
 	HashMap<String, VBoxContainer *> item_path;
 	Map<VBoxContainer *, EditorInspectorSection *> section_map;
@@ -1538,28 +1538,7 @@ void EditorInspector::update_tree() {
 			category_vbox = NULL; //reset
 
 			String type = p.name;
-			if (!ClassDB::class_exists(type) && !ScriptServer::is_global_class(type) && p.hint_string.length() && FileAccess::exists(p.hint_string)) {
-				Ref<Script> s = ResourceLoader::load(p.hint_string, "Script");
-				String base_type;
-				if (s.is_valid()) {
-					base_type = s->get_instance_base_type();
-				}
-				while (s.is_valid()) {
-					StringName name = EditorNode::get_editor_data().script_class_get_name(s->get_path());
-					String icon_path = EditorNode::get_editor_data().script_class_get_icon_path(name);
-					if (name != StringName() && icon_path.length()) {
-						category->icon = ResourceLoader::load(icon_path, "Texture");
-						break;
-					}
-					s = s->get_base_script();
-				}
-				if (category->icon.is_null() && has_icon(base_type, "EditorIcons")) {
-					category->icon = get_icon(base_type, "EditorIcons");
-				}
-			}
-			if (category->icon.is_null()) {
-				category->icon = EditorNode::get_singleton()->get_class_icon(type, "Object");
-			}
+			category->icon = EditorNode::get_singleton()->get_class_icon(type, "Object");
 			category->label = type;
 
 			category->bg_color = get_color("prop_category", "Editor");
@@ -2333,83 +2312,6 @@ void EditorInspector::_feature_profile_changed() {
 	update_tree();
 }
 
-void EditorInspector::_update_script_class_properties(const Object &p_object, List<PropertyInfo> &r_list) const {
-	Ref<Script> script = p_object.get_script();
-	if (script.is_null()) {
-		return;
-	}
-
-	List<StringName> classes;
-	Map<StringName, String> paths;
-
-	// NodeC -> NodeB -> NodeA
-	while (script.is_valid()) {
-		String n = EditorNode::get_editor_data().script_class_get_name(script->get_path());
-		if (n.length()) {
-			classes.push_front(n);
-		} else {
-			n = script->get_path().get_file();
-			classes.push_front(n);
-		}
-		paths[n] = script->get_path();
-		script = script->get_base_script();
-	}
-
-	if (classes.empty()) {
-		return;
-	}
-
-	// Script Variables -> to insert: NodeC..B..A -> bottom (insert_here)
-	List<PropertyInfo>::Element *script_variables = NULL;
-	List<PropertyInfo>::Element *bottom = NULL;
-	List<PropertyInfo>::Element *insert_here = NULL;
-	for (List<PropertyInfo>::Element *E = r_list.front(); E; E = E->next()) {
-		PropertyInfo &pi = E->get();
-		if (pi.name != "Script Variables") {
-			continue;
-		}
-		script_variables = E;
-		bottom = r_list.insert_after(script_variables, PropertyInfo());
-		insert_here = bottom;
-		break;
-	}
-
-	Set<StringName> added;
-	for (List<StringName>::Element *E = classes.front(); E; E = E->next()) {
-		StringName name = E->get();
-		String path = paths[name];
-		Ref<Script> s = ResourceLoader::load(path, "Script");
-		List<PropertyInfo> props;
-		s->get_script_property_list(&props);
-
-		// Script Variables -> NodeA -> bottom (insert_here)
-		List<PropertyInfo>::Element *category = r_list.insert_before(insert_here, PropertyInfo(Variant::NIL, name, PROPERTY_HINT_NONE, path, PROPERTY_USAGE_CATEGORY));
-
-		// Script Variables -> NodeA -> A props... -> bottom (insert_here)
-		for (List<PropertyInfo>::Element *P = props.front(); P; P = P->next()) {
-			PropertyInfo &pi = P->get();
-			if (added.has(pi.name)) {
-				continue;
-			}
-			added.insert(pi.name);
-
-			r_list.insert_before(insert_here, pi);
-		}
-
-		// Script Variables -> NodeA (insert_here) -> A props... -> bottom
-		insert_here = category;
-	}
-
-	// NodeC -> C props... -> NodeB..C..
-	r_list.erase(script_variables);
-	List<PropertyInfo>::Element *to_delete = bottom->next();
-	while (to_delete && !(to_delete->get().usage & PROPERTY_USAGE_CATEGORY)) {
-		r_list.erase(to_delete);
-		to_delete = bottom->next();
-	}
-	r_list.erase(bottom);
-}
-
 void EditorInspector::_bind_methods() {
 
 	ClassDB::bind_method("_property_changed", &EditorInspector::_property_changed, DEFVAL(""), DEFVAL(false));

+ 0 - 1
editor/editor_inspector.h

@@ -325,7 +325,6 @@ class EditorInspector : public ScrollContainer {
 	void _vscroll_changed(double);
 
 	void _feature_profile_changed();
-	void _update_script_class_properties(const Object &p_object, List<PropertyInfo> &r_list) const;
 
 	bool _is_property_disabled_by_feature_profile(const StringName &p_property);
 

+ 2 - 0
editor/editor_node.cpp

@@ -3952,6 +3952,8 @@ Ref<Texture> EditorNode::get_class_icon(const String &p_class, const String &p_f
 		if (icon.is_null()) {
 			icon = gui_base->get_icon(ScriptServer::get_global_class_base(name), "EditorIcons");
 		}
+
+		return icon;
 	}
 
 	const Map<String, Vector<EditorData::CustomType> > &p_map = EditorNode::get_editor_data().get_custom_types();