Class MainGameOrderTicketDisplay
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.rendering.RenderComponent
com.csse3200.game.ui.UIComponent
com.csse3200.game.components.ordersystem.MainGameOrderTicketDisplay
- All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable
,Renderable
,Comparable<Renderable>
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.
-
Field Summary
Fields inherited from class com.csse3200.game.ui.UIComponent
skin, stage
-
Constructor Summary
ConstructorsConstructorDescriptionMainGameOrderTicketDisplay
(RenderService renderService, PlayerService playerService) Constructs an MainGameOrderTicketDisplay instance -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a new order ticket to the display and sets its initial position and size.void
create()
Initialises the display and sets up event listeners for creating and shifting orders.void
dispose()
Disposes of all resources associated with the order tickets, including clearing and removing tables from the stage.void
draw
(com.badlogic.gdx.graphics.g2d.SpriteBatch batch) Draws the order tickets on the screen.Gets the Docket's background displaysGet combat statistics componentstatic List
<com.badlogic.gdx.scenes.scene2d.ui.Label> Gets the recipes' timer count down labelsGet recipe namestatic int
Returns Order Number.long
Gets the start pause timeGets recipe dataGets the list of recipe timesstatic float
getScalingFactor
(float currentWidth, float currentHeight) Gets the scaling factor in respect to current width and height of screen.Gets the times that the recipes were createdstatic List
<com.badlogic.gdx.scenes.scene2d.ui.Table> Returns the list of tables used for displaying order tickets.long
getTimer()
Gets the making time of the recipe multiplied by the default timerlong
Gets the total pause duration timefloat
Returns the viewportHeight.float
Returns the viewportHeightMultiplayer.float
Returns the viewportWidth.float
Returns the z-index for this component.boolean
handleKeyDown
(int keycode) Handles key press events.boolean
isPaused()
Gets the True or False depending on if the game is paused or not respectivelyvoid
Removes the current big ticket from the UI, as well as its values in the arraystatic void
reorderDockets
(int index) Reorders the dockets after one is removed or shifted.static void
Resets order number to 0 for screen transition purposes.void
setCombatStatsComponent
(CombatStatsComponent newCombatStatsComponent) Sets the combat statistics componentvoid
setPaused
(boolean paused) void
Sets recipe datavoid
setStage
(com.badlogic.gdx.scenes.scene2d.Stage stage) Sets the stagevoid
* Shifts the order tickets to the left by moving the first ticket to the end of the list.void
Shifts the order tickets to the right by moving the last ticket to the beginning of the list.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.void
update()
Updates the state of all order tickets, including countdown timers and their positions on the screen.void
Updates the display for all dockets.void
Updates the docket sizesMethods inherited from class com.csse3200.game.ui.UIComponent
getLayer
Methods inherited from class com.csse3200.game.rendering.RenderComponent
compareTo, render
Methods inherited from class com.csse3200.game.components.Component
earlyUpdate, getEntity, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Comparable
compareTo
Methods inherited from interface com.csse3200.game.rendering.Renderable
render
-
Constructor Details
-
MainGameOrderTicketDisplay
Constructs an MainGameOrderTicketDisplay instance
-
-
Method Details
-
getCombatStats
Get combat statistics component -
setCombatStatsComponent
Sets the combat statistics component -
setRecipe
Sets recipe data- Parameters:
recipeName
- the name of the recipe
-
getRecipe
Gets recipe data- Returns:
- recipe data
-
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 classUIComponent
-
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
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. -
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 classRenderComponent
- 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 interfaceRenderable
- Overrides:
getZIndex
in classUIComponent
- 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 interfacecom.badlogic.gdx.utils.Disposable
- Overrides:
dispose
in classRenderComponent
-
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
Returns the list of tables used for displaying order tickets.- Returns:
- the list of order ticket tables.
-
getStartTimeArrayList
Gets the times that the recipes were created- Returns:
- the start time array list
-
getCountdownLabelArrayList
Gets the recipes' timer count down labels- Returns:
- the countdown label array list
-
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
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
-