Don't allow a player to delete themselves

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@10386 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2011-12-09 01:12:30 +00:00
parent e705e98a69
commit 3aa77cccfa
2 changed files with 10 additions and 1 deletions

View File

@ -71,6 +71,8 @@ public:
/** Eye- (or rather ear-) candy. Play a sound when user tries to access a locked area */
void playLockSound() const;
const core::stringw& getCurrentSlotName() const { return m_current_game_slot; }
GameSlot* getCurrentSlot() { return m_game_slots[m_current_game_slot]; }
/** \param slotid name of the player */

View File

@ -20,6 +20,7 @@
#include <IGUIStaticText.h>
#include <IGUIEnvironment.h>
#include "challenges/unlock_manager.hpp"
#include "config/player.hpp"
#include "guiengine/engine.hpp"
#include "guiengine/widgets/button_widget.hpp"
@ -148,11 +149,16 @@ void PlayerInfoDialog::showConfirmDialog()
const int textHeight = GUIEngine::getFontHeight();
const int buttonHeight = textHeight + 10;
irr::core::stringw message =
//I18N: In the player info dialog (when deleting)
_("Do you really want to delete player '%s' ?", m_player->getName());
if (unlock_manager->getCurrentSlotName() == m_player->getName())
{
message = _("You cannot delete this player because it is currently in use.");
}
core::rect< s32 > area_left(5, 0, m_area.getWidth()-5, m_area.getHeight()/2);
// When there is no need to tab through / click on images/labels, we can add directly
@ -162,6 +168,7 @@ void PlayerInfoDialog::showConfirmDialog()
m_irrlicht_window);
a->setTextAlignment(EGUIA_CENTER, EGUIA_CENTER);
if (unlock_manager->getCurrentSlotName() != m_player->getName())
{
ButtonWidget* widget = new ButtonWidget();
widget->m_properties[PROP_ID] = "confirmremove";