diff options
| author | Leland Liu <14846866+lelandliu@users.noreply.github.com> | 2019-07-09 22:23:24 -0400 | 
|---|---|---|
| committer | Petr Mrázek <peterix@gmail.com> | 2021-07-22 20:26:59 +0200 | 
| commit | 1762d2fc7de99e38477a517c9b379447fd00b968 (patch) | |
| tree | 8c510ad8f7de5e98dc8c46a3e2deac04ee4fd9a8 /api/logic | |
| parent | 8ea500de68fa184ab1198f7a68c53987840014c3 (diff) | |
| download | PrismLauncher-1762d2fc7de99e38477a517c9b379447fd00b968.tar.gz PrismLauncher-1762d2fc7de99e38477a517c9b379447fd00b968.tar.bz2 PrismLauncher-1762d2fc7de99e38477a517c9b379447fd00b968.zip | |
Added total playtime
Diffstat (limited to 'api/logic')
| -rw-r--r-- | api/logic/InstanceList.cpp | 18 | ||||
| -rw-r--r-- | api/logic/InstanceList.h | 4 | 
2 files changed, 21 insertions, 1 deletions
| diff --git a/api/logic/InstanceList.cpp b/api/logic/InstanceList.cpp index 02fae6ac..cb38853b 100644 --- a/api/logic/InstanceList.cpp +++ b/api/logic/InstanceList.cpp @@ -387,9 +387,19 @@ InstanceList::InstListError InstanceList::loadList()          add(newList);      }      m_dirty = false; +    updateTotalPlayTime();      return NoError;  } +void InstanceList::updateTotalPlayTime() +{ +    totalPlayTime = 0; +    for(auto const& itr : m_instances) +    { +        totalPlayTime += itr.get()->totalTimePlayed(); +    } +} +  void InstanceList::saveNow()  {      for(auto & item: m_instances) @@ -475,6 +485,7 @@ void InstanceList::propertiesChanged(BaseInstance *inst)      if (i != -1)      {          emit dataChanged(index(i), index(i)); +        updateTotalPlayTime();      }  } @@ -848,4 +859,9 @@ bool InstanceList::destroyStagingPath(const QString& keyPath)      return FS::deletePath(keyPath);  } -#include "InstanceList.moc"
\ No newline at end of file +int InstanceList::getTotalPlayTime() { +    updateTotalPlayTime(); +    return totalPlayTime; +} + +#include "InstanceList.moc" diff --git a/api/logic/InstanceList.h b/api/logic/InstanceList.h index 8215cb66..56ee3be4 100644 --- a/api/logic/InstanceList.h +++ b/api/logic/InstanceList.h @@ -128,6 +128,8 @@ public:       */      bool destroyStagingPath(const QString & keyPath); +    int getTotalPlayTime(); +  signals:      void dataIsInvalid();      void instancesChanged(); @@ -145,6 +147,7 @@ private slots:  private:      int getInstIndex(BaseInstance *inst) const; +    void updateTotalPlayTime();      void suspendWatch();      void resumeWatch();      void add(const QList<InstancePtr> &list); @@ -155,6 +158,7 @@ private:  private:      int m_watchLevel = 0; +    int totalPlayTime = 0;      bool m_dirty = false;      QList<InstancePtr> m_instances;      QSet<QString> m_groupNameCache; | 
