Cytopia icon indicating copy to clipboard operation
Cytopia copied to clipboard

Use better enums to serialize enums

Open SimplyLiz opened this issue 5 years ago • 1 comments

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

SimplyLiz avatar Mar 17 '19 06:03 SimplyLiz

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 throw std::runtime_error if the string is invalid.

ghost avatar Aug 03 '19 16:08 ghost