From b9301f08dafce69a55a5629e0584b299d8912c96 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Wed, 28 Oct 2020 17:49:29 +0100 Subject: [PATCH] Added indication icons when editing custom collection to show what games are already part of the collection. --- USERGUIDE.md | 4 +++ es-app/src/guis/GuiGamelistOptions.cpp | 17 ++++++++++ .../src/views/gamelist/BasicGameListView.cpp | 21 ++++++++++-- .../views/gamelist/ISimpleGameListView.cpp | 33 ++++++++++++++----- 4 files changed, 64 insertions(+), 11 deletions(-) diff --git a/USERGUIDE.md b/USERGUIDE.md index e63f0c161..2558f1db0 100644 --- a/USERGUIDE.md +++ b/USERGUIDE.md @@ -1064,6 +1064,10 @@ The collection will now be added and the collection edit mode will be automatica Removing games works in the same way, just press 'Y' to remove it if it's already present in your collection. You can do this either from the game system where the game was added, or from the collection itself. +Note that only files can be part of collections, not folders. + +During the time that the collection is being edited, any game that is already part of the collection will be marked with a leading tick mark in their game name to make it easy to see which games have already been added. + When you are done adding games, you can either open the main menu and go to 'Game collection settings' and select the 'Finish editing '1980s' collection' or you can open the game options menu and select the same option there. The latter works from within any game system, you don't need to navigate back to the collection that you're editing. You can later add additional games to the collection by navigating to it, bringing up the game options menu and choosing 'Add/remove games to this game collection'. diff --git a/es-app/src/guis/GuiGamelistOptions.cpp b/es-app/src/guis/GuiGamelistOptions.cpp index 94081edba..79dc27857 100644 --- a/es-app/src/guis/GuiGamelistOptions.cpp +++ b/es-app/src/guis/GuiGamelistOptions.cpp @@ -281,12 +281,29 @@ void GuiGamelistOptions::startEditMode() editingSystem = file->getSystem()->getName(); } CollectionSystemManager::get()->setEditMode(editingSystem); + + // Display the indication icons which show what games are part of the custom collection + // currently being edited. This is done cheaply using onFileChanged() which will trigger + // populateList(). + for (auto it = SystemData::sSystemVector.begin(); + it != SystemData::sSystemVector.end(); it++) { + ViewController::get()->getGameListView((*it))->onFileChanged( + ViewController::get()->getGameListView((*it))->getCursor(), false); + } + delete this; } void GuiGamelistOptions::exitEditMode() { CollectionSystemManager::get()->exitEditMode(); + + for (auto it = SystemData::sSystemVector.begin(); + it != SystemData::sSystemVector.end(); it++) { + ViewController::get()->getGameListView((*it))->onFileChanged( + ViewController::get()->getGameListView((*it))->getCursor(), false); + } + delete this; } diff --git a/es-app/src/views/gamelist/BasicGameListView.cpp b/es-app/src/views/gamelist/BasicGameListView.cpp index 82e08e104..f7ef26511 100644 --- a/es-app/src/views/gamelist/BasicGameListView.cpp +++ b/es-app/src/views/gamelist/BasicGameListView.cpp @@ -53,6 +53,14 @@ void BasicGameListView::populateList(const std::vector& files) { firstGameEntry = nullptr; bool favoriteStar = true; + bool isEditing = false; + std::string editingCollection; + std::string inCollectionPrefix; + + if (CollectionSystemManager::get()->isEditing()) { + editingCollection = CollectionSystemManager::get()->getEditingCollection(); + isEditing = true; + } // Read the settings that control whether a unicode star character should be added // as a prefix to the game name. @@ -69,10 +77,17 @@ void BasicGameListView::populateList(const std::vector& files) for (auto it = files.cbegin(); it != files.cend(); it++) { if (!firstGameEntry && (*it)->getType() == GAME) firstGameEntry = (*it); - + // Add a leading tick mark icon to the game name if it's part of the custom collection + // currently being edited. + if (isEditing && (*it)->getType() == GAME) { + if (CollectionSystemManager::get()->inCustomCollection(editingCollection, (*it))) + inCollectionPrefix = "\uF14A "; + else + inCollectionPrefix = ""; + } if ((*it)->getFavorite() && favoriteStar && mRoot->getSystem()->getName() != "favorites") { - mList.add(FAVORITE_CHAR + " " + (*it)->getName(), + mList.add(inCollectionPrefix + FAVORITE_CHAR + " " + (*it)->getName(), *it, ((*it)->getType() == FOLDER)); } else if ((*it)->getType() == FOLDER && @@ -80,7 +95,7 @@ void BasicGameListView::populateList(const std::vector& files) mList.add(FOLDER_CHAR + " " + (*it)->getName(), *it, true); } else { - mList.add((*it)->getName(), *it, ((*it)->getType() == FOLDER)); + mList.add(inCollectionPrefix + (*it)->getName(), *it, ((*it)->getType() == FOLDER)); } } } diff --git a/es-app/src/views/gamelist/ISimpleGameListView.cpp b/es-app/src/views/gamelist/ISimpleGameListView.cpp index dbe8c521c..e00b47b4b 100644 --- a/es-app/src/views/gamelist/ISimpleGameListView.cpp +++ b/es-app/src/views/gamelist/ISimpleGameListView.cpp @@ -127,14 +127,21 @@ bool ISimpleGameListView::input(InputConfig* config, Input input) NavigationSounds::getInstance()->playThemeNavigationSound(BACKSOUND); populateList(mCursorStack.top()->getParent()->getChildrenListToDisplay()); setCursor(mCursorStack.top()); - mCursorStack.pop(); + if (mCursorStack.size() > 0) + mCursorStack.pop(); + onFileChanged(getCursor(), false); } else { NavigationSounds::getInstance()->playThemeNavigationSound(BACKSOUND); onFocusLost(); stopListScrolling(); SystemData* systemToView = getCursor()->getSystem(); - ViewController::get()->goToSystemView(systemToView); + if (systemToView->isCustomCollection() && + systemToView->getRootFolder()->getParent()) + ViewController::get()->goToSystemView( + systemToView->getRootFolder()->getParent()->getSystem()); + else + ViewController::get()->goToSystemView(systemToView); } return true; @@ -168,7 +175,7 @@ bool ISimpleGameListView::input(InputConfig* config, Input input) } else if (config->isMappedTo("y", input) && !UIModeController::getInstance()->isUIModeKid()) { - if (mRoot->getSystem()->isGameSystem() && + if (mRoot->getSystem()->isGameSystem() && getCursor()->getType() != PLACEHOLDER && getCursor()->getParent()->getPath() != "collections") { if (getCursor()->getType() == GAME || getCursor()->getType() == FOLDER) NavigationSounds::getInstance()->playThemeNavigationSound(FAVORITESOUND); @@ -178,6 +185,7 @@ bool ISimpleGameListView::input(InputConfig* config, Input input) FileData* entryToUpdate = getCursor(); bool favoritesSorting; bool removedLastFavorite = false; + bool isEditing = CollectionSystemManager::get()->isEditing(); bool foldersOnTop = Settings::getInstance()->getBool("FoldersOnTop"); // If the current list only contains folders, then treat it as if the folders // are not sorted on top, this way the logic should work exactly as for mixed @@ -191,8 +199,7 @@ bool ISimpleGameListView::input(InputConfig* config, Input input) favoritesSorting = Settings::getInstance()->getBool("FavoritesFirst"); if (favoritesSorting && static_cast( - mRoot->getSystem()->getName()) != "recent" && - !CollectionSystemManager::get()->isEditing()) { + mRoot->getSystem()->getName()) != "recent" && !isEditing) { FileData* entryToSelect; // Add favorite flag. if (!getCursor()->getFavorite()) { @@ -256,7 +263,7 @@ bool ISimpleGameListView::input(InputConfig* config, Input input) // CollectionSystemManager. if (entryToUpdate->getType() == FOLDER) { GuiInfoPopup* s; - if (CollectionSystemManager::get()->isEditing()) { + if (isEditing) { s = new GuiInfoPopup(mWindow, "CAN'T ADD FOLDERS TO CUSTOM COLLECTIONS", 4000); } @@ -295,8 +302,7 @@ bool ISimpleGameListView::input(InputConfig* config, Input input) } return true; } - else if (CollectionSystemManager::get()->isEditing() && - entryToUpdate->metadata.get("nogamecount") == "true") { + else if (isEditing && entryToUpdate->metadata.get("nogamecount") == "true") { GuiInfoPopup* s = new GuiInfoPopup(mWindow, "CAN'T ADD ENTRIES THAT ARE NOT COUNTED " "AS GAMES TO CUSTOM COLLECTIONS", 4000); @@ -312,6 +318,17 @@ bool ISimpleGameListView::input(InputConfig* config, Input input) else if (removedLastFavorite && !entryToUpdate->getSystem()->isCustomCollection()) setCursor(getFirstEntry()); + // Display the indication icons which show what games are part of the + // custom collection currently being edited. This is done cheaply using + // onFileChanged() which will trigger populateList(). + if (isEditing) { + for (auto it = SystemData::sSystemVector.begin(); + it != SystemData::sSystemVector.end(); it++) { + ViewController::get()->getGameListView((*it))->onFileChanged( + ViewController::get()->getGameListView((*it))-> + getCursor(), false); + } + } return true; } }