Fixed multiple issues with the UI modes.

This commit is contained in:
Leon Styhre 2021-01-05 10:45:32 +01:00
parent 4cc66a12a1
commit d2d6813a54
12 changed files with 157 additions and 74 deletions

View file

@ -14,6 +14,7 @@
#include "utils/FileSystemUtil.h" #include "utils/FileSystemUtil.h"
#include "utils/StringUtil.h" #include "utils/StringUtil.h"
#include "utils/TimeUtil.h" #include "utils/TimeUtil.h"
#include "views/UIModeController.h"
#include "AudioManager.h" #include "AudioManager.h"
#include "CollectionSystemsManager.h" #include "CollectionSystemsManager.h"
#include "FileFilterIndex.h" #include "FileFilterIndex.h"
@ -110,6 +111,14 @@ const bool FileData::getFavorite()
return false; return false;
} }
const bool FileData::getKidgame()
{
if (metadata.get("kidgame") == "true")
return true;
else
return false;
}
const bool FileData::getHidden() const bool FileData::getHidden()
{ {
if (metadata.get("hidden") == "true") if (metadata.get("hidden") == "true")
@ -301,7 +310,7 @@ const std::string FileData::getVideoPath() const
const std::vector<FileData*>& FileData::getChildrenListToDisplay() const std::vector<FileData*>& FileData::getChildrenListToDisplay()
{ {
FileFilterIndex* idx = mSystem->getIndex(); FileFilterIndex* idx = mSystem->getIndex();
if (idx->isFiltered()) { if (idx->isFiltered() || UIModeController::getInstance()->isUIModeKid()) {
mFilteredChildren.clear(); mFilteredChildren.clear();
for (auto it = mChildren.cbegin(); it != mChildren.cend(); it++) { for (auto it = mChildren.cbegin(); it != mChildren.cend(); it++) {
if (idx->showFile((*it))) { if (idx->showFile((*it))) {
@ -441,6 +450,7 @@ void FileData::sort(ComparisonFunction& comparator, bool ascending,
mHasFolders = false; mHasFolders = false;
bool foldersOnTop = Settings::getInstance()->getBool("FoldersOnTop"); bool foldersOnTop = Settings::getInstance()->getBool("FoldersOnTop");
bool showHiddenGames = Settings::getInstance()->getBool("ShowHiddenGames"); bool showHiddenGames = Settings::getInstance()->getBool("ShowHiddenGames");
bool isKidMode = UIModeController::getInstance()->isUIModeKid();
std::vector<FileData*> mChildrenFolders; std::vector<FileData*> mChildrenFolders;
std::vector<FileData*> mChildrenOthers; std::vector<FileData*> mChildrenOthers;
@ -526,10 +536,12 @@ void FileData::sort(ComparisonFunction& comparator, bool ascending,
for (auto it = mChildren.cbegin(); it != mChildren.cend(); it++) { for (auto it = mChildren.cbegin(); it != mChildren.cend(); it++) {
// Game count, which will be displayed in the system view. // Game count, which will be displayed in the system view.
if ((*it)->getType() == GAME && (*it)->getCountAsGame()) { if ((*it)->getType() == GAME && (*it)->getCountAsGame()) {
if (!isKidMode || (isKidMode && (*it)->getKidgame())) {
gameCount.first++; gameCount.first++;
if ((*it)->getFavorite()) if ((*it)->getFavorite())
gameCount.second++; gameCount.second++;
} }
}
if ((*it)->getType() != FOLDER) if ((*it)->getType() != FOLDER)
mOnlyFolders = false; mOnlyFolders = false;
@ -552,6 +564,7 @@ void FileData::sortFavoritesOnTop(ComparisonFunction& comparator, bool ascending
mHasFolders = false; mHasFolders = false;
bool foldersOnTop = Settings::getInstance()->getBool("FoldersOnTop"); bool foldersOnTop = Settings::getInstance()->getBool("FoldersOnTop");
bool showHiddenGames = Settings::getInstance()->getBool("ShowHiddenGames"); bool showHiddenGames = Settings::getInstance()->getBool("ShowHiddenGames");
bool isKidMode = UIModeController::getInstance()->isUIModeKid();
std::vector<FileData*> mChildrenFolders; std::vector<FileData*> mChildrenFolders;
std::vector<FileData*> mChildrenFavoritesFolders; std::vector<FileData*> mChildrenFavoritesFolders;
std::vector<FileData*> mChildrenFavorites; std::vector<FileData*> mChildrenFavorites;
@ -589,10 +602,12 @@ void FileData::sortFavoritesOnTop(ComparisonFunction& comparator, bool ascending
// Game count, which will be displayed in the system view. // Game count, which will be displayed in the system view.
if (mChildren[i]->getType() == GAME && mChildren[i]->getCountAsGame()) { if (mChildren[i]->getType() == GAME && mChildren[i]->getCountAsGame()) {
if (!isKidMode || (isKidMode && mChildren[i]->getKidgame())) {
gameCount.first++; gameCount.first++;
if (mChildren[i]->getFavorite()) if (mChildren[i]->getFavorite())
gameCount.second++; gameCount.second++;
} }
}
if (foldersOnTop && mChildren[i]->getType() == FOLDER) { if (foldersOnTop && mChildren[i]->getType() == FOLDER) {
if (!mChildren[i]->getFavorite()) if (!mChildren[i]->getFavorite())
@ -707,12 +722,20 @@ void FileData::sort(const SortType& type, bool mFavoritesOnTop)
void FileData::countGames(std::pair<unsigned int, unsigned int>& gameCount) void FileData::countGames(std::pair<unsigned int, unsigned int>& gameCount)
{ {
bool isKidMode = (Settings::getInstance()->getString("UIMode") == "kid" ||
Settings::getInstance()->getBool("ForceKid"));
(Settings::getInstance()->getString("UIMode") == "kid" ||
Settings::getInstance()->getBool("ForceKid"));
for (unsigned int i = 0; i < mChildren.size(); i++) { for (unsigned int i = 0; i < mChildren.size(); i++) {
if (mChildren[i]->getType() == GAME && mChildren[i]->getCountAsGame()) { if (mChildren[i]->getType() == GAME && mChildren[i]->getCountAsGame()) {
if (!isKidMode || (isKidMode && mChildren[i]->getKidgame())) {
gameCount.first++; gameCount.first++;
if (mChildren[i]->getFavorite()) if (mChildren[i]->getFavorite())
gameCount.second++; gameCount.second++;
} }
}
// Iterate through any folders. // Iterate through any folders.
else if (mChildren[i]->getType() == FOLDER) else if (mChildren[i]->getType() == FOLDER)
mChildren[i]->countGames(gameCount); mChildren[i]->countGames(gameCount);

View file

@ -38,6 +38,7 @@ public:
virtual const std::string& getName(); virtual const std::string& getName();
const std::string& getSortName(); const std::string& getSortName();
const bool getFavorite(); const bool getFavorite();
const bool getKidgame();
const bool getHidden(); const bool getHidden();
const bool getCountAsGame(); const bool getCountAsGame();
const std::pair<unsigned int, unsigned int> getGameCount() { return mGameCount; }; const std::pair<unsigned int, unsigned int> getGameCount() { return mGameCount; };

View file

@ -85,11 +85,11 @@ void FileFilterIndex::importIndex(FileFilterIndex* indexToImport)
sizeof(indexStructDecls) / sizeof(indexStructDecls[0])); sizeof(indexStructDecls) / sizeof(indexStructDecls[0]));
for (std::vector<IndexImportStructure>::const_iterator indexesIt = for (std::vector<IndexImportStructure>::const_iterator indexesIt =
indexImportDecl.cbegin(); indexesIt != indexImportDecl.cend(); ++indexesIt ) indexImportDecl.cbegin(); indexesIt != indexImportDecl.cend(); indexesIt++)
{ {
for (std::map<std::string, int>::const_iterator sourceIt = for (std::map<std::string, int>::const_iterator sourceIt =
(*indexesIt).sourceIndex->cbegin(); sourceIt != (*indexesIt).sourceIndex->cbegin(); sourceIt !=
(*indexesIt).sourceIndex->cend(); ++sourceIt ) { (*indexesIt).sourceIndex->cend(); sourceIt++) {
if ((*indexesIt).destinationIndex->find((*sourceIt).first) == if ((*indexesIt).destinationIndex->find((*sourceIt).first) ==
(*indexesIt).destinationIndex->cend()) (*indexesIt).destinationIndex->cend())
// Entry doesn't exist. // Entry doesn't exist.
@ -254,13 +254,13 @@ void FileFilterIndex::setFilter(FilterIndexType type, std::vector<std::string>*
} }
else { else {
for (std::vector<FilterDataDecl>::const_iterator it = filterDataDecl.cbegin(); for (std::vector<FilterDataDecl>::const_iterator it = filterDataDecl.cbegin();
it != filterDataDecl.cend(); ++it ) { it != filterDataDecl.cend(); it++) {
if ((*it).type == type) { if ((*it).type == type) {
FilterDataDecl filterData = (*it); FilterDataDecl filterData = (*it);
*(filterData.filteredByRef) = values->size() > 0; *(filterData.filteredByRef) = values->size() > 0;
filterData.currentFilteredKeys->clear(); filterData.currentFilteredKeys->clear();
for (std::vector<std::string>::const_iterator vit = for (std::vector<std::string>::const_iterator vit =
values->cbegin(); vit != values->cend(); ++vit ) { values->cbegin(); vit != values->cend(); vit++) {
// Check if it exists. // Check if it exists.
if (filterData.allIndexKeys->find(*vit) != filterData.allIndexKeys->cend()) { if (filterData.allIndexKeys->find(*vit) != filterData.allIndexKeys->cend()) {
filterData.currentFilteredKeys->push_back(std::string(*vit)); filterData.currentFilteredKeys->push_back(std::string(*vit));
@ -285,35 +285,29 @@ void FileFilterIndex::setFilter(FilterIndexType type, std::vector<std::string>*
void FileFilterIndex::clearAllFilters() void FileFilterIndex::clearAllFilters()
{ {
for (std::vector<FilterDataDecl>::const_iterator it = filterDataDecl.cbegin(); for (std::vector<FilterDataDecl>::const_iterator it = filterDataDecl.cbegin();
it != filterDataDecl.cend(); ++it ) { it != filterDataDecl.cend(); it++) {
FilterDataDecl filterData = (*it); FilterDataDecl filterData = (*it);
*(filterData.filteredByRef) = false; *(filterData.filteredByRef) = false;
filterData.currentFilteredKeys->clear(); filterData.currentFilteredKeys->clear();
} }
setTextFilter("");
return; return;
} }
void FileFilterIndex::resetFilters() void FileFilterIndex::resetFilters()
{ {
clearAllFilters(); clearAllFilters();
setUIModeFilters(); setKidModeFilters();
} }
void FileFilterIndex::setUIModeFilters() void FileFilterIndex::setKidModeFilters()
{ {
if (Settings::getInstance()->getBool("GamelistFilters")){
if (UIModeController::getInstance()->isUIModeKiosk()) {
mFilterByHidden = true;
std::vector<std::string> val = { "FALSE" };
setFilter(HIDDEN_FILTER, &val);
}
if (UIModeController::getInstance()->isUIModeKid()) { if (UIModeController::getInstance()->isUIModeKid()) {
mFilterByKidGame = true; mFilterByKidGame = true;
std::vector<std::string> val = { "TRUE" }; std::vector<std::string> val = { "TRUE" };
setFilter(KIDGAME_FILTER, &val); setFilter(KIDGAME_FILTER, &val);
} }
} }
}
void FileFilterIndex::debugPrintIndexes() void FileFilterIndex::debugPrintIndexes()
{ {
@ -349,17 +343,13 @@ void FileFilterIndex::debugPrintIndexes()
bool FileFilterIndex::showFile(FileData* game) bool FileFilterIndex::showFile(FileData* game)
{ {
// This shouldn't happen, but just in case let's get it out of the way.
if (!isFiltered())
return true;
// If folder, needs further inspection - i.e. see if folder contains at least one element // If folder, needs further inspection - i.e. see if folder contains at least one element
// that should be shown. // that should be shown.
if (game->getType() == FOLDER) { if (game->getType() == FOLDER) {
std::vector<FileData*> children = game->getChildren(); std::vector<FileData*> children = game->getChildren();
// Iterate through all of the children, until there's a match. // Iterate through all of the children, until there's a match.
for (std::vector<FileData*>::const_iterator it = children.cbegin(); for (std::vector<FileData*>::const_iterator it = children.cbegin();
it != children.cend(); ++it ) { it != children.cend(); it++) {
if (showFile(*it)) if (showFile(*it))
return true; return true;
} }
@ -380,9 +370,12 @@ bool FileFilterIndex::showFile(FileData* game)
} }
for (std::vector<FilterDataDecl>::const_iterator it = filterDataDecl.cbegin(); for (std::vector<FilterDataDecl>::const_iterator it = filterDataDecl.cbegin();
it != filterDataDecl.cend(); ++it ) { it != filterDataDecl.cend(); it++) {
FilterDataDecl filterData = (*it); FilterDataDecl filterData = (*it);
if (*(filterData.filteredByRef)) { if (filterData.primaryKey == "kidgame" && UIModeController::getInstance()->isUIModeKid()) {
return (getIndexableKey(game, filterData.type, false) != "FALSE");
}
else if (*(filterData.filteredByRef)) {
// Try to find a match. // Try to find a match.
std::string key = getIndexableKey(game, filterData.type, false); std::string key = getIndexableKey(game, filterData.type, false);
keepGoing = isKeyBeingFilteredBy(key, filterData.type); keepGoing = isKeyBeingFilteredBy(key, filterData.type);
@ -410,6 +403,20 @@ bool FileFilterIndex::showFile(FileData* game)
return keepGoing; return keepGoing;
} }
bool FileFilterIndex::isFiltered()
{
if (UIModeController::getInstance()->isUIModeKid()) {
return (mFilterByText || mFilterByFavorites || mFilterByGenre || mFilterByPlayers ||
mFilterByPubDev || mFilterByRatings || mFilterByCompleted || mFilterByBroken ||
mFilterByHidden);
}
else {
return (mFilterByText || mFilterByFavorites || mFilterByGenre || mFilterByPlayers ||
mFilterByPubDev || mFilterByRatings || mFilterByKidGame || mFilterByCompleted ||
mFilterByBroken || mFilterByHidden);
}
}
bool FileFilterIndex::isKeyBeingFilteredBy(std::string key, FilterIndexType type) bool FileFilterIndex::isKeyBeingFilteredBy(std::string key, FilterIndexType type)
{ {
const FilterIndexType filterTypes[9] = { FAVORITES_FILTER, GENRE_FILTER, const FilterIndexType filterTypes[9] = { FAVORITES_FILTER, GENRE_FILTER,
@ -423,7 +430,7 @@ bool FileFilterIndex::isKeyBeingFilteredBy(std::string key, FilterIndexType type
for (int i = 0; i < 9; i++) { for (int i = 0; i < 9; i++) {
if (filterTypes[i] == type) { if (filterTypes[i] == type) {
for (std::vector<std::string>::const_iterator it = filterKeysList[i].cbegin(); for (std::vector<std::string>::const_iterator it = filterKeysList[i].cbegin();
it != filterKeysList[i].cend(); ++it ) { it != filterKeysList[i].cend(); it++) {
if (key == (*it)) if (key == (*it))
return true; return true;
} }

View file

@ -56,16 +56,14 @@ public:
void clearAllFilters(); void clearAllFilters();
void debugPrintIndexes(); void debugPrintIndexes();
bool showFile(FileData* game); bool showFile(FileData* game);
bool isFiltered() { return (mFilterByText || mFilterByFavorites || mFilterByGenre || bool isFiltered();
mFilterByPlayers || mFilterByPubDev || mFilterByRatings || mFilterByKidGame ||
mFilterByCompleted || mFilterByBroken || mFilterByHidden ); };
bool isKeyBeingFilteredBy(std::string key, FilterIndexType type); bool isKeyBeingFilteredBy(std::string key, FilterIndexType type);
std::vector<FilterDataDecl>& getFilterDataDecls(); std::vector<FilterDataDecl>& getFilterDataDecls();
void importIndex(FileFilterIndex* indexToImport); void importIndex(FileFilterIndex* indexToImport);
void resetIndex(); void resetIndex();
void resetFilters(); void resetFilters();
void setUIModeFilters(); void setKidModeFilters();
private: private:
std::vector<FilterDataDecl> filterDataDecl; std::vector<FilterDataDecl> filterDataDecl;

View file

@ -110,14 +110,8 @@ void GuiGamelistFilter::addFiltersToMenu()
std::vector<FilterDataDecl> decls = mFilterIndex->getFilterDataDecls(); std::vector<FilterDataDecl> decls = mFilterIndex->getFilterDataDecls();
int skip = 0; for (std::vector<FilterDataDecl>::const_iterator it =
if (!UIModeController::getInstance()->isUIModeFull()) decls.cbegin(); it != decls.cend(); it++) {
skip = 1;
if (UIModeController::getInstance()->isUIModeKid())
skip = 2;
for (std::vector<FilterDataDecl>::const_iterator it = decls.cbegin();
it != decls.cend()-skip; ++it ) {
FilterIndexType type = (*it).type; // Type of filter. FilterIndexType type = (*it).type; // Type of filter.
// All possible filters for this type. // All possible filters for this type.

View file

@ -24,6 +24,7 @@
#include "views/ViewController.h" #include "views/ViewController.h"
#include "CollectionSystemsManager.h" #include "CollectionSystemsManager.h"
#include "EmulationStation.h" #include "EmulationStation.h"
#include "FileFilterIndex.h"
#include "FileSorts.h" #include "FileSorts.h"
#include "Platform.h" #include "Platform.h"
#include "Scripting.h" #include "Scripting.h"
@ -191,12 +192,15 @@ void GuiMenu::openUISettings()
ui_mode->add(*it, *it, setMode == *it); ui_mode->add(*it, *it, setMode == *it);
s->addWithLabel("UI MODE", ui_mode); s->addWithLabel("UI MODE", ui_mode);
s->addSaveFunc([ui_mode, this, s] { s->addSaveFunc([ui_mode, this, s] {
// Always save settings if mode was forced to 'full'.
if (Settings::getInstance()->getBool("ForceFull"))
s->setNeedsSaving();
std::string selectedMode = ui_mode->getSelected(); std::string selectedMode = ui_mode->getSelected();
if (selectedMode != Settings::getInstance()->getString("UIMode") && // If any of the force flags are set, then always apply and save the setting.
selectedMode != "full") { if (selectedMode == Settings::getInstance()->getString("UIMode") &&
!Settings::getInstance()->getBool("ForceFull") &&
!Settings::getInstance()->getBool("ForceKiosk") &&
!Settings::getInstance()->getBool("ForceKid")) {
return;
}
else if (selectedMode != "full") {
std::string msg = "YOU ARE CHANGING THE UI TO A RESTRICTED MODE:\n'" + std::string msg = "YOU ARE CHANGING THE UI TO A RESTRICTED MODE:\n'" +
Utils::String::toUpper(selectedMode) + "'\n"; Utils::String::toUpper(selectedMode) + "'\n";
msg += "THIS WILL HIDE MOST MENU OPTIONS TO PREVENT CHANGES TO THE SYSTEM.\n"; msg += "THIS WILL HIDE MOST MENU OPTIONS TO PREVENT CHANGES TO THE SYSTEM.\n";
@ -204,7 +208,7 @@ void GuiMenu::openUISettings()
msg += "\"" + UIModeController::getInstance()->getFormattedPassKeyStr() + "\"\n\n"; msg += "\"" + UIModeController::getInstance()->getFormattedPassKeyStr() + "\"\n\n";
msg += "DO YOU WANT TO PROCEED?"; msg += "DO YOU WANT TO PROCEED?";
mWindow->pushGui(new GuiMsgBox(mWindow, this->getHelpStyle(), msg, mWindow->pushGui(new GuiMsgBox(mWindow, this->getHelpStyle(), msg,
"YES", [selectedMode, s] { "YES", [this, selectedMode] {
LOG(LogDebug) << "GuiMenu::openUISettings(): Setting UI mode to '" LOG(LogDebug) << "GuiMenu::openUISettings(): Setting UI mode to '"
<< selectedMode << "'."; << selectedMode << "'.";
Settings::getInstance()->setString("UIMode", selectedMode); Settings::getInstance()->setString("UIMode", selectedMode);
@ -212,17 +216,36 @@ void GuiMenu::openUISettings()
Settings::getInstance()->setBool("ForceKiosk", false); Settings::getInstance()->setBool("ForceKiosk", false);
Settings::getInstance()->setBool("ForceKid", false); Settings::getInstance()->setBool("ForceKid", false);
Settings::getInstance()->saveFile(); Settings::getInstance()->saveFile();
UIModeController::getInstance()->setCurrentUIMode(selectedMode);
for (auto it = SystemData::sSystemVector.cbegin();
it != SystemData::sSystemVector.cend(); it++) {
if ((*it)->getThemeFolder() == "custom-collections") {
for (FileData* customSystem :
(*it)->getRootFolder()->getChildrenListToDisplay())
customSystem->getSystem()->getIndex()->resetFilters();
}
(*it)->sortSystem();
(*it)->getIndex()->resetFilters();
}
ViewController::get()->reloadAll();
ViewController::get()->goToSystem(SystemData::sSystemVector.front(), false);
mWindow->invalidateCachedBackground();
}, "NO", nullptr)); }, "NO", nullptr));
} }
else if (ui_mode->getSelected() != Settings::getInstance()->getString("UIMode") && else {
selectedMode == "full") {
LOG(LogDebug) << "GuiMenu::openUISettings(): Setting UI mode to '" << LOG(LogDebug) << "GuiMenu::openUISettings(): Setting UI mode to '" <<
selectedMode << "'."; selectedMode << "'.";
Settings::getInstance()->setString("UIMode", ui_mode->getSelected()); Settings::getInstance()->setString("UIMode", ui_mode->getSelected());
Settings::getInstance()->setBool("ForceFull", false); Settings::getInstance()->setBool("ForceFull", false);
Settings::getInstance()->setBool("ForceKiosk", false); Settings::getInstance()->setBool("ForceKiosk", false);
Settings::getInstance()->setBool("ForceKid", false); Settings::getInstance()->setBool("ForceKid", false);
UIModeController::getInstance()->setCurrentUIMode("full");
s->setNeedsSaving(); s->setNeedsSaving();
s->setNeedsSorting();
s->setNeedsSortingCollections();
s->setNeedsResetFilters();
s->setNeedsReloading();
s->setNeedsGoToSystem(SystemData::sSystemVector.front());
} }
}); });

View file

@ -4,8 +4,8 @@
// GuiSettings.cpp // GuiSettings.cpp
// //
// User interface template for a settings GUI. // User interface template for a settings GUI.
// The saving of es_settings.cfg and the reload of the gamelists are triggered from here // The saving of es_settings.cfg, the reload of gamelists and some other actions are
// based on the flags set by the actual menu entries' lambda functions. // also triggered to be executed here via flags set by the menu entries' lambda functions.
// //
#include "guis/GuiSettings.h" #include "guis/GuiSettings.h"
@ -14,6 +14,7 @@
#include "views/gamelist/IGameListView.h" #include "views/gamelist/IGameListView.h"
#include "views/ViewController.h" #include "views/ViewController.h"
#include "CollectionSystemsManager.h" #include "CollectionSystemsManager.h"
#include "FileFilterIndex.h"
#include "Settings.h" #include "Settings.h"
#include "SystemData.h" #include "SystemData.h"
#include "Window.h" #include "Window.h"
@ -25,13 +26,14 @@ GuiSettings::GuiSettings(
mMenu(window, title), mMenu(window, title),
mNeedsSaving(false), mNeedsSaving(false),
mNeedsCollectionsUpdate(false), mNeedsCollectionsUpdate(false),
mNeedsReloading(false),
mNeedsSorting(false), mNeedsSorting(false),
mNeedsSortingCollections(false), mNeedsSortingCollections(false),
mGoToSystem(nullptr), mNeedsResetFilters(false),
mNeedsReloading(false),
mNeedsGoToStart(false), mNeedsGoToStart(false),
mNeedsGoToSystem(false), mNeedsGoToSystem(false),
mNeedsGoToGroupedCollections(false) mNeedsGoToGroupedCollections(false),
mGoToSystem(nullptr)
{ {
addChild(&mMenu); addChild(&mMenu);
mMenu.addButton("BACK", "back", [this] { delete this; }); mMenu.addButton("BACK", "back", [this] { delete this; });
@ -62,9 +64,6 @@ void GuiSettings::save()
CollectionSystemsManager::get()->updateSystemsList(); CollectionSystemsManager::get()->updateSystemsList();
} }
if (mNeedsReloading)
ViewController::get()->reloadAll();
if (mNeedsSorting) { if (mNeedsSorting) {
for (auto it = SystemData::sSystemVector.cbegin(); it != for (auto it = SystemData::sSystemVector.cbegin(); it !=
SystemData::sSystemVector.cend(); it++) { SystemData::sSystemVector.cend(); it++) {
@ -77,6 +76,21 @@ void GuiSettings::save()
} }
} }
if (mNeedsResetFilters) {
for (auto it = SystemData::sSystemVector.cbegin();
it != SystemData::sSystemVector.cend(); it++) {
if ((*it)->getThemeFolder() == "custom-collections") {
for (FileData* customSystem :
(*it)->getRootFolder()->getChildrenListToDisplay())
customSystem->getSystem()->getIndex()->resetFilters();
}
(*it)->getIndex()->resetFilters();
}
}
if (mNeedsReloading)
ViewController::get()->reloadAll();
if (mNeedsGoToStart) if (mNeedsGoToStart)
ViewController::get()->goToStart(); ViewController::get()->goToStart();

View file

@ -4,8 +4,8 @@
// GuiSettings.h // GuiSettings.h
// //
// User interface template for a settings GUI. // User interface template for a settings GUI.
// The saving of es_settings.cfg and the reload of the gamelists are triggered from here // The saving of es_settings.cfg, the reload of gamelists and some other actions are
// based on the flags set by the actual menu entries' lambda functions. // also triggered to be executed here via flags set by the menu entries' lambda functions.
// //
#ifndef ES_APP_GUIS_GUI_SETTINGS_H #ifndef ES_APP_GUIS_GUI_SETTINGS_H
@ -35,9 +35,10 @@ public:
void setNeedsSaving() { mNeedsSaving = true; }; void setNeedsSaving() { mNeedsSaving = true; };
void setNeedsCollectionsUpdate() { mNeedsCollectionsUpdate = true; }; void setNeedsCollectionsUpdate() { mNeedsCollectionsUpdate = true; };
void setNeedsReloading() { mNeedsReloading = true; };
void setNeedsSorting() { mNeedsSorting = true; }; void setNeedsSorting() { mNeedsSorting = true; };
void setNeedsSortingCollections() { mNeedsSortingCollections = true; }; void setNeedsSortingCollections() { mNeedsSortingCollections = true; };
void setNeedsResetFilters() { mNeedsResetFilters = true; }
void setNeedsReloading() { mNeedsReloading = true; };
void setNeedsGoToStart() { mNeedsGoToStart = true; }; void setNeedsGoToStart() { mNeedsGoToStart = true; };
void setNeedsGoToSystem(SystemData* goToSystem) void setNeedsGoToSystem(SystemData* goToSystem)
{ mNeedsGoToSystem = true; mGoToSystem = goToSystem; }; { mNeedsGoToSystem = true; mGoToSystem = goToSystem; };
@ -52,9 +53,10 @@ private:
std::vector<std::function<void()>> mSaveFuncs; std::vector<std::function<void()>> mSaveFuncs;
bool mNeedsSaving; bool mNeedsSaving;
bool mNeedsCollectionsUpdate; bool mNeedsCollectionsUpdate;
bool mNeedsReloading;
bool mNeedsSorting; bool mNeedsSorting;
bool mNeedsSortingCollections; bool mNeedsSortingCollections;
bool mNeedsResetFilters;
bool mNeedsReloading;
bool mNeedsGoToStart; bool mNeedsGoToStart;
bool mNeedsGoToSystem; bool mNeedsGoToSystem;
bool mNeedsGoToGroupedCollections; bool mNeedsGoToGroupedCollections;

View file

@ -11,7 +11,9 @@
#include "utils/StringUtil.h" #include "utils/StringUtil.h"
#include "views/ViewController.h" #include "views/ViewController.h"
#include "FileFilterIndex.h"
#include "Log.h" #include "Log.h"
#include "SystemData.h"
#include "Window.h" #include "Window.h"
UIModeController* UIModeController::sInstance = nullptr; UIModeController* UIModeController::sInstance = nullptr;
@ -34,8 +36,19 @@ void UIModeController::monitorUIMode()
{ {
std::string uimode = Settings::getInstance()->getString("UIMode"); std::string uimode = Settings::getInstance()->getString("UIMode");
// UI mode was changed. // UI mode was changed.
if (uimode != mCurrentUIMode) { if (uimode != mCurrentUIMode && !ViewController::get()->isCameraMoving()) {
mCurrentUIMode = uimode; mCurrentUIMode = uimode;
// Reset filters and sort gamelists (which will update the game counter).
for (auto it = SystemData::sSystemVector.cbegin(); it !=
SystemData::sSystemVector.cend(); it++) {
(*it)->sortSystem(true);
(*it)->getIndex()->resetFilters();
if ((*it)->getThemeFolder() == "custom-collections") {
for (FileData* customSystem :
(*it)->getRootFolder()->getChildrenListToDisplay())
customSystem->getSystem()->getIndex()->resetFilters();
}
}
ViewController::get()->ReloadAndGoToStart(); ViewController::get()->ReloadAndGoToStart();
} }
} }

View file

@ -38,6 +38,8 @@ public:
bool isUIModeKid(); bool isUIModeKid();
bool isUIModeKiosk(); bool isUIModeKiosk();
void setCurrentUIMode(const std::string& mode) { mCurrentUIMode = mode; };
private: private:
UIModeController(); UIModeController();
bool inputIsMatch(InputConfig * config, Input input); bool inputIsMatch(InputConfig * config, Input input);

View file

@ -133,8 +133,14 @@ void ViewController::goToStart()
void ViewController::ReloadAndGoToStart() void ViewController::ReloadAndGoToStart()
{ {
mWindow->renderLoadingScreen("Loading..."); mWindow->renderLoadingScreen("Loading...");
ViewController::get()->reloadAll(); reloadAll();
ViewController::get()->goToStart(); if (mState.viewing == GAME_LIST) {
goToSystemView(SystemData::sSystemVector.front(), false);
goToSystem(SystemData::sSystemVector.front(), false);
}
else {
goToSystem(SystemData::sSystemVector.front(), false);
}
} }
bool ViewController::isCameraMoving() bool ViewController::isCameraMoving()
@ -554,7 +560,7 @@ std::shared_ptr<IGameListView> ViewController::getGameListView(SystemData* syste
if (exists != mGameListViews.cend()) if (exists != mGameListViews.cend())
return exists->second; return exists->second;
system->getIndex()->setUIModeFilters(); system->getIndex()->setKidModeFilters();
// If there's no entry, then create it and return it. // If there's no entry, then create it and return it.
std::shared_ptr<IGameListView> view; std::shared_ptr<IGameListView> view;
@ -781,7 +787,7 @@ void ViewController::reloadGameListView(IGameListView* view, bool reloadTheme)
if (reloadTheme) if (reloadTheme)
system->loadTheme(); system->loadTheme();
system->getIndex()->setUIModeFilters(); system->getIndex()->setKidModeFilters();
std::shared_ptr<IGameListView> newView = getGameListView(system); std::shared_ptr<IGameListView> newView = getGameListView(system);
// To counter having come from a placeholder. // To counter having come from a placeholder.

View file

@ -30,7 +30,7 @@ ScrollableContainer::ScrollableContainer(
mAutoScrollResetAccumulator(0) mAutoScrollResetAccumulator(0)
{ {
// Set the modifier to get equivalent scrolling speed regardless of screen resolution. // Set the modifier to get equivalent scrolling speed regardless of screen resolution.
// 1920p is the reference. // 1080p is the reference.
mResolutionModifier = static_cast<float>(Renderer::getScreenWidth()) / 1920.0f; mResolutionModifier = static_cast<float>(Renderer::getScreenWidth()) / 1920.0f;
} }