summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Edwardsson <simon@crossnet.se>2004-10-03 14:55:10 +0000
committerSimon Edwardsson <simon@crossnet.se>2004-10-03 14:55:10 +0000
commit2401b8b64f4c7ac574545b4db2dff1f4504a37fb (patch)
treeab4d91848ae38b9ab7a6b70fab48c1c68def5e67
parent9c4d57c8a76f8494d702f733998aaa70eaab0e5e (diff)
downloadmana-client-2401b8b64f4c7ac574545b4db2dff1f4504a37fb.tar.gz
mana-client-2401b8b64f4c7ac574545b4db2dff1f4504a37fb.tar.bz2
mana-client-2401b8b64f4c7ac574545b4db2dff1f4504a37fb.tar.xz
mana-client-2401b8b64f4c7ac574545b4db2dff1f4504a37fb.zip
Now possible to use items (again)
-rw-r--r--src/game.cpp8
-rw-r--r--src/gui/inventory.cpp52
-rw-r--r--src/gui/inventory.h4
-rw-r--r--src/gui/stats.cpp5
-rw-r--r--tmw.ini2
5 files changed, 64 insertions, 7 deletions
diff --git a/src/game.cpp b/src/game.cpp
index 3dbd599f..9c343f49 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -705,7 +705,11 @@ void do_parse() {
// Remove item to inventory after you sold it
case 0x00af:
printf("sell %i\n",-RFIFOW(4));
- inventory.change_quantity(RFIFOW(2),-RFIFOW(4));
+ inventory.increase_quantity(RFIFOW(2),-RFIFOW(4));
+ break;
+ //use a item
+ case 0x01c8:
+ inventory.change_quantity(RFIFOW(2),RFIFOW(10));
break;
case 0x0119:
sprintf(pkt_nfo, "%i %i %i %i", RFIFOL(2), RFIFOW(6), RFIFOW(8), RFIFOW(10));
@@ -713,7 +717,7 @@ void do_parse() {
break;
// Manage non implemented packets
default:
- // use when debug packets :) printf("%x\n",id);
+ //printf("%x\n",id);
//alert(pkt_nfo,"","","","",0,0);
break;
}
diff --git a/src/gui/inventory.cpp b/src/gui/inventory.cpp
index be2b239f..13643ab1 100644
--- a/src/gui/inventory.cpp
+++ b/src/gui/inventory.cpp
@@ -63,8 +63,48 @@ void TmwInventory::draw(BITMAP * buffer) {
}
}
}
+ if(mouse_b & 2)
+ {
+ for(int i=0;i<INVENTORY_SIZE;i++) {
+ if(items[i].quantity>0 && inventory_dialog[0].x+24*i+24 > mouse_x && inventory_dialog[0].x+24*i < mouse_x && inventory_dialog[0].y+44+24 > mouse_y && inventory_dialog[0].y+44 < mouse_y)
+ {
+ itemMeny = 1;
+ itemMeny_x = 24*i;
+ itemMeny_y = 44+24;
+ itemMeny_i = i;
+ }
+ }
+
+
+ }
+
+
+ if(itemMeny){
+ if(inventory_dialog[0].y+itemMeny_y < mouse_y && inventory_dialog[0].y+itemMeny_y+10 > mouse_y) {
+ if(mouse_b&1)
+ {
+ use_item(itemMeny_i,items[itemMeny_i].id);
+ itemMeny = 0;
+ }
+ alfont_textprintf_aa(buffer, gui_font, inventory_dialog[0].x+itemMeny_x, inventory_dialog[0].y+itemMeny_y, makecol(255,237,33), "Use item");
+ } else {
+ alfont_textprintf_aa(buffer, gui_font, inventory_dialog[0].x+itemMeny_x, inventory_dialog[0].y+itemMeny_y, MAKECOL_BLACK, "Use item");
+ }
+ if(inventory_dialog[0].y+itemMeny_y+10 < mouse_y && inventory_dialog[0].y+itemMeny_y+20 > mouse_y) {
+ if(mouse_b&1)
+ {
+ drop_item(itemMeny_i,1);
+ itemMeny = 0;
+ }
+ alfont_textprintf_aa(buffer, gui_font, inventory_dialog[0].x+itemMeny_x, inventory_dialog[0].y+itemMeny_y+10, makecol(255,237,33), "Del item");
+ } else {
+ alfont_textprintf_aa(buffer, gui_font, inventory_dialog[0].x+itemMeny_x, inventory_dialog[0].y+itemMeny_y+10, MAKECOL_BLACK, "Del item");
+ }
+ }
+
}
+
/** Set if inventory is visible */
void TmwInventory::show(bool val) {
show_inventory = val;
@@ -89,7 +129,7 @@ int TmwInventory::remove_item(int id) {
/** Change quantity of an item */
int TmwInventory::change_quantity(int index, int quantity) {
- items[index].quantity += quantity;
+ items[index].quantity = quantity;
return 0;
}
@@ -108,3 +148,13 @@ int TmwInventory::use_item(int index, int id) {
while((out_size>0))flush();
return 0;
}
+
+int TmwInventory::drop_item(int index, int amunt) {
+ WFIFOW(0) = net_w_value(0x00a7);
+ WFIFOW(2) = net_w_value(index);
+ WFIFOL(4) = net_l_value(amunt);
+ WFIFOSET(8);
+ while((out_size>0))flush();
+ return 0;
+}
+
diff --git a/src/gui/inventory.h b/src/gui/inventory.h
index 0a8fd600..de710cfd 100644
--- a/src/gui/inventory.h
+++ b/src/gui/inventory.h
@@ -61,12 +61,14 @@ class TmwInventory {
int increase_quantity(int index, int quantity); // increase quantity of a item
int use_item(int index, int id);
int quantityForIndex(int index) { return items[index].quantity; }
+ int drop_item(int index, int amunt);
//END API
-
+
itemHolder items[INVENTORY_SIZE]; // this is the holder of items
private:
DATAFILE *itemset;
bool show_inventory;
+ int itemMeny, itemMeny_x, itemMeny_y, itemMeny_i;
};
#endif
diff --git a/src/gui/stats.cpp b/src/gui/stats.cpp
index f4d8c661..4b63c9d5 100644
--- a/src/gui/stats.cpp
+++ b/src/gui/stats.cpp
@@ -32,9 +32,10 @@ DIALOG stats_dialog[] = {
/* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
{ tmw_ldialog_proc, 493, 0, 300, 55, 0, 0, 0, 0, 0, 0, stats_name, NULL, NULL },
{ tmw_text_proc, 497, 34, 296, 100, 0, 0, 0, 0, 0, 0, stats_hp, NULL, NULL },
- { tmw_bar_proc, 497, 22, 60, 18, 0, 0, '1', 0, 1, 1, NULL, NULL, NULL },
- { tmw_text_proc, 607, 22, 296, 100, 0, 0, 0, 0, 0, 0, stats_zeny, NULL, NULL },
+ { tmw_bar_proc, 507, 22, 60, 18, 0, 0, '1', 0, 1, 1, NULL, NULL, NULL },
+ { tmw_text_proc, 707, 34, 296, 100, 0, 0, 0, 0, 0, 0, stats_zeny, NULL, NULL },
{ tmw_text_proc, 607, 34, 296, 100, 0, 0, 0, 0, 0, 0, stats_sp, NULL, NULL },
+ { tmw_bar_proc, 617, 22, 60, 18, 0, 0, '1', 0, 1, 1, NULL, NULL, NULL },
{ NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
};
diff --git a/tmw.ini b/tmw.ini
index a0ada48c..7102ec29 100644
--- a/tmw.ini
+++ b/tmw.ini
@@ -30,7 +30,7 @@ stretch = 1
[login]
remember = 1
<<<<<<< = tmw.ini
-username = test
+username = test2
=======
username = elven
>>>>>>> = 1.57