summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugenio Favalli <elvenprogrammer@gmail.com>2004-09-30 16:51:29 +0000
committerEugenio Favalli <elvenprogrammer@gmail.com>2004-09-30 16:51:29 +0000
commit25246c487851b7d113d1fb1d3daf7dc1cdf000c5 (patch)
tree8047797b8daa160ba120bdeea9ad80d79e3a17bc
parent9353cfbee08ae3e130e2e9dcfb0942ff465a8329 (diff)
downloadmana-25246c487851b7d113d1fb1d3daf7dc1cdf000c5.tar.gz
mana-25246c487851b7d113d1fb1d3daf7dc1cdf000c5.tar.bz2
mana-25246c487851b7d113d1fb1d3daf7dc1cdf000c5.tar.xz
mana-25246c487851b7d113d1fb1d3daf7dc1cdf000c5.zip
*** empty log message ***
-rw-r--r--src/game.cpp2
-rw-r--r--src/gui/inventory.cpp21
-rw-r--r--src/gui/inventory.h14
3 files changed, 22 insertions, 15 deletions
diff --git a/src/game.cpp b/src/game.cpp
index c6e8d855..2cda6426 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -682,7 +682,7 @@ void do_parse() {
else
chatlog.chat_log("Unable to sell", BY_SERVER, gui_font);
break;
- // Add item to inventory
+ // Add item to inventory after you bought it
case 0x00a0:
inventory.add_item(RFIFOW(2), RFIFOW(6), RFIFOW(4));
break;
diff --git a/src/gui/inventory.cpp b/src/gui/inventory.cpp
index 26f289d2..864adf06 100644
--- a/src/gui/inventory.cpp
+++ b/src/gui/inventory.cpp
@@ -52,7 +52,16 @@ void TmwInventory::create(int tempxpos, int tempypos) {
void TmwInventory::draw(BITMAP * buffer) {
if(show_inventory) {
dialog_message(inventory_dialog,MSG_DRAW,0,0);
- update_dialog(inventory_player);
+ update_dialog(inventory_player);
+ for(int i=0;i<INVENTORY_SIZE;i++) {
+ if(items[i].quantity>0) {
+ if(items[i].id>=501 && items[i].id<=510)
+ masked_blit((BITMAP *)itemset[items[i].id-500].dat, gui_bitmap, 0, 0, inventory_dialog[0].x-90+24*i, inventory_dialog[0].y+26, 22, 22);
+ else
+ masked_blit((BITMAP *)itemset[0].dat, gui_bitmap, 0, 0, inventory_dialog[0].x-90+24*i, inventory_dialog[0].y+26, 22, 22);
+ alfont_textprintf_aa(gui_bitmap, gui_font, inventory_dialog[0].x-90+24*i, inventory_dialog[0].y+44, makecol(0,0,0), "%i", items[i].quantity);
+ }
+ }
}
}
@@ -64,7 +73,7 @@ void TmwInventory::show(bool val) {
/** Add an item the inventory */
int TmwInventory::add_item(int index, int id, int quantity) {
items[index].id = id;
- items[index].quantity = quantity;
+ items[index].quantity += quantity;
return 0;
}
@@ -84,6 +93,12 @@ int TmwInventory::change_quantity(int index, int quantity) {
return 0;
}
+/** Increase quantity of an item */
+int TmwInventory::increase_quantity(int index, int quantity) {
+ items[index].quantity += quantity;
+ return 0;
+}
+
int TmwInventory::useItem(int idnum) {
printf("Use item %i\n",idnum);
WFIFOW(0) = net_w_value(0x00a7);
@@ -92,4 +107,4 @@ int TmwInventory::useItem(int idnum) {
while((out_size>0))flush();
return 0;
-}*/
+}
diff --git a/src/gui/inventory.h b/src/gui/inventory.h
index 61ec9e7b..21a958ab 100644
--- a/src/gui/inventory.h
+++ b/src/gui/inventory.h
@@ -53,26 +53,18 @@ class TmwInventory{
void create(int x, int y); // create the window
void draw(BITMAP *); // draw the window (if areDisplaying != 0 )
void show(bool val); // choose between showing and not showing the window
- void toggle() { if(areDisplaying){show(0);}else{show(1);} }
+ void toggle() {if(show_inventory){show(0);}else{show(1);}}
//API
int add_item(int index, int id, int quantity); // add a item
int remove_item(int id); // remove a item
- int changeNum(int idnum, int antal); // change number of a item
+ int change_quantity(int index, int quantity); // change number of a item
+ int increase_quantity(int index, int quantity); // increase quantity of a item
int useItem(int idnum);
//END API
private:
itemHolder items[INVENTORY_SIZE]; // this is the holder of items
DATAFILE *itemset;
bool show_inventory;
- int ghostX, ghostY, ghostID, ghostOldIDX,ghostOldIDY; //info needed when moving item
- int dragingItem, lastSelectedX,lastSelectedY; //info needed when moving item
- int areDisplaying, dragingWindow;
- int bigwindow;
- int xpos, ypos; // Where am I ?
- int itemMeny;
- int itemMeny_x, itemMeny_y;
- int itemIdn;
-
};
#endif