chrisnorman7 / earwax

An audio game engine for fast prototyping
Mozilla Public License 2.0
6 stars 2 forks source link

Make menu and menu titles dynamic #17

Closed chrisnorman7 closed 3 years ago

chrisnorman7 commented 3 years ago

Describe the solution you'd like

It should be possible to specify menu and menu item titles as callables that return strings.

Instead of

m: Menu = Menu(game, f'Edit {thing.name}')
m.add_item(rename, title=f'Rename ({thing.name})')

You should be able to do:

m: Menu = Menu(game, lambda: f'Edit {thing.name}')
m.add_item(rename, lambda: f'Rename ({thing.name})')

Of course the old behaviour should remain for compatability.

Describe alternatives you've considered

Currently, it is necessary to pop then pull menus you want to change items in.

The story editor has a rather nasty hack where the menu is popped and pushed, and the current position preserved. It would be much nicer if titles could be dynamically generated.

Additional context

This would only ever be a problem if visuals were added to Earwax. If that happened, titles would be outdated.