Improved the code of abstract state manager / state manager (moved code from abstract class to derived class, improving the design a lot and removing duplicated code). closes many FIXMEs
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5264 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
e6d933eba5
commit
e6b0b5238d
@ -20,11 +20,9 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "audio/sfx_manager.hpp"
|
|
||||||
#include "guiengine/engine.hpp"
|
#include "guiengine/engine.hpp"
|
||||||
#include "guiengine/screen.hpp"
|
#include "guiengine/screen.hpp"
|
||||||
#include "input/device_manager.hpp"
|
#include "input/device_manager.hpp"
|
||||||
#include "input/input_manager.hpp"
|
|
||||||
|
|
||||||
using namespace GUIEngine;
|
using namespace GUIEngine;
|
||||||
|
|
||||||
@ -49,8 +47,6 @@ void AbstractStateManager::enterGameState()
|
|||||||
setGameState(GAME);
|
setGameState(GAME);
|
||||||
GUIEngine::cleanForGame();
|
GUIEngine::cleanForGame();
|
||||||
|
|
||||||
//FIXME: this probably doesn't belong in the *abstract* state manager
|
|
||||||
input_manager->setMode(InputManager::INGAME);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@ -90,7 +86,6 @@ void AbstractStateManager::pushMenu(std::string name)
|
|||||||
// Send tear-down event to previous menu
|
// Send tear-down event to previous menu
|
||||||
if (m_menu_stack.size() > 0 && m_game_mode != GAME) getCurrentScreen()->tearDown();
|
if (m_menu_stack.size() > 0 && m_game_mode != GAME) getCurrentScreen()->tearDown();
|
||||||
|
|
||||||
input_manager->setMode(InputManager::MENU);
|
|
||||||
m_menu_stack.push_back(name);
|
m_menu_stack.push_back(name);
|
||||||
if (m_game_mode == GAME)
|
if (m_game_mode == GAME)
|
||||||
{
|
{
|
||||||
@ -173,9 +168,6 @@ void AbstractStateManager::popMenu()
|
|||||||
|
|
||||||
setGameState(GAME);
|
setGameState(GAME);
|
||||||
GUIEngine::cleanForGame();
|
GUIEngine::cleanForGame();
|
||||||
|
|
||||||
//FIXME: this doesn't go in the *abstract* state manager
|
|
||||||
input_manager->setMode(InputManager::INGAME);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -197,15 +189,9 @@ void AbstractStateManager::resetAndGoToScreen(Screen* screen)
|
|||||||
if (m_game_mode != GAME) getCurrentScreen()->tearDown();
|
if (m_game_mode != GAME) getCurrentScreen()->tearDown();
|
||||||
m_menu_stack.clear();
|
m_menu_stack.clear();
|
||||||
|
|
||||||
//FIXME: this doesn't go in the *abstract* state manager
|
|
||||||
input_manager->setMode(InputManager::MENU);
|
|
||||||
|
|
||||||
m_menu_stack.push_back(name);
|
m_menu_stack.push_back(name);
|
||||||
setGameState(MENU);
|
setGameState(MENU);
|
||||||
|
|
||||||
//FIXME: this doesn't go in the *abstract* state manager
|
|
||||||
sfx_manager->positionListener( Vec3(0,0,0), Vec3(0,1,0) );
|
|
||||||
|
|
||||||
switchToScreen(name.c_str());
|
switchToScreen(name.c_str());
|
||||||
getCurrentScreen()->init();
|
getCurrentScreen()->init();
|
||||||
}
|
}
|
||||||
@ -217,9 +203,6 @@ void AbstractStateManager::resetAndSetStack(Screen* screens[])
|
|||||||
assert(screens != NULL);
|
assert(screens != NULL);
|
||||||
assert(screens[0] != NULL);
|
assert(screens[0] != NULL);
|
||||||
|
|
||||||
//FIXME: this doesn't go in the *abstract* state manager
|
|
||||||
input_manager->setMode(InputManager::MENU);
|
|
||||||
|
|
||||||
if (m_game_mode != GAME) getCurrentScreen()->tearDown();
|
if (m_game_mode != GAME) getCurrentScreen()->tearDown();
|
||||||
m_menu_stack.clear();
|
m_menu_stack.clear();
|
||||||
|
|
||||||
@ -230,9 +213,6 @@ void AbstractStateManager::resetAndSetStack(Screen* screens[])
|
|||||||
|
|
||||||
setGameState(MENU);
|
setGameState(MENU);
|
||||||
|
|
||||||
//FIXME: this doesn't go in the *abstract* state manager
|
|
||||||
sfx_manager->positionListener( Vec3(0,0,0), Vec3(0,1,0) );
|
|
||||||
|
|
||||||
switchToScreen(m_menu_stack[m_menu_stack.size()-1].c_str());
|
switchToScreen(m_menu_stack[m_menu_stack.size()-1].c_str());
|
||||||
getCurrentScreen()->init();
|
getCurrentScreen()->init();
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include "states_screens/state_manager.hpp"
|
#include "states_screens/state_manager.hpp"
|
||||||
|
|
||||||
|
#include "audio/sfx_manager.hpp"
|
||||||
#include "audio/music_manager.hpp"
|
#include "audio/music_manager.hpp"
|
||||||
#include "config/stk_config.hpp"
|
#include "config/stk_config.hpp"
|
||||||
#include "guiengine/engine.hpp"
|
#include "guiengine/engine.hpp"
|
||||||
@ -181,6 +182,7 @@ void StateManager::onGameStateChange(GameState previousState, GameState newState
|
|||||||
if (newState == GAME)
|
if (newState == GAME)
|
||||||
{
|
{
|
||||||
irr_driver->hidePointer();
|
irr_driver->hidePointer();
|
||||||
|
input_manager->setMode(InputManager::INGAME);
|
||||||
|
|
||||||
if (previousState == INGAME_MENU)
|
if (previousState == INGAME_MENU)
|
||||||
{
|
{
|
||||||
@ -191,6 +193,8 @@ void StateManager::onGameStateChange(GameState previousState, GameState newState
|
|||||||
else // menu (including in-game menu)
|
else // menu (including in-game menu)
|
||||||
{
|
{
|
||||||
irr_driver->showPointer();
|
irr_driver->showPointer();
|
||||||
|
input_manager->setMode(InputManager::MENU);
|
||||||
|
sfx_manager->positionListener( Vec3(0,0,0), Vec3(0,1,0) );
|
||||||
|
|
||||||
if (newState == MENU)
|
if (newState == MENU)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user