From 09b951b99b1a8e799b00adaa896c788949c18017 Mon Sep 17 00:00:00 2001 From: reduz Date: Wed, 23 Mar 2022 21:08:54 +0100 Subject: Refactor Object metadata * API kept the same (Although functions could be renamed to set_metadata/get_metadata in a later PR), so not much should change. * Metadata now exposed as individual properties. * Properties are editable in inspector (unless metadata name begins with _) under the metadata/ namespace. * Added the ability to Add/Remove metadata properties to the inspector. This is a functionality that was requested very often, that makes metadata work a bit more similar to custom properties in Blender. --- tests/core/io/test_resource.h | 6 +++--- tests/core/object/test_object.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'tests/core') diff --git a/tests/core/io/test_resource.h b/tests/core/io/test_resource.h index b3983bb06d..84d651b63f 100644 --- a/tests/core/io/test_resource.h +++ b/tests/core/io/test_resource.h @@ -69,7 +69,7 @@ TEST_CASE("[Resource] Duplication") { TEST_CASE("[Resource] Saving and loading") { Ref resource = memnew(Resource); resource->set_name("Hello world"); - resource->set_meta(" ExampleMetadata ", Vector2i(40, 80)); + resource->set_meta("ExampleMetadata", Vector2i(40, 80)); resource->set_meta("string", "The\nstring\nwith\nunnecessary\nline\n\t\\\nbreaks"); Ref child_resource = memnew(Resource); child_resource->set_name("I'm a child resource"); @@ -84,7 +84,7 @@ TEST_CASE("[Resource] Saving and loading") { loaded_resource_binary->get_name() == "Hello world", "The loaded resource name should be equal to the expected value."); CHECK_MESSAGE( - loaded_resource_binary->get_meta(" ExampleMetadata ") == Vector2i(40, 80), + loaded_resource_binary->get_meta("ExampleMetadata") == Vector2i(40, 80), "The loaded resource metadata should be equal to the expected value."); CHECK_MESSAGE( loaded_resource_binary->get_meta("string") == "The\nstring\nwith\nunnecessary\nline\n\t\\\nbreaks", @@ -99,7 +99,7 @@ TEST_CASE("[Resource] Saving and loading") { loaded_resource_text->get_name() == "Hello world", "The loaded resource name should be equal to the expected value."); CHECK_MESSAGE( - loaded_resource_text->get_meta(" ExampleMetadata ") == Vector2i(40, 80), + loaded_resource_text->get_meta("ExampleMetadata") == Vector2i(40, 80), "The loaded resource metadata should be equal to the expected value."); CHECK_MESSAGE( loaded_resource_text->get_meta("string") == "The\nstring\nwith\nunnecessary\nline\n\t\\\nbreaks", diff --git a/tests/core/object/test_object.h b/tests/core/object/test_object.h index e44b93bb66..5b9d9cab53 100644 --- a/tests/core/object/test_object.h +++ b/tests/core/object/test_object.h @@ -133,7 +133,7 @@ TEST_CASE("[Object] Core getters") { } TEST_CASE("[Object] Metadata") { - const String meta_path = "hello/world complex métadata\n\n\t\tpath"; + const String meta_path = "complex_metadata_path"; Object object; object.set_meta(meta_path, Color(0, 1, 0)); -- cgit v1.2.3