summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/game.cpp29
-rw-r--r--src/graphic/graphic.cpp38
-rw-r--r--src/graphic/graphic.h2
-rw-r--r--src/gui/char_select.cpp2
-rw-r--r--src/gui/npc.cpp88
-rw-r--r--src/gui/npc.h38
6 files changed, 193 insertions, 4 deletions
diff --git a/src/game.cpp b/src/game.cpp
index 0a50dd44..0dec4268 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -34,6 +34,7 @@
#include "./gui/gui.h"
#include "./gui/inventory.h"
#include "./gui/shop.h"
+#include "./gui/npc.h"
#include "./graphic/graphic.h"
#include "./sound/sound.h"
@@ -799,6 +800,34 @@ void do_parse() {
WFIFOL(2) = net_l_value(RFIFOL(2));
WFIFOSET(6);
break;
+ // Next button in NPC dialog
+ case 0x00b5:
+ strcpy(npc_button, "Next");
+ current_npc = RFIFOL(2);
+ break;
+ // Close button in NPC dialog
+ case 0x00b6:
+ strcpy(npc_button, "Close");
+ current_npc = RFIFOL(2);
+ break;
+ // List in NPC dialog
+ case 0x00b7:
+ current_npc = RFIFOL(4);
+ alert(RFIFOP(8),"","","","",0,0);
+ parse_items(RFIFOP(8), RFIFOW(2));
+ show_npc_dialog = 5;
+ break;
+ // Look change
+ case 0x00c3:
+ // Change hair color
+ if(RFIFOB(6)==6) {
+ node = find_node(RFIFOL(2));
+ node->hair_color = RFIFOB(7);
+ /*char prova[100];
+ sprintf(prova, "%i %i %i", RFIFOL(2), RFIFOB(6), RFIFOB(7));
+ alert(prova,"","","","",0,0);*/
+ }
+ break;
// Manage non implemented packets
default:
//printf("%x\n",id);
diff --git a/src/graphic/graphic.cpp b/src/graphic/graphic.cpp
index 9a323379..3cc90377 100644
--- a/src/graphic/graphic.cpp
+++ b/src/graphic/graphic.cpp
@@ -39,7 +39,7 @@ DATAFILE *tileset;
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, *stats_player, *skill_list_player;
+DIALOG_PLAYER *chat_player, *npc_player, *skill_player, *buy_sell_player, *buy_player, *sell_player, *stats_player, *skill_list_player, *npc_list_player;
char speech[255] = "";
char npc_text[1000] = "";
char statsString2[255] = "n/a";
@@ -49,11 +49,12 @@ Chat chatlog("./docs/chatlog.txt", 20);
int show_npc_dialog = 0;
bool show_skill_dialog = false;
bool show_skill_list_dialog = false;
+char npc_button[10] = "Close";
DIALOG npc_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 *)"NPC", NULL, NULL },
- { tmw_button_proc, 508, 326, 50, 20, 255, 0, 'c', D_EXIT, 0, 0, (char *)"&Close", NULL, NULL },
+ { tmw_button_proc, 508, 326, 50, 20, 255, 0, 'c', D_EXIT, 0, 0, (char *)npc_button, NULL, NULL },
{ tmw_textbox_proc, 304, 224, 252, 100, 0, 0, 0, 0, 0, 0, npc_text, NULL, NULL },
{ NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
};
@@ -107,6 +108,15 @@ DIALOG chat_dialog[] = {
{ NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
};
+DIALOG npc_list_dialog[] = {
+ /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
+ { tmw_dialog_proc, 300, 200, 260, 200, 0, 0, 0, 0, 0, 0, (char *)"NPC", NULL, NULL },
+ { tmw_button_proc, 450, 376, 50, 20, 255, 0, 'o', D_EXIT, 0, 0, (char *)"&Ok", NULL, NULL },
+ { tmw_button_proc, 508, 376, 50, 20, 255, 0, 'c', D_EXIT, 0, 0, (char *)"&Cancel", NULL, NULL },
+ { tmw_list_proc, 304, 224, 252, 100, 0, 0, 0, 0, 0, 0, (char *)item_list, NULL, NULL },
+ { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
+};
+
char hairtable[10][4][2] = {
// S(x,y) W(x,y) N(x,y) E(x,y)
{ { 0, 0}, {-1, 2}, {-1, 2}, {0, 2} }, // STAND
@@ -181,6 +191,7 @@ void init_graphic() {
buy_player = init_dialog(buy_dialog, -1);
sell_player = init_dialog(sell_dialog, -1);
skill_list_player = init_dialog(skill_list_dialog, -1);
+ npc_list_player = init_dialog(npc_list_dialog, -1);
gui_bitmap = double_buffer;
alfont_text_mode(-1);
inventory.create(100, 100);
@@ -361,7 +372,13 @@ void do_graphic(void) {
switch(show_npc_dialog) {
case 1:
dialog_message(npc_dialog, MSG_DRAW, 0, 0);
- if(!(show_npc_dialog = gui_update(npc_player)))strcpy(npc_text, "");
+ if(!(show_npc_dialog = gui_update(npc_player))) {
+ strcpy(npc_text, "");
+ WFIFOW(0) = net_w_value(0x00b9);
+ //alert("","","","","",0,0);
+ WFIFOL(2) = net_l_value(current_npc);
+ WFIFOSET(6);
+ }
break;
case 2:
dialog_message(buy_sell_dialog, MSG_DRAW, 0, 0);
@@ -425,6 +442,21 @@ void do_graphic(void) {
close_shop();
}
break;
+ case 5:
+ dialog_message(npc_list_dialog, MSG_DRAW, 0, 0);
+ if(!gui_update(npc_list_player)) {
+ show_npc_dialog = shutdown_dialog(npc_list_player);
+ if(show_npc_dialog==1) {
+ WFIFOW(0) = net_w_value(0x00b8);
+ WFIFOL(2) = net_l_value(current_npc);
+ WFIFOB(6) = net_b_value(npc_list_dialog[3].d1+1);
+ WFIFOSET(7);
+ }
+ show_npc_dialog = 0;
+ npc_list_player = init_dialog(npc_list_dialog, -1);
+ remove_all_items();
+ }
+ break;
}
if(show_skill_dialog) {
diff --git a/src/graphic/graphic.h b/src/graphic/graphic.h
index a652b5cf..571f5136 100644
--- a/src/graphic/graphic.h
+++ b/src/graphic/graphic.h
@@ -39,6 +39,7 @@
#include "../gui/shop.h"
#include "../gui/chat.h"
#include "../gui/inventory.h"
+#include "../gui/npc.h"
#include "../../data/graphic/gfx_data.h"
extern BITMAP *buffer, *double_buffer;
@@ -51,6 +52,7 @@ extern int show_npc_dialog;
extern TmwInventory inventory;
extern int map_x, map_y, camera_x, camera_y;
extern BITMAP *hairset;
+extern char npc_button[10];
void set_npc_dialog(int show);
void do_graphic(void);
diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp
index ad151f25..b4294f3d 100644
--- a/src/gui/char_select.cpp
+++ b/src/gui/char_select.cpp
@@ -58,7 +58,7 @@ DIALOG char_create_dialog[] = {
{ NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
};
-#define MAX_HAIR_COLOR 6
+#define MAX_HAIR_COLOR 10
int tmw_incbutt_proc(int msg, DIALOG *d, int c) {
if(msg==MSG_CLICK) {
diff --git a/src/gui/npc.cpp b/src/gui/npc.cpp
new file mode 100644
index 00000000..43deb1a8
--- /dev/null
+++ b/src/gui/npc.cpp
@@ -0,0 +1,88 @@
+/**
+
+ The Mana World
+ Copyright 2004 The Mana World Development Team
+
+ This file is part of The Mana World.
+
+ The Mana World is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ any later version.
+
+ The Mana World is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ 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 ElvenProgrammer aka Eugenio Favalli (umperio@users.sourceforge.net)
+
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "npc.h"
+
+ITEM *item_head = NULL;
+int item_number = 0;
+
+char *item_list(int index, int *list_size) {
+ if(index<0) {
+ *list_size = item_number;
+ return NULL;
+ } else {
+ int iterator = 0;
+ ITEM *temp = item_head;
+ while(iterator<index) {
+ temp = temp->next;
+ iterator++;
+ }
+ return temp->name;
+ }
+}
+
+void add_item(char *name) {
+ ITEM *item = item_head;
+ ITEM *temp = (ITEM *)malloc(sizeof(ITEM));
+ temp->name = name;
+ temp->next = NULL;
+ if(!item_head)
+ item_head = temp;
+ else {
+ while(item->next)
+ item = item->next;
+ item->next = temp;
+ }
+ item_number++;
+}
+
+void parse_items(char *string, short len) {
+ char *token = strtok(string, ":");
+ while(token!=NULL) {
+ char *temp = (char *)malloc(strlen(token));
+ strcpy(temp, token);
+ add_item(temp);
+ token = strtok(NULL, ":");
+ }
+}
+
+void remove_all_items() {
+ ITEM *temp, *next;
+ temp = item_head;
+ while(temp) {
+ next = temp->next;
+ free(temp->name);
+ free(temp);
+ temp = next;
+ }
+ item_head = NULL;
+ item_number = 0;
+}
+
+
diff --git a/src/gui/npc.h b/src/gui/npc.h
new file mode 100644
index 00000000..ed2e3e88
--- /dev/null
+++ b/src/gui/npc.h
@@ -0,0 +1,38 @@
+/**
+
+ The Mana World
+ Copyright 2004 The Mana World Development Team
+
+ This file is part of The Mana World.
+
+ The Mana World is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ any later version.
+
+ The Mana World is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ 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 ElvenProgrammer aka Eugenio Favalli (umperio@users.sourceforge.net)
+
+*/
+
+#ifndef _NPC_H
+#define _NPC_H
+
+struct ITEM {
+ char *name;
+ ITEM *next;
+};
+
+char *item_list(int index, int *list_size);
+void parse_items(char *string, short len);
+void remove_all_items();
+
+#endif