diff --git a/es-app/src/VolumeControl.cpp b/es-app/src/VolumeControl.cpp index fe944223e..c2c220c77 100644 --- a/es-app/src/VolumeControl.cpp +++ b/es-app/src/VolumeControl.cpp @@ -8,12 +8,24 @@ #include "math/Misc.h" #include "Log.h" + +#ifdef _RPI_ #include "Settings.h" +#endif #ifdef _WIN64 #include #endif +// The ALSA Audio Card and Audio Device selection code is disabled at the moment. +// As PulseAudio controls the sound devices for the desktop environment, it doesn't +// make much sense to be able to select ALSA devices directly. Normally (always?) +// the selection doesn't make any difference at all. But maybe some PulseAudio +// settings could be added later on, if needed. +// The code is still active for Raspberry Pi though as I'm not sure if this is +// useful for that device. +// Keeping mixerName and mixerCard at their default values should make sure that +// the rest of the volume control code in here compiles and works fine. #if defined(__linux__) #if defined(_RPI_) || defined(_VERO4K_) const char * VolumeControl::mixerName = "PCM"; @@ -102,8 +114,10 @@ void VolumeControl::init() // Try to open mixer device. if (mixerHandle == nullptr) { // Allow user to override the AudioCard and AudioDevice in es_settings.cfg. + #ifdef _RPI_ mixerCard = Settings::getInstance()->getString("AudioCard").c_str(); mixerName = Settings::getInstance()->getString("AudioDevice").c_str(); + #endif snd_mixer_selem_id_alloca(&mixerSelemId); // Sets simple-mixer index and name. @@ -312,8 +326,7 @@ int VolumeControl::getVolume() const float floatVolume = 0.0f; // 0-1 if (endpointVolume->GetMasterVolumeLevelScalar(&floatVolume) == S_OK) { volume = (int)Math::round(floatVolume * 100.0f); - LOG(LogInfo) << "System audio volume is " << volume << - " (floating point value " << floatVolume << ")"; + LOG(LogInfo) << "System audio volume is " << volume; } else { LOG(LogError) << "VolumeControl::getVolume() - Failed to get master volume!"; diff --git a/es-app/src/guis/GuiMenu.cpp b/es-app/src/guis/GuiMenu.cpp index f97050ae8..5d711ec4f 100644 --- a/es-app/src/guis/GuiMenu.cpp +++ b/es-app/src/guis/GuiMenu.cpp @@ -87,7 +87,15 @@ void GuiMenu::openSoundSettings() setVolume((int)Math::round(volume->getValue())); }); if (UIModeController::getInstance()->isUIModeFull()) { - #if defined(__linux__) + // The ALSA Audio Card and Audio Device selection code is disabled at the moment. + // As PulseAudio controls the sound devices for the desktop environment, it doesn't + // make much sense to be able to select ALSA devices directly. Normally (always?) + // the selection doesn't make any difference at all. But maybe some PulseAudio + // settings could be added later on, if needed. + // The code is still active for Raspberry Pi though as I'm not sure if this is + // useful for that device. + // #if defined(__linux__) + #ifdef _RPI_ // audio card auto audio_card = std::make_shared> (mWindow, getHelpStyle(), "AUDIO CARD", false); @@ -173,24 +181,24 @@ void GuiMenu::openSoundSettings() // Video audio. auto video_audio = std::make_shared(mWindow); video_audio->setState(Settings::getInstance()->getBool("VideoAudio")); - s->addWithLabel("ENABLE AUDIO FOR VIDEO FILES", video_audio); + s->addWithLabel("AUDIO FOR VIDEO FILES", video_audio); s->addSaveFunc([video_audio] { Settings::getInstance()->setBool("VideoAudio", video_audio->getState()); }); // Navigation sounds. - auto navigationsounds_enabled = std::make_shared(mWindow); - navigationsounds_enabled->setState(Settings::getInstance()-> - getBool("EnableNavigationSounds")); - s->addWithLabel("ENABLE NAVIGATION SOUNDS", navigationsounds_enabled); - s->addSaveFunc([navigationsounds_enabled] { - if (navigationsounds_enabled->getState() && - !Settings::getInstance()->getBool("EnableNavigationSounds") && + auto navigation_sounds = std::make_shared(mWindow); + navigation_sounds->setState(Settings::getInstance()-> + getBool("NavigationSounds")); + s->addWithLabel("NAVIGATION SOUNDS", navigation_sounds); + s->addSaveFunc([navigation_sounds] { + if (navigation_sounds->getState() && + !Settings::getInstance()->getBool("NavigationSounds") && PowerSaver::getMode() == PowerSaver::INSTANT) { Settings::getInstance()->setString("PowerSaverMode", "default"); PowerSaver::init(); } - Settings::getInstance()->setBool("EnableNavigationSounds", - navigationsounds_enabled->getState()); + Settings::getInstance()->setBool("NavigationSounds", + navigation_sounds->getState()); }); } @@ -353,7 +361,7 @@ void GuiMenu::openUISettings() // Enable filters (ForceDisableFilters). auto enable_filter = std::make_shared(mWindow); enable_filter->setState(!Settings::getInstance()->getBool("ForceDisableFilters")); - s->addWithLabel("ENABLE GAMELIST FILTERS", enable_filter); + s->addWithLabel("GAMELIST FILTERS", enable_filter); s->addSaveFunc([enable_filter] { bool filter_is_enabled = !Settings::getInstance()->getBool("ForceDisableFilters"); Settings::getInstance()->setBool("ForceDisableFilters", !enable_filter->getState()); @@ -382,13 +390,6 @@ void GuiMenu::openUISettings() Settings::getInstance()->setBool("MoveCarousel", move_carousel->getState()); }); - // Hide start menu in Kid Mode. - auto disable_start = std::make_shared(mWindow); - disable_start->setState(Settings::getInstance()->getBool("DisableKidStartMenu")); - s->addWithLabel("DISABLE START MENU IN KID MODE", disable_start); - s->addSaveFunc([disable_start] { Settings::getInstance()->setBool("DisableKidStartMenu", - disable_start->getState()); }); - // Show help. auto show_help = std::make_shared(mWindow); show_help->setState(Settings::getInstance()->getBool("ShowHelpPrompts")); @@ -396,6 +397,13 @@ void GuiMenu::openUISettings() s->addSaveFunc([show_help] { Settings::getInstance()->setBool("ShowHelpPrompts", show_help->getState()); }); + // Whether to show start menu in Kid Mode. + auto show_kidstartmenu = std::make_shared(mWindow); + show_kidstartmenu->setState(Settings::getInstance()->getBool("ShowKidStartMenu")); + s->addWithLabel("SHOW START MENU IN KID MODE", show_kidstartmenu); + s->addSaveFunc([show_kidstartmenu] { Settings::getInstance()->setBool("ShowKidStartMenu", + show_kidstartmenu->getState()); }); + // Screensaver. ComponentListRow screensaver_row; screensaver_row.elements.clear(); @@ -453,7 +461,7 @@ void GuiMenu::openOtherSettings() "instant" && power_saver->getSelected() == "instant") { Settings::getInstance()->setString("TransitionStyle", "instant"); Settings::getInstance()->setBool("MoveCarousel", false); - Settings::getInstance()->setBool("EnableNavigationSounds", false); + Settings::getInstance()->setBool("NavigationSounds", false); } Settings::getInstance()->setString("PowerSaverMode", power_saver->getSelected()); PowerSaver::init(); @@ -499,10 +507,17 @@ void GuiMenu::openOtherSettings() // to disable this is intended primarily for testing purposes). auto launchcommand_override = std::make_shared(mWindow); launchcommand_override->setState(Settings::getInstance()->getBool("LaunchCommandOverride")); - s->addWithLabel("ENABLE PER GAME LAUNCH COMMAND OVERRIDE", launchcommand_override); + s->addWithLabel("PER GAME LAUNCH COMMAND OVERRIDE", launchcommand_override); s->addSaveFunc([launchcommand_override] { Settings::getInstance()-> setBool("LaunchCommandOverride", launchcommand_override->getState()); }); + // Custom event scripts, fired using Scripting::fireEvent(). + auto custom_eventscripts = std::make_shared(mWindow); + custom_eventscripts->setState(Settings::getInstance()->getBool("CustomEventScripts")); + s->addWithLabel("CUSTOM EVENT SCRIPTS", custom_eventscripts); + s->addSaveFunc([custom_eventscripts] { Settings::getInstance()-> + setBool("CustomEventScripts", custom_eventscripts->getState()); }); + auto parse_gamelists = std::make_shared(mWindow); parse_gamelists->setState(Settings::getInstance()->getBool("ParseGamelistOnly")); s->addWithLabel("ONLY SHOW ROMS FROM GAMELIST.XML FILES", parse_gamelists); diff --git a/es-app/src/scrapers/Scraper.cpp b/es-app/src/scrapers/Scraper.cpp index d51cb6270..879da3fa8 100644 --- a/es-app/src/scrapers/Scraper.cpp +++ b/es-app/src/scrapers/Scraper.cpp @@ -246,8 +246,8 @@ MDResolveHandle::MDResolveHandle(const ScraperSearchResult& result, } // Resize it. - if (!resizeImage(filePath, Settings::getInstance()->getInt("ScraperResizeWidth"), - Settings::getInstance()->getInt("ScraperResizeHeight"))) { + if (!resizeImage(filePath, Settings::getInstance()->getInt("ScraperResizeMaxWidth"), + Settings::getInstance()->getInt("ScraperResizeMaxHeight"))) { setError("Error saving resized image. Out of memory? Disk full?"); return; } @@ -292,8 +292,8 @@ std::unique_ptr downloadImageAsync(const std::string& url, url, saveAs, existingMediaFile, - Settings::getInstance()->getInt("ScraperResizeWidth"), - Settings::getInstance()->getInt("ScraperResizeHeight"))); + Settings::getInstance()->getInt("ScraperResizeMaxWidth"), + Settings::getInstance()->getInt("ScraperResizeMaxHeight"))); } ImageDownloadHandle::ImageDownloadHandle( diff --git a/es-app/src/scrapers/Scraper.h b/es-app/src/scrapers/Scraper.h index e6870615f..d83530fa2 100644 --- a/es-app/src/scrapers/Scraper.h +++ b/es-app/src/scrapers/Scraper.h @@ -203,8 +203,8 @@ private: std::string getSaveAsPath(const ScraperSearchParams& params, const std::string& filetypeSubdirectory, const std::string& url); -// Will resize according to Settings::getInt("ScraperResizeWidth") and -// Settings::getInt("ScraperResizeHeight"). +// Will resize according to Settings::getInt("ScraperResizeMaxWidth") and +// Settings::getInt("ScraperResizeMaxHeight"). std::unique_ptr downloadImageAsync(const std::string& url, const std::string& saveAs, const std::string& existingMediaPath); diff --git a/es-app/src/views/SystemView.h b/es-app/src/views/SystemView.h index 3004b8dba..0c2427751 100644 --- a/es-app/src/views/SystemView.h +++ b/es-app/src/views/SystemView.h @@ -13,6 +13,7 @@ #include "resources/Font.h" #include "GuiComponent.h" #include "Sound.h" + #include class AnimatedImageComponent; diff --git a/es-app/src/views/ViewController.cpp b/es-app/src/views/ViewController.cpp index 224e53409..68a19661f 100644 --- a/es-app/src/views/ViewController.cpp +++ b/es-app/src/views/ViewController.cpp @@ -388,7 +388,7 @@ bool ViewController::input(InputConfig* config, Input input) // Open menu. if (!(UIModeController::getInstance()->isUIModeKid() && - Settings::getInstance()->getBool("DisableKidStartMenu")) && + !Settings::getInstance()->getBool("ShowKidStartMenu")) && config->isMappedTo("start", input) && input.value != 0) { // If we don't stop the scrolling here, it will continue to // run after closing the menu. @@ -564,7 +564,7 @@ std::vector ViewController::getHelpPrompts() prompts = mCurrentView->getHelpPrompts(); if (!(UIModeController::getInstance()->isUIModeKid() && - Settings::getInstance()->getBool("DisableKidStartMenu"))) + !Settings::getInstance()->getBool("ShowKidStartMenu"))) prompts.push_back(HelpPrompt("start", "menu")); return prompts; } diff --git a/es-core/src/AudioManager.cpp b/es-core/src/AudioManager.cpp index 977e4eb73..bad9ba604 100644 --- a/es-core/src/AudioManager.cpp +++ b/es-core/src/AudioManager.cpp @@ -73,7 +73,7 @@ AudioManager::~AudioManager() std::shared_ptr & AudioManager::getInstance() { // Check if an AudioManager instance is already created, if not create one. - if (sInstance == nullptr && Settings::getInstance()->getBool("EnableNavigationSounds")) { + if (sInstance == nullptr && Settings::getInstance()->getBool("NavigationSounds")) { sInstance = std::shared_ptr(new AudioManager); } return sInstance; diff --git a/es-core/src/Scripting.cpp b/es-core/src/Scripting.cpp index d230dde57..0a0c6dc76 100644 --- a/es-core/src/Scripting.cpp +++ b/es-core/src/Scripting.cpp @@ -11,14 +11,19 @@ // #include "Scripting.h" + +#include "utils/FileSystemUtil.h" #include "Log.h" #include "Platform.h" -#include "utils/FileSystemUtil.h" +#include "Settings.h" namespace Scripting { void fireEvent(const std::string& eventName, const std::string& arg1, const std::string& arg2) { + if (!Settings::getInstance()->getBool("CustomEventScripts")) + return; + LOG(LogDebug) << "fireEvent: " << eventName << " " << arg1 << " " << arg2; std::list scriptDirList; diff --git a/es-core/src/Settings.cpp b/es-core/src/Settings.cpp index 3cc9f3e4f..f415e0eb7 100644 --- a/es-core/src/Settings.cpp +++ b/es-core/src/Settings.cpp @@ -76,7 +76,7 @@ void Settings::setDefaults() // UI settings. mStringMap["StartupSystem"] = ""; - mStringMap["GamelistViewStyle"] = "automatic"; + mStringMap["GamelistViewStyle"] = "detailed"; mStringMap["TransitionStyle"] = "instant"; mStringMap["ThemeSet"] = ""; mStringMap["UIMode"] = "Full"; @@ -84,8 +84,8 @@ void Settings::setDefaults() mBoolMap["ForceDisableFilters"] = false; mBoolMap["QuickSystemSelect"] = true; mBoolMap["MoveCarousel"] = true; - mBoolMap["DisableKidStartMenu"] = true; mBoolMap["ShowHelpPrompts"] = true; + mBoolMap["ShowKidStartMenu"] = false; // UI settings -> scrensaver settings. mIntMap["ScreenSaverTime"] = 5*60*1000; // 5 minutes @@ -111,17 +111,26 @@ void Settings::setDefaults() mStringMap["SlideshowScreenSaverImageFilter"] = ".png,.jpg"; // Sound settings. + // The ALSA Audio Card and Audio Device selection code is disabled at the moment. + // As PulseAudio controls the sound devices for the desktop environment, it doesn't + // make much sense to be able to select ALSA devices directly. Normally (always?) + // the selection doesn't make any difference at all. But maybe some PulseAudio + // settings could be added later on, if needed. + // The code is still active for Raspberry Pi though as I'm not sure if this is + // useful for that device. + #ifdef _RPI_ mStringMap["AudioCard"] = "default"; // Audio out device for volume control. - #ifdef _RPI_ - mStringMap["AudioDevice"] = "PCM"; - #else - mStringMap["AudioDevice"] = "Master"; - #endif - mBoolMap["VideoAudio"] = true; - mBoolMap["EnableNavigationSounds"] = true; + //#endif + //#ifdef _RPI_ + mStringMap["AudioDevice"] = "PCM"; // Audio out device for Video playback using OMX player. mStringMap["OMXAudioDev"] = "both"; + //#else + // mStringMap["AudioDevice"] = "Master"; + #endif + mBoolMap["VideoAudio"] = true; + mBoolMap["NavigationSounds"] = true; // Game collection settings. mStringMap["CollectionSystemsAuto"] = ""; @@ -138,7 +147,7 @@ void Settings::setDefaults() // mBoolMap["ScraperGenerateThumbnails"] = false; mBoolMap["ScraperInteractive"] = true; mBoolMap["ScraperSemiautomatic"] = true; - mBoolMap["ScraperOverwriteData"] = false; + mBoolMap["ScraperOverwriteData"] = true; mBoolMap["ScrapeMetadata"] = true; mBoolMap["ScrapeGameNames"] = true; mBoolMap["ScrapeRatings"] = true; @@ -171,6 +180,7 @@ void Settings::setDefaults() #endif mStringMap["SaveGamelistsMode"] = "always"; mBoolMap["LaunchCommandOverride"] = true; + mBoolMap["CustomEventScripts"] = false; mBoolMap["ParseGamelistOnly"] = false; mBoolMap["LocalArt"] = false; mBoolMap["ShowHiddenFiles"] = false; @@ -209,8 +219,8 @@ void Settings::setDefaults() mStringMap["DefaultSortOrder"] = "filename, ascending"; mStringMap["MediaDirectory"] = ""; mStringMap["ROMDirectory"] = ""; - mIntMap["ScraperResizeWidth"] = 600; - mIntMap["ScraperResizeHeight"] = 0; + mIntMap["ScraperResizeMaxWidth"] = 600; + mIntMap["ScraperResizeMaxHeight"] = 0; // // Hardcoded or program-internal settings. @@ -275,7 +285,7 @@ void Settings::loadFile() pugi::xml_document doc; pugi::xml_parse_result result = doc.load_file(path.c_str()); if (!result) { - LOG(LogError) << "Could not parse Settings file!\n " << result.description(); + LOG(LogError) << "Error - Could not parse Settings file!\n " << result.description(); return; } @@ -295,7 +305,7 @@ void Settings::loadFile() type Settings::getMethodName(const std::string& name) \ { \ if (mapName.find(name) == mapName.cend()) { \ - LOG(LogError) << "Tried to use unset setting " << name << "!"; \ + LOG(LogError) << "Error - Tried to use unset setting " << name << "!"; \ } \ return mapName[name]; \ } \ diff --git a/es-core/src/Sound.cpp b/es-core/src/Sound.cpp index a475167c9..e2a48040a 100644 --- a/es-core/src/Sound.cpp +++ b/es-core/src/Sound.cpp @@ -164,7 +164,7 @@ void Sound::play() if(mSampleData == nullptr) return; - if(!Settings::getInstance()->getBool("EnableNavigationSounds")) + if(!Settings::getInstance()->getBool("NavigationSounds")) return; AudioManager::getInstance();