mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 23:55:38 +00:00
Bundled fallback sounds are now loaded if the theme does not provide any navigation sounds.
This commit is contained in:
parent
143a92cb8f
commit
6565355831
31
THEMES.md
31
THEMES.md
|
@ -277,16 +277,21 @@ You can now change the order in which elements are rendered by setting `zIndex`
|
||||||
|
|
||||||
#### Navigation sounds
|
#### Navigation sounds
|
||||||
|
|
||||||
The navigation sounds are configured globally per theme, so it needs to be defined as a feature and with the view set to the special 'all' category.
|
The navigation sounds are configured globally per theme set, so it needs to be defined as a feature and with the view set to the special 'all' category.
|
||||||
It's recommended to put these elements in a separate file and include it from the main theme file (e.g. `<include>./navigationsounds.xml</include>`).
|
It's recommended to put these elements in a separate file and include it from the main theme file (e.g. `<include>./navigationsounds.xml</include>`).
|
||||||
There are seven different navigation sounds that can be configured. The names as well as the element structure should be self-explanatory based
|
There are seven different navigation sounds that can be configured. The names as well as the element structure should be self-explanatory based
|
||||||
on the example below.
|
on the example below.
|
||||||
Starting EmulationStation with the --debug flag will provide feedback on whether the navigation sound elements were read correctly, as well as
|
Starting EmulationStation with the --debug flag will provide feedback on whether any navigation sound elements were read from the theme set. If no navigation sound is provided by the theme, ES will use the bundled navigation sound file as a fallback. This is done per sound, so the theme could provide for example one or two custom sound files while using the bundled ES sounds for the other samples.
|
||||||
providing an error message if any of the .wav sound files could not be loaded.
|
|
||||||
|
|
||||||
Example debug output: \
|
|
||||||
`May 12 21:12:37 lvl2: Sound::getFromTheme() looking for [all.selectSound]` \
|
Example debug output:
|
||||||
`May 12 21:12:37 lvl2: [selectSound] found, ready to play sound file`
|
```
|
||||||
|
Jul 12 11:28:58 lvl3: Sound::getFromTheme(): Looking for navigation sound tag <sound name="quicksysselect">.
|
||||||
|
Jul 12 11:28:58 lvl3: Sound::getFromTheme(): Tag found, ready to load theme sound file.
|
||||||
|
Jul 12 11:28:58 lvl3: Sound::getFromTheme(): Looking for navigation sound tag <sound name="select">.
|
||||||
|
Jul 12 11:28:58 lvl3: Sound::getFromTheme(): Tag not found, using fallback sound file.
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
Example `navigationsounds.xml`, to be included from the main theme file:
|
Example `navigationsounds.xml`, to be included from the main theme file:
|
||||||
|
|
||||||
|
@ -295,25 +300,25 @@ Example `navigationsounds.xml`, to be included from the main theme file:
|
||||||
<formatVersion>6</formatVersion>
|
<formatVersion>6</formatVersion>
|
||||||
<feature supported="navigationsounds">
|
<feature supported="navigationsounds">
|
||||||
<view name="all">
|
<view name="all">
|
||||||
<sound name="systembrowseSound">
|
<sound name="systembrowse">
|
||||||
<path>./core/sounds/systembrowse.wav</path>
|
<path>./core/sounds/systembrowse.wav</path>
|
||||||
</sound>
|
</sound>
|
||||||
<sound name="quicksysselectSound">
|
<sound name="quicksysselect">
|
||||||
<path>./core/sounds/quicksysselect.wav</path>
|
<path>./core/sounds/quicksysselect.wav</path>
|
||||||
</sound>
|
</sound>
|
||||||
<sound name="selectSound">
|
<sound name="select">
|
||||||
<path>./core/sounds/select.wav</path>
|
<path>./core/sounds/select.wav</path>
|
||||||
</sound>
|
</sound>
|
||||||
<sound name="backSound">
|
<sound name="back">
|
||||||
<path>./core/sounds/back.wav</path>
|
<path>./core/sounds/back.wav</path>
|
||||||
</sound>
|
</sound>
|
||||||
<sound name="scrollSound">
|
<sound name="scroll">
|
||||||
<path>./core/sounds/scroll.wav</path>
|
<path>./core/sounds/scroll.wav</path>
|
||||||
</sound>
|
</sound>
|
||||||
<sound name="favoriteSound">
|
<sound name="favorite">
|
||||||
<path>./core/sounds/favorite.wav</path>
|
<path>./core/sounds/favorite.wav</path>
|
||||||
</sound>
|
</sound>
|
||||||
<sound name="launchSound">
|
<sound name="launch">
|
||||||
<path>./core/sounds/launch.wav</path>
|
<path>./core/sounds/launch.wav</path>
|
||||||
</sound>
|
</sound>
|
||||||
</view>
|
</view>
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
#include "Sound.h"
|
#include "Sound.h"
|
||||||
|
|
||||||
|
#include "resources/ResourceManager.h"
|
||||||
#include "AudioManager.h"
|
#include "AudioManager.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
|
@ -31,15 +32,17 @@ std::shared_ptr<Sound> Sound::get(const std::string& path)
|
||||||
std::shared_ptr<Sound> Sound::getFromTheme(const std::shared_ptr<ThemeData>& theme,
|
std::shared_ptr<Sound> Sound::getFromTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
const std::string& view, const std::string& element)
|
const std::string& view, const std::string& element)
|
||||||
{
|
{
|
||||||
LOG(LogInfo) << "Sound::getFromTheme() looking for [" << view << "." << element << "]";
|
LOG(LogDebug) << "Sound::getFromTheme(): Looking for navigation sound tag <sound name=\"" <<
|
||||||
|
element << "\">.";
|
||||||
|
|
||||||
const ThemeData::ThemeElement* elem = theme->getElement(view, element, "sound");
|
const ThemeData::ThemeElement* elem = theme->getElement(view, element, "sound");
|
||||||
if(!elem || !elem->has("path")) {
|
if(!elem || !elem->has("path")) {
|
||||||
LOG(LogInfo) << "[" << element << "] not found, won't load any sound file";
|
LOG(LogDebug) << "Sound::getFromTheme(): " << "Tag not found, using fallback sound file.";
|
||||||
return get("");
|
return get(ResourceManager::getInstance()->
|
||||||
|
getResourcePath(":/sounds/" + element + ".wav"));
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG(LogInfo) << "[" << element << "] found, ready to load sound file";
|
LOG(LogDebug) << "Sound::getFromTheme(): Tag found, ready to load theme sound file.";
|
||||||
return get(elem->get<std::string>("path"));
|
return get(elem->get<std::string>("path"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,13 +64,13 @@ void NavigationSounds::deinit()
|
||||||
|
|
||||||
void NavigationSounds::loadThemeNavigationSounds(const std::shared_ptr<ThemeData>& theme)
|
void NavigationSounds::loadThemeNavigationSounds(const std::shared_ptr<ThemeData>& theme)
|
||||||
{
|
{
|
||||||
navigationSounds.push_back(Sound::getFromTheme(theme, "all", "systembrowseSound"));
|
navigationSounds.push_back(Sound::getFromTheme(theme, "all", "systembrowse"));
|
||||||
navigationSounds.push_back(Sound::getFromTheme(theme, "all", "quicksysselectSound"));
|
navigationSounds.push_back(Sound::getFromTheme(theme, "all", "quicksysselect"));
|
||||||
navigationSounds.push_back(Sound::getFromTheme(theme, "all", "selectSound"));
|
navigationSounds.push_back(Sound::getFromTheme(theme, "all", "select"));
|
||||||
navigationSounds.push_back(Sound::getFromTheme(theme, "all", "backSound"));
|
navigationSounds.push_back(Sound::getFromTheme(theme, "all", "back"));
|
||||||
navigationSounds.push_back(Sound::getFromTheme(theme, "all", "scrollSound"));
|
navigationSounds.push_back(Sound::getFromTheme(theme, "all", "scroll"));
|
||||||
navigationSounds.push_back(Sound::getFromTheme(theme, "all", "favoriteSound"));
|
navigationSounds.push_back(Sound::getFromTheme(theme, "all", "favorite"));
|
||||||
navigationSounds.push_back(Sound::getFromTheme(theme, "all", "launchSound"));
|
navigationSounds.push_back(Sound::getFromTheme(theme, "all", "launch"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void NavigationSounds::playThemeNavigationSound(NavigationSoundsID soundID)
|
void NavigationSounds::playThemeNavigationSound(NavigationSoundsID soundID)
|
||||||
|
@ -114,7 +117,8 @@ void Sound::init()
|
||||||
Uint8 * data = nullptr;
|
Uint8 * data = nullptr;
|
||||||
Uint32 dlen = 0;
|
Uint32 dlen = 0;
|
||||||
if (SDL_LoadWAV(mPath.c_str(), &wave, &data, &dlen) == nullptr) {
|
if (SDL_LoadWAV(mPath.c_str(), &wave, &data, &dlen) == nullptr) {
|
||||||
LOG(LogError) << "Error loading sound file \"" << mPath << "\"!\n" << " " << SDL_GetError();
|
LOG(LogError) << "Error - Failed to load theme navigation sound file:";
|
||||||
|
LOG(LogError) << SDL_GetError();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Build conversion buffer.
|
// Build conversion buffer.
|
||||||
|
|
|
@ -3,25 +3,25 @@
|
||||||
|
|
||||||
<feature supported="navigationsounds">
|
<feature supported="navigationsounds">
|
||||||
<view name="all">
|
<view name="all">
|
||||||
<sound name="systembrowseSound">
|
<sound name="systembrowse">
|
||||||
<path>./core/sounds/systembrowse.wav</path>
|
<path>./core/sounds/systembrowse.wav</path>
|
||||||
</sound>
|
</sound>
|
||||||
<sound name="quicksysselectSound">
|
<sound name="quicksysselect">
|
||||||
<path>./core/sounds/quicksysselect.wav</path>
|
<path>./core/sounds/quicksysselect.wav</path>
|
||||||
</sound>
|
</sound>
|
||||||
<sound name="selectSound">
|
<sound name="select">
|
||||||
<path>./core/sounds/select.wav</path>
|
<path>./core/sounds/select.wav</path>
|
||||||
</sound>
|
</sound>
|
||||||
<sound name="backSound">
|
<sound name="back">
|
||||||
<path>./core/sounds/back.wav</path>
|
<path>./core/sounds/back.wav</path>
|
||||||
</sound>
|
</sound>
|
||||||
<sound name="scrollSound">
|
<sound name="scroll">
|
||||||
<path>./core/sounds/scroll.wav</path>
|
<path>./core/sounds/scroll.wav</path>
|
||||||
</sound>
|
</sound>
|
||||||
<sound name="favoriteSound">
|
<sound name="favorite">
|
||||||
<path>./core/sounds/favorite.wav</path>
|
<path>./core/sounds/favorite.wav</path>
|
||||||
</sound>
|
</sound>
|
||||||
<sound name="launchSound">
|
<sound name="launch">
|
||||||
<path>./core/sounds/launch.wav</path>
|
<path>./core/sounds/launch.wav</path>
|
||||||
</sound>
|
</sound>
|
||||||
</view>
|
</view>
|
||||||
|
|
Loading…
Reference in a new issue