Stores a conversation that an NPC or trainer can have with the player.
More...
#include <Conversation.hpp>
|
class | Node |
| Building block of conversations. A conversation is a tree of nodes and each node is an action that happens in the conversation. More...
|
|
|
| Conversation ()=default |
| Creates an empty conversation. More...
|
|
bool | load (const std::string &file) |
| Loads the conversation from the given file. More...
|
|
bool | loadDev (std::istream &input) |
| Loads the conversation from its json format. More...
|
|
bool | loadProd (bl::serial::binary::InputStream &input) |
| Loads the conversation from its binary format. More...
|
|
bool | save (const std::string &file) const |
| Saves the conversation to the given file. More...
|
|
bool | saveBundle (bl::serial::binary::OutputStream &output, bl::resource::bundle::FileHandlerContext &ctx) const |
| Saves the data from this object to the given bundle and registers depency files if any. More...
|
|
const std::vector< Node > & | nodes () const |
| Returns the list of nodes in the conversation. More...
|
|
void | deleteNode (unsigned int i) |
| Deletes the node at the given index. Jump indexes for other nodes are updated if affected. Jumps to node i are invalidated and will terminate the conversation. More...
|
|
void | appendNode (const Node &node) |
| Appends the given node to the list of nodes. More...
|
|
void | setNode (unsigned int i, const Node &node) |
| Updates the value of the node at the given index. More...
|
|
|
static Conversation | makeLoadError (const std::string &filename) |
| Helper function to create a conversation that reports an error if in debug mode. More...
|
|
static void | getNextJumps (const Node &node, std::vector< unsigned int > &jumps) |
| Populates the jumps vector with the indices reachable from the given node. More...
|
|
Stores a conversation that an NPC or trainer can have with the player.
Definition at line 22 of file Conversation.hpp.
◆ Conversation()
core::file::Conversation::Conversation |
( |
| ) |
|
|
default |
Creates an empty conversation.
◆ appendNode()
void core::file::Conversation::appendNode |
( |
const Node & |
node | ) |
|
Appends the given node to the list of nodes.
- Parameters
-
Definition at line 93 of file Conversation.cpp.
◆ deleteNode()
void core::file::Conversation::deleteNode |
( |
unsigned int |
i | ) |
|
Deletes the node at the given index. Jump indexes for other nodes are updated if affected. Jumps to node i are invalidated and will terminate the conversation.
- Parameters
-
i | The index to erase the node at |
Definition at line 85 of file Conversation.cpp.
◆ getNextJumps()
void core::file::Conversation::getNextJumps |
( |
const Node & |
node, |
|
|
std::vector< unsigned int > & |
jumps |
|
) |
| |
|
static |
Populates the jumps vector with the indices reachable from the given node.
- Parameters
-
node | The node to get the jumps for |
jumps | The result vector to populate |
Definition at line 263 of file Conversation.cpp.
◆ load()
bool core::file::Conversation::load |
( |
const std::string & |
file | ) |
|
Loads the conversation from the given file.
- Parameters
-
file | The file to load from. This should be relative to the conversation path |
- Returns
- True if loaded, false on error
Definition at line 61 of file Conversation.cpp.
◆ loadDev()
bool core::file::Conversation::loadDev |
( |
std::istream & |
input | ) |
|
Loads the conversation from its json format.
- Parameters
-
input | The input stream to process |
- Returns
- True if the conversation was loaded, false otherwise
Definition at line 65 of file Conversation.cpp.
◆ loadProd()
bool core::file::Conversation::loadProd |
( |
bl::serial::binary::InputStream & |
input | ) |
|
Loads the conversation from its binary format.
- Parameters
-
input | The input stream to process |
- Returns
- True if the conversation was loaded, false otherwise
Definition at line 69 of file Conversation.cpp.
◆ makeLoadError()
Conversation core::file::Conversation::makeLoadError |
( |
const std::string & |
filename | ) |
|
|
static |
Helper function to create a conversation that reports an error if in debug mode.
- Parameters
-
filename | The file that failed to load |
- Returns
- Conversation The conversation that reports the error
Definition at line 222 of file Conversation.cpp.
◆ nodes()
Returns the list of nodes in the conversation.
Definition at line 83 of file Conversation.cpp.
◆ save()
bool core::file::Conversation::save |
( |
const std::string & |
file | ) |
const |
Saves the conversation to the given file.
- Parameters
-
file | The file to save to, relative to the conversation path |
- Returns
- True if saved, false on error
Definition at line 73 of file Conversation.cpp.
◆ saveBundle()
bool core::file::Conversation::saveBundle |
( |
bl::serial::binary::OutputStream & |
output, |
|
|
bl::resource::bundle::FileHandlerContext & |
ctx |
|
) |
| const |
Saves the data from this object to the given bundle and registers depency files if any.
- Parameters
-
output | Stream to output to |
ctx | Context to register dependencies with |
- Returns
- True if serialization succeeded, false otherwise
Definition at line 78 of file Conversation.cpp.
◆ setNode()
void core::file::Conversation::setNode |
( |
unsigned int |
i, |
|
|
const Node & |
node |
|
) |
| |
Updates the value of the node at the given index.
- Parameters
-
i | The index to update |
node | The new node value |
Definition at line 95 of file Conversation.cpp.
◆ bl::serial::SerializableObject< Conversation >
friend struct bl::serial::SerializableObject< Conversation > |
|
friend |
The documentation for this class was generated from the following files: