Add the the ability to iterate over Godot enums #600
Labels
c: engine
Godot classes (nodes, resources, ...)
feature
Adds functionality to the library
good first issue
Good for newcomers
I'm looking at the struct
Mode
(godot::engine::window::Mode
) and I want some way to iterate over thepub 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 toEngineEnum
(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.
, convert to title case, create inverse mapping). I have previously used this approach in C# (
I would still have to massage the names of the fields to be human readable, but this is usually quite easy (
_
->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 onEngineEnum
itself.The text was updated successfully, but these errors were encountered: