diff --git a/es-app/src/guis/GuiGamelistFilter.cpp b/es-app/src/guis/GuiGamelistFilter.cpp index 8889e7361..b2797fe6c 100644 --- a/es-app/src/guis/GuiGamelistFilter.cpp +++ b/es-app/src/guis/GuiGamelistFilter.cpp @@ -53,26 +53,6 @@ void GuiGamelistFilter::initializeMenu() void GuiGamelistFilter::resetAllFilters() { - // For grouped custom collections, if the user locks himself out by applying a filter - // and then removes all entries that are applied by the filter, then this workaround is - // required to reset the filters. This situation may occur if filtering on favorite games, - // and then unflagging all games as favorites, ending up with the - // indicator. Without this code an application restart would have been required to - // reset the filters. - if (mSystem->isCollection() && mSystem->getFullName() == "collections") { - std::vector customCollections = mSystem->getRootFolder()->getChildren(); - if (customCollections.size() > 0) { - for (auto it = customCollections.begin(); it != customCollections.end(); it++) { - FileFilterIndex* customIndex = (*it)->getSystem()->getIndex(); - if (customIndex->isFiltered()) { - std::vector customChildren = (*it)->getChildrenListToDisplay(); - if (customChildren.size() == 0) - customIndex->resetFilters(); - } - } - } - } - mFilterIndex->resetFilters(); for (std::map>>:: const_iterator it = mFilterOptions.cbegin(); it != mFilterOptions.cend(); ++it ) { diff --git a/es-app/src/views/gamelist/BasicGameListView.cpp b/es-app/src/views/gamelist/BasicGameListView.cpp index 88cea3e32..0c8267128 100644 --- a/es-app/src/views/gamelist/BasicGameListView.cpp +++ b/es-app/src/views/gamelist/BasicGameListView.cpp @@ -26,7 +26,7 @@ BasicGameListView::BasicGameListView(Window* window, FileData* root) mList.setDefaultZIndex(20); addChild(&mList); - populateList(root->getChildrenListToDisplay()); + populateList(root->getChildrenListToDisplay(), root); } void BasicGameListView::onThemeChanged(const std::shared_ptr& theme) @@ -49,7 +49,7 @@ void BasicGameListView::onFileChanged(FileData* file, bool reloadGameList) ISimpleGameListView::onFileChanged(file, reloadGameList); } -void BasicGameListView::populateList(const std::vector& files) +void BasicGameListView::populateList(const std::vector& files, FileData* firstEntry) { mFirstGameEntry = nullptr; bool favoriteStar = true; @@ -57,9 +57,6 @@ void BasicGameListView::populateList(const std::vector& files) std::string editingCollection; std::string inCollectionPrefix; - generateGamelistInfo(files); - generateFirstLetterIndex(files); - if (CollectionSystemManager::get()->isEditing()) { editingCollection = CollectionSystemManager::get()->getEditingCollection(); isEditing = true; @@ -103,8 +100,11 @@ void BasicGameListView::populateList(const std::vector& files) } } else { - addPlaceholder(); + addPlaceholder(firstEntry); } + + generateGamelistInfo(getCursor(), firstEntry); + generateFirstLetterIndex(files); } FileData* BasicGameListView::getCursor() @@ -115,7 +115,7 @@ FileData* BasicGameListView::getCursor() void BasicGameListView::setCursor(FileData* cursor) { if (!mList.setCursor(cursor) && (!cursor->isPlaceHolder())) { - populateList(cursor->getParent()->getChildrenListToDisplay()); + populateList(cursor->getParent()->getChildrenListToDisplay(), cursor->getParent()); mList.setCursor(cursor); // Update our cursor stack in case our cursor just @@ -163,11 +163,17 @@ FileData* BasicGameListView::getFirstGameEntry() return mFirstGameEntry; } -void BasicGameListView::addPlaceholder() +void BasicGameListView::addPlaceholder(FileData* firstEntry) { // Empty list - add a placeholder. + SystemData* system; + if (firstEntry && firstEntry->getSystem()->isGroupedCustomCollection()) + system = firstEntry->getSystem(); + else + system = this->mRoot->getSystem(); + FileData* placeholder = new FileData(PLACEHOLDER, "", - this->mRoot->getSystem()->getSystemEnvData(), this->mRoot->getSystem()); + this->mRoot->getSystem()->getSystemEnvData(), system); mList.add(placeholder->getName(), placeholder, (placeholder->getType() == PLACEHOLDER)); } diff --git a/es-app/src/views/gamelist/BasicGameListView.h b/es-app/src/views/gamelist/BasicGameListView.h index 3d3cc668e..f4aa9daac 100644 --- a/es-app/src/views/gamelist/BasicGameListView.h +++ b/es-app/src/views/gamelist/BasicGameListView.h @@ -44,10 +44,10 @@ public: protected: virtual std::string getQuickSystemSelectRightButton() override; virtual std::string getQuickSystemSelectLeftButton() override; - virtual void populateList(const std::vector& files) override; + virtual void populateList(const std::vector& files, FileData* firstEntry) override; virtual void remove(FileData* game, bool deleteFile) override; virtual void removeMedia(FileData* game) override; - virtual void addPlaceholder(); + virtual void addPlaceholder(FileData* firstEntry = nullptr); TextListComponent mList; // Points to the first game in the list, i.e. the first entry which is of the type 'GAME'. diff --git a/es-app/src/views/gamelist/GridGameListView.cpp b/es-app/src/views/gamelist/GridGameListView.cpp index 8c542d8c4..623c73ad7 100644 --- a/es-app/src/views/gamelist/GridGameListView.cpp +++ b/es-app/src/views/gamelist/GridGameListView.cpp @@ -71,7 +71,7 @@ GridGameListView::GridGameListView( mGrid.setCursorChangedCallback([&](const CursorState& /*state*/) { updateInfoPanel(); }); addChild(&mGrid); - populateList(root->getChildrenListToDisplay()); + populateList(root->getChildrenListToDisplay(), root); // Metadata labels + values. mLblRating.setText("Rating: "); @@ -162,8 +162,8 @@ FileData* GridGameListView::getCursor() void GridGameListView::setCursor(FileData* file) { - if (!mGrid.setCursor(file)) { - populateList(file->getParent()->getChildrenListToDisplay()); + if (!mGrid.setCursor(file) && (!file->isPlaceHolder())) { + populateList(file->getParent()->getChildrenListToDisplay(), file->getParent()); mGrid.setCursor(file); } } @@ -244,13 +244,10 @@ const std::string GridGameListView::getImagePath(FileData* file) return file->getThumbnailPath(); } -void GridGameListView::populateList(const std::vector& files) +void GridGameListView::populateList(const std::vector& files, FileData* firstEntry) { firstGameEntry = nullptr; - generateGamelistInfo(files); - generateFirstLetterIndex(files); - mGrid.clear(); mHeaderText.setText(mRoot->getSystem()->getFullName()); if (files.size() > 0) { @@ -261,8 +258,11 @@ void GridGameListView::populateList(const std::vector& files) } } else { - addPlaceholder(); + addPlaceholder(firstEntry); } + + generateGamelistInfo(getCursor(), firstEntry); + generateFirstLetterIndex(files); } void GridGameListView::onThemeChanged(const std::shared_ptr& theme) @@ -310,7 +310,7 @@ void GridGameListView::onThemeChanged(const std::shared_ptr& theme) // Repopulate list in case a new theme is displaying a different image. // Preserve selection. FileData* file = mGrid.getSelected(); - populateList(mRoot->getChildrenListToDisplay()); + populateList(mRoot->getChildrenListToDisplay(), mRoot); mGrid.setCursor(file); mGamelistInfo.applyTheme(theme, getName(), "gamelistInfo", ALL ^ ThemeFlags::TEXT); @@ -517,11 +517,17 @@ void GridGameListView::updateInfoPanel() } } -void GridGameListView::addPlaceholder() +void GridGameListView::addPlaceholder(FileData* firstEntry) { - // Empty grid - add a placeholder. + // Empty list - add a placeholder. + SystemData* system; + if (firstEntry && firstEntry->getSystem()->isGroupedCustomCollection()) + system = firstEntry->getSystem(); + else + system = this->mRoot->getSystem(); + FileData* placeholder = new FileData(PLACEHOLDER, "", - this->mRoot->getSystem()->getSystemEnvData(), this->mRoot->getSystem()); + this->mRoot->getSystem()->getSystemEnvData(), system); mGrid.add(placeholder->getName(), "", placeholder); } diff --git a/es-app/src/views/gamelist/GridGameListView.h b/es-app/src/views/gamelist/GridGameListView.h index b48964d70..a07f7f71a 100644 --- a/es-app/src/views/gamelist/GridGameListView.h +++ b/es-app/src/views/gamelist/GridGameListView.h @@ -48,10 +48,10 @@ protected: virtual void update(int deltaTime) override; virtual std::string getQuickSystemSelectRightButton() override; virtual std::string getQuickSystemSelectLeftButton() override; - virtual void populateList(const std::vector& files) override; + virtual void populateList(const std::vector& files, FileData* firstEntry) override; virtual void remove(FileData* game, bool deleteFile) override; virtual void removeMedia(FileData* game) override; - virtual void addPlaceholder(); + virtual void addPlaceholder(FileData* firstEntry = nullptr); ImageGridComponent mGrid; // Points to the first game in the list, i.e. the first entry which is of the type 'GAME'. diff --git a/es-app/src/views/gamelist/ISimpleGameListView.cpp b/es-app/src/views/gamelist/ISimpleGameListView.cpp index 36df31b93..000c19512 100644 --- a/es-app/src/views/gamelist/ISimpleGameListView.cpp +++ b/es-app/src/views/gamelist/ISimpleGameListView.cpp @@ -89,11 +89,11 @@ void ISimpleGameListView::onFileChanged(FileData* file, bool reloadGameList) // but this shouldn't happen very often so we'll just always repopulate. FileData* cursor = getCursor(); if (!cursor->isPlaceHolder()) { - populateList(cursor->getParent()->getChildrenListToDisplay()); + populateList(cursor->getParent()->getChildrenListToDisplay(), cursor->getParent()); setCursor(cursor); } else { - populateList(mRoot->getChildrenListToDisplay()); + populateList(mRoot->getChildrenListToDisplay(), mRoot); setCursor(cursor); } } @@ -114,7 +114,7 @@ bool ISimpleGameListView::input(InputConfig* config, Input input) ViewController::get()->resetMovingCamera(); NavigationSounds::getInstance()->playThemeNavigationSound(SELECTSOUND); mCursorStack.push(cursor); - populateList(cursor->getChildrenListToDisplay()); + populateList(cursor->getChildrenListToDisplay(), cursor); FileData* cursor = getCursor(); setCursor(cursor); } @@ -126,7 +126,8 @@ bool ISimpleGameListView::input(InputConfig* config, Input input) ViewController::get()->resetMovingCamera(); if (mCursorStack.size()) { NavigationSounds::getInstance()->playThemeNavigationSound(BACKSOUND); - populateList(mCursorStack.top()->getParent()->getChildrenListToDisplay()); + populateList(mCursorStack.top()->getParent()->getChildrenListToDisplay(), + mCursorStack.top()->getParent()); setCursor(mCursorStack.top()); if (mCursorStack.size() > 0) mCursorStack.pop(); @@ -345,15 +346,16 @@ bool ISimpleGameListView::input(InputConfig* config, Input input) return IGameListView::input(config, input); } -void ISimpleGameListView::generateGamelistInfo(const std::vector& files) +void ISimpleGameListView::generateGamelistInfo(FileData* cursor, FileData* firstEntry) { // Generate data needed for the gamelistInfo field, which is displayed from the // gamelist interfaces (Detailed/Video/Grid). mIsFiltered = false; mIsFolder = false; + FileData* rootFolder = firstEntry->getSystem()->getRootFolder(); std::pair gameCount; - FileFilterIndex* idx = mRoot->getSystem()->getIndex(); + FileFilterIndex* idx = rootFolder->getSystem()->getIndex(); // For the 'recent' collection we need to recount the games as the collection was // trimmed down to 50 items. If we don't do this, the game count will not be correct @@ -361,11 +363,7 @@ void ISimpleGameListView::generateGamelistInfo(const std::vector& fil if (mRoot->getPath() == "recent") mRoot->countGames(gameCount); - if (files.size() > 0 && files.front()->getParent() != mRoot && - files.front()->getSystem()->isGroupedCustomCollection()) - gameCount = files.front()->getSystem()->getRootFolder()->getGameCount(); - else - gameCount = mRoot->getGameCount(); + gameCount = rootFolder->getGameCount(); mGameCount = gameCount.first + gameCount.second; mFavoritesGameCount = gameCount.second; @@ -374,14 +372,14 @@ void ISimpleGameListView::generateGamelistInfo(const std::vector& fil if (idx->isFiltered()) { mIsFiltered = true; - mFilteredGameCount = mRoot->getFilesRecursive(GAME, true, false).size(); + mFilteredGameCount = rootFolder->getFilesRecursive(GAME, true, false).size(); // Also count the games that are set to not be counted as games, as the filter may // apply to such entries as well and this will be indicated with a separate '+ XX' // in the GamelistInfo field. - mFilteredGameCountAll = mRoot->getFilesRecursive(GAME, true, true).size(); + mFilteredGameCountAll = rootFolder->getFilesRecursive(GAME, true, true).size(); } - if (files.size() > 0 && files.front()->getParent() != mRoot) + if (firstEntry->getParent() && firstEntry->getParent()->getType() == FOLDER) mIsFolder = true; } diff --git a/es-app/src/views/gamelist/ISimpleGameListView.h b/es-app/src/views/gamelist/ISimpleGameListView.h index 74253fee6..548f21844 100644 --- a/es-app/src/views/gamelist/ISimpleGameListView.h +++ b/es-app/src/views/gamelist/ISimpleGameListView.h @@ -38,9 +38,9 @@ public: protected: virtual std::string getQuickSystemSelectRightButton() = 0; virtual std::string getQuickSystemSelectLeftButton() = 0; - virtual void populateList(const std::vector& files) = 0; + virtual void populateList(const std::vector& files, FileData* firstEntry) = 0; - void generateGamelistInfo(const std::vector& files); + void generateGamelistInfo(FileData* cursor, FileData* firstEntry); void generateFirstLetterIndex(const std::vector& files); TextComponent mHeaderText;