summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/Makefile.am2
-rw-r--r--src/game.cpp5
-rw-r--r--src/gui/item_amount.cpp19
-rw-r--r--src/gui/item_amount.h2
-rw-r--r--src/inventory.h1
-rw-r--r--src/localplayer.cpp7
-rw-r--r--src/localplayer.h5
-rw-r--r--src/net/inventoryhandler.cpp73
-rw-r--r--tmw.cbp2
10 files changed, 94 insertions, 24 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index e7abb5fd..fc6d1f35 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -191,6 +191,8 @@ SET(SRCS
gui/speechbubble.h
gui/status.cpp
gui/status.h
+ gui/storagewindow.cpp
+ gui/storagewindow.h
gui/table.cpp
gui/table.h
gui/table_model.cpp
diff --git a/src/Makefile.am b/src/Makefile.am
index e8e9a695..4982c215 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -141,6 +141,8 @@ tmw_SOURCES = gui/widgets/dropdown.cpp \
gui/speechbubble.h \
gui/status.cpp \
gui/status.h \
+ gui/storagewindow.cpp \
+ gui/storagewindow.h \
gui/table.cpp \
gui/table.h \
gui/table_model.cpp \
diff --git a/src/game.cpp b/src/game.cpp
index 40bfd5e4..9f8a2613 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -69,6 +69,7 @@
#include "gui/setup.h"
#include "gui/skill.h"
#include "gui/status.h"
+#include "gui/storagewindow.h"
#include "gui/trade.h"
#include "gui/viewport.h"
@@ -128,6 +129,7 @@ HelpWindow *helpWindow;
DebugWindow *debugWindow;
ShortcutWindow *itemShortcutWindow;
ShortcutWindow *emoteShortcutWindow;
+StorageWindow *storageWindow;
BeingManager *beingManager = NULL;
FloorItemManager *floorItemManager = NULL;
@@ -212,6 +214,7 @@ void createGuiWindows(Network *network)
new ItemShortcutContainer);
emoteShortcutWindow = new ShortcutWindow("emoteShortcut",
new EmoteShortcutContainer);
+ storageWindow = new StorageWindow(network);
// Set initial window visibility
chatWindow->setVisible((bool) config.getValue(
@@ -231,6 +234,7 @@ void createGuiWindows(Network *network)
emoteShortcutWindow->getWindowName() + "Visible", true));
minimap->setVisible((bool) config.getValue(
minimap->getWindowName() + "Visible", true));
+ storageWindow->setVisible(false);
}
/**
@@ -261,6 +265,7 @@ void destroyGuiWindows()
delete debugWindow;
delete itemShortcutWindow;
delete emoteShortcutWindow;
+ delete storageWindow;
}
Game::Game(Network *network):
diff --git a/src/gui/item_amount.cpp b/src/gui/item_amount.cpp
index 92be3d6e..280f063e 100644
--- a/src/gui/item_amount.cpp
+++ b/src/gui/item_amount.cpp
@@ -23,6 +23,7 @@
#include "inttextfield.h"
#include "item_amount.h"
#include "slider.h"
+#include "storagewindow.h"
#include "trade.h"
#include "widgets/layout.h"
@@ -80,6 +81,14 @@ ItemAmountWindow::ItemAmountWindow(int usage, Window *parent, Item *item):
setCaption(_("Select amount of items to drop."));
okButton->setActionEventId("Drop");
break;
+ case AMOUNT_STORE_ADD:
+ setCaption(_("Select amount of items to store."));
+ okButton->setActionEventId("AddStore");
+ break;
+ case AMOUNT_STORE_REMOVE:
+ setCaption(_("Select amount of items to remove from storage."));
+ okButton->setActionEventId("RemoveStore");
+ break;
default:
break;
}
@@ -123,6 +132,16 @@ void ItemAmountWindow::action(const gcn::ActionEvent &event)
tradeWindow->tradeItem(mItem, mItemAmountTextField->getValue());
scheduleDelete();
}
+ else if (event.getId() == "AddStore")
+ {
+ storageWindow->addStore(mItem, mItemAmountTextField->getValue());
+ scheduleDelete();
+ }
+ else if (event.getId() == "RemoveStore")
+ {
+ storageWindow->removeStore(mItem, mItemAmountTextField->getValue());
+ scheduleDelete();
+ }
mItemAmountTextField->setValue(amount);
mItemAmountSlide->setValue(amount);
}
diff --git a/src/gui/item_amount.h b/src/gui/item_amount.h
index 618d7d51..26cca32c 100644
--- a/src/gui/item_amount.h
+++ b/src/gui/item_amount.h
@@ -31,6 +31,8 @@ class Item;
#define AMOUNT_TRADE_ADD 1
#define AMOUNT_ITEM_DROP 2
+#define AMOUNT_STORE_ADD 3
+#define AMOUNT_STORE_REMOVE 4
/**
* Window used for selecting the amount of items to drop or trade.
diff --git a/src/inventory.h b/src/inventory.h
index 2c5d99e3..df2aac38 100644
--- a/src/inventory.h
+++ b/src/inventory.h
@@ -25,6 +25,7 @@
class Item;
#define INVENTORY_SIZE 102
+#define STORAGE_SIZE 301
class Inventory
{
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index abeb134c..296bc28c 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -38,6 +38,7 @@
#include "gui/gui.h"
#include "gui/ministatus.h"
+#include "gui/storagewindow.h"
#include "net/messageout.h"
#include "net/protocol.h"
@@ -742,3 +743,9 @@ void LocalPlayer::loadTargetCursor(std::string filename, int width, int height,
mTargetCursor[index][size] = currentCursor;
}
+void LocalPlayer::setInStorage(bool inStorage)
+{
+ mInStorage = inStorage;
+
+ storageWindow->setVisible(inStorage);
+}
diff --git a/src/localplayer.h b/src/localplayer.h
index ba6e7670..ce181c74 100644
--- a/src/localplayer.h
+++ b/src/localplayer.h
@@ -30,9 +30,6 @@
// TODO move into some sane place...
#define MAX_SLOT 2
-#define INVENTORY_SIZE 102
-#define STORAGE_SIZE 301
-
class Equipment;
class FloorItem;
class ImageSet;
@@ -194,7 +191,7 @@ class LocalPlayer : public Player
* Accessors for mInStorage
*/
bool getInStorage() { return mInStorage; }
- void setInStorage(bool inStorage) { mInStorage = inStorage; }
+ void setInStorage(bool inStorage);
/**
* Sets the amount of XP. Shows XP gaining effect if the player is on
diff --git a/src/net/inventoryhandler.cpp b/src/net/inventoryhandler.cpp
index d78a7a45..ebcca885 100644
--- a/src/net/inventoryhandler.cpp
+++ b/src/net/inventoryhandler.cpp
@@ -33,6 +33,7 @@
#include "../log.h"
#include "../gui/chat.h"
+#include "../gui/storagewindow.h"
#include "../resources/iteminfo.h"
@@ -71,7 +72,6 @@ void InventoryHandler::handleMessage(MessageIn *msg)
{
case SMSG_PLAYER_INVENTORY:
case SMSG_PLAYER_STORAGE_ITEMS:
- case SMSG_PLAYER_STORAGE_EQUIP:
switch (msg->getId()) {
case SMSG_PLAYER_INVENTORY:
// Clear inventory - this will be a complete refresh
@@ -85,11 +85,10 @@ void InventoryHandler::handleMessage(MessageIn *msg)
* clear storage here
*/
storage->clear();
- logger->log("Received SMSG_PLAYER_STORAGE_ITEMS");
break;
default:
- logger->log("Received SMSG_PLAYER_STORAGE_EQUIP");
- break;
+ logger->log("HOW DID WE GET HERE?");
+ return;
}
msg->readInt16(); // length
number = (msg->getLength() - 4) / 18;
@@ -99,17 +98,8 @@ void InventoryHandler::handleMessage(MessageIn *msg)
itemId = msg->readInt16();
itemType = msg->readInt8();
identified = msg->readInt8();
- if (msg->getId() == SMSG_PLAYER_STORAGE_EQUIP) {
- amount = 1;
- msg->readInt16(); // Equip Point?
- } else {
- amount = msg->readInt16();
- }
+ amount = msg->readInt16();
arrow = msg->readInt16();
- if (msg->getId() == SMSG_PLAYER_STORAGE_EQUIP) {
- msg->readInt8(); // Attribute (broken)
- msg->readInt8(); // Refine level
- }
for (int i = 0; i < 4; i++)
cards[i] = msg->readInt16();
@@ -129,6 +119,29 @@ void InventoryHandler::handleMessage(MessageIn *msg)
}
break;
+ case SMSG_PLAYER_STORAGE_EQUIP:
+ msg->readInt16(); // length
+ number = (msg->getLength() - 4) / 20;
+
+ for (int loop = 0; loop < number; loop++) {
+ index = msg->readInt16();
+ itemId = msg->readInt16();
+ itemType = msg->readInt8();
+ identified = msg->readInt8();
+ amount = 1;
+ msg->readInt16(); // Equip Point?
+ msg->readInt16(); // Another Equip Point?
+ msg->readInt8(); // Attribute (broken)
+ msg->readInt8(); // Refine level
+ for (int i = 0; i < 4; i++)
+ cards[i] = msg->readInt16();
+
+ logger->log("Index:%d, ID:%d, Type:%d, Identified:%d, Qty:%d, Cards:%d, %d, %d, %d",
+ index, itemId, itemType, identified, amount, cards[0], cards[1], cards[2], cards[3]);
+ storage->setItem(index, itemId, amount, false);
+ }
+ break;
+
case SMSG_PLAYER_INVENTORY_ADD:
index = msg->readInt16();
amount = msg->readInt16();
@@ -209,7 +222,6 @@ void InventoryHandler::handleMessage(MessageIn *msg)
* SMSG_PLAYER_STORAGE_... packets that update
* storage contents.
*/
- logger->log("Received SMSG_PLAYER_STORAGE_STATUS");
player_node->setInStorage(true);
break;
@@ -217,20 +229,41 @@ void InventoryHandler::handleMessage(MessageIn *msg)
/*
* Move an item into storage
*/
+ index = msg->readInt16();
+ amount = msg->readInt32();
+ itemId = msg->readInt16();
+ identified = msg->readInt8();
+ msg->readInt8(); // attribute
+ msg->readInt8(); // refine
+ for (int i = 0; i < 4; i++)
+ cards[i] = msg->readInt16();
+
+ if (Item *item = storage->getItem(index)) {
+ item->setId(itemId);
+ item->increaseQuantity(amount);
+ } else {
+ storage->setItem(index, itemId, amount, false);
+ }
break;
case SMSG_PLAYER_STORAGE_REMOVE:
/*
- * Move an item out of storage
- */
+ * Move an item out of storage
+ */
+ index = msg->readInt16();
+ amount = msg->readInt16();
+ if (Item *item = storage->getItem(index)) {
+ item->increaseQuantity(-amount);
+ if (item->getQuantity() == 0)
+ storage->removeItemAt(index);
+ }
break;
case SMSG_PLAYER_STORAGE_CLOSE:
/*
- * Storage access has been closed
- */
+ * Storage access has been closed
+ */
player_node->setInStorage(false);
- logger->log("Received SMSG_PLAYER_STORAGE_CLOSE");
break;
}
}
diff --git a/tmw.cbp b/tmw.cbp
index 7d24164a..62799884 100644
--- a/tmw.cbp
+++ b/tmw.cbp
@@ -236,6 +236,8 @@
<Unit filename="src\gui\speechbubble.h" />
<Unit filename="src\gui\status.cpp" />
<Unit filename="src\gui\status.h" />
+ <Unit filename="src\gui\storagewindow.cpp" />
+ <Unit filename="src\gui\storagewindow.h" />
<Unit filename="src\gui\table.cpp" />
<Unit filename="src\gui\table.h" />
<Unit filename="src\gui\table_model.cpp" />