Show 'feature unlocked' screen when unlocking a feature. It's not yet complete : it doesn't really show what you unlocked, and you can't leave the screen properly (game crashes or hangs)

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@4889 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria
2010-03-01 20:17:31 +00:00
parent 2ee8c18e68
commit d27e3d90c5
4 changed files with 62 additions and 7 deletions

View File

@@ -87,7 +87,7 @@ void AbstractStateManager::pushMenu(std::string name)
if (m_game_mode == GAME)
{
setGameState(INGAME_MENU);
World::getWorld()->pause();
if (World::getWorld() != NULL) World::getWorld()->pause();
}
else
{
@@ -161,7 +161,7 @@ void AbstractStateManager::popMenu()
m_menu_stack.push_back("race");
if (m_game_mode == INGAME_MENU)
{
World::getWorld()->unpause();
if (World::getWorld() != NULL) World::getWorld()->unpause();
}
setGameState(GAME);
cleanForGame();

View File

@@ -137,10 +137,13 @@ protected:
public:
World();
virtual ~World();
/** Returns a pointer to the world object. This is only used by
* the race_manager. */
/** Returns a pointer to the (singleton) world object. */
static World* getWorld() { return m_world; }
/** Delete the )singleton) world object, if it exists, and sets the singleton pointer to NULL.
* It's harmless to call this if the world has been deleted already. */
static void deleteWorld() { delete m_world; m_world = NULL; }
/** Sets the pointer to the world object. This is only used by
* the race_manager.*/
static void setWorld(World *world) {m_world = world; }

View File

@@ -270,7 +270,7 @@ void RaceManager::startNextRace()
*/
void RaceManager::next()
{
delete World::getWorld();
World::deleteWorld();
m_num_finished_karts = 0;
m_num_finished_players = 0;
m_track_number++;
@@ -386,7 +386,7 @@ void RaceManager::exitRace()
GrandPrixOver::getInstance()->setKarts(winners);
}
delete World::getWorld();
World::deleteWorld();
m_track_number = 0;
} // exitRace

View File

@@ -21,14 +21,18 @@
#include "io/file_manager.hpp"
#include "input/input_manager.hpp"
#include "karts/kart.hpp"
#include "karts/kart_properties_manager.hpp"
#include "modes/three_strikes_battle.hpp"
#include "modes/world.hpp"
#include "network/network_manager.hpp"
#include "race/race_manager.hpp"
#include "states_screens/dialogs/race_over_dialog.hpp"
#include "states_screens/feature_unlocked.hpp"
#include "states_screens/main_menu_screen.hpp"
#include "states_screens/race_setup_screen.hpp"
#include "states_screens/state_manager.hpp"
#include "tracks/track_manager.hpp"
#include "tracks/track.hpp"
#include "utils/string_utils.hpp"
#include "utils/translation.hpp"
@@ -366,6 +370,49 @@ GUIEngine::EventPropagation RaceOverDialog::processEvent(const std::string& even
race_manager->next();
return GUIEngine::EVENT_BLOCK;
}
else if (eventSource == "seeunlocked")
{
std::vector<const Challenge*> unlocked = unlock_manager->getRecentlyUnlockedFeatures();
unlock_manager->clearUnlocked();
FeatureUnlockedCutScene* scene = FeatureUnlockedCutScene::getInstance();
for (unsigned int n=0; n<unlocked.size(); n++)
{
//FIXME: this is only a placeholder
const bool unlocked_kart = true;
const bool unlocked_track = false;
const bool unlocked_game_mode = false;
//FIXME: update the feature unlocked scene to be able to handle when many features are unlocked
if (unlocked_kart)
{
// the passed kart will not be modified, that's why I allow myself to use const_cast
scene->setUnlockedKart( const_cast<KartProperties*>(kart_properties_manager->getKart("gnu")) );
}
else if (unlocked_track)
{
scene->setUnlockedPicture( irr_driver->getTexture(track_manager->getTrack("beach")->getScreenshotFile().c_str()) );
}
else if (unlocked_game_mode)
{
//TODO!
assert(false);
}
else
{
assert(false);
}
}
ModalDialog::dismiss();
// clear the race (FIXME: is this the right way to go?)
World::deleteWorld();
StateManager::get()->pushScreen(scene);
return GUIEngine::EVENT_BLOCK;
}
return GUIEngine::EVENT_LET;
}
@@ -373,7 +420,12 @@ GUIEngine::EventPropagation RaceOverDialog::processEvent(const std::string& even
void RaceOverDialog::escapePressed()
{
if (race_manager->getMajorMode() == RaceManager::MAJOR_MODE_GRAND_PRIX)
if (unlock_manager->getRecentlyUnlockedFeatures().size() > 0)
{
std::string what = "seeunlocked";
processEvent(what);
}
else if (race_manager->getMajorMode() == RaceManager::MAJOR_MODE_GRAND_PRIX)
{
std::string what = "continuegp";
processEvent(what);