summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2004-12-23 17:05:58 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2004-12-23 17:05:58 +0000
commitcf59ec424306ceec1f1ff5c642c10a0c0db44985 (patch)
tree4003c1be403d26ab10f4fa4a8b9f5d9e49a7ce33
parent3a9ae4770fcfec80c660fd9351ecea8c3c9bc913 (diff)
downloadmana-client-cf59ec424306ceec1f1ff5c642c10a0c0db44985.tar.gz
mana-client-cf59ec424306ceec1f1ff5c642c10a0c0db44985.tar.bz2
mana-client-cf59ec424306ceec1f1ff5c642c10a0c0db44985.tar.xz
mana-client-cf59ec424306ceec1f1ff5c642c10a0c0db44985.zip
Password masking is back!
-rw-r--r--The Mana World.dev20
-rw-r--r--file.list8
-rw-r--r--src/Makefile.am1
-rw-r--r--src/gui/gui.cpp140
-rw-r--r--src/gui/gui.h2
-rw-r--r--src/gui/login.cpp3
-rw-r--r--src/gui/passwordfield.cpp49
-rw-r--r--src/gui/passwordfield.h47
-rw-r--r--src/gui/textfield.h2
9 files changed, 125 insertions, 147 deletions
diff --git a/The Mana World.dev b/The Mana World.dev
index 5ed578e5..a4dba93f 100644
--- a/The Mana World.dev
+++ b/The Mana World.dev
@@ -613,3 +613,23 @@ Priority=1000
OverrideBuildCmd=0
BuildCmd=
+[Unit57]
+FileName=src\gui\passwordfield.cpp
+CompileCpp=1
+Folder=gui
+Compile=1
+Link=1
+Priority=1000
+OverrideBuildCmd=0
+BuildCmd=
+
+[Unit58]
+FileName=src\gui\passwordfield.h
+CompileCpp=1
+Folder=gui
+Compile=1
+Link=1
+Priority=1000
+OverrideBuildCmd=0
+BuildCmd=
+
diff --git a/file.list b/file.list
index 7ba8dd9f..361b5588 100644
--- a/file.list
+++ b/file.list
@@ -10,6 +10,7 @@ MODULES = src/sound/sound.cpp \
src/gui/inventory.cpp \
src/gui/login.cpp \
src/gui/npc.cpp \
+ src/gui/passwordfield.cpp \
src/gui/progressbar.cpp \
src/gui/setup.cpp \
src/gui/shop.cpp \
@@ -19,8 +20,9 @@ MODULES = src/sound/sound.cpp \
src/gui/window.cpp \
src/net/network.cpp \
src/net/protocol.cpp \
- src/being.cpp src/game.cpp \
+ src/astar.cpp \
+ src/being.cpp \
+ src/game.cpp \
src/main.cpp \
src/map.cpp \
- src/log.cpp \
- src/astar.cpp
+ src/log.cpp
diff --git a/src/Makefile.am b/src/Makefile.am
index ffc5023a..1890a8d6 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -11,6 +11,7 @@ tmw_SOURCES = sound/sound.cpp \
gui/inventory.cpp \
gui/login.cpp \
gui/npc.cpp \
+ gui/passwordfield.cpp \
gui/progressbar.cpp \
gui/setup.cpp \
gui/shop.cpp \
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index 714f114f..0c052fec 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -727,146 +727,6 @@ int tmw_radio_proc(int msg, DIALOG *d, int c) {
return D_O_K;
}
-int tmw_edit_proc(int msg, DIALOG *d, int c) {
- int x;
- int tx, ty, l;
- int rtm = 0;
- int col = 0;
- char* start;
- char* text;
- char hack;
- int cl, cr, cb, ct;
- int lb, rb;
-
-
- if (msg == MSG_DRAW) {
- rectfill(gui_bitmap, d->x, d->y, d->x + d->w, d->y+d->h, d->bg);
- draw_skinned_rect(gui_bitmap, &gui_skin.textbox.bg, d->x, d->y, d->w, d->h);
-
- if (d->flags & D_DISABLED) {
- col = gui_skin.textbox.textcolor[1];
- } else {
- col = gui_skin.textbox.textcolor[0];
- }
-
- lb = gui_skin.textbox.bg.grid[0]->w;
- rb = gui_skin.textbox.bg.grid[2]->w;
- tx = d->x + lb;
- ty = d->y + (d->h - text_height(font))/2;
-
-
- text = (char *)d->dp;
- start = text;
-
- 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;
- }
- set_clip_rect(gui_bitmap, tx, ty, d->x+d->w-rb, ty + text_height(font));
- hack = text[d->d2];
- text[d->d2] = '\0';
- l = text_length(font, text);
- text[d->d2] = hack;
-
- if (l > d->w-lb-rb) {
- tx += ((d->w-lb-rb) - l);
- }
- gui_text(gui_bitmap, start, tx, ty, col, 0);
-
-
- if (d->flags & D_GOTFOCUS) {
- hack = text[d->d2];
- text[d->d2] = '\0';
- x = tx + text_length(font, text);
- vline(gui_bitmap, x, ty, ty + text_height(font), col);
- text[d->d2] = hack;
- }
- set_clip_rect(gui_bitmap, cl, ct, cr, cb);
- } else {
- return d_edit_proc(msg, d, c);
- }
- return D_O_K;
-}
-
-int tmw_password_proc(int msg, DIALOG *d, int c) {
-// BITMAP *box = NULL;
- int x;
- int tx, ty, l;
- int rtm = 0;
- int col = 0;
- char* start;
- char* text;
- char hack;
- int cl, cr, cb, ct;
- int lb, rb;
-
-
- if (msg == MSG_DRAW) {
- rectfill(gui_bitmap, d->x, d->y, d->x + d->w, d->y+d->h, d->bg);
- draw_skinned_rect(gui_bitmap, &gui_skin.textbox.bg, d->x, d->y, d->w, d->h);
-
- if (d->flags & D_DISABLED) {
- col = gui_skin.textbox.textcolor[1];
- } else {
- col = gui_skin.textbox.textcolor[0];
- }
-
- lb = gui_skin.textbox.bg.grid[0]->w;
- rb = gui_skin.textbox.bg.grid[2]->w;
- tx = d->x + lb;
- ty = d->y + (d->h - text_height(font))/2;
-
-
- text = (char *)malloc(strlen((char *)d->dp)+1);
- // Sull: new ansi standard
- unsigned int i;
- for(i=0;i<strlen((char *)d->dp);i++)text[i] = '*';
- text[i] = '\0';
- start = text;
-
- 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;
- }
- set_clip_rect(gui_bitmap, tx, ty, d->x+d->w-rb, ty + text_height(font));
-
- hack = text[d->d2];
- text[d->d2] = '\0';
- l = text_length(font, text);
- text[d->d2] = hack;
-
- if (l > d->w-lb-rb) {
- tx += ((d->w-lb-rb) - l);
- }
- gui_text(gui_bitmap, start, tx, ty, col, 0);
-
-
- if (d->flags & D_GOTFOCUS) {
- hack = text[d->d2];
- text[d->d2] = '\0';
- x = tx + text_length(font, text);
- vline(gui_bitmap, x, ty, ty + text_height(font), col);
- text[d->d2] = hack;
- }
-
- set_clip_rect(gui_bitmap, cl, ct, cr, cb);
- } else {
- return d_edit_proc(msg, d, c);
- }
- return D_O_K;
-}
int tmw_list_proc(int msg, DIALOG *d, int c) {
static int ignoreRedraw = FALSE;
diff --git a/src/gui/gui.h b/src/gui/gui.h
index d7936c06..d987c54f 100644
--- a/src/gui/gui.h
+++ b/src/gui/gui.h
@@ -129,8 +129,6 @@ int gui_text(BITMAP *bmp, AL_CONST char *s,
int tmw_button_proc(int msg, DIALOG *d, int c);
int tmw_slider_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);
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);
diff --git a/src/gui/login.cpp b/src/gui/login.cpp
index 4ba0fe67..252d9929 100644
--- a/src/gui/login.cpp
+++ b/src/gui/login.cpp
@@ -26,6 +26,7 @@
#include "button.h"
#include "checkbox.h"
#include "textfield.h"
+#include "passwordfield.h"
#include "../graphic/graphic.h"
@@ -35,7 +36,7 @@ LoginDialog::LoginDialog(gcn::Container *parent):
userLabel = new gcn::Label("Name:");
passLabel = new gcn::Label("Password:");
userField = new TextField("player");
- passField = new TextField();
+ passField = new PasswordField();
keepCheck = new CheckBox("Keep", false);
okButton = new Button("OK");
cancelButton = new Button("Cancel");
diff --git a/src/gui/passwordfield.cpp b/src/gui/passwordfield.cpp
new file mode 100644
index 00000000..028d435b
--- /dev/null
+++ b/src/gui/passwordfield.cpp
@@ -0,0 +1,49 @@
+/*
+ * 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
+ */
+
+#include "passwordfield.h"
+#include "gui.h"
+
+
+PasswordField::PasswordField(const std::string& text):
+ TextField(text)
+{
+}
+
+void PasswordField::draw(gcn::Graphics *graphics)
+{
+ int x, y, w, h, col;
+ getAbsolutePosition(x, y);
+ w = getWidth();
+ h = getHeight();
+ std::string stars;
+ stars.assign(mText.length(), '*');
+
+ if (hasFocus()) {
+ drawCaret(graphics,
+ getFont()->getWidth(stars.substr(0, mCaretPosition)) -
+ mXScroll);
+ }
+
+ graphics->setColor(getForegroundColor());
+ graphics->setFont(getFont());
+ graphics->drawText(stars, 1 - mXScroll, 1);
+}
diff --git a/src/gui/passwordfield.h b/src/gui/passwordfield.h
new file mode 100644
index 00000000..328dc4d0
--- /dev/null
+++ b/src/gui/passwordfield.h
@@ -0,0 +1,47 @@
+/*
+ * 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 __PASSWORDFIELD_H__
+#define __PASSWORDFIELD_H__
+
+#include <allegro.h>
+#include <guichan.hpp>
+#include "textfield.h"
+
+/**
+ * A password field.
+ *
+ * \ingroup GUI
+ */
+class PasswordField : public TextField {
+ public:
+ /**
+ * Constructor, initializes the password field with the given string.
+ */
+ PasswordField(const std::string& text = "");
+
+ /**
+ * Draws the text field.
+ */
+ void draw(gcn::Graphics *graphics);
+};
+
+#endif
diff --git a/src/gui/textfield.h b/src/gui/textfield.h
index c401e416..619b87f8 100644
--- a/src/gui/textfield.h
+++ b/src/gui/textfield.h
@@ -40,7 +40,7 @@ class TextField : public gcn::TextField {
/**
* Draws the text field.
*/
- void draw(gcn::Graphics *graphics);
+ virtual void draw(gcn::Graphics *graphics);
/**
* Draws the background and border.