Peoplemon  0.1.0
Peoplemon 3 game source documentation
Classes | Public Types | Public Member Functions | List of all members
core::system::HUD Class Reference

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>

+ Inheritance diagram for core::system::HUD:

Public Types

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...
 

Public Member Functions

 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...
 

Detailed Description

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.

Member Typedef Documentation

◆ Callback

using core::system::HUD::Callback = std::function<void(const std::string& value)>

Signature for HUD callbacks. Used for both messages completing and choices made.

Parameters
valueThe message that completed or the choice that was chosen

Definition at line 39 of file HUD.hpp.

◆ QtyCallback

using core::system::HUD::QtyCallback = std::function<void(int qty)>

Called when a qty is entered.

Parameters
qtyThe user selected qty

Definition at line 47 of file HUD.hpp.

Constructor & Destructor Documentation

◆ HUD()

core::system::HUD::HUD ( Systems owner)

Construct a new HUD system.

Parameters
ownerThe primary systems object

Definition at line 25 of file HUD.cpp.

◆ ~HUD()

virtual core::system::HUD::~HUD ( )
virtualdefault

Destroys the system.

Member Function Documentation

◆ dismissStickyMessage()

bool core::system::HUD::dismissStickyMessage ( bool  ignoreGhostWrite = true)

Dismisses the currently active sticky message.

Parameters
ignoreGhostWriteTrue 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
nameThe 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
messageThe message to display
cbCallback 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
messageThe message to display
ghostWriteTrue to display text char by char, false to show entire message at once
cbCallback 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
promptText prompt to display. Does not ghost write in
minLenMinimum length string to allow
maxLenMaximum length string to allow
cbCallback 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
promptText to prompt the player with
minQtyThe minimum number to accept
maxQtyThe maximum number to accept
cbCallback 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
promptThe question to ask
choicesThe available choices the player can make
cbThe 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: