removed boolean running flag with state enum

This commit is contained in:
Marc Zinnschlag 2013-11-18 15:15:47 +01:00
parent c5f81e3508
commit 82c8495338
4 changed files with 20 additions and 10 deletions

View file

@ -92,7 +92,8 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt)
MWBase::Environment::get().getSoundManager()->update(frametime);
// global scripts
if (MWBase::Environment::get().getStateManager()->isGameRunning())
if (MWBase::Environment::get().getStateManager()->getState()==
MWBase::StateManager::State_Running)
{
MWBase::Environment::get().getScriptManager()->getGlobalScripts().run();

View file

@ -6,6 +6,15 @@ namespace MWBase
/// \brief Interface for game state manager (implemented in MWState)
class StateManager
{
public:
enum State
{
State_NoGame,
State_Ended,
State_Running
};
private:
StateManager (const StateManager&);
@ -24,7 +33,7 @@ namespace MWBase
virtual bool hasQuitRequest() const = 0;
virtual bool isGameRunning() const = 0;
virtual State getState() const = 0;
virtual void newGame (bool bypass = false) = 0;
///< Start a new game.

View file

@ -8,7 +8,7 @@
#include "../mwbase/windowmanager.hpp"
MWState::StateManager::StateManager()
: mQuitRequest (false), mRunning (false)
: mQuitRequest (false), mState (State_NoGame)
{
}
@ -23,18 +23,18 @@ bool MWState::StateManager::hasQuitRequest() const
return mQuitRequest;
}
bool MWState::StateManager::isGameRunning() const
MWState::StateManager::State MWState::StateManager::getState() const
{
return mRunning;
return mState;
}
void MWState::StateManager::newGame (bool bypass)
{
if (mRunning)
if (mState!=State_NoGame)
{
MWBase::Environment::get().getDialogueManager()->clear();
MWBase::Environment::get().getJournal()->clear();
mRunning = false;
mState = State_NoGame;
}
if (!bypass)
@ -44,5 +44,5 @@ void MWState::StateManager::newGame (bool bypass)
MWBase::Environment::get().getWindowManager()->setNewGame (true);
}
mRunning = true;
mState = State_Running;
}

View file

@ -8,7 +8,7 @@ namespace MWState
class StateManager : public MWBase::StateManager
{
bool mQuitRequest;
bool mRunning;
State mState;
public:
@ -18,7 +18,7 @@ namespace MWState
virtual bool hasQuitRequest() const;
virtual bool isGameRunning() const;
virtual State getState() const;
virtual void newGame (bool bypass = false);
///< Start a new game.