The chest scene is now shown for challenges that require beating a GP too
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@4958 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
5239b62e0d
commit
38b0cfaa2a
@ -31,8 +31,8 @@
|
||||
#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 "tracks/track_manager.hpp"
|
||||
//#include "tracks/track.hpp"
|
||||
#include "utils/string_utils.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
|
||||
@ -411,62 +411,7 @@ GUIEngine::EventPropagation RaceOverDialog::processEvent(const std::string& even
|
||||
*/
|
||||
|
||||
assert(unlocked.size() > 0);
|
||||
for (unsigned int n=0; n<unlocked.size(); n++)
|
||||
{
|
||||
const std::vector<UnlockableFeature>& unlockedFeatures = unlocked[n]->getFeatures();
|
||||
assert(unlockedFeatures.size() > 0);
|
||||
|
||||
for (unsigned int i=0; i<unlockedFeatures.size(); i++)
|
||||
{
|
||||
|
||||
switch (unlockedFeatures[i].type)
|
||||
{
|
||||
case UNLOCK_TRACK:
|
||||
{
|
||||
Track* track = track_manager->getTrack(unlockedFeatures[i].name);
|
||||
assert(track != NULL);
|
||||
const std::string sshot = track->getScreenshotFile();
|
||||
scene->addUnlockedPicture( irr_driver->getTexture(sshot.c_str()), 1.0f, 0.75f,
|
||||
unlockedFeatures[i].getUnlockedMessage() );
|
||||
break;
|
||||
}
|
||||
case UNLOCK_GP:
|
||||
{
|
||||
//TODO
|
||||
break;
|
||||
}
|
||||
case UNLOCK_MODE:
|
||||
{
|
||||
const RaceManager::MinorRaceModeType mode =
|
||||
RaceManager::getModeIDFromInternalName(unlockedFeatures[i].name.c_str());
|
||||
const std::string icon = file_manager->getDataDir() + "/" + RaceManager::getIconOf(mode);
|
||||
scene->addUnlockedPicture( irr_driver->getTexture(icon.c_str()), 0.8f, 0.8f,
|
||||
unlockedFeatures[i].getUnlockedMessage() );
|
||||
break;
|
||||
}
|
||||
case UNLOCK_KART:
|
||||
{
|
||||
const KartProperties* kart = kart_properties_manager->getKart(unlockedFeatures[i].name);
|
||||
assert(kart != NULL);
|
||||
|
||||
// the passed kart will not be modified, that's why I allow myself to use const_cast
|
||||
scene->addUnlockedKart( const_cast<KartProperties*>(kart),
|
||||
unlockedFeatures[i].getUnlockedMessage() );
|
||||
break;
|
||||
}
|
||||
case UNLOCK_DIFFICULTY:
|
||||
{
|
||||
//TODO
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
} // next feature
|
||||
} // next challenge
|
||||
scene->addUnlockedThings(unlocked);
|
||||
|
||||
ModalDialog::dismiss();
|
||||
|
||||
|
@ -1,13 +1,17 @@
|
||||
|
||||
#include "states_screens/feature_unlocked.hpp"
|
||||
|
||||
|
||||
#include "challenges/challenge.hpp"
|
||||
#include "guiengine/engine.hpp"
|
||||
#include "io/file_manager.hpp"
|
||||
#include "items/item_manager.hpp"
|
||||
#include "karts/kart.hpp"
|
||||
#include "karts/kart_properties_manager.hpp"
|
||||
#include "modes/world.hpp"
|
||||
#include "states_screens/main_menu_screen.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
#include "tracks/track.hpp"
|
||||
#include "tracks/track_manager.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
|
||||
#include <SColor.h>
|
||||
@ -292,6 +296,78 @@ void FeatureUnlockedCutScene::onUpdate(float dt, irr::video::IVideoDriver* drive
|
||||
|
||||
// -------------------------------------------------------------------------------------
|
||||
|
||||
void FeatureUnlockedCutScene::addUnlockedThings(const std::vector<const Challenge*> unlocked)
|
||||
{
|
||||
for (unsigned int n=0; n<unlocked.size(); n++)
|
||||
{
|
||||
const std::vector<UnlockableFeature>& unlockedFeatures = unlocked[n]->getFeatures();
|
||||
assert(unlockedFeatures.size() > 0);
|
||||
|
||||
for (unsigned int i=0; i<unlockedFeatures.size(); i++)
|
||||
{
|
||||
|
||||
switch (unlockedFeatures[i].type)
|
||||
{
|
||||
case UNLOCK_TRACK:
|
||||
{
|
||||
Track* track = track_manager->getTrack(unlockedFeatures[i].name);
|
||||
assert(track != NULL);
|
||||
const std::string sshot = track->getScreenshotFile();
|
||||
addUnlockedPicture( irr_driver->getTexture(sshot.c_str()), 1.0f, 0.75f,
|
||||
unlockedFeatures[i].getUnlockedMessage() );
|
||||
break;
|
||||
}
|
||||
case UNLOCK_GP:
|
||||
{
|
||||
//TODO: implement
|
||||
std::cerr << "OK, I see you unlocked a GP, but this is not supported yet\n";
|
||||
|
||||
video::ITexture* tex = irr_driver->getTexture( file_manager->getGUIDir() + "/main_help.png");
|
||||
addUnlockedPicture( tex, 1.0f, 0.75f,
|
||||
unlockedFeatures[i].getUnlockedMessage() );
|
||||
break;
|
||||
}
|
||||
case UNLOCK_MODE:
|
||||
{
|
||||
const RaceManager::MinorRaceModeType mode =
|
||||
RaceManager::getModeIDFromInternalName(unlockedFeatures[i].name.c_str());
|
||||
const std::string icon = file_manager->getDataDir() + "/" + RaceManager::getIconOf(mode);
|
||||
addUnlockedPicture( irr_driver->getTexture(icon.c_str()), 0.8f, 0.8f,
|
||||
unlockedFeatures[i].getUnlockedMessage() );
|
||||
break;
|
||||
}
|
||||
case UNLOCK_KART:
|
||||
{
|
||||
const KartProperties* kart = kart_properties_manager->getKart(unlockedFeatures[i].name);
|
||||
assert(kart != NULL);
|
||||
|
||||
// the passed kart will not be modified, that's why I allow myself to use const_cast
|
||||
addUnlockedKart( const_cast<KartProperties*>(kart),
|
||||
unlockedFeatures[i].getUnlockedMessage() );
|
||||
break;
|
||||
}
|
||||
case UNLOCK_DIFFICULTY:
|
||||
{
|
||||
//TODO : implement
|
||||
std::cerr << "OK, I see you unlocked a difficulty, but this is not supported yet\n";
|
||||
|
||||
video::ITexture* tex = irr_driver->getTexture( file_manager->getGUIDir() + "/main_help.png");
|
||||
addUnlockedPicture( tex, 1.0f, 0.75f,
|
||||
unlockedFeatures[i].getUnlockedMessage() );
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
} // next feature
|
||||
} // next challenge
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------
|
||||
|
||||
bool FeatureUnlockedCutScene::onEscapePressed()
|
||||
{
|
||||
continueButtonPressed();
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
namespace irr { namespace scene { class ISceneNode; class ICameraSceneNode; class ILightSceneNode; } }
|
||||
class KartProperties;
|
||||
|
||||
class Challenge;
|
||||
|
||||
class FeatureUnlockedCutScene : public GUIEngine::Screen, public GUIEngine::ScreenSingleton<FeatureUnlockedCutScene>
|
||||
{
|
||||
@ -89,6 +89,10 @@ public:
|
||||
/** Call before showing up the screen to make a picture come out of the chest */
|
||||
void addUnlockedPicture(irr::video::ITexture* picture, float w, float h, irr::core::stringw msg);
|
||||
|
||||
/** Call before showing up the screen to make whatever the passed challenges unlocked
|
||||
* come out of the chest */
|
||||
void addUnlockedThings(const std::vector<const Challenge*> unlocked);
|
||||
|
||||
/** override from base class to handle escape press */
|
||||
virtual bool onEscapePressed();
|
||||
};
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "io/file_manager.hpp"
|
||||
#include "items/item_manager.hpp"
|
||||
#include "karts/kart_properties_manager.hpp"
|
||||
#include "states_screens/feature_unlocked.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
|
||||
@ -338,8 +339,26 @@ void GrandPrixOver::eventCallback(GUIEngine::Widget* widget,
|
||||
{
|
||||
if (name == "continue")
|
||||
{
|
||||
// we assume the main menu was pushed before showing this menu
|
||||
StateManager::get()->popMenu();
|
||||
// un-set the GP mode so that after unlocking, it doesn't try to continue the GP
|
||||
race_manager->setMajorMode (RaceManager::MAJOR_MODE_SINGLE);
|
||||
|
||||
if (unlock_manager->getRecentlyUnlockedFeatures().size() > 0)
|
||||
{
|
||||
std::vector<const Challenge*> unlocked = unlock_manager->getRecentlyUnlockedFeatures();
|
||||
unlock_manager->clearUnlocked();
|
||||
|
||||
FeatureUnlockedCutScene* scene = FeatureUnlockedCutScene::getInstance();
|
||||
|
||||
assert(unlocked.size() > 0);
|
||||
scene->addUnlockedThings(unlocked);
|
||||
|
||||
StateManager::get()->replaceTopMostScreen(scene);
|
||||
}
|
||||
else
|
||||
{
|
||||
// we assume the main menu was pushed before showing this menu
|
||||
StateManager::get()->popMenu();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user