From 3901ea9840d743c6a6dc21e9f459b9444dc7232d Mon Sep 17 00:00:00 2001 From: auria Date: Sun, 24 Jun 2012 01:22:42 +0000 Subject: [PATCH] Continue after cutscene git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@11328 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/animations/animation_base.hpp | 17 +++++++++++++ src/modes/cutscene_world.cpp | 41 ++++++++++++++++++++++++++++++- src/modes/cutscene_world.hpp | 4 +++ 3 files changed, 61 insertions(+), 1 deletion(-) diff --git a/src/animations/animation_base.hpp b/src/animations/animation_base.hpp index 7a963e45f..7620840c9 100644 --- a/src/animations/animation_base.hpp +++ b/src/animations/animation_base.hpp @@ -33,6 +33,8 @@ #include "tracks/track_object.hpp" #include "utils/ptr_vector.hpp" +#include + class XMLNode; /** @@ -82,6 +84,21 @@ public: /** Disables or enables an animation. */ void setPlaying(bool playing) {m_playing = playing; } + // ------------------------------------------------------------------------ + + float getAnimationDuration() const + { + float duration = -1; + + const Ipo* currIpo; + for_in (currIpo, m_all_ipos) + { + duration = std::max(duration, currIpo->getEndTime()); + } + + return duration; + } + }; // AnimationBase #endif diff --git a/src/modes/cutscene_world.cpp b/src/modes/cutscene_world.cpp index a3ac81e7c..ac8a024a5 100644 --- a/src/modes/cutscene_world.cpp +++ b/src/modes/cutscene_world.cpp @@ -21,13 +21,16 @@ #include #include +#include "animations/animation_base.hpp" #include "audio/music_manager.hpp" #include "graphics/irr_driver.hpp" #include "io/file_manager.hpp" #include "karts/abstract_kart.hpp" #include "karts/kart_model.hpp" #include "karts/kart_properties.hpp" +#include "modes/overworld.hpp" #include "physics/physics.hpp" +#include "states_screens/main_menu_screen.hpp" #include "states_screens/race_gui_base.hpp" #include "tracks/track.hpp" #include "tracks/track_object.hpp" @@ -52,6 +55,9 @@ CutsceneWorld::CutsceneWorld() : World() void CutsceneWorld::init() { World::init(); + + m_duration = -1.0f; + //const btTransform &s = getTrack()->getStartTransform(0); //const Vec3 &v = s.getOrigin(); m_camera = irr_driver->getSceneManager() @@ -84,7 +90,18 @@ void CutsceneWorld::init() m_sounds_to_trigger[frame / FPS].push_back(curr); } } + + if (dynamic_cast(curr) != NULL) + { + m_duration = std::max(m_duration, dynamic_cast(curr)->getAnimationDuration()); + } } + + if (m_duration <= 0.0f) + { + fprintf(stderr, "[CutsceneWorld] WARNING: cutscene has no duration\n"); + } + } // CutsceneWorld //----------------------------------------------------------------------------- @@ -118,6 +135,19 @@ const std::string& CutsceneWorld::getIdent() const void CutsceneWorld::update(float dt) { m_time += dt; + + /* + if (m_time > m_duration) + { + printf("DONE!\n"); + + race_manager->exitRace(); + StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance()); + //OverWorld::enterOverWorld(); + return; + } + */ + World::update(dt); World::updateTrack(dt); @@ -156,12 +186,21 @@ void CutsceneWorld::update(float dt) } } // update +//----------------------------------------------------------------------------- + +void CutsceneWorld::enterRaceOverState() +{ + race_manager->exitRace(); + StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance()); + OverWorld::enterOverWorld(); +} + //----------------------------------------------------------------------------- /** The battle is over if only one kart is left, or no player kart. */ bool CutsceneWorld::isRaceOver() { - return false; + return m_time > m_duration; } // isRaceOver //----------------------------------------------------------------------------- diff --git a/src/modes/cutscene_world.hpp b/src/modes/cutscene_world.hpp index 2c01a140d..47c8eb586 100644 --- a/src/modes/cutscene_world.hpp +++ b/src/modes/cutscene_world.hpp @@ -40,6 +40,8 @@ class CutsceneWorld : public World scene::ICameraSceneNode* m_camera; std::map > m_sounds_to_trigger; + + float m_duration; public: @@ -68,6 +70,8 @@ public: { m_race_gui = NULL; } + + virtual void enterRaceOverState() OVERRIDE; }; // CutsceneWorld