added running flag; moved new game code to MWState

actorid
Marc Zinnschlag 11 years ago
parent 31ec973c9c
commit ec5b2e9a7e

@ -488,6 +488,8 @@ void OMW::Engine::go()
// start in main menu
if (!mSkipMenu)
MWBase::Environment::get().getWindowManager()->pushGuiMode (MWGui::GM_MainMenu);
else
MWBase::Environment::get().getStateManager()->newGame (true);
// Start the main rendering loop
while (!mEnvironment.get().getStateManager()->hasQuitRequest())

@ -23,6 +23,13 @@ namespace MWBase
virtual void requestQuit() = 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();
else if (sender == mButtons["newgame"])
{
MWBase::Environment::get().getWorld()->startNewGame();
MWBase::Environment::get().getWindowManager()->setNewGame(true);
MWBase::Environment::get().getDialogueManager()->clear();
MWBase::Environment::get().getJournal()->clear();
MWBase::Environment::get().getStateManager()->newGame();
}
else if (sender == mButtons["loadgame"])

@ -1,8 +1,14 @@
#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()
: mQuitRequest (false)
: mQuitRequest (false), mRunning (false)
{
}
@ -15,4 +21,28 @@ void MWState::StateManager::requestQuit()
bool MWState::StateManager::hasQuitRequest() const
{
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
{
bool mQuitRequest;
bool mRunning;
public:
@ -16,6 +17,13 @@ namespace MWState
virtual void requestQuit();
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…
Cancel
Save