dao::dialogue

Conversations, cutscenes and movies: watch them, steer which replies appear, skip them.

Declared in dao/Dialogue.h.

Classes

Class  
Conversation A conversation that is playing. You never create one: Current() and the callbacks give you one.

Type aliases

Line

using Line = core::ConversationLine

A line of a conversation, as stored in the conversation’s file (dao/core/Conversation.h).

Functions

Choose()

bool Choose(std::size_t index)

Chooses a reply on the screen, the same as clicking it or pressing its number key.

Dialogue mode accepts it only while replies are on the screen. It ignores a reply with no text, the hidden “continue” reply the screen does not list; use Continue for that one. Call it on the game thread, and not from one of the callbacks above. To click through a conversation:

if (!dao::dialogue::Replies().empty())
    dao::dialogue::Choose(0);   // the first reply
else
    dao::dialogue::Continue();  // skip the line being spoken
Parameter  
index the reply’s position in Replies()

Returns true if the choice was sent (OnReplyChosen then reports it); false, with nothing sent, outside a conversation or if the index is past the last reply

Continue()

bool Continue()

Skips ahead, the same as the skip key in a conversation.

The NPC line being spoken is cut short and its replies appear at once. If the first reply has no text, the conversation continues through it. Call it on the game thread, and not from one of the callbacks above.

Returns false outside a conversation

Current()

Conversation * Current()

Returns the conversation on the screen.

Returns the conversation, or null unless the game is in dialogue mode

InCutscene()

bool InCutscene()

Returns whether a cutscene is playing, that is, whether the game is in cutscene mode.

Many of the game’s staged scenes are conversations instead, and those run in dialogue mode.

InMovie()

bool InMovie()

Returns whether a pre-rendered video is playing, that is, whether the game is in movie mode.

The scripts’ PlayMovie starts one.

OnLineAvailable()

void OnLineAvailable(std::function<bool(Conversation &, const Line &line, bool available)> decide)

Adds a callback that decides whether a line is available.

It sees every NPC line the engine considers as the next line spoken, and every reply it considers offering. A callback can hide a line whose condition passes, or offer one whose condition fails, but only among the lines the file lists under that NPC line. It cannot add a line the file does not have.

Parameter  
decide receives the conversation, the line and the decision so far, and returns the final decision

OnNpcLine()

void OnNpcLine(std::function<void(Conversation &, const Line &line)> observer)

Adds a callback that runs when an NPC line is about to be spoken.

OnReplies()

void OnReplies(std::function<void(Conversation &, std::span<const Line> replies)> observer)

Adds a callback that runs once the replies to an NPC line are on the screen.

It receives them in the order shown.

OnReplyChosen()

void OnReplyChosen(std::function<void(Conversation &, const Line &reply)> observer)

Adds a callback that runs when the conversation moves on from the reply the player chose.

Moving on without a reply does not call it.

Replies()

std::vector<Line> Replies()

Returns the replies on the screen, in order: the lines the player can choose from right now.

The list is empty outside a conversation and while the NPC is speaking.

SkipCutscene()

bool SkipCutscene()

Skips the cutscene that is playing, the same as pressing Escape.

Returns false if no cutscene is playing

SkipMovie()

bool SkipMovie()

Skips the video that is playing, the same as pressing the skip key.

Returns false if no video is playing