Class BaseScreenDisplay
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.rendering.RenderComponent
com.csse3200.game.ui.UIComponent
com.csse3200.game.components.screens.BaseScreenDisplay
- All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable
,Renderable
,Comparable<Renderable>
- Direct Known Subclasses:
BaseEndScreenDisplays
,PauseMenuDisplay
,TerminalDisplay
,TutorialScreenDisplay
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
buildUI(Table)
to construct their specific UI.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected 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
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
BaseScreenDisplay
(GdxGame game) Constructs a screen display bound to a game instance. -
Method Summary
Modifier and TypeMethodDescriptionprotected com.badlogic.gdx.scenes.scene2d.ui.Label
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 providedroot
table.protected com.badlogic.gdx.scenes.scene2d.ui.TextButton
Creates a rounded neonTextButton
and binds the given action.void
create()
Initialises common UI infrastructure and delegates tobuildUI(Table)
.void
dispose()
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-colourTexture
and tracks it for auto-disposal.protected com.badlogic.gdx.scenes.scene2d.ui.Image
solidImage
(com.badlogic.gdx.graphics.Color c) Creates anImage
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 loggerClass-scoped logger for subclasses. -
game
Game reference used for screen navigation helpers. -
root
protected com.badlogic.gdx.scenes.scene2d.ui.Table rootRoot table added to the stage; fill-parent and centered. -
neon
Shared style builder for rounded neon buttons.
-
-
Constructor Details
-
BaseScreenDisplay
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 tobuildUI(Table)
.Creates
root
, adds it to the stage, initialisesneon
, and then callsbuildUI(Table)
for subclass-specific layout.- Overrides:
create
in classUIComponent
-
buildUI
protected abstract void buildUI(com.badlogic.gdx.scenes.scene2d.ui.Table root) Subclasses implement their UI here using the providedroot
table.- Parameters:
root
- a fill-parent, centeredTable
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 totext
- title textfontScale
- scale for the title fontcolor
- optional tint colour for the title (may benull
)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 totext
- body textfontScale
- scale for the body fontpadBottom
- 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 neonTextButton
and binds the given action.- Parameters:
text
- button labellabelScale
- font scale applied to the labelonClick
- action executed onChangeListener
event (may benull
)- Returns:
- the configured
TextButton
-
makeSolidTexture
protected com.badlogic.gdx.graphics.Texture makeSolidTexture(com.badlogic.gdx.graphics.Color c) Creates a solid-colourTexture
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 anImage
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 classRenderComponent
- 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 interfaceRenderable
- Overrides:
getZIndex
in classUIComponent
- 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 callingsuper.dispose()
to avoid rendering disposed resources.- Specified by:
dispose
in interfacecom.badlogic.gdx.utils.Disposable
- Overrides:
dispose
in classRenderComponent
-