_________ __ __ / _____// |_____________ _/ |______ ____ __ __ ______ \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/ / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ \ /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ > \/ \/ \//_____/ \/ ______________________ ______________________ T H E W A R B E G I N S Stratagus - A free fantasy real time strategy game engine
#include "stratagus.h"
#include "font.h"
#include "intern_video.h"
#include "video.h"
#include <vector>
#include <map>
font.cpp - The color fonts. | |
typedef std::map< std::string, CFont * > | FontMap |
typedef std::map< std::string, CFontColor * > | FontColorMap |
Font mappings. More... | |
typedef std::map< const CFontColor *, CGraphic * > | FontColorGraphicMap |
Default reverse color index. More... | |
static FontMap | Fonts |
static FontColorMap | FontColors |
static CFontColor * | FontColor |
Map of ident to font color. More... | |
static const CFontColor * | LastTextColor |
Current font color. More... | |
static CFontColor * | DefaultTextColor |
Last text color. More... | |
static CFontColor * | ReverseTextColor |
Default text color. More... | |
static std::string | DefaultNormalColorIndex |
Reverse text color. More... | |
static std::string | DefaultReverseColorIndex |
Default normal color index. More... | |
static std::map< const CFont *, FontColorGraphicMap > | FontColorGraphics |
static CFont * | SmallFont |
static CFont * | GameFont |
Small font used in stats. More... | |
static int | FormatNumber (int number, char *buf) |
Normal font used in game. More... | |
CFont & | GetSmallFont () |
bool | IsGameFontReady () |
Normal font used in game. More... | |
CFont & | GetGameFont () |
Small font used in stats. More... | |
static void | VideoDrawChar (const CGraphic &g, int gx, int gy, int w, int h, int x, int y, const CFontColor &fc) |
void | SetDefaultTextColors (const std::string &normal, const std::string &reverse) |
true when GameFont is provided More... | |
void | GetDefaultTextColors (std::string &normalp, std::string &reversep) |
Get the default text colors for normal and reverse text. More... | |
static bool | GetUTF8 (const std::string &text, size_t &pos, int &utf8) |
static bool | GetUTF8 (const char text[], const size_t len, size_t &pos, int &utf8) |
int | convertKey (const char *key) |
int | GetHotKey (const std::string &text) |
Get the hot key from a string. More... | |
static void | VideoDrawCharClip (const CGraphic &g, int gx, int gy, int w, int h, int x, int y, const CFontColor &fc) |
static int | strchrlen (const std::string &s, char c, unsigned int maxlen, const CFont *font) |
std::string | GetLineFont (unsigned int line, const std::string &s, unsigned int maxlen, const CFont *font) |
Return the 'line' line of the string 's'. More... | |
void | LoadFonts () |
Load and initialize the fonts. More... | |
void | FreeOpenGLFonts () |
Free OpenGL fonts. More... | |
void | ReloadFonts () |
Reload OpenGL fonts. More... | |
void | CleanFonts () |
Cleanup the font module. More... | |
typedef std::map<const CFontColor *, CGraphic *> FontColorGraphicMap |
Default reverse color index.
Font color graphics Usage: FontColorGraphics[CFont *font][CFontColor *color]
typedef std::map<std::string, CFontColor *> FontColorMap |
Font mappings.
void CleanFonts | ( | ) |
Cleanup the font module.
Clean up the font module.
int convertKey | ( | const char * | key | ) |
|
static |
Normal font used in game.
Format a number using commas
number | Number to be formatted |
buf | Buffer to save the formatted number to |
void FreeOpenGLFonts | ( | ) |
Free OpenGL fonts.
Free OpenGL fonts
void GetDefaultTextColors | ( | std::string & | normalp, |
std::string & | reversep | ||
) |
Get the default text colors for normal and reverse text.
Get the default text colors.
normalp | Normal text color pointer. |
reversep | Reverse text color pointer. |
CFont& GetGameFont | ( | ) |
Small font used in stats.
int GetHotKey | ( | const std::string & | text | ) |
Get the hot key from a string.
Get the hot key from a string
std::string GetLineFont | ( | unsigned int | line, |
const std::string & | s, | ||
unsigned int | maxlen, | ||
const CFont * | font | ||
) |
Return the 'line' line of the string 's'.
Return the 'line' line of the string 's'.
line | line number. |
s | multiline string. |
maxlen | max length of the string (0 : unlimited) (in char if font == NULL else in pixels). |
font | if specified use font->Width() instead of strlen. |
CFont& GetSmallFont | ( | ) |
Font selector for the font functions. FIXME: should be moved to lua
|
static |
Get the next utf8 character from a string
|
static |
Get the next utf8 character from an array of chars
bool IsGameFontReady | ( | ) |
Normal font used in game.
void LoadFonts | ( | ) |
Load and initialize the fonts.
Load all fonts.
void ReloadFonts | ( | ) |
Reload OpenGL fonts.
Reload OpenGL fonts
void SetDefaultTextColors | ( | const std::string & | normal, |
const std::string & | reverse | ||
) |
true when GameFont is provided
Set the default text colors.
normal | Normal text color. |
reverse | Reverse text color. |
|
static |
Return the index of first occurrence of c in [s- s + maxlen]
s | original string. |
c | character to find. |
maxlen | size limit of the search. (0 means unlimited). (in char if font == NULL else in pixels). |
font | if specified use font->Width() instead of strlen. |
|
static |
Draw character with current color.
g | Pointer to object |
gx | X offset into object |
gy | Y offset into object |
w | width to display |
h | height to display |
x | X screen position |
y | Y screen position |
|
static |
Draw character with current color clipped into 8 bit framebuffer.
g | Pointer to object |
gx | X offset into object |
gy | Y offset into object |
w | width to display |
h | height to display |
x | X screen position |
y | Y screen position |
|
static |
Reverse text color.
|
static |
Default normal color index.
|
static |
Last text color.
|
static |
Map of ident to font color.
|
static |
|
static |
|
static |
|
static |
Small font used in stats.
|
static |
Current font color.
|
static |
Default text color.
|
static |