Work on cutscene+menu combination. Fix bugs in GPWin cutscene, make them easier to work with in general
This commit is contained in:
parent
c7606cf6ef
commit
0057e40e6d
@ -668,6 +668,7 @@ namespace GUIEngine
|
|||||||
#include "guiengine/widget.hpp"
|
#include "guiengine/widget.hpp"
|
||||||
#include "guiengine/dialog_queue.hpp"
|
#include "guiengine/dialog_queue.hpp"
|
||||||
#include "modes/demo_world.hpp"
|
#include "modes/demo_world.hpp"
|
||||||
|
#include "modes/cutscene_world.hpp"
|
||||||
#include "modes/world.hpp"
|
#include "modes/world.hpp"
|
||||||
#include "states_screens/race_gui_base.hpp"
|
#include "states_screens/race_gui_base.hpp"
|
||||||
|
|
||||||
@ -1210,6 +1211,12 @@ namespace GUIEngine
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (gamestate == INGAME_MENU && dynamic_cast<CutsceneWorld*>(World::getWorld()) != NULL)
|
||||||
|
{
|
||||||
|
RaceGUIBase* rg = World::getWorld()->getRaceGUI();
|
||||||
|
if (rg != NULL) rg->renderGlobal(elapsed_time);
|
||||||
|
}
|
||||||
|
|
||||||
if (gamestate == MENU || gamestate == INGAME_MENU)
|
if (gamestate == MENU || gamestate == INGAME_MENU)
|
||||||
{
|
{
|
||||||
g_skin->drawTooltips();
|
g_skin->drawTooltips();
|
||||||
|
@ -309,6 +309,17 @@ namespace GUIEngine
|
|||||||
virtual void onDialogClose() {}
|
virtual void onDialogClose() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class CutsceneScreen : public Screen
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CutsceneScreen(const char* name) : Screen(name, false)
|
||||||
|
{
|
||||||
|
setNeeds3D(true);
|
||||||
|
m_throttle_FPS = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void onCutsceneEnd() = 0;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -43,6 +43,7 @@
|
|||||||
#include <IMeshSceneNode.h>
|
#include <IMeshSceneNode.h>
|
||||||
#include <ISceneManager.h>
|
#include <ISceneManager.h>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
bool CutsceneWorld::s_use_duration = false;
|
bool CutsceneWorld::s_use_duration = false;
|
||||||
@ -187,12 +188,12 @@ void CutsceneWorld::update(float dt)
|
|||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
PtrVector<TrackObject>& objects = m_track->getTrackObjectManager()->getObjects();
|
PtrVector<TrackObject>& objects = m_track->getTrackObjectManager()->getObjects();
|
||||||
TrackObject* curr;
|
TrackObject* curr;
|
||||||
for_in(curr, objects)
|
for_in(curr, objects)
|
||||||
{
|
{
|
||||||
printf("* %s\n", curr->getType().c_str());
|
printf("* %s\n", curr->getType().c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
**/
|
**/
|
||||||
|
|
||||||
@ -235,18 +236,29 @@ void CutsceneWorld::update(float dt)
|
|||||||
dt = (float)(m_time - prev_time);
|
dt = (float)(m_time - prev_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
float fade;
|
float fade = 0.0f;
|
||||||
|
float fadeIn = -1.0f;
|
||||||
|
float fadeOut = -1.0f;
|
||||||
if (m_time < 2.0f)
|
if (m_time < 2.0f)
|
||||||
{
|
{
|
||||||
fade = 1.0f - (float)m_time / 2.0f;
|
fadeIn = 1.0f - (float)m_time / 2.0f;
|
||||||
}
|
}
|
||||||
else if (m_time > m_duration - 2.0f)
|
if (m_time > m_duration - 2.0f)
|
||||||
{
|
{
|
||||||
fade = (float)(m_time - (m_duration - 2.0f)) / 2.0f;
|
fadeOut = (float)(m_time - (m_duration - 2.0f)) / 2.0f;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (fadeIn >= 0.0f && fadeOut >= 0.0f)
|
||||||
{
|
{
|
||||||
fade = 0.0f;
|
fade = std::max(fadeIn, fadeOut);
|
||||||
|
}
|
||||||
|
else if (fadeIn >= 0.0f)
|
||||||
|
{
|
||||||
|
fade = fadeIn;
|
||||||
|
}
|
||||||
|
else if (fadeOut >= 0.0f)
|
||||||
|
{
|
||||||
|
fade = fadeOut;
|
||||||
}
|
}
|
||||||
dynamic_cast<CutsceneGUI*>(m_race_gui)->setFadeLevel(fade);
|
dynamic_cast<CutsceneGUI*>(m_race_gui)->setFadeLevel(fade);
|
||||||
|
|
||||||
@ -354,6 +366,15 @@ void CutsceneWorld::update(float dt)
|
|||||||
it++;
|
it++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isOver = (m_time > m_duration);
|
||||||
|
if (isOver && (s_use_duration || m_aborted))
|
||||||
|
{
|
||||||
|
GUIEngine::CutsceneScreen* cs = dynamic_cast<GUIEngine::CutsceneScreen*>(
|
||||||
|
GUIEngine::getCurrentScreen());
|
||||||
|
if (cs != NULL)
|
||||||
|
cs->onCutsceneEnd();
|
||||||
|
}
|
||||||
} // update
|
} // update
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -440,10 +461,12 @@ void CutsceneWorld::enterRaceOverState()
|
|||||||
*/
|
*/
|
||||||
bool CutsceneWorld::isRaceOver()
|
bool CutsceneWorld::isRaceOver()
|
||||||
{
|
{
|
||||||
|
bool isOver = (m_time > m_duration);
|
||||||
|
|
||||||
if (!s_use_duration && !m_aborted)
|
if (!s_use_duration && !m_aborted)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return m_time > m_duration;
|
return isOver;
|
||||||
} // isRaceOver
|
} // isRaceOver
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -82,15 +82,18 @@ DEFINE_SCREEN_SINGLETON( GrandPrixLose );
|
|||||||
|
|
||||||
// -------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------
|
||||||
|
|
||||||
GrandPrixLose::GrandPrixLose() : Screen("grand_prix_lose.stkgui", false /* pause race */)
|
GrandPrixLose::GrandPrixLose() : CutsceneScreen("grand_prix_lose.stkgui")
|
||||||
{
|
{
|
||||||
setNeeds3D(true);
|
|
||||||
|
|
||||||
m_throttle_FPS = false;
|
|
||||||
} // GrandPrixLose
|
} // GrandPrixLose
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void GrandPrixLose::onCutsceneEnd()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------------------------
|
||||||
|
|
||||||
void GrandPrixLose::loadedFromFile()
|
void GrandPrixLose::loadedFromFile()
|
||||||
{
|
{
|
||||||
m_kart_node[0] = NULL;
|
m_kart_node[0] = NULL;
|
||||||
|
@ -33,7 +33,7 @@ class TrackObject;
|
|||||||
* \brief Screen shown at the end of a Grand Prix
|
* \brief Screen shown at the end of a Grand Prix
|
||||||
* \ingroup states_screens
|
* \ingroup states_screens
|
||||||
*/
|
*/
|
||||||
class GrandPrixLose : public GUIEngine::Screen, public GUIEngine::ScreenSingleton<GrandPrixLose>
|
class GrandPrixLose : public GUIEngine::CutsceneScreen, public GUIEngine::ScreenSingleton<GrandPrixLose>
|
||||||
{
|
{
|
||||||
friend class GUIEngine::ScreenSingleton<GrandPrixLose>;
|
friend class GUIEngine::ScreenSingleton<GrandPrixLose>;
|
||||||
|
|
||||||
@ -53,6 +53,8 @@ class GrandPrixLose : public GUIEngine::Screen, public GUIEngine::ScreenSingleto
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
virtual void onCutsceneEnd() OVERRIDE;
|
||||||
|
|
||||||
/** \brief implement callback from parent class GUIEngine::Screen */
|
/** \brief implement callback from parent class GUIEngine::Screen */
|
||||||
virtual void loadedFromFile() OVERRIDE;
|
virtual void loadedFromFile() OVERRIDE;
|
||||||
|
|
||||||
|
@ -66,12 +66,8 @@ DEFINE_SCREEN_SINGLETON( GrandPrixWin );
|
|||||||
|
|
||||||
// -------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------
|
||||||
|
|
||||||
GrandPrixWin::GrandPrixWin() : Screen("grand_prix_win.stkgui", false /* pause race */)
|
GrandPrixWin::GrandPrixWin() : CutsceneScreen("grand_prix_win.stkgui")
|
||||||
{
|
{
|
||||||
setNeeds3D(true);
|
|
||||||
|
|
||||||
m_throttle_FPS = false;
|
|
||||||
|
|
||||||
m_kart_node[0] = NULL;
|
m_kart_node[0] = NULL;
|
||||||
m_kart_node[1] = NULL;
|
m_kart_node[1] = NULL;
|
||||||
m_kart_node[2] = NULL;
|
m_kart_node[2] = NULL;
|
||||||
@ -84,6 +80,70 @@ GrandPrixWin::GrandPrixWin() : Screen("grand_prix_win.stkgui", false /* pause ra
|
|||||||
|
|
||||||
// -------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
GrandPrixWin::~GrandPrixWin()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void GrandPrixWin::onCutsceneEnd()
|
||||||
|
{
|
||||||
|
for (unsigned int i = 0; i<m_all_kart_models.size(); i++)
|
||||||
|
delete m_all_kart_models[i];
|
||||||
|
m_all_kart_models.clear();
|
||||||
|
|
||||||
|
if (m_unlocked_label != NULL)
|
||||||
|
{
|
||||||
|
manualRemoveWidget(m_unlocked_label);
|
||||||
|
delete m_unlocked_label;
|
||||||
|
m_unlocked_label = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
TrackObjectManager* tobjman = World::getWorld()->getTrack()->getTrackObjectManager();
|
||||||
|
if (m_kart_node[0] != NULL)
|
||||||
|
m_kart_node[0]->getPresentation<TrackObjectPresentationSceneNode>()->getNode()->remove();
|
||||||
|
if (m_kart_node[1] != NULL)
|
||||||
|
m_kart_node[1]->getPresentation<TrackObjectPresentationSceneNode>()->getNode()->remove();
|
||||||
|
if (m_kart_node[2] != NULL)
|
||||||
|
m_kart_node[2]->getPresentation<TrackObjectPresentationSceneNode>()->getNode()->remove();
|
||||||
|
|
||||||
|
m_kart_node[0] = NULL;
|
||||||
|
m_kart_node[1] = NULL;
|
||||||
|
m_kart_node[2] = NULL;
|
||||||
|
|
||||||
|
m_podium_steps[0] = NULL;
|
||||||
|
m_podium_steps[1] = NULL;
|
||||||
|
m_podium_steps[2] = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 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 (PlayerManager::getCurrentPlayer()
|
||||||
|
->getRecentlyCompletedChallenges().size() > 0)
|
||||||
|
{
|
||||||
|
std::vector<const ChallengeData*> unlocked =
|
||||||
|
PlayerManager::getCurrentPlayer()->getRecentlyCompletedChallenges();
|
||||||
|
PlayerManager::getCurrentPlayer()->clearUnlocked();
|
||||||
|
|
||||||
|
FeatureUnlockedCutScene* scene = FeatureUnlockedCutScene::getInstance();
|
||||||
|
|
||||||
|
assert(unlocked.size() > 0);
|
||||||
|
scene->addTrophy(race_manager->getDifficulty());
|
||||||
|
scene->findWhatWasUnlocked(race_manager->getDifficulty());
|
||||||
|
|
||||||
|
StateManager::get()->replaceTopMostScreen(scene);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// we assume the main menu was pushed before showing this menu
|
||||||
|
StateManager::get()->popMenu();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------------------------
|
||||||
|
|
||||||
void GrandPrixWin::loadedFromFile()
|
void GrandPrixWin::loadedFromFile()
|
||||||
{
|
{
|
||||||
} // loadedFromFile
|
} // loadedFromFile
|
||||||
@ -161,29 +221,17 @@ void GrandPrixWin::init()
|
|||||||
|
|
||||||
// -------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
bool GrandPrixWin::onEscapePressed()
|
||||||
|
{
|
||||||
|
((CutsceneWorld*)World::getWorld())->abortCutscene();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------------------------
|
||||||
|
|
||||||
void GrandPrixWin::tearDown()
|
void GrandPrixWin::tearDown()
|
||||||
{
|
{
|
||||||
Screen::tearDown();
|
Screen::tearDown();
|
||||||
((CutsceneWorld*)World::getWorld())->abortCutscene();
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i<m_all_kart_models.size(); i++)
|
|
||||||
delete m_all_kart_models[i];
|
|
||||||
m_all_kart_models.clear();
|
|
||||||
|
|
||||||
if (m_unlocked_label != NULL)
|
|
||||||
{
|
|
||||||
manualRemoveWidget(m_unlocked_label);
|
|
||||||
delete m_unlocked_label;
|
|
||||||
m_unlocked_label = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_kart_node[0] = NULL;
|
|
||||||
m_kart_node[1] = NULL;
|
|
||||||
m_kart_node[2] = NULL;
|
|
||||||
|
|
||||||
m_podium_steps[0] = NULL;
|
|
||||||
m_podium_steps[1] = NULL;
|
|
||||||
m_podium_steps[2] = NULL;
|
|
||||||
} // tearDown
|
} // tearDown
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------
|
||||||
@ -311,29 +359,7 @@ void GrandPrixWin::eventCallback(GUIEngine::Widget* widget,
|
|||||||
{
|
{
|
||||||
if (name == "continue")
|
if (name == "continue")
|
||||||
{
|
{
|
||||||
// un-set the GP mode so that after unlocking, it doesn't try to continue the GP
|
((CutsceneWorld*)World::getWorld())->abortCutscene();
|
||||||
race_manager->setMajorMode (RaceManager::MAJOR_MODE_SINGLE);
|
|
||||||
|
|
||||||
if (PlayerManager::getCurrentPlayer()
|
|
||||||
->getRecentlyCompletedChallenges().size() > 0)
|
|
||||||
{
|
|
||||||
std::vector<const ChallengeData*> unlocked =
|
|
||||||
PlayerManager::getCurrentPlayer()->getRecentlyCompletedChallenges();
|
|
||||||
PlayerManager::getCurrentPlayer()->clearUnlocked();
|
|
||||||
|
|
||||||
FeatureUnlockedCutScene* scene = FeatureUnlockedCutScene::getInstance();
|
|
||||||
|
|
||||||
assert(unlocked.size() > 0);
|
|
||||||
scene->addTrophy(race_manager->getDifficulty());
|
|
||||||
scene->findWhatWasUnlocked(race_manager->getDifficulty());
|
|
||||||
|
|
||||||
StateManager::get()->replaceTopMostScreen(scene);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// we assume the main menu was pushed before showing this menu
|
|
||||||
StateManager::get()->popMenu();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} // eventCallback
|
} // eventCallback
|
||||||
|
|
||||||
|
@ -32,12 +32,14 @@ class TrackObject;
|
|||||||
* \brief Screen shown at the end of a Grand Prix
|
* \brief Screen shown at the end of a Grand Prix
|
||||||
* \ingroup states_screens
|
* \ingroup states_screens
|
||||||
*/
|
*/
|
||||||
class GrandPrixWin : public GUIEngine::Screen, public GUIEngine::ScreenSingleton<GrandPrixWin>
|
class GrandPrixWin : public GUIEngine::CutsceneScreen, public GUIEngine::ScreenSingleton<GrandPrixWin>
|
||||||
{
|
{
|
||||||
friend class GUIEngine::ScreenSingleton<GrandPrixWin>;
|
friend class GUIEngine::ScreenSingleton<GrandPrixWin>;
|
||||||
|
|
||||||
GrandPrixWin();
|
GrandPrixWin();
|
||||||
|
|
||||||
|
virtual ~GrandPrixWin();
|
||||||
|
|
||||||
/** Global evolution of time */
|
/** Global evolution of time */
|
||||||
double m_global_time;
|
double m_global_time;
|
||||||
|
|
||||||
@ -61,6 +63,10 @@ class GrandPrixWin : public GUIEngine::Screen, public GUIEngine::ScreenSingleton
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
virtual void onCutsceneEnd() OVERRIDE;
|
||||||
|
|
||||||
|
virtual bool onEscapePressed() OVERRIDE;
|
||||||
|
|
||||||
/** \brief implement callback from parent class GUIEngine::Screen */
|
/** \brief implement callback from parent class GUIEngine::Screen */
|
||||||
virtual void loadedFromFile() OVERRIDE;
|
virtual void loadedFromFile() OVERRIDE;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user