mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-20 06:53:52 +00:00
moved exit game flag from Environment to StateManager
This commit is contained in:
parent
79b7fa258b
commit
f19973450f
8 changed files with 25 additions and 11 deletions
|
@ -487,7 +487,7 @@ void OMW::Engine::go()
|
||||||
MWBase::Environment::get().getWindowManager()->executeInConsole (mStartupScript);
|
MWBase::Environment::get().getWindowManager()->executeInConsole (mStartupScript);
|
||||||
|
|
||||||
// Start the main rendering loop
|
// Start the main rendering loop
|
||||||
while (!mEnvironment.getRequestExit())
|
while (!mEnvironment.get().getStateManager()->hasQuitRequest())
|
||||||
Ogre::Root::getSingleton().renderOneFrame();
|
Ogre::Root::getSingleton().renderOneFrame();
|
||||||
|
|
||||||
// Save user settings
|
// Save user settings
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
#include "statemanager.hpp"
|
#include "statemanager.hpp"
|
||||||
|
|
||||||
MWBase::Environment *MWBase::Environment::sThis = 0;
|
MWBase::Environment *MWBase::Environment::sThis = 0;
|
||||||
bool MWBase::Environment::sExit = false;
|
|
||||||
|
|
||||||
MWBase::Environment::Environment()
|
MWBase::Environment::Environment()
|
||||||
: mWorld (0), mSoundManager (0), mScriptManager (0), mWindowManager (0),
|
: mWorld (0), mSoundManager (0), mScriptManager (0), mWindowManager (0),
|
||||||
|
|
|
@ -34,8 +34,6 @@ namespace MWBase
|
||||||
StateManager *mStateManager;
|
StateManager *mStateManager;
|
||||||
float mFrameDuration;
|
float mFrameDuration;
|
||||||
|
|
||||||
static bool sExit;
|
|
||||||
|
|
||||||
Environment (const Environment&);
|
Environment (const Environment&);
|
||||||
///< not implemented
|
///< not implemented
|
||||||
|
|
||||||
|
@ -48,9 +46,6 @@ namespace MWBase
|
||||||
|
|
||||||
~Environment();
|
~Environment();
|
||||||
|
|
||||||
static void setRequestExit () { sExit = true; }
|
|
||||||
static bool getRequestExit () { return sExit; }
|
|
||||||
|
|
||||||
void setWorld (World *world);
|
void setWorld (World *world);
|
||||||
|
|
||||||
void setSoundManager (SoundManager *soundManager);
|
void setSoundManager (SoundManager *soundManager);
|
||||||
|
|
|
@ -19,6 +19,10 @@ namespace MWBase
|
||||||
StateManager() {}
|
StateManager() {}
|
||||||
|
|
||||||
virtual ~StateManager() {}
|
virtual ~StateManager() {}
|
||||||
|
|
||||||
|
virtual void requestQuit() = 0;
|
||||||
|
|
||||||
|
virtual bool hasQuitRequest() const = 0;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
#include "mainmenu.hpp"
|
#include "mainmenu.hpp"
|
||||||
|
|
||||||
#include <OgreRoot.h>
|
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
#include "../mwbase/windowmanager.hpp"
|
#include "../mwbase/windowmanager.hpp"
|
||||||
#include "../mwbase/soundmanager.hpp"
|
#include "../mwbase/soundmanager.hpp"
|
||||||
#include "../mwbase/world.hpp"
|
#include "../mwbase/world.hpp"
|
||||||
#include "../mwbase/journal.hpp"
|
#include "../mwbase/journal.hpp"
|
||||||
#include "../mwbase/dialoguemanager.hpp"
|
#include "../mwbase/dialoguemanager.hpp"
|
||||||
|
#include "../mwbase/statemanager.hpp"
|
||||||
|
|
||||||
#include "savegamedialog.hpp"
|
#include "savegamedialog.hpp"
|
||||||
|
|
||||||
|
@ -79,7 +78,7 @@ namespace MWGui
|
||||||
else if (sender == mButtons["options"])
|
else if (sender == mButtons["options"])
|
||||||
MWBase::Environment::get().getWindowManager ()->pushGuiMode (GM_Settings);
|
MWBase::Environment::get().getWindowManager ()->pushGuiMode (GM_Settings);
|
||||||
else if (sender == mButtons["exitgame"])
|
else if (sender == mButtons["exitgame"])
|
||||||
MWBase::Environment::get().setRequestExit();
|
MWBase::Environment::get().getStateManager()->requestQuit();
|
||||||
else if (sender == mButtons["newgame"])
|
else if (sender == mButtons["newgame"])
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getWorld()->startNewGame();
|
MWBase::Environment::get().getWorld()->startNewGame();
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include "../mwbase/world.hpp"
|
#include "../mwbase/world.hpp"
|
||||||
#include "../mwbase/windowmanager.hpp"
|
#include "../mwbase/windowmanager.hpp"
|
||||||
#include "../mwbase/soundmanager.hpp"
|
#include "../mwbase/soundmanager.hpp"
|
||||||
|
#include "../mwbase/statemanager.hpp"
|
||||||
#include "../mwgui/bookwindow.hpp"
|
#include "../mwgui/bookwindow.hpp"
|
||||||
#include "../mwmechanics/creaturestats.hpp"
|
#include "../mwmechanics/creaturestats.hpp"
|
||||||
|
|
||||||
|
@ -644,7 +645,7 @@ namespace MWInput
|
||||||
|
|
||||||
void InputManager::windowClosed()
|
void InputManager::windowClosed()
|
||||||
{
|
{
|
||||||
MWBase::Environment::setRequestExit();
|
MWBase::Environment::get().getStateManager()->requestQuit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputManager::toggleMainMenu()
|
void InputManager::toggleMainMenu()
|
||||||
|
|
|
@ -2,6 +2,17 @@
|
||||||
#include "statemanagerimp.hpp"
|
#include "statemanagerimp.hpp"
|
||||||
|
|
||||||
MWState::StateManager::StateManager()
|
MWState::StateManager::StateManager()
|
||||||
|
: mQuitRequest (false)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void MWState::StateManager::requestQuit()
|
||||||
|
{
|
||||||
|
mQuitRequest = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MWState::StateManager::hasQuitRequest() const
|
||||||
|
{
|
||||||
|
return mQuitRequest;
|
||||||
}
|
}
|
|
@ -7,10 +7,15 @@ namespace MWState
|
||||||
{
|
{
|
||||||
class StateManager : public MWBase::StateManager
|
class StateManager : public MWBase::StateManager
|
||||||
{
|
{
|
||||||
|
bool mQuitRequest;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
StateManager();
|
StateManager();
|
||||||
|
|
||||||
|
virtual void requestQuit();
|
||||||
|
|
||||||
|
virtual bool hasQuitRequest() const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue