Properly implemented hiding of games.

Also added a flag to force the Full UI mode from the command line.
This commit is contained in:
Leon Styhre 2020-07-26 22:19:29 +02:00
parent 47523ba627
commit 329a8da441
12 changed files with 124 additions and 11 deletions

View file

@ -560,6 +560,7 @@ You can use `--help` or `-h` to view a list of command line options, as shown he
--gamelist-only Skip automatic game ROM search, only read from gamelist.xml --gamelist-only Skip automatic game ROM search, only read from gamelist.xml
--ignore-gamelist Ignore the gamelist files (useful for troubleshooting) --ignore-gamelist Ignore the gamelist files (useful for troubleshooting)
--show-hidden-files Show hidden files and folders --show-hidden-files Show hidden files and folders
--show-hidden-games Show hidden games
--draw-framerate Display the framerate --draw-framerate Display the framerate
--no-exit Don't show the exit option in the menu --no-exit Don't show the exit option in the menu
--no-splash Don't show the splash screen --no-splash Don't show the splash screen
@ -570,6 +571,7 @@ You can use `--help` or `-h` to view a list of command line options, as shown he
--vsync [1/on or 0/off] Turn vsync on or off (default is on) --vsync [1/on or 0/off] Turn vsync on or off (default is on)
--max-vram [size] Max VRAM to use in Mb before swapping --max-vram [size] Max VRAM to use in Mb before swapping
Set to at least 20 to avoid unpredictable behavior Set to at least 20 to avoid unpredictable behavior
--force-full Force the UI mode to Full
--force-kid Force the UI mode to Kid --force-kid Force the UI mode to Kid
--force-kiosk Force the UI mode to Kiosk --force-kiosk Force the UI mode to Kiosk
--force-disable-filters Force the UI to ignore applied filters in gamelist --force-disable-filters Force the UI to ignore applied filters in gamelist
@ -585,6 +587,7 @@ You can use `--help` or `-h` to view a list of command line options, as shown he
--gamelist-only Skip automatic game ROM search, only read from gamelist.xml --gamelist-only Skip automatic game ROM search, only read from gamelist.xml
--ignore-gamelist Ignore the gamelist files (useful for troubleshooting) --ignore-gamelist Ignore the gamelist files (useful for troubleshooting)
--show-hidden-files Show hidden files and folders --show-hidden-files Show hidden files and folders
--show-hidden-games Show hidden games
--draw-framerate Display the framerate --draw-framerate Display the framerate
--no-exit Don't show the exit option in the menu --no-exit Don't show the exit option in the menu
--no-splash Don't show the splash screen --no-splash Don't show the splash screen
@ -592,6 +595,7 @@ You can use `--help` or `-h` to view a list of command line options, as shown he
--vsync [1/on or 0/off] Turn vsync on or off (default is on) --vsync [1/on or 0/off] Turn vsync on or off (default is on)
--max-vram [size] Max VRAM to use in Mb before swapping --max-vram [size] Max VRAM to use in Mb before swapping
Set to at least 20 to avoid unpredictable behavior Set to at least 20 to avoid unpredictable behavior
--force-full Force the UI mode to Full
--force-kid Force the UI mode to Kid --force-kid Force the UI mode to Kid
--force-kiosk Force the UI mode to Kiosk --force-kiosk Force the UI mode to Kiosk
--force-disable-filters Force the UI to ignore applied filters in gamelist --force-disable-filters Force the UI to ignore applied filters in gamelist

View file

@ -17,6 +17,8 @@ v1.0.0
* Seamless (almost) launch of games without showing the desktop when starting and returning from RetroArch and other emulators * Seamless (almost) launch of games without showing the desktop when starting and returning from RetroArch and other emulators
* Per-game launch command override, so that different cores or emulators can be used on a per-game basis (saved to gamelist.xml) * Per-game launch command override, so that different cores or emulators can be used on a per-game basis (saved to gamelist.xml)
* Core location can be defined relative to the emulator binary using the %EMUPATH% varible in es_systems.cfg (mostly useful for Windows) * Core location can be defined relative to the emulator binary using the %EMUPATH% varible in es_systems.cfg (mostly useful for Windows)
* Properly implemented the option to show or hide hidden files and folders
* Properly implemented the option to show or hide games flagged as hidden in the metadata editor
* Help system updated and expanded to the complete application (previously it was only partially implemented) * Help system updated and expanded to the complete application (previously it was only partially implemented)
* Improved input device configuration, and default keyboard mappings are now applied if the keyboard has not been configured by the user * Improved input device configuration, and default keyboard mappings are now applied if the keyboard has not been configured by the user
* GUI-configurable option to sort favorite games on the top of the game lists (favorites marked with stars) * GUI-configurable option to sort favorite games on the top of the game lists (favorites marked with stars)

View file

@ -110,6 +110,32 @@ const bool FileData::getFavorite()
return false; return false;
} }
const bool FileData::getHidden()
{
if (metadata.get("hidden") == "true")
return true;
else
return false;
}
const std::vector<FileData*> FileData::getChildrenRercursive() const
{
std::vector<FileData*> childrenRecursive;
for (auto it = mChildrenByFilename.cbegin();
it != mChildrenByFilename.cend(); it++) {
childrenRecursive.push_back((*it).second);
// Recurse through any subdirectories.
if ((*it).second->getType() == FOLDER) {
std::vector<FileData*> childrenSubdirectory = (*it).second->getChildrenRercursive();
childrenRecursive.insert(childrenRecursive.end(),
childrenSubdirectory.begin(), childrenSubdirectory.end());
}
}
return childrenRecursive;
}
const std::string FileData::getROMDirectory() const std::string FileData::getROMDirectory()
{ {
std::string romDirSetting = Settings::getInstance()->getString("ROMDirectory"); std::string romDirSetting = Settings::getInstance()->getString("ROMDirectory");
@ -346,6 +372,24 @@ void FileData::removeChild(FileData* file)
void FileData::sort(ComparisonFunction& comparator, bool ascending) void FileData::sort(ComparisonFunction& comparator, bool ascending)
{ {
mFirstLetterIndex.clear(); mFirstLetterIndex.clear();
// Only run this section of code if the setting to show hidden games has been disabled,
// in order to avoid unnecessary processing.
if (!Settings::getInstance()->getBool("ShowHiddenGames")) {
std::vector<FileData*> mChildrenShown;
for (unsigned int i = 0; i < mChildren.size(); i++) {
if (mChildren[i]->getHidden()) {
LOG(LogDebug) << "Debug - FileData::sort(): Skipping hidden game '" <<
mChildren[i]->getName() << "'";
continue;
}
mChildrenShown.push_back(mChildren[i]);
}
mChildren.erase(mChildren.begin(), mChildren.end());
mChildren.reserve(mChildrenShown.size());
mChildren.insert(mChildren.end(), mChildrenShown.begin(), mChildrenShown.end());
}
std::stable_sort(mChildren.begin(), mChildren.end(), comparator); std::stable_sort(mChildren.begin(), mChildren.end(), comparator);
for (auto it = mChildren.cbegin(); it != mChildren.cend(); it++) { for (auto it = mChildren.cbegin(); it != mChildren.cend(); it++) {
@ -371,8 +415,16 @@ void FileData::sortFavoritesOnTop(ComparisonFunction& comparator, bool ascending
mFirstLetterIndex.clear(); mFirstLetterIndex.clear();
std::vector<FileData*> mChildrenFavorites; std::vector<FileData*> mChildrenFavorites;
std::vector<FileData*> mChildrenOthers; std::vector<FileData*> mChildrenOthers;
bool showHiddenGames = Settings::getInstance()->getBool("ShowHiddenGames");
for (unsigned int i = 0; i < mChildren.size(); i++) { for (unsigned int i = 0; i < mChildren.size(); i++) {
// Exclude game if it's marked as hidden and the hide setting has been set.
if (!showHiddenGames && mChildren[i]->getHidden()) {
LOG(LogDebug) << "Debug - FileData::sortFavoritesOnTop(): Skipping hidden game '" <<
mChildren[i]->getName() << "'";
continue;
}
if (mChildren[i]->getFavorite()) { if (mChildren[i]->getFavorite()) {
mChildrenFavorites.push_back(mChildren[i]); mChildrenFavorites.push_back(mChildren[i]);
} }

View file

@ -47,6 +47,8 @@ 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 getHidden();
const std::vector<FileData*> getChildrenRercursive() const;
inline FileType getType() const { return mType; } inline FileType getType() const { return mType; }
inline const std::string& getPath() const { return mPath; } inline const std::string& getPath() const { return mPath; }
inline FileData* getParent() const { return mParent; } inline FileData* getParent() const { return mParent; }

View file

@ -128,7 +128,7 @@ void parseGamelist(SystemData* system)
relativeTo, false); relativeTo, false);
if (!trustGamelist && !Utils::FileSystem::exists(path)) { if (!trustGamelist && !Utils::FileSystem::exists(path)) {
LOG(LogWarning) << "File \"" << path << "\" does not exist! Ignoring."; LOG(LogWarning) << "Warning - File \"" << path << "\" does not exist, ignoring.";
continue; continue;
} }

View file

@ -315,7 +315,24 @@ bool SystemData::loadConfig()
envData->mPlatformIds = platformIds; envData->mPlatformIds = platformIds;
SystemData* newSys = new SystemData(name, fullname, envData, themeFolder); SystemData* newSys = new SystemData(name, fullname, envData, themeFolder);
if (newSys->getRootFolder()->getChildrenByFilename().size() == 0) { bool onlyHidden = false;
// If the option to show hidden games has been disabled, then check whether all
// games for the system are hidden. That will flag the system as empty.
if (!Settings::getInstance()->getBool("ShowHiddenGames")) {
std::vector<FileData*> recursiveGames =
newSys->getRootFolder()->getChildrenRercursive();
onlyHidden = true;
for (auto it = recursiveGames.cbegin(); it != recursiveGames.cend(); it++) {
if ((*it)->getType() != FOLDER) {
onlyHidden = (*it)->getHidden();
if (!onlyHidden)
break;
}
}
}
if (newSys->getRootFolder()->getChildrenByFilename().size() == 0 || onlyHidden) {
LOG(LogDebug) << "SystemData::loadConfig(): System \"" << name << LOG(LogDebug) << "SystemData::loadConfig(): System \"" << name <<
"\" has no games, ignoring it."; "\" has no games, ignoring it.";
delete newSys; delete newSys;

Binary file not shown.

View file

@ -618,6 +618,22 @@ void GuiMenu::openOtherSettings()
s->addSaveFunc([launchcommand_override] { Settings::getInstance()-> s->addSaveFunc([launchcommand_override] { Settings::getInstance()->
setBool("LaunchCommandOverride", launchcommand_override->getState()); }); setBool("LaunchCommandOverride", launchcommand_override->getState()); });
// Hidden files.
auto hidden_files = std::make_shared<SwitchComponent>(mWindow);
hidden_files->setState(Settings::getInstance()->getBool("ShowHiddenFiles"));
s->addWithLabel("SHOW HIDDEN FILES AND FOLDERS (REQUIRES RESTART)", hidden_files);
s->addSaveFunc([hidden_files] { Settings::getInstance()->setBool("ShowHiddenFiles",
hidden_files->getState()); });
// Hidden games.
auto hidden_games = std::make_shared<SwitchComponent>(mWindow);
hidden_games->setState(Settings::getInstance()->getBool("ShowHiddenGames"));
s->addWithLabel("SHOW HIDDEN GAMES (REQUIRES RESTART)", hidden_games);
s->addSaveFunc([hidden_games] {
Settings::getInstance()->setBool("ShowHiddenGames",
hidden_games->getState());
});
// Custom event scripts, fired using Scripting::fireEvent(). // Custom event scripts, fired using Scripting::fireEvent().
auto custom_eventscripts = std::make_shared<SwitchComponent>(mWindow); auto custom_eventscripts = std::make_shared<SwitchComponent>(mWindow);
custom_eventscripts->setState(Settings::getInstance()->getBool("CustomEventScripts")); custom_eventscripts->setState(Settings::getInstance()->getBool("CustomEventScripts"));
@ -637,13 +653,6 @@ void GuiMenu::openOtherSettings()
s->addSaveFunc([local_art] { Settings::getInstance()-> s->addSaveFunc([local_art] { Settings::getInstance()->
setBool("LocalArt", local_art->getState()); }); setBool("LocalArt", local_art->getState()); });
// Hidden files.
auto hidden_files = std::make_shared<SwitchComponent>(mWindow);
hidden_files->setState(Settings::getInstance()->getBool("ShowHiddenFiles"));
s->addWithLabel("SHOW HIDDEN FILES AND FOLDERS (REQUIRES RESTART)", hidden_files);
s->addSaveFunc([hidden_files] { Settings::getInstance()->setBool("ShowHiddenFiles",
hidden_files->getState()); });
// Framerate. // Framerate.
auto framerate = std::make_shared<SwitchComponent>(mWindow); auto framerate = std::make_shared<SwitchComponent>(mWindow);
framerate->setState(Settings::getInstance()->getBool("DrawFramerate")); framerate->setState(Settings::getInstance()->getBool("DrawFramerate"));

View file

@ -26,6 +26,7 @@
#include "CollectionSystemManager.h" #include "CollectionSystemManager.h"
#include "FileData.h" #include "FileData.h"
#include "FileFilterIndex.h" #include "FileFilterIndex.h"
#include "Gamelist.h"
#include "SystemData.h" #include "SystemData.h"
#include "Window.h" #include "Window.h"
@ -283,10 +284,19 @@ void GuiMetaDataEd::save()
// Remove game from index. // Remove game from index.
mScraperParams.system->getIndex()->removeFromIndex(mScraperParams.game); mScraperParams.system->getIndex()->removeFromIndex(mScraperParams.game);
// We need this to handle the special situation where the user sets a game to hidden while
// ShowHiddenGames is set to false, meaning it will immediately disappear from the gamelist.
bool showHiddenGames = Settings::getInstance()->getBool("ShowHiddenGames");
bool hideGameWhileHidden = false;
for (unsigned int i = 0; i < mEditors.size(); i++) { for (unsigned int i = 0; i < mEditors.size(); i++) {
if (mMetaDataDecl.at(i).isStatistic) if (mMetaDataDecl.at(i).isStatistic)
continue; continue;
if (!showHiddenGames && mMetaDataDecl.at(i).key == "hidden" &&
mEditors.at(i)->getValue() != mMetaData->get("hidden"))
hideGameWhileHidden = true;
// If the user has entered a blank game name, then set the name to the ROM // If the user has entered a blank game name, then set the name to the ROM
// filename (minus the extension). // filename (minus the extension).
if (mMetaDataDecl.at(i).key == "name" && mEditors.at(i)->getValue() == "") { if (mMetaDataDecl.at(i).key == "name" && mEditors.at(i)->getValue() == "") {
@ -298,6 +308,14 @@ void GuiMetaDataEd::save()
} }
} }
// If hidden games are not shown and the hide flag was set for the game, then write the
// metadata immediately regardless of the SaveGamelistsMode setting. Otherwise the file
// will never be written as the game will be filtered from the gamelist. This solution is not
// really good as the gamelist will be written twice, but it's a very special and hopefully
// rare situation.
if (hideGameWhileHidden)
updateGamelist(mScraperParams.system);
// Enter game in index. // Enter game in index.
mScraperParams.system->getIndex()->addToIndex(mScraperParams.game); mScraperParams.system->getIndex()->addToIndex(mScraperParams.game);

View file

@ -232,6 +232,9 @@ bool parseArgs(int argc, char* argv[])
else if (strcmp(argv[i], "--show-hidden-files") == 0) { else if (strcmp(argv[i], "--show-hidden-files") == 0) {
Settings::getInstance()->setBool("ShowHiddenFiles", true); Settings::getInstance()->setBool("ShowHiddenFiles", true);
} }
else if (strcmp(argv[i], "--show-hidden-games") == 0) {
Settings::getInstance()->setBool("ShowHiddenGames", true);
}
else if (strcmp(argv[i], "--draw-framerate") == 0) { else if (strcmp(argv[i], "--draw-framerate") == 0) {
Settings::getInstance()->setBool("DrawFramerate", true); Settings::getInstance()->setBool("DrawFramerate", true);
} }
@ -263,6 +266,9 @@ bool parseArgs(int argc, char* argv[])
Settings::getInstance()->setBool("VSync", vsync); Settings::getInstance()->setBool("VSync", vsync);
i++; // Skip vsync value. i++; // Skip vsync value.
} }
else if (strcmp(argv[i], "--force-full") == 0) {
Settings::getInstance()->setString("UIMode", "Full");
}
else if (strcmp(argv[i], "--force-kiosk") == 0) { else if (strcmp(argv[i], "--force-kiosk") == 0) {
Settings::getInstance()->setBool("ForceKiosk", true); Settings::getInstance()->setBool("ForceKiosk", true);
} }
@ -286,6 +292,7 @@ bool parseArgs(int argc, char* argv[])
" --gamelist-only Skip automatic game ROM search, only read from gamelist.xml\n" " --gamelist-only Skip automatic game ROM search, only read from gamelist.xml\n"
" --ignore-gamelist Ignore the gamelist files (useful for troubleshooting)\n" " --ignore-gamelist Ignore the gamelist files (useful for troubleshooting)\n"
" --show-hidden-files Show hidden files and folders\n" " --show-hidden-files Show hidden files and folders\n"
" --show-hidden-games Show hidden games\n"
" --draw-framerate Display the framerate\n" " --draw-framerate Display the framerate\n"
" --no-exit Don't show the exit option in the menu\n" " --no-exit Don't show the exit option in the menu\n"
" --no-splash Don't show the splash screen\n" " --no-splash Don't show the splash screen\n"
@ -298,6 +305,7 @@ bool parseArgs(int argc, char* argv[])
" --vsync [1/on or 0/off] Turn vsync on or off (default is on)\n" " --vsync [1/on or 0/off] Turn vsync on or off (default is on)\n"
" --max-vram [size] Max VRAM to use in Mb before swapping\n" " --max-vram [size] Max VRAM to use in Mb before swapping\n"
" Set to at least 20 to avoid unpredictable behavior\n" " Set to at least 20 to avoid unpredictable behavior\n"
" --force-full Force the UI mode to Full\n"
" --force-kid Force the UI mode to Kid\n" " --force-kid Force the UI mode to Kid\n"
" --force-kiosk Force the UI mode to Kiosk\n" " --force-kiosk Force the UI mode to Kiosk\n"
" --force-disable-filters Force the UI to ignore applied filters in gamelist\n" " --force-disable-filters Force the UI to ignore applied filters in gamelist\n"

View file

@ -194,7 +194,8 @@ void Settings::setDefaults()
mBoolMap["CustomEventScripts"] = false; mBoolMap["CustomEventScripts"] = false;
mBoolMap["ParseGamelistOnly"] = false; mBoolMap["ParseGamelistOnly"] = false;
mBoolMap["LocalArt"] = false; mBoolMap["LocalArt"] = false;
mBoolMap["ShowHiddenFiles"] = false; mBoolMap["ShowHiddenFiles"] = true;
mBoolMap["ShowHiddenGames"] = true;
mBoolMap["DrawFramerate"] = false; mBoolMap["DrawFramerate"] = false;
mBoolMap["ShowRebootSystem"] = true; mBoolMap["ShowRebootSystem"] = true;
mBoolMap["ShowPoweroffSystem"] = true; mBoolMap["ShowPoweroffSystem"] = true;