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.
This commit is contained in:
parent
d7d528c15f
commit
09b951b99b
9 changed files with 175 additions and 33 deletions
|
|
@ -69,7 +69,7 @@ TEST_CASE("[Resource] Duplication") {
|
|||
TEST_CASE("[Resource] Saving and loading") {
|
||||
Ref<Resource> 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<Resource> 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",
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue