summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Makefile.am2
-rw-r--r--src/being.cpp11
-rw-r--r--src/being.h12
-rw-r--r--src/gui/beingpopup.cpp114
-rw-r--r--src/gui/beingpopup.h66
-rw-r--r--src/gui/popupmenu.h6
-rw-r--r--src/gui/viewport.cpp9
-rw-r--r--src/gui/viewport.h2
-rw-r--r--src/net/ea/beinghandler.cpp10
-rw-r--r--src/net/ea/network.cpp2
-rw-r--r--src/net/ea/protocol.h1
11 files changed, 230 insertions, 5 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 75b699b7..0a34bddd 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -95,6 +95,8 @@ mana_SOURCES = gui/widgets/avatarlistbox.cpp \
gui/widgets/window.h \
gui/widgets/windowcontainer.cpp \
gui/widgets/windowcontainer.h \
+ gui/beingpopup.cpp \
+ gui/beingpopup.h \
gui/buy.cpp \
gui/buy.h \
gui/buysell.cpp \
diff --git a/src/being.cpp b/src/being.cpp
index 33194e0e..247e193a 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -363,6 +363,17 @@ void Being::setShowName(bool doShowName)
}
}
+void Being::setGuildName(const std::string &name)
+{
+ logger->log("Got guild name \"%s\" for being %s(%i)", name.c_str(), mName.c_str(), mId);
+}
+
+
+void Being::setGuildPos(const std::string &pos)
+{
+ logger->log("Got guild position \"%s\" for being %s(%i)", pos.c_str(), mName.c_str(), mId);
+}
+
void Being::setMap(Map *map)
{
// Remove sprite from potential previous map
diff --git a/src/being.h b/src/being.h
index 2eadfb66..58fe4c77 100644
--- a/src/being.h
+++ b/src/being.h
@@ -240,6 +240,17 @@ class Being : public Sprite, public ConfigListener
virtual void setShowName(bool doShowName);
/**
+ * Following are set from the server (mainly for players)
+ */
+ void setPartyName(const std::string &name) { mPartyName = name; }
+
+ const std::string &getPartyName() const { return mPartyName; }
+
+ virtual void setGuildName(const std::string &name);
+
+ virtual void setGuildPos(const std::string &pos);
+
+ /**
* Get the number of hairstyles implemented
*/
static int getNumOfHairstyles()
@@ -602,6 +613,7 @@ class Being : public Sprite, public ConfigListener
Uint8 mSpriteDirection; /**< Facing direction */
Map *mMap; /**< Map on which this being resides */
std::string mName; /**< Name of character */
+ std::string mPartyName;
MapSprite mMapSprite;
/**
diff --git a/src/gui/beingpopup.cpp b/src/gui/beingpopup.cpp
new file mode 100644
index 00000000..89933067
--- /dev/null
+++ b/src/gui/beingpopup.cpp
@@ -0,0 +1,114 @@
+/*
+ * The Mana Client
+ * Copyright (C) 2008 The Legend of Mazzeroth Development Team
+ * Copyright (C) 2008-2009 The Mana World Development Team
+ * Copyright (C) 2009-2010 The Mana Developers
+ *
+ * This file is part of The Mana Client.
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "gui/beingpopup.h"
+
+#include "graphics.h"
+#include "units.h"
+
+#include "being.h"
+
+#include "gui/gui.h"
+#include "gui/palette.h"
+
+#include "gui/widgets/textbox.h"
+
+#include "utils/gettext.h"
+#include "utils/stringutils.h"
+
+#include <guichan/font.hpp>
+
+
+BeingPopup::BeingPopup():
+ Popup("BeingPopup")
+{
+ // Item Name
+ mBeingName = new TextBox();
+ mBeingName->setFont(boldFont);
+ mBeingName->setPosition(getPadding(), getPadding());
+
+ const int fontHeight = getFont()->getHeight();
+
+ // Item Description
+ mBeingParty = new TextBox();
+ mBeingParty->setPosition(getPadding(), fontHeight);
+
+ add(mBeingName);
+ add(mBeingParty);
+
+ loadPopupConfiguration();
+}
+
+BeingPopup::~BeingPopup()
+{
+}
+
+void BeingPopup::setBeing(int x, int y, Being *b)
+{
+ if (!b)
+ {
+ setVisible(false);
+ return;
+ }
+
+ if (!(b->getPartyName().empty()))
+ {
+ mBeingName->setTextWrapped(b->getName(), 196);
+ mBeingParty->setTextWrapped(strprintf(_("Party: %s"),b->getPartyName().c_str()), 196);
+
+ int minWidth = mBeingName->getMinWidth();
+
+ if (mBeingParty->getMinWidth() > minWidth)
+ minWidth = mBeingParty->getMinWidth();
+
+ const int height = getFont()->getHeight();
+
+ setContentSize(minWidth, (height * 2) + 10);
+
+ view(x, y);
+ return;
+ }
+
+ setVisible(false);
+}
+
+gcn::Color BeingPopup::getColor()
+{
+ return guiPalette->getColor(Palette::GENERIC);
+}
+
+void BeingPopup::view(int x, int y)
+{
+ const int distance = 20;
+
+ int posX = std::max(0, x - getWidth() / 2);
+ int posY = y + distance;
+
+ if (posX > graphics->getWidth() - getWidth())
+ posX = graphics->getWidth() - getWidth();
+ if (posY > graphics->getHeight() - getHeight())
+ posY = y - getHeight() - distance;
+
+ setPosition(posX, posY);
+ setVisible(true);
+ requestMoveToTop();
+}
diff --git a/src/gui/beingpopup.h b/src/gui/beingpopup.h
new file mode 100644
index 00000000..964235bb
--- /dev/null
+++ b/src/gui/beingpopup.h
@@ -0,0 +1,66 @@
+/*
+ * The Mana Client
+ * Copyright (C) 2008 The Legend of Mazzeroth Development Team
+ * Copyright (C) 2008-2009 The Mana World Development Team
+ * Copyright (C) 2009-2010 The Mana Developers
+ *
+ * This file is part of The Mana Client.
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef BEINGPOPUP_H
+#define BEINGPOPUP_H
+
+#include "gui/widgets/popup.h"
+
+#include <guichan/mouselistener.hpp>
+
+class TextBox;
+class Being;
+
+/**
+ * A popup that displays information about an item.
+ */
+class BeingPopup : public Popup
+{
+ public:
+ /**
+ * Constructor. Initializes the item popup.
+ */
+ BeingPopup();
+
+ /**
+ * Destructor. Cleans up the item popup on deletion.
+ */
+ ~BeingPopup();
+
+ /**
+ * Sets the info to be displayed given a particular item.
+ */
+ void setBeing(int x, int y, Being *b);
+
+ /**
+ * Sets the location to display the item popup.
+ */
+ void view(int x, int y);
+
+ private:
+ TextBox *mBeingName;
+ TextBox *mBeingParty;
+
+ static gcn::Color getColor();
+};
+
+#endif // BEINGPOPUP_H
diff --git a/src/gui/popupmenu.h b/src/gui/popupmenu.h
index 3299694f..57cd5ee1 100644
--- a/src/gui/popupmenu.h
+++ b/src/gui/popupmenu.h
@@ -59,6 +59,12 @@ class PopupMenu : public Popup, public LinkHandler
void showPopup(int x, int y, Item *item, bool isInventory);
/**
+ * Just shows general information about a being
+ */
+ void showPopupBeing(int x, int y, Being *being);
+
+
+ /**
* Handles link action.
*/
void handleLink(const std::string &link);
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index b51d4878..543082e7 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -36,6 +36,7 @@
#include "gui/gui.h"
#include "gui/ministatus.h"
#include "gui/popupmenu.h"
+#include "gui/beingpopup.h"
#include "net/net.h"
@@ -73,6 +74,7 @@ Viewport::Viewport():
config.addListener("visiblenames", this);
mPopupMenu = new PopupMenu;
+ mBeingPopup = new BeingPopup;
}
Viewport::~Viewport()
@@ -472,10 +474,11 @@ void Viewport::mouseMoved(gcn::MouseEvent &event)
if (!mMap || !player_node)
return;
- const int tilex = (event.getX() + (int) mPixelViewX) / 32;
- const int tiley = (event.getY() + (int) mPixelViewY) / 32;
+ const int x = (event.getX() + (int) mPixelViewX);
+ const int y = (event.getY() + (int) mPixelViewY);
- mSelectedBeing = beingManager->findBeing(tilex, tiley);
+ mSelectedBeing = beingManager->findBeingByPixel(x, y);
+ mBeingPopup->setBeing(getMouseX(), getMouseY(), mSelectedBeing);
}
void Viewport::toggleDebugPath()
diff --git a/src/gui/viewport.h b/src/gui/viewport.h
index a52d7806..9a64ff78 100644
--- a/src/gui/viewport.h
+++ b/src/gui/viewport.h
@@ -36,6 +36,7 @@ class ImageSet;
class Item;
class Map;
class PopupMenu;
+class BeingPopup;
/** Delay between two mouse calls when dragging mouse and move the player */
const int walkingMouseDelay = 500;
@@ -187,6 +188,7 @@ class Viewport : public WindowContainer, public gcn::MouseListener,
PopupMenu *mPopupMenu; /**< Popup menu. */
Being *mSelectedBeing; /**< Current selected being. */
+ BeingPopup *mBeingPopup;
};
extern Viewport *viewport; /**< The viewport */
diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp
index fd08ecaf..56f23fdb 100644
--- a/src/net/ea/beinghandler.cpp
+++ b/src/net/ea/beinghandler.cpp
@@ -56,6 +56,7 @@ BeingHandler::BeingHandler(bool enableSync):
SMSG_BEING_CHANGE_LOOKS,
SMSG_BEING_CHANGE_LOOKS2,
SMSG_BEING_NAME_RESPONSE,
+ SMSG_PLAYER_GUILD_PARTY_INFO,
SMSG_BEING_CHANGE_DIRECTION,
SMSG_PLAYER_UPDATE_1,
SMSG_PLAYER_UPDATE_2,
@@ -480,7 +481,14 @@ void BeingHandler::handleMessage(Net::MessageIn &msg)
dstBeing->setName(msg.readString(24));
}
break;
-
+ case SMSG_PLAYER_GUILD_PARTY_INFO:
+ if ((dstBeing = beingManager->findBeing(msg.readInt32())))
+ {
+ dstBeing->setPartyName(msg.readString(24));
+ dstBeing->setGuildName(msg.readString(24));
+ dstBeing->setGuildPos(msg.readString(24));
+ }
+ break;
case SMSG_BEING_CHANGE_DIRECTION:
if (!(dstBeing = beingManager->findBeing(msg.readInt32())))
{
diff --git a/src/net/ea/network.cpp b/src/net/ea/network.cpp
index 28cf60dd..7214ef10 100644
--- a/src/net/ea/network.cpp
+++ b/src/net/ea/network.cpp
@@ -69,7 +69,7 @@ short packet_lengths[] = {
14, 30, 10, 3, -1, 6,106, -1, 4, 5, 4, -1, 6, 7, -1, -1,
// #0x0180
6, 3,106, 10, 10, 34, 0, 6, 8, 4, 4, 4, 29, -1, 10, 6,
- 90, 86, 24, 6, 30,102, 9, 4, 8, 4, 14, 10, 4, 6, 2, 6,
+ 90, 86, 24, 6, 30, 78, 9, 4, 8, 4, 14, 10, 4, 6, 2, 6,
3, 3, 35, 5, 11, 26, -1, 4, 4, 6, 10, 12, 6, -1, 4, 4,
11, 7, -1, 67, 12, 18,114, 6, 3, 6, 26, 26, 26, 26, 2, 3,
// #0x01C0
diff --git a/src/net/ea/protocol.h b/src/net/ea/protocol.h
index 75920e18..24fe5ba5 100644
--- a/src/net/ea/protocol.h
+++ b/src/net/ea/protocol.h
@@ -133,6 +133,7 @@ static const int STORAGE_OFFSET = 1;
#define SMSG_BEING_RESURRECT 0x0148
#define SMSG_PLAYER_STATUS_CHANGE 0x0119
+#define SMSG_PLAYER_GUILD_PARTY_INFO 0x0195
#define SMSG_BEING_STATUS_CHANGE 0x0196
#define SMSG_NPC_MESSAGE 0x00b4