Fix #647, again
Didn't take into account the lack of optionsscreen teardown when storymodelobby gets called up at STK startup (had it disabled). Creating slots and saving the configuration immediately when entering a player name now. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@11377 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
9d664e1fc7
commit
f26a34647e
@ -20,6 +20,8 @@
|
||||
#include <IGUIEnvironment.h>
|
||||
|
||||
#include "audio/sfx_manager.hpp"
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
#include "config/player.hpp"
|
||||
#include "guiengine/engine.hpp"
|
||||
#include "guiengine/widgets/button_widget.hpp"
|
||||
#include "guiengine/widgets/label_widget.hpp"
|
||||
@ -96,7 +98,7 @@ void EnterPlayerNameDialog::onEnterPressedInternal()
|
||||
return;
|
||||
}
|
||||
|
||||
// ---- Otherwise, accept entered name
|
||||
// ---- Otherwise, see if we can accept the new name
|
||||
TextBoxWidget* textCtrl = getWidget<TextBoxWidget>("textfield");
|
||||
stringw playerName = textCtrl->getText().trim();
|
||||
const int size = playerName.size();
|
||||
@ -127,7 +129,11 @@ void EnterPlayerNameDialog::onEnterPressedInternal()
|
||||
}
|
||||
}
|
||||
|
||||
// Finally, add the new player.
|
||||
UserConfigParams::m_all_players.push_back( new PlayerProfile(playerName) );
|
||||
bool created = unlock_manager->createSlotsIfNeeded();
|
||||
if (created) unlock_manager->save();
|
||||
user_config->saveConfig();
|
||||
|
||||
// It's unsafe to delete from inside the event handler so we do it
|
||||
// in onUpdate (which checks for m_self_destroy)
|
||||
|
@ -37,7 +37,7 @@ using namespace GUIEngine;
|
||||
using namespace irr::gui;
|
||||
using namespace irr::core;
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
PlayerInfoDialog::PlayerInfoDialog(PlayerProfile* player, const float w, const float h) : ModalDialog(w, h)
|
||||
{
|
||||
@ -46,7 +46,7 @@ PlayerInfoDialog::PlayerInfoDialog(PlayerProfile* player, const float w, const f
|
||||
showRegularDialog();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
PlayerInfoDialog::~PlayerInfoDialog()
|
||||
{
|
||||
@ -56,7 +56,7 @@ PlayerInfoDialog::~PlayerInfoDialog()
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
void PlayerInfoDialog::showRegularDialog()
|
||||
{
|
||||
clearWindow();
|
||||
@ -139,7 +139,7 @@ void PlayerInfoDialog::showRegularDialog()
|
||||
textCtrl->setFocusForPlayer( PLAYER_ID_GAME_MASTER );
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void PlayerInfoDialog::showConfirmDialog()
|
||||
{
|
||||
@ -162,8 +162,9 @@ void PlayerInfoDialog::showConfirmDialog()
|
||||
|
||||
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
|
||||
// irrlicht labels (more complicated uses require the use of our widget set)
|
||||
// When there is no need to tab through / click on images/labels,
|
||||
// we can add irrlicht labels directly
|
||||
// (more complicated uses require the use of our widget set)
|
||||
IGUIStaticText* a = GUIEngine::getGUIEnv()->addStaticText( message.c_str(),
|
||||
area_left, false /* border */, true /* word wrap */,
|
||||
m_irrlicht_window);
|
||||
@ -212,13 +213,13 @@ void PlayerInfoDialog::showConfirmDialog()
|
||||
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void PlayerInfoDialog::onEnterPressedInternal()
|
||||
{
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
GUIEngine::EventPropagation PlayerInfoDialog::processEvent(const std::string& eventSource)
|
||||
{
|
||||
@ -291,5 +292,5 @@ GUIEngine::EventPropagation PlayerInfoDialog::processEvent(const std::string& ev
|
||||
return GUIEngine::EVENT_LET;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
@ -67,7 +67,7 @@ void OptionsScreenPlayers::init()
|
||||
|
||||
RibbonWidget* tabBar = this->getWidget<RibbonWidget>("options_choice");
|
||||
if (tabBar != NULL) tabBar->select( "tab_players", PLAYER_ID_GAME_MASTER );
|
||||
|
||||
|
||||
tabBar->getRibbonChildren()[0].setTooltip( _("Graphics") );
|
||||
tabBar->getRibbonChildren()[1].setTooltip( _("Audio") );
|
||||
tabBar->getRibbonChildren()[2].setTooltip( _("User Interface") );
|
||||
@ -131,7 +131,7 @@ void OptionsScreenPlayers::onNewPlayerWithName(const stringw& newName)
|
||||
void OptionsScreenPlayers::deletePlayer(PlayerProfile* player)
|
||||
{
|
||||
UserConfigParams::m_all_players.erase(player);
|
||||
|
||||
|
||||
refreshPlayerList();
|
||||
} // deletePlayer
|
||||
|
||||
@ -153,7 +153,7 @@ void OptionsScreenPlayers::eventCallback(Widget* widget, const std::string& name
|
||||
if (name == "options_choice")
|
||||
{
|
||||
std::string selection = ((RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER).c_str();
|
||||
|
||||
|
||||
if (selection == "tab_audio") StateManager::get()->replaceTopMostScreen(OptionsScreenAudio::getInstance());
|
||||
else if (selection == "tab_video") StateManager::get()->replaceTopMostScreen(OptionsScreenVideo::getInstance());
|
||||
else if (selection == "tab_players") StateManager::get()->replaceTopMostScreen(OptionsScreenPlayers::getInstance());
|
||||
@ -173,7 +173,7 @@ void OptionsScreenPlayers::eventCallback(Widget* widget, const std::string& name
|
||||
// Find which player in the list was clicked
|
||||
ListWidget* players = this->getWidget<ListWidget>("players");
|
||||
assert(players != NULL);
|
||||
|
||||
|
||||
core::stringw selectedPlayer = players->getSelectionLabel();
|
||||
const int playerAmount = UserConfigParams::m_all_players.size();
|
||||
for (int n=0; n<playerAmount; n++)
|
||||
@ -193,7 +193,7 @@ void OptionsScreenPlayers::eventCallback(Widget* widget, const std::string& name
|
||||
UserConfigParams::m_default_player = L"";
|
||||
StateManager::get()->pushScreen(StoryModeLobbyScreen::getInstance());
|
||||
}
|
||||
|
||||
|
||||
} // eventCallback
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@ -203,7 +203,7 @@ void OptionsScreenPlayers::selectPlayer(const irr::core::stringw& name)
|
||||
ListWidget* players = this->getWidget<ListWidget>("players");
|
||||
assert(players != NULL);
|
||||
players->selectItemWithLabel(name);
|
||||
|
||||
|
||||
players->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
|
||||
}
|
||||
|
||||
|
@ -147,7 +147,6 @@ void StoryModeLobbyScreen::unloaded()
|
||||
|
||||
void StoryModeLobbyScreen::onNewPlayerWithName(const stringw& newName)
|
||||
{
|
||||
|
||||
bool slot_found = false;
|
||||
|
||||
PtrVector<PlayerProfile>& players = UserConfigParams::m_all_players;
|
||||
|
Loading…
x
Reference in New Issue
Block a user