Fixed challenges to support multiple rewards. Made translation easier.
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@1878 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
e07416f898
commit
1047d5e184
@ -17,7 +17,11 @@
|
|||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
#include "translation.hpp"
|
||||||
#include "challenges/challenge.hpp"
|
#include "challenges/challenge.hpp"
|
||||||
|
#include "world.hpp"
|
||||||
|
#include "race_manager.hpp"
|
||||||
|
#include "track_manager.hpp"
|
||||||
|
|
||||||
Challenge::Challenge(std::string id, std::string name) :
|
Challenge::Challenge(std::string id, std::string name) :
|
||||||
m_state(CH_INACTIVE), m_Id(id), m_Name(name)
|
m_state(CH_INACTIVE), m_Id(id), m_Name(name)
|
||||||
@ -51,3 +55,71 @@ void Challenge::save(lisp::Writer* writer)
|
|||||||
} // save
|
} // save
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
void Challenge::addUnlockTrackReward(std::string track_name)
|
||||||
|
{
|
||||||
|
UnlockableFeature feature;
|
||||||
|
feature.name = track_name;
|
||||||
|
feature.type = UNLOCK_TRACK;
|
||||||
|
m_feature.push_back(feature);
|
||||||
|
}
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void Challenge::addUnlockModeReward(std::string internal_mode_name, std::string user_mode_name)
|
||||||
|
{
|
||||||
|
UnlockableFeature feature;
|
||||||
|
feature.name = internal_mode_name;
|
||||||
|
feature.type = UNLOCK_MODE;
|
||||||
|
feature.user_name = user_mode_name;
|
||||||
|
m_feature.push_back(feature);
|
||||||
|
}
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void Challenge::addUnlockGPReward(std::string gp_name)
|
||||||
|
{
|
||||||
|
UnlockableFeature feature;
|
||||||
|
feature.name = gp_name;
|
||||||
|
feature.type = UNLOCK_GP;
|
||||||
|
m_feature.push_back(feature);
|
||||||
|
}
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void Challenge::addUnlockDifficultyReward(std::string internal_name, std::string user_name)
|
||||||
|
{
|
||||||
|
UnlockableFeature feature;
|
||||||
|
feature.name = internal_name;
|
||||||
|
feature.type = UNLOCK_DIFFICULTY;
|
||||||
|
feature.user_name = user_name;
|
||||||
|
m_feature.push_back(feature);
|
||||||
|
}
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
const std::string Challenge::getUnlockedMessage() const
|
||||||
|
{
|
||||||
|
std::string unlocked_message;
|
||||||
|
|
||||||
|
const unsigned int amount = m_feature.size();
|
||||||
|
for(unsigned int n=0; n<amount; n++)
|
||||||
|
{
|
||||||
|
// add line break if we are showing multiple messages
|
||||||
|
if(n>0) unlocked_message+='\n';
|
||||||
|
|
||||||
|
char message[128];
|
||||||
|
|
||||||
|
// write message depending on feature type
|
||||||
|
switch(m_feature[n].type)
|
||||||
|
{
|
||||||
|
case UNLOCK_TRACK:
|
||||||
|
Track* track = track_manager->getTrack( m_feature[n].name );
|
||||||
|
snprintf(message, 127, _("New track '%s'\nnow available"), gettext(track->getName()) );
|
||||||
|
break;
|
||||||
|
case UNLOCK_MODE:
|
||||||
|
snprintf(message, 127, _("New game mode\n'%s'\nnow available"), m_feature[n].user_name.c_str() );
|
||||||
|
break;
|
||||||
|
case UNLOCK_GP:
|
||||||
|
snprintf(message, 127, _("New Grand Prix '%s'\nnow available"), m_feature[n].name.c_str() );
|
||||||
|
break;
|
||||||
|
case UNLOCK_DIFFICULTY:
|
||||||
|
snprintf(message, 127, _("New difficulty\n'%s'\nnow available"), m_feature[n].user_name.c_str() );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
unlocked_message += message;
|
||||||
|
}
|
||||||
|
|
||||||
|
return unlocked_message;
|
||||||
|
}
|
@ -27,6 +27,18 @@
|
|||||||
#include "lisp/parser.hpp"
|
#include "lisp/parser.hpp"
|
||||||
#include "lisp/writer.hpp"
|
#include "lisp/writer.hpp"
|
||||||
|
|
||||||
|
enum REWARD_TYPE
|
||||||
|
{UNLOCK_TRACK,
|
||||||
|
UNLOCK_GP,
|
||||||
|
UNLOCK_MODE,
|
||||||
|
UNLOCK_DIFFICULTY};
|
||||||
|
|
||||||
|
struct UnlockableFeature
|
||||||
|
{
|
||||||
|
std::string name; // itnernal name
|
||||||
|
std::string user_name; // not all types of feature have one
|
||||||
|
REWARD_TYPE type;
|
||||||
|
};
|
||||||
|
|
||||||
// A base class for all challenges
|
// A base class for all challenges
|
||||||
class Challenge
|
class Challenge
|
||||||
@ -36,32 +48,34 @@ class Challenge
|
|||||||
CH_SOLVED} m_state; // challenge was solved
|
CH_SOLVED} m_state; // challenge was solved
|
||||||
std::string m_Id; // short, internal name for this challenge
|
std::string m_Id; // short, internal name for this challenge
|
||||||
std::string m_Name; // name used in menu for this challenge
|
std::string m_Name; // name used in menu for this challenge
|
||||||
std::string m_Description; // description
|
std::string m_challenge_description; // Message the user gets when the feature is not yet unlocked
|
||||||
std::string m_feature_description; // Description of feature to unlock
|
std::vector<UnlockableFeature> m_feature; // Features to unlock
|
||||||
std::string m_feature; // Feature to unlock
|
std::vector<std::string> m_prerequisites; // what needs to be done before accessing this challenge
|
||||||
std::vector<std::string> m_prerequisites;
|
|
||||||
public:
|
public:
|
||||||
Challenge(std::string id, std::string name);
|
Challenge(std::string id, std::string name);
|
||||||
virtual ~Challenge() {};
|
virtual ~Challenge() {};
|
||||||
const std::string& getId() const {return m_Id; }
|
const std::string& getId() const {return m_Id; }
|
||||||
const std::string& getName() const {return m_Name; }
|
const std::string& getName() const {return m_Name; }
|
||||||
void setFeatureDescription(const std::string& f)
|
|
||||||
{m_feature_description=f; }
|
void addUnlockTrackReward(std::string track_name);
|
||||||
const std::string&
|
void addUnlockModeReward(std::string internal_mode_name, std::string user_mode_name);
|
||||||
getFeatureDescription() const {return m_feature_description; }
|
void addUnlockGPReward(std::string gp_name);
|
||||||
void setFeature(const std::string& s) {m_feature=s; }
|
void addUnlockDifficultyReward(std::string internal_name, std::string user_name);
|
||||||
const std::string& getFeature() const {return m_feature; }
|
|
||||||
|
const std::string getUnlockedMessage() const;
|
||||||
|
const std::vector<UnlockableFeature>&
|
||||||
|
getFeatures() const {return m_feature; }
|
||||||
void setChallengeDescription(const std::string& d)
|
void setChallengeDescription(const std::string& d)
|
||||||
{m_Description=d; }
|
{m_challenge_description=d; }
|
||||||
const std::string&
|
const std::string&
|
||||||
getChallengeDescription() const {return m_Description; }
|
getChallengeDescription() const {return m_challenge_description; }
|
||||||
void addDependency(const std::string id) {m_prerequisites.push_back(id);}
|
void addDependency(const std::string id) {m_prerequisites.push_back(id); }
|
||||||
bool isSolved() const {return m_state==CH_SOLVED; }
|
bool isSolved() const {return m_state==CH_SOLVED; }
|
||||||
bool isActive() const {return m_state==CH_ACTIVE; }
|
bool isActive() const {return m_state==CH_ACTIVE; }
|
||||||
void setSolved() {m_state = CH_SOLVED; }
|
void setSolved() {m_state = CH_SOLVED; }
|
||||||
void setActive() {m_state = CH_ACTIVE; }
|
void setActive() {m_state = CH_ACTIVE; }
|
||||||
const std::vector<std::string>&
|
const std::vector<std::string>&
|
||||||
getPrerequisites() const {return m_prerequisites; }
|
getPrerequisites() const {return m_prerequisites; }
|
||||||
void load(const lisp::Lisp* config);
|
void load(const lisp::Lisp* config);
|
||||||
void save(lisp::Writer* writer);
|
void save(lisp::Writer* writer);
|
||||||
|
|
||||||
|
@ -25,8 +25,7 @@
|
|||||||
CityTime::CityTime() : Challenge("citytime", _("Finish the City track in 5:20"))
|
CityTime::CityTime() : Challenge("citytime", _("Finish the City track in 5:20"))
|
||||||
{
|
{
|
||||||
setChallengeDescription(_("Finish 3 laps on the City track\nwith 3 AI karts\nin under 5:20 minutes."));
|
setChallengeDescription(_("Finish 3 laps on the City track\nwith 3 AI karts\nin under 5:20 minutes."));
|
||||||
setFeatureDescription(_("New track: SnowTux Peak\nnow available"));
|
addUnlockTrackReward("snowtuxpeak");
|
||||||
setFeature("snowtuxpeak");
|
|
||||||
addDependency("junglefollow");
|
addDependency("junglefollow");
|
||||||
} // CityTime
|
} // CityTime
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -26,8 +26,7 @@
|
|||||||
EnergyMathClass::EnergyMathClass() : Challenge("energymathclass", _("Collect Coins in Math Class"))
|
EnergyMathClass::EnergyMathClass() : Challenge("energymathclass", _("Collect Coins in Math Class"))
|
||||||
{
|
{
|
||||||
setChallengeDescription(_("Collect at least 6 coins\non three laps of\nOliver's Math Class\nin under 1 minute."));
|
setChallengeDescription(_("Collect at least 6 coins\non three laps of\nOliver's Math Class\nin under 1 minute."));
|
||||||
setFeatureDescription(_("New game mode\n'Grand Prix'\nnow available"));
|
addUnlockModeReward("grandprix", _("Grand Prix"));
|
||||||
setFeature("grandprix");
|
|
||||||
} // EnergyMathClass
|
} // EnergyMathClass
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -25,8 +25,7 @@
|
|||||||
EnergyShiftingSands::EnergyShiftingSands() : Challenge("energyshiftingsands", _("Collect the Pharaohs Treasure"))
|
EnergyShiftingSands::EnergyShiftingSands() : Challenge("energyshiftingsands", _("Collect the Pharaohs Treasure"))
|
||||||
{
|
{
|
||||||
setChallengeDescription(_("Collect at least 9 coins\non 3 laps of Shifting Sands\nin under 2:20 minutes."));
|
setChallengeDescription(_("Collect at least 9 coins\non 3 laps of Shifting Sands\nin under 2:20 minutes."));
|
||||||
setFeatureDescription(_("New Grand Prix:\nTo the Moon and Back\nnow available"));
|
addUnlockGPReward("To the Moon and Back");
|
||||||
setFeature("To the Moon and Back");
|
|
||||||
// The energymathclass challenge must be done, otherwise GP can't be selected
|
// The energymathclass challenge must be done, otherwise GP can't be selected
|
||||||
addDependency("energymathclass");
|
addDependency("energymathclass");
|
||||||
addDependency("racetracktime");
|
addDependency("racetracktime");
|
||||||
|
@ -25,8 +25,7 @@
|
|||||||
IslandFollow::IslandFollow() : Challenge("islandfollow", _("Follow the Leader on a\nDesert Island"))
|
IslandFollow::IslandFollow() : Challenge("islandfollow", _("Follow the Leader on a\nDesert Island"))
|
||||||
{
|
{
|
||||||
setChallengeDescription(_("Win a Follow the Leader race\nwith 3 AI karts\non a Desert Island."));
|
setChallengeDescription(_("Win a Follow the Leader race\nwith 3 AI karts\non a Desert Island."));
|
||||||
setFeatureDescription(_("New Grand Prix: At World's End\nnow available"));
|
addUnlockGPReward("At world's end");
|
||||||
setFeature("At world's end");
|
|
||||||
addDependency("moonandbackgp");
|
addDependency("moonandbackgp");
|
||||||
addDependency("tollwaytime");
|
addDependency("tollwaytime");
|
||||||
addDependency("citytime");
|
addDependency("citytime");
|
||||||
|
@ -25,8 +25,7 @@
|
|||||||
JungleFollow::JungleFollow() : Challenge("junglefollow", _("Follow the Leader in the Jungle"))
|
JungleFollow::JungleFollow() : Challenge("junglefollow", _("Follow the Leader in the Jungle"))
|
||||||
{
|
{
|
||||||
setChallengeDescription(_("Win a Follow the Leader race\nwith 3 AI karts\nin the Amazonian Jungle."));
|
setChallengeDescription(_("Win a Follow the Leader race\nwith 3 AI karts\nin the Amazonian Jungle."));
|
||||||
setFeatureDescription(_("New track: City\nnow available"));
|
addUnlockTrackReward("city");
|
||||||
setFeature("city");
|
|
||||||
addDependency("penguinplaygroundgp");
|
addDependency("penguinplaygroundgp");
|
||||||
addDependency("racetracktime");
|
addDependency("racetracktime");
|
||||||
} // JungleFollow
|
} // JungleFollow
|
||||||
|
@ -25,8 +25,7 @@
|
|||||||
MoonAndBackGP::MoonAndBackGP() : Challenge("moonandbackgp",_("Win To the Moon and Back\nGrand Prix"))
|
MoonAndBackGP::MoonAndBackGP() : Challenge("moonandbackgp",_("Win To the Moon and Back\nGrand Prix"))
|
||||||
{
|
{
|
||||||
setChallengeDescription(_("Win the To the Moon and Back\nGrand Prix with 3 'Racer'\nLevel AI karts."));
|
setChallengeDescription(_("Win the To the Moon and Back\nGrand Prix with 3 'Racer'\nLevel AI karts."));
|
||||||
setFeatureDescription(_("New Grand Prix: Snag Drive\nnow available"));
|
addUnlockGPReward("Snag Drive");
|
||||||
setFeature("Snag Drive"); //gp3
|
|
||||||
// The energyshiftingsands challenge must be done, otherwise gp2 can't be selected
|
// The energyshiftingsands challenge must be done, otherwise gp2 can't be selected
|
||||||
// Thejunglefollow challenge must be done, to get city for gp3
|
// Thejunglefollow challenge must be done, to get city for gp3
|
||||||
addDependency("energyshiftingsands");
|
addDependency("energyshiftingsands");
|
||||||
|
@ -25,8 +25,7 @@
|
|||||||
PenguinPlaygroundGP::PenguinPlaygroundGP() : Challenge("penguinplaygroundgp", _("Win Penguin Playground Grand\nPrix"))
|
PenguinPlaygroundGP::PenguinPlaygroundGP() : Challenge("penguinplaygroundgp", _("Win Penguin Playground Grand\nPrix"))
|
||||||
{
|
{
|
||||||
setChallengeDescription(_("Win Penguin Playground Grand\nPrix with 3 'Racer' Level AI karts."));
|
setChallengeDescription(_("Win Penguin Playground Grand\nPrix with 3 'Racer' Level AI karts."));
|
||||||
setFeatureDescription(_("New game mode\n'Follow Leader'\nnow available"));
|
addUnlockModeReward("followleader", _("Follow the Leader"));
|
||||||
setFeature("followleader");
|
|
||||||
// The energymathclass challenge must be done, otherwise GP can't be selected
|
// The energymathclass challenge must be done, otherwise GP can't be selected
|
||||||
addDependency("energymathclass");
|
addDependency("energymathclass");
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,7 @@
|
|||||||
RaceTrackTime::RaceTrackTime() : Challenge("racetracktime", _("Finish Race track in 1:15"))
|
RaceTrackTime::RaceTrackTime() : Challenge("racetracktime", _("Finish Race track in 1:15"))
|
||||||
{
|
{
|
||||||
setChallengeDescription(_("Finish 3 laps in the Race track\nwith 3 AI karts\nin under 1:15 minutes."));
|
setChallengeDescription(_("Finish 3 laps in the Race track\nwith 3 AI karts\nin under 1:15 minutes."));
|
||||||
setFeatureDescription(_("New track: Amazonian Journey\nnow available"));
|
addUnlockTrackReward("jungle");
|
||||||
setFeature("jungle");
|
|
||||||
} // RaceTrackTime
|
} // RaceTrackTime
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -25,9 +25,8 @@
|
|||||||
TollwayHead2Head::TollwayHead2Head() : Challenge("tollwayhead", _("Win a Head to Head on\nTux Tollway"))
|
TollwayHead2Head::TollwayHead2Head() : Challenge("tollwayhead", _("Win a Head to Head on\nTux Tollway"))
|
||||||
{
|
{
|
||||||
setChallengeDescription(_("Win a 1 lap Head to Head\non Tux Tollway against 1 'Racer'\nlevel AI kart."));
|
setChallengeDescription(_("Win a 1 lap Head to Head\non Tux Tollway against 1 'Racer'\nlevel AI kart."));
|
||||||
setFeatureDescription(_("New track: Fort Magma\nnow available"));
|
addUnlockTrackReward("fortmagma");
|
||||||
setFeature("fortmagma");
|
}
|
||||||
} // TollwayTime
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void TollwayHead2Head::setRace() const {
|
void TollwayHead2Head::setRace() const {
|
||||||
|
@ -25,8 +25,7 @@
|
|||||||
TollwayTime::TollwayTime() : Challenge("tollwaytime", _("Finish Tux Tollway track in 3:00"))
|
TollwayTime::TollwayTime() : Challenge("tollwaytime", _("Finish Tux Tollway track in 3:00"))
|
||||||
{
|
{
|
||||||
setChallengeDescription(_("Finish 3 laps on the Tux Tollway\ntrack with 3 AI karts\nin under 3:00 minutes."));
|
setChallengeDescription(_("Finish 3 laps on the Tux Tollway\ntrack with 3 AI karts\nin under 3:00 minutes."));
|
||||||
setFeatureDescription(_("New track: Canyon\nnow available"));
|
addUnlockTrackReward("canyon");
|
||||||
setFeature("canyon");
|
|
||||||
} // TollwayTime
|
} // TollwayTime
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -25,9 +25,10 @@
|
|||||||
WorldsEndGP::WorldsEndGP() : Challenge("worldsendgp",_("Win the At World's End\nGrand Prix"))
|
WorldsEndGP::WorldsEndGP() : Challenge("worldsendgp",_("Win the At World's End\nGrand Prix"))
|
||||||
{
|
{
|
||||||
setChallengeDescription(_("Come first in the At World's End\nGrand Prix with 3 'Racer'\nLevel AI karts."));
|
setChallengeDescription(_("Come first in the At World's End\nGrand Prix with 3 'Racer'\nLevel AI karts."));
|
||||||
setFeatureDescription(_("New Grand Prix: All Tracks GP\nand Bonus Preview: Skidding\nnow available.\nSelect 'skidding' as difficulty."));
|
|
||||||
setFeature("All tracks");
|
addUnlockDifficultyReward("skidding","Skidding Preview");
|
||||||
setFeature("skidding"); // Add Skidding Preview
|
addUnlockGPReward("All tracks");
|
||||||
|
|
||||||
addDependency("islandfollow");
|
addDependency("islandfollow");
|
||||||
addDependency("racetracktime");
|
addDependency("racetracktime");
|
||||||
addDependency("tollwaytime");
|
addDependency("tollwaytime");
|
||||||
|
@ -41,7 +41,7 @@ FeatureUnlocked::FeatureUnlocked()
|
|||||||
unlock_manager->clearUnlocked();
|
unlock_manager->clearUnlocked();
|
||||||
|
|
||||||
widget_manager->addTextWgt( WTOK_DESCRIPTION, 60, 30,
|
widget_manager->addTextWgt( WTOK_DESCRIPTION, 60, 30,
|
||||||
m_new_features[0]->getFeatureDescription());
|
m_new_features[0]->getUnlockedMessage());
|
||||||
|
|
||||||
widget_manager->addTextButtonWgt(WTOK_CONTINUE, 50, 7,
|
widget_manager->addTextButtonWgt(WTOK_CONTINUE, 50, 7,
|
||||||
_("Continue"));
|
_("Continue"));
|
||||||
@ -63,7 +63,7 @@ void FeatureUnlocked::select()
|
|||||||
m_new_features.erase(m_new_features.begin());
|
m_new_features.erase(m_new_features.begin());
|
||||||
if(m_new_features.size()>0)
|
if(m_new_features.size()>0)
|
||||||
{
|
{
|
||||||
widget_manager->setWgtText( WTOK_DESCRIPTION, m_new_features[0]->getFeature());
|
widget_manager->setWgtText( WTOK_DESCRIPTION, m_new_features[0]->getUnlockedMessage() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -116,14 +116,14 @@ void UnlockManager::computeActive()
|
|||||||
// The constructor calls computeActive, which actually locks
|
// The constructor calls computeActive, which actually locks
|
||||||
// all features, so unlock the solved ones (and don't try to
|
// all features, so unlock the solved ones (and don't try to
|
||||||
// save the state, since we are currently reading it)
|
// save the state, since we are currently reading it)
|
||||||
if (isLocked(i->second->getFeature()))
|
|
||||||
unlockFeature(i->second, /*save*/ false);
|
unlockFeature(i->second, /*save*/ false);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise lock the feature, and check if the challenge is active
|
// Otherwise lock the feature, and check if the challenge is active
|
||||||
// ----------------------------------------------------------------
|
// ----------------------------------------------------------------
|
||||||
lockFeature(i->second->getFeature());
|
lockFeature(i->second);
|
||||||
std::vector<std::string> pre_req=(i->second)->getPrerequisites();
|
std::vector<std::string> pre_req=(i->second)->getPrerequisites();
|
||||||
bool allSolved=true;
|
bool allSolved=true;
|
||||||
for(std::vector<std::string>::iterator pre =pre_req.begin();
|
for(std::vector<std::string>::iterator pre =pre_req.begin();
|
||||||
@ -181,29 +181,36 @@ void UnlockManager::grandPrixFinished()
|
|||||||
} // grandPrixFinished
|
} // grandPrixFinished
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void UnlockManager::lockFeature(const std::string& feature)
|
void UnlockManager::lockFeature(Challenge* challenge)
|
||||||
{
|
{
|
||||||
m_locked_features[feature]=true;
|
const unsigned int amount = challenge->getFeatures().size();
|
||||||
|
for(unsigned int n=0; n<amount; n++)
|
||||||
|
m_locked_features[challenge->getFeatures()[n].name]=true;
|
||||||
} // lockFeature
|
} // lockFeature
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
void UnlockManager::unlockFeature(Challenge* c, bool save)
|
void UnlockManager::unlockFeature(Challenge* c, bool save)
|
||||||
{
|
{
|
||||||
const std::string& feature=c->getFeature();
|
const unsigned int amount = c->getFeatures().size();
|
||||||
std::map<std::string,bool>::iterator p=m_locked_features.find(feature);
|
for(unsigned int n=0; n<amount; n++)
|
||||||
if(p==m_locked_features.end())
|
|
||||||
{
|
{
|
||||||
fprintf(stderr,"Unlocking feature '%s' failed: feature is not locked.\n",
|
std::string feature = c->getFeatures()[n].name;
|
||||||
(feature).c_str());
|
std::map<std::string,bool>::iterator p=m_locked_features.find(feature);
|
||||||
return;
|
if(p==m_locked_features.end())
|
||||||
|
{
|
||||||
|
//fprintf(stderr,"Unlocking feature '%s' failed: feature is not locked.\n",
|
||||||
|
// (feature).c_str());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_locked_features.erase(p);
|
||||||
}
|
}
|
||||||
m_locked_features.erase(p);
|
|
||||||
|
|
||||||
// Add to list of recently unlocked features
|
// Add to list of recently unlocked features
|
||||||
m_unlocked_features.push_back(c);
|
m_unlocked_features.push_back(c);
|
||||||
c->setSolved(); // reset isActive flag
|
c->setSolved(); // reset isActive flag
|
||||||
|
|
||||||
// Save the new unlock informationxt
|
// Save the new unlock information
|
||||||
if(save) user_config->saveConfig();
|
if(save) user_config->saveConfig();
|
||||||
} // unlockFeature
|
} // unlockFeature
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ public:
|
|||||||
void raceFinished ();
|
void raceFinished ();
|
||||||
void grandPrixFinished ();
|
void grandPrixFinished ();
|
||||||
void unlockFeature (Challenge* c, bool save=true);
|
void unlockFeature (Challenge* c, bool save=true);
|
||||||
void lockFeature (const std::string& feature);
|
void lockFeature (Challenge* challenge);
|
||||||
bool isLocked (const std::string& feature);
|
bool isLocked (const std::string& feature);
|
||||||
}; // UnlockManager
|
}; // UnlockManager
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user