Update the number of points are list of locked tracks after winning a trophy
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@11053 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
5af4be2217
commit
b6dac0b50b
@ -34,6 +34,7 @@ bool GameSlot::isLocked(const std::string& feature)
|
||||
void GameSlot::computeActive()
|
||||
{
|
||||
m_points = 0;
|
||||
m_locked_features.clear(); // start afresh
|
||||
|
||||
std::map<std::string, Challenge*>::const_iterator i;
|
||||
for(i = m_challenges_state.begin();
|
||||
@ -111,8 +112,10 @@ void GameSlot::lockFeature(Challenge *challenge)
|
||||
const std::vector<ChallengeData::UnlockableFeature>& features = challenge->getData()->getFeatures();
|
||||
|
||||
const unsigned int amount = (unsigned int)features.size();
|
||||
for(unsigned int n=0; n<amount; n++)
|
||||
m_locked_features[features[n].m_name]=true;
|
||||
for (unsigned int n=0; n<amount; n++)
|
||||
{
|
||||
m_locked_features[features[n].m_name] = true;
|
||||
}
|
||||
} // lockFeature
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -120,11 +123,11 @@ void GameSlot::lockFeature(Challenge *challenge)
|
||||
void GameSlot::unlockFeature(Challenge* c, RaceManager::Difficulty d, bool do_save)
|
||||
{
|
||||
const unsigned int amount = (unsigned int)c->getData()->getFeatures().size();
|
||||
for(unsigned int n=0; n<amount; n++)
|
||||
for (unsigned int n=0; n<amount; n++)
|
||||
{
|
||||
std::string feature = c->getData()->getFeatures()[n].m_name;
|
||||
std::map<std::string,bool>::iterator p=m_locked_features.find(feature);
|
||||
if(p==m_locked_features.end())
|
||||
std::map<std::string,bool>::iterator p = m_locked_features.find(feature);
|
||||
if (p == m_locked_features.end())
|
||||
{
|
||||
//fprintf(stderr,"Unlocking feature '%s' failed: feature is not locked.\n",
|
||||
// (feature).c_str());
|
||||
@ -138,7 +141,7 @@ void GameSlot::unlockFeature(Challenge* c, RaceManager::Difficulty d, bool do_sa
|
||||
c->setSolved(d); // reset isActive flag
|
||||
|
||||
// Save the new unlock information
|
||||
if(do_save) unlock_manager->save();
|
||||
if (do_save) unlock_manager->save();
|
||||
} // unlockFeature
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -158,6 +161,7 @@ void GameSlot::raceFinished()
|
||||
unlockFeature(i->second, race_manager->getDifficulty());
|
||||
} // if isActive && challenge solved
|
||||
}
|
||||
|
||||
//race_manager->setCoinTarget(0); //reset
|
||||
} // raceFinished
|
||||
|
||||
@ -176,6 +180,7 @@ void GameSlot::grandPrixFinished()
|
||||
unlockFeature(i->second, race_manager->getDifficulty());
|
||||
}
|
||||
}
|
||||
|
||||
race_manager->setCoinTarget(0);
|
||||
} // grandPrixFinished
|
||||
|
||||
|
@ -344,3 +344,8 @@ PlayerProfile* UnlockManager::getCurrentPlayer()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void UnlockManager::updateActiveChallengeList()
|
||||
{
|
||||
getCurrentSlot()->computeActive();
|
||||
}
|
||||
|
||||
|
@ -80,6 +80,8 @@ public:
|
||||
|
||||
PlayerProfile* getCurrentPlayer();
|
||||
|
||||
void updateActiveChallengeList();
|
||||
|
||||
}; // UnlockManager
|
||||
|
||||
extern UnlockManager* unlock_manager;
|
||||
|
@ -351,7 +351,7 @@ RaceOverDialog::RaceOverDialog(const float percentWidth,
|
||||
whats_next_btn->m_h = button_h;
|
||||
whats_next_btn->setParent(m_irrlicht_window);
|
||||
|
||||
whats_next_btn->setText( _("See unlocked features") );
|
||||
whats_next_btn->setText( _("You completed a challenge!") );
|
||||
whats_next_btn->m_properties[PROP_ID] = "seeunlocked";
|
||||
|
||||
m_widgets.push_back(whats_next_btn);
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <SColor.h>
|
||||
|
||||
#include "challenges/challenge_data.hpp"
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
#include "guiengine/engine.hpp"
|
||||
#include "guiengine/scalable_font.hpp"
|
||||
#include "io/file_manager.hpp"
|
||||
@ -376,6 +377,9 @@ void FeatureUnlockedCutScene::tearDown()
|
||||
|
||||
m_unlocked_stuff.clearAndDeleteAll();
|
||||
m_all_kart_models.clearAndDeleteAll();
|
||||
|
||||
// update point count and the list of locked/unlocked stuff
|
||||
unlock_manager->updateActiveChallengeList();
|
||||
} // tearDown
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -96,8 +96,8 @@ void RaceResultGUI::enableAllButtons()
|
||||
int n = unlock_manager->getCurrentSlot()->getRecentlyCompletedChallenges().size();
|
||||
if(n>0)
|
||||
{
|
||||
top->setText(n==1 ? _("See unlocked feature")
|
||||
: _("See unlocked features"));
|
||||
top->setText(n==1 ? _("You completed a challenge!")
|
||||
: _("You completed challenges!"));
|
||||
top->setVisible(true);
|
||||
top->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
|
||||
}
|
||||
|
@ -41,19 +41,19 @@ const char* ALL_TRACK_GROUPS_ID = "all";
|
||||
|
||||
DEFINE_SCREEN_SINGLETON( TracksScreen );
|
||||
|
||||
// -----------------------------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
TracksScreen::TracksScreen() : Screen("tracks.stkgui")
|
||||
{
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void TracksScreen::loadedFromFile()
|
||||
{
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void TracksScreen::eventCallback(Widget* widget, const std::string& name, const int playerID)
|
||||
{
|
||||
@ -167,7 +167,7 @@ void TracksScreen::eventCallback(Widget* widget, const std::string& name, const
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void TracksScreen::beforeAddingWidget()
|
||||
{
|
||||
@ -206,7 +206,7 @@ void TracksScreen::beforeAddingWidget()
|
||||
tracks_widget->setItemCountHint( track_manager->getNumberOfTracks() );
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void TracksScreen::init()
|
||||
{
|
||||
@ -243,7 +243,8 @@ void TracksScreen::init()
|
||||
}
|
||||
if (sshot_files.size() == 0)
|
||||
{
|
||||
std::cerr << "/!\\ WARNING: Grand Prix '" << gp->getId() << "' does not contain any valid track.\n";
|
||||
std::cerr << "/!\\ WARNING: Grand Prix '" << gp->getId()
|
||||
<< "' does not contain any valid track.\n";
|
||||
sshot_files.push_back("gui/main_help.png");
|
||||
}
|
||||
|
||||
@ -255,8 +256,9 @@ void TracksScreen::init()
|
||||
}
|
||||
else
|
||||
{
|
||||
gps_widget->addAnimatedItem(translations->fribidize(gp->getName()), gp->getId(), sshot_files, 1.5f,
|
||||
TROPHY_BADGE, IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE );
|
||||
gps_widget->addAnimatedItem(translations->fribidize(gp->getName()), gp->getId(),
|
||||
sshot_files, 1.5f, TROPHY_BADGE,
|
||||
IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE );
|
||||
}
|
||||
}
|
||||
gps_widget->updateItemDisplay();
|
||||
@ -270,15 +272,16 @@ void TracksScreen::init()
|
||||
buildTrackList();
|
||||
|
||||
// select something for the game master
|
||||
// FIXME: 'setSelection' will not scroll up to the passed track, so if given track is not visible
|
||||
// with current scrolling this fails
|
||||
if (!tracks_widget->setSelection(UserConfigParams::m_last_track, PLAYER_ID_GAME_MASTER, true))
|
||||
// FIXME: 'setSelection' will not scroll up to the passed track, so if given track
|
||||
// is not visible with current scrolling this fails
|
||||
if (!tracks_widget->setSelection(UserConfigParams::m_last_track,
|
||||
PLAYER_ID_GAME_MASTER, true))
|
||||
{
|
||||
tracks_widget->setSelection(0, PLAYER_ID_GAME_MASTER, true);
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void TracksScreen::buildTrackList()
|
||||
{
|
||||
@ -314,7 +317,8 @@ void TracksScreen::buildTrackList()
|
||||
else
|
||||
{
|
||||
tracks_widget->addItem(translations->fribidize(curr->getName()), curr->getIdent(),
|
||||
curr->getScreenshotFile(), 0, IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE );
|
||||
curr->getScreenshotFile(), 0,
|
||||
IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE );
|
||||
m_random_track_list.push_back(curr->getIdent());
|
||||
}
|
||||
}
|
||||
@ -354,7 +358,7 @@ void TracksScreen::buildTrackList()
|
||||
std::random_shuffle( m_random_track_list.begin(), m_random_track_list.end() );
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void TracksScreen::setFocusOnTrack(const std::string& trackName)
|
||||
{
|
||||
@ -365,7 +369,7 @@ void TracksScreen::setFocusOnTrack(const std::string& trackName)
|
||||
tracks_widget->setSelection(trackName, PLAYER_ID_GAME_MASTER, true);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void TracksScreen::setFocusOnGP(const std::string& gpName)
|
||||
{
|
||||
@ -376,5 +380,5 @@ void TracksScreen::setFocusOnGP(const std::string& gpName)
|
||||
gps_widget->setSelection(gpName, PLAYER_ID_GAME_MASTER, true);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user