summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Sehmisch <crush@themanaworld.org>2009-01-25 03:56:27 +0100
committerPhilipp Sehmisch <crush@themanaworld.org>2009-01-25 03:56:27 +0100
commit17d2756975a8ff22ecba92c055fa7a7f77d425c6 (patch)
tree76aaa104da3ee97b07aec7f2d972f8b8d6239d9a
parent7e928fc6559e89b64f49aea30d796dbfe75c4912 (diff)
parent61040888a373b03cc599750c33186848cae37ef4 (diff)
downloadmana-17d2756975a8ff22ecba92c055fa7a7f77d425c6.tar.gz
mana-17d2756975a8ff22ecba92c055fa7a7f77d425c6.tar.bz2
mana-17d2756975a8ff22ecba92c055fa7a7f77d425c6.tar.xz
mana-17d2756975a8ff22ecba92c055fa7a7f77d425c6.zip
Merge branch 'master' of git@gitorious.org:tmw/eathena
-rw-r--r--CMakeLists.txt2
-rw-r--r--NEWS2
-rw-r--r--README2
-rwxr-xr-xconfigure.ac2
-rw-r--r--data/graphics/gui/bubble.pngbin0 -> 407 bytes
-rw-r--r--data/help/changes.txt8
-rw-r--r--data/help/header.txt2
-rw-r--r--po/LINGUAS2
-rw-r--r--src/being.cpp4
-rw-r--r--src/gui/chat.cpp27
-rw-r--r--src/gui/chat.h5
-rw-r--r--src/gui/gui.cpp29
-rw-r--r--src/gui/gui.h4
-rw-r--r--src/gui/ministatus.cpp24
-rw-r--r--src/gui/progressbar.cpp11
-rw-r--r--src/gui/trade.cpp15
-rw-r--r--src/gui/truetypefont.cpp6
-rw-r--r--src/monster.cpp25
-rw-r--r--src/npc.cpp4
-rw-r--r--src/player.cpp12
-rw-r--r--src/resources/image.h32
-rw-r--r--src/text.cpp120
-rw-r--r--src/text.h12
-rw-r--r--src/winver.h4
24 files changed, 195 insertions, 159 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2c31196f..0ce5d305 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,6 +1,6 @@
PROJECT(TMW)
-SET(VERSION 0.0.27)
+SET(VERSION 0.0.28)
# where to look for cmake modules
SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMake/Modules)
diff --git a/NEWS b/NEWS
index eba6ee22..649771dc 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,4 @@
-0.0.28 (...)
+0.0.28 (25 January 2009)
- Added support for animated map tiles
- Added support for internationalization, plus many translations
- Added support for TrueType fonts
diff --git a/README b/README
index 18621c6c..1af4d3a2 100644
--- a/README
+++ b/README
@@ -1,7 +1,7 @@
THE MANA WORLD
==============
- Version: 0.0.27 Date: 9/12/2008
+ Version: 0.0.28 Date: 25/1/2009
Development team:
- See AUTHORS file for a list
diff --git a/configure.ac b/configure.ac
index 8c1ce8a4..6162dca7 100755
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,5 @@
AC_PREREQ(2.59)
-AC_INIT([The Mana World], [0.0.27], [themanaworld-devel@lists.sourceforge.net], [tmw])
+AC_INIT([The Mana World], [0.0.28], [themanaworld-devel@lists.sourceforge.net], [tmw])
AM_INIT_AUTOMAKE
AC_CONFIG_HEADERS([config.h:config.h.in])
AC_LANG_CPLUSPLUS
diff --git a/data/graphics/gui/bubble.png b/data/graphics/gui/bubble.png
new file mode 100644
index 00000000..45322eb2
--- /dev/null
+++ b/data/graphics/gui/bubble.png
Binary files differ
diff --git a/data/help/changes.txt b/data/help/changes.txt
index 62035a01..62eed904 100644
--- a/data/help/changes.txt
+++ b/data/help/changes.txt
@@ -3,6 +3,14 @@
##3 === RECENT CHANGES ===
+ 0.0.28 (25 January 2009)
+ - Added support for animated map tiles
+ - Added support for internationalization, plus many translations
+ - Added support for TrueType fonts
+ - Trade window is now resizable
+ - Obscure precise home directory name when making screenshots
+ - Fixed follow-parent of nested and being-following particle emitters
+
0.0.27 (9 December 2008)
- Added support for showing map name above minimap
- Added showing how long the ban is when banned
diff --git a/data/help/header.txt b/data/help/header.txt
index 0d3ff134..151eb262 100644
--- a/data/help/header.txt
+++ b/data/help/header.txt
@@ -2,7 +2,7 @@
##1 T H E M A N A W O R L D
##1 ==========================================
- ##2Version:##6 0.0.27 ##2Date:##3 9 December 2008
+ ##2Version:##6 0.0.28 ##2Date:##3 25 January 2009
##2 Website: http://themanaworld.org
diff --git a/po/LINGUAS b/po/LINGUAS
index 4959c0de..b67d0209 100644
--- a/po/LINGUAS
+++ b/po/LINGUAS
@@ -22,4 +22,4 @@ ru
sk
sv
th
-zh_CN
+#zh_CN
diff --git a/src/being.cpp b/src/being.cpp
index b11177e1..7036b8cd 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -156,8 +156,8 @@ 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::Color(255, 255, 255));
+ gcn::Graphics::CENTER,
+ gcn::Color(255, 255, 255), true);
mSpeechTime = 500;
}
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index 4854f1ca..87d843a0 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -32,6 +32,8 @@
#include "sdlinput.h"
#include "windowcontainer.h"
+#include "widgets/layout.h"
+
#include "../configuration.h"
#include "../game.h"
#include "../localplayer.h"
@@ -52,6 +54,8 @@ ChatWindow::ChatWindow(Network *network):
setResizable(true);
setDefaultSize(0, windowContainer->getHeight() - 123, 600, 123);
+ setMinWidth(150);
+ setMinHeight(90);
mChatInput = new ChatInput;
mChatInput->setActionEventId("chatinput");
@@ -68,8 +72,12 @@ ChatWindow::ChatWindow(Network *network):
gcn::ScrollArea::SHOW_NEVER, gcn::ScrollArea::SHOW_ALWAYS);
mScrollArea->setOpaque(false);
- add(mScrollArea);
- add(mChatInput);
+ place(0, 0, mScrollArea, 5, 5).setPadding(0);
+ place(0, 5, mChatInput, 5).setPadding(1);
+
+ Layout &layout = getLayout();
+ layout.setRowHeight(0, Layout::AUTO_SET);
+ layout.setMargin(2);
loadWindowState();
@@ -78,21 +86,6 @@ ChatWindow::ChatWindow(Network *network):
mCurHist = mHistory.end();
}
-void ChatWindow::widgetResized(const gcn::Event &event)
-{
- Window::widgetResized(event);
-
- const gcn::Rectangle area = getChildrenArea();
-
- mChatInput->setPosition(mChatInput->getFrameSize(),
- area.height - mChatInput->getHeight() -
- mChatInput->getFrameSize());
- mChatInput->setWidth(area.width - 2 * mChatInput->getFrameSize());
- mScrollArea->setWidth(area.width - 2 * mScrollArea->getFrameSize());
- mScrollArea->setHeight(area.height - 2 * mScrollArea->getFrameSize() -
- mChatInput->getHeight() - 5);
-}
-
void ChatWindow::chatLog(std::string line, int own)
{
// Trim whitespace
diff --git a/src/gui/chat.h b/src/gui/chat.h
index db03aa47..2baafdef 100644
--- a/src/gui/chat.h
+++ b/src/gui/chat.h
@@ -127,11 +127,6 @@ class ChatWindow : public Window, public gcn::ActionListener,
ChatWindow(Network *network);
/**
- * Called whenever the widget changes size.
- */
- void widgetResized(const gcn::Event &event);
-
- /*
* Adds a line of text to our message list. Parameters:
*
* @param line Text message.
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..f49022b6 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);
@@ -80,8 +72,7 @@ MiniStatusWindow::MiniStatusWindow():
loadWindowState();
}
-void
-MiniStatusWindow::setIcon(int index, AnimatedSprite *sprite)
+void MiniStatusWindow::setIcon(int index, AnimatedSprite *sprite)
{
if (index >= (int) mIcons.size())
mIcons.resize(index + 1, NULL);
@@ -92,8 +83,7 @@ MiniStatusWindow::setIcon(int index, AnimatedSprite *sprite)
mIcons[index] = sprite;
}
-void
-MiniStatusWindow::eraseIcon(int index)
+void MiniStatusWindow::eraseIcon(int index)
{
mIcons.erase(mIcons.begin() + index);
}
@@ -156,20 +146,20 @@ void MiniStatusWindow::update()
}
-void MiniStatusWindow::draw(gcn::Graphics *gcn_graphics)
+void MiniStatusWindow::draw(gcn::Graphics *graphics)
{
update();
- drawChildren(gcn_graphics);
+ drawChildren(graphics);
}
-void
-MiniStatusWindow::drawIcons(Graphics *graphics)
+void MiniStatusWindow::drawIcons(Graphics *graphics)
{
// Draw icons
int icon_x = mXpBar->getX() + mXpBar->getWidth() + 4;
- for (unsigned int i = 0; i < mIcons.size(); i++)
+ for (unsigned int i = 0; i < mIcons.size(); i++) {
if (mIcons[i]) {
mIcons[i]->draw(graphics, icon_x, 3);
icon_x += 2 + mIcons[i]->getWidth();
}
+ }
}
diff --git a/src/gui/progressbar.cpp b/src/gui/progressbar.cpp
index 7b88a556..5ce01b35 100644
--- a/src/gui/progressbar.cpp
+++ b/src/gui/progressbar.cpp
@@ -88,8 +88,7 @@ void ProgressBar::logic()
if (mBlueToGo < mBlue) mBlue--;
}
-void
-ProgressBar::draw(gcn::Graphics *graphics)
+void ProgressBar::draw(gcn::Graphics *graphics)
{
static_cast<Graphics*>(graphics)->
drawImageRect(0, 0, getWidth(), getHeight(), mBorder);
@@ -99,21 +98,19 @@ ProgressBar::draw(gcn::Graphics *graphics)
{
graphics->setColor(gcn::Color(mRed, mGreen, mBlue, 200));
graphics->fillRectangle(gcn::Rectangle(4, 4,
- (int)(mProgress * (getWidth() - 8)),
+ (int) (mProgress * (getWidth() - 8)),
getHeight() - 8));
}
}
-void
-ProgressBar::setProgress(float progress)
+void ProgressBar::setProgress(float progress)
{
if (progress < 0.0f) mProgress = 0.0;
else if (progress > 1.0f) mProgress = 1.0;
else mProgress = progress;
}
-void
-ProgressBar::setColor(Uint8 red, Uint8 green, Uint8 blue)
+void ProgressBar::setColor(Uint8 red, Uint8 green, Uint8 blue)
{
mRedToGo = red;
mGreenToGo = green;
diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp
index 1e58c409..66df55b8 100644
--- a/src/gui/trade.cpp
+++ b/src/gui/trade.cpp
@@ -128,10 +128,15 @@ void TradeWindow::widgetResized(const gcn::Event &event)
mMoneyField->getX() + mMoneyField->getWidth() + 6,
mMoneyLabel2->getY());
- mCancelButton->setPosition(width - 54, height - 8 - mCancelButton->getHeight());
- mTradeButton->setPosition(mCancelButton->getX() - 41, mCancelButton->getY());
- mOkButton->setPosition(mTradeButton->getX() - 24, mCancelButton->getY());
- mAddButton->setPosition(mOkButton->getX() - 31, mCancelButton->getY());
+ mCancelButton->setPosition(width - 8 - mCancelButton->getWidth(),
+ height - 8 - mCancelButton->getHeight());
+ mTradeButton->setPosition(
+ mCancelButton->getX() - 4 - mTradeButton->getWidth(),
+ mCancelButton->getY());
+ mOkButton->setPosition(mTradeButton->getX() - 4 - mOkButton->getWidth(),
+ mCancelButton->getY());
+ mAddButton->setPosition(mOkButton->getX() - 4 - mAddButton->getWidth(),
+ mCancelButton->getY());
mItemDescriptionLabel->setPosition(8,
mOkButton->getY() - mItemDescriptionLabel->getHeight() - 4);
@@ -263,8 +268,10 @@ void TradeWindow::valueChanged(const gcn::SelectionEvent &event)
ItemInfo const *info = item ? &item->getInfo() : NULL;
mItemNameLabel->setCaption(strprintf(_("Name: %s"),
info ? info->getName().c_str() : ""));
+ mItemNameLabel->adjustSize();
mItemDescriptionLabel->setCaption(strprintf(_("Description: %s"),
info ? info->getDescription().c_str() : ""));
+ mItemDescriptionLabel->adjustSize();
}
void TradeWindow::action(const gcn::ActionEvent &event)
diff --git a/src/gui/truetypefont.cpp b/src/gui/truetypefont.cpp
index fc6783f7..f65b3446 100644
--- a/src/gui/truetypefont.cpp
+++ b/src/gui/truetypefont.cpp
@@ -111,13 +111,11 @@ TrueTypeFont::~TrueTypeFont()
}
void TrueTypeFont::drawString(gcn::Graphics *graphics,
- const std::string &text,
- int x, int y)
+ const std::string &text,
+ int x, int y)
{
if (text.empty())
- {
return;
- }
Graphics *g = dynamic_cast<Graphics *>(graphics);
diff --git a/src/monster.cpp b/src/monster.cpp
index 65049c9e..f50855ca 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"
@@ -81,8 +79,7 @@ Monster::~Monster()
}
}
-void
-Monster::logic()
+void Monster::logic()
{
if (mAction != STAND)
{
@@ -97,14 +94,12 @@ Monster::logic()
Being::logic();
}
-Being::Type
-Monster::getType() const
+Being::Type Monster::getType() const
{
return MONSTER;
}
-void
-Monster::setAction(Uint8 action)
+void Monster::setAction(Uint8 action)
{
SpriteAction currentAction = ACTION_INVALID;
@@ -142,8 +137,7 @@ Monster::setAction(Uint8 action)
}
}
-void
-Monster::handleAttack(Being *victim, int damage)
+void Monster::handleAttack(Being *victim, int damage)
{
Being::handleAttack(victim, damage);
@@ -152,21 +146,18 @@ Monster::handleAttack(Being *victim, int damage)
MONSTER_EVENT_HIT : MONSTER_EVENT_MISS));
}
-void
-Monster::takeDamage(int amount)
+void Monster::takeDamage(int amount)
{
if (amount > 0) sound.playSfx(getInfo().getSound(MONSTER_EVENT_HURT));
Being::takeDamage(amount);
}
-Being::TargetCursorSize
-Monster::getTargetCursorSize() const
+Being::TargetCursorSize Monster::getTargetCursorSize() const
{
return getInfo().getTargetCursorSize();
}
-const MonsterInfo&
-Monster::getInfo() const
+const MonsterInfo &Monster::getInfo() const
{
return MonsterDB::get(mJob - 1002);
}
@@ -179,7 +170,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..ec3b1c1c 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,13 +56,12 @@ 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);
}
}
-void
-Player::logic()
+void Player::logic()
{
switch (mAction) {
case WALK:
@@ -90,14 +88,12 @@ Player::logic()
Being::logic();
}
-Being::Type
-Player::getType() const
+Being::Type Player::getType() const
{
return PLAYER;
}
-void
-Player::flash(int time)
+void Player::flash(int time)
{
if (mName)
{
diff --git a/src/resources/image.h b/src/resources/image.h
index faaf3db7..2c0569f9 100644
--- a/src/resources/image.h
+++ b/src/resources/image.h
@@ -54,8 +54,7 @@ class Image : public Resource
/**
* Destructor.
*/
- virtual
- ~Image();
+ virtual ~Image();
/**
* Loads an image from a buffer in memory.
@@ -78,7 +77,8 @@ class Image : public Resource
* @return <code>NULL</code> if an error occurred, a valid pointer
* otherwise.
*/
- static Resource *load(void *buffer, unsigned bufferSize, Dye const &dye);
+ static Resource *load(void *buffer, unsigned bufferSize,
+ Dye const &dye);
/**
* Loads an image from an SDL surface.
@@ -88,21 +88,20 @@ class Image : public Resource
/**
* Frees the resources created by SDL.
*/
- virtual void
- unload();
+ virtual void unload();
/**
* Returns the width of the image.
*/
- virtual int
- getWidth() const { return mBounds.w; }
+ virtual int getWidth() const
+ { return mBounds.w; }
/**
* Returns the height of the image.
*/
- virtual int
- getHeight() const { return mBounds.h; }
+ virtual int getHeight() const
+ { return mBounds.h; }
/**
* Creates a new image with the desired clipping rectangle.
@@ -110,20 +109,17 @@ class Image : public Resource
* @return <code>NULL</code> if creation failed and a valid
* object otherwise.
*/
- virtual Image*
- getSubImage(int x, int y, int width, int height);
+ virtual Image *getSubImage(int x, int y, int width, int height);
/**
* Sets the alpha value of this image.
*/
- void
- setAlpha(float alpha);
+ void setAlpha(float alpha);
/**
* Returns the alpha value of this image.
*/
- float
- getAlpha();
+ float getAlpha();
#ifdef USE_OPENGL
/**
@@ -145,8 +141,7 @@ class Image : public Resource
/**
* Returns the first power of two equal or bigger than the input.
*/
- static int
- powerOfTwo(int input);
+ static int powerOfTwo(int input);
#endif
Image(SDL_Surface *image);
@@ -192,8 +187,7 @@ class SubImage : public Image
* @return <code>NULL</code> if creation failed and a valid
* image otherwise.
*/
- Image*
- getSubImage(int x, int y, int width, int height);
+ Image *getSubImage(int x, int y, int width, int height);
private:
Image *mParent;
diff --git a/src/text.cpp b/src/text.cpp
index c0cd1ecc..0e458c9f 100644
--- a/src/text.cpp
+++ b/src/text.cpp
@@ -25,23 +25,52 @@
#include <guichan/font.hpp>
+#include "configuration.h"
#include "textmanager.h"
+#include "resources/resourcemanager.h"
+#include "resources/image.h"
-int Text::mInstances = 0;
+#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::Color colour) :
- mText(text), mColour(colour)
+ gcn::Graphics::Alignment alignment,
+ gcn::Color colour, bool isSpeech) :
+ mText(text),
+ mColour(colour),
+ mIsSpeech(isSpeech)
{
if (textManager == 0)
{
- textManager = new TextManager();
+ textManager = new TextManager;
+ ResourceManager *resman = ResourceManager::getInstance();
+ Image *sbImage = resman->getImage("graphics/gui/bubble.png|W:#"
+ + config.getValue("speechBubbleColour", "000000"));
+ mBubble.grid[0] = sbImage->getSubImage(0, 0, 5, 5);
+ mBubble.grid[1] = sbImage->getSubImage(5, 0, 5, 5);
+ mBubble.grid[2] = sbImage->getSubImage(10, 0, 5, 5);
+ mBubble.grid[3] = sbImage->getSubImage(0, 5, 5, 5);
+ mBubble.grid[4] = sbImage->getSubImage(5, 5, 5, 5);
+ mBubble.grid[5] = sbImage->getSubImage(10, 5, 5, 5);
+ mBubble.grid[6] = sbImage->getSubImage(0, 10, 5, 5);
+ 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);
+ const float bubbleAlpha = config.getValue("speechBubbleAlpha", 1.0);
+ for (int i = 0; i < 9; i++)
+ {
+ mBubble.grid[i]->setAlpha(bubbleAlpha);
+ }
+ mBubbleArrow->setAlpha(bubbleAlpha);
+ sbImage->decRef();
}
++mInstances;
- mHeight = font->getHeight();
- mWidth = font->getWidth(text);
+ mHeight = gui->getFont()->getHeight();
+ mWidth = gui->getFont()->getWidth(text);
+
switch (alignment)
{
case gcn::Graphics::LEFT:
@@ -57,12 +86,6 @@ Text::Text(const std::string &text, int x, int y,
mX = x - mXOffset;
mY = y;
textManager->addText(this);
- mFont = font;
-}
-
-void Text::adviseXY(int x, int y)
-{
- textManager->moveText(this, x - mXOffset, y);
}
Text::~Text()
@@ -72,20 +95,83 @@ Text::~Text()
{
delete textManager;
textManager = 0;
+ delete mBubble.grid[0];
+ delete mBubble.grid[1];
+ delete mBubble.grid[2];
+ delete mBubble.grid[3];
+ delete mBubble.grid[4];
+ delete mBubble.grid[5];
+ delete mBubble.grid[6];
+ delete mBubble.grid[7];
+ delete mBubble.grid[8];
+ delete mBubbleArrow;
}
}
+void Text::adviseXY(int x, int y)
+{
+ textManager->moveText(this, x - mXOffset, y);
+}
+
void Text::draw(Graphics *graphics, int xOff, int yOff)
{
- graphics->setFont(mFont);
+ 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);
+ 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)
{
}
diff --git a/src/text.h b/src/text.h
index 11e4e4be..0c6f072a 100644
--- a/src/text.h
+++ b/src/text.h
@@ -37,8 +37,8 @@ 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::Color colour);
+ gcn::Graphics::Alignment alignment,
+ gcn::Color colour, bool isSpeech = false);
/**
* Destructor. The text is removed from the screen.
@@ -62,16 +62,20 @@ 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? */
+
+ protected:
+ static ImageRect mBubble; /**< Speech bubble graphic */
+ static Image *mBubbleArrow; /**< Speech bubble arrow graphic */
};
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);
/**
diff --git a/src/winver.h b/src/winver.h
index 46d247fc..45043409 100644
--- a/src/winver.h
+++ b/src/winver.h
@@ -1,6 +1,6 @@
/* VERSION DEFINITIONS */
#define VER_MAJOR 0
#define VER_MINOR 0
-#define VER_RELEASE 27
+#define VER_RELEASE 28
#define VER_BUILD 0
-#define PACKAGE_VERSION "0.0.27"
+#define PACKAGE_VERSION "0.0.28"