diff --git a/es-app/src/views/ViewController.cpp b/es-app/src/views/ViewController.cpp index ae75ca0c0..ab79fac78 100644 --- a/es-app/src/views/ViewController.cpp +++ b/es-app/src/views/ViewController.cpp @@ -881,10 +881,19 @@ void ViewController::preload() (*it)->getIndex()->resetFilters(); getGameListView(*it); } - // Load navigation sounds, but only if at least one system exists. - if (systemCount > 0) - NavigationSounds::getInstance()->loadThemeNavigationSounds( - SystemData::sSystemVector.front()->getTheme()); + + // Load navigation sounds, either from the theme if it supports it, or otherwise from + // the bundled fallback sound files. + bool themeSoundSupport = false; + for (SystemData* system : SystemData::sSystemVector) { + if (system->getTheme()->hasView("all")) { + NavigationSounds::getInstance()->loadThemeNavigationSounds(system->getTheme()); + themeSoundSupport = true; + break; + } + } + if (!SystemData::sSystemVector.empty() && !themeSoundSupport) + NavigationSounds::getInstance()->loadThemeNavigationSounds(nullptr); } void ViewController::reloadGameListView(IGameListView* view, bool reloadTheme) @@ -972,10 +981,19 @@ void ViewController::reloadAll() goToSystemView(SystemData::sSystemVector.front(), false); } - // Load navigation sounds. + // Load navigation sounds, either from the theme if it supports it, or otherwise from + // the bundled fallback sound files. NavigationSounds::getInstance()->deinit(); - NavigationSounds::getInstance()->loadThemeNavigationSounds( - SystemData::sSystemVector.front()->getTheme()); + bool themeSoundSupport = false; + for (SystemData* system : SystemData::sSystemVector) { + if (system->getTheme()->hasView("all")) { + NavigationSounds::getInstance()->loadThemeNavigationSounds(system->getTheme()); + themeSoundSupport = true; + break; + } + } + if (!SystemData::sSystemVector.empty() && !themeSoundSupport) + NavigationSounds::getInstance()->loadThemeNavigationSounds(nullptr); mCurrentView->onShow(); updateHelpPrompts(); diff --git a/es-core/src/Sound.cpp b/es-core/src/Sound.cpp index 6ca48d8a4..ab1dc64e5 100644 --- a/es-core/src/Sound.cpp +++ b/es-core/src/Sound.cpp @@ -34,14 +34,18 @@ std::shared_ptr Sound::get(const std::string& path) std::shared_ptr Sound::getFromTheme(const std::shared_ptr& theme, const std::string& view, const std::string& element) { - LOG(LogDebug) << "Sound::getFromTheme(): Looking for navigation sound tag "; + if (!theme) { + LOG(LogDebug) << "Sound::getFromTheme(): Using fallback sound file for \"" + << element << "\""; + return get(ResourceManager::getInstance()->getResourcePath(":/sounds/" + element + ".wav")); + } + + LOG(LogDebug) << "Sound::getFromTheme(): Looking for tag "; const ThemeData::ThemeElement* elem = theme->getElement(view, element, "sound"); if (!elem || !elem->has("path")) { LOG(LogDebug) << "Sound::getFromTheme(): " << "Tag not found, using fallback sound file"; - return get(ResourceManager::getInstance()-> - getResourcePath(":/sounds/" + element + ".wav")); + return get(ResourceManager::getInstance()->getResourcePath(":/sounds/" + element + ".wav")); } LOG(LogDebug) << "Sound::getFromTheme(): Tag found, ready to load theme sound file"; @@ -228,6 +232,15 @@ void NavigationSounds::deinit() void NavigationSounds::loadThemeNavigationSounds(const std::shared_ptr& theme) { + if (theme) { + LOG(LogDebug) << "NavigationSounds::loadThemeNavigationSounds(): " + "Theme set includes navigation sound support, loading custom sounds"; + } + else { + LOG(LogDebug) << "NavigationSounds::loadThemeNavigationSounds(): " + "Theme set does not include navigation sound support, using fallback sounds"; + } + navigationSounds.push_back(std::move(Sound::getFromTheme(theme, "all", "systembrowse"))); navigationSounds.push_back(std::move(Sound::getFromTheme(theme, "all", "quicksysselect"))); navigationSounds.push_back(std::move(Sound::getFromTheme(theme, "all", "select")));