mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-17 01:10:10 +00:00
bug 428 ask to load recent saved game
This commit is contained in:
parent
a854eb73db
commit
3816a09c6f
@ -44,6 +44,8 @@ namespace MWBase
|
||||
|
||||
virtual bool hasQuitRequest() const = 0;
|
||||
|
||||
virtual void askLoadRecent() = 0;
|
||||
|
||||
virtual State getState() const = 0;
|
||||
|
||||
virtual void newGame (bool bypass = false) = 0;
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "../mwbase/world.hpp"
|
||||
#include "../mwbase/soundmanager.hpp"
|
||||
#include "../mwbase/windowmanager.hpp"
|
||||
#include "../mwbase/statemanager.hpp"
|
||||
|
||||
#include "../mwworld/player.hpp"
|
||||
#include "../mwworld/class.hpp"
|
||||
@ -1057,11 +1058,10 @@ bool CharacterController::kill()
|
||||
if( isDead() )
|
||||
{
|
||||
//player's death animation is over
|
||||
if( mPtr.getRefData().getHandle()=="player" && !isAnimPlaying(mCurrentDeath)
|
||||
&& MWBase::Environment::get().getWindowManager()->getMode() != MWGui::GM_MainMenu )
|
||||
if( mPtr.getRefData().getHandle()=="player" && !isAnimPlaying(mCurrentDeath) )
|
||||
{
|
||||
MWWorld::Class::get(mPtr).getCreatureStats(mPtr).setHealth(0);
|
||||
MWBase::Environment::get().getWindowManager()->pushGuiMode (MWGui::GM_MainMenu);
|
||||
MWBase::Environment::get().getStateManager()->askLoadRecent();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ void MWState::StateManager::cleanup()
|
||||
}
|
||||
|
||||
MWState::StateManager::StateManager (const boost::filesystem::path& saves, const std::string& game)
|
||||
: mQuitRequest (false), mState (State_NoGame), mCharacterManager (saves, game), mTimePlayed (0)
|
||||
: mQuitRequest (false), mAskLoadRecent(false), mState (State_NoGame), mCharacterManager (saves, game), mTimePlayed (0)
|
||||
{
|
||||
|
||||
}
|
||||
@ -47,6 +47,48 @@ bool MWState::StateManager::hasQuitRequest() const
|
||||
return mQuitRequest;
|
||||
}
|
||||
|
||||
void MWState::StateManager::askLoadRecent()
|
||||
{
|
||||
if (MWBase::Environment::get().getWindowManager()->getMode() == MWGui::GM_MainMenu)
|
||||
return;
|
||||
|
||||
if( !mAskLoadRecent )
|
||||
{
|
||||
if(MWBase::Environment::get().getStateManager()->getCurrentCharacter()->begin()
|
||||
== MWBase::Environment::get().getStateManager()->getCurrentCharacter()->end() )//no saves
|
||||
{
|
||||
MWBase::Environment::get().getWindowManager()->pushGuiMode (MWGui::GM_MainMenu);
|
||||
}
|
||||
else
|
||||
{
|
||||
MWState::Slot lastSave = *getCurrentCharacter()->begin();
|
||||
std::vector<std::string> buttons;
|
||||
buttons.push_back("Yes");
|
||||
buttons.push_back("No");
|
||||
std::string message = "The most recent Save Game is '" + lastSave.mProfile.mDescription + "'.\n Would you like to load it?";
|
||||
MWBase::Environment::get().getWindowManager()->messageBox(message, buttons);
|
||||
mAskLoadRecent = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int iButton = MWBase::Environment::get().getWindowManager()->readPressedButton();
|
||||
if(iButton==0)
|
||||
{
|
||||
mAskLoadRecent = false;
|
||||
//Load last saved game for current character
|
||||
MWState::Character *curCharacter = getCurrentCharacter();
|
||||
MWState::Slot lastSave = *curCharacter->begin();
|
||||
loadGame(curCharacter, &lastSave);
|
||||
}
|
||||
else if(iButton==1)
|
||||
{
|
||||
mAskLoadRecent = false;
|
||||
MWBase::Environment::get().getWindowManager()->pushGuiMode (MWGui::GM_MainMenu);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MWState::StateManager::State MWState::StateManager::getState() const
|
||||
{
|
||||
return mState;
|
||||
|
@ -12,6 +12,7 @@ namespace MWState
|
||||
class StateManager : public MWBase::StateManager
|
||||
{
|
||||
bool mQuitRequest;
|
||||
bool mAskLoadRecent;
|
||||
State mState;
|
||||
CharacterManager mCharacterManager;
|
||||
double mTimePlayed;
|
||||
@ -28,6 +29,8 @@ namespace MWState
|
||||
|
||||
virtual bool hasQuitRequest() const;
|
||||
|
||||
virtual void askLoadRecent();
|
||||
|
||||
virtual State getState() const;
|
||||
|
||||
virtual void newGame (bool bypass = false);
|
||||
|
Loading…
Reference in New Issue
Block a user