-
-
Notifications
You must be signed in to change notification settings - Fork 31
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
fix: template not parsed #59
base: main
Are you sure you want to change the base?
Conversation
@@ -59,7 +59,7 @@ class TiledObject { | |||
bool point; | |||
bool rectangle; | |||
|
|||
Template? template; | |||
Future<Template?>? template; |
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.
Why does this need to be a future?
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 template object must wait for the template file to be loaded.
We also can’t load it beforehand because we can’t know which file to load until reaching a template property.
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.
But it will be loaded while parsing right? Since this is mutable for some reason it could just be set once it is finished?
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.
Yes it would be the easier way. However, all the call stack down to TiledObject.parse is synchronous, if we make it async, we must change the upstream too. I want to avoid a breaking change.
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.
But since it is mutable you don't have to make it async, just set it when it is done?
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.
Hmm, this new TiledObject instance is added to the final parsed object after load()
function is completed. If the template
is mutated after that, users can't know when it happens to get the latest value. If using Future, at least they know explicitly that they need to await
it to get the value. That's my intention. But I have to admit that it's not the best solution.
I've just thought about another solution. If load()
function somehow can await for all pending Futures complete, it's the best.
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've just thought about another solution. If
load()
function somehow can await for all pending Futures complete, it's the best.
Yeah, that sounds much better, that shouldn't be a problem to do.
Can you clarify what docs and when this changed? If it changed relatively recently we may want to check for the template xml the old way, and then if it's not there, check the new way. That would support both versions of Tiled. I would also add inline comments that link to the relevant Tiled docs and version changes |
List<TsxProvider>? tsxList, | ||
Future<TsxProvider> Function(String key)? tsxProviderFunction, |
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.
what's the difference between these two? seems like two different ways to pass in external tsx files?
@trunghq3101 any update on this? |
I'm gonna continue working on this. I'm kinda being distracted by working on my game lately. |
According to this change log, |
Sorry for the extremely late reply, it should be pretty simple to verify that with a small test, right? |
@trunghq3101 are you planning to continue on this PR? :) |
Description
Currently,
template
is parsed from a child node like this:But according to the current Tiled format,
template
is not a child node anymore:There is no place to load the template file as well.
So, it is never found, that's why the
template
field in a parsedTiledObject
is alwaysnull
. I believe it's related to the issue #47.The object
id
is also not required anymore:Checklist
fix:
,feat:
,docs:
etc).docs
and added dartdoc comments with///
.examples
.Breaking Change
Related Issues
Fixes #47