summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-05-27 21:29:06 +0300
committerAndrei Karas <akaras@inbox.ru>2015-05-27 21:29:06 +0300
commit420664f4025b261674e0cdea503d43fb95beae38 (patch)
treea7f75459b34593f355384abe9e68c20239d1c51a /src
parentb2f868c841bf466714796bc9ce155f411ae8df06 (diff)
downloadmanaplus-420664f4025b261674e0cdea503d43fb95beae38.tar.gz
manaplus-420664f4025b261674e0cdea503d43fb95beae38.tar.bz2
manaplus-420664f4025b261674e0cdea503d43fb95beae38.tar.xz
manaplus-420664f4025b261674e0cdea503d43fb95beae38.zip
Add strong typed bool type Speech.
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/Makefile.am1
-rw-r--r--src/being/being.cpp18
-rw-r--r--src/enums/simpletypes/speech.h28
-rw-r--r--src/text.cpp15
-rw-r--r--src/text.h10
6 files changed, 57 insertions, 16 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 5e35994b3..ca9bf2d0b 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1075,6 +1075,7 @@ SET(SRCS
enums/simpletypes/showcenter.h
enums/simpletypes/simpledefines.h
enums/simpletypes/skiperror.h
+ enums/simpletypes/speech.h
enums/simpletypes/trading.h
enums/simpletypes/tryremovecolors.h
enums/simpletypes/useargs.h
diff --git a/src/Makefile.am b/src/Makefile.am
index 5f57a7587..44c4d1750 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1204,6 +1204,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \
enums/simpletypes/showcenter.h \
enums/simpletypes/simpledefines.h \
enums/simpletypes/skiperror.h \
+ enums/simpletypes/speech.h \
enums/simpletypes/trading.h \
enums/simpletypes/tryremovecolors.h \
enums/simpletypes/useargs.h \
diff --git a/src/being/being.cpp b/src/being/being.cpp
index 206151533..9c820f0c5 100644
--- a/src/being/being.cpp
+++ b/src/being/being.cpp
@@ -567,10 +567,11 @@ void Being::setSpeech(const std::string &text, const std::string &channel,
{
delete mText;
mText = new Text(mSpeech,
- getPixelX(), getPixelY() - getHeight(),
- Graphics::CENTER,
- &userPalette->getColor(UserPalette::PARTICLE),
- true);
+ getPixelX(),
+ getPixelY() - getHeight(),
+ Graphics::CENTER,
+ &userPalette->getColor(UserPalette::PARTICLE),
+ Speech_true);
}
else
{
@@ -1875,9 +1876,12 @@ void Being::drawSpeech(const int offsetX, const int offsetY)
if (!mText && userPalette)
{
- mText = new Text(mSpeech, getPixelX(), getPixelY() - getHeight(),
- Graphics::CENTER, &theme->getColor(
- Theme::BUBBLE_TEXT, 255), true);
+ mText = new Text(mSpeech,
+ getPixelX(),
+ getPixelY() - getHeight(),
+ Graphics::CENTER,
+ &theme->getColor(Theme::BUBBLE_TEXT, 255),
+ Speech_true);
}
}
else if (speech == BeingSpeech::NO_SPEECH)
diff --git a/src/enums/simpletypes/speech.h b/src/enums/simpletypes/speech.h
new file mode 100644
index 000000000..03a962f96
--- /dev/null
+++ b/src/enums/simpletypes/speech.h
@@ -0,0 +1,28 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2015 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 ENUMS_SIMPLETYPES_SPEECH_H
+#define ENUMS_SIMPLETYPES_SPEECH_H
+
+#include "enums/simpletypes/simpledefines.h"
+
+defBoolEnum(Speech);
+
+#endif // ENUMS_SIMPLETYPES_SPEECH_H
diff --git a/src/text.cpp b/src/text.cpp
index 0331b5263..bec055f60 100644
--- a/src/text.cpp
+++ b/src/text.cpp
@@ -41,9 +41,11 @@
int Text::mInstances = 0;
ImageRect Text::mBubble;
-Text::Text(const std::string &text, const int x, const int y,
+Text::Text(const std::string &text,
+ const int x, const int y,
const Graphics::Alignment alignment,
- const Color *const color, const bool isSpeech,
+ const Color *const color,
+ const Speech isSpeech,
Font *const font) :
mFont(font ? font : (gui ? gui->getFont() : nullptr)),
mTextChunk(),
@@ -54,7 +56,8 @@ 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)),
+ mOutlineColor(isSpeech == Speech_true ?
+ *color : theme->getColor(Theme::OUTLINE, 255)),
mIsSpeech(isSpeech),
mTextChanged(true)
{
@@ -120,7 +123,7 @@ Text::~Text()
void Text::setColor(const Color *const color)
{
mTextChanged = true;
- if (mIsSpeech)
+ if (mIsSpeech == Speech_true)
{
mColor = color;
mOutlineColor = *color;
@@ -147,7 +150,7 @@ void Text::adviseXY(const int x, const int y, const bool move)
void Text::draw(Graphics *const graphics, const int xOff, const int yOff)
{
BLOCK_START("Text::draw")
- if (mIsSpeech)
+ if (mIsSpeech == Speech_true)
{
graphics->drawImageRect(mX - xOff - 5,
mY - yOff - 5,
@@ -179,7 +182,7 @@ FlashText::FlashText(const std::string &text,
const Graphics::Alignment alignment,
const Color *const color,
Font *const font) :
- Text(text, x, y, alignment, color, false, font),
+ Text(text, x, y, alignment, color, Speech_false, font),
mTime(0)
{
}
diff --git a/src/text.h b/src/text.h
index 845b96353..916de924e 100644
--- a/src/text.h
+++ b/src/text.h
@@ -24,6 +24,8 @@
#ifndef TEXT_H
#define TEXT_H
+#include "enums/simpletypes/speech.h"
+
#include "gui/fonts/textchunk.h"
#include "render/graphics.h"
@@ -40,9 +42,11 @@ class Text notfinal
/**
* Constructor creates a text object to display on the screen.
*/
- Text(const std::string &text, const int x, const int y,
+ Text(const std::string &text,
+ const int x, const int y,
const Graphics::Alignment alignment,
- const Color *const color, const bool isSpeech = false,
+ const Color *const color,
+ const Speech isSpeech = Speech_false,
Font *const font = nullptr);
A_DELETE_COPY(Text)
@@ -83,7 +87,7 @@ class Text notfinal
std::string mText; /**< The text to display. */
const Color *mColor; /**< The color of the text. */
Color mOutlineColor;
- bool mIsSpeech; /**< Is this text a speech bubble? */
+ Speech mIsSpeech; /**< Is this text a speech bubble? */
bool mTextChanged;
protected: