Added support in feature unlocked chest for unlocked GPs
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5231 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
055687abbf
commit
4c755d02c0
@ -8,6 +8,7 @@
|
||||
#include "karts/kart.hpp"
|
||||
#include "karts/kart_properties_manager.hpp"
|
||||
#include "modes/world.hpp"
|
||||
#include "race/grand_prix_manager.hpp"
|
||||
#include "states_screens/main_menu_screen.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
#include "tracks/track.hpp"
|
||||
@ -52,6 +53,16 @@ void FeatureUnlockedCutScene::addUnlockedPicture(irr::video::ITexture* picture,
|
||||
|
||||
// -------------------------------------------------------------------------------------
|
||||
|
||||
void FeatureUnlockedCutScene::addUnlockedPictures(std::vector<irr::video::ITexture*> pictures,
|
||||
float w, float h, irr::core::stringw msg)
|
||||
{
|
||||
assert(!pictures.empty());
|
||||
|
||||
m_unlocked_stuff.push_back( new UnlockedThing(pictures, w, h, msg) );
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------
|
||||
|
||||
void FeatureUnlockedCutScene::init()
|
||||
{
|
||||
m_sky_angle = 0.0f;
|
||||
@ -110,12 +121,12 @@ void FeatureUnlockedCutScene::init()
|
||||
|
||||
m_unlocked_stuff[n].m_root_gift_node = kart_node;
|
||||
}
|
||||
else if (m_unlocked_stuff[n].m_picture != NULL)
|
||||
else if (!m_unlocked_stuff[n].m_pictures.empty())
|
||||
{
|
||||
video::SMaterial m;
|
||||
m.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
|
||||
m.BackfaceCulling = false;
|
||||
m.setTexture(0, m_unlocked_stuff[n].m_picture);
|
||||
m.setTexture(0, m_unlocked_stuff[n].m_pictures[0]);
|
||||
m.AmbientColor = video::SColor(255, 255, 255, 255);
|
||||
m.DiffuseColor = video::SColor(255, 255, 255, 255);
|
||||
m.EmissiveColor = video::SColor(255, 255, 255, 255);
|
||||
@ -255,7 +266,42 @@ void FeatureUnlockedCutScene::onUpdate(float dt, irr::video::IVideoDriver* drive
|
||||
30.0f,
|
||||
sin((1.0f-m_key_angle)*M_PI/8 + M_PI/4)*70.0f) );
|
||||
}
|
||||
|
||||
|
||||
for (int n=0; n<unlockedStuffCount; n++)
|
||||
{
|
||||
if (m_unlocked_stuff[n].m_root_gift_node == NULL) continue;
|
||||
|
||||
if (!m_unlocked_stuff[n].m_pictures.empty())
|
||||
{
|
||||
const int pictureCount = m_unlocked_stuff[n].m_pictures.size();
|
||||
|
||||
if (pictureCount > 1)
|
||||
{
|
||||
const int previousTextureID = m_unlocked_stuff[n].m_curr_image;
|
||||
const int textureID = int(m_global_time/1.2f) % pictureCount;
|
||||
|
||||
if (textureID != previousTextureID)
|
||||
{
|
||||
scene::IMeshSceneNode* node = (scene::IMeshSceneNode*)m_unlocked_stuff[n].m_root_gift_node;
|
||||
scene::IMesh* mesh = node->getMesh();
|
||||
|
||||
assert(mesh->getMeshBufferCount() == 1);
|
||||
|
||||
scene::IMeshBuffer* mb = mesh->getMeshBuffer(0);
|
||||
|
||||
SMaterial& m = mb->getMaterial();
|
||||
m.setTexture(0, m_unlocked_stuff[n].m_pictures[textureID]);
|
||||
|
||||
// FIXME: this mesh is already associated with this node. I'm calling this
|
||||
// to force irrLicht to refresh the display, now that Material has changed.
|
||||
node->setMesh(mesh);
|
||||
|
||||
m_unlocked_stuff[n].m_curr_image = textureID;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
assert(m_unlocked_stuff.size() > 0);
|
||||
if (m_unlocked_stuff[0].m_root_gift_node != NULL)
|
||||
{
|
||||
@ -322,11 +368,38 @@ void FeatureUnlockedCutScene::addUnlockedThings(const std::vector<const Challeng
|
||||
}
|
||||
case UNLOCK_GP:
|
||||
{
|
||||
//TODO: implement gp reward
|
||||
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,
|
||||
std::vector<ITexture*> images;
|
||||
const GrandPrixData* gp = grand_prix_manager->getGrandPrix(unlockedFeatures[i].name);
|
||||
if (gp == NULL)
|
||||
{
|
||||
std::cerr << "ERROR: Unlocked GP does not exist???\n";
|
||||
video::ITexture* WTF_image = irr_driver->getTexture( file_manager->getGUIDir() + "/main_help.png");
|
||||
images.push_back(WTF_image);
|
||||
}
|
||||
else
|
||||
{
|
||||
const std::vector<std::string>& gptracks = gp->getTracks();
|
||||
const int trackAmount = gptracks.size();
|
||||
|
||||
if (trackAmount == 0)
|
||||
{
|
||||
std::cerr << "ERROR: Unlocked GP is empty???\n";
|
||||
video::ITexture* WTF_image = irr_driver->getTexture( file_manager->getGUIDir() + "/main_help.png");
|
||||
images.push_back(WTF_image);
|
||||
}
|
||||
|
||||
for (int t=0; t<trackAmount; t++)
|
||||
{
|
||||
Track* track = track_manager->getTrack(gptracks[t]);
|
||||
|
||||
ITexture* tex = irr_driver->getTexture(track != NULL ?
|
||||
track->getScreenshotFile().c_str() :
|
||||
file_manager->getDataDir() + "gui/main_help.png");
|
||||
images.push_back(tex);
|
||||
}
|
||||
}
|
||||
|
||||
addUnlockedPictures(images, 1.0f, 0.75f,
|
||||
unlockedFeatures[i].getUnlockedMessage() );
|
||||
break;
|
||||
}
|
||||
|
@ -20,10 +20,12 @@ class FeatureUnlockedCutScene : public GUIEngine::Screen, public GUIEngine::Scre
|
||||
/** Will be non-null if this unlocked thing is a kart */
|
||||
KartProperties* m_unlocked_kart;
|
||||
|
||||
/** Will be non-null if this unlocked thing is a picture */
|
||||
irr::video::ITexture* m_picture;
|
||||
/** Will be non-empty if this unlocked thing is one or many pictures */
|
||||
std::vector<irr::video::ITexture*> m_pictures;
|
||||
/** Will be set if this unlocked thing is a picture */
|
||||
float m_w, m_h;
|
||||
/** used for slideshows */
|
||||
int m_curr_image;
|
||||
|
||||
/** Contains whatever is in the chest */
|
||||
scene::ISceneNode* m_root_gift_node;
|
||||
@ -33,17 +35,42 @@ class FeatureUnlockedCutScene : public GUIEngine::Screen, public GUIEngine::Scre
|
||||
UnlockedThing(KartProperties* kart, irr::core::stringw msg)
|
||||
{
|
||||
m_unlocked_kart = kart;
|
||||
m_picture = NULL;
|
||||
m_unlock_message = msg;
|
||||
m_curr_image = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a 'picture' reward.
|
||||
* \param pict the picture to display as reward.
|
||||
* \param w width of the picture to display
|
||||
* \param y height of the picture to display
|
||||
*/
|
||||
UnlockedThing(irr::video::ITexture* pict, float w, float h, irr::core::stringw msg)
|
||||
{
|
||||
m_unlocked_kart = NULL;
|
||||
m_picture = pict;
|
||||
m_pictures.push_back(pict);
|
||||
m_w = w;
|
||||
m_h = h;
|
||||
m_unlock_message = msg;
|
||||
m_curr_image = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a 'picture slideshow' reward.
|
||||
* \param picts the pictures to display as reward.
|
||||
* \param w width of the pictures to display
|
||||
* \param y height of the pictures to display
|
||||
*/
|
||||
UnlockedThing(std::vector<irr::video::ITexture*> picts, float w, float h, irr::core::stringw msg)
|
||||
{
|
||||
m_unlocked_kart = NULL;
|
||||
m_pictures = picts;
|
||||
m_w = w;
|
||||
m_h = h;
|
||||
m_unlock_message = msg;
|
||||
m_curr_image = 0;
|
||||
}
|
||||
|
||||
~UnlockedThing()
|
||||
{
|
||||
if (m_root_gift_node != NULL) irr_driver->removeNode(m_root_gift_node);
|
||||
@ -83,16 +110,24 @@ public:
|
||||
|
||||
void eventCallback(GUIEngine::Widget* widget, const std::string& name, const int playerID);
|
||||
|
||||
/** Call before showing up the screen to make a kart come out of the chest */
|
||||
/** Call before showing up the screen to make a kart come out of the chest.
|
||||
'addUnlockedThings' will invoke this, so you generally don't need to call this directly. */
|
||||
void addUnlockedKart(KartProperties* unlocked_kart, irr::core::stringw msg);
|
||||
|
||||
/** Call before showing up the screen to make a picture come out of the chest */
|
||||
/** Call before showing up the screen to make a picture come out of the chest
|
||||
'addUnlockedThings' will invoke this, so you generally don't need to call this directly. */
|
||||
void addUnlockedPicture(irr::video::ITexture* picture, float w, float h, irr::core::stringw msg);
|
||||
|
||||
/** Call before showing up the screen to make a picture slideshow come out of the chest
|
||||
'addUnlockedThings' will invoke this, so you generally don't need to call this directly. */
|
||||
void addUnlockedPictures(std::vector<irr::video::ITexture*> pictures,
|
||||
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();
|
||||
};
|
||||
|
@ -88,8 +88,19 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name, cons
|
||||
}
|
||||
else if (i % 3 == 1)
|
||||
{
|
||||
std::vector<video::ITexture*> textures;
|
||||
textures.push_back(irr_driver->getTexture(track_manager->getTrack("lighthouse")->getScreenshotFile().c_str()));
|
||||
textures.push_back(irr_driver->getTexture(track_manager->getTrack("beach")->getScreenshotFile().c_str()));
|
||||
textures.push_back(irr_driver->getTexture(track_manager->getTrack("sandtrack")->getScreenshotFile().c_str()));
|
||||
textures.push_back(irr_driver->getTexture(track_manager->getTrack("snowmountain")->getScreenshotFile().c_str()));
|
||||
|
||||
scene->addUnlockedPictures(textures, 1.0, 0.75, L"You did it");
|
||||
|
||||
/*
|
||||
scene->addUnlockedPicture( irr_driver->getTexture(track_manager->getTrack("lighthouse")->getScreenshotFile().c_str()),
|
||||
1.0, 0.75, L"You did it");
|
||||
*/
|
||||
|
||||
StateManager::get()->pushScreen(scene);
|
||||
}
|
||||
else
|
||||
|
Loading…
x
Reference in New Issue
Block a user