V-Gears 0
Free Final Fantasy VII engine.
TextHandler.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2022 The V-Gears Team
3 *
4 * This file is part of V-Gears
5 *
6 * V-Gears is free software: you can redistribute it and/or modify it under
7 * terms of the GNU General Public License as published by the Free Software
8 * Foundation, version 3.0 (GPLv3) of the License.
9 *
10 * V-Gears is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#pragma once
17
18#include <OgreString.h>
19#include <OgreSingleton.h>
20#include <tinyxml.h>
21
25class TextHandler : public Ogre::Singleton<TextHandler>{
26
27 public:
28
33
37 virtual ~TextHandler();
38
42 void InitCmd();
43
49 void LoadFieldText(const std::string field_name);
50
57 void SetLanguage(const Ogre::String& language);
58
65
72 void AddText(const Ogre::String& name, TiXmlNode* node);
73
82 void AddDialog(
83 const Ogre::String& name, TiXmlNode* node, const float width, const float height
84 );
85
92 TiXmlNode* GetText(const Ogre::String& name) const;
93
104 TiXmlNode* GetDialog(const Ogre::String& name, float &width, float& height) const;
105
112 std::string GetDialogText(const std::string name);
113
117 void UnloadTexts();
118
126 std::string GetCharacterName(int id);
127
136 std::string GetPartyCharacterName(int position);
137
144 void SetCharacterName(int id, char* name);
145
153 void SetParty(int char_1, int char_2, int char_3);
154
160 std::vector<int> GetParty();
161
162 private:
163
168
172 struct Text{
173
178
182 TiXmlNode* node;
183 };
184
188 std::vector<Text> texts_;
189
193 struct Dialog{
194
199
203 TiXmlNode* node;
204
208 float width;
209
213 float height;
214 };
215
219 std::vector<Dialog> dialogs_;
220
227 std::string character_names_[11];
228
237};
238
float * position
Used to keep track of the skeleton and it's bones positions.
Definition: DrawSkeleton.cpp:33
The text handler.
Definition: TextHandler.h:25
void AddText(const Ogre::String &name, TiXmlNode *node)
Adds text.
Definition: TextHandler.cpp:50
std::string GetPartyCharacterName(int position)
Retrieves a character name from it's party position.
Definition: TextHandler.cpp:108
std::vector< Dialog > dialogs_
The list of dialogs in the handler.
Definition: TextHandler.h:219
virtual ~TextHandler()
Destructor.
Definition: TextHandler.cpp:34
void AddDialog(const Ogre::String &name, TiXmlNode *node, const float width, const float height)
Adds a text dialog.
Definition: TextHandler.cpp:57
std::string GetCharacterName(int id)
Retrieves a character name from it's ID.
Definition: TextHandler.cpp:103
std::string character_names_[11]
Character names, indexed by character IDs.
Definition: TextHandler.h:227
TiXmlNode * GetDialog(const Ogre::String &name, float &width, float &height) const
Retrieves a dialog and it's dimensions by name.
Definition: TextHandler.cpp:75
TextHandler()
Constructor.
Definition: TextHandler.cpp:28
std::vector< Text > texts_
The list of texts in the handler.
Definition: TextHandler.h:188
void UnloadTexts()
Deletes all texts in the handler.
Definition: TextHandler.cpp:96
const Ogre::String & GetLanguage()
Retrieves the currently set language.
Definition: TextHandler.cpp:48
void InitCmd()
Initializes the commands for the text handler.
Definition: TextHandlerCommands.h:50
void SetParty(int char_1, int char_2, int char_3)
Sets the party member IDs.
Definition: TextHandler.cpp:121
void SetCharacterName(int id, char *name)
Sets a character name.
Definition: TextHandler.cpp:116
std::string GetDialogText(const std::string name)
Retrieves a dialog text by name.
Definition: TextHandler.cpp:86
TiXmlNode * GetText(const Ogre::String &name) const
Retrieves a text by name.
Definition: TextHandler.cpp:68
std::vector< int > GetParty()
Retrieves the party member IDs.
Definition: TextHandler.cpp:127
void SetLanguage(const Ogre::String &language)
Sets the language for texts.
Definition: TextHandler.cpp:41
Ogre::String language_
The language for the texts.
Definition: TextHandler.h:167
int current_party_[3]
Current party formation.
Definition: TextHandler.h:236
void LoadFieldText(const std::string field_name)
Loads texts for a specific field.
Definition: TextHandler.cpp:36
Ogre::String String
Definition: TypeDefine.h:37
A dialog.
Definition: TextHandler.h:193
float width
The text width.
Definition: TextHandler.h:208
float height
The text height.
Definition: TextHandler.h:213
TiXmlNode * node
Text node in an XML file.
Definition: TextHandler.h:203
Ogre::String name
Name or identifier of the text.
Definition: TextHandler.h:198
A text.
Definition: TextHandler.h:172
Ogre::String name
Name or identifier of the text.
Definition: TextHandler.h:177
TiXmlNode * node
Text node in an XML file.
Definition: TextHandler.h:182