Made the game counter more logical.

This commit is contained in:
Leon Styhre 2020-11-10 18:48:16 +01:00
parent 6bc30a68cb
commit 0bb8737211
4 changed files with 12 additions and 16 deletions

View file

@ -517,9 +517,8 @@ void FileData::sort(ComparisonFunction& comparator, bool ascending,
for (auto it = mChildren.cbegin(); it != mChildren.cend(); it++) { for (auto it = mChildren.cbegin(); it != mChildren.cend(); it++) {
// Game count, which will be displayed in the system view. // Game count, which will be displayed in the system view.
if ((*it)->getType() == GAME && (*it)->getCountAsGame()) { if ((*it)->getType() == GAME && (*it)->getCountAsGame()) {
if (!(*it)->getFavorite()) gameCount.first++;
gameCount.first++; if ((*it)->getFavorite())
else
gameCount.second++; gameCount.second++;
} }
@ -581,9 +580,8 @@ void FileData::sortFavoritesOnTop(ComparisonFunction& comparator, bool ascending
// Game count, which will be displayed in the system view. // Game count, which will be displayed in the system view.
if (mChildren[i]->getType() == GAME && mChildren[i]->getCountAsGame()) { if (mChildren[i]->getType() == GAME && mChildren[i]->getCountAsGame()) {
if (!mChildren[i]->getFavorite()) gameCount.first++;
gameCount.first++; if (mChildren[i]->getFavorite())
else
gameCount.second++; gameCount.second++;
} }
@ -702,9 +700,8 @@ void FileData::countGames(std::pair<unsigned int, unsigned int>& gameCount)
{ {
for (unsigned int i = 0; i < mChildren.size(); i++) { for (unsigned int i = 0; i < mChildren.size(); i++) {
if (mChildren[i]->getType() == GAME && mChildren[i]->getCountAsGame()) { if (mChildren[i]->getType() == GAME && mChildren[i]->getCountAsGame()) {
if (!mChildren[i]->getFavorite()) gameCount.first++;
gameCount.first++; if (mChildren[i]->getFavorite())
else
gameCount.second++; gameCount.second++;
} }
// Iterate through any folders. // Iterate through any folders.

View file

@ -146,7 +146,7 @@ private:
std::unordered_map<std::string,FileData*> mChildrenByFilename; std::unordered_map<std::string,FileData*> mChildrenByFilename;
std::vector<FileData*> mChildren; std::vector<FileData*> mChildren;
std::vector<FileData*> mFilteredChildren; std::vector<FileData*> mFilteredChildren;
// The pair includes non-favorite games, and favorite games. // The pair includes all games, and favorite games.
std::pair<unsigned int, unsigned int> mGameCount; std::pair<unsigned int, unsigned int> mGameCount;
bool mOnlyFolders; bool mOnlyFolders;
bool mHasFolders; bool mHasFolders;

View file

@ -284,19 +284,18 @@ void SystemView::onCursorChanged(const CursorState& /*state*/)
// Also change the text after we've fully faded out. // Also change the text after we've fully faded out.
setAnimation(infoFadeOut, 0, [this, gameCount] { setAnimation(infoFadeOut, 0, [this, gameCount] {
std::stringstream ss; std::stringstream ss;
unsigned int totalGameCount = gameCount.first + gameCount.second;
if (!getSelected()->isGameSystem()) if (!getSelected()->isGameSystem())
ss << "CONFIGURATION"; ss << "CONFIGURATION";
else if (getSelected()->isCollection() && (getSelected()->getName() == "favorites")) 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 // The 'recent' gamelist has probably been trimmed after sorting, so we'll cap it at
// its maximum limit of 50 games. // its maximum limit of 50 games.
else if (getSelected()->isCollection() && (getSelected()->getName() == "recent")) else if (getSelected()->isCollection() && (getSelected()->getName() == "recent"))
ss << (totalGameCount > 50 ? 50 : totalGameCount) << " GAME" << ss << (gameCount.first > 50 ? 50 : gameCount.first) << " GAME" <<
(totalGameCount == 1 ? " " : "S"); (gameCount.first == 1 ? " " : "S");
else else
ss << totalGameCount << " GAME" << (totalGameCount == 1 ? " " : "S ") << "(" << ss << gameCount.first << " GAME" << (gameCount.first == 1 ? " " : "S ") << "(" <<
gameCount.second << " FAVORITE" << (gameCount.second == 1 ? ")" : "S)"); gameCount.second << " FAVORITE" << (gameCount.second == 1 ? ")" : "S)");
mSystemInfo.setText(ss.str()); mSystemInfo.setText(ss.str());

View file

@ -365,7 +365,7 @@ void ISimpleGameListView::generateGamelistInfo(FileData* cursor, FileData* first
gameCount = rootFolder->getGameCount(); gameCount = rootFolder->getGameCount();
mGameCount = gameCount.first + gameCount.second; mGameCount = gameCount.first;
mFavoritesGameCount = gameCount.second; mFavoritesGameCount = gameCount.second;
mFilteredGameCount = 0; mFilteredGameCount = 0;
mFilteredGameCountAll = 0; mFilteredGameCountAll = 0;