summaryrefslogtreecommitdiff
path: root/src/gui/sdlfont.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-05-19 17:48:34 +0300
committerAndrei Karas <akaras@inbox.ru>2013-05-19 17:48:34 +0300
commit3203c6bd824cd8ac4e86374afafe01e45d358a40 (patch)
tree39b922bedf17bc2629d9b00da84a4024332c6243 /src/gui/sdlfont.cpp
parente7c83487949d173e230e8868ef5410a1ac5a9398 (diff)
downloadmanaverse-3203c6bd824cd8ac4e86374afafe01e45d358a40.tar.gz
manaverse-3203c6bd824cd8ac4e86374afafe01e45d358a40.tar.bz2
manaverse-3203c6bd824cd8ac4e86374afafe01e45d358a40.tar.xz
manaverse-3203c6bd824cd8ac4e86374afafe01e45d358a40.zip
improve SDLFont class.
Diffstat (limited to 'src/gui/sdlfont.cpp')
-rw-r--r--src/gui/sdlfont.cpp45
1 files changed, 9 insertions, 36 deletions
diff --git a/src/gui/sdlfont.cpp b/src/gui/sdlfont.cpp
index 0b4f57baa..7df00260a 100644
--- a/src/gui/sdlfont.cpp
+++ b/src/gui/sdlfont.cpp
@@ -152,7 +152,7 @@ void SDLTextChunk::generate(TTF_Font *const font, const float alpha)
|| color.b != color2.b)
{ // outlining
SDL_Color sdlCol2;
- SDL_Surface *background = imageHelper->create32BitSurface(
+ SDL_Surface *const background = imageHelper->create32BitSurface(
width, height);
if (!background)
{
@@ -314,7 +314,9 @@ void TextChunkList::clear()
static int fontCounter;
-SDLFont::SDLFont(std::string filename, const int size, const int style) :
+SDLFont::SDLFont(std::string filename,
+ const int size,
+ const int style) :
mFont(nullptr),
mCreateCounter(0),
mDeleteCounter(0),
@@ -369,7 +371,9 @@ SDLFont::~SDLFont()
}
}
-void SDLFont::loadFont(std::string filename, const int size, const int style)
+void SDLFont::loadFont(std::string filename,
+ const int size,
+ const int style)
{
const ResourceManager *const resman = ResourceManager::getInstance();
@@ -421,7 +425,7 @@ void SDLFont::drawString(gcn::Graphics *const graphics,
return;
gcn::Color col = g->getColor();
- gcn::Color col2 = g->getColor2();
+ const gcn::Color col2 = g->getColor2();
const float alpha = static_cast<float>(col.a) / 255.0f;
/* The alpha value is ignored at string generation so avoid caching the
@@ -506,37 +510,6 @@ int SDLFont::getWidth(const std::string &text) const
return 0;
}
-/*
-#ifdef DEBUG_FONT
- int cnt = 0;
-#endif
-
- SDLTextChunk *i = cache->start;
- while (i)
- {
- if (i->text == text)
- {
- // Raise priority: move it to front
- // Assumption is that TTF::draw will be called next
- cache->moveToFirst(i);
- const Image *const image = i->img;
- if (image)
- return image->getWidth();
- else
- return 0;
- }
- i = i->next;
-#ifdef DEBUG_FONT
- cnt ++;
-#endif
- }
-
-#ifdef DEBUG_FONT
- logger->log(std::string("getWidth: ").append(text).append(
- ", iterations: ").append(toString(cnt)));
-#endif
-*/
-
// if string was not drawed
int w, h;
getSafeUtf8String(text, strBuf);
@@ -591,7 +564,7 @@ void SDLFont::doClean()
}
}
-TextChunkList *SDLFont::getCache()
+TextChunkList *SDLFont::getCache() const
{
return mCache;
}