From dc7b347b0d77a8c74f302e48ea980ec8014df3dd Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Thu, 16 Dec 2004 00:38:41 +0000 Subject: Skinned checkbox similar to what it used to be. --- src/gui/gui.cpp | 71 -------------------------------------- src/gui/gui.h | 2 -- src/gui/login.cpp | 90 ++++++++++++++++++++++++++++--------------------- src/gui/mw_button.cpp | 10 +++--- src/gui/mw_button.h | 4 +-- src/gui/mw_checkbox.cpp | 65 +++++++++++++++++++++++++++++++++++ src/gui/mw_checkbox.h | 36 ++++++++++++++++++++ 7 files changed, 159 insertions(+), 119 deletions(-) create mode 100644 src/gui/mw_checkbox.cpp create mode 100644 src/gui/mw_checkbox.h (limited to 'src') diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 2a3631c2..22391550 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -508,22 +508,6 @@ void gui_shutdown(void) { } } -/* - * Find out the screen area of a Guichan widget - */ -gcn::Rectangle getScreenDimension(gcn::Widget *widget) { - gcn::Rectangle rect = gcn::Rectangle(widget->getDimension()); - gcn::BasicContainer *parent = widget->getParent(); - - while (parent != NULL) { - rect.x += parent->getX(); - rect.y += parent->getY(); - parent = parent->getParent(); - } - - return rect; -} - /* * Draw text for gui widgets */ @@ -696,61 +680,6 @@ int tmw_slider_proc(int msg, DIALOG *d, int c) { return ret; } -int tmw_check_proc(int msg, DIALOG *d, int c) { - BITMAP *box = NULL; - int x, y; - int tx, ty, l; - int rtm = 0; - int col = 0; - 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.checkbox.disabled_checked; - } else { - box = gui_skin.checkbox.checked; - } - } else if (d->flags & D_DISABLED) { - box = gui_skin.checkbox.disabled; - } else { - box = gui_skin.checkbox.normal; - } - - if (d->flags & D_DISABLED) { - col = gui_skin.checkbox.textcolor[1]; - } else { - col = gui_skin.checkbox.textcolor[0]; - } - - if (d->dp != NULL) { - l = gui_strlen((const char *)d->dp); - } else { - l = 0; - } - - if (d->d1 != 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 - alfont_text_height(gui_font)) / 2; - - masked_blit(box, gui_bitmap, 0, 0, x, y, box->w, box->h); - if (d->dp != NULL) { - rtm = alfont_text_mode(-1); - gui_text(gui_bitmap, (const char *)d->dp, tx, ty, col, 0); - alfont_text_mode(rtm); - } - - - } else { - return d_check_proc(msg, d, c); - } - return D_O_K; -} int tmw_radio_proc(int msg, DIALOG *d, int c) { BITMAP *box = NULL; diff --git a/src/gui/gui.h b/src/gui/gui.h index b6b134e1..99d302db 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -118,7 +118,6 @@ int gui_load_skin(const char* skinname); void gui_shutdown(void); // Helper procedures used for GUI drawing -gcn::Rectangle getScreenDimension(gcn::Widget *widget); void draw_skinned_rect(BITMAP*dst, LexSkinnedRect *skin, int x, int y, int w, int h); int gui_text(BITMAP *bmp, AL_CONST char *s, @@ -127,7 +126,6 @@ int gui_text(BITMAP *bmp, AL_CONST char *s, // Old Allegro GUI procs int tmw_button_proc(int msg, DIALOG *d, int c); int tmw_slider_proc(int msg, DIALOG *d, int c); -int tmw_check_proc(int msg, DIALOG *d, int c); int tmw_radio_proc(int msg, DIALOG *d, int c); int tmw_edit_proc(int msg, DIALOG *d, int c); int tmw_password_proc(int msg, DIALOG *d, int c); diff --git a/src/gui/login.cpp b/src/gui/login.cpp index 1b80ffc6..bae87745 100644 --- a/src/gui/login.cpp +++ b/src/gui/login.cpp @@ -24,6 +24,7 @@ #include "login.h" #include "gui.h" #include "mw_button.h" +#include "mw_checkbox.h" #include "../graphic/graphic.h" // Dialog parts @@ -74,7 +75,7 @@ void login() { passLabel = new gcn::Label("Password:"); userField = new gcn::TextField("player"); passField = new gcn::TextField(); - keepCheck = new gcn::CheckBox("Keep", false); + keepCheck = new MWCheckBox("Keep", false); okButton = new MWButton("OK"); cancelButton = new MWButton("Cancel"); @@ -111,7 +112,7 @@ void login() { dialog->add(cancelButton); guiTop->add(dialog); - + if (get_config_int("login", "remember", 0)) { if (get_config_string("login", "username", 0)) { userField->setText(get_config_string("login", "username", "")); @@ -149,14 +150,17 @@ void server_login(const std::string& user, const std::string& pass) { int ret; // Connect to login server - ret = open_session(get_config_string("server", "host", 0), get_config_int("server", "port", 0)); + ret = open_session( + get_config_string("server", "host", 0), + get_config_int("server", "port", 0)); + if (ret == SOCKET_ERROR) { state = LOGIN; ok("Error", "Unable to connect to login server"); warning("Unable to connect to login server"); return; } - + // Send login infos WFIFOW(0) = net_w_value(0x0064); @@ -167,41 +171,49 @@ void server_login(const std::string& user, const std::string& pass) { WFIFOB(54) = 0; WFIFOSET(55); - while((in_size<23)||(out_size>0))flush(); + while ((in_size < 23) || (out_size > 0)) { + flush(); + } log("Network", "Packet ID: %x", RFIFOW(0)); log("Network", "Packet length: %d", get_packet_length(RFIFOW(0))); - - if(RFIFOW(0)==0x0069) { - while(in_sizew + 2; + ty = y - 2; + + masked_blit(box, gui_bitmap, 0, 0, x, y, box->w, box->h); + + int rtm = alfont_text_mode(-1); + gui_text(gui_bitmap, getCaption().c_str(), tx, ty, col, 0); + alfont_text_mode(rtm); +} diff --git a/src/gui/mw_checkbox.h b/src/gui/mw_checkbox.h new file mode 100644 index 00000000..427d943a --- /dev/null +++ b/src/gui/mw_checkbox.h @@ -0,0 +1,36 @@ +/* + * 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 + */ + +#ifndef _TMW_CHECKBOX_H +#define _TMW_CHECKBOX_H + +#include "gui.h" + +class MWCheckBox : public gcn::CheckBox { + public: + MWCheckBox(const std::string& caption, bool marked = false); + + // Inherited from Widget + + void draw(gcn::Graphics* graphics); +}; + +#endif -- cgit v1.2.3-70-g09d2