-
-
Notifications
You must be signed in to change notification settings - Fork 34
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
♻️ rework property type lookup #98
Conversation
e570041
to
cfb34ad
Compare
new_property.load_data(property.save_data()) | ||
assert_that(new_property.get_default_value()).is_null() | ||
assert_that(new_property.get_default_value()).is_equal("") |
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.
These tests now change as it is impossible to create a PandoraProperty
that has a valid type but an invalid default value.
|
||
|
||
|
||
func get_default_settings() -> Dictionary: |
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.
Settings are now comping from the type directly, rather than from some random UI component.
class_name PandoraPropertyType extends RefCounted | ||
|
||
|
||
class UndefinedType extends PandoraPropertyType: |
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.
This type is useful to avoid null
checks but have instead an undefined
type.
cfb34ad
to
0285a06
Compare
if name == "": | ||
return UndefinedType.new() | ||
var ScriptType = load("res://addons/pandora/model/types/" + name + ".gd") | ||
if ScriptType != null and ScriptType.has_source_code(): |
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.
This explicit check is required since Godot 4.0.x and 4.1.x have different behavior:
- Godot 4.0.x:
load()
returnsGDScript
even if it failed to load - Godot 4.1.x:
load()
returnsnull
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.
This all looks great to me!
Prerequisite for:
Description
Complete overhaul of the type system of Pandora by introducing the
PandoraPropertyType
class. This allows us to make it easier to specify new types, e.g. by adding a new file tores://addons/pandora/model/types/new-type.gd
which then internally specifies everything Pandora needs to know, including serialization, property settings and validation!Highlights
PandoraProperty
and move it over intoPandoraPropertyType
- instead, it now acts as a "stupid" containerPandoraProperty
now gets its default value from the type, rather than having to pass it in manuallyFunctionally, this pull request should not change anything critically.