Moved quick save into statemanager class. Kept loader as is as it's rather specalized.

actorid
Thomas 11 years ago
parent 6a8bf71c4c
commit 05b21c92af

@ -65,6 +65,10 @@ namespace MWBase
///
/// \note \a slot must belong to \a character.
///Simple saver, writes over the file if already existing
/** Used for quick save and autosave **/
virtual void quickSave(std::string = "Quicksave")=0;
virtual MWState::Character *getCurrentCharacter (bool create = true) = 0;
///< \param create Create a new character, if there is no current character.

@ -122,7 +122,7 @@ namespace MWGui
world->getFader ()->fadeOut(0.2);
setVisible(false);
if(Settings::Manager::getBool("autosave","Saves")) //autosaves
autosave();
MWBase::Environment::get().getStateManager()->quickSave("Autosave");
mProgressBar.setVisible (true);
mWaiting = true;
@ -242,22 +242,6 @@ namespace MWGui
}
}
void WaitDialog::autosave() {
if(MWBase::Environment::get().getWorld()->getGlobalInt ("chargenstate")==-1) { //ensure you're not in character creation
const MWState::Slot* slot = NULL;
MWState::Character* mCurrentCharacter = MWBase::Environment::get().getStateManager()->getCurrentCharacter(true); //Get current character
if (mCurrentCharacter) //Ensure one exists
{
//Find quicksave slot
for (MWState::Character::SlotIterator it = mCurrentCharacter->begin(); it != mCurrentCharacter->end(); ++it)
{
if (it->mProfile.mDescription == "Autosave")
slot = &*it;
}
MWBase::Environment::get().getStateManager()->saveGame("Autosave", slot);
}
}
}
void WaitDialog::wakeUp ()
{

@ -657,21 +657,7 @@ namespace MWInput
}
void InputManager::quickSave() {
if(MWBase::Environment::get().getWorld()->getGlobalInt ("chargenstate")==-1) { //ensure you're not in character creation
const MWState::Slot* slot = NULL;
MWState::Character* mCurrentCharacter = MWBase::Environment::get().getStateManager()->getCurrentCharacter(true); //Get current character
if (mCurrentCharacter) //Ensure one exists
{
//Find quicksave slot
for (MWState::Character::SlotIterator it = mCurrentCharacter->begin(); it != mCurrentCharacter->end(); ++it)
{
if (it->mProfile.mDescription == "Quicksave")
slot = &*it;
}
//MWBase::Environment::get().getWindowManager()->messageBox("#{sQuick_save}"); //No message on quicksave?
MWBase::Environment::get().getStateManager()->saveGame("Quicksave", slot);
}
}
MWBase::Environment::get().getStateManager()->quickSave();
}
void InputManager::toggleSpell()
{

@ -223,6 +223,23 @@ void MWState::StateManager::saveGame (const std::string& description, const Slot
slot->mPath.parent_path().filename().string());
}
void MWState::StateManager::quickSave(std::string name) {
if(MWBase::Environment::get().getWorld()->getGlobalInt ("chargenstate")==-1) { //ensure you're not in character creation
const MWState::Slot* slot = NULL;
MWState::Character* mCurrentCharacter = MWBase::Environment::get().getStateManager()->getCurrentCharacter(true); //Get current character
if (mCurrentCharacter) //Ensure one exists
{
//Find quicksave slot
for (MWState::Character::SlotIterator it = mCurrentCharacter->begin(); it != mCurrentCharacter->end(); ++it)
{
if (it->mProfile.mDescription == name)
slot = &*it;
}
MWBase::Environment::get().getStateManager()->saveGame(name, slot);
}
}
}
void MWState::StateManager::loadGame (const Character *character, const Slot *slot)
{
try
@ -309,11 +326,11 @@ void MWState::StateManager::loadGame (const Character *character, const Slot *sl
MWBase::Environment::get().getMechanicsManager()->playerLoaded();
MWWorld::Ptr ptr = MWBase::Environment::get().getWorld()->getPlayerPtr();
//Update the weapon icon in the hud with whatever the player is currently holding.
MWWorld::InventoryStore& invStore = ptr.getClass().getInventoryStore(ptr);
MWWorld::ContainerStoreIterator item = invStore.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
if (item != invStore.end())
MWBase::Environment::get().getWindowManager()->setSelectedWeapon(*item);

@ -49,6 +49,10 @@ namespace MWState
///
/// \note Slot must belong to the current character.
///Saves a file, using supplied filename, overwritting if needed
/** This is mostly used for quicksaving and autosaving, for they use the same name over and over again **/
virtual void quickSave(std::string name = "Quicksave");
virtual void loadGame (const Character *character, const Slot *slot);
///< Load a saved game file from \a slot.
///

Loading…
Cancel
Save