V-Gears 0
Free Final Fantasy VII engine.
TextHandler Class Reference

The text handler. More...

#include <TextHandler.h>

Inheritance diagram for TextHandler:
Collaboration diagram for TextHandler:

Classes

struct  Dialog
 A dialog. More...
 
struct  Text
 A text. More...
 

Public Member Functions

 TextHandler ()
 Constructor. More...
 
virtual ~TextHandler ()
 Destructor. More...
 
void InitCmd ()
 Initializes the commands for the text handler. More...
 
void LoadFieldText (const std::string field_name)
 Loads texts for a specific field. More...
 
void SetLanguage (const Ogre::String &language)
 Sets the language for texts. More...
 
const Ogre::String & GetLanguage ()
 Retrieves the currently set language. More...
 
void AddText (const Ogre::String &name, TiXmlNode *node)
 Adds text. More...
 
void AddDialog (const Ogre::String &name, TiXmlNode *node, const float width, const float height)
 Adds a text dialog. More...
 
TiXmlNode * GetText (const Ogre::String &name) const
 Retrieves a text by name. More...
 
TiXmlNode * GetDialog (const Ogre::String &name, float &width, float &height) const
 Retrieves a dialog and it's dimensions by name. More...
 
std::string GetDialogText (const std::string name)
 Retrieves a dialog text by name. More...
 
void UnloadTexts ()
 Deletes all texts in the handler. More...
 
std::string GetCharacterName (int id)
 Retrieves a character name from it's ID. More...
 
std::string GetPartyCharacterName (int position)
 Retrieves a character name from it's party position. More...
 
void SetCharacterName (int id, char *name)
 Sets a character name. More...
 
void SetParty (int char_1, int char_2, int char_3)
 Sets the party member IDs. More...
 
std::vector< int > GetParty ()
 Retrieves the party member IDs. More...
 

Private Attributes

Ogre::String language_
 The language for the texts. More...
 
std::vector< Texttexts_
 The list of texts in the handler. More...
 
std::vector< Dialogdialogs_
 The list of dialogs in the handler. More...
 
std::string character_names_ [11]
 Character names, indexed by character IDs. More...
 
int current_party_ [3]
 Current party formation. More...
 

Detailed Description

The text handler.

Constructor & Destructor Documentation

◆ TextHandler()

TextHandler::TextHandler ( )

Constructor.

◆ ~TextHandler()

TextHandler::~TextHandler ( )
virtual

Destructor.

Member Function Documentation

◆ AddDialog()

void TextHandler::AddDialog ( const Ogre::String &  name,
TiXmlNode *  node,
const float  width,
const float  height 
)

Adds a text dialog.

Parameters
[in]nameText name or identifier.
[in]nodeText node in an XML file.
[in]widthText width.
[in]heightText height.

◆ AddText()

void TextHandler::AddText ( const Ogre::String &  name,
TiXmlNode *  node 
)

Adds text.

Parameters
[in]nameText name or identifier.
[in]nodeText node in an XML file.

◆ GetCharacterName()

std::string TextHandler::GetCharacterName ( int  id)

Retrieves a character name from it's ID.

Parameters
[in]idID of the character.
Returns
The name of the character. If the character doesn't exist, "UNKNOWN_CHAR_" + id will be returned.

◆ GetDialog()

TiXmlNode * TextHandler::GetDialog ( const Ogre::String &  name,
float &  width,
float &  height 
) const

Retrieves a dialog and it's dimensions by name.

Parameters
[in]nameText name or identifier.
[out]widthThe text width will be saved here. It won't change if the dialog is not found.
[out]heightThe text height will be saved here. It won't change if the dialog is not found.
Returns
Text node in an XML file, or NULL if there is none.

◆ GetDialogText()

std::string TextHandler::GetDialogText ( const std::string  name)

Retrieves a dialog text by name.

Parameters
[in]nameText name or identifier.
Returns
Dialog text, an empty string if there is none by the specified ID.

◆ GetLanguage()

const Ogre::String & TextHandler::GetLanguage ( )

Retrieves the currently set language.

Returns
The current language.

◆ GetParty()

std::vector< int > TextHandler::GetParty ( )

Retrieves the party member IDs.

Returns
The list of party member IDs.

◆ GetPartyCharacterName()

std::string TextHandler::GetPartyCharacterName ( int  position)

Retrieves a character name from it's party position.

Parameters
[in]positionPosition in the party[1-3].
Returns
The name of the character in the party specified position. If an invalid position is supplied, "UNKNOWN_PARTY_POS_" + id will be returned. If the position is correct, but there is no character on it, an empty string will be returned.

◆ GetText()

TiXmlNode * TextHandler::GetText ( const Ogre::String &  name) const

Retrieves a text by name.

Parameters
[in]nameText name or identifier.
Returns
Text node in an XML file, or NULL if there is none.

◆ InitCmd()

void TextHandler::InitCmd ( )

Initializes the commands for the text handler.

◆ LoadFieldText()

void TextHandler::LoadFieldText ( const std::string  field_name)

Loads texts for a specific field.

Parameters
[in]field_nameName of the field.

◆ SetCharacterName()

void TextHandler::SetCharacterName ( int  id,
char *  name 
)

Sets a character name.

Parameters
[in]idCharacter ID.
[in]nameCharacter name.

◆ SetLanguage()

void TextHandler::SetLanguage ( const Ogre::String &  language)

Sets the language for texts.

Parameters
[in]languageLanguage identifier. Must be the name of one of the folders in the data/text/.

◆ SetParty()

void TextHandler::SetParty ( int  char_1,
int  char_2,
int  char_3 
)

Sets the party member IDs.

Parameters
[in]char_1First member id.
[in]char_2Second member id. -1 if not set.
[in]char_3Third member id. -1 if not set.

◆ UnloadTexts()

void TextHandler::UnloadTexts ( )

Deletes all texts in the handler.

Member Data Documentation

◆ character_names_

std::string TextHandler::character_names_[11]
private

Character names, indexed by character IDs.

Sometimes, character names must appear in texts. This must be refreshed on engine start and when a character name changes.

◆ current_party_

int TextHandler::current_party_[3]
private

Current party formation.

Sometimes, the name of a character in the party must appear in texts. This holds the current party member IDs (or -1 if the party is not full). It must be refreshed every time the party changes.

◆ dialogs_

std::vector<Dialog> TextHandler::dialogs_
private

The list of dialogs in the handler.

◆ language_

Ogre::String TextHandler::language_
private

The language for the texts.

◆ texts_

std::vector<Text> TextHandler::texts_
private

The list of texts in the handler.


The documentation for this class was generated from the following files: