mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-21 21:55:38 +00:00
Some cosmetic code cleanup.
This commit is contained in:
parent
370914791e
commit
2eb5125d0e
|
@ -984,7 +984,7 @@ This will remove any media files for the game file or folder and also remove its
|
|||
|
||||
**Delete** _(Files only)_
|
||||
|
||||
This will remove the actual game file and its gamelist.xml entry, as well as any media files. A prompt will be shown asking for confirmation. The deletion of folders is not supported as that would potentially be a bit dangerous, instead use the valid operating system tools to handle deletion of folders.
|
||||
This will remove the actual game file and its gamelist.xml entry, as well as any media files. A prompt will be shown asking for confirmation. The deletion of folders is not supported as that would potentially be a bit dangerous, instead use the appropriate operating system tools to handle deletion of folders.
|
||||
|
||||
|
||||
## Screensaver
|
||||
|
|
|
@ -66,10 +66,10 @@ const std::vector<MetaDataDecl> folderMDD(folderDecls, folderDecls +
|
|||
const std::vector<MetaDataDecl>& getMDDByType(MetaDataListType type)
|
||||
{
|
||||
switch(type) {
|
||||
case GAME_METADATA:
|
||||
return gameMDD;
|
||||
case FOLDER_METADATA:
|
||||
return folderMDD;
|
||||
case GAME_METADATA:
|
||||
return gameMDD;
|
||||
case FOLDER_METADATA:
|
||||
return folderMDD;
|
||||
}
|
||||
|
||||
LOG(LogError) << "Invalid MDD type";
|
||||
|
|
|
@ -18,7 +18,7 @@ std::vector<std::shared_ptr<Sound>> AudioManager::sSoundVector;
|
|||
SDL_AudioSpec AudioManager::sAudioFormat;
|
||||
std::shared_ptr<AudioManager> AudioManager::sInstance;
|
||||
|
||||
void AudioManager::mixAudio(void* /*unused*/, Uint8 *stream, int len)
|
||||
void AudioManager::mixAudio(void* /*unused*/, Uint8* stream, int len)
|
||||
{
|
||||
bool stillPlaying = false;
|
||||
|
||||
|
@ -32,7 +32,7 @@ void AudioManager::mixAudio(void* /*unused*/, Uint8 *stream, int len)
|
|||
if (sound->isPlaying()) {
|
||||
// Calculate rest length of current sample.
|
||||
Uint32 restLength = (sound->getLength() - sound->getPosition());
|
||||
if (restLength > (Uint32)len) {
|
||||
if (restLength > static_cast<Uint32>(len)) {
|
||||
// If stream length is smaller than sample length, clip it.
|
||||
restLength = len;
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ AudioManager::~AudioManager()
|
|||
deinit();
|
||||
}
|
||||
|
||||
std::shared_ptr<AudioManager> & AudioManager::getInstance()
|
||||
std::shared_ptr<AudioManager>& AudioManager::getInstance()
|
||||
{
|
||||
// Check if an AudioManager instance is already created, if not create one.
|
||||
if (sInstance == nullptr && Settings::getInstance()->getBool("NavigationSounds")) {
|
||||
|
@ -116,13 +116,13 @@ void AudioManager::deinit()
|
|||
sInstance = nullptr;
|
||||
}
|
||||
|
||||
void AudioManager::registerSound(std::shared_ptr<Sound> & sound)
|
||||
void AudioManager::registerSound(std::shared_ptr<Sound>& sound)
|
||||
{
|
||||
getInstance();
|
||||
sSoundVector.push_back(sound);
|
||||
}
|
||||
|
||||
void AudioManager::unregisterSound(std::shared_ptr<Sound> & sound)
|
||||
void AudioManager::unregisterSound(std::shared_ptr<Sound>& sound)
|
||||
{
|
||||
getInstance();
|
||||
for (unsigned int i = 0; i < sSoundVector.size(); i++) {
|
||||
|
|
|
@ -21,18 +21,18 @@ class AudioManager
|
|||
static std::vector<std::shared_ptr<Sound>> sSoundVector;
|
||||
static std::shared_ptr<AudioManager> sInstance;
|
||||
|
||||
static void mixAudio(void *unused, Uint8 *stream, int len);
|
||||
static void mixAudio(void* unused, Uint8* stream, int len);
|
||||
|
||||
AudioManager();
|
||||
|
||||
public:
|
||||
static std::shared_ptr<AudioManager> & getInstance();
|
||||
static std::shared_ptr<AudioManager>& getInstance();
|
||||
|
||||
void init();
|
||||
void deinit();
|
||||
|
||||
void registerSound(std::shared_ptr<Sound> & sound);
|
||||
void unregisterSound(std::shared_ptr<Sound> & sound);
|
||||
void registerSound(std::shared_ptr<Sound>& sound);
|
||||
void unregisterSound(std::shared_ptr<Sound>& sound);
|
||||
|
||||
void play();
|
||||
void stop();
|
||||
|
|
|
@ -86,7 +86,7 @@ bool NavigationSounds::isPlayingThemeNavigationSound(NavigationSoundsID soundID)
|
|||
}
|
||||
|
||||
Sound::Sound(
|
||||
const std::string & path)
|
||||
const std::string& path)
|
||||
: mSampleData(nullptr),
|
||||
mSamplePos(0),
|
||||
mSampleLength(0),
|
||||
|
@ -100,7 +100,7 @@ Sound::~Sound()
|
|||
deinit();
|
||||
}
|
||||
|
||||
void Sound::loadFile(const std::string & path)
|
||||
void Sound::loadFile(const std::string& path)
|
||||
{
|
||||
mPath = path;
|
||||
init();
|
||||
|
@ -116,7 +116,7 @@ void Sound::init()
|
|||
|
||||
// Load WAV file via SDL.
|
||||
SDL_AudioSpec wave;
|
||||
Uint8 * data = nullptr;
|
||||
Uint8* data = nullptr;
|
||||
Uint32 dlen = 0;
|
||||
if (SDL_LoadWAV(mPath.c_str(), &wave, &data, &dlen) == nullptr) {
|
||||
LOG(LogError) << "Failed to load theme navigation sound file:";
|
||||
|
@ -203,7 +203,7 @@ void Sound::stop()
|
|||
SDL_UnlockAudio();
|
||||
}
|
||||
|
||||
const Uint8 * Sound::getData() const
|
||||
const Uint8* Sound::getData() const
|
||||
{
|
||||
return mSampleData;
|
||||
}
|
||||
|
@ -232,5 +232,5 @@ Uint32 Sound::getLengthMS() const
|
|||
{
|
||||
// 44100 samples per second, 2 channels (stereo).
|
||||
// I have no idea why the *0.75 is necessary, but otherwise it's inaccurate.
|
||||
return (Uint32)((mSampleLength / 44100.0f / 2.0f * 0.75f) * 1000);
|
||||
return static_cast<Uint32>((mSampleLength / 44100.0f / 2.0f * 0.75f) * 1000);
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ class Sound
|
|||
{
|
||||
std::string mPath;
|
||||
SDL_AudioSpec mSampleFormat;
|
||||
Uint8 * mSampleData;
|
||||
Uint8* mSampleData;
|
||||
Uint32 mSamplePos;
|
||||
Uint32 mSampleLength;
|
||||
bool playing;
|
||||
|
@ -40,21 +40,21 @@ public:
|
|||
void init();
|
||||
void deinit();
|
||||
|
||||
void loadFile(const std::string & path);
|
||||
void loadFile(const std::string& path);
|
||||
|
||||
void play();
|
||||
bool isPlaying() const;
|
||||
void stop();
|
||||
|
||||
const Uint8 * getData() const;
|
||||
const Uint8* getData() const;
|
||||
Uint32 getPosition() const;
|
||||
void setPosition(Uint32 newPosition);
|
||||
Uint32 getLength() const;
|
||||
Uint32 getLengthMS() const;
|
||||
|
||||
private:
|
||||
Sound(const std::string & path = "");
|
||||
static std::map< std::string, std::shared_ptr<Sound> > sMap;
|
||||
Sound(const std::string& path = "");
|
||||
static std::map<std::string, std::shared_ptr<Sound>> sMap;
|
||||
};
|
||||
|
||||
enum NavigationSoundsID {
|
||||
|
|
|
@ -229,14 +229,14 @@ std::string resolvePlaceholders(const char* in)
|
|||
return inStr;
|
||||
|
||||
const size_t variableBegin = inStr.find("${");
|
||||
const size_t variableEnd = inStr.find("}", variableBegin);
|
||||
const size_t variableEnd = inStr.find("}", variableBegin);
|
||||
|
||||
if ((variableBegin == std::string::npos) || (variableEnd == std::string::npos))
|
||||
return inStr;
|
||||
|
||||
std::string prefix = inStr.substr(0, variableBegin);
|
||||
std::string prefix = inStr.substr(0, variableBegin);
|
||||
std::string replace = inStr.substr(variableBegin + 2, variableEnd - (variableBegin + 2));
|
||||
std::string suffix = resolvePlaceholders(inStr.substr(variableEnd + 1).c_str());
|
||||
std::string suffix = resolvePlaceholders(inStr.substr(variableEnd + 1).c_str());
|
||||
|
||||
return prefix + mVariables[replace] + suffix;
|
||||
}
|
||||
|
@ -413,7 +413,7 @@ void ThemeData::parseView(const pugi::xml_node& root, ThemeView& view)
|
|||
const char* delim = " \t\r\n,";
|
||||
const std::string nameAttr = node.attribute("name").as_string();
|
||||
size_t prevOff = nameAttr.find_first_not_of(delim, 0);
|
||||
size_t off = nameAttr.find_first_of(delim, prevOff);
|
||||
size_t off = nameAttr.find_first_of(delim, prevOff);
|
||||
while (off != std::string::npos || prevOff != std::string::npos) {
|
||||
std::string elemKey = nameAttr.substr(prevOff, off - prevOff);
|
||||
prevOff = nameAttr.find_first_not_of(delim, off);
|
||||
|
@ -453,12 +453,16 @@ void ThemeData::parseElement(const pugi::xml_node& root,
|
|||
|
||||
auto splits = Utils::String::delimitedStringToVector(str, " ");
|
||||
if (splits.size() == 2) {
|
||||
val = Vector4f((float)atof(splits.at(0).c_str()), (float)atof(splits.at(1).c_str()),
|
||||
(float)atof(splits.at(0).c_str()), (float)atof(splits.at(1).c_str()));
|
||||
val = Vector4f(static_cast<float>(atof(splits.at(0).c_str())),
|
||||
static_cast<float>(atof(splits.at(1).c_str())),
|
||||
static_cast<float>(atof(splits.at(0).c_str())),
|
||||
static_cast<float>(atof(splits.at(1).c_str())));
|
||||
}
|
||||
else if (splits.size() == 4) {
|
||||
val = Vector4f((float)atof(splits.at(0).c_str()), (float)atof(splits.at(1).c_str()),
|
||||
(float)atof(splits.at(2).c_str()), (float)atof(splits.at(3).c_str()));
|
||||
val = Vector4f(static_cast<float>(atof(splits.at(0).c_str())),
|
||||
static_cast<float>(atof(splits.at(1).c_str())),
|
||||
static_cast<float>(atof(splits.at(2).c_str())),
|
||||
static_cast<float>(atof(splits.at(3).c_str())));
|
||||
}
|
||||
|
||||
element.properties[node.name()] = val;
|
||||
|
@ -473,7 +477,8 @@ void ThemeData::parseElement(const pugi::xml_node& root,
|
|||
std::string first = str.substr(0, divider);
|
||||
std::string second = str.substr(divider, std::string::npos);
|
||||
|
||||
Vector2f val((float)atof(first.c_str()), (float)atof(second.c_str()));
|
||||
Vector2f val(static_cast<float>(atof(first.c_str())),
|
||||
static_cast<float>(atof(second.c_str())));
|
||||
|
||||
element.properties[node.name()] = val;
|
||||
break;
|
||||
|
@ -536,7 +541,8 @@ const ThemeData::ThemeElement* ThemeData::getElement(const std::string& view,
|
|||
return nullptr; // Not found.
|
||||
|
||||
auto elemIt = viewIt->second.elements.find(element);
|
||||
if (elemIt == viewIt->second.elements.cend()) return nullptr;
|
||||
if (elemIt == viewIt->second.elements.cend())
|
||||
return nullptr;
|
||||
|
||||
if (elemIt->second.type != expectedType && !expectedType.empty()) {
|
||||
LOG(LogWarning) << " requested mismatched theme type for [" <<
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "math/Vector2f.h"
|
||||
#include "math/Vector4f.h"
|
||||
#include "utils/FileSystemUtil.h"
|
||||
|
||||
#include <deque>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
|
Loading…
Reference in a new issue