____ _ __
/ __ )____ _____ | | / /___ ___________
/ __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
/ /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
/_____/\____/____/ |__/|__/\__,_/_/ /____/
A futuristic real-time strategy game.
This file is part of Bos Wars.
(C) Copyright 2001-2007 by the Bos Wars and Stratagus Project.
Distributed under the "GNU General Public License"
#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"
Go to the source code of this file.
Functions | |
| static void | VideoDrawChar (const CGraphic *g, int gx, int gy, int w, int h, int x, int y) |
| void | SetDefaultTextColors (const std::string &normal, const std::string &reverse) |
| < Set the default text colors for normal and reverse text | |
| void | GetDefaultTextColors (std::string &normalp, std::string &reversep) |
| Draw text unclipped. | |
| static bool | GetUTF8 (const std::string &text, size_t &pos, int &utf8) |
| int | convertKey (const char *key) |
| int | GetHotKey (const std::string &text) |
| Load and initialize the fonts. | |
| static void | VideoDrawCharClip (const CGraphic *g, int gx, int gy, int w, int h, int x, int y) |
| static int | DoDrawText (int x, int y, CFont *font, const std::string &text, bool clip) |
| int | VideoDrawText (int x, int y, CFont *font, const std::string &text) |
| Draw text unclipped. | |
| int | VideoDrawTextClip (int x, int y, CFont *font, const std::string &text) |
| Draw reverse text unclipped. | |
| int | VideoDrawReverseText (int x, int y, CFont *font, const std::string &text) |
| Draw reverse text clipped. | |
| int | VideoDrawReverseTextClip (int x, int y, CFont *font, const std::string &text) |
| Draw text centered and unclipped. | |
| int | VideoDrawTextCentered (int x, int y, CFont *font, const std::string &text) |
| Draw number unclipped. | |
| static void | FormatNumber (int number, char *buf) |
| int | VideoDrawNumber (int x, int y, CFont *font, int number) |
| Draw number clipped. | |
| int | VideoDrawNumberClip (int x, int y, CFont *font, int number) |
| Draw reverse number unclipped. | |
| int | VideoDrawReverseNumber (int x, int y, CFont *font, int number) |
| Draw reverse number clipped. | |
| int | VideoDrawReverseNumberClip (int x, int y, CFont *font, int number) |
| Get the hot key from a string. | |
| void | MakeFontColorTextures (CFont *font) |
| void | LoadFonts () |
| Free OpenGL fonts. | |
| void | FreeOpenGLFonts () |
| Reload OpenGL fonts. | |
| void | ReloadFonts () |
| Cleanup the font module. | |
| void | CleanFonts () |
Variables | |
| static std::vector< CFont * > | AllFonts |
| Vector of all fonts. | |
| static std::map< std::string, CFont * > | Fonts |
| Font mappings. | |
| static std::vector< CFontColor * > | AllFontColors |
| Vector of all font colors. | |
| std::map< std::string, CFontColor * > | FontColors |
| Map of ident to font color. | |
| static CFontColor * | FontColor |
| Current font color. | |
| static CFontColor * | LastTextColor |
| Last text color. | |
| static CFontColor * | DefaultTextColor |
| Default text color. | |
| static CFontColor * | ReverseTextColor |
| Reverse text color. | |
| static std::string | DefaultNormalColorIndex |
| Default normal color index. | |
| static std::string | DefaultReverseColorIndex |
| Default reverse color index. | |
| static std::map< CFont *, std::map< CFontColor *, CGraphic * > > | FontColorGraphics |
| CFont * | SmallFont |
| Small font used in stats. | |
| CFont * | GameFont |
| Normal font used in game. | |
| CFont * | LargeFont |
| Large font used in menus. | |
Definition in file font.cpp.
| void CleanFonts | ( | void | ) |
Clean up the font module.
Definition at line 902 of file font.cpp.
References AllFontColors, AllFonts, FontColorGraphics, FontColors, Fonts, int(), CGraphic::NumTextures, CGraphic::Textures, and UseOpenGL.
Referenced by CleanModules().
| int convertKey | ( | const char * | key | ) |
Definition at line 70 of file widget.cpp.
References gcn::SDLInput::convertKeyCharacter(), gcn::Key::getValue(), and Str2SdlKey().
Referenced by GetHotKey(), and gcn::Widget::setHotKey().
| static int DoDrawText | ( | int | x, | |
| int | y, | |||
| CFont * | font, | |||
| const std::string & | text, | |||
| bool | clip | |||
| ) | [static] |
Draw text with font at x,y clipped/unclipped.
~ is special prefix. ~~ is the ~ character self. ~! print next character reverse. ~< start reverse. ~> switch back to last used color.
| x | X screen position | |
| y | Y screen position | |
| font | Font number | |
| text | Text to be displayed. | |
| clip | Flag to clip the text. |
Definition at line 349 of file font.cpp.
References Assert, CFont::CharWidth, DebugPrint, FontColorGraphics, CFont::G, CFontColor::Get(), GetUTF8(), CGraphic::GraphicHeight, CGraphic::GraphicWidth, CGraphic::Height, int(), UseOpenGL, VideoDrawChar(), VideoDrawCharClip(), and CGraphic::Width.
Referenced by VideoDrawText(), and VideoDrawTextClip().
| static void FormatNumber | ( | int | number, | |
| char * | buf | |||
| ) | [static] |
Format a number using commas
| number | Number to be formatted | |
| buf | Buffer to save the formatted number to |
Definition at line 573 of file font.cpp.
References int(), and sprintf_s().
Referenced by VideoDrawNumber(), VideoDrawNumberClip(), VideoDrawReverseNumber(), and VideoDrawReverseNumberClip().
| void FreeOpenGLFonts | ( | ) |
Reload OpenGL fonts.
Free OpenGL fonts
Definition at line 774 of file font.cpp.
References AllFontColors, AllFonts, FontColorGraphics, CFont::G, int(), CGraphic::NumTextures, and CGraphic::Textures.
Referenced by CVideo::ResizeScreen().
| void GetDefaultTextColors | ( | std::string & | normalp, | |
| std::string & | reversep | |||
| ) |
Draw text unclipped.
Get the default text colors.
| normalp | Normal text color pointer. | |
| reversep | Reverse text color pointer. |
Definition at line 161 of file font.cpp.
References DefaultNormalColorIndex, and DefaultReverseColorIndex.
Referenced by DrawInfoPanelNoneSelected(), DrawMenuButton(), DrawPopup(), StartEditor(), and StartMap().
| int GetHotKey | ( | const std::string & | text | ) |
Load and initialize the fonts.
Get the hot key from a string
Definition at line 264 of file font.cpp.
References convertKey(), and GetUTF8().
Referenced by AddButton(), and ButtonWidget::ButtonWidget().
| static bool GetUTF8 | ( | const std::string & | text, | |
| size_t & | pos, | |||
| int & | utf8 | |||
| ) | [static] |
Get the next utf8 character from a string
Definition at line 170 of file font.cpp.
References DebugPrint.
Referenced by DoDrawText(), GetHotKey(), and CFont::Width().
| void LoadFonts | ( | ) |
Free OpenGL fonts.
Load all fonts.
Definition at line 750 of file font.cpp.
References AllFonts, CGraphic::File, CFont::G, CFont::Get(), int(), CGraphic::Load(), MakeFontColorTextures(), ShowLoadProgress(), and UseOpenGL.
Referenced by LoadGame(), LoadModules(), main1(), and PreMenuSetup().
| void MakeFontColorTextures | ( | CFont * | font | ) |
Make font bitmap.
| font | Font number |
Definition at line 714 of file font.cpp.
References AllFontColors, CFontColor::Colors, FontColorGraphics, CFont::G, CGraphic::GraphicHeight, CGraphic::GraphicWidth, CGraphic::Height, int(), MakeTexture(), MaxFontColors, CGraphic::NumFrames, CGraphic::Surface, and CGraphic::Width.
Referenced by LoadFonts(), and ReloadFonts().
| void ReloadFonts | ( | void | ) |
Cleanup the font module.
Reload OpenGL fonts
Definition at line 790 of file font.cpp.
References AllFontColors, AllFonts, FontColorGraphics, CFont::G, int(), MakeFontColorTextures(), and CGraphic::Textures.
Referenced by ReloadOpenGL().
| void SetDefaultTextColors | ( | const std::string & | normal, | |
| const std::string & | reverse | |||
| ) |
< Set the default text colors for normal and reverse text
Set the default text colors.
| normal | Normal text color. | |
| reverse | Reverse text color. |
Definition at line 147 of file font.cpp.
References DefaultNormalColorIndex, DefaultReverseColorIndex, and CFontColor::Get().
Referenced by CreateGame(), DrawInfoPanelNoneSelected(), DrawMenuButton(), DrawPopup(), LoadGame(), LoadModules(), main1(), PreMenuSetup(), StartEditor(), and StartMap().
| static void VideoDrawChar | ( | const CGraphic * | g, | |
| int | gx, | |||
| int | gy, | |||
| int | w, | |||
| int | h, | |||
| int | x, | |||
| int | y | |||
| ) | [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 |
Definition at line 127 of file font.cpp.
References CFontColor::Colors, CGraphic::DrawSub(), MaxFontColors, CGraphic::Surface, TheScreen, and UseOpenGL.
Referenced by DoDrawText(), and VideoDrawCharClip().
| static void VideoDrawCharClip | ( | const CGraphic * | g, | |
| int | gx, | |||
| int | gy, | |||
| int | w, | |||
| int | h, | |||
| int | x, | |||
| int | y | |||
| ) | [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 |
Definition at line 322 of file font.cpp.
References CLIP_RECTANGLE_OFS, and VideoDrawChar().
Referenced by DoDrawText().
| int VideoDrawNumber | ( | int | x, | |
| int | y, | |||
| CFont * | font, | |||
| int | number | |||
| ) |
Draw number clipped.
Draw number with font at x,y unclipped.
| x | X screen position | |
| y | Y screen position | |
| font | Font number | |
| number | Number to be displayed. |
Definition at line 601 of file font.cpp.
References FormatNumber(), int(), and VideoDrawText().
Referenced by DrawCosts(), DrawInfoPanelNoneSelected(), and DrawPopup().
| int VideoDrawNumberClip | ( | int | x, | |
| int | y, | |||
| CFont * | font, | |||
| int | number | |||
| ) |
Draw reverse number unclipped.
Draw number with font at x,y clipped.
| x | X screen position | |
| y | Y screen position | |
| font | Font number | |
| number | Number to be displayed. |
Definition at line 619 of file font.cpp.
References FormatNumber(), int(), and VideoDrawTextClip().
Referenced by DrawDecoration(), and Missile::DrawMissile().
| int VideoDrawReverseNumber | ( | int | x, | |
| int | y, | |||
| CFont * | font, | |||
| int | number | |||
| ) |
Draw reverse number clipped.
Draw reverse number with font at x,y unclipped.
| x | X screen position | |
| y | Y screen position | |
| font | Font number | |
| number | Number to be displayed. |
Definition at line 637 of file font.cpp.
References FormatNumber(), int(), and VideoDrawReverseText().
| int VideoDrawReverseNumberClip | ( | int | x, | |
| int | y, | |||
| CFont * | font, | |||
| int | number | |||
| ) |
Get the hot key from a string.
Draw reverse number with font at x,y clipped.
| x | X screen position | |
| y | Y screen position | |
| font | Font number | |
| number | Number to be displayed. |
Definition at line 655 of file font.cpp.
References FormatNumber(), int(), and VideoDrawReverseTextClip().
| int VideoDrawReverseText | ( | int | x, | |
| int | y, | |||
| CFont * | font, | |||
| const std::string & | text | |||
| ) |
Draw reverse text clipped.
Draw reverse text with font at x,y unclipped.
| x | X screen position | |
| y | Y screen position | |
| font | Font number | |
| text | Text to be displayed. |
Definition at line 511 of file font.cpp.
References VideoDrawText().
Referenced by VideoDrawReverseNumber().
| int VideoDrawReverseTextClip | ( | int | x, | |
| int | y, | |||
| CFont * | font, | |||
| const std::string & | text | |||
| ) |
Draw text centered and unclipped.
Draw reverse text with font at x,y clipped.
| x | X screen position | |
| y | Y screen position | |
| font | Font number | |
| text | Text to be displayed. |
Definition at line 534 of file font.cpp.
References VideoDrawTextClip().
Referenced by VideoDrawReverseNumberClip().
| int VideoDrawText | ( | int | x, | |
| int | y, | |||
| CFont * | font, | |||
| const std::string & | text | |||
| ) |
Draw text unclipped.
Draw text with font at x,y unclipped.
| x | X screen position | |
| y | Y screen position | |
| font | Font number | |
| text | Text to be displayed. |
Definition at line 477 of file font.cpp.
References DoDrawText().
Referenced by DrawInfoPanelMultipleSelected(), DrawInfoPanelNoneSelected(), DrawMenuButton(), DrawPlayers(), DrawPopup(), DrawResources(), DrawTimer(), DrawTrainingUnits(), DrawUnitStats(), ShowTitleImage(), VideoDrawNumber(), VideoDrawReverseText(), and VideoDrawTextCentered().
| int VideoDrawTextCentered | ( | int | x, | |
| int | y, | |||
| CFont * | font, | |||
| const std::string & | text | |||
| ) |
Draw number unclipped.
Draw text with font at x,y centered.
| x | X screen position | |
| y | Y screen position | |
| font | Font number | |
| text | Text to be displayed. |
Definition at line 557 of file font.cpp.
References VideoDrawText(), and CFont::Width().
Referenced by DrawCoordinates(), DrawMenuButton(), DrawPlayers(), DrawTrainingUnits(), DrawUnitInfo(), DrawUnitStats(), and ShowLoadProgress().
| int VideoDrawTextClip | ( | int | x, | |
| int | y, | |||
| CFont * | font, | |||
| const std::string & | text | |||
| ) |
Draw reverse text unclipped.
Draw text with font at x,y clipped.
| x | X screen position | |
| y | Y screen position | |
| font | Font number | |
| text | Text to be displayed. |
Definition at line 494 of file font.cpp.
References DoDrawText().
Referenced by CStatusLine::Draw(), DrawInformations(), MessagesDisplay::DrawMessages(), DrawPieMenu(), CFont::drawString(), VideoDrawNumberClip(), and VideoDrawReverseTextClip().
std::vector<CFontColor *> AllFontColors [static] |
Vector of all font colors.
Definition at line 58 of file font.cpp.
Referenced by CleanFonts(), FreeOpenGLFonts(), MakeFontColorTextures(), CFontColor::New(), and ReloadFonts().
Vector of all fonts.
Definition at line 55 of file font.cpp.
Referenced by CleanFonts(), FreeOpenGLFonts(), LoadFonts(), CFont::New(), and ReloadFonts().
std::string DefaultNormalColorIndex [static] |
Default normal color index.
Definition at line 66 of file font.cpp.
Referenced by GetDefaultTextColors(), and SetDefaultTextColors().
std::string DefaultReverseColorIndex [static] |
Default reverse color index.
Definition at line 67 of file font.cpp.
Referenced by GetDefaultTextColors(), and SetDefaultTextColors().
CFontColor* DefaultTextColor [static] |
CFontColor* FontColor [static] |
std::map<CFont *, std::map<CFontColor *, CGraphic *> > FontColorGraphics [static] |
Font color graphics Usage: FontColorGraphics[CFont *font][CFontColor *color]
Definition at line 73 of file font.cpp.
Referenced by CleanFonts(), DoDrawText(), FreeOpenGLFonts(), MakeFontColorTextures(), and ReloadFonts().
| std::map<std::string, CFontColor *> FontColors |
Map of ident to font color.
Definition at line 59 of file font.cpp.
Referenced by CleanFonts(), CFontColor::Get(), and CFontColor::New().
Font mappings.
Definition at line 56 of file font.cpp.
Referenced by CleanFonts(), CFont::Get(), and CFont::New().
Normal font used in game.
Definition at line 77 of file font.cpp.
Referenced by DrawCoordinates(), DrawCosts(), DrawDecoration(), DrawInfoPanelNoneSelected(), Missile::DrawMissile(), DrawPieMenu(), DrawPlayers(), DrawResources(), DrawUnitInfo(), DrawUnitStats(), and ShowLoadProgress().
CFontColor* LastTextColor [static] |
CFontColor* ReverseTextColor [static] |
Small font used in stats.
Font selector for the font functions. FIXME: should be moved to lua
Definition at line 76 of file font.cpp.
Referenced by DrawPlayers(), DrawPopup(), and DrawUnitInfo().
1.5.6