Class HeadsUpDisplay
- java.lang.Object
-
- bytemusketeers.heslingtonhustle.ui.Overlay
-
- bytemusketeers.heslingtonhustle.ui.HeadsUpDisplay
-
- All Implemented Interfaces:
MetricListener
,Drawable
,com.badlogic.gdx.utils.Disposable
class HeadsUpDisplay extends Overlay implements MetricListener
TheHeadsUpDisplay
displays persistent player and game information throughout the gameplay.- Author:
- ENG1 Team 23 (Cohort 3)
-
-
Field Summary
Fields Modifier and Type Field Description private static com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle
LABEL_STYLE
TheLabel.LabelStyle
to use for all text; this is standard and shipped with LibGDXprivate java.util.Map<MetricController.Metric,com.badlogic.gdx.scenes.scene2d.ui.Label>
metricLabels
A persistent mapping betweenMetricController.Metric
elements and theOverlay
-specificLabel
form elements-
Fields inherited from class bytemusketeers.heslingtonhustle.ui.Overlay
GENERAL_FORM_PADDING
-
-
Constructor Summary
Constructors Constructor Description HeadsUpDisplay(com.badlogic.gdx.graphics.g2d.SpriteBatch batch, MetricController.Metric[] leftMetrics, MetricController.Metric[] rightMetrics)
Creates a newHeadsUpDisplay
relating to the givenSpriteBatch
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addLabel(MetricController.Metric metric, com.badlogic.gdx.scenes.scene2d.ui.Table table)
Prepares and adds a name-valueLabel
pair to the givenTable
, and ends the rowvoid
updateMetricText(MetricController.Metric metric, java.lang.String text)
Update theMetricController.Metric
label with the given value
-
-
-
Field Detail
-
metricLabels
private final java.util.Map<MetricController.Metric,com.badlogic.gdx.scenes.scene2d.ui.Label> metricLabels
A persistent mapping betweenMetricController.Metric
elements and theOverlay
-specificLabel
form elements- See Also:
MetricController
-
LABEL_STYLE
private static final com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle LABEL_STYLE
TheLabel.LabelStyle
to use for all text; this is standard and shipped with LibGDX
-
-
Constructor Detail
-
HeadsUpDisplay
HeadsUpDisplay(com.badlogic.gdx.graphics.g2d.SpriteBatch batch, MetricController.Metric[] leftMetrics, MetricController.Metric[] rightMetrics)
Creates a newHeadsUpDisplay
relating to the givenSpriteBatch
- Parameters:
batch
- TheSpriteBatch
to which theHeadsUpDisplay
should be connectedleftMetrics
- TheMetricController.Metric
elements to be displayed on the left-hand siderightMetrics
- TheMetricController.Metric
elements to be displayed on the right-hand side
-
-
Method Detail
-
updateMetricText
public void updateMetricText(MetricController.Metric metric, java.lang.String text)
Update theMetricController.Metric
label with the given value- Specified by:
updateMetricText
in interfaceMetricListener
- Parameters:
metric
- The key of theMetricController.Metric
to updatetext
- The new text
-
addLabel
private void addLabel(MetricController.Metric metric, com.badlogic.gdx.scenes.scene2d.ui.Table table)
Prepares and adds a name-valueLabel
pair to the givenTable
, and ends the row- Parameters:
metric
- TheMetricController.Metric
associated with theLabel
-
-