mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-17 22:55:38 +00:00
Fixed multiple issues with filters and the gamelistInfo field.
This commit is contained in:
parent
f17bf43d4f
commit
db94f5daee
|
@ -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 <NO ENTRIES FOUND>
|
||||
// indicator. Without this code an application restart would have been required to
|
||||
// reset the filters.
|
||||
if (mSystem->isCollection() && mSystem->getFullName() == "collections") {
|
||||
std::vector<FileData*> 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<FileData*> customChildren = (*it)->getChildrenListToDisplay();
|
||||
if (customChildren.size() == 0)
|
||||
customIndex->resetFilters();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mFilterIndex->resetFilters();
|
||||
for (std::map<FilterIndexType, std::shared_ptr< OptionListComponent<std::string>>>::
|
||||
const_iterator it = mFilterOptions.cbegin(); it != mFilterOptions.cend(); ++it ) {
|
||||
|
|
|
@ -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<ThemeData>& theme)
|
||||
|
@ -49,7 +49,7 @@ void BasicGameListView::onFileChanged(FileData* file, bool reloadGameList)
|
|||
ISimpleGameListView::onFileChanged(file, reloadGameList);
|
||||
}
|
||||
|
||||
void BasicGameListView::populateList(const std::vector<FileData*>& files)
|
||||
void BasicGameListView::populateList(const std::vector<FileData*>& files, FileData* firstEntry)
|
||||
{
|
||||
mFirstGameEntry = nullptr;
|
||||
bool favoriteStar = true;
|
||||
|
@ -57,9 +57,6 @@ void BasicGameListView::populateList(const std::vector<FileData*>& 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<FileData*>& 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, "<No Entries Found>",
|
||||
this->mRoot->getSystem()->getSystemEnvData(), this->mRoot->getSystem());
|
||||
this->mRoot->getSystem()->getSystemEnvData(), system);
|
||||
mList.add(placeholder->getName(), placeholder, (placeholder->getType() == PLACEHOLDER));
|
||||
}
|
||||
|
||||
|
|
|
@ -44,10 +44,10 @@ public:
|
|||
protected:
|
||||
virtual std::string getQuickSystemSelectRightButton() override;
|
||||
virtual std::string getQuickSystemSelectLeftButton() override;
|
||||
virtual void populateList(const std::vector<FileData*>& files) override;
|
||||
virtual void populateList(const std::vector<FileData*>& 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<FileData*> mList;
|
||||
// Points to the first game in the list, i.e. the first entry which is of the type 'GAME'.
|
||||
|
|
|
@ -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<FileData*>& files)
|
||||
void GridGameListView::populateList(const std::vector<FileData*>& 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<FileData*>& files)
|
|||
}
|
||||
}
|
||||
else {
|
||||
addPlaceholder();
|
||||
addPlaceholder(firstEntry);
|
||||
}
|
||||
|
||||
generateGamelistInfo(getCursor(), firstEntry);
|
||||
generateFirstLetterIndex(files);
|
||||
}
|
||||
|
||||
void GridGameListView::onThemeChanged(const std::shared_ptr<ThemeData>& theme)
|
||||
|
@ -310,7 +310,7 @@ void GridGameListView::onThemeChanged(const std::shared_ptr<ThemeData>& 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, "<No Entries Found>",
|
||||
this->mRoot->getSystem()->getSystemEnvData(), this->mRoot->getSystem());
|
||||
this->mRoot->getSystem()->getSystemEnvData(), system);
|
||||
mGrid.add(placeholder->getName(), "", placeholder);
|
||||
}
|
||||
|
||||
|
|
|
@ -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<FileData*>& files) override;
|
||||
virtual void populateList(const std::vector<FileData*>& 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<FileData*> mGrid;
|
||||
// Points to the first game in the list, i.e. the first entry which is of the type 'GAME'.
|
||||
|
|
|
@ -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<FileData*>& 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<unsigned int, unsigned int> 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<FileData*>& 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<FileData*>& 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -38,9 +38,9 @@ public:
|
|||
protected:
|
||||
virtual std::string getQuickSystemSelectRightButton() = 0;
|
||||
virtual std::string getQuickSystemSelectLeftButton() = 0;
|
||||
virtual void populateList(const std::vector<FileData*>& files) = 0;
|
||||
virtual void populateList(const std::vector<FileData*>& files, FileData* firstEntry) = 0;
|
||||
|
||||
void generateGamelistInfo(const std::vector<FileData*>& files);
|
||||
void generateGamelistInfo(FileData* cursor, FileData* firstEntry);
|
||||
void generateFirstLetterIndex(const std::vector<FileData*>& files);
|
||||
|
||||
TextComponent mHeaderText;
|
||||
|
|
Loading…
Reference in a new issue