Added indication icons when editing custom collection to show what games are already part of the collection.

This commit is contained in:
Leon Styhre 2020-10-28 17:49:29 +01:00
parent 0e59654399
commit b9301f08da
4 changed files with 64 additions and 11 deletions

View file

@ -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'.

View file

@ -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;
}

View file

@ -53,6 +53,14 @@ void BasicGameListView::populateList(const std::vector<FileData*>& 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<FileData*>& 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<FileData*>& 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));
}
}
}

View file

@ -127,13 +127,20 @@ bool ISimpleGameListView::input(InputConfig* config, Input input)
NavigationSounds::getInstance()->playThemeNavigationSound(BACKSOUND);
populateList(mCursorStack.top()->getParent()->getChildrenListToDisplay());
setCursor(mCursorStack.top());
if (mCursorStack.size() > 0)
mCursorStack.pop();
onFileChanged(getCursor(), false);
}
else {
NavigationSounds::getInstance()->playThemeNavigationSound(BACKSOUND);
onFocusLost();
stopListScrolling();
SystemData* systemToView = getCursor()->getSystem();
if (systemToView->isCustomCollection() &&
systemToView->getRootFolder()->getParent())
ViewController::get()->goToSystemView(
systemToView->getRootFolder()->getParent()->getSystem());
else
ViewController::get()->goToSystemView(systemToView);
}
@ -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<std::string>(
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;
}
}