1 #ifndef JUGIMAP_GUI_TEXT_H
2 #define JUGIMAP_GUI_TEXT_H
11 #include "../utf8cpp/utf8.h"
14 #include "jmGuiCommon.h"
39 UnicodeString(
const std::string &_s);
41 void Set(
const std::string &_s);
42 void Append(
const std::string &_s);
43 void Append(
const UnicodeString &_us);
44 void Append(
int _code);
46 bool IsEmpty(){
return codes.empty(); }
47 int GetLength(){
return codes.size(); }
49 std::string ToStdString();
50 std::string ToStdString(
int _startIndex,
int _endIndex=-1);
53 std::vector<int> & GetCodes(){
return codes; }
56 std::vector<int>codes;
61 void VerifyAndFixUtf8string(std::string& str);
64 std::string GetSubstring(
const std::string &text,
int indexStart,
int indexEnd,
bool &endReached);
67 void GetStringUnicodes(
const std::string &text, std::vector<int> &unicodes);
70 int GetStringNumberOfCharacters(
const std::string &text);
84 std::string originalWord;
85 ColorRGBA color{255,255,255};
86 Font * font =
nullptr;
87 float fFontHeight = 1.0;
91 ColorRGBA buttonColor_CO{200,0,0};
110 Content content =
TEXT;
113 void UpdateSize(
bool _forceUpdate =
false);
135 currentColor = defaultColor;
136 currentFont = defaultFont;
137 currentIndent = defaultIndent;
138 currentTabSpacing = defaultTabSpacing;
159 bool Replace(
const std::string &_searchedWord,
const std::string &newWord);
166 bool Contains(
const std::string &_word,
bool compareWithOriginalWord =
false);
172 std::vector<TextSegmentWord*> &GetWords(){
return words; }
173 void SetWordSizesIfNeeded();
178 std::vector<TextSegmentWord*> words;
179 std::vector<Parameter> parameters;
183 static ColorRGBA defaultColor;
184 static Font *defaultFont;
185 static ColorRGBA currentColor;
186 static Font *currentFont;
187 static std::string currentButton;
188 static ColorRGBA currentButtonColor;
189 static ColorRGBA currentButtonColor_CO;
191 static int defaultIndent;
192 static int defaultTabSpacing;
193 static int currentIndent;
194 static int currentTabSpacing;
197 void ProcessAddingWord(TextSegmentWord *word, ColorsLibrary &colors, FontsLibrary &fonts);
232 std::vector<TextSegment*>TextSegments;
233 std::vector<Parameter> parameters;
299 std::vector<TextSegment*>TextSegments;
300 std::vector<TextSequence*>TextSequences;
303 void _ParseParametersIfDefined(std::string &text, std::vector<Parameter>&_parameters);
319 static std::string path;
320 static std::string pathPrefix;
350 std::vector<TextBook*>books;
bool AddTextSegment(TextSegment *_textSegment)
Add the given *_textSegment* to this text book.
Definition: jmGuiText.cpp:204
The ColorsLibrary defines storage for ColorRGBA objects.
Definition: jmColor.h:108
std::vector< TextSegment * > & GetTextSegments()
Returns a reference to the vector of stored text segments.
Definition: jmGuiText.h:223
std::vector< TextSegment * > & GetTextSegments()
Returns a reference to the vector of stored text segments.
Definition: jmGuiText.h:289
The TextSequence class defines a storage for text segments.
Definition: jmGuiText.h:209
TextSegment * GetTextSegmentFromBook(const std::string &_bookName, int _segmentID)
Returns a pointer link to the text segment within a book.
Definition: jmGuiText.cpp:941
int GetId()
Returns the identification number of this text segment.
Definition: jmGuiText.h:219
std::string GetName()
Returns the name of this text book.
Definition: jmGuiText.h:264
std::vector< Parameter > & GetParameters()
Returns a reference to the vector of stored custom parameter.
Definition: jmGuiText.h:150
void LoadContent(const std::string &_filePath, ColorsLibrary &_colors, FontsLibrary &_fonts)
Load text segments and text sequences from a text file.
Definition: jmGuiText.cpp:236
TextBook * CreateNewBook(const std::string &_bookName)
Create a new text book with the given *_bookName* and returns a pointer link.
Definition: jmGuiText.cpp:911
std::vector< Parameter > & GetParameters()
Returns a reference to the vector of stored custom parameters.
Definition: jmGuiText.h:227
bool Contains(const std::string &_word, bool compareWithOriginalWord=false)
Returns true if this text segment contain the given *_word*; otherwise it returns false.
Definition: jmGuiText.cpp:820
bool Replace(const std::string &_searchedWord, const std::string &newWord)
Replace the given word *_searchedWord* with the newWord.
Definition: jmGuiText.cpp:849
The TextLibrary class defines a storage for text books.
Definition: jmGuiText.h:316
bool AddTextSequence(TextSequence *_textSequence)
Add the given *_textSequence* to this text book.
Definition: jmGuiText.cpp:220
The TextSegment class defines a segment of text which can be accessed and displayed separatelly from ...
Definition: jmGuiText.h:125
~TextBook()
Destructor.
Definition: jmGuiText.cpp:194
The FontsLibrary class defines storage for Font objects.
Definition: jmFont.h:83
TextBook(const std::string &_name)
Constructor.
Definition: jmGuiText.h:252
The TextBook class defines a storage for text segments and text sequences.
Definition: jmGuiText.h:245
TextBook * FindBook(const std::string &_bookName)
Returns a pointer link to the text book with the given *_bookName*.
Definition: jmGuiText.cpp:928
Text sprite - TextSprite object.
int GetId()
Returns the identification number of this text segment.
Definition: jmGuiText.h:146
std::vector< TextSequence * > & GetTextSequences()
Returns a reference to the vector of stored text sequences.
Definition: jmGuiText.h:293