removing git blame output file in src

This commit is contained in:
konstin 2014-05-06 19:46:20 +02:00
parent 8e21810282
commit a22b407568

View File

@ -1,212 +0,0 @@
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 1) // SuperTuxKart - a fun racing game with go-kart
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 2) // Copyright (C) 2013 Glenn De Jonghe
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 3) //
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 4) // This program is free software; you can redistribute it and/or
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 5) // modify it under the terms of the GNU General Public License
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 6) // as published by the Free Software Foundation; either version 3
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 7) // of the License, or (at your option) any later version.
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 8) //
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 9) // This program is distributed in the hope that it will be useful,
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 10) // but WITHOUT ANY WARRANTY; without even the implied warranty of
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 11) // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 12) // GNU General Public License for more details.
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 13) //
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 14) // You should have received a copy of the GNU General Public License
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 15) // along with this program; if not, write to the Free Software
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 16) // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 17)
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 18) #include "states_screens/dialogs/recovery_dialog.hpp"
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 19)
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 20) #include "audio/sfx_manager.hpp"
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 21) #include "guiengine/engine.hpp"
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 22) #include "states_screens/state_manager.hpp"
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 23) #include "utils/translation.hpp"
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 24) #include "utils/string_utils.hpp"
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 25) #include "online/messages.hpp"
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 26)
4d6b110e (hiker 2014-02-26 12:52:16 +1100 27) #include <IGUIEnvironment.h>
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 28)
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 29) using namespace GUIEngine;
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 30) using namespace irr;
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 31) using namespace irr::gui;
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 32) using namespace Online;
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 33)
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 34) // -----------------------------------------------------------------------------
6afc12c8 (hiker 2014-03-14 16:44:58 +1100 35) /** Constructor for the recovery dialog.
6afc12c8 (hiker 2014-03-14 16:44:58 +1100 36) */
6afc12c8 (hiker 2014-03-14 16:44:58 +1100 37) RecoveryDialog::RecoveryDialog() : ModalDialog(0.8f,0.8f)
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 38) {
6afc12c8 (hiker 2014-03-14 16:44:58 +1100 39) m_recovery_request = NULL;
6afc12c8 (hiker 2014-03-14 16:44:58 +1100 40) m_self_destroy = false;
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 41) m_show_recovery_input = true;
6afc12c8 (hiker 2014-03-14 16:44:58 +1100 42) m_show_recovery_info = false;
8e8f02a1 (hiker 2014-04-06 01:27:04 +1100 43) doInit();
6afc12c8 (hiker 2014-03-14 16:44:58 +1100 44) showRecoveryInput();
6afc12c8 (hiker 2014-03-14 16:44:58 +1100 45) } // RecoveryDialog
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 46)
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 47) // -----------------------------------------------------------------------------
6afc12c8 (hiker 2014-03-14 16:44:58 +1100 48) /** Destructor, destroys the recovery request.
6afc12c8 (hiker 2014-03-14 16:44:58 +1100 49) */
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 50) RecoveryDialog::~RecoveryDialog()
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 51) {
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 52) delete m_recovery_request;
6afc12c8 (hiker 2014-03-14 16:44:58 +1100 53) } //~RecoverDialog
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 54)
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 55) // -----------------------------------------------------------------------------
6afc12c8 (hiker 2014-03-14 16:44:58 +1100 56) /** Shows the input screen to get the account name and email address.
6afc12c8 (hiker 2014-03-14 16:44:58 +1100 57) */
6afc12c8 (hiker 2014-03-14 16:44:58 +1100 58) void RecoveryDialog::showRecoveryInput()
6afc12c8 (hiker 2014-03-14 16:44:58 +1100 59) {
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 60) m_show_recovery_input = false;
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 61) clearWindow();
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 62) m_phase = Input;
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 63) loadFromFile("online/recovery_input.stkgui");
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 64)
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 65) m_username_widget = getWidget<TextBoxWidget>("username");
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 66) assert(m_username_widget != NULL);
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 67) m_username_widget->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 68)
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 69) m_email_widget = getWidget<TextBoxWidget>("email");
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 70) assert(m_email_widget != NULL);
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 71)
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 72) m_info_widget = getWidget<LabelWidget>("info");
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 73) assert(m_info_widget != NULL);
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 74)
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 75) m_options_widget = getWidget<RibbonWidget>("options");
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 76) assert(m_options_widget != NULL);
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 77) m_submit_widget = getWidget<IconButtonWidget>("submit");
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 78) assert(m_submit_widget != NULL);
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 79) m_cancel_widget = getWidget<IconButtonWidget>("cancel");
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 80) assert(m_cancel_widget != NULL);
6afc12c8 (hiker 2014-03-14 16:44:58 +1100 81) } // showRecoveryInput
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 82)
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 83) // -----------------------------------------------------------------------------
7cc83e14 (konstin 2014-03-29 11:33:43 +0100 84) /** Informs the user that an email will be sent.
6afc12c8 (hiker 2014-03-14 16:44:58 +1100 85) */
6afc12c8 (hiker 2014-03-14 16:44:58 +1100 86) void RecoveryDialog::showRecoveryInfo()
6afc12c8 (hiker 2014-03-14 16:44:58 +1100 87) {
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 88) m_show_recovery_info = false;
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 89) clearWindow();
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 90) m_phase = Info;
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 91) loadFromFile("online/recovery_info.stkgui");
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 92)
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 93) m_info_widget = getWidget<LabelWidget>("info");
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 94) assert(m_info_widget != NULL);
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 95)
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 96) m_options_widget = getWidget<RibbonWidget>("options");
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 97) assert(m_options_widget != NULL);
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 98) m_cancel_widget = getWidget<IconButtonWidget>("cancel");
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 99) assert(m_cancel_widget != NULL);
6afc12c8 (hiker 2014-03-14 16:44:58 +1100 100) } // showRecoveryInfo
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 101)
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 102) // -----------------------------------------------------------------------------
6afc12c8 (hiker 2014-03-14 16:44:58 +1100 103) /** Let esc act as cancel.
6afc12c8 (hiker 2014-03-14 16:44:58 +1100 104) */
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 105) bool RecoveryDialog::onEscapePressed()
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 106) {
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 107) return m_cancel_widget->isActivated();
6afc12c8 (hiker 2014-03-14 16:44:58 +1100 108) } // onEscapePressed
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 109)
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 110) // -----------------------------------------------------------------------------
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 111)
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 112) void RecoveryDialog::processInput()
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 113) {
4d6b110e (hiker 2014-02-26 12:52:16 +1100 114) const core::stringw username = m_username_widget->getText().trim();
4d6b110e (hiker 2014-02-26 12:52:16 +1100 115) const core::stringw email = m_email_widget->getText().trim();
7cc83e14 (konstin 2014-03-29 11:33:43 +0100 116) if (username.size() < 4 || username.size() > 30 ||
6afc12c8 (hiker 2014-03-14 16:44:58 +1100 117) email.size() < 4 || email.size() > 50 )
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 118) {
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 119) sfx_manager->quickSound("anvil");
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 120) m_info_widget->setErrorColor();
6afc12c8 (hiker 2014-03-14 16:44:58 +1100 121) m_info_widget->setText(_("Username and/or email address invalid."),
6afc12c8 (hiker 2014-03-14 16:44:58 +1100 122) false);
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 123) }
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 124) else
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 125) {
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 126) m_info_widget->setDefaultColor();
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 127) m_options_widget->setDeactivated();
6afc12c8 (hiker 2014-03-14 16:44:58 +1100 128) m_recovery_request = new XMLRequest();
cb959acb (hiker 2014-04-07 08:25:48 +1000 129) // This function also works when the current user is not logged in
cb959acb (hiker 2014-04-07 08:25:48 +1000 130) CurrentUser::setUserDetails(m_recovery_request, "recovery");
6afc12c8 (hiker 2014-03-14 16:44:58 +1100 131) m_recovery_request->addParameter("username", username);
cb959acb (hiker 2014-04-07 08:25:48 +1000 132) m_recovery_request->addParameter("email", email );
6afc12c8 (hiker 2014-03-14 16:44:58 +1100 133) m_recovery_request->queue();
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 134) }
6afc12c8 (hiker 2014-03-14 16:44:58 +1100 135) } // processInput
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 136)
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 137) // -----------------------------------------------------------------------------
6afc12c8 (hiker 2014-03-14 16:44:58 +1100 138) /** Handle a user event.
6afc12c8 (hiker 2014-03-14 16:44:58 +1100 139) */
7cc83e14 (konstin 2014-03-29 11:33:43 +0100 140) GUIEngine::EventPropagation
6afc12c8 (hiker 2014-03-14 16:44:58 +1100 141) RecoveryDialog::processEvent(const std::string& eventSource)
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 142) {
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 143) std::string selection;
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 144) if (eventSource == m_options_widget->m_properties[PROP_ID])
7cc83e14 (konstin 2014-03-29 11:33:43 +0100 145) selection =
6afc12c8 (hiker 2014-03-14 16:44:58 +1100 146) m_options_widget->getSelectionIDString(PLAYER_ID_GAME_MASTER);
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 147) else
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 148) selection = eventSource;
6afc12c8 (hiker 2014-03-14 16:44:58 +1100 149)
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 150) if (selection == m_cancel_widget->m_properties[PROP_ID])
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 151) {
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 152) m_self_destroy = true;
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 153) return GUIEngine::EVENT_BLOCK;
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 154) }
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 155) else if (selection == m_submit_widget->m_properties[PROP_ID])
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 156) {
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 157) processInput();
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 158) return GUIEngine::EVENT_BLOCK;
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 159) }
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 160) return GUIEngine::EVENT_LET;
6afc12c8 (hiker 2014-03-14 16:44:58 +1100 161) } // processEvent
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 162)
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 163) // -----------------------------------------------------------------------------
6afc12c8 (hiker 2014-03-14 16:44:58 +1100 164) /** Called when the user pressed enter.
6afc12c8 (hiker 2014-03-14 16:44:58 +1100 165) */
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 166) void RecoveryDialog::onEnterPressedInternal()
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 167) {
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 168)
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 169) if (GUIEngine::isFocusedForPlayer(m_options_widget, PLAYER_ID_GAME_MASTER))
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 170) return;
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 171) if (m_submit_widget->isActivated())
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 172) processInput();
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 173) }
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 174)
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 175) // -----------------------------------------------------------------------------
6afc12c8 (hiker 2014-03-14 16:44:58 +1100 176) /** This is called every frame and checks if an outstanding recovery request
6afc12c8 (hiker 2014-03-14 16:44:58 +1100 177) * was finished. If so, it displays the results.
6afc12c8 (hiker 2014-03-14 16:44:58 +1100 178) * \param dt Time step size.
6afc12c8 (hiker 2014-03-14 16:44:58 +1100 179) */
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 180) void RecoveryDialog::onUpdate(float dt)
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 181) {
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 182) if(m_recovery_request != NULL)
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 183) {
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 184) if(m_recovery_request->isDone())
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 185) {
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 186) if(m_recovery_request->isSuccess())
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 187) {
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 188) m_show_recovery_info = true;
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 189) }
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 190) else
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 191) {
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 192) sfx_manager->quickSound( "anvil" );
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 193) m_info_widget->setErrorColor();
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 194) m_info_widget->setText(m_recovery_request->getInfo(), false);
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 195) m_options_widget->setActivated();
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 196) }
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 197) delete m_recovery_request;
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 198) m_recovery_request = NULL;
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 199) }
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 200) else
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 201) {
99e7b565 (unitraxx 2013-09-14 01:07:22 +0000 202) m_info_widget->setText(Messages::validatingInfo(), false);
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 203) }
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 204) }
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 205) // It's unsafe to delete from inside the event handler so we do it here
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 206) if (m_self_destroy)
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 207) ModalDialog::dismiss();
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 208) else if (m_show_recovery_input)
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 209) showRecoveryInput();
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 210) else if (m_show_recovery_info)
4091c4c9 (unitraxx 2013-07-27 20:55:10 +0000 211) showRecoveryInfo();
6afc12c8 (hiker 2014-03-14 16:44:58 +1100 212) } // onUpdates