Skip to content

Companion UI Components Updated

Maxwell Schroder edited this page Oct 5, 2023 · 2 revisions

Introduction:

Java class called CompanionStatsDisplay.java is responsible for showing the companion information, such as heath, on the screen in an easy to read style. Furthermore it must match the style of the player and other in-game items. This wiki will provide a detailed explanation of how this feature is implemented, along with a UML diagram to visualize the class structure.

Class Overview:

The CompanionStatsDisplay class extends UIComponent and is used for managing the UI elements related to companion statistics. It has several instance variables and methods for updating and displaying companion health. Handling alerts will be done in a new class, CompanionInGameAlerts.

image

1. Instance Variables:

Table container:

A UI layout element used for organising all the relevant UI components. Bundles them all together into one section

Table companionStatisticsUI

Is a smaller UI layout elment which is embedded inside of table. It actually contains the rows of the different elements of the UI

Label companionHealthLabel:

It is a label element which contains the text of what the health level is at

Stack healthStack:

Contains a stack of Images/Frame which combine to form a dynamic health bar. When the bar is full, the health is at 100.

Label companionModeLabel:

Label element which represents what the current mode the companion is in

2 Constructor:

The class has one constructor which sets some config variables. The trigger/listeners and other creation of elements is done in create() method.

3 Create() method:

This method sets up the listeners on changing mode and changing health amount

it also calls addActors, which puts the UI elements on screen

4. addActors() method:

Creates and positions UI elements (labels) for displaying companion health as a bar and companion mode. Uses frames and images to make the UI consistent with the theme of the game

5 createHealthBar(Table statsTable):

Given the Ui table it adds the bar to, create the health bar.

6 createModesBar(Table statsTable):

Given the UI table, it puts the background image and the mode status over the top

7 createInventoryButton:

Adds a button below the other UI elements. This button, when clicked, opens up the inventory UI display

8 updateCompanionHealthUI:

Updates the companions health bar and the number of health points associated

9 updateCompanionModeUI:

Updates the companions mode string/status.

10. dispose() Method:

Cleans up resources and removes UI elements when they are no longer needed.

Contributors:

Maxwell Schroder (@MaxwellSchroder)

Clone this wiki locally