]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/guiPasswordChange.cpp
Tests: Add random unittests
[dragonfireclient.git] / src / guiPasswordChange.cpp
index a4d16444da63abf4332463902a4c8f06bd0990e4..1c1a1f06e7c47c437b976cd73e63b253a3ecb2fe 100644 (file)
@@ -79,7 +79,7 @@ void GUIPasswordChange::regenerateGui(v2u32 screensize)
                Remove stuff
        */
        removeChildren();
-       
+
        /*
                Calculate new sizes and positions
        */
@@ -89,76 +89,70 @@ void GUIPasswordChange::regenerateGui(v2u32 screensize)
                        screensize.X/2 + 580/2,
                        screensize.Y/2 + 300/2
        );
-       
+
        DesiredRect = rect;
        recalculateAbsolutePosition(false);
 
        v2s32 size = rect.getSize();
        v2s32 topleft_client(40, 0);
-       v2s32 size_client = size - v2s32(40, 0);
+
+       const wchar_t *text;
 
        /*
                Add stuff
        */
        s32 ypos = 50;
-       changeCtype("");
        {
-               core::rect<s32> rect(0, 0, 110, 20);
-               rect += topleft_client + v2s32(35, ypos+6);
-               wchar_t* text = wgettext("Old Password");
+               core::rect<s32> rect(0, 0, 150, 20);
+               rect += topleft_client + v2s32(25, ypos+6);
+               text = wgettext("Old Password");
                Environment->addStaticText(text, rect, false, true, this, -1);
                delete[] text;
        }
-       changeCtype("C");
        {
                core::rect<s32> rect(0, 0, 230, 30);
                rect += topleft_client + v2s32(160, ypos);
-               gui::IGUIEditBox *e = 
+               gui::IGUIEditBox *e =
                Environment->addEditBox(L"", rect, true, this, ID_oldPassword);
                Environment->setFocus(e);
                e->setPasswordBox(true);
        }
        ypos += 50;
-       changeCtype("");
        {
-               core::rect<s32> rect(0, 0, 110, 20);
-               rect += topleft_client + v2s32(35, ypos+6);
-               wchar_t* text = wgettext("New Password");
+               core::rect<s32> rect(0, 0, 150, 20);
+               rect += topleft_client + v2s32(25, ypos+6);
+               text = wgettext("New Password");
                Environment->addStaticText(text, rect, false, true, this, -1);
                delete[] text;
        }
-       changeCtype("C");
        {
                core::rect<s32> rect(0, 0, 230, 30);
                rect += topleft_client + v2s32(160, ypos);
-               gui::IGUIEditBox *e = 
+               gui::IGUIEditBox *e =
                Environment->addEditBox(L"", rect, true, this, ID_newPassword1);
                e->setPasswordBox(true);
        }
        ypos += 50;
-       changeCtype("");
        {
-               core::rect<s32> rect(0, 0, 110, 20);
-               rect += topleft_client + v2s32(35, ypos+6);
-               wchar_t* text = wgettext("Confirm Password");
+               core::rect<s32> rect(0, 0, 150, 20);
+               rect += topleft_client + v2s32(25, ypos+6);
+               text = wgettext("Confirm Password");
                Environment->addStaticText(text, rect, false, true, this, -1);
                delete[] text;
        }
-       changeCtype("C");
        {
                core::rect<s32> rect(0, 0, 230, 30);
                rect += topleft_client + v2s32(160, ypos);
-               gui::IGUIEditBox *e = 
+               gui::IGUIEditBox *e =
                Environment->addEditBox(L"", rect, true, this, ID_newPassword2);
                e->setPasswordBox(true);
        }
 
        ypos += 50;
-       changeCtype("");
        {
                core::rect<s32> rect(0, 0, 140, 30);
                rect = rect + v2s32(size.X/2-140/2, ypos);
-               wchar_t* text = wgettext("Change");
+               text = wgettext("Change");
                Environment->addButton(rect, this, ID_change, text);
                delete[] text;
        }
@@ -167,16 +161,14 @@ void GUIPasswordChange::regenerateGui(v2u32 screensize)
        {
                core::rect<s32> rect(0, 0, 300, 20);
                rect += topleft_client + v2s32(35, ypos);
-               wchar_t* text = wgettext("Passwords do not match!");
-               IGUIElement *e = 
+               text = wgettext("Passwords do not match!");
+               IGUIElement *e =
                Environment->addStaticText(
                        text,
                        rect, false, true, this, ID_message);
                e->setVisible(false);
                delete[] text;
        }
-       changeCtype("C");
-
 }
 
 void GUIPasswordChange::drawMenu()
@@ -185,7 +177,7 @@ void GUIPasswordChange::drawMenu()
        if (!skin)
                return;
        video::IVideoDriver* driver = Environment->getVideoDriver();
-       
+
        video::SColor bgcolor(140,0,0,0);
        driver->draw2DRectangle(bgcolor, AbsoluteRect, &AbsoluteClippingRect);
 
@@ -211,7 +203,8 @@ bool GUIPasswordChange::acceptInput()
                                e->setVisible(true);
                        return false;
                }
-               m_client->sendChangePassword(oldpass, newpass);
+               m_client->sendChangePassword(wide_to_narrow(oldpass),
+                       wide_to_narrow(newpass));
                return true;
 }