summaryrefslogtreecommitdiff
path: root/src/graphic
diff options
context:
space:
mode:
Diffstat (limited to 'src/graphic')
-rw-r--r--src/graphic/graphic.cpp69
-rw-r--r--src/graphic/graphic.h6
-rw-r--r--src/graphic/image.h4
3 files changed, 57 insertions, 22 deletions
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) {