summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-04-04 03:28:21 +0300
committerAndrei Karas <akaras@inbox.ru>2011-04-04 03:28:21 +0300
commitd18b9616bbe54db5d33363a197c8b9efa6161fa8 (patch)
tree56b1bca0f9ca60699810e2bf31625365c0affd42
parent07e988baf55b0e0f4b736e9305604536dbc872ff (diff)
downloadplus-d18b9616bbe54db5d33363a197c8b9efa6161fa8.tar.gz
plus-d18b9616bbe54db5d33363a197c8b9efa6161fa8.tar.bz2
plus-d18b9616bbe54db5d33363a197c8b9efa6161fa8.tar.xz
plus-d18b9616bbe54db5d33363a197c8b9efa6161fa8.zip
Rename TrueTypeFont to SDLFont.
-rw-r--r--src/CMakeLists.txt4
-rw-r--r--src/Makefile.am4
-rw-r--r--src/being.cpp2
-rw-r--r--src/commandhandler.cpp6
-rw-r--r--src/flooritem.cpp2
-rw-r--r--src/gui/gui.cpp16
-rw-r--r--src/gui/sdlfont.cpp (renamed from src/gui/truetypefont.cpp)44
-rw-r--r--src/gui/sdlfont.h (renamed from src/gui/truetypefont.h)18
-rw-r--r--src/gui/widgets/textpreview.cpp6
-rw-r--r--src/map.cpp2
10 files changed, 52 insertions, 52 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 873638df1..0b2dc20bf 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -315,6 +315,8 @@ SET(SRCS
gui/setup_players.h
gui/setup_video.cpp
gui/setup_video.h
+ gui/sdlfont.cpp
+ gui/sdlfont.h
gui/shopwindow.cpp
gui/shopwindow.h
gui/shortcutwindow.cpp
@@ -337,8 +339,6 @@ SET(SRCS
gui/theme.h
gui/trade.cpp
gui/trade.h
- gui/truetypefont.cpp
- gui/truetypefont.h
gui/unregisterdialog.cpp
gui/unregisterdialog.h
gui/updatewindow.cpp
diff --git a/src/Makefile.am b/src/Makefile.am
index fb698aee3..c07f5b1ea 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -210,6 +210,8 @@ manaplus_SOURCES = gui/widgets/avatarlistbox.cpp \
gui/setup_players.h \
gui/setup_video.cpp \
gui/setup_video.h \
+ gui/sdlfont.cpp \
+ gui/sdlfont.h \
gui/shopwindow.cpp \
gui/shopwindow.h \
gui/shortcutwindow.cpp \
@@ -232,8 +234,6 @@ manaplus_SOURCES = gui/widgets/avatarlistbox.cpp \
gui/theme.h \
gui/trade.cpp \
gui/trade.h \
- gui/truetypefont.cpp \
- gui/truetypefont.h \
gui/unregisterdialog.cpp \
gui/unregisterdialog.h \
gui/updatewindow.cpp \
diff --git a/src/being.cpp b/src/being.cpp
index a18f28ae3..be446e0fa 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -50,7 +50,7 @@
#include "gui/socialwindow.h"
#include "gui/speechbubble.h"
#include "gui/theme.h"
-#include "gui/truetypefont.h"
+#include "gui/sdlfont.h"
#include "gui/userpalette.h"
#include "net/charhandler.h"
diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp
index 96af6e775..3b2f38f72 100644
--- a/src/commandhandler.cpp
+++ b/src/commandhandler.cpp
@@ -36,7 +36,7 @@
#include "gui/outfitwindow.h"
#include "gui/shopwindow.h"
#include "gui/trade.h"
-#include "gui/truetypefont.h"
+#include "gui/sdlfont.h"
#include "gui/widgets/channeltab.h"
#include "gui/widgets/chattab.h"
@@ -984,11 +984,11 @@ void CommandHandler::handleCacheInfo(const std::string &args _UNUSED_,
if (!chatWindow || !debugChatTab)
return;
- TrueTypeFont *font = dynamic_cast<TrueTypeFont *>(chatWindow->getFont());
+ SDLFont *font = dynamic_cast<SDLFont *>(chatWindow->getFont());
if (!font)
return;
- std::list<TextChunk> *cache = font->getCache();
+ std::list<SDLTextChunk> *cache = font->getCache();
if (!cache)
return;
diff --git a/src/flooritem.cpp b/src/flooritem.cpp
index 9d59fe25b..bf5df1704 100644
--- a/src/flooritem.cpp
+++ b/src/flooritem.cpp
@@ -29,7 +29,7 @@
#include "configuration.h"
#include "gui/gui.h"
-#include "gui/truetypefont.h"
+#include "gui/sdlfont.h"
#include "net/net.h"
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index baccb7796..aecb6a6f8 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -26,7 +26,7 @@
#include "gui/palette.h"
#include "gui/sdlinput.h"
#include "gui/theme.h"
-#include "gui/truetypefont.h"
+#include "gui/sdlfont.h"
#include "gui/widgets/mouseevent.h"
#include "gui/widgets/window.h"
@@ -113,7 +113,7 @@ Gui::Gui(Graphics *graphics):
try
{
- mGuiFont = new TrueTypeFont(fontFile, fontSize);
+ mGuiFont = new SDLFont(fontFile, fontSize);
}
catch (const gcn::Exception &e)
{
@@ -128,7 +128,7 @@ Gui::Gui(Graphics *graphics):
try
{
- mInfoParticleFont = new TrueTypeFont(
+ mInfoParticleFont = new SDLFont(
fontFile, fontSize, TTF_STYLE_BOLD);
}
catch (const gcn::Exception &e)
@@ -144,7 +144,7 @@ Gui::Gui(Graphics *graphics):
try
{
- boldFont = new TrueTypeFont(fontFile, fontSize);
+ boldFont = new SDLFont(fontFile, fontSize);
}
catch (const gcn::Exception &e)
{
@@ -159,7 +159,7 @@ Gui::Gui(Graphics *graphics):
try
{
- mHelpFont = new TrueTypeFont(fontFile, fontSize);
+ mHelpFont = new SDLFont(fontFile, fontSize);
}
catch (const gcn::Exception &e)
{
@@ -295,20 +295,20 @@ void Gui::updateFonts()
if (fontFile.empty())
fontFile = branding.getStringValue("font");
- static_cast<TrueTypeFont*>(mGuiFont)->loadFont(fontFile, fontSize);
+ static_cast<SDLFont*>(mGuiFont)->loadFont(fontFile, fontSize);
fontFile = config.getValue("particleFont", "");
if (fontFile.empty())
fontFile = branding.getStringValue("particleFont");
- static_cast<TrueTypeFont*>(mInfoParticleFont)->loadFont(
+ static_cast<SDLFont*>(mInfoParticleFont)->loadFont(
fontFile, fontSize, TTF_STYLE_BOLD);
fontFile = config.getValue("boldFont", "");
if (fontFile.empty())
fontFile = branding.getStringValue("boldFont");
- static_cast<TrueTypeFont*>(boldFont)->loadFont(fontFile, fontSize);
+ static_cast<SDLFont*>(boldFont)->loadFont(fontFile, fontSize);
}
void Gui::distributeMouseEvent(gcn::Widget* source, int type, int button,
diff --git a/src/gui/truetypefont.cpp b/src/gui/sdlfont.cpp
index 62003d94c..ab20eee97 100644
--- a/src/gui/truetypefont.cpp
+++ b/src/gui/sdlfont.cpp
@@ -2,8 +2,8 @@
* The ManaPlus Client
* Copyright (C) 2004-2009 The Mana World Development Team
* Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011 The ManaPlus Developers
* Copyright (C) 2009 Aethyra Development Team
+ * Copyright (C) 2011 The ManaPlus Developers
*
* This file is part of The ManaPlus Client.
*
@@ -21,7 +21,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "gui/truetypefont.h"
+#include "gui/sdlfont.h"
#include "client.h"
#include "graphics.h"
@@ -41,21 +41,21 @@ const unsigned int CACHE_SIZE_SMALL2 = 150;
char *strBuf;
-class TextChunk
+class SDLTextChunk
{
public:
- TextChunk(const std::string &text, const gcn::Color &color) :
+ SDLTextChunk(const std::string &text, const gcn::Color &color) :
img(0), text(text), color(color)
{
}
- ~TextChunk()
+ ~SDLTextChunk()
{
delete img;
img = 0;
}
- bool operator==(const TextChunk &chunk) const
+ bool operator==(const SDLTextChunk &chunk) const
{
return (chunk.text == text && chunk.color == color);
}
@@ -89,11 +89,11 @@ class TextChunk
gcn::Color color;
};
-typedef std::list<TextChunk>::iterator CacheIterator;
+typedef std::list<SDLTextChunk>::iterator CacheIterator;
static int fontCounter;
-TrueTypeFont::TrueTypeFont(const std::string &filename, int size, int style) :
+SDLFont::SDLFont(const std::string &filename, int size, int style) :
mCreateCounter(0),
mDeleteCounter(0)
{
@@ -121,7 +121,7 @@ TrueTypeFont::TrueTypeFont(const std::string &filename, int size, int style) :
"fonts/dejavusans.ttf").c_str(), size);
if (!mFont)
{
- throw GCN_EXCEPTION("SDLTrueTypeFont::SDLTrueTypeFont: " +
+ throw GCN_EXCEPTION("SDLSDLFont::SDLSDLFont: " +
std::string(TTF_GetError()));
}
}
@@ -130,7 +130,7 @@ TrueTypeFont::TrueTypeFont(const std::string &filename, int size, int style) :
mCleanTime = cur_time + 120;
}
-TrueTypeFont::~TrueTypeFont()
+SDLFont::~SDLFont()
{
TTF_CloseFont(mFont);
mFont = 0;
@@ -143,7 +143,7 @@ TrueTypeFont::~TrueTypeFont()
}
}
-void TrueTypeFont::loadFont(const std::string &filename, int size, int style)
+void SDLFont::loadFont(const std::string &filename, int size, int style)
{
ResourceManager *resman = ResourceManager::getInstance();
@@ -158,7 +158,7 @@ void TrueTypeFont::loadFont(const std::string &filename, int size, int style)
if (!font)
{
- logger->log("SDLTrueTypeFont::SDLTrueTypeFont: " +
+ logger->log("SDLSDLFont::SDLSDLFont: " +
std::string(TTF_GetError()));
return;
}
@@ -171,7 +171,7 @@ void TrueTypeFont::loadFont(const std::string &filename, int size, int style)
clear();
}
-void TrueTypeFont::clear()
+void SDLFont::clear()
{
for (unsigned short f = 0; f < static_cast<unsigned short>(
CACHES_NUMBER); f ++)
@@ -180,7 +180,7 @@ void TrueTypeFont::clear()
}
}
-void TrueTypeFont::drawString(gcn::Graphics *graphics,
+void SDLFont::drawString(gcn::Graphics *graphics,
const std::string &text,
int x, int y)
{
@@ -197,10 +197,10 @@ void TrueTypeFont::drawString(gcn::Graphics *graphics,
*/
col.a = 255;
- TextChunk chunk(text, col);
+ SDLTextChunk chunk(text, col);
unsigned char chr = text[0];
- std::list<TextChunk> *cache = &mCache[chr];
+ std::list<SDLTextChunk> *cache = &mCache[chr];
bool found = false;
@@ -260,7 +260,7 @@ void TrueTypeFont::drawString(gcn::Graphics *graphics,
}
-void TrueTypeFont::createTextChunk(TextChunk *chunk)
+void SDLFont::createSDLTextChunk(SDLTextChunk *chunk)
{
if (!chunk || chunk->text.empty())
return;
@@ -272,13 +272,13 @@ void TrueTypeFont::createTextChunk(TextChunk *chunk)
chunk->img->setAlpha(alpha);
}
-int TrueTypeFont::getWidth(const std::string &text) const
+int SDLFont::getWidth(const std::string &text) const
{
if (text.empty())
return 0;
unsigned char chr = text[0];
- std::list<TextChunk> *cache = &mCache[chr];
+ std::list<SDLTextChunk> *cache = &mCache[chr];
#ifdef DEBUG_FONT
int cnt = 0;
@@ -311,16 +311,16 @@ int TrueTypeFont::getWidth(const std::string &text) const
return w;
}
-int TrueTypeFont::getHeight() const
+int SDLFont::getHeight() const
{
return TTF_FontHeight(mFont);
}
-void TrueTypeFont::doClean()
+void SDLFont::doClean()
{
for (int f = 0; f < CACHES_NUMBER; f ++)
{
- std::list<TextChunk> *cache = &mCache[f];
+ std::list<SDLTextChunk> *cache = &mCache[f];
if (cache->size() > CACHE_SIZE_SMALL2)
{
#ifdef DEBUG_FONT_COUNTERS
diff --git a/src/gui/truetypefont.h b/src/gui/sdlfont.h
index 9279cee63..86ef2f1e9 100644
--- a/src/gui/truetypefont.h
+++ b/src/gui/sdlfont.h
@@ -21,8 +21,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef TRUETYPEFONT_H
-#define TRUETYPEFONT_H
+#ifndef SDLFONT_H
+#define SDLFONT_H
#include <guichan/font.hpp>
@@ -41,14 +41,14 @@
#define CACHES_NUMBER 256
-class TextChunk;
+class SDLTextChunk;
/**
* A wrapper around SDL_ttf for allowing the use of TrueType fonts.
*
* <b>NOTE:</b> This class initializes SDL_ttf as necessary.
*/
-class TrueTypeFont : public gcn::Font
+class SDLFont : public gcn::Font
{
public:
/**
@@ -57,22 +57,22 @@ class TrueTypeFont : public gcn::Font
* @param filename Font filename.
* @param size Font size.
*/
- TrueTypeFont(const std::string &filename, int size, int style = 0);
+ SDLFont(const std::string &filename, int size, int style = 0);
/**
* Destructor.
*/
- ~TrueTypeFont();
+ ~SDLFont();
void loadFont(const std::string &filename, int size, int style = 0);
- void createTextChunk(TextChunk *chunk);
+ void createSDLTextChunk(SDLTextChunk *chunk);
virtual int getWidth(const std::string &text) const;
virtual int getHeight() const;
- std::list<TextChunk> *getCache()
+ std::list<SDLTextChunk> *getCache()
{ return mCache; }
/**
@@ -98,7 +98,7 @@ class TrueTypeFont : public gcn::Font
unsigned mDeleteCounter;
// Word surfaces cache
- mutable std::list<TextChunk> mCache[CACHES_NUMBER];
+ mutable std::list<SDLTextChunk> mCache[CACHES_NUMBER];
int mCleanTime;
};
diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp
index 6171a072f..6d41bef06 100644
--- a/src/gui/widgets/textpreview.cpp
+++ b/src/gui/widgets/textpreview.cpp
@@ -28,7 +28,7 @@
#include "gui/gui.h"
#include "gui/palette.h"
-#include "gui/truetypefont.h"
+#include "gui/sdlfont.h"
#include <typeinfo>
@@ -66,9 +66,9 @@ void TextPreview::draw(gcn::Graphics* graphics)
graphics->fillRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight()));
}
- if (mTextBGColor && typeid(*mFont) == typeid(TrueTypeFont))
+ if (mTextBGColor && typeid(*mFont) == typeid(SDLFont))
{
- TrueTypeFont *font = static_cast<TrueTypeFont*>(mFont);
+ SDLFont *font = static_cast<SDLFont*>(mFont);
int x = font->getWidth(mText) + 1 + 2 * ((mOutline || mShadow) ? 1 :0);
int y = font->getHeight() + 1 + 2 * ((mOutline || mShadow) ? 1 : 0);
graphics->setColor(gcn::Color(static_cast<int>(mTextBGColor->r),
diff --git a/src/map.cpp b/src/map.cpp
index 69ce1331d..3cdccbc2e 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -38,7 +38,7 @@
#include "gui/gui.h"
#include "gui/palette.h"
-#include "gui/truetypefont.h"
+#include "gui/sdlfont.h"
#include "gui/widgets/chattab.h"