summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-12-27 15:58:18 +0300
committerAndrei Karas <akaras@inbox.ru>2012-12-27 23:15:05 +0300
commit697e5bbf3171b0ba1fbbc0bbe61461c7726bf1ce (patch)
treee5cbf0d91a689a598193c7b7a292e7c711c49fdc
parent60add2c149c9c61bfbede5ae92cfe216927aca8a (diff)
downloadplus-697e5bbf3171b0ba1fbbc0bbe61461c7726bf1ce.tar.gz
plus-697e5bbf3171b0ba1fbbc0bbe61461c7726bf1ce.tar.bz2
plus-697e5bbf3171b0ba1fbbc0bbe61461c7726bf1ce.tar.xz
plus-697e5bbf3171b0ba1fbbc0bbe61461c7726bf1ce.zip
Remove textrenderer class.
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/Makefile.am1
-rw-r--r--src/gui/widgets/textpreview.cpp14
-rw-r--r--src/text.cpp16
-rw-r--r--src/text.h5
-rw-r--r--src/textmanager.cpp2
-rw-r--r--src/textmanager.h8
-rw-r--r--src/textparticle.cpp23
-rw-r--r--src/textparticle.h1
-rw-r--r--src/textrenderer.h79
10 files changed, 41 insertions, 109 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 7140fba7d..c7335fd10 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -650,7 +650,6 @@ SET(SRCS
textmanager.h
textparticle.cpp
textparticle.h
- textrenderer.h
tileset.h
touchactions.cpp
touchactions.h
diff --git a/src/Makefile.am b/src/Makefile.am
index 32844edb8..8c2ecc7f1 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -652,7 +652,6 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \
textmanager.h \
textparticle.cpp \
textparticle.h \
- textrenderer.h \
tileset.h \
touchactions.cpp \
touchactions.h \
diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp
index 8468da782..00ce7f42a 100644
--- a/src/gui/widgets/textpreview.cpp
+++ b/src/gui/widgets/textpreview.cpp
@@ -24,7 +24,6 @@
#include "client.h"
#include "configuration.h"
-#include "textrenderer.h"
#include "gui/gui.h"
#include "gui/sdlfont.h"
@@ -110,9 +109,16 @@ void TextPreview::draw(gcn::Graphics* graphics)
}
}
- TextRenderer::renderText(graphics, mText, mPadding + 1, mPadding + 1,
- gcn::Graphics::LEFT, gcn::Color(mTextColor->r, mTextColor->g,
- mTextColor->b, alpha), mFont, mOutline, mShadow);
+ graphics->setColor(gcn::Color(mTextColor->r, mTextColor->g,
+ mTextColor->b, alpha));
+
+ if (mOutline)
+ {
+ Graphics *const g = static_cast<Graphics *const>(graphics);
+ g->setColor2(Theme::getThemeColor(Theme::OUTLINE));
+ }
+
+ mFont->drawString(graphics, mText, mPadding + 1, mPadding + 1);
BLOCK_END("TextPreview::draw")
}
diff --git a/src/text.cpp b/src/text.cpp
index cf15590fe..8c6b00fbe 100644
--- a/src/text.cpp
+++ b/src/text.cpp
@@ -25,10 +25,10 @@
#include "configuration.h"
#include "textmanager.h"
-#include "textrenderer.h"
#include "gui/gui.h"
#include "gui/sdlfont.h"
+#include "gui/theme.h"
#include "resources/resourcemanager.h"
#include "resources/image.h"
@@ -50,6 +50,7 @@ Text::Text(const std::string &text, const int x, const int y,
mHeight(mFont->getHeight()),
mText(text),
mColor(color),
+ mOutlineColor(Theme::getThemeColor(Theme::OUTLINE)),
mIsSpeech(isSpeech)
{
if (!textManager)
@@ -123,7 +124,7 @@ void Text::adviseXY(const int x, const int y)
textManager->moveText(this, x - mXOffset, y);
}
-void Text::draw(gcn::Graphics *const graphics, const int xOff, const int yOff)
+void Text::draw(Graphics *const graphics, const int xOff, const int yOff)
{
BLOCK_START("Text::draw")
if (mIsSpeech)
@@ -133,9 +134,11 @@ void Text::draw(gcn::Graphics *const graphics, const int xOff, const int yOff)
mBubble);
}
- TextRenderer::renderText(graphics, mText,
- mX - xOff, mY - yOff, gcn::Graphics::LEFT,
- *mColor, mFont, !mIsSpeech, true);
+ graphics->setColor(*mColor);
+ if (!mIsSpeech)
+ graphics->setColor2(mOutlineColor);
+
+ mFont->drawString(graphics, mText, mX - xOff, mY - yOff);
BLOCK_END("Text::draw")
}
@@ -147,8 +150,7 @@ FlashText::FlashText(const std::string &text, const int x, const int y,
{
}
-void FlashText::draw(gcn::Graphics *const graphics,
- const int xOff, const int yOff)
+void FlashText::draw(Graphics *const graphics, const int xOff, const int yOff)
{
BLOCK_START("FlashText::draw")
if (mTime)
diff --git a/src/text.h b/src/text.h
index f42c564a9..1c922a866 100644
--- a/src/text.h
+++ b/src/text.h
@@ -67,7 +67,7 @@ class Text
/**
* Draws the text.
*/
- virtual void draw(gcn::Graphics *const graphics,
+ virtual void draw(Graphics *const graphics,
const int xOff, const int yOff);
private:
@@ -80,6 +80,7 @@ class Text
static int mInstances; /**< Instances of text. */
std::string mText; /**< The text to display. */
const gcn::Color *mColor; /**< The color of the text. */
+ const gcn::Color mOutlineColor;
bool mIsSpeech; /**< Is this text a speech bubble? */
protected:
@@ -111,7 +112,7 @@ class FlashText final : public Text
/**
* Draws the text.
*/
- virtual void draw(gcn::Graphics *const graphics,
+ virtual void draw(Graphics *const graphics,
const int xOff, const int yOff) override;
private:
diff --git a/src/textmanager.cpp b/src/textmanager.cpp
index f44f22383..702b024f1 100644
--- a/src/textmanager.cpp
+++ b/src/textmanager.cpp
@@ -63,7 +63,7 @@ TextManager::~TextManager()
{
}
-void TextManager::draw(gcn::Graphics *const graphics,
+void TextManager::draw(Graphics *const graphics,
const int xOff, const int yOff)
{
BLOCK_START("TextManager::draw")
diff --git a/src/textmanager.h b/src/textmanager.h
index b16527498..f67b0aaf6 100644
--- a/src/textmanager.h
+++ b/src/textmanager.h
@@ -26,13 +26,9 @@
#include "localconsts.h"
+class Graphics;
class Text;
-namespace gcn
-{
- class Graphics;
-}
-
class TextManager final
{
public:
@@ -66,7 +62,7 @@ class TextManager final
/**
* Draw the text
*/
- void draw(gcn::Graphics *const graphics,
+ void draw(Graphics *const graphics,
const int xOff, const int yOff);
private:
diff --git a/src/textparticle.cpp b/src/textparticle.cpp
index e3d3fc710..178a6a086 100644
--- a/src/textparticle.cpp
+++ b/src/textparticle.cpp
@@ -22,9 +22,12 @@
#include "textparticle.h"
-#include "textrenderer.h"
+#include "graphics.h"
+
+#include "gui/theme.h"
#include <guichan/color.hpp>
+#include <guichan/font.hpp>
#include "debug.h"
@@ -35,7 +38,8 @@ TextParticle::TextParticle(Map *const map, const std::string &text,
mText(text),
mTextFont(font),
mColor(color),
- mOutline(outline)
+ mOutline(outline),
+ mTextWidth(mTextFont->getWidth(mText) / 2)
{
}
@@ -66,13 +70,16 @@ bool TextParticle::draw(Graphics *graphics, int offsetX, int offsetY) const
/ static_cast<float>(mFadeIn);
}
- const gcn::Color color = *mColor;
-// color.a = (int)alpha;
-
- TextRenderer::renderText(graphics, mText,
- screenX, screenY, gcn::Graphics::CENTER,
- color, mTextFont, mOutline, false, static_cast<int>(alpha));
+ gcn::Color color = *mColor;
+ color.a = (int)alpha;
+ graphics->setColor(color);
+ if (mOutline)
+ {
+ graphics->setColor2(Theme::getThemeColor(
+ Theme::OUTLINE, static_cast<int>(alpha)));
+ }
+ mTextFont->drawString(graphics, mText, screenX - mTextWidth, screenY);
BLOCK_END("TextParticle::draw")
return true;
}
diff --git a/src/textparticle.h b/src/textparticle.h
index a9f1a86ad..cfd6841ba 100644
--- a/src/textparticle.h
+++ b/src/textparticle.h
@@ -56,6 +56,7 @@ class TextParticle final : public Particle
gcn::Font *mTextFont; /**< Font used for drawing the text. */
const gcn::Color *mColor; /**< Color used for drawing the text. */
bool mOutline; /**< Make the text better readable */
+ int mTextWidth;
};
#endif
diff --git a/src/textrenderer.h b/src/textrenderer.h
deleted file mode 100644
index 5f42f87fb..000000000
--- a/src/textrenderer.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Text Renderer
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2012 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef TEXT_RENDERER_H
-#define TEXT_RENDERER_H
-
-#include "gui/theme.h"
-
-/**
- * Class for text rendering. Used by the TextParticle, the Text and FlashText
- * objects and the Preview in the color dialog.
- */
-class TextRenderer final
-{
- public:
- A_DELETE_COPY(TextRenderer)
-
- /**
- * Renders a specified text.
- */
- static inline void renderText(gcn::Graphics *const graphics,
- const std::string &text,
- const int x, const int y,
- const gcn::Graphics::Alignment align,
- const gcn::Color &color,
- gcn::Font *const font,
- const bool outline = false,
- const bool shadow = false,
- const int alpha = 255)
- {
- graphics->setFont(font);
-
- // Text shadow
- if (shadow)
- {
- graphics->setColor(Theme::getThemeColor(Theme::SHADOW,
- color.a / 2));
- if (outline)
- graphics->drawText(text, x + 2, y + 2, align);
- else
- graphics->drawText(text, x + 1, y + 1, align);
- }
-
- if (outline)
- {
- // Text outline
- graphics->setColor(Theme::getThemeColor(Theme::OUTLINE, alpha));
-// graphics->setColor(Theme::getThemeColor(Theme::OUTLINE, color.a));
- graphics->drawText(text, x + 1, y, align);
- graphics->drawText(text, x - 1, y, align);
- graphics->drawText(text, x, y + 1, align);
- graphics->drawText(text, x, y - 1, align);
- }
-
- graphics->setColor(color);
- graphics->drawText(text, x, y, align);
- }
-};
-
-#endif