Added 'delete player' functionality.
This commit is contained in:
parent
bb18d65ccd
commit
737c8a9983
@ -52,6 +52,10 @@
|
|||||||
I18N="Login dialog" text="OK" label_location="bottom"/>
|
I18N="Login dialog" text="OK" label_location="bottom"/>
|
||||||
<icon-button id="new_user" width="64" height="64" icon="gui/main_help.png"
|
<icon-button id="new_user" width="64" height="64" icon="gui/main_help.png"
|
||||||
I18N="Login dialog" text="Create new user" label_location="bottom"/>
|
I18N="Login dialog" text="Create new user" label_location="bottom"/>
|
||||||
|
<icon-button id="rename" width="64" height="64" icon="gui/main_help.png"
|
||||||
|
I18N="Login dialog" text="Rename" label_location="bottom"/>
|
||||||
|
<icon-button id="delete" width="64" height="64" icon="gui/main_help.png"
|
||||||
|
I18N="Login dialog" text="Delete" label_location="bottom"/>
|
||||||
<icon-button id="cancel" width="64" height="64" icon="gui/main_help.png"
|
<icon-button id="cancel" width="64" height="64" icon="gui/main_help.png"
|
||||||
I18N="Login dialog" text="Cancel" label_location="bottom"/>
|
I18N="Login dialog" text="Cancel" label_location="bottom"/>
|
||||||
</buttonbar>
|
</buttonbar>
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "guiengine/widgets/list_widget.hpp"
|
#include "guiengine/widgets/list_widget.hpp"
|
||||||
#include "online/messages.hpp"
|
#include "online/messages.hpp"
|
||||||
#include "states_screens/dialogs/enter_player_name_dialog.hpp"
|
#include "states_screens/dialogs/enter_player_name_dialog.hpp"
|
||||||
|
#include "states_screens/dialogs/message_dialog.hpp"
|
||||||
#include "states_screens/main_menu_screen.hpp"
|
#include "states_screens/main_menu_screen.hpp"
|
||||||
#include "states_screens/register_screen.hpp"
|
#include "states_screens/register_screen.hpp"
|
||||||
#include "states_screens/state_manager.hpp"
|
#include "states_screens/state_manager.hpp"
|
||||||
@ -116,6 +117,16 @@ void UserScreen::init()
|
|||||||
|
|
||||||
} // init
|
} // init
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
PlayerProfile* UserScreen::getSelectedPlayer()
|
||||||
|
{
|
||||||
|
const std::string &s_id = m_players
|
||||||
|
->getSelectionIDString(PLAYER_ID_GAME_MASTER);
|
||||||
|
unsigned int n_id;
|
||||||
|
StringUtils::fromString(s_id, n_id);
|
||||||
|
return PlayerManager::get()->getPlayer(n_id);
|
||||||
|
} // getSelectedPlayer
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
void UserScreen::tearDown()
|
void UserScreen::tearDown()
|
||||||
@ -241,6 +252,13 @@ void UserScreen::eventCallback(Widget* widget,
|
|||||||
cp->requestSignOut();
|
cp->requestSignOut();
|
||||||
StateManager::get()->popMenu();
|
StateManager::get()->popMenu();
|
||||||
}
|
}
|
||||||
|
else if (button == "rename")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
else if (button == "delete")
|
||||||
|
{
|
||||||
|
deletePlayer();
|
||||||
|
}
|
||||||
} // options
|
} // options
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -268,10 +286,7 @@ void UserScreen::login(bool remember_me)
|
|||||||
// problem will activate the widget again.
|
// problem will activate the widget again.
|
||||||
m_options_widget->setDeactivated();
|
m_options_widget->setDeactivated();
|
||||||
|
|
||||||
const std::string &s_id = m_players->getSelectionIDString(0);
|
PlayerProfile *profile = getSelectedPlayer();
|
||||||
unsigned int n_id;
|
|
||||||
StringUtils::fromString(s_id, n_id);
|
|
||||||
PlayerProfile *profile = PlayerManager::get()->getPlayer(n_id);
|
|
||||||
PlayerManager::get()->setCurrentPlayer(profile, remember_me);
|
PlayerManager::get()->setCurrentPlayer(profile, remember_me);
|
||||||
assert(profile);
|
assert(profile);
|
||||||
|
|
||||||
@ -358,11 +373,49 @@ void UserScreen::loginError(const irr::core::stringw & error_message)
|
|||||||
m_options_widget->setActivated();
|
m_options_widget->setActivated();
|
||||||
} // loginError
|
} // loginError
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
/** Called when a player will be deleted.
|
||||||
|
*/
|
||||||
|
void UserScreen::deletePlayer()
|
||||||
|
{
|
||||||
|
PlayerProfile *player = getSelectedPlayer();
|
||||||
|
irr::core::stringw message =
|
||||||
|
//I18N: In the player info dialog (when deleting)
|
||||||
|
_("Do you really want to delete player '%s' ?", player->getName());
|
||||||
|
|
||||||
|
class ConfirmServer : public MessageDialog::IConfirmDialogListener
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void onConfirm()
|
||||||
|
{
|
||||||
|
UserScreen::getInstance()->doDeletePlayer();
|
||||||
|
} // onConfirm
|
||||||
|
}; // ConfirmServer
|
||||||
|
|
||||||
|
|
||||||
|
new MessageDialog(message, MessageDialog::MESSAGE_DIALOG_CONFIRM,
|
||||||
|
new ConfirmServer(), true);
|
||||||
|
} // deletePlayer
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
/** Callback when the user confirms to delete a player. This function actually
|
||||||
|
* deletes the player, discards the dialog, and re-initialised the UserScreen
|
||||||
|
* to display only the available players.
|
||||||
|
*/
|
||||||
|
void UserScreen::doDeletePlayer()
|
||||||
|
{
|
||||||
|
PlayerProfile *player = getSelectedPlayer();
|
||||||
|
PlayerManager::get()->deletePlayer(player);
|
||||||
|
GUIEngine::ModalDialog::dismiss();
|
||||||
|
init();
|
||||||
|
} // doDeletePlayer
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
void UserScreen::unloaded()
|
void UserScreen::unloaded()
|
||||||
{
|
{
|
||||||
} // unloaded
|
} // unloaded
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
/** Gets called when a dialog closes. At a first time start of STK the
|
/** Gets called when a dialog closes. At a first time start of STK the
|
||||||
* internet dialog is shown first. Only when this dialog closes is it possible
|
* internet dialog is shown first. Only when this dialog closes is it possible
|
||||||
|
@ -32,6 +32,8 @@ namespace GUIEngine
|
|||||||
class Widget;
|
class Widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class PlayerProfile;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Audio options screen
|
* \brief Audio options screen
|
||||||
@ -71,6 +73,9 @@ private:
|
|||||||
void makeEntryFieldsVisible(bool online);
|
void makeEntryFieldsVisible(bool online);
|
||||||
void login(bool remember_me);
|
void login(bool remember_me);
|
||||||
void closeScreen();
|
void closeScreen();
|
||||||
|
void deletePlayer();
|
||||||
|
void doDeletePlayer();
|
||||||
|
PlayerProfile* getSelectedPlayer();
|
||||||
virtual void onDialogClose();
|
virtual void onDialogClose();
|
||||||
virtual void onUpdate(float dt) OVERRIDE;
|
virtual void onUpdate(float dt) OVERRIDE;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user