Renamed Challenge to ChallengeStatus (to better describe what
this class is doing).
This commit is contained in:
parent
1f7028f997
commit
f2e6126f8d
@ -17,8 +17,8 @@ src/audio/music_ogg.cpp
|
||||
src/audio/sfx_buffer.cpp
|
||||
src/audio/sfx_manager.cpp
|
||||
src/audio/sfx_openal.cpp
|
||||
src/challenges/challenge.cpp
|
||||
src/challenges/challenge_data.cpp
|
||||
src/challenges/challenge_status.cpp
|
||||
src/challenges/game_slot.cpp
|
||||
src/challenges/unlock_manager.cpp
|
||||
src/config/device_config.cpp
|
||||
@ -346,8 +346,8 @@ src/audio/sfx_base.hpp
|
||||
src/audio/sfx_buffer.hpp
|
||||
src/audio/sfx_manager.hpp
|
||||
src/audio/sfx_openal.hpp
|
||||
src/challenges/challenge.hpp
|
||||
src/challenges/challenge_data.hpp
|
||||
src/challenges/challenge_status.hpp
|
||||
src/challenges/game_slot.hpp
|
||||
src/challenges/unlock_manager.hpp
|
||||
src/config/device_config.hpp
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "challenges/challenge.hpp"
|
||||
|
||||
#include "race/race_manager.hpp"
|
||||
|
||||
/**
|
||||
|
@ -16,7 +16,7 @@
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "challenges/challenge.hpp"
|
||||
#include "challenges/challenge_status.hpp"
|
||||
|
||||
#include "challenges/challenge_data.hpp"
|
||||
#include "io/utf_writer.hpp"
|
||||
@ -33,12 +33,12 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Loads the state for a challenge object (esp. m_state)
|
||||
*/
|
||||
void Challenge::load(const XMLNode* challengesNode)
|
||||
void ChallengeStatus::load(const XMLNode* challenges_node)
|
||||
{
|
||||
const XMLNode* node = challengesNode->getNode( m_data->getId() );
|
||||
const XMLNode* node = challenges_node->getNode( m_data->getId() );
|
||||
if(node == NULL)
|
||||
{
|
||||
Log::info("Challenge", "Couldn't find node <%s> in challenge list."
|
||||
Log::info("ChallengeStatus", "Couldn't find node <%s> in challenge list."
|
||||
"(If this is the first time you play this is normal)\n",
|
||||
m_data->getId().c_str());
|
||||
return;
|
||||
@ -76,7 +76,7 @@ void Challenge::load(const XMLNode* challengesNode)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void Challenge::setSolved(RaceManager::Difficulty d)
|
||||
void ChallengeStatus::setSolved(RaceManager::Difficulty d)
|
||||
{
|
||||
// solve not only the current difficulty but all those before
|
||||
// e.g. if you solved hard then you also get easy
|
||||
@ -88,7 +88,7 @@ void Challenge::setSolved(RaceManager::Difficulty d)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void Challenge::save(UTFWriter& writer)
|
||||
void ChallengeStatus::save(UTFWriter& writer)
|
||||
{
|
||||
writer << L" <"<< m_data->getId() << L">\n"
|
||||
<< L" <easy solved=\""
|
@ -16,8 +16,8 @@
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#ifndef HEADER_CHALLENGE_HPP
|
||||
#define HEADER_CHALLENGE_HPP
|
||||
#ifndef HEADER_CHALLENGE_STATUS_HPP
|
||||
#define HEADER_CHALLENGE_STATUS_HPP
|
||||
|
||||
/**
|
||||
* \defgroup challenges
|
||||
@ -40,14 +40,20 @@ class XMLNode;
|
||||
|
||||
/**
|
||||
* \brief The state of a challenge for one player.
|
||||
* Each Challenge has one ChallengeData associcated, which stores
|
||||
* the actual data about the challenge.
|
||||
* Each ChallengeStatus has one ChallengeData associcated, which stores
|
||||
* the actual data about the challenge. The ChallengeStatus stores if the
|
||||
* challenge is not possible yet (inactive), active (i.e. user can try to
|
||||
* solve it), or solved. This status is stored for each difficulty level.
|
||||
* This data is saved to and loaded from the player.xml file.
|
||||
* A PlayerProfile will store an array of ChallengeStatuses, one for each
|
||||
* Challenge in STK.
|
||||
*
|
||||
* \ingroup challenges
|
||||
*/
|
||||
class Challenge : public NoCopy
|
||||
class ChallengeStatus : public NoCopy
|
||||
{
|
||||
private:
|
||||
/** The different states the challenge can be in. */
|
||||
enum {CH_INACTIVE, // challenge not yet possible
|
||||
CH_ACTIVE, // challenge possible, but not yet solved
|
||||
CH_SOLVED} // challenge was solved
|
||||
@ -57,14 +63,14 @@ private:
|
||||
const ChallengeData* m_data;
|
||||
|
||||
public:
|
||||
Challenge(const ChallengeData* data)
|
||||
ChallengeStatus(const ChallengeData* data)
|
||||
{
|
||||
m_data = data;
|
||||
m_state[RaceManager::DIFFICULTY_EASY] = CH_INACTIVE;
|
||||
m_state[RaceManager::DIFFICULTY_MEDIUM] = CH_INACTIVE;
|
||||
m_state[RaceManager::DIFFICULTY_HARD] = CH_INACTIVE;
|
||||
}
|
||||
virtual ~Challenge() {};
|
||||
virtual ~ChallengeStatus() {};
|
||||
void load(const XMLNode* config);
|
||||
void save(UTFWriter& writer);
|
||||
void setSolved(RaceManager::Difficulty d);
|
||||
@ -102,5 +108,5 @@ public:
|
||||
/** Returns a pointer to the actual Challenge data.
|
||||
*/
|
||||
const ChallengeData* getData() const { return m_data; }
|
||||
}; // Challenge
|
||||
}; // ChallengeStatus
|
||||
#endif
|
@ -19,7 +19,7 @@
|
||||
|
||||
#include "challenges/game_slot.hpp"
|
||||
|
||||
#include "challenges/challenge.hpp"
|
||||
#include "challenges/challenge_status.hpp"
|
||||
#include "challenges/challenge_data.hpp"
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
@ -47,7 +47,7 @@ GameSlot::GameSlot(const XMLNode *node)
|
||||
//-----------------------------------------------------------------------------
|
||||
GameSlot::~GameSlot()
|
||||
{
|
||||
std::map<std::string, Challenge*>::iterator it;
|
||||
std::map<std::string, ChallengeStatus*>::iterator it;
|
||||
for (it = m_challenges_state.begin();it != m_challenges_state.end();it++)
|
||||
{
|
||||
delete it->second;
|
||||
@ -69,7 +69,7 @@ void GameSlot::computeActive()
|
||||
|
||||
m_locked_features.clear(); // start afresh
|
||||
|
||||
std::map<std::string, Challenge*>::const_iterator i;
|
||||
std::map<std::string, ChallengeStatus*>::const_iterator i;
|
||||
for(i = m_challenges_state.begin();
|
||||
i != m_challenges_state.end(); i++)
|
||||
{
|
||||
@ -166,10 +166,10 @@ void GameSlot::computeActive()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void GameSlot::lockFeature(Challenge *challenge)
|
||||
void GameSlot::lockFeature(ChallengeStatus *challenge_status)
|
||||
{
|
||||
const std::vector<ChallengeData::UnlockableFeature>& features =
|
||||
challenge->getData()->getFeatures();
|
||||
challenge_status->getData()->getFeatures();
|
||||
|
||||
const unsigned int amount = (unsigned int)features.size();
|
||||
for (unsigned int n=0; n<amount; n++)
|
||||
@ -184,7 +184,7 @@ void GameSlot::lockFeature(Challenge *challenge)
|
||||
* \param d Difficulty at which the challenge was solved.
|
||||
* \param do_save If true update the challenge file on disk.
|
||||
*/
|
||||
void GameSlot::unlockFeature(Challenge* c, RaceManager::Difficulty d,
|
||||
void GameSlot::unlockFeature(ChallengeStatus* c, RaceManager::Difficulty d,
|
||||
bool do_save)
|
||||
{
|
||||
const unsigned int amount=(unsigned int)c->getData()->getFeatures().size();
|
||||
@ -216,7 +216,7 @@ void GameSlot::unlockFeature(Challenge* c, RaceManager::Difficulty d,
|
||||
void GameSlot::setCurrentChallenge(const std::string &challenge_id)
|
||||
{
|
||||
m_current_challenge = challenge_id=="" ? NULL
|
||||
: getChallenge(challenge_id);
|
||||
: getChallengeStatus(challenge_id);
|
||||
} // setCurrentChallenge
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -232,7 +232,7 @@ void GameSlot::raceFinished()
|
||||
// cast const away so that the challenge can be set to fulfilled.
|
||||
// The 'clean' implementation would involve searching the challenge
|
||||
// in m_challenges_state, which is a bit of an overkill
|
||||
unlockFeature(const_cast<Challenge*>(m_current_challenge),
|
||||
unlockFeature(const_cast<ChallengeStatus*>(m_current_challenge),
|
||||
race_manager->getDifficulty());
|
||||
} // if isActive && challenge solved
|
||||
} // raceFinished
|
||||
@ -247,7 +247,7 @@ void GameSlot::grandPrixFinished()
|
||||
m_current_challenge->isActive(race_manager->getDifficulty()) &&
|
||||
m_current_challenge->getData()->isGPFulfilled() )
|
||||
{
|
||||
unlockFeature(const_cast<Challenge*>(m_current_challenge),
|
||||
unlockFeature(const_cast<ChallengeStatus*>(m_current_challenge),
|
||||
race_manager->getDifficulty());
|
||||
} // if isActive && challenge solved
|
||||
|
||||
@ -262,7 +262,7 @@ void GameSlot::save(UTFWriter &out)
|
||||
{
|
||||
out << " <game-slot playerID=\"" << m_player_unique_id
|
||||
<< "\" first-time=\"" << m_first_time << L"\">\n";
|
||||
std::map<std::string, Challenge*>::const_iterator i;
|
||||
std::map<std::string, ChallengeStatus*>::const_iterator i;
|
||||
for(i = m_challenges_state.begin();
|
||||
i != m_challenges_state.end(); i++)
|
||||
{
|
||||
|
@ -28,9 +28,8 @@ using namespace irr;
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
|
||||
class Challenge;
|
||||
class ChallengeData;
|
||||
class ChallengeStatus;
|
||||
class UTFWriter;
|
||||
class XMLNode;
|
||||
|
||||
@ -56,11 +55,11 @@ class GameSlot
|
||||
* until they are shown to the user) */
|
||||
std::vector<const ChallengeData*> m_unlocked_features;
|
||||
|
||||
std::map<std::string, Challenge*> m_challenges_state;
|
||||
std::map<std::string, ChallengeStatus*> m_challenges_state;
|
||||
|
||||
/** A pointer to the current challenge, or NULL
|
||||
* if no challenge is active. */
|
||||
const Challenge *m_current_challenge;
|
||||
const ChallengeStatus *m_current_challenge;
|
||||
|
||||
friend class UnlockManager;
|
||||
|
||||
@ -80,8 +79,8 @@ public:
|
||||
|
||||
void computeActive();
|
||||
bool isLocked (const std::string& feature);
|
||||
void lockFeature (Challenge *challenge);
|
||||
void unlockFeature (Challenge* c, RaceManager::Difficulty d,
|
||||
void lockFeature (ChallengeStatus *challenge);
|
||||
void unlockFeature (ChallengeStatus* c, RaceManager::Difficulty d,
|
||||
bool do_save=true);
|
||||
void raceFinished ();
|
||||
void grandPrixFinished ();
|
||||
@ -115,17 +114,20 @@ public:
|
||||
/** Returns if this is the first time the intro is shown. */
|
||||
bool isFirstTime() const { return m_first_time; }
|
||||
// ------------------------------------------------------------------------
|
||||
const Challenge *getCurrentChallenge() const { return m_current_challenge; }
|
||||
const ChallengeStatus *getCurrentChallengeStatus() const
|
||||
{
|
||||
return m_current_challenge;
|
||||
} // getCurrentChallengeStatus
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns a challenge given the challenge id.
|
||||
*/
|
||||
const Challenge* getChallenge(const std::string& id) const
|
||||
const ChallengeStatus* getChallengeStatus(const std::string& id) const
|
||||
{
|
||||
std::map<std::string, Challenge*>::const_iterator it =
|
||||
std::map<std::string, ChallengeStatus*>::const_iterator it =
|
||||
m_challenges_state.find(id);
|
||||
assert(it!=m_challenges_state.end());
|
||||
return it->second;
|
||||
} // getChallenge
|
||||
} // getChallengeStatus
|
||||
}; // GameSlot
|
||||
|
||||
#endif
|
||||
|
@ -18,11 +18,11 @@
|
||||
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
|
||||
|
||||
#include "achievements/achievements_manager.hpp"
|
||||
#include "audio/sfx_base.hpp"
|
||||
#include "audio/sfx_manager.hpp"
|
||||
#include "challenges/challenge_data.hpp"
|
||||
#include "challenges/challenge_status.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "config/player_profile.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
@ -204,10 +204,10 @@ GameSlot *UnlockManager::createGameSlot(const XMLNode *node)
|
||||
i!=m_all_challenges.end(); i++)
|
||||
{
|
||||
ChallengeData* cd = i->second;
|
||||
Challenge *challenge = new Challenge(cd);
|
||||
ChallengeStatus *challenge_status = new ChallengeStatus(cd);
|
||||
if(node)
|
||||
challenge->load(node);
|
||||
slot->m_challenges_state[cd->getId()] = challenge;
|
||||
challenge_status->load(node);
|
||||
slot->m_challenges_state[cd->getId()] = challenge_status;
|
||||
}
|
||||
|
||||
slot->computeActive();
|
||||
|
@ -164,15 +164,15 @@ public:
|
||||
void clearUnlocked() { m_game_slot->clearUnlocked(); }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the current challenge for this player. */
|
||||
const Challenge* getCurrentChallenge() const
|
||||
const ChallengeStatus* getCurrentChallengeStatus() const
|
||||
{
|
||||
return m_game_slot->getCurrentChallenge();
|
||||
} // getCurrentChallenge
|
||||
return m_game_slot->getCurrentChallengeStatus();
|
||||
} // getCurrentChallengeStatus
|
||||
// ------------------------------------------------------------------------
|
||||
const Challenge* getChallenge(const std::string &id)
|
||||
const ChallengeStatus* getChallengeStatus(const std::string &id)
|
||||
{
|
||||
return m_game_slot->getChallenge(id);
|
||||
} // getChallenge
|
||||
return m_game_slot->getChallengeStatus(id);
|
||||
} // getChallengeStatus
|
||||
// ------------------------------------------------------------------------
|
||||
unsigned int getNumEasyTrophies() const
|
||||
{
|
||||
|
@ -19,16 +19,10 @@
|
||||
|
||||
#include "karts/kart.hpp"
|
||||
|
||||
#include <math.h>
|
||||
#include <iostream>
|
||||
#include <algorithm> // for min and max
|
||||
|
||||
#include <ICameraSceneNode.h>
|
||||
#include <ISceneManager.h>
|
||||
|
||||
#include "audio/music_manager.hpp"
|
||||
#include "audio/sfx_manager.hpp"
|
||||
#include "audio/sfx_base.hpp"
|
||||
#include "challenges/challenge_status.hpp"
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
@ -73,6 +67,12 @@
|
||||
#include "utils/log.hpp" //TODO: remove after debugging is done
|
||||
#include "utils/vs.hpp"
|
||||
|
||||
#include <ICameraSceneNode.h>
|
||||
#include <ISceneManager.h>
|
||||
|
||||
#include <algorithm> // for min and max
|
||||
#include <iostream>
|
||||
#include <math.h>
|
||||
|
||||
|
||||
#if defined(WIN32) && !defined(__CYGWIN__) && !defined(__MINGW32__)
|
||||
@ -806,7 +806,7 @@ void Kart::finishedRace(float time)
|
||||
if (m_controller->isPlayerController()) // if player is on this computer
|
||||
{
|
||||
PlayerProfile *player = PlayerManager::get()->getCurrentPlayer();
|
||||
const Challenge *challenge = player->getCurrentChallenge();
|
||||
const ChallengeStatus *challenge = player->getCurrentChallengeStatus();
|
||||
// In case of a GP challenge don't make the end animation depend
|
||||
// on if the challenge is fulfilled
|
||||
if(challenge && !challenge->getData()->isGrandPrix())
|
||||
|
@ -15,6 +15,9 @@
|
||||
// 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/dialogs/select_challenge.hpp"
|
||||
|
||||
#include "challenges/challenge_status.hpp"
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
@ -29,7 +32,6 @@
|
||||
#include "network/network_manager.hpp"
|
||||
#include "race/grand_prix_manager.hpp"
|
||||
#include "race/race_manager.hpp"
|
||||
#include "states_screens/dialogs/select_challenge.hpp"
|
||||
#include "tracks/track_manager.hpp"
|
||||
#include "tracks/track.hpp"
|
||||
#include "utils/log.hpp"
|
||||
@ -93,7 +95,8 @@ SelectChallengeDialog::SelectChallengeDialog(const float percentWidth,
|
||||
break;
|
||||
}
|
||||
|
||||
const Challenge* c = PlayerManager::get()->getCurrentPlayer()->getChallenge(challenge_id);
|
||||
const ChallengeStatus* c = PlayerManager::get()->getCurrentPlayer()
|
||||
->getChallengeStatus(challenge_id);
|
||||
|
||||
if (c->isSolved(RaceManager::DIFFICULTY_EASY))
|
||||
{
|
||||
|
@ -19,10 +19,7 @@
|
||||
|
||||
#include "states_screens/race_gui_overworld.hpp"
|
||||
|
||||
using namespace irr;
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "challenges/challenge_status.hpp"
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
@ -54,6 +51,9 @@ using namespace irr;
|
||||
|
||||
#include <ISceneCollisionManager.h>
|
||||
#include <ISceneManager.h>
|
||||
using namespace irr;
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
const int LOCKED = 0;
|
||||
const int OPEN = 1;
|
||||
@ -398,9 +398,9 @@ 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 = PlayerManager::get()->getCurrentPlayer()
|
||||
->getChallenge(challenges[n].m_challenge_id);
|
||||
if (c->isSolved(RaceManager::DIFFICULTY_HARD)) state = COMPLETED_HARD;
|
||||
const ChallengeStatus* c = PlayerManager::get()->getCurrentPlayer()
|
||||
->getChallengeStatus(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,7 +21,7 @@
|
||||
|
||||
#include "addons/addon.hpp"
|
||||
#include "audio/music_manager.hpp"
|
||||
#include "challenges/challenge.hpp"
|
||||
#include "challenges/challenge_status.hpp"
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "config/stk_config.hpp"
|
||||
@ -164,7 +164,7 @@ unsigned int Track::getNumOfCompletedChallenges()
|
||||
unlocked_challenges++;
|
||||
continue;
|
||||
}
|
||||
if (player->getChallenge(m_challenges[i].m_challenge_id)
|
||||
if (player->getChallengeStatus(m_challenges[i].m_challenge_id)
|
||||
->isSolvedAtAnyDifficulty())
|
||||
{
|
||||
unlocked_challenges++;
|
||||
|
Loading…
x
Reference in New Issue
Block a user