forked from mirror/openmw-tes3mp
improved character selection logic
This commit is contained in:
parent
67cd0887e6
commit
e3670cff8a
6 changed files with 23 additions and 15 deletions
|
@ -63,7 +63,8 @@ namespace MWBase
|
|||
///
|
||||
/// \note \a slot must belong to \a character.
|
||||
|
||||
virtual MWState::Character *getCurrentCharacter() = 0;
|
||||
virtual MWState::Character *getCurrentCharacter (bool create = true) = 0;
|
||||
///< \param create Create a new character, if there is no current character.
|
||||
|
||||
virtual CharacterIterator characterBegin() = 0;
|
||||
///< Any call to SaveGame and getCurrentCharacter can invalidate the returned
|
||||
|
|
|
@ -91,9 +91,10 @@ namespace MWGui
|
|||
if (mgr->characterBegin() == mgr->characterEnd())
|
||||
return;
|
||||
|
||||
mCurrentCharacter = mgr->getCurrentCharacter();
|
||||
mCurrentCharacter = mgr->getCurrentCharacter (false);
|
||||
|
||||
mCharacterSelection->removeAllItems();
|
||||
|
||||
for (MWBase::StateManager::CharacterIterator it = mgr->characterBegin(); it != mgr->characterEnd(); ++it)
|
||||
{
|
||||
if (it->begin()!=it->end())
|
||||
|
@ -104,7 +105,7 @@ namespace MWGui
|
|||
|
||||
mCharacterSelection->addItem (title.str());
|
||||
|
||||
if (mgr->getCurrentCharacter() == &*it)
|
||||
if (mCurrentCharacter == &*it)
|
||||
mCharacterSelection->setIndexSelected(mCharacterSelection->getItemCount()-1);
|
||||
}
|
||||
}
|
||||
|
@ -123,7 +124,7 @@ namespace MWGui
|
|||
|
||||
if (!load)
|
||||
{
|
||||
mCurrentCharacter = MWBase::Environment::get().getStateManager()->getCurrentCharacter();
|
||||
mCurrentCharacter = MWBase::Environment::get().getStateManager()->getCurrentCharacter (false);
|
||||
}
|
||||
|
||||
center();
|
||||
|
@ -139,11 +140,15 @@ namespace MWGui
|
|||
// Get the selected slot, if any
|
||||
unsigned int i=0;
|
||||
const MWState::Slot* slot = NULL;
|
||||
|
||||
if (mCurrentCharacter)
|
||||
{
|
||||
for (MWState::Character::SlotIterator it = mCurrentCharacter->begin(); it != mCurrentCharacter->end(); ++it,++i)
|
||||
{
|
||||
if (i == mSaveList->getIndexSelected())
|
||||
slot = &*it;
|
||||
}
|
||||
}
|
||||
|
||||
if (mSaving)
|
||||
{
|
||||
|
@ -151,6 +156,7 @@ namespace MWGui
|
|||
}
|
||||
else
|
||||
{
|
||||
if (mCurrentCharacter && slot)
|
||||
MWBase::Environment::get().getStateManager()->loadGame (mCurrentCharacter, slot);
|
||||
}
|
||||
|
||||
|
|
|
@ -38,9 +38,9 @@ MWState::CharacterManager::CharacterManager (const boost::filesystem::path& save
|
|||
}
|
||||
}
|
||||
|
||||
MWState::Character *MWState::CharacterManager::getCurrentCharacter()
|
||||
MWState::Character *MWState::CharacterManager::getCurrentCharacter (bool create)
|
||||
{
|
||||
if (!mCurrent)
|
||||
if (!mCurrent && create)
|
||||
createCharacter();
|
||||
|
||||
return mCurrent;
|
||||
|
|
|
@ -26,8 +26,8 @@ namespace MWState
|
|||
|
||||
CharacterManager (const boost::filesystem::path& saves);
|
||||
|
||||
Character *getCurrentCharacter();
|
||||
///< A character is implicitly created, if there is none.
|
||||
Character *getCurrentCharacter (bool create = true);
|
||||
///< \param create Create a new character, if there is no current character.
|
||||
|
||||
void createCharacter();
|
||||
///< Create new character within saved game management
|
||||
|
|
|
@ -138,9 +138,9 @@ void MWState::StateManager::loadGame (const Character *character, const Slot *sl
|
|||
mState = State_Running;
|
||||
}
|
||||
|
||||
MWState::Character *MWState::StateManager::getCurrentCharacter()
|
||||
MWState::Character *MWState::StateManager::getCurrentCharacter (bool create)
|
||||
{
|
||||
return mCharacterManager.getCurrentCharacter();
|
||||
return mCharacterManager.getCurrentCharacter (create);
|
||||
}
|
||||
|
||||
MWState::StateManager::CharacterIterator MWState::StateManager::characterBegin()
|
||||
|
|
|
@ -42,7 +42,8 @@ namespace MWState
|
|||
///
|
||||
/// \note \a slot must belong to \a character.
|
||||
|
||||
virtual Character *getCurrentCharacter();
|
||||
virtual Character *getCurrentCharacter (bool create = true);
|
||||
///< \param create Create a new character, if there is no current character.
|
||||
|
||||
virtual CharacterIterator characterBegin();
|
||||
///< Any call to SaveGame and getCurrentCharacter can invalidate the returned
|
||||
|
|
Loading…
Reference in a new issue