Remove unused font (LargeFont, SmallFontTitle).
Replace global Font by accessor.
This commit is contained in:
parent
0a316c6464
commit
1c91eb3250
11 changed files with 62 additions and 52 deletions
|
@ -562,7 +562,7 @@ static void DrawPlayers()
|
|||
{
|
||||
int i;
|
||||
char buf[256];
|
||||
CLabel label(SmallFont);
|
||||
CLabel label(GetSmallFont());
|
||||
|
||||
int x = UI.InfoPanel.X + 8;
|
||||
int y = UI.InfoPanel.Y + 4 + IconHeight + 10;
|
||||
|
@ -613,7 +613,7 @@ static void DrawPlayers()
|
|||
strcat_s(buf, sizeof(buf), "Computer");
|
||||
break;
|
||||
}
|
||||
label.SetFont(GameFont);
|
||||
label.SetFont(GetGameFont());
|
||||
label.Draw(x, y, buf);
|
||||
}
|
||||
}
|
||||
|
@ -627,7 +627,7 @@ static void DrawPopup() {
|
|||
std::string nc, rc;
|
||||
GetDefaultTextColors(nc, rc);
|
||||
DrawPopupUnitInfo(Editor.ShownUnitTypes[Editor.CursorUnitIndex],
|
||||
Editor.SelectedPlayer, SmallFont,
|
||||
Editor.SelectedPlayer, GetSmallFont(),
|
||||
Video.MapRGB(TheScreen->format, 38, 38, 78),
|
||||
Editor.PopUpX, Editor.PopUpY);
|
||||
SetDefaultTextColors(nc, rc);
|
||||
|
@ -722,7 +722,7 @@ static void DrawTileIcon(unsigned tilenum, unsigned x, unsigned y, unsigned flag
|
|||
static void DrawTileIcons()
|
||||
{
|
||||
int i;
|
||||
CLabel label(GameFont);
|
||||
CLabel label(GetGameFont());
|
||||
int x = UI.InfoPanel.X + 46;
|
||||
int y = UI.InfoPanel.Y + 4 + IconHeight + 11;
|
||||
|
||||
|
@ -987,7 +987,7 @@ static void DrawEditorInfo()
|
|||
}
|
||||
|
||||
snprintf(buf, sizeof(buf),"Editor (%d %d)", x, y);
|
||||
VideoDrawText(UI.ResourceX + 2, UI.ResourceY + 2, GameFont, buf);
|
||||
VideoDrawText(UI.ResourceX + 2, UI.ResourceY + 2, GetGameFont(), buf);
|
||||
CMapField *mf = Map.Field(x, y);
|
||||
//
|
||||
// Flags info
|
||||
|
@ -1008,7 +1008,7 @@ static void DrawEditorInfo()
|
|||
flags & MapFieldAirUnit ? 'a' : '-',
|
||||
flags & MapFieldSeaUnit ? 's' : '-',
|
||||
flags & MapFieldBuilding ? 'b' : '-');
|
||||
VideoDrawText(UI.ResourceX + 118, UI.ResourceY + 2, GameFont, buf);
|
||||
VideoDrawText(UI.ResourceX + 118, UI.ResourceY + 2, GetGameFont(), buf);
|
||||
|
||||
//
|
||||
// Tile info
|
||||
|
@ -1029,7 +1029,7 @@ static void DrawEditorInfo()
|
|||
? Map.Tileset.SolidTerrainTypes[Map.Tileset.Tiles[i].MixTerrain].TerrainName
|
||||
: "");
|
||||
|
||||
VideoDrawText(UI.ResourceX + 252, UI.ResourceY + 2, GameFont, buf);
|
||||
VideoDrawText(UI.ResourceX + 252, UI.ResourceY + 2, GetGameFont(), buf);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -158,10 +158,8 @@ public:
|
|||
** Font selector for the font functions.
|
||||
** FIXME: should be moved to lua
|
||||
*/
|
||||
extern CFont *SmallFont; /// Small font used in stats
|
||||
extern CFont *GameFont; /// Normal font used in game
|
||||
extern CFont *LargeFont; /// Large font used in menus
|
||||
extern CFont *SmallTitleFont; /// Small font used in episoden titles
|
||||
extern CFont *GetSmallFont(); /// Small font used in stats
|
||||
extern CFont *GetGameFont(); /// Normal font used in game
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Functions
|
||||
|
|
|
@ -316,9 +316,9 @@ void CViewport::DrawMapBackgroundInViewport() const
|
|||
Video.DrawHLineClip(color, dx, dy, PixelTileSize.x);
|
||||
Video.DrawVLineClip(color, dx, dy, PixelTileSize.y);
|
||||
if ( 0 && my_mask ) {
|
||||
CLabel label(SmallFont);
|
||||
CLabel label(GetSmallFont());
|
||||
label.Draw(dx + 2, dy +2, tile);
|
||||
label.Draw(dx + 2, dy + SmallFont->Height() + 4,
|
||||
label.Draw(dx + 2, dy + GetSmallFont()->Height() + 4,
|
||||
Map.Fields[sx].TilesetTile );
|
||||
|
||||
}
|
||||
|
|
|
@ -557,8 +557,8 @@ void MissileDrawProxy::DrawMissile(const CViewport *vp) const
|
|||
const int y = this->Y - vp->MapY * PixelTileSize.y + vp->Y - vp->OffsetY;
|
||||
switch (this->Type->Class) {
|
||||
case MissileClassHit:
|
||||
CLabel(GameFont).DrawClip(x,y, this->data.Damage);
|
||||
//VideoDrawNumberClip(x, y, GameFont, this->data.Damage);
|
||||
CLabel(GetGameFont()).DrawClip(x,y, this->data.Damage);
|
||||
//VideoDrawNumberClip(x, y, GetGameFont(), this->data.Damage);
|
||||
break;
|
||||
default:
|
||||
this->Type->DrawMissileType(this->data.SpriteFrame, x, y);
|
||||
|
@ -596,7 +596,7 @@ void Missile::DrawMissile(const CViewport *vp) const
|
|||
const int y = this->position.y - vp->MapY * PixelTileSize.y + vp->Y - vp->OffsetY;
|
||||
switch (this->Type->Class) {
|
||||
case MissileClassHit:
|
||||
CLabel(GameFont).DrawClip(x, y, this->Damage);
|
||||
CLabel(GetGameFont()).DrawClip(x, y, this->Damage);
|
||||
break;
|
||||
default:
|
||||
this->Type->DrawMissileType(this->SpriteFrame, x, y);
|
||||
|
|
|
@ -289,7 +289,7 @@ void ShowLoadProgress(const char *fmt, ...)
|
|||
temp[sizeof(temp) - 1] = '\0';
|
||||
va_end(va);
|
||||
|
||||
if (Video.Depth && GameFont && GameFont->IsLoaded()) {
|
||||
if (Video.Depth && GetGameFont() && GetGameFont()->IsLoaded()) {
|
||||
DisplayAutoLocker autolock;
|
||||
// Remove non printable chars
|
||||
for (char *s = temp; *s; ++s) {
|
||||
|
@ -298,7 +298,7 @@ void ShowLoadProgress(const char *fmt, ...)
|
|||
}
|
||||
}
|
||||
Video.FillRectangle(ColorBlack, 5, Video.Height - 18, Video.Width - 10, 18);
|
||||
CLabel(GameFont).DrawCentered(Video.Width / 2, Video.Height - 16, temp);
|
||||
CLabel(GetGameFont()).DrawCentered(Video.Width / 2, Video.Height - 16, temp);
|
||||
InvalidateArea(5, Video.Height - 18, Video.Width - 10, 18);
|
||||
RealizeVideoMemory();
|
||||
} else {
|
||||
|
|
|
@ -133,7 +133,7 @@ static void ShowTitleImage(TitleScreen *t)
|
|||
timeout = -1;
|
||||
}
|
||||
|
||||
CLabel label(GameFont);
|
||||
CLabel label(GetGameFont());
|
||||
DisplayAutoLocker autolock;
|
||||
while (timeout-- && WaitNoEvent) {
|
||||
g->DrawClip((Video.Width - g->Width) / 2, (Video.Height - g->Height) / 2);
|
||||
|
|
|
@ -479,7 +479,7 @@ static void DrawPopup(const ButtonAction *button, const CUIButton *uibutton)
|
|||
//Uint32 backgroundColor = Video.MapRGB(TheScreen->format, 255, 255, 200);
|
||||
//Uint32 backgroundColor = Video.MapRGB(TheScreen->format, 255, 255, 255);
|
||||
Uint32 backgroundColor = Video.MapRGB(TheScreen->format, 38, 38, 78);
|
||||
CFont *font = SmallFont;
|
||||
CFont *font = GetSmallFont();
|
||||
const int font_height = font->Height();
|
||||
|
||||
int start_x, x, popupWidth;
|
||||
|
|
|
@ -567,7 +567,7 @@ static void DrawUnitInfo(CUnit &unit)
|
|||
int x;
|
||||
int y;
|
||||
CUnit *uins;
|
||||
CLabel label(GameFont);
|
||||
CLabel label(GetGameFont());
|
||||
|
||||
if (CPU_NUM == 1) {
|
||||
UpdateUnitVariables(unit);
|
||||
|
@ -741,7 +741,7 @@ void DrawResources()
|
|||
{
|
||||
int i;
|
||||
int v;
|
||||
CLabel label(GameFont);
|
||||
CLabel label(GetGameFont());
|
||||
|
||||
// Draw all icons of resource.
|
||||
for (i = 0; i <= ScoreCost; ++i) {
|
||||
|
@ -753,7 +753,7 @@ void DrawResources()
|
|||
for (i = 0; i < MaxCosts; ++i) {
|
||||
if (UI.Resources[i].TextX != -1) {
|
||||
v = ThisPlayer->Resources[i];
|
||||
label.SetFont(v > 99999 ? SmallFont : GameFont);
|
||||
label.SetFont(v > 99999 ? GetSmallFont() : GetGameFont());
|
||||
label.Draw(UI.Resources[i].TextX,
|
||||
UI.Resources[i].TextY + (v > 99999) * 3, v);
|
||||
}
|
||||
|
@ -761,7 +761,7 @@ void DrawResources()
|
|||
if (UI.Resources[FoodCost].TextX != -1) {
|
||||
char tmp[128];
|
||||
snprintf(tmp,sizeof(tmp), "%d/%d", ThisPlayer->Demand, ThisPlayer->Supply);
|
||||
label.SetFont(GameFont);
|
||||
label.SetFont(GetGameFont());
|
||||
if (ThisPlayer->Supply < ThisPlayer->Demand) {
|
||||
label.DrawReverse(UI.Resources[FoodCost].TextX,
|
||||
UI.Resources[FoodCost].TextY, tmp);
|
||||
|
@ -772,7 +772,7 @@ void DrawResources()
|
|||
}
|
||||
if (UI.Resources[ScoreCost].TextX != -1) {
|
||||
v = ThisPlayer->Score;
|
||||
label.SetFont(v > 99999 ? SmallFont : GameFont);
|
||||
label.SetFont(v > 99999 ? GetSmallFont() : GetGameFont());
|
||||
label.Draw(UI.Resources[ScoreCost].TextX,
|
||||
UI.Resources[ScoreCost].TextY + (v > 99999) * 3, v);
|
||||
}
|
||||
|
@ -1256,7 +1256,7 @@ static int Costs[MaxCosts + 1]; /// costs to display in status line
|
|||
void DrawCosts()
|
||||
{
|
||||
int x = UI.StatusLine.TextX + 268;
|
||||
CLabel label(GameFont);
|
||||
CLabel label(GetGameFont());
|
||||
if (CostsMana) {
|
||||
// FIXME: hardcoded image!!!
|
||||
UI.Resources[GoldCost].G->DrawFrameClip(3, x, UI.StatusLine.TextY);
|
||||
|
@ -1411,11 +1411,11 @@ void CInfoPanel::Draw()
|
|||
x = UI.InfoPanel.X + 16;
|
||||
y = UI.InfoPanel.Y + 8;
|
||||
|
||||
VideoDrawTextClip(x, y, GameFont, "Stratagus");
|
||||
VideoDrawTextClip(x, y, GetGameFont(), "Stratagus");
|
||||
y += 16;
|
||||
VideoDrawTextClip(x, y, GameFont, "Cycle:");
|
||||
VideoDrawNumberClip(x + 48, y, GameFont, GameCycle);
|
||||
VideoDrawNumberClip(x + 110, y, GameFont,
|
||||
VideoDrawTextClip(x, y, GetGameFont(), "Cycle:");
|
||||
VideoDrawNumberClip(x + 48, y, GetGameFont(), GameCycle);
|
||||
VideoDrawNumberClip(x + 110, y, GetGameFont(),
|
||||
CYCLES_PER_SECOND * VideoSyncSpeed / 100);
|
||||
y += 20;
|
||||
|
||||
|
@ -1430,13 +1430,13 @@ void CInfoPanel::Draw()
|
|||
SetDefaultTextColors(nc, rc);
|
||||
}
|
||||
|
||||
VideoDrawNumberClip(x + 15, y, GameFont, i);
|
||||
VideoDrawNumberClip(x + 15, y, GetGameFont(), i);
|
||||
|
||||
Video.DrawRectangleClip(ColorWhite,x, y, 12, 12);
|
||||
Video.FillRectangleClip(Players[i].Color, x + 1, y + 1, 10, 10);
|
||||
|
||||
VideoDrawTextClip(x + 27, y, GameFont,Players[i].Name);
|
||||
VideoDrawNumberClip(x + 117, y, GameFont,Players[i].Score);
|
||||
VideoDrawTextClip(x + 27, y, GetGameFont(),Players[i].Name);
|
||||
VideoDrawNumberClip(x + 117, y, GetGameFont(),Players[i].Score);
|
||||
y += 14;
|
||||
}
|
||||
}
|
||||
|
@ -1501,7 +1501,7 @@ static void DrawInfoPanelNoneSelected()
|
|||
std::string rc;
|
||||
int x = UI.InfoPanel.X + 16;
|
||||
int y = UI.InfoPanel.Y + 8;
|
||||
CLabel label(GameFont);
|
||||
CLabel label(GetGameFont());
|
||||
|
||||
label.Draw(x,y, "Stratagus");
|
||||
y += 16;
|
||||
|
@ -1510,7 +1510,7 @@ static void DrawInfoPanelNoneSelected()
|
|||
label.Draw(x + 110, y, CYCLES_PER_SECOND * VideoSyncSpeed / 100);
|
||||
y += 20;
|
||||
|
||||
if( y + PlayerMax * GameFont->Height() > Video.Height )
|
||||
if( y + PlayerMax * GetGameFont()->Height() > Video.Height )
|
||||
{
|
||||
x = 16;
|
||||
y = 30;
|
||||
|
|
|
@ -2047,7 +2047,7 @@ void DrawPieMenu()
|
|||
return;
|
||||
}
|
||||
ButtonActionProxy buttons(CurrentButtons);
|
||||
CLabel label(GameFont);
|
||||
CLabel label(GetGameFont());
|
||||
CViewport *vp = UI.SelectedViewport;
|
||||
PushClipping();
|
||||
SetClipping(vp->X, vp->Y, vp->EndX, vp->EndY);
|
||||
|
|
|
@ -486,7 +486,7 @@ void CDecoVarText::Draw(int x, int y,
|
|||
const CUnitType *, const CVariable &Variable) const
|
||||
{
|
||||
if (this->IsCenteredInX) {
|
||||
x -= 2; // GameFont->Width(buf) / 2, with buf = str(Value)
|
||||
x -= 2; // GetGameFont()->Width(buf) / 2, with buf = str(Value)
|
||||
}
|
||||
if (this->IsCenteredInY) {
|
||||
y -= this->Font->Height() / 2;
|
||||
|
@ -575,7 +575,7 @@ static void DrawDecoration(const CUnit &unit, const CUnitType *type, int x, int
|
|||
//
|
||||
// Show the number of references.
|
||||
//
|
||||
VideoDrawNumberClip(x + 1, y + 1, GameFont, unit.Refs);
|
||||
VideoDrawNumberClip(x + 1, y + 1, GetGameFont(), unit.Refs);
|
||||
#endif
|
||||
|
||||
UpdateUnitVariables(unit);
|
||||
|
@ -615,11 +615,11 @@ static void DrawDecoration(const CUnit &unit, const CUnitType *type, int x, int
|
|||
int groupId = 0;
|
||||
for (groupId = 0; !(unit.GroupId & (1 << groupId)); ++groupId)
|
||||
;
|
||||
int width = GameFont->Width(groupId);
|
||||
int width = GetGameFont()->Width(groupId);
|
||||
x += (unit.Type->TileWidth * PixelTileSize.x + unit.Type->BoxWidth) / 2 - width;
|
||||
width = GameFont->Height();
|
||||
width = GetGameFont()->Height();
|
||||
y += (unit.Type->TileHeight * PixelTileSize.y + unit.Type->BoxHeight) / 2 - width;
|
||||
CLabel(GameFont).DrawClip(x, y, groupId);
|
||||
CLabel(GetGameFont()).DrawClip(x, y, groupId);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1340,11 +1340,11 @@ void CUnitDrawProxy::DrawDecorationAt(int x, int y) const
|
|||
&& Player == ThisPlayer
|
||||
#endif
|
||||
) {
|
||||
int width = GameFont->Width(GroupId - 1);
|
||||
int width = GetGameFont()->Width(GroupId - 1);
|
||||
x += (Type->TileWidth * PixelTileSize.x + Type->BoxWidth) / 2 - width;
|
||||
width = GameFont->Height();
|
||||
width = GetGameFont()->Height();
|
||||
y += (Type->TileHeight * PixelTileSize.y + Type->BoxHeight) / 2 - width;
|
||||
CLabel(GameFont).DrawClip(x, y, GroupId - 1);
|
||||
CLabel(GetGameFont()).DrawClip(x, y, GroupId - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -75,13 +75,29 @@ static std::string DefaultReverseColorIndex; /// Default reverse color index
|
|||
static std::map< const CFont *, std::map<const CFontColor *, CGraphic *> > FontColorGraphics;
|
||||
|
||||
// FIXME: remove these
|
||||
CFont *SmallFont; /// Small font used in stats
|
||||
CFont *GameFont; /// Normal font used in game
|
||||
CFont *LargeFont; /// Large font used in menus
|
||||
CFont *SmallTitleFont; /// Small font used in episoden titles
|
||||
static CFont *SmallFont; /// Small font used in stats
|
||||
static CFont *GameFont; /// Normal font used in game
|
||||
|
||||
static int FormatNumber(int number, char *buf);
|
||||
|
||||
|
||||
CFont *GetSmallFont()
|
||||
{
|
||||
if (!SmallFont) {
|
||||
SmallFont = CFont::Get("small");
|
||||
}
|
||||
return SmallFont;
|
||||
}
|
||||
|
||||
CFont *GetGameFont()
|
||||
{
|
||||
if (!GameFont) {
|
||||
GameFont = CFont::Get("game");
|
||||
}
|
||||
return GameFont;
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Guichan Functions
|
||||
----------------------------------------------------------------------------*/
|
||||
|
@ -866,8 +882,6 @@ void LoadFonts()
|
|||
// TODO: remove this
|
||||
SmallFont = CFont::Get("small");
|
||||
GameFont = CFont::Get("game");
|
||||
LargeFont = CFont::Get("large");
|
||||
SmallTitleFont = CFont::Get("small-title");
|
||||
}
|
||||
|
||||
void CFont::FreeOpenGL()
|
||||
|
@ -1056,8 +1070,6 @@ void CleanFonts()
|
|||
|
||||
SmallFont = NULL;
|
||||
GameFont = NULL;
|
||||
LargeFont = NULL;
|
||||
SmallTitleFont = NULL;
|
||||
}
|
||||
|
||||
//@}
|
||||
|
|
Loading…
Reference in a new issue