Merge 86bec25c51
into a5015b6390
This commit is contained in:
commit
1fb3885d15
|
@ -150,7 +150,7 @@ public:
|
|||
|
||||
virtual void update_exports() {} //editor tool
|
||||
virtual void get_script_method_list(List<MethodInfo> *p_list) const = 0;
|
||||
virtual void get_script_property_list(List<PropertyInfo> *p_list) const = 0;
|
||||
virtual void get_script_property_list(List<PropertyInfo> *p_list, const ScriptInstance *p_instance = nullptr) const = 0;
|
||||
|
||||
virtual int get_member_line(const StringName &p_member) const { return -1; }
|
||||
|
||||
|
|
|
@ -3470,7 +3470,7 @@ void EditorInspector::_update_script_class_properties(const Object &p_object, Li
|
|||
}
|
||||
|
||||
List<PropertyInfo> props;
|
||||
s->get_script_property_list(&props);
|
||||
s->get_script_property_list(&props, p_object.get_script_instance());
|
||||
|
||||
// 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));
|
||||
|
@ -3492,11 +3492,24 @@ void EditorInspector::_update_script_class_properties(const Object &p_object, Li
|
|||
|
||||
// NodeC -> C props... -> NodeB..C..
|
||||
if (script_variables) {
|
||||
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();
|
||||
bool properties_left = false;
|
||||
List<PropertyInfo>::Element *current = bottom->next();
|
||||
List<PropertyInfo>::Element *previous = bottom;
|
||||
while (current && !(current->get().usage & PROPERTY_USAGE_CATEGORY)) {
|
||||
// Fallback check so that we don't lose editor fields
|
||||
// for properties coming from _get_property_list
|
||||
if (added.has(current->get().name)) {
|
||||
r_list.erase(current);
|
||||
} else {
|
||||
properties_left = true;
|
||||
previous = current;
|
||||
}
|
||||
|
||||
current = previous->next();
|
||||
}
|
||||
|
||||
if (!properties_left) {
|
||||
r_list.erase(script_variables);
|
||||
}
|
||||
r_list.erase(bottom);
|
||||
}
|
||||
|
|
|
@ -105,7 +105,7 @@ void PropertySelector::_update_search() {
|
|||
Object *obj = ObjectDB::get_instance(script);
|
||||
if (Object::cast_to<Script>(obj)) {
|
||||
props.push_back(PropertyInfo(Variant::NIL, "Script Variables", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_CATEGORY));
|
||||
Object::cast_to<Script>(obj)->get_script_property_list(&props);
|
||||
Object::cast_to<Script>(obj)->get_script_property_list(&props, obj->get_script_instance());
|
||||
}
|
||||
|
||||
StringName base = base_type;
|
||||
|
|
|
@ -96,7 +96,7 @@ void NativeScript::_update_placeholder(PlaceHolderScriptInstance *p_placeholder)
|
|||
ERR_FAIL_COND(!script_data);
|
||||
|
||||
List<PropertyInfo> info;
|
||||
get_script_property_list(&info);
|
||||
get_script_property_list(&info, p_placeholder);
|
||||
Map<StringName, Variant> values;
|
||||
for (const PropertyInfo &E : info) {
|
||||
Variant value;
|
||||
|
@ -413,7 +413,7 @@ void NativeScript::get_script_method_list(List<MethodInfo> *p_list) const {
|
|||
}
|
||||
}
|
||||
|
||||
void NativeScript::get_script_property_list(List<PropertyInfo> *p_list) const {
|
||||
void NativeScript::get_script_property_list(List<PropertyInfo> *p_list, const ScriptInstance *p_instance) const {
|
||||
NativeScriptDesc *script_data = get_script_desc();
|
||||
|
||||
Set<StringName> existing_properties;
|
||||
|
@ -651,7 +651,7 @@ bool NativeScriptInstance::get(const StringName &p_name, Variant &r_ret) const {
|
|||
}
|
||||
|
||||
void NativeScriptInstance::get_property_list(List<PropertyInfo> *p_properties) const {
|
||||
script->get_script_property_list(p_properties);
|
||||
script->get_script_property_list(p_properties, this);
|
||||
|
||||
NativeScriptDesc *script_data = GET_SCRIPT_DESC();
|
||||
|
||||
|
|
|
@ -173,7 +173,7 @@ public:
|
|||
|
||||
virtual void update_exports() override; //editor tool
|
||||
virtual void get_script_method_list(List<MethodInfo> *p_list) const override;
|
||||
virtual void get_script_property_list(List<PropertyInfo> *p_list) const override;
|
||||
virtual void get_script_property_list(List<PropertyInfo> *p_list, const ScriptInstance *p_instance = nullptr) const override;
|
||||
|
||||
virtual const Vector<Multiplayer::RPCConfig> get_rpc_methods() const override;
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ Variant::Type PluginScriptInstance::get_property_type(const StringName &p_name,
|
|||
}
|
||||
|
||||
void PluginScriptInstance::get_property_list(List<PropertyInfo> *p_properties) const {
|
||||
_script->get_script_property_list(p_properties);
|
||||
_script->get_script_property_list(p_properties, this);
|
||||
}
|
||||
|
||||
void PluginScriptInstance::get_method_list(List<MethodInfo> *p_list) const {
|
||||
|
|
|
@ -373,7 +373,7 @@ void PluginScript::get_script_method_list(List<MethodInfo> *r_methods) const {
|
|||
}
|
||||
}
|
||||
|
||||
void PluginScript::get_script_property_list(List<PropertyInfo> *r_properties) const {
|
||||
void PluginScript::get_script_property_list(List<PropertyInfo> *r_properties, const ScriptInstance *p_instance) const {
|
||||
ASSERT_SCRIPT_VALID();
|
||||
for (Map<StringName, PropertyInfo>::Element *e = _properties_info.front(); e != nullptr; e = e->next()) {
|
||||
r_properties->push_back(e->get());
|
||||
|
|
|
@ -132,7 +132,7 @@ public:
|
|||
|
||||
virtual void update_exports() override;
|
||||
virtual void get_script_method_list(List<MethodInfo> *r_methods) const override;
|
||||
virtual void get_script_property_list(List<PropertyInfo> *r_properties) const override;
|
||||
virtual void get_script_property_list(List<PropertyInfo> *r_properties, const ScriptInstance *p_instance = nullptr) const override;
|
||||
|
||||
virtual int get_member_line(const StringName &p_member) const override;
|
||||
|
||||
|
|
|
@ -280,6 +280,68 @@ void GDScript::get_script_method_list(List<MethodInfo> *r_list) const {
|
|||
_get_script_method_list(r_list, true);
|
||||
}
|
||||
|
||||
void GDScript::_call_get_script_property_list(List<PropertyInfo> *r_list, const ScriptInstance *p_instance, bool p_include_base) const {
|
||||
const GDScript *sptr = this;
|
||||
List<PropertyInfo> props;
|
||||
|
||||
while (sptr) {
|
||||
const Map<StringName, GDScriptFunction *>::Element *E = sptr->member_functions.find(GDScriptLanguage::get_singleton()->strings._get_property_list);
|
||||
if (E) {
|
||||
Callable::CallError err;
|
||||
Variant ret = const_cast<GDScriptFunction *>(E->get())->call(const_cast<GDScriptInstance *>(dynamic_cast<const GDScriptInstance *>(p_instance)), nullptr, 0, err);
|
||||
if (err.error == Callable::CallError::CALL_OK) {
|
||||
ERR_FAIL_COND_MSG(ret.get_type() != Variant::ARRAY, "Wrong type for _get_property_list, must be an array of dictionaries.");
|
||||
|
||||
Array arr = ret;
|
||||
for (int i = 0; i < arr.size(); i++) {
|
||||
Dictionary d = arr[i];
|
||||
ERR_CONTINUE(!d.has("name"));
|
||||
ERR_CONTINUE(!d.has("type"));
|
||||
PropertyInfo pinfo;
|
||||
pinfo.type = Variant::Type(d["type"].operator int());
|
||||
ERR_CONTINUE(pinfo.type < 0 || pinfo.type >= Variant::VARIANT_MAX);
|
||||
pinfo.name = d["name"];
|
||||
ERR_CONTINUE(pinfo.name == "");
|
||||
if (d.has("hint")) {
|
||||
pinfo.hint = PropertyHint(d["hint"].operator int());
|
||||
}
|
||||
if (d.has("hint_string")) {
|
||||
pinfo.hint_string = d["hint_string"];
|
||||
}
|
||||
if (d.has("usage")) {
|
||||
pinfo.usage = d["usage"];
|
||||
}
|
||||
|
||||
props.push_back(pinfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//instance a fake script for editing the values
|
||||
|
||||
Vector<_GDScriptMemberSort> msort;
|
||||
for (const KeyValue<StringName, PropertyInfo> &F : sptr->member_info) {
|
||||
_GDScriptMemberSort ms;
|
||||
ERR_CONTINUE(!sptr->member_indices.has(F.key));
|
||||
ms.index = sptr->member_indices[F.key].index;
|
||||
ms.name = F.key;
|
||||
msort.push_back(ms);
|
||||
}
|
||||
|
||||
msort.sort();
|
||||
msort.reverse();
|
||||
for (int i = 0; i < msort.size(); i++) {
|
||||
props.push_front(sptr->member_info[msort[i].name]);
|
||||
}
|
||||
|
||||
sptr = sptr->_base;
|
||||
}
|
||||
|
||||
for (const PropertyInfo &E : props) {
|
||||
r_list->push_back(E);
|
||||
}
|
||||
}
|
||||
|
||||
void GDScript::_get_script_property_list(List<PropertyInfo> *r_list, bool p_include_base) const {
|
||||
const GDScript *sptr = this;
|
||||
List<PropertyInfo> props;
|
||||
|
@ -311,8 +373,12 @@ void GDScript::_get_script_property_list(List<PropertyInfo> *r_list, bool p_incl
|
|||
}
|
||||
}
|
||||
|
||||
void GDScript::get_script_property_list(List<PropertyInfo> *r_list) const {
|
||||
void GDScript::get_script_property_list(List<PropertyInfo> *r_list, const ScriptInstance *p_instance) const {
|
||||
_get_script_property_list(r_list, true);
|
||||
|
||||
if (p_instance) {
|
||||
_call_get_script_property_list(r_list, p_instance, true);
|
||||
}
|
||||
}
|
||||
|
||||
bool GDScript::has_method(const StringName &p_method) const {
|
||||
|
@ -1406,64 +1472,7 @@ void GDScriptInstance::get_property_list(List<PropertyInfo> *p_properties) const
|
|||
// exported members, not done yet!
|
||||
|
||||
const GDScript *sptr = script.ptr();
|
||||
List<PropertyInfo> props;
|
||||
|
||||
while (sptr) {
|
||||
const Map<StringName, GDScriptFunction *>::Element *E = sptr->member_functions.find(GDScriptLanguage::get_singleton()->strings._get_property_list);
|
||||
if (E) {
|
||||
Callable::CallError err;
|
||||
Variant ret = const_cast<GDScriptFunction *>(E->get())->call(const_cast<GDScriptInstance *>(this), nullptr, 0, err);
|
||||
if (err.error == Callable::CallError::CALL_OK) {
|
||||
ERR_FAIL_COND_MSG(ret.get_type() != Variant::ARRAY, "Wrong type for _get_property_list, must be an array of dictionaries.");
|
||||
|
||||
Array arr = ret;
|
||||
for (int i = 0; i < arr.size(); i++) {
|
||||
Dictionary d = arr[i];
|
||||
ERR_CONTINUE(!d.has("name"));
|
||||
ERR_CONTINUE(!d.has("type"));
|
||||
PropertyInfo pinfo;
|
||||
pinfo.type = Variant::Type(d["type"].operator int());
|
||||
ERR_CONTINUE(pinfo.type < 0 || pinfo.type >= Variant::VARIANT_MAX);
|
||||
pinfo.name = d["name"];
|
||||
ERR_CONTINUE(pinfo.name == "");
|
||||
if (d.has("hint")) {
|
||||
pinfo.hint = PropertyHint(d["hint"].operator int());
|
||||
}
|
||||
if (d.has("hint_string")) {
|
||||
pinfo.hint_string = d["hint_string"];
|
||||
}
|
||||
if (d.has("usage")) {
|
||||
pinfo.usage = d["usage"];
|
||||
}
|
||||
|
||||
props.push_back(pinfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//instance a fake script for editing the values
|
||||
|
||||
Vector<_GDScriptMemberSort> msort;
|
||||
for (const KeyValue<StringName, PropertyInfo> &F : sptr->member_info) {
|
||||
_GDScriptMemberSort ms;
|
||||
ERR_CONTINUE(!sptr->member_indices.has(F.key));
|
||||
ms.index = sptr->member_indices[F.key].index;
|
||||
ms.name = F.key;
|
||||
msort.push_back(ms);
|
||||
}
|
||||
|
||||
msort.sort();
|
||||
msort.reverse();
|
||||
for (int i = 0; i < msort.size(); i++) {
|
||||
props.push_front(sptr->member_info[msort[i].name]);
|
||||
}
|
||||
|
||||
sptr = sptr->_base;
|
||||
}
|
||||
|
||||
for (const PropertyInfo &E : props) {
|
||||
p_properties->push_back(E);
|
||||
}
|
||||
sptr->_call_get_script_property_list(p_properties, this, true);
|
||||
}
|
||||
|
||||
void GDScriptInstance::get_method_list(List<MethodInfo> *p_list) const {
|
||||
|
|
|
@ -227,10 +227,11 @@ public:
|
|||
bool get_property_default_value(const StringName &p_property, Variant &r_value) const override;
|
||||
|
||||
virtual void get_script_method_list(List<MethodInfo> *p_list) const override;
|
||||
void _call_get_script_property_list(List<PropertyInfo> *r_list, const ScriptInstance *p_instance, bool p_include_base) const;
|
||||
virtual bool has_method(const StringName &p_method) const override;
|
||||
virtual MethodInfo get_method_info(const StringName &p_method) const override;
|
||||
|
||||
virtual void get_script_property_list(List<PropertyInfo> *p_list) const override;
|
||||
virtual void get_script_property_list(List<PropertyInfo> *p_list, const ScriptInstance *p_instance = nullptr) const override;
|
||||
|
||||
virtual ScriptLanguage *get_language() const override;
|
||||
|
||||
|
|
|
@ -1938,7 +1938,7 @@ static bool _guess_identifier_type_from_base(GDScriptParser::CompletionContext &
|
|||
|
||||
if (!is_static) {
|
||||
List<PropertyInfo> members;
|
||||
scr->get_script_property_list(&members);
|
||||
scr->get_script_property_list(&members, nullptr);
|
||||
for (const PropertyInfo &prop : members) {
|
||||
if (prop.name == p_identifier) {
|
||||
r_type = _type_from_property(prop);
|
||||
|
|
|
@ -3503,7 +3503,7 @@ Ref<Script> CSharpScript::get_base_script() const {
|
|||
return Ref<Script>();
|
||||
}
|
||||
|
||||
void CSharpScript::get_script_property_list(List<PropertyInfo> *r_list) const {
|
||||
void CSharpScript::get_script_property_list(List<PropertyInfo> *r_list, const ScriptInstance *p_instance) const {
|
||||
List<PropertyInfo> props;
|
||||
|
||||
for (OrderedHashMap<StringName, PropertyInfo>::ConstElement E = member_info.front(); E; E = E.next()) {
|
||||
|
|
|
@ -215,7 +215,7 @@ public:
|
|||
void get_script_signal_list(List<MethodInfo> *r_signals) const override;
|
||||
|
||||
bool get_property_default_value(const StringName &p_property, Variant &r_value) const override;
|
||||
void get_script_property_list(List<PropertyInfo> *r_list) const override;
|
||||
void get_script_property_list(List<PropertyInfo> *r_list, const ScriptInstance *p_instance = nullptr) const override;
|
||||
void update_exports() override;
|
||||
|
||||
void get_members(Set<StringName> *p_members) override;
|
||||
|
|
|
@ -925,7 +925,7 @@ MethodInfo VisualScript::get_method_info(const StringName &p_method) const {
|
|||
return mi;
|
||||
}
|
||||
|
||||
void VisualScript::get_script_property_list(List<PropertyInfo> *p_list) const {
|
||||
void VisualScript::get_script_property_list(List<PropertyInfo> *p_list, const ScriptInstance *instance) const {
|
||||
List<StringName> vars;
|
||||
get_variable_list(&vars);
|
||||
|
||||
|
|
|
@ -358,7 +358,7 @@ public:
|
|||
virtual bool has_method(const StringName &p_method) const override;
|
||||
virtual MethodInfo get_method_info(const StringName &p_method) const override;
|
||||
|
||||
virtual void get_script_property_list(List<PropertyInfo> *p_list) const override;
|
||||
virtual void get_script_property_list(List<PropertyInfo> *p_list, const ScriptInstance *instance = nullptr) const override;
|
||||
|
||||
virtual int get_member_line(const StringName &p_member) const override;
|
||||
|
||||
|
|
|
@ -154,7 +154,7 @@ void VisualScriptPropertySelector::_update_search() {
|
|||
} else {
|
||||
Object *obj = ObjectDB::get_instance(script);
|
||||
if (Object::cast_to<Script>(obj)) {
|
||||
Object::cast_to<Script>(obj)->get_script_property_list(&props);
|
||||
Object::cast_to<Script>(obj)->get_script_property_list(&props, obj->get_script_instance());
|
||||
} else {
|
||||
ClassDB::get_property_list(E, &props, true);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue