mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-20 15:40:32 +00:00
keep track of total play time per character
This commit is contained in:
parent
7e2819c62e
commit
35e8e23037
@ -117,6 +117,9 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt)
|
||||
|
||||
// update world
|
||||
MWBase::Environment::get().getWorld()->update(frametime, MWBase::Environment::get().getWindowManager()->isGuiMode());
|
||||
|
||||
// update game state
|
||||
MWBase::Environment::get().getStateManager()->update (frametime);
|
||||
}
|
||||
|
||||
// update GUI
|
||||
|
@ -71,6 +71,8 @@ namespace MWBase
|
||||
/// iterator.
|
||||
|
||||
virtual CharacterIterator characterEnd() = 0;
|
||||
|
||||
virtual void update (float duration) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include "../mwmechanics/npcstats.hpp"
|
||||
|
||||
MWState::StateManager::StateManager (const boost::filesystem::path& saves, const std::string& game)
|
||||
: mQuitRequest (false), mState (State_NoGame), mCharacterManager (saves, game)
|
||||
: mQuitRequest (false), mState (State_NoGame), mCharacterManager (saves, game), mTimePlayed (0)
|
||||
{
|
||||
|
||||
}
|
||||
@ -46,6 +46,7 @@ void MWState::StateManager::newGame (bool bypass)
|
||||
MWBase::Environment::get().getJournal()->clear();
|
||||
mState = State_NoGame;
|
||||
mCharacterManager.clearCurrentCharacter();
|
||||
mTimePlayed = 0;
|
||||
}
|
||||
|
||||
if (!bypass)
|
||||
@ -83,7 +84,7 @@ void MWState::StateManager::saveGame (const std::string& description, const Slot
|
||||
profile.mInGameTime.mDay = world.getDay();
|
||||
profile.mInGameTime.mMonth = world.getMonth();
|
||||
profile.mInGameTime.mYear = world.getYear();
|
||||
/// \todo time played
|
||||
profile.mTimePlayed = mTimePlayed;
|
||||
profile.mDescription = description;
|
||||
|
||||
if (!slot)
|
||||
@ -114,6 +115,8 @@ void MWState::StateManager::loadGame (const Character *character, const Slot *sl
|
||||
mCharacterManager.clearCurrentCharacter();
|
||||
}
|
||||
|
||||
mTimePlayed = slot->mProfile.mTimePlayed;
|
||||
|
||||
ESM::ESMReader reader;
|
||||
reader.open (slot->mPath.string());
|
||||
|
||||
@ -144,3 +147,8 @@ MWState::StateManager::CharacterIterator MWState::StateManager::characterEnd()
|
||||
{
|
||||
return mCharacterManager.end();
|
||||
}
|
||||
|
||||
void MWState::StateManager::update (float duration)
|
||||
{
|
||||
mTimePlayed += duration;
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ namespace MWState
|
||||
bool mQuitRequest;
|
||||
State mState;
|
||||
CharacterManager mCharacterManager;
|
||||
double mTimePlayed;
|
||||
|
||||
public:
|
||||
|
||||
@ -50,6 +51,8 @@ namespace MWState
|
||||
/// iterator.
|
||||
|
||||
virtual CharacterIterator characterEnd();
|
||||
|
||||
virtual void update (float duration);
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user