diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/gui.cpp | 21 | ||||
-rw-r--r-- | src/gui/gui.h | 4 | ||||
-rw-r--r-- | src/gui/ministatus.cpp | 8 | ||||
-rw-r--r-- | src/gui/speechbubble.cpp | 25 | ||||
-rw-r--r-- | src/gui/speechbubble.h | 1 |
5 files changed, 44 insertions, 15 deletions
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 5314b9ba..fe8cae78 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -50,15 +50,9 @@ SDLInput *guiInput = 0; gcn::Font *hitRedFont = 0; gcn::Font *hitBlueFont = 0; gcn::Font *hitYellowFont = 0; -// Font used to display speech and player names -gcn::Font *speechFont; -// Font for displaying NPC names -gcn::Font *npcNameFont; -// Font for displaying mob names -gcn::Font *mobNameFont; -// Font for displaying GM names -gcn::Font *gmNameFont; +// Bolded font +gcn::Font *boldFont = 0; class GuiConfigListener : public ConfigListener { @@ -122,6 +116,17 @@ Gui::Gui(Graphics *graphics): + e.getMessage()); } + // Set bold font + path = resman->getPath("fonts/dejavusans-bold.ttf"); + try { + boldFont = new TrueTypeFont(path, 11); + } + catch (gcn::Exception e) + { + logger->error(std::string("Unable to load dejavusans-bold.ttf: ") + + e.getMessage()); + } + gcn::Widget::setGlobalFont(mGuiFont); // Load hits' colourful fonts diff --git a/src/gui/gui.h b/src/gui/gui.h index bb14d4dc..9f45a3f3 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -125,5 +125,9 @@ extern gcn::Font *hitRedFont; extern gcn::Font *hitBlueFont; extern gcn::Font *hitYellowFont; +/** + * Bolded text font + */ +extern gcn::Font *boldFont; #endif diff --git a/src/gui/ministatus.cpp b/src/gui/ministatus.cpp index f2e466f4..6e162141 100644 --- a/src/gui/ministatus.cpp +++ b/src/gui/ministatus.cpp @@ -46,6 +46,14 @@ MiniStatusWindow::MiniStatusWindow(): mMpLabel = new gcn::Label(""); mXpLabel = new gcn::Label(""); + mHpLabel->setForegroundColor(gcn::Color(50, 50, 50)); + mMpLabel->setForegroundColor(gcn::Color(50, 50, 50)); + mXpLabel->setForegroundColor(gcn::Color(50, 50, 50)); + + mHpLabel->setFont(boldFont); + mMpLabel->setFont(boldFont); + mXpLabel->setFont(boldFont); + mHpBar->setPosition(0, 3); mMpBar->setPosition(mHpBar->getWidth() + 3, 3); mXpBar->setPosition(mMpBar->getX() + mMpBar->getWidth() + 3, 3); diff --git a/src/gui/speechbubble.cpp b/src/gui/speechbubble.cpp index 4fa63973..eb3232ea 100644 --- a/src/gui/speechbubble.cpp +++ b/src/gui/speechbubble.cpp @@ -22,6 +22,7 @@ #include <guichan/font.hpp> +#include "gui.h" #include "speechbubble.h" #include "../resources/image.h" @@ -32,7 +33,7 @@ // TODO: Fix windows so that they can each load their own skins without the // other windows overriding another window's skin. SpeechBubble::SpeechBubble(): - Window(_("Message"), false, NULL, "graphics/gui/speechbubble.xml") + Window(_(""), false, NULL, "graphics/gui/speechbubble.xml") { mSpeechBox = new TextBox(); mSpeechBox->setEditable(false); @@ -59,28 +60,38 @@ SpeechBubble::SpeechBubble(): mSpeechBox->setTextWrapped( "" ); } +void SpeechBubble::setName(const std::string &name) +{ + setWindowName(name); + setCaption(name); +} + void SpeechBubble::setText(std::string mText) { mSpeechBox->setMinWidth(140); mSpeechBox->setTextWrapped( mText ); + const int fontHeight = getFont()->getHeight(); int numRows = mSpeechBox->getNumberOfRows(); if (numRows > 1) { // 15 == height of each line of text (based on font heights) // 14 == speechbubble Top + Bottom graphic pixel heights - setContentSize(mSpeechBox->getMinWidth() + 15, 15 + (numRows * 15)); - mSpeechArea->setDimension(gcn::Rectangle(4, 15, mSpeechBox->getMinWidth() + 5, - 3 +(numRows * 14))); + setContentSize(mSpeechBox->getMinWidth() + fontHeight, fontHeight + + (numRows * fontHeight)); + mSpeechArea->setDimension(gcn::Rectangle(4, fontHeight, + mSpeechBox->getMinWidth() + 5, + 3 + (numRows * fontHeight))); } else { - int width = getFont()->getWidth(this->getCaption()); + int width = boldFont->getWidth(this->getCaption()); if (width < getFont()->getWidth(mText)) width = getFont()->getWidth(mText); - setContentSize(width + 15, 30); - mSpeechArea->setDimension(gcn::Rectangle(4, 15, width + 5, 17)); + setContentSize(width + fontHeight, fontHeight * 2); + mSpeechArea->setDimension(gcn::Rectangle(4, fontHeight, + width + 5, fontHeight + 2)); } } diff --git a/src/gui/speechbubble.h b/src/gui/speechbubble.h index 9b8eab70..6d8a94d4 100644 --- a/src/gui/speechbubble.h +++ b/src/gui/speechbubble.h @@ -33,6 +33,7 @@ class SpeechBubble : public Window SpeechBubble(); + void setName(const std::string &name); void setText(std::string mText); void setLocation(int x, int y); unsigned int getNumRows(); |