summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/game.cpp9
-rw-r--r--src/graphic/graphic.cpp12
-rw-r--r--src/gui/chat.cpp4
-rw-r--r--src/gui/inventory.cpp269
-rw-r--r--src/gui/inventory.h2
5 files changed, 157 insertions, 139 deletions
diff --git a/src/game.cpp b/src/game.cpp
index b6d21c5a..17a45ded 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -218,11 +218,7 @@ void do_input() {
action(3, 0);
action_time = false;
}
- if(key[KEY_F6] && action_time==true) {
- inventory.toggle();
- action_time = false;
- }
-
+
if(key[KEY_ENTER]) {
if(strcmp(speech, "")!=0) {
chatlog.chat_send(char_info[0].name, speech);
@@ -265,6 +261,9 @@ void do_input() {
if(key[KEY_S]) {
show_skill_dialog = !show_skill_dialog;
action_time = false;
+ } else if(key[KEY_I]) {
+ inventory.toggle();
+ action_time = false;
}
}
diff --git a/src/graphic/graphic.cpp b/src/graphic/graphic.cpp
index 7cda470f..3c9232de 100644
--- a/src/graphic/graphic.cpp
+++ b/src/graphic/graphic.cpp
@@ -119,7 +119,7 @@ void init_graphic() {
skill_player = init_dialog(skill_dialog, -1);
gui_bitmap = double_buffer;
alfont_text_mode(-1);
- inventory.create(0, 0);
+ inventory.create(100, 100);
}
void do_graphic(void) {
@@ -149,7 +149,6 @@ void do_graphic(void) {
if((node->job>=100)&&(node->job<=110)) { // Draw a NPC
masked_blit((BITMAP *)graphic[NPCSET_BMP].dat, buffer, (get_direction(node->coordinates)/2+4*(node->job-100))*25, 0, (get_x(node->coordinates)-camera_x)*16-4-offset_x, (get_y(node->coordinates)-camera_y)*16-24-offset_y, 25, 40);
} else if(node->job<10) { // Draw a player
-
node->text_x = (get_x(node->coordinates)-camera_x)*16-34+get_x_offset(node)-offset_x;
node->text_y = (get_y(node->coordinates)-camera_y)*16-36+get_y_offset(node)-offset_y;
masked_blit((BITMAP *)graphic[PLAYERSET_BMP].dat, buffer, 80*(get_direction(node->coordinates)/2), 60*(node->frame+node->action), node->text_x, node->text_y, 80, 60);
@@ -214,9 +213,11 @@ void do_graphic(void) {
// Draw player speech
node = get_head();
while(node) {
- //alfont_textprintf_aa(double_buffer, gui_font, node->text_x+260, node->text_y+100, node->speech_color, "%i,%i", get_x(node->coordinates),get_y(node->coordinates));
- if(node->speech!=NULL) {
- alfont_textprintf_aa(double_buffer, gui_font, node->text_x+260-alfont_text_length(gui_font, node->speech)/2, node->text_y+100, node->speech_color, "%s", node->speech);
+ if(node->speech!=NULL) {
+ if(node->speech_color==makecol(255,255,255))
+ alfont_textprintf_aa(double_buffer, gui_font, node->text_x*2+90-alfont_text_length(gui_font, node->speech)/2, node->text_y*2, node->speech_color, "%s", node->speech);
+ else
+ alfont_textprintf_aa(double_buffer, gui_font, node->text_x*2+60-alfont_text_length(gui_font, node->speech)/2, node->text_y*2, node->speech_color, "%s", node->speech);
node->speech_time--;
if(node->speech_time==0) {
@@ -245,7 +246,6 @@ void do_graphic(void) {
if(gui_update(skill_player)==0)show_skill_dialog = false;
}
-
alfont_textprintf(double_buffer, gui_font, 0, 0, MAKECOL_WHITE, "FPS:%i", fps);
blit(double_buffer, screen, 0, 0, 0, 0, 800, 600);
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index c6967a08..fb424b4e 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -201,9 +201,9 @@ char * Chat::chat_send(string nick, string msg) {
// send processed message
WFIFOW(0) = net_w_value(packid);
- WFIFOW(2) = net_w_value(msg.length()+4);
+ WFIFOW(2) = net_w_value((unsigned short)(msg.length()+4));
memcpy(WFIFOP(4), msg.c_str(), msg.length());
- WFIFOSET(msg.length()+4);
+ WFIFOSET((int)msg.length()+4);
nick = msg = "";
return "";
}
diff --git a/src/gui/inventory.cpp b/src/gui/inventory.cpp
index add7a99d..8fa4b913 100644
--- a/src/gui/inventory.cpp
+++ b/src/gui/inventory.cpp
@@ -19,13 +19,30 @@
along with The Mana World; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ By SimEdw
+
*/
#include "inventory.h"
+DIALOG inventory_dialog[] = {
+ /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
+ { tmw_dialog_proc, 300, 252, 322, 60, 0, -1, 0, 0, 0, 0, (char*)"Inventory", NULL, NULL },
+ /*{ tmw_text_proc, 304, 284, 50, 10, 0, 0, 0, 0, 0, 0, (char*)"Name:", NULL, NULL },
+ { tmw_text_proc, 304, 304, 50, 10, 0, 0, 0, 0, 0, 0,(char*)"Password:", NULL, NULL },
+ { tmw_edit_proc, 360, 280, 130, 18, 0, -1, 0, 0, 24, 0, username, NULL, NULL },
+ { tmw_password_proc, 360, 300, 130, 18, 0, -1, 0, 0, 24, 0, password, NULL, NULL },
+ { tmw_button_proc, 398, 322, 44, 18, 0, -1, 'o', D_EXIT, -1, 0, (char*)"&Ok", NULL, NULL },
+ { tmw_button_proc, 446, 322, 44, 18, 0, -1, 'c', D_EXIT, -1, 0, (char*)"&Cancel", NULL, NULL },
+ { tmw_check_proc, 304, 322, 60, 18, 0, 0, '1', 0, 0, 0, (char*)"keep", NULL, NULL }, */
+ { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
+};
+
+DIALOG_PLAYER *inventory_player;
+
void TmwInventory::create(int tempxpos, int tempypos) {
- xpos =tempxpos;
- ypos =tempypos;
+ xpos = tempxpos;
+ ypos = tempypos;
itemset = load_datafile("./items/item.dat");
empty = load_bitmap("items/empty.bmp", NULL);
selected = load_bitmap("items/selected.bmp", NULL);
@@ -35,7 +52,7 @@ void TmwInventory::create(int tempxpos, int tempypos) {
items[i][ii].flag = 0; //doesn't hold anything
items[i][ii].itemIDNum = -1; //doesn't exist :)
items[i][ii].xpos = empty->w*i+1;
- items[i][ii].ypos = empty->h*ii;
+ items[i][ii].ypos = empty->h*ii+20;
items[i][ii].num = 0;
}
}
@@ -53,122 +70,130 @@ void TmwInventory::create(int tempxpos, int tempypos) {
backgroundSmall = create_bitmap(empty->w*10+10, empty->h+10);
backgroundBig = create_bitmap(empty->w*10+10, empty->h*10+10);
title = create_bitmap(15, backgroundSmall->h);
- floodfill(title,0,0,200);
- floodfill(backgroundSmall,0,0,100);
- floodfill(backgroundBig,0,0,100);
+ clear_to_color(title, makecol(0, 0, 200));
+ clear_to_color(backgroundSmall, makecol(0,0,100));
+ clear_to_color(backgroundBig, makecol(0,0,100));
areDisplaying = 0;
dragingWindow = 0;
lastSelectedX = -1;
lastSelectedY = -1;
bigwindow = 0; //false
+ inventory_player = init_dialog(inventory_dialog, -1);
+
}
void TmwInventory::draw(BITMAP * buffer) {
// let's draw the inventory
if(areDisplaying) {
- int max;
- if(!bigwindow) {
+ position_dialog(inventory_dialog, xpos, ypos);
+ dialog_message(inventory_dialog,MSG_DRAW,0,0);
+ update_dialog(inventory_player);
+ int max = 1;
+ /*if(!bigwindow) {
max = 1;
blit(backgroundSmall, buffer, 0, 0, xpos-5, ypos-5, 800, 600);
} else {
max = 10;
blit(backgroundBig, buffer, 0, 0, xpos-5, ypos-5, 800, 600);
- }
- blit(title, buffer, 0, 0, xpos+backgroundSmall->w-5, ypos+-5, 800, 600);
- for(int itemX = 0; itemX< 10; itemX++) {
- for(int itemY = 0;itemY<max;itemY++) {
+ }*/
+ //blit(title, buffer, 0, 0, xpos+backgroundSmall->w-5, ypos+-5, 800, 600);
+ 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);
+ //blit(empty, buffer, 0, 0, (xpos+items[itemX][itemY].xpos), (ypos+items[itemX][itemY].ypos), 800, 600);
if(mouse_b&1) {
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(items[itemX][itemY].flag) // have a item
- if(!dragingItem) { //not dragging it
- dragingItem=1; //begin to drag
- ghostOldIDX = itemX;
- ghostOldIDY = itemY;
- ghostID = items[itemX][itemY].itemIDNum;
- ghostX = mouse_x;
- ghostY = mouse_y;
- }
- }
- } else {
- if(lastSelectedX != -1 && dragingItem) { // have stoped dragging it over a itemholder
- //swap place
- itemHolder temp;
- int txpos1,typos1,txpos2,typos2;
- txpos1 = items[lastSelectedX][lastSelectedY].xpos;
- typos1 = items[lastSelectedX][lastSelectedY].ypos;
- txpos2 = items[ghostOldIDX][ghostOldIDY].xpos;
- typos2 = items[ghostOldIDX][ghostOldIDY].ypos;
- temp = items[lastSelectedX][lastSelectedY];
- items[lastSelectedX][lastSelectedY] = items[ghostOldIDX][ghostOldIDY];
- items[ghostOldIDX][ghostOldIDY] = temp;
- items[lastSelectedX][lastSelectedY].xpos = txpos1;
- items[lastSelectedX][lastSelectedY].ypos = typos1;
- items[ghostOldIDX][ghostOldIDY].xpos = txpos2;
- items[ghostOldIDX][ghostOldIDY].ypos = typos2;
- }
- dragingItem = 0; // stop dragging
- }
- if(mouse_b&2 && items[itemX][itemY].flag) {
+ masked_blit(selected, buffer, 0, 0, (xpos+items[itemX][itemY].xpos), (ypos+items[itemX][itemY].ypos), 800, 600);
+ draw = 1;
+ if(items[itemX][itemY].flag) // have a item
+ if(!dragingItem) { //not dragging it
+ dragingItem=1; //begin to drag
+ ghostOldIDX = itemX;
+ ghostOldIDY = itemY;
+ ghostID = items[itemX][itemY].itemIDNum;
+ ghostX = mouse_x;
+ ghostY = mouse_y;
+ }
+ }
+ } else { // if !mouse_b&1
+ if(lastSelectedX != -1 && dragingItem) { // have stoped dragging it over a itemholder
+ //swap place
+ itemHolder temp;
+ int txpos1,typos1,txpos2,typos2;
+ txpos1 = items[lastSelectedX][lastSelectedY].xpos;
+ typos1 = items[lastSelectedX][lastSelectedY].ypos;
+ txpos2 = items[ghostOldIDX][ghostOldIDY].xpos;
+ typos2 = items[ghostOldIDX][ghostOldIDY].ypos;
+ temp = items[lastSelectedX][lastSelectedY];
+ items[lastSelectedX][lastSelectedY] = items[ghostOldIDX][ghostOldIDY];
+ items[ghostOldIDX][ghostOldIDY] = temp;
+ items[lastSelectedX][lastSelectedY].xpos = txpos1;
+ items[lastSelectedX][lastSelectedY].ypos = typos1;
+ items[ghostOldIDX][ghostOldIDY].xpos = txpos2;
+ items[ghostOldIDX][ghostOldIDY].ypos = typos2;
+ }
+ dragingItem = 0; // stop dragging
+ }
+
+ if(mouse_b&2 && items[itemX][itemY].flag) { // if roght mouse button over an item
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;}
+ 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;
- lastSelectedY = itemY;
- }
-
- if(items[itemX][itemY].flag) //draw the item
- masked_blit((BITMAP *)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)
- alfont_textprintf_aa(buffer, gui_font, xpos+items[itemX][itemY].xpos+20, ypos+items[itemX][itemY].ypos+empty->h-15, makecol(0,0,0), "%i",items[itemX][itemY].num);
- else
- alfont_textprintf_aa(buffer, gui_font, xpos+items[itemX][itemY].xpos+20, ypos+items[itemX][itemY].ypos+empty->h-15, makecol(0,0,0), "%i",items[itemX][itemY].num);
}
+
+ 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;
+ lastSelectedY = itemY;
+ }
+
+ xpos = inventory_dialog[0].x;
+ ypos = inventory_dialog[0].y;
+
+ if(items[itemX][itemY].flag) //draw the item
+ masked_blit((BITMAP *)itemset[items[itemX][itemY].itemIDNum].dat, buffer, 0, 0, (xpos+items[itemX][itemY].xpos), (ypos+items[itemX][itemY].ypos), 32, 32);
+
+ //the number of that item
+ if(!bigwindow)
+ alfont_textprintf_aa(buffer, gui_font, xpos+items[itemX][itemY].xpos+20, ypos+items[itemX][itemY].ypos+empty->h-15, makecol(0,0,0), "%i",items[itemX][itemY].num);
+ else
+ alfont_textprintf_aa(buffer, gui_font, xpos+items[itemX][itemY].xpos+20, ypos+items[itemX][itemY].ypos+empty->h-15, makecol(0,0,0), "%i",items[itemX][itemY].num);
+
}
-
-
- if(mouse_b&2) {
- if(xpos+title->w+backgroundSmall->w > mouse_x && xpos+backgroundSmall->w < mouse_x)
- if(ypos+title->h > mouse_y && ypos < mouse_y) {
- if(bigwindow)
+ }
+
+ if(mouse_b&2) {
+ if(xpos+title->w+backgroundSmall->w > mouse_x && xpos+backgroundSmall->w < mouse_x)
+ if(ypos+title->h > mouse_y && ypos < mouse_y) {
+ if(bigwindow)
bigwindow=0;
else
bigwindow = 1;
}
- }
+ }
}
- if(mouse_b&1) {
+ /*if(mouse_b&1) {
if(xpos+title->w+backgroundSmall->w > mouse_x && xpos+backgroundSmall->w < mouse_x)
if(ypos+title->h > mouse_y && ypos < mouse_y) { //begin to move the window
xpos = mouse_x-(backgroundSmall->w);
ypos = mouse_y;
dragingWindow=1;
}
- } else { dragingWindow=0;}
+ } else { dragingWindow=0;}*/
- if(dragingWindow) { //moving the window ?
+ /*if(dragingWindow) { //moving the window ?
xpos = mouse_x-(backgroundSmall->w);
ypos = mouse_y;
- }
+ }*/
if(dragingItem) { //moving the item
masked_blit((BITMAP *)itemset[ghostID].dat, buffer, 0, 0, ghostX, ghostY, 800, 600);
@@ -177,28 +202,25 @@ void TmwInventory::draw(BITMAP * buffer) {
}
if(itemMeny){
- if(itemMeny_y < mouse_y && itemMeny_y+10 > mouse_y) {
- if(mouse_b&1)
- {
- useItem(itemIdn);
- itemMeny = 0;
+ 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");
+ 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;
+ 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");
+ 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");
}
}
-
}
@@ -247,44 +269,39 @@ int TmwInventory::addItem(int idnum, int antal) {
return -3;
}
-int TmwInventory::rmItem(int idnum)
-{
-int found, tempi;
-found = 0;
-tempi = -1;
-for(int i = 0; i< 10; i++)
- {
- for(int ii = 0; ii< 10; ii++)
- {
- if(items[i][ii].itemIDNum == idnum)
- { items[i][ii].itemIDNum = -1;
- items[i][ii].flag = 0;
- items[i][ii].num = 0;
- return 1;
- }
- }
+int TmwInventory::rmItem(int idnum) {
+ int found, tempi;
+ found = 0;
+ tempi = -1;
+ for(int i = 0; i< 10; i++) {
+ for(int ii = 0; ii< 10; ii++) {
+ if(items[i][ii].itemIDNum == idnum) {
+ items[i][ii].itemIDNum = -1;
+ items[i][ii].flag = 0;
+ items[i][ii].num = 0;
+ return 1;
+ }
+ }
}
-return -1;
+ return -1;
}
-int TmwInventory::changeNum(int idnum, int antal)
-{
-int found, tempi;
-found = 0;
-tempi = -1;
-for(int i = 0; i< 10; i++)
- {
- for(int ii = 0; ii< 10; ii++)
- {
- if(items[i][ii].itemIDNum == idnum)
- { items[i][ii].num = antal; return 1; }
- }
- }
-return -1;
+int TmwInventory::changeNum(int idnum, int antal) {
+ int found, tempi;
+ found = 0;
+ tempi = -1;
+ for(int i = 0; i< 10; i++) {
+ for(int ii = 0; ii< 10; ii++) {
+ if(items[i][ii].itemIDNum == idnum) {
+ items[i][ii].num = antal;
+ return 1;
+ }
+ }
+ }
+ return -1;
}
-int TmwInventory::useItem(int idnum)
-{
+int TmwInventory::useItem(int idnum) {
printf("Use item %i\n",idnum);
WFIFOW(0) = net_w_value(0x00a7);
WFIFOW(2) = net_w_value(idnum);
diff --git a/src/gui/inventory.h b/src/gui/inventory.h
index 1b5d2c12..82a98497 100644
--- a/src/gui/inventory.h
+++ b/src/gui/inventory.h
@@ -19,6 +19,8 @@
along with The Mana World; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ By SimEdw
+
*/
#ifdef WIN32