-
-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modify Array type to encode values type, if possible, when serialized #162
Changes from all commits
c893926
173c589
4c268a5
d9daa6d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -146,6 +146,18 @@ func test_array_property_wrong_type() -> void: | |
new_property.load_data(property.save_data()) | ||
assert_that(new_property.get_default_value()).is_equal("") | ||
|
||
func test_array_property_custom_parsers() -> void: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we probably also want a test that verifies that when the array is saved to json and then re-read, that the type is still there and not lost somehow. Could we extend one of the other existing tests (in entity backend) that deal with that sort of use case by adding a typed array there? |
||
var array_type = load("res://addons/pandora/model/types/array.gd") | ||
var category = Pandora.create_category("Test Category") | ||
var property = Pandora.create_property(category, "property", "array") | ||
property.set_setting_override(array_type.SETTING_ARRAY_TYPE, "color") | ||
var entity = Pandora.create_entity("entity", category) | ||
var entity_property = entity.get_entity_property("property") | ||
entity_property.set_default_value([Color.WHITE]) | ||
entity.load_data(entity.save_data()) | ||
assert_that(entity.get_array("property")[0]).is_equal(Color.WHITE) | ||
assert_that(typeof(entity.get_array("property")[0])).is_not_equal(TYPE_STRING) | ||
|
||
func test_vector2_property() -> void: | ||
var vector = Vector2.ONE | ||
var property = PandoraProperty.new("123", "property", "vector2") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should avoid using absolute paths, can you make this a relative lookup? (in other places too if applicable)
In case this turns out to be difficult, I am happy to keep it absolute for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked into it and unfortunately it doesn't seem possible for the moment (at least not trivially).
DirAccess.open
requires an absolute path: "Static methods only support absolute paths (including res:// and user://)." docsload
also requires an absolute path: "Important: The path must be absolute. A relative path will always return null." docsResourceLoader.load
doesn't specify but after testing it seems to be the case as well.It seems that
lookup
andget_all_types
are implicitly covered by some existing tests (because I broke them when trying) but I could add some tests forPandoraPropertyType
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The best way to do this is by taking the resource path of the existing class and using it as the root dir for all loading.
ie.
Prints
res://addons/pandora/model
res://addons/pandora/model/int.gd