forked from mirror/openmw-tes3mp
restore last played character selection across sessions
This commit is contained in:
parent
b40c0f2a07
commit
eea433f141
3 changed files with 23 additions and 4 deletions
|
@ -1,10 +1,13 @@
|
||||||
#include "savegamedialog.hpp"
|
#include "savegamedialog.hpp"
|
||||||
#include "widgets.hpp"
|
#include "widgets.hpp"
|
||||||
|
|
||||||
|
#include <components/misc/stringops.hpp>
|
||||||
|
|
||||||
|
#include <components/settings/settings.hpp>
|
||||||
|
|
||||||
#include "../mwbase/statemanager.hpp"
|
#include "../mwbase/statemanager.hpp"
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
|
|
||||||
|
|
||||||
#include "../mwstate/character.hpp"
|
#include "../mwstate/character.hpp"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
|
@ -93,6 +96,9 @@ namespace MWGui
|
||||||
|
|
||||||
mCurrentCharacter = mgr->getCurrentCharacter (false);
|
mCurrentCharacter = mgr->getCurrentCharacter (false);
|
||||||
|
|
||||||
|
std::string directory =
|
||||||
|
Misc::StringUtils::lowerCase (Settings::Manager::getString ("character", "Saves"));
|
||||||
|
|
||||||
mCharacterSelection->removeAllItems();
|
mCharacterSelection->removeAllItems();
|
||||||
|
|
||||||
for (MWBase::StateManager::CharacterIterator it = mgr->characterBegin(); it != mgr->characterEnd(); ++it)
|
for (MWBase::StateManager::CharacterIterator it = mgr->characterBegin(); it != mgr->characterEnd(); ++it)
|
||||||
|
@ -105,7 +111,9 @@ namespace MWGui
|
||||||
|
|
||||||
mCharacterSelection->addItem (title.str());
|
mCharacterSelection->addItem (title.str());
|
||||||
|
|
||||||
if (mCurrentCharacter == &*it)
|
if (mCurrentCharacter == &*it ||
|
||||||
|
(!mCurrentCharacter && directory==Misc::StringUtils::lowerCase (
|
||||||
|
it->begin()->mPath.parent_path().filename().string())))
|
||||||
mCharacterSelection->setIndexSelected(mCharacterSelection->getItemCount()-1);
|
mCharacterSelection->setIndexSelected(mCharacterSelection->getItemCount()-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
#include <components/esm/esmwriter.hpp>
|
#include <components/esm/esmwriter.hpp>
|
||||||
#include <components/esm/esmreader.hpp>
|
#include <components/esm/esmreader.hpp>
|
||||||
|
|
||||||
|
#include <components/settings/settings.hpp>
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
#include "../mwbase/world.hpp"
|
#include "../mwbase/world.hpp"
|
||||||
#include "../mwbase/journal.hpp"
|
#include "../mwbase/journal.hpp"
|
||||||
|
@ -114,6 +116,9 @@ void MWState::StateManager::saveGame (const std::string& description, const Slot
|
||||||
slot->mProfile.save (writer);
|
slot->mProfile.save (writer);
|
||||||
writer.endRecord ("SAVE");
|
writer.endRecord ("SAVE");
|
||||||
writer.close();
|
writer.close();
|
||||||
|
|
||||||
|
Settings::Manager::setString ("character", "Saves",
|
||||||
|
slot->mPath.parent_path().filename().string());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MWState::StateManager::loadGame (const Character *character, const Slot *slot)
|
void MWState::StateManager::loadGame (const Character *character, const Slot *slot)
|
||||||
|
@ -137,6 +142,9 @@ void MWState::StateManager::loadGame (const Character *character, const Slot *sl
|
||||||
mCharacterManager.setCurrentCharacter(character);
|
mCharacterManager.setCurrentCharacter(character);
|
||||||
|
|
||||||
mState = State_Running;
|
mState = State_Running;
|
||||||
|
|
||||||
|
Settings::Manager::setString ("character", "Saves",
|
||||||
|
slot->mPath.parent_path().filename().string());
|
||||||
}
|
}
|
||||||
|
|
||||||
MWState::Character *MWState::StateManager::getCurrentCharacter (bool create)
|
MWState::Character *MWState::StateManager::getCurrentCharacter (bool create)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# WARNING: Editing this file might have no effect, as these
|
# WARNING: Editing this file might have no effect, as these
|
||||||
# settings are overwritten by your user settings file.
|
# settings are overwritten by your user settings file.
|
||||||
|
|
||||||
[Video]
|
[Video]
|
||||||
|
@ -13,7 +13,7 @@ screen = 0
|
||||||
# Valid values:
|
# Valid values:
|
||||||
# OpenGL Rendering Subsystem
|
# OpenGL Rendering Subsystem
|
||||||
# Direct3D9 Rendering Subsystem
|
# Direct3D9 Rendering Subsystem
|
||||||
render system =
|
render system =
|
||||||
|
|
||||||
# Valid values:
|
# Valid values:
|
||||||
# none
|
# none
|
||||||
|
@ -169,3 +169,6 @@ ui y multiplier = 1.0
|
||||||
[Game]
|
[Game]
|
||||||
# Always use the most powerful attack when striking with a weapon (chop, slash or thrust)
|
# Always use the most powerful attack when striking with a weapon (chop, slash or thrust)
|
||||||
best attack = false
|
best attack = false
|
||||||
|
|
||||||
|
[Saves]
|
||||||
|
character =
|
Loading…
Reference in a new issue