summaryrefslogtreecommitdiff
path: root/core/io
diff options
context:
space:
mode:
authorJuan Linietsky <juan@godotengine.org>2020-02-20 18:58:05 -0300
committerJuan Linietsky <reduzio@gmail.com>2020-02-21 14:25:29 +0100
commit3c0059650da3f1feb3c95364d571fe706826dec6 (patch)
treea36ba94f313e2dee88dc2eb253175849fb2d4138 /core/io
parent7ac0973e9abb308b91597dd8881aeed62682733c (diff)
Added StringName as a variant type.
Also changed all relevant properties defined manually to StringName.
Diffstat (limited to 'core/io')
-rw-r--r--core/io/marshalls.cpp15
-rw-r--r--core/io/resource_format_binary.cpp12
-rw-r--r--core/io/resource_loader.cpp2
3 files changed, 28 insertions, 1 deletions
diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp
index ab88f4d85c..b77ef40fd3 100644
--- a/core/io/marshalls.cpp
+++ b/core/io/marshalls.cpp
@@ -328,6 +328,16 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
(*r_len) += 4 * 4;
} break;
+ case Variant::STRING_NAME: {
+
+ String str;
+ Error err = _decode_string(buf, len, r_len, str);
+ if (err)
+ return err;
+ r_variant = StringName(str);
+
+ } break;
+
case Variant::NODE_PATH: {
ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA);
@@ -939,6 +949,11 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
_encode_string(p_variant, buf, r_len);
} break;
+ case Variant::STRING_NAME: {
+
+ _encode_string(p_variant, buf, r_len);
+
+ } break;
// math types
case Variant::VECTOR2: {
diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp
index 991853e86d..144e48d0da 100644
--- a/core/io/resource_format_binary.cpp
+++ b/core/io/resource_format_binary.cpp
@@ -75,6 +75,7 @@ enum {
VARIANT_DOUBLE = 41,
VARIANT_CALLABLE = 42,
VARIANT_SIGNAL = 43,
+ VARIANT_STRING_NAME = 44,
OBJECT_EMPTY = 0,
OBJECT_EXTERNAL_RESOURCE = 1,
OBJECT_INTERNAL_RESOURCE = 2,
@@ -260,6 +261,10 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
r_v = v;
} break;
+ case VARIANT_STRING_NAME: {
+
+ r_v = StringName(get_unicode_string());
+ } break;
case VARIANT_NODE_PATH: {
@@ -1394,6 +1399,13 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia
f->store_real(val.a);
} break;
+ case Variant::STRING_NAME: {
+
+ f->store_32(VARIANT_STRING_NAME);
+ String val = p_property;
+ save_unicode_string(f, val);
+
+ } break;
case Variant::NODE_PATH: {
f->store_32(VARIANT_NODE_PATH);
diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp
index 1d5d8f9280..39bbebefa6 100644
--- a/core/io/resource_loader.cpp
+++ b/core/io/resource_loader.cpp
@@ -248,7 +248,7 @@ void ResourceFormatLoader::_bind_methods() {
}
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::PACKED_STRING_ARRAY, "get_recognized_extensions"));
- ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "handles_type", PropertyInfo(Variant::STRING, "typename")));
+ ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "handles_type", PropertyInfo(Variant::STRING_NAME, "typename")));
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::STRING, "get_resource_type", PropertyInfo(Variant::STRING, "path")));
ClassDB::add_virtual_method(get_class_static(), MethodInfo("get_dependencies", PropertyInfo(Variant::STRING, "path"), PropertyInfo(Variant::STRING, "add_types")));
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::INT, "rename_dependencies", PropertyInfo(Variant::STRING, "path"), PropertyInfo(Variant::STRING, "renames")));