diff options
author | Björn Steinbrink <B.Steinbrink@gmx.de> | 2006-02-01 14:53:10 +0000 |
---|---|---|
committer | Björn Steinbrink <B.Steinbrink@gmx.de> | 2006-02-01 14:53:10 +0000 |
commit | 75feac69e27648fb50142756651270891c492537 (patch) | |
tree | 3c5d6eb28674c3664df48c1261f2eca9eb138d13 | |
parent | 30a90b9ad7859fa56184cf6a775e7fd99a6c1647 (diff) | |
download | mana-75feac69e27648fb50142756651270891c492537.tar.gz mana-75feac69e27648fb50142756651270891c492537.tar.bz2 mana-75feac69e27648fb50142756651270891c492537.tar.xz mana-75feac69e27648fb50142756651270891c492537.zip |
Removed duplicated code.
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | src/gui/passwordfield.cpp | 21 |
2 files changed, 7 insertions, 15 deletions
@@ -1,5 +1,6 @@ 2006-02-01 Björn Steinbrink <B.Steinbrink@gmx.de> + * src/gui/passwordfield.cpp: Removed duplicated code. * src/Makefile.am, src/main.cpp, src/gui/error.cpp, src/gui/error.h: Replaced ErrorDialog by OkDialog + listener. * src/Makefile.am, src/game.cpp, src/gui/buysell.cpp, diff --git a/src/gui/passwordfield.cpp b/src/gui/passwordfield.cpp index 7f27607b..533f54fb 100644 --- a/src/gui/passwordfield.cpp +++ b/src/gui/passwordfield.cpp @@ -23,9 +23,7 @@ #include "passwordfield.h" -#include <guichan/font.hpp> -#include <guichan/graphics.hpp> - +#include <string> PasswordField::PasswordField(const std::string& text): TextField(text) @@ -34,16 +32,9 @@ PasswordField::PasswordField(const std::string& text): void PasswordField::draw(gcn::Graphics *graphics) { - 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); + // std::string uses cow, thus cheap copy + const std::string original = mText; + mText.assign(mText.length(), '*'); + TextField::draw(graphics); + mText = original; } |