mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 23:55:38 +00:00
Added a discrete game counting function.
This commit is contained in:
parent
2dc8b85aee
commit
f753fef1c5
|
@ -752,6 +752,22 @@ void FileData::sort(const SortType& type, bool mFavoritesOnTop)
|
|||
sort(*type.comparisonFunction, type.ascending, mGameCount);
|
||||
}
|
||||
|
||||
void FileData::countGames(std::pair<unsigned int, unsigned int>& 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.second++;
|
||||
}
|
||||
// Iterate through any folders.
|
||||
else if (mChildren[i]->getType() == FOLDER)
|
||||
mChildren[i]->countGames(gameCount);
|
||||
}
|
||||
mGameCount = gameCount;
|
||||
}
|
||||
|
||||
FileData::SortType FileData::getSortTypeFromString(std::string desc) {
|
||||
std::vector<FileData::SortType> SortTypes = FileSorts::SortTypes;
|
||||
|
||||
|
|
|
@ -123,6 +123,8 @@ public:
|
|||
std::pair<unsigned int, unsigned int>& gameCount);
|
||||
void sort(const SortType& type, bool mFavoritesOnTop = false);
|
||||
MetaDataList metadata;
|
||||
// Only count the games, a cheaper alternative to a full sort when that is not required.
|
||||
void countGames(std::pair<unsigned int, unsigned int>& gameCount);
|
||||
|
||||
inline void setSortTypeString(std::string typestring) { mSortTypeString = typestring; }
|
||||
inline std::string getSortTypeString() { return mSortTypeString; }
|
||||
|
|
Loading…
Reference in a new issue