commit
90095882ee
1
.gitignore
vendored
1
.gitignore
vendored
@ -35,6 +35,7 @@ data/.svn
|
||||
*.vcxproj
|
||||
*.vcxproj.filters
|
||||
*.vcxproj.user
|
||||
*~
|
||||
|
||||
packets_log.txt
|
||||
history.dat
|
||||
|
@ -23,6 +23,7 @@ src/challenges/game_slot.cpp
|
||||
src/challenges/unlock_manager.cpp
|
||||
src/config/device_config.cpp
|
||||
src/config/player.cpp
|
||||
src/config/player_manager.cpp
|
||||
src/config/saved_grand_prix.cpp
|
||||
src/config/stk_config.cpp
|
||||
src/config/user_config.cpp
|
||||
@ -101,8 +102,8 @@ src/input/input_manager.cpp
|
||||
src/input/wiimote.cpp
|
||||
src/input/wiimote_manager.cpp
|
||||
src/io/file_manager.cpp
|
||||
src/io/utf_writer.cpp
|
||||
src/io/xml_node.cpp
|
||||
src/io/xml_writer.cpp
|
||||
src/items/attachment.cpp
|
||||
src/items/attachment_manager.cpp
|
||||
src/items/bowling.cpp
|
||||
@ -351,6 +352,7 @@ src/challenges/game_slot.hpp
|
||||
src/challenges/unlock_manager.hpp
|
||||
src/config/device_config.hpp
|
||||
src/config/player.hpp
|
||||
src/config/player_manager.hpp
|
||||
src/config/saved_grand_prix.hpp
|
||||
src/config/stk_config.hpp
|
||||
src/config/user_config.hpp
|
||||
@ -429,8 +431,8 @@ src/input/input_manager.hpp
|
||||
src/input/wiimote.hpp
|
||||
src/input/wiimote_manager.hpp
|
||||
src/io/file_manager.hpp
|
||||
src/io/utf_writer.hpp
|
||||
src/io/xml_node.hpp
|
||||
src/io/xml_writer.hpp
|
||||
src/items/attachment.hpp
|
||||
src/items/attachment_manager.hpp
|
||||
src/items/attachment_plugin.hpp
|
||||
|
@ -22,14 +22,14 @@
|
||||
#include "achievements/achievement_info.hpp"
|
||||
#include "guiengine/dialog_queue.hpp"
|
||||
#include "states_screens/dialogs/notification_dialog.hpp"
|
||||
#include "io/xml_writer.hpp"
|
||||
#include "utils/log.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
// ============================================================================
|
||||
Achievement::Achievement(const AchievementInfo * info)
|
||||
|
@ -20,8 +20,6 @@
|
||||
|
||||
#include "utils/log.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
#include "io/xml_writer.hpp"
|
||||
|
||||
|
||||
#include <sstream>
|
||||
#include <stdlib.h>
|
||||
|
@ -18,14 +18,13 @@
|
||||
|
||||
#include "achievements/achievements_manager.hpp"
|
||||
|
||||
#include "config/player.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "io/file_manager.hpp"
|
||||
#include "online/current_user.hpp"
|
||||
#include "utils/log.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
#include "io/file_manager.hpp"
|
||||
#include "io/xml_writer.hpp"
|
||||
#include "config/player.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "online/current_user.hpp"
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
|
||||
#include <sstream>
|
||||
#include <stdlib.h>
|
||||
@ -139,7 +138,7 @@ void AchievementsManager::parseUserConfigFile()
|
||||
} // load
|
||||
|
||||
|
||||
AchievementsSlot * AchievementsManager::createNewSlot(std::string id, bool online)
|
||||
AchievementsSlot * AchievementsManager::createNewSlot(unsigned int id, bool online)
|
||||
{
|
||||
AchievementsSlot* slot = new AchievementsSlot(id, online);
|
||||
m_slots.push_back(slot);
|
||||
@ -156,12 +155,12 @@ void AchievementsManager::createSlotsIfNeeded()
|
||||
bool something_changed = false;
|
||||
|
||||
// make sure all players have at least one game slot associated
|
||||
PtrVector<PlayerProfile>& players = UserConfigParams::m_all_players;
|
||||
for (unsigned int n=0; n<players.size(); n++)
|
||||
for (unsigned int i=0; i<PlayerManager::get()->getNumPlayers(); i++)
|
||||
{
|
||||
if (getSlot(players[n].getUniqueID(), false) == NULL )
|
||||
const PlayerProfile *player = PlayerManager::get()->getPlayer(i);
|
||||
if (getSlot(player->getUniqueID(), false) == NULL )
|
||||
{
|
||||
createNewSlot(players[n].getUniqueID(), false);
|
||||
createNewSlot(player->getUniqueID(), false);
|
||||
something_changed = true;
|
||||
}
|
||||
}
|
||||
@ -208,7 +207,7 @@ void AchievementsManager::onRaceEnd()
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
AchievementsSlot * AchievementsManager::getSlot(const std::string & id, bool online)
|
||||
AchievementsSlot * AchievementsManager::getSlot(unsigned int id, bool online)
|
||||
{
|
||||
for(unsigned int i = 0; i < m_slots.size(); i++)
|
||||
{
|
||||
@ -225,19 +224,19 @@ void AchievementsManager::updateCurrentPlayer()
|
||||
{
|
||||
if(Online::CurrentUser::get()->isRegisteredUser())
|
||||
{
|
||||
m_active_slot = getSlot(StringUtils::toString(Online::CurrentUser::get()->getID()), true);
|
||||
m_active_slot = getSlot(Online::CurrentUser::get()->getID(), true);
|
||||
if(m_active_slot == NULL)
|
||||
{
|
||||
m_active_slot = createNewSlot(StringUtils::toString(Online::CurrentUser::get()->getID()), true);
|
||||
m_active_slot = createNewSlot(Online::CurrentUser::get()->getID(), true);
|
||||
save();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_active_slot = getSlot(unlock_manager->getCurrentPlayer()->getUniqueID(), false);
|
||||
m_active_slot = getSlot(PlayerManager::get()->getCurrentPlayer()->getUniqueID(), false);
|
||||
if(m_active_slot == NULL)
|
||||
{
|
||||
m_active_slot = createNewSlot(unlock_manager->getCurrentPlayer()->getUniqueID(), false);
|
||||
m_active_slot = createNewSlot(PlayerManager::get()->getCurrentPlayer()->getUniqueID(), false);
|
||||
save();
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ private :
|
||||
std::map<uint32_t, AchievementInfo *> m_achievements_info;
|
||||
AchievementsManager ();
|
||||
~AchievementsManager ();
|
||||
AchievementsSlot * createNewSlot(std::string id, bool online);
|
||||
AchievementsSlot * createNewSlot(unsigned int id, bool online);
|
||||
void parseAssetFile();
|
||||
void parseUserConfigFile();
|
||||
|
||||
@ -59,7 +59,7 @@ public:
|
||||
void onRaceEnd();
|
||||
void updateCurrentPlayer();
|
||||
AchievementsSlot * getActive() const { return m_active_slot; }
|
||||
AchievementsSlot * getSlot(const std::string & id, bool online);
|
||||
AchievementsSlot * getSlot(unsigned int id, bool online);
|
||||
void createSlotsIfNeeded();
|
||||
AchievementInfo * getAchievementInfo(uint32_t id);
|
||||
const std::map<uint32_t, AchievementInfo *> & getAllInfo() { return m_achievements_info;}
|
||||
|
@ -24,12 +24,13 @@
|
||||
#include "utils/log.hpp"
|
||||
#include "utils/ptr_vector.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
#include "io/xml_writer.hpp"
|
||||
#include "online/current_user.hpp"
|
||||
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
// ============================================================================
|
||||
AchievementsSlot::AchievementsSlot(const XMLNode * input)
|
||||
{
|
||||
@ -62,11 +63,11 @@ AchievementsSlot::AchievementsSlot(const XMLNode * input)
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
AchievementsSlot::AchievementsSlot(std::string id, bool online)
|
||||
AchievementsSlot::AchievementsSlot(unsigned int id, bool online)
|
||||
{
|
||||
m_valid = true;
|
||||
m_valid = true;
|
||||
m_online = online;
|
||||
m_id = id;
|
||||
m_id = id;
|
||||
|
||||
createFreshSlot();
|
||||
}
|
||||
@ -111,7 +112,7 @@ void AchievementsSlot::createFreshSlot()
|
||||
// ============================================================================
|
||||
void AchievementsSlot::save(std::ofstream & out)
|
||||
{
|
||||
out << " <slot user_id=\"" << m_id.c_str()
|
||||
out << " <slot user_id=\"" << m_id
|
||||
<< "\" online=\"" << StringUtils::toString(m_online)
|
||||
<< "\"> \n";
|
||||
std::map<uint32_t, Achievement*>::const_iterator i;
|
||||
|
@ -33,9 +33,9 @@ class AchievementsSlot
|
||||
{
|
||||
private:
|
||||
std::map<uint32_t, Achievement *> m_achievements;
|
||||
bool m_online;
|
||||
bool m_valid;
|
||||
std::string m_id;
|
||||
bool m_online;
|
||||
bool m_valid;
|
||||
unsigned int m_id;
|
||||
|
||||
void createFreshSlot();
|
||||
void deleteAchievements();
|
||||
@ -48,14 +48,14 @@ private:
|
||||
|
||||
public :
|
||||
AchievementsSlot(const XMLNode * input);
|
||||
AchievementsSlot(std::string id, bool online);
|
||||
AchievementsSlot(unsigned int id, bool online);
|
||||
~AchievementsSlot();
|
||||
bool isValid() const { return m_valid;}
|
||||
void save(std::ofstream & out);
|
||||
bool isOnline() const {return m_online;}
|
||||
void sync(const std::vector<uint32_t> & achieved_ids);
|
||||
void onRaceEnd();
|
||||
const std::string & getID() const {return m_id;}
|
||||
unsigned int getID() const {return m_id;}
|
||||
const std::map<uint32_t, Achievement *> & getAllAchievements() {return m_achievements;}
|
||||
Achievement * getAchievement(uint32_t id);
|
||||
};
|
||||
|
@ -18,11 +18,9 @@
|
||||
|
||||
#include "challenges/challenge.hpp"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include "challenges/challenge_data.hpp"
|
||||
#include "io/utf_writer.hpp"
|
||||
#include "io/xml_node.hpp"
|
||||
#include "io/xml_writer.hpp"
|
||||
#include "karts/kart_properties_manager.hpp"
|
||||
#include "karts/kart_properties.hpp"
|
||||
#include "race/grand_prix_manager.hpp"
|
||||
@ -90,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,7 +22,27 @@
|
||||
#include "challenges/challenge.hpp"
|
||||
#include "challenges/challenge_data.hpp"
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
#include "io/xml_writer.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "io/utf_writer.hpp"
|
||||
#include "io/xml_node.hpp"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
GameSlot::GameSlot(const XMLNode *node)
|
||||
{
|
||||
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("first-time", &m_first_time);
|
||||
} // if node
|
||||
|
||||
} // GameSlot
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
GameSlot::~GameSlot()
|
||||
@ -175,7 +195,7 @@ void GameSlot::unlockFeature(Challenge* c, RaceManager::Difficulty d,
|
||||
if (p == m_locked_features.end())
|
||||
{
|
||||
c->setSolved(d);
|
||||
if(do_save) unlock_manager->save();
|
||||
if(do_save) PlayerManager::get()->save();
|
||||
return;
|
||||
}
|
||||
m_locked_features.erase(p);
|
||||
@ -186,7 +206,7 @@ void GameSlot::unlockFeature(Challenge* c, RaceManager::Difficulty d,
|
||||
c->setSolved(d); // reset isActive flag
|
||||
|
||||
// Save the new unlock information
|
||||
if (do_save) unlock_manager->save();
|
||||
if (do_save) PlayerManager::get()->save();
|
||||
} // unlockFeature
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -235,13 +255,13 @@ 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.c_str()
|
||||
<< "\" kart=\"" << m_kart_ident.c_str()
|
||||
<< "\" firstTime=\"" << StringUtils::toString(m_first_time)
|
||||
<< "\"> <!-- " << name.c_str() << " -->\n";
|
||||
out << " <game-slot playerID=\"" << m_player_unique_id
|
||||
<< "\" first-time=\"" << 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++)
|
||||
@ -249,5 +269,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 };
|
||||
|
||||
@ -40,13 +43,11 @@ const int CHALLENGE_POINTS[] = { 8, 9, 10 };
|
||||
|
||||
class GameSlot
|
||||
{
|
||||
std::string m_kart_ident;
|
||||
|
||||
/** Profile names can change, so rather than try to make sure all renames
|
||||
* are done everywhere, assign a unique ID to each profiler.
|
||||
* Will save much headaches.
|
||||
*/
|
||||
std::string m_player_unique_id;
|
||||
unsigned int m_player_unique_id;
|
||||
|
||||
/** Contains whether each feature of the challenge is locked or unlocked */
|
||||
std::map<std::string, bool> m_locked_features;
|
||||
@ -63,8 +64,6 @@ class GameSlot
|
||||
|
||||
friend class UnlockManager;
|
||||
|
||||
void computeActive();
|
||||
|
||||
int m_points;
|
||||
|
||||
/** Set to false after the initial stuff (intro, select kart, etc.) */
|
||||
@ -76,50 +75,28 @@ 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(std::string 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();
|
||||
|
||||
const std::string& getPlayerID() const { return m_player_unique_id; }
|
||||
const std::string& getKartIdent () const { return m_kart_ident; }
|
||||
void setKartIdent(const std::string& kart_ident)
|
||||
{
|
||||
m_kart_ident = 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);
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** 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; }
|
||||
// ------------------------------------------------------------------------
|
||||
|
@ -18,26 +18,27 @@
|
||||
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <iostream>
|
||||
|
||||
#include "achievements/achievements_manager.hpp"
|
||||
#include "audio/sfx_base.hpp"
|
||||
#include "audio/sfx_manager.hpp"
|
||||
#include "config/player.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "challenges/challenge_data.hpp"
|
||||
#include "config/player.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "io/file_manager.hpp"
|
||||
#include "io/xml_writer.hpp"
|
||||
#include "karts/kart_properties_manager.hpp"
|
||||
#include "race/race_manager.hpp"
|
||||
#include "tracks/track_manager.hpp"
|
||||
#include "utils/log.hpp"
|
||||
#include "utils/string_utils.hpp"
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <iostream>
|
||||
|
||||
UnlockManager* unlock_manager=0;
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@ -48,8 +49,6 @@ UnlockManager::UnlockManager()
|
||||
// in main).
|
||||
unlock_manager = this;
|
||||
|
||||
m_current_game_slot = "";
|
||||
|
||||
m_locked_sound = sfx_manager->createSoundSource("locked");
|
||||
|
||||
|
||||
@ -77,8 +76,6 @@ UnlockManager::UnlockManager()
|
||||
|
||||
// Hard coded challenges can be added here.
|
||||
|
||||
load();
|
||||
|
||||
} // UnlockManager
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -86,23 +83,12 @@ UnlockManager::UnlockManager()
|
||||
*/
|
||||
UnlockManager::~UnlockManager()
|
||||
{
|
||||
save();
|
||||
|
||||
for(AllChallengesType::iterator i =m_all_challenges.begin();
|
||||
i!=m_all_challenges.end(); i++)
|
||||
{
|
||||
delete i->second;
|
||||
}
|
||||
|
||||
|
||||
std::map<std::string, GameSlot*>::iterator it;
|
||||
for (it = m_game_slots.begin(); it != m_game_slots.end(); it++)
|
||||
{
|
||||
delete it->second;
|
||||
}
|
||||
|
||||
// sfx_manager is destroyed before UnlockManager is, so SFX will be already deleted
|
||||
// sfx_manager->deleteSFX(m_locked_sound);
|
||||
} // ~UnlockManager
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -155,7 +141,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.",
|
||||
@ -202,189 +190,29 @@ const ChallengeData* UnlockManager::getChallenge(const std::string& id)
|
||||
} // getChallenge
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** This is called from user_config when reading the config file
|
||||
*/
|
||||
void UnlockManager::load()
|
||||
{
|
||||
const std::string filename=file_manager->getUserConfigFile("challenges.xml");
|
||||
XMLNode* root = file_manager->createXMLTree(filename);
|
||||
if(!root || root->getName() != "challenges")
|
||||
{
|
||||
Log::info("unlock_manager", "Challenge file '%s' will be created.",
|
||||
filename.c_str());
|
||||
createSlotsIfNeeded();
|
||||
save();
|
||||
|
||||
if (root) delete root;
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<XMLNode*> xml_game_slots;
|
||||
root->getNodes("gameslot", xml_game_slots);
|
||||
for (unsigned int n=0; n<xml_game_slots.size(); n++)
|
||||
{
|
||||
std::string player_id;
|
||||
if (!xml_game_slots[n]->get("playerID", &player_id))
|
||||
{
|
||||
Log::warn("unlock_manager", "Found game slot without "
|
||||
"a player ID attached. Discarding it.");
|
||||
continue;
|
||||
}
|
||||
|
||||
GameSlot* slot = new GameSlot(player_id);
|
||||
|
||||
std::string kart_id;
|
||||
xml_game_slots[n]->get("kart", &kart_id);
|
||||
slot->setKartIdent(kart_id);
|
||||
|
||||
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++)
|
||||
{
|
||||
ChallengeData* curr = i->second;
|
||||
Challenge* state = new Challenge(curr);
|
||||
|
||||
slot->m_challenges_state[curr->getId()] = state;
|
||||
state->load(xml_game_slots[n]);
|
||||
}
|
||||
slot->computeActive();
|
||||
}
|
||||
|
||||
bool something_changed = createSlotsIfNeeded();
|
||||
if (something_changed) save();
|
||||
|
||||
delete root;
|
||||
} // load
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void UnlockManager::save()
|
||||
{
|
||||
std::string filename = file_manager->getUserConfigFile("challenges.xml");
|
||||
|
||||
std::ofstream challenge_file(filename.c_str(), std::ios::out);
|
||||
|
||||
if (!challenge_file.is_open())
|
||||
{
|
||||
Log::warn("unlock_manager",
|
||||
"Failed to open '%s' for writing, challenges won't be saved\n",
|
||||
filename.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
challenge_file << "<?xml version=\"1.0\"?>\n";
|
||||
challenge_file << "<challenges>\n";
|
||||
|
||||
std::map<std::string, GameSlot*>::iterator it;
|
||||
for (it = m_game_slots.begin(); it != m_game_slots.end(); it++)
|
||||
{
|
||||
std::string name = "unknown player";
|
||||
for (unsigned int i = 0; i < UserConfigParams::m_all_players.size(); i++)
|
||||
{
|
||||
if (UserConfigParams::m_all_players[i].getUniqueID() == it->second->getPlayerID())
|
||||
{
|
||||
name = core::stringc(UserConfigParams::m_all_players[i].getName().c_str()).c_str();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
it->second->save(challenge_file, name);
|
||||
}
|
||||
|
||||
challenge_file << "</challenges>\n\n";
|
||||
challenge_file.close();
|
||||
} // save
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Creates a gameslot for players that don't have one yet
|
||||
* \return true if any were created
|
||||
/** 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.
|
||||
*/
|
||||
bool UnlockManager::createSlotsIfNeeded()
|
||||
GameSlot *UnlockManager::createGameSlot(const XMLNode *node)
|
||||
{
|
||||
bool something_changed = false;
|
||||
|
||||
// make sure all players have at least one game slot associated
|
||||
PtrVector<PlayerProfile>& players = UserConfigParams::m_all_players;
|
||||
for (unsigned int n=0; n<players.size(); n++)
|
||||
GameSlot *slot = new GameSlot(node);
|
||||
|
||||
for(AllChallengesType::iterator i = m_all_challenges.begin();
|
||||
i!=m_all_challenges.end(); i++)
|
||||
{
|
||||
bool exists = false;
|
||||
|
||||
std::map<std::string, GameSlot*>::iterator it;
|
||||
for (it = m_game_slots.begin(); it != m_game_slots.end(); it++)
|
||||
{
|
||||
GameSlot* curr_slot = it->second;
|
||||
if (curr_slot->getPlayerID() == players[n].getUniqueID())
|
||||
{
|
||||
exists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!exists)
|
||||
{
|
||||
GameSlot* slot = new GameSlot(players[n].getUniqueID());
|
||||
for(AllChallengesType::iterator i = m_all_challenges.begin();
|
||||
i!=m_all_challenges.end(); i++)
|
||||
{
|
||||
ChallengeData* cd = i->second;
|
||||
slot->m_challenges_state[cd->getId()] = new Challenge(cd);
|
||||
}
|
||||
slot->computeActive();
|
||||
|
||||
m_game_slots[players[n].getUniqueID()] = slot;
|
||||
|
||||
something_changed = true;
|
||||
}
|
||||
ChallengeData* cd = i->second;
|
||||
Challenge *challenge = new Challenge(cd);
|
||||
if(node)
|
||||
challenge->load(node);
|
||||
slot->m_challenges_state[cd->getId()] = challenge;
|
||||
}
|
||||
|
||||
return something_changed;
|
||||
} // UnlockManager::createSlotsIfNeeded
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Removes gameslots that refer to a non-existing player.
|
||||
* \return true if any were removed
|
||||
*/
|
||||
bool UnlockManager::deleteSlotsIfNeeded()
|
||||
{
|
||||
bool changed = false;
|
||||
std::map<std::string, GameSlot*>::iterator it = m_game_slots.begin();
|
||||
while (it != m_game_slots.end())
|
||||
{
|
||||
bool found = false;
|
||||
const int playerAmount = UserConfigParams::m_all_players.size();
|
||||
for (int i = 0; i < playerAmount; i++)
|
||||
{
|
||||
if (it->second->getPlayerID() ==
|
||||
UserConfigParams::m_all_players[i].getUniqueID())
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
} // for players
|
||||
|
||||
if (!found)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("Deleting gameslot %s, no player found.\n",
|
||||
it->second->getPlayerID().c_str());
|
||||
#endif
|
||||
// Iterators aren't invalidated this way
|
||||
m_game_slots.erase(it++);
|
||||
changed = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
++it;
|
||||
}
|
||||
} // for gameslots
|
||||
|
||||
return changed;
|
||||
} // UnlockManager::deleteSlotsIfNeeded
|
||||
slot->computeActive();
|
||||
return slot;
|
||||
} // createGameSlot
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void UnlockManager::playLockSound() const
|
||||
@ -404,34 +232,6 @@ bool UnlockManager::isSupportedVersion(const ChallengeData &challenge)
|
||||
} // isSupportedVersion
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
PlayerProfile* UnlockManager::getCurrentPlayer()
|
||||
{
|
||||
PtrVector<PlayerProfile>& players = UserConfigParams::m_all_players;
|
||||
for (unsigned int n=0; n<players.size(); n++)
|
||||
{
|
||||
if (players[n].getUniqueID() == m_current_game_slot) return players.get(n);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void UnlockManager::updateActiveChallengeList()
|
||||
{
|
||||
getCurrentSlot()->computeActive();
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void UnlockManager::setCurrentSlot(std::string slotid)
|
||||
{
|
||||
m_current_game_slot = slotid;
|
||||
AchievementsManager::get()->updateCurrentPlayer();
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void UnlockManager::findWhatWasUnlocked(int points_before, int points_now,
|
||||
@ -447,12 +247,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());
|
||||
}
|
||||
}
|
||||
|
@ -43,18 +43,11 @@ class UnlockManager : public NoCopy
|
||||
private:
|
||||
SFXBase *m_locked_sound;
|
||||
|
||||
void load ();
|
||||
|
||||
typedef std::map<std::string, ChallengeData*> AllChallengesType;
|
||||
AllChallengesType m_all_challenges;
|
||||
|
||||
std::map<std::string, GameSlot*> m_game_slots;
|
||||
|
||||
void readAllChallengesInDirs(const std::vector<std::string>* all_dirs);
|
||||
|
||||
/** ID of the active player */
|
||||
std::string m_current_game_slot;
|
||||
|
||||
friend class GameSlot;
|
||||
|
||||
public:
|
||||
@ -62,9 +55,6 @@ public:
|
||||
~UnlockManager ();
|
||||
void addOrFreeChallenge(ChallengeData *c);
|
||||
void addChallenge (const std::string& filename);
|
||||
void save ();
|
||||
bool createSlotsIfNeeded();
|
||||
bool deleteSlotsIfNeeded();
|
||||
|
||||
const ChallengeData *getChallenge (const std::string& id);
|
||||
|
||||
@ -73,23 +63,11 @@ public:
|
||||
/** Eye- (or rather ear-) candy. Play a sound when user tries to access a locked area */
|
||||
void playLockSound() const;
|
||||
|
||||
const std::string& 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(std::string 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
|
||||
|
||||
|
@ -16,60 +16,74 @@
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#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"
|
||||
#include "utils/string_utils.hpp"
|
||||
|
||||
#include <sstream>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "config/player.hpp"
|
||||
#include "utils/string_utils.hpp"
|
||||
#include <sstream>
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
PlayerProfile::PlayerProfile(const core::stringw& name) :
|
||||
m_player_group("Player", "Represents one human player"),
|
||||
m_name(name, "name", &m_player_group),
|
||||
m_is_guest_account(false, "guest", &m_player_group),
|
||||
m_use_frequency(0, "use_frequency", &m_player_group),
|
||||
m_unique_id("", "unique_id", &m_player_group)
|
||||
/** Constructor to create a new player that didn't exist before.
|
||||
* \param name Name of the player.
|
||||
* \param is_guest True if this is a guest account.
|
||||
*/
|
||||
PlayerProfile::PlayerProfile(const core::stringw& name, bool is_guest)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
m_magic_number = 0xABCD1234;
|
||||
#endif
|
||||
int64_t unique_id = generateUniqueId(core::stringc(name.c_str()).c_str());
|
||||
m_name = name;
|
||||
m_is_guest_account = is_guest;
|
||||
m_use_frequency = is_guest ? -1 : 0;
|
||||
m_unique_id = PlayerManager::get()->getUniqueId();
|
||||
m_game_slot = unlock_manager->createGameSlot();
|
||||
|
||||
std::ostringstream to_string;
|
||||
to_string << std::hex << unique_id;
|
||||
m_unique_id = to_string.str();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
PlayerProfile::PlayerProfile(const XMLNode* node) :
|
||||
m_player_group("Player", "Represents one human player"),
|
||||
m_name("-", "name", &m_player_group),
|
||||
m_is_guest_account(false, "guest", &m_player_group),
|
||||
m_use_frequency(0, "use_frequency", &m_player_group),
|
||||
m_unique_id("", "unique_id", &m_player_group)
|
||||
{
|
||||
//m_player_group.findYourDataInAChildOf(node);
|
||||
m_name.findYourDataInAnAttributeOf(node);
|
||||
m_is_guest_account.findYourDataInAnAttributeOf(node);
|
||||
m_use_frequency.findYourDataInAnAttributeOf(node);
|
||||
m_unique_id.findYourDataInAnAttributeOf(node);
|
||||
|
||||
if ((std::string)m_unique_id == "")
|
||||
{
|
||||
fprintf(stderr, "** WARNING: Player has no unique ID, probably it is from an older STK version\n");
|
||||
int64_t unique_id = generateUniqueId(core::stringc(m_name.c_str()).c_str());
|
||||
std::ostringstream tostring;
|
||||
tostring << std::hex << unique_id;
|
||||
m_unique_id = tostring.str();
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
m_magic_number = 0xABCD1234;
|
||||
#endif
|
||||
} // PlayerProfile
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/** Constructor to deserialize a player that was saved to a XML file.
|
||||
* \param node The XML node representing this player.
|
||||
*/
|
||||
PlayerProfile::PlayerProfile(const XMLNode* node)
|
||||
{
|
||||
node->get("name", &m_name );
|
||||
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
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/** Writes the data for this player to the specified UTFWriter.
|
||||
* \param out The utf writer to write the data to.
|
||||
*/
|
||||
void PlayerProfile::save(UTFWriter &out)
|
||||
{
|
||||
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
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/** Increments how often that account was used. Guest accounts are not counted.
|
||||
*/
|
||||
void PlayerProfile::incrementUseFrequency()
|
||||
{
|
||||
if (m_is_guest_account) m_use_frequency = -1;
|
||||
@ -77,16 +91,19 @@ void PlayerProfile::incrementUseFrequency()
|
||||
} // incrementUseFrequency
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
int64_t PlayerProfile::generateUniqueId(const char* player_name)
|
||||
/** Comparison used to sort players.
|
||||
*/
|
||||
bool PlayerProfile::operator<(const PlayerProfile &other)
|
||||
{
|
||||
// First create a simple hash based on he player name
|
||||
int hash = 0;
|
||||
for (int n=0; player_name[n] != 0; n++)
|
||||
{
|
||||
hash += (hash << (hash & 0xF)) ^ player_name[n];
|
||||
}
|
||||
return m_use_frequency < other.m_use_frequency;
|
||||
} // operator<
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
/** \brief Needed for toggling sort order **/
|
||||
bool PlayerProfile::operator>(const PlayerProfile &other)
|
||||
{
|
||||
return m_use_frequency > other.m_use_frequency;
|
||||
} // operator>
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
return ((int64_t)(StkTime::getTimeSinceEpoch()) << 32) |
|
||||
((rand() << 16) & 0xFFFF0000) |
|
||||
hash;
|
||||
} // generateUniqueId
|
||||
|
@ -19,13 +19,20 @@
|
||||
#ifndef HEADER_PLAYER_HPP
|
||||
#define HEADER_PLAYER_HPP
|
||||
|
||||
#include <string>
|
||||
#include "challenges/game_slot.hpp"
|
||||
|
||||
#include "config/user_config.hpp"
|
||||
#include "utils/no_copy.hpp"
|
||||
#include "utils/types.hpp"
|
||||
|
||||
#include <irrString.h>
|
||||
using namespace irr;
|
||||
|
||||
#include <string>
|
||||
|
||||
class GameSlot;
|
||||
class UTFWriter;
|
||||
|
||||
/**
|
||||
* \brief Class for managing player profiles (name, control configuration, etc.)
|
||||
* A list of all possible players is stored as PlayerProfiles in the user config.
|
||||
@ -34,93 +41,155 @@ using namespace irr;
|
||||
*/
|
||||
class PlayerProfile : public NoCopy
|
||||
{
|
||||
protected:
|
||||
private:
|
||||
|
||||
/**
|
||||
* For saving to config file.
|
||||
* WARNING : m_player_group has to be declared before the other userconfigparams!
|
||||
*/
|
||||
GroupUserConfigParam m_player_group;
|
||||
/** The name of the player (wide string, so it can be in native
|
||||
* language). */
|
||||
core::stringw m_name;
|
||||
|
||||
WStringUserConfigParam m_name;
|
||||
|
||||
BoolUserConfigParam m_is_guest_account;
|
||||
/** True if this account is a guest account. */
|
||||
bool m_is_guest_account;
|
||||
|
||||
#ifdef DEBUG
|
||||
unsigned int m_magic_number;
|
||||
#endif
|
||||
|
||||
IntUserConfigParam m_use_frequency;
|
||||
/** Counts how often this player was used (always -1 for guests). */
|
||||
int m_use_frequency;
|
||||
|
||||
/** Profile names can change, so rather than try to make sure all renames are done everywhere,
|
||||
* assign a unique ID to each profiler. Will save much headaches.
|
||||
*/
|
||||
StringUserConfigParam m_unique_id;
|
||||
/** A unique number for this player, used to link it to challenges etc. */
|
||||
unsigned int m_unique_id;
|
||||
|
||||
int64_t generateUniqueId(const char* playerName);
|
||||
/** True if this is the default (last used) player. */
|
||||
bool m_is_default;
|
||||
|
||||
/** The complete challenge state. */
|
||||
GameSlot *m_game_slot;
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor to create a new player that didn't exist before
|
||||
*/
|
||||
PlayerProfile(const core::stringw& name);
|
||||
PlayerProfile(const core::stringw& name, bool is_guest = false);
|
||||
|
||||
/**
|
||||
* Constructor to deserialize a player that was saved to a XML file
|
||||
* (...UserConfigParam classes will automagically take care of serializing all
|
||||
* create players to the user's config file)
|
||||
*/
|
||||
PlayerProfile(const XMLNode* node);
|
||||
|
||||
void save(UTFWriter &out);
|
||||
void incrementUseFrequency();
|
||||
bool operator<(const PlayerProfile &other);
|
||||
bool operator>(const PlayerProfile &other);
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
~PlayerProfile()
|
||||
{
|
||||
#ifdef DEBUG
|
||||
m_magic_number = 0xDEADBEEF;
|
||||
#endif
|
||||
}
|
||||
} // ~PlayerProfile
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Sets the name of this player. */
|
||||
void setName(const core::stringw& name)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
assert(m_magic_number == 0xABCD1234);
|
||||
#endif
|
||||
m_name = name;
|
||||
}
|
||||
} // setName
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the name of this player. */
|
||||
core::stringw getName() const
|
||||
{
|
||||
#ifdef DEBUG
|
||||
assert(m_magic_number == 0xABCD1234);
|
||||
#endif
|
||||
return m_name.c_str();
|
||||
}
|
||||
} // getName
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns true if this player is a guest account. */
|
||||
bool isGuestAccount() const
|
||||
{
|
||||
#ifdef DEBUG
|
||||
assert(m_magic_number == 0xABCD1234);
|
||||
#endif
|
||||
return m_is_guest_account;
|
||||
}
|
||||
} // isGuestAccount
|
||||
|
||||
int getUseFrequency() const
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the unique id of this player. */
|
||||
unsigned int getUniqueID() const { return m_unique_id; }
|
||||
// -----------------------------------------------------------------------
|
||||
/** 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; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returnes if the feature (kart, track) is locked. */
|
||||
bool isLocked(const std::string &feature) const
|
||||
{
|
||||
if (m_is_guest_account) return -1;
|
||||
else return m_use_frequency;
|
||||
}
|
||||
|
||||
|
||||
void incrementUseFrequency();
|
||||
|
||||
// please do NOT try to optimise this to return a reference, I don't know why,
|
||||
// maybe compiler bug, but hell breaks loose when you do that
|
||||
std::string getUniqueID() const
|
||||
return m_game_slot->isLocked(feature);
|
||||
} // isLocked
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns all active challenges. */
|
||||
void computeActive() { m_game_slot->computeActive(); }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the list of recently completed challenges. */
|
||||
std::vector<const ChallengeData*> getRecentlyCompletedChallenges()
|
||||
{
|
||||
return m_unique_id;
|
||||
}
|
||||
};
|
||||
return m_game_slot->getRecentlyCompletedChallenges();
|
||||
} // getRecently Completed Challenges
|
||||
// ------------------------------------------------------------------------
|
||||
/** Sets the currently active challenge. */
|
||||
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(); }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Callback when a GP is finished (to test if a challenge was
|
||||
* fulfilled). */
|
||||
void grandPrixFinished() { m_game_slot->grandPrixFinished(); }
|
||||
// ------------------------------------------------------------------------
|
||||
unsigned int getPoints() const { return m_game_slot->getPoints(); }
|
||||
// ------------------------------------------------------------------------
|
||||
void setFirstTime(bool b) { m_game_slot->setFirstTime(b); }
|
||||
// ------------------------------------------------------------------------
|
||||
bool isFirstTime() const { return m_game_slot->isFirstTime(); }
|
||||
// ------------------------------------------------------------------------
|
||||
void clearUnlocked() { m_game_slot->clearUnlocked(); }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the current challenge for this player. */
|
||||
const Challenge* getCurrentChallenge() const
|
||||
{
|
||||
return m_game_slot->getCurrentChallenge();
|
||||
} // getCurrentChallenge
|
||||
// ------------------------------------------------------------------------
|
||||
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
|
||||
|
||||
}; // class PlayerProfile
|
||||
|
||||
#endif
|
||||
|
||||
|
226
src/config/player_manager.cpp
Normal file
226
src/config/player_manager.cpp
Normal file
@ -0,0 +1,226 @@
|
||||
//
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2012-2014 Joerg Henrichs
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "config/player_manager.hpp"
|
||||
|
||||
#include "achievements/achievements_manager.hpp"
|
||||
#include "config/player.hpp"
|
||||
#include "io/file_manager.hpp"
|
||||
#include "io/utf_writer.hpp"
|
||||
#include "io/xml_node.hpp"
|
||||
#include "utils/log.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
|
||||
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()
|
||||
{
|
||||
m_current_player = NULL;
|
||||
load();
|
||||
} // PlayerManager
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Destructor.
|
||||
*/
|
||||
PlayerManager::~PlayerManager()
|
||||
{
|
||||
save();
|
||||
} // ~PlayerManager
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void PlayerManager::load()
|
||||
{
|
||||
std::string filename = file_manager->getUserConfigFile("players.xml");
|
||||
|
||||
const XMLNode *players = file_manager->createXMLTree(filename);
|
||||
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 *player = new PlayerProfile(player_xml);
|
||||
m_all_players.push_back(player);
|
||||
if(player->isDefault())
|
||||
m_current_player = player;
|
||||
}
|
||||
m_all_players.insertionSort(/*start*/0, /*desc*/true);
|
||||
|
||||
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
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void PlayerManager::save()
|
||||
{
|
||||
std::string filename = file_manager->getUserConfigFile("players.xml");
|
||||
try
|
||||
{
|
||||
UTFWriter players_file(filename.c_str());
|
||||
|
||||
players_file << L"<?xml version=\"1.0\"?>\n";
|
||||
players_file << L"<players version=\"1\" >\n";
|
||||
|
||||
PlayerProfile *player;
|
||||
for_in(player, m_all_players)
|
||||
{
|
||||
player->save(players_file);
|
||||
}
|
||||
players_file << L"</players>\n";
|
||||
players_file.close();
|
||||
}
|
||||
catch (std::runtime_error& e)
|
||||
{
|
||||
Log::error("PlayerManager", "Failed to write config to %s.",
|
||||
filename.c_str());
|
||||
Log::error("PlayerManager", "Error: %s", e.what());
|
||||
}
|
||||
|
||||
} // save
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Adds a new player to the list of all players.
|
||||
* \param name Name of the new player.
|
||||
*/
|
||||
void PlayerManager::addNewPlayer(const core::stringw& name)
|
||||
{
|
||||
m_all_players.push_back( new PlayerProfile(name) );
|
||||
} // addNewPlayer
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void PlayerManager::deletePlayer(PlayerProfile *player)
|
||||
{
|
||||
m_all_players.erase(player);
|
||||
} // deletePlayer
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void PlayerManager::addDefaultPlayer()
|
||||
{
|
||||
std::string username = "unnamed player";
|
||||
|
||||
if(getenv("USERNAME")!=NULL) // for windows
|
||||
username = getenv("USERNAME");
|
||||
else if(getenv("USER")!=NULL) // Linux, Macs
|
||||
username = getenv("USER");
|
||||
else if(getenv("LOGNAME")!=NULL) // Linux, Macs
|
||||
username = getenv("LOGNAME");
|
||||
|
||||
// Set the name as the default name for all players.
|
||||
m_all_players.push_back(new PlayerProfile(username.c_str()) );
|
||||
|
||||
// add default guest player
|
||||
m_all_players.push_back( new PlayerProfile(_LTR("Guest"), /*guest*/true) );
|
||||
|
||||
|
||||
} // addDefaultPlayer
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** This returns a unique id. This is 1 + larger id so far used.
|
||||
*/
|
||||
unsigned int PlayerManager::getUniqueId() const
|
||||
{
|
||||
unsigned int max_id=0;
|
||||
const PlayerProfile *player;
|
||||
for_in(player, m_all_players)
|
||||
{
|
||||
if(player->getUniqueID()>max_id)
|
||||
max_id = player->getUniqueID();
|
||||
}
|
||||
return max_id+1;
|
||||
} // getUniqueId
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
const PlayerProfile *PlayerManager::getPlayerById(unsigned int id)
|
||||
{
|
||||
const PlayerProfile *player;
|
||||
for_in(player, m_all_players)
|
||||
{
|
||||
if(player->getUniqueID()==id)
|
||||
return player;
|
||||
}
|
||||
return NULL;
|
||||
} // getPlayerById
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
PlayerProfile *PlayerManager::getPlayer(const irr::core::stringw &name)
|
||||
{
|
||||
PlayerProfile *player;
|
||||
for_in(player, m_all_players)
|
||||
{
|
||||
if(player->getName()==name)
|
||||
return player;
|
||||
}
|
||||
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);
|
||||
m_current_player->computeActive();
|
||||
AchievementsManager::get()->updateCurrentPlayer();
|
||||
} // setCurrentPlayer
|
||||
|
||||
// ----------------------------------------------------------------------------
|
96
src/config/player_manager.hpp
Normal file
96
src/config/player_manager.hpp
Normal file
@ -0,0 +1,96 @@
|
||||
//
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2010-2014 Joerg Henrichs
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// 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_MANAGER_HPP
|
||||
#define HEADER_PLAYER_MANAGER_HPP
|
||||
|
||||
#include "utils/no_copy.hpp"
|
||||
#include "utils/ptr_vector.hpp"
|
||||
|
||||
#include <irrString.h>
|
||||
|
||||
#include <cstddef> // NULL
|
||||
|
||||
class PlayerProfile;
|
||||
|
||||
/** A special class that manages all local player accounts.
|
||||
*/
|
||||
class PlayerManager : public NoCopy
|
||||
{
|
||||
private:
|
||||
static PlayerManager* m_player_manager;
|
||||
|
||||
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()
|
||||
{
|
||||
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 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.*/
|
||||
unsigned int getNumPlayers() const { return m_all_players.size(); }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns a player with a given unique id. */
|
||||
const PlayerProfile *getPlayer(unsigned int n) const
|
||||
{
|
||||
return &m_all_players[n];
|
||||
} // getPlayer
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns a player with a given unique id. */
|
||||
PlayerProfile *getPlayer(unsigned int n) { return &m_all_players[n];}
|
||||
// ------------------------------------------------------------------------
|
||||
}; // PlayerManager
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/*EOF*/
|
@ -63,7 +63,7 @@ SavedGrandPrix::SavedGPKart::SavedGPKart(GroupUserConfigParam * group,
|
||||
} // SavedGPKart
|
||||
|
||||
// ============================================================================
|
||||
SavedGrandPrix::SavedGrandPrix(const std::string &player_id,
|
||||
SavedGrandPrix::SavedGrandPrix(unsigned int player_id,
|
||||
const std::string &gp_id,
|
||||
RaceManager::Difficulty difficulty,
|
||||
int player_karts,
|
||||
@ -71,7 +71,7 @@ SavedGrandPrix::SavedGrandPrix(const std::string &player_id,
|
||||
const std::vector<RaceManager::KartStatus> &kart_list)
|
||||
: m_savedgp_group("SavedGP",
|
||||
"Represents the saved state of a GP"),
|
||||
m_player_id(player_id.c_str(), "player_id", &m_savedgp_group),
|
||||
m_player_id(player_id),
|
||||
m_gp_id(gp_id.c_str(), "gp_id", &m_savedgp_group),
|
||||
m_difficulty((int)difficulty,"difficulty", &m_savedgp_group),
|
||||
m_player_karts(player_karts,"player_karts", &m_savedgp_group),
|
||||
@ -94,14 +94,13 @@ SavedGrandPrix::SavedGrandPrix(const std::string &player_id,
|
||||
SavedGrandPrix::SavedGrandPrix(const XMLNode* node)
|
||||
: m_savedgp_group("SavedGP",
|
||||
"Represents the saved state of a GP"),
|
||||
m_player_id("-", "player_id", &m_savedgp_group),
|
||||
m_player_id(0),
|
||||
m_gp_id("-", "gp_id", &m_savedgp_group),
|
||||
m_difficulty(0,"difficulty", &m_savedgp_group),
|
||||
m_player_karts(0,"player_karts", &m_savedgp_group),
|
||||
m_next_track(0,"last_track", &m_savedgp_group)
|
||||
{
|
||||
//m_player_group.findYourDataInAChildOf(node);
|
||||
m_player_id.findYourDataInAnAttributeOf(node);
|
||||
m_gp_id.findYourDataInAnAttributeOf(node);
|
||||
m_difficulty.findYourDataInAnAttributeOf(node);
|
||||
m_player_karts.findYourDataInAnAttributeOf(node);
|
||||
|
@ -60,7 +60,7 @@ protected:
|
||||
* WARNING : m_savedgp_group has to be declared before the other userconfigparams!
|
||||
*/
|
||||
GroupUserConfigParam m_savedgp_group;
|
||||
StringUserConfigParam m_player_id;
|
||||
unsigned int m_player_id;
|
||||
|
||||
/** Identifier of this GP. */
|
||||
StringUserConfigParam m_gp_id;
|
||||
@ -81,7 +81,7 @@ public:
|
||||
/**
|
||||
* Constructor to create a new entry.
|
||||
*/
|
||||
SavedGrandPrix(const std::string &player_id,
|
||||
SavedGrandPrix(unsigned int player_id,
|
||||
const std::string &gp_id,
|
||||
RaceManager::Difficulty difficulty,
|
||||
int player_karts,
|
||||
@ -98,7 +98,7 @@ public:
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the player id for this saved GP. */
|
||||
const std::string getPlayerID() const { return m_player_id; }
|
||||
unsigned int getPlayerID() const { return m_player_id; }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the grand prix id. */
|
||||
@ -137,7 +137,7 @@ public:
|
||||
/** Finds the right SavedGrandPrix given the specified data, or
|
||||
* NULL if no matching GP was found.
|
||||
*/
|
||||
static SavedGrandPrix* getSavedGP(const std::string &player,
|
||||
static SavedGrandPrix* getSavedGP(unsigned int player,
|
||||
const std::string &gpid,
|
||||
int difficulty, int total_karts,
|
||||
int player_karts)
|
||||
|
@ -18,34 +18,36 @@
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <stdlib.h>
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
#include "io/xml_writer.hpp"
|
||||
#include "utils/ptr_vector.hpp"
|
||||
|
||||
// The order here is important. If all_params is declared later (e.g. after
|
||||
// the #includes), all elements will be added to all_params, and then
|
||||
// all_params will be initialised, i.e. cleared!
|
||||
class UserConfigParam;
|
||||
static PtrVector<UserConfigParam, REF> all_params;
|
||||
|
||||
|
||||
// X-macros
|
||||
#define PARAM_PREFIX
|
||||
#define PARAM_DEFAULT(X) = X
|
||||
#include "config/user_config.hpp"
|
||||
|
||||
#include "config/saved_grand_prix.hpp"
|
||||
#include "config/player.hpp"
|
||||
#include "config/saved_grand_prix.hpp"
|
||||
#include "config/stk_config.hpp"
|
||||
#include "guiengine/engine.hpp"
|
||||
#include "io/file_manager.hpp"
|
||||
#include "io/utf_writer.hpp"
|
||||
#include "io/xml_node.hpp"
|
||||
#include "race/race_manager.hpp"
|
||||
#include "utils/ptr_vector.hpp"
|
||||
#include "utils/string_utils.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
const int UserConfig::m_current_config_version = 8;
|
||||
|
||||
|
||||
@ -60,7 +62,7 @@ UserConfigParam::~UserConfigParam()
|
||||
* \param stream the xml writer.
|
||||
* \param level determines indentation level.
|
||||
*/
|
||||
void UserConfigParam::writeInner(XMLWriter& stream, int level) const
|
||||
void UserConfigParam::writeInner(UTFWriter& stream, int level) const
|
||||
{
|
||||
std::string tab(level * 4,' ');
|
||||
stream << L" " << tab.c_str() << m_param_name.c_str() << L"=\""
|
||||
@ -87,7 +89,7 @@ GroupUserConfigParam::GroupUserConfigParam(const char* group_name,
|
||||
} // GroupUserConfigParam
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void GroupUserConfigParam::write(XMLWriter& stream) const
|
||||
void GroupUserConfigParam::write(UTFWriter& stream) const
|
||||
{
|
||||
const int attr_amount = m_attributes.size();
|
||||
|
||||
@ -117,7 +119,7 @@ void GroupUserConfigParam::write(XMLWriter& stream) const
|
||||
} // write
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void GroupUserConfigParam::writeInner(XMLWriter& stream, int level) const
|
||||
void GroupUserConfigParam::writeInner(UTFWriter& stream, int level) const
|
||||
{
|
||||
std::string tab(level * 4,' ');
|
||||
for(int i = 0; i < level; i++) tab =+ " ";
|
||||
@ -244,7 +246,7 @@ ListUserConfigParam<T, U>::ListUserConfigParam(const char* param_name,
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
template<typename T, typename U>
|
||||
void ListUserConfigParam<T, U>::write(XMLWriter& stream) const
|
||||
void ListUserConfigParam<T, U>::write(UTFWriter& stream) const
|
||||
{
|
||||
const int elts_amount = m_elements.size();
|
||||
|
||||
@ -350,7 +352,7 @@ IntUserConfigParam::IntUserConfigParam(int default_value,
|
||||
} // IntUserConfigParam
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void IntUserConfigParam::write(XMLWriter& stream) const
|
||||
void IntUserConfigParam::write(UTFWriter& stream) const
|
||||
{
|
||||
if(m_comment.size() > 0) stream << L" <!-- " << m_comment.c_str()
|
||||
<< L" -->\n";
|
||||
@ -412,7 +414,7 @@ TimeUserConfigParam::TimeUserConfigParam(StkTime::TimeType default_value,
|
||||
} // TimeUserConfigParam
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void TimeUserConfigParam::write(XMLWriter& stream) const
|
||||
void TimeUserConfigParam::write(UTFWriter& stream) const
|
||||
{
|
||||
if(m_comment.size() > 0) stream << L" <!-- " << m_comment.c_str()
|
||||
<< L" -->\n";
|
||||
@ -483,7 +485,7 @@ StringUserConfigParam::StringUserConfigParam(const char* default_value,
|
||||
} // StringUserConfigParam
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void StringUserConfigParam::write(XMLWriter& stream) const
|
||||
void StringUserConfigParam::write(UTFWriter& stream) const
|
||||
{
|
||||
if(m_comment.size() > 0) stream << L" <!-- " << m_comment.c_str()
|
||||
<< L" -->\n";
|
||||
@ -535,7 +537,7 @@ WStringUserConfigParam::WStringUserConfigParam(const core::stringw& default_valu
|
||||
} // WStringUserConfigParam
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void WStringUserConfigParam::write(XMLWriter& stream) const
|
||||
void WStringUserConfigParam::write(UTFWriter& stream) const
|
||||
{
|
||||
if(m_comment.size() > 0) stream << L" <!-- " << m_comment.c_str()
|
||||
<< L" -->\n";
|
||||
@ -586,7 +588,7 @@ BoolUserConfigParam::BoolUserConfigParam(bool default_value,
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void BoolUserConfigParam::write(XMLWriter& stream) const
|
||||
void BoolUserConfigParam::write(UTFWriter& stream) const
|
||||
{
|
||||
if(m_comment.size() > 0) stream << L" <!-- " << m_comment.c_str()
|
||||
<< L" -->\n";
|
||||
@ -673,7 +675,7 @@ FloatUserConfigParam::FloatUserConfigParam(float default_value,
|
||||
} // FloatUserConfigParam
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void FloatUserConfigParam::write(XMLWriter& stream) const
|
||||
void FloatUserConfigParam::write(UTFWriter& stream) const
|
||||
{
|
||||
if(m_comment.size() > 0) stream << L" <!-- " << m_comment.c_str()
|
||||
<< L" -->\n";
|
||||
@ -725,61 +727,9 @@ UserConfig::UserConfig()
|
||||
// -----------------------------------------------------------------------------
|
||||
UserConfig::~UserConfig()
|
||||
{
|
||||
UserConfigParams::m_all_players.clearAndDeleteAll();
|
||||
UserConfigParams::m_saved_grand_prix_list.clearAndDeleteAll();
|
||||
} // ~UserConfig
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
void UserConfig::addDefaultPlayer()
|
||||
{
|
||||
|
||||
std::string username = "unnamed player";
|
||||
|
||||
if(getenv("USERNAME")!=NULL) // for windows
|
||||
username = getenv("USERNAME");
|
||||
else if(getenv("USER")!=NULL) // Linux, Macs
|
||||
username = getenv("USER");
|
||||
else if(getenv("LOGNAME")!=NULL) // Linux, Macs
|
||||
username = getenv("LOGNAME");
|
||||
|
||||
|
||||
class GuestPlayerProfile : public PlayerProfile
|
||||
{
|
||||
public:
|
||||
GuestPlayerProfile() : PlayerProfile(_LTR("Guest"))
|
||||
{
|
||||
m_is_guest_account = true;
|
||||
}
|
||||
};
|
||||
|
||||
// add default guest player
|
||||
UserConfigParams::m_all_players.push_back( new GuestPlayerProfile() );
|
||||
|
||||
// Set the name as the default name for all players.
|
||||
UserConfigParams::m_all_players.push_back(
|
||||
new PlayerProfile(username.c_str()) );
|
||||
|
||||
} // addDefaultPlayer
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/** Comparison used to sort players. Most frequent players should be
|
||||
* listed first, so a<b actually means that
|
||||
* a.m_use_frequency > b.m_use_frequency
|
||||
* This way we get a reversed sorted list.
|
||||
*/
|
||||
bool operator<(const PlayerProfile &a, const PlayerProfile &b)
|
||||
{
|
||||
return a.getUseFrequency() > b.getUseFrequency();
|
||||
} // operator<
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
/** \brief Needed for toggling sort order **/
|
||||
bool operator>(const PlayerProfile &a, const PlayerProfile &b)
|
||||
{
|
||||
return a.getUseFrequency() < b.getUseFrequency();
|
||||
} // operator>
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
/** Load configuration values from file. */
|
||||
bool UserConfig::loadConfig()
|
||||
@ -824,26 +774,6 @@ bool UserConfig::loadConfig()
|
||||
}
|
||||
|
||||
|
||||
// ---- Read players
|
||||
// we create those AFTER other values are being read simply because we have many Player
|
||||
// nodes that all bear the same name, so the generic loading code won't work here
|
||||
UserConfigParams::m_all_players.clearAndDeleteAll();
|
||||
|
||||
std::vector<XMLNode*> players;
|
||||
root->getNodes("Player", players);
|
||||
const int amount = players.size();
|
||||
for (int i=0; i<amount; i++)
|
||||
{
|
||||
//std::string name;
|
||||
//players[i]->get("name", &name);
|
||||
UserConfigParams::m_all_players.push_back(
|
||||
new PlayerProfile(players[i]) );
|
||||
}
|
||||
|
||||
// sort players by frequency of use
|
||||
UserConfigParams::m_all_players.insertionSort();
|
||||
|
||||
|
||||
// ---- Read Saved GP's
|
||||
UserConfigParams::m_saved_grand_prix_list.clearAndDeleteAll();
|
||||
std::vector<XMLNode*> saved_gps;
|
||||
@ -859,17 +789,6 @@ bool UserConfig::loadConfig()
|
||||
return true;
|
||||
} // loadConfig
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void UserConfig::postLoadInit()
|
||||
{
|
||||
for (unsigned int i = 0; i < UserConfigParams::m_all_players.size(); i++)
|
||||
{
|
||||
PlayerProfile* player = UserConfigParams::m_all_players.get(i);
|
||||
if (player->isGuestAccount()) player->setName(_LTR("Guest"));
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Write settings to config file. */
|
||||
void UserConfig::saveConfig()
|
||||
@ -878,7 +797,7 @@ void UserConfig::saveConfig()
|
||||
|
||||
try
|
||||
{
|
||||
XMLWriter configfile(filename.c_str());
|
||||
UTFWriter configfile(filename.c_str());
|
||||
|
||||
configfile << L"<?xml version=\"1.0\"?>\n";
|
||||
configfile << L"<stkconfig version=\"" << m_current_config_version
|
||||
|
@ -46,7 +46,6 @@
|
||||
using irr::core::stringc;
|
||||
using irr::core::stringw;
|
||||
|
||||
#include "io/xml_writer.hpp"
|
||||
#include "utils/constants.hpp"
|
||||
#include "utils/no_copy.hpp"
|
||||
#include "utils/ptr_vector.hpp"
|
||||
@ -55,7 +54,7 @@ using irr::core::stringw;
|
||||
class PlayerProfile;
|
||||
class SavedGrandPrix;
|
||||
class XMLNode;
|
||||
class XMLWriter;
|
||||
class UTFWriter;
|
||||
|
||||
/**
|
||||
* The base of a set of small utilities to enable quickly adding/removing
|
||||
@ -69,8 +68,8 @@ protected:
|
||||
std::string m_comment;
|
||||
public:
|
||||
virtual ~UserConfigParam();
|
||||
virtual void write(XMLWriter& stream) const = 0;
|
||||
virtual void writeInner(XMLWriter& stream, int level = 0) const;
|
||||
virtual void write(UTFWriter& stream) const = 0;
|
||||
virtual void writeInner(UTFWriter& stream, int level = 0) const;
|
||||
virtual void findYourDataInAChildOf(const XMLNode* node) = 0;
|
||||
virtual void findYourDataInAnAttributeOf(const XMLNode* node) = 0;
|
||||
virtual irr::core::stringw toString() const = 0;
|
||||
@ -86,8 +85,8 @@ public:
|
||||
GroupUserConfigParam(const char* param_name,
|
||||
GroupUserConfigParam* group,
|
||||
const char* comment = NULL);
|
||||
void write(XMLWriter& stream) const;
|
||||
void writeInner(XMLWriter& stream, int level = 0) const;
|
||||
void write(UTFWriter& stream) const;
|
||||
void writeInner(UTFWriter& stream, int level = 0) const;
|
||||
void findYourDataInAChildOf(const XMLNode* node);
|
||||
void findYourDataInAnAttributeOf(const XMLNode* node);
|
||||
|
||||
@ -120,7 +119,7 @@ public:
|
||||
int nb_elts,
|
||||
...);
|
||||
|
||||
void write(XMLWriter& stream) const;
|
||||
void write(UTFWriter& stream) const;
|
||||
void findYourDataInAChildOf(const XMLNode* node);
|
||||
void findYourDataInAnAttributeOf(const XMLNode* node);
|
||||
|
||||
@ -151,7 +150,7 @@ public:
|
||||
GroupUserConfigParam* group,
|
||||
const char* comment = NULL);
|
||||
|
||||
void write(XMLWriter& stream) const;
|
||||
void write(UTFWriter& stream) const;
|
||||
void findYourDataInAChildOf(const XMLNode* node);
|
||||
void findYourDataInAnAttributeOf(const XMLNode* node);
|
||||
|
||||
@ -178,7 +177,7 @@ public:
|
||||
TimeUserConfigParam(StkTime::TimeType default_value, const char* param_name,
|
||||
GroupUserConfigParam* group, const char* comment=NULL);
|
||||
|
||||
void write(XMLWriter& stream) const;
|
||||
void write(UTFWriter& stream) const;
|
||||
void findYourDataInAChildOf(const XMLNode* node);
|
||||
void findYourDataInAnAttributeOf(const XMLNode* node);
|
||||
|
||||
@ -205,7 +204,7 @@ public:
|
||||
GroupUserConfigParam* group,
|
||||
const char* comment = NULL);
|
||||
|
||||
void write(XMLWriter& stream) const;
|
||||
void write(UTFWriter& stream) const;
|
||||
void findYourDataInAChildOf(const XMLNode* node);
|
||||
void findYourDataInAnAttributeOf(const XMLNode* node);
|
||||
|
||||
@ -240,7 +239,7 @@ public:
|
||||
GroupUserConfigParam* group,
|
||||
const char* comment = NULL);
|
||||
|
||||
void write(XMLWriter& stream) const;
|
||||
void write(UTFWriter& stream) const;
|
||||
void findYourDataInAChildOf(const XMLNode* node);
|
||||
void findYourDataInAnAttributeOf(const XMLNode* node);
|
||||
|
||||
@ -267,7 +266,7 @@ public:
|
||||
BoolUserConfigParam(bool default_value, const char* param_name,
|
||||
GroupUserConfigParam* group,
|
||||
const char* comment = NULL);
|
||||
void write(XMLWriter& stream) const;
|
||||
void write(UTFWriter& stream) const;
|
||||
void findYourDataInAChildOf(const XMLNode* node);
|
||||
void findYourDataInAnAttributeOf(const XMLNode* node);
|
||||
|
||||
@ -293,7 +292,7 @@ public:
|
||||
GroupUserConfigParam* group,
|
||||
const char* comment = NULL);
|
||||
|
||||
void write(XMLWriter& stream) const;
|
||||
void write(UTFWriter& stream) const;
|
||||
void findYourDataInAChildOf(const XMLNode* node);
|
||||
void findYourDataInAnAttributeOf(const XMLNode* node);
|
||||
|
||||
@ -770,8 +769,6 @@ namespace UserConfigParams
|
||||
// TODO? implement blacklist for new irrlicht device and GUI
|
||||
PARAM_PREFIX std::vector<std::string> m_blacklist_res;
|
||||
|
||||
PARAM_PREFIX PtrVector<PlayerProfile> m_all_players;
|
||||
|
||||
/** List of all saved GPs. */
|
||||
PARAM_PREFIX PtrVector<SavedGrandPrix> m_saved_grand_prix_list;
|
||||
|
||||
@ -826,8 +823,6 @@ public:
|
||||
const irr::core::stringw& getWarning() { return m_warning; }
|
||||
void resetWarning() { m_warning=""; }
|
||||
void setWarning(irr::core::stringw& warning) { m_warning=warning; }
|
||||
void postLoadInit();
|
||||
void addDefaultPlayer();
|
||||
|
||||
}; // UserConfig
|
||||
|
||||
|
@ -16,90 +16,52 @@
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "io/xml_writer.hpp"
|
||||
#include "io/utf_writer.hpp"
|
||||
|
||||
#include <wchar.h>
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
using namespace irr;
|
||||
|
||||
#if IRRLICHT_VERSION_MAJOR > 1 || (IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR >= 8)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
XMLWriter::XMLWriter(const char* dest) : m_base(dest, std::ios::out | std::ios::binary)
|
||||
UTFWriter::UTFWriter(const char* dest)
|
||||
: m_base(dest, std::ios::out | std::ios::binary)
|
||||
{
|
||||
if (!m_base.is_open())
|
||||
{
|
||||
throw std::runtime_error("Failed to open file for writing : " + std::string(dest));
|
||||
throw std::runtime_error("Failed to open file for writing : " +
|
||||
std::string(dest));
|
||||
}
|
||||
|
||||
// FIXME: make sure to properly handle endianness
|
||||
wchar_t BOM = 0xFEFF; // UTF-16 BOM is 0xFEFF; UTF-32 BOM is 0x0000FEFF. So this works in either case
|
||||
// UTF-16 BOM is 0xFEFF; UTF-32 BOM is 0x0000FEFF. So this works in either case
|
||||
wchar_t BOM = 0xFEFF;
|
||||
|
||||
m_base.write((char *) &BOM, sizeof(wchar_t));
|
||||
}
|
||||
} // UTFWriter
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
XMLWriter& XMLWriter::operator<< (const irr::core::stringw& txt)
|
||||
UTFWriter& UTFWriter::operator<< (const irr::core::stringw& txt)
|
||||
{
|
||||
m_base.write((char *) txt.c_str(), txt.size() * sizeof(wchar_t));
|
||||
return *this;
|
||||
}
|
||||
} // operator<< (stringw)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
XMLWriter& XMLWriter::operator<< (const wchar_t*txt)
|
||||
UTFWriter& UTFWriter::operator<< (const wchar_t*txt)
|
||||
{
|
||||
m_base.write((char *) txt, wcslen(txt) * sizeof(wchar_t));
|
||||
return *this;
|
||||
}
|
||||
} // operator<< (wchar_t)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void XMLWriter::close()
|
||||
void UTFWriter::close()
|
||||
{
|
||||
m_base.close();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#else // Non-unicode version for irrlicht 1.7 and before
|
||||
|
||||
XMLWriter::XMLWriter(const char* dest) : m_base(dest, std::ios::out | std::ios::binary)
|
||||
{
|
||||
if (!m_base.is_open())
|
||||
{
|
||||
throw std::runtime_error("Failed to open file for writing : " + std::string(dest));
|
||||
}
|
||||
}
|
||||
} // close
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
XMLWriter& XMLWriter::operator<< (const irr::core::stringw& txt)
|
||||
{
|
||||
core::stringc s( txt.c_str() );
|
||||
m_base.write((char *) s.c_str(), s.size());
|
||||
return *this;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
XMLWriter& XMLWriter::operator<< (const wchar_t*txt)
|
||||
{
|
||||
core::stringc s( txt );
|
||||
m_base.write((char *) s.c_str(), s.size());
|
||||
return *this;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void XMLWriter::close()
|
||||
{
|
||||
m_base.close();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#endif
|
@ -16,11 +16,14 @@
|
||||
// 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_XML_WRITER_HPP
|
||||
#define HEADER_XML_WRITER_HPP
|
||||
#ifndef HEADER_UTF_WRITER_HPP
|
||||
#define HEADER_UTF_WRITER_HPP
|
||||
|
||||
#include "utils/string_utils.hpp"
|
||||
|
||||
#include <irrString.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <irrString.h>
|
||||
|
||||
/**
|
||||
* \brief utility class used to write wide (UTF-16 or UTF-32, depending of size of wchar_t) XML files
|
||||
@ -28,27 +31,38 @@
|
||||
* we only want to accept arrays of wchar_t to make sure we get reasonable files out
|
||||
* \ingroup io
|
||||
*/
|
||||
class XMLWriter
|
||||
class UTFWriter
|
||||
{
|
||||
std::ofstream m_base;
|
||||
public:
|
||||
|
||||
XMLWriter(const char* dest);
|
||||
|
||||
XMLWriter& operator<< (const irr::core::stringw& txt);
|
||||
XMLWriter& operator<< (const wchar_t* txt);
|
||||
|
||||
template<typename T>
|
||||
XMLWriter& operator<< (const T t)
|
||||
{
|
||||
irr::core::stringw tmp;
|
||||
tmp += t;
|
||||
(*this) << tmp;
|
||||
return *this;
|
||||
}
|
||||
|
||||
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)
|
||||
// ------------------------------------------------------------------------
|
||||
UTFWriter& operator<< (const bool &b)
|
||||
{
|
||||
return operator<<(StringUtils::toString(b));
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
template<typename T>
|
||||
UTFWriter& operator<< (const T &t)
|
||||
{
|
||||
return operator<<(StringUtils::toString<T>(t));
|
||||
} // operator<< (template)
|
||||
// ------------------------------------------------------------------------
|
||||
bool is_open() { return m_base.is_open(); }
|
||||
};
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "audio/sfx_manager.hpp"
|
||||
#include "audio/sfx_base.hpp"
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "graphics/camera.hpp"
|
||||
#include "graphics/explosion.hpp"
|
||||
@ -804,8 +805,8 @@ void Kart::finishedRace(float time)
|
||||
m_controller));
|
||||
if (m_controller->isPlayerController()) // if player is on this computer
|
||||
{
|
||||
GameSlot *slot = unlock_manager->getCurrentSlot();
|
||||
const Challenge *challenge = slot->getCurrentChallenge();
|
||||
PlayerProfile *player = PlayerManager::get()->getCurrentPlayer();
|
||||
const Challenge *challenge = player->getCurrentChallenge();
|
||||
// In case of a GP challenge don't make the end animation depend
|
||||
// on if the challenge is fulfilled
|
||||
if(challenge && !challenge->getData()->isGrandPrix())
|
||||
|
@ -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
|
||||
|
||||
@ -461,7 +464,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());
|
||||
}
|
||||
|
171
src/main.cpp
171
src/main.cpp
@ -146,9 +146,10 @@
|
||||
#include "audio/music_manager.hpp"
|
||||
#include "audio/sfx_manager.hpp"
|
||||
#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 "config/player.hpp"
|
||||
#include "graphics/hardware_skinning.hpp"
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "graphics/material_manager.hpp"
|
||||
@ -680,10 +681,9 @@ int handleCmdLine()
|
||||
|
||||
if(CommandLine::has("--kart", &s))
|
||||
{
|
||||
unlock_manager->setCurrentSlot(UserConfigParams::m_all_players[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);
|
||||
@ -750,9 +750,8 @@ int handleCmdLine()
|
||||
|
||||
if(CommandLine::has("--track", &s) || CommandLine::has("-t", &s))
|
||||
{
|
||||
unlock_manager->setCurrentSlot(UserConfigParams::m_all_players[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'.",
|
||||
@ -898,8 +897,6 @@ int handleCmdLine()
|
||||
// Demo mode
|
||||
if(CommandLine::has("--demo-mode", &s))
|
||||
{
|
||||
unlock_manager->setCurrentSlot(UserConfigParams::m_all_players[0]
|
||||
.getUniqueID() );
|
||||
float t;
|
||||
StringUtils::fromString(s, t);
|
||||
DemoWorld::enableDemoMode(t);
|
||||
@ -940,9 +937,6 @@ int handleCmdLine()
|
||||
|
||||
CommandLine::reportInvalidParameters();
|
||||
|
||||
if(UserConfigParams::m_no_start_screen)
|
||||
unlock_manager->setCurrentSlot(UserConfigParams::m_all_players[0]
|
||||
.getUniqueID() );
|
||||
if(ProfileWorld::isProfileMode())
|
||||
{
|
||||
UserConfigParams::m_sfx = false; // Disable sound effects
|
||||
@ -973,7 +967,7 @@ void initUserConfig()
|
||||
irr_driver = new IrrDriver();
|
||||
file_manager = new FileManager();
|
||||
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
|
||||
@ -988,12 +982,6 @@ void initUserConfig()
|
||||
translations = new Translations(); // needs file_manager
|
||||
stk_config = new STKConfig(); // in case of --stk-config
|
||||
// command line parameters
|
||||
user_config->postLoadInit();
|
||||
if (!config_ok || UserConfigParams::m_all_players.size() == 0)
|
||||
{
|
||||
user_config->addDefaultPlayer();
|
||||
user_config->saveConfig();
|
||||
}
|
||||
|
||||
} // initUserConfig
|
||||
|
||||
@ -1025,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
|
||||
@ -1068,60 +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;
|
||||
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,
|
||||
@ -1189,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
|
||||
@ -1218,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") );
|
||||
@ -1252,18 +1194,7 @@ int main(int argc, char *argv[] )
|
||||
}
|
||||
}
|
||||
|
||||
// no graphics, and no profile mode
|
||||
if (ProfileWorld::isNoGraphics() && !ProfileWorld::isProfileMode())
|
||||
{
|
||||
// hack to have a running game slot :
|
||||
PtrVector<PlayerProfile>& players = UserConfigParams::m_all_players;
|
||||
if (UserConfigParams::m_default_player.toString().size() > 0)
|
||||
for (unsigned int n=0; n<players.size(); n++)
|
||||
if (players[n].getName() == UserConfigParams::m_default_player.toString())
|
||||
unlock_manager->setCurrentSlot(players[n].getUniqueID());
|
||||
|
||||
}
|
||||
else if(!UserConfigParams::m_no_start_screen)
|
||||
if(!UserConfigParams::m_no_start_screen)
|
||||
{
|
||||
StateManager::get()->pushScreen(StoryModeLobbyScreen::getInstance());
|
||||
#ifdef ENABLE_WIIUSE
|
||||
@ -1314,7 +1245,7 @@ int main(int argc, char *argv[] )
|
||||
|
||||
// Create player and associate player with keyboard
|
||||
StateManager::get()->createActivePlayer(
|
||||
UserConfigParams::m_all_players.get(0), device, NULL);
|
||||
PlayerManager::get()->getPlayer(0), device, NULL);
|
||||
|
||||
if (kart_properties_manager->getKart(UserConfigParams::m_default_kart) == NULL)
|
||||
{
|
||||
@ -1435,10 +1366,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
|
||||
|
||||
|
@ -17,15 +17,12 @@
|
||||
|
||||
#include "modes/cutscene_world.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <IMeshSceneNode.h>
|
||||
#include <ISceneManager.h>
|
||||
|
||||
#include "animations/animation_base.hpp"
|
||||
#include "animations/three_d_animation.hpp"
|
||||
#include "audio/music_manager.hpp"
|
||||
#include "challenges/game_slot.hpp"
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "io/file_manager.hpp"
|
||||
#include "karts/abstract_kart.hpp"
|
||||
@ -43,6 +40,11 @@
|
||||
#include "utils/constants.hpp"
|
||||
#include "utils/ptr_vector.hpp"
|
||||
|
||||
#include <IMeshSceneNode.h>
|
||||
#include <ISceneManager.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Constructor. Sets up the clock mode etc.
|
||||
*/
|
||||
@ -376,14 +378,14 @@ void CutsceneWorld::enterRaceOverState()
|
||||
else if (race_manager->getTrackName() == "introcutscene" ||
|
||||
race_manager->getTrackName() == "introcutscene2")
|
||||
{
|
||||
GameSlot* slot = unlock_manager->getCurrentSlot();
|
||||
if (slot->isFirstTime())
|
||||
PlayerProfile *player = PlayerManager::get()->getCurrentPlayer();
|
||||
if (player->isFirstTime())
|
||||
{
|
||||
race_manager->exitRace();
|
||||
StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance());
|
||||
|
||||
slot->setFirstTime(false);
|
||||
unlock_manager->save();
|
||||
player->setFirstTime(false);
|
||||
PlayerManager::get()->save();
|
||||
KartSelectionScreen* s = OfflineKartSelectionScreen::getInstance();
|
||||
s->setMultiplayer(false);
|
||||
s->setGoToOverworldNext();
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
#include "modes/demo_world.hpp"
|
||||
|
||||
#include "config/player_manager.hpp"
|
||||
#include "guiengine/modaldialog.hpp"
|
||||
#include "input/device_manager.hpp"
|
||||
#include "input/input_manager.hpp"
|
||||
@ -140,7 +141,7 @@ bool DemoWorld::updateIdleTimeAndStartDemo(float dt)
|
||||
// Use keyboard 0 by default in --no-start-screen
|
||||
device = input_manager->getDeviceList()->getKeyboard(0);
|
||||
StateManager::get()->createActivePlayer(
|
||||
UserConfigParams::m_all_players.get(0), device , NULL);
|
||||
PlayerManager::get()->getPlayer(0), device , NULL);
|
||||
// ASSIGN should make sure that only input from assigned devices
|
||||
// is read.
|
||||
input_manager->getDeviceList()->setAssignMode(ASSIGN);
|
||||
|
0
src/modes/easter_egg_hunt.hpp
Executable file → Normal file
0
src/modes/easter_egg_hunt.hpp
Executable file → Normal file
@ -17,6 +17,7 @@
|
||||
|
||||
#include "audio/music_manager.hpp"
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "input/device_manager.hpp"
|
||||
#include "input/input.hpp"
|
||||
@ -63,7 +64,7 @@ void OverWorld::enterOverWorld()
|
||||
InputDevice* device = input_manager->getDeviceList()->getKeyboard(0);
|
||||
|
||||
// Create player and associate player with keyboard
|
||||
StateManager::get()->createActivePlayer(unlock_manager->getCurrentPlayer(),
|
||||
StateManager::get()->createActivePlayer(PlayerManager::get()->getCurrentPlayer(),
|
||||
device, NULL);
|
||||
|
||||
if (!kart_properties_manager->getKart(UserConfigParams::m_default_kart))
|
||||
|
@ -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();
|
||||
|
||||
@ -750,7 +752,7 @@ void World::updateWorld(float dt)
|
||||
InputDevice* device = input_manager->getDeviceList()->getKeyboard(0);
|
||||
|
||||
// Create player and associate player with keyboard
|
||||
StateManager::get()->createActivePlayer(unlock_manager->getCurrentPlayer(),
|
||||
StateManager::get()->createActivePlayer(PlayerManager::get()->getCurrentPlayer(),
|
||||
device, NULL);
|
||||
|
||||
if (!kart_properties_manager->getKart(UserConfigParams::m_default_kart))
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "network/protocols/start_game_protocol.hpp"
|
||||
|
||||
#include "config/player_manager.hpp"
|
||||
#include "input/device_manager.hpp"
|
||||
#include "input/input_manager.hpp"
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
@ -113,14 +114,14 @@ void StartGameProtocol::update()
|
||||
rki.setGlobalPlayerId(profile->race_id);
|
||||
rki.setLocalPlayerId(is_me?0:1);
|
||||
rki.setHostId(profile->race_id);
|
||||
PlayerProfile* profileToUse = unlock_manager->getCurrentPlayer();
|
||||
assert(profileToUse);
|
||||
PlayerProfile* profile_to_use = PlayerManager::get()->getCurrentPlayer();
|
||||
assert(profile_to_use);
|
||||
InputDevice* device = input_manager->getDeviceList()->getLatestUsedDevice();
|
||||
int new_player_id = 0;
|
||||
if (StateManager::get()->getActivePlayers().size() >= 1) // more than one player, we're the first
|
||||
new_player_id = 0;
|
||||
else
|
||||
new_player_id = StateManager::get()->createActivePlayer( profileToUse, device , players[i]->user_profile);
|
||||
new_player_id = StateManager::get()->createActivePlayer( profile_to_use, device , players[i]->user_profile);
|
||||
device->setPlayer(StateManager::get()->getActivePlayer(new_player_id));
|
||||
input_manager->getDeviceList()->setSinglePlayer(StateManager::get()->getActivePlayer(new_player_id));
|
||||
|
||||
|
@ -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
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
#include "config/user_config.hpp"
|
||||
#include "io/file_manager.hpp"
|
||||
#include "io/xml_writer.hpp"
|
||||
#include "io/utf_writer.hpp"
|
||||
#include "race/race_manager.hpp"
|
||||
#include "utils/constants.hpp"
|
||||
#include "utils/string_utils.hpp"
|
||||
@ -149,7 +149,7 @@ void HighscoreManager::saveHighscores()
|
||||
|
||||
try
|
||||
{
|
||||
XMLWriter highscore_file(m_filename.c_str());
|
||||
UTFWriter highscore_file(m_filename.c_str());
|
||||
highscore_file << L"<?xml version=\"1.0\"?>\n";
|
||||
highscore_file << L"<highscores version=\"" << CURRENT_HSCORE_FILE_VERSION << "\">\n";
|
||||
|
||||
|
@ -18,13 +18,13 @@
|
||||
|
||||
#include "race/highscores.hpp"
|
||||
|
||||
#include "io/utf_writer.hpp"
|
||||
#include "io/xml_node.hpp"
|
||||
#include "race/race_manager.hpp"
|
||||
|
||||
#include <stdexcept>
|
||||
#include <fstream>
|
||||
|
||||
#include "io/xml_node.hpp"
|
||||
#include "io/xml_writer.hpp"
|
||||
#include "race/race_manager.hpp"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
Highscores::Highscores(const HighscoreType highscore_type,
|
||||
int num_karts,
|
||||
@ -105,7 +105,7 @@ void Highscores::readEntry(const XMLNode &node)
|
||||
* resulting in empty entries here.
|
||||
* \param writer The file stream to write the data to.
|
||||
*/
|
||||
void Highscores::writeEntry(XMLWriter &writer)
|
||||
void Highscores::writeEntry(UTFWriter &writer)
|
||||
{
|
||||
// Only
|
||||
bool one_is_set = false;
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include <irrString.h>
|
||||
|
||||
class XMLNode;
|
||||
class XMLWriter;
|
||||
class UTFWriter;
|
||||
|
||||
/**
|
||||
* Represents one highscore entry, i.e. the (atm up to three) highscores
|
||||
@ -62,7 +62,7 @@ public:
|
||||
Highscores (const XMLNode &node);
|
||||
|
||||
void readEntry (const XMLNode &node);
|
||||
void writeEntry(XMLWriter &writer);
|
||||
void writeEntry(UTFWriter &writer);
|
||||
int matches (HighscoreType highscore_type, int num_karts,
|
||||
const RaceManager::Difficulty difficulty,
|
||||
const std::string track, const int number_of_laps,
|
||||
|
@ -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 );
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "audio/sfx_manager.hpp"
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
#include "config/player.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "guiengine/engine.hpp"
|
||||
#include "guiengine/widgets/button_widget.hpp"
|
||||
#include "guiengine/widgets/label_widget.hpp"
|
||||
@ -102,14 +103,14 @@ void EnterPlayerNameDialog::onEnterPressedInternal()
|
||||
|
||||
// ---- Otherwise, see if we can accept the new name
|
||||
TextBoxWidget* textCtrl = getWidget<TextBoxWidget>("textfield");
|
||||
stringw playerName = textCtrl->getText().trim();
|
||||
if (StringUtils::notEmpty(playerName))
|
||||
stringw player_name = textCtrl->getText().trim();
|
||||
if (StringUtils::notEmpty(player_name))
|
||||
{
|
||||
// check for duplicates
|
||||
const int amount = UserConfigParams::m_all_players.size();
|
||||
const int amount = PlayerManager::get()->getNumPlayers();
|
||||
for (int n=0; n<amount; n++)
|
||||
{
|
||||
if (UserConfigParams::m_all_players[n].getName() == playerName)
|
||||
if (PlayerManager::get()->getPlayer(n)->getName() == player_name)
|
||||
{
|
||||
LabelWidget* label = getWidget<LabelWidget>("title");
|
||||
label->setText(_("Cannot add a player with this name."), false);
|
||||
@ -119,10 +120,8 @@ 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();
|
||||
PlayerManager::get()->addNewPlayer(player_name);
|
||||
PlayerManager::get()->save();
|
||||
|
||||
// It's unsafe to delete from inside the event handler so we do it
|
||||
// in onUpdate (which checks for m_self_destroy)
|
||||
@ -144,7 +143,7 @@ void EnterPlayerNameDialog::onUpdate(float dt)
|
||||
if (m_self_destroy)
|
||||
{
|
||||
TextBoxWidget* textCtrl = getWidget<TextBoxWidget>("textfield");
|
||||
stringw playerName = textCtrl->getText().trim();
|
||||
stringw player_name = textCtrl->getText().trim();
|
||||
|
||||
// irrLicht is too stupid to remove focus from deleted widgets
|
||||
// so do it by hand
|
||||
@ -158,6 +157,6 @@ void EnterPlayerNameDialog::onUpdate(float dt)
|
||||
|
||||
ModalDialog::dismiss();
|
||||
|
||||
if (listener != NULL) listener->onNewPlayerWithName( playerName );
|
||||
if (listener != NULL) listener->onNewPlayerWithName( player_name );
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "audio/sfx_manager.hpp"
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
#include "config/player.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "guiengine/engine.hpp"
|
||||
#include "guiengine/widgets/button_widget.hpp"
|
||||
#include "guiengine/widgets/label_widget.hpp"
|
||||
@ -155,7 +156,7 @@ void PlayerInfoDialog::showConfirmDialog()
|
||||
_("Do you really want to delete player '%s' ?", m_player->getName());
|
||||
|
||||
|
||||
if (unlock_manager->getCurrentSlotID() == m_player->getUniqueID())
|
||||
if (PlayerManager::get()->getCurrentPlayer() == m_player)
|
||||
{
|
||||
message = _("You cannot delete this player because it is currently in use.");
|
||||
}
|
||||
@ -170,7 +171,7 @@ void PlayerInfoDialog::showConfirmDialog()
|
||||
m_irrlicht_window);
|
||||
a->setTextAlignment(EGUIA_CENTER, EGUIA_CENTER);
|
||||
|
||||
if (unlock_manager->getCurrentSlotID() != m_player->getUniqueID())
|
||||
if (PlayerManager::get()->getCurrentPlayer() != m_player)
|
||||
{
|
||||
ButtonWidget* widget = new ButtonWidget();
|
||||
widget->m_properties[PROP_ID] = "confirmremove";
|
||||
@ -228,12 +229,13 @@ GUIEngine::EventPropagation PlayerInfoDialog::processEvent(const std::string& ev
|
||||
// accept entered name
|
||||
stringw playerName = textCtrl->getText().trim();
|
||||
|
||||
const int playerAmount = UserConfigParams::m_all_players.size();
|
||||
for(int n=0; n<playerAmount; n++)
|
||||
const int player_amount = PlayerManager::get()->getNumPlayers();
|
||||
for(int n=0; n<player_amount; n++)
|
||||
{
|
||||
if (UserConfigParams::m_all_players.get(n) == m_player) continue;
|
||||
const PlayerProfile *player = PlayerManager::get()->getPlayer(n);
|
||||
if (player == m_player) continue;
|
||||
|
||||
if (UserConfigParams::m_all_players[n].getName() == playerName)
|
||||
if (player->getName() == playerName)
|
||||
{
|
||||
ButtonWidget* label = getWidget<ButtonWidget>("renameplayer");
|
||||
label->setBadge(BAD_BADGE);
|
||||
|
@ -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();
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "states_screens/help_screen_1.hpp"
|
||||
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "guiengine/widget.hpp"
|
||||
#include "guiengine/widgets/list_widget.hpp"
|
||||
#include "guiengine/widgets/ribbon_widget.hpp"
|
||||
@ -64,7 +65,7 @@ void HelpScreen1::eventCallback(Widget* widget, const std::string& name, const i
|
||||
InputDevice* device = input_manager->getDeviceList()->getKeyboard(0);
|
||||
|
||||
// Create player and associate player with keyboard
|
||||
StateManager::get()->createActivePlayer(unlock_manager->getCurrentPlayer(),
|
||||
StateManager::get()->createActivePlayer(PlayerManager::get()->getCurrentPlayer(),
|
||||
device, NULL);
|
||||
|
||||
if (kart_properties_manager->getKart(UserConfigParams::m_default_kart) == NULL)
|
||||
|
@ -16,10 +16,12 @@
|
||||
// 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/kart_selection.hpp"
|
||||
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
#include "config/player.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "kart_selection.hpp"
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "guiengine/engine.hpp"
|
||||
#include "guiengine/screen.hpp"
|
||||
@ -125,17 +127,18 @@ static FocusDispatcher* g_dispatcher = NULL;
|
||||
/** A small extension to the spinner widget to add features like player ID
|
||||
* management or badging */
|
||||
|
||||
PlayerNameSpinner::PlayerNameSpinner(KartSelectionScreen* parent, const int playerID)
|
||||
PlayerNameSpinner::PlayerNameSpinner(KartSelectionScreen* parent,
|
||||
const int player_id)
|
||||
{
|
||||
m_playerID = playerID;
|
||||
m_player_id = player_id;
|
||||
m_incorrect = false;
|
||||
m_red_mark_widget = NULL;
|
||||
m_parent = parent;
|
||||
} // PlayerNameSpinner
|
||||
// ------------------------------------------------------------------------
|
||||
void PlayerNameSpinner::setID(const int m_playerID)
|
||||
void PlayerNameSpinner::setID(const int m_player_id)
|
||||
{
|
||||
PlayerNameSpinner::m_playerID = m_playerID;
|
||||
PlayerNameSpinner::m_player_id = m_player_id;
|
||||
} // setID
|
||||
// ------------------------------------------------------------------------
|
||||
/** Add a red mark on the spinner to mean "invalid choice" */
|
||||
@ -183,22 +186,22 @@ void PlayerNameSpinner::markAsCorrect()
|
||||
* number, name, the kart view, the kart's name) */
|
||||
|
||||
PlayerKartWidget::PlayerKartWidget(KartSelectionScreen* parent,
|
||||
StateManager::ActivePlayer* associatedPlayer,
|
||||
Online::Profile* associatedUser,
|
||||
core::recti area, const int playerID,
|
||||
std::string kartGroup,
|
||||
const int irrlichtWidgetID) : Widget(WTYPE_DIV)
|
||||
StateManager::ActivePlayer* associated_player,
|
||||
Online::Profile* associated_user,
|
||||
core::recti area, const int player_id,
|
||||
std::string kart_group,
|
||||
const int irrlicht_widget_id) : Widget(WTYPE_DIV)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if (associatedPlayer)
|
||||
assert(associatedPlayer->ok());
|
||||
if (associated_player)
|
||||
assert(associated_player->ok());
|
||||
m_magic_number = 0x33445566;
|
||||
#endif
|
||||
m_ready_text = NULL;
|
||||
m_parent_screen = parent;
|
||||
|
||||
m_associated_user = associatedUser;
|
||||
m_associatedPlayer = associatedPlayer;
|
||||
m_associated_user = associated_user;
|
||||
m_associated_player = associated_player;
|
||||
x_speed = 1.0f;
|
||||
y_speed = 1.0f;
|
||||
w_speed = 1.0f;
|
||||
@ -206,10 +209,10 @@ PlayerKartWidget::PlayerKartWidget(KartSelectionScreen* parent,
|
||||
m_ready = false;
|
||||
m_not_updated_yet = true;
|
||||
|
||||
m_irrlicht_widget_ID = irrlichtWidgetID;
|
||||
m_irrlicht_widget_id = irrlicht_widget_id;
|
||||
|
||||
m_playerID = playerID;
|
||||
m_properties[PROP_ID] = StringUtils::insertValues("@p%i", m_playerID);
|
||||
m_player_id = player_id;
|
||||
m_properties[PROP_ID] = StringUtils::insertValues("@p%i", m_player_id);
|
||||
|
||||
setSize(area.UpperLeftCorner.X, area.UpperLeftCorner.Y,
|
||||
area.getWidth(), area.getHeight() );
|
||||
@ -221,19 +224,19 @@ PlayerKartWidget::PlayerKartWidget(KartSelectionScreen* parent,
|
||||
// ---- Player identity spinner
|
||||
m_player_ident_spinner = NULL;
|
||||
|
||||
m_player_ident_spinner = new PlayerNameSpinner(parent, m_playerID);
|
||||
m_player_ident_spinner = new PlayerNameSpinner(parent, m_player_id);
|
||||
m_player_ident_spinner->m_x = player_name_x;
|
||||
m_player_ident_spinner->m_y = player_name_y;
|
||||
m_player_ident_spinner->m_w = player_name_w;
|
||||
m_player_ident_spinner->m_h = player_name_h;
|
||||
|
||||
if (parent->m_multiplayer && associatedPlayer)
|
||||
if (parent->m_multiplayer && associated_player)
|
||||
{
|
||||
if (associatedPlayer->getDevice()->getType() == DT_KEYBOARD)
|
||||
if (associated_player->getDevice()->getType() == DT_KEYBOARD)
|
||||
{
|
||||
m_player_ident_spinner->setBadge(KEYBOARD_BADGE);
|
||||
}
|
||||
else if (associatedPlayer->getDevice()->getType() == DT_GAMEPAD)
|
||||
else if (associated_player->getDevice()->getType() == DT_GAMEPAD)
|
||||
{
|
||||
m_player_ident_spinner->setBadge(GAMEPAD_BADGE);
|
||||
}
|
||||
@ -243,20 +246,20 @@ PlayerKartWidget::PlayerKartWidget(KartSelectionScreen* parent,
|
||||
m_player_ident_spinner->setBadge(OK_BADGE);
|
||||
}
|
||||
|
||||
if (irrlichtWidgetID == -1)
|
||||
if (irrlicht_widget_id == -1)
|
||||
{
|
||||
m_player_ident_spinner->m_tab_down_root = g_root_id;
|
||||
}
|
||||
|
||||
spinnerID = StringUtils::insertValues("@p%i_spinner", m_playerID);
|
||||
spinnerID = StringUtils::insertValues("@p%i_spinner", m_player_id);
|
||||
|
||||
m_player_ident_spinner->m_properties[PROP_ID] = spinnerID;
|
||||
if (parent->m_multiplayer)
|
||||
{
|
||||
const int playerAmount = UserConfigParams::m_all_players.size();
|
||||
const int player_amount = PlayerManager::get()->getNumPlayers();
|
||||
m_player_ident_spinner->m_properties[PROP_MIN_VALUE] = "0";
|
||||
m_player_ident_spinner->m_properties[PROP_MAX_VALUE] =
|
||||
StringUtils::toString(playerAmount-1);
|
||||
StringUtils::toString(player_amount-1);
|
||||
m_player_ident_spinner->m_properties[PROP_WRAP_AROUND] = "true";
|
||||
}
|
||||
else
|
||||
@ -277,7 +280,7 @@ PlayerKartWidget::PlayerKartWidget(KartSelectionScreen* parent,
|
||||
m_model_view->m_w = model_w;
|
||||
m_model_view->m_h = model_h;
|
||||
m_model_view->m_properties[PROP_ID] =
|
||||
StringUtils::insertValues("@p%i_model", m_playerID);
|
||||
StringUtils::insertValues("@p%i_model", m_player_id);
|
||||
//m_model_view->setParent(this);
|
||||
m_children.push_back(m_model_view);
|
||||
|
||||
@ -292,7 +295,7 @@ PlayerKartWidget::PlayerKartWidget(KartSelectionScreen* parent,
|
||||
// kart was used, but the addon package was removed), use the
|
||||
// first kart as a default. This way we don't have to hardcode
|
||||
// any kart names.
|
||||
int id = kart_properties_manager->getKartByGroup(kartGroup, 0);
|
||||
int id = kart_properties_manager->getKartByGroup(kart_group, 0);
|
||||
if (id == -1)
|
||||
{
|
||||
props = kart_properties_manager->getKartById(0);
|
||||
@ -339,7 +342,7 @@ PlayerKartWidget::PlayerKartWidget(KartSelectionScreen* parent,
|
||||
m_kart_name->setText(props->getName(), false);
|
||||
m_kart_name->m_properties[PROP_TEXT_ALIGN] = "center";
|
||||
m_kart_name->m_properties[PROP_ID] =
|
||||
StringUtils::insertValues("@p%i_kartname", m_playerID);
|
||||
StringUtils::insertValues("@p%i_kartname", m_player_id);
|
||||
m_kart_name->m_x = kart_name_x;
|
||||
m_kart_name->m_y = kart_name_y;
|
||||
m_kart_name->m_w = kart_name_w;
|
||||
@ -351,9 +354,9 @@ PlayerKartWidget::PlayerKartWidget(KartSelectionScreen* parent,
|
||||
|
||||
PlayerKartWidget::~PlayerKartWidget()
|
||||
{
|
||||
if (GUIEngine::getFocusForPlayer(m_playerID) == this)
|
||||
if (GUIEngine::getFocusForPlayer(m_player_id) == this)
|
||||
{
|
||||
GUIEngine::focusNothingForPlayer(m_playerID);
|
||||
GUIEngine::focusNothingForPlayer(m_player_id);
|
||||
}
|
||||
|
||||
//if (m_player_ID_label->getIrrlichtElement() != NULL)
|
||||
@ -389,30 +392,30 @@ void PlayerKartWidget::setPlayerID(const int newPlayerID)
|
||||
assert(m_magic_number == 0x33445566);
|
||||
|
||||
if (StateManager::get()->getActivePlayer(newPlayerID)
|
||||
!= m_associatedPlayer)
|
||||
!= m_associated_player)
|
||||
{
|
||||
Log::warn("[KartSelectionScreen]", "Internal "
|
||||
"inconsistency, PlayerKartWidget has IDs and "
|
||||
"pointers that do not correspond to one player");
|
||||
fprintf(stderr,
|
||||
" Player: %p - Index: %d - m_associatedPlayer: %p\n",
|
||||
" Player: %p - Index: %d - m_associated_player: %p\n",
|
||||
StateManager::get()->getActivePlayer(newPlayerID),
|
||||
newPlayerID, m_associatedPlayer);
|
||||
newPlayerID, m_associated_player);
|
||||
assert(false);
|
||||
}
|
||||
|
||||
// Remove current focus, but rembmer it
|
||||
Widget* focus = GUIEngine::getFocusForPlayer(m_playerID);
|
||||
GUIEngine::focusNothingForPlayer(m_playerID);
|
||||
Widget* focus = GUIEngine::getFocusForPlayer(m_player_id);
|
||||
GUIEngine::focusNothingForPlayer(m_player_id);
|
||||
|
||||
// Change the player ID
|
||||
m_playerID = newPlayerID;
|
||||
m_player_id = newPlayerID;
|
||||
|
||||
// restore previous focus, but with new player ID
|
||||
if (focus != NULL) focus->setFocusForPlayer(m_playerID);
|
||||
if (focus != NULL) focus->setFocusForPlayer(m_player_id);
|
||||
|
||||
if (m_player_ident_spinner != NULL)
|
||||
m_player_ident_spinner->setID(m_playerID);
|
||||
m_player_ident_spinner->setID(m_player_id);
|
||||
} // setPlayerID
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@ -420,7 +423,7 @@ void PlayerKartWidget::setPlayerID(const int newPlayerID)
|
||||
int PlayerKartWidget::getPlayerID() const
|
||||
{
|
||||
assert(m_magic_number == 0x33445566);
|
||||
return m_playerID;
|
||||
return m_player_id;
|
||||
} // getPlayerID
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@ -431,7 +434,7 @@ void PlayerKartWidget::add()
|
||||
|
||||
assert(KartSelectionScreen::getRunningInstance()
|
||||
->m_kart_widgets.contains(this));
|
||||
if (m_associatedPlayer) // if player is local
|
||||
if (m_associated_player) // if player is local
|
||||
{
|
||||
bool mineInList = false;
|
||||
for (unsigned int p=0; p<StateManager::get()->activePlayerCount(); p++)
|
||||
@ -439,7 +442,7 @@ void PlayerKartWidget::add()
|
||||
#ifdef DEBUG
|
||||
assert(StateManager::get()->getActivePlayer(p)->ok());
|
||||
#endif
|
||||
if (StateManager::get()->getActivePlayer(p) == m_associatedPlayer)
|
||||
if (StateManager::get()->getActivePlayer(p) == m_associated_player)
|
||||
{
|
||||
mineInList = true;
|
||||
}
|
||||
@ -451,8 +454,8 @@ void PlayerKartWidget::add()
|
||||
|
||||
// the first player will have an ID of its own to allow for keyboard
|
||||
// navigation despite this widget being added last
|
||||
if (m_irrlicht_widget_ID != -1)
|
||||
m_player_ident_spinner->m_reserved_id = m_irrlicht_widget_ID;
|
||||
if (m_irrlicht_widget_id != -1)
|
||||
m_player_ident_spinner->m_reserved_id = m_irrlicht_widget_id;
|
||||
else
|
||||
m_player_ident_spinner->m_reserved_id = Widget::getNewNoFocusID();
|
||||
|
||||
@ -468,17 +471,17 @@ void PlayerKartWidget::add()
|
||||
m_player_ident_spinner->clearLabels();
|
||||
|
||||
irr::core::stringw name; // name of the player
|
||||
if (m_associatedPlayer)
|
||||
name = m_associatedPlayer->getProfile()->getName();
|
||||
if (m_associated_player)
|
||||
name = m_associated_player->getProfile()->getName();
|
||||
if (m_associated_user)
|
||||
name = m_associated_user->getUserName();
|
||||
|
||||
if (m_parent_screen->m_multiplayer)
|
||||
{
|
||||
const int playerAmount = UserConfigParams::m_all_players.size();
|
||||
for (int n=0; n<playerAmount; n++)
|
||||
const int player_amount = PlayerManager::get()->getNumPlayers();
|
||||
for (int n=0; n<player_amount; n++)
|
||||
{
|
||||
core::stringw name = UserConfigParams::m_all_players[n].getName();
|
||||
core::stringw name = PlayerManager::get()->getPlayer(n)->getName();
|
||||
m_player_ident_spinner->addLabel( translations->fribidize(name) );
|
||||
}
|
||||
|
||||
@ -499,7 +502,7 @@ void PlayerKartWidget::add()
|
||||
StateManager::ActivePlayer* PlayerKartWidget::getAssociatedPlayer()
|
||||
{
|
||||
assert(m_magic_number == 0x33445566);
|
||||
return m_associatedPlayer;
|
||||
return m_associated_player;
|
||||
} // getAssociatedPlayer
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@ -671,7 +674,7 @@ void PlayerKartWidget::onUpdate(float delta)
|
||||
GUIEngine::EventPropagation PlayerKartWidget::transmitEvent(
|
||||
Widget* w,
|
||||
const std::string& originator,
|
||||
const int m_playerID)
|
||||
const int m_player_id)
|
||||
{
|
||||
assert(m_magic_number == 0x33445566);
|
||||
// if it's declared ready, there is really nothing to process
|
||||
@ -691,7 +694,7 @@ GUIEngine::EventPropagation PlayerKartWidget::transmitEvent(
|
||||
if(UserConfigParams::logGUI())
|
||||
{
|
||||
Log::info("[KartSelectionScreen]", "Identity changed "
|
||||
"for player %s : %s",m_playerID,
|
||||
"for player %s : %s",m_player_id,
|
||||
irr::core::stringc(
|
||||
m_player_ident_spinner->getStringValue()
|
||||
.c_str()).c_str());
|
||||
@ -699,8 +702,8 @@ GUIEngine::EventPropagation PlayerKartWidget::transmitEvent(
|
||||
|
||||
if (m_parent_screen->m_multiplayer)
|
||||
{
|
||||
m_associatedPlayer->setPlayerProfile(
|
||||
UserConfigParams::m_all_players.get(m_player_ident_spinner
|
||||
m_associated_player->setPlayerProfile(
|
||||
PlayerManager::get()->getPlayer(m_player_ident_spinner
|
||||
->getValue()) );
|
||||
}
|
||||
}
|
||||
@ -781,7 +784,7 @@ const std::string& PlayerKartWidget::getKartInternalName() const
|
||||
/** \brief Event callback from ISpinnerConfirmListener */
|
||||
EventPropagation PlayerKartWidget::onSpinnerConfirmed()
|
||||
{
|
||||
KartSelectionScreen::getRunningInstance()->playerConfirm(m_playerID);
|
||||
KartSelectionScreen::getRunningInstance()->playerConfirm(m_player_id);
|
||||
return EVENT_BLOCK;
|
||||
} // onSpinnerConfirmed
|
||||
|
||||
@ -1097,16 +1100,17 @@ bool KartSelectionScreen::playerJoin(InputDevice* device, bool firstPlayer)
|
||||
kartsAreaWidget->m_y + kartsAreaWidget->m_h);
|
||||
|
||||
// ---- Create new active player
|
||||
PlayerProfile* profileToUse = unlock_manager->getCurrentPlayer();
|
||||
PlayerProfile* profile_to_use = PlayerManager::get()->getCurrentPlayer();
|
||||
|
||||
if (!firstPlayer)
|
||||
{
|
||||
const int playerProfileCount = UserConfigParams::m_all_players.size();
|
||||
for (int n=0; n<playerProfileCount; n++)
|
||||
const int player_profile_count = PlayerManager::get()->getNumPlayers();
|
||||
for (int i=0; i<player_profile_count; i++)
|
||||
{
|
||||
if (UserConfigParams::m_all_players[n].isGuestAccount())
|
||||
PlayerProfile *player = PlayerManager::get()->getPlayer(i);
|
||||
if (player->isGuestAccount())
|
||||
{
|
||||
profileToUse = UserConfigParams::m_all_players.get(n);
|
||||
profile_to_use = player;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1124,7 +1128,7 @@ bool KartSelectionScreen::playerJoin(InputDevice* device, bool firstPlayer)
|
||||
}
|
||||
|
||||
const int new_player_id =
|
||||
StateManager::get()->createActivePlayer( profileToUse, device, NULL );
|
||||
StateManager::get()->createActivePlayer( profile_to_use, device, NULL );
|
||||
StateManager::ActivePlayer* aplayer =
|
||||
StateManager::get()->getActivePlayer(new_player_id);
|
||||
|
||||
@ -1814,9 +1818,10 @@ bool KartSelectionScreen::validateIdentChoices()
|
||||
// verify internal consistency in debug mode
|
||||
if (m_multiplayer)
|
||||
{
|
||||
assert( m_kart_widgets[n].getAssociatedPlayer()->getProfile() ==
|
||||
UserConfigParams::m_all_players.get(m_kart_widgets[n]
|
||||
.m_player_ident_spinner->getValue()) );
|
||||
assert(m_kart_widgets[n].getAssociatedPlayer()->getProfile() ==
|
||||
PlayerManager::get()->getPlayer(m_kart_widgets[n]
|
||||
.m_player_ident_spinner->getValue())
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2004,7 +2009,7 @@ void KartSelectionScreen::setKartsFromCurrentGroup()
|
||||
{
|
||||
const KartProperties* prop =
|
||||
kart_properties_manager->getKartById(n);
|
||||
if (unlock_manager->getCurrentSlot()->isLocked(prop->getIdent()))
|
||||
if (PlayerManager::get()->getCurrentPlayer()->isLocked(prop->getIdent()))
|
||||
{
|
||||
w->addItem(
|
||||
_("Locked : solve active challenges to gain access "
|
||||
@ -2036,7 +2041,7 @@ void KartSelectionScreen::setKartsFromCurrentGroup()
|
||||
kart_properties_manager->getKartById(group[n]);
|
||||
const std::string &icon_path = prop->getAbsoluteIconFile();
|
||||
|
||||
if (unlock_manager->getCurrentSlot()->isLocked(prop->getIdent()))
|
||||
if (PlayerManager::get()->getCurrentPlayer()->isLocked(prop->getIdent()))
|
||||
{
|
||||
w->addItem(
|
||||
_("Locked : solve active challenges to gain access "
|
||||
|
@ -199,7 +199,7 @@ public:
|
||||
* management or badging */
|
||||
class PlayerNameSpinner : public GUIEngine::SpinnerWidget
|
||||
{
|
||||
int m_playerID;
|
||||
int m_player_id;
|
||||
bool m_incorrect;
|
||||
irr::gui::IGUIImage* m_red_mark_widget;
|
||||
KartSelectionScreen* m_parent;
|
||||
@ -235,16 +235,19 @@ class PlayerKartWidget : public GUIEngine::Widget,
|
||||
|
||||
/** A reserved ID for this widget if any, -1 otherwise. (If no ID is
|
||||
* reserved, widget will not be in the regular tabbing order */
|
||||
int m_irrlicht_widget_ID;
|
||||
int m_irrlicht_widget_id;
|
||||
|
||||
/** For animation purposes (see method 'move') */
|
||||
int target_x, target_y, target_w, target_h;
|
||||
float x_speed, y_speed, w_speed, h_speed;
|
||||
|
||||
/** Object representing this player */
|
||||
StateManager::ActivePlayer* m_associatedPlayer; // local info
|
||||
int m_playerID;
|
||||
Online::Profile* m_associated_user; // network info
|
||||
/** Local info about the player. */
|
||||
StateManager::ActivePlayer* m_associated_player;
|
||||
int m_player_id;
|
||||
|
||||
/** Network info about the user. */
|
||||
Online::Profile* m_associated_user;
|
||||
|
||||
/** Internal name of the spinner; useful to interpret spinner events,
|
||||
* which contain the name of the activated object */
|
||||
@ -259,7 +262,6 @@ public:
|
||||
LEAK_CHECK()
|
||||
|
||||
/** Sub-widgets created by this widget */
|
||||
//LabelWidget* m_player_ID_label;
|
||||
PlayerNameSpinner* m_player_ident_spinner;
|
||||
GUIEngine::ModelViewWidget* m_model_view;
|
||||
GUIEngine::LabelWidget* m_kart_name;
|
||||
@ -275,11 +277,11 @@ public:
|
||||
bool m_not_updated_yet;
|
||||
|
||||
PlayerKartWidget(KartSelectionScreen* parent,
|
||||
StateManager::ActivePlayer* associatedPlayer,
|
||||
Online::Profile* associatedUser,
|
||||
core::recti area, const int playerID,
|
||||
std::string kartGroup,
|
||||
const int irrlichtWidgetID=-1);
|
||||
StateManager::ActivePlayer* associated_player,
|
||||
Online::Profile* associated_user,
|
||||
core::recti area, const int player_id,
|
||||
std::string kart_group,
|
||||
const int irrlicht_idget_id=-1);
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
~PlayerKartWidget();
|
||||
@ -322,7 +324,7 @@ public:
|
||||
virtual GUIEngine::EventPropagation transmitEvent(
|
||||
GUIEngine::Widget* w,
|
||||
const std::string& originator,
|
||||
const int m_playerID);
|
||||
const int m_player_id);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
/** Sets the size of the widget as a whole, and placed children widgets
|
||||
|
@ -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"
|
||||
@ -339,7 +340,7 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name,
|
||||
InputDevice* device = input_manager->getDeviceList()->getKeyboard(0);
|
||||
|
||||
// Create player and associate player with keyboard
|
||||
StateManager::get()->createActivePlayer(unlock_manager->getCurrentPlayer(),
|
||||
StateManager::get()->createActivePlayer(PlayerManager::get()->getCurrentPlayer(),
|
||||
device, NULL);
|
||||
|
||||
if (kart_properties_manager->getKart(UserConfigParams::m_default_kart) == NULL)
|
||||
@ -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();
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
#include "config/player.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "config/device_config.hpp"
|
||||
#include "guiengine/engine.hpp"
|
||||
#include "guiengine/scalable_font.hpp"
|
||||
@ -78,18 +79,13 @@ void OptionsScreenPlayers::init()
|
||||
refreshPlayerList();
|
||||
|
||||
ButtonWidget* you = getWidget<ButtonWidget>("playername");
|
||||
const std::string& playerID = unlock_manager->getCurrentSlot()->getPlayerID();
|
||||
core::stringw playerName = L"-";
|
||||
PlayerProfile* curr;
|
||||
for_in (curr, UserConfigParams::m_all_players)
|
||||
{
|
||||
if (curr->getUniqueID() == playerID)
|
||||
{
|
||||
playerName = curr->getName();
|
||||
break;
|
||||
}
|
||||
}
|
||||
you->setText( playerName );
|
||||
unsigned int playerID = PlayerManager::get()->getCurrentPlayer()->getUniqueID();
|
||||
core::stringw player_name = L"-";
|
||||
const PlayerProfile* curr = PlayerManager::get()->getPlayerById(playerID);
|
||||
if(curr)
|
||||
player_name = curr->getName();
|
||||
|
||||
you->setText( player_name );
|
||||
((gui::IGUIButton*)you->getIrrlichtElement())->setOverrideFont( GUIEngine::getSmallFont() );
|
||||
|
||||
if (StateManager::get()->getGameState() == GUIEngine::INGAME_MENU)
|
||||
@ -129,7 +125,7 @@ void OptionsScreenPlayers::onNewPlayerWithName(const stringw& newName)
|
||||
|
||||
void OptionsScreenPlayers::deletePlayer(PlayerProfile* player)
|
||||
{
|
||||
UserConfigParams::m_all_players.erase(player);
|
||||
PlayerManager::get()->deletePlayer(player);
|
||||
|
||||
refreshPlayerList();
|
||||
} // deletePlayer
|
||||
@ -140,9 +136,6 @@ void OptionsScreenPlayers::tearDown()
|
||||
{
|
||||
Screen::tearDown();
|
||||
user_config->saveConfig();
|
||||
bool created = unlock_manager->createSlotsIfNeeded();
|
||||
bool removed = unlock_manager->deleteSlotsIfNeeded();
|
||||
if (created || removed) unlock_manager->save();
|
||||
} // tearDown
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@ -174,14 +167,15 @@ void OptionsScreenPlayers::eventCallback(Widget* widget, const std::string& name
|
||||
assert(players != NULL);
|
||||
|
||||
core::stringw selectedPlayer = players->getSelectionLabel();
|
||||
const int playerAmount = UserConfigParams::m_all_players.size();
|
||||
for (int n=0; n<playerAmount; n++)
|
||||
const int player_amount = PlayerManager::get()->getNumPlayers();
|
||||
for (int i=0; i<player_amount; i++)
|
||||
{
|
||||
if (selectedPlayer == translations->fribidize(UserConfigParams::m_all_players[n].getName()))
|
||||
PlayerProfile *player = PlayerManager::get()->getPlayer(i);
|
||||
if (selectedPlayer == translations->fribidize(player->getName()))
|
||||
{
|
||||
if (!(UserConfigParams::m_all_players[n].isGuestAccount()))
|
||||
if (!(player->isGuestAccount()))
|
||||
{
|
||||
new PlayerInfoDialog( &UserConfigParams::m_all_players[n], 0.5f, 0.6f );
|
||||
new PlayerInfoDialog( player, 0.5f, 0.6f );
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -217,15 +211,16 @@ bool OptionsScreenPlayers::refreshPlayerList()
|
||||
// Get rid of previous
|
||||
players->clear();
|
||||
// Rebuild it
|
||||
const int playerAmount = UserConfigParams::m_all_players.size();
|
||||
for (int i = 0; i < playerAmount; i++)
|
||||
const int player_amount = PlayerManager::get()->getNumPlayers();
|
||||
for (int i = 0; i < player_amount; i++)
|
||||
{
|
||||
// FIXME: Using a truncated ASCII string for internal ID. Let's cross
|
||||
// our fingers and hope no one enters two player names that,
|
||||
// when stripped down to ASCII, give the same identifier...
|
||||
const PlayerProfile *player = PlayerManager::get()->getPlayer(i);
|
||||
players->addItem(
|
||||
core::stringc(UserConfigParams::m_all_players[i].getName().c_str()).c_str(),
|
||||
translations->fribidize(UserConfigParams::m_all_players[i].getName()));
|
||||
core::stringc(player->getName().c_str()).c_str(),
|
||||
translations->fribidize(player->getName()));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -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);
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "states_screens/story_mode_lobby.hpp"
|
||||
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "guiengine/widgets/check_box_widget.hpp"
|
||||
#include "guiengine/widgets/list_widget.hpp"
|
||||
#include "states_screens/dialogs/enter_player_name_dialog.hpp"
|
||||
@ -53,29 +54,29 @@ void StoryModeLobbyScreen::init()
|
||||
ListWidget* list = getWidget<ListWidget>("gameslots");
|
||||
list->clear();
|
||||
|
||||
PtrVector<PlayerProfile>& players = UserConfigParams::m_all_players;
|
||||
core::stringw name = UserConfigParams::m_default_player.toString();
|
||||
|
||||
|
||||
if (UserConfigParams::m_default_player.toString().size() > 0)
|
||||
{
|
||||
for (unsigned int n=0; n<players.size(); n++)
|
||||
PlayerProfile *player = PlayerManager::get()->getPlayer(name);
|
||||
if(player)
|
||||
{
|
||||
if (players[n].getName() == UserConfigParams::m_default_player.toString())
|
||||
{
|
||||
unlock_manager->setCurrentSlot(players[n].getUniqueID());
|
||||
StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance());
|
||||
return;
|
||||
}
|
||||
PlayerManager::get()->setCurrentPlayer(player);
|
||||
StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (unsigned int n=0; n<players.size(); n++)
|
||||
for (unsigned int n=0; n<PlayerManager::get()->getNumPlayers(); n++)
|
||||
{
|
||||
if (players[n].isGuestAccount()) continue;
|
||||
const PlayerProfile *player = PlayerManager::get()->getPlayer(n);
|
||||
if (player->isGuestAccount()) continue;
|
||||
|
||||
// FIXME: we're using a trunacted ascii version of the player name as
|
||||
// identifier, let's hope this causes no issues...
|
||||
list->addItem(core::stringc(players[n].getName().c_str()).c_str(),
|
||||
players[n].getName() );
|
||||
list->addItem(core::stringc(player->getName().c_str()).c_str(),
|
||||
player->getName() );
|
||||
}
|
||||
|
||||
list->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
|
||||
@ -110,32 +111,24 @@ void StoryModeLobbyScreen::eventCallback(Widget* widget,
|
||||
|
||||
bool slot_found = false;
|
||||
|
||||
PtrVector<PlayerProfile>& players = UserConfigParams::m_all_players;
|
||||
for (unsigned int n=0; n<players.size(); n++)
|
||||
{
|
||||
if (list->getSelectionLabel() == players[n].getName())
|
||||
{
|
||||
unlock_manager->setCurrentSlot(players[n].getUniqueID());
|
||||
unlock_manager->updateActiveChallengeList();
|
||||
slot_found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!slot_found)
|
||||
{
|
||||
Log::error("StoryModeLobby",
|
||||
"Cannot find player corresponding to slot '%s'.",
|
||||
core::stringc(list->getSelectionLabel().c_str()).c_str());
|
||||
}
|
||||
else
|
||||
PlayerProfile *player = PlayerManager::get()
|
||||
->getPlayer(list->getSelectionLabel());
|
||||
if(player)
|
||||
{
|
||||
PlayerManager::get()->setCurrentPlayer(player);
|
||||
player->computeActive();
|
||||
CheckBoxWidget* cb = getWidget<CheckBoxWidget>("rememberme");
|
||||
if (cb->getState())
|
||||
{
|
||||
UserConfigParams::m_default_player = list->getSelectionLabel();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log::error("StoryModeLobby",
|
||||
"Cannot find player corresponding to slot '%s'.",
|
||||
core::stringc(list->getSelectionLabel().c_str()).c_str());
|
||||
}
|
||||
|
||||
StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance());
|
||||
}
|
||||
@ -149,27 +142,19 @@ void StoryModeLobbyScreen::unloaded()
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void StoryModeLobbyScreen::onNewPlayerWithName(const stringw& newName)
|
||||
void StoryModeLobbyScreen::onNewPlayerWithName(const stringw& new_name)
|
||||
{
|
||||
bool slot_found = false;
|
||||
|
||||
PtrVector<PlayerProfile>& players = UserConfigParams::m_all_players;
|
||||
for (unsigned int n=0; n<players.size(); n++)
|
||||
PlayerProfile *player = PlayerManager::get()->getPlayer(new_name);
|
||||
if(player)
|
||||
{
|
||||
if (players[n].getName() == newName)
|
||||
{
|
||||
unlock_manager->setCurrentSlot(players[n].getUniqueID());
|
||||
unlock_manager->updateActiveChallengeList();
|
||||
slot_found = true;
|
||||
break;
|
||||
}
|
||||
PlayerManager::get()->setCurrentPlayer(player);
|
||||
player->computeActive();
|
||||
}
|
||||
|
||||
if (!slot_found)
|
||||
else
|
||||
{
|
||||
Log::error("StoryModeLobbyScreen",
|
||||
"Cannot find player corresponding to slot '%s'.",
|
||||
core::stringc(newName.c_str()).c_str());
|
||||
core::stringc(new_name.c_str()).c_str());
|
||||
}
|
||||
|
||||
StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance());
|
||||
|
@ -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;
|
||||
|
||||
@ -154,7 +156,7 @@ Track::~Track()
|
||||
unsigned int Track::getNumOfCompletedChallenges()
|
||||
{
|
||||
unsigned int unlocked_challenges = 0;
|
||||
GameSlot* slot = unlock_manager->getCurrentSlot();
|
||||
PlayerProfile *player = PlayerManager::get()->getCurrentPlayer();
|
||||
for (unsigned int i=0; i<m_challenges.size(); i++)
|
||||
{
|
||||
if (m_challenges[i].m_challenge_id == "tutorial")
|
||||
@ -162,7 +164,7 @@ unsigned int Track::getNumOfCompletedChallenges()
|
||||
unlocked_challenges++;
|
||||
continue;
|
||||
}
|
||||
if (slot->getChallenge(m_challenges[i].m_challenge_id)
|
||||
if (player->getChallenge(m_challenges[i].m_challenge_id)
|
||||
->isSolvedAtAnyDifficulty())
|
||||
{
|
||||
unlocked_challenges++;
|
||||
@ -954,8 +956,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(
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include "guiengine/event_handler.hpp"
|
||||
#include "guiengine/engine.hpp"
|
||||
#include "guiengine/scalable_font.hpp"
|
||||
#include "io/xml_writer.hpp"
|
||||
#include "io/utf_writer.hpp"
|
||||
#include "utils/vs.hpp"
|
||||
|
||||
#include <assert.h>
|
||||
@ -100,7 +100,7 @@ void Profiler::setCaptureReport(bool captureReport)
|
||||
{
|
||||
// when disabling capture to file, flush captured data to a file
|
||||
{
|
||||
XMLWriter writer(file_manager->getUserConfigFile("profiling.csv").c_str());
|
||||
UTFWriter writer(file_manager->getUserConfigFile("profiling.csv").c_str());
|
||||
writer << m_capture_report_buffer->getRawBuffer();
|
||||
}
|
||||
m_capture_report = false;
|
||||
|
24
tools/find_unused.sh
Executable file
24
tools/find_unused.sh
Executable file
@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "Searching for unused stkgui files"
|
||||
echo "---------------------------------"
|
||||
cd data/gui
|
||||
l=""
|
||||
for i in $(find . -iname "*.stkgui"); do
|
||||
s=$(basename $i)
|
||||
x=$(find ../../src/states_screens -exec grep -H $s \{} \; | wc -l)
|
||||
echo -n "."
|
||||
if [ $x == "0" ]; then
|
||||
l="$l $i"
|
||||
fi
|
||||
done
|
||||
echo
|
||||
|
||||
for i in $l; do
|
||||
echo "$i appears to be not used."
|
||||
done
|
||||
|
||||
echo "done"
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user