Here's the high level API design I'm thinking.
We have a Singleton, global Dialogue class with
Dialogue.load(intro_dialogue.txt) // loads a text file, sets a accessible-anywhere boolean isInDialogue=true
Dialogue.advance() // advances to the next line in the file, display the line, calls .end() if no more lines
Dialogue.end() // remove the dialogue box,
For now, if world isInDialogue, let's skip on PatrolAI::update, health bar display, Pari movement key listening.
Here's where we handle dialogue advance
// in user_view.cpp
void UserView::pressEvent(...) {
switch (key.code) {
...
case sf::Keyboard::Enter: // could trigger on left click too...
Dialogue->advance();
}
}
Dialogue.advance() has and needs some nice abstractions because I want to display the dialogue with animations: (See https://www.earthboundtext.com/images/splash.gif)
The advance() code probably looks like:
string nextLine = I/O.fetchNextLine();
if(!nextLine):
Dialogue.end();
return;
if isTextAnimating:
Dialogue.skipAnimation() // so, when User presses enter, it will skip out on the
else:
SFML.draw(nextLine);
When the uesr presses Enter, if text is animating, we skip out the animation and display the whole text out. If text is not animating, we have displayed the whole line, so let's display the next line.
Here's the high level API design I'm thinking. We have a Singleton, global Dialogue class with
For now, if world
isInDialogue
, let's skip onPatrolAI::update
, health bar display, Pari movement key listening.Here's where we handle dialogue advance
Dialogue.advance()
has and needs some nice abstractions because I want to display the dialogue with animations: (See https://www.earthboundtext.com/images/splash.gif) Theadvance()
code probably looks like:When the uesr presses
Enter
, if text is animating, we skip out the animation and display the whole text out. If text is not animating, we have displayed the whole line, so let's display the next line.