Class BaseScreenDisplay

All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable, Renderable, Comparable<Renderable>
Direct Known Subclasses:
BaseEndScreenDisplays, PauseMenuDisplay, TerminalDisplay, TutorialScreenDisplay

public abstract class BaseScreenDisplay extends UIComponent
Abstract base for screen/overlay UI components.

Centralises common wiring for Scene2D-based screens:

  • Creates and adds a fill-parent Table root to the stage
  • Initialises shared NeonStyles for buttons
  • Provides helpers for adding titles, body text, and buttons
  • Manages auto-disposal of helper-created Texture assets
Subclasses implement buildUI(Table) to construct their specific UI.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final GdxGame
    Game reference used for screen navigation helpers.
    protected final org.slf4j.Logger
    Class-scoped logger for subclasses.
    protected NeonStyles
    Shared style builder for rounded neon buttons.
    protected com.badlogic.gdx.scenes.scene2d.ui.Table
    Root table added to the stage; fill-parent and centered.

    Fields inherited from class com.csse3200.game.ui.UIComponent

    skin, stage

    Fields inherited from class com.csse3200.game.components.Component

    enabled, entity, prio
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Constructs a screen display bound to a game instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected com.badlogic.gdx.scenes.scene2d.ui.Label
    addBody(com.badlogic.gdx.scenes.scene2d.ui.Table to, String text, float fontScale, float padBottom)
    Adds a body label by cloning the skin's "small" style and forcing a white font colour.
    protected com.badlogic.gdx.scenes.scene2d.ui.Label
    addTitle(com.badlogic.gdx.scenes.scene2d.ui.Table to, String text, float fontScale, com.badlogic.gdx.graphics.Color color, float padBottom)
    Adds a title label using the skin's "title" style.
    protected void
    Convenience helper to navigate back to the main menu.
    protected abstract void
    buildUI(com.badlogic.gdx.scenes.scene2d.ui.Table root)
    Subclasses implement their UI here using the provided root table.
    protected com.badlogic.gdx.scenes.scene2d.ui.TextButton
    button(String text, float labelScale, Runnable onClick)
    Creates a rounded neon TextButton and binds the given action.
    void
    Initialises common UI infrastructure and delegates to buildUI(Table).
    void
    Removes the root table from the stage and disposes any helper-created textures.
    void
    draw(com.badlogic.gdx.graphics.g2d.SpriteBatch batch)
    Stage handles rendering of attached actors.
    float
    Default z-index; override in overlays that must sit above other UI.
    protected com.badlogic.gdx.graphics.Texture
    makeSolidTexture(com.badlogic.gdx.graphics.Color c)
    Creates a solid-colour Texture and tracks it for auto-disposal.
    protected com.badlogic.gdx.scenes.scene2d.ui.Image
    solidImage(com.badlogic.gdx.graphics.Color c)
    Creates an Image backed by a 1x1 solid-colour texture.

    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
  • Field Details

    • logger

      protected final org.slf4j.Logger logger
      Class-scoped logger for subclasses.
    • game

      protected final GdxGame game
      Game reference used for screen navigation helpers.
    • root

      protected com.badlogic.gdx.scenes.scene2d.ui.Table root
      Root table added to the stage; fill-parent and centered.
    • neon

      protected NeonStyles neon
      Shared style builder for rounded neon buttons.
  • Constructor Details

    • BaseScreenDisplay

      protected BaseScreenDisplay(GdxGame game)
      Constructs a screen display bound to a game instance.
      Parameters:
      game - game instance for navigation (e.g., backMainMenu())
  • Method Details

    • create

      public void create()
      Initialises common UI infrastructure and delegates to buildUI(Table).

      Creates root, adds it to the stage, initialises neon, and then calls buildUI(Table) for subclass-specific layout.

      Overrides:
      create in class UIComponent
    • buildUI

      protected abstract void buildUI(com.badlogic.gdx.scenes.scene2d.ui.Table root)
      Subclasses implement their UI here using the provided root table.
      Parameters:
      root - a fill-parent, centered Table already added to the stage
    • addTitle

      protected com.badlogic.gdx.scenes.scene2d.ui.Label addTitle(com.badlogic.gdx.scenes.scene2d.ui.Table to, String text, float fontScale, com.badlogic.gdx.graphics.Color color, float padBottom)
      Adds a title label using the skin's "title" style.
      Parameters:
      to - table to add the title to
      text - title text
      fontScale - scale for the title font
      color - optional tint colour for the title (may be null)
      padBottom - bottom padding applied after the title row
      Returns:
      the created Label
    • addBody

      protected com.badlogic.gdx.scenes.scene2d.ui.Label addBody(com.badlogic.gdx.scenes.scene2d.ui.Table to, String text, float fontScale, float padBottom)
      Adds a body label by cloning the skin's "small" style and forcing a white font colour.
      Parameters:
      to - table to add the body text to
      text - body text
      fontScale - scale for the body font
      padBottom - bottom padding applied after the body row
      Returns:
      the created Label
    • button

      protected com.badlogic.gdx.scenes.scene2d.ui.TextButton button(String text, float labelScale, Runnable onClick)
      Creates a rounded neon TextButton and binds the given action.
      Parameters:
      text - button label
      labelScale - font scale applied to the label
      onClick - action executed on ChangeListener event (may be null)
      Returns:
      the configured TextButton
    • makeSolidTexture

      protected com.badlogic.gdx.graphics.Texture makeSolidTexture(com.badlogic.gdx.graphics.Color c)
      Creates a solid-colour Texture and tracks it for auto-disposal.
      Parameters:
      c - colour (including alpha)
      Returns:
      the created Texture
    • solidImage

      protected com.badlogic.gdx.scenes.scene2d.ui.Image solidImage(com.badlogic.gdx.graphics.Color c)
      Creates an Image backed by a 1x1 solid-colour texture. The underlying texture is tracked and disposed automatically.
      Parameters:
      c - colour (including alpha)
      Returns:
      an Image using the generated texture
    • backMainMenu

      protected void backMainMenu()
      Convenience helper to navigate back to the main menu. Subclasses can call this in button handlers.
    • draw

      public void draw(com.badlogic.gdx.graphics.g2d.SpriteBatch batch)
      Stage handles rendering of attached actors.
      Specified by:
      draw in class RenderComponent
      Parameters:
      batch - Batch to render to.
    • getZIndex

      public float getZIndex()
      Default z-index; override in overlays that must sit above other UI.
      Specified by:
      getZIndex in interface Renderable
      Overrides:
      getZIndex in class UIComponent
      Returns:
      Z index
    • dispose

      public void dispose()
      Removes the root table from the stage and disposes any helper-created textures. Subclasses overriding this should remove any actors that reference textures before calling super.dispose() to avoid rendering disposed resources.
      Specified by:
      dispose in interface com.badlogic.gdx.utils.Disposable
      Overrides:
      dispose in class RenderComponent