The primary HUD system for the player. Manages displaying messages and asking questions. A callback is issued when messages are complete or when choices are made.
More...
#include <HUD.hpp>
|
using | Callback = std::function< void(const std::string &value)> |
| Signature for HUD callbacks. Used for both messages completing and choices made. More...
|
|
using | QtyCallback = std::function< void(int qty)> |
| Called when a qty is entered. More...
|
|
|
| HUD (Systems &owner) |
| Construct a new HUD system. More...
|
|
virtual | ~HUD ()=default |
| Destroys the system. More...
|
|
void | displayMessage (const std::string &message, const Callback &cb=[](const std::string &) {}) |
| Displays a message in the HUD textbox. Messages are queued in order that they arrive. More...
|
|
void | displayStickyMessage (const std::string &message, bool ghostWrite, const Callback &cb=[](const std::string &) {}) |
| Displays a message in the HUD textbox. Sticky messages stay displayed until programmatically dismissed. Events can queue up behind sticky messages. More...
|
|
bool | dismissStickyMessage (bool ignoreGhostWrite=true) |
| Dismisses the currently active sticky message. More...
|
|
void | promptUser (const std::string &prompt, const std::vector< std::string > &choices, const Callback &cb) |
| Asks the player a question through the HUD. More...
|
|
void | getInputString (const std::string &prompt, unsigned int minLen, unsigned int maxLen, const Callback &cb) |
| Prompts the player to input a string using the screen keyboard. More...
|
|
void | getQty (const std::string &prompt, int minQty, int maxQty, const QtyCallback &cb) |
| Gets a number from the player. More...
|
|
void | displayEntryCard (const std::string &name) |
| Displays a card to indicate entering a new town, route, or map. More...
|
|
void | hideEntryCard () |
| Hides the entry card. More...
|
|
The primary HUD system for the player. Manages displaying messages and asking questions. A callback is issued when messages are complete or when choices are made.
Definition at line 31 of file HUD.hpp.
◆ Callback
Signature for HUD callbacks. Used for both messages completing and choices made.
- Parameters
-
value | The message that completed or the choice that was chosen |
Definition at line 39 of file HUD.hpp.
◆ QtyCallback
Called when a qty is entered.
- Parameters
-
Definition at line 47 of file HUD.hpp.
◆ HUD()
core::system::HUD::HUD |
( |
Systems & |
owner | ) |
|
Construct a new HUD system.
- Parameters
-
owner | The primary systems object |
Definition at line 25 of file HUD.cpp.
◆ ~HUD()
virtual core::system::HUD::~HUD |
( |
| ) |
|
|
virtualdefault |
◆ dismissStickyMessage()
bool core::system::HUD::dismissStickyMessage |
( |
bool |
ignoreGhostWrite = true | ) |
|
Dismisses the currently active sticky message.
- Parameters
-
ignoreGhostWrite | True to dismiss even if message is not done printing, false to wait |
- Returns
- True if a message was dismissed, false otherwise
Definition at line 102 of file HUD.cpp.
◆ displayEntryCard()
void core::system::HUD::displayEntryCard |
( |
const std::string & |
name | ) |
|
Displays a card to indicate entering a new town, route, or map.
- Parameters
-
name | The name to display inside the card |
Definition at line 129 of file HUD.cpp.
◆ displayMessage()
void core::system::HUD::displayMessage |
( |
const std::string & |
message, |
|
|
const Callback & |
cb = [](const std::string&) {} |
|
) |
| |
Displays a message in the HUD textbox. Messages are queued in order that they arrive.
- Parameters
-
message | The message to display |
cb | Callback to issue when the message is completed and the player hits continue |
Definition at line 92 of file HUD.cpp.
◆ displayStickyMessage()
void core::system::HUD::displayStickyMessage |
( |
const std::string & |
message, |
|
|
bool |
ghostWrite, |
|
|
const Callback & |
cb = [](const std::string&) {} |
|
) |
| |
Displays a message in the HUD textbox. Sticky messages stay displayed until programmatically dismissed. Events can queue up behind sticky messages.
- Parameters
-
message | The message to display |
ghostWrite | True to display text char by char, false to show entire message at once |
cb | Callback to issue when the message is fully shown |
Definition at line 97 of file HUD.cpp.
◆ getInputString()
void core::system::HUD::getInputString |
( |
const std::string & |
prompt, |
|
|
unsigned int |
minLen, |
|
|
unsigned int |
maxLen, |
|
|
const Callback & |
cb |
|
) |
| |
Prompts the player to input a string using the screen keyboard.
- Parameters
-
prompt | Text prompt to display. Does not ghost write in |
minLen | Minimum length string to allow |
maxLen | Maximum length string to allow |
cb | Callback to trigger when the string is entered |
Definition at line 118 of file HUD.cpp.
◆ getQty()
void core::system::HUD::getQty |
( |
const std::string & |
prompt, |
|
|
int |
minQty, |
|
|
int |
maxQty, |
|
|
const QtyCallback & |
cb |
|
) |
| |
Gets a number from the player.
- Parameters
-
prompt | Text to prompt the player with |
minQty | The minimum number to accept |
maxQty | The maximum number to accept |
cb | Callback to call with the selected number |
Definition at line 124 of file HUD.cpp.
◆ hideEntryCard()
void core::system::HUD::hideEntryCard |
( |
| ) |
|
Hides the entry card.
Definition at line 131 of file HUD.cpp.
◆ promptUser()
void core::system::HUD::promptUser |
( |
const std::string & |
prompt, |
|
|
const std::vector< std::string > & |
choices, |
|
|
const Callback & |
cb |
|
) |
| |
Asks the player a question through the HUD.
- Parameters
-
prompt | The question to ask |
choices | The available choices the player can make |
cb | The callback to issue with the choice that was chosen when the player chooses |
Definition at line 112 of file HUD.cpp.
The documentation for this class was generated from the following files: