mirror of
https://github.com/godotengine/godot.git
synced 2026-01-06 10:11:57 +03:00
Implement typed dictionaries
This commit is contained in:
@@ -624,6 +624,19 @@ Error ResourceLoaderText::load() {
|
||||
}
|
||||
}
|
||||
|
||||
if (value.get_type() == Variant::DICTIONARY) {
|
||||
Dictionary set_dict = value;
|
||||
bool is_get_valid = false;
|
||||
Variant get_value = res->get(assign, &is_get_valid);
|
||||
if (is_get_valid && get_value.get_type() == Variant::DICTIONARY) {
|
||||
Dictionary get_dict = get_value;
|
||||
if (!set_dict.is_same_typed(get_dict)) {
|
||||
value = Dictionary(set_dict, get_dict.get_typed_key_builtin(), get_dict.get_typed_key_class_name(), get_dict.get_typed_key_script(),
|
||||
get_dict.get_typed_value_builtin(), get_dict.get_typed_value_class_name(), get_dict.get_typed_value_script());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (set_valid) {
|
||||
res->set(assign, value);
|
||||
}
|
||||
@@ -751,6 +764,19 @@ Error ResourceLoaderText::load() {
|
||||
}
|
||||
}
|
||||
|
||||
if (value.get_type() == Variant::DICTIONARY) {
|
||||
Dictionary set_dict = value;
|
||||
bool is_get_valid = false;
|
||||
Variant get_value = resource->get(assign, &is_get_valid);
|
||||
if (is_get_valid && get_value.get_type() == Variant::DICTIONARY) {
|
||||
Dictionary get_dict = get_value;
|
||||
if (!set_dict.is_same_typed(get_dict)) {
|
||||
value = Dictionary(set_dict, get_dict.get_typed_key_builtin(), get_dict.get_typed_key_class_name(), get_dict.get_typed_key_script(),
|
||||
get_dict.get_typed_value_builtin(), get_dict.get_typed_value_class_name(), get_dict.get_typed_value_script());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (set_valid) {
|
||||
resource->set(assign, value);
|
||||
}
|
||||
@@ -1642,6 +1668,8 @@ void ResourceFormatSaverTextInstance::_find_resources(const Variant &p_variant,
|
||||
} break;
|
||||
case Variant::DICTIONARY: {
|
||||
Dictionary d = p_variant;
|
||||
_find_resources(d.get_typed_key_script());
|
||||
_find_resources(d.get_typed_value_script());
|
||||
List<Variant> keys;
|
||||
d.get_key_list(&keys);
|
||||
for (const Variant &E : keys) {
|
||||
|
||||
Reference in New Issue
Block a user