mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-21 21:55:38 +00:00
Made the navigation sounds loading more robust to handle incomplete theme sets.
Also improved some log messages related to the navigation sounds.
This commit is contained in:
parent
26b593455e
commit
1ae88c93d7
|
@ -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();
|
||||
|
|
|
@ -34,14 +34,18 @@ std::shared_ptr<Sound> Sound::get(const std::string& path)
|
|||
std::shared_ptr<Sound> Sound::getFromTheme(const std::shared_ptr<ThemeData>& theme,
|
||||
const std::string& view, const std::string& element)
|
||||
{
|
||||
LOG(LogDebug) << "Sound::getFromTheme(): Looking for navigation sound tag <sound name=\"" <<
|
||||
element << "\">";
|
||||
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 <sound name=\"" << element << "\">";
|
||||
|
||||
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<ThemeData>& 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")));
|
||||
|
|
Loading…
Reference in a new issue