java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
fr.paris.saclay.sidescroller.controllers.components.menu.GameMenu
All Implemented Interfaces:
ActionListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible

public class GameMenu extends JPanel implements ActionListener
Game menu, it handles both the initial menu and the paused one.
See Also:
  • Constructor Details

    • GameMenu

      public GameMenu(MainFrame frame)
      Creates a GameMenu instance.
      Parameters:
      frame - parent reference.
  • Method Details

    • quitToMenu

      public void quitToMenu(MainFrame frame)
      Quits current game and returns to the main menu.
      Parameters:
      frame - parent reference.
    • setNormalGridConstraints

      public void setNormalGridConstraints()
      Setups layout for main menu: 2 buttons and credits.
    • setPausedGridConstraints

      public void setPausedGridConstraints()
      Setups layout for pause menu: 2 buttons.
    • setSelectionGridConstraints

      public void setSelectionGridConstraints()
      Setups layout for selection menu: 2 previews with 2 buttons each to select them, 2 buttons (back, start game) and 2 descriptions.
    • paintComponent

      protected void paintComponent(Graphics graphics)
      Draws menu calling the view method responsible for that.
      Overrides:
      paintComponent in class JComponent
      Parameters:
      graphics - the rendering component.
    • getPreferredSize

      public Dimension getPreferredSize()
      Retrieves preferred size.
      Overrides:
      getPreferredSize in class JComponent
      Returns:
      preferred size.
    • getSize

      public Dimension getSize()
      Retrieves size.
      Overrides:
      getSize in class Component
      Returns:
      size.
    • actionPerformed

      public void actionPerformed(ActionEvent e)
      Handles opening animation of the menu.
      Specified by:
      actionPerformed in interface ActionListener
      Parameters:
      e - the event to be processed.
    • isPauseMenu

      public boolean isPauseMenu()
      Calls related method of the model.
      Returns:
      result.
    • setPauseMenu

      public void setPauseMenu(boolean pauseMenu)
      Calls related method of the model.
      Parameters:
      pauseMenu - pause menu flag.
    • getModel

      public GameMenuModel getModel()
      Gets model.
      Returns:
      the model