$treeview $search $mathjax
Stratagus  2.2.6
$projectbrief
$projectbrief
$searchbox
-->
         _________ __                 __
        /   _____//  |_____________ _/  |______     ____  __ __  ______
        \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
        /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
       /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
               \/                  \/          \//_____/            \/
    ______________________                           ______________________
                          T H E   W A R   B E G I N S
           Stratagus - A free fantasy real time strategy game engine

src/video/font.cpp File Reference

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "stratagus.h"
#include <string>
#include <vector>
#include <map>
#include "video.h"
#include "font.h"
#include "script.h"
#include "intern_video.h"

font.cpp - The color fonts.

static std::vector< CFont * > AllFonts
static std::map< std::string,
CFont * > 
Fonts
 Vector of all fonts.
static std::vector< CFontColor * > AllFontColors
 Font mappings.
std::map< std::string,
CFontColor * > 
FontColors
 Vector of all font colors.
static CFontColorFontColor
 Map of ident to font color.
static CFontColorLastTextColor
 Current font color.
static CFontColorDefaultTextColor
 Last text color.
static CFontColorReverseTextColor
 Default text color.
static std::string DefaultNormalColorIndex
 Reverse text color.
static std::string DefaultReverseColorIndex
 Default normal color index.
static std::map< const CFont
*, std::map< const CFontColor
*, CGraphic * > > 
FontColorGraphics
 Default reverse color index.
static CFontSmallFont
static CFontGameFont
 Small font used in stats.
static int FormatNumber (int number, char *buf)
 Normal font used in game.
CFontGetSmallFont ()
CFontGetGameFont ()
 Small font used in stats.
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)
 Normal font used in game.
void GetDefaultTextColors (std::string &normalp, std::string &reversep)
 Get the default text colors for normal and reverse text.
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.
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, CFont *font)
std::string GetLineFont (unsigned int line, const std::string &s, unsigned int maxlen, CFont *font)
 Return the 'line' line of the string 's'.
void LoadFonts ()
 Load and initialize the fonts.
void FreeOpenGLFonts ()
 Free OpenGL fonts.
void ReloadFonts ()
 Reload OpenGL fonts.
void CleanFonts ()
 Cleanup the font module.

Function Documentation

void CleanFonts (  ) 

Cleanup the font module.

Clean up the font module.

int convertKey ( const char *  key  ) 

static int FormatNumber ( int  number,
char *  buf 
) [static]

Normal font used in game.

Format a number using commas

Parameters:
number Number to be formatted
buf Buffer to save the formatted number to
Returns:
The real length of the Formated Number.

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.

Parameters:
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,
CFont font 
)

Return the 'line' line of the string 's'.

Return the 'line' line of the string 's'.

Parameters:
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.
Returns:
computed value.

CFont* GetSmallFont (  ) 

Font selector for the font functions. FIXME: should be moved to lua

static bool GetUTF8 ( const char  text[],
const size_t  len,
size_t &  pos,
int &  utf8 
) [inline, static]

Get the next utf8 character from a array of chars

static bool GetUTF8 ( const std::string &  text,
size_t &  pos,
int &  utf8 
) [static]

Get the next utf8 character from a string

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 
)

Normal font used in game.

Set the default text colors.

Parameters:
normal Normal text color.
reverse Reverse text color.

static int strchrlen ( const std::string &  s,
char  c,
unsigned int  maxlen,
CFont font 
) [static]

Return the index of first occurance of c in [s- s + maxlen]

Parameters:
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.
Returns:
computed value.

static void VideoDrawChar ( const CGraphic g,
int  gx,
int  gy,
int  w,
int  h,
int  x,
int  y,
const CFontColor fc 
) [static]

Draw character with current color.

Parameters:
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 void VideoDrawCharClip ( const CGraphic g,
int  gx,
int  gy,
int  w,
int  h,
int  x,
int  y,
const CFontColor fc 
) [static]

Draw character with current color clipped into 8 bit framebuffer.

Parameters:
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


Variable Documentation

std::vector<CFontColor *> AllFontColors [static]

Font mappings.

std::vector<CFont *> AllFonts [static]

std::string DefaultNormalColorIndex [static]

Reverse text color.

std::string DefaultReverseColorIndex [static]

Default normal color index.

Last text color.

CFontColor* FontColor [static]

Map of ident to font color.

std::map< const CFont *, std::map<const CFontColor *, CGraphic *> > FontColorGraphics [static]

Default reverse color index.

Font color graphics Usage: FontColorGraphics[CFont *font][CFontColor *color]

std::map<std::string, CFontColor *> FontColors

Vector of all font colors.

std::map<std::string, CFont *> Fonts [static]

Vector of all fonts.

CFont* GameFont [static]

Small font used in stats.

Current font color.

Default text color.

CFont* SmallFont [static]

(C) Copyright 1998-2011 by The Stratagus Project under the GNU General Public License.
All trademarks and copyrights on this page are owned by their respective owners.