Started implementing locking (follow-the-leader is now locked) + 3 strikes must not appear in single player

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@4024 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2009-09-15 23:49:58 +00:00
parent 0a84da2726
commit 73a925e3b6
5 changed files with 65 additions and 32 deletions

View File

@ -117,6 +117,7 @@ void SFXManager::loadSfx()
}
loadSingleSfx(lisp, "ugh", SOUND_UGH );
loadSingleSfx(lisp, "skid", SOUND_SKID );
loadSingleSfx(lisp, "locked", SOUND_LOCKED );
loadSingleSfx(lisp, "bowling_roll", SOUND_BOWLING_ROLL );
loadSingleSfx(lisp, "bowling_strike",SOUND_BOWLING_STRIKE );
loadSingleSfx(lisp, "winner", SOUND_WINNER );

View File

@ -45,7 +45,7 @@ public:
{
SOUND_UGH, SOUND_SKID, SOUND_BOWLING_ROLL, SOUND_BOWLING_STRIKE, SOUND_WINNER, SOUND_CRASH, SOUND_GRAB,
SOUND_SHOT, SOUND_GOO, SOUND_WEE, SOUND_EXPLOSION, SOUND_BZZT, SOUND_BEEP, SOUND_BACK_MENU, SOUND_USE_ANVIL,
SOUND_USE_PARACHUTE, SOUND_SELECT_MENU, SOUND_MOVE_MENU, SOUND_FULL,
SOUND_USE_PARACHUTE, SOUND_SELECT_MENU, SOUND_MOVE_MENU, SOUND_FULL, SOUND_LOCKED,
SOUND_PRESTART, SOUND_START, SOUND_ENGINE_SMALL, SOUND_ENGINE_LARGE,
NUM_SOUNDS
};

View File

@ -24,6 +24,8 @@
#include <vector>
#include <stdio.h>
#include "audio/sfx_base.hpp"
#include "audio/sfx_manager.hpp"
#include "config/user_config.hpp"
#include "challenges/challenge_data.hpp"
#include "io/file_manager.hpp"
@ -42,6 +44,8 @@ UnlockManager::UnlockManager()
// in main).
unlock_manager=this;
m_locked_sound = sfx_manager->newSFX(SFXManager::SOUND_LOCKED);
// Read challenges from .../data
// -----------------------------
std::set<std::string> result;
@ -220,6 +224,11 @@ void UnlockManager::save()
challenge_file.close();
} // save
void UnlockManager::playLockSound() const
{
m_locked_sound->play();
}
//-----------------------------------------------------------------------------
void UnlockManager::computeActive()
{

View File

@ -26,10 +26,12 @@
#include <fstream>
class XMLNode;
class SFXBase;
class UnlockManager
{
private:
SFXBase *m_locked_sound;
typedef std::map<std::string, Challenge*> AllChallengesType;
AllChallengesType m_all_challenges;
std::map<std::string, bool> m_locked_features;
@ -55,6 +57,10 @@ public:
void lockFeature (Challenge* challenge);
bool isLocked (const std::string& feature);
void check () const;
/** Eye- (or rather ear-) candy. Play a sound when user tries to access a locked area */
void playLockSound() const;
}; // UnlockManager
extern UnlockManager* unlock_manager;

View File

@ -22,6 +22,7 @@
#include "main_loop.hpp"
#include "audio/sound_manager.hpp"
#include "challenges/unlock_manager.hpp"
#include "config/player.hpp"
#include "config/user_config.hpp"
#include "graphics/irr_driver.hpp"
@ -182,15 +183,31 @@ void StateManager::menuEventRaceSetup(Widget* widget, const std::string& name)
w2->addItem( _("Snaky Competition\nAll blows allowed, so catch weapons and make clever use of them!"),
"normal",
file_manager->getDataDir() + "/gui/mode_normal.png");
w2->addItem( _("Time Trial\nContains no powerups, so only your driving skills matter!"),
"timetrial",
file_manager->getDataDir() + "/gui/mode_tt.png");
w2->addItem( _("Follow the Leader\nrun for second place, as the last kart will be disqualified every time the counter hits zero. Beware : going in front of the leader will get you eliminated too!"),
"ftl",
file_manager->getDataDir() + "/gui/mode_ftl.png");
w2->addItem( _("3-Strikes Battle\nonly in multiplayer games. Hit others with weapons until they lose all their lives."),
"3strikes",
file_manager->getDataDir() + "/gui/mode_3strikes.png");
if (unlock_manager->isLocked("followtheleader"))
{
w2->addItem( _("Locked!\nFulfill challenges to gain access to locked areas"),
"locked",
file_manager->getDataDir() + "textures/gui_lock.png");
}
else
{
w2->addItem( _("Follow the Leader\nrun for second place, as the last kart will be disqualified every time the counter hits zero. Beware : going in front of the leader will get you eliminated too!"),
"ftl",
file_manager->getDataDir() + "/gui/mode_ftl.png");
}
if (race_manager->getNumPlayers() > 1)
{
w2->addItem( _("3-Strikes Battle\nonly in multiplayer games. Hit others with weapons until they lose all their lives."),
"3strikes",
file_manager->getDataDir() + "/gui/mode_3strikes.png");
}
getCurrentScreen()->m_inited = true;
}
w2->updateItemDisplay();
@ -240,9 +257,14 @@ void StateManager::menuEventRaceSetup(Widget* widget, const std::string& name)
}
else if (selectedMode == "3strikes")
{
// TODO - 3 strikes battle mode selection
// TODO - 3 strikes battle track selection
race_manager->setMinorMode(RaceManager::MINOR_MODE_3_STRIKES);
}
else if (selectedMode == "locked")
{
std::cout << "Requesting sound to be played\n";
unlock_manager->playLockSound();
}
}
else if(name == "aikartamount")
{
@ -308,43 +330,33 @@ void StateManager::menuEventTracks(Widget* widget, const std::string& name)
DynamicRibbonWidget* w = getCurrentScreen()->getWidget<DynamicRibbonWidget>("tracks");
assert( w != NULL );
if(!getCurrentScreen()->m_inited)
if (!getCurrentScreen()->m_inited)
{
/*
const std::vector<std::string>&
getAllGroups() const { return m_all_groups; }
size_t getNumberOfTracks() const { return m_tracks.size(); }
Track *getTrack(size_t id) const { return m_tracks[id]; }
Track *getTrack(const std::string& ident) const;
void unavailable(const std::string &ident);
void setUnavailableTracks(const std::vector<std::string> &tracks);
bool isAvailable(unsigned int n) const {return m_track_avail[n];}
*/
const int trackAmount = track_manager->getNumberOfTracks();
bool hasLockedTracks = false;
for (int n=0; n<trackAmount; n++)
{
Track* curr = track_manager->getTrack(n);
if (unlock_manager->isLocked(curr->getIdent()))
{
hasLockedTracks = true;
continue;
}
w->addItem(curr->getName(), curr->getIdent(), curr->getScreenshotFile());
}
/*
w->addItem("Track 1","t1","gui/track1.png");
w->addItem("Track 2","t2","gui/track2.png");
w->addItem("Track 3","t3","gui/track3.png");
w->addItem("Track 4","t4","gui/track4.png");
w->addItem("Track 5","t5","gui/track5.png");
w->addItem("Track 6","t6","gui/track6.png");
w->addItem("Track 7","t7","gui/track7.png");
w->addItem("Track 8","t8","gui/track8.png");
*/
if (hasLockedTracks)
{
w->addItem(_("Locked Tracks"), "Lock", "textures/gui_lock.png");
}
getCurrentScreen()->m_inited = true;
}
w->updateItemDisplay();
}
// -- track seelction screen
if(name == "tracks")
if (name == "tracks")
{
DynamicRibbonWidget* w2 = dynamic_cast<DynamicRibbonWidget*>(widget);
if(w2 != NULL)
@ -360,7 +372,7 @@ void StateManager::menuEventTracks(Widget* widget, const std::string& name)
}
}
}
else if(name == "gps")
else if (name == "gps")
{
RibbonWidget* w = dynamic_cast<RibbonWidget*>(widget);
if(w != NULL)
@ -416,6 +428,11 @@ void StateManager::eventCallback(Widget* widget, const std::string& name)
{
std::cout << "event!! " << name.c_str() << std::endl;
if (name == "lock")
{
unlock_manager->playLockSound();
}
Screen* topScreen = getCurrentScreen();
if (topScreen == NULL) return;
const std::string& screen_name = topScreen->getName();