Removed the CutScene adapter, the new event handling for Screen does not require that kind of thing anymore to combine 2D and 3D, and to use animations
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@4115 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
5
data/gui/feature_unlocked.stkgui
Normal file
5
data/gui/feature_unlocked.stkgui
Normal file
@@ -0,0 +1,5 @@
|
||||
<stkgui>
|
||||
|
||||
<button id="back" x="20" y="-40" width="250" height="35" align="left" text="Continue"/>
|
||||
|
||||
</stkgui>
|
||||
@@ -74,8 +74,6 @@ supertuxkart_SOURCES = \
|
||||
graphics/water_splash.cpp \
|
||||
guiengine/abstract_state_manager.cpp \
|
||||
guiengine/abstract_state_manager.hpp \
|
||||
guiengine/cutscene.cpp \
|
||||
guiengine/cutscene.hpp \
|
||||
guiengine/engine.cpp \
|
||||
guiengine/engine.hpp \
|
||||
guiengine/event_handler.hpp \
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "graphics/material_manager.hpp"
|
||||
#include "guiengine/engine.hpp"
|
||||
#include "guiengine/modaldialog.hpp"
|
||||
#include "guiengine/screen.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
#include "io/file_manager.hpp"
|
||||
#include "items/item_manager.hpp"
|
||||
@@ -650,7 +651,8 @@ void IrrDriver::update(float dt)
|
||||
m_scene_manager->drawAll();
|
||||
}
|
||||
}
|
||||
else if (state == GUIEngine::CUTSCENE)
|
||||
|
||||
if (GUIEngine::getCurrentScreen()->needs3D())
|
||||
{
|
||||
// render 3D stuff in cutscene mode too
|
||||
m_scene_manager->drawAll();
|
||||
|
||||
@@ -93,32 +93,9 @@ void AbstractStateManager::pushMenu(std::string name)
|
||||
switchToScreen(name.c_str());
|
||||
}
|
||||
|
||||
void AbstractStateManager::pushCutScene(std::string name)
|
||||
{
|
||||
// Send tear-down event to previous menu
|
||||
if (m_menu_stack.size() > 0 && m_game_mode != GAME) getCurrentScreen()->tearDown();
|
||||
|
||||
input_manager->setMode(InputManager::MENU);
|
||||
m_menu_stack.push_back(name);
|
||||
|
||||
m_game_mode = CUTSCENE;
|
||||
GUIEngine::switchToScreen(name.c_str());
|
||||
}
|
||||
|
||||
void AbstractStateManager::pushScreen(Screen* screen)
|
||||
{
|
||||
if (screen->getScreenType() == SCREEN_TYPE_MENU)
|
||||
{
|
||||
pushMenu(screen->getName());
|
||||
}
|
||||
else if(screen->getScreenType() == SCREEN_TYPE_CUTSCENE)
|
||||
{
|
||||
pushCutScene(screen->getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
pushMenu(screen->getName());
|
||||
screen->init();
|
||||
}
|
||||
|
||||
@@ -193,9 +170,7 @@ void AbstractStateManager::popMenu()
|
||||
void AbstractStateManager::resetAndGoToScreen(Screen* screen)
|
||||
{
|
||||
std::string name = screen->getName();
|
||||
|
||||
// FIXME: handle cutscenes ?
|
||||
|
||||
|
||||
race_manager->exitRace();
|
||||
input_manager->setMode(InputManager::MENU);
|
||||
m_menu_stack.clear();
|
||||
|
||||
@@ -13,7 +13,6 @@ namespace GUIEngine
|
||||
{
|
||||
MENU,
|
||||
GAME,
|
||||
CUTSCENE,
|
||||
INGAME_MENU
|
||||
};
|
||||
|
||||
@@ -34,7 +33,6 @@ protected:
|
||||
std::vector<std::string> m_menu_stack;
|
||||
|
||||
void pushMenu(std::string name);
|
||||
void pushCutScene(std::string name);
|
||||
|
||||
public:
|
||||
AbstractStateManager();
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2009 Marianne Gagnon
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "guiengine/cutscene.hpp"
|
||||
|
||||
using namespace GUIEngine;
|
||||
|
||||
CutScene::CutScene(const char* name) : Screen(name)
|
||||
{
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2009 Marianne Gagnon
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#ifndef HEADER_CUTSCENE_HPP
|
||||
#define HEADER_CUTSCENE_HPP
|
||||
|
||||
#include "guiengine/screen.hpp"
|
||||
|
||||
namespace irr { namespace video { class IVideoDriver; } }
|
||||
|
||||
namespace GUIEngine
|
||||
{
|
||||
|
||||
/**
|
||||
* A CutScene isn't really a GUI screen, but deriving from Screen helps integrate in the screen stack
|
||||
*/
|
||||
class CutScene : public Screen
|
||||
{
|
||||
public:
|
||||
void addWidgets() {}
|
||||
void calculateLayout() {}
|
||||
|
||||
CutScene(const char* name);
|
||||
|
||||
virtual ScreenType getScreenType() { return SCREEN_TYPE_CUTSCENE; }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -23,7 +23,6 @@
|
||||
|
||||
#include "io/file_manager.hpp"
|
||||
#include "input/input_manager.hpp"
|
||||
#include "guiengine/cutscene.hpp"
|
||||
#include "guiengine/event_handler.hpp"
|
||||
#include "guiengine/modaldialog.hpp"
|
||||
#include "guiengine/screen.hpp"
|
||||
@@ -38,49 +37,27 @@ namespace GUIEngine
|
||||
{
|
||||
Widget* g_focus_for_player[MAX_PLAYER_COUNT]; // unused for player 0, player 0's focus is tracked by irrlicht
|
||||
|
||||
IGUIEnvironment* g_env;
|
||||
Skin* g_skin = NULL;
|
||||
IGUIFont* g_font;
|
||||
IrrlichtDevice* g_device;
|
||||
IVideoDriver* g_driver;
|
||||
|
||||
ptr_vector<Screen, HOLD> g_loaded_screens;
|
||||
Screen* g_current_screen = NULL;
|
||||
namespace Private
|
||||
{
|
||||
IGUIEnvironment* g_env;
|
||||
Skin* g_skin = NULL;
|
||||
IGUIFont* g_font;
|
||||
IrrlichtDevice* g_device;
|
||||
IVideoDriver* g_driver;
|
||||
Screen* g_current_screen = NULL;
|
||||
AbstractStateManager* g_state_manager = NULL;
|
||||
}
|
||||
using namespace Private;
|
||||
|
||||
ptr_vector<Widget, REF> needsUpdate;
|
||||
ptr_vector<Screen, HOLD> g_loaded_screens;
|
||||
|
||||
AbstractStateManager* g_state_manager = NULL;
|
||||
|
||||
float dt = 0;
|
||||
|
||||
float getLatestDt()
|
||||
{
|
||||
return dt;
|
||||
}
|
||||
// -----------------------------------------------------------------------------
|
||||
IrrlichtDevice* getDevice()
|
||||
{
|
||||
return g_device;
|
||||
}
|
||||
// -----------------------------------------------------------------------------
|
||||
IGUIFont* getFont()
|
||||
{
|
||||
return g_font;
|
||||
}
|
||||
// -----------------------------------------------------------------------------
|
||||
IVideoDriver* getDriver()
|
||||
{
|
||||
return g_driver;
|
||||
}
|
||||
// -----------------------------------------------------------------------------
|
||||
IGUIEnvironment* getGUIEnv()
|
||||
{
|
||||
return g_env;
|
||||
}
|
||||
// -----------------------------------------------------------------------------
|
||||
AbstractStateManager* getStateManager()
|
||||
{
|
||||
return g_state_manager;
|
||||
}
|
||||
// -----------------------------------------------------------------------------
|
||||
void clear()
|
||||
{
|
||||
@@ -143,11 +120,6 @@ void reshowCurrentScreen()
|
||||
//g_current_screen->addWidgets();
|
||||
}
|
||||
// -----------------------------------------------------------------------------
|
||||
Screen* getCurrentScreen()
|
||||
{
|
||||
return g_current_screen;
|
||||
}
|
||||
// -----------------------------------------------------------------------------
|
||||
void cleanUp()
|
||||
{
|
||||
if(g_skin != NULL) delete g_skin;
|
||||
@@ -208,7 +180,7 @@ void render(float elapsed_time)
|
||||
|
||||
const GameState gamestate = g_state_manager->getGameState();
|
||||
|
||||
if (gamestate == MENU)
|
||||
if (gamestate == MENU && !GUIEngine::getCurrentScreen()->needs3D())
|
||||
{
|
||||
g_skin->drawBgImage();
|
||||
}
|
||||
|
||||
@@ -212,11 +212,24 @@ namespace GUIEngine
|
||||
class CutScene;
|
||||
class Widget;
|
||||
|
||||
extern IrrlichtDevice* getDevice();
|
||||
extern irr::gui::IGUIEnvironment* getGUIEnv();
|
||||
extern irr::video::IVideoDriver* getDriver();
|
||||
extern irr::gui::IGUIFont* getFont();
|
||||
extern AbstractStateManager* getStateManager();
|
||||
// In an attempt to make getters as fast as possible by possibly allowing inlining
|
||||
namespace Private
|
||||
{
|
||||
extern irr::gui::IGUIEnvironment* g_env;
|
||||
extern Skin* g_skin;
|
||||
extern irr::gui::IGUIFont* g_font;
|
||||
extern IrrlichtDevice* g_device;
|
||||
extern irr::video::IVideoDriver* g_driver;
|
||||
extern Screen* g_current_screen;
|
||||
extern AbstractStateManager* g_state_manager;
|
||||
}
|
||||
|
||||
inline IrrlichtDevice* getDevice() { return Private::g_device; }
|
||||
inline irr::gui::IGUIEnvironment* getGUIEnv() { return Private::g_env; }
|
||||
inline irr::video::IVideoDriver* getDriver() { return Private::g_driver; }
|
||||
inline irr::gui::IGUIFont* getFont() { return Private::g_font; }
|
||||
inline Screen* getCurrentScreen() { return Private::g_current_screen; }
|
||||
inline AbstractStateManager* getStateManager() { return Private::g_state_manager; }
|
||||
|
||||
float getLatestDt();
|
||||
|
||||
@@ -234,7 +247,6 @@ namespace GUIEngine
|
||||
void clear();
|
||||
void cleanForGame();
|
||||
|
||||
Screen* getCurrentScreen();
|
||||
void reshowCurrentScreen();
|
||||
|
||||
void render(float dt);
|
||||
|
||||
@@ -47,6 +47,7 @@ Screen::Screen(const char* file)
|
||||
m_loaded = false;
|
||||
loadFromFile();
|
||||
m_inited = false;
|
||||
m_render_3d = false;
|
||||
}
|
||||
|
||||
Screen::Screen()
|
||||
@@ -55,6 +56,7 @@ Screen::Screen()
|
||||
m_mouse_y = 0;
|
||||
m_loaded = false;
|
||||
m_inited = false;
|
||||
m_render_3d = false;
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
@@ -53,12 +53,6 @@ namespace GUIEngine
|
||||
|
||||
void parseScreenFileDiv(irr::io::IrrXMLReader* xml, ptr_vector<Widget>& append_to);
|
||||
|
||||
enum ScreenType
|
||||
{
|
||||
SCREEN_TYPE_MENU,
|
||||
SCREEN_TYPE_CUTSCENE
|
||||
};
|
||||
|
||||
/**
|
||||
* Represents a single screen. Mainly responsible of its children widgets; Screen lays them
|
||||
* out, asks them to add themselves, asks them to remove themselves, etc.
|
||||
@@ -76,6 +70,9 @@ namespace GUIEngine
|
||||
static void addWidgetsRecursively(ptr_vector<Widget>& widgets, Widget* parent=NULL);
|
||||
void calculateLayout(ptr_vector<Widget>& widgets, Widget* parent=NULL);
|
||||
|
||||
/** Will be called to determine if the 3D scene must be rendered when at this screen. */
|
||||
bool m_render_3d;
|
||||
|
||||
public:
|
||||
ptr_vector<Widget, HOLD> m_widgets;
|
||||
|
||||
@@ -109,9 +106,7 @@ namespace GUIEngine
|
||||
|
||||
virtual void addWidgets();
|
||||
virtual void calculateLayout();
|
||||
|
||||
virtual ScreenType getScreenType() { return SCREEN_TYPE_MENU; }
|
||||
|
||||
|
||||
void manualAddWidget(Widget* w);
|
||||
void manualRemoveWidget(Widget* w);
|
||||
|
||||
@@ -119,6 +114,9 @@ namespace GUIEngine
|
||||
|
||||
void elementsWereDeleted(ptr_vector<Widget>* within_vector = NULL);
|
||||
|
||||
/** Will be called to determine if the 3D scene must be rendered when at this screen */
|
||||
bool needs3D() { return m_render_3d; }
|
||||
void setNeeds3D(bool needs3D) { m_render_3d = needs3D; }
|
||||
|
||||
virtual void init() = 0;
|
||||
virtual void tearDown() = 0;
|
||||
|
||||
@@ -267,7 +267,6 @@
|
||||
95C77D6F106958E10080838E /* check_sphere.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95C77D6D106958E10080838E /* check_sphere.cpp */; };
|
||||
95CB476C0FF30EF400413BAE /* bezier_curve.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95CB476B0FF30EF400413BAE /* bezier_curve.cpp */; };
|
||||
95D1F5F70FC8C3E300FF6968 /* input.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95D1F5F60FC8C3E300FF6968 /* input.cpp */; };
|
||||
95D233F51078203900625256 /* cutscene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95D233F41078203900625256 /* cutscene.cpp */; };
|
||||
95D2343F1078227A00625256 /* feature_unlocked.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95D2343E1078227A00625256 /* feature_unlocked.cpp */; };
|
||||
95D950D20FE473CA002E10AD /* stk_config.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95D950CE0FE473CA002E10AD /* stk_config.cpp */; };
|
||||
95D950D30FE473CA002E10AD /* user_config.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95D950D00FE473CA002E10AD /* user_config.cpp */; };
|
||||
@@ -861,8 +860,6 @@
|
||||
95CB476A0FF30EF400413BAE /* bezier_curve.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = bezier_curve.hpp; path = ../../tracks/bezier_curve.hpp; sourceTree = SOURCE_ROOT; };
|
||||
95CB476B0FF30EF400413BAE /* bezier_curve.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = bezier_curve.cpp; path = ../../tracks/bezier_curve.cpp; sourceTree = SOURCE_ROOT; };
|
||||
95D1F5F60FC8C3E300FF6968 /* input.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = input.cpp; path = ../../input/input.cpp; sourceTree = SOURCE_ROOT; };
|
||||
95D233F31078203900625256 /* cutscene.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = cutscene.hpp; path = ../../guiengine/cutscene.hpp; sourceTree = SOURCE_ROOT; };
|
||||
95D233F41078203900625256 /* cutscene.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = cutscene.cpp; path = ../../guiengine/cutscene.cpp; sourceTree = SOURCE_ROOT; };
|
||||
95D2343D1078227A00625256 /* feature_unlocked.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = feature_unlocked.hpp; path = ../../states_screens/feature_unlocked.hpp; sourceTree = SOURCE_ROOT; };
|
||||
95D2343E1078227A00625256 /* feature_unlocked.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = feature_unlocked.cpp; path = ../../states_screens/feature_unlocked.cpp; sourceTree = SOURCE_ROOT; };
|
||||
95D464880FA37B1B00F50CA2 /* libIrrlicht.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libIrrlicht.a; path = /usr/local/lib/libIrrlicht.a; sourceTree = "<absolute>"; };
|
||||
@@ -1229,8 +1226,6 @@
|
||||
children = (
|
||||
9583319810123B0200C5137E /* abstract_state_manager.cpp */,
|
||||
9583319710123B0200C5137E /* abstract_state_manager.hpp */,
|
||||
95D233F41078203900625256 /* cutscene.cpp */,
|
||||
95D233F31078203900625256 /* cutscene.hpp */,
|
||||
958330B210122B4A00C5137E /* engine.cpp */,
|
||||
958330B310122B4A00C5137E /* engine.hpp */,
|
||||
958330B410122B4A00C5137E /* event_handler.cpp */,
|
||||
@@ -2541,7 +2536,6 @@
|
||||
95C77D631069589B0080838E /* ambient_light_sphere.cpp in Sources */,
|
||||
95C77D66106958A50080838E /* check_line.cpp in Sources */,
|
||||
95C77D6F106958E10080838E /* check_sphere.cpp in Sources */,
|
||||
95D233F51078203900625256 /* cutscene.cpp in Sources */,
|
||||
95D2343F1078227A00625256 /* feature_unlocked.cpp in Sources */,
|
||||
9522F125107948AD0067ECF5 /* main_menu_screen.cpp in Sources */,
|
||||
9522F15B107949780067ECF5 /* race_setup_screen.cpp in Sources */,
|
||||
|
||||
@@ -14,26 +14,9 @@ using namespace irr::core;
|
||||
using namespace irr::gui;
|
||||
using namespace irr::video;
|
||||
|
||||
static const char* CUTSCENE_NAME = "feature_unlocked";
|
||||
/*
|
||||
static FeatureUnlockedCutScene* singleton = NULL;
|
||||
|
||||
void FeatureUnlockedCutScene::show()
|
||||
{
|
||||
if (singleton == NULL)
|
||||
{
|
||||
singleton = new FeatureUnlockedCutScene();
|
||||
addCutScene(singleton);
|
||||
}
|
||||
|
||||
singleton->prepare();
|
||||
|
||||
StateManager::get()->pushCutScene(CUTSCENE_NAME);
|
||||
}
|
||||
*/
|
||||
|
||||
FeatureUnlockedCutScene::FeatureUnlockedCutScene() : CutScene(CUTSCENE_NAME)
|
||||
FeatureUnlockedCutScene::FeatureUnlockedCutScene() : Screen("feature_unlocked.stkgui")
|
||||
{
|
||||
setNeeds3D(true);
|
||||
}
|
||||
|
||||
void FeatureUnlockedCutScene::init()
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
#ifndef HEADER_FEATURE_UNLOCKED_HPP
|
||||
#define HEADER_FEATURE_UNLOCKED_HPP
|
||||
|
||||
#include "guiengine/cutscene.hpp"
|
||||
#include "guiengine/screen.hpp"
|
||||
|
||||
namespace irr { namespace scene { class ISceneNode; class ICameraSceneNode; class ILightSceneNode; } }
|
||||
|
||||
class FeatureUnlockedCutScene : public GUIEngine::CutScene, public GUIEngine::ScreenSingleton<FeatureUnlockedCutScene>
|
||||
class FeatureUnlockedCutScene : public GUIEngine::Screen, public GUIEngine::ScreenSingleton<FeatureUnlockedCutScene>
|
||||
{
|
||||
friend class GUIEngine::ScreenSingleton<FeatureUnlockedCutScene>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user