Description
I'm looking at the struct Mode
(godot::engine::window::Mode
) and I want some way to iterate over the pub const
fields. Minimally, this would be an iterator over the keys (field names in the order they appear in Godot), and a map from key to value, which most naturally could be added to EngineEnum
(godot::obj::EngineEnum
) (or to sidecars).
I want to use this to automatically represent the window settings in an options menu without writing out a mapping manually.
I would still have to massage the names of the fields to be human readable, but this is usually quite easy (_
->
, convert to title case, create inverse mapping). I have previously used this approach in C# (Enum.Parse
, Enum.GetNames
) and Java (enum.keys
), and AFAIK it was possible in previous Godot versions since enums used to be dictionaries.
In the long term it's probably better to just write the mapping myself, especially when eventually serialising and localising it, but it could be at least used to quickly generate the templates for those (although I could generate them from outside of gdext).
If this is already possible somehow, please add information about it to a section in the book or to docs on each EngineEnum
or on EngineEnum
itself.