You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Include more attributes in the global class names cache
This commit is contained in:
@@ -269,10 +269,10 @@ void ScriptServer::init_languages() {
|
||||
|
||||
for (const Variant &script_class : script_classes) {
|
||||
Dictionary c = script_class;
|
||||
if (!c.has("class") || !c.has("language") || !c.has("path") || !c.has("base")) {
|
||||
if (!c.has("class") || !c.has("language") || !c.has("path") || !c.has("base") || !c.has("is_abstract") || !c.has("is_tool")) {
|
||||
continue;
|
||||
}
|
||||
add_global_class(c["class"], c["base"], c["language"], c["path"]);
|
||||
add_global_class(c["class"], c["base"], c["language"], c["path"], c["is_abstract"], c["is_tool"]);
|
||||
}
|
||||
ProjectSettings::get_singleton()->clear("_global_script_classes");
|
||||
}
|
||||
@@ -281,10 +281,10 @@ void ScriptServer::init_languages() {
|
||||
Array script_classes = ProjectSettings::get_singleton()->get_global_class_list();
|
||||
for (const Variant &script_class : script_classes) {
|
||||
Dictionary c = script_class;
|
||||
if (!c.has("class") || !c.has("language") || !c.has("path") || !c.has("base")) {
|
||||
if (!c.has("class") || !c.has("language") || !c.has("path") || !c.has("base") || !c.has("is_abstract") || !c.has("is_tool")) {
|
||||
continue;
|
||||
}
|
||||
add_global_class(c["class"], c["base"], c["language"], c["path"]);
|
||||
add_global_class(c["class"], c["base"], c["language"], c["path"], c["is_abstract"], c["is_tool"]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -390,7 +390,7 @@ void ScriptServer::global_classes_clear() {
|
||||
inheriters_cache.clear();
|
||||
}
|
||||
|
||||
void ScriptServer::add_global_class(const StringName &p_class, const StringName &p_base, const StringName &p_language, const String &p_path) {
|
||||
void ScriptServer::add_global_class(const StringName &p_class, const StringName &p_base, const StringName &p_language, const String &p_path, bool p_is_abstract, bool p_is_tool) {
|
||||
ERR_FAIL_COND_MSG(p_class == p_base || (global_classes.has(p_base) && get_global_class_native_base(p_base) == p_class), "Cyclic inheritance in script class.");
|
||||
GlobalScriptClass *existing = global_classes.getptr(p_class);
|
||||
if (existing) {
|
||||
@@ -399,6 +399,8 @@ void ScriptServer::add_global_class(const StringName &p_class, const StringName
|
||||
existing->base = p_base;
|
||||
existing->path = p_path;
|
||||
existing->language = p_language;
|
||||
existing->is_abstract = p_is_abstract;
|
||||
existing->is_tool = p_is_tool;
|
||||
inheriters_cache_dirty = true;
|
||||
}
|
||||
} else {
|
||||
@@ -407,6 +409,8 @@ void ScriptServer::add_global_class(const StringName &p_class, const StringName
|
||||
g.language = p_language;
|
||||
g.path = p_path;
|
||||
g.base = p_base;
|
||||
g.is_abstract = p_is_abstract;
|
||||
g.is_tool = p_is_tool;
|
||||
global_classes[p_class] = g;
|
||||
inheriters_cache_dirty = true;
|
||||
}
|
||||
@@ -480,6 +484,16 @@ StringName ScriptServer::get_global_class_native_base(const String &p_class) {
|
||||
return base;
|
||||
}
|
||||
|
||||
bool ScriptServer::is_global_class_abstract(const String &p_class) {
|
||||
ERR_FAIL_COND_V(!global_classes.has(p_class), false);
|
||||
return global_classes[p_class].is_abstract;
|
||||
}
|
||||
|
||||
bool ScriptServer::is_global_class_tool(const String &p_class) {
|
||||
ERR_FAIL_COND_V(!global_classes.has(p_class), false);
|
||||
return global_classes[p_class].is_tool;
|
||||
}
|
||||
|
||||
void ScriptServer::get_global_class_list(List<StringName> *r_global_classes) {
|
||||
List<StringName> classes;
|
||||
for (const KeyValue<StringName, GlobalScriptClass> &E : global_classes) {
|
||||
@@ -507,12 +521,15 @@ void ScriptServer::save_global_classes() {
|
||||
get_global_class_list(&gc);
|
||||
Array gcarr;
|
||||
for (const StringName &E : gc) {
|
||||
const GlobalScriptClass &global_class = global_classes[E];
|
||||
Dictionary d;
|
||||
d["class"] = E;
|
||||
d["language"] = global_classes[E].language;
|
||||
d["path"] = global_classes[E].path;
|
||||
d["base"] = global_classes[E].base;
|
||||
d["language"] = global_class.language;
|
||||
d["path"] = global_class.path;
|
||||
d["base"] = global_class.base;
|
||||
d["icon"] = class_icons.get(E, "");
|
||||
d["is_abstract"] = global_class.is_abstract;
|
||||
d["is_tool"] = global_class.is_tool;
|
||||
gcarr.push_back(d);
|
||||
}
|
||||
ProjectSettings::get_singleton()->store_global_class_list(gcarr);
|
||||
|
||||
Reference in New Issue
Block a user