Overhaul of settings code.

This commit is contained in:
Leon Styhre 2020-11-05 18:18:11 +01:00
parent ee943a3ae7
commit 1a6bec2e3b
29 changed files with 1186 additions and 741 deletions

View file

@ -836,7 +836,6 @@ You can use `--help` or `-h` to view a list of command line options, as shown he
--force-full Force the UI mode to Full --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-input-config Force configuration of input device --force-input-config Force configuration of input device
--home [path] Directory to use as home path --home [path] Directory to use as home path
--version, -v Displays version information --version, -v Displays version information
@ -860,7 +859,6 @@ You can use `--help` or `-h` to view a list of command line options, as shown he
--force-full Force the UI mode to Full --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-input-config Force configuration of input device --force-input-config Force configuration of input device
--home [path] Directory to use as home path --home [path] Directory to use as home path
--version, -v Displays version information --version, -v Displays version information
@ -884,7 +882,6 @@ You can use `--help` or `-h` to view a list of command line options, as shown he
--force-full Force the UI mode to Full --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-input-config Force configuration of input device --force-input-config Force configuration of input device
--home [path] Directory to use as home path --home [path] Directory to use as home path
--version, -v Displays version information --version, -v Displays version information

View file

@ -61,6 +61,7 @@ Many bugs have been fixed, and numerous features that were only partially implem
* Refactoring, cleanup and documentation of the source code, removal of deprecated files etc. * Refactoring, cleanup and documentation of the source code, removal of deprecated files etc.
* All required fonts bundled with the application, no dependencies on the OS to provide them any longer * All required fonts bundled with the application, no dependencies on the OS to provide them any longer
* Made pugixml an external dependency instead of bundling it * Made pugixml an external dependency instead of bundling it
* Overhaul of application settings, now the configuration file is only updated when there have been actual configuration changes
* Decreased CPU usage dramatically by only rendering the currently visible view (previously all views were always rendered) * Decreased CPU usage dramatically by only rendering the currently visible view (previously all views were always rendered)
* Updated the CMake/CPack install and package build script to work as expected (it can now generate .deb, .rpm, .dmg and NSIS installation packages) * Updated the CMake/CPack install and package build script to work as expected (it can now generate .deb, .rpm, .dmg and NSIS installation packages)
* Added support for Clang/LLVM, made the application build with no errors or warnings using this compiler (Unix and macOS only) * Added support for Clang/LLVM, made the application build with no errors or warnings using this compiler (Unix and macOS only)

View file

@ -468,7 +468,7 @@ JPG and PNG file formats and file extensions are supported.
Remember that on Unix files are case sensitive, and as well the file extensions must be in lower case, i.e. .png intead of .PNG or .Png or the file won't be found. Remember that on Unix files are case sensitive, and as well the file extensions must be in lower case, i.e. .png intead of .PNG or .Png or the file won't be found.
As an alternative, you can also locate your game media in the ROM directory. This is explained below in this guide under the option **Display game art from ROM directories**. This is however not recommended and the built-in scraper will never save any game media to this folder structure. As an alternative, you can also locate your game media in the ROM directory. This is explained below in this guide under the option **Display game media from ROM directories**. This is however not recommended and the built-in scraper will never save any game media to this folder structure.
Note that it's possible to change the game media directory from within ES, see the option **Game media directory** detailed below. Note that it's possible to change the game media directory from within ES, see the option **Game media directory** detailed below.
@ -671,7 +671,7 @@ Options specific to the slideshow screensaver.
**Swap images after (secs)** **Swap images after (secs)**
How long to show images before change to the next game. How long to play videos before changing to the next game. Allowed range is between 5 and 120 seconds.
**Stretch images to screen resolution** **Stretch images to screen resolution**
@ -707,7 +707,7 @@ Options specific to the video screensaver.
**Swap videos after (secs)** **Swap videos after (secs)**
How long to play videos before change to the next game. How long to play videos before changing to the next game. Allowed range is between 5 and 120 seconds.
**Stretch videos to screen resolution** **Stretch videos to screen resolution**
@ -791,10 +791,6 @@ The amount of video RAM to use for the application. Defaults to 128 MiB which se
This gives you a choice between Normal and Borderless modes. With the borderless being more seamless as the ES window will always stay on top of other windows so the taskbar will not be visible when launching and returning from games. It will however break the alt-tab application switching of your window manager. For normal fullscreen mode, if a lower resolution than the screen resolution has been set via the --resolution command line argument, ES will render in full screen at the lower resolution. If a higher resolution than the screen resolution has been set, ES will run in a window. For the borderless mode, any changes to the resolution will make ES run in a window. This gives you a choice between Normal and Borderless modes. With the borderless being more seamless as the ES window will always stay on top of other windows so the taskbar will not be visible when launching and returning from games. It will however break the alt-tab application switching of your window manager. For normal fullscreen mode, if a lower resolution than the screen resolution has been set via the --resolution command line argument, ES will render in full screen at the lower resolution. If a higher resolution than the screen resolution has been set, ES will run in a window. For the borderless mode, any changes to the resolution will make ES run in a window.
**Power saver modes**
Can be set to Disabled, Default, Enhanced or Instant. Set to Disabled by default.
**When to save metadata** **When to save metadata**
The metadata for a game is updated both by scraping and modifying data in the metadata editor, but also when launching a game, as the play count and last played date is then updated. This setting enables you to define when to write such metadata changes to the gamelist.xml files. Setting the option to "Never" will disable writing to these files altogether, except for some special conditions such as when a game is manually deleted using the metadata editor, or when scraping using the multi-scraper (the multi-scraper will always save any updates immediately to the gamelist.xml files). In theory "On exit" will give some performance gains, but it's normally recommended to leave the setting at its default value which is "Always". Note that with the settings set to "Never", any updates such as the last played date will still be shown on screen, however during the next application startup, any values previously saved to the gamelist.xml files will be read in again. As well, when changing this setting to "Always" from either of the two other options, any pending changes will be immediately written to the gamelist.xml files. The metadata for a game is updated both by scraping and modifying data in the metadata editor, but also when launching a game, as the play count and last played date is then updated. This setting enables you to define when to write such metadata changes to the gamelist.xml files. Setting the option to "Never" will disable writing to these files altogether, except for some special conditions such as when a game is manually deleted using the metadata editor, or when scraping using the multi-scraper (the multi-scraper will always save any updates immediately to the gamelist.xml files). In theory "On exit" will give some performance gains, but it's normally recommended to leave the setting at its default value which is "Always". Note that with the settings set to "Never", any updates such as the last played date will still be shown on screen, however during the next application startup, any values previously saved to the gamelist.xml files will be read in again. As well, when changing this setting to "Always" from either of the two other options, any pending changes will be immediately written to the gamelist.xml files.
@ -823,9 +819,9 @@ It's possible to trigger custom scripts for a number of actions in ES. _(Details
If enabled, only ROMs that have metadata saved to the gamelist.xml files will be shown in ES. This option is intended primarily for testing and debugging purposes so it should normally not be enabled. If enabled, only ROMs that have metadata saved to the gamelist.xml files will be shown in ES. This option is intended primarily for testing and debugging purposes so it should normally not be enabled.
**Display game art from ROM directories** **Display game media from ROM directories**
Using this option, you can locate game images in the ROM directory tree. The images are searched inside the directory "\<ROM directory\>/\<system name\>/images/" and the filenames must be the same as the ROM names, followed by a dash and the image type. For example "~/ROMs/nes/images/Contra-screenshot.jpg" and "~/ROMs/nes/images/Contra-marquee.jpg". This option is mostly intended for legacy purposes, if you have an existing game collection with this media setup that you would like to open in ES. The scraper will never save files to this directory structure and will instead use the standard media directory logic. It's recommended to keep this option disabled unless you really need it since it slows down the application somewhat. Using this option, you can place game images and videos in the ROM directory tree. The media files are searched inside the directory "\<ROM directory\>/\<system name\>/images/" and "\<ROM directory\>/\<system name\>/videos/" and the filenames must be the same as the ROM names, followed by a dash and the media type. For example "~/ROMs/nes/images/Contra-screenshot.jpg", "~/ROMs/nes/images/Contra-marquee.jpg" and "~/ROMs/nes/videos/Contra-video.jpg". This option is mostly intended for legacy purposes, if you have an existing game collection with this media setup that you would like to open in ES. The scraper will never save files to this directory structure and will instead use the standard media directory logic. It's recommended to keep this option disabled unless you really need it since it slows down the application somewhat.
**Display GPU statistics overlay** **Display GPU statistics overlay**

View file

@ -213,7 +213,7 @@ const std::string FileData::getMediafilePath(std::string subdirectory, std::stri
// No media found in the media directory, so look // No media found in the media directory, so look
// for local art as well (if configured to do so). // for local art as well (if configured to do so).
if (Settings::getInstance()->getBool("LocalArt")) { if (Settings::getInstance()->getBool("ROMDirGameMedia")) {
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
std::string localMediaPath = mEnvData->mStartPath + "/images/" + std::string localMediaPath = mEnvData->mStartPath + "/images/" +
getDisplayName() + "-" + mediatype + extList[i]; getDisplayName() + "-" + mediatype + extList[i];
@ -285,7 +285,7 @@ const std::string FileData::getVideoPath() const
// No media found in the media directory, so look // No media found in the media directory, so look
// for local art as well (if configured to do so). // for local art as well (if configured to do so).
if (Settings::getInstance()->getBool("LocalArt")) if (Settings::getInstance()->getBool("ROMDirGameMedia"))
{ {
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
std::string localMediaPath = mEnvData->mStartPath + "/videos/" + std::string localMediaPath = mEnvData->mStartPath + "/videos/" +

View file

@ -288,7 +288,7 @@ void FileFilterIndex::resetFilters()
void FileFilterIndex::setUIModeFilters() void FileFilterIndex::setUIModeFilters()
{ {
if (!Settings::getInstance()->getBool("ForceDisableFilters")){ if (Settings::getInstance()->getBool("GamelistFilters")){
if (UIModeController::getInstance()->isUIModeKiosk()) { if (UIModeController::getInstance()->isUIModeKiosk()) {
filterByHidden = true; filterByHidden = true;
std::vector<std::string> val = { "FALSE" }; std::vector<std::string> val = { "FALSE" };

View file

@ -619,14 +619,15 @@ FileData* SystemData::getRandomGame(const FileData* currentGame)
return gameList.at(target); return gameList.at(target);
} }
void SystemData::sortSystem(bool reloadGamelist) void SystemData::sortSystem(bool reloadGamelist, bool jumpToFirstRow)
{ {
if (getName() == "recent") if (getName() == "recent")
return; return;
bool favoritesSorting; bool favoritesSorting;
if (this->isCustomCollection()) if (this->isCustomCollection() ||
(this->isCollection() && this->getFullName() == "collections"))
favoritesSorting = Settings::getInstance()->getBool("FavFirstCustom"); favoritesSorting = Settings::getInstance()->getBool("FavFirstCustom");
else else
favoritesSorting = Settings::getInstance()->getBool("FavoritesFirst"); favoritesSorting = Settings::getInstance()->getBool("FavoritesFirst");
@ -646,6 +647,11 @@ void SystemData::sortSystem(bool reloadGamelist)
if (reloadGamelist) if (reloadGamelist)
ViewController::get()->reloadGameListView(this, false); ViewController::get()->reloadGameListView(this, false);
if (jumpToFirstRow) {
IGameListView* gameList = ViewController::get()->getGameListView(this).get();
gameList->setCursor(gameList->getFirstEntry());
}
} }
std::pair<unsigned int, unsigned int> SystemData::getDisplayedGameCount() const std::pair<unsigned int, unsigned int> SystemData::getDisplayedGameCount() const

View file

@ -95,7 +95,7 @@ public:
static SystemData* getRandomSystem(const SystemData* currentSystem); static SystemData* getRandomSystem(const SystemData* currentSystem);
FileData* getRandomGame(const FileData* currentGame = nullptr); FileData* getRandomGame(const FileData* currentGame = nullptr);
void sortSystem(bool reloadGamelist = true); void sortSystem(bool reloadGamelist = true, bool jumpToFirstRow = false);
// Load or re-load theme. // Load or re-load theme.
void loadTheme(); void loadTheme();

View file

@ -74,7 +74,7 @@ bool SystemScreenSaver::isScreenSaverActive()
void SystemScreenSaver::startScreenSaver() void SystemScreenSaver::startScreenSaver()
{ {
std::string screensaver_behavior = Settings::getInstance()->getString("ScreenSaverBehavior"); std::string screensaver_behavior = Settings::getInstance()->getString("ScreensaverBehavior");
// Set mPreviousGame which will be used to avoid showing the same game again during // Set mPreviousGame which will be used to avoid showing the same game again during
// the random selection. // the random selection.
@ -86,7 +86,7 @@ void SystemScreenSaver::startScreenSaver()
// Configure to fade out the windows, skip fading if mode is set to Instant. // Configure to fade out the windows, skip fading if mode is set to Instant.
mState = PowerSaver::getMode() == mState = PowerSaver::getMode() ==
PowerSaver::INSTANT ? STATE_SCREENSAVER_ACTIVE : STATE_FADE_OUT_WINDOW; PowerSaver::INSTANT ? STATE_SCREENSAVER_ACTIVE : STATE_FADE_OUT_WINDOW;
mVideoChangeTime = Settings::getInstance()->getInt("ScreenSaverSwapVideoTimeout"); mVideoChangeTime = Settings::getInstance()->getInt("ScreensaverSwapVideoTimeout");
mOpacity = 0.0f; mOpacity = 0.0f;
// Load a random video. // Load a random video.
@ -103,7 +103,7 @@ void SystemScreenSaver::startScreenSaver()
if (!path.empty() && Utils::FileSystem::exists(path)) { if (!path.empty() && Utils::FileSystem::exists(path)) {
#if defined(_RPI_) #if defined(_RPI_)
// Create the correct type of video component // Create the correct type of video component
if (Settings::getInstance()->getBool("ScreenSaverOmxPlayer")) if (Settings::getInstance()->getBool("ScreensaverOmxPlayer"))
mVideoScreensaver = new VideoPlayerComponent(mWindow); mVideoScreensaver = new VideoPlayerComponent(mWindow);
else else
mVideoScreensaver = new VideoVlcComponent(mWindow); mVideoScreensaver = new VideoVlcComponent(mWindow);
@ -116,7 +116,7 @@ void SystemScreenSaver::startScreenSaver()
mVideoScreensaver->setPosition(Renderer::getScreenWidth() / 2.0f, mVideoScreensaver->setPosition(Renderer::getScreenWidth() / 2.0f,
Renderer::getScreenHeight() / 2.0f); Renderer::getScreenHeight() / 2.0f);
if (Settings::getInstance()->getBool("ScreenSaverStretchVideos")) if (Settings::getInstance()->getBool("ScreensaverStretchVideos"))
mVideoScreensaver->setResize(static_cast<float>(Renderer::getScreenWidth()), mVideoScreensaver->setResize(static_cast<float>(Renderer::getScreenWidth()),
static_cast<float>(Renderer::getScreenHeight())); static_cast<float>(Renderer::getScreenHeight()));
else else
@ -135,12 +135,12 @@ void SystemScreenSaver::startScreenSaver()
// Configure to fade out the windows, skip fading if mode is set to Instant. // Configure to fade out the windows, skip fading if mode is set to Instant.
mState = PowerSaver::getMode() == mState = PowerSaver::getMode() ==
PowerSaver::INSTANT ? STATE_SCREENSAVER_ACTIVE : STATE_FADE_OUT_WINDOW; PowerSaver::INSTANT ? STATE_SCREENSAVER_ACTIVE : STATE_FADE_OUT_WINDOW;
mVideoChangeTime = Settings::getInstance()->getInt("ScreenSaverSwapImageTimeout"); mVideoChangeTime = Settings::getInstance()->getInt("ScreensaverSwapImageTimeout");
mOpacity = 0.0f; mOpacity = 0.0f;
// Load a random image. // Load a random image.
std::string path = ""; std::string path = "";
if (Settings::getInstance()->getBool("SlideshowScreenSaverCustomImageSource")) { if (Settings::getInstance()->getBool("ScreensaverSlideshowCustomImages")) {
pickRandomCustomImage(path); pickRandomCustomImage(path);
// Custom images are not tied to the game list. // Custom images are not tied to the game list.
mCurrentGame = nullptr; mCurrentGame = nullptr;
@ -159,7 +159,7 @@ void SystemScreenSaver::startScreenSaver()
mImageScreensaver->setPosition(Renderer::getScreenWidth() / 2.0f, mImageScreensaver->setPosition(Renderer::getScreenWidth() / 2.0f,
Renderer::getScreenHeight() / 2.0f); Renderer::getScreenHeight() / 2.0f);
if (Settings::getInstance()->getBool("ScreenSaverStretchImages")) if (Settings::getInstance()->getBool("ScreensaverStretchImages"))
mImageScreensaver->setResize(static_cast<float>(Renderer::getScreenWidth()), mImageScreensaver->setResize(static_cast<float>(Renderer::getScreenWidth()),
static_cast<float>(Renderer::getScreenHeight())); static_cast<float>(Renderer::getScreenHeight()));
else else
@ -167,7 +167,7 @@ void SystemScreenSaver::startScreenSaver()
static_cast<float>(Renderer::getScreenHeight())); static_cast<float>(Renderer::getScreenHeight()));
std::string bg_audio_file = Settings::getInstance()-> std::string bg_audio_file = Settings::getInstance()->
getString("SlideshowScreenSaverBackgroundAudioFile"); getString("ScreensaverSlideshowAudioFile");
if ((!mBackgroundAudio) && (bg_audio_file != "")) { if ((!mBackgroundAudio) && (bg_audio_file != "")) {
if (Utils::FileSystem::exists(bg_audio_file)) { if (Utils::FileSystem::exists(bg_audio_file)) {
// Pause PowerSaver so that the background audio keeps playing. // Pause PowerSaver so that the background audio keeps playing.
@ -210,7 +210,7 @@ void SystemScreenSaver::stopScreenSaver()
void SystemScreenSaver::renderScreenSaver() void SystemScreenSaver::renderScreenSaver()
{ {
std::string screensaver_behavior = Settings::getInstance()->getString("ScreenSaverBehavior"); std::string screensaver_behavior = Settings::getInstance()->getString("ScreensaverBehavior");
if (mVideoScreensaver && screensaver_behavior == "video") { if (mVideoScreensaver && screensaver_behavior == "video") {
// Render black background. // Render black background.
Renderer::setMatrix(Transform4x4f::Identity()); Renderer::setMatrix(Transform4x4f::Identity());
@ -241,7 +241,7 @@ void SystemScreenSaver::renderScreenSaver()
// Check if we need to restart the background audio. // Check if we need to restart the background audio.
if ((mBackgroundAudio) && (Settings::getInstance()-> if ((mBackgroundAudio) && (Settings::getInstance()->
getString("SlideshowScreenSaverBackgroundAudioFile") != "")) { getString("ScreensaverSlideshowAudioFile") != "")) {
if (!mBackgroundAudio->isPlaying()) if (!mBackgroundAudio->isPlaying())
mBackgroundAudio->play(); mBackgroundAudio->play();
} }
@ -377,14 +377,13 @@ void SystemScreenSaver::pickRandomGameListImage(std::string& path)
void SystemScreenSaver::pickRandomCustomImage(std::string& path) void SystemScreenSaver::pickRandomCustomImage(std::string& path)
{ {
std::string imageDir = Settings::getInstance()->getString("SlideshowScreenSaverImageDir"); std::string imageDir = Settings::getInstance()->getString("ScreensaverSlideshowImageDir");
if ((imageDir != "") && (Utils::FileSystem::exists(imageDir))) { if ((imageDir != "") && (Utils::FileSystem::exists(imageDir))) {
std::string imageFilter = Settings::getInstance()-> std::string imageFilter = ".jpg, .JPG, .png, .PNG";
getString("SlideshowScreenSaverImageFilter");
std::vector<std::string> matchingFiles; std::vector<std::string> matchingFiles;
Utils::FileSystem::stringList dirContent = Utils::FileSystem::getDirContent( Utils::FileSystem::stringList dirContent = Utils::FileSystem::getDirContent(
imageDir, Settings::getInstance()->getBool("SlideshowScreenSaverRecurse")); imageDir, Settings::getInstance()->getBool("ScreensaverSlideshowRecurse"));
for (Utils::FileSystem::stringList::const_iterator it = dirContent.cbegin(); for (Utils::FileSystem::stringList::const_iterator it = dirContent.cbegin();
it != dirContent.cend(); ++it) { it != dirContent.cend(); ++it) {

View file

@ -133,8 +133,7 @@ GuiGamelistOptions::GuiGamelistOptions(
// Add the filters entry, unless this is the grouped custom collections list. // Add the filters entry, unless this is the grouped custom collections list.
if (!isCustomCollectionGroup) { if (!isCustomCollectionGroup) {
if (system->getName() != "recent" && if (system->getName() != "recent" && Settings::getInstance()->getBool("GamelistFilters")) {
!Settings::getInstance()->getBool("ForceDisableFilters")) {
row.elements.clear(); row.elements.clear();
row.addElement(std::make_shared<TextComponent> row.addElement(std::make_shared<TextComponent>
(mWindow, "FILTER GAMELIST", Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true); (mWindow, "FILTER GAMELIST", Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true);

View file

@ -4,7 +4,6 @@
// GuiGeneralScreensaverOptions.cpp // GuiGeneralScreensaverOptions.cpp
// //
// User interface for the screensaver options. // User interface for the screensaver options.
// Based on the GuiScreenSaverOptions template.
// Submenu to the GuiMenu main menu. // Submenu to the GuiMenu main menu.
// //
@ -14,30 +13,38 @@
#include "components/SliderComponent.h" #include "components/SliderComponent.h"
#include "components/SwitchComponent.h" #include "components/SwitchComponent.h"
#include "guis/GuiMsgBox.h" #include "guis/GuiMsgBox.h"
#include "guis/GuiSlideshowScreensaverOptions.h"
#include "guis/GuiVideoScreensaverOptions.h"
#include "Settings.h" #include "Settings.h"
GuiGeneralScreensaverOptions::GuiGeneralScreensaverOptions(Window* window, const char* title) GuiGeneralScreensaverOptions::GuiGeneralScreensaverOptions(Window* window, const char* title)
: GuiScreensaverOptions(window, title) : GuiSettings(window, title)
{ {
// Screensaver time. // Screensaver timer.
auto screensaver_time = std::make_shared<SliderComponent>(mWindow, 0.f, 30.f, 1.f, "m"); auto screensaver_time = std::make_shared<SliderComponent>(mWindow, 0.f, 30.f, 1.f, "m");
screensaver_time->setValue((float)(Settings::getInstance()-> screensaver_time->setValue(static_cast<float>(Settings::getInstance()->
getInt("ScreenSaverTime") / (1000 * 60))); getInt("ScreensaverTimer") / (1000 * 60)));
addWithLabel("SCREENSAVER AFTER", screensaver_time); addWithLabel("SCREENSAVER AFTER", screensaver_time);
addSaveFunc([screensaver_time] { addSaveFunc([screensaver_time, this] {
Settings::getInstance()->setInt("ScreenSaverTime", if (static_cast<int>(Math::round(screensaver_time->getValue()) * (1000 * 60)) !=
(int)Math::round(screensaver_time->getValue()) * (1000 * 60)); Settings::getInstance()->getInt("ScreensaverTimer")) {
PowerSaver::updateTimeouts(); Settings::getInstance()->setInt("ScreensaverTimer",
static_cast<int>(Math::round(screensaver_time->getValue()) * (1000 * 60)));
PowerSaver::updateTimeouts();
setNeedsSaving();
}
}); });
// Allow ScreenSaver Controls - ScreenSaverControls. // Whether to enable screensaver controls.
auto ss_controls = std::make_shared<SwitchComponent>(mWindow); auto screensaver_controls = std::make_shared<SwitchComponent>(mWindow);
ss_controls->setState(Settings::getInstance()->getBool("ScreenSaverControls")); screensaver_controls->setState(Settings::getInstance()->getBool("ScreensaverControls"));
addWithLabel("SCREENSAVER CONTROLS", ss_controls); addWithLabel("SCREENSAVER CONTROLS", screensaver_controls);
addSaveFunc([ss_controls] { Settings::getInstance()->setBool("ScreenSaverControls", addSaveFunc([screensaver_controls, this] {
ss_controls->getState()); }); if (screensaver_controls->getState() !=
Settings::getInstance()->getBool("ScreensaverControls")) {
Settings::getInstance()->setBool("ScreensaverControls",
screensaver_controls->getState());
setNeedsSaving();
}
});
// Screensaver behavior. // Screensaver behavior.
auto screensaver_behavior = std::make_shared<OptionListComponent<std::string>> auto screensaver_behavior = std::make_shared<OptionListComponent<std::string>>
@ -49,20 +56,24 @@ GuiGeneralScreensaverOptions::GuiGeneralScreensaverOptions(Window* window, const
screensavers.push_back("video"); screensavers.push_back("video");
for (auto it = screensavers.cbegin(); it != screensavers.cend(); it++) for (auto it = screensavers.cbegin(); it != screensavers.cend(); it++)
screensaver_behavior->add(*it, *it, Settings::getInstance()-> screensaver_behavior->add(*it, *it, Settings::getInstance()->
getString("ScreenSaverBehavior") == *it); getString("ScreensaverBehavior") == *it);
addWithLabel("SCREENSAVER BEHAVIOR", screensaver_behavior); addWithLabel("SCREENSAVER BEHAVIOR", screensaver_behavior);
addSaveFunc([this, screensaver_behavior] { addSaveFunc([screensaver_behavior, this] {
if (Settings::getInstance()->getString("ScreenSaverBehavior") != if (screensaver_behavior->getSelected() !=
"video" && screensaver_behavior->getSelected() == "video") { Settings::getInstance()->getString("ScreensaverBehavior")) {
// If before it wasn't risky but now there's a risk of problems, show warning. if (screensaver_behavior->getSelected() == "video") {
mWindow->pushGui(new GuiMsgBox(mWindow, getHelpStyle(), // If before it wasn't risky but now there's a risk of problems, show warning.
"THE \"VIDEO\" SCREENSAVER SHOWS\nVIDEOS FROM YOUR GAMELISTS.\n\nIF YOU DO NOT " mWindow->pushGui(new GuiMsgBox(mWindow, getHelpStyle(),
"HAVE ANY VIDEOS, THE\nSCREENSAVER WILL DEFAULT TO \"BLACK\"", "THE \"VIDEO\" SCREENSAVER SHOWS\nVIDEOS FROM YOUR GAMELISTS.\n\n"
"OK", [] { return; }, "", nullptr, "", nullptr)); "IF YOU DO NOT HAVE ANY VIDEOS, THE\n"
"SCREENSAVER WILL DEFAULT TO \"BLACK\"",
"OK", [] { return; }, "", nullptr, "", nullptr));
}
Settings::getInstance()->setString("ScreensaverBehavior",
screensaver_behavior->getSelected());
setNeedsSaving();
PowerSaver::updateTimeouts();
} }
Settings::getInstance()->setString("ScreenSaverBehavior",
screensaver_behavior->getSelected());
PowerSaver::updateTimeouts();
}); });
ComponentListRow row; ComponentListRow row;
@ -85,14 +96,250 @@ GuiGeneralScreensaverOptions::GuiGeneralScreensaverOptions(Window* window, const
addRow(row); addRow(row);
} }
GuiGeneralScreensaverOptions::~GuiGeneralScreensaverOptions() void GuiGeneralScreensaverOptions::openSlideshowScreensaverOptions()
{ {
auto s = new GuiSettings(mWindow, "SLIDESHOW SCREENSAVER");
// Timer for swapping images (in seconds).
auto screensaver_swap_image_timeout =
std::make_shared<SliderComponent>(mWindow, 5.f, 120.f, 1.f, "s");
screensaver_swap_image_timeout->setValue(static_cast<float>(Settings::getInstance()->
getInt("ScreensaverSwapImageTimeout") / (1000)));
s->addWithLabel("SWAP IMAGE AFTER (SECS)", screensaver_swap_image_timeout);
s->addSaveFunc([screensaver_swap_image_timeout, s] {
if (screensaver_swap_image_timeout->getValue() !=
static_cast<float>(Settings::getInstance()->
getInt("ScreensaverSwapImageTimeout") / (1000))) {
Settings::getInstance()->setInt("ScreensaverSwapImageTimeout",
static_cast<int>(Math::round(screensaver_swap_image_timeout->getValue()) *
(1000)));
s->setNeedsSaving();
PowerSaver::updateTimeouts();
}
});
// Stretch images to screen resolution.
auto screensaver_stretch_images = std::make_shared<SwitchComponent>(mWindow);
screensaver_stretch_images->
setState(Settings::getInstance()->getBool("ScreensaverStretchImages"));
s->addWithLabel("STRETCH IMAGES TO SCREEN RESOLUTION", screensaver_stretch_images);
s->addSaveFunc([screensaver_stretch_images, s] {
if (screensaver_stretch_images->getState() !=
Settings::getInstance()->getBool("ScreensaverStretchImages")) {
Settings::getInstance()->setBool("ScreensaverStretchImages",
screensaver_stretch_images->getState());
s->setNeedsSaving();
}
});
#if defined(USE_OPENGL_21)
// Render scanlines using a shader.
auto screensaver_image_scanlines = std::make_shared<SwitchComponent>(mWindow);
screensaver_image_scanlines->
setState(Settings::getInstance()->getBool("ScreensaverImageScanlines"));
s->addWithLabel("RENDER SCANLINES", screensaver_image_scanlines);
s->addSaveFunc([screensaver_image_scanlines, s] {
if (screensaver_image_scanlines->getState() !=
Settings::getInstance()->getBool("ScreensaverImageScanlines")) {
Settings::getInstance()->
setBool("ScreensaverImageScanlines", screensaver_image_scanlines->getState());
s->setNeedsSaving();
}
});
#endif
// Background audio file.
auto screensaver_slideshow_audio_file = std::make_shared<TextComponent>(mWindow, "",
Font::get(FONT_SIZE_SMALL), 0x777777FF, ALIGN_RIGHT);
s->addEditableTextComponent("BACKGROUND AUDIO", screensaver_slideshow_audio_file,
Settings::getInstance()->getString("ScreensaverSlideshowAudioFile"),
"~/.emulationstation/slideshow/audio/slideshow.wav");
s->addSaveFunc([screensaver_slideshow_audio_file, s] {
if (screensaver_slideshow_audio_file->getValue() !=
Settings::getInstance()->getString("ScreensaverSlideshowAudioFile")) {
Settings::getInstance()->setString("ScreensaverSlideshowAudioFile",
screensaver_slideshow_audio_file->getValue());
s->setNeedsSaving();
}
});
// Whether to use custom images.
auto screensaver_slideshow_custom_images = std::make_shared<SwitchComponent>(mWindow);
screensaver_slideshow_custom_images->setState(Settings::getInstance()->
getBool("ScreensaverSlideshowCustomImages"));
s->addWithLabel("USE CUSTOM IMAGES", screensaver_slideshow_custom_images);
s->addSaveFunc([screensaver_slideshow_custom_images, s] {
if (screensaver_slideshow_custom_images->getState() !=
Settings::getInstance()->getBool("ScreensaverSlideshowCustomImages")) {
Settings::getInstance()->setBool("ScreensaverSlideshowCustomImages",
screensaver_slideshow_custom_images->getState());
s->setNeedsSaving();
}
});
// Custom image directory.
auto screensaver_slideshow_image_dir = std::make_shared<TextComponent>(mWindow, "",
Font::get(FONT_SIZE_SMALL), 0x777777FF, ALIGN_RIGHT);
s->addEditableTextComponent("CUSTOM IMAGE DIR", screensaver_slideshow_image_dir,
Settings::getInstance()->getString("ScreensaverSlideshowImageDir"),
"~/.emulationstation/slideshow/custom_images");
s->addSaveFunc([screensaver_slideshow_image_dir, s] {
if (screensaver_slideshow_image_dir->getValue() !=
Settings::getInstance()->getString("ScreensaverSlideshowImageDir")) {
Settings::getInstance()->setString("ScreensaverSlideshowImageDir",
screensaver_slideshow_image_dir->getValue());
s->setNeedsSaving();
}
});
// Whether to recurse the custom image directory.
auto screensaver_slideshow_recurse = std::make_shared<SwitchComponent>(mWindow);
screensaver_slideshow_recurse->setState(Settings::getInstance()->
getBool("ScreensaverSlideshowRecurse"));
s->addWithLabel("CUSTOM IMAGE DIR RECURSIVE", screensaver_slideshow_recurse);
s->addSaveFunc([screensaver_slideshow_recurse, s] {
if (screensaver_slideshow_recurse->getState() !=
Settings::getInstance()->getBool("ScreensaverSlideshowRecurse")) {
Settings::getInstance()->setBool("ScreensaverSlideshowRecurse",
screensaver_slideshow_recurse->getState());
s->setNeedsSaving();
}
});
mWindow->pushGui(s);
} }
void GuiGeneralScreensaverOptions::openVideoScreensaverOptions() { void GuiGeneralScreensaverOptions::openVideoScreensaverOptions()
mWindow->pushGui(new GuiVideoScreensaverOptions(mWindow, "VIDEO SCREENSAVER")); {
} auto s = new GuiSettings(mWindow, "VIDEO SCREENSAVER");
void GuiGeneralScreensaverOptions::openSlideshowScreensaverOptions() { // Timer for swapping videos (in seconds).
mWindow->pushGui(new GuiSlideshowScreensaverOptions(mWindow, "SLIDESHOW SCREENSAVER")); auto screensaver_swap_video_timeout =
std::make_shared<SliderComponent>(mWindow, 5.f, 120.f, 1.f, "s");
screensaver_swap_video_timeout->setValue(static_cast<float>(Settings::getInstance()->
getInt("ScreensaverSwapVideoTimeout") / (1000)));
s->addWithLabel("SWAP VIDEO AFTER (SECS)", screensaver_swap_video_timeout);
s->addSaveFunc([screensaver_swap_video_timeout,s ] {
if (screensaver_swap_video_timeout->getValue() !=
static_cast<float>(Settings::getInstance()->
getInt("ScreensaverSwapVideoTimeout") / (1000))) {
Settings::getInstance()->setInt("ScreensaverSwapVideoTimeout",
static_cast<int>(Math::round(screensaver_swap_video_timeout->getValue()) *
(1000)));
s->setNeedsSaving();
PowerSaver::updateTimeouts();
}
});
// Stretch videos to screen resolution.
auto screensaver_stretch_videos = std::make_shared<SwitchComponent>(mWindow);
screensaver_stretch_videos->
setState(Settings::getInstance()->getBool("ScreensaverStretchVideos"));
s->addWithLabel("STRETCH VIDEOS TO SCREEN RESOLUTION", screensaver_stretch_videos);
s->addSaveFunc([screensaver_stretch_videos, s] {
if (screensaver_stretch_videos->getState() !=
Settings::getInstance()->getBool("ScreensaverStretchVideos")) {
Settings::getInstance()->setBool("ScreensaverStretchVideos",
screensaver_stretch_videos->getState());
s->setNeedsSaving();
}
});
#if defined(_RPI_)
auto screensaver_omx_player = std::make_shared<SwitchComponent>(mWindow);
screensaver_omx_player->setState(Settings::getInstance()->getBool("ScreensaverOmxPlayer"));
s->addWithLabel("USE OMX PLAYER FOR SCREENSAVER", screensaver_omx_player);
s->addSaveFunc([screensaver_omx_player, s] {
if (screensaver_omx_player->getState() !=
Settings::getInstance()->getBool("ScreensaverOmxPlayer")) {
Settings::getInstance()->
setBool("ScreensaverOmxPlayer", screensaver_omx_player->getState());
s->setNeedsSaving();
}
});
// TEMPORARY - Disabled for now, need to find a proper way to make an overlay on top of
// the videos. The solution with rendering subtitles is not a good solution.
// And as well the VLC video player subtitles seem to be somehow broken.
// Render video game name as subtitles.
// auto ss_info = std::make_shared<OptionListComponent<std::string>>
// (mWindow,getHelpStyle(), "SHOW GAME INFO", false);
// std::vector<std::string> info_type;
// info_type.push_back("always");
// info_type.push_back("start & end");
// info_type.push_back("never");
// for (auto it = info_type.cbegin(); it != info_type.cend(); it++)
// ss_info->add(*it, *it, Settings::getInstance()->getString("ScreensaverGameInfo") == *it);
// addWithLabel("SHOW GAME INFO ON SCREENSAVER", ss_info);
// addSaveFunc([ss_info, this] { Settings::getInstance()->
// setString("ScreensaverGameInfo", ss_info->getSelected()); });
// ComponentListRow row;
// Set subtitle position.
// auto ss_omx_subs_align = std::make_shared<OptionListComponent<std::string>>
// (mWindow, getHelpStyle(), "GAME INFO ALIGNMENT", false);
// std::vector<std::string> align_mode;
// align_mode.push_back("left");
// align_mode.push_back("center");
// for (auto it = align_mode.cbegin(); it != align_mode.cend(); it++)
// ss_omx_subs_align->add(*it, *it, Settings::getInstance()->
// getString("SubtitleAlignment") == *it);
// addWithLabel("GAME INFO ALIGNMENT", ss_omx_subs_align);
// addSaveFunc([ss_omx_subs_align, this] { Settings::getInstance()->
// setString("SubtitleAlignment", ss_omx_subs_align->getSelected()); });
// Set font size.
// auto ss_omx_font_size = std::make_shared<SliderComponent>(mWindow, 1.f, 64.f, 1.f, "h");
// ss_omx_font_size->setValue((float)(Settings::getInstance()->getInt("SubtitleSize")));
// addWithLabel("GAME INFO FONT SIZE", ss_omx_font_size);
// addSaveFunc([ss_omx_font_size] {
// int subSize = (int)Math::round(ss_omx_font_size->getValue());
// Settings::getInstance()->setInt("SubtitleSize", subSize);
// });
#endif
auto screensaver_video_audio = std::make_shared<SwitchComponent>(mWindow);
screensaver_video_audio->setState(Settings::getInstance()->getBool("ScreensaverVideoAudio"));
s->addWithLabel("PLAY AUDIO FOR SCREENSAVER VIDEO FILES", screensaver_video_audio);
s->addSaveFunc([screensaver_video_audio, s] {
if (screensaver_video_audio->getState() !=
Settings::getInstance()->getBool("ScreensaverVideoAudio")) {
Settings::getInstance()->setBool("ScreensaverVideoAudio",
screensaver_video_audio->getState());
s->setNeedsSaving();
}
});
#if defined(USE_OPENGL_21)
// Render scanlines using a shader.
auto screensaver_video_scanlines = std::make_shared<SwitchComponent>(mWindow);
screensaver_video_scanlines->
setState(Settings::getInstance()->getBool("ScreensaverVideoScanlines"));
s->addWithLabel("RENDER SCANLINES", screensaver_video_scanlines);
s->addSaveFunc([screensaver_video_scanlines, s] {
if (screensaver_video_scanlines->getState() !=
Settings::getInstance()->getBool("ScreensaverVideoScanlines")) {
Settings::getInstance()->setBool("ScreensaverVideoScanlines",
screensaver_video_scanlines->getState());
s->setNeedsSaving();
}
});
// Render blur using a shader.
auto screensaver_video_blur = std::make_shared<SwitchComponent>(mWindow);
screensaver_video_blur->setState(Settings::getInstance()->getBool("ScreensaverVideoBlur"));
s->addWithLabel("RENDER BLUR", screensaver_video_blur);
s->addSaveFunc([screensaver_video_blur, s] {
if (screensaver_video_blur->getState() !=
Settings::getInstance()->getBool("ScreensaverVideoBlur")) {
Settings::getInstance()->setBool("ScreensaverVideoBlur",
screensaver_video_blur->getState());
s->setNeedsSaving();
}
});
#endif
mWindow->pushGui(s);
} }

View file

@ -4,24 +4,22 @@
// GuiGeneralScreensaverOptions.h // GuiGeneralScreensaverOptions.h
// //
// User interface for the screensaver options. // User interface for the screensaver options.
// Based on the GuiScreenSaverOptions template.
// Submenu to the GuiMenu main menu. // Submenu to the GuiMenu main menu.
// //
#ifndef ES_APP_GUIS_GUI_GENERAL_SCREENSAVER_OPTIONS_H #ifndef ES_APP_GUIS_GUI_GENERAL_SCREENSAVER_OPTIONS_H
#define ES_APP_GUIS_GUI_GENERAL_SCREENSAVER_OPTIONS_H #define ES_APP_GUIS_GUI_GENERAL_SCREENSAVER_OPTIONS_H
#include "GuiScreensaverOptions.h" #include "guis/GuiSettings.h"
class GuiGeneralScreensaverOptions : public GuiScreensaverOptions class GuiGeneralScreensaverOptions : public GuiSettings
{ {
public: public:
GuiGeneralScreensaverOptions(Window* window, const char* title); GuiGeneralScreensaverOptions(Window* window, const char* title);
virtual ~GuiGeneralScreensaverOptions();
private: private:
void openVideoScreensaverOptions();
void openSlideshowScreensaverOptions(); void openSlideshowScreensaverOptions();
void openVideoScreensaverOptions();
}; };
#endif // ES_APP_GUIS_GUI_GENERAL_SCREENSAVER_OPTIONS_H #endif // ES_APP_GUIS_GUI_GENERAL_SCREENSAVER_OPTIONS_H

File diff suppressed because it is too large Load diff

View file

@ -29,14 +29,15 @@ private:
void addEntry(const char* name, unsigned int color, void addEntry(const char* name, unsigned int color,
bool add_arrow, const std::function<void()>& func); bool add_arrow, const std::function<void()>& func);
void addVersionInfo(); void addVersionInfo();
void openCollectionSystemSettings();
void openConfigInput();
void openOtherSettings();
void openQuitMenu();
void openScraperSettings(); void openScraperSettings();
void openUISettings();
void openScreensaverOptions(); void openScreensaverOptions();
void openSoundSettings(); void openSoundSettings();
void openUISettings(); void openCollectionSystemSettings();
void openOtherSettings();
void openConfigInput();
void openQuitMenu();
MenuComponent mMenu; MenuComponent mMenu;
TextComponent mVersion; TextComponent mVersion;

View file

@ -22,19 +22,21 @@
GuiScraperMenu::GuiScraperMenu(Window* window) : GuiComponent(window), GuiScraperMenu::GuiScraperMenu(Window* window) : GuiComponent(window),
mMenu(window, "SCRAPER") mMenu(window, "SCRAPER")
{ {
// Scrape from. // Scraper service.
auto scraper_list = std::make_shared<OptionListComponent<std::string>> mScraper = std::make_shared<OptionListComponent<std::string>>
(mWindow, getHelpStyle(), "SCRAPE FROM", false); (mWindow, getHelpStyle(), "SCRAPE FROM", false);
std::vector<std::string> scrapers = getScraperList(); std::vector<std::string> scrapers = getScraperList();
// Select either the first entry or the one read from the settings, // Select either the first entry or the one read from the settings,
// just in case the scraper from settings has vanished. // just in case the scraper from settings has vanished.
for (auto it = scrapers.cbegin(); it != scrapers.cend(); it++) for (auto it = scrapers.cbegin(); it != scrapers.cend(); it++)
scraper_list->add(*it, *it, *it == Settings::getInstance()->getString("Scraper")); mScraper->add(*it, *it, *it == Settings::getInstance()->getString("Scraper"));
mMenu.addWithLabel("SCRAPE FROM", mScraper);
mMenu.addWithLabel("SCRAPE FROM", scraper_list); mMenu.addSaveFunc([this] {
mMenu.addSaveFunc([scraper_list] { Settings::getInstance()->setString("Scraper", if (mScraper->getSelected() != Settings::getInstance()->getString("Scraper")) {
scraper_list->getSelected()); }); Settings::getInstance()->setString("Scraper", mScraper->getSelected());
mMenu.setNeedsSaving();
}
});
// Search filters, getSearches() will generate a queue of games to scrape // Search filters, getSearches() will generate a queue of games to scrape
// based on the outcome of the checks below. // based on the outcome of the checks below.
@ -71,15 +73,19 @@ GuiScraperMenu::GuiScraperMenu(Window* window) : GuiComponent(window),
mMenu.addWithLabel("Systems", mSystems); mMenu.addWithLabel("Systems", mSystems);
addEntry("CONTENT SETTINGS", 0x777777FF, true, [this] { addEntry("CONTENT SETTINGS", 0x777777FF, true, [this] {
// Always save the settings when entering this menu, so the options that are // If the scraper service has been changed before entering this menu, then save the
// not supported by TheGamesDB can be disabled. // settings so that the specific options supported by the respective scrapers
mMenu.save(); // can be enabled or disabled.
if (mScraper->getSelected() != Settings::getInstance()->getString("Scraper"))
mMenu.save();
openContentSettings(); openContentSettings();
}); });
addEntry("OTHER SETTINGS", 0x777777FF, true, [this] { addEntry("OTHER SETTINGS", 0x777777FF, true, [this] {
// Always save the settings when entering this menu, so the options that are // If the scraper service has been changed before entering this menu, then save the
// not supported by TheGamesDB can be disabled. // settings so that the specific options supported by the respective scrapers
mMenu.save(); // can be enabled or disabled.
if (mScraper->getSelected() != Settings::getInstance()->getString("Scraper"))
mMenu.save();
openOtherSettings(); openOtherSettings();
}); });
@ -114,18 +120,26 @@ void GuiScraperMenu::openContentSettings()
auto s = new GuiSettings(mWindow, "SCRAPER CONTENT SETTINGS"); auto s = new GuiSettings(mWindow, "SCRAPER CONTENT SETTINGS");
// Scrape game names. // Scrape game names.
auto scrape_gamename = std::make_shared<SwitchComponent>(mWindow); auto scrape_game_names = std::make_shared<SwitchComponent>(mWindow);
scrape_gamename->setState(Settings::getInstance()->getBool("ScrapeGameNames")); scrape_game_names->setState(Settings::getInstance()->getBool("ScrapeGameNames"));
s->addWithLabel("SCRAPE GAME NAMES", scrape_gamename); s->addWithLabel("SCRAPE GAME NAMES", scrape_game_names);
s->addSaveFunc([scrape_gamename] { Settings::getInstance()->setBool("ScrapeGameNames", s->addSaveFunc([scrape_game_names, s] {
scrape_gamename->getState()); }); if (scrape_game_names->getState() != Settings::getInstance()->getBool("ScrapeGameNames")) {
Settings::getInstance()->setBool("ScrapeGameNames", scrape_game_names->getState());
s->setNeedsSaving();
}
});
// Scrape ratings. // Scrape ratings.
auto scrape_ratings = std::make_shared<SwitchComponent>(mWindow); auto scrape_ratings = std::make_shared<SwitchComponent>(mWindow);
scrape_ratings->setState(Settings::getInstance()->getBool("ScrapeRatings")); scrape_ratings->setState(Settings::getInstance()->getBool("ScrapeRatings"));
s->addWithLabel("SCRAPE RATINGS", scrape_ratings); s->addWithLabel("SCRAPE RATINGS", scrape_ratings);
s->addSaveFunc([scrape_ratings] { Settings::getInstance()->setBool("ScrapeRatings", s->addSaveFunc([scrape_ratings, s] {
scrape_ratings->getState()); }); if (scrape_ratings->getState() != Settings::getInstance()->getBool("ScrapeRatings")) {
Settings::getInstance()->setBool("ScrapeRatings", scrape_ratings->getState());
s->setNeedsSaving();
}
});
// Ratings are not supported by TheGamesDB, so disable the option if this scraper is selected. // Ratings are not supported by TheGamesDB, so disable the option if this scraper is selected.
if (Settings::getInstance()->getString("Scraper") == "thegamesdb") { if (Settings::getInstance()->getString("Scraper") == "thegamesdb") {
@ -140,15 +154,23 @@ void GuiScraperMenu::openContentSettings()
auto scrape_metadata = std::make_shared<SwitchComponent>(mWindow); auto scrape_metadata = std::make_shared<SwitchComponent>(mWindow);
scrape_metadata->setState(Settings::getInstance()->getBool("ScrapeMetadata")); scrape_metadata->setState(Settings::getInstance()->getBool("ScrapeMetadata"));
s->addWithLabel("SCRAPE OTHER METADATA", scrape_metadata); s->addWithLabel("SCRAPE OTHER METADATA", scrape_metadata);
s->addSaveFunc([scrape_metadata] { Settings::getInstance()->setBool("ScrapeMetadata", s->addSaveFunc([scrape_metadata, s] {
scrape_metadata->getState()); }); if (scrape_metadata->getState() != Settings::getInstance()->getBool("ScrapeMetadata")) {
Settings::getInstance()->setBool("ScrapeMetadata", scrape_metadata->getState());
s->setNeedsSaving();
}
});
// Scrape videos. // Scrape videos.
auto scrape_videos = std::make_shared<SwitchComponent>(mWindow); auto scrape_videos = std::make_shared<SwitchComponent>(mWindow);
scrape_videos->setState(Settings::getInstance()->getBool("ScrapeVideos")); scrape_videos->setState(Settings::getInstance()->getBool("ScrapeVideos"));
s->addWithLabel("SCRAPE VIDEOS", scrape_videos); s->addWithLabel("SCRAPE VIDEOS", scrape_videos);
s->addSaveFunc([scrape_videos] { Settings::getInstance()->setBool("ScrapeVideos", s->addSaveFunc([scrape_videos, s] {
scrape_videos->getState()); }); if (scrape_videos->getState() != Settings::getInstance()->getBool("ScrapeVideos")) {
Settings::getInstance()->setBool("ScrapeVideos", scrape_videos->getState());
s->setNeedsSaving();
}
});
// Videos are not supported by TheGamesDB, so disable the option if this scraper is selected. // Videos are not supported by TheGamesDB, so disable the option if this scraper is selected.
if (Settings::getInstance()->getString("Scraper") == "thegamesdb") { if (Settings::getInstance()->getString("Scraper") == "thegamesdb") {
@ -163,29 +185,46 @@ void GuiScraperMenu::openContentSettings()
auto scrape_screenshots = std::make_shared<SwitchComponent>(mWindow); auto scrape_screenshots = std::make_shared<SwitchComponent>(mWindow);
scrape_screenshots->setState(Settings::getInstance()->getBool("ScrapeScreenshots")); scrape_screenshots->setState(Settings::getInstance()->getBool("ScrapeScreenshots"));
s->addWithLabel("SCRAPE SCREENSHOT IMAGES", scrape_screenshots); s->addWithLabel("SCRAPE SCREENSHOT IMAGES", scrape_screenshots);
s->addSaveFunc([scrape_screenshots] { Settings::getInstance()->setBool("ScrapeScreenshots", s->addSaveFunc([scrape_screenshots, s] {
scrape_screenshots->getState()); }); if (scrape_screenshots->getState() !=
Settings::getInstance()->getBool("ScrapeScreenshots")) {
Settings::getInstance()->setBool("ScrapeScreenshots", scrape_screenshots->getState());
s->setNeedsSaving();
}
});
// Scrape cover images. // Scrape cover images.
auto scrape_covers = std::make_shared<SwitchComponent>(mWindow); auto scrape_covers = std::make_shared<SwitchComponent>(mWindow);
scrape_covers->setState(Settings::getInstance()->getBool("ScrapeCovers")); scrape_covers->setState(Settings::getInstance()->getBool("ScrapeCovers"));
s->addWithLabel("SCRAPE BOX COVER IMAGES", scrape_covers); s->addWithLabel("SCRAPE BOX COVER IMAGES", scrape_covers);
s->addSaveFunc([scrape_covers] { Settings::getInstance()->setBool("ScrapeCovers", s->addSaveFunc([scrape_covers, s] {
scrape_covers->getState()); }); if (scrape_covers->getState() != Settings::getInstance()->getBool("ScrapeCovers")) {
Settings::getInstance()->setBool("ScrapeCovers", scrape_covers->getState());
s->setNeedsSaving();
}
});
// Scrape marquee images. // Scrape marquee images.
auto scrape_marquees = std::make_shared<SwitchComponent>(mWindow); auto scrape_marquees = std::make_shared<SwitchComponent>(mWindow);
scrape_marquees->setState(Settings::getInstance()->getBool("ScrapeMarquees")); scrape_marquees->setState(Settings::getInstance()->getBool("ScrapeMarquees"));
s->addWithLabel("SCRAPE MARQUEE (WHEEL) IMAGES", scrape_marquees); s->addWithLabel("SCRAPE MARQUEE (WHEEL) IMAGES", scrape_marquees);
s->addSaveFunc([scrape_marquees] { Settings::getInstance()->setBool("ScrapeMarquees", s->addSaveFunc([scrape_marquees, s] {
scrape_marquees->getState()); }); if (scrape_marquees->getState() != Settings::getInstance()->getBool("ScrapeMarquees")) {
Settings::getInstance()->setBool("ScrapeMarquees", scrape_marquees->getState());
s->setNeedsSaving();
}
});
// Scrape 3D box images. // Scrape 3D box images.
auto scrape_3dboxes = std::make_shared<SwitchComponent>(mWindow); auto scrape_3dboxes = std::make_shared<SwitchComponent>(mWindow);
scrape_3dboxes->setState(Settings::getInstance()->getBool("Scrape3DBoxes")); scrape_3dboxes->setState(Settings::getInstance()->getBool("Scrape3DBoxes"));
s->addWithLabel("SCRAPE 3D BOX IMAGES", scrape_3dboxes); s->addWithLabel("SCRAPE 3D BOX IMAGES", scrape_3dboxes);
s->addSaveFunc([scrape_3dboxes] { Settings::getInstance()->setBool("Scrape3DBoxes", s->addSaveFunc([scrape_3dboxes, s] {
scrape_3dboxes->getState()); }); if (scrape_3dboxes->getState() != Settings::getInstance()->getBool("Scrape3DBoxes")) {
Settings::getInstance()->setBool("Scrape3DBoxes", scrape_3dboxes->getState());
s->setNeedsSaving();
}
});
// 3D box images are not supported by TheGamesDB, so disable the option if this scraper // 3D box images are not supported by TheGamesDB, so disable the option if this scraper
// is selected. // is selected.
@ -213,7 +252,6 @@ void GuiScraperMenu::openOtherSettings()
transitions_rg.push_back("us"); transitions_rg.push_back("us");
transitions_rg.push_back("ss"); transitions_rg.push_back("ss");
transitions_rg.push_back("wor"); transitions_rg.push_back("wor");
if (Settings::getInstance()->getString("ScraperRegion") != "") { if (Settings::getInstance()->getString("ScraperRegion") != "") {
if (std::find(transitions_rg.begin(), transitions_rg.end(), if (std::find(transitions_rg.begin(), transitions_rg.end(),
Settings::getInstance()->getString("ScraperRegion")) == transitions_rg.end()) { Settings::getInstance()->getString("ScraperRegion")) == transitions_rg.end()) {
@ -223,8 +261,11 @@ void GuiScraperMenu::openOtherSettings()
for (auto it = transitions_rg.cbegin(); it != transitions_rg.cend(); it++) for (auto it = transitions_rg.cbegin(); it != transitions_rg.cend(); it++)
scraper_region->add(*it, *it, Settings::getInstance()->getString("ScraperRegion") == *it); scraper_region->add(*it, *it, Settings::getInstance()->getString("ScraperRegion") == *it);
s->addWithLabel("REGION", scraper_region); s->addWithLabel("REGION", scraper_region);
s->addSaveFunc([scraper_region] { s->addSaveFunc([scraper_region, s] {
Settings::getInstance()->setString("ScraperRegion", scraper_region->getSelected()); if (scraper_region->getSelected() != Settings::getInstance()->getString("ScraperRegion")) {
Settings::getInstance()->setString("ScraperRegion", scraper_region->getSelected());
s->setNeedsSaving();
}
}); });
// Regions are not supported by TheGamesDB, so disable the option if this scraper is selected. // Regions are not supported by TheGamesDB, so disable the option if this scraper is selected.
@ -242,7 +283,6 @@ void GuiScraperMenu::openOtherSettings()
std::vector<std::string> transitions_lg; std::vector<std::string> transitions_lg;
transitions_lg.push_back("en"); transitions_lg.push_back("en");
transitions_lg.push_back("wor"); transitions_lg.push_back("wor");
if (Settings::getInstance()->getString("ScraperLanguage") != "") { if (Settings::getInstance()->getString("ScraperLanguage") != "") {
if (std::find(transitions_lg.begin(), transitions_lg.end(), if (std::find(transitions_lg.begin(), transitions_lg.end(),
Settings::getInstance()->getString("ScraperLanguage")) == transitions_lg.end()) { Settings::getInstance()->getString("ScraperLanguage")) == transitions_lg.end()) {
@ -253,8 +293,12 @@ void GuiScraperMenu::openOtherSettings()
scraper_language->add(*it, *it, scraper_language->add(*it, *it,
Settings::getInstance()->getString("ScraperLanguage") == *it); Settings::getInstance()->getString("ScraperLanguage") == *it);
s->addWithLabel("LANGUAGE", scraper_language); s->addWithLabel("LANGUAGE", scraper_language);
s->addSaveFunc([scraper_language] { s->addSaveFunc([scraper_language, s] {
Settings::getInstance()->setString("ScraperLanguage", scraper_language->getSelected()); if (scraper_language->getSelected() !=
Settings::getInstance()->getString("ScraperLanguage")) {
Settings::getInstance()->setString("ScraperLanguage", scraper_language->getSelected());
s->setNeedsSaving();
}
}); });
// Languages are not supported by TheGamesDB, so disable the option if this scraper is selected. // Languages are not supported by TheGamesDB, so disable the option if this scraper is selected.
@ -267,69 +311,108 @@ void GuiScraperMenu::openOtherSettings()
} }
// Overwrite files and data. // Overwrite files and data.
auto scrape_overwrite = std::make_shared<SwitchComponent>(mWindow); auto scraper_overwrite_data = std::make_shared<SwitchComponent>(mWindow);
scrape_overwrite->setState(Settings::getInstance()->getBool("ScraperOverwriteData")); scraper_overwrite_data->setState(Settings::getInstance()->getBool("ScraperOverwriteData"));
s->addWithLabel("OVERWRITE FILES AND DATA", scrape_overwrite); s->addWithLabel("OVERWRITE FILES AND DATA", scraper_overwrite_data);
s->addSaveFunc([scrape_overwrite] { Settings::getInstance()->setBool("ScraperOverwriteData", s->addSaveFunc([scraper_overwrite_data, s] {
scrape_overwrite->getState()); }); if (scraper_overwrite_data->getState() !=
Settings::getInstance()->getBool("ScraperOverwriteData")) {
Settings::getInstance()->setBool("ScraperOverwriteData",
scraper_overwrite_data->getState());
s->setNeedsSaving();
}
});
// Search using metadata name. // Search using metadata name.
auto scrape_metadata_name = std::make_shared<SwitchComponent>(mWindow); auto scraper_search_metadata_name = std::make_shared<SwitchComponent>(mWindow);
scrape_metadata_name->setState(Settings::getInstance()->getBool("ScraperSearchMetadataName")); scraper_search_metadata_name->
s->addWithLabel("SEARCH USING METADATA NAME", scrape_metadata_name); setState(Settings::getInstance()->getBool("ScraperSearchMetadataName"));
s->addSaveFunc([scrape_metadata_name] { s->addWithLabel("SEARCH USING METADATA NAME", scraper_search_metadata_name);
Settings::getInstance()->setBool("ScraperSearchMetadataName", s->addSaveFunc([scraper_search_metadata_name, s] {
scrape_metadata_name->getState()); }); if (scraper_search_metadata_name->getState() !=
Settings::getInstance()->getBool("ScraperSearchMetadataName")) {
Settings::getInstance()->setBool("ScraperSearchMetadataName",
scraper_search_metadata_name->getState());
s->setNeedsSaving();
}
});
// Interactive scraping. // Interactive scraping.
auto scraper_interactive = std::make_shared<SwitchComponent>(mWindow); auto scraper_interactive = std::make_shared<SwitchComponent>(mWindow);
scraper_interactive->setState(Settings::getInstance()->getBool("ScraperInteractive")); scraper_interactive->setState(Settings::getInstance()->getBool("ScraperInteractive"));
s->addWithLabel("INTERACTIVE MODE", scraper_interactive); s->addWithLabel("INTERACTIVE MODE", scraper_interactive);
s->addSaveFunc([scraper_interactive] { Settings::getInstance()->setBool("ScraperInteractive", s->addSaveFunc([scraper_interactive, s] {
scraper_interactive->getState()); }); if (scraper_interactive->getState() !=
Settings::getInstance()->getBool("ScraperInteractive")) {
Settings::getInstance()->setBool("ScraperInteractive", scraper_interactive->getState());
s->setNeedsSaving();
}
});
// Semi-automatic scraping. // Semi-automatic scraping.
auto scraper_semiautomatic = std::make_shared<SwitchComponent>(mWindow); auto scraper_semiautomatic = std::make_shared<SwitchComponent>(mWindow);
scraper_semiautomatic->setState(Settings::getInstance()->getBool("ScraperSemiautomatic")); scraper_semiautomatic->setState(Settings::getInstance()->getBool("ScraperSemiautomatic"));
s->addWithLabel("AUTO-ACCEPT SINGLE GAME MATCHES", scraper_semiautomatic); s->addWithLabel("AUTO-ACCEPT SINGLE GAME MATCHES", scraper_semiautomatic);
s->addSaveFunc([scraper_semiautomatic] { s->addSaveFunc([scraper_semiautomatic ,s] {
if (scraper_semiautomatic->getState() !=
Settings::getInstance()->getBool("ScraperSemiautomatic")) {
Settings::getInstance()->setBool("ScraperSemiautomatic", Settings::getInstance()->setBool("ScraperSemiautomatic",
scraper_semiautomatic->getState()); }); scraper_semiautomatic->getState());
s->setNeedsSaving();
}
});
// Respect the per-file multi-scraper exclusion flag. // Respect the per-file multi-scraper exclusion flag.
auto scraper_respect_exclusions = std::make_shared<SwitchComponent>(mWindow); auto scraper_respect_exclusions = std::make_shared<SwitchComponent>(mWindow);
scraper_respect_exclusions->setState( scraper_respect_exclusions->setState(
Settings::getInstance()->getBool("ScraperRespectExclusions")); Settings::getInstance()->getBool("ScraperRespectExclusions"));
s->addWithLabel("RESPECT PER-FILE SCRAPER EXCLUSIONS", scraper_respect_exclusions); s->addWithLabel("RESPECT PER-FILE SCRAPER EXCLUSIONS", scraper_respect_exclusions);
s->addSaveFunc([scraper_respect_exclusions] { s->addSaveFunc([scraper_respect_exclusions, s] {
if (scraper_respect_exclusions->getState() !=
Settings::getInstance()->getBool("ScraperRespectExclusions")) {
Settings::getInstance()->setBool("ScraperRespectExclusions", Settings::getInstance()->setBool("ScraperRespectExclusions",
scraper_respect_exclusions->getState()); }); scraper_respect_exclusions->getState());
s->setNeedsSaving();
}
});
// Exclude files recursively for excluded folders. // Exclude files recursively for excluded folders.
auto scraper_exclude_recursively = std::make_shared<SwitchComponent>(mWindow); auto scraper_exclude_recursively = std::make_shared<SwitchComponent>(mWindow);
scraper_exclude_recursively->setState( scraper_exclude_recursively->setState(
Settings::getInstance()->getBool("ScraperExcludeRecursively")); Settings::getInstance()->getBool("ScraperExcludeRecursively"));
s->addWithLabel("EXCLUDE FOLDERS RECURSIVELY", scraper_exclude_recursively); s->addWithLabel("EXCLUDE FOLDERS RECURSIVELY", scraper_exclude_recursively);
s->addSaveFunc([scraper_exclude_recursively] { s->addSaveFunc([scraper_exclude_recursively, s] {
if (scraper_exclude_recursively->getState() !=
Settings::getInstance()->getBool("ScraperExcludeRecursively")) {
Settings::getInstance()->setBool("ScraperExcludeRecursively", Settings::getInstance()->setBool("ScraperExcludeRecursively",
scraper_exclude_recursively->getState()); }); scraper_exclude_recursively->getState());
s->setNeedsSaving();
}
});
// Include actual folders when scraping. // Include actual folders when scraping.
auto scraper_include_folders = std::make_shared<SwitchComponent>(mWindow); auto scraper_include_folders = std::make_shared<SwitchComponent>(mWindow);
scraper_include_folders->setState( scraper_include_folders->setState(
Settings::getInstance()->getBool("ScraperIncludeFolders")); Settings::getInstance()->getBool("ScraperIncludeFolders"));
s->addWithLabel("SCRAPE ACTUAL FOLDERS", scraper_include_folders); s->addWithLabel("SCRAPE ACTUAL FOLDERS", scraper_include_folders);
s->addSaveFunc([scraper_include_folders] { s->addSaveFunc([scraper_include_folders, s] {
if (scraper_include_folders->getState() !=
Settings::getInstance()->getBool("ScraperIncludeFolders")) {
Settings::getInstance()->setBool("ScraperIncludeFolders", Settings::getInstance()->setBool("ScraperIncludeFolders",
scraper_include_folders->getState()); }); scraper_include_folders->getState());
s->setNeedsSaving();
}
});
mWindow->pushGui(s); mWindow->pushGui(s);
} }
void GuiScraperMenu::pressedStart() void GuiScraperMenu::pressedStart()
{ {
// Save any GUI settings that may have been modified. // If the scraper service has been changed, then save the settings as otherwise the
mMenu.save(); // wrong scraper would be used.
if (mScraper->getSelected() != Settings::getInstance()->getString("Scraper"))
mMenu.save();
std::vector<SystemData*> sys = mSystems->getSelectedObjects(); std::vector<SystemData*> sys = mSystems->getSelectedObjects();
for (auto it = sys.cbegin(); it != sys.cend(); it++) { for (auto it = sys.cbegin(); it != sys.cend(); it++) {

View file

@ -45,6 +45,7 @@ private:
std::queue<ScraperSearchParams> getSearches( std::queue<ScraperSearchParams> getSearches(
std::vector<SystemData*> systems, GameFilterFunc selector); std::vector<SystemData*> systems, GameFilterFunc selector);
std::shared_ptr<OptionListComponent<std::string>> mScraper;
std::shared_ptr<OptionListComponent<GameFilterFunc>> mFilters; std::shared_ptr<OptionListComponent<GameFilterFunc>> mFilters;
std::shared_ptr<OptionListComponent<SystemData*>> mSystems; std::shared_ptr<OptionListComponent<SystemData*>> mSystems;

View file

@ -4,17 +4,29 @@
// 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
// based on the flags set by the actual menu entries' lambda functions.
// //
#include "guis/GuiSettings.h" #include "guis/GuiSettings.h"
#include "guis/GuiTextEditPopup.h"
#include "views/gamelist/IGameListView.h"
#include "views/ViewController.h" #include "views/ViewController.h"
#include "Settings.h" #include "Settings.h"
#include "SystemData.h" #include "SystemData.h"
#include "Window.h" #include "Window.h"
GuiSettings::GuiSettings(Window* window, const char* title) GuiSettings::GuiSettings(
: GuiComponent(window), mMenu(window, title) Window* window,
const char* title)
: GuiComponent(window),
mMenu(window, title),
mNeedsSaving(false),
mNeedsGoToStart(false),
mNeedsReloading(false),
mNeedsSorting(false),
mNeedsSortingCollections(false)
{ {
addChild(&mMenu); addChild(&mMenu);
mMenu.addButton("BACK", "back", [this] { delete this; }); mMenu.addButton("BACK", "back", [this] { delete this; });
@ -36,7 +48,68 @@ void GuiSettings::save()
for (auto it = mSaveFuncs.cbegin(); it != mSaveFuncs.cend(); it++) for (auto it = mSaveFuncs.cbegin(); it != mSaveFuncs.cend(); it++)
(*it)(); (*it)();
Settings::getInstance()->saveFile(); if (mNeedsSaving)
Settings::getInstance()->saveFile();
if (mNeedsGoToStart)
ViewController::get()->goToStart();
if (mNeedsReloading)
ViewController::get()->reloadAll();
if (mNeedsSorting) {
for (auto it = SystemData::sSystemVector.cbegin(); it !=
SystemData::sSystemVector.cend(); it++) {
if (!(!mNeedsSortingCollections && (*it)->isCollection())) {
(*it)->sortSystem(true);
}
// Jump to the first row of the gamelist.
IGameListView* gameList = ViewController::get()->getGameListView((*it)).get();
gameList->setCursor(gameList->getFirstEntry());
}
}
if (mNeedsSaving || mNeedsGoToStart || mNeedsReloading || mNeedsSorting)
mWindow->invalidateCachedBackground();
}
void GuiSettings::addEditableTextComponent(const std::string label,
std::shared_ptr<GuiComponent> ed, std::string value, std::string defaultValue)
{
ComponentListRow row;
row.elements.clear();
auto lbl = std::make_shared<TextComponent>(mWindow, Utils::String::toUpper(label),
Font::get(FONT_SIZE_MEDIUM), 0x777777FF);
row.addElement(lbl, true);
row.addElement(ed, true);
auto spacer = std::make_shared<GuiComponent>(mWindow);
spacer->setSize(Renderer::getScreenWidth() * 0.005f, 0);
row.addElement(spacer, false);
auto bracket = std::make_shared<ImageComponent>(mWindow);
bracket->setImage(":/graphics/arrow.svg");
bracket->setResize(Vector2f(0, lbl->getFont()->getLetterHeight()));
row.addElement(bracket, false);
// OK callback (apply new value to ed).
auto updateVal = [ed, defaultValue](const std::string& newVal) {
// If the field is blank, apply the default value if it's been passes as an argument.
if (defaultValue != "" && newVal == "")
ed->setValue(defaultValue);
else
ed->setValue(newVal);
};
row.makeAcceptInputHandler([this, label, ed, updateVal] {
mWindow->pushGui(new GuiTextEditPopup(mWindow, getHelpStyle(), label,
ed->getValue(), updateVal, false));
});
assert(ed);
addRow(row);
ed->setValue(value);
} }
bool GuiSettings::input(InputConfig* config, Input input) bool GuiSettings::input(InputConfig* config, Input input)
@ -47,9 +120,8 @@ bool GuiSettings::input(InputConfig* config, Input input)
} }
// Keep code for potential future use. // Keep code for potential future use.
// if (config->isMappedTo("start", input) && input.value != 0) // if (config->isMappedTo("start", input) && input.value != 0) {
// { // // Close everything.
// // close everything
// Window* window = mWindow; // Window* window = mWindow;
// while (window->peekGui() && window->peekGui() != ViewController::get()) // while (window->peekGui() && window->peekGui() != ViewController::get())
// delete window->peekGui(); // delete window->peekGui();

View file

@ -4,6 +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
// based on the flags set by the actual menu entries' lambda functions.
// //
#ifndef ES_APP_GUIS_GUI_SETTINGS_H #ifndef ES_APP_GUIS_GUI_SETTINGS_H
@ -16,21 +18,34 @@ class GuiSettings : public GuiComponent
{ {
public: public:
GuiSettings(Window* window, const char* title); GuiSettings(Window* window, const char* title);
virtual ~GuiSettings(); // Just calls save() virtual ~GuiSettings();
void save(); void save();
inline void addRow(const ComponentListRow& row) { mMenu.addRow(row); }; inline void addRow(const ComponentListRow& row) { mMenu.addRow(row); };
inline void addWithLabel(const std::string& label, inline void addWithLabel(const std::string& label,
const std::shared_ptr<GuiComponent>& comp) { mMenu.addWithLabel(label, comp); }; const std::shared_ptr<GuiComponent>& comp) { mMenu.addWithLabel(label, comp); };
void addEditableTextComponent(const std::string label, std::shared_ptr<GuiComponent> ed,
std::string value, std::string defaultValue = "");
inline void addSaveFunc(const std::function<void()>& func) { mSaveFuncs.push_back(func); }; inline void addSaveFunc(const std::function<void()>& func) { mSaveFuncs.push_back(func); };
void setNeedsSaving() { mNeedsSaving = true; };
void setNeedsGoToStart() { mNeedsGoToStart = true; };
void setNeedsReloading() { mNeedsReloading = true; };
void setNeedsSorting() { mNeedsSorting = true; };
void setNeedsSortingCollections() { mNeedsSortingCollections = true; };
bool input(InputConfig* config, Input input) override; bool input(InputConfig* config, Input input) override;
std::vector<HelpPrompt> getHelpPrompts() override; std::vector<HelpPrompt> getHelpPrompts() override;
HelpStyle getHelpStyle() override; HelpStyle getHelpStyle() override;
private: private:
MenuComponent mMenu; MenuComponent mMenu;
std::vector< std::function<void()> > mSaveFuncs; std::vector<std::function<void()>> mSaveFuncs;
bool mNeedsSaving;
bool mNeedsGoToStart;
bool mNeedsReloading;
bool mNeedsSorting;
bool mNeedsSortingCollections;
}; };
#endif // ES_APP_GUIS_GUI_SETTINGS_H #endif // ES_APP_GUIS_GUI_SETTINGS_H

View file

@ -286,9 +286,6 @@ bool parseArgs(int argc, char* argv[])
else if (strcmp(argv[i], "--force-kid") == 0) { else if (strcmp(argv[i], "--force-kid") == 0) {
Settings::getInstance()->setBool("ForceKid", true); Settings::getInstance()->setBool("ForceKid", true);
} }
else if (strcmp(argv[i], "--force-disable-filters") == 0) {
Settings::getInstance()->setBool("ForceDisableFilters", true);
}
else if (strcmp(argv[i], "--force-input-config") == 0) { else if (strcmp(argv[i], "--force-input-config") == 0) {
forceInputConfig = true; forceInputConfig = true;
} }
@ -321,7 +318,6 @@ bool parseArgs(int argc, char* argv[])
" --force-full Force the UI mode to Full\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-input-config Force configuration of input device\n" " --force-input-config Force configuration of input device\n"
" --home [path] Directory to use as home path\n" " --home [path] Directory to use as home path\n"
" --version, -v Display version information\n" " --version, -v Display version information\n"

View file

@ -218,7 +218,7 @@ bool SystemView::input(InputConfig* config, Input input)
if (!UIModeController::getInstance()->isUIModeKid() && if (!UIModeController::getInstance()->isUIModeKid() &&
config->isMappedTo("select", input) && config->isMappedTo("select", input) &&
Settings::getInstance()->getBool("ScreenSaverControls")) { Settings::getInstance()->getBool("ScreensaverControls")) {
if (!mWindow->isScreenSaverActive()) { if (!mWindow->isScreenSaverActive()) {
mWindow->startScreenSaver(); mWindow->startScreenSaver();
mWindow->renderScreenSaver(); mWindow->renderScreenSaver();
@ -315,11 +315,11 @@ void SystemView::onCursorChanged(const CursorState& /*state*/)
return; return;
Animation* anim; Animation* anim;
bool move_carousel = Settings::getInstance()->getBool("MoveCarousel"); bool carousel_transitions = Settings::getInstance()->getBool("CarouselTransitions");
if (transition_style == "fade") { if (transition_style == "fade") {
float startExtrasFade = mExtrasFadeOpacity; float startExtrasFade = mExtrasFadeOpacity;
anim = new LambdaAnimation( anim = new LambdaAnimation(
[this, startExtrasFade, startPos, endPos, posMax, move_carousel](float t) { [this, startExtrasFade, startPos, endPos, posMax, carousel_transitions](float t) {
t -= 1; t -= 1;
float f = Math::lerp(startPos, endPos, t*t*t + 1); float f = Math::lerp(startPos, endPos, t*t*t + 1);
if (f < 0) if (f < 0)
@ -327,7 +327,7 @@ void SystemView::onCursorChanged(const CursorState& /*state*/)
if (f >= posMax) if (f >= posMax)
f -= posMax; f -= posMax;
this->mCamOffset = move_carousel ? f : endPos; this->mCamOffset = carousel_transitions ? f : endPos;
t += 1; t += 1;
if (t < 0.3f) if (t < 0.3f)
@ -345,7 +345,7 @@ void SystemView::onCursorChanged(const CursorState& /*state*/)
else if (transition_style == "slide") { else if (transition_style == "slide") {
// Slide. // Slide.
anim = new LambdaAnimation( anim = new LambdaAnimation(
[this, startPos, endPos, posMax, move_carousel](float t) { [this, startPos, endPos, posMax, carousel_transitions](float t) {
t -= 1; t -= 1;
float f = Math::lerp(startPos, endPos, t*t*t + 1); float f = Math::lerp(startPos, endPos, t*t*t + 1);
if (f < 0) if (f < 0)
@ -353,14 +353,14 @@ void SystemView::onCursorChanged(const CursorState& /*state*/)
if (f >= posMax) if (f >= posMax)
f -= posMax; f -= posMax;
this->mCamOffset = move_carousel ? f : endPos; this->mCamOffset = carousel_transitions ? f : endPos;
this->mExtrasCamOffset = f; this->mExtrasCamOffset = f;
}, 500); }, 500);
} }
else { else {
// Instant. // Instant.
anim = new LambdaAnimation( anim = new LambdaAnimation(
[this, startPos, endPos, posMax, move_carousel ](float t) { [this, startPos, endPos, posMax, carousel_transitions ](float t) {
t -= 1; t -= 1;
float f = Math::lerp(startPos, endPos, t*t*t + 1); float f = Math::lerp(startPos, endPos, t*t*t + 1);
if (f < 0) if (f < 0)
@ -368,9 +368,9 @@ void SystemView::onCursorChanged(const CursorState& /*state*/)
if (f >= posMax) if (f >= posMax)
f -= posMax; f -= posMax;
this->mCamOffset = move_carousel ? f : endPos; this->mCamOffset = carousel_transitions ? f : endPos;
this->mExtrasCamOffset = endPos; this->mExtrasCamOffset = endPos;
}, move_carousel ? 500 : 1); }, carousel_transitions ? 500 : 1);
} }
setAnimation(anim, 0, nullptr, false, 0); setAnimation(anim, 0, nullptr, false, 0);
@ -419,7 +419,7 @@ std::vector<HelpPrompt> SystemView::getHelpPrompts()
prompts.push_back(HelpPrompt("x", "random")); prompts.push_back(HelpPrompt("x", "random"));
if (!UIModeController::getInstance()->isUIModeKid() && if (!UIModeController::getInstance()->isUIModeKid() &&
Settings::getInstance()->getBool("ScreenSaverControls")) Settings::getInstance()->getBool("ScreensaverControls"))
prompts.push_back(HelpPrompt("select", "toggle screensaver")); prompts.push_back(HelpPrompt("select", "toggle screensaver"));
return prompts; return prompts;

View file

@ -14,7 +14,7 @@
#include "Log.h" #include "Log.h"
#include "Window.h" #include "Window.h"
UIModeController* UIModeController::sInstance = nullptr; UIModeController* UIModeController::sInstance = nullptr;
UIModeController* UIModeController::getInstance() UIModeController* UIModeController::getInstance()
{ {
@ -24,8 +24,7 @@ UIModeController* UIModeController::getInstance()
return sInstance; return sInstance;
} }
UIModeController::UIModeController() UIModeController::UIModeController() : mPassKeyCounter(0)
:mPassKeyCounter(0)
{ {
mPassKeySequence = Settings::getInstance()->getString("UIMode_passkey"); mPassKeySequence = Settings::getInstance()->getString("UIMode_passkey");
mCurrentUIMode = Settings::getInstance()->getString("UIMode"); mCurrentUIMode = Settings::getInstance()->getString("UIMode");

View file

@ -37,7 +37,6 @@ public:
bool isUIModeFull(); bool isUIModeFull();
bool isUIModeKid(); bool isUIModeKid();
bool isUIModeKiosk(); bool isUIModeKiosk();
inline std::vector<std::string> getUIModes() { return mUIModes; };
private: private:
UIModeController(); UIModeController();
@ -47,8 +46,7 @@ private:
// Return UI mode to 'full'. // Return UI mode to 'full'.
void unlockUIMode(); void unlockUIMode();
static UIModeController * sInstance; static UIModeController* sInstance;
const std::vector<std::string> mUIModes = { "full", "kiosk", "kid" };
// Default passkeyseq = "uuddlrlrba", as defined in the setting 'UIMode_passkey'. // Default passkeyseq = "uuddlrlrba", as defined in the setting 'UIMode_passkey'.
std::string mPassKeySequence; std::string mPassKeySequence;

View file

@ -40,18 +40,18 @@ int PowerSaver::getTimeout()
void PowerSaver::loadWakeupTime() void PowerSaver::loadWakeupTime()
{ {
// TODO : Move this to Screensaver Class. // TODO : Move this to Screensaver Class.
std::string behaviour = Settings::getInstance()->getString("ScreenSaverBehavior"); std::string behaviour = Settings::getInstance()->getString("ScreensaverBehavior");
if (behaviour == "video") if (behaviour == "video")
mWakeupTimeout = Settings::getInstance()->getInt("ScreenSaverSwapVideoTimeout") - getMode(); mWakeupTimeout = Settings::getInstance()->getInt("ScreensaverSwapVideoTimeout") - getMode();
else if (behaviour == "slideshow") else if (behaviour == "slideshow")
mWakeupTimeout = Settings::getInstance()->getInt("ScreenSaverSwapImageTimeout") - getMode(); mWakeupTimeout = Settings::getInstance()->getInt("ScreensaverSwapImageTimeout") - getMode();
else // Dim and Blank. else // Dim and Blank.
mWakeupTimeout = -1; mWakeupTimeout = -1;
} }
void PowerSaver::updateTimeouts() void PowerSaver::updateTimeouts()
{ {
mScreenSaverTimeout = (unsigned int) Settings::getInstance()->getInt("ScreenSaverTime"); mScreenSaverTimeout = (unsigned int) Settings::getInstance()->getInt("ScreensaverTimer");
mScreenSaverTimeout = mScreenSaverTimeout > 0 ? mScreenSaverTimeout - getMode() : -1; mScreenSaverTimeout = mScreenSaverTimeout > 0 ? mScreenSaverTimeout - getMode() : -1;
loadWakeupTime(); loadWakeupTime();
} }

View file

@ -79,6 +79,26 @@ void Settings::setDefaults()
// Settings configured via the in-program settings menu. // Settings configured via the in-program settings menu.
// //
// Scraper.
mStringMap["Scraper"] = "screenscraper";
mBoolMap["ScrapeGameNames"] = true;
mBoolMap["ScrapeRatings"] = true;
mBoolMap["ScrapeMetadata"] = true;
mBoolMap["ScrapeVideos"] = true;
mBoolMap["ScrapeScreenshots"] = true;
mBoolMap["ScrapeCovers"] = true;
mBoolMap["ScrapeMarquees"] = true;
mBoolMap["Scrape3DBoxes"] = true;
mStringMap["ScraperRegion"] = "eu";
mStringMap["ScraperLanguage"] = "en";
mBoolMap["ScraperOverwriteData"] = true;
mBoolMap["ScraperSearchMetadataName"] = true;
mBoolMap["ScraperInteractive"] = true;
mBoolMap["ScraperSemiautomatic"] = true;
mBoolMap["ScraperRespectExclusions"] = true;
mBoolMap["ScraperExcludeRecursively"] = true;
mBoolMap["ScraperIncludeFolders"] = false;
// UI settings. // UI settings.
mStringMap["StartupSystem"] = ""; mStringMap["StartupSystem"] = "";
mStringMap["GamelistViewStyle"] = "automatic"; mStringMap["GamelistViewStyle"] = "automatic";
@ -87,44 +107,42 @@ void Settings::setDefaults()
mStringMap["UIMode"] = "full"; mStringMap["UIMode"] = "full";
mStringMap["DefaultSortOrder"] = "filename, ascending"; mStringMap["DefaultSortOrder"] = "filename, ascending";
mStringMap["MenuOpeningEffect"] = "scale-up"; mStringMap["MenuOpeningEffect"] = "scale-up";
mBoolMap["MoveCarousel"] = true; mBoolMap["CarouselTransitions"] = true;
mBoolMap["GamelistVideoScanlines"] = true; mBoolMap["GamelistVideoScanlines"] = true;
mBoolMap["FoldersOnTop"] = true; mBoolMap["FoldersOnTop"] = true;
mBoolMap["FavoritesFirst"] = true; mBoolMap["FavoritesFirst"] = true;
mBoolMap["FavoritesStar"] = true; mBoolMap["FavoritesStar"] = true;
mBoolMap["FavoritesAddButton"] = true; mBoolMap["FavoritesAddButton"] = true;
mBoolMap["ForceDisableFilters"] = false; mBoolMap["GamelistFilters"] = true;
mBoolMap["QuickSystemSelect"] = true; mBoolMap["QuickSystemSelect"] = true;
mBoolMap["ShowHelpPrompts"] = true; mBoolMap["ShowHelpPrompts"] = true;
mBoolMap["PlayVideosImmediately"] = false; mBoolMap["PlayVideosImmediately"] = false;
mBoolMap["ShowKidStartMenu"] = false; mBoolMap["ShowKidStartMenu"] = false;
// UI settings -> scrensaver settings. // UI settings -> screensaver settings.
mIntMap["ScreenSaverTime"] = 5*60*1000; // 5 minutes mIntMap["ScreensaverTimer"] = 5*60*1000; // 5 minutes
mBoolMap["ScreenSaverControls"] = true; mBoolMap["ScreensaverControls"] = true;
mStringMap["ScreenSaverBehavior"] = "dim"; mStringMap["ScreensaverBehavior"] = "dim";
// UI settings -> screensaver settings -> slideshow screensaver settings. // UI settings -> screensaver settings -> slideshow screensaver settings.
mIntMap["ScreenSaverSwapImageTimeout"] = 10000; mIntMap["ScreensaverSwapImageTimeout"] = 8000;
mBoolMap["ScreenSaverStretchImages"] = false; mBoolMap["ScreensaverStretchImages"] = false;
mBoolMap["ScreenSaverImageScanlines"] = true; mBoolMap["ScreensaverImageScanlines"] = true;
mStringMap["SlideshowScreenSaverBackgroundAudioFile"] = Utils::FileSystem::getHomePath() + mStringMap["ScreensaverSlideshowAudioFile"] =
"/.emulationstation/slideshow/audio/slideshow_bg.wav"; "~/.emulationstation/slideshow/audio/slideshow.wav";
mBoolMap["SlideshowScreenSaverCustomImageSource"] = false; mBoolMap["ScreensaverSlideshowCustomImages"] = false;
mStringMap["SlideshowScreenSaverImageDir"] = Utils::FileSystem::getHomePath() + mStringMap["ScreensaverSlideshowImageDir"] = "~/.emulationstation/slideshow/custom_images";
"/.emulationstation/slideshow/image"; mBoolMap["ScreensaverSlideshowRecurse"] = false;
mBoolMap["SlideshowScreenSaverRecurse"] = false;
mStringMap["SlideshowScreenSaverImageFilter"] = ".png,.jpg";
// UI settings -> screensaver settings -> video screensaver settings. // UI settings -> screensaver settings -> video screensaver settings.
mIntMap["ScreenSaverSwapVideoTimeout"] = 25000; mIntMap["ScreensaverSwapVideoTimeout"] = 25000;
mBoolMap["ScreenSaverStretchVideos"] = false; mBoolMap["ScreensaverStretchVideos"] = false;
#if defined(_RPI_) #if defined(_RPI_)
mStringMap["ScreenSaverGameInfo"] = "never"; mStringMap["ScreensaverGameInfo"] = "never";
#endif #endif
mBoolMap["ScreenSaverVideoAudio"] = false; mBoolMap["ScreensaverVideoAudio"] = false;
mBoolMap["ScreenSaverVideoScanlines"] = true; mBoolMap["ScreensaverVideoScanlines"] = true;
mBoolMap["ScreenSaverVideoBlur"] = false; mBoolMap["ScreensaverVideoBlur"] = false;
// Sound settings. // Sound settings.
// The ALSA Audio Card and Audio Device selection code is disabled at the moment. // The ALSA Audio Card and Audio Device selection code is disabled at the moment.
@ -151,66 +169,43 @@ void Settings::setDefaults()
// Game collection settings. // Game collection settings.
mStringMap["CollectionSystemsAuto"] = ""; mStringMap["CollectionSystemsAuto"] = "";
mStringMap["CollectionSystemsCustom"] = ""; mStringMap["CollectionSystemsCustom"] = "";
mBoolMap["UseCustomCollectionsSystem"] = true;
mBoolMap["FavFirstCustom"] = false; mBoolMap["FavFirstCustom"] = false;
mBoolMap["FavStarCustom"] = false; mBoolMap["FavStarCustom"] = false;
mBoolMap["UseCustomCollectionsSystem"] = true;
mBoolMap["CollectionShowSystemInfo"] = true; mBoolMap["CollectionShowSystemInfo"] = true;
// Scraper.
mStringMap["Scraper"] = "screenscraper";
mStringMap["ScraperRegion"] = "eu";
mStringMap["ScraperLanguage"] = "en";
// mBoolMap["ScraperGenerateMiximages"] = false;
// mBoolMap["ScraperGenerateThumbnails"] = false;
mBoolMap["ScraperInteractive"] = true;
mBoolMap["ScraperSemiautomatic"] = true;
mBoolMap["ScraperSearchMetadataName"] = true;
mBoolMap["ScraperOverwriteData"] = true;
mBoolMap["ScraperRespectExclusions"] = true;
mBoolMap["ScraperExcludeRecursively"] = true;
mBoolMap["ScraperIncludeFolders"] = false;
mBoolMap["ScrapeMetadata"] = true;
mBoolMap["ScrapeGameNames"] = true;
mBoolMap["ScrapeRatings"] = true;
mBoolMap["Scrape3DBoxes"] = true;
mBoolMap["ScrapeCovers"] = true;
mBoolMap["ScrapeMarquees"] = true;
mBoolMap["ScrapeScreenshots"] = true;
mBoolMap["ScrapeVideos"] = true;
// Other settings. // Other settings.
#if defined(_RPI_) #if defined(_RPI_)
mIntMap["MaxVRAM"] = 80; mIntMap["MaxVRAM"] = 80;
#else #else
mIntMap["MaxVRAM"] = 128; mIntMap["MaxVRAM"] = 128;
#endif #endif
#if defined (__unix__) #if defined (__unix__)
mStringMap["FullscreenMode"] = "normal"; mStringMap["FullscreenMode"] = "normal";
#endif #endif
mStringMap["PowerSaverMode"] = "disabled"; mStringMap["PowerSaverMode"] = "disabled";
// This setting only applies to raspberry pi but set it for all platforms so // This setting only applies to Raspberry Pi but we set it for all platforms so
// we don't get a warning if we encounter it on a different platform. // we don't get a warning if we encounter it on a different platform.
mBoolMap["VideoOmxPlayer"] = false; mBoolMap["VideoOmxPlayer"] = false;
#if defined(_RPI_) #if defined(_RPI_)
// We're defaulting to OMX Player for full screen video on the Pi. // We're defaulting to OMX Player for full screen video on the Pi.
mBoolMap["ScreenSaverOmxPlayer"] = true; mBoolMap["ScreensaverOmxPlayer"] = true;
#else
mBoolMap["ScreenSaverOmxPlayer"] = false;
#endif #endif
mStringMap["SaveGamelistsMode"] = "always"; mStringMap["SaveGamelistsMode"] = "always";
#if defined(_WIN64) #if defined(_WIN64)
mBoolMap["HideTaskbar"] = false; mBoolMap["HideTaskbar"] = false;
// Set this to true as default as it's unreliable to suspend ES during game launches // This setting may cause problems on some Windows versions, but it seems as if Windows 10
// on some Windows versions/installations. // handles the suspension of ES correctly. As there are some adverse affects from running ES
mBoolMap["RunInBackground"] = true; // in the background while a game is running, by default this is set to false.
mBoolMap["RunInBackground"] = false;
#endif #endif
mStringMap["MediaDirectory"] = ""; mStringMap["MediaDirectory"] = "";
mBoolMap["LaunchCommandOverride"] = true; mBoolMap["LaunchCommandOverride"] = true;
mBoolMap["CustomEventScripts"] = false;
mBoolMap["ParseGamelistOnly"] = false;
mBoolMap["LocalArt"] = false;
mBoolMap["ShowHiddenFiles"] = true; mBoolMap["ShowHiddenFiles"] = true;
mBoolMap["ShowHiddenGames"] = true; mBoolMap["ShowHiddenGames"] = true;
mBoolMap["CustomEventScripts"] = false;
mBoolMap["ParseGamelistOnly"] = false;
mBoolMap["ROMDirGameMedia"] = false;
mBoolMap["DisplayGPUStatistics"] = false; mBoolMap["DisplayGPUStatistics"] = false;
// macOS requires root privileges to reboot and power off so it doesn't make much // macOS requires root privileges to reboot and power off so it doesn't make much
// sense to enable these settings and menu entries for this operating system. // sense to enable these settings and menu entries for this operating system.
@ -293,7 +288,6 @@ void Settings::saveFile()
saveMap<std::string, int>(doc, mIntMap, "int"); saveMap<std::string, int>(doc, mIntMap, "int");
saveMap<std::string, float>(doc, mFloatMap, "float"); saveMap<std::string, float>(doc, mFloatMap, "float");
//saveMap<std::string, std::string>(doc, mStringMap, "string");
for (auto iter = mStringMap.cbegin(); iter != mStringMap.cend(); iter++) { for (auto iter = mStringMap.cbegin(); iter != mStringMap.cend(); iter++) {
pugi::xml_node node = doc.append_child("string"); pugi::xml_node node = doc.append_child("string");
node.append_attribute("name").set_value(iter->first.c_str()); node.append_attribute("name").set_value(iter->first.c_str());

View file

@ -146,9 +146,9 @@ void Window::input(InputConfig* config, Input input)
if (mScreenSaver) { if (mScreenSaver) {
if (mScreenSaver->isScreenSaverActive() && if (mScreenSaver->isScreenSaverActive() &&
Settings::getInstance()->getBool("ScreenSaverControls") && Settings::getInstance()->getBool("ScreensaverControls") &&
((Settings::getInstance()->getString("ScreenSaverBehavior") == "video") || ((Settings::getInstance()->getString("ScreensaverBehavior") == "video") ||
(Settings::getInstance()->getString("ScreenSaverBehavior") == "slideshow"))) { (Settings::getInstance()->getString("ScreensaverBehavior") == "slideshow"))) {
if (mScreenSaver->getCurrentGame() != nullptr && if (mScreenSaver->getCurrentGame() != nullptr &&
(config->isMappedTo("a", input) || (config->isMappedTo("a", input) ||
config->isMappedLike("left", input) || config->isMappedLike("right", input))) { config->isMappedLike("left", input) || config->isMappedLike("right", input))) {
@ -358,11 +358,11 @@ void Window::render()
if (!mRenderedHelpPrompts) if (!mRenderedHelpPrompts)
mHelp->render(transform); mHelp->render(transform);
unsigned int screensaverTime = unsigned int screensaverTimer =
static_cast<unsigned int>(Settings::getInstance()->getInt("ScreenSaverTime")); static_cast<unsigned int>(Settings::getInstance()->getInt("ScreensaverTimer"));
// If a game has been launched, reset the screensaver timer when it's been reached as we // If a game has been launched, reset the screensaver timer when it's been reached as we
// don't want to start the screensaver in the background when running a game. // don't want to start the screensaver in the background when running a game.
if (mTimeSinceLastInput >= screensaverTime && screensaverTime != 0) { if (mTimeSinceLastInput >= screensaverTimer && screensaverTimer != 0) {
if (mGameLaunchedState) if (mGameLaunchedState)
mTimeSinceLastInput = 0; mTimeSinceLastInput = 0;
else if (!isProcessing() && !mScreenSaver->isScreenSaverActive()) else if (!isProcessing() && !mScreenSaver->isScreenSaverActive())
@ -376,7 +376,7 @@ void Window::render()
if (!mRenderScreenSaver && mInfoPopup) if (!mRenderScreenSaver && mInfoPopup)
mInfoPopup->render(transform); mInfoPopup->render(transform);
if (mTimeSinceLastInput >= screensaverTime && screensaverTime != 0) { if (mTimeSinceLastInput >= screensaverTimer && screensaverTimer != 0) {
if (!isProcessing() && mAllowSleep && (!mScreenSaver)) { if (!isProcessing() && mAllowSleep && (!mScreenSaver)) {
// Go to sleep. // Go to sleep.
if (mSleeping == false) { if (mSleeping == false) {
@ -389,11 +389,11 @@ void Window::render()
#if defined(USE_OPENGL_21) #if defined(USE_OPENGL_21)
// Shaders for the screensavers. // Shaders for the screensavers.
if (mScreenSaver->isScreenSaverActive()) { if (mScreenSaver->isScreenSaverActive()) {
if (Settings::getInstance()->getString("ScreenSaverBehavior") == "video") { if (Settings::getInstance()->getString("ScreensaverBehavior") == "video") {
if (mScreenSaver->getVideoCount() > 0) { if (mScreenSaver->getVideoCount() > 0) {
if (Settings::getInstance()->getBool("ScreenSaverVideoBlur")) if (Settings::getInstance()->getBool("ScreensaverVideoBlur"))
Renderer::shaderPostprocessing(Renderer::SHADER_BLUR_HORIZONTAL); Renderer::shaderPostprocessing(Renderer::SHADER_BLUR_HORIZONTAL);
if (Settings::getInstance()->getBool("ScreenSaverVideoScanlines")) if (Settings::getInstance()->getBool("ScreensaverVideoScanlines"))
Renderer::shaderPostprocessing(Renderer::SHADER_SCANLINES); Renderer::shaderPostprocessing(Renderer::SHADER_SCANLINES);
} }
else { else {
@ -405,11 +405,11 @@ void Window::render()
mDimValue = Math::clamp(mDimValue-0.045, 0.0, 1.0); mDimValue = Math::clamp(mDimValue-0.045, 0.0, 1.0);
} }
} }
else if (Settings::getInstance()->getString("ScreenSaverBehavior") == "slideshow") { else if (Settings::getInstance()->getString("ScreensaverBehavior") == "slideshow") {
if (Settings::getInstance()->getBool("ScreenSaverImageScanlines")) if (Settings::getInstance()->getBool("ScreensaverImageScanlines"))
Renderer::shaderPostprocessing(Renderer::SHADER_SCANLINES); Renderer::shaderPostprocessing(Renderer::SHADER_SCANLINES);
} }
else if (Settings::getInstance()->getString("ScreenSaverBehavior") == "dim") { else if (Settings::getInstance()->getString("ScreensaverBehavior") == "dim") {
Renderer::shaderParameters dimParameters; Renderer::shaderParameters dimParameters;
dimParameters.fragmentDimValue = mDimValue; dimParameters.fragmentDimValue = mDimValue;
Renderer::shaderPostprocessing(Renderer::SHADER_DIM, dimParameters); Renderer::shaderPostprocessing(Renderer::SHADER_DIM, dimParameters);
@ -420,7 +420,7 @@ void Window::render()
if (mSaturationAmount > 0.0) if (mSaturationAmount > 0.0)
mSaturationAmount = Math::clamp(mSaturationAmount-0.035, 0.0, 1.0); mSaturationAmount = Math::clamp(mSaturationAmount-0.035, 0.0, 1.0);
} }
else if (Settings::getInstance()->getString("ScreenSaverBehavior") == "black") { else if (Settings::getInstance()->getString("ScreensaverBehavior") == "black") {
Renderer::shaderParameters blackParameters; Renderer::shaderParameters blackParameters;
blackParameters.fragmentDimValue = mDimValue; blackParameters.fragmentDimValue = mDimValue;
Renderer::shaderPostprocessing(Renderer::SHADER_DIM, blackParameters); Renderer::shaderPostprocessing(Renderer::SHADER_DIM, blackParameters);

View file

@ -22,7 +22,8 @@ MenuComponent::MenuComponent(
const std::shared_ptr<Font>& titleFont) const std::shared_ptr<Font>& titleFont)
: GuiComponent(window), : GuiComponent(window),
mBackground(window), mBackground(window),
mGrid(window, Vector2i(1, 3)) mGrid(window, Vector2i(1, 3)),
mNeedsSaving(false)
{ {
addChild(&mBackground); addChild(&mBackground);
addChild(&mGrid); addChild(&mGrid);
@ -59,7 +60,10 @@ void MenuComponent::save()
for (auto it = mSaveFuncs.cbegin(); it != mSaveFuncs.cend(); it++) for (auto it = mSaveFuncs.cbegin(); it != mSaveFuncs.cend(); it++)
(*it)(); (*it)();
Settings::getInstance()->saveFile(); if (mNeedsSaving) {
Settings::getInstance()->saveFile();
mNeedsSaving = false;
}
} }
void MenuComponent::setTitle(const char* title, const std::shared_ptr<Font>& font) void MenuComponent::setTitle(const char* title, const std::shared_ptr<Font>& font)

View file

@ -34,6 +34,8 @@ public:
void save(); void save();
void onSizeChanged() override; void onSizeChanged() override;
void setNeedsSaving() { mNeedsSaving = true; };
inline void addRow(const ComponentListRow& row, bool setCursorHere = false) inline void addRow(const ComponentListRow& row, bool setCursorHere = false)
{ mList->addRow(row, setCursorHere); updateSize(); } { mList->addRow(row, setCursorHere); updateSize(); }
@ -70,8 +72,10 @@ private:
std::shared_ptr<TextComponent> mTitle; std::shared_ptr<TextComponent> mTitle;
std::shared_ptr<ComponentList> mList; std::shared_ptr<ComponentList> mList;
std::shared_ptr<ComponentGrid> mButtonGrid; std::shared_ptr<ComponentGrid> mButtonGrid;
std::vector< std::shared_ptr<ButtonComponent> > mButtons; std::vector<std::shared_ptr<ButtonComponent>> mButtons;
std::vector< std::function<void()> > mSaveFuncs; std::vector<std::function<void()>> mSaveFuncs;
bool mNeedsSaving;
}; };
#endif // ES_CORE_COMPONENTS_MENU_COMPONENT_H #endif // ES_CORE_COMPONENTS_MENU_COMPONENT_H

View file

@ -332,7 +332,7 @@ void VideoComponent::onScreenSaverActivate()
{ {
mBlockPlayer = true; mBlockPlayer = true;
mPause = true; mPause = true;
if (Settings::getInstance()->getString("ScreenSaverBehavior") == "dim") if (Settings::getInstance()->getString("ScreensaverBehavior") == "dim")
stopVideo(); stopVideo();
manageState(); manageState();
} }

View file

@ -165,7 +165,7 @@ void VideoPlayerComponent::startVideo()
// Check if we want to mute the audio. // Check if we want to mute the audio.
if ((!Settings::getInstance()->getBool("GamelistVideoAudio") || if ((!Settings::getInstance()->getBool("GamelistVideoAudio") ||
(float)VolumeControl::getInstance()->getVolume() == 0) || (float)VolumeControl::getInstance()->getVolume() == 0) ||
(!Settings::getInstance()->getBool("ScreenSaverVideoAudio") && (!Settings::getInstance()->getBool("ScreensaverVideoAudio") &&
mScreensaverMode)) { mScreensaverMode)) {
argv[8] = "-1000000"; argv[8] = "-1000000";
} }

View file

@ -237,7 +237,7 @@ void VideoVlcComponent::handleLooping()
libvlc_media_player_set_media(mMediaPlayer, mMedia); libvlc_media_player_set_media(mMediaPlayer, mMedia);
if ((!Settings::getInstance()->getBool("GamelistVideoAudio") && !mScreensaverMode) || if ((!Settings::getInstance()->getBool("GamelistVideoAudio") && !mScreensaverMode) ||
(!Settings::getInstance()->getBool("ScreenSaverVideoAudio") && mScreensaverMode)) (!Settings::getInstance()->getBool("ScreensaverVideoAudio") && mScreensaverMode))
libvlc_audio_set_mute(mMediaPlayer, 1); libvlc_audio_set_mute(mMediaPlayer, 1);
libvlc_media_player_play(mMediaPlayer); libvlc_media_player_play(mMediaPlayer);
@ -316,7 +316,7 @@ void VideoVlcComponent::startVideo()
if ((!Settings::getInstance()->getBool("GamelistVideoAudio") && if ((!Settings::getInstance()->getBool("GamelistVideoAudio") &&
!mScreensaverMode) || !mScreensaverMode) ||
(!Settings::getInstance()->getBool("ScreenSaverVideoAudio") && (!Settings::getInstance()->getBool("ScreensaverVideoAudio") &&
mScreensaverMode)) mScreensaverMode))
libvlc_audio_set_mute(mMediaPlayer, 1); libvlc_audio_set_mute(mMediaPlayer, 1);