Class BaseEndScreenDisplays
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.rendering.RenderComponent
com.csse3200.game.ui.UIComponent
com.csse3200.game.components.screens.BaseScreenDisplay
com.csse3200.game.components.screens.BaseEndScreenDisplays
- All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable
,Renderable
,Comparable<Renderable>
Configurable, shared end-of-run screen for both Victory and Defeated outcomes.
Centralises common layout and behaviour:
- Title (text + colour)
- Round and elapsed-time labels
- Primary/secondary action buttons
victory(GdxGame)
and
defeated(GdxGame)
.
This class extends BaseScreenDisplay
for shared UI helpers and lifecycle.
-
Field Summary
Fields inherited from class com.csse3200.game.components.screens.BaseScreenDisplay
game, logger, neon, root
Fields inherited from class com.csse3200.game.ui.UIComponent
skin, stage
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected float
blockPad()
Vertical padding applied beneath title and info blocks.protected void
buildUI
(com.badlogic.gdx.scenes.scene2d.ui.Table root) Builds the end-screen UI: title, round/time labels, and the action buttons.protected float
Font scale for button labels.protected float
Horizontal gap between the primary and secondary buttons.static BaseEndScreenDisplays
Convenience factory for a Defeated end screen.protected float
Font scale for informational labels (round/time).void
setElapsedSeconds
(long seconds) Updates the elapsed time label using total seconds, formatted asmm:ss
.void
setElapsedText
(String mmss) Updates the elapsed time label with a preformatted string (e.g.,"12:34"
).void
setRound
(int round) Updates the displayed round number.protected float
Font scale for the title label.static BaseEndScreenDisplays
Convenience factory for a Victory end screen.Methods inherited from class com.csse3200.game.components.screens.BaseScreenDisplay
addBody, addTitle, backMainMenu, button, create, dispose, draw, getZIndex, makeSolidTexture, solidImage
Methods inherited from class com.csse3200.game.ui.UIComponent
getLayer
Methods inherited from class com.csse3200.game.rendering.RenderComponent
compareTo, disableComponent, enableComponent, isDisabled, render
Methods inherited from class com.csse3200.game.components.Component
earlyUpdate, getEntity, getPrio, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate, update
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
-
BaseEndScreenDisplays
protected BaseEndScreenDisplays(GdxGame game, String titleText, com.badlogic.gdx.graphics.Color titleColor, String primaryText, Runnable primaryAction, Runnable secondaryAction) Constructs a new end-of-run display with the given configuration.- Parameters:
game
- game instance used for screen navigationtitleText
- title text (e.g., "Victory", "DEFEATED")titleColor
- colour to apply to the titleprimaryText
- label for the primary buttonprimaryAction
- action executed on primary button presssecondaryAction
- action executed on secondary button press; ifnull
, defaults toBaseScreenDisplay.backMainMenu()
-
-
Method Details
-
buildUI
protected void buildUI(com.badlogic.gdx.scenes.scene2d.ui.Table root) Builds the end-screen UI: title, round/time labels, and the action buttons.Appearance can be tuned by overriding the styling hooks:
titleFontScale()
,infoFontScale()
,buttonLabelScale()
,buttonsGap()
,blockPad()
.- Specified by:
buildUI
in classBaseScreenDisplay
- Parameters:
root
- the root table (already added to the Stage byBaseScreenDisplay
)
-
setRound
public void setRound(int round) Updates the displayed round number.- Parameters:
round
- the current round (values < 1 are clamped to 1)
-
setElapsedSeconds
public void setElapsedSeconds(long seconds) Updates the elapsed time label using total seconds, formatted asmm:ss
.- Parameters:
seconds
- total elapsed seconds (negative values are clamped to 0)
-
setElapsedText
Updates the elapsed time label with a preformatted string (e.g.,"12:34"
).- Parameters:
mmss
- elapsed time string inmm:ss
format
-
titleFontScale
protected float titleFontScale()Font scale for the title label.- Returns:
- title font scale (default
3.0f
)
-
infoFontScale
protected float infoFontScale()Font scale for informational labels (round/time).- Returns:
- info label font scale (default
3.0f
)
-
buttonLabelScale
protected float buttonLabelScale()Font scale for button labels.- Returns:
- button label font scale (default
2.0f
)
-
buttonsGap
protected float buttonsGap()Horizontal gap between the primary and secondary buttons.- Returns:
- gap in pixels (default
30f
)
-
blockPad
protected float blockPad()Vertical padding applied beneath title and info blocks.- Returns:
- padding in pixels (default
50f
)
-
victory
Convenience factory for a Victory end screen.- Parameters:
game
- game instance for navigation- Returns:
- a configured
BaseEndScreenDisplays
showing "Victory" with a "Continue" action
-
defeated
Convenience factory for a Defeated end screen.- Parameters:
game
- game instance for navigation- Returns:
- a configured
BaseEndScreenDisplays
showing "DEFEATED" with a "Try Again" action
-