Ability to disable/enable menu items

, ,


I'd like a way to temporarily disable system menu items without entirely removing them, to make it clear that they aren't missing, but that some aspect of the present game context prevents them from functioning in the moment the game was paused.


I'm working on a little bowling game. I include an option in the menu to abandon a given roll if something goes awry (e.g., you hop the gutter and the ball winds up a lane over). I can obviously detect various circumstances — out of bounds, ball no longer moving, etc. — and also have a timeout so that the game never winds up in a permanently stuck state, but the menu item acts as a fallback and/or a fast-forward instead of awaiting that timer, which is generous so as not to interfere with normal play.

That menu item only makes sense while the ball is in motion. In between rolls/frames (viewing the scorecard, etc.), it serves no purpose. However, those moments are brief, and I'm not leaving the context of the active game, so entirely removing it for a few seconds and then restoring it feels like overkill. I can imagine other (even more compelling) use cases in other games, such as preventing saving while in the water, in a cave, in a fight etc.


I've considered a couple potential approaches:

  1. Add e.g., playdate.menu.item:setEnabled(flag)
  2. Add something like playdate.menu.item:setShouldBeEnabledCallback(callback), which would be called immediately before showing the system menu and return a boolean. (This could be handy when multiple factors, controlled by various parts of the code, all affect the appropriate state, making it difficult for any one place to authoritatively enable/disable.)

The first is certainly most straightforward. I'd expect the text and/or selection box to be grayed out with a dither effect when an item is disabled, and maybe make an audible and possibly also visual "bonk" when attempting to select. Bonus points for an optional reason which could be displayed to users on hover/select.


Nice idea, thanks for the feedback! I'll file an issue on this.

1 Like