]> git.lizzy.rs Git - minetest.git/blobdiff - src/guiPasswordChange.cpp
MSVC: Generate debug information for release builds (#4674)
[minetest.git] / src / guiPasswordChange.cpp
index 79601a99fb5724cd60f238f7c12c7f34b366b65e..e2f9994be29cf0fe9926dc9350e616e1ea3a22e7 100644 (file)
@@ -1,7 +1,7 @@
 /*
 /*
-Part of Minetest-c55
-Copyright (C) 2011 celeron55, Perttu Ahola <celeron55@gmail.com>
-Copyright (C) 2011 Ciaran Gultnieks <ciaran@ciarang.com>
+Part of Minetest
+Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
+Copyright (C) 2013 Ciaran Gultnieks <ciaran@ciarang.com>
 
 Permission to use, copy, modify, and distribute this software for any
 purpose with or without fee is hereby granted, provided that the above
 
 Permission to use, copy, modify, and distribute this software for any
 purpose with or without fee is hereby granted, provided that the above
@@ -20,6 +20,11 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include "debug.h"
 #include "serialization.h"
 #include <string>
 #include "debug.h"
 #include "serialization.h"
 #include <string>
+#include <IGUICheckBox.h>
+#include <IGUIEditBox.h>
+#include <IGUIButton.h>
+#include <IGUIStaticText.h>
+#include <IGUIFont.h>
 
 #include "gettext.h"
 
 
 #include "gettext.h"
 
@@ -74,7 +79,7 @@ void GUIPasswordChange::regenerateGui(v2u32 screensize)
                Remove stuff
        */
        removeChildren();
                Remove stuff
        */
        removeChildren();
-       
+
        /*
                Calculate new sizes and positions
        */
        /*
                Calculate new sizes and positions
        */
@@ -84,54 +89,61 @@ void GUIPasswordChange::regenerateGui(v2u32 screensize)
                        screensize.X/2 + 580/2,
                        screensize.Y/2 + 300/2
        );
                        screensize.X/2 + 580/2,
                        screensize.Y/2 + 300/2
        );
-       
+
        DesiredRect = rect;
        recalculateAbsolutePosition(false);
 
        v2s32 size = rect.getSize();
        v2s32 topleft_client(40, 0);
        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;
        {
 
        /*
                Add stuff
        */
        s32 ypos = 50;
        {
-               core::rect<s32> rect(0, 0, 110, 20);
-               rect += topleft_client + v2s32(35, ypos+6);
-               Environment->addStaticText(chartowchar_t(gettext("Old Password")), rect, false, true, this, -1);
+               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;
        }
        {
                core::rect<s32> rect(0, 0, 230, 30);
                rect += topleft_client + v2s32(160, ypos);
        }
        {
                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;
        {
                Environment->addEditBox(L"", rect, true, this, ID_oldPassword);
                Environment->setFocus(e);
                e->setPasswordBox(true);
        }
        ypos += 50;
        {
-               core::rect<s32> rect(0, 0, 110, 20);
-               rect += topleft_client + v2s32(35, ypos+6);
-               Environment->addStaticText(chartowchar_t(gettext("New Password")), rect, false, true, this, -1);
+               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;
        }
        {
                core::rect<s32> rect(0, 0, 230, 30);
                rect += topleft_client + v2s32(160, ypos);
        }
        {
                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;
        {
                Environment->addEditBox(L"", rect, true, this, ID_newPassword1);
                e->setPasswordBox(true);
        }
        ypos += 50;
        {
-               core::rect<s32> rect(0, 0, 110, 20);
-               rect += topleft_client + v2s32(35, ypos+6);
-               Environment->addStaticText(chartowchar_t(gettext("Confirm Password")), rect, false, true, this, -1);
+               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;
        }
        {
                core::rect<s32> rect(0, 0, 230, 30);
                rect += topleft_client + v2s32(160, ypos);
        }
        {
                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);
        }
                Environment->addEditBox(L"", rect, true, this, ID_newPassword2);
                e->setPasswordBox(true);
        }
@@ -140,18 +152,23 @@ void GUIPasswordChange::regenerateGui(v2u32 screensize)
        {
                core::rect<s32> rect(0, 0, 140, 30);
                rect = rect + v2s32(size.X/2-140/2, ypos);
        {
                core::rect<s32> rect(0, 0, 140, 30);
                rect = rect + v2s32(size.X/2-140/2, ypos);
-               Environment->addButton(rect, this, ID_change, chartowchar_t(gettext("Change")));
+               text = wgettext("Change");
+               Environment->addButton(rect, this, ID_change, text);
+               delete[] text;
        }
 
        ypos += 50;
        {
                core::rect<s32> rect(0, 0, 300, 20);
                rect += topleft_client + v2s32(35, ypos);
        }
 
        ypos += 50;
        {
                core::rect<s32> rect(0, 0, 300, 20);
                rect += topleft_client + v2s32(35, ypos);
-               IGUIElement *e = 
-               Environment->addStaticText(chartowchar_t(gettext("Passwords do not match!")), rect, false, true, this, ID_message);
+               text = wgettext("Passwords do not match!");
+               IGUIElement *e =
+               Environment->addStaticText(
+                       text,
+                       rect, false, true, this, ID_message);
                e->setVisible(false);
                e->setVisible(false);
+               delete[] text;
        }
        }
-
 }
 
 void GUIPasswordChange::drawMenu()
 }
 
 void GUIPasswordChange::drawMenu()
@@ -160,7 +177,7 @@ void GUIPasswordChange::drawMenu()
        if (!skin)
                return;
        video::IVideoDriver* driver = Environment->getVideoDriver();
        if (!skin)
                return;
        video::IVideoDriver* driver = Environment->getVideoDriver();
-       
+
        video::SColor bgcolor(140,0,0,0);
        driver->draw2DRectangle(bgcolor, AbsoluteRect, &AbsoluteClippingRect);
 
        video::SColor bgcolor(140,0,0,0);
        driver->draw2DRectangle(bgcolor, AbsoluteRect, &AbsoluteClippingRect);
 
@@ -186,7 +203,8 @@ bool GUIPasswordChange::acceptInput()
                                e->setVisible(true);
                        return false;
                }
                                e->setVisible(true);
                        return false;
                }
-               m_client->sendChangePassword(oldpass, newpass);
+               m_client->sendChangePassword(wide_to_utf8(oldpass),
+                       wide_to_utf8(newpass));
                return true;
 }
 
                return true;
 }