summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/graphics/gui/textfield.xml1
-rw-r--r--src/gui/widgets/passwordfield.cpp8
-rw-r--r--src/gui/widgets/passwordfield.h3
-rw-r--r--src/gui/widgets/textfield.cpp2
-rw-r--r--src/gui/widgets/textfield.h3
5 files changed, 13 insertions, 4 deletions
diff --git a/data/graphics/gui/textfield.xml b/data/graphics/gui/textfield.xml
index 3141cea2b..b53ca71e7 100644
--- a/data/graphics/gui/textfield.xml
+++ b/data/graphics/gui/textfield.xml
@@ -2,6 +2,7 @@
<widget type="Window" xpos="41" ypos="186">
<option name="padding" value="1" />
<option name="frameSize" value="2" />
+ <option name="passwordChar" value="0" />
<!-- Top Row -->
<part type="top-left-corner" xpos="0" ypos="0" width="4" height="4" />
diff --git a/src/gui/widgets/passwordfield.cpp b/src/gui/widgets/passwordfield.cpp
index f0dd0f256..f301f2fe7 100644
--- a/src/gui/widgets/passwordfield.cpp
+++ b/src/gui/widgets/passwordfield.cpp
@@ -26,7 +26,8 @@
PasswordField::PasswordField(const Widget2 *const widget,
const std::string &text):
- TextField(widget, text)
+ TextField(widget, text),
+ mPasswordChar(mSkin ? mSkin->getOption("passwordChar", 42) : 42)
{
}
@@ -34,7 +35,10 @@ void PasswordField::draw(gcn::Graphics *graphics)
{
// std::string uses cow, thus cheap copy
const std::string original = mText;
- mText.assign(mText.length(), '*');
+ if (mPasswordChar)
+ mText.assign(mText.length(), mPasswordChar);
+ else
+ mText = "";
TextField::draw(graphics);
mText = original;
}
diff --git a/src/gui/widgets/passwordfield.h b/src/gui/widgets/passwordfield.h
index 69aaa32fc..87b248221 100644
--- a/src/gui/widgets/passwordfield.h
+++ b/src/gui/widgets/passwordfield.h
@@ -45,6 +45,9 @@ class PasswordField final : public TextField
* Draws the password field.
*/
void draw(gcn::Graphics *graphics) override;
+
+ protected:
+ int mPasswordChar;
};
#endif
diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp
index 4e5e7e027..a31ae59fe 100644
--- a/src/gui/widgets/textfield.cpp
+++ b/src/gui/widgets/textfield.cpp
@@ -39,10 +39,10 @@
#include "debug.h"
+Skin *TextField::mSkin;
int TextField::instances = 0;
float TextField::mAlpha = 1.0;
ImageRect TextField::skin;
-Skin *TextField::mSkin;
TextField::TextField(const Widget2 *const widget,
const std::string &text, const bool loseFocusOnTab,
diff --git a/src/gui/widgets/textfield.h b/src/gui/widgets/textfield.h
index dc35cfe70..f4592e292 100644
--- a/src/gui/widgets/textfield.h
+++ b/src/gui/widgets/textfield.h
@@ -124,6 +124,8 @@ class TextField : public gcn::TextField,
bool mSendAlwaysEvents;
+ static Skin *mSkin;
+
private:
void handlePaste();
@@ -132,7 +134,6 @@ class TextField : public gcn::TextField,
static int instances;
static float mAlpha;
static ImageRect skin;
- static Skin *mSkin;
bool mNumeric;
int mMinimum;
unsigned mMaximum;