mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-29 09:32:45 +00:00
added running flag; moved new game code to MWState
This commit is contained in:
parent
31ec973c9c
commit
ec5b2e9a7e
@ -488,6 +488,8 @@ void OMW::Engine::go()
|
|||||||
// start in main menu
|
// start in main menu
|
||||||
if (!mSkipMenu)
|
if (!mSkipMenu)
|
||||||
MWBase::Environment::get().getWindowManager()->pushGuiMode (MWGui::GM_MainMenu);
|
MWBase::Environment::get().getWindowManager()->pushGuiMode (MWGui::GM_MainMenu);
|
||||||
|
else
|
||||||
|
MWBase::Environment::get().getStateManager()->newGame (true);
|
||||||
|
|
||||||
// Start the main rendering loop
|
// Start the main rendering loop
|
||||||
while (!mEnvironment.get().getStateManager()->hasQuitRequest())
|
while (!mEnvironment.get().getStateManager()->hasQuitRequest())
|
||||||
|
@ -23,6 +23,13 @@ namespace MWBase
|
|||||||
virtual void requestQuit() = 0;
|
virtual void requestQuit() = 0;
|
||||||
|
|
||||||
virtual bool hasQuitRequest() const = 0;
|
virtual bool hasQuitRequest() const = 0;
|
||||||
|
|
||||||
|
virtual bool isGameRunning() const = 0;
|
||||||
|
|
||||||
|
virtual void newGame (bool bypass = false) = 0;
|
||||||
|
///< Start a new game.
|
||||||
|
///
|
||||||
|
/// \param bypass Skip new game mechanics.
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,10 +81,7 @@ namespace MWGui
|
|||||||
MWBase::Environment::get().getStateManager()->requestQuit();
|
MWBase::Environment::get().getStateManager()->requestQuit();
|
||||||
else if (sender == mButtons["newgame"])
|
else if (sender == mButtons["newgame"])
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getWorld()->startNewGame();
|
MWBase::Environment::get().getStateManager()->newGame();
|
||||||
MWBase::Environment::get().getWindowManager()->setNewGame(true);
|
|
||||||
MWBase::Environment::get().getDialogueManager()->clear();
|
|
||||||
MWBase::Environment::get().getJournal()->clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (sender == mButtons["loadgame"])
|
else if (sender == mButtons["loadgame"])
|
||||||
|
@ -1,8 +1,14 @@
|
|||||||
|
|
||||||
#include "statemanagerimp.hpp"
|
#include "statemanagerimp.hpp"
|
||||||
|
|
||||||
|
#include "../mwbase/environment.hpp"
|
||||||
|
#include "../mwbase/world.hpp"
|
||||||
|
#include "../mwbase/journal.hpp"
|
||||||
|
#include "../mwbase/dialoguemanager.hpp"
|
||||||
|
#include "../mwbase/windowmanager.hpp"
|
||||||
|
|
||||||
MWState::StateManager::StateManager()
|
MWState::StateManager::StateManager()
|
||||||
: mQuitRequest (false)
|
: mQuitRequest (false), mRunning (false)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -15,4 +21,28 @@ void MWState::StateManager::requestQuit()
|
|||||||
bool MWState::StateManager::hasQuitRequest() const
|
bool MWState::StateManager::hasQuitRequest() const
|
||||||
{
|
{
|
||||||
return mQuitRequest;
|
return mQuitRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MWState::StateManager::isGameRunning() const
|
||||||
|
{
|
||||||
|
return mRunning;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MWState::StateManager::newGame (bool bypass)
|
||||||
|
{
|
||||||
|
if (mRunning)
|
||||||
|
{
|
||||||
|
MWBase::Environment::get().getDialogueManager()->clear();
|
||||||
|
MWBase::Environment::get().getJournal()->clear();
|
||||||
|
mRunning = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!bypass)
|
||||||
|
{
|
||||||
|
/// \todo extract cleanup code
|
||||||
|
MWBase::Environment::get().getWorld()->startNewGame();
|
||||||
|
MWBase::Environment::get().getWindowManager()->setNewGame (true);
|
||||||
|
}
|
||||||
|
|
||||||
|
mRunning = true;
|
||||||
|
}
|
||||||
|
@ -8,6 +8,7 @@ namespace MWState
|
|||||||
class StateManager : public MWBase::StateManager
|
class StateManager : public MWBase::StateManager
|
||||||
{
|
{
|
||||||
bool mQuitRequest;
|
bool mQuitRequest;
|
||||||
|
bool mRunning;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -16,6 +17,13 @@ namespace MWState
|
|||||||
virtual void requestQuit();
|
virtual void requestQuit();
|
||||||
|
|
||||||
virtual bool hasQuitRequest() const;
|
virtual bool hasQuitRequest() const;
|
||||||
|
|
||||||
|
virtual bool isGameRunning() const;
|
||||||
|
|
||||||
|
virtual void newGame (bool bypass = false);
|
||||||
|
///< Start a new game.
|
||||||
|
///
|
||||||
|
/// \param bypass Skip new game mechanics.
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user