Class MainGameOrderTicketDisplay

All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable, Renderable, Comparable<Renderable>

public class MainGameOrderTicketDisplay extends UIComponent
Displays order tickets on the main game screen. This class manages the creation, positioning, and updating of order tickets, as well as shifting them left or right in response to user actions. It also handles the countdown timers for each order and disposes of them when the timer expires.
  • Constructor Details

    • MainGameOrderTicketDisplay

      public MainGameOrderTicketDisplay(RenderService renderService, PlayerService playerService)
      Constructs an MainGameOrderTicketDisplay instance
  • Method Details

    • getCombatStats

      public CombatStatsComponent getCombatStats()
      Get combat statistics component
    • setCombatStatsComponent

      public void setCombatStatsComponent(CombatStatsComponent newCombatStatsComponent)
      Sets the combat statistics component
    • setRecipe

      public void setRecipe(String recipeName)
      Sets recipe data
      Parameters:
      recipeName - the name of the recipe
    • getRecipe

      public Recipe getRecipe()
      Gets recipe data
      Returns:
      recipe data
    • getCurrentRecipeName

      public String getCurrentRecipeName()
      Get recipe name
      Returns:
      recipe name
    • setPaused

      public void setPaused(boolean paused)
    • create

      public void create()
      Initialises the display and sets up event listeners for creating and shifting orders.
      Overrides:
      create in class UIComponent
    • handleKeyDown

      public boolean handleKeyDown(int keycode)
      Handles key press events. If the ESCAPE key is pressed, it toggles the paused state.
      Parameters:
      keycode - The key code of the key that was pressed.
      Returns:
      true if the ESCAPE key was pressed and the event was handled, false otherwise.
    • addActors

      public void addActors()
      Adds a new order ticket to the display and sets its initial position and size. Initialises the background, labels, and countdown timer for the order.
    • reorderDockets

      public static void reorderDockets(int index)
      Reorders the dockets after one is removed or shifted.
      Parameters:
      index - the index of the docket that was removed or shifted.
    • shiftDocketsLeft

      public void shiftDocketsLeft()
      * Shifts the order tickets to the left by moving the first ticket to the end of the list. Updates the positions and sizes of all tickets.
    • stageDispose

      public void stageDispose(Docket docket, com.badlogic.gdx.scenes.scene2d.ui.Table table, int i)
      Removes and disposes of a docket from the stage and its associated resources.
      Parameters:
      docket - the docket to be disposed of.
      table - the table representing the docket.
      i - the index of the docket.
    • shiftDocketsRight

      public void shiftDocketsRight()
      Shifts the order tickets to the right by moving the last ticket to the beginning of the list. Updates the positions and sizes of all tickets.
    • updateDocketSizes

      public void updateDocketSizes()
      Updates the docket sizes
    • getScalingFactor

      public static float getScalingFactor(float currentWidth, float currentHeight)
      Gets the scaling factor in respect to current width and height of screen.
      Parameters:
      currentWidth - current width of the game window screen.
      currentHeight - current height of the game window screen.
      Returns:
      scaling factor
    • update

      public void update()
      Updates the state of all order tickets, including countdown timers and their positions on the screen. Removes any order tickets whose timers have expired.
      Overrides:
      update in class Component
    • removeBigTicket

      public void removeBigTicket()
      Removes the current big ticket from the UI, as well as its values in the array
    • updateDocketDisplay

      public void updateDocketDisplay()
      Updates the display for all dockets. This includes updating their positions and sizes.
    • draw

      public void draw(com.badlogic.gdx.graphics.g2d.SpriteBatch batch)
      Draws the order tickets on the screen. The actual drawing is handled by the stage.
      Specified by:
      draw in class RenderComponent
      Parameters:
      batch - the sprite batch used for drawing.
    • getZIndex

      public float getZIndex()
      Returns the z-index for this component. The z-index determines the rendering order of UI components.
      Specified by:
      getZIndex in interface Renderable
      Overrides:
      getZIndex in class UIComponent
      Returns:
      the z-index for this component.
    • setStage

      public void setStage(com.badlogic.gdx.scenes.scene2d.Stage stage)
      Sets the stage
      Parameters:
      stage - the stage of the game
    • dispose

      public void dispose()
      Disposes of all resources associated with the order tickets, including clearing and removing tables from the stage.
      Specified by:
      dispose in interface com.badlogic.gdx.utils.Disposable
      Overrides:
      dispose in class RenderComponent
    • resetOrderNumb

      public static void resetOrderNumb()
      Resets order number to 0 for screen transition purposes.
    • getOrderNumb

      public static int getOrderNumb()
      Returns Order Number.
    • getViewportWidth

      public float getViewportWidth()
      Returns the viewportWidth.
      Returns:
      the float value of viewportWidth.
    • getViewportHeight

      public float getViewportHeight()
      Returns the viewportHeight.
      Returns:
      the float value of viewportHeight.
    • getViewPortHeightMultiplier

      public float getViewPortHeightMultiplier()
      Returns the viewportHeightMultiplayer.
      Returns:
      the float value of viewportHeightMultiplayer.
    • getTableArrayList

      public static List<com.badlogic.gdx.scenes.scene2d.ui.Table> getTableArrayList()
      Returns the list of tables used for displaying order tickets.
      Returns:
      the list of order ticket tables.
    • getStartTimeArrayList

      public static List<Long> getStartTimeArrayList()
      Gets the times that the recipes were created
      Returns:
      the start time array list
    • getCountdownLabelArrayList

      public static List<com.badlogic.gdx.scenes.scene2d.ui.Label> getCountdownLabelArrayList()
      Gets the recipes' timer count down labels
      Returns:
      the countdown label array list
    • getBackgroundArrayList

      public static List<Docket> getBackgroundArrayList()
      Gets the Docket's background displays
      Returns:
      the background array list
    • getTimer

      public long getTimer()
      Gets the making time of the recipe multiplied by the default timer
      Returns:
      the recipe timer
    • getRecipeTimeArrayList

      public static List<Long> getRecipeTimeArrayList()
      Gets the list of recipe times
      Returns:
      the recipe time array list
    • isPaused

      public boolean isPaused()
      Gets the True or False depending on if the game is paused or not respectively
      Returns:
      the boolean value of isPaused
    • getPauseStartTime

      public long getPauseStartTime()
      Gets the start pause time
      Returns:
      the long value of pauseStartTime
    • getTotalPausedDuration

      public long getTotalPausedDuration()
      Gets the total pause duration time
      Returns:
      the long value of totalPausedDuration