summaryrefslogtreecommitdiff
path: root/src/text.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2009-01-24 19:43:26 +0100
committerBjørn Lindeijer <bjorn@lindeijer.nl>2009-01-24 19:43:26 +0100
commita928798a9326de1e6781e14c8ccf5abec1232385 (patch)
tree2e0f82055cab1bddf85102d5161a3262637879ee /src/text.cpp
parent944c187b91e823075dd1708b4f575acd43f0428f (diff)
downloadmana-a928798a9326de1e6781e14c8ccf5abec1232385.tar.gz
mana-a928798a9326de1e6781e14c8ccf5abec1232385.tar.bz2
mana-a928798a9326de1e6781e14c8ccf5abec1232385.tar.xz
mana-a928798a9326de1e6781e14c8ccf5abec1232385.zip
Use standard GUI font also for speech and names
The speech bitmap font can't handle unicode, so it has now been replaced by the standard GUI font, drawn with a shadow for chat and with a full outline for names.
Diffstat (limited to 'src/text.cpp')
-rw-r--r--src/text.cpp55
1 files changed, 45 insertions, 10 deletions
diff --git a/src/text.cpp b/src/text.cpp
index d256b82d..0e458c9f 100644
--- a/src/text.cpp
+++ b/src/text.cpp
@@ -30,12 +30,14 @@
#include "resources/resourcemanager.h"
#include "resources/image.h"
+#include "gui/gui.h"
+
int Text::mInstances = 0;
ImageRect Text::mBubble;
Image *Text::mBubbleArrow;
Text::Text(const std::string &text, int x, int y,
- gcn::Graphics::Alignment alignment, gcn::Font *font,
+ gcn::Graphics::Alignment alignment,
gcn::Color colour, bool isSpeech) :
mText(text),
mColour(colour),
@@ -57,7 +59,7 @@ Text::Text(const std::string &text, int x, int y,
mBubble.grid[7] = sbImage->getSubImage(5, 10, 5, 5);
mBubble.grid[8] = sbImage->getSubImage(10, 10, 5, 5);
mBubbleArrow = sbImage->getSubImage(0, 15, 15, 10);
- double bubbleAlpha = config.getValue("speechBubbleAlpha", 0.4);
+ const float bubbleAlpha = config.getValue("speechBubbleAlpha", 1.0);
for (int i = 0; i < 9; i++)
{
mBubble.grid[i]->setAlpha(bubbleAlpha);
@@ -66,8 +68,8 @@ Text::Text(const std::string &text, int x, int y,
sbImage->decRef();
}
++mInstances;
- mHeight = font->getHeight();
- mWidth = font->getWidth(text);
+ mHeight = gui->getFont()->getHeight();
+ mWidth = gui->getFont()->getWidth(text);
switch (alignment)
{
@@ -84,7 +86,6 @@ Text::Text(const std::string &text, int x, int y,
mX = x - mXOffset;
mY = y;
textManager->addText(this);
- mFont = font;
}
Text::~Text()
@@ -114,29 +115,63 @@ void Text::adviseXY(int x, int y)
void Text::draw(Graphics *graphics, int xOff, int yOff)
{
- graphics->setFont(mFont);
- graphics->setColor(mColour);
+ graphics->setFont(gui->getFont());
if (mIsSpeech) {
static_cast<Graphics*>(graphics)->drawImageRect(
mX - xOff - 5, mY - yOff - 5, mWidth + 10, mHeight + 10,
mBubble);
-
+ /*
if (mWidth >= 15) {
static_cast<Graphics*>(graphics)->drawImage(
mBubbleArrow, mX - xOff - 7 + mWidth / 2,
mY - yOff + mHeight + 4);
}
+ */
+ }
+
+ // Text shadow
+ graphics->setColor(gcn::Color(0, 0, 0));
+ graphics->drawText(mText, mX - xOff + 1, mY - yOff + 1,
+ gcn::Graphics::LEFT);
+
+ if (!mIsSpeech) {
+ graphics->setColor(gcn::Color(0, 0, 0, 64));
+ /*
+ // TODO: Reanable when we can draw it nicely in software mode
+ graphics->drawText(mText, mX - xOff + 2, mY - yOff + 2,
+ gcn::Graphics::LEFT);
+ graphics->drawText(mText, mX - xOff + 1, mY - yOff + 2,
+ gcn::Graphics::LEFT);
+ graphics->drawText(mText, mX - xOff + 2, mY - yOff + 1,
+ gcn::Graphics::LEFT);
+ */
+
+ // Text outline
+ graphics->setColor(gcn::Color(0, 0, 0));
+ graphics->drawText(mText, mX - xOff + 1, mY - yOff,
+ gcn::Graphics::LEFT);
+
+ graphics->drawText(mText, mX - xOff - 1, mY - yOff,
+ gcn::Graphics::LEFT);
+
+ graphics->drawText(mText, mX - xOff, mY - yOff + 1,
+ gcn::Graphics::LEFT);
+
+ graphics->drawText(mText, mX - xOff, mY - yOff - 1,
+ gcn::Graphics::LEFT);
}
+ graphics->setColor(mColour);
graphics->drawText(mText, mX - xOff, mY - yOff,
gcn::Graphics::LEFT);
}
FlashText::FlashText(const std::string &text, int x, int y,
- gcn::Graphics::Alignment alignment, gcn::Font *font,
+ gcn::Graphics::Alignment alignment,
gcn::Color colour) :
- Text(text, x, y, alignment, font, colour), mTime(0)
+ Text(text, x, y, alignment, colour),
+ mTime(0)
{
}