1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-24 17:09:43 +00:00

keep track of total play time per character

This commit is contained in:
Marc Zinnschlag 2013-11-28 09:33:50 +01:00
parent 7e2819c62e
commit 35e8e23037
4 changed files with 18 additions and 2 deletions

View file

@ -117,6 +117,9 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt)
// update world // update world
MWBase::Environment::get().getWorld()->update(frametime, MWBase::Environment::get().getWindowManager()->isGuiMode()); MWBase::Environment::get().getWorld()->update(frametime, MWBase::Environment::get().getWindowManager()->isGuiMode());
// update game state
MWBase::Environment::get().getStateManager()->update (frametime);
} }
// update GUI // update GUI

View file

@ -71,6 +71,8 @@ namespace MWBase
/// iterator. /// iterator.
virtual CharacterIterator characterEnd() = 0; virtual CharacterIterator characterEnd() = 0;
virtual void update (float duration) = 0;
}; };
} }

View file

@ -18,7 +18,7 @@
#include "../mwmechanics/npcstats.hpp" #include "../mwmechanics/npcstats.hpp"
MWState::StateManager::StateManager (const boost::filesystem::path& saves, const std::string& game) 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(); MWBase::Environment::get().getJournal()->clear();
mState = State_NoGame; mState = State_NoGame;
mCharacterManager.clearCurrentCharacter(); mCharacterManager.clearCurrentCharacter();
mTimePlayed = 0;
} }
if (!bypass) if (!bypass)
@ -83,7 +84,7 @@ void MWState::StateManager::saveGame (const std::string& description, const Slot
profile.mInGameTime.mDay = world.getDay(); profile.mInGameTime.mDay = world.getDay();
profile.mInGameTime.mMonth = world.getMonth(); profile.mInGameTime.mMonth = world.getMonth();
profile.mInGameTime.mYear = world.getYear(); profile.mInGameTime.mYear = world.getYear();
/// \todo time played profile.mTimePlayed = mTimePlayed;
profile.mDescription = description; profile.mDescription = description;
if (!slot) if (!slot)
@ -114,6 +115,8 @@ void MWState::StateManager::loadGame (const Character *character, const Slot *sl
mCharacterManager.clearCurrentCharacter(); mCharacterManager.clearCurrentCharacter();
} }
mTimePlayed = slot->mProfile.mTimePlayed;
ESM::ESMReader reader; ESM::ESMReader reader;
reader.open (slot->mPath.string()); reader.open (slot->mPath.string());
@ -144,3 +147,8 @@ MWState::StateManager::CharacterIterator MWState::StateManager::characterEnd()
{ {
return mCharacterManager.end(); return mCharacterManager.end();
} }
void MWState::StateManager::update (float duration)
{
mTimePlayed += duration;
}

View file

@ -14,6 +14,7 @@ namespace MWState
bool mQuitRequest; bool mQuitRequest;
State mState; State mState;
CharacterManager mCharacterManager; CharacterManager mCharacterManager;
double mTimePlayed;
public: public:
@ -50,6 +51,8 @@ namespace MWState
/// iterator. /// iterator.
virtual CharacterIterator characterEnd(); virtual CharacterIterator characterEnd();
virtual void update (float duration);
}; };
} }