Class TextMenu

java.lang.Object
dev.kyzel.game.menu.Menu
dev.kyzel.game.menu.TextMenu
Direct Known Subclasses:
OverMenu, PauseMenu, StatMenu

public class TextMenu extends Menu
The text menu super class.
  • Field Details

    • text

      private final String[] text
      The texts in the menu.
    • textWidth

      private final int[] textWidth
      The texts' width.
    • textHeight

      private final int[] textHeight
      The texts' height.
    • fontList

      private final Font[] fontList
      The fonts list.
    • useOneFont

      private final boolean useOneFont
      A variable to see if the menu only uses one font.
  • Constructor Details

    • TextMenu

      public TextMenu(Renderer render, String[] text, Font font, int alignment)
      Creates a new text menu.
      Parameters:
      render - the Renderer where the menu will be drawn on
      text - the texts in the menu
      font - the font for the texts
      alignment - the alignment of the menu
    • TextMenu

      public TextMenu(Renderer render, String[] text, Font[] fontList, int alignment)
      Creates a new text menu.
      Parameters:
      render - the Renderer where the menu will be drawn on
      text - the texts in the menu
      fontList - the fonts for the texts
      alignment - the alignment of the menu
    • TextMenu

      public TextMenu(Renderer render, String[] text, Font font)
      Creates a new text menu.
      Parameters:
      render - the Renderer where the menu will be drawn on
      text - the texts in the menu
      font - the font for the texts
    • TextMenu

      public TextMenu(Renderer render, String[] text, Font[] fontList)
      Creates a new text menu.
      Parameters:
      render - the Renderer where the menu will be drawn on
      text - the texts in the menu
      fontList - the fonts for the texts
  • Method Details

    • importTextAndFont

      public void importTextAndFont()
      Import all the texts and fonts.
    • calculateXY

      public void calculateXY()
      Calculate the x and y coordinates based on the given information.
    • getTextSize

      public Rectangle2D getTextSize(Graphics g, String text)
      Gets the text size in the given Graphics context.
      Parameters:
      g - the given Graphics context
      text - the text
      Returns:
      the size of the text, represents by a Rectangle2D
    • draw

      public void draw(Graphics g)
      Draws the container of the menu. Draws the texts.
      Overrides:
      draw in class Menu
      Parameters:
      g - the Graphics which is used to draw