insideout-andrew / simple-card-pile-ui

This plugin provides a flexible and customizable card pile user interface for the Godot game engine. It is designed to handle various card-related functionalities including drawing, discarding, and managing different piles.
MIT License
84 stars 9 forks source link

Decouple CardPileUI from JSON file loading #5

Open mathrick opened 2 months ago

mathrick commented 2 months ago

This splits the card database loading into a separate component (CardDB) which can be implemented however the user wishes, with JSONFileCardDB being a built-in option provided. CardCollection has 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 to CardPileUI through 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_database or card_collection has 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 use JSONFileCardDB explicitly, whereas example 2 uses the old deprecated *_file_path properties. Both work without issues.

All of the changes have been fully documented in the README.

Fixes #4.

mathrick commented 2 months ago

Marking it as a draft for now, since I haven't fully integrated CardPileUI into my project yet, and I want to make sure I'm not overlooking something. As soon as I have that working, I will mark this PR as ready.