Started to move current player info from unlock manager into
player_manager.
This commit is contained in:
parent
3fee08d743
commit
97be85777d
@ -18,9 +18,8 @@
|
||||
|
||||
#include "challenges/challenge.hpp"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include "challenges/challenge_data.hpp"
|
||||
#include "io/utf_writer.hpp"
|
||||
#include "io/xml_node.hpp"
|
||||
#include "karts/kart_properties_manager.hpp"
|
||||
#include "karts/kart_properties.hpp"
|
||||
@ -89,17 +88,17 @@ void Challenge::setSolved(RaceManager::Difficulty d)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void Challenge::save(std::ofstream& writer)
|
||||
void Challenge::save(UTFWriter& writer)
|
||||
{
|
||||
writer << " <" << m_data->getId().c_str() << ">\n"
|
||||
<< " <easy solved=\""
|
||||
<< StringUtils::toString(isSolved(RaceManager::DIFFICULTY_EASY))
|
||||
<< "\"/>\n"
|
||||
<< " <medium solved=\""
|
||||
<< StringUtils::toString(isSolved(RaceManager::DIFFICULTY_MEDIUM))
|
||||
<< "\"/>\n"
|
||||
<< " <hard solved=\""
|
||||
<< StringUtils::toString(isSolved(RaceManager::DIFFICULTY_HARD))
|
||||
<< "\"/>\n"
|
||||
<< " </" << m_data->getId().c_str() << ">\n";
|
||||
writer << L" <"<< m_data->getId() << L">\n"
|
||||
<< L" <easy solved=\""
|
||||
<< isSolved(RaceManager::DIFFICULTY_EASY)
|
||||
<< L"\"/>\n"
|
||||
<< L" <medium solved=\""
|
||||
<< isSolved(RaceManager::DIFFICULTY_MEDIUM)
|
||||
<< L"\"/>\n"
|
||||
<< L" <hard solved=\""
|
||||
<< isSolved(RaceManager::DIFFICULTY_HARD)
|
||||
<< L"\"/>\n"
|
||||
<< L" </" << m_data->getId() << L">\n";
|
||||
} // save
|
||||
|
@ -34,9 +34,9 @@
|
||||
#include "utils/no_copy.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
|
||||
class XMLNode;
|
||||
class XMLWriter;
|
||||
class ChallengeData;
|
||||
class UTFWriter;
|
||||
class XMLNode;
|
||||
|
||||
/**
|
||||
* \brief The state of a challenge for one player.
|
||||
@ -53,10 +53,11 @@ private:
|
||||
CH_SOLVED} // challenge was solved
|
||||
m_state[RaceManager::DIFFICULTY_COUNT];
|
||||
|
||||
ChallengeData* m_data;
|
||||
/** Pointer to the original challenge data. */
|
||||
const ChallengeData* m_data;
|
||||
|
||||
public:
|
||||
Challenge(ChallengeData* data)
|
||||
Challenge(const ChallengeData* data)
|
||||
{
|
||||
m_data = data;
|
||||
m_state[RaceManager::DIFFICULTY_EASY] = CH_INACTIVE;
|
||||
@ -65,7 +66,7 @@ public:
|
||||
}
|
||||
virtual ~Challenge() {};
|
||||
void load(const XMLNode* config);
|
||||
void save(std::ofstream& writer);
|
||||
void save(UTFWriter& writer);
|
||||
void setSolved(RaceManager::Difficulty d);
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@ -98,10 +99,6 @@ public:
|
||||
m_state[d] = CH_ACTIVE;
|
||||
} // setActive
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns a pointer to the actual Challenge data.
|
||||
*/
|
||||
ChallengeData* getData() { return m_data; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns a pointer to the actual Challenge data.
|
||||
*/
|
||||
const ChallengeData* getData() const { return m_data; }
|
||||
|
@ -22,6 +22,33 @@
|
||||
#include "challenges/challenge.hpp"
|
||||
#include "challenges/challenge_data.hpp"
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
#include "io/utf_writer.hpp"
|
||||
#include "io/xml_node.hpp"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
GameSlot::GameSlot(const XMLNode *node)
|
||||
{
|
||||
m_kart_ident = "";
|
||||
m_points = 0;
|
||||
m_first_time = true;
|
||||
m_easy_challenges = 0;
|
||||
m_medium_challenges = 0;
|
||||
m_hard_challenges = 0;
|
||||
m_current_challenge = NULL;
|
||||
|
||||
// If there is saved data, load it
|
||||
if(node)
|
||||
{
|
||||
node->get("kart", &m_kart_ident);
|
||||
node->get("first-time", &m_first_time);
|
||||
|
||||
for(unsigned int i=0; i<node->getNumNodes(); i++)
|
||||
{
|
||||
const XMLNode *challenge = node->getNode(i);
|
||||
} // for i <getNumNodes
|
||||
} // if node
|
||||
|
||||
} // GameSlot
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
GameSlot::~GameSlot()
|
||||
@ -234,13 +261,14 @@ void GameSlot::grandPrixFinished()
|
||||
} // grandPrixFinished
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void GameSlot::save(std::ofstream& out, const std::string& name)
|
||||
/** Writes the data of this GameSlot to the specified stream.
|
||||
* \param out UTF stream to write to.
|
||||
*/
|
||||
void GameSlot::save(UTFWriter &out)
|
||||
{
|
||||
out << " <gameslot playerID=\"" << m_player_unique_id
|
||||
<< "\" kart=\"" << m_kart_ident.c_str()
|
||||
<< "\" firstTime=\"" << (m_first_time ? "true" : "false")
|
||||
<< "\"> <!-- " << name.c_str() << " -->\n";
|
||||
out << L" <game-slot playerID=\"" << m_player_unique_id
|
||||
<< L"\" kart=\"" << m_kart_ident
|
||||
<< L"\" firstTime=\"" << m_first_time << L"\">\n";
|
||||
std::map<std::string, Challenge*>::const_iterator i;
|
||||
for(i = m_challenges_state.begin();
|
||||
i != m_challenges_state.end(); i++)
|
||||
@ -248,5 +276,5 @@ void GameSlot::save(std::ofstream& out, const std::string& name)
|
||||
if (i->second != NULL)
|
||||
i->second->save(out);
|
||||
}
|
||||
out << " </gameslot>\n";
|
||||
}
|
||||
out << " </game-slot>\n";
|
||||
} // save
|
||||
|
@ -19,17 +19,20 @@
|
||||
#ifndef GAME_SLOT_HPP
|
||||
#define GAME_SLOT_HPP
|
||||
|
||||
#include "race/race_manager.hpp"
|
||||
|
||||
#include <irrString.h>
|
||||
using namespace irr;
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <irrString.h>
|
||||
|
||||
#include "race/race_manager.hpp"
|
||||
|
||||
class ChallengeData;
|
||||
class Challenge;
|
||||
class XMLWriter;
|
||||
class ChallengeData;
|
||||
class UTFWriter;
|
||||
class XMLNode;
|
||||
|
||||
const int CHALLENGE_POINTS[] = { 8, 9, 10 };
|
||||
|
||||
@ -63,8 +66,6 @@ class GameSlot
|
||||
|
||||
friend class UnlockManager;
|
||||
|
||||
void computeActive();
|
||||
|
||||
int m_points;
|
||||
|
||||
/** Set to false after the initial stuff (intro, select kart, etc.) */
|
||||
@ -76,50 +77,35 @@ class GameSlot
|
||||
|
||||
public:
|
||||
|
||||
// do NOT attempt to pass 'player_unique_id' by reference here. I don't
|
||||
// know why (compiler bug maybe?) but this screws up everything. Better
|
||||
// pass by copy.
|
||||
GameSlot(unsigned int player_unique_id)
|
||||
{
|
||||
m_player_unique_id = player_unique_id;
|
||||
m_points = 0;
|
||||
m_first_time = true;
|
||||
m_easy_challenges = 0;
|
||||
m_medium_challenges = 0;
|
||||
m_hard_challenges = 0;
|
||||
m_current_challenge = NULL;
|
||||
}
|
||||
GameSlot(const XMLNode *node=NULL);
|
||||
~GameSlot();
|
||||
|
||||
unsigned int getPlayerID() const { return m_player_unique_id; }
|
||||
const std::string& getKartIdent () const { return m_kart_ident; }
|
||||
void computeActive();
|
||||
bool isLocked (const std::string& feature);
|
||||
void lockFeature (Challenge *challenge);
|
||||
void unlockFeature (Challenge* c, RaceManager::Difficulty d,
|
||||
bool do_save=true);
|
||||
void raceFinished ();
|
||||
void grandPrixFinished ();
|
||||
void save (UTFWriter &out);
|
||||
void setCurrentChallenge(const std::string &challenge_id);
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
void setKartIdent(const std::string& kart_ident)
|
||||
{
|
||||
m_kart_ident = kart_ident;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the list of recently unlocked features (e.g. call at the end
|
||||
* of a race to know if any features were unlocked) */
|
||||
const std::vector<const ChallengeData*>
|
||||
getRecentlyCompletedChallenges() {return m_unlocked_features;}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Clear the list of recently unlocked challenges */
|
||||
void clearUnlocked () {m_unlocked_features.clear(); }
|
||||
|
||||
bool isLocked (const std::string& feature);
|
||||
|
||||
void lockFeature (Challenge *challenge);
|
||||
|
||||
void unlockFeature (Challenge* c, RaceManager::Difficulty d,
|
||||
bool do_save=true);
|
||||
|
||||
void raceFinished ();
|
||||
void grandPrixFinished ();
|
||||
|
||||
void save (std::ofstream& file, const std::string& name);
|
||||
void setCurrentChallenge(const std::string &challenge_id);
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the number of points accumulated. */
|
||||
int getPoints () const { return m_points; }
|
||||
// ------------------------------------------------------------------------
|
||||
|
@ -156,7 +156,9 @@ void UnlockManager::readAllChallengesInDirs(const std::vector<std::string>* all_
|
||||
void UnlockManager::addOrFreeChallenge(ChallengeData *c)
|
||||
{
|
||||
if(isSupportedVersion(*c))
|
||||
{
|
||||
m_all_challenges[c->getId()]=c;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log::warn("Challenge", "Challenge '%s' is not supported - ignored.",
|
||||
@ -213,7 +215,7 @@ void UnlockManager::load()
|
||||
{
|
||||
Log::info("unlock_manager", "Challenge file '%s' will be created.",
|
||||
filename.c_str());
|
||||
createSlotsIfNeeded();
|
||||
// createSlotsIfNeeded();
|
||||
save();
|
||||
|
||||
if (root) delete root;
|
||||
@ -232,17 +234,10 @@ void UnlockManager::load()
|
||||
continue;
|
||||
}
|
||||
|
||||
GameSlot* slot = new GameSlot(player_id);
|
||||
|
||||
std::string kart_id;
|
||||
xml_game_slots[n]->get("kart", &kart_id);
|
||||
slot->setKartIdent(kart_id);
|
||||
GameSlot* slot = new GameSlot(NULL);
|
||||
|
||||
m_game_slots[player_id] = 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++)
|
||||
@ -256,12 +251,38 @@ void UnlockManager::load()
|
||||
slot->computeActive();
|
||||
}
|
||||
|
||||
bool something_changed = createSlotsIfNeeded();
|
||||
if (something_changed) save();
|
||||
// FIXME
|
||||
// bool something_changed = createSlotsIfNeeded();
|
||||
// if (something_changed) save();
|
||||
|
||||
delete root;
|
||||
} // load
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Creates a game slot. It initialises the game slot's status with the
|
||||
* information in the xml node (if given), basically restoring the saved
|
||||
* states for a player.
|
||||
* \param node The XML game-slots node with all data for a player.
|
||||
*/
|
||||
GameSlot *UnlockManager::createGameSlot(const XMLNode *node)
|
||||
{
|
||||
|
||||
GameSlot *slot = new GameSlot(node);
|
||||
|
||||
for(AllChallengesType::iterator i = m_all_challenges.begin();
|
||||
i!=m_all_challenges.end(); i++)
|
||||
{
|
||||
ChallengeData* cd = i->second;
|
||||
Challenge *challenge = new Challenge(cd);
|
||||
if(node)
|
||||
challenge->load(node);
|
||||
slot->m_challenges_state[cd->getId()] = challenge;
|
||||
}
|
||||
|
||||
slot->computeActive();
|
||||
return slot;
|
||||
} // createGameSlot
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void UnlockManager::save()
|
||||
@ -295,7 +316,7 @@ void UnlockManager::save()
|
||||
}
|
||||
}
|
||||
|
||||
it->second->save(challenge_file, name);
|
||||
//FIXME it->second->save(challenge_file, name);
|
||||
}
|
||||
|
||||
challenge_file << "</challenges>\n\n";
|
||||
@ -329,7 +350,7 @@ bool UnlockManager::createSlotsIfNeeded()
|
||||
|
||||
if (!exists)
|
||||
{
|
||||
GameSlot* slot = new GameSlot(profile->getUniqueID());
|
||||
GameSlot* slot = new GameSlot(NULL);
|
||||
for(AllChallengesType::iterator i = m_all_challenges.begin();
|
||||
i!=m_all_challenges.end(); i++)
|
||||
{
|
||||
@ -418,22 +439,6 @@ PlayerProfile* UnlockManager::getCurrentPlayer()
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void UnlockManager::updateActiveChallengeList()
|
||||
{
|
||||
getCurrentSlot()->computeActive();
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void UnlockManager::setCurrentSlot(unsigned int slotid)
|
||||
{
|
||||
m_current_game_slot = slotid;
|
||||
AchievementsManager::get()->updateCurrentPlayer();
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void UnlockManager::findWhatWasUnlocked(int points_before, int points_now,
|
||||
@ -449,12 +454,12 @@ void UnlockManager::findWhatWasUnlocked(int points_before, int points_now,
|
||||
{
|
||||
if (c->getMode() == ChallengeData::CM_SINGLE_RACE && c->getTrackId() != "")
|
||||
{
|
||||
if (!getCurrentSlot()->isLocked(c->getTrackId()))
|
||||
if (!PlayerManager::get()->getCurrentPlayer()->isLocked(c->getTrackId()))
|
||||
tracks.push_back(c->getTrackId());
|
||||
}
|
||||
else if (c->getMode() == ChallengeData::CM_GRAND_PRIX && c->getGPId() != "")
|
||||
{
|
||||
if (!getCurrentSlot()->isLocked(c->getGPId()))
|
||||
if (!PlayerManager::get()->getCurrentPlayer()->isLocked(c->getGPId()))
|
||||
gps.push_back(c->getGPId());
|
||||
}
|
||||
}
|
||||
|
@ -75,21 +75,12 @@ public:
|
||||
|
||||
unsigned int getCurrentSlotID() const { return m_current_game_slot; }
|
||||
|
||||
GameSlot* getCurrentSlot()
|
||||
{
|
||||
assert(m_game_slots.find(m_current_game_slot) != m_game_slots.end());
|
||||
return m_game_slots[m_current_game_slot];
|
||||
}
|
||||
|
||||
/** \param slotid name of the player */
|
||||
void setCurrentSlot(unsigned int slotid);
|
||||
void findWhatWasUnlocked(int pointsBefore, int pointsNow,
|
||||
std::vector<std::string>& tracks,
|
||||
std::vector<std::string>& gps);
|
||||
|
||||
PlayerProfile* getCurrentPlayer();
|
||||
|
||||
void updateActiveChallengeList();
|
||||
GameSlot *createGameSlot(const XMLNode *node=NULL);
|
||||
|
||||
}; // UnlockManager
|
||||
|
||||
|
@ -18,6 +18,8 @@
|
||||
|
||||
#include "config/player.hpp"
|
||||
|
||||
#include "challenges/game_slot.hpp"
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "io/xml_node.hpp"
|
||||
#include "io/utf_writer.hpp"
|
||||
@ -40,6 +42,7 @@ PlayerProfile::PlayerProfile(const core::stringw& name, bool is_guest)
|
||||
m_is_guest_account = is_guest;
|
||||
m_use_frequency = 0;
|
||||
m_unique_id = PlayerManager::get()->getUniqueId();
|
||||
m_game_slot = unlock_manager->createGameSlot();
|
||||
|
||||
} // PlayerProfile
|
||||
|
||||
@ -53,9 +56,13 @@ PlayerProfile::PlayerProfile(const XMLNode* node)
|
||||
node->get("guest", &m_is_guest_account);
|
||||
node->get("use-frequency", &m_use_frequency );
|
||||
node->get("unique-id", &m_unique_id );
|
||||
node->get("is-default", &m_is_default );
|
||||
#ifdef DEBUG
|
||||
m_magic_number = 0xABCD1234;
|
||||
#endif
|
||||
const XMLNode *xml_game_slot = node->getNode("game-slot");
|
||||
m_game_slot = unlock_manager->createGameSlot(xml_game_slot);
|
||||
|
||||
} // PlayerProfile
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@ -64,11 +71,14 @@ PlayerProfile::PlayerProfile(const XMLNode* node)
|
||||
*/
|
||||
void PlayerProfile::save(UTFWriter &out)
|
||||
{
|
||||
out << L" <player name=\"" << m_name << L"\"\n";
|
||||
out << L" guest=\"" << m_is_guest_account << L"\"\n";
|
||||
out << L" use-frequency=\""<< m_use_frequency << L"\"\n";
|
||||
out << L" unique-id=\"" << m_unique_id << L"\"\n";
|
||||
out << L" />\n";
|
||||
out << L" <player name=\"" << m_name
|
||||
<< L"\" guest=\"" << m_is_guest_account
|
||||
<< L"\" use-frequency=\"" << m_use_frequency
|
||||
<< L"\" is-default=\"" << m_is_default
|
||||
<< L"\" unique-id=\"" << m_unique_id << L"\">\n";
|
||||
assert(m_game_slot);
|
||||
m_game_slot->save(out);
|
||||
out << L" </player>\n";
|
||||
} // save
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
@ -19,6 +19,8 @@
|
||||
#ifndef HEADER_PLAYER_HPP
|
||||
#define HEADER_PLAYER_HPP
|
||||
|
||||
#include "challenges/game_slot.hpp"
|
||||
|
||||
#include "config/user_config.hpp"
|
||||
#include "utils/no_copy.hpp"
|
||||
#include "utils/types.hpp"
|
||||
@ -28,6 +30,7 @@ using namespace irr;
|
||||
|
||||
#include <string>
|
||||
|
||||
class GameSlot;
|
||||
class UTFWriter;
|
||||
|
||||
/**
|
||||
@ -38,7 +41,7 @@ class UTFWriter;
|
||||
*/
|
||||
class PlayerProfile : public NoCopy
|
||||
{
|
||||
protected:
|
||||
private:
|
||||
|
||||
/** The name of the player (wide string, so it can be in native
|
||||
* language). */
|
||||
@ -57,6 +60,12 @@ protected:
|
||||
/** A unique number for this player, used to link it to challenges etc. */
|
||||
unsigned int m_unique_id;
|
||||
|
||||
/** True if this is the default (last used) player. */
|
||||
bool m_is_default;
|
||||
|
||||
/** The complete challenge state. */
|
||||
GameSlot *m_game_slot;
|
||||
|
||||
public:
|
||||
|
||||
PlayerProfile(const core::stringw& name, bool is_guest = false);
|
||||
@ -69,6 +78,7 @@ public:
|
||||
bool operator>(const PlayerProfile &other);
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
~PlayerProfile()
|
||||
{
|
||||
#ifdef DEBUG
|
||||
@ -76,6 +86,7 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
void setName(const core::stringw& name)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
@ -84,6 +95,7 @@ public:
|
||||
m_name = name;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
core::stringw getName() const
|
||||
{
|
||||
#ifdef DEBUG
|
||||
@ -92,6 +104,7 @@ public:
|
||||
return m_name.c_str();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
bool isGuestAccount() const
|
||||
{
|
||||
#ifdef DEBUG
|
||||
@ -100,17 +113,74 @@ public:
|
||||
return m_is_guest_account;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
int getUseFrequency() const
|
||||
{
|
||||
if (m_is_guest_account) return -1;
|
||||
else return m_use_frequency;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the unique id of this player. */
|
||||
unsigned int getUniqueID() const { return m_unique_id; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returned if the feature (kart, track) is locked. */
|
||||
bool isLocked(const std::string &feature) const
|
||||
{
|
||||
return m_game_slot->isLocked(feature);
|
||||
} // isLocked
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns all active challenges. */
|
||||
void computeActive() { m_game_slot->computeActive(); }
|
||||
// ------------------------------------------------------------------------
|
||||
std::vector<const ChallengeData*> getRecentlyCompletedChallenges()
|
||||
{
|
||||
return m_game_slot->getRecentlyCompletedChallenges();
|
||||
} // getRecently Completed Challenges
|
||||
// ------------------------------------------------------------------------
|
||||
void setCurrentChallenge(const std::string &name)
|
||||
{
|
||||
m_game_slot->setCurrentChallenge(name);
|
||||
} // setCurrentChallenge
|
||||
// ------------------------------------------------------------------------
|
||||
/** Notification of a finished race, which can trigger fulfilling
|
||||
* challenges. */
|
||||
void raceFinished() { m_game_slot->raceFinished(); }
|
||||
// ------------------------------------------------------------------------
|
||||
void grandPrixFinished() { m_game_slot->grandPrixFinished(); }
|
||||
// ------------------------------------------------------------------------
|
||||
unsigned int getPoints() const { return m_game_slot->getPoints(); }
|
||||
// ------------------------------------------------------------------------
|
||||
bool isFirstTime() const { return m_game_slot->isFirstTime(); }
|
||||
// ------------------------------------------------------------------------
|
||||
void clearUnlocked() { m_game_slot->clearUnlocked(); }
|
||||
// ------------------------------------------------------------------------
|
||||
const Challenge* getChallenge(const std::string &id)
|
||||
{
|
||||
return m_game_slot->getChallenge(id);
|
||||
} // getChallenge
|
||||
// ------------------------------------------------------------------------
|
||||
unsigned int getNumEasyTrophies() const
|
||||
{
|
||||
return m_game_slot->getNumEasyTrophies();
|
||||
} // getNumEasyTrophies
|
||||
// ------------------------------------------------------------------------
|
||||
unsigned int getNumMediumTrophies() const
|
||||
{
|
||||
return m_game_slot->getNumMediumTrophies();
|
||||
} // getNumEasyTrophies
|
||||
// -----------------------------------------------------------------------
|
||||
unsigned int getNumHardTrophies() const
|
||||
{
|
||||
return m_game_slot->getNumHardTrophies();
|
||||
} // getNumHardTropies
|
||||
// -----------------------------------------------------------------------
|
||||
/** Returns true if this is the default (last used) player. */
|
||||
bool isDefault() const { return m_is_default; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Sets if this player is the default player or not. */
|
||||
void setDefault(bool is_default) { m_is_default = is_default; }
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
}; // class PlayerProfile
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
#include "config/player_manager.hpp"
|
||||
|
||||
#include "achievements/achievements_manager.hpp"
|
||||
#include "config/player.hpp"
|
||||
#include "io/file_manager.hpp"
|
||||
#include "io/utf_writer.hpp"
|
||||
@ -27,10 +28,29 @@
|
||||
|
||||
PlayerManager *PlayerManager::m_player_manager = NULL;
|
||||
|
||||
|
||||
/** Create the instance of the player manager.
|
||||
* Also make sure that at least one player is defined (and if not,
|
||||
* create a default player and a guest player).
|
||||
*/
|
||||
void PlayerManager::create()
|
||||
{
|
||||
assert(!m_player_manager);
|
||||
m_player_manager = new PlayerManager();
|
||||
if(m_player_manager->getNumPlayers() == 0)
|
||||
{
|
||||
m_player_manager->addDefaultPlayer();
|
||||
m_player_manager->save();
|
||||
}
|
||||
|
||||
} // create
|
||||
|
||||
// ============================================================================
|
||||
/** Constructor.
|
||||
*/
|
||||
PlayerManager::PlayerManager()
|
||||
{
|
||||
load();
|
||||
} // PlayerManager
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -48,23 +68,44 @@ void PlayerManager::load()
|
||||
std::string filename = file_manager->getUserConfigFile("players.xml");
|
||||
|
||||
const XMLNode *players = file_manager->createXMLTree(filename);
|
||||
if(!players || players->getName()!="players")
|
||||
if(!players)
|
||||
{
|
||||
Log::info("player_manager", "A new players.xml file will be created.");
|
||||
return;
|
||||
}
|
||||
else if(players->getName()!="players")
|
||||
{
|
||||
Log::info("player_manager", "The players.xml file is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
m_current_player = NULL;
|
||||
for(unsigned int i=0; i<players->getNumNodes(); i++)
|
||||
{
|
||||
const XMLNode *player_xml = players->getNode(i);
|
||||
PlayerProfile *profile = new PlayerProfile(player_xml);
|
||||
|
||||
if(profile->isGuestAccount())
|
||||
profile->setName(_LTR("Guest"));
|
||||
|
||||
m_all_players.push_back(profile);
|
||||
PlayerProfile *player = new PlayerProfile(player_xml);
|
||||
m_all_players.push_back(player);
|
||||
if(player->isDefault())
|
||||
m_current_player = player;
|
||||
}
|
||||
m_all_players.insertionSort();
|
||||
|
||||
if(!m_current_player)
|
||||
{
|
||||
PlayerProfile *player;
|
||||
for_in(player, m_all_players)
|
||||
{
|
||||
if(!player->isGuestAccount())
|
||||
{
|
||||
m_current_player = player;
|
||||
player->setDefault(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!m_current_player)
|
||||
Log::fatal("PlayerManager", "Can't find a default player.");
|
||||
|
||||
} // load
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -93,7 +134,6 @@ void PlayerManager::save()
|
||||
Log::error("PlayerManager", "Error: %s", e.what());
|
||||
}
|
||||
|
||||
|
||||
} // save
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -171,4 +211,14 @@ PlayerProfile *PlayerManager::getPlayer(const irr::core::stringw &name)
|
||||
return NULL;
|
||||
} // getPlayer
|
||||
// ----------------------------------------------------------------------------
|
||||
void PlayerManager::setCurrentPlayer(PlayerProfile *player)
|
||||
{
|
||||
// Reset current default player
|
||||
if(m_current_player)
|
||||
m_current_player->setDefault(false);
|
||||
m_current_player = player;
|
||||
m_current_player->setDefault(true);
|
||||
AchievementsManager::get()->updateCurrentPlayer();
|
||||
} // setCurrentPlayer
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -16,8 +16,8 @@
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#ifndef HEADER_PLAYER_CONFIG_HPP
|
||||
#define HEADER_PLAYER_CONFIG_HPP
|
||||
#ifndef HEADER_PLAYER_MANAGER_HPP
|
||||
#define HEADER_PLAYER_MANAGER_HPP
|
||||
|
||||
#include "utils/no_copy.hpp"
|
||||
#include "utils/ptr_vector.hpp"
|
||||
@ -37,35 +37,43 @@ private:
|
||||
|
||||
PtrVector<PlayerProfile> m_all_players;
|
||||
|
||||
/** A pointer to the current player. */
|
||||
PlayerProfile* m_current_player;
|
||||
|
||||
void load();
|
||||
PlayerManager();
|
||||
~PlayerManager();
|
||||
|
||||
|
||||
public:
|
||||
static void create();
|
||||
// ------------------------------------------------------------------------
|
||||
/** Static singleton get function. */
|
||||
static PlayerManager* get()
|
||||
{
|
||||
if(!m_player_manager)
|
||||
m_player_manager = new PlayerManager();
|
||||
assert(m_player_manager);
|
||||
return m_player_manager;
|
||||
} // get
|
||||
// ------------------------------------------------------------------------
|
||||
static void destroy()
|
||||
{
|
||||
assert(m_player_manager);
|
||||
delete m_player_manager;
|
||||
m_player_manager = NULL;
|
||||
} // destroy
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
void load();
|
||||
void save();
|
||||
unsigned int getUniqueId() const;
|
||||
void addDefaultPlayer();
|
||||
void addNewPlayer(const irr::core::stringw& name);
|
||||
void deletePlayer(PlayerProfile *player);
|
||||
void setCurrentPlayer(PlayerProfile *player);
|
||||
const PlayerProfile *getPlayerById(unsigned int id);
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the current player. */
|
||||
PlayerProfile* getCurrentPlayer() { return m_current_player; }
|
||||
// ------------------------------------------------------------------------
|
||||
PlayerProfile *getPlayer(const irr::core::stringw &name);
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the number of players in the config file.*/
|
||||
|
@ -58,7 +58,6 @@ UTFWriter& UTFWriter::operator<< (const wchar_t*txt)
|
||||
} // operator<< (wchar_t)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void UTFWriter::close()
|
||||
{
|
||||
m_base.close();
|
||||
|
@ -34,10 +34,21 @@ class UTFWriter
|
||||
public:
|
||||
|
||||
UTFWriter(const char* dest);
|
||||
void close();
|
||||
|
||||
UTFWriter& operator<< (const irr::core::stringw& txt);
|
||||
UTFWriter& operator<< (const wchar_t* txt);
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
UTFWriter& operator<< (const char *txt)
|
||||
{
|
||||
return operator<<(irr::core::stringw(txt));
|
||||
} // operator<<(char*)
|
||||
// ------------------------------------------------------------------------
|
||||
UTFWriter& operator<< (const std::string &txt)
|
||||
{
|
||||
return operator<< (irr::core::stringw(txt.c_str()));
|
||||
} // operator<<(std::string)
|
||||
// ------------------------------------------------------------------------
|
||||
template<typename T>
|
||||
UTFWriter& operator<< (const T t)
|
||||
{
|
||||
@ -45,10 +56,8 @@ public:
|
||||
tmp += t;
|
||||
(*this) << tmp;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void close();
|
||||
|
||||
} // operator<< (template)
|
||||
// ------------------------------------------------------------------------
|
||||
bool is_open() { return m_base.is_open(); }
|
||||
};
|
||||
|
||||
|
@ -19,13 +19,9 @@
|
||||
|
||||
#include "karts/kart_properties_manager.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <ctime>
|
||||
#include <stdio.h>
|
||||
#include <stdexcept>
|
||||
#include <iostream>
|
||||
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
#include "config/player.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "config/stk_config.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "graphics/irr_driver.hpp"
|
||||
@ -35,6 +31,12 @@
|
||||
#include "utils/log.hpp"
|
||||
#include "utils/string_utils.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <ctime>
|
||||
#include <stdio.h>
|
||||
#include <stdexcept>
|
||||
#include <iostream>
|
||||
|
||||
KartPropertiesManager *kart_properties_manager=0;
|
||||
|
||||
std::vector<std::string> KartPropertiesManager::m_kart_search_path;
|
||||
@ -353,7 +355,8 @@ bool KartPropertiesManager::kartAvailable(int kartid)
|
||||
if ( kartid == *it) return false;
|
||||
}
|
||||
const KartProperties *kartprop = getKartById(kartid);
|
||||
if(unlock_manager->getCurrentSlot()->isLocked(kartprop->getIdent())) return false;
|
||||
if( PlayerManager::get()->getCurrentPlayer()->isLocked(kartprop->getIdent()) )
|
||||
return false;
|
||||
return true;
|
||||
} // kartAvailable
|
||||
|
||||
@ -465,7 +468,7 @@ void KartPropertiesManager::getRandomKartList(int count,
|
||||
const KartProperties &kp=m_karts_properties[karts_in_group[i]];
|
||||
if (!used[karts_in_group[i]] &&
|
||||
m_kart_available[karts_in_group[i]] &&
|
||||
!unlock_manager->getCurrentSlot()->isLocked(kp.getIdent()) )
|
||||
!PlayerManager::get()->getCurrentPlayer()->isLocked(kp.getIdent()) )
|
||||
{
|
||||
random_kart_queue.push_back(kp.getIdent());
|
||||
}
|
||||
|
165
src/main.cpp
165
src/main.cpp
@ -681,10 +681,9 @@ int handleCmdLine()
|
||||
|
||||
if(CommandLine::has("--kart", &s))
|
||||
{
|
||||
unlock_manager->setCurrentSlot(PlayerManager::get()->getPlayer(0)
|
||||
->getUniqueID());
|
||||
const PlayerProfile *player = PlayerManager::get()->getCurrentPlayer();
|
||||
|
||||
if (!unlock_manager->getCurrentSlot()->isLocked(s))
|
||||
if(!player->isLocked(s))
|
||||
{
|
||||
const KartProperties *prop =
|
||||
kart_properties_manager->getKart(s);
|
||||
@ -751,9 +750,8 @@ int handleCmdLine()
|
||||
|
||||
if(CommandLine::has("--track", &s) || CommandLine::has("-t", &s))
|
||||
{
|
||||
unlock_manager->setCurrentSlot(PlayerManager::get()->getPlayer(0)
|
||||
->getUniqueID());
|
||||
if (!unlock_manager->getCurrentSlot()->isLocked(s))
|
||||
const PlayerProfile *player = PlayerManager::get()->getCurrentPlayer();
|
||||
if (!player->isLocked(s))
|
||||
{
|
||||
race_manager->setTrack(s);
|
||||
Log::verbose("main", "You choose to start in track '%s'.",
|
||||
@ -899,8 +897,6 @@ int handleCmdLine()
|
||||
// Demo mode
|
||||
if(CommandLine::has("--demo-mode", &s))
|
||||
{
|
||||
unlock_manager->setCurrentSlot(PlayerManager::get()->getPlayer(0)
|
||||
->getUniqueID());
|
||||
float t;
|
||||
StringUtils::fromString(s, t);
|
||||
DemoWorld::enableDemoMode(t);
|
||||
@ -941,9 +937,6 @@ int handleCmdLine()
|
||||
|
||||
CommandLine::reportInvalidParameters();
|
||||
|
||||
if(UserConfigParams::m_no_start_screen)
|
||||
unlock_manager->setCurrentSlot(PlayerManager::get()->getPlayer(0)
|
||||
->getUniqueID());
|
||||
if(ProfileWorld::isProfileMode())
|
||||
{
|
||||
UserConfigParams::m_sfx = false; // Disable sound effects
|
||||
@ -973,9 +966,8 @@ void initUserConfig()
|
||||
{
|
||||
irr_driver = new IrrDriver();
|
||||
file_manager = new FileManager();
|
||||
PlayerManager::get()->load();
|
||||
user_config = new UserConfig(); // needs file_manager
|
||||
const bool config_ok = user_config->loadConfig();
|
||||
user_config->loadConfig();
|
||||
if (UserConfigParams::m_language.toString() != "system")
|
||||
{
|
||||
#ifdef WIN32
|
||||
@ -990,11 +982,6 @@ void initUserConfig()
|
||||
translations = new Translations(); // needs file_manager
|
||||
stk_config = new STKConfig(); // in case of --stk-config
|
||||
// command line parameters
|
||||
if (!config_ok || PlayerManager::get()->getNumPlayers() == 0)
|
||||
{
|
||||
PlayerManager::get()->addDefaultPlayer();
|
||||
PlayerManager::get()->save();
|
||||
}
|
||||
|
||||
} // initUserConfig
|
||||
|
||||
@ -1026,7 +1013,6 @@ void initRest()
|
||||
Online::RequestManager::get()->startNetworkThread();
|
||||
NewsManager::get(); // this will create the news manager
|
||||
|
||||
AchievementsManager::get()->init();
|
||||
music_manager = new MusicManager();
|
||||
sfx_manager = new SFXManager();
|
||||
// The order here can be important, e.g. KartPropertiesManager needs
|
||||
@ -1069,61 +1055,6 @@ void initRest()
|
||||
|
||||
} // initRest
|
||||
|
||||
//=============================================================================
|
||||
/** Frees all manager and their associated memory.
|
||||
*/
|
||||
static void cleanSuperTuxKart()
|
||||
{
|
||||
|
||||
delete main_loop;
|
||||
|
||||
irr_driver->updateConfigIfRelevant();
|
||||
|
||||
if(Online::RequestManager::isRunning())
|
||||
Online::RequestManager::get()->stopNetworkThread();
|
||||
|
||||
//delete in reverse order of what they were created in.
|
||||
//see InitTuxkart()
|
||||
Online::RequestManager::deallocate();
|
||||
Online::ServersManager::deallocate();
|
||||
Online::ProfileManager::deallocate();
|
||||
AchievementsManager::deallocate();
|
||||
Online::CurrentUser::deallocate();
|
||||
GUIEngine::DialogQueue::deallocate();
|
||||
|
||||
Referee::cleanup();
|
||||
if(ReplayPlay::get()) ReplayPlay::destroy();
|
||||
if(race_manager) delete race_manager;
|
||||
NewsManager::deallocate();
|
||||
if(addons_manager) delete addons_manager;
|
||||
NetworkManager::kill();
|
||||
|
||||
if(grand_prix_manager) delete grand_prix_manager;
|
||||
if(highscore_manager) delete highscore_manager;
|
||||
if(attachment_manager) delete attachment_manager;
|
||||
ItemManager::removeTextures();
|
||||
if(powerup_manager) delete powerup_manager;
|
||||
if(projectile_manager) delete projectile_manager;
|
||||
if(kart_properties_manager) delete kart_properties_manager;
|
||||
if(track_manager) delete track_manager;
|
||||
if(material_manager) delete material_manager;
|
||||
if(history) delete history;
|
||||
ReplayRecorder::destroy();
|
||||
if(sfx_manager) delete sfx_manager;
|
||||
if(music_manager) delete music_manager;
|
||||
delete ParticleKindManager::get();
|
||||
if(stk_config) delete stk_config;
|
||||
if(user_config) delete user_config;
|
||||
PlayerManager::destroy();
|
||||
if(unlock_manager) delete unlock_manager;
|
||||
if(translations) delete translations;
|
||||
if(file_manager) delete file_manager;
|
||||
if(irr_driver) delete irr_driver;
|
||||
|
||||
StateManager::deallocate();
|
||||
GUIEngine::EventHandler::deallocate();
|
||||
} // cleanSuperTuxKart
|
||||
|
||||
//=============================================================================
|
||||
#ifdef BREAKPAD
|
||||
bool ShowDumpResults(const wchar_t* dump_path,
|
||||
@ -1191,10 +1122,19 @@ int main(int argc, char *argv[] )
|
||||
"options_video.png"));
|
||||
kart_properties_manager -> loadAllKarts ();
|
||||
handleXmasMode();
|
||||
unlock_manager = new UnlockManager();
|
||||
|
||||
// Needs the kart and track directories to load potential challenges
|
||||
// in those dirs.
|
||||
unlock_manager = new UnlockManager();
|
||||
// Needs the unlock manager to initialise the game slots of all players
|
||||
PlayerManager::create();
|
||||
|
||||
// Needs the player manager
|
||||
AchievementsManager::get()->init();
|
||||
|
||||
GUIEngine::addLoadingIcon( irr_driver->getTexture(FileManager::GUI,
|
||||
"gui_lock.png" ) );
|
||||
projectile_manager -> loadData ();
|
||||
projectile_manager->loadData();
|
||||
|
||||
// Both item_manager and powerup_manager load models and therefore
|
||||
// textures from the model directory. To avoid reading the
|
||||
@ -1220,7 +1160,7 @@ int main(int argc, char *argv[] )
|
||||
|
||||
file_manager->popTextureSearchPath();
|
||||
|
||||
attachment_manager -> loadModels ();
|
||||
attachment_manager->loadModels();
|
||||
|
||||
GUIEngine::addLoadingIcon( irr_driver->getTexture(FileManager::GUI,
|
||||
"banana.png") );
|
||||
@ -1253,17 +1193,6 @@ int main(int argc, char *argv[] )
|
||||
addons_manager->initAddons(xml);
|
||||
}
|
||||
}
|
||||
|
||||
// no graphics, and no profile mode
|
||||
if (ProfileWorld::isNoGraphics() && !ProfileWorld::isProfileMode())
|
||||
{
|
||||
core::stringw name = UserConfigParams::m_default_player.toString();
|
||||
PlayerProfile *player = PlayerManager::get()->getPlayer(name);
|
||||
// hack to have a running game slot :
|
||||
if(player)
|
||||
unlock_manager->setCurrentSlot(player->getUniqueID());
|
||||
|
||||
}
|
||||
else if(!UserConfigParams::m_no_start_screen)
|
||||
{
|
||||
StateManager::get()->pushScreen(StoryModeLobbyScreen::getInstance());
|
||||
@ -1436,10 +1365,68 @@ int main(int argc, char *argv[] )
|
||||
return 0 ;
|
||||
} // main
|
||||
|
||||
// ============================================================================
|
||||
#ifdef WIN32
|
||||
//routine for running under windows
|
||||
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
|
||||
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||
LPTSTR lpCmdLine, int nCmdShow)
|
||||
{
|
||||
return main(__argc, __argv);
|
||||
}
|
||||
#endif
|
||||
|
||||
//=============================================================================
|
||||
/** Frees all manager and their associated memory.
|
||||
*/
|
||||
static void cleanSuperTuxKart()
|
||||
{
|
||||
|
||||
delete main_loop;
|
||||
|
||||
irr_driver->updateConfigIfRelevant();
|
||||
|
||||
if(Online::RequestManager::isRunning())
|
||||
Online::RequestManager::get()->stopNetworkThread();
|
||||
|
||||
//delete in reverse order of what they were created in.
|
||||
//see InitTuxkart()
|
||||
Online::RequestManager::deallocate();
|
||||
Online::ServersManager::deallocate();
|
||||
Online::ProfileManager::deallocate();
|
||||
AchievementsManager::deallocate();
|
||||
Online::CurrentUser::deallocate();
|
||||
GUIEngine::DialogQueue::deallocate();
|
||||
|
||||
Referee::cleanup();
|
||||
if(ReplayPlay::get()) ReplayPlay::destroy();
|
||||
if(race_manager) delete race_manager;
|
||||
NewsManager::deallocate();
|
||||
if(addons_manager) delete addons_manager;
|
||||
NetworkManager::kill();
|
||||
|
||||
if(grand_prix_manager) delete grand_prix_manager;
|
||||
if(highscore_manager) delete highscore_manager;
|
||||
if(attachment_manager) delete attachment_manager;
|
||||
ItemManager::removeTextures();
|
||||
if(powerup_manager) delete powerup_manager;
|
||||
if(projectile_manager) delete projectile_manager;
|
||||
if(kart_properties_manager) delete kart_properties_manager;
|
||||
if(track_manager) delete track_manager;
|
||||
if(material_manager) delete material_manager;
|
||||
if(history) delete history;
|
||||
ReplayRecorder::destroy();
|
||||
if(sfx_manager) delete sfx_manager;
|
||||
if(music_manager) delete music_manager;
|
||||
delete ParticleKindManager::get();
|
||||
if(stk_config) delete stk_config;
|
||||
if(user_config) delete user_config;
|
||||
PlayerManager::destroy();
|
||||
if(unlock_manager) delete unlock_manager;
|
||||
if(translations) delete translations;
|
||||
if(file_manager) delete file_manager;
|
||||
if(irr_driver) delete irr_driver;
|
||||
|
||||
StateManager::deallocate();
|
||||
GUIEngine::EventHandler::deallocate();
|
||||
} // cleanSuperTuxKart
|
||||
|
||||
|
@ -18,16 +18,11 @@
|
||||
|
||||
#include "modes/world.hpp"
|
||||
|
||||
#include <assert.h>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <algorithm>
|
||||
#include <ctime>
|
||||
|
||||
#include "achievements/achievements_manager.hpp"
|
||||
#include "audio/music_manager.hpp"
|
||||
#include "audio/sfx_base.hpp"
|
||||
#include "audio/sfx_manager.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "graphics/camera.hpp"
|
||||
@ -65,6 +60,13 @@
|
||||
#include "utils/translation.hpp"
|
||||
#include "utils/string_utils.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <assert.h>
|
||||
#include <ctime>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
|
||||
|
||||
World* World::m_world = NULL;
|
||||
|
||||
/** The main world class is used to handle the track and the karts.
|
||||
@ -441,10 +443,10 @@ void World::terminateRace()
|
||||
{
|
||||
updateHighscores(&best_highscore_rank, &best_finish_time, &highscore_who,
|
||||
&best_player);
|
||||
unlock_manager->getCurrentSlot()->raceFinished();
|
||||
PlayerManager::get()->getCurrentPlayer()->raceFinished();
|
||||
}
|
||||
|
||||
unlock_manager->getCurrentSlot()->raceFinished();
|
||||
PlayerManager::get()->getCurrentPlayer()->raceFinished();
|
||||
((MapAchievement *) AchievementsManager::get()->getActive()->getAchievement(1))->increase(getTrack()->getIdent(), 1);
|
||||
AchievementsManager::get()->onRaceEnd();
|
||||
|
||||
|
@ -19,7 +19,9 @@
|
||||
|
||||
#include "race/grand_prix_data.hpp"
|
||||
|
||||
#include "config/player.hpp"
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "io/file_manager.hpp"
|
||||
#include "tracks/track_manager.hpp"
|
||||
#include "tracks/track.hpp"
|
||||
@ -157,7 +159,7 @@ bool GrandPrixData::checkConsistency(bool chatty) const
|
||||
bool GrandPrixData::isTrackAvailable(const std::string &id) const
|
||||
{
|
||||
return id!="fortmagma" ||
|
||||
!unlock_manager->getCurrentSlot()->isLocked("fortmagma");
|
||||
!PlayerManager::get()->getCurrentPlayer()->isLocked("fortmagma");
|
||||
} // isTrackAvailable
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include <algorithm>
|
||||
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "config/saved_grand_prix.hpp"
|
||||
#include "config/stk_config.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
@ -630,7 +631,7 @@ void RaceManager::exitRace(bool delete_world)
|
||||
// were finished, and not when a race is aborted.
|
||||
if (m_major_mode==MAJOR_MODE_GRAND_PRIX && m_track_number==(int)m_tracks.size())
|
||||
{
|
||||
unlock_manager->getCurrentSlot()->grandPrixFinished();
|
||||
PlayerManager::get()->getCurrentPlayer()->grandPrixFinished();
|
||||
if(m_major_mode==MAJOR_MODE_GRAND_PRIX&& !NetworkWorld::getInstance()->isRunning())
|
||||
{
|
||||
//Delete saved GP
|
||||
|
@ -16,6 +16,7 @@
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "guiengine/widget.hpp"
|
||||
#include "guiengine/widgets/dynamic_ribbon_widget.hpp"
|
||||
@ -234,7 +235,7 @@ void ArenasScreen::buildTrackList()
|
||||
if(!curr->isArena()) continue;
|
||||
}
|
||||
|
||||
if (unlock_manager->getCurrentSlot()->isLocked(curr->getIdent()))
|
||||
if (PlayerManager::get()->getCurrentPlayer()->isLocked(curr->getIdent()))
|
||||
{
|
||||
w->addItem( _("Locked : solve active challenges to gain access to more!"),
|
||||
"locked", curr->getScreenshotFile(), LOCKED_BADGE );
|
||||
@ -264,7 +265,7 @@ void ArenasScreen::buildTrackList()
|
||||
if(!curr->isArena()) continue;
|
||||
}
|
||||
|
||||
if (unlock_manager->getCurrentSlot()->isLocked(curr->getIdent()))
|
||||
if (PlayerManager::get()->getCurrentPlayer()->isLocked(curr->getIdent()))
|
||||
{
|
||||
w->addItem( _("Locked : solve active challenges to gain access to more!"),
|
||||
"locked", curr->getScreenshotFile(), LOCKED_BADGE );
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
#include "audio/sfx_manager.hpp"
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "config/saved_grand_prix.hpp"
|
||||
#include "guiengine/engine.hpp"
|
||||
#include "guiengine/screen.hpp"
|
||||
@ -219,7 +220,7 @@ void GPInfoDialog::onEnterPressedInternal()
|
||||
std::string gp_id = m_gp_ident;
|
||||
ModalDialog::dismiss();
|
||||
// Disable accidentally unlocking of a challenge
|
||||
unlock_manager->getCurrentSlot()->setCurrentChallenge("");
|
||||
PlayerManager::get()->getCurrentPlayer()->setCurrentChallenge("");
|
||||
race_manager->startGP(grand_prix_manager->getGrandPrix(gp_id), false, false);
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "guiengine/engine.hpp"
|
||||
@ -92,7 +93,7 @@ SelectChallengeDialog::SelectChallengeDialog(const float percentWidth,
|
||||
break;
|
||||
}
|
||||
|
||||
const Challenge* c = unlock_manager->getCurrentSlot()->getChallenge(challenge_id);
|
||||
const Challenge* c = PlayerManager::get()->getCurrentPlayer()->getChallenge(challenge_id);
|
||||
|
||||
if (c->isSolved(RaceManager::DIFFICULTY_EASY))
|
||||
{
|
||||
@ -169,7 +170,7 @@ GUIEngine::EventPropagation SelectChallengeDialog::processEvent(const std::strin
|
||||
return GUIEngine::EVENT_LET;
|
||||
}
|
||||
|
||||
unlock_manager->getCurrentSlot()->setCurrentChallenge(m_challenge_id);
|
||||
PlayerManager::get()->getCurrentPlayer()->setCurrentChallenge(m_challenge_id);
|
||||
|
||||
ModalDialog::dismiss();
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "states_screens/dialogs/track_info_dialog.hpp"
|
||||
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "guiengine/engine.hpp"
|
||||
#include "guiengine/screen.hpp"
|
||||
@ -250,7 +251,7 @@ void TrackInfoDialog::onEnterPressedInternal()
|
||||
race_manager->setReverseTrack(reverse_track);
|
||||
std::string track_ident = m_track_ident;
|
||||
// Disable accidentally unlocking of a challenge
|
||||
unlock_manager->getCurrentSlot()->setCurrentChallenge("");
|
||||
PlayerManager::get()->getCurrentPlayer()->setCurrentChallenge("");
|
||||
|
||||
ModalDialog::dismiss();
|
||||
race_manager->startSingleRace(track_ident, num_laps, false);
|
||||
|
@ -15,14 +15,16 @@
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "states_screens/easter_egg_screen.hpp"
|
||||
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "guiengine/widget.hpp"
|
||||
#include "guiengine/widgets/dynamic_ribbon_widget.hpp"
|
||||
#include "guiengine/widgets/icon_button_widget.hpp"
|
||||
#include "io/file_manager.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
#include "states_screens/easter_egg_screen.hpp"
|
||||
#include "states_screens/dialogs/track_info_dialog.hpp"
|
||||
#include "tracks/track.hpp"
|
||||
#include "tracks/track_manager.hpp"
|
||||
@ -233,7 +235,7 @@ void EasterEggScreen::buildTrackList()
|
||||
if (curr->isArena() || curr->isSoccer()) continue;
|
||||
if (curr->isInternal()) continue;
|
||||
|
||||
if (unlock_manager->getCurrentSlot()->isLocked(curr->getIdent()))
|
||||
if (PlayerManager::get()->getCurrentPlayer()->isLocked(curr->getIdent()))
|
||||
{
|
||||
tracks_widget->addItem( _("Locked : solve active challenges to gain access to more!"),
|
||||
"locked", curr->getScreenshotFile(), LOCKED_BADGE,
|
||||
@ -264,7 +266,7 @@ void EasterEggScreen::buildTrackList()
|
||||
if (curr->isSoccer()) continue;
|
||||
if (curr->isInternal()) continue;
|
||||
|
||||
if (unlock_manager->getCurrentSlot()->isLocked(curr->getIdent()))
|
||||
if (PlayerManager::get()->getCurrentPlayer()->isLocked(curr->getIdent()))
|
||||
{
|
||||
tracks_widget->addItem( _("Locked : solve active challenges to gain access to more!"),
|
||||
"locked", curr->getScreenshotFile(), LOCKED_BADGE,
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "challenges/challenge_data.hpp"
|
||||
#include "challenges/game_slot.hpp"
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "guiengine/engine.hpp"
|
||||
#include "guiengine/scalable_font.hpp"
|
||||
#include "io/file_manager.hpp"
|
||||
@ -144,14 +145,15 @@ void FeatureUnlockedCutScene::loadedFromFile()
|
||||
|
||||
void FeatureUnlockedCutScene::findWhatWasUnlocked(RaceManager::Difficulty difficulty)
|
||||
{
|
||||
int pointsBefore = unlock_manager->getCurrentSlot()->getPoints();
|
||||
int pointsNow = pointsBefore + CHALLENGE_POINTS[difficulty];
|
||||
PlayerProfile *player = PlayerManager::get()->getCurrentPlayer();
|
||||
int points_before = player->getPoints();
|
||||
int points_now = points_before + CHALLENGE_POINTS[difficulty];
|
||||
|
||||
std::vector<std::string> tracks;
|
||||
std::vector<std::string> gps;
|
||||
|
||||
unlock_manager->updateActiveChallengeList();
|
||||
unlock_manager->findWhatWasUnlocked(pointsBefore, pointsNow, tracks, gps);
|
||||
player->computeActive();
|
||||
unlock_manager->findWhatWasUnlocked(points_before, points_now, tracks, gps);
|
||||
|
||||
for (unsigned int i = 0; i < tracks.size(); i++)
|
||||
{
|
||||
@ -409,7 +411,7 @@ void FeatureUnlockedCutScene::tearDown()
|
||||
m_all_kart_models.clearAndDeleteAll();
|
||||
|
||||
// update point count and the list of locked/unlocked stuff
|
||||
unlock_manager->updateActiveChallengeList();
|
||||
PlayerManager::get()->getCurrentPlayer()->computeActive();
|
||||
} // tearDown
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "audio/music_manager.hpp"
|
||||
#include "audio/sfx_manager.hpp"
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "guiengine/engine.hpp"
|
||||
#include "guiengine/scalable_font.hpp"
|
||||
@ -276,20 +277,19 @@ void GrandPrixLose::eventCallback(GUIEngine::Widget* widget,
|
||||
// un-set the GP mode so that after unlocking, it doesn't try to continue the GP
|
||||
race_manager->setMajorMode (RaceManager::MAJOR_MODE_SINGLE);
|
||||
|
||||
if (unlock_manager->getCurrentSlot()->getRecentlyCompletedChallenges().size() > 0)
|
||||
std::vector<const ChallengeData*> unlocked =
|
||||
PlayerManager::get()->getCurrentPlayer()->getRecentlyCompletedChallenges();
|
||||
if (unlocked.size() > 0)
|
||||
{
|
||||
std::vector<const ChallengeData*> unlocked =
|
||||
unlock_manager->getCurrentSlot()->getRecentlyCompletedChallenges();
|
||||
unlock_manager->getCurrentSlot()->clearUnlocked();
|
||||
|
||||
FeatureUnlockedCutScene* scene =
|
||||
FeatureUnlockedCutScene::getInstance();
|
||||
|
||||
assert(unlocked.size() > 0);
|
||||
scene->addTrophy(race_manager->getDifficulty());
|
||||
scene->findWhatWasUnlocked(race_manager->getDifficulty());
|
||||
|
||||
StateManager::get()->replaceTopMostScreen(scene);
|
||||
PlayerManager::get()->getCurrentPlayer()->clearUnlocked();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "audio/music_manager.hpp"
|
||||
#include "audio/sfx_manager.hpp"
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "guiengine/engine.hpp"
|
||||
#include "guiengine/scalable_font.hpp"
|
||||
@ -97,7 +98,7 @@ void GrandPrixWin::loadedFromFile()
|
||||
void GrandPrixWin::init()
|
||||
{
|
||||
Screen::init();
|
||||
if (unlock_manager->getCurrentSlot()->getRecentlyCompletedChallenges().size() > 0)
|
||||
if (PlayerManager::get()->getCurrentPlayer()->getRecentlyCompletedChallenges().size() > 0)
|
||||
{
|
||||
const core::dimension2d<u32>& frame_size = GUIEngine::getDriver()->getCurrentRenderTargetSize();
|
||||
|
||||
@ -405,11 +406,12 @@ void GrandPrixWin::eventCallback(GUIEngine::Widget* widget,
|
||||
// un-set the GP mode so that after unlocking, it doesn't try to continue the GP
|
||||
race_manager->setMajorMode (RaceManager::MAJOR_MODE_SINGLE);
|
||||
|
||||
if (unlock_manager->getCurrentSlot()->getRecentlyCompletedChallenges().size() > 0)
|
||||
if (PlayerManager::get()->getCurrentPlayer()
|
||||
->getRecentlyCompletedChallenges().size() > 0)
|
||||
{
|
||||
std::vector<const ChallengeData*> unlocked =
|
||||
unlock_manager->getCurrentSlot()->getRecentlyCompletedChallenges();
|
||||
unlock_manager->getCurrentSlot()->clearUnlocked();
|
||||
PlayerManager::get()->getCurrentPlayer()->getRecentlyCompletedChallenges();
|
||||
PlayerManager::get()->getCurrentPlayer()->clearUnlocked();
|
||||
|
||||
FeatureUnlockedCutScene* scene =
|
||||
FeatureUnlockedCutScene::getInstance();
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
#include "challenges/game_slot.hpp"
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "guiengine/scalable_font.hpp"
|
||||
#include "guiengine/widgets/label_widget.hpp"
|
||||
@ -362,8 +363,8 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name,
|
||||
}
|
||||
else if (selection == "story")
|
||||
{
|
||||
GameSlot* slot = unlock_manager->getCurrentSlot();
|
||||
if (slot->isFirstTime())
|
||||
PlayerProfile *player = PlayerManager::get()->getCurrentPlayer();
|
||||
if (player->isFirstTime())
|
||||
{
|
||||
StateManager::get()->enterGameState();
|
||||
race_manager->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE);
|
||||
@ -382,7 +383,7 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name,
|
||||
else
|
||||
{
|
||||
const std::string default_kart = UserConfigParams::m_default_kart;
|
||||
if (slot->isLocked(default_kart))
|
||||
if (player->isLocked(default_kart))
|
||||
{
|
||||
KartSelectionScreen *next = OfflineKartSelectionScreen::getInstance();
|
||||
next->setGoToOverworldNext();
|
||||
|
@ -79,7 +79,7 @@ void OptionsScreenPlayers::init()
|
||||
refreshPlayerList();
|
||||
|
||||
ButtonWidget* you = getWidget<ButtonWidget>("playername");
|
||||
unsigned int playerID = unlock_manager->getCurrentSlot()->getPlayerID();
|
||||
unsigned int playerID = PlayerManager::get()->getCurrentPlayer()->getUniqueID();
|
||||
core::stringw player_name = L"-";
|
||||
const PlayerProfile* curr = PlayerManager::get()->getPlayerById(playerID);
|
||||
if(curr)
|
||||
|
@ -24,6 +24,7 @@ using namespace irr;
|
||||
#include <algorithm>
|
||||
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "graphics/camera.hpp"
|
||||
#include "graphics/glwrap.hpp"
|
||||
@ -206,8 +207,8 @@ void RaceGUIOverworld::renderPlayerView(const Camera *camera, float dt)
|
||||
*/
|
||||
void RaceGUIOverworld::drawTrophyPoints()
|
||||
{
|
||||
GameSlot* slot = unlock_manager->getCurrentSlot();
|
||||
const int points = slot->getPoints();
|
||||
PlayerProfile *player = PlayerManager::get()->getCurrentPlayer();
|
||||
const int points = player->getPoints();
|
||||
std::string s = StringUtils::toString(points);
|
||||
core::stringw sw(s.c_str());
|
||||
|
||||
@ -238,7 +239,7 @@ void RaceGUIOverworld::drawTrophyPoints()
|
||||
}
|
||||
|
||||
dest += core::position2di((int)(size*1.5f), 0);
|
||||
std::string easyTrophies = StringUtils::toString(slot->getNumEasyTrophies());
|
||||
std::string easyTrophies = StringUtils::toString(player->getNumEasyTrophies());
|
||||
core::stringw easyTrophiesW(easyTrophies.c_str());
|
||||
if (!m_close_to_a_challenge)
|
||||
{
|
||||
@ -253,7 +254,7 @@ void RaceGUIOverworld::drawTrophyPoints()
|
||||
}
|
||||
|
||||
dest += core::position2di((int)(size*1.5f), 0);
|
||||
std::string mediumTrophies = StringUtils::toString(slot->getNumMediumTrophies());
|
||||
std::string mediumTrophies = StringUtils::toString(player->getNumMediumTrophies());
|
||||
core::stringw mediumTrophiesW(mediumTrophies.c_str());
|
||||
if (!m_close_to_a_challenge)
|
||||
{
|
||||
@ -267,7 +268,7 @@ void RaceGUIOverworld::drawTrophyPoints()
|
||||
NULL, true /* alpha */);
|
||||
}
|
||||
dest += core::position2di((int)(size*1.5f), 0);
|
||||
std::string hardTrophies = StringUtils::toString(slot->getNumHardTrophies());
|
||||
std::string hardTrophies = StringUtils::toString(player->getNumHardTrophies());
|
||||
core::stringw hardTrophiesW(hardTrophies.c_str());
|
||||
if (!m_close_to_a_challenge)
|
||||
{
|
||||
@ -397,7 +398,8 @@ void RaceGUIOverworld::drawGlobalMiniMap()
|
||||
// bool locked = (m_locked_challenges.find(c) != m_locked_challenges.end());
|
||||
int state = (challenges[n].getForceField().m_is_locked ? LOCKED : OPEN);
|
||||
|
||||
const Challenge* c = unlock_manager->getCurrentSlot()->getChallenge(challenges[n].m_challenge_id);
|
||||
const Challenge* c = PlayerManager::get()->getCurrentPlayer()
|
||||
->getChallenge(challenges[n].m_challenge_id);
|
||||
if (c->isSolved(RaceManager::DIFFICULTY_HARD)) state = COMPLETED_HARD;
|
||||
else if (c->isSolved(RaceManager::DIFFICULTY_MEDIUM)) state = COMPLETED_MEDIUM;
|
||||
else if (c->isSolved(RaceManager::DIFFICULTY_EASY)) state = COMPLETED_EASY;
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "audio/music_manager.hpp"
|
||||
#include "audio/sfx_base.hpp"
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "graphics/glwrap.hpp"
|
||||
#include "graphics/material.hpp"
|
||||
#include "guiengine/engine.hpp"
|
||||
@ -130,7 +131,7 @@ void RaceResultGUI::enableAllButtons()
|
||||
|
||||
// If something was unlocked
|
||||
// -------------------------
|
||||
int n = unlock_manager->getCurrentSlot()->getRecentlyCompletedChallenges().size();
|
||||
int n = PlayerManager::get()->getCurrentPlayer()->getRecentlyCompletedChallenges().size();
|
||||
if(n>0)
|
||||
{
|
||||
top->setText(n==1 ? _("You completed a challenge!")
|
||||
@ -185,7 +186,8 @@ void RaceResultGUI::eventCallback(GUIEngine::Widget* widget,
|
||||
// If something was unlocked, the 'continue' button was
|
||||
// actually used to display "Show unlocked feature(s)" text.
|
||||
// ---------------------------------------------------------
|
||||
int n = unlock_manager->getCurrentSlot()->getRecentlyCompletedChallenges().size();
|
||||
int n = PlayerManager::get()->getCurrentPlayer()
|
||||
->getRecentlyCompletedChallenges().size();
|
||||
if(n>0)
|
||||
{
|
||||
if(name=="top")
|
||||
@ -196,7 +198,7 @@ void RaceResultGUI::eventCallback(GUIEngine::Widget* widget,
|
||||
}
|
||||
|
||||
std::vector<const ChallengeData*> unlocked =
|
||||
unlock_manager->getCurrentSlot()->getRecentlyCompletedChallenges();
|
||||
PlayerManager::get()->getCurrentPlayer()->getRecentlyCompletedChallenges();
|
||||
|
||||
bool gameCompleted = false;
|
||||
for (unsigned int n = 0; n < unlocked.size(); n++)
|
||||
@ -208,7 +210,7 @@ void RaceResultGUI::eventCallback(GUIEngine::Widget* widget,
|
||||
}
|
||||
}
|
||||
|
||||
unlock_manager->getCurrentSlot()->clearUnlocked();
|
||||
PlayerManager::get()->getCurrentPlayer()->clearUnlocked();
|
||||
|
||||
if (gameCompleted)
|
||||
{
|
||||
|
@ -15,7 +15,10 @@
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "states_screens/race_setup_screen.hpp"
|
||||
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "guiengine/widgets/dynamic_ribbon_widget.hpp"
|
||||
#include "guiengine/widgets/ribbon_widget.hpp"
|
||||
#include "guiengine/widgets/spinner_widget.hpp"
|
||||
@ -29,8 +32,6 @@
|
||||
#include "states_screens/tracks_screen.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
|
||||
#include "states_screens/race_setup_screen.hpp"
|
||||
|
||||
#define ENABLE_SOCCER_MODE
|
||||
|
||||
const int CONFIG_CODE_NORMAL = 0;
|
||||
@ -178,7 +179,7 @@ void RaceSetupScreen::assignDifficulty()
|
||||
}
|
||||
else if (difficultySelection == "best")
|
||||
{
|
||||
if (unlock_manager->getCurrentSlot()->isLocked("difficulty_best"))
|
||||
if (PlayerManager::get()->getCurrentPlayer()->isLocked("difficulty_best"))
|
||||
{
|
||||
unlock_manager->playLockSound();
|
||||
UserConfigParams::m_difficulty = RaceManager::DIFFICULTY_HARD;
|
||||
@ -229,7 +230,7 @@ void RaceSetupScreen::init()
|
||||
assert( w != NULL );
|
||||
|
||||
if (UserConfigParams::m_difficulty == RaceManager::DIFFICULTY_BEST &&
|
||||
unlock_manager->getCurrentSlot()->isLocked("difficulty_best"))
|
||||
PlayerManager::get()->getCurrentPlayer()->isLocked("difficulty_best"))
|
||||
{
|
||||
w->setSelection(RaceManager::DIFFICULTY_HARD, PLAYER_ID_GAME_MASTER);
|
||||
}
|
||||
@ -267,7 +268,7 @@ void RaceSetupScreen::init()
|
||||
name2 += _("Contains no powerups, so only your driving skills matter!");
|
||||
w2->addItem( name2, IDENT_TTRIAL, RaceManager::getIconOf(RaceManager::MINOR_MODE_TIME_TRIAL));
|
||||
|
||||
if (unlock_manager->getCurrentSlot()->isLocked(IDENT_FTL))
|
||||
if (PlayerManager::get()->getCurrentPlayer()->isLocked(IDENT_FTL))
|
||||
{
|
||||
w2->addItem( _("Locked : solve active challenges to gain access to more!"),
|
||||
"locked", RaceManager::getIconOf(RaceManager::MINOR_MODE_FOLLOW_LEADER), true);
|
||||
@ -343,7 +344,7 @@ void RaceSetupScreen::init()
|
||||
w2->registerHoverListener(m_mode_listener);
|
||||
|
||||
|
||||
if (unlock_manager->getCurrentSlot()->isLocked("difficulty_best"))
|
||||
if (PlayerManager::get()->getCurrentPlayer()->isLocked("difficulty_best"))
|
||||
{
|
||||
RibbonWidget* w = getWidget<RibbonWidget>("difficulty");
|
||||
assert(w != NULL);
|
||||
|
@ -62,7 +62,7 @@ void StoryModeLobbyScreen::init()
|
||||
PlayerProfile *player = PlayerManager::get()->getPlayer(name);
|
||||
if(player)
|
||||
{
|
||||
unlock_manager->setCurrentSlot(player->getUniqueID());
|
||||
PlayerManager::get()->setCurrentPlayer(player);
|
||||
StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance());
|
||||
return;
|
||||
}
|
||||
@ -115,8 +115,8 @@ void StoryModeLobbyScreen::eventCallback(Widget* widget,
|
||||
->getPlayer(list->getSelectionLabel());
|
||||
if(player)
|
||||
{
|
||||
unlock_manager->setCurrentSlot(player->getUniqueID());
|
||||
unlock_manager->updateActiveChallengeList();
|
||||
PlayerManager::get()->setCurrentPlayer(player);
|
||||
player->computeActive();
|
||||
CheckBoxWidget* cb = getWidget<CheckBoxWidget>("rememberme");
|
||||
if (cb->getState())
|
||||
{
|
||||
@ -147,8 +147,8 @@ void StoryModeLobbyScreen::onNewPlayerWithName(const stringw& new_name)
|
||||
PlayerProfile *player = PlayerManager::get()->getPlayer(new_name);
|
||||
if(player)
|
||||
{
|
||||
unlock_manager->setCurrentSlot(player->getUniqueID());
|
||||
unlock_manager->updateActiveChallengeList();
|
||||
PlayerManager::get()->setCurrentPlayer(player);
|
||||
player->computeActive();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -15,7 +15,10 @@
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "states_screens/tracks_screen.hpp"
|
||||
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "guiengine/widget.hpp"
|
||||
#include "guiengine/widgets/dynamic_ribbon_widget.hpp"
|
||||
@ -24,7 +27,6 @@
|
||||
#include "race/grand_prix_data.hpp"
|
||||
#include "race/grand_prix_manager.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
#include "states_screens/tracks_screen.hpp"
|
||||
#include "states_screens/dialogs/gp_info_dialog.hpp"
|
||||
#include "states_screens/dialogs/track_info_dialog.hpp"
|
||||
#include "tracks/track.hpp"
|
||||
@ -235,7 +237,7 @@ void TracksScreen::init()
|
||||
sshot_files.push_back("gui/main_help.png");
|
||||
}
|
||||
|
||||
if (unlock_manager->getCurrentSlot()->isLocked(gp->getId()))
|
||||
if (PlayerManager::get()->getCurrentPlayer()->isLocked(gp->getId()))
|
||||
{
|
||||
gps_widget->addAnimatedItem(_("Locked!"),
|
||||
"locked", sshot_files, 1.5f, LOCKED_BADGE | TROPHY_BADGE,
|
||||
@ -300,7 +302,7 @@ void TracksScreen::buildTrackList()
|
||||
if (curr->isArena() || curr->isSoccer()) continue;
|
||||
if (curr->isInternal()) continue;
|
||||
|
||||
if (unlock_manager->getCurrentSlot()->isLocked(curr->getIdent()))
|
||||
if(PlayerManager::get()->getCurrentPlayer()->isLocked(curr->getIdent()))
|
||||
{
|
||||
tracks_widget->addItem( _("Locked : solve active challenges to gain access to more!"),
|
||||
"locked", curr->getScreenshotFile(), LOCKED_BADGE,
|
||||
@ -331,7 +333,7 @@ void TracksScreen::buildTrackList()
|
||||
if (curr->isSoccer()) continue;
|
||||
if (curr->isInternal()) continue;
|
||||
|
||||
if (unlock_manager->getCurrentSlot()->isLocked(curr->getIdent()))
|
||||
if (PlayerManager::get()->getCurrentPlayer()->isLocked(curr->getIdent()))
|
||||
{
|
||||
tracks_widget->addItem( _("Locked : solve active challenges to gain access to more!"),
|
||||
"locked", curr->getScreenshotFile(), LOCKED_BADGE,
|
||||
|
@ -19,17 +19,11 @@
|
||||
|
||||
#include "tracks/track.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
#include <sstream>
|
||||
#include <IBillboardTextSceneNode.h>
|
||||
|
||||
using namespace irr;
|
||||
|
||||
#include "addons/addon.hpp"
|
||||
#include "audio/music_manager.hpp"
|
||||
#include "challenges/challenge.hpp"
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "config/stk_config.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "graphics/camera.hpp"
|
||||
@ -68,11 +62,19 @@ using namespace irr;
|
||||
#include "utils/string_utils.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
|
||||
#include <ISceneManager.h>
|
||||
#include <IMeshSceneNode.h>
|
||||
#include <IMeshManipulator.h>
|
||||
#include <IBillboardTextSceneNode.h>
|
||||
#include <ILightSceneNode.h>
|
||||
#include <IMeshCache.h>
|
||||
#include <IMeshManipulator.h>
|
||||
#include <IMeshSceneNode.h>
|
||||
#include <ISceneManager.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
#include <sstream>
|
||||
|
||||
using namespace irr;
|
||||
|
||||
|
||||
const float Track::NOHIT = -99999.9f;
|
||||
|
||||
@ -931,8 +933,8 @@ bool Track::loadMainTrack(const XMLNode &root)
|
||||
continue;
|
||||
}
|
||||
|
||||
const int val = challenge->getNumTrophies();
|
||||
bool shown = (unlock_manager->getCurrentSlot()->getPoints() < val);
|
||||
const unsigned int val = challenge->getNumTrophies();
|
||||
bool shown = (PlayerManager::get()->getCurrentPlayer()->getPoints() < val);
|
||||
m_force_fields.push_back(OverworldForceField(xyz, shown, val));
|
||||
|
||||
m_challenges[closest_challenge_id].setForceField(
|
||||
@ -962,7 +964,7 @@ bool Track::loadMainTrack(const XMLNode &root)
|
||||
else if (condition == "allchallenges")
|
||||
{
|
||||
unsigned int unlocked_challenges = 0;
|
||||
GameSlot* slot = unlock_manager->getCurrentSlot();
|
||||
PlayerProfile *player = PlayerManager::get()->getCurrentPlayer();
|
||||
for (unsigned int c=0; c<m_challenges.size(); c++)
|
||||
{
|
||||
if (m_challenges[c].m_challenge_id == "tutorial")
|
||||
@ -970,7 +972,7 @@ bool Track::loadMainTrack(const XMLNode &root)
|
||||
unlocked_challenges++;
|
||||
continue;
|
||||
}
|
||||
if (slot->getChallenge(m_challenges[c].m_challenge_id)
|
||||
if (player->getChallenge(m_challenges[c].m_challenge_id)
|
||||
->isSolvedAtAnyDifficulty())
|
||||
{
|
||||
unlocked_challenges++;
|
||||
@ -994,7 +996,7 @@ bool Track::loadMainTrack(const XMLNode &root)
|
||||
else if (neg_condition == "allchallenges")
|
||||
{
|
||||
unsigned int unlocked_challenges = 0;
|
||||
GameSlot* slot = unlock_manager->getCurrentSlot();
|
||||
PlayerProfile *player = PlayerManager::get()->getCurrentPlayer();
|
||||
for (unsigned int c=0; c<m_challenges.size(); c++)
|
||||
{
|
||||
if (m_challenges[c].m_challenge_id == "tutorial")
|
||||
@ -1002,7 +1004,7 @@ bool Track::loadMainTrack(const XMLNode &root)
|
||||
unlocked_challenges++;
|
||||
continue;
|
||||
}
|
||||
if (slot->getChallenge(m_challenges[c].m_challenge_id)
|
||||
if (player->getChallenge(m_challenges[c].m_challenge_id)
|
||||
->isSolvedAtAnyDifficulty())
|
||||
{
|
||||
unlocked_challenges++;
|
||||
|
Loading…
Reference in New Issue
Block a user