mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Fix Object encoded as id in dictionnaries to be represented as int in the inspector.
This commit is contained in:
parent
e25f3c0d38
commit
f46e94d460
2 changed files with 13 additions and 5 deletions
|
@ -124,6 +124,16 @@ bool EditorPropertyDictionaryObject::_set(const StringName &p_name, const Varian
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EditorPropertyDictionaryObject::_get(const StringName &p_name, Variant &r_ret) const {
|
bool EditorPropertyDictionaryObject::_get(const StringName &p_name, Variant &r_ret) const {
|
||||||
|
if (!get_by_property_name(p_name, r_ret)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (r_ret.get_type() == Variant::OBJECT && Object::cast_to<EncodedObjectAsID>(r_ret)) {
|
||||||
|
r_ret = Object::cast_to<EncodedObjectAsID>(r_ret)->get_object_id();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EditorPropertyDictionaryObject::get_by_property_name(const String &p_name, Variant &r_ret) const {
|
||||||
String name = p_name;
|
String name = p_name;
|
||||||
|
|
||||||
if (name == "new_item_key") {
|
if (name == "new_item_key") {
|
||||||
|
@ -140,10 +150,6 @@ bool EditorPropertyDictionaryObject::_get(const StringName &p_name, Variant &r_r
|
||||||
int index = name.get_slicec('/', 1).to_int();
|
int index = name.get_slicec('/', 1).to_int();
|
||||||
Variant key = dict.get_key_at_index(index);
|
Variant key = dict.get_key_at_index(index);
|
||||||
r_ret = dict[key];
|
r_ret = dict[key];
|
||||||
if (r_ret.get_type() == Variant::OBJECT && Object::cast_to<EncodedObjectAsID>(r_ret)) {
|
|
||||||
r_ret = Object::cast_to<EncodedObjectAsID>(r_ret)->get_object_id();
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1050,7 +1056,8 @@ void EditorPropertyDictionary::update_property() {
|
||||||
if (!slot_visible) {
|
if (!slot_visible) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Variant value = object->get(slot.prop_name);
|
Variant value;
|
||||||
|
object->get_by_property_name(slot.prop_name, value);
|
||||||
Variant::Type value_type = value.get_type();
|
Variant::Type value_type = value.get_type();
|
||||||
|
|
||||||
// Check if the editor property needs to be updated.
|
// Check if the editor property needs to be updated.
|
||||||
|
|
|
@ -77,6 +77,7 @@ public:
|
||||||
NEW_VALUE_INDEX,
|
NEW_VALUE_INDEX,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool get_by_property_name(const String &p_name, Variant &r_ret) const;
|
||||||
void set_dict(const Dictionary &p_dict);
|
void set_dict(const Dictionary &p_dict);
|
||||||
Dictionary get_dict();
|
Dictionary get_dict();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue