Dialogue Box Service Programming Guide - UQcsse3200/2024-studio-2 GitHub Wiki

DialogueBoxService Class

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.

Initialising the Dialogue Box Service

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.

Using the Dialogue Box Service

The main purpose of the Dialogue Box Service is updating text and hiding the dialogue box.

Hiding the Dialogue Box

To hide the current dialogue box, call the following method on the Dialogue Box Service instance:

dialogueBoxService.hideCurrentOverlay();

Updating the Dialogue Box Text

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.

Updating Text Without Entity Highlighting

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: A String[][] containing the dialogue text.
  • priority: An integer that determines the priority of the dialogue (e.g., battle-related dialogues might have a higher priority).
Updating Text With Entity Highlighting

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: A String[][] containing the dialogue text.
  • entity: The Entity to highlight while displaying the dialogue.
  • priority: An integer that determines the priority of the dialogue.

UML Diagram

In order to understand this class' dependencies a UML diagram can be seen below:

UML Diagram

Testing Guide

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.

⚠️ **GitHub.com Fallback** ⚠️