summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEugenio Favalli <elvenprogrammer@gmail.com>2005-02-11 17:21:55 +0000
committerEugenio Favalli <elvenprogrammer@gmail.com>2005-02-11 17:21:55 +0000
commit448fe8430f5f0ae81101fe86d664f98be1a92201 (patch)
tree76737e4447cca1dd24c4e9203a2d2ea674d72a1e /src
parent528ded235f60c349272ecbf428731b2f579ed758 (diff)
downloadmana-client-448fe8430f5f0ae81101fe86d664f98be1a92201.tar.gz
mana-client-448fe8430f5f0ae81101fe86d664f98be1a92201.tar.bz2
mana-client-448fe8430f5f0ae81101fe86d664f98be1a92201.tar.xz
mana-client-448fe8430f5f0ae81101fe86d664f98be1a92201.zip
Working on equipment
Diffstat (limited to 'src')
-rw-r--r--src/game.cpp33
-rw-r--r--src/graphic/graphic.cpp9
-rw-r--r--src/graphic/graphic.h2
-rw-r--r--src/gui/inventory.cpp22
-rw-r--r--src/gui/inventory.h6
-rw-r--r--src/gui/itemcontainer.cpp8
-rw-r--r--src/gui/itemcontainer.h5
7 files changed, 67 insertions, 18 deletions
diff --git a/src/game.cpp b/src/game.cpp
index 1191ba28..e4ec2d45 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -220,6 +220,10 @@ void do_input()
setupWindow->setVisible(true);
used = true;
}
+ else if (keysym.sym == SDLK_e) {
+ equipmentWindow->setVisible(!equipmentWindow->isVisible());
+ used = true;
+ }
}
if (event.key.keysym.sym == SDLK_ESCAPE)
@@ -408,11 +412,11 @@ void do_parse() {
}
fclose(file);
*/
-#ifdef DEBUG
+//#ifdef DEBUG
FILE *file = fopen("./docs/packet.list", "a");
fprintf(file, "%x\n", RFIFOW(0));
fclose(file);
-#endif
+//#endif
// Parse packet based on their id
switch(id) {
// Received speech
@@ -589,7 +593,14 @@ void do_parse() {
case 0x01ee:
for (int loop = 0; loop < (RFIFOW(2) - 4) / 18; loop++) {
inventoryWindow->addItem(RFIFOW(4 + loop * 18),
- RFIFOW(4 + loop * 18 + 2), RFIFOW(4 + loop * 18 + 6));
+ RFIFOW(4 + loop * 18 + 2), RFIFOW(4 + loop * 18 + 6), false);
+ }
+ break;
+ // Get the equipments
+ case 0x00a4:
+ for (int loop = 0; loop < (RFIFOW(2) - 4) / 20; loop++) {
+ inventoryWindow->addItem(RFIFOW(4 + loop * 20),
+ RFIFOW(4 + loop * 20 + 2), 1, true);
}
break;
// Can I use the item?
@@ -874,7 +885,7 @@ void do_parse() {
if (RFIFOB(22) > 0)
chatBox->chat_log("Unable to pick up item", BY_SERVER);
else
- inventoryWindow->addItem(RFIFOW(2), RFIFOW(6), RFIFOW(4));
+ inventoryWindow->addItem(RFIFOW(2), RFIFOW(6), RFIFOW(4), false);
break;
// Decrease quantity of an item in inventory
case 0x00af:
@@ -956,11 +967,17 @@ void do_parse() {
being->hair_style = RFIFOB(7);
}
break;
- case 0x00a4:
- for (int i = 0; i < (RFIFOW(2) - 4) / 20; i++)
- inventoryWindow->addItem(RFIFOW(4 + 20 * i), RFIFOW(6 + 20 * i), 1);
+ // Answer to equip items
+ case 0x00aa:
+ if (RFIFOB(6) == 0)
+ chatBox->chat_log("Unable to equip.", BY_SERVER);
+ break;
+ // Equipment related
+ case 0x01d7:
+ char content[40];
+ sprintf(content, "%i %i", RFIFOW(7), RFIFOW(9));
+ chatBox->chat_log(content, BY_SERVER);
break;
-
// Manage non implemented packets
default:
//printf("%x\n",id);
diff --git a/src/graphic/graphic.cpp b/src/graphic/graphic.cpp
index 65775c75..bff5a29b 100644
--- a/src/graphic/graphic.cpp
+++ b/src/graphic/graphic.cpp
@@ -26,6 +26,7 @@
#include "../gui/textfield.h"
#include "../gui/status.h"
#include "../gui/minimap.h"
+#include "../gui/equipment.h"
#include "../main.h"
#include "../being.h"
@@ -55,6 +56,7 @@ SkillDialog *skillDialog;
StatsWindow *statsWindow;
Setup* setupWindow;
Minimap *minimap;
+EquipmentWindow *equipmentWindow;
void ChatListener::action(const std::string& eventId)
{
@@ -269,9 +271,10 @@ Engine::Engine()
setupWindow = new Setup();
setupWindow->setVisible(false);
- // Create minimap
-
minimap = new Minimap();
+
+ equipmentWindow = new EquipmentWindow();
+ equipmentWindow->setVisible(true);
// Give focus to the chat input
chatInput->requestFocus();
@@ -310,6 +313,8 @@ Engine::~Engine()
delete skillDialog;
delete statsWindow;
delete setupWindow;
+ delete minimap;
+ delete equipmentWindow;
delete tileset;
delete monsterset;
diff --git a/src/graphic/graphic.h b/src/graphic/graphic.h
index 8b4a2bde..0bae4327 100644
--- a/src/graphic/graphic.h
+++ b/src/graphic/graphic.h
@@ -42,6 +42,7 @@ class Graphics;
#include "../gui/stats.h"
#include "../gui/skill.h"
#include "../gui/setup.h"
+#include "../gui/equipment.h"
#include "../resources/resourcemanager.h"
#include "spriteset.h"
#include <SDL.h>
@@ -69,6 +70,7 @@ extern NpcTextDialog *npcTextDialog;
extern SkillDialog *skillDialog;
extern StatsWindow *statsWindow;
extern Setup *setupWindow;
+extern EquipmentWindow *equipmentWindow;
char get_x_offset(char, char);
char get_y_offset(char, char);
diff --git a/src/gui/inventory.cpp b/src/gui/inventory.cpp
index 259f728d..db5dfb54 100644
--- a/src/gui/inventory.cpp
+++ b/src/gui/inventory.cpp
@@ -67,10 +67,10 @@ void InventoryWindow::draw(gcn::Graphics *graphics)
}
-int InventoryWindow::addItem(int index, int id, int quantity) {
+int InventoryWindow::addItem(int index, int id, int quantity, bool equipment) {
/*items[index].id = id;
items[index].quantity += quantity;*/
- items->addItem(index, id, quantity);
+ items->addItem(index, id, quantity, equipment);
return 0;
}
@@ -116,13 +116,27 @@ int InventoryWindow::dropItem(int index, int quantity) {
return 0;
}
+void InventoryWindow::equipItem(int index) {
+ WFIFOW(0) = net_w_value(0x00a9);
+ WFIFOW(2) = net_w_value(index);
+ WFIFOW(4) = net_w_value(0);
+ WFIFOSET(6);
+ while ((out_size > 0)) flush();
+}
+
void InventoryWindow::action(const std::string &eventId)
{
//if(selectedItem >= 0 && selectedItem <= INVENTORY_SIZE) {
if (items->getIndex() != -1) {
if (eventId == "use") {
- useItem(items->getIndex(), items->getId());
- } else if (eventId == "drop") {
+ if(items->isEquipment(items->getIndex())) {
+ equipItem(items->getIndex());
+ }
+ else {
+ useItem(items->getIndex(), items->getId());
+ }
+ }
+ else if (eventId == "drop") {
dropItem(items->getIndex(), items->getQuantity());
// Temp: drop all the items, you should choose quantity instead
}
diff --git a/src/gui/inventory.h b/src/gui/inventory.h
index e48d5477..178c8019 100644
--- a/src/gui/inventory.h
+++ b/src/gui/inventory.h
@@ -56,12 +56,14 @@ class InventoryWindow : public Window, gcn::ActionListener {
/**
* Add an item the inventory.
*/
- int addItem(int index, int id, int quantity);
+ int addItem(int index, int id, int quantity, bool equipment);
/**
* Remove a item from the inventory.
*/
int removeItem(int id);
+
+ void equipItem(int index);
/**
* Change quantity of an item.
@@ -83,7 +85,7 @@ class InventoryWindow : public Window, gcn::ActionListener {
private:
gcn::Button *useButton, *dropButton;
int useItem(int index, int id);
- int dropItem(int index, int amunt);
+ int dropItem(int index, int quantity);
};
diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp
index 123270c2..0bd236e2 100644
--- a/src/gui/itemcontainer.cpp
+++ b/src/gui/itemcontainer.cpp
@@ -37,6 +37,7 @@ ItemContainer::ItemContainer()
for (int i = 0; i < INVENTORY_SIZE; i++) {
items[i].id = -1;
items[i].quantity = 0;
+ items[i].equipment = false;
}
}
@@ -113,10 +114,11 @@ int ItemContainer::getQuantity(int index)
return items[index].quantity;
}
-void ItemContainer::addItem(int index, int id, int quantity)
+void ItemContainer::addItem(int index, int id, int quantity, bool equipment)
{
items[index].id = id;
items[index].quantity += quantity;
+ items[index].equipment = equipment;
}
void ItemContainer::removeItem(int id)
@@ -155,3 +157,7 @@ void ItemContainer::_mouseInputMessage(const gcn::MouseInput &mouseInput)
}
}
+bool ItemContainer::isEquipment(int index)
+{
+ return items[index].equipment;
+}
diff --git a/src/gui/itemcontainer.h b/src/gui/itemcontainer.h
index 5774feb6..69e59149 100644
--- a/src/gui/itemcontainer.h
+++ b/src/gui/itemcontainer.h
@@ -34,6 +34,7 @@
struct ITEM_HOLDER { // the holder of a item
int id; // the id of the item
int quantity; // number of items
+ bool equipment;
};
/**
@@ -101,7 +102,7 @@ class ItemContainer : public gcn::Widget
/**
* Adds a new item.
*/
- void addItem(int index, int id, int quantity);
+ void addItem(int index, int id, int quantity, bool equipment);
/**
* Remove a item from the inventory.
@@ -119,6 +120,8 @@ class ItemContainer : public gcn::Widget
void increaseQuantity(int index, int quantity);
void _mouseInputMessage(const gcn::MouseInput &mouseInput);
+
+ bool isEquipment(int index);
};
#endif