Dialogue Box Service Programming Guide - UQcsse3200/2024-studio-2 GitHub Wiki
The Dialogue Box Service acts as a streamlined interface for interacting with the Dialogue Box system, managing multiple assets and ensuring smooth interaction. It follows the Facade design pattern to simplify the process of adding, displaying, and navigating dialogue in-game.
The Dialogue Box Service is initialised to handle the loading and management of dialogue boxes for various game screens. The service helps keep track of all active dialogue boxes and manages resizing and dynamic updating of the dialogue box UI elements.
DialogueBoxService dialogueBoxService = new DialogueBoxService(stage);
Typically once a Dialogue Box Service has been initialised it should be attached to the Service Locator through the public static void registerRenderService(RenderService service)
method.
The main purpose of the Dialogue Box Service is updating text and hiding the dialogue box.
To hide the current dialogue box, call the following method on the Dialogue Box Service instance:
dialogueBoxService.hideCurrentOverlay();
The updateText()
method is overloaded to provide flexibility for updating the dialogue box content. You can update the dialogue text with or without highlighting a specific entity in the game.
You can update the dialogue box with new text while specifying a priority for the update. The priority system ensures that higher-priority dialogues (such as battle events) take precedence over lower-priority ones.
dialogueBoxService.updateText(hints, priority);
-
hints
: AString[][]
containing the dialogue text. -
priority
: An integer that determines the priority of the dialogue (e.g., battle-related dialogues might have a higher priority).
In some cases, you may want to highlight an entity while displaying dialogue. This overload of updateText()
allows you to update the dialogue and highlight a selected entity with animations.
dialogueBoxService.updateText(hints, entity, priority);
-
hints
: AString[][]
containing the dialogue text. -
entity
: TheEntity
to highlight while displaying the dialogue. -
priority
: An integer that determines the priority of the dialogue.
In order to understand this class' dependencies a UML diagram can be seen below:
In order to see the testing guide for this class see: Dialogue Box Service & Dialogue Box Testing. A minimum of 80% test coverage has been maintained and it is important to ensure > 80% coverage is maintained when changing this code.