Fixed the skiping of the lobby screen :)
This commit is contained in:
parent
2ef991e9e7
commit
d0f93d3b98
@ -86,26 +86,17 @@ void PlayerManager::load()
|
||||
const XMLNode *player_xml = players->getNode(i);
|
||||
PlayerProfile *player = new PlayerProfile(player_xml);
|
||||
m_all_players.push_back(player);
|
||||
if(player->isDefault())
|
||||
if(player->isDefault()){
|
||||
m_current_player = player;
|
||||
}
|
||||
}
|
||||
m_all_players.insertionSort(/*start*/0, /*desc*/true);
|
||||
|
||||
if(!m_current_player)
|
||||
if(!m_current_player) // if there is no default player assigned set the current player to guest
|
||||
{
|
||||
PlayerProfile *player;
|
||||
for_in(player, m_all_players)
|
||||
{
|
||||
if(!player->isGuestAccount())
|
||||
{
|
||||
m_current_player = player;
|
||||
player->setDefault(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
m_current_player = getGuestPlayer();
|
||||
m_current_player->setDefault(true);
|
||||
}
|
||||
if(!m_current_player)
|
||||
Log::fatal("PlayerManager", "Can't find a default player.");
|
||||
|
||||
delete players;
|
||||
} // load
|
||||
@ -201,6 +192,24 @@ const PlayerProfile *PlayerManager::getPlayerById(unsigned int id)
|
||||
return NULL;
|
||||
} // getPlayerById
|
||||
|
||||
|
||||
PlayerProfile* PlayerManager::getGuestPlayer(){
|
||||
|
||||
PlayerProfile *player;
|
||||
for_in(player, m_all_players)
|
||||
{
|
||||
if(player->isGuestAccount())
|
||||
{
|
||||
return player;
|
||||
}
|
||||
}
|
||||
|
||||
player = new PlayerProfile(_LTR("Guest"), /*guest*/true);
|
||||
m_all_players.push_back( player );
|
||||
|
||||
return player;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
PlayerProfile *PlayerManager::getPlayer(const irr::core::stringw &name)
|
||||
{
|
||||
@ -213,14 +222,15 @@ PlayerProfile *PlayerManager::getPlayer(const irr::core::stringw &name)
|
||||
return NULL;
|
||||
} // getPlayer
|
||||
// ----------------------------------------------------------------------------
|
||||
void PlayerManager::setCurrentPlayer(PlayerProfile *player)
|
||||
void PlayerManager::setCurrentPlayer(PlayerProfile *player, bool remember_me)
|
||||
{
|
||||
// Reset current default player
|
||||
if(m_current_player)
|
||||
m_current_player->setDefault(false);
|
||||
m_current_player = player;
|
||||
m_current_player->setDefault(true);
|
||||
m_current_player->setDefault(remember_me);
|
||||
m_current_player->computeActive();
|
||||
m_remember_me = false;
|
||||
} // setCurrentPlayer
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -47,6 +47,7 @@ private:
|
||||
|
||||
/** A pointer to the current player. */
|
||||
PlayerProfile* m_current_player;
|
||||
bool m_remember_me;
|
||||
|
||||
void load();
|
||||
PlayerManager();
|
||||
@ -76,12 +77,16 @@ public:
|
||||
void addDefaultPlayer();
|
||||
void addNewPlayer(const irr::core::stringw& name);
|
||||
void deletePlayer(PlayerProfile *player);
|
||||
void setCurrentPlayer(PlayerProfile *player);
|
||||
void setCurrentPlayer(PlayerProfile *player, bool remember_me);
|
||||
void rememberCurrentPlayer(bool value) { m_remember_me = value; }
|
||||
const PlayerProfile *getPlayerById(unsigned int id);
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the current player. */
|
||||
PlayerProfile* getCurrentPlayer() { return m_current_player; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the guest player. */
|
||||
PlayerProfile* getGuestPlayer();
|
||||
// ------------------------------------------------------------------------
|
||||
PlayerProfile *getPlayer(const irr::core::stringw &name);
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the number of players in the config file.*/
|
||||
|
@ -185,6 +185,7 @@ void OptionsScreenPlayers::eventCallback(Widget* widget, const std::string& name
|
||||
else if (name == "playername")
|
||||
{
|
||||
race_manager->clearKartLastPositionOnOverworld();
|
||||
PlayerManager::get()->setCurrentPlayer(PlayerManager::get()->getGuestPlayer(),false);
|
||||
StateManager::get()->pushScreen(StoryModeLobbyScreen::getInstance());
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ void StoryModeLobbyScreen::init()
|
||||
list->clear();
|
||||
|
||||
PlayerProfile *player = PlayerManager::get()->getCurrentPlayer();
|
||||
if(player)
|
||||
if(!player->isGuestAccount())
|
||||
{
|
||||
StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance());
|
||||
return;
|
||||
@ -107,14 +107,9 @@ void StoryModeLobbyScreen::eventCallback(Widget* widget,
|
||||
->getPlayer(list->getSelectionLabel());
|
||||
if(player)
|
||||
{
|
||||
PlayerManager::get()->setCurrentPlayer(player);
|
||||
player->computeActive();
|
||||
CheckBoxWidget* cb = getWidget<CheckBoxWidget>("rememberme");
|
||||
if (cb->getState())
|
||||
{
|
||||
PlayerManager::get()->setCurrentPlayer(PlayerManager::get()
|
||||
->getPlayer(list->getSelectionLabel()));
|
||||
}
|
||||
PlayerManager::get()->setCurrentPlayer(player,cb->getState());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -140,7 +135,7 @@ void StoryModeLobbyScreen::onNewPlayerWithName(const stringw& new_name)
|
||||
PlayerProfile *player = PlayerManager::get()->getPlayer(new_name);
|
||||
if(player)
|
||||
{
|
||||
PlayerManager::get()->setCurrentPlayer(player);
|
||||
PlayerManager::get()->setCurrentPlayer(player,false);
|
||||
player->computeActive();
|
||||
}
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user