summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Edwardsson <simon@crossnet.se>2004-10-02 15:50:55 +0000
committerSimon Edwardsson <simon@crossnet.se>2004-10-02 15:50:55 +0000
commit91fbf564fe4a28a93122d6a8a6a1df9d119dce91 (patch)
treee1c8025714fb70c40f4e2e63117e1a86246f8b17 /src
parent572f377ea2eca51469e06109503e9f4bcb198166 (diff)
downloadmana-client-91fbf564fe4a28a93122d6a8a6a1df9d119dce91.tar.gz
mana-client-91fbf564fe4a28a93122d6a8a6a1df9d119dce91.tar.bz2
mana-client-91fbf564fe4a28a93122d6a8a6a1df9d119dce91.tar.xz
mana-client-91fbf564fe4a28a93122d6a8a6a1df9d119dce91.zip
Sell in shops does now works, and you can choose amount :) (hope I don't break anything)
Diffstat (limited to 'src')
-rw-r--r--src/graphic/graphic.cpp21
-rw-r--r--src/gui/inventory.h1
-rw-r--r--src/gui/shop.cpp28
-rw-r--r--src/gui/shop.h10
4 files changed, 52 insertions, 8 deletions
diff --git a/src/graphic/graphic.cpp b/src/graphic/graphic.cpp
index 1640d7af..027723cf 100644
--- a/src/graphic/graphic.cpp
+++ b/src/graphic/graphic.cpp
@@ -43,6 +43,8 @@
BITMAP *buffer, *double_buffer, *chat_background;
DATAFILE *tileset;
+//extern char* itemCurrenyQ;
+char itemCurrenyQ[10] = "0";
char page_num;
int map_x, map_y, camera_x, camera_y;
DIALOG_PLAYER *chat_player, *npc_player, *skill_player, *buy_sell_player, *buy_player, *sell_player;
@@ -82,13 +84,15 @@ DIALOG buy_dialog[] = {
DIALOG sell_dialog[] = {
/* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
- { tmw_dialog_proc, 300, 200, 260, 150, 0, 0, 0, 0, 0, 0, (char *)"Sell", NULL, NULL },
- { tmw_button_proc, 450, 326, 50, 20, 255, 0, 'o', D_EXIT, 0, 0, (char *)"&Ok", NULL, NULL },
- { tmw_button_proc, 508, 326, 50, 20, 255, 0, 'c', D_EXIT, 0, 0, (char *)"&Cancel", NULL, NULL },
+ { tmw_dialog_proc, 300, 200, 260, 175, 0, 0, 0, 0, 0, 0, (char *)"Sell", NULL, NULL },
+ { tmw_button_proc, 450, 326+25, 50, 20, 255, 0, 'o', D_EXIT, 0, 0, (char *)"&Ok", NULL, NULL },
+ { tmw_button_proc, 508, 326+25, 50, 20, 255, 0, 'c', D_EXIT, 0, 0, (char *)"&Cancel", NULL, NULL },
+ { tmw_slider_proc, 304, 326, 200, 20, 255, 0, 0, 0, 10, 0, NULL, (void *)changeQ, NULL },
{ tmw_list_proc, 304, 224, 252, 100, 0, 0, 0, 0, 0, 0, (char *)shop_list, NULL, NULL },
+ { tmw_text_proc, 514, 326, 40, 100, 0, 0, 0, 0, 0, 0, (char *)itemCurrenyQ, NULL, NULL },
{ NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
};
-
+
DIALOG chat_dialog[] = {
/* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
{ tmw_edit_proc, 0, 574, 592, 25, 0, 0, 'c', 0, 90, 0, speech, NULL, NULL },
@@ -166,7 +170,8 @@ void do_graphic(void) {
int offset_y = map_y & 15;
sort();
-
+
+
for(int j=0;j<20;j++)
for(int i=0;i<26;i++) {
if( /* get_tile(i+camera_x, j+camera_y, 0) >= 0 && */ get_tile(i+camera_x, j+camera_y, 0) < 600)
@@ -308,13 +313,15 @@ void do_graphic(void) {
break;
case 4:
dialog_message(sell_dialog, MSG_DRAW, 0, 0);
+ sell_dialog[3].d1 = get_item_quantity(sell_dialog[4].d1);
if(!gui_update(sell_player)) {
show_npc_dialog = shutdown_dialog(sell_player);
+
if(show_npc_dialog==1) {
WFIFOW(0) = net_w_value(0x00c9);
WFIFOW(2) = net_w_value(8);
- WFIFOW(4) = net_w_value(1);
- WFIFOW(6) = net_w_value(get_item_id(sell_dialog[3].d1));
+ WFIFOW(4) = net_w_value(get_item_index(sell_dialog[4].d1));
+ WFIFOW(6) = net_w_value(sell_dialog[3].d2);
WFIFOSET(8);
}
show_npc_dialog = 0;
diff --git a/src/gui/inventory.h b/src/gui/inventory.h
index ee16d56b..0a8fd600 100644
--- a/src/gui/inventory.h
+++ b/src/gui/inventory.h
@@ -60,6 +60,7 @@ class TmwInventory {
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 use_item(int index, int id);
+ int quantityForIndex(int index) { return items[index].quantity; }
//END API
itemHolder items[INVENTORY_SIZE]; // this is the holder of items
diff --git a/src/gui/shop.cpp b/src/gui/shop.cpp
index 3065f8ea..487465b6 100644
--- a/src/gui/shop.cpp
+++ b/src/gui/shop.cpp
@@ -26,6 +26,7 @@
#include "shop.h"
int n_items;
+char* selectedItem = "You got 4";
ITEM_SHOP *shop = NULL;
char *item_db[] = {
@@ -75,7 +76,9 @@ void add_sell_item(short index, int price) {
else
sprintf(item_shop->name, "Unknown item %i gp", price);
item_shop->price = price;
+ item_shop->index = index;
item_shop->id = id;
+ item_shop->quantity = inventory.items[index].quantity;
item_shop->next = NULL;
if(shop==NULL)
shop = item_shop;
@@ -107,3 +110,28 @@ short get_item_id(int index) {
}
return item_shop->id;
}
+
+int get_item_quantity(int index) {
+ int iterator = 0;
+ ITEM_SHOP *item_shop = shop;
+ while(iterator<index) {
+ item_shop = item_shop->next;
+ iterator++;
+ }
+ return item_shop->quantity;
+}
+int get_item_index(int index) {
+ int iterator = 0;
+ ITEM_SHOP *item_shop = shop;
+ while(iterator<index) {
+ item_shop = item_shop->next;
+ iterator++;
+ }
+ return item_shop->index;
+}
+
+void changeQ(void *dp3, int d2)
+{
+sprintf(itemCurrenyQ,"%i",d2);
+printf("%s\n",itemCurrenyQ);
+} \ No newline at end of file
diff --git a/src/gui/shop.h b/src/gui/shop.h
index 5aa8548a..8c3869d0 100644
--- a/src/gui/shop.h
+++ b/src/gui/shop.h
@@ -30,20 +30,28 @@
#include <stdio.h>
#include "../graphic/graphic.h"
+#include "inventory.h"
+
struct ITEM_SHOP {
char name[30];
int price;
short id;
+ int index;
+ int quantity;
ITEM_SHOP *next;
};
extern int n_items;
+extern char* selectedItem;
+extern char itemCurrenyQ[10];
char *shop_list(int index, int *list_size);
void add_buy_item(short id, int price);
void add_sell_item(short index, int price);
+void changeQ(void *dp3, int d2);
void close_shop();
short get_item_id(int index);
-
+int get_item_quantity(int index);
+int get_item_index(int index);
#endif