3. Menu - a-roy/pacman-mp GitHub Wiki

A menu item can be in one of these forms:

  • Static text that has a function on selection
    • Main menu: Host game, Join game, Quit
    • Host lobby: Start game, Close lobby
  • An enumeration which can be cycled through
    • Host lobby: Field selection
    • Client connected: Character selection
  • A numerical value that can be incremented or decremented
    • Join game: IP address and port
  • A toggle switch
    • Client connected: Ready
  • Static text that can't be selected
    • Join game: Symbols

A menu is usually vertical, but the join game screen uses a horizontal version.

We can implement this as an abstract MenuItem class, with virtual Forward, Backward, and Render functions. A Menu object contains a vector of these items and provides Update and Render functions.

Class hierarchy derived from MenuItem:

  • InactiveMenuItem
  • FunctionalMenuItem
  • EnumMenuItem
    • FieldMenuItem
    • CharacterMenuItem
  • IntMenuItem
  • ToggleMenuItem