forked from mirror/openmw-tes3mp
removed boolean running flag with state enum
This commit is contained in:
parent
c5f81e3508
commit
82c8495338
4 changed files with 20 additions and 10 deletions
|
@ -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();
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue