afonsolage / bevy_ecss

Bevy crate which uses a subset of CSS to update Bevy ECS components
Apache License 2.0
98 stars 11 forks source link

Merging Multiple StyleSheets #45

Closed TheDudeFromCI closed 7 months ago

TheDudeFromCI commented 7 months ago

This feature request is a small quality of life enhancement to allow for the merging of multiple smaller style sheets into a single larger style sheet when applied to an entity. This motivation behind this is for allowing separation of files depending on what interface is being loaded without having to put everything into a single large file.

For example, one main style sheet might exist that controls a global theme and overall design for how the game should look and feel, while more specific components, like a specific inventory menu might define custom image paths and style changes that are specific to it, while still requiring access to the global theme for buttons and text within the inventory.

I imagine tracking them could be done by creating a StyleSheetList component that contains a list of asset handles (all of the tracked style sheets), and merges them together (naively via text concat??) before passing that merged file contents to the parser. Whenever any of these tracked asset handles changes, it can grab the contents from all tracked assets and re-merge and apply.