Class SubMenu

Direct Known Subclasses:
MenuGrid, MenuList

public abstract class SubMenu extends MenuItem
This class realizes a Menu displaying a list of MenuItems.
  • Field Details

    • inMenu

      protected boolean inMenu
      This bool indicates whether this Menu (false) or its Items (true) shall be rendered.
    • index

      protected int index
      The current index.
    • itemSize

      protected Vec itemSize
      The size of the items.
  • Constructor Details

    • SubMenu

      public SubMenu(IScene scene, String text)
      Create the submenu.
      Parameters:
      scene - the scene
      text - the text (name)
  • Method Details

    • addItem

      public void addItem(MenuItem i, MenuItem... items)
      Add an Item.
      Parameters:
      i - the item
      items - more items
    • removeItem

      public void removeItem(MenuItem i)
      Remove an Item.
      Parameters:
      i - the item
    • setIndex

      public void setIndex(int index)
      Set the index (only when the menu is currently shown). On if the index is < 0 or ≥ length it will be set to 0 or length-1
      Parameters:
      index - the new index.
    • setItemSize

      public void setItemSize(Vec value)
      Set the size of Items.
      Parameters:
      value - the new size
    • up

      public final void up()
      Description copied from class: MenuItem
      This method will be invoked to indicate an UP request.
      Overrides:
      up in class MenuItem
    • down

      public final void down()
      Description copied from class: MenuItem
      This method will be invoked to indicate an DOWN request.
      Overrides:
      down in class MenuItem
    • left

      public final void left()
      Description copied from class: MenuItem
      This method will be invoked to indicate an LEFT request.
      Overrides:
      left in class MenuItem
    • right

      public final void right()
      Description copied from class: MenuItem
      This method will be invoked to indicate an RIGHT request.
      Overrides:
      right in class MenuItem
    • select

      public void select()
      Description copied from class: MenuItem
      Select the Item.
      Overrides:
      select in class MenuItem
    • unselect

      public void unselect()
      Description copied from class: MenuItem
      Deselect the Item.
      Overrides:
      unselect in class MenuItem
    • focus

      protected void focus()
      Description copied from class: MenuItem
      This method will be invoked to indicate an focus request.
      Overrides:
      focus in class MenuItem
    • internalRender

      protected void internalRender(GameGrid f)
      Description copied from class: GuiElement

      Template method that will be called periodically after being added to a IScene. Must be as performant as possible to keep the FPS low, since it will be called in every render-loop.

      Should be overwritten in sub classes for custom visualization using the GameGrid.

      Overrides:
      internalRender in class MenuItem
      Parameters:
      f - the GameGrid that represents the games field and supplies primitive drawing operations.
    • renderMenu

      protected void renderMenu(GameGrid f)
      Renders all items of this menu. Called when this menu is selected (displaying its children).
      Parameters:
      f - the field for rendering
    • calcItemPos

      protected abstract void calcItemPos()
      Calculate the new Position of each Item.
    • hasChildren

      public boolean hasChildren()
      Description copied from class: MenuItem
      Indicates whether has children.
      Specified by:
      hasChildren in class MenuItem
      Returns:
      true if children are available false otherwise