-
Notifications
You must be signed in to change notification settings - Fork 3
Description
Redguard has a dialog system to talk to NPCs.
This consists of a list of topics in the top left of the screen, from which the player picks one, characters talk/animate/whatever and the process starts anew.
While in dialog, the game is not paused but input is taken away from the character.
This dialog system is fully implemented in the game scripts, an excerpt:

We see a new conversation being started with menuNew(), one by one the conversation topics are being added with menuAddItem(...).
The dialog waits for player input with menuSelection(), the picked topic is read into a variable and text is displayed.
Implementation details:
We have 3 main functions:
- void menuNew(): clears all dialog data
- void MenuAddItem(string RTXtext, int seenBefore, int index):
Adds a new menu item with a given text. seenBefore grays out the font if true. index is the location of the text, 0 being at the top, rest below. - int menuSelection():
Displays the dialog data on screen and steals input. The player can use movement keys to highlight items, and press enter to select an item.
When an item is selected, the index of that item is returned.
This functionality should be implemented across different classes. Suggested resposibilities:
UIManager: Displays the menu, handles highlighting of options and sends a callback when the player has made a selection.
MainUIScript: Keeps a list of current dialog options, forwards to UIManager when menuSelection is called, then listens for the selection callback and returns the selected index.
RGScriptedObject: gets script input, gets RTX texts from the RTXStore and forwards everything to MainUIScript.