Show what was unlocked
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@12092 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
839ee99c5e
commit
9c59842db9
@ -405,3 +405,20 @@ void UnlockManager::updateActiveChallengeList()
|
||||
getCurrentSlot()->computeActive();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void UnlockManager::findWhatWasUnlocked(int pointsBefore, int pointsNow,
|
||||
std::vector<std::string>& tracks,
|
||||
std::vector<std::string>& gps)
|
||||
{printf("pointsBefore : %i, pointsNow: %i\n", pointsBefore, pointsNow);
|
||||
for (AllChallengesType::iterator it = m_all_challenges.begin();
|
||||
it != m_all_challenges.end(); it++)
|
||||
{
|
||||
ChallengeData* c = it->second;
|
||||
if (c->getNumTrophies() > pointsBefore && c->getNumTrophies() <= pointsNow)
|
||||
{
|
||||
if (c->getTrackId() != "") tracks.push_back(c->getTrackId());
|
||||
else if (c->getGPId() != "") gps.push_back(c->getGPId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -84,6 +84,10 @@ public:
|
||||
/** \param slotid name of the player */
|
||||
void setCurrentSlot(std::string slotid) { m_current_game_slot = slotid; }
|
||||
|
||||
void findWhatWasUnlocked(int pointsBefore, int pointsNow,
|
||||
std::vector<std::string>& tracks,
|
||||
std::vector<std::string>& gps);
|
||||
|
||||
PlayerProfile* getCurrentPlayer();
|
||||
|
||||
void updateActiveChallengeList();
|
||||
|
@ -503,6 +503,7 @@ GUIEngine::EventPropagation RaceOverDialog::processEvent(const std::string& even
|
||||
|
||||
assert(unlocked.size() > 0);
|
||||
scene->addTrophy(race_manager->getDifficulty());
|
||||
scene->findWhatWasUnlocked(race_manager->getDifficulty());
|
||||
|
||||
ModalDialog::dismiss();
|
||||
|
||||
|
@ -142,6 +142,28 @@ void FeatureUnlockedCutScene::loadedFromFile()
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void FeatureUnlockedCutScene::findWhatWasUnlocked(RaceManager::Difficulty difficulty)
|
||||
{
|
||||
int pointsBefore = unlock_manager->getCurrentSlot()->getPoints();
|
||||
int pointsNow = pointsBefore + CHALLENGE_POINTS[difficulty];
|
||||
|
||||
std::vector<std::string> tracks;
|
||||
std::vector<std::string> gps;
|
||||
|
||||
unlock_manager->findWhatWasUnlocked(pointsBefore, pointsNow, tracks, gps);
|
||||
|
||||
for (unsigned int i = 0; i < tracks.size(); i++)
|
||||
{
|
||||
addUnlockedTrack(track_manager->getTrack(tracks[i]));
|
||||
}
|
||||
for (unsigned int i = 0; i < gps.size(); i++)
|
||||
{
|
||||
addUnlockedGP(grand_prix_manager->getGrandPrix(gps[i]));
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void FeatureUnlockedCutScene::addTrophy(RaceManager::Difficulty difficulty)
|
||||
{
|
||||
core::stringw msg;
|
||||
@ -576,13 +598,20 @@ void FeatureUnlockedCutScene::onUpdate(float dt,
|
||||
|
||||
void FeatureUnlockedCutScene::addUnlockedTrack(const Track* track)
|
||||
{
|
||||
assert(track != NULL);
|
||||
if (track == NULL)
|
||||
{
|
||||
std::cerr << "ERROR: Unlocked track does not exist???\n";
|
||||
return;
|
||||
}
|
||||
|
||||
const std::string sshot = track->getScreenshotFile();
|
||||
core::stringw trackname = track->getName();
|
||||
addUnlockedPicture( irr_driver->getTexture(sshot.c_str()), 4.0f, 3.0f,
|
||||
_("You unlocked track %0", trackname));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void FeatureUnlockedCutScene::addUnlockedGP(const GrandPrixData* gp)
|
||||
{
|
||||
std::vector<ITexture*> images;
|
||||
@ -591,7 +620,6 @@ void FeatureUnlockedCutScene::addUnlockedGP(const GrandPrixData* gp)
|
||||
std::cerr << "ERROR: Unlocked GP does not exist???\n";
|
||||
video::ITexture* WTF_image = irr_driver->getTexture( file_manager->getGUIDir() + "/main_help.png");
|
||||
images.push_back(WTF_image);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -140,6 +140,8 @@ public:
|
||||
void eventCallback(GUIEngine::Widget* widget, const std::string& name,
|
||||
const int playerID) OVERRIDE;
|
||||
|
||||
void findWhatWasUnlocked(RaceManager::Difficulty difficulty);
|
||||
|
||||
/** Call before showing up the screen to make a kart come out of the chest.
|
||||
'addUnlockedThings' will invoke this, so you generally don't need to call this directly. */
|
||||
void addUnlockedKart(KartProperties* unlocked_kart, irr::core::stringw msg);
|
||||
|
@ -285,6 +285,7 @@ void GrandPrixLose::eventCallback(GUIEngine::Widget* widget,
|
||||
|
||||
assert(unlocked.size() > 0);
|
||||
scene->addTrophy(race_manager->getDifficulty());
|
||||
scene->findWhatWasUnlocked(race_manager->getDifficulty());
|
||||
|
||||
StateManager::get()->replaceTopMostScreen(scene);
|
||||
}
|
||||
|
@ -405,6 +405,7 @@ void GrandPrixWin::eventCallback(GUIEngine::Widget* widget,
|
||||
|
||||
assert(unlocked.size() > 0);
|
||||
scene->addTrophy(race_manager->getDifficulty());
|
||||
scene->findWhatWasUnlocked(race_manager->getDifficulty());
|
||||
|
||||
StateManager::get()->replaceTopMostScreen(scene);
|
||||
}
|
||||
|
@ -201,6 +201,7 @@ void RaceResultGUI::eventCallback(GUIEngine::Widget* widget,
|
||||
FeatureUnlockedCutScene* scene =
|
||||
FeatureUnlockedCutScene::getInstance();
|
||||
scene->addTrophy(race_manager->getDifficulty());
|
||||
scene->findWhatWasUnlocked(race_manager->getDifficulty());
|
||||
StateManager::get()->popMenu();
|
||||
World::deleteWorld();
|
||||
StateManager::get()->pushScreen(scene);
|
||||
|
Loading…
Reference in New Issue
Block a user