diff --git a/sources.cmake b/sources.cmake index a03343490..d20d394ac 100644 --- a/sources.cmake +++ b/sources.cmake @@ -19,7 +19,7 @@ src/audio/sfx_manager.cpp src/audio/sfx_openal.cpp src/challenges/challenge_data.cpp src/challenges/challenge_status.cpp -src/challenges/game_slot.cpp +src/challenges/story_mode_status.cpp src/challenges/unlock_manager.cpp src/config/device_config.cpp src/config/player_manager.cpp @@ -348,7 +348,7 @@ src/audio/sfx_manager.hpp src/audio/sfx_openal.hpp src/challenges/challenge_data.hpp src/challenges/challenge_status.hpp -src/challenges/game_slot.hpp +src/challenges/story_mode_status.hpp src/challenges/unlock_manager.hpp src/config/device_config.hpp src/config/player_manager.hpp diff --git a/src/challenges/game_slot.cpp b/src/challenges/story_mode_status.cpp similarity index 93% rename from src/challenges/game_slot.cpp rename to src/challenges/story_mode_status.cpp index d5d80334f..8ee1c7e2a 100644 --- a/src/challenges/game_slot.cpp +++ b/src/challenges/story_mode_status.cpp @@ -17,7 +17,7 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -#include "challenges/game_slot.hpp" +#include "challenges/story_mode_status.hpp" #include "challenges/challenge_status.hpp" #include "challenges/challenge_data.hpp" @@ -27,7 +27,7 @@ #include "io/xml_node.hpp" //----------------------------------------------------------------------------- -GameSlot::GameSlot(const XMLNode *node) +StoryModeStatus::StoryModeStatus(const XMLNode *node) { m_points = 0; m_first_time = true; @@ -42,25 +42,25 @@ GameSlot::GameSlot(const XMLNode *node) node->get("first-time", &m_first_time); } // if node -} // GameSlot +} // StoryModeStatus //----------------------------------------------------------------------------- -GameSlot::~GameSlot() +StoryModeStatus::~StoryModeStatus() { std::map::iterator it; for (it = m_challenges_state.begin();it != m_challenges_state.end();it++) { delete it->second; } -} // ~GameSlot +} // ~StoryModeStatus //----------------------------------------------------------------------------- -bool GameSlot::isLocked(const std::string& feature) +bool StoryModeStatus::isLocked(const std::string& feature) { return m_locked_features.find(feature)!=m_locked_features.end(); } // featureIsLocked //----------------------------------------------------------------------------- -void GameSlot::computeActive() +void StoryModeStatus::computeActive() { m_points = 0; m_easy_challenges = 0; @@ -166,7 +166,7 @@ void GameSlot::computeActive() //----------------------------------------------------------------------------- -void GameSlot::lockFeature(ChallengeStatus *challenge_status) +void StoryModeStatus::lockFeature(ChallengeStatus *challenge_status) { const std::vector& features = challenge_status->getData()->getFeatures(); @@ -184,7 +184,7 @@ void GameSlot::lockFeature(ChallengeStatus *challenge_status) * \param d Difficulty at which the challenge was solved. * \param do_save If true update the challenge file on disk. */ -void GameSlot::unlockFeature(ChallengeStatus* c, RaceManager::Difficulty d, +void StoryModeStatus::unlockFeature(ChallengeStatus* c, RaceManager::Difficulty d, bool do_save) { const unsigned int amount=(unsigned int)c->getData()->getFeatures().size(); @@ -213,7 +213,7 @@ void GameSlot::unlockFeature(ChallengeStatus* c, RaceManager::Difficulty d, /** Set the current challenge (or NULL if no challenge is done). * \param challenge Pointer to the challenge (or NULL) */ -void GameSlot::setCurrentChallenge(const std::string &challenge_id) +void StoryModeStatus::setCurrentChallenge(const std::string &challenge_id) { m_current_challenge = challenge_id=="" ? NULL : getChallengeStatus(challenge_id); @@ -223,7 +223,7 @@ void GameSlot::setCurrentChallenge(const std::string &challenge_id) /** This is called when a race is finished. See if there is an active * challenge that was fulfilled. */ -void GameSlot::raceFinished() +void StoryModeStatus::raceFinished() { if(m_current_challenge && m_current_challenge->isActive(race_manager->getDifficulty()) && @@ -241,7 +241,7 @@ void GameSlot::raceFinished() /** This is called when a GP is finished. See if there is an active * challenge that was fulfilled. */ -void GameSlot::grandPrixFinished() +void StoryModeStatus::grandPrixFinished() { if(m_current_challenge && m_current_challenge->isActive(race_manager->getDifficulty()) && @@ -255,10 +255,10 @@ void GameSlot::grandPrixFinished() } // grandPrixFinished //----------------------------------------------------------------------------- -/** Writes the data of this GameSlot to the specified stream. +/** Writes the data of this StoryModeStatus to the specified stream. * \param out UTF stream to write to. */ -void GameSlot::save(UTFWriter &out) +void StoryModeStatus::save(UTFWriter &out) { out << " \n"; diff --git a/src/challenges/game_slot.hpp b/src/challenges/story_mode_status.hpp similarity index 97% rename from src/challenges/game_slot.hpp rename to src/challenges/story_mode_status.hpp index 459a1cf95..93bc585c6 100644 --- a/src/challenges/game_slot.hpp +++ b/src/challenges/story_mode_status.hpp @@ -40,7 +40,7 @@ const int CHALLENGE_POINTS[] = { 8, 9, 10 }; * This class contains the progression through challenges for one game slot */ -class GameSlot +class StoryModeStatus { /** Profile names can change, so rather than try to make sure all renames * are done everywhere, assign a unique ID to each profiler. @@ -74,8 +74,8 @@ class GameSlot public: - GameSlot(const XMLNode *node=NULL); - ~GameSlot(); + StoryModeStatus(const XMLNode *node=NULL); + ~StoryModeStatus(); void computeActive(); bool isLocked (const std::string& feature); @@ -128,6 +128,6 @@ public: assert(it!=m_challenges_state.end()); return it->second; } // getChallengeStatus -}; // GameSlot +}; // StoryModeStatus #endif diff --git a/src/challenges/unlock_manager.cpp b/src/challenges/unlock_manager.cpp index fba554ccf..3182e2852 100644 --- a/src/challenges/unlock_manager.cpp +++ b/src/challenges/unlock_manager.cpp @@ -182,12 +182,12 @@ void UnlockManager::addChallenge(const std::string& filename) * challenge exist. * \param id Id of the challenge. */ -const ChallengeData* UnlockManager::getChallenge(const std::string& id) +const ChallengeData* UnlockManager::getChallengeData(const std::string& id) { AllChallengesType::const_iterator it = m_all_challenges.find(id); if(it==m_all_challenges.end()) return NULL; return it->second; -} // getChallenge +} // getChallengeData //----------------------------------------------------------------------------- /** Creates a game slot. It initialises the game slot's status with the @@ -195,10 +195,10 @@ const ChallengeData* UnlockManager::getChallenge(const std::string& id) * states for a player. * \param node The XML game-slots node with all data for a player. */ -GameSlot *UnlockManager::createGameSlot(const XMLNode *node) +StoryModeStatus* UnlockManager::createStoryModeStatus(const XMLNode *node) { - GameSlot *slot = new GameSlot(node); + StoryModeStatus *status = new StoryModeStatus(node); for(AllChallengesType::iterator i = m_all_challenges.begin(); i!=m_all_challenges.end(); i++) @@ -207,12 +207,12 @@ GameSlot *UnlockManager::createGameSlot(const XMLNode *node) ChallengeStatus *challenge_status = new ChallengeStatus(cd); if(node) challenge_status->load(node); - slot->m_challenges_state[cd->getId()] = challenge_status; + status->m_challenges_state[cd->getId()] = challenge_status; } - slot->computeActive(); - return slot; -} // createGameSlot + status->computeActive(); + return status; +} // createStoryModeStatus //----------------------------------------------------------------------------- void UnlockManager::playLockSound() const diff --git a/src/challenges/unlock_manager.hpp b/src/challenges/unlock_manager.hpp index 70a5fd1f6..093079389 100644 --- a/src/challenges/unlock_manager.hpp +++ b/src/challenges/unlock_manager.hpp @@ -24,7 +24,7 @@ #include "config/user_config.hpp" #include "challenges/challenge_data.hpp" -#include "challenges/game_slot.hpp" +#include "challenges/story_mode_status.hpp" #include "utils/no_copy.hpp" #include "utils/ptr_vector.hpp" @@ -48,15 +48,13 @@ private: void readAllChallengesInDirs(const std::vector* all_dirs); - friend class GameSlot; - public: UnlockManager (); ~UnlockManager (); void addOrFreeChallenge(ChallengeData *c); void addChallenge (const std::string& filename); - const ChallengeData *getChallenge (const std::string& id); + const ChallengeData *getChallengeData(const std::string& id); bool isSupportedVersion(const ChallengeData &challenge); @@ -67,7 +65,7 @@ public: std::vector& tracks, std::vector& gps); - GameSlot *createGameSlot(const XMLNode *node=NULL); + StoryModeStatus *createStoryModeStatus(const XMLNode *node=NULL); }; // UnlockManager diff --git a/src/config/player_profile.cpp b/src/config/player_profile.cpp index b1323b16a..537acb956 100644 --- a/src/config/player_profile.cpp +++ b/src/config/player_profile.cpp @@ -18,7 +18,6 @@ #include "config/player_profile.hpp" -#include "challenges/game_slot.hpp" #include "challenges/unlock_manager.hpp" #include "config/player_manager.hpp" #include "io/xml_node.hpp" @@ -38,11 +37,11 @@ PlayerProfile::PlayerProfile(const core::stringw& name, bool is_guest) #ifdef DEBUG m_magic_number = 0xABCD1234; #endif - 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(); + m_name = name; + m_is_guest_account = is_guest; + m_use_frequency = is_guest ? -1 : 0; + m_unique_id = PlayerManager::get()->getUniqueId(); + m_story_mode_status = unlock_manager->createStoryModeStatus(); } // PlayerProfile @@ -61,7 +60,7 @@ PlayerProfile::PlayerProfile(const XMLNode* node) m_magic_number = 0xABCD1234; #endif const XMLNode *xml_game_slot = node->getNode("game-slot"); - m_game_slot = unlock_manager->createGameSlot(xml_game_slot); + m_story_mode_status = unlock_manager->createStoryModeStatus(xml_game_slot); } // PlayerProfile @@ -76,8 +75,8 @@ void PlayerProfile::save(UTFWriter &out) << 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); + assert(m_story_mode_status); + m_story_mode_status->save(out); out << L" \n"; } // save diff --git a/src/config/player_profile.hpp b/src/config/player_profile.hpp index 25856005b..1a8ce792d 100644 --- a/src/config/player_profile.hpp +++ b/src/config/player_profile.hpp @@ -16,11 +16,10 @@ // 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_HPP -#define HEADER_PLAYER_HPP - -#include "challenges/game_slot.hpp" +#ifndef HEADER_PLAYER_PROFILE_HPP +#define HEADER_PLAYER_PROFILE_HPP +#include "challenges/story_mode_status.hpp" #include "config/user_config.hpp" #include "utils/no_copy.hpp" #include "utils/types.hpp" @@ -30,7 +29,6 @@ using namespace irr; #include -class GameSlot; class UTFWriter; /** @@ -64,7 +62,7 @@ private: bool m_is_default; /** The complete challenge state. */ - GameSlot *m_game_slot; + StoryModeStatus *m_story_mode_status; public: @@ -129,64 +127,64 @@ public: /** Returnes if the feature (kart, track) is locked. */ bool isLocked(const std::string &feature) const { - return m_game_slot->isLocked(feature); + return m_story_mode_status->isLocked(feature); } // isLocked // ------------------------------------------------------------------------ /** Returns all active challenges. */ - void computeActive() { m_game_slot->computeActive(); } + void computeActive() { m_story_mode_status->computeActive(); } // ------------------------------------------------------------------------ /** Returns the list of recently completed challenges. */ std::vector getRecentlyCompletedChallenges() { - return m_game_slot->getRecentlyCompletedChallenges(); + return m_story_mode_status->getRecentlyCompletedChallenges(); } // getRecently Completed Challenges // ------------------------------------------------------------------------ /** Sets the currently active challenge. */ void setCurrentChallenge(const std::string &name) { - m_game_slot->setCurrentChallenge(name); + m_story_mode_status->setCurrentChallenge(name); } // setCurrentChallenge // ------------------------------------------------------------------------ /** Notification of a finished race, which can trigger fulfilling * challenges. */ - void raceFinished() { m_game_slot->raceFinished(); } + void raceFinished() { m_story_mode_status->raceFinished(); } // ------------------------------------------------------------------------ /** Callback when a GP is finished (to test if a challenge was * fulfilled). */ - void grandPrixFinished() { m_game_slot->grandPrixFinished(); } + void grandPrixFinished() { m_story_mode_status->grandPrixFinished(); } // ------------------------------------------------------------------------ - unsigned int getPoints() const { return m_game_slot->getPoints(); } + unsigned int getPoints() const { return m_story_mode_status->getPoints(); } // ------------------------------------------------------------------------ - void setFirstTime(bool b) { m_game_slot->setFirstTime(b); } + void setFirstTime(bool b) { m_story_mode_status->setFirstTime(b); } // ------------------------------------------------------------------------ - bool isFirstTime() const { return m_game_slot->isFirstTime(); } + bool isFirstTime() const { return m_story_mode_status->isFirstTime(); } // ------------------------------------------------------------------------ - void clearUnlocked() { m_game_slot->clearUnlocked(); } + void clearUnlocked() { m_story_mode_status->clearUnlocked(); } // ------------------------------------------------------------------------ /** Returns the current challenge for this player. */ const ChallengeStatus* getCurrentChallengeStatus() const { - return m_game_slot->getCurrentChallengeStatus(); + return m_story_mode_status->getCurrentChallengeStatus(); } // getCurrentChallengeStatus // ------------------------------------------------------------------------ const ChallengeStatus* getChallengeStatus(const std::string &id) { - return m_game_slot->getChallengeStatus(id); + return m_story_mode_status->getChallengeStatus(id); } // getChallengeStatus // ------------------------------------------------------------------------ unsigned int getNumEasyTrophies() const { - return m_game_slot->getNumEasyTrophies(); + return m_story_mode_status->getNumEasyTrophies(); } // getNumEasyTrophies // ------------------------------------------------------------------------ unsigned int getNumMediumTrophies() const { - return m_game_slot->getNumMediumTrophies(); + return m_story_mode_status->getNumMediumTrophies(); } // getNumEasyTrophies // ----------------------------------------------------------------------- unsigned int getNumHardTrophies() const { - return m_game_slot->getNumHardTrophies(); + return m_story_mode_status->getNumHardTrophies(); } // getNumHardTropies }; // class PlayerProfile diff --git a/src/modes/cutscene_world.cpp b/src/modes/cutscene_world.cpp index 6ba63c3b1..e394f0670 100644 --- a/src/modes/cutscene_world.cpp +++ b/src/modes/cutscene_world.cpp @@ -20,7 +20,6 @@ #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" diff --git a/src/states_screens/create_server_screen.cpp b/src/states_screens/create_server_screen.cpp index a2edf6a9c..64952f816 100644 --- a/src/states_screens/create_server_screen.cpp +++ b/src/states_screens/create_server_screen.cpp @@ -22,7 +22,6 @@ #include #include -#include "challenges/game_slot.hpp" #include "challenges/unlock_manager.hpp" #include "audio/sfx_manager.hpp" #include "states_screens/online_screen.hpp" diff --git a/src/states_screens/dialogs/select_challenge.cpp b/src/states_screens/dialogs/select_challenge.cpp index 7839ca6ed..883f385e6 100644 --- a/src/states_screens/dialogs/select_challenge.cpp +++ b/src/states_screens/dialogs/select_challenge.cpp @@ -164,7 +164,7 @@ GUIEngine::EventPropagation SelectChallengeDialog::processEvent(const std::strin if (eventSource == "novice" || eventSource == "intermediate" || eventSource == "expert") { - const ChallengeData* challenge = unlock_manager->getChallenge(m_challenge_id); + const ChallengeData* challenge = unlock_manager->getChallengeData(m_challenge_id); if (challenge == NULL) { diff --git a/src/states_screens/feature_unlocked.cpp b/src/states_screens/feature_unlocked.cpp index bdeb22146..f726dbd1d 100644 --- a/src/states_screens/feature_unlocked.cpp +++ b/src/states_screens/feature_unlocked.cpp @@ -22,7 +22,6 @@ #include "audio/music_manager.hpp" #include "challenges/challenge_data.hpp" -#include "challenges/game_slot.hpp" #include "challenges/unlock_manager.hpp" #include "config/player_manager.hpp" #include "guiengine/engine.hpp" diff --git a/src/states_screens/main_menu_screen.cpp b/src/states_screens/main_menu_screen.cpp index 5ffba1630..c2ed26403 100644 --- a/src/states_screens/main_menu_screen.cpp +++ b/src/states_screens/main_menu_screen.cpp @@ -19,9 +19,7 @@ #include "states_screens/main_menu_screen.hpp" -#include - -#include "challenges/game_slot.hpp" +#include "addons/news_manager.hpp" #include "challenges/unlock_manager.hpp" #include "config/player_manager.hpp" #include "graphics/irr_driver.hpp" @@ -46,20 +44,21 @@ #include "states_screens/online_screen.hpp" #include "states_screens/options_screen_video.hpp" #include "states_screens/state_manager.hpp" - #if DEBUG_MENU_ITEM #include "states_screens/feature_unlocked.hpp" #include "states_screens/grand_prix_lose.hpp" #include "states_screens/grand_prix_win.hpp" #endif - #include "states_screens/dialogs/message_dialog.hpp" - -#include "addons/news_manager.hpp" #include "tracks/track_manager.hpp" #include "tracks/track.hpp" #include "utils/string_utils.hpp" + + +#include + + using namespace GUIEngine; using namespace Online; diff --git a/src/states_screens/networking_lobby.cpp b/src/states_screens/networking_lobby.cpp index 3f04b57dd..37ed2a886 100644 --- a/src/states_screens/networking_lobby.cpp +++ b/src/states_screens/networking_lobby.cpp @@ -22,7 +22,6 @@ #include #include -#include "challenges/game_slot.hpp" #include "challenges/unlock_manager.hpp" #include "graphics/irr_driver.hpp" #include "guiengine/scalable_font.hpp" diff --git a/src/states_screens/race_gui_overworld.cpp b/src/states_screens/race_gui_overworld.cpp index 2b1fd0e34..d2233d6b7 100644 --- a/src/states_screens/race_gui_overworld.cpp +++ b/src/states_screens/race_gui_overworld.cpp @@ -460,7 +460,8 @@ void RaceGUIOverworld::drawGlobalMiniMap() continue; } - const ChallengeData* challenge = unlock_manager->getChallenge(challenges[n].m_challenge_id); + const ChallengeData* challenge = + unlock_manager->getChallengeData(challenges[n].m_challenge_id); if (challenge == NULL) { diff --git a/src/tracks/track.cpp b/src/tracks/track.cpp index bdf139d1f..eca974607 100644 --- a/src/tracks/track.cpp +++ b/src/tracks/track.cpp @@ -947,7 +947,7 @@ bool Track::loadMainTrack(const XMLNode &root) assert(closest_challenge_id < (int)m_challenges.size()); const std::string &s = m_challenges[closest_challenge_id].m_challenge_id; - const ChallengeData* challenge = unlock_manager->getChallenge(s); + const ChallengeData* challenge = unlock_manager->getChallengeData(s); if (challenge == NULL) { if (s != "tutorial") @@ -1126,7 +1126,7 @@ bool Track::loadMainTrack(const XMLNode &root) if (challenge != "tutorial") { - c = unlock_manager->getChallenge(challenge); + c = unlock_manager->getChallengeData(challenge); if (c == NULL) { Log::error("track", "Cannot find challenge named <%s>\n",