summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorDavid Athay <ko2fan@gmail.com>2009-05-21 10:20:32 +0100
committerDavid Athay <ko2fan@gmail.com>2009-05-21 10:20:32 +0100
commit2dad08e4e8e199c84da6a6f2f5289c8c0e40fc81 (patch)
tree293d4922893dfffcc065604743116e653c3b8d37 /src/gui
parentdc1eb0895382451b1c79c60ecb7ca7dbbec89681 (diff)
parent244b0d9b46128ab3498da078020c8bbf8c65f69f (diff)
downloadmana-2dad08e4e8e199c84da6a6f2f5289c8c0e40fc81.tar.gz
mana-2dad08e4e8e199c84da6a6f2f5289c8c0e40fc81.tar.bz2
mana-2dad08e4e8e199c84da6a6f2f5289c8c0e40fc81.tar.xz
mana-2dad08e4e8e199c84da6a6f2f5289c8c0e40fc81.zip
Merge branch 'master' of git@gitorious.org:tmw/mainline
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/connection.cpp2
-rw-r--r--src/gui/connection.h6
-rw-r--r--src/gui/inventorywindow.cpp18
-rw-r--r--src/gui/inventorywindow.h1
-rw-r--r--src/gui/itemcontainer.cpp4
-rw-r--r--src/gui/outfitwindow.cpp306
-rw-r--r--src/gui/outfitwindow.h92
-rw-r--r--src/gui/partywindow.cpp5
-rw-r--r--src/gui/serverselectdialog.cpp2
-rw-r--r--src/gui/serverselectdialog.h6
-rw-r--r--src/gui/setup.cpp2
-rw-r--r--src/gui/skin.cpp10
-rw-r--r--src/gui/textrenderer.h2
-rw-r--r--src/gui/viewport.cpp22
-rw-r--r--src/gui/widgets/avatar.cpp6
-rw-r--r--src/gui/widgets/avatar.h3
-rw-r--r--src/gui/widgets/chattab.cpp20
-rw-r--r--src/gui/widgets/progressbar.cpp14
-rw-r--r--src/gui/windowmenu.cpp1
19 files changed, 467 insertions, 55 deletions
diff --git a/src/gui/connection.cpp b/src/gui/connection.cpp
index 0862ee69..4863edcd 100644
--- a/src/gui/connection.cpp
+++ b/src/gui/connection.cpp
@@ -30,7 +30,7 @@
#include "utils/gettext.h"
-ConnectionDialog::ConnectionDialog(int previousState):
+ConnectionDialog::ConnectionDialog(State previousState):
Window("Info"), mProgress(0), mPreviousState(previousState)
{
setContentSize(200, 100);
diff --git a/src/gui/connection.h b/src/gui/connection.h
index 62441fa9..d6059c3f 100644
--- a/src/gui/connection.h
+++ b/src/gui/connection.h
@@ -24,6 +24,8 @@
#include "gui/widgets/window.h"
+#include "main.h"
+
#include <guichan/actionlistener.hpp>
class ProgressBar;
@@ -41,7 +43,7 @@ class ConnectionDialog : public Window, gcn::ActionListener
*
* @see Window::Window
*/
- ConnectionDialog(int previousState);
+ ConnectionDialog(State previousState);
/**
* Called when the user presses Cancel. Restores the global state to
@@ -54,7 +56,7 @@ class ConnectionDialog : public Window, gcn::ActionListener
private:
ProgressBar *mProgressBar;
float mProgress;
- int mPreviousState;
+ State mPreviousState;
};
#endif
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index d6cd3a84..c44ae9e7 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -79,6 +79,7 @@ InventoryWindow::InventoryWindow(int invSize):
mUseButton = new Button(longestUseString, "use", this);
mDropButton = new Button(_("Drop"), "drop", this);
mSplitButton = new Button(_("Split"), "split", this);
+ mOutfitButton = new Button(_("Outfits"), "outfit", this);
mItems = new ItemContainer(player_node->getInventory());
mItems->addSelectionListener(this);
@@ -103,6 +104,7 @@ InventoryWindow::InventoryWindow(int invSize):
place(0, 2, mUseButton);
place(1, 2, mDropButton);
place(2, 2, mSplitButton);
+ place(6, 2, mOutfitButton);
Layout &layout = getLayout();
layout.setRowHeight(1, Layout::AUTO_SET);
@@ -156,6 +158,16 @@ void InventoryWindow::logic()
void InventoryWindow::action(const gcn::ActionEvent &event)
{
+ if (event.getId() == "outfit")
+ {
+ extern Window *outfitWindow;
+ outfitWindow->setVisible(!outfitWindow->isVisible());
+ if (outfitWindow->isVisible())
+ {
+ outfitWindow->requestMoveToTop();
+ }
+ }
+
Item *item = mItems->getSelectedItem();
if (!item)
@@ -163,7 +175,7 @@ void InventoryWindow::action(const gcn::ActionEvent &event)
if (event.getId() == "use")
{
- if (item->isEquipment())
+ if (item->isEquipment())
{
if (item->isEquipped())
Net::getInventoryHandler()->unequipItem(item);
@@ -258,10 +270,10 @@ void InventoryWindow::updateButtons()
mDropButton->setEnabled(false);
return;
}
-
+
mUseButton->setEnabled(true);
mDropButton->setEnabled(true);
-
+
if (selectedItem->isEquipment())
{
if (selectedItem->isEquipped())
diff --git a/src/gui/inventorywindow.h b/src/gui/inventorywindow.h
index 6e34666d..fbda5ac7 100644
--- a/src/gui/inventorywindow.h
+++ b/src/gui/inventorywindow.h
@@ -109,6 +109,7 @@ class InventoryWindow : public Window,
gcn::Button *mUseButton;
gcn::Button *mDropButton;
gcn::Button *mSplitButton;
+ gcn::Button *mOutfitButton;
gcn::Label *mWeightLabel;
gcn::Label *mSlotsLabel;
diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp
index 54aa818b..d8ae6e20 100644
--- a/src/gui/itemcontainer.cpp
+++ b/src/gui/itemcontainer.cpp
@@ -23,6 +23,7 @@
#include "gui/chat.h"
#include "gui/itempopup.h"
+#include "gui/outfitwindow.h"
#include "gui/palette.h"
#include "gui/sdlinput.h"
#include "gui/viewport.h"
@@ -162,6 +163,7 @@ void ItemContainer::selectNone()
{
setSelectedIndex(-1);
mSelectionStatus = SEL_NONE;
+ outfitWindow->setItemSelected(-1);
}
void ItemContainer::setSelectedIndex(int newIndex)
@@ -260,6 +262,8 @@ void ItemContainer::mousePressed(gcn::MouseEvent &event)
mSelectionStatus = SEL_SELECTING;
itemShortcut->setItemSelected(item->getId());
+ if (item->isEquipment())
+ outfitWindow->setItemSelected(item->getId());
}
else
{
diff --git a/src/gui/outfitwindow.cpp b/src/gui/outfitwindow.cpp
new file mode 100644
index 00000000..f43e1440
--- /dev/null
+++ b/src/gui/outfitwindow.cpp
@@ -0,0 +1,306 @@
+/*
+ * The Mana World
+ * Copyright (C) 2007 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "outfitwindow.h"
+
+#include "configuration.h"
+#include "localplayer.h"
+#include "graphics.h"
+#include "inventory.h"
+#include "equipment.h"
+#include "item.h"
+
+#include "gui/widgets/button.h"
+#include "gui/widgets/checkbox.h"
+#include "gui/widgets/label.h"
+#include "gui/widgets/layout.h"
+
+#include "net/inventoryhandler.h"
+#include "net/net.h"
+
+#include "resources/image.h"
+
+#include "utils/gettext.h"
+#include "utils/stringutils.h"
+
+#include <vector>
+
+OutfitWindow::OutfitWindow():
+ Window(_("Outfits")),
+ mBoxWidth(33),
+ mBoxHeight(33),
+ mGridWidth(3),
+ mGridHeight(3),
+ mItemClicked(false),
+ mItemMoved(NULL),
+ mItemSelected(-1),
+ mCurrentOutfit(0)
+{
+ setWindowName("Outfits");
+ setCloseButton(true);
+ setDefaultSize(250, 250, 118, 180); //160
+
+ mPreviousButton = new Button("<", "previous", this);
+ mNextButton = new Button(">", "next", this);
+ mCurrentLabel = new Label("Outfit: 1");
+ mCurrentLabel->setAlignment(gcn::Graphics::CENTER);
+ mUnequipCheck = new CheckBox(_("Unequip first"),
+ config.getValue("OutfitUnequip", true));
+
+ place(0, 3, mPreviousButton, 1);
+ place(1, 3, mCurrentLabel, 2);
+ place(3, 3, mNextButton, 1);
+ place(0, 4, mUnequipCheck, 4);
+
+ Layout &layout = getLayout();
+ layout.setRowHeight(0, Layout::AUTO_SET);
+ layout.setColWidth(4, Layout::CENTER);
+
+ loadWindowState();
+
+ load();
+}
+
+OutfitWindow::~OutfitWindow()
+{
+ save();
+}
+
+void OutfitWindow::load()
+{
+ memset(mItems, -1, sizeof(mItems));
+ for (int o = 0; o < 10; o++)
+ {
+ std::string outfit = config.getValue("Outfit" + toString(o), "-1");
+ std::string buf;
+ std::stringstream ss(outfit);
+
+ std::vector<int> tokens;
+
+ while (ss >> buf) {
+ tokens.push_back(atoi(buf.c_str()));
+ }
+
+ for (int i = 0; i < (int)tokens.size(); i++)
+ {
+ mItems[o][i] = tokens[i];
+ }
+ }
+}
+
+void OutfitWindow::save()
+{
+ std::string outfitStr;
+ for (int o = 0; o < 10; o++)
+ {
+ for (int i = 0; i < 9; i++)
+ {
+ outfitStr += mItems[o][i] ? toString(mItems[o][i]) : toString(-1);
+ if (i <8) outfitStr += " ";
+ }
+ config.setValue("Outfit" + toString(o), outfitStr);
+ outfitStr = "";
+ }
+ config.setValue("OutfitUnequip", mUnequipCheck->isSelected());
+}
+
+void OutfitWindow::action(const gcn::ActionEvent &event)
+{
+ if (event.getId() == "next")
+ {
+ if (mCurrentOutfit < 9) {
+ mCurrentOutfit++;
+ } else {
+ mCurrentOutfit = 0;
+ }
+ }
+ else if (event.getId() == "previous")
+ {
+ if (mCurrentOutfit > 0) {
+ mCurrentOutfit--;
+ } else {
+ mCurrentOutfit = 9;
+ }
+ }
+ mCurrentLabel->setCaption("Outfit: " + toString(mCurrentOutfit + 1));
+}
+
+void OutfitWindow::wearOutfit(int outfit)
+{
+ Item *item;
+ if (mUnequipCheck->isSelected())
+ {
+ for (int i = 0; i < 11; i++)
+ {
+ //non vis is 3,4,7
+ if (i != 3 && i != 4 && i != 7)
+ {
+#ifdef TMWSERV_SUPPORT
+ if (!(item = player_node->mEquipment.get()->getEquipment(i)))
+ continue;
+#else
+ if (!(item = player_node->getInventory()->getItem(
+ player_node->mEquipment.get()->getEquipment(i))))
+ continue;
+#endif
+ Net::getInventoryHandler()->unequipItem(item);
+ }
+ }
+ }
+
+ for (int i = 0; i < 9; i++)
+ {
+ item = player_node->getInventory()->findItem(mItems[outfit][i]);
+ if (item && item->getQuantity())
+ {
+ if (item->isEquipment()) {
+ Net::getInventoryHandler()->equipItem(item);
+ }
+ }
+ }
+}
+
+void OutfitWindow::draw(gcn::Graphics *graphics)
+{
+ Window::draw(graphics);
+ Graphics *g = static_cast<Graphics*>(graphics);
+
+ for (int i = 0; i < 9; i++)
+ {
+ const int itemX = 10 + (i % mGridWidth) * mBoxWidth;
+ const int itemY = 25 + (i / mGridWidth) * mBoxHeight;
+
+ graphics->setColor(gcn::Color(0, 0, 0, 64));
+ graphics->drawRectangle(gcn::Rectangle(itemX, itemY, 32, 32));
+ graphics->setColor(gcn::Color(255, 255, 255, 32));
+ graphics->fillRectangle(gcn::Rectangle(itemX, itemY, 32, 32));
+
+ if (mItems[mCurrentOutfit][i] < 0)
+ continue;
+
+ Item *item =
+ player_node->getInventory()->findItem(mItems[mCurrentOutfit][i]);
+ if (item) {
+ // Draw item icon.
+ Image* image = item->getImage();
+ if (image) {
+ g->drawImage(image, itemX, itemY);
+ }
+ }
+ }
+ if (mItemMoved)
+ {
+ // Draw the item image being dragged by the cursor.
+ Image* image = mItemMoved->getImage();
+ if (image)
+ {
+ const int tPosX = mCursorPosX - (image->getWidth() / 2);
+ const int tPosY = mCursorPosY - (image->getHeight() / 2);
+
+ g->drawImage(image, tPosX, tPosY);
+ }
+ }
+}
+
+
+void OutfitWindow::mouseDragged(gcn::MouseEvent &event)
+{
+ Window::mouseDragged(event);
+ if (event.getButton() == gcn::MouseEvent::LEFT) {
+ if (!mItemMoved && mItemClicked) {
+ const int index = getIndexFromGrid(event.getX(), event.getY());
+ if (index == -1) {
+ return;
+ }
+ const int itemId = mItems[mCurrentOutfit][index];
+ if (itemId < 0)
+ return;
+ Item *item = player_node->getInventory()->findItem(itemId);
+ if (item)
+ {
+ mItemMoved = item;
+ mItems[mCurrentOutfit][index] = -1;
+ }
+ }
+ if (mItemMoved) {
+ mCursorPosX = event.getX();
+ mCursorPosY = event.getY();
+ }
+ }
+}
+
+void OutfitWindow::mousePressed(gcn::MouseEvent &event)
+{
+ Window::mousePressed(event);
+ const int index = getIndexFromGrid(event.getX(), event.getY());
+ if (index == -1) {
+ return;
+ }
+
+ // Stores the selected item if there is one.
+ if (isItemSelected()) {
+ mItems[mCurrentOutfit][index] = mItemSelected;
+ mItemSelected = -1;
+ }
+ else if (mItems[mCurrentOutfit][index]) {
+ mItemClicked = true;
+ }
+}
+
+void OutfitWindow::mouseReleased(gcn::MouseEvent &event)
+{
+ Window::mouseReleased(event);
+ if (event.getButton() == gcn::MouseEvent::LEFT)
+ {
+ if (isItemSelected())
+ {
+ mItemSelected = -1;
+ }
+ const int index = getIndexFromGrid(event.getX(), event.getY());
+ if (index == -1) {
+ mItemMoved = NULL;
+ return;
+ }
+ if (mItemMoved) {
+ mItems[mCurrentOutfit][index] = mItemMoved->getId();
+ mItemMoved = NULL;
+ }
+ if (mItemClicked) {
+ mItemClicked = false;
+ }
+ }
+}
+
+int OutfitWindow::getIndexFromGrid(int pointX, int pointY) const
+{
+ const gcn::Rectangle tRect = gcn::Rectangle(
+ 10, 25, 10 + mGridWidth * mBoxWidth, 25 + mGridHeight * mBoxHeight);
+ if (!tRect.isPointInRect(pointX, pointY)) {
+ return -1;
+ }
+ const int index = (((pointY - 25) / mBoxHeight) * mGridWidth) +
+ (pointX - 10) / mBoxWidth;
+ if (index >= 9)
+ {
+ return -1;
+ }
+ return index;
+}
diff --git a/src/gui/outfitwindow.h b/src/gui/outfitwindow.h
new file mode 100644
index 00000000..3e70815c
--- /dev/null
+++ b/src/gui/outfitwindow.h
@@ -0,0 +1,92 @@
+/*
+ * The Mana World
+ * Copyright (C) 2007 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef OUTFITWINDOW_H
+#define OUTFITWINDOW_H
+
+#include "gui/widgets/window.h"
+
+#include <guichan/actionlistener.hpp>
+
+class Button;
+class CheckBox;
+class Item;
+class Label;
+
+class OutfitWindow : public Window, gcn::ActionListener
+{
+ public:
+ /**
+ * Constructor.
+ */
+ OutfitWindow();
+
+ /**
+ * Destructor.
+ */
+ ~OutfitWindow();
+
+ void action(const gcn::ActionEvent &event);
+
+ void draw(gcn::Graphics *graphics);
+
+ void mousePressed(gcn::MouseEvent &event);
+
+ void mouseDragged(gcn::MouseEvent &event);
+
+ void mouseReleased(gcn::MouseEvent &event);
+
+ void load();
+
+ void setItemSelected(int itemId)
+ { mItemSelected = itemId; }
+
+ bool isItemSelected()
+ { return mItemSelected > -1; }
+
+ void wearOutfit(int outfit);
+
+ private:
+ Button *mPreviousButton;
+ Button *mNextButton;
+ Label *mCurrentLabel;
+ CheckBox *mUnequipCheck;
+
+ int getIndexFromGrid(int pointX, int pointY) const;
+
+ int mBoxWidth;
+ int mBoxHeight;
+ int mCursorPosX, mCursorPosY;
+ int mGridWidth, mGridHeight;
+ bool mItemClicked;
+ Item *mItemMoved;
+
+ void save();
+
+ int mItems[10][9];
+ int mItemSelected;
+
+ int mCurrentOutfit;
+};
+
+extern OutfitWindow *outfitWindow;
+
+#endif
diff --git a/src/gui/partywindow.cpp b/src/gui/partywindow.cpp
index 1260a2c3..5e384413 100644
--- a/src/gui/partywindow.cpp
+++ b/src/gui/partywindow.cpp
@@ -54,8 +54,8 @@ PartyWindow::PartyWindow() :
setSaveVisible(true);
setCloseButton(true);
setMinWidth(120);
- setMinHeight(200);
- setDefaultSize(590, 200, 150, 200);
+ setMinHeight(55);
+ setDefaultSize(590, 200, 150, 60);
loadWindowState();
}
@@ -123,6 +123,7 @@ void PartyWindow::updateMember(int id, const std::string &memberName,
member->name = memberName;
member->leader = leader;
member->online = online;
+ member->avatar->setDisplayBold(leader);
member->avatar->setName(memberName);
member->avatar->setOnline(online);
diff --git a/src/gui/serverselectdialog.cpp b/src/gui/serverselectdialog.cpp
index ccdf2bb6..f492ebc7 100644
--- a/src/gui/serverselectdialog.cpp
+++ b/src/gui/serverselectdialog.cpp
@@ -55,7 +55,7 @@ class ServerListModel : public gcn::ListModel
}
};
-ServerSelectDialog::ServerSelectDialog(LoginData *loginData, int nextState):
+ServerSelectDialog::ServerSelectDialog(LoginData *loginData, State nextState):
Window(_("Select Server")),
mLoginData(loginData),
mNextState(nextState)
diff --git a/src/gui/serverselectdialog.h b/src/gui/serverselectdialog.h
index b80ad286..fd1484af 100644
--- a/src/gui/serverselectdialog.h
+++ b/src/gui/serverselectdialog.h
@@ -24,6 +24,8 @@
#include "gui/widgets/window.h"
+#include "main.h"
+
#include <guichan/actionlistener.hpp>
#include <guichan/listmodel.hpp>
@@ -42,7 +44,7 @@ class ServerSelectDialog : public Window, public gcn::ActionListener {
*
* @see Window::Window
*/
- ServerSelectDialog(LoginData *loginData, int nextState);
+ ServerSelectDialog(LoginData *loginData, State nextState);
/**
* Destructor.
@@ -59,7 +61,7 @@ class ServerSelectDialog : public Window, public gcn::ActionListener {
ServerListModel *mServerListModel;
gcn::ListBox *mServerList;
gcn::Button *mOkButton;
- int mNextState;
+ State mNextState;
};
#endif
diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp
index e73f9b74..aebcf61b 100644
--- a/src/gui/setup.cpp
+++ b/src/gui/setup.cpp
@@ -46,6 +46,7 @@ extern Window *inventoryWindow;
extern Window *npcTextDialog;
extern Window *npcStringDialog;
extern Window *skillDialog;
+extern Window *partyWindow;
extern Window *minimap;
extern Window *equipmentWindow;
extern Window *tradeWindow;
@@ -145,6 +146,7 @@ void Setup::action(const gcn::ActionEvent &event)
#endif
inventoryWindow->resetToDefaultSize();
skillDialog->resetToDefaultSize();
+ partyWindow->resetToDefaultSize();
minimap->resetToDefaultSize();
equipmentWindow->resetToDefaultSize();
tradeWindow->resetToDefaultSize();
diff --git a/src/gui/skin.cpp b/src/gui/skin.cpp
index f6eb0d58..5881a073 100644
--- a/src/gui/skin.cpp
+++ b/src/gui/skin.cpp
@@ -101,16 +101,14 @@ void Skin::updateAlpha()
int Skin::getMinWidth() const
{
- return (mBorder.grid[ImageRect::UPPER_LEFT]->getWidth() +
- mBorder.grid[ImageRect::UPPER_CENTER]->getWidth()) +
- mBorder.grid[ImageRect::UPPER_RIGHT]->getWidth();
+ return mBorder.grid[ImageRect::UPPER_LEFT]->getWidth() +
+ mBorder.grid[ImageRect::UPPER_RIGHT]->getWidth();
}
int Skin::getMinHeight() const
{
- return (mBorder.grid[ImageRect::UPPER_LEFT]->getHeight() +
- mBorder.grid[ImageRect::LEFT]->getHeight()) +
- mBorder.grid[ImageRect::LOWER_LEFT]->getHeight();
+ return mBorder.grid[ImageRect::UPPER_LEFT]->getHeight() +
+ mBorder.grid[ImageRect::LOWER_LEFT]->getHeight();
}
SkinLoader::SkinLoader()
diff --git a/src/gui/textrenderer.h b/src/gui/textrenderer.h
index 712c1312..c8ff5833 100644
--- a/src/gui/textrenderer.h
+++ b/src/gui/textrenderer.h
@@ -50,7 +50,7 @@ class TextRenderer
if (shadow)
{
graphics->setColor(guiPalette->getColor(Palette::SHADOW,
- alpha / 2));
+ alpha / 2));
if (outline)
{
graphics->drawText(text, x + 2, y + 2, align);
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index f92a81b8..787723c0 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -195,7 +195,7 @@ void Viewport::draw(gcn::Graphics *gcnGraphics)
mMap->drawCollision(graphics,
(int) mPixelViewX,
(int) mPixelViewY);
-#if 0
+#if EATHENA_SUPPORT
drawDebugPath(graphics);
#endif
}
@@ -265,8 +265,8 @@ void Viewport::drawDebugPath(Graphics *graphics)
const Vector &playerPos = player_node->getPosition();
Path debugPath = mMap->findPath(
- (int) playerPos.x / 32,
- (int) playerPos.y / 32,
+ (int) (playerPos.x - 16) / 32,
+ (int) (playerPos.y - 32) / 32,
mouseTileX, mouseTileY, 0xFF);
drawPath(graphics, debugPath);
@@ -357,24 +357,12 @@ void Viewport::mousePressed(gcn::MouseEvent &event)
if (player_node->withinAttackRange(being) ||
keyboard.isKeyActive(keyboard.KEY_ATTACK))
{
- player_node->setGotoTarget(being);
-//TODO: This can be changed when TMWServ moves to target based combat
-#ifdef TMWSERV_SUPPORT
- player_node->attack();
-#else
player_node->attack(being,
!keyboard.isKeyActive(keyboard.KEY_TARGET));
-#endif
-
}
else
{
-#ifdef TMWSERV_SUPPORT
- player_node->setDestination(event.getX() + (int) mPixelViewX,
- event.getY() + (int) mPixelViewY);
-#else
- player_node->setDestination(tilex, tiley);
-#endif
+ player_node->setGotoTarget(being);
}
break;
default:
@@ -403,9 +391,9 @@ void Viewport::mousePressed(gcn::MouseEvent &event)
event.getY() + (int) mPixelViewY);
}
#else
- player_node->stopAttack();
player_node->setDestination(tilex, tiley);
#endif
+ player_node->stopAttack();
mPlayerFollowMouse = true;
}
}
diff --git a/src/gui/widgets/avatar.cpp b/src/gui/widgets/avatar.cpp
index 16c77233..f7273c75 100644
--- a/src/gui/widgets/avatar.cpp
+++ b/src/gui/widgets/avatar.cpp
@@ -23,6 +23,7 @@
#include "localplayer.h"
+#include "gui/gui.h"
#include "gui/widgets/icon.h"
#include "gui/widgets/label.h"
@@ -39,7 +40,8 @@ namespace {
Avatar::Avatar():
mHp(0),
- mMaxHp(0)
+ mMaxHp(0),
+ mDisplayBold(false)
{
setOpaque(false);
@@ -111,6 +113,8 @@ void Avatar::updateAvatarLabel()
if (mName != player_node->getName() && mMaxHp != 0)
ss << " (" << mHp << "/" << mMaxHp << ")";
+ if (mDisplayBold)
+ mLabel->setFont(boldFont);
mLabel->setCaption(ss.str());
mLabel->adjustSize();
}
diff --git a/src/gui/widgets/avatar.h b/src/gui/widgets/avatar.h
index 32586668..dbe30a94 100644
--- a/src/gui/widgets/avatar.h
+++ b/src/gui/widgets/avatar.h
@@ -51,6 +51,8 @@ public:
void setMaxHp(int maxHp);
+ void setDisplayBold(bool displayBold) { mDisplayBold = displayBold; }
+
private:
void updateAvatarLabel();
@@ -59,6 +61,7 @@ private:
int mMaxHp;
Icon *mStatus;
gcn::Label *mLabel;
+ bool mDisplayBold;
};
#endif // AVATAR_H
diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp
index 711680d1..85353bf7 100644
--- a/src/gui/widgets/chattab.cpp
+++ b/src/gui/widgets/chattab.cpp
@@ -227,15 +227,19 @@ void ChatTab::chatInput(std::string &msg)
std::string temp = msg.substr(start + 1, end - start - 1);
- toLower(trim(temp));
-
- const ItemInfo itemInfo = ItemDB::get(temp);
- if (itemInfo.getName() != _("Unknown item"))
+ // Do not parse an empty string (it crashes the client)
+ if (!temp.empty())
{
- msg.insert(end, "@@");
- msg.insert(start+1, "|");
- msg.insert(start+1, toString(itemInfo.getId()));
- msg.insert(start+1, "@@");
+ toLower(trim(temp));
+
+ const ItemInfo itemInfo = ItemDB::get(temp);
+ if (itemInfo.getName() != _("Unknown item"))
+ {
+ msg.insert(end, "@@");
+ msg.insert(start+1, "|");
+ msg.insert(start+1, toString(itemInfo.getId()));
+ msg.insert(start+1, "@@");
+ }
}
}
start = msg.find('[', start + 1);
diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp
index 58f24651..c673ffb3 100644
--- a/src/gui/widgets/progressbar.cpp
+++ b/src/gui/widgets/progressbar.cpp
@@ -31,6 +31,8 @@
#include "resources/image.h"
#include "resources/resourcemanager.h"
+#include "utils/dtor.h"
+
#include <guichan/font.hpp>
ImageRect ProgressBar::mBorder;
@@ -59,7 +61,7 @@ ProgressBar::ProgressBar(float progress,
mBorder.grid[1] = dBorders->getSubImage(4, 0, 3, 4);
mBorder.grid[2] = dBorders->getSubImage(7, 0, 4, 4);
mBorder.grid[3] = dBorders->getSubImage(0, 4, 4, 10);
- mBorder.grid[4] = resman->getImage("graphics/gui/bg_quad_dis.png");
+ mBorder.grid[4] = dBorders->getSubImage(4, 4, 3, 10);
mBorder.grid[5] = dBorders->getSubImage(7, 4, 4, 10);
mBorder.grid[6] = dBorders->getSubImage(0, 15, 4, 4);
mBorder.grid[7] = dBorders->getSubImage(4, 15, 3, 4);
@@ -82,15 +84,7 @@ ProgressBar::~ProgressBar()
if (mInstances == 0)
{
- delete mBorder.grid[0];
- delete mBorder.grid[1];
- delete mBorder.grid[2];
- delete mBorder.grid[3];
- mBorder.grid[4]->decRef();
- delete mBorder.grid[5];
- delete mBorder.grid[6];
- delete mBorder.grid[7];
- delete mBorder.grid[8];
+ for_each(mBorder.grid, mBorder.grid + 9, dtor<Image*>());
}
}
diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp
index 5e33a4ed..8964f072 100644
--- a/src/gui/windowmenu.cpp
+++ b/src/gui/windowmenu.cpp
@@ -48,7 +48,6 @@ extern Window *guildWindow;
extern Window *magicDialog;
#endif
-
WindowMenu::WindowMenu():
mEmotePopup(0)
{