From 0bb8737211c5cdb2e2aff243501a741de9ce1ba1 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Tue, 10 Nov 2020 18:48:16 +0100 Subject: [PATCH] Made the game counter more logical. --- es-app/src/FileData.cpp | 15 ++++++--------- es-app/src/FileData.h | 2 +- es-app/src/views/SystemView.cpp | 9 ++++----- es-app/src/views/gamelist/ISimpleGameListView.cpp | 2 +- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/es-app/src/FileData.cpp b/es-app/src/FileData.cpp index 5cc5f393a..bed5aacdb 100644 --- a/es-app/src/FileData.cpp +++ b/es-app/src/FileData.cpp @@ -517,9 +517,8 @@ void FileData::sort(ComparisonFunction& comparator, bool ascending, for (auto it = mChildren.cbegin(); it != mChildren.cend(); it++) { // Game count, which will be displayed in the system view. if ((*it)->getType() == GAME && (*it)->getCountAsGame()) { - if (!(*it)->getFavorite()) - gameCount.first++; - else + gameCount.first++; + if ((*it)->getFavorite()) gameCount.second++; } @@ -581,9 +580,8 @@ void FileData::sortFavoritesOnTop(ComparisonFunction& comparator, bool ascending // Game count, which will be displayed in the system view. if (mChildren[i]->getType() == GAME && mChildren[i]->getCountAsGame()) { - if (!mChildren[i]->getFavorite()) - gameCount.first++; - else + gameCount.first++; + if (mChildren[i]->getFavorite()) gameCount.second++; } @@ -702,9 +700,8 @@ void FileData::countGames(std::pair& gameCount) { for (unsigned int i = 0; i < mChildren.size(); i++) { if (mChildren[i]->getType() == GAME && mChildren[i]->getCountAsGame()) { - if (!mChildren[i]->getFavorite()) - gameCount.first++; - else + gameCount.first++; + if (mChildren[i]->getFavorite()) gameCount.second++; } // Iterate through any folders. diff --git a/es-app/src/FileData.h b/es-app/src/FileData.h index 3573381db..c26a01ff2 100644 --- a/es-app/src/FileData.h +++ b/es-app/src/FileData.h @@ -146,7 +146,7 @@ private: std::unordered_map mChildrenByFilename; std::vector mChildren; std::vector mFilteredChildren; - // The pair includes non-favorite games, and favorite games. + // The pair includes all games, and favorite games. std::pair mGameCount; bool mOnlyFolders; bool mHasFolders; diff --git a/es-app/src/views/SystemView.cpp b/es-app/src/views/SystemView.cpp index ed6f4648a..763ba2826 100644 --- a/es-app/src/views/SystemView.cpp +++ b/es-app/src/views/SystemView.cpp @@ -284,19 +284,18 @@ void SystemView::onCursorChanged(const CursorState& /*state*/) // Also change the text after we've fully faded out. setAnimation(infoFadeOut, 0, [this, gameCount] { std::stringstream ss; - unsigned int totalGameCount = gameCount.first + gameCount.second; if (!getSelected()->isGameSystem()) ss << "CONFIGURATION"; else if (getSelected()->isCollection() && (getSelected()->getName() == "favorites")) - ss << totalGameCount << " GAME" << (totalGameCount == 1 ? " " : "S"); + ss << gameCount.first << " GAME" << (gameCount.first == 1 ? " " : "S"); // The 'recent' gamelist has probably been trimmed after sorting, so we'll cap it at // its maximum limit of 50 games. else if (getSelected()->isCollection() && (getSelected()->getName() == "recent")) - ss << (totalGameCount > 50 ? 50 : totalGameCount) << " GAME" << - (totalGameCount == 1 ? " " : "S"); + ss << (gameCount.first > 50 ? 50 : gameCount.first) << " GAME" << + (gameCount.first == 1 ? " " : "S"); else - ss << totalGameCount << " GAME" << (totalGameCount == 1 ? " " : "S ") << "(" << + ss << gameCount.first << " GAME" << (gameCount.first == 1 ? " " : "S ") << "(" << gameCount.second << " FAVORITE" << (gameCount.second == 1 ? ")" : "S)"); mSystemInfo.setText(ss.str()); diff --git a/es-app/src/views/gamelist/ISimpleGameListView.cpp b/es-app/src/views/gamelist/ISimpleGameListView.cpp index 000c19512..12110611d 100644 --- a/es-app/src/views/gamelist/ISimpleGameListView.cpp +++ b/es-app/src/views/gamelist/ISimpleGameListView.cpp @@ -365,7 +365,7 @@ void ISimpleGameListView::generateGamelistInfo(FileData* cursor, FileData* first gameCount = rootFolder->getGameCount(); - mGameCount = gameCount.first + gameCount.second; + mGameCount = gameCount.first; mFavoritesGameCount = gameCount.second; mFilteredGameCount = 0; mFilteredGameCountAll = 0;