summaryrefslogtreecommitdiff
path: root/src/gui/equipmentwindow.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-05-22 00:23:08 +0300
committerAndrei Karas <akaras@inbox.ru>2011-05-22 04:19:02 +0300
commit7c34adebb068549ca6a56bdf1b211398a0b1de11 (patch)
tree04a1e1ba87fa2005fc32c2358b2747390d1cd9d0 /src/gui/equipmentwindow.cpp
parent54f8367afe9d30c21bcda057872439199c7dd9c1 (diff)
downloadmanaverse-7c34adebb068549ca6a56bdf1b211398a0b1de11.tar.gz
manaverse-7c34adebb068549ca6a56bdf1b211398a0b1de11.tar.bz2
manaverse-7c34adebb068549ca6a56bdf1b211398a0b1de11.tar.xz
manaverse-7c34adebb068549ca6a56bdf1b211398a0b1de11.zip
Allow show equipment from other players from context menu "show items".
Also allow undress separate items from players locally.
Diffstat (limited to 'src/gui/equipmentwindow.cpp')
-rw-r--r--src/gui/equipmentwindow.cpp73
1 files changed, 64 insertions, 9 deletions
diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp
index d5bfa4ddc..2a0ad96bb 100644
--- a/src/gui/equipmentwindow.cpp
+++ b/src/gui/equipmentwindow.cpp
@@ -20,15 +20,17 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "gui/equipmentwindow.h"
+
#include "gui/widgets/button.h"
+#include "being.h"
#include "equipment.h"
#include "graphics.h"
#include "inventory.h"
#include "item.h"
#include "localplayer.h"
-#include "gui/equipmentwindow.h"
#include "gui/itempopup.h"
#include "gui/theme.h"
#include "gui/setup.h"
@@ -69,21 +71,28 @@ static const int boxPosition[][2] =
{ 129, 123 }, // EQUIP_EVOL_RING2_SLOT
};
-EquipmentWindow::EquipmentWindow(Equipment *equipment):
+EquipmentWindow::EquipmentWindow(Equipment *equipment, Being *being,
+ bool foring):
Window(_("Equipment")),
mEquipment(equipment),
- mSelected(-1)
+ mSelected(-1),
+ mForing(foring)
{
+ mBeing = being;
mItemPopup = new ItemPopup;
if (setupWindow)
setupWindow->registerWindowForReset(this);
// Control that shows the Player
- PlayerBox *playerBox = new PlayerBox;
- playerBox->setDimension(gcn::Rectangle(50, 80, 74, 168));
- playerBox->setPlayer(player_node);
+ mPlayerBox = new PlayerBox;
+ mPlayerBox->setDimension(gcn::Rectangle(50, 80, 74, 168));
+ mPlayerBox->setPlayer(being);
+
+ if (foring)
+ setWindowName("Being equipment");
+ else
+ setWindowName("Equipment");
- setWindowName("Equipment");
setCloseButton(true);
setSaveVisible(true);
setDefaultSize(180, 345, ImageRect::CENTER);
@@ -95,7 +104,7 @@ EquipmentWindow::EquipmentWindow(Equipment *equipment):
area.height - mUnequip->getHeight() - 5);
mUnequip->setEnabled(false);
- add(playerBox);
+ add(mPlayerBox);
add(mUnequip);
for (int i = 0; i < Equipment::EQUIP_VECTOREND; i++)
@@ -138,6 +147,9 @@ void EquipmentWindow::draw(gcn::Graphics *graphics)
g->drawRectangle(gcn::Rectangle(mEquipBox[i].posX, mEquipBox[i].posY,
BOX_WIDTH, BOX_HEIGHT));
+ if (!mEquipment)
+ continue;
+
Item *item = mEquipment->getEquipment(i);
if (item)
{
@@ -165,6 +177,9 @@ void EquipmentWindow::draw(gcn::Graphics *graphics)
void EquipmentWindow::action(const gcn::ActionEvent &event)
{
+ if (!mEquipment)
+ return;
+
if (event.getId() == "unequip" && mSelected > -1)
{
Item *item = mEquipment->getEquipment(mSelected);
@@ -175,6 +190,9 @@ void EquipmentWindow::action(const gcn::ActionEvent &event)
Item *EquipmentWindow::getItem(int x, int y) const
{
+ if (!mEquipment)
+ return 0;
+
for (int i = 0; i < Equipment::EQUIP_VECTOREND; i++)
{
gcn::Rectangle tRect(mEquipBox[i].posX, mEquipBox[i].posY,
@@ -190,11 +208,16 @@ void EquipmentWindow::mousePressed(gcn::MouseEvent& mouseEvent)
{
Window::mousePressed(mouseEvent);
+ if (!mEquipment)
+ return;
+
const int x = mouseEvent.getX();
const int y = mouseEvent.getY();
if (mouseEvent.getButton() == gcn::MouseEvent::LEFT)
{
+ if (mForing)
+ return;
// Checks if any of the presses were in the equip boxes.
for (int i = 0; i < Equipment::EQUIP_VECTOREND; i++)
{
@@ -216,7 +239,12 @@ void EquipmentWindow::mousePressed(gcn::MouseEvent& mouseEvent)
const int mx = x + getX();
const int my = y + getY();
if (viewport)
- viewport->showPopup(this, mx, my, item, true);
+ {
+ if (mForing)
+ viewport->showUndressPopup(mx, my, mBeing, item);
+ else
+ viewport->showPopup(this, mx, my, item, true);
+ }
}
}
}
@@ -259,3 +287,30 @@ void EquipmentWindow::setSelected(int index)
if (mUnequip)
mUnequip->setEnabled(mSelected != -1);
}
+
+void EquipmentWindow::setBeing(Being *being)
+{
+ mPlayerBox->setPlayer(being);
+ mBeing = being;
+ if (!being)
+ {
+ delete mEquipment;
+ mEquipment = 0;
+ return;
+ }
+ mEquipment = being->getEquipment();
+ if (!mEquipment)
+ return;
+}
+
+void EquipmentWindow::updateBeing(Being *being)
+{
+ if (being == mBeing)
+ setBeing(being);
+}
+
+void EquipmentWindow::resetBeing(Being *being)
+{
+ if (being == mBeing)
+ setBeing(0);
+}