summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Edwardsson <simon@crossnet.se>2004-09-26 19:01:56 +0000
committerSimon Edwardsson <simon@crossnet.se>2004-09-26 19:01:56 +0000
commitf141416397c8fd7f65fd9cd363a99257ca769d86 (patch)
tree72146533436ba487b35c8795194f729c220935f5
parent9f25a358b6a10b9abeb93cd42129254a331d80cf (diff)
downloadmana-client-f141416397c8fd7f65fd9cd363a99257ca769d86.tar.gz
mana-client-f141416397c8fd7f65fd9cd363a99257ca769d86.tar.bz2
mana-client-f141416397c8fd7f65fd9cd363a99257ca769d86.tar.xz
mana-client-f141416397c8fd7f65fd9cd363a99257ca769d86.zip
The invetory now gets real items, and you can use them.
-rw-r--r--makefile.macosx10
-rw-r--r--src/game.cpp14
-rw-r--r--src/gui/inventory.cpp60
-rw-r--r--src/gui/inventory.h11
-rw-r--r--tmw.ini2
5 files changed, 78 insertions, 19 deletions
diff --git a/makefile.macosx b/makefile.macosx
index 4a054f34..165b39c9 100644
--- a/makefile.macosx
+++ b/makefile.macosx
@@ -7,11 +7,11 @@ CXXFLAGS =-Wall -O3 -fexpensive-optimizations -pipe -fomit-frame-pointer -funrol
CFLAGS=`allegro-config --libs release` -lalfont /usr/lib/libjgmod.a
-OBJS = being.o game.o main.o map.o log.o astar.o
-OBJS += Gui/chat.o Gui/skill.o
-OBJS += Sound/sound.o Graphic/SuperEagle.o Graphic/graphic.o
-OBJS += Gui/gui.o Gui/login.o Gui/char_server.o Gui/char_select.o Gui/inventory.o
-OBJS += Net/network.o Net/protocol.o Net/win2mac.o
+OBJS = src/sound/sound.o src/graphic/super_eagle.o src/graphic/graphic.o
+OBJS += src/gui/chat.o src/gui/skill.o
+OBJS += src/gui/gui.o src/gui/login.o src/gui/char_server.o src/gui/char_select.o src/gui/inventory.o
+OBJS += src/net/network.o src/net/protocol.o src/net/win2mac.o
+OBJS += src/being.o src/game.o src/main.o src/map.o src/log.o src/astar.o
tmw: $(OBJS)
$(CXX) -o tmw $(OBJS) $(CFLAGS)
diff --git a/src/game.cpp b/src/game.cpp
index cd494b8a..ebf1ddd6 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -462,6 +462,20 @@ void do_parse() {
show_npc_dialog = 1;
}
break;
+ case 0x01ee: //Get the items
+ for(int loop = 0; loop < RFIFOW(4); loop++)
+ {
+ inventory.addItem(loop,RFIFOW(10+18*loop));
+ }
+ break;
+ case 0x00a8: // could I use the item?
+ // index RFIFOW(2)
+ // succes or not RFIFOB(6);
+ if(RFIFOB(6))
+ {
+ inventory.addItem(RFIFOW(2),RFIFOW(4));
+ }
+ break;
// Warp
case 0x0091:
memset(map_path, '\0', 480);
diff --git a/src/gui/inventory.cpp b/src/gui/inventory.cpp
index 72c2cbaa..8300a310 100644
--- a/src/gui/inventory.cpp
+++ b/src/gui/inventory.cpp
@@ -26,9 +26,7 @@
void TmwInventory::create(int tempxpos, int tempypos) {
xpos =tempxpos;
ypos =tempypos;
-
- itemPIC[0].pic = load_bitmap("items/herb.bmp", NULL); //ID=0
- itemPIC[1].pic = load_bitmap("items/magicthing.bmp", NULL); //ID=1
+ itemset = load_datafile("./items/item.dat");
empty = load_bitmap("items/empty.bmp", NULL);
selected = load_bitmap("items/selected.bmp", NULL);
@@ -41,15 +39,16 @@ void TmwInventory::create(int tempxpos, int tempypos) {
items[i][ii].num = 0;
}
}
+ //draw_rle_sprite(buffer, (RLE_SPRITE *)itemPIC[items[itemX][itemY].itemIDNum].pic, (xpos+items[itemX][itemY].xpos), (ypos+items[itemX][itemY].ypos));
//create two fake items
- items[0][0].flag = 1;
+ /*items[0][0].flag = 1;
items[0][0].itemIDNum = 0;
items[0][0].num = 1;
items[2][0].flag = 1;
items[2][0].itemIDNum = 1;
- items[2][0].num = 3;
+ items[2][0].num = 3;*/
backgroundSmall = create_bitmap(empty->w*10+10, empty->h+10);
backgroundBig = create_bitmap(empty->w*10+10, empty->h*10+10);
@@ -62,6 +61,7 @@ void TmwInventory::create(int tempxpos, int tempypos) {
lastSelectedX = -1;
lastSelectedY = -1;
bigwindow = 0; //false
+
}
void TmwInventory::draw(BITMAP * buffer) {
@@ -79,7 +79,6 @@ void TmwInventory::draw(BITMAP * buffer) {
for(int itemX = 0; itemX< 10; itemX++) {
for(int itemY = 0;itemY<max;itemY++) {
int draw = 0;
-
blit(empty, buffer, 0, 0, (xpos+items[itemX][itemY].xpos), (ypos+items[itemX][itemY].ypos), 800, 600);
if(mouse_b&1) {
@@ -117,7 +116,17 @@ void TmwInventory::draw(BITMAP * buffer) {
}
dragingItem = 0; // stop dragging
}
-
+ if(mouse_b&2 && items[itemX][itemY].flag) {
+ if(xpos+items[itemX][itemY].xpos+empty->w > mouse_x && xpos+items[itemX][itemY].xpos < mouse_x)
+ if(ypos+items[itemX][itemY].ypos+empty->h > mouse_y && ypos+items[itemX][itemY].ypos < mouse_y) {
+ //selected
+ masked_blit(selected, buffer, 0, 0, (xpos+items[itemX][itemY].xpos), (ypos+items[itemX][itemY].ypos), 800, 600);
+ draw = 1;
+ if(itemMeny){ itemMeny=0; } else { itemMeny=1; itemIdn =items[itemX][itemY].itemIDNum ;itemMeny_x = (xpos+items[itemX][itemY].xpos)+selected->w;itemMeny_y = (ypos+items[itemX][itemY].ypos)+selected->h;}
+ }
+ }
+
+
if(xpos+items[itemX][itemY].xpos+empty->w > mouse_x && xpos+items[itemX][itemY].xpos < mouse_x && ypos+items[itemX][itemY].ypos+empty->h > mouse_y && ypos+items[itemX][itemY].ypos < mouse_y ) {
// a hoover
lastSelectedX = itemX;
@@ -125,7 +134,7 @@ void TmwInventory::draw(BITMAP * buffer) {
}
if(items[itemX][itemY].flag) //draw the item
- masked_blit(itemPIC[items[itemX][itemY].itemIDNum].pic, buffer, 0, 0, (xpos+items[itemX][itemY].xpos), (ypos+items[itemX][itemY].ypos), 800, 600);
+ masked_blit(itemset[items[itemX][itemY].itemIDNum].dat, buffer, 0, 0, (xpos+items[itemX][itemY].xpos), (ypos+items[itemX][itemY].ypos), 800, 600);
//the number of that item
if(!bigwindow)
@@ -162,10 +171,34 @@ void TmwInventory::draw(BITMAP * buffer) {
}
if(dragingItem) { //moving the item
- masked_blit(itemPIC[ghostID].pic, buffer, 0, 0, ghostX, ghostY, 800, 600);
+ masked_blit(itemset[ghostID].dat, buffer, 0, 0, ghostX, ghostY, 800, 600);
ghostX = mouse_x;
ghostY = mouse_y;
}
+
+ if(itemMeny){
+ if(itemMeny_y < mouse_y && itemMeny_y+10 > mouse_y) {
+ if(mouse_b&1)
+ {
+ useItem(itemIdn);
+ itemMeny = 0;
+ }
+ alfont_textprintf_aa(buffer, gui_font, itemMeny_x, itemMeny_y, makecol(255,237,33), "Use item");
+ } else {
+ alfont_textprintf_aa(buffer, gui_font, itemMeny_x, itemMeny_y, MAKECOL_BLACK, "Use item");
+ }
+ if(itemMeny_y+10 < mouse_y && itemMeny_y+20 > mouse_y) {
+ if(mouse_b&1)
+ {
+ rmItem(itemIdn);
+ itemMeny = 0;
+ }
+ alfont_textprintf_aa(buffer, gui_font, itemMeny_x, itemMeny_y+10, makecol(255,237,33), "Del item");
+ } else {
+ alfont_textprintf_aa(buffer, gui_font, itemMeny_x, itemMeny_y+10, MAKECOL_BLACK, "Del item");
+ }
+ }
+
}
@@ -246,4 +279,13 @@ for(int i = 0; i< 10; i++)
}
}
return -1;
+}
+
+int TmwInventory::useItem(int idnum)
+{
+ printf("Use item %i\n",idnum);
+ WFIFOW(0) = net_w_value(0x00a7);
+ WFIFOW(2) = net_w_value(idnum);
+ WFIFOSET(4);
+ while((out_size>0))flush();
} \ No newline at end of file
diff --git a/src/gui/inventory.h b/src/gui/inventory.h
index f72bdb64..1b5d2c12 100644
--- a/src/gui/inventory.h
+++ b/src/gui/inventory.h
@@ -44,9 +44,7 @@ struct itemHolder { // the holder of a item
int xpos,ypos; // where am I?
};
-struct itemID {//the holder of the pictures for each item, maybe more in the future
- BITMAP * pic;
-};
+
class TmwInventory{
public:
@@ -61,6 +59,7 @@ class TmwInventory{
int addItem(int idnum, int antal); //add a item
int rmItem(int idnum); //remove a item
int changeNum(int idnum, int antal); // change nummber of a item
+ int useItem(int idnum);
//END API
private:
BITMAP * backgroundSmall;
@@ -69,12 +68,16 @@ class TmwInventory{
BITMAP * empty;
BITMAP * selected;
itemHolder items[10][10]; // this is the test holder of items
- itemID itemPIC[2]; // I only got two items
+ DATAFILE *itemset;
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
diff --git a/tmw.ini b/tmw.ini
index 882c3193..cd1d0eb3 100644
--- a/tmw.ini
+++ b/tmw.ini
@@ -28,4 +28,4 @@ stretch = 1
[login]
remember = 1
-username = elven
+username = test2