Class BaseEndScreenDisplays

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

public class BaseEndScreenDisplays extends BaseScreenDisplay
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
Consumers provide configuration via the constructor (texts, colours, actions), or use the convenience factory methods victory(GdxGame) and defeated(GdxGame).

This class extends BaseScreenDisplay for shared UI helpers and lifecycle.

  • 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 navigation
      titleText - title text (e.g., "Victory", "DEFEATED")
      titleColor - colour to apply to the title
      primaryText - label for the primary button
      primaryAction - action executed on primary button press
      secondaryAction - action executed on secondary button press; if null, defaults to BaseScreenDisplay.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 class BaseScreenDisplay
      Parameters:
      root - the root table (already added to the Stage by BaseScreenDisplay)
    • 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 as mm:ss.
      Parameters:
      seconds - total elapsed seconds (negative values are clamped to 0)
    • setElapsedText

      public void setElapsedText(String mmss)
      Updates the elapsed time label with a preformatted string (e.g., "12:34").
      Parameters:
      mmss - elapsed time string in mm: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

      public static BaseEndScreenDisplays victory(GdxGame game)
      Convenience factory for a Victory end screen.
      Parameters:
      game - game instance for navigation
      Returns:
      a configured BaseEndScreenDisplays showing "Victory" with a "Continue" action
    • defeated

      public static BaseEndScreenDisplays defeated(GdxGame game)
      Convenience factory for a Defeated end screen.
      Parameters:
      game - game instance for navigation
      Returns:
      a configured BaseEndScreenDisplays showing "DEFEATED" with a "Try Again" action