summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2004-12-12 16:18:13 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2004-12-12 16:18:13 +0000
commit197b684831c9701635fd140bbb06a6c2b3f0fcc7 (patch)
tree035d637cba6634d9195094213d80679838fd925e /src
parent72d8e5065d6c2bdb4c941e91d4280b48afc6d602 (diff)
downloadmana-client-197b684831c9701635fd140bbb06a6c2b3f0fcc7.tar.gz
mana-client-197b684831c9701635fd140bbb06a6c2b3f0fcc7.tar.bz2
mana-client-197b684831c9701635fd140bbb06a6c2b3f0fcc7.tar.xz
mana-client-197b684831c9701635fd140bbb06a6c2b3f0fcc7.zip
Chat input field to Guichan.
Diffstat (limited to 'src')
-rw-r--r--src/game.cpp7
-rw-r--r--src/graphic/graphic.cpp69
-rw-r--r--src/graphic/graphic.h6
-rw-r--r--src/graphic/image.h4
-rw-r--r--src/gui/chat.cpp487
-rw-r--r--src/gui/gui.cpp40
-rw-r--r--src/gui/gui.h3
-rw-r--r--src/gui/login.cpp2
-rw-r--r--src/gui/login.h3
9 files changed, 330 insertions, 291 deletions
diff --git a/src/game.cpp b/src/game.cpp
index 0465cfea..7b15b9ea 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -240,13 +240,6 @@ void do_input() {
if(key[KEY_F11] && action_time==true)
show_player_setup = true;
- if(key[KEY_ENTER]) {
- if(strcmp(speech, "")!=0) {
- chatlog.chat_send(char_info[0].name, speech);
- strcpy(speech,"");
- }
- }
-
// Emotions, Skill dialog
if(key_shifts & KB_ALT_FLAG && action_time == true) {
if(player_node->emotion==0) {
diff --git a/src/graphic/graphic.cpp b/src/graphic/graphic.cpp
index 401e9bc9..184ede63 100644
--- a/src/graphic/graphic.cpp
+++ b/src/graphic/graphic.cpp
@@ -23,6 +23,7 @@
#include "graphic.h"
#include "2xsai.h"
+#include "../gui/gui.h"
#include "../gui/setup.h"
#define TILESET_W 480
@@ -41,8 +42,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, *npc_list_player;
-char speech[255] = "";
+DIALOG_PLAYER *npc_player, *skill_player, *buy_sell_player, *buy_player, *sell_player, *stats_player, *skill_list_player, *npc_list_player;
char npc_text[1000] = "";
char statsString2[255] = "n/a";
char skill_points[10] = "";
@@ -53,6 +53,21 @@ bool show_skill_dialog = false;
bool show_skill_list_dialog = false;
char npc_button[10] = "Close";
+gcn::TextField *chatInput;
+
+void ChatListener::action(const std::string& eventId)
+{
+ if (eventId == "chatinput") {
+ std::string message = chatInput->getText();
+
+ if (message.length() > 0) {
+ chatlog.chat_send(char_info[0].name, message.c_str());
+ chatInput->setText("");
+ }
+ }
+}
+
+
SPRITESET *new_tileset, *new_playerset, *new_npcset, *new_emotionset, *new_monsterset;
DIALOG npc_dialog[] = {
@@ -106,11 +121,12 @@ DIALOG skill_list_dialog[] = {
{ 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 },
{ 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) */
@@ -197,18 +213,29 @@ BITMAP *load_graphic_file(char *filename) {
}
void init_graphic() {
- //tileset = load_datafile("./data/graphic/desert.dat");
- //if(!tileset)error("Unable to load tileset datafile");
- //buffer = create_bitmap(SCREEN_W/2, SCREEN_H/2);
- //double_buffer = create_bitmap(SCREEN_W, SCREEN_H);
-
- alfont_set_font_size(gui_font, 16);
- clear_bitmap(screen);
- chat_background = create_bitmap(592, 100);
- clear_to_color(chat_background, makecol(0,0,0));
-
- // Initialize gui
- chat_player = init_dialog(chat_dialog, -1);
+ //tileset = load_datafile("./data/graphic/desert.dat");
+ //if(!tileset)error("Unable to load tileset datafile");
+ //buffer = create_bitmap(SCREEN_W/2, SCREEN_H/2);
+ //double_buffer = create_bitmap(SCREEN_W, SCREEN_H);
+
+ alfont_set_font_size(gui_font, 16);
+ clear_bitmap(screen);
+ chat_background = create_bitmap(592, 100);
+ clear_to_color(chat_background, makecol(0,0,0));
+
+ // Initialize gui
+
+ // Create chat input field
+ chatInput = new gcn::TextField();
+ chatInput->setPosition(0, SCREEN_H - chatInput->getHeight());
+ chatInput->setWidth(592);
+
+ ChatListener *chatListener = new ChatListener();
+ chatInput->setEventId("chatinput");
+ chatInput->addActionListener(chatListener);
+
+ guiTop->add(chatInput);
+
npc_player = init_dialog(npc_dialog, -1);
position_dialog(npc_dialog, 300, 200);
skill_player = init_dialog(skill_dialog, -1);
@@ -410,7 +437,11 @@ new_tileset->spriteset[0]->draw(vbuffer, 0, 0);
SuperEagle(vbuffer, vpage[page_num], 0, 0, 0, 0, 400, 300);
textprintf_ex(vpage[page_num], font, 0, 0, makecol(255,255,255), -1, "[%i fps]", fps);
-
+
+ // Update GUI
+ guiGraphics->setTarget(vpage[page_num]);
+ gui_update(NULL);
+
// Draw player speech
node = get_head();
while(node) {
@@ -435,7 +466,6 @@ new_tileset->spriteset[0]->draw(vbuffer, 0, 0);
draw_trans_sprite(vpage[page_num], chat_background, 0, SCREEN_H-125);
chatlog.chat_draw(vpage[page_num], 8, gui_font);
- gui_update(chat_player);
switch(show_npc_dialog) {
case 1:
@@ -881,7 +911,6 @@ new_tileset->spriteset[0]->draw(vbuffer, 0, 0);
}
void exit_graphic() {
- shutdown_dialog(npc_player);
- shutdown_dialog(chat_player);
- shutdown_dialog(skill_player);
+ shutdown_dialog(npc_player);
+ shutdown_dialog(skill_player);
}
diff --git a/src/graphic/graphic.h b/src/graphic/graphic.h
index e4fd66aa..4ab0aa32 100644
--- a/src/graphic/graphic.h
+++ b/src/graphic/graphic.h
@@ -53,6 +53,12 @@ extern int map_x, map_y, camera_x, camera_y;
extern BITMAP *hairset;
extern char npc_button[10];
+// The action listener for the chat field
+class ChatListener : public gcn::ActionListener {
+ public:
+ void action(const std::string& eventId);
+};
+
void set_npc_dialog(int show);
void do_graphic(void);
void init_graphic(void);
diff --git a/src/graphic/image.h b/src/graphic/image.h
index bd3545e3..a9b7e8cd 100644
--- a/src/graphic/image.h
+++ b/src/graphic/image.h
@@ -26,7 +26,7 @@ class RLE_IMAGE : public IMAGE {
RLE_IMAGE(RLE_SPRITE *src, int offset_x, int offset_y) : IMAGE(offset_x, offset_y) {
this->src = src;
}
- ~RLE_IMAGE() {
+ virtual ~RLE_IMAGE() {
destroy_rle_sprite(src);
}
void draw(BITMAP *dest, int x, int y) {
@@ -41,7 +41,7 @@ class VIDEO_IMAGE : public IMAGE {
VIDEO_IMAGE(BITMAP *src, int offset_x, int offset_y) : IMAGE(offset_x, offset_y) {
this->src = src;
}
- ~VIDEO_IMAGE() {
+ virtual ~VIDEO_IMAGE() {
destroy_bitmap(src);
}
void draw(BITMAP *dest, int x, int y) {
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index b9b1daf7..b1cec890 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -21,278 +21,285 @@
#include "chat.h"
-/**
- Simple ChatLog Object v0.5 (i'd say...)
-
- Bestviewd w/ Bitstream Vera Sans Mono @ 9pt and a tab-width of 2 spaces
-
- Author: kth5 aka Alexander Baldeck
- pipe your questions, suggestions and flames to: kth5@gawab.com
-*/
+/*
+ * Simple ChatLog Object v0.5 (i'd say...)
+ *
+ * Bestviewd w/ Bitstream Vera Sans Mono @ 9pt and a tab-width of 2 spaces
+ *
+ * Author: kth5 aka Alexander Baldeck
+ * pipe your questions, suggestions and flames to: kth5@gawab.com
+ */
-/**
-*/
+/*
+ */
Chat::Chat(const char * logfile, int item_num) {
- chatlog_file.open(logfile, std::ios::out | std::ios::app);
- items = 0;
- items_keep = item_num;
+ chatlog_file.open(logfile, std::ios::out | std::ios::app);
+ items = 0;
+ items_keep = item_num;
}
-/**
-*/
+/*
+ */
Chat::~Chat() {
- chatlog_file.flush();
- chatlog_file.close();
+ chatlog_file.flush();
+ chatlog_file.close();
}
-/**
-*/
+/*
+ */
void Chat::chat_dlgrsize(int) {
}
-/** adds a line of text to our message list
-
- string line -> message text
- int own -> type of message (usually the owner-type)
- ALFONT_FONT * font -> font that'll be used to draw the text later
-
- NOTE:
- to all of you who wonder why the font needs to be passed, simple.
- i already store the width in pixel in the list rather than
- calculating it again and again on every draw event. ;-)
+/*
+ * Adds a line of text to our message list. Parameters:
+ *
+ * line: message text
+ * own: type of message (usually the owner-type)
+ * font: font that'll be used to draw the text later
+ *
+ * NOTE:
+ * To all of you who wonder why the font needs to be passed, simple.
+ * i already store the width in pixel in the list rather than
+ * calculating it again and again on every draw event. ;-)
*/
void Chat::chat_log(std::string line, int own, ALFONT_FONT * font) {
- int pos;
- CHATLOG tmp;
-
- if(items<=items_keep)
- items++; // delete overhead from the end of the list
- else
- chatlog.pop_back();
-
- pos = 0;
- pos = (int)line.find(" : ", 0);
- if(pos > 0) {
- tmp.nick = line.substr(0,pos);
- switch(own) {
- case ACT_IS :
- tmp.nick += CAT_IS;
- break;
- case ACT_WHISPER :
- tmp.nick += CAT_WHISPER;
- break;
- default :
- tmp.nick += CAT_NORMAL;
- }
- tmp.width = TEXT_GETWIDTH(tmp.nick.c_str())+2;
- line.erase(0,pos+3);
- }else {
- tmp.nick = "";
- tmp.width = 1;
- }
- tmp.own = own;
- tmp.text = line;
+ int pos;
+ CHATLOG tmp;
+
+ if (items <= items_keep) {
+ items++; // delete overhead from the end of the list
+ }
+ else {
+ chatlog.pop_back();
+ }
+
+ pos = 0;
+ pos = (int)line.find(" : ", 0);
+ if (pos > 0) {
+ tmp.nick = line.substr(0,pos);
+ switch(own) {
+ case ACT_IS :
+ tmp.nick += CAT_IS;
+ break;
+ case ACT_WHISPER :
+ tmp.nick += CAT_WHISPER;
+ break;
+ default :
+ tmp.nick += CAT_NORMAL;
+ }
+ tmp.width = TEXT_GETWIDTH(tmp.nick.c_str())+2;
+ line.erase(0,pos+3);
+ } else {
+ tmp.nick = "";
+ tmp.width = 1;
+ }
+ tmp.own = own;
+ tmp.text = line;
- chatlog_file << tmp.nick << tmp.text << "\n";
- chatlog_file.flush();
+ chatlog_file << tmp.nick << tmp.text << "\n";
+ chatlog_file.flush();
- chatlog.push_front(tmp);
+ chatlog.push_front(tmp);
}
-/** function overload -> calls original chat_log()
- after processing the packet
-*/
+/*
+ * function overload -> calls original chat_log() after processing the packet
+ */
void Chat::chat_log(CHATSKILL action, ALFONT_FONT * font) {
- chat_log(const_msg(action), BY_SERVER, font);
+ chat_log(const_msg(action), BY_SERVER, font);
}
-/** draw first n lines of the list onto a Allegro type bitmap buffer
- using Alfont
-
- BITMAP * bmp -> Allegro type bitmap buffer to draw onto
- int n -> number of lines to be drawn
- ALFONT_FONT * font -> font to use
-
- NOTE:
- take great care using this, make sure the buffer passed is
- empty! ;-) anyway, line wrapping is not supported yet.
+/*
+ * Draw first n lines of the list onto a Allegro type bitmap buffer using
+ * Alfont.
+ *
+ * BITMAP * bmp: Allegro type bitmap buffer to draw onto
+ * int n: number of lines to be drawn
+ * ALFONT_FONT * font: font to use
+ *
+ * NOTE:
+ * take great care using this, make sure the buffer passed is
+ * empty! ;-) anyway, line wrapping is not supported yet.
*/
void Chat::chat_draw(BITMAP * bmp, int n, ALFONT_FONT * font) {
- int y = 600-35, i = 0;
- CHATLOG line;
- n -= 1;
-
- for(iter = chatlog.begin(); iter != chatlog.end(); iter++) {
- line = *iter;
- y -=11;
-
- switch(line.own) {
- case BY_GM :
- alfont_textprintf_aa(bmp, font, 1, y, COLOR_BLUE, "Global announcement: ");
- alfont_textprintf_aa(bmp, font, TEXT_GETWIDTH("Global announcement: "), y, COLOR_GREEN, line.text.c_str());
- break;
- case BY_PLAYER :
- alfont_textprintf_aa(bmp, font, 1, y, COLOR_YELLOW, line.nick.c_str());
- alfont_textprintf_aa(bmp, font, line.width, y, COLOR_WHITE, line.text.c_str());
- break;
- case BY_OTHER :
- alfont_textprintf_aa(bmp, font, 1, y, COLOR_GREEN, line.nick.c_str());
- alfont_textprintf_aa(bmp, font, line.width, y, COLOR_WHITE, line.text.c_str());
- break;
- default :
- alfont_textprintf_aa(bmp, font, 1, y, COLOR_LIGHTBLUE, line.text.c_str());
- }
-
- if(i>=n)
- return;
- i++;
- }
+ int y = 600-35, i = 0;
+ CHATLOG line;
+ n -= 1;
+
+ for (iter = chatlog.begin(); iter != chatlog.end(); iter++) {
+ line = *iter;
+ y -=11;
+
+ switch (line.own) {
+ case BY_GM :
+ alfont_textprintf_aa(bmp, font, 1, y, COLOR_BLUE, "Global announcement: ");
+ alfont_textprintf_aa(bmp, font, TEXT_GETWIDTH("Global announcement: "), y, COLOR_GREEN, line.text.c_str());
+ break;
+ case BY_PLAYER :
+ alfont_textprintf_aa(bmp, font, 1, y, COLOR_YELLOW, line.nick.c_str());
+ alfont_textprintf_aa(bmp, font, line.width, y, COLOR_WHITE, line.text.c_str());
+ break;
+ case BY_OTHER :
+ alfont_textprintf_aa(bmp, font, 1, y, COLOR_GREEN, line.nick.c_str());
+ alfont_textprintf_aa(bmp, font, line.width, y, COLOR_WHITE, line.text.c_str());
+ break;
+ default :
+ alfont_textprintf_aa(bmp, font, 1, y, COLOR_LIGHTBLUE, line.text.c_str());
+ }
+
+ if (i>=n) {
+ return;
+ }
+ i++;
+ }
}
-/** determines wether to send a command or an ordinary message, then
- contructs packets & sends them
-
- string nick -> the character's name to display infront
- string msg -> the message's text which is to be send.
-
- NOTE:
- the nickname is required by the server, if not specified
- the message may not be sent unless a command was intended
- which requires another packet to be constructed! you can
- achieve this by putting a slash ("/") infront of the
- message followed by the command name and the message.
- of course all slash-commands need implemented handler-
- routines. ;-)
- remember, a line starting w/ "@" is not a command that needs
- to be parsed rather is sent using the normal chat-packet.
-
- EXAMPLE:
- // for an global announcement /- command
- chatlog.chat_send("", "/announce Hello to all logged in users!");
- // for simple message by a user /- message
- chatlog.chat_send("Zaeiru", "Hello to all users on the screen!");
-*/
+/*
+ * Determines wether to send a command or an ordinary message, then
+ * contructs packets & sends them
+ *
+ * string nick -> the character's name to display infront
+ * string msg -> the message's text which is to be send.
+ *
+ * NOTE:
+ * the nickname is required by the server, if not specified
+ * the message may not be sent unless a command was intended
+ * which requires another packet to be constructed! you can
+ * achieve this by putting a slash ("/") infront of the
+ * message followed by the command name and the message.
+ * of course all slash-commands need implemented handler-
+ * routines. ;-)
+ * remember, a line starting w/ "@" is not a command that needs
+ * to be parsed rather is sent using the normal chat-packet.
+ *
+ * EXAMPLE:
+ * // for an global announcement /- command
+ * chatlog.chat_send("", "/announce Hello to all logged in users!");
+ * // for simple message by a user /- message
+ * chatlog.chat_send("Zaeiru", "Hello to all users on the screen!");
+ */
char * Chat::chat_send(std::string nick, std::string msg) {
- short packid;
-
- // prepare command
- if(msg.substr(0,1)=="/") {
- // global announcement
- if(msg.substr(0,IS_ANNOUNCE_LENGTH) == IS_ANNOUNCE) {
- msg.erase(0,IS_ANNOUNCE_LENGTH);
- packid = 0x0099;
- } else if(msg.substr(0,IS_WHERE_LENGTH) == IS_WHERE) {
+ short packid;
+
+ // prepare command
+ if(msg.substr(0,1)=="/") {
+ // global announcement
+ if(msg.substr(0,IS_ANNOUNCE_LENGTH) == IS_ANNOUNCE) {
+ msg.erase(0,IS_ANNOUNCE_LENGTH);
+ packid = 0x0099;
+ } else if(msg.substr(0,IS_WHERE_LENGTH) == IS_WHERE) {
+ } else {
+ packid = 0x008c;
+ }
+ // prepare ordinary message
} else {
- packid = 0x008c;
- }
- // prepare ordinary message
- } else {
- // temporary hack to make messed-up-keyboard-ppl able to send GM commands
- if(msg.substr(0,1)=="#")
- msg.replace(0,1,"@");
- // end temp. hack XD
- nick += " : ";
- nick += msg;
- msg = nick;
- packid = 0x008c;
- }
-
- msg += "\0";
-
- // send processed message
- WFIFOW(0) = net_w_value(packid);
- WFIFOW(2) = net_w_value((unsigned short)(msg.length()+4));
- memcpy(WFIFOP(4), msg.c_str(), msg.length());
- WFIFOSET((int)msg.length()+4);
- nick = msg = "";
- return "";
+ // temporary hack to make messed-up-keyboard-ppl able to send GM commands
+ if(msg.substr(0,1)=="#")
+ msg.replace(0,1,"@");
+ // end temp. hack XD
+ nick += " : ";
+ nick += msg;
+ msg = nick;
+ packid = 0x008c;
+ }
+
+ msg += "\0";
+
+ // send processed message
+ WFIFOW(0) = net_w_value(packid);
+ WFIFOW(2) = net_w_value((unsigned short)(msg.length()+4));
+ memcpy(WFIFOP(4), msg.c_str(), msg.length());
+ WFIFOSET((int)msg.length()+4);
+ nick = msg = "";
+ return "";
}
-/** PRIVATE :
- NOTE:
- these usually will be left undocumented coz u can't call them
- directly anyway. ;-)
-*/
+/*
+ * PRIVATE :
+ * NOTE:
+ * these usually will be left undocumented coz u can't call them
+ * directly anyway. ;-)
+ */
/** constructs failed messages for actions */
std::string Chat::const_msg(CHATSKILL action) {
- std::string msg;
- if(action.success == SKILL_FAILED && action.skill == SKILL_BASIC) {
- switch(action.bskill) {
- case BSKILL_TRADE :
- msg = "Trade failed!";
- break;
- case BSKILL_EMOTE :
- msg = "Emote failed!";
- break;
- case BSKILL_SIT :
- msg = "Sit failed!";
- break;
- case BSKILL_CREATECHAT :
- msg = "Chat creating failed!";
- break;
- case BSKILL_JOINPARTY :
- msg = "Could not join party!";
- break;
- case BSKILL_SHOUT :
- msg = "Cannot shout!";
- break;
- }
-
- switch(action.reason) {
- case RFAIL_SKILLDEP :
- msg += " You have not yet reached a high enough lvl!";
- break;
- case RFAIL_INSUFHP :
- msg += " Insufficient HP!";
- break;
- case RFAIL_INSUFSP :
- msg += " Insufficient SP!";
- break;
- case RFAIL_NOMEMO :
- msg += " You have no memos!";
- break;
- case RFAIL_SKILLDELAY :
- msg += " You cannot do that right now!";
- break;
- case RFAIL_ZENY :
- msg += " Seems you need more Zeny... ;-)";
- break;
- case RFAIL_WEAPON :
- msg += " You cannot use this skill with that kind of weapon!";
- break;
- case RFAIL_REDGEM :
- msg += " You need another red gem!";
- break;
- case RFAIL_BLUEGEM :
- msg += " You need another blue gem!";
- break;
- case RFAIL_OVERWEIGHT :
- msg += " You're carrying to much to do this!";
- break;
- default :
- msg += " Huh? What's that?";
- break;
- }
- }else{
- switch(action.skill) {
- case SKILL_WARP :
- msg = "Warp failed...";
- break;
- case SKILL_STEAL :
- msg = "Could not steal anything...";
- break;
- case SKILL_ENVENOM :
- msg = "Poison had no effect...";
- break;
- }
- }
-
- return msg;
+ std::string msg;
+ if (action.success == SKILL_FAILED && action.skill == SKILL_BASIC) {
+ switch (action.bskill) {
+ case BSKILL_TRADE :
+ msg = "Trade failed!";
+ break;
+ case BSKILL_EMOTE :
+ msg = "Emote failed!";
+ break;
+ case BSKILL_SIT :
+ msg = "Sit failed!";
+ break;
+ case BSKILL_CREATECHAT :
+ msg = "Chat creating failed!";
+ break;
+ case BSKILL_JOINPARTY :
+ msg = "Could not join party!";
+ break;
+ case BSKILL_SHOUT :
+ msg = "Cannot shout!";
+ break;
+ }
+
+ switch (action.reason) {
+ case RFAIL_SKILLDEP :
+ msg += " You have not yet reached a high enough lvl!";
+ break;
+ case RFAIL_INSUFHP :
+ msg += " Insufficient HP!";
+ break;
+ case RFAIL_INSUFSP :
+ msg += " Insufficient SP!";
+ break;
+ case RFAIL_NOMEMO :
+ msg += " You have no memos!";
+ break;
+ case RFAIL_SKILLDELAY :
+ msg += " You cannot do that right now!";
+ break;
+ case RFAIL_ZENY :
+ msg += " Seems you need more Zeny... ;-)";
+ break;
+ case RFAIL_WEAPON :
+ msg += " You cannot use this skill with that kind of weapon!";
+ break;
+ case RFAIL_REDGEM :
+ msg += " You need another red gem!";
+ break;
+ case RFAIL_BLUEGEM :
+ msg += " You need another blue gem!";
+ break;
+ case RFAIL_OVERWEIGHT :
+ msg += " You're carrying to much to do this!";
+ break;
+ default :
+ msg += " Huh? What's that?";
+ break;
+ }
+ } else {
+ switch(action.skill) {
+ case SKILL_WARP :
+ msg = "Warp failed...";
+ break;
+ case SKILL_STEAL :
+ msg = "Could not steal anything...";
+ break;
+ case SKILL_ENVENOM :
+ msg = "Poison had no effect...";
+ break;
+ }
+ }
+
+ return msg;
}
std::string const_msg(int own) {
- std::string msg;
- return msg;
+ std::string msg;
+ return msg;
}
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index b9dcf923..b20d2e1d 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -57,13 +57,13 @@ int (*gui__external_slider_callback)(void *, int);
int reroute_slider_proc(void *dp3, int d2);
// Guichan Allegro stuff
-gcn::AllegroInput* input; // Input driver
-gcn::AllegroGraphics* graphics; // Graphics driver
+gcn::AllegroInput* guiInput; // Input driver
+gcn::AllegroGraphics* guiGraphics; // Graphics driver
gcn::AllegroImageLoader* imageLoader; // For loading images
// Guichan stuff
gcn::Gui* gui; // A Gui object - binds it all together
-gcn::Container* guitop; // The top container
+gcn::Container* guiTop; // The top container
gcn::ImageFont* guiFont; // A font
@@ -74,19 +74,19 @@ void init_gui(BITMAP *bitmap, const char *skin) {
imageLoader = new gcn::AllegroImageLoader();
gcn::Image::setImageLoader(imageLoader);
- graphics = new gcn::AllegroGraphics();
- graphics->setTarget(bitmap);
+ guiGraphics = new gcn::AllegroGraphics();
+ guiGraphics->setTarget(bitmap);
- input = new gcn::AllegroInput();
+ guiInput = new gcn::AllegroInput();
- guitop = new gcn::Container();
- guitop->setDimension(gcn::Rectangle(0, 0, SCREEN_W, SCREEN_H));
- guitop->setOpaque(false);
+ guiTop = new gcn::Container();
+ guiTop->setDimension(gcn::Rectangle(0, 0, SCREEN_W, SCREEN_H));
+ guiTop->setOpaque(false);
gui = new gcn::Gui();
- gui->setGraphics(graphics);
- gui->setInput(input);
- gui->setTop(guitop);
+ gui->setGraphics(guiGraphics);
+ gui->setInput(guiInput);
+ gui->setTop(guiTop);
guiFont = new gcn::ImageFont("./data/graphic/fixedfont.bmp",
" abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
gcn::Widget::setGlobalFont(guiFont);
@@ -102,14 +102,18 @@ void init_gui(BITMAP *bitmap, const char *skin) {
}
int gui_update(DIALOG_PLAYER *player) {
- int ret;
- gui->logic();
- gui->draw();
+ int ret = 0;
if (player) {
+ // Update Allegro dialog (to be replaced)
dialog_message(player->dialog, MSG_DRAW, 0, 0);
ret = update_dialog(player);
}
+ else {
+ // Update new GUI system using Guichan
+ gui->logic();
+ gui->draw();
+ }
// Draw the mouse
draw_sprite(gui_bitmap, mouse_sprite, mouse_x, mouse_y);
@@ -458,11 +462,11 @@ int gui_load_skin(const char* skinname) {
void gui_exit() {
delete guiFont;
- delete guitop;
+ delete guiTop;
delete gui;
- delete input;
- delete graphics;
+ delete guiInput;
+ delete guiGraphics;
delete imageLoader;
//alfont_destroy_font(gui_font);
diff --git a/src/gui/gui.h b/src/gui/gui.h
index a29d02b7..b3c989c2 100644
--- a/src/gui/gui.h
+++ b/src/gui/gui.h
@@ -103,7 +103,8 @@ extern LexSkin gui_skin;
extern BITMAP *gui_bitmap;
extern ALFONT_FONT *gui_font;
-extern gcn::Container* guitop; // The top container
+extern gcn::Container* guiTop; // The top container
+extern gcn::AllegroGraphics* guiGraphics; // Graphics driver
/* Definition of the callback function prototypes */
typedef int (*gui_buttonCallback)(int id);
diff --git a/src/gui/login.cpp b/src/gui/login.cpp
index 0fe39cef..c61b0e01 100644
--- a/src/gui/login.cpp
+++ b/src/gui/login.cpp
@@ -110,7 +110,7 @@ void login() {
dialog->add(okButton);
dialog->add(cancelButton);
- guitop->add(dialog);
+ guiTop->add(dialog);
if (get_config_int("login", "remember", 0)) {
if (get_config_string("login", "username", 0)) {
diff --git a/src/gui/login.h b/src/gui/login.h
index 9f8f49b6..8798ddea 100644
--- a/src/gui/login.h
+++ b/src/gui/login.h
@@ -36,8 +36,7 @@
#include "gui.h"
// The action listener for the login dialog
-class LoginActionListener : public gcn::ActionListener
-{
+class LoginActionListener : public gcn::ActionListener {
public:
void action(const std::string& eventId);
};