diff --git a/build/macOS/MultiCraft/MultiCraft.xcodeproj/project.pbxproj b/build/macOS/MultiCraft/MultiCraft.xcodeproj/project.pbxproj index 8d5d00403..bc351075c 100644 --- a/build/macOS/MultiCraft/MultiCraft.xcodeproj/project.pbxproj +++ b/build/macOS/MultiCraft/MultiCraft.xcodeproj/project.pbxproj @@ -246,7 +246,6 @@ 84F20F0A25D52958009562A9 /* guiBackgroundImage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84F20EE325D52956009562A9 /* guiBackgroundImage.cpp */; }; 84F20F0B25D52958009562A9 /* guiHyperText.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84F20EE425D52956009562A9 /* guiHyperText.cpp */; }; 84F20F0C25D52958009562A9 /* guiAnimatedImage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84F20EE525D52956009562A9 /* guiAnimatedImage.cpp */; }; - 84F20F0D25D52958009562A9 /* guiPasswordChange.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84F20EE725D52956009562A9 /* guiPasswordChange.cpp */; }; 84F20F0E25D52958009562A9 /* modalMenu.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84F20EE825D52956009562A9 /* modalMenu.cpp */; }; 84F20F0F25D52958009562A9 /* guiButtonItemImage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84F20EE925D52957009562A9 /* guiButtonItemImage.cpp */; }; 84F20F1025D52958009562A9 /* guiVolumeChange.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84F20EEA25D52957009562A9 /* guiVolumeChange.cpp */; }; @@ -800,7 +799,6 @@ 84F20ECA25D52954009562A9 /* guiHyperText.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = guiHyperText.h; path = ../../../../src/gui/guiHyperText.h; sourceTree = ""; }; 84F20ECB25D52954009562A9 /* guiEditBoxWithScrollbar.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = guiEditBoxWithScrollbar.cpp; path = ../../../../src/gui/guiEditBoxWithScrollbar.cpp; sourceTree = ""; }; 84F20ECC25D52955009562A9 /* guiButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = guiButton.h; path = ../../../../src/gui/guiButton.h; sourceTree = ""; }; - 84F20ECD25D52955009562A9 /* guiPasswordChange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = guiPasswordChange.h; path = ../../../../src/gui/guiPasswordChange.h; sourceTree = ""; }; 84F20ECE25D52955009562A9 /* intlGUIEditBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = intlGUIEditBox.h; path = ../../../../src/gui/intlGUIEditBox.h; sourceTree = ""; }; 84F20ECF25D52955009562A9 /* guiFormSpecMenu.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = guiFormSpecMenu.cpp; path = ../../../../src/gui/guiFormSpecMenu.cpp; sourceTree = ""; }; 84F20ED125D52955009562A9 /* guiButtonImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = guiButtonImage.h; path = ../../../../src/gui/guiButtonImage.h; sourceTree = ""; }; @@ -825,7 +823,6 @@ 84F20EE425D52956009562A9 /* guiHyperText.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = guiHyperText.cpp; path = ../../../../src/gui/guiHyperText.cpp; sourceTree = ""; }; 84F20EE525D52956009562A9 /* guiAnimatedImage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = guiAnimatedImage.cpp; path = ../../../../src/gui/guiAnimatedImage.cpp; sourceTree = ""; }; 84F20EE625D52956009562A9 /* guiSkin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = guiSkin.h; path = ../../../../src/gui/guiSkin.h; sourceTree = ""; }; - 84F20EE725D52956009562A9 /* guiPasswordChange.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = guiPasswordChange.cpp; path = ../../../../src/gui/guiPasswordChange.cpp; sourceTree = ""; }; 84F20EE825D52956009562A9 /* modalMenu.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = modalMenu.cpp; path = ../../../../src/gui/modalMenu.cpp; sourceTree = ""; }; 84F20EE925D52957009562A9 /* guiButtonItemImage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = guiButtonItemImage.cpp; path = ../../../../src/gui/guiButtonItemImage.cpp; sourceTree = ""; }; 84F20EEA25D52957009562A9 /* guiVolumeChange.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = guiVolumeChange.cpp; path = ../../../../src/gui/guiVolumeChange.cpp; sourceTree = ""; }; @@ -1032,8 +1029,6 @@ 84F20EF125D52957009562A9 /* guiKeyChangeMenu.cpp */, 84F20EFF25D52958009562A9 /* guiKeyChangeMenu.h */, 84F20EFC25D52958009562A9 /* guiMainMenu.h */, - 84F20EE725D52956009562A9 /* guiPasswordChange.cpp */, - 84F20ECD25D52955009562A9 /* guiPasswordChange.h */, 84F20EF525D52957009562A9 /* guiPathSelectMenu.cpp */, 84F20EDA25D52955009562A9 /* guiPathSelectMenu.h */, 84FD8E3326A0B04900EF2BFA /* guiScene.cpp */, @@ -2047,7 +2042,6 @@ 84135C1825D526D700CA4DCF /* filecache.cpp in Sources */, 84F20E3425D5282A009562A9 /* l_settings.cpp in Sources */, 84F20EB125D528D7009562A9 /* packages.cpp in Sources */, - 84F20F0D25D52958009562A9 /* guiPasswordChange.cpp in Sources */, 84F20F0525D52958009562A9 /* profilergraph.cpp in Sources */, 84135C2625D526D700CA4DCF /* guiscalingfilter.cpp in Sources */, 84F20E4225D5282A009562A9 /* l_auth.cpp in Sources */, diff --git a/src/client/client.cpp b/src/client/client.cpp index 9ee574e8d..4c8a88ea8 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -1247,12 +1247,18 @@ void Client::clearOutChatQueue() } void Client::sendChangePassword(const std::string &oldpassword, - const std::string &newpassword) + const std::string &newpassword, const bool close_form) { LocalPlayer *player = m_env.getLocalPlayer(); if (player == NULL) return; + if (close_form) { + auto formspec = m_game_ui->getFormspecGUI(); + if (formspec) + formspec->quitMenu(); + } + // get into sudo mode and then send new password to server m_password = oldpassword; m_new_password = newpassword; diff --git a/src/client/client.h b/src/client/client.h index 6c1c6fe14..fe1b6c42e 100644 --- a/src/client/client.h +++ b/src/client/client.h @@ -240,7 +240,7 @@ public: void sendChatMessage(const std::wstring &message); void clearOutChatQueue(); void sendChangePassword(const std::string &oldpassword, - const std::string &newpassword); + const std::string &newpassword, const bool close_form = false); void sendDamage(u16 damage); void sendBreath(u16 breath); void sendRespawn(); diff --git a/src/client/game.cpp b/src/client/game.cpp index aa7eb41d2..bb5a1e577 100644 --- a/src/client/game.cpp +++ b/src/client/game.cpp @@ -46,7 +46,6 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "gui/guiConfirmRegistration.h" #include "gui/guiFormSpecMenu.h" #include "gui/guiKeyChangeMenu.h" -#include "gui/guiPasswordChange.h" #include "gui/guiVolumeChange.h" #include "gui/mainmenumanager.h" #include "gui/profilergraph.h" @@ -175,6 +174,21 @@ struct LocalFormspecHandler : public TextDest return; } + if (m_formname == "MT_CHANGE_PW") { + if (fields.find("btn_change_pw") != fields.end()) { + const std::string old_pw = fields.at("old_pw"); + const std::string new_pw = fields.at("new_pw"); + const std::string confirm_pw = fields.at("confirm_pw"); + if (new_pw != confirm_pw) { + g_gamecallback->changePassword(old_pw, new_pw, confirm_pw); + return; + } + m_client->sendChangePassword(old_pw, new_pw, true); + } + + return; + } + if (m_formname == "MT_DEATH_SCREEN") { assert(m_client != 0); m_client->sendRespawn(); @@ -809,6 +823,8 @@ private: void showDeathFormspec(); void showPauseMenu(); + void showChangePasswordDialog(std::string old_pw, std::string new_pw, + std::string confirm_pw); void pauseAnimation(); void resumeAnimation(); @@ -1716,9 +1732,12 @@ inline bool Game::handleCallbacks() } if (g_gamecallback->changepassword_requested) { - (new GUIPasswordChange(guienv, guiroot, -1, - &g_menumgr, client, texture_src))->drop(); + showChangePasswordDialog(g_gamecallback->old_pw_tmp, + g_gamecallback->new_pw_tmp, g_gamecallback->confirm_pw_tmp); g_gamecallback->changepassword_requested = false; + g_gamecallback->old_pw_tmp.clear(); + g_gamecallback->new_pw_tmp.clear(); + g_gamecallback->confirm_pw_tmp.clear(); } if (g_gamecallback->changevolume_requested) { @@ -4333,7 +4352,7 @@ void Game::showPauseMenu() << strgettext("Continue") << "]"; if (!simple_singleplayer_mode) { - os << "button_exit[3.5," << (ypos++) << ";4,0.5;btn_change_password;" + os << "button[3.5," << (ypos++) << ";4,0.5;btn_change_password;" << strgettext("Change Password") << "]"; } @@ -4408,6 +4427,39 @@ void Game::showPauseMenu() pauseAnimation(); } +void Game::showChangePasswordDialog(std::string old_pw, std::string new_pw, + std::string confirm_pw) +{ + str_formspec_escape(old_pw); + str_formspec_escape(new_pw); + str_formspec_escape(confirm_pw); + + std::ostringstream os; + os << "formspec_version[5]" + << "size[10.5,7.9]" + << "no_prepend[]" + << "bgcolor[#320000b4;true]" + << "background9[0,0;0,0;bg_common.png;true;40]" + << "pwdfield[1,1.4;8.5,0.8;old_pw;" << strgettext("Old Password") << ":;" << old_pw << "]" + << "pwdfield[1,3;8.5,0.8;new_pw;" << strgettext("New Password") << ":;" << new_pw << "]" + << "pwdfield[1,4.6;8.5,0.8;confirm_pw;" << strgettext("Confirm Password") << ":;" << confirm_pw << "]" + << "button[1,5.9;4.1,0.8;btn_change_pw;" << strgettext("Change") << "]" + << "button_exit[5.4,5.9;4.1,0.8;btn_cancel;" << strgettext("Cancel") << "]"; + + if (new_pw != confirm_pw) + os << "label[1,7.2;\x1b(c@red)" << strgettext("Passwords do not match!") << "]"; + + /* Create menu */ + /* Note: FormspecFormSource and LocalFormspecHandler * + * are deleted by guiFormSpecMenu */ + FormspecFormSource *fs_src = new FormspecFormSource(os.str()); + LocalFormspecHandler *txt_dst = new LocalFormspecHandler("MT_CHANGE_PW", client); + + auto *&formspec = m_game_ui->getFormspecGUI(); + GUIFormSpecMenu::create(formspec, client, &input->joystick, + fs_src, txt_dst, client->getFormspecPrepend(), sound); +} + /****************************************************************************/ /**************************************************************************** extern function for launching the game diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index af007648f..273495649 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -19,7 +19,6 @@ set(gui_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/guiInventoryList.cpp ${CMAKE_CURRENT_SOURCE_DIR}/guiItemImage.cpp ${CMAKE_CURRENT_SOURCE_DIR}/guiKeyChangeMenu.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/guiPasswordChange.cpp ${CMAKE_CURRENT_SOURCE_DIR}/guiPathSelectMenu.cpp ${CMAKE_CURRENT_SOURCE_DIR}/guiScene.cpp ${CMAKE_CURRENT_SOURCE_DIR}/guiScrollBar.cpp diff --git a/src/gui/guiFormSpecMenu.cpp b/src/gui/guiFormSpecMenu.cpp index 07ebad44c..79045a3d1 100644 --- a/src/gui/guiFormSpecMenu.cpp +++ b/src/gui/guiFormSpecMenu.cpp @@ -1507,7 +1507,7 @@ void GUIFormSpecMenu::parsePwdField(parserData* data, const std::string &element ); spec.send = true; - gui::IGUIEditBox *e = Environment->addEditBox(0, rect, true, + gui::IGUIEditBox *e = Environment->addEditBox(wpassword.c_str(), rect, true, data->current_parent, spec.fid); if (spec.fname == m_focused_element) { diff --git a/src/gui/guiPasswordChange.cpp b/src/gui/guiPasswordChange.cpp deleted file mode 100644 index e72f8acaa..000000000 --- a/src/gui/guiPasswordChange.cpp +++ /dev/null @@ -1,323 +0,0 @@ -/* -Part of Minetest -Copyright (C) 2013 celeron55, Perttu Ahola -Copyright (C) 2013 Ciaran Gultnieks - -Permission to use, copy, modify, and distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ - -#include "guiPasswordChange.h" -#include "client/client.h" -#include "guiButton.h" -#include -#include -#include -#include -#include - -#ifdef HAVE_TOUCHSCREENGUI - #include "client/renderingengine.h" -#endif - -#include "porting.h" -#include "gettext.h" -#include "client/renderingengine.h" - -const int ID_oldPassword = 256; -const int ID_newPassword1 = 257; -const int ID_newPassword2 = 258; -const int ID_change = 259; -const int ID_message = 260; -const int ID_cancel = 261; - -GUIPasswordChange::GUIPasswordChange(gui::IGUIEnvironment* env, - gui::IGUIElement* parent, s32 id, - IMenuManager *menumgr, - Client* client, - ISimpleTextureSource *tsrc -): - GUIModalMenu(env, parent, id, menumgr), - m_client(client), - m_tsrc(tsrc) -{ -} - -GUIPasswordChange::~GUIPasswordChange() -{ - removeChildren(); -} - -void GUIPasswordChange::removeChildren() -{ - const core::list &children = getChildren(); - core::list children_copy; - for (gui::IGUIElement *i : children) { - children_copy.push_back(i); - } - - for (gui::IGUIElement *i : children_copy) { - i->remove(); - } -} -void GUIPasswordChange::regenerateGui(v2u32 screensize) -{ - /* - save current input - */ - acceptInput(); - - /* - Remove stuff - */ - removeChildren(); - - /* - Calculate new sizes and positions - */ -#ifdef HAVE_TOUCHSCREENGUI - const float s = m_gui_scale * RenderingEngine::getDisplayDensity() / 2; -#elif defined(__MACH__) && defined(__APPLE__) && !defined(__IOS__) - const float s = m_gui_scale * RenderingEngine::getDisplayDensity() * 1.5; -#else - const float s = m_gui_scale; -#endif - DesiredRect = core::rect( - screensize.X / 2 - 580 * s / 2, - screensize.Y / 2 - 300 * s / 2, - screensize.X / 2 + 580 * s / 2, - screensize.Y / 2 + 300 * s / 2 - ); - recalculateAbsolutePosition(false); - - v2s32 size = DesiredRect.getSize(); - v2s32 topleft_client(40 * s, 0); - - const wchar_t *text; - - /* - Add stuff - */ - s32 ypos = 50 * s; - { - core::rect rect(0, 0, 150 * s, 20 * s); - rect += topleft_client + v2s32(25 * s, ypos + 6 * s); - text = wgettext("Old Password"); - Environment->addStaticText(text, rect, false, true, this, -1); - delete[] text; - } - { - core::rect rect(0, 0, 230 * s, 30 * s); - rect += topleft_client + v2s32(160 * s, ypos); - gui::IGUIEditBox *e = Environment->addEditBox( - m_oldpass.c_str(), rect, true, this, ID_oldPassword); - Environment->setFocus(e); - e->setPasswordBox(true); - } - ypos += 50 * s; - { - core::rect rect(0, 0, 150 * s, 20 * s); - rect += topleft_client + v2s32(25 * s, ypos + 6 * s); - text = wgettext("New Password"); - Environment->addStaticText(text, rect, false, true, this, -1); - delete[] text; - } - { - core::rect rect(0, 0, 230 * s, 30 * s); - rect += topleft_client + v2s32(160 * s, ypos); - gui::IGUIEditBox *e = Environment->addEditBox( - m_newpass.c_str(), rect, true, this, ID_newPassword1); - e->setPasswordBox(true); - } - ypos += 50 * s; - { - core::rect rect(0, 0, 150 * s, 20 * s); - rect += topleft_client + v2s32(25 * s, ypos + 6 * s); - text = wgettext("Confirm Password"); - Environment->addStaticText(text, rect, false, true, this, -1); - delete[] text; - } - { - core::rect rect(0, 0, 230 * s, 30 * s); - rect += topleft_client + v2s32(160 * s, ypos); - gui::IGUIEditBox *e = Environment->addEditBox( - m_newpass_confirm.c_str(), rect, true, this, ID_newPassword2); - e->setPasswordBox(true); - } - - ypos += 50 * s; - { - core::rect rect(0, 0, 100 * s, 30 * s); - rect = rect + v2s32(size.X / 4 + 56 * s, ypos); - text = wgettext("Change"); - GUIButton::addButton(Environment, rect, m_tsrc, this, ID_change, text); - delete[] text; - } - { - core::rect rect(0, 0, 100 * s, 30 * s); - rect = rect + v2s32(size.X / 4 + 185 * s, ypos); - text = wgettext("Cancel"); - GUIButton::addButton(Environment, rect, m_tsrc, this, ID_cancel, text); - delete[] text; - } - - ypos += 50 * s; - { - core::rect rect(0, 0, 300 * s, 20 * s); - rect += topleft_client + v2s32(35 * s, ypos); - text = wgettext("Passwords do not match!"); - IGUIElement *e = - Environment->addStaticText( - text, rect, false, true, this, ID_message); - e->setVisible(false); - delete[] text; - } -} - -void GUIPasswordChange::drawMenu() -{ - gui::IGUISkin *skin = Environment->getSkin(); - if (!skin) - return; - video::IVideoDriver *driver = Environment->getVideoDriver(); - - video::SColor bgcolor(140, 0, 0, 0); - driver->draw2DRectangle(bgcolor, AbsoluteRect, &AbsoluteClippingRect); - - gui::IGUIElement::draw(); -#if defined(__ANDROID__) || defined(__IOS__) - getAndroidUIInput(); -#endif -} - -void GUIPasswordChange::acceptInput() -{ - gui::IGUIElement *e; - e = getElementFromId(ID_oldPassword); - if (e != NULL) - m_oldpass = e->getText(); - e = getElementFromId(ID_newPassword1); - if (e != NULL) - m_newpass = e->getText(); - e = getElementFromId(ID_newPassword2); - if (e != NULL) - m_newpass_confirm = e->getText(); -} - -bool GUIPasswordChange::processInput() -{ - if (m_newpass != m_newpass_confirm) { - gui::IGUIElement *e = getElementFromId(ID_message); - if (e != NULL) - e->setVisible(true); - return false; - } - m_client->sendChangePassword(wide_to_utf8(m_oldpass), wide_to_utf8(m_newpass)); - return true; -} - -bool GUIPasswordChange::OnEvent(const SEvent &event) -{ - if (event.EventType == EET_KEY_INPUT_EVENT) { - // clang-format off - if ((event.KeyInput.Key == KEY_ESCAPE || - event.KeyInput.Key == KEY_CANCEL) && - event.KeyInput.PressedDown) { - quitMenu(); - return true; - } - // clang-format on - if (event.KeyInput.Key == KEY_RETURN && event.KeyInput.PressedDown) { - acceptInput(); - if (processInput()) - quitMenu(); - return true; - } - } - if (event.EventType == EET_GUI_EVENT) { - if (event.GUIEvent.EventType == gui::EGET_ELEMENT_FOCUS_LOST && - isVisible()) { - if (!canTakeFocus(event.GUIEvent.Element)) { - infostream << "GUIPasswordChange: Not allowing focus change." - << std::endl; - // Returning true disables focus change - return true; - } - } - if (event.GUIEvent.EventType == gui::EGET_BUTTON_CLICKED) { - switch (event.GUIEvent.Caller->getID()) { - case ID_change: - acceptInput(); - if (processInput()) - quitMenu(); - return true; - case ID_cancel: - quitMenu(); - return true; - } - } - if (event.GUIEvent.EventType == gui::EGET_EDITBOX_ENTER) { - switch (event.GUIEvent.Caller->getID()) { - case ID_oldPassword: - case ID_newPassword1: - case ID_newPassword2: - acceptInput(); - if (processInput()) - quitMenu(); - return true; - } - } - } - - return Parent ? Parent->OnEvent(event) : false; -} - -std::string GUIPasswordChange::getNameByID(s32 id) -{ - switch (id) { - case ID_oldPassword: - return "old_password"; - case ID_newPassword1: - return "new_password_1"; - case ID_newPassword2: - return "new_password_2"; - } - return ""; -} - -#if defined(__ANDROID__) || defined(__IOS__) -bool GUIPasswordChange::getAndroidUIInput() -{ - if (!hasAndroidUIInput()) - return false; - - // still waiting - if (porting::getInputDialogState() == -1) - return true; - - gui::IGUIElement *e = nullptr; - if (m_jni_field_name == "old_password") - e = getElementFromId(ID_oldPassword); - else if (m_jni_field_name == "new_password_1") - e = getElementFromId(ID_newPassword1); - else if (m_jni_field_name == "new_password_2") - e = getElementFromId(ID_newPassword2); - m_jni_field_name.clear(); - - if (!e || e->getType() != irr::gui::EGUIET_EDIT_BOX) - return false; - - std::string text = porting::getInputDialogValue(); - e->setText(utf8_to_wide(text).c_str()); - return false; -} -#endif diff --git a/src/gui/guiPasswordChange.h b/src/gui/guiPasswordChange.h deleted file mode 100644 index c20509ea8..000000000 --- a/src/gui/guiPasswordChange.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -Part of Minetest -Copyright (C) 2010-2013 celeron55, Perttu Ahola -Copyright (C) 2013 Ciaran Gultnieks - -Permission to use, copy, modify, and distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ - -#pragma once - -#include "irrlichttypes_extrabloated.h" -#include "modalMenu.h" -#include - -class Client; -class ISimpleTextureSource; - -class GUIPasswordChange : public GUIModalMenu -{ -public: - GUIPasswordChange(gui::IGUIEnvironment *env, gui::IGUIElement *parent, s32 id, - IMenuManager *menumgr, Client *client, - ISimpleTextureSource *tsrc); - ~GUIPasswordChange(); - - void removeChildren(); - /* - Remove and re-add (or reposition) stuff - */ - void regenerateGui(v2u32 screensize); - - void drawMenu(); - - void acceptInput(); - - bool processInput(); - - bool OnEvent(const SEvent &event); -#if defined(__ANDROID__) || defined(__IOS__) - bool getAndroidUIInput(); -#endif - -protected: - std::wstring getLabelByID(s32 id) { return L""; } - std::string getNameByID(s32 id); - -private: - Client *m_client; - std::wstring m_oldpass = L""; - std::wstring m_newpass = L""; - std::wstring m_newpass_confirm = L""; - ISimpleTextureSource *m_tsrc; -}; diff --git a/src/gui/mainmenumanager.h b/src/gui/mainmenumanager.h index 038940e96..c4de78cd2 100644 --- a/src/gui/mainmenumanager.h +++ b/src/gui/mainmenumanager.h @@ -32,7 +32,8 @@ public: virtual void exitToOS() = 0; virtual void keyConfig() = 0; virtual void disconnect() = 0; - virtual void changePassword() = 0; + virtual void changePassword(const std::string &old_pw = "", + const std::string &new_pw = "", const std::string &confirm_pw = "") = 0; virtual void changeVolume() = 0; virtual void signalKeyConfigChange() = 0; @@ -119,9 +120,13 @@ public: disconnect_requested = true; } - virtual void changePassword() + virtual void changePassword(const std::string &old_pw = "", + const std::string &new_pw = "", const std::string &confirm_pw = "") { changepassword_requested = true; + old_pw_tmp = old_pw; + new_pw_tmp = new_pw; + confirm_pw_tmp = confirm_pw; } virtual void changeVolume() @@ -142,6 +147,10 @@ public: bool disconnect_requested = false; bool changepassword_requested = false; + std::string old_pw_tmp; + std::string new_pw_tmp; + std::string confirm_pw_tmp; + bool changevolume_requested = false; bool keyconfig_requested = false; bool shutdown_requested = false;