Lock the highest difficulty until the game was beaten

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@12891 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2013-06-19 23:21:22 +00:00
parent 2c336bb89e
commit 16dcb4f38b
3 changed files with 38 additions and 6 deletions

View File

@ -19,5 +19,6 @@
<unlock kart="gnu"/>
<unlock kart="nolok"/>
<unlock difficulty="difficulty_best"/>
<unlock track="fortmagma"/>
</challenge>

View File

@ -331,9 +331,7 @@ void ChallengeData::setUnlocks(const std::string &id, RewardType reward)
}
case UNLOCK_DIFFICULTY:
{
//TODO: difficulty names when unlocking
irr::core::stringw user_name = "?";
addUnlockDifficultyReward(id, user_name);
addUnlockDifficultyReward(id, core::stringw(id.c_str()));
break;
}
case UNLOCK_KART: {

View File

@ -98,8 +98,19 @@ void RaceSetupScreen::eventCallback(Widget* widget, const std::string& name, con
}
else if (selection == "best")
{
UserConfigParams::m_difficulty = RaceManager::DIFFICULTY_BEST;
race_manager->setDifficulty(RaceManager::DIFFICULTY_BEST);
if (unlock_manager->getCurrentSlot()->isLocked("difficulty_best"))
{
unlock_manager->playLockSound();
UserConfigParams::m_difficulty = RaceManager::DIFFICULTY_HARD;
race_manager->setDifficulty(RaceManager::DIFFICULTY_HARD);
w->setSelection(2, PLAYER_ID_GAME_MASTER);
w->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
}
else
{
UserConfigParams::m_difficulty = RaceManager::DIFFICULTY_BEST;
race_manager->setDifficulty(RaceManager::DIFFICULTY_BEST);
}
}
}
else if (name == "gamemode")
@ -169,6 +180,7 @@ void RaceSetupScreen::eventCallback(Widget* widget, const std::string& name, con
{
StateManager::get()->escapePressed();
}
} // eventCallback
// -----------------------------------------------------------------------------
@ -203,8 +215,17 @@ void RaceSetupScreen::init()
Screen::init();
RibbonWidget* w = getWidget<RibbonWidget>("difficulty");
assert( w != NULL );
w->setSelection( UserConfigParams::m_difficulty, PLAYER_ID_GAME_MASTER );
if (UserConfigParams::m_difficulty == RaceManager::DIFFICULTY_BEST &&
unlock_manager->getCurrentSlot()->isLocked("difficulty_best"))
{
w->setSelection(RaceManager::DIFFICULTY_HARD, PLAYER_ID_GAME_MASTER);
}
else
{
w->setSelection( UserConfigParams::m_difficulty, PLAYER_ID_GAME_MASTER );
}
SpinnerWidget* kartamount = getWidget<SpinnerWidget>("aikartamount");
kartamount->setActivated();
@ -306,6 +327,18 @@ void RaceSetupScreen::init()
m_mode_listener = new GameModeRibbonListener(this);
w2->registerHoverListener(m_mode_listener);
if (unlock_manager->getCurrentSlot()->isLocked("difficulty_best"))
{
RibbonWidget* w = getWidget<RibbonWidget>("difficulty");
assert(w != NULL);
int index = w->findItemNamed("best");
Widget* hardestWidget = &w->getChildren()[index];
hardestWidget->setBadge(LOCKED_BADGE);
hardestWidget->setDeactivated();
}
} // init
// -----------------------------------------------------------------------------