summaryrefslogtreecommitdiff
path: root/src/text.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-05-26 14:38:25 +0300
committerAndrei Karas <akaras@inbox.ru>2015-05-26 14:38:25 +0300
commit055345145f35286b3f45ed05d5a80d118a1ab8f4 (patch)
tree6b6ab1ddcf335ad6025a752abde126cb1c2fcb8a /src/text.cpp
parentde328959771fcc5f992f13517ea7adacdda61550 (diff)
downloadmanaverse-055345145f35286b3f45ed05d5a80d118a1ab8f4.tar.gz
manaverse-055345145f35286b3f45ed05d5a80d118a1ab8f4.tar.bz2
manaverse-055345145f35286b3f45ed05d5a80d118a1ab8f4.tar.xz
manaverse-055345145f35286b3f45ed05d5a80d118a1ab8f4.zip
Use local TextChunk in text class.
Diffstat (limited to 'src/text.cpp')
-rw-r--r--src/text.cpp27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/text.cpp b/src/text.cpp
index 4f56f7cdf..0331b5263 100644
--- a/src/text.cpp
+++ b/src/text.cpp
@@ -46,6 +46,7 @@ Text::Text(const std::string &text, const int x, const int y,
const Color *const color, const bool isSpeech,
Font *const font) :
mFont(font ? font : (gui ? gui->getFont() : nullptr)),
+ mTextChunk(),
mX(x),
mY(y),
mWidth(mFont ? mFont->getWidth(text) : 1),
@@ -53,8 +54,9 @@ Text::Text(const std::string &text, const int x, const int y,
mXOffset(0),
mText(text),
mColor(color),
- mOutlineColor(isSpeech ? color : theme->getColor(Theme::OUTLINE, 255)),
- mIsSpeech(isSpeech)
+ mOutlineColor(isSpeech ? *color : theme->getColor(Theme::OUTLINE, 255)),
+ mIsSpeech(isSpeech),
+ mTextChanged(true)
{
if (!textManager)
{
@@ -117,10 +119,11 @@ Text::~Text()
void Text::setColor(const Color *const color)
{
+ mTextChanged = true;
if (mIsSpeech)
{
mColor = color;
- mOutlineColor = color;
+ mOutlineColor = *color;
}
else
{
@@ -153,9 +156,21 @@ void Text::draw(Graphics *const graphics, const int xOff, const int yOff)
mBubble);
}
- mFont->drawString(graphics,
- *mColor, mOutlineColor,
- mText, mX - xOff, mY - yOff);
+ if (mTextChanged)
+ {
+ mTextChunk.textFont = mFont;
+ mTextChunk.deleteImage();
+ mTextChunk.text = mText;
+ mTextChunk.color = *mColor;
+ mTextChunk.color2 = mOutlineColor;
+ mFont->generate(mTextChunk);
+ mTextChanged = false;
+ }
+
+ const Image *const image = mTextChunk.img;
+ if (image)
+ graphics->drawImage(image, mX - xOff, mY - yOff);
+
BLOCK_END("Text::draw")
}