The first time a player starts story mode, ask them to select a kart

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@11068 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2012-04-01 17:59:00 +00:00
parent b83202439c
commit 7b9fce0486
4 changed files with 29 additions and 2 deletions

View File

@ -189,7 +189,8 @@ void GameSlot::grandPrixFinished()
void GameSlot::save(XMLWriter& out)
{
out << L" <gameslot player=\"" << m_player_name.c_str() << L"\" kart=\""
<< m_kart_ident.c_str() << L"\">\n";
<< m_kart_ident.c_str() << L" firstTime=\"" << (m_first_time ? L"true" : L"false")
<< L"\">\n";
std::map<std::string, Challenge*>::const_iterator i;
for(i = m_challenges_state.begin();
i != m_challenges_state.end(); i++)

View File

@ -56,12 +56,16 @@ class GameSlot
int m_points;
/** Set to false after the initial stuff (intro, select kart, etc.) */
bool m_first_time;
public:
GameSlot(const irr::core::stringw& player_name)
{
m_player_name = player_name;
m_points = 0;
m_first_time = true;
}
const irr::core::stringw& getPlayerName() const { return m_player_name; }
@ -90,6 +94,9 @@ public:
int getPoints () const { return m_points; }
void setFirstTime(bool ft) { m_first_time = ft; }
bool isFirstTime() const { return m_first_time; }
const Challenge* getChallenge(const std::string& id) { return m_challenges_state[id]; }
};

View File

@ -224,6 +224,10 @@ void UnlockManager::load()
m_game_slots[player_name] = slot;
bool first_time = true;
xml_game_slots[n]->get("firstTime", &first_time);
slot->setFirstTime(first_time);
for(AllChallengesType::iterator i = m_all_challenges.begin();
i!=m_all_challenges.end(); i++)
{

View File

@ -22,6 +22,8 @@
#include <string>
#include "addons/network_http.hpp"
#include "challenges/game_slot.hpp"
#include "challenges/unlock_manager.hpp"
#include "graphics/irr_driver.hpp"
#include "guiengine/scalable_font.hpp"
#include "guiengine/widgets/label_widget.hpp"
@ -283,7 +285,20 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name,
}
else if (selection == "story")
{
OverWorld::enterOverWorld();
GameSlot* slot = unlock_manager->getCurrentSlot();
if (slot->isFirstTime())
{
slot->setFirstTime(false);
unlock_manager->save();
KartSelectionScreen* s = KartSelectionScreen::getInstance();
s->setMultiplayer(false);
s->setFromOverworld(true);
StateManager::get()->pushScreen( s );
}
else
{
OverWorld::enterOverWorld();
}
}
else if (selection == "tutorial")
{