Decouple CardPileUI from JSON file loading #5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This splits the card database loading into a separate component (
CardDB) which can be implemented however the user wishes, withJSONFileCardDBbeing a built-in option provided.CardCollectionhas also undergone a similar treatment (unfortunately, in Godot 4.2 it's not possible to provide a drop-in replacement object which can be iterated like a simple array whilst also allowing custom logic, because of godotengine/godot#74686). They are coupled toCardPileUIthrough a very simple protocol which imposes a minimal amount of requirements on the user code.For backwards compatibility, JSON loading will still happen as a fallback if no
card_databaseorcard_collectionhas been provided, so existing code will continue to work unchanged. This has been tested using the examples: example 1 (ie. main scene) has been ported to useJSONFileCardDBexplicitly, whereas example 2 uses the old deprecated*_file_pathproperties. Both work without issues.All of the changes have been fully documented in the
README.Fixes #4.