summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-10-09 20:55:06 +0300
committerAndrei Karas <akaras@inbox.ru>2012-10-09 20:55:06 +0300
commit0e2f673e74b2817029653f418a88f6ae8ac2ff74 (patch)
treead6d6df3d90e7e20308c939b96d861006461b8e5 /src
parent362e1e1e1aad25e4b7aaa2b7d09fc841a30bc58f (diff)
downloadmanaverse-0e2f673e74b2817029653f418a88f6ae8ac2ff74.tar.gz
manaverse-0e2f673e74b2817029653f418a88f6ae8ac2ff74.tar.bz2
manaverse-0e2f673e74b2817029653f418a88f6ae8ac2ff74.tar.xz
manaverse-0e2f673e74b2817029653f418a88f6ae8ac2ff74.zip
Remove typeinfo from textpreview class.
Diffstat (limited to 'src')
-rw-r--r--src/gui/widgets/textpreview.cpp27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp
index ab5a8ce28..a8591b22a 100644
--- a/src/gui/widgets/textpreview.cpp
+++ b/src/gui/widgets/textpreview.cpp
@@ -29,8 +29,6 @@
#include "gui/gui.h"
#include "gui/sdlfont.h"
-#include <typeinfo>
-
#include "debug.h"
float TextPreview::mAlpha = 1.0;
@@ -65,18 +63,21 @@ void TextPreview::draw(gcn::Graphics* graphics)
graphics->fillRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight()));
}
- if (mTextBGColor && typeid(*mFont) == typeid(SDLFont))
+ if (mTextBGColor)
{
- const SDLFont *const font = static_cast<SDLFont*>(mFont);
- const int x = font->getWidth(mText) + 1
- + 2 * ((mOutline || mShadow) ? 1 :0);
- const int y = font->getHeight() + 1
- + 2 * ((mOutline || mShadow) ? 1 : 0);
- graphics->setColor(gcn::Color(static_cast<int>(mTextBGColor->r),
- static_cast<int>(mTextBGColor->g),
- static_cast<int>(mTextBGColor->b),
- static_cast<int>(mAlpha * 255.0f)));
- graphics->fillRectangle(gcn::Rectangle(1, 1, x, y));
+ const SDLFont *const font = dynamic_cast<SDLFont*>(mFont);
+ if (font)
+ {
+ const int x = font->getWidth(mText) + 1
+ + 2 * ((mOutline || mShadow) ? 1 :0);
+ const int y = font->getHeight() + 1
+ + 2 * ((mOutline || mShadow) ? 1 : 0);
+ graphics->setColor(gcn::Color(static_cast<int>(mTextBGColor->r),
+ static_cast<int>(mTextBGColor->g),
+ static_cast<int>(mTextBGColor->b),
+ static_cast<int>(mAlpha * 255.0f)));
+ graphics->fillRectangle(gcn::Rectangle(1, 1, x, y));
+ }
}
TextRenderer::renderText(graphics, mText, 2, 2, gcn::Graphics::LEFT,