1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-21 09:53:50 +00:00
openmw-tes3mp/apps/openmw/mwstate/statemanagerimp.cpp

80 lines
1.8 KiB
C++
Raw Normal View History

2013-11-16 09:31:46 +00:00
#include "statemanagerimp.hpp"
#include <components/esm/esmwriter.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/journal.hpp"
#include "../mwbase/dialoguemanager.hpp"
#include "../mwbase/windowmanager.hpp"
MWState::StateManager::StateManager (const boost::filesystem::path& saves)
: mQuitRequest (false), mState (State_NoGame), mCharacterManager (saves)
2013-11-16 09:31:46 +00:00
{
}
void MWState::StateManager::requestQuit()
{
mQuitRequest = true;
}
bool MWState::StateManager::hasQuitRequest() const
{
return mQuitRequest;
}
MWState::StateManager::State MWState::StateManager::getState() const
{
return mState;
}
void MWState::StateManager::newGame (bool bypass)
{
if (mState!=State_NoGame)
{
MWBase::Environment::get().getDialogueManager()->clear();
MWBase::Environment::get().getJournal()->clear();
mState = State_NoGame;
}
if (!bypass)
{
/// \todo extract cleanup code
MWBase::Environment::get().getWorld()->startNewGame();
MWBase::Environment::get().getWindowManager()->setNewGame (true);
}
mCharacterManager.createCharacter();
mState = State_Running;
}
2013-11-18 14:38:08 +00:00
void MWState::StateManager::endGame()
{
mState = State_Ended;
}
void MWState::StateManager::saveGame (const Slot *slot)
{
ESM::SavedGame profile;
/// \todo configure profile
if (!slot)
slot = mCharacterManager.getCurrentCharacter()->createSlot (profile);
else
slot = mCharacterManager.getCurrentCharacter()->updateSlot (slot, profile);
ESM::ESMWriter writer;
// writer.setFormat ();
writer.save (slot->mPath.string());
slot->mProfile.save (writer);
writer.close();
}
MWState::Character *MWState::StateManager::getCurrentCharacter()
{
return mCharacterManager.getCurrentCharacter();
}