2020-09-15 20:57:54 +00:00
|
|
|
// SPDX-License-Identifier: MIT
|
2020-05-24 08:29:29 +00:00
|
|
|
//
|
2020-09-15 20:57:54 +00:00
|
|
|
// EmulationStation Desktop Edition
|
2020-06-21 12:25:28 +00:00
|
|
|
// GuiGamelistOptions.cpp
|
2020-05-24 08:29:29 +00:00
|
|
|
//
|
2020-06-21 12:25:28 +00:00
|
|
|
// Gamelist options menu for the 'Jump to...' quick selector,
|
|
|
|
// game sorting, game filters, and metadata edit.
|
2020-05-24 08:29:29 +00:00
|
|
|
//
|
2020-06-21 12:25:28 +00:00
|
|
|
// The filter interface is covered by GuiGamelistFilter and the
|
|
|
|
// metadata edit interface is covered by GuiMetaDataEd.
|
2020-05-26 16:34:33 +00:00
|
|
|
//
|
2020-05-24 08:29:29 +00:00
|
|
|
|
2014-06-25 16:29:58 +00:00
|
|
|
#include "GuiGamelistOptions.h"
|
2017-11-01 22:21:10 +00:00
|
|
|
|
|
|
|
#include "guis/GuiGamelistFilter.h"
|
|
|
|
#include "scrapers/Scraper.h"
|
2014-06-25 16:29:58 +00:00
|
|
|
#include "views/gamelist/IGameListView.h"
|
2017-11-18 22:23:56 +00:00
|
|
|
#include "views/UIModeController.h"
|
2014-06-25 16:29:58 +00:00
|
|
|
#include "views/ViewController.h"
|
2017-06-12 16:38:59 +00:00
|
|
|
#include "CollectionSystemManager.h"
|
2017-11-01 22:21:10 +00:00
|
|
|
#include "FileFilterIndex.h"
|
|
|
|
#include "FileSorts.h"
|
|
|
|
#include "GuiMetaDataEd.h"
|
2020-05-15 16:21:24 +00:00
|
|
|
#include "Sound.h"
|
2020-09-15 20:57:54 +00:00
|
|
|
#include "SystemData.h"
|
2014-06-25 16:29:58 +00:00
|
|
|
|
2020-05-24 08:29:29 +00:00
|
|
|
GuiGamelistOptions::GuiGamelistOptions(
|
2020-06-21 12:25:28 +00:00
|
|
|
Window* window,
|
|
|
|
SystemData* system)
|
|
|
|
: GuiComponent(window),
|
|
|
|
mSystem(system),
|
|
|
|
mMenu(window, "OPTIONS"),
|
|
|
|
fromPlaceholder(false),
|
|
|
|
mFiltersChanged(false),
|
2020-10-21 19:56:31 +00:00
|
|
|
mCancelled(false),
|
|
|
|
isCustomCollection(false),
|
|
|
|
isCustomCollectionGroup(false)
|
2014-06-25 16:29:58 +00:00
|
|
|
{
|
2020-06-21 12:25:28 +00:00
|
|
|
addChild(&mMenu);
|
|
|
|
|
|
|
|
// Check that it's not a placeholder folder - if it is, only show "Filter Options".
|
|
|
|
FileData* file = getGamelist()->getCursor();
|
2020-09-20 10:17:38 +00:00
|
|
|
FAVORITE_CHAR = file->FAVORITE_CHAR;
|
|
|
|
FOLDER_CHAR = file->FOLDER_CHAR;
|
2020-06-21 12:25:28 +00:00
|
|
|
fromPlaceholder = file->isPlaceHolder();
|
|
|
|
ComponentListRow row;
|
|
|
|
|
2020-10-21 19:56:31 +00:00
|
|
|
// There is some special logic required for custom collections.
|
|
|
|
if (file->getSystem()->isCustomCollection() &&
|
|
|
|
file->getPath() != file->getSystem()->getName())
|
|
|
|
isCustomCollection = true;
|
|
|
|
else if (file->getSystem()->isCustomCollection() &&
|
|
|
|
file->getPath() == file->getSystem()->getName())
|
|
|
|
isCustomCollectionGroup = true;
|
|
|
|
|
2020-07-28 17:44:17 +00:00
|
|
|
// Read the setting for whether folders are sorted on top of the gamelists.
|
|
|
|
// Also check if the gamelist only contains folders, as generated by the FileData sorting.
|
|
|
|
mFoldersOnTop = Settings::getInstance()->getBool("FoldersOnTop");
|
2020-08-06 20:11:55 +00:00
|
|
|
if (file->getType() != PLACEHOLDER)
|
|
|
|
mOnlyHasFolders = file->getParent()->getOnlyFoldersFlag();
|
2020-07-28 17:44:17 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
// Read the applicable favorite sorting setting depending on whether the
|
|
|
|
// system is a custom collection or not.
|
2020-10-25 17:55:01 +00:00
|
|
|
if (isCustomCollection)
|
2020-06-21 12:25:28 +00:00
|
|
|
mFavoritesSorting = Settings::getInstance()->getBool("FavFirstCustom");
|
|
|
|
else
|
|
|
|
mFavoritesSorting = Settings::getInstance()->getBool("FavoritesFirst");
|
|
|
|
|
|
|
|
if (!fromPlaceholder) {
|
|
|
|
// Jump to letter quick selector.
|
|
|
|
row.elements.clear();
|
|
|
|
|
|
|
|
// The letter index is generated in FileData during gamelist sorting.
|
|
|
|
mFirstLetterIndex = file->getParent()->getFirstLetterIndex();
|
|
|
|
|
2020-07-28 17:44:17 +00:00
|
|
|
// Don't include the folder name starting characters if folders are sorted on top
|
|
|
|
// unless the list only contains folders.
|
|
|
|
if (!mOnlyHasFolders && mFoldersOnTop && file->getType() == FOLDER) {
|
2020-09-20 10:17:38 +00:00
|
|
|
mCurrentFirstCharacter = FOLDER_CHAR;
|
2020-07-28 17:44:17 +00:00
|
|
|
}
|
|
|
|
else {
|
2020-09-20 10:36:51 +00:00
|
|
|
// Check if the currently selected game is a favorite.
|
|
|
|
bool isFavorite = false;
|
|
|
|
if (mFirstLetterIndex.size() == 1 && mFirstLetterIndex.front() == FAVORITE_CHAR)
|
|
|
|
isFavorite = true;
|
|
|
|
else if (mFirstLetterIndex.size() > 1 && (mFirstLetterIndex.front() == FAVORITE_CHAR ||
|
|
|
|
mFirstLetterIndex[1] == FAVORITE_CHAR))
|
|
|
|
isFavorite = true;
|
|
|
|
|
|
|
|
if (mFavoritesSorting && file->getFavorite() && isFavorite)
|
2020-07-28 17:44:17 +00:00
|
|
|
mCurrentFirstCharacter = FAVORITE_CHAR;
|
2020-09-20 10:17:38 +00:00
|
|
|
else
|
2020-07-28 17:44:17 +00:00
|
|
|
mCurrentFirstCharacter = toupper(file->getSortName().front());
|
|
|
|
}
|
2020-06-21 12:25:28 +00:00
|
|
|
|
|
|
|
mJumpToLetterList = std::make_shared<LetterList>(mWindow, getHelpStyle(),
|
|
|
|
"JUMP TO...", false);
|
|
|
|
|
|
|
|
// Populate the quick selector.
|
|
|
|
for (unsigned int i = 0; i < mFirstLetterIndex.size(); i++) {
|
|
|
|
mJumpToLetterList->add(mFirstLetterIndex[i], mFirstLetterIndex[i], 0);
|
|
|
|
if (mFirstLetterIndex[i] == mCurrentFirstCharacter)
|
|
|
|
mJumpToLetterList->selectEntry(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (system->getName() != "recent")
|
|
|
|
mMenu.addWithLabel("JUMP TO..", mJumpToLetterList);
|
|
|
|
|
2020-10-21 19:56:31 +00:00
|
|
|
// Add the sorting entry, unless this is the grouped custom collections list.
|
|
|
|
if (!isCustomCollectionGroup) {
|
|
|
|
// Sort list by selected sort type (persistent throughout the program session).
|
|
|
|
mListSort = std::make_shared<SortList>(mWindow, getHelpStyle(), "SORT GAMES BY", false);
|
|
|
|
FileData* root;
|
|
|
|
if (isCustomCollection)
|
|
|
|
root = getGamelist()->getCursor()->getSystem()->getRootFolder();
|
2020-06-21 12:25:28 +00:00
|
|
|
else
|
2020-10-21 19:56:31 +00:00
|
|
|
root = mSystem->getRootFolder();
|
|
|
|
|
|
|
|
std::string sortType = root->getSortTypeString();
|
|
|
|
|
|
|
|
for (unsigned int i = 0; i <FileSorts::SortTypes.size(); i++) {
|
|
|
|
const FileData::SortType& sort = FileSorts::SortTypes.at(i);
|
|
|
|
if (sort.description == sortType)
|
|
|
|
mListSort->add(sort.description, &sort, 1);
|
|
|
|
else
|
|
|
|
mListSort->add(sort.description, &sort, 0);
|
|
|
|
}
|
|
|
|
// Don't show the sort type option if the gamelist type is recent/last played.
|
|
|
|
if (system->getName() != "recent")
|
|
|
|
mMenu.addWithLabel("SORT GAMES BY", mListSort);
|
2020-06-21 12:25:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-21 19:56:31 +00:00
|
|
|
// Add the filters entry, unless this is the grouped custom collections list.
|
|
|
|
if (!isCustomCollectionGroup) {
|
|
|
|
if (system->getName() != "recent" &&
|
|
|
|
!Settings::getInstance()->getBool("ForceDisableFilters")) {
|
|
|
|
row.elements.clear();
|
|
|
|
row.addElement(std::make_shared<TextComponent>
|
|
|
|
(mWindow, "FILTER GAMELIST", Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true);
|
|
|
|
row.addElement(makeArrow(mWindow), false);
|
|
|
|
row.makeAcceptInputHandler(std::bind(&GuiGamelistOptions::openGamelistFilter, this));
|
|
|
|
mMenu.addRow(row);
|
|
|
|
}
|
2020-06-21 12:25:28 +00:00
|
|
|
}
|
|
|
|
|
2020-10-22 19:23:16 +00:00
|
|
|
std::map<std::string, CollectionSystemData, stringComparator> customCollections =
|
2020-06-21 12:25:28 +00:00
|
|
|
CollectionSystemManager::get()->getCustomCollectionSystems();
|
|
|
|
|
|
|
|
if (UIModeController::getInstance()->isUIModeFull() &&
|
|
|
|
((customCollections.find(system->getName()) != customCollections.cend() &&
|
|
|
|
CollectionSystemManager::get()->getEditingCollection() != system->getName()) ||
|
|
|
|
CollectionSystemManager::get()->getCustomCollectionsBundle()->getName() ==
|
|
|
|
system->getName())) {
|
|
|
|
row.elements.clear();
|
|
|
|
row.addElement(std::make_shared<TextComponent>(
|
|
|
|
mWindow, "ADD/REMOVE GAMES TO THIS GAME COLLECTION", Font::get(FONT_SIZE_MEDIUM),
|
|
|
|
0x777777FF), true);
|
|
|
|
row.makeAcceptInputHandler(std::bind(&GuiGamelistOptions::startEditMode, this));
|
|
|
|
mMenu.addRow(row);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (UIModeController::getInstance()->isUIModeFull() &&
|
|
|
|
CollectionSystemManager::get()->isEditing()) {
|
|
|
|
row.elements.clear();
|
|
|
|
row.addElement(std::make_shared<TextComponent>(
|
|
|
|
mWindow, "FINISH EDITING '" + Utils::String::toUpper(
|
|
|
|
CollectionSystemManager::get()->getEditingCollection()) +
|
|
|
|
"' COLLECTION",Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true);
|
|
|
|
row.makeAcceptInputHandler(std::bind(&GuiGamelistOptions::exitEditMode, this));
|
|
|
|
mMenu.addRow(row);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (file->getType() == FOLDER) {
|
|
|
|
if (UIModeController::getInstance()->isUIModeFull() && !fromPlaceholder &&
|
|
|
|
!(mSystem->isCollection() && file->getType() == FOLDER)) {
|
|
|
|
row.elements.clear();
|
|
|
|
row.addElement(std::make_shared<TextComponent>(mWindow,
|
|
|
|
"EDIT THIS FOLDER'S METADATA", Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true);
|
|
|
|
row.addElement(makeArrow(mWindow), false);
|
|
|
|
row.makeAcceptInputHandler(std::bind(&GuiGamelistOptions::openMetaDataEd, this));
|
|
|
|
mMenu.addRow(row);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (UIModeController::getInstance()->isUIModeFull() && !fromPlaceholder &&
|
|
|
|
!(mSystem->isCollection() && file->getType() == FOLDER)) {
|
|
|
|
row.elements.clear();
|
|
|
|
row.addElement(std::make_shared<TextComponent>(mWindow,
|
|
|
|
"EDIT THIS GAME'S METADATA", Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true);
|
|
|
|
row.addElement(makeArrow(mWindow), false);
|
|
|
|
row.makeAcceptInputHandler(std::bind(&GuiGamelistOptions::openMetaDataEd, this));
|
|
|
|
mMenu.addRow(row);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Buttons. Logic to apply or cancel settings are handled by the destructor.
|
|
|
|
mMenu.addButton("APPLY", "apply", [&] { delete this; });
|
|
|
|
mMenu.addButton("CANCEL", "cancel", [&] { mCancelled = true; delete this; });
|
|
|
|
|
|
|
|
// Center the menu.
|
|
|
|
setSize((float)Renderer::getScreenWidth(), (float)Renderer::getScreenHeight());
|
|
|
|
mMenu.setPosition((mSize.x() - mMenu.getSize().x()) / 2, (mSize.y() -
|
|
|
|
mMenu.getSize().y()) / 2);
|
2014-06-25 16:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GuiGamelistOptions::~GuiGamelistOptions()
|
|
|
|
{
|
2020-09-15 20:57:54 +00:00
|
|
|
// This is required for the situation where scrolling started just before the menu
|
|
|
|
// was openened. Without this, the scrolling would run until manually stopped after
|
|
|
|
// the menu has been closed.
|
|
|
|
ViewController::get()->stopScrolling();
|
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
if (mCancelled)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!fromPlaceholder) {
|
2020-10-21 19:56:31 +00:00
|
|
|
FileData* root;
|
|
|
|
if (isCustomCollection)
|
|
|
|
root = getGamelist()->getCursor()->getSystem()->getRootFolder();
|
|
|
|
else
|
|
|
|
root = mSystem->getRootFolder();
|
2020-06-21 12:25:28 +00:00
|
|
|
|
|
|
|
// If a new sorting type was selected, then sort and update mSortTypeString for the system.
|
2020-10-21 19:56:31 +00:00
|
|
|
if (!isCustomCollectionGroup &&
|
|
|
|
(*mListSort->getSelected()).description != root->getSortTypeString()) {
|
2020-06-21 12:25:28 +00:00
|
|
|
// This will also recursively sort children.
|
|
|
|
root->sort(*mListSort->getSelected(), mFavoritesSorting);
|
|
|
|
root->setSortTypeString((*mListSort->getSelected()).description);
|
|
|
|
|
|
|
|
// Notify that the root folder was sorted (refresh).
|
|
|
|
getGamelist()->onFileChanged(root, FILE_SORTED);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Has the user changed the letter using the quick selector?
|
2020-09-20 10:17:38 +00:00
|
|
|
if (mCurrentFirstCharacter != mJumpToLetterList->getSelected()) {
|
|
|
|
if (mJumpToLetterList->getSelected() == FAVORITE_CHAR ||
|
|
|
|
mJumpToLetterList->getSelected() == FOLDER_CHAR)
|
2020-06-21 12:25:28 +00:00
|
|
|
jumpToFirstRow();
|
|
|
|
else
|
|
|
|
jumpToLetter();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mFiltersChanged) {
|
|
|
|
// Only reload full view if we came from a placeholder as we need to
|
|
|
|
// re-display the remaining elements for whatever new game is selected.
|
|
|
|
ViewController::get()->reloadGameListView(mSystem);
|
|
|
|
}
|
|
|
|
|
|
|
|
NavigationSounds::getInstance()->playThemeNavigationSound(SCROLLSOUND);
|
2014-06-25 16:29:58 +00:00
|
|
|
}
|
|
|
|
|
2017-03-18 17:54:39 +00:00
|
|
|
void GuiGamelistOptions::openGamelistFilter()
|
|
|
|
{
|
2020-10-25 17:55:01 +00:00
|
|
|
GuiGamelistFilter* ggf;
|
2020-06-21 12:25:28 +00:00
|
|
|
mFiltersChanged = true;
|
2020-10-25 17:55:01 +00:00
|
|
|
|
|
|
|
if (isCustomCollection)
|
|
|
|
ggf = new GuiGamelistFilter(mWindow, getGamelist()->getCursor()->getSystem());
|
|
|
|
else
|
|
|
|
ggf = new GuiGamelistFilter(mWindow, mSystem);
|
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
mWindow->pushGui(ggf);
|
2017-05-18 10:16:57 +00:00
|
|
|
}
|
2017-03-18 17:54:39 +00:00
|
|
|
|
2017-07-18 09:45:50 +00:00
|
|
|
void GuiGamelistOptions::startEditMode()
|
|
|
|
{
|
2020-06-21 12:25:28 +00:00
|
|
|
std::string editingSystem = mSystem->getName();
|
|
|
|
// Need to check if we're editing the collections bundle,
|
|
|
|
// as we will want to edit the selected collection within.
|
|
|
|
if (editingSystem == CollectionSystemManager::get()->getCustomCollectionsBundle()->getName()) {
|
|
|
|
FileData* file = getGamelist()->getCursor();
|
|
|
|
// Do we have the cursor on a specific collection?.
|
|
|
|
if (file->getType() == FOLDER)
|
|
|
|
editingSystem = file->getName();
|
|
|
|
else
|
|
|
|
// We are inside a specific collection. We want to edit that one.
|
|
|
|
editingSystem = file->getSystem()->getName();
|
|
|
|
}
|
|
|
|
CollectionSystemManager::get()->setEditMode(editingSystem);
|
|
|
|
delete this;
|
2017-07-18 09:45:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GuiGamelistOptions::exitEditMode()
|
|
|
|
{
|
2020-06-21 12:25:28 +00:00
|
|
|
CollectionSystemManager::get()->exitEditMode();
|
|
|
|
delete this;
|
2017-07-18 09:45:50 +00:00
|
|
|
}
|
|
|
|
|
2014-06-25 16:29:58 +00:00
|
|
|
void GuiGamelistOptions::openMetaDataEd()
|
|
|
|
{
|
2020-06-21 12:25:28 +00:00
|
|
|
// Open metadata editor.
|
|
|
|
// Get the FileData that holds the original metadata.
|
|
|
|
FileData* file = getGamelist()->getCursor()->getSourceFileData();
|
|
|
|
ScraperSearchParams p;
|
|
|
|
p.game = file;
|
|
|
|
p.system = file->getSystem();
|
|
|
|
|
2020-09-27 08:41:00 +00:00
|
|
|
std::function<void()> clearGameBtnFunc;
|
2020-07-30 18:05:57 +00:00
|
|
|
std::function<void()> deleteGameBtnFunc;
|
|
|
|
|
2020-09-27 08:41:00 +00:00
|
|
|
clearGameBtnFunc = [this, file] {
|
|
|
|
if (file->getType() == FOLDER) {
|
2020-10-20 19:01:24 +00:00
|
|
|
LOG(LogInfo) << "Deleting the media files and gamelist.xml entry for the folder \"" <<
|
|
|
|
file->getFullPath() << "\"";
|
2020-09-27 08:41:00 +00:00
|
|
|
}
|
|
|
|
else {
|
2020-10-20 19:01:24 +00:00
|
|
|
LOG(LogInfo) << "Deleting the media files and gamelist.xml entry for the file \"" <<
|
|
|
|
file->getFullPath() << "\"";
|
2020-09-27 08:41:00 +00:00
|
|
|
}
|
|
|
|
ViewController::get()->getGameListView(file->getSystem()).get()->removeMedia(file);
|
|
|
|
|
|
|
|
// Manually reset all the metadata values, set the name to the actual file/folder name.
|
|
|
|
const std::vector<MetaDataDecl>& mdd = file->metadata.getMDD();
|
|
|
|
for (auto it = mdd.cbegin(); it != mdd.cend(); it++) {
|
|
|
|
if (it->key == "name") {
|
|
|
|
file->metadata.set(it->key, file->getDisplayName());
|
|
|
|
continue;
|
2020-07-30 18:05:57 +00:00
|
|
|
}
|
2020-09-27 08:41:00 +00:00
|
|
|
file->metadata.set(it->key, it->defaultValue);
|
|
|
|
}
|
2020-07-30 18:05:57 +00:00
|
|
|
|
2020-09-27 16:37:43 +00:00
|
|
|
file->getSystem()->sortSystem();
|
2020-10-11 08:07:38 +00:00
|
|
|
mWindow->invalidateCachedBackground();
|
2020-09-27 16:37:43 +00:00
|
|
|
|
2020-09-27 08:41:00 +00:00
|
|
|
// Remove the folder entry from the gamelist.xml file.
|
|
|
|
file->setDeletionFlag();
|
|
|
|
file->getParent()->getSystem()->writeMetaData();
|
|
|
|
};
|
|
|
|
|
|
|
|
deleteGameBtnFunc = [this, file] {
|
2020-10-20 19:01:24 +00:00
|
|
|
LOG(LogInfo) << "Deleting the game file \"" << file->getFullPath() <<
|
|
|
|
"\", all its media files and its gamelist.xml entry.";
|
2020-09-27 08:41:00 +00:00
|
|
|
CollectionSystemManager::get()->deleteCollectionFiles(file);
|
|
|
|
ViewController::get()->getGameListView(
|
|
|
|
file->getSystem()).get()->removeMedia(file);
|
|
|
|
ViewController::get()->getGameListView(
|
|
|
|
file->getSystem()).get()->remove(file, true);
|
2020-10-11 08:07:38 +00:00
|
|
|
mWindow->invalidateCachedBackground();
|
2020-09-27 08:41:00 +00:00
|
|
|
};
|
2020-06-21 12:25:28 +00:00
|
|
|
|
|
|
|
if (file->getType() == FOLDER) {
|
|
|
|
mWindow->pushGui(new GuiMetaDataEd(mWindow, &file->metadata,
|
|
|
|
file->metadata.getMDD(FOLDER_METADATA), p,
|
|
|
|
Utils::FileSystem::getFileName(file->getPath()), std::bind(
|
|
|
|
&IGameListView::onFileChanged, ViewController::get()->getGameListView(
|
2020-07-30 18:05:57 +00:00
|
|
|
file->getSystem()).get(), file, FILE_METADATA_CHANGED),
|
2020-09-27 08:41:00 +00:00
|
|
|
clearGameBtnFunc, deleteGameBtnFunc));
|
2020-06-21 12:25:28 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
mWindow->pushGui(new GuiMetaDataEd(mWindow, &file->metadata,
|
|
|
|
file->metadata.getMDD(GAME_METADATA), p,
|
|
|
|
Utils::FileSystem::getFileName(file->getPath()), std::bind(
|
|
|
|
&IGameListView::onFileChanged, ViewController::get()->getGameListView(
|
2020-07-30 18:05:57 +00:00
|
|
|
file->getSystem()).get(), file, FILE_METADATA_CHANGED),
|
2020-09-27 08:41:00 +00:00
|
|
|
clearGameBtnFunc, deleteGameBtnFunc));
|
2020-06-21 12:25:28 +00:00
|
|
|
}
|
2014-06-25 16:29:58 +00:00
|
|
|
}
|
|
|
|
|
2014-07-27 22:49:43 +00:00
|
|
|
void GuiGamelistOptions::jumpToLetter()
|
|
|
|
{
|
2020-06-21 12:25:28 +00:00
|
|
|
char letter = mJumpToLetterList->getSelected().front();
|
|
|
|
|
|
|
|
// Get the gamelist.
|
|
|
|
const std::vector<FileData*>& files = getGamelist()->getCursor()->
|
|
|
|
getParent()->getChildrenListToDisplay();
|
|
|
|
|
|
|
|
for (unsigned int i = 0; i < files.size(); i++) {
|
2020-09-27 11:39:37 +00:00
|
|
|
if (mFavoritesSorting && (mFirstLetterIndex.front() == FAVORITE_CHAR ||
|
|
|
|
mFirstLetterIndex.front() == FOLDER_CHAR)) {
|
2020-06-21 12:25:28 +00:00
|
|
|
if ((char)toupper(files.at(i)->getSortName().front()) ==
|
|
|
|
letter && !files.at(i)->getFavorite()) {
|
2020-09-20 18:25:32 +00:00
|
|
|
if (!mOnlyHasFolders && mFoldersOnTop && files.at(i)->getType() == FOLDER) {
|
2020-07-28 17:44:17 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
getGamelist()->setCursor(files.at(i));
|
|
|
|
break;
|
|
|
|
}
|
2020-06-21 12:25:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if ((char)toupper(files.at(i)->getSortName().front()) == letter) {
|
2020-07-28 17:44:17 +00:00
|
|
|
if (!mOnlyHasFolders && mFoldersOnTop && files.at(i)->getType() == FOLDER) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
getGamelist()->setCursor(files.at(i));
|
|
|
|
break;
|
|
|
|
}
|
2020-06-21 12:25:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-07-27 22:49:43 +00:00
|
|
|
}
|
|
|
|
|
2020-05-24 08:29:29 +00:00
|
|
|
void GuiGamelistOptions::jumpToFirstRow()
|
2020-05-15 16:16:04 +00:00
|
|
|
{
|
2020-09-20 10:17:38 +00:00
|
|
|
if (mFoldersOnTop && mJumpToLetterList->getSelected() == FAVORITE_CHAR) {
|
2020-07-28 17:44:17 +00:00
|
|
|
// Get the gamelist.
|
|
|
|
const std::vector<FileData*>& files = getGamelist()->getCursor()->
|
|
|
|
getParent()->getChildrenListToDisplay();
|
2020-09-20 18:25:32 +00:00
|
|
|
// Select the first game that is not a folder, unless it's a folder-only list in
|
|
|
|
// which case the first line overall is selected.
|
2020-07-28 17:44:17 +00:00
|
|
|
for (auto it = files.cbegin(); it != files.cend(); it++) {
|
2020-09-20 18:25:32 +00:00
|
|
|
if (!mOnlyHasFolders && mFoldersOnTop && (*it)->getType() == FOLDER) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else {
|
2020-07-28 17:44:17 +00:00
|
|
|
getGamelist()->setCursor(*it);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Get first row of the gamelist.
|
|
|
|
getGamelist()->setCursor(getGamelist()->getFirstEntry());
|
|
|
|
}
|
2020-05-15 16:16:04 +00:00
|
|
|
}
|
|
|
|
|
2014-06-25 16:29:58 +00:00
|
|
|
bool GuiGamelistOptions::input(InputConfig* config, Input input)
|
|
|
|
{
|
2020-06-21 12:25:28 +00:00
|
|
|
if (input.value != 0 && config->isMappedTo("select", input))
|
|
|
|
mCancelled = true;
|
2020-06-09 18:03:31 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
if (input.value != 0 && (config->isMappedTo("b", input) ||
|
|
|
|
config->isMappedTo("select", input))) {
|
|
|
|
delete this;
|
|
|
|
return true;
|
|
|
|
}
|
2014-06-25 16:29:58 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
return mMenu.input(config, input);
|
2014-06-25 16:29:58 +00:00
|
|
|
}
|
|
|
|
|
2017-05-28 18:13:00 +00:00
|
|
|
HelpStyle GuiGamelistOptions::getHelpStyle()
|
|
|
|
{
|
2020-06-21 12:25:28 +00:00
|
|
|
HelpStyle style = HelpStyle();
|
|
|
|
style.applyTheme(mSystem->getTheme(), "system");
|
|
|
|
return style;
|
2017-05-28 18:13:00 +00:00
|
|
|
}
|
|
|
|
|
2014-06-25 16:29:58 +00:00
|
|
|
std::vector<HelpPrompt> GuiGamelistOptions::getHelpPrompts()
|
|
|
|
{
|
2020-06-21 12:25:28 +00:00
|
|
|
auto prompts = mMenu.getHelpPrompts();
|
|
|
|
prompts.push_back(HelpPrompt("a", "select"));
|
|
|
|
prompts.push_back(HelpPrompt("b", "close (apply)"));
|
|
|
|
prompts.push_back(HelpPrompt("select", "close (cancel)"));
|
|
|
|
return prompts;
|
2014-06-25 16:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
IGameListView* GuiGamelistOptions::getGamelist()
|
|
|
|
{
|
2020-06-21 12:25:28 +00:00
|
|
|
return ViewController::get()->getGameListView(mSystem).get();
|
2014-06-25 16:29:58 +00:00
|
|
|
}
|