diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2024-09-06 22:38:13 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2024-09-06 22:38:13 +0200 |
commit | 0b4ae20156c1597671a748192ed8c032ed1d053e (patch) | |
tree | ebb6b242506eb6697e34962cce83e49f3ad96ec9 /core/io/resource_format_binary.cpp | |
parent | c9dc1eb1d59bf67bb123ed1ac5f9e0cfb93e275b (diff) | |
parent | 9853a691447cd4e279f48820067174d3833b0065 (diff) | |
download | redot-engine-0b4ae20156c1597671a748192ed8c032ed1d053e.tar.gz |
Merge pull request #78656 from Repiteo/typed-dictionary
Implement typed dictionaries
Diffstat (limited to 'core/io/resource_format_binary.cpp')
-rw-r--r-- | core/io/resource_format_binary.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index f71257fa76..41a8a569d0 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -857,6 +857,19 @@ Error ResourceLoaderBinary::load() { } } + if (value.get_type() == Variant::DICTIONARY) { + Dictionary set_dict = value; + bool is_get_valid = false; + Variant get_value = res->get(name, &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(name, value); } @@ -2064,6 +2077,8 @@ void ResourceFormatSaverBinaryInstance::_find_resources(const Variant &p_variant 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) { |