diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/being.cpp | 2 | ||||
-rw-r--r-- | src/gui/gui.cpp | 29 | ||||
-rw-r--r-- | src/gui/gui.h | 4 | ||||
-rw-r--r-- | src/gui/ministatus.cpp | 8 | ||||
-rw-r--r-- | src/monster.cpp | 4 | ||||
-rw-r--r-- | src/npc.cpp | 4 | ||||
-rw-r--r-- | src/player.cpp | 3 | ||||
-rw-r--r-- | src/text.cpp | 55 | ||||
-rw-r--r-- | src/text.h | 5 |
9 files changed, 57 insertions, 57 deletions
diff --git a/src/being.cpp b/src/being.cpp index 5782c423..7036b8cd 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -156,7 +156,7 @@ void Being::setSpeech(const std::string &text, Uint32 time) delete mSpeech; mSpeech = new Text(text, mPx + X_SPEECH_OFFSET, mPy - Y_SPEECH_OFFSET, - gcn::Graphics::CENTER, speechFont, + gcn::Graphics::CENTER, gcn::Color(255, 255, 255), true); mSpeechTime = 500; } diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 722779ca..22d94791 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -43,16 +43,14 @@ #include "../resources/imageloader.h" // Guichan stuff -Gui *gui; -Viewport *viewport; /**< Viewport on the map. */ -SDLInput *guiInput; +Gui *gui = 0; +Viewport *viewport = 0; /**< Viewport on the map. */ +SDLInput *guiInput = 0; // Fonts used in showing hits -gcn::Font *hitRedFont; -gcn::Font *hitBlueFont; -gcn::Font *hitYellowFont; -// Font used to display speech and player names -gcn::Font *speechFont; +gcn::Font *hitRedFont = 0; +gcn::Font *hitBlueFont = 0; +gcn::Font *hitYellowFont = 0; class GuiConfigListener : public ConfigListener { @@ -116,20 +114,6 @@ Gui::Gui(Graphics *graphics): + e.getMessage()); } - // Set speech font - try { - speechFont = new gcn::ImageFont("graphics/gui/rpgfont_wider.png", - " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" - "0123456789.,!?-+/():;%&`'*#=[]\"<>{}^~|_@$\\" - "áÁéÉíÍóÓúÚç륣¢¡¿àãõêñÑöüäÖÜÄßøèÈåÅ" - ); - } - catch (gcn::Exception e) - { - logger->error(std::string("Unable to load rpgfont_wider.png: ") - + e.getMessage()); - } - gcn::Widget::setGlobalFont(mGuiFont); // Load hits' colourful fonts @@ -173,7 +157,6 @@ Gui::~Gui() mMouseCursors->decRef(); delete mGuiFont; - delete speechFont; delete viewport; delete getTop(); diff --git a/src/gui/gui.h b/src/gui/gui.h index 6af0a26a..c153b8e1 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -124,9 +124,5 @@ extern SDLInput *guiInput; /**< GUI input */ extern gcn::Font *hitRedFont; extern gcn::Font *hitBlueFont; extern gcn::Font *hitYellowFont; -/** - * Font used to display speech and player names - */ -extern gcn::Font *speechFont; #endif diff --git a/src/gui/ministatus.cpp b/src/gui/ministatus.cpp index 7a10ed3f..fa4f75da 100644 --- a/src/gui/ministatus.cpp +++ b/src/gui/ministatus.cpp @@ -55,14 +55,6 @@ MiniStatusWindow::MiniStatusWindow(): mMpLabel->setDimension(mMpBar->getDimension()); mXpLabel->setDimension(mXpBar->getDimension()); - mHpLabel->setForegroundColor(gcn::Color(255, 255, 255)); - mMpLabel->setForegroundColor(gcn::Color(255, 255, 255)); - mXpLabel->setForegroundColor(gcn::Color(255, 255, 255)); - - mHpLabel->setFont(speechFont); - mMpLabel->setFont(speechFont); - mXpLabel->setFont(speechFont); - mHpLabel->setAlignment(gcn::Graphics::CENTER); mMpLabel->setAlignment(gcn::Graphics::CENTER); mXpLabel->setAlignment(gcn::Graphics::CENTER); diff --git a/src/monster.cpp b/src/monster.cpp index 65049c9e..b6e6fc35 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -28,8 +28,6 @@ #include "text.h" #include "localplayer.h" -#include "gui/gui.h" - #include "resources/monsterdb.h" #include "utils/tostring.h" @@ -179,7 +177,7 @@ void Monster::showName(bool show) mText = new Text(getInfo().getName(), mPx + NAME_X_OFFSET, mPy + NAME_Y_OFFSET - getHeight(), gcn::Graphics::CENTER, - speechFont, gcn::Color(255, 32, 32)); + gcn::Color(255, 64, 64)); } else { diff --git a/src/npc.cpp b/src/npc.cpp index 3de1228f..aed6d87b 100644 --- a/src/npc.cpp +++ b/src/npc.cpp @@ -30,8 +30,6 @@ #include "net/protocol.h" #include "resources/npcdb.h" -#include "gui/gui.h" - NPC *current_npc = 0; static const int NAME_X_OFFSET = 15; @@ -76,7 +74,7 @@ void NPC::setName(const std::string &name) { delete mName; mName = new Text(name, mPx + NAME_X_OFFSET, mPy + NAME_Y_OFFSET, - gcn::Graphics::CENTER, speechFont, + gcn::Graphics::CENTER, gcn::Color(200, 200, 255)); } diff --git a/src/player.cpp b/src/player.cpp index 22efc711..27820acf 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -31,7 +31,6 @@ #include "utils/strprintf.h" -#include "gui/gui.h" #include <iostream> static const int NAME_X_OFFSET = 15; @@ -57,7 +56,7 @@ void Player::setName(const std::string &name) { mName = new FlashText(name, mPx + NAME_X_OFFSET, mPy + NAME_Y_OFFSET, gcn::Graphics::CENTER, - speechFont, gcn::Color(255, 255, 255)); + gcn::Color(255, 255, 255)); Being::setName(name); } } 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) { } @@ -37,7 +37,7 @@ class Text * Constructor creates a text object to display on the screen. */ 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 = false); /** @@ -62,7 +62,6 @@ class Text int mHeight; /**< The height of the text. */ int mXOffset; /**< The offset of mX from the desired x. */ static int mInstances; /**< Instances of text. */ - gcn::Font *mFont; /**< The font used. */ std::string mText; /**< The text to display. */ gcn::Color mColour; /**< The colour of the text. */ bool mIsSpeech; /**< Is this text a speech bubble? */ @@ -76,7 +75,7 @@ class FlashText : public Text { public: FlashText(const std::string &text, int x, int y, - gcn::Graphics::Alignment alignment, gcn::Font *font, + gcn::Graphics::Alignment alignment, gcn::Color colour); /** |