summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/graphic/graphic.cpp23
-rw-r--r--src/gui/char_server.cpp14
-rw-r--r--src/gui/gui.cpp733
-rw-r--r--src/gui/gui.h17
-rw-r--r--src/gui/login.cpp19
-rw-r--r--src/gui/skill.cpp6
6 files changed, 185 insertions, 627 deletions
diff --git a/src/graphic/graphic.cpp b/src/graphic/graphic.cpp
index f4affd67..4537ee12 100644
--- a/src/graphic/graphic.cpp
+++ b/src/graphic/graphic.cpp
@@ -30,7 +30,6 @@ BITMAP *buffer, *chat_background;
char itemCurrenyQ[10] = "0";
int map_x, map_y, camera_x, camera_y;
-DIALOG_PLAYER *skill_player, *skill_list_player;
char npc_text[1000] = "";
char statsString2[255] = "n/a";
char skill_points[10] = "";
@@ -83,17 +82,6 @@ void BuySellListener::action(const std::string& eventId)
buySellDialog->setVisible(false);
}
-/*
-DIALOG skill_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 *)"Stats", NULL, NULL },
- { tmw_button_proc, 450, 376, 50, 20, 255, 0, 'u', D_EXIT, 0, 0, (char *)"&Up", NULL, NULL },
- { tmw_button_proc, 508, 376, 50, 20, 255, 0, 'c', D_EXIT, 0, 0, (char *)"&Close", NULL, NULL },
- { tmw_list_proc, 304, 224, 252, 100, 0, 0, 0, 0, 0, 0, (char *)skill_list, NULL, NULL },
- { tmw_text_proc, 304, 326, 40, 20, 0, 0, 0, 0, 0, 0, (char *)skill_points, NULL, NULL },
- { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
-};
-*/
char hairtable[14][4][2] = {
// S(x,y) W(x,y) N(x,y) E(x,y)
@@ -195,9 +183,6 @@ GraphicEngine::GraphicEngine() {
skillDialog = new SkillDialog(guiTop);
skillDialog->setVisible(false);
- //skill_player = init_dialog(skill_dialog, -1);
- //skill_list_player = init_dialog(skill_list_dialog, -1);
-
// Give focus to the chat input
chatInput->requestFocus();
@@ -229,8 +214,6 @@ GraphicEngine::~GraphicEngine() {
delete skillDialog;
//delete tileset;
-
- //shutdown_dialog(skill_player);
}
void GraphicEngine::refresh() {
@@ -468,13 +451,8 @@ void GraphicEngine::refresh() {
/*
if (show_skill_dialog) {
update_skill_dialog();
- if (gui_update(skill_player) == 0) {
- show_skill_dialog = false;
- }
}
- */
- /*
if (show_skill_list_dialog) {
if (gui_update(skill_list_player) == 0) {
int ret = shutdown_dialog(skill_list_player);
@@ -488,7 +466,6 @@ void GraphicEngine::refresh() {
} else if(ret == 2) {
show_skill_list_dialog = false;
}
- skill_list_player = init_dialog(skill_list_dialog, -1);
}
}
*/
diff --git a/src/gui/char_server.cpp b/src/gui/char_server.cpp
index 38fb0595..ea28d849 100644
--- a/src/gui/char_server.cpp
+++ b/src/gui/char_server.cpp
@@ -42,9 +42,17 @@ ServerSelectDialog::ServerSelectDialog(gcn::Container *parent):
cancelButton = new Button("Cancel");
setSize(200, 100);
- scrollArea->setDimension(gcn::Rectangle(4, 4, 192, 55));
- okButton->setPosition(120, 70);
- cancelButton->setPosition(146, 70);
+
+ cancelButton->setPosition(
+ 200 - cancelButton->getWidth() - 5,
+ 100 - cancelButton->getHeight() - 5);
+ okButton->setPosition(
+ cancelButton->getX() - okButton->getWidth() - 5,
+ 100 - okButton->getHeight() - 5);
+ scrollArea->setDimension(gcn::Rectangle(
+ 5, 5, 200 - 2 * 5,
+ 100 - 3 * 5 - cancelButton->getHeight() -
+ scrollArea->getBorderSize()));
serverList->setEventId("ok");
okButton->setEventId("ok");
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index e2a22df3..52b4bc85 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -119,18 +119,18 @@ int gui_update(DIALOG_PLAYER *player) {
void loadButtonSkin() {
char **tokens;
- int tokenCount;
- int gridx[4];
- int gridy[4];
- int a = 0;
- int x,y,mode;
+ int tokenCount;
+ int gridx[4];
+ int gridy[4];
+ int a = 0;
+ int x, y, mode;
tokens = get_config_argv("button", "gridx", &tokenCount);
- for (a=0; a < 4; a++) {
+ for (a = 0; a < 4; a++) {
gridx[a] = atoi(tokens[a]);
}
tokens = get_config_argv("button", "gridy", &tokenCount);
- for (a=0; a < 4; a++) {
+ for (a = 0; a < 4; a++) {
gridy[a] = atoi(tokens[a]);
}
@@ -148,10 +148,10 @@ void loadButtonSkin() {
gui__repository[GUI_BMP_OFS_BUTTON + 2] = (BITMAP *)gui_gfx[3].dat;
gui__repository[GUI_BMP_OFS_BUTTON + 3] = (BITMAP *)gui_gfx[1].dat;
- for (mode=0; mode < 4; mode++) {
- a=0;
- for (y=0; y < 3; y++) {
- for (x=0; x < 3; x++) {
+ for (mode = 0; mode < 4; mode++) {
+ a = 0;
+ for (y = 0; y < 3; y++) {
+ for (x = 0; x < 3; x++) {
gui_skin.button.background[mode].grid[a] = create_sub_bitmap(
gui__repository[GUI_BMP_OFS_BUTTON + mode],
gridx[x] , gridy[y],
@@ -240,18 +240,18 @@ void loadCheckboxSkin() {
void loadTextboxSkin() {
char **tokens;
- int tokenCount;
- int gridx[4];
- int gridy[4];
- int a = 0;
- int x,y;
+ int tokenCount;
+ int gridx[4];
+ int gridy[4];
+ int a = 0;
+ int x, y;
tokens = get_config_argv("textbox", "gridx", &tokenCount);
- for (a=0; a < 4; a++) {
+ for (a = 0; a < 4; a++) {
gridx[a] = atoi(tokens[a]);
}
tokens = get_config_argv("textbox", "gridy", &tokenCount);
- for (a=0; a < 4; a++) {
+ for (a = 0; a < 4; a++) {
gridy[a] = atoi(tokens[a]);
}
@@ -262,11 +262,9 @@ void loadTextboxSkin() {
gui__repository[GUI_BMP_OFS_TEXTBOX] = (BITMAP *)gui_gfx[9].dat;
-
-
- a=0;
- for (y=0; y < 3; y++) {
- for (x=0; x < 3; x++) {
+ a = 0;
+ for (y = 0; y < 3; y++) {
+ for (x = 0; x < 3; x++) {
gui_skin.textbox.bg.grid[a] = create_sub_bitmap(
gui__repository[GUI_BMP_OFS_TEXTBOX],
gridx[x] , gridy[y],
@@ -279,18 +277,18 @@ void loadTextboxSkin() {
void loadListboxSkin() {
char **tokens;
- int tokenCount;
- int gridx[4];
- int gridy[4];
- int a = 0;
- int x,y;
+ int tokenCount;
+ int gridx[4];
+ int gridy[4];
+ int a = 0;
+ int x, y;
tokens = get_config_argv("listbox", "gridx", &tokenCount);
- for (a=0; a < 4; a++) {
+ for (a = 0; a < 4; a++) {
gridx[a] = atoi(tokens[a]);
}
tokens = get_config_argv("listbox", "gridy", &tokenCount);
- for (a=0; a < 4; a++) {
+ for (a = 0; a < 4; a++) {
gridy[a] = atoi(tokens[a]);
}
@@ -303,12 +301,12 @@ void loadListboxSkin() {
tokens = get_config_argv("listbox", "textcol_disabled", &tokenCount);
gui_skin.listbox.textcolor[3] = makecol(atoi(tokens[0]),atoi(tokens[1]),atoi(tokens[2]));
- gui__repository[GUI_BMP_OFS_LISTBOX+0] = (BITMAP *)gui_gfx[6].dat;
- gui__repository[GUI_BMP_OFS_LISTBOX+1] = (BITMAP *)gui_gfx[10].dat;
+ gui__repository[GUI_BMP_OFS_LISTBOX + 0] = (BITMAP*)gui_gfx[6].dat;
+ gui__repository[GUI_BMP_OFS_LISTBOX + 1] = (BITMAP*)gui_gfx[10].dat;
- a=0;
- for (y=0; y < 3; y++) {
- for (x=0; x < 3; x++) {
+ a = 0;
+ for (y = 0; y < 3; y++) {
+ for (x = 0; x < 3; x++) {
gui_skin.listbox.bg.grid[a] = create_sub_bitmap(
gui__repository[GUI_BMP_OFS_LISTBOX],
gridx[x] , gridy[y],
@@ -319,16 +317,16 @@ void loadListboxSkin() {
}
tokens = get_config_argv("listbox", "vscroll_gridx", &tokenCount);
- for (a=0; a < 4; a++) {
+ for (a = 0; a < 4; a++) {
gridx[a] = atoi(tokens[a]);
}
tokens = get_config_argv("listbox", "vscroll_gridy", &tokenCount);
- for (a=0; a < 4; a++) {
+ for (a = 0; a < 4; a++) {
gridy[a] = atoi(tokens[a]);
}
- a=0;
- for (y=0; y < 3; y++) {
- for (x=0; x < 3; x++) {
+ a = 0;
+ for (y = 0; y < 3; y++) {
+ for (x = 0; x < 3; x++) {
gui_skin.listbox.vscroll.grid[a] = create_sub_bitmap(
gui__repository[GUI_BMP_OFS_LISTBOX+1],
gridx[x] , gridy[y],
@@ -377,26 +375,26 @@ void loadPlusSkin() {
void loadDialogSkin() {
char **tokens;
- int tokenCount;
- int gridx[4];
- int gridy[4];
- int a = 0;
- int x,y;
+ int tokenCount;
+ int gridx[4];
+ int gridy[4];
+ int a = 0;
+ int x, y;
tokens = get_config_argv("dialog", "gridx", &tokenCount);
- for (a=0; a < 4; a++) {
+ for (a = 0; a < 4; a++) {
gridx[a] = atoi(tokens[a]);
}
tokens = get_config_argv("dialog", "gridy", &tokenCount);
- for (a=0; a < 4; a++) {
+ for (a = 0; a < 4; a++) {
gridy[a] = atoi(tokens[a]);
}
gui__repository[GUI_BMP_OFS_DIALOG] = (BITMAP *)gui_gfx[5].dat;
- a=0;
- for (y=0; y < 3; y++) {
- for (x=0; x < 3; x++) {
+ a = 0;
+ for (y = 0; y < 3; y++) {
+ for (x = 0; x < 3; x++) {
gui_skin.dialog.bg.grid[a] = create_sub_bitmap(
gui__repository[GUI_BMP_OFS_DIALOG],
gridx[x] , gridy[y],
@@ -407,7 +405,9 @@ void loadDialogSkin() {
}
}
-void draw_skinned_rect(BITMAP*dst, LexSkinnedRect *skin, int x, int y,int w, int h) {
+void draw_skinned_rect(BITMAP*dst, LexSkinnedRect *skin,
+ int x, int y, int w, int h)
+{
BITMAP **grid = skin->grid;
int w0 = grid[0]->w;
@@ -479,14 +479,14 @@ void gui_shutdown(void) {
int a, b;
/* Button */
- for (a=0; a < 3; a++) {
- for (b=0; b < 9 ; b++) {
+ for (a = 0; a < 3; a++) {
+ for (b = 0; b < 9 ; b++) {
destroy_bitmap(gui_skin.button.background[a].grid[b]);
}
-
}
+
/* Slider */
- for (a=0; a < 3; a++) {
+ for (a = 0; a < 3; a++) {
destroy_bitmap(gui_skin.slider.hSlider[a]);
destroy_bitmap(gui_skin.slider.vSlider[a]);
}
@@ -505,14 +505,11 @@ void gui_shutdown(void) {
destroy_bitmap(gui_skin.radiobutton.disabled);
destroy_bitmap(gui_skin.radiobutton.disabled_checked);
- for (a=0; a < GUI_BMP_COUNT; a++) {
+ for (a = 0; a < GUI_BMP_COUNT; a++) {
destroy_bitmap(gui__repository[a]);
}
}
-/*
- * Draw text for gui widgets
- */
int gui_text(BITMAP *bmp, AL_CONST char *s, int x, int y, int color, int centre) {
char tmp[1024];
int hline_pos = -1;
@@ -556,15 +553,14 @@ int gui_text(BITMAP *bmp, AL_CONST char *s, int x, int y, int color, int centre)
}
int tmw_text_proc(int msg, DIALOG *d, int c) {
- if (msg==MSG_DRAW) {
+ if (msg == MSG_DRAW) {
gui_text(gui_bitmap, (char *)d->dp, d->x, d->y, d->fg, FALSE);
}
return D_O_K;
}
-
-int tmw_button_proc(int msg, DIALOG *d, int c) {
-
+int tmw_button_proc(int msg, DIALOG *d, int c)
+{
int col = 0;
int ofs = 0;
int ret = D_O_K;
@@ -586,539 +582,116 @@ int tmw_button_proc(int msg, DIALOG *d, int c) {
draw_skinned_rect(gui_bitmap, &gui_skin.button.background[0], d->x, d->y, d->w, d->h);
col = gui_skin.button.textcolor[0];
}
- gui_text(gui_bitmap, (const char *)d->dp, d->x+d->w/2+ofs, d->y+d->h/2-text_height(font)/2+ofs, col, TRUE);
- ret = D_O_K;
- } else {
- /*if(msg==MSG_CLICK) {
- if(d->d1==1)((int)d->dp2) + 1;
- else if(d->d1==2)((int)d->dp2) - 1;
- }*/
-
- ret = d_button_proc(msg,d,c);
+ gui_text(gui_bitmap, (const char *)d->dp, d->x+d->w/2+ofs, d->y+d->h/2-text_height(font)/2+ofs, col, TRUE);
+ ret = D_O_K;
+ } else {
+ /*
+ if (msg == MSG_CLICK) {
+ if (d->d1 == 1) ((int)d->dp2) + 1;
+ else if (d->d1 == 2) ((int)d->dp2) - 1;
+ }
+ */
+
+ ret = d_button_proc(msg,d,c);
}
return ret;
}
-int tmw_radio_proc(int msg, DIALOG *d, int c) {
- BITMAP *box = NULL;
- int x, y;
- int tx, ty, l;
- int col = 0;
+int tmw_dialog_proc(int msg, DIALOG *d, int c) {
+ int x, y;
- if (msg == MSG_DRAW) {
- rectfill(gui_bitmap, d->x, d->y, d->x + d->w, d->y+d->h, d->bg);
- if (d->flags & D_SELECTED) {
- if (d->flags & D_DISABLED) {
- box = gui_skin.radiobutton.disabled_checked;
+ switch (msg) {
+ case MSG_CLICK:
+ if (mouse_y<d->y + gui_skin.dialog.bg.grid[1]->h) {
+ d->d1 = mouse_x - d->x;
+ d->d2 = mouse_y - d->y;
+ }
+ break;
+ case MSG_DRAW:
+ if((mouse_b & 1) && (d->d1 >= 0) && (d->d2 >= 0)) {
+ x = mouse_x - d->d1;
+ y = mouse_y - d->d2;
+ if (x < 15) {
+ x = 0;
+ position_mouse(d->d1, mouse_y);
+ }
+ if (y < 15) {
+ y = 0;
+ position_mouse(mouse_x, d->d2);
+ }
+ if (x + d->w >= SCREEN_W - 15) {
+ x = SCREEN_W - d->w;
+ position_mouse(x+d->d1, mouse_y);
+ }
+ if (y + d->h >= SCREEN_H - 15) {
+ y = SCREEN_H - d->h;
+ position_mouse(mouse_x, y + d->d2);
+ }
+ position_dialog(d, x, y);
} else {
- box = gui_skin.radiobutton.checked;
+ d->d1 = -1;
+ d->d2 = -1;
}
- } else if (d->flags & D_DISABLED) {
- box = gui_skin.radiobutton.disabled;
- } else {
- box = gui_skin.radiobutton.normal;
- }
-
- if (d->flags & D_DISABLED) {
- col = gui_skin.radiobutton.textcolor[1];
- } else {
- col = gui_skin.radiobutton.textcolor[0];
- }
-
- if (d->dp != NULL) {
- l = gui_strlen((const char *)d->dp);
- } else {
- l = 0;
- }
-
- if (d->d2 != 0) {
- x = d->x;
- tx = x + box->w + box->w/2;
- } else {
- x = d->x + d->w - box->w;
- tx = x - box->w/2 - l;
- }
- y = d->y + (d->h - box->h)/ 2;
- ty = d->y + (d->h - text_height(font)) / 2;
-
- masked_blit(box, gui_bitmap, 0, 0, x, y, box->w, box->h);
- if (d->dp != NULL) {
- gui_text(gui_bitmap, (const char *)d->dp, tx, ty, col, 0);
- }
+ draw_skinned_rect(gui_bitmap, &gui_skin.dialog.bg,
+ d->x, d->y, d->w, d->h);
+ textprintf_centre_ex(gui_bitmap, font,
+ d->x + d->w/2,
+ d->y + (gui_skin.dialog.bg.grid[1]->h - text_height(font)) / 2,
+ d->fg, -1, "%s", (char*)d->dp);
- } else {
- return d_radio_proc(msg, d, c);
+ break;
}
return D_O_K;
}
-
-int tmw_list_proc(int msg, DIALOG *d, int c) {
- static int ignoreRedraw = FALSE;
- int itemCount = 0;
- int firstItem = d->d2;
- int lastItem = 0;
- int selectedItem = d->d1;
- int x,y,delta;
- int a, col;
- int w, h = 0;
- int cl, cr, cb, ct;
- int th = text_height(font);
-
- int vscroll = 0;
- int sliderh = 10;
- int slidery = 0;
-
- (*(getfuncptr)d->dp)(-1, &itemCount);
- w = d->w - gui_skin.listbox.bg.grid[0]->w - gui_skin.listbox.bg.grid[2]->w;
- h = d->h - gui_skin.listbox.bg.grid[1]->h - gui_skin.listbox.bg.grid[7]->h;
- lastItem = MIN(itemCount-1, firstItem + h / text_height(font));
-
- if (msg == MSG_DRAW) {
- if (ignoreRedraw) {
- return D_O_K;
- }
- rectfill(gui_bitmap, d->x, d->y, d->x + d->w, d->y+d->h, d->bg);
- draw_skinned_rect(gui_bitmap, &gui_skin.listbox.bg, d->x, d->y, d->w, d->h);
- (*(getfuncptr)d->dp)(-1, &itemCount);
- vscroll = (h/th) < (itemCount-1);
- if (vscroll) {
- w = d->w - 17 - gui_skin.listbox.bg.grid[0]->w;
- draw_skinned_rect(gui_bitmap, &gui_skin.listbox.bg, d->x+d->w-15, d->y+1, 14, d->h-2);
- sliderh = MAX(((d->h-2)* (h / th)) / itemCount, gui_skin.listbox.bg.grid[0]->h*2);
- slidery = ((d->h-2-sliderh) * firstItem) / (itemCount);
- slidery+= d->y+1;
- draw_skinned_rect(gui_bitmap, &gui_skin.listbox.vscroll, d->x+d->w-13, slidery, 11, sliderh);
- }
-
- if (gui_bitmap->clip) {
- cl = gui_bitmap->cl;
- ct = gui_bitmap->ct;
- cr = gui_bitmap->cr;
- cb = gui_bitmap->cb;
- } else {
- cl=ct=0;
- cr=gui_bitmap->w;
- cb=gui_bitmap->h;
- }
- x = d->x + gui_skin.listbox.bg.grid[0]->w;
- y = d->y + gui_skin.listbox.bg.grid[0]->h;
- set_clip_rect(gui_bitmap, x,y, x+w, y+h);
- if (d->flags & D_DISABLED) {
- col = gui_skin.listbox.textcolor[3];
- for (a=firstItem; a < lastItem; a++) {
- textprintf_ex(gui_bitmap, font, x, y, col, -1, (*(getfuncptr)d->dp)(a, 0));
- y += text_height(font);
- }
- } else {
- for (a=firstItem; a <= lastItem; a++) {
- if (a==d->d1) {
- col = gui_skin.listbox.textcolor[1];
- rectfill(gui_bitmap, x, y, x+w, y+text_height(font)-1, gui_skin.listbox.textcolor[2]);
- } else {
- col = gui_skin.listbox.textcolor[0];
- }
- textprintf_ex(gui_bitmap, font, x, y, col, -1, (*(getfuncptr)d->dp)(a, 0));
- y += text_height(font);
- }
- }
- set_clip_rect(gui_bitmap, cl, ct, cr, cb);
- } else if (msg == MSG_CLICK) {
- x = d->x + gui_skin.listbox.bg.grid[0]->w;
- y = d->y + gui_skin.listbox.bg.grid[0]->h;
- sliderh = MAX(((d->h-2)* (h / th)) / itemCount, gui_skin.listbox.bg.grid[0]->h*2);
- //sliderh = ((d->h-2)* (h / th)) / itemCount;
- slidery = ((d->h-2-sliderh) * firstItem) / (itemCount);
- slidery+= d->y+1;
- if (mouse_x > (d->x + d->w - 14) && mouse_x < (d->x+d->w-1)) {
- // Ok, scroll bar
- if (mouse_y >= slidery && mouse_y < slidery + sliderh) {
- delta= mouse_y - slidery;
- while (mouse_b) {
- a = mouse_y - delta - d->y -1;
- a *= itemCount;
- a /= (d->h-2);
- a = MID(0, a, itemCount- h/th);
- if (a != d->d2) {
- d->d2 = a;
- scare_mouse();
- object_message(d, MSG_DRAW, 0);
- unscare_mouse();
- }
- slidery = ((d->h-2) * firstItem) / (itemCount);
- slidery+= d->y+1;
- }
- } else if (mouse_y < slidery) {
- a = d->d2 - (h/th)+1;
- a = MID(0, a, itemCount- h/th);
-
- d->d2 = a;
- scare_mouse();
- object_message(d, MSG_DRAW, 0);
- unscare_mouse();
- while (mouse_b) {
- }
- } else if (mouse_y > slidery + sliderh) {
- a = d->d2 + (h/th)-1;
- a = MID(0, a, itemCount- h/th);
- d->d2 = a;
- scare_mouse();
- object_message(d, MSG_DRAW, 0);
- unscare_mouse();
- while (mouse_b) {
- }
- }
- } else if (mouse_x >= x && mouse_x < x+w && mouse_y >= y && mouse_y < y+h) {
- while (mouse_b) {
- a = firstItem + (mouse_y-y) / text_height(font);
- if (a <= lastItem && a != selectedItem) {
- d->d1 = selectedItem = a;
- scare_mouse();
- object_message(d, MSG_DRAW, 0);
- unscare_mouse();
- }
- }
- }
- } else {
- ignoreRedraw = (msg == MSG_GOTFOCUS || msg == MSG_LOSTFOCUS);
- a = d_list_proc(msg, d, c);
- if (a == D_USED_CHAR) {
- if (d->d1 < d->d2) {
- if (d->d1 > 0) {
- d->d1 = d->d2;
- }
- } else if (d->d1 > d->d2 + h/th -1) {
- d->d2 = d->d1 - h/th + 1;
- }
- }
- return a;
- }
- return D_O_K;
-}
-int tmw_plus_proc(int msg, DIALOG *d, int c)
-{
-//d->d1 = 0;
-bool draw = false;
-
-if(mouse_b & 1)
- {
- if(d->x+d->w > mouse_x && d->x < mouse_x && d->y+d->h > mouse_y && d->y < mouse_y)
- if(d->d2==1)
- {
- //d->d1 = 1;
- (*(int(__cdecl *)(void *, int))d->dp)(NULL, d->d1);
- masked_blit(gui_skin.plus.bg.grid[1], gui_bitmap, 0, 0, d->x, d->y, gui_bitmap->w, gui_bitmap->h);
- draw = true;
- } else {
- masked_blit(gui_skin.plus.bg.grid[0], gui_bitmap, 0, 0, d->x, d->y, gui_bitmap->w, gui_bitmap->h);
- draw = true;
- }
- } else {
- if (!d->d2) {
- //disable
- masked_blit(gui_skin.plus.bg.grid[2], gui_bitmap, 0, 0, d->x, d->y, gui_bitmap->w, gui_bitmap->h);
- draw = true;
- }
- }
- if(!draw)
- masked_blit(gui_skin.plus.bg.grid[0], gui_bitmap, 0, 0, d->x, d->y, gui_bitmap->w, gui_bitmap->h);
-
-
-return D_O_K;
-}
-
-/* Dialog box with left centered head */
-int tmw_dialog_proc(int msg, DIALOG *d, int c) {
- int x, y;
-
- switch(msg) {
-
- case MSG_CLICK:
- if(mouse_y<d->y+gui_skin.dialog.bg.grid[1]->h) {
- d->d1 = mouse_x - d->x;
- d->d2 = mouse_y - d->y;
- }
- break;
- case MSG_DRAW:
- if((mouse_b & 1)&&(d->d1>=0)&&(d->d2>=0)) {
- x = mouse_x-d->d1;
- y = mouse_y-d->d2;
- if(x<15) {
- x=0;
- position_mouse(d->d1, mouse_y);
- }
- if(y<15) {
- y=0;
- position_mouse(mouse_x, d->d2);
- }
- if(x+d->w>=SCREEN_W-15) {
- x=SCREEN_W-d->w;
- position_mouse(x+d->d1, mouse_y);
- }
- if(y+d->h>=SCREEN_H-15) {
- y=SCREEN_H-d->h;
- position_mouse(mouse_x, y+d->d2);
- }
- position_dialog(d, x, y);
- } else {
- d->d1 = -1;
- d->d2 = -1;
- }
- draw_skinned_rect(gui_bitmap, &gui_skin.dialog.bg, d->x, d->y, d->w, d->h);
-
- textprintf_centre_ex(gui_bitmap, font,
- d->x + d->w/2,
- d->y + (gui_skin.dialog.bg.grid[1]->h - text_height(font))/2, d->fg, -1, "%s", (char*)d->dp);
-
- break;
- }
- return D_O_K;
-}
-
-
-// Helper function to draw a scrollable bar
-void _gui_draw_scrollable_frame(DIALOG *d, int listsize, int offset, int height, int fg_color, int bg) {
- int i, len;
- int xx, yy;
-
- /* create and draw the scrollbar */
- i = ((d->h-5) * height + listsize/2) / listsize;
- xx = d->x+d->w-10;
- yy = d->y;
-
- if (offset > 0) {
- len = (((d->h-5) * offset) + listsize/2) / listsize;
- } else len = 0;
- if (yy+i < d->y+d->h-3) {
- draw_skinned_rect(gui_bitmap, &gui_skin.listbox.vscroll, xx, yy+len, 10, i);
- } else {
- draw_skinned_rect(gui_bitmap, &gui_skin.listbox.vscroll, xx, yy, 10, d->h-3);
- }
-}
-
-/* _gui_draw_textbox:
- * Helper function to draw a textbox object.
- */
-void _gui_draw_textbox(char *thetext, int *listsize, int draw, int offset,
- int wword, int tabsize, int x, int y, int w, int h,
- int disabled, int fore, int deselect, int disable)
-{
- int fg = fore;
- int y1 = y+4;
- int x1;
- int len;
- int ww = w-6;
- char s[16];
- char text[16];
- char space[16];
- char *printed = text;
- char *scanned = text;
- char *oldscan = text;
- char *ignore = NULL;
- char *tmp, *ptmp;
- int width;
- int line = 0;
- int i = 0;
- int noignore;
-
- usetc(s+usetc(s, '.'), 0);
- usetc(text+usetc(text, ' '), 0);
- usetc(space+usetc(space, ' '), 0);
-
- /* find the correct text */
- if (thetext != NULL) {
- printed = thetext;
- scanned = thetext;
- }
-
- /* choose the text color */
- if (disabled)
- fg = disable;
-
- /* loop over the entire string */
- while (1) {
- width = 0;
-
- /* find the next break */
- while (ugetc(scanned)) {
- /* check for a forced break */
- if (ugetc(scanned) == '\n') {
- scanned += uwidth(scanned);
-
- /* we are done parsing the line end */
- break;
- }
-
- /* the next character length */
- usetc(s+usetc(s, ugetc(scanned)), 0);
- len = text_length(font, s);
-
- /* modify length if its a tab */
- if (ugetc(s) == '\t')
- len = tabsize * text_length(font, space);
-
- /* check for the end of a line by excess width of next char */
- if (width+len >= ww) {
- /* we have reached end of line do we go back to find start */
- if (wword) {
- /* remember where we were */
- oldscan = scanned;
- noignore = FALSE;
-
- /* go backwards looking for start of word */
- while (!uisspace(ugetc(scanned))) {
- /* don't wrap too far */
- if (scanned == printed) {
- /* the whole line is filled, so stop here */
- tmp = ptmp = scanned;
- while (ptmp != oldscan) {
- ptmp = tmp;
- tmp += uwidth(tmp);
- }
- scanned = ptmp;
- noignore = TRUE;
- break;
- }
- /* look further backwards to wrap */
- tmp = ptmp = printed;
- while (tmp < scanned) {
- ptmp = tmp;
- tmp += uwidth(tmp);
- }
- scanned = ptmp;
- }
- /* put the space at the end of the line */
- if (!noignore) {
- ignore = scanned;
- scanned += uwidth(scanned);
- }
- else
- ignore = NULL;
-
- /* check for endline at the convenient place */
- if (ugetc(scanned) == '\n')
- scanned += uwidth(scanned);
- }
- /* we are done parsing the line end */
- break;
- }
-
- /* the character can be added */
- scanned += uwidth(scanned);
- width += len;
- }
-
- /* check if we are to print it */
- if ((draw) && (line >= offset) && (y1+text_height(font) < (y+h-3))) {
- x1 = x+4;
-
- /* the initial blank bit */
- //rectfill(gui_bitmap, x+2, y1, x1-1, y1+text_height(font), deselect);
-
- /* print up to the marked character */
- while (printed != scanned) {
- /* do special stuff for each charater */
- switch (ugetc(printed)) {
-
- case '\r':
- case '\n':
- /* don't print endlines in the text */
- break;
-
- /* possibly expand the tabs */
- case '\t':
- for (i=0; i<tabsize; i++) {
- usetc(s+usetc(s, ' '), 0);
- textprintf_ex(gui_bitmap, font, x1, y1, fg, -1, s);
- x1 += text_length(font, s);
- }
- break;
-
- /* print a normal character */
- default:
- if (printed != ignore) {
- usetc(s+usetc(s, ugetc(printed)), 0);
- textprintf_ex(gui_bitmap, font, x1, y1, fg, -1, s);
- x1 += text_length(font, s);
- }
- }
-
- /* goto the next character */
- printed += uwidth(printed);
- }
- /* the last blank bit */
- /*if (x1 <= x+w-3)
- rectfill(gui_bitmap, x1, y1, x+w-3, y1+alfont_text_height(font)-1, deselect);*/
-
- /* print the line end */
- y1 += text_height(font);
- }
- printed = scanned;
-
- /* we have done a line */
- line++;
-
- /* check if we are at the end of the string */
- if (!ugetc(printed)) {
- /* the under blank bit */
- /*if (draw)
- rectfill(gui_bitmap, x+1, y1, x+w-3, y+h-1, deselect);*/
-
- /* tell how many lines we found */
- *listsize = line;
- return;
- }
- }
-}
-
void ok(const char *title, const char *message) {
-DIALOG alert_dialog[] = {
- /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
- { tmw_dialog_proc, 0, 0, 0, 60, 0, -1, 0, 0, 0, 0, (void *)title, NULL, NULL },
- { tmw_text_proc, 2, 22, 0, 0, 0, 0, 0, 0, 0, 0, (void *)message, NULL, NULL },
- { tmw_button_proc, 0, 40, 44, 18, 0, -1, 'o', D_EXIT, -1, 0, (char *)"&Ok", NULL, NULL },
- { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }};
-
- BITMAP *temp = gui_bitmap;
- gui_bitmap = screen;
- show_mouse(screen);
- alert_dialog[0].w = text_length(font, message)+4;
- alert_dialog[1].w = text_length(font, message);
- alert_dialog[1].h = text_height(font);
- alert_dialog[2].x = text_length(font, message)/2-22;
- position_dialog(alert_dialog, 400-alert_dialog[0].w/2, 270);
- do_dialog(alert_dialog, 2);
- show_mouse(NULL);
- gui_bitmap = temp;
+ DIALOG alert_dialog[] = {
+ /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
+ { tmw_dialog_proc, 0, 0, 0, 60, 0, -1, 0, 0, 0, 0, (void *)title, NULL, NULL },
+ { tmw_text_proc, 2, 22, 0, 0, 0, 0, 0, 0, 0, 0, (void *)message, NULL, NULL },
+ { tmw_button_proc, 0, 40, 44, 18, 0, -1, 'o', D_EXIT, -1, 0, (char *)"&Ok", NULL, NULL },
+ { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
+ };
+
+ BITMAP *temp = gui_bitmap;
+ gui_bitmap = screen;
+ show_mouse(screen);
+ alert_dialog[0].w = text_length(font, message) + 4;
+ alert_dialog[1].w = text_length(font, message);
+ alert_dialog[1].h = text_height(font);
+ alert_dialog[2].x = text_length(font, message) / 2 - 22;
+ position_dialog(alert_dialog, 400 - alert_dialog[0].w / 2, 270);
+ do_dialog(alert_dialog, 2);
+ show_mouse(NULL);
+ gui_bitmap = temp;
}
unsigned int yes_no(const char *title, const char *message) {
- unsigned int ret;
- DIALOG alert_dialog[] = {
- /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
- { tmw_dialog_proc, 0, 0, 0, 60, 0, -1, 0, 0, 0, 0, (void *)title, NULL, NULL },
- { tmw_text_proc, 2, 22, 0, 0, 0, 0, 0, 0, 0, 0, (void *)message, NULL, NULL },
- { tmw_button_proc, 0, 40, 44, 18, 0, -1, 'o', D_EXIT, -1, 0, (char *)"&Yes", NULL, NULL },
- { tmw_button_proc, 0, 40, 44, 18, 0, -1, 'o', D_EXIT, -1, 0, (char *)"&No", NULL, NULL },
- { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }};
-
- BITMAP *temp = gui_bitmap;
- gui_bitmap = screen;
- show_mouse(screen);
- int width = text_length(font, message)+4;
- if(width<100)width=100;
- alert_dialog[0].w = width;
- alert_dialog[1].w = text_length(font, message);
- alert_dialog[1].h = text_height(font);
- alert_dialog[2].x = width/2-46;
- alert_dialog[2].x = width/2+2;
- position_dialog(alert_dialog, 400-width/2, 270);
- ret = do_dialog(alert_dialog, 3);
- show_mouse(NULL);
- gui_bitmap = temp;
- return ret-2;
+ unsigned int ret;
+ DIALOG alert_dialog[] = {
+ /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
+ { tmw_dialog_proc, 0, 0, 0, 60, 0, -1, 0, 0, 0, 0, (void *)title, NULL, NULL },
+ { tmw_text_proc, 2, 22, 0, 0, 0, 0, 0, 0, 0, 0, (void *)message, NULL, NULL },
+ { tmw_button_proc, 0, 40, 44, 18, 0, -1, 'o', D_EXIT, -1, 0, (char *)"&Yes", NULL, NULL },
+ { tmw_button_proc, 0, 40, 44, 18, 0, -1, 'o', D_EXIT, -1, 0, (char *)"&No", NULL, NULL },
+ { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
+ };
+
+ BITMAP *temp = gui_bitmap;
+ gui_bitmap = screen;
+ show_mouse(screen);
+ int width = text_length(font, message) + 4;
+ if (width < 100) width = 100;
+ alert_dialog[0].w = width;
+ alert_dialog[1].w = text_length(font, message);
+ alert_dialog[1].h = text_height(font);
+ alert_dialog[2].x = width / 2 - 46;
+ alert_dialog[2].x = width / 2 + 2;
+ position_dialog(alert_dialog, 400 - width / 2, 270);
+ ret = do_dialog(alert_dialog, 3);
+ show_mouse(NULL);
+ gui_bitmap = temp;
+ return ret - 2;
}
-
-
diff --git a/src/gui/gui.h b/src/gui/gui.h
index 6aa9be57..f1556898 100644
--- a/src/gui/gui.h
+++ b/src/gui/gui.h
@@ -111,32 +111,27 @@ extern gcn::Container* guiTop; // The top container
extern gcn::AllegroGraphics* guiGraphics; // Graphics driver
extern gcn::ImageFont* guiFont; // The gui font
-// Definition of the callback function prototypes
-typedef int (*gui_buttonCallback)(int id);
-typedef char *(*getfuncptr)(int, int *);
-
void init_gui(BITMAP *dest_bitmap, const char *skin);
void gui_exit();
-int gui_update(DIALOG_PLAYER *player);
-int gui_load_skin(const char* skinname);
+int gui_update(DIALOG_PLAYER *player);
+int gui_load_skin(const char* skinname);
void gui_shutdown(void);
-// Helper procedures used for GUI drawing
+/** Helper procedure to draw skinned rectangles */
void draw_skinned_rect(BITMAP*dst, LexSkinnedRect *skin,
int x, int y, int w, int h);
+
+/** Draw text for gui widgets */
int gui_text(BITMAP *bmp, AL_CONST char *s,
int x, int y, int color, int centre);
// Old Allegro GUI procs
int tmw_button_proc(int msg, DIALOG *d, int c);
-int tmw_radio_proc(int msg, DIALOG *d, int c);
-int tmw_list_proc(int msg, DIALOG *d, int c);
int tmw_text_proc(int msg, DIALOG *d, int c);
int tmw_dialog_proc(int msg, DIALOG *d, int c);
-int tmw_plus_proc(int msg, DIALOG *d, int c);
+// Last two remaining Allegro GUI dialogs
void ok(const char *title, const char *message);
unsigned int yes_no(const char *title, const char *message);
-
#endif
diff --git a/src/gui/login.cpp b/src/gui/login.cpp
index bf294c32..52325105 100644
--- a/src/gui/login.cpp
+++ b/src/gui/login.cpp
@@ -40,17 +40,22 @@ LoginDialog::LoginDialog(gcn::Container *parent):
okButton = new Button("OK");
cancelButton = new Button("Cancel");
- setSize(200, 80);
- userLabel->setPosition(4, 11);
- passLabel->setPosition(4, 31);
- userField->setPosition(60, 10);
- passField->setPosition(60, 30);
+ setSize(200, 75);
+
+ userLabel->setPosition(5, 5);
+ passLabel->setPosition(5, 14 + userLabel->getHeight());
+ userField->setPosition(65, 5);
+ passField->setPosition(65, 14 + userLabel->getHeight());
userField->setWidth(130);
passField->setWidth(130);
keepCheck->setPosition(4, 52);
keepCheck->setMarked(config.getValue("remember", 0));
- okButton->setPosition(120, 52);
- cancelButton->setPosition(146, 52);
+ cancelButton->setPosition(
+ 200 - cancelButton->getWidth() - 5,
+ 75 - cancelButton->getHeight() - 5);
+ okButton->setPosition(
+ cancelButton->getX() - okButton->getWidth() - 5,
+ 75 - okButton->getHeight() - 5);
userField->setEventId("ok");
passField->setEventId("ok");
diff --git a/src/gui/skill.cpp b/src/gui/skill.cpp
index 3abc6eb1..2139c4ff 100644
--- a/src/gui/skill.cpp
+++ b/src/gui/skill.cpp
@@ -73,7 +73,7 @@ int SkillListModel::getNumberOfElements()
std::string SkillListModel::getElementAt(int i)
{
- if (i >= 0 && i < skillList.size())
+ if (i >= 0 && i < (int)skillList.size())
{
//return skill_db[skillList[i]->id];
char tmp[128];
@@ -125,7 +125,8 @@ SkillDialog::SkillDialog(gcn::Container *parent)
incButton->setEventId("inc");
closeButton->setEventId("close");
- skillScrollArea->setDimension(gcn::Rectangle(8, 4, 200, 180));
+ setSize(240, 240);
+ skillScrollArea->setDimension(gcn::Rectangle(5, 5, 229, 180));
pointsLabel->setDimension(gcn::Rectangle(8, 190, 200, 16));
incButton->setPosition(64, 210);
closeButton->setPosition(160, 210);
@@ -138,7 +139,6 @@ SkillDialog::SkillDialog(gcn::Container *parent)
incButton->addActionListener(this);
closeButton->addActionListener(this);
- setSize(240, 240);
setLocationRelativeTo(getParent());
}