Cytopia
Cytopia copied to clipboard
Use better enums to serialize enums
Change types to enum where applicable and use BetterEnums library to serialize them to json,.
https://github.com/aantron/better-enums
- [ ] std::string Action in UIManager should be wrapped in enums and the if's should be replaced by switch-case
- [x] std::string uiElementType in UIManager too
For those changes, the qt tool TileDataEditor will need to be adjusted as well:
- [ ] Replace std::string category by a better enum
- [ ] Replace std::string biome by a better enum
But for those tileData changes, i'd strongly suggest to leave it as is until the new UI and everything is done, so we can easily make changes here and add new categories and biomes on the fly, without the need to adjust the TileData Editor
In /src/engine/basics/tileData.hxx
,
- Replace
std::string category
by a better enum - Replace
std::string biome
by a better enum tileData is being used in many places. You will need to find where it is being used and replace all string equalities by enum equalities. In the parsing of TileData, you will also need to use better enum's_from_string
and make sure to document that it can throwstd::runtime_error
if the string is invalid.