2012-01-21 21:57:41 +01:00
|
|
|
|
|
|
|
#ifndef __TEXT_HPP
|
|
|
|
#define __TEXT_HPP
|
|
|
|
|
2012-05-06 14:03:43 +02:00
|
|
|
#include <vector>
|
2012-01-21 21:57:41 +01:00
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include "FreeTypeGX.h"
|
|
|
|
#include "video.hpp"
|
2012-08-05 15:48:15 +02:00
|
|
|
#include "wstringEx/wstringEx.hpp"
|
2012-01-21 21:57:41 +01:00
|
|
|
|
2012-05-06 14:03:43 +02:00
|
|
|
using namespace std;
|
|
|
|
|
2012-11-03 20:16:03 +01:00
|
|
|
class SFont
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2012-11-03 20:16:03 +01:00
|
|
|
public:
|
|
|
|
SFont(void) : font(NULL), lineSpacing(0), weight(0), index(0), data(NULL), dataSize(0) { }
|
|
|
|
~SFont(void) { };
|
|
|
|
void ClearData(void);
|
|
|
|
bool fromBuffer(const u8 *buffer, const u32 bufferSize, u32 size, u32 lspacing, u32 w = 0, u32 idx = 0, const char *genKey = NULL);
|
|
|
|
bool fromFile(const char *filename, u32 size, u32 lspacing, u32 w = 0, u32 idx = 0);
|
|
|
|
FreeTypeGX *font;
|
2012-01-21 21:57:41 +01:00
|
|
|
u32 lineSpacing;
|
|
|
|
u32 weight;
|
|
|
|
u32 index;
|
2012-11-03 20:16:03 +01:00
|
|
|
private:
|
|
|
|
u8 *data;
|
|
|
|
size_t dataSize;
|
2012-01-21 21:57:41 +01:00
|
|
|
};
|
|
|
|
|
2013-01-21 00:30:28 +01:00
|
|
|
struct SWord
|
|
|
|
{
|
|
|
|
wstringEx text;
|
|
|
|
Vector3D pos;
|
|
|
|
Vector3D targetPos;
|
|
|
|
};
|
|
|
|
typedef vector<SWord> CLine;
|
|
|
|
|
2012-01-21 21:57:41 +01:00
|
|
|
class CText
|
|
|
|
{
|
|
|
|
public:
|
2012-11-03 20:16:03 +01:00
|
|
|
void setText(const SFont &font, const wstringEx &t);
|
|
|
|
void setText(const SFont &font, const wstringEx &t, u32 startline);
|
2012-01-21 21:57:41 +01:00
|
|
|
void setColor(const CColor &c);
|
|
|
|
void setFrame(float width, u16 style, bool ignoreNewlines = false, bool instant = false);
|
|
|
|
void tick(void);
|
|
|
|
void draw(void);
|
|
|
|
int getTotalHeight();
|
|
|
|
private:
|
2012-05-06 14:03:43 +02:00
|
|
|
vector<CLine> m_lines;
|
2012-01-21 21:57:41 +01:00
|
|
|
SFont m_font;
|
|
|
|
CColor m_color;
|
|
|
|
u32 firstLine;
|
|
|
|
u32 totalHeight;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Nothing to do with CText. Q&D helpers for string formating.
|
2012-05-04 14:30:43 +02:00
|
|
|
|
|
|
|
enum {
|
2012-05-06 14:59:09 +02:00
|
|
|
MAX_MSG_SIZE = 1024,
|
2012-09-23 14:10:25 +02:00
|
|
|
MAX_USES = 8,
|
2012-05-04 14:30:43 +02:00
|
|
|
};
|
|
|
|
|
2012-10-10 16:03:04 +02:00
|
|
|
char *fmt(const char *format, ...);
|
2012-01-21 21:57:41 +01:00
|
|
|
std::string sfmt(const char *format, ...);
|
|
|
|
wstringEx wfmt(const wstringEx &format, ...);
|
|
|
|
bool checkFmt(const wstringEx &ref, const wstringEx &format);
|
2012-05-06 14:03:43 +02:00
|
|
|
std::string vectorToString(const vector<std::string> &vect, std::string sep);
|
|
|
|
wstringEx vectorToString(const vector<wstringEx> &vect, char sep);
|
|
|
|
vector<wstringEx> stringToVector(const wstringEx &text, char sep);
|
|
|
|
vector<std::string> stringToVector(const std::string &text, char sep);
|
2012-01-21 21:57:41 +01:00
|
|
|
std::string upperCase(std::string text);
|
|
|
|
std::string lowerCase(std::string text);
|
|
|
|
std::string ltrim(std::string s);
|
|
|
|
std::string rtrim(std::string s);
|
|
|
|
void Asciify( wchar_t *str );
|
2012-02-17 03:35:42 +01:00
|
|
|
void Asciify2( char *str );
|
2012-01-21 21:57:41 +01:00
|
|
|
|
|
|
|
#endif // !defined(__TEXT_HPP)
|