Some cosmetic code changes.

This commit is contained in:
Leon Styhre 2020-07-13 20:58:25 +02:00
parent 40be69cd64
commit 57d6dab2cc
34 changed files with 142 additions and 152 deletions

View file

@ -53,10 +53,10 @@ namespace FileSorts
// appended which messes up the order. // appended which messes up the order.
std::string name1 = Utils::String::toUpper(file1->metadata.get("sortname")); std::string name1 = Utils::String::toUpper(file1->metadata.get("sortname"));
std::string name2 = Utils::String::toUpper(file2->metadata.get("sortname")); std::string name2 = Utils::String::toUpper(file2->metadata.get("sortname"));
if(name1.empty()){ if (name1.empty()){
name1 = Utils::String::toUpper(file1->metadata.get("name")); name1 = Utils::String::toUpper(file1->metadata.get("name"));
} }
if(name2.empty()){ if (name2.empty()){
name2 = Utils::String::toUpper(file2->metadata.get("name")); name2 = Utils::String::toUpper(file2->metadata.get("name"));
} }
return name1.compare(name2) < 0; return name1.compare(name2) < 0;
@ -70,7 +70,7 @@ namespace FileSorts
bool compareTimesPlayed(const FileData* file1, const FileData* file2) bool compareTimesPlayed(const FileData* file1, const FileData* file2)
{ {
//only games have playcount metadata //only games have playcount metadata
if(file1->metadata.getType() == GAME_METADATA && file2->metadata.getType() == GAME_METADATA) if (file1->metadata.getType() == GAME_METADATA && file2->metadata.getType() == GAME_METADATA)
return (file1)->metadata.getInt("playcount") < (file2)->metadata.getInt("playcount"); return (file1)->metadata.getInt("playcount") < (file2)->metadata.getInt("playcount");
return false; return false;

View file

@ -42,7 +42,7 @@ void GuiCollectionSystemsOptions::initializeMenu()
(mWindow, getHelpStyle(), "SELECT THEME FOLDER", true); (mWindow, getHelpStyle(), "SELECT THEME FOLDER", true);
// Add custom systems. // Add custom systems.
for(auto it = unusedFolders.cbegin() ; it != unusedFolders.cend() ; it++ ) { for (auto it = unusedFolders.cbegin() ; it != unusedFolders.cend() ; it++ ) {
ComponentListRow row; ComponentListRow row;
std::string name = *it; std::string name = *it;
@ -97,7 +97,7 @@ void GuiCollectionSystemsOptions::initializeMenu()
getBool("CollectionShowSystemInfo")); getBool("CollectionShowSystemInfo"));
mMenu.addWithLabel("SHOW SYSTEM NAMES IN COLLECTIONS", toggleSystemNameInCollections); mMenu.addWithLabel("SHOW SYSTEM NAMES IN COLLECTIONS", toggleSystemNameInCollections);
if(CollectionSystemManager::get()->isEditing()) { if (CollectionSystemManager::get()->isEditing()) {
row.elements.clear(); row.elements.clear();
row.addElement(std::make_shared<TextComponent>(mWindow, "FINISH EDITING '" + row.addElement(std::make_shared<TextComponent>(mWindow, "FINISH EDITING '" +
Utils::String::toUpper(CollectionSystemManager::get()->getEditingCollection()) + Utils::String::toUpper(CollectionSystemManager::get()->getEditingCollection()) +
@ -120,7 +120,7 @@ void GuiCollectionSystemsOptions::addEntry(const char* name, unsigned int color,
ComponentListRow row; ComponentListRow row;
row.addElement(std::make_shared<TextComponent>(mWindow, name, font, color), true); row.addElement(std::make_shared<TextComponent>(mWindow, name, font, color), true);
if(add_arrow) { if (add_arrow) {
std::shared_ptr<ImageComponent> bracket = makeArrow(mWindow); std::shared_ptr<ImageComponent> bracket = makeArrow(mWindow);
row.addElement(bracket, false); row.addElement(bracket, false);
} }
@ -142,7 +142,7 @@ void GuiCollectionSystemsOptions::createCollection(std::string inName) {
Window* window = mWindow; Window* window = mWindow;
CollectionSystemManager::get()->setEditMode(name); CollectionSystemManager::get()->setEditMode(name);
while(window->peekGui() && window->peekGui() != ViewController::get()) while (window->peekGui() && window->peekGui() != ViewController::get())
delete window->peekGui(); delete window->peekGui();
return; return;
} }
@ -166,7 +166,7 @@ void GuiCollectionSystemsOptions::addSystemsToMenu()
(mWindow, getHelpStyle(), "SELECT COLLECTIONS", true); (mWindow, getHelpStyle(), "SELECT COLLECTIONS", true);
// Add automatic systems. // Add automatic systems.
for(std::map<std::string, CollectionSystemData>::const_iterator it = autoSystems.cbegin(); for (std::map<std::string, CollectionSystemData>::const_iterator it = autoSystems.cbegin();
it != autoSystems.cend() ; it++ ) it != autoSystems.cend() ; it++ )
autoOptionList->add(it->second.decl.longName, it->second.decl.name, it->second.isEnabled); autoOptionList->add(it->second.decl.longName, it->second.decl.name, it->second.isEnabled);
mMenu.addWithLabel("AUTOMATIC GAME COLLECTIONS", autoOptionList); mMenu.addWithLabel("AUTOMATIC GAME COLLECTIONS", autoOptionList);
@ -178,7 +178,7 @@ void GuiCollectionSystemsOptions::addSystemsToMenu()
(mWindow, getHelpStyle(), "SELECT COLLECTIONS", true); (mWindow, getHelpStyle(), "SELECT COLLECTIONS", true);
// Add custom systems. // Add custom systems.
for(std::map<std::string, CollectionSystemData>::const_iterator it = customSystems.cbegin(); for (std::map<std::string, CollectionSystemData>::const_iterator it = customSystems.cbegin();
it != customSystems.cend() ; it++ ) it != customSystems.cend() ; it++ )
customOptionList->add(it->second.decl.longName, it->second.decl.name, it->second.isEnabled); customOptionList->add(it->second.decl.longName, it->second.decl.name, it->second.isEnabled);
mMenu.addWithLabel("CUSTOM GAME COLLECTIONS", customOptionList); mMenu.addWithLabel("CUSTOM GAME COLLECTIONS", customOptionList);
@ -228,10 +228,10 @@ bool GuiCollectionSystemsOptions::input(InputConfig* config, Input input)
{ {
bool consumed = GuiComponent::input(config, input); bool consumed = GuiComponent::input(config, input);
if(consumed) if (consumed)
return true; return true;
if(config->isMappedTo("b", input) && input.value != 0) if (config->isMappedTo("b", input) && input.value != 0)
applySettings(); applySettings();
return false; return false;

View file

@ -86,7 +86,7 @@ GuiGameScraper::GuiGameScraper(
// mSearchComponent::update() // mSearchComponent::update()
// acceptCallback -> close() -> mClose = true // acceptCallback -> close() -> mClose = true
// it++; // OK. // it++; // OK.
// if(mClose) // if (mClose)
// delete this; // delete this;
mSearch->setAcceptCallback([this, doneFunc](const ScraperSearchResult& result) { mSearch->setAcceptCallback([this, doneFunc](const ScraperSearchResult& result) {
doneFunc(result); close(); }); doneFunc(result); close(); });
@ -117,7 +117,7 @@ void GuiGameScraper::onSizeChanged()
bool GuiGameScraper::input(InputConfig* config, Input input) bool GuiGameScraper::input(InputConfig* config, Input input)
{ {
if(config->isMappedTo("b", input) && input.value) { if (config->isMappedTo("b", input) && input.value) {
PowerSaver::resume(); PowerSaver::resume();
delete this; delete this;
return true; return true;
@ -130,7 +130,7 @@ void GuiGameScraper::update(int deltaTime)
{ {
GuiComponent::update(deltaTime); GuiComponent::update(deltaTime);
if(mClose) if (mClose)
delete this; delete this;
} }

View file

@ -17,9 +17,7 @@
class GuiGameScraper : public GuiComponent class GuiGameScraper : public GuiComponent
{ {
public: public:
GuiGameScraper( GuiGameScraper(Window* window, ScraperSearchParams params,
Window* window,
ScraperSearchParams params,
std::function<void(const ScraperSearchResult&)> doneFunc); std::function<void(const ScraperSearchResult&)> doneFunc);
void onSizeChanged() override; void onSizeChanged() override;

View file

@ -45,7 +45,7 @@ GuiGeneralScreensaverOptions::GuiGeneralScreensaverOptions(Window* window, const
screensavers.push_back("black"); screensavers.push_back("black");
screensavers.push_back("random video"); screensavers.push_back("random video");
screensavers.push_back("slideshow"); screensavers.push_back("slideshow");
for(auto it = screensavers.cbegin(); it != screensavers.cend(); it++) for (auto it = screensavers.cbegin(); it != screensavers.cend(); it++)
screensaver_behavior->add(*it, *it, Settings::getInstance()-> screensaver_behavior->add(*it, *it, Settings::getInstance()->
getString("ScreenSaverBehavior") == *it); getString("ScreenSaverBehavior") == *it);
addWithLabel("SCREENSAVER BEHAVIOR", screensaver_behavior); addWithLabel("SCREENSAVER BEHAVIOR", screensaver_behavior);

View file

@ -29,10 +29,10 @@ GuiScreensaverOptions::~GuiScreensaverOptions()
void GuiScreensaverOptions::save() void GuiScreensaverOptions::save()
{ {
if(!mSaveFuncs.size()) if (!mSaveFuncs.size())
return; return;
for(auto it = mSaveFuncs.cbegin(); it != mSaveFuncs.cend(); it++) for (auto it = mSaveFuncs.cbegin(); it != mSaveFuncs.cend(); it++)
(*it)(); (*it)();
Settings::getInstance()->saveFile(); Settings::getInstance()->saveFile();

View file

@ -48,7 +48,7 @@ GuiVideoScreensaverOptions::GuiVideoScreensaverOptions(Window* window, const cha
info_type.push_back("always"); info_type.push_back("always");
info_type.push_back("start & end"); info_type.push_back("start & end");
info_type.push_back("never"); info_type.push_back("never");
for(auto it = info_type.cbegin(); it != info_type.cend(); it++) for (auto it = info_type.cbegin(); it != info_type.cend(); it++)
ss_info->add(*it, *it, Settings::getInstance()->getString("ScreenSaverGameInfo") == *it); ss_info->add(*it, *it, Settings::getInstance()->getString("ScreenSaverGameInfo") == *it);
addWithLabel("SHOW GAME INFO ON SCREENSAVER", ss_info); addWithLabel("SHOW GAME INFO ON SCREENSAVER", ss_info);
addSaveFunc([ss_info, this] { Settings::getInstance()-> addSaveFunc([ss_info, this] { Settings::getInstance()->
@ -63,7 +63,7 @@ GuiVideoScreensaverOptions::GuiVideoScreensaverOptions(Window* window, const cha
std::vector<std::string> align_mode; std::vector<std::string> align_mode;
align_mode.push_back("left"); align_mode.push_back("left");
align_mode.push_back("center"); align_mode.push_back("center");
for(auto it = align_mode.cbegin(); it != align_mode.cend(); it++) for (auto it = align_mode.cbegin(); it != align_mode.cend(); it++)
ss_omx_subs_align->add(*it, *it, Settings::getInstance()-> ss_omx_subs_align->add(*it, *it, Settings::getInstance()->
getString("SubtitleAlignment") == *it); getString("SubtitleAlignment") == *it);
addWithLabel("GAME INFO ALIGNMENT", ss_omx_subs_align); addWithLabel("GAME INFO ALIGNMENT", ss_omx_subs_align);

View file

@ -148,11 +148,11 @@ bool parseArgs(int argc, char* argv[])
std::cerr << "Error: No home path supplied with \'--home'.\n"; std::cerr << "Error: No home path supplied with \'--home'.\n";
return false; return false;
} }
if(!Utils::FileSystem::exists(argv[i + 1])) { if (!Utils::FileSystem::exists(argv[i + 1])) {
std::cerr << "Error: Home path \'" << argv[i + 1] << "\' does not exist.\n"; std::cerr << "Error: Home path \'" << argv[i + 1] << "\' does not exist.\n";
return false; return false;
} }
if(Utils::FileSystem::isRegularFile(argv[i + 1])) { if (Utils::FileSystem::isRegularFile(argv[i + 1])) {
std::cerr << "Error: Home path \'" << argv[i + 1] << std::cerr << "Error: Home path \'" << argv[i + 1] <<
"\' is a file and not a directory.\n"; "\' is a file and not a directory.\n";
return false; return false;
@ -162,7 +162,7 @@ bool parseArgs(int argc, char* argv[])
} }
} }
for(int i = 1; i < argc; i++) { for (int i = 1; i < argc; i++) {
// Skip past --home flag as we already processed it. // Skip past --home flag as we already processed it.
if (strcmp(argv[i], "--home") == 0) { if (strcmp(argv[i], "--home") == 0) {
i++; i++;

View file

@ -233,7 +233,7 @@ MDResolveHandle::MDResolveHandle(const ScraperSearchResult& result,
// This avoids the problem where there's already a file for this media type // This avoids the problem where there's already a file for this media type
// with a different format/extension (e.g. game.jpg and we're going to write // with a different format/extension (e.g. game.jpg and we're going to write
// game.png) which would lead to two media files for this game. // game.png) which would lead to two media files for this game.
if(it->existingMediaFile != "") if (it->existingMediaFile != "")
Utils::FileSystem::removeFile(it->existingMediaFile); Utils::FileSystem::removeFile(it->existingMediaFile);
// If the media directory does not exist, something is wrong, possibly permission // If the media directory does not exist, something is wrong, possibly permission
@ -351,7 +351,7 @@ void ImageDownloadHandle::update()
// This avoids the problem where there's already a file for this media type // This avoids the problem where there's already a file for this media type
// with a different format/extension (e.g. game.jpg and we're going to write // with a different format/extension (e.g. game.jpg and we're going to write
// game.png) which would lead to two media files for this game. // game.png) which would lead to two media files for this game.
if(mExistingMediaFile != "") if (mExistingMediaFile != "")
Utils::FileSystem::removeFile(mExistingMediaFile); Utils::FileSystem::removeFile(mExistingMediaFile);
// If the media directory does not exist, something is wrong, possibly permission // If the media directory does not exist, something is wrong, possibly permission

View file

@ -82,20 +82,17 @@ void BasicGameListView::setCursor(FileData* cursor)
// Update our cursor stack in case our cursor just // Update our cursor stack in case our cursor just
// got set to some folder we weren't in before. // got set to some folder we weren't in before.
if (mCursorStack.empty() || mCursorStack.top() != cursor->getParent()) if (mCursorStack.empty() || mCursorStack.top() != cursor->getParent()) {
{
std::stack<FileData*> tmp; std::stack<FileData*> tmp;
FileData* ptr = cursor->getParent(); FileData* ptr = cursor->getParent();
while (ptr && ptr != mRoot) while (ptr && ptr != mRoot) {
{
tmp.push(ptr); tmp.push(ptr);
ptr = ptr->getParent(); ptr = ptr->getParent();
} }
// Flip the stack and put it in mCursorStack. // Flip the stack and put it in mCursorStack.
mCursorStack = std::stack<FileData*>(); mCursorStack = std::stack<FileData*>();
while (!tmp.empty()) while (!tmp.empty()) {
{
mCursorStack.push(tmp.top()); mCursorStack.push(tmp.top());
tmp.pop(); tmp.pop();
} }
@ -205,8 +202,7 @@ std::vector<HelpPrompt> BasicGameListView::getHelpPrompts()
prompts.push_back(HelpPrompt("select", "options")); prompts.push_back(HelpPrompt("select", "options"));
if (mRoot->getSystem()->isGameSystem()) if (mRoot->getSystem()->isGameSystem())
prompts.push_back(HelpPrompt("x", "random")); prompts.push_back(HelpPrompt("x", "random"));
if (mRoot->getSystem()->isGameSystem() && !UIModeController::getInstance()->isUIModeKid()) if (mRoot->getSystem()->isGameSystem() && !UIModeController::getInstance()->isUIModeKid()) {
{
std::string prompt = CollectionSystemManager::get()->getEditingCollection(); std::string prompt = CollectionSystemManager::get()->getEditingCollection();
prompts.push_back(HelpPrompt("y", prompt)); prompts.push_back(HelpPrompt("y", prompt));
} }

View file

@ -274,8 +274,8 @@ void DetailedGameListView::updateInfoPanel()
for (auto it = comps.cbegin(); it != comps.cend(); it++) { for (auto it = comps.cbegin(); it != comps.cend(); it++) {
GuiComponent* comp = *it; GuiComponent* comp = *it;
// An animation is playing, then animate if reverse != fadingOut // An animation is playing, then animate if reverse != fadingOut.
// An animation is not playing, then animate if opacity != our target opacity // An animation is not playing, then animate if opacity != our target opacity.
if ((comp->isAnimationPlaying(0) && comp->isAnimationReversed(0) != fadingOut) || if ((comp->isAnimationPlaying(0) && comp->isAnimationReversed(0) != fadingOut) ||
(!comp->isAnimationPlaying(0) && comp->getOpacity() != (fadingOut ? 0 : 255))) { (!comp->isAnimationPlaying(0) && comp->getOpacity() != (fadingOut ? 0 : 255))) {
auto func = [comp](float t) { auto func = [comp](float t) {

View file

@ -54,14 +54,14 @@ GridGameListView::GridGameListView(
const float padding = 0.01f; const float padding = 0.01f;
// Create the correct type of video window. // Create the correct type of video window.
#ifdef _RPI_ #ifdef _RPI_
if (Settings::getInstance()->getBool("VideoOmxPlayer")) if (Settings::getInstance()->getBool("VideoOmxPlayer"))
mVideo = new VideoPlayerComponent(window, ""); mVideo = new VideoPlayerComponent(window, "");
else else
mVideo = new VideoVlcComponent(window, getTitlePath()); mVideo = new VideoVlcComponent(window, getTitlePath());
#else #else
mVideo = new VideoVlcComponent(window, getTitlePath()); mVideo = new VideoVlcComponent(window, getTitlePath());
#endif #endif
mGrid.setPosition(mSize.x() * 0.1f, mSize.y() * 0.1f); mGrid.setPosition(mSize.x() * 0.1f, mSize.y() * 0.1f);
mGrid.setDefaultZIndex(20); mGrid.setDefaultZIndex(20);
@ -228,8 +228,9 @@ void GridGameListView::populateList(const std::vector<FileData*>& files)
for (auto it = files.cbegin(); it != files.cend(); it++) for (auto it = files.cbegin(); it != files.cend(); it++)
mGrid.add((*it)->getName(), getImagePath(*it), *it); mGrid.add((*it)->getName(), getImagePath(*it), *it);
} }
else else {
addPlaceholder(); addPlaceholder();
}
} }
void GridGameListView::onThemeChanged(const std::shared_ptr<ThemeData>& theme) void GridGameListView::onThemeChanged(const std::shared_ptr<ThemeData>& theme)
@ -237,7 +238,6 @@ void GridGameListView::onThemeChanged(const std::shared_ptr<ThemeData>& theme)
ISimpleGameListView::onThemeChanged(theme); ISimpleGameListView::onThemeChanged(theme);
using namespace ThemeFlags; using namespace ThemeFlags;
mGrid.applyTheme(theme, getName(), "gamegrid", ALL); mGrid.applyTheme(theme, getName(), "gamegrid", ALL);
mName.applyTheme(theme, getName(), "md_name", ALL); mName.applyTheme(theme, getName(), "md_name", ALL);
mMarquee.applyTheme(theme, getName(), "md_marquee", mMarquee.applyTheme(theme, getName(), "md_marquee",
@ -354,19 +354,18 @@ void GridGameListView::updateInfoPanel()
FileData* file = (mGrid.size() == 0 || mGrid.isScrolling()) ? nullptr : mGrid.getSelected(); FileData* file = (mGrid.size() == 0 || mGrid.isScrolling()) ? nullptr : mGrid.getSelected();
bool fadingOut; bool fadingOut;
if (file == nullptr) if (file == nullptr) {
{
mVideo->setVideo(""); mVideo->setVideo("");
mVideo->setImage(""); mVideo->setImage("");
mVideoPlaying = false; mVideoPlaying = false;
fadingOut = true; fadingOut = true;
}else{ }
// Temporary fix to disable only audio from playing else {
// Temporary fix to disable only audio from playing.
// if (!mVideo->setVideo(file->getVideoPath())) // if (!mVideo->setVideo(file->getVideoPath()))
// {
// mVideo->setDefaultVideo(); // mVideo->setDefaultVideo();
// }
// mVideoPlaying = true; // mVideoPlaying = true;
// mVideo->setImage(file->getThumbnailPath()); // mVideo->setImage(file->getThumbnailPath());
@ -403,8 +402,8 @@ void GridGameListView::updateInfoPanel()
for (auto it = comps.cbegin(); it != comps.cend(); it++) { for (auto it = comps.cbegin(); it != comps.cend(); it++) {
GuiComponent* comp = *it; GuiComponent* comp = *it;
// An animation is playing, then animate if reverse != fadingOut // An animation is playing, then animate if reverse != fadingOut.
// An animation is not playing, then animate if opacity != our target opacity // An animation is not playing, then animate if opacity != our target opacity.
if ((comp->isAnimationPlaying(0) && comp->isAnimationReversed(0) != fadingOut) || if ((comp->isAnimationPlaying(0) && comp->isAnimationReversed(0) != fadingOut) ||
(!comp->isAnimationPlaying(0) && comp->getOpacity() != (fadingOut ? 0 : 255))) { (!comp->isAnimationPlaying(0) && comp->getOpacity() != (fadingOut ? 0 : 255))) {
auto func = [comp](float t) { auto func = [comp](float t) {

View file

@ -55,6 +55,7 @@ public:
virtual HelpStyle getHelpStyle() override; virtual HelpStyle getHelpStyle() override;
void render(const Transform4x4f& parentTrans) override; void render(const Transform4x4f& parentTrans) override;
protected: protected:
FileData* mRoot; FileData* mRoot;
std::shared_ptr<ThemeData> mTheme; std::shared_ptr<ThemeData> mTheme;

View file

@ -47,8 +47,7 @@ void ISimpleGameListView::onThemeChanged(const std::shared_ptr<ThemeData>& theme
mHeaderText.applyTheme(theme, getName(), "logoText", ALL); mHeaderText.applyTheme(theme, getName(), "logoText", ALL);
// Remove old theme extras. // Remove old theme extras.
for (auto extra : mThemeExtras) for (auto extra : mThemeExtras) {
{
removeChild(extra); removeChild(extra);
delete extra; delete extra;
} }
@ -78,8 +77,7 @@ void ISimpleGameListView::onFileChanged(FileData* /*file*/, FileChangeType /*cha
populateList(cursor->getParent()->getChildrenListToDisplay()); populateList(cursor->getParent()->getChildrenListToDisplay());
setCursor(cursor); setCursor(cursor);
} }
else else {
{
populateList(mRoot->getChildrenListToDisplay()); populateList(mRoot->getChildrenListToDisplay());
setCursor(cursor); setCursor(cursor);
} }
@ -118,9 +116,8 @@ bool ISimpleGameListView::input(InputConfig* config, Input input)
onFocusLost(); onFocusLost();
SystemData* systemToView = getCursor()->getSystem(); SystemData* systemToView = getCursor()->getSystem();
if (systemToView->isCollection()) if (systemToView->isCollection())
{
systemToView = CollectionSystemManager::get()->getSystemToView(systemToView); systemToView = CollectionSystemManager::get()->getSystemToView(systemToView);
}
ViewController::get()->goToSystemView(systemToView); ViewController::get()->goToSystemView(systemToView);
} }

View file

@ -23,7 +23,7 @@ public:
// Called when a new file is added, a file is removed, a file's metadata changes, // Called when a new file is added, a file is removed, a file's metadata changes,
// or a file's children are sorted. // or a file's children are sorted.
// NOTE: FILE_SORTED is only reported for the topmost FileData, where the sort started. // NOTE: FILE_SORTED is only reported for the topmost FileData, where the sort started.
// Since sorts are recursive, that FileData's children probably changed too. // Since sorts are recursive, that FileData's children probably changed too.
virtual void onFileChanged(FileData* file, FileChangeType change) override; virtual void onFileChanged(FileData* file, FileChangeType change) override;
// Called whenever the theme changes. // Called whenever the theme changes.

View file

@ -52,14 +52,14 @@ VideoGameListView::VideoGameListView(
const float padding = 0.01f; const float padding = 0.01f;
// Create the correct type of video window. // Create the correct type of video window.
#ifdef _RPI_ #ifdef _RPI_
if (Settings::getInstance()->getBool("VideoOmxPlayer")) if (Settings::getInstance()->getBool("VideoOmxPlayer"))
mVideo = new VideoPlayerComponent(window, ""); mVideo = new VideoPlayerComponent(window, "");
else else
mVideo = new VideoVlcComponent(window, getTitlePath()); mVideo = new VideoVlcComponent(window, getTitlePath());
#else #else
mVideo = new VideoVlcComponent(window, getTitlePath()); mVideo = new VideoVlcComponent(window, getTitlePath());
#endif #endif
mList.setPosition(mSize.x() * (0.50f + padding), mList.getPosition().y()); mList.setPosition(mSize.x() * (0.50f + padding), mList.getPosition().y());
mList.setSize(mSize.x() * (0.50f - padding), mList.getSize().y()); mList.setSize(mSize.x() * (0.50f - padding), mList.getSize().y());

View file

@ -33,14 +33,14 @@ public:
inline std::string getStatusString() inline std::string getStatusString()
{ {
switch (mStatus) { switch (mStatus) {
case ASYNC_IN_PROGRESS: case ASYNC_IN_PROGRESS:
return "in progress"; return "in progress";
case ASYNC_ERROR: case ASYNC_ERROR:
return mError; return mError;
case ASYNC_DONE: case ASYNC_DONE:
return "done"; return "done";
default: default:
return "something impossible has occured; row, row, fight the power"; return "something impossible has occured; row, row, fight the power";
} }
} }

View file

@ -31,7 +31,7 @@ void AudioManager::mixAudio(void* /*unused*/, Uint8 *stream, int len)
std::vector<std::shared_ptr<Sound>>::const_iterator soundIt = sSoundVector.cbegin(); std::vector<std::shared_ptr<Sound>>::const_iterator soundIt = sSoundVector.cbegin();
while (soundIt != sSoundVector.cend()) { while (soundIt != sSoundVector.cend()) {
std::shared_ptr<Sound> sound = *soundIt; std::shared_ptr<Sound> sound = *soundIt;
if(sound->isPlaying()) { if (sound->isPlaying()) {
// Calculate rest length of current sample. // Calculate rest length of current sample.
Uint32 restLength = (sound->getLength() - sound->getPosition()); Uint32 restLength = (sound->getLength() - sound->getPosition());
if (restLength > (Uint32)len) { if (restLength > (Uint32)len) {
@ -87,8 +87,8 @@ void AudioManager::init()
} }
// Stop playing all Sounds. // Stop playing all Sounds.
for(unsigned int i = 0; i < sSoundVector.size(); i++) { for (unsigned int i = 0; i < sSoundVector.size(); i++) {
if(sSoundVector.at(i)->isPlaying()) if (sSoundVector.at(i)->isPlaying())
sSoundVector[i]->stop(); sSoundVector[i]->stop();
} }
@ -127,8 +127,8 @@ void AudioManager::registerSound(std::shared_ptr<Sound> & sound)
void AudioManager::unregisterSound(std::shared_ptr<Sound> & sound) void AudioManager::unregisterSound(std::shared_ptr<Sound> & sound)
{ {
getInstance(); getInstance();
for(unsigned int i = 0; i < sSoundVector.size(); i++) { for (unsigned int i = 0; i < sSoundVector.size(); i++) {
if(sSoundVector.at(i) == sound) { if (sSoundVector.at(i) == sound) {
sSoundVector[i]->stop(); sSoundVector[i]->stop();
sSoundVector.erase(sSoundVector.cbegin() + i); sSoundVector.erase(sSoundVector.cbegin() + i);
return; return;
@ -148,10 +148,10 @@ void AudioManager::play()
void AudioManager::stop() void AudioManager::stop()
{ {
// Stop playing all Sounds. // Stop playing all Sounds.
for(unsigned int i = 0; i < sSoundVector.size(); i++) { for (unsigned int i = 0; i < sSoundVector.size(); i++) {
if(sSoundVector.at(i)->isPlaying()) if (sSoundVector.at(i)->isPlaying())
sSoundVector[i]->stop(); sSoundVector[i]->stop();
} }
// Pause audio // Pause audio.
SDL_PauseAudio(1); SDL_PauseAudio(1);
} }

View file

@ -16,7 +16,7 @@ HelpStyle::HelpStyle()
iconColor = 0x777777FF; iconColor = 0x777777FF;
textColor = 0x777777FF; textColor = 0x777777FF;
if(FONT_SIZE_SMALL != 0) if (FONT_SIZE_SMALL != 0)
font = Font::get(FONT_SIZE_SMALL); font = Font::get(FONT_SIZE_SMALL);
else else
font = nullptr; font = nullptr;
@ -25,22 +25,22 @@ HelpStyle::HelpStyle()
void HelpStyle::applyTheme(const std::shared_ptr<ThemeData>& theme, const std::string& view) void HelpStyle::applyTheme(const std::shared_ptr<ThemeData>& theme, const std::string& view)
{ {
auto elem = theme->getElement(view, "help", "helpsystem"); auto elem = theme->getElement(view, "help", "helpsystem");
if(!elem) if (!elem)
return; return;
if(elem->has("pos")) if (elem->has("pos"))
position = elem->get<Vector2f>("pos") * position = elem->get<Vector2f>("pos") *
Vector2f((float)Renderer::getScreenWidth(), (float)Renderer::getScreenHeight()); Vector2f((float)Renderer::getScreenWidth(), (float)Renderer::getScreenHeight());
if(elem->has("origin")) if (elem->has("origin"))
origin = elem->get<Vector2f>("origin"); origin = elem->get<Vector2f>("origin");
if(elem->has("textColor")) if (elem->has("textColor"))
textColor = elem->get<unsigned int>("textColor"); textColor = elem->get<unsigned int>("textColor");
if(elem->has("iconColor")) if (elem->has("iconColor"))
iconColor = elem->get<unsigned int>("iconColor"); iconColor = elem->get<unsigned int>("iconColor");
if(elem->has("fontPath") || elem->has("fontSize")) if (elem->has("fontPath") || elem->has("fontSize"))
font = Font::getFromTheme(elem, ThemeFlags::ALL, font); font = Font::getFromTheme(elem, ThemeFlags::ALL, font);
} }

View file

@ -21,12 +21,12 @@
// while (myRequest.status() == HttpReq::REQ_IN_PROGRESS); // while (myRequest.status() == HttpReq::REQ_IN_PROGRESS);
// //
// For non-blocking behavior: // For non-blocking behavior:
// Check 'if(myRequest.status() != HttpReq::REQ_IN_PROGRESS)' in some sort of update method. // Check 'if (myRequest.status() != HttpReq::REQ_IN_PROGRESS)' in some sort of update method.
// //
// Once one of those calls complete, the request is ready. // Once one of those calls complete, the request is ready.
// //
// Do something like this to capture errors: // Do something like this to capture errors:
// if(myRequest.status() != REQ_SUCCESS) { // if (myRequest.status() != REQ_SUCCESS) {
// // An error occured. // // An error occured.
// LOG(LogError) << "HTTP request error - " << myRequest.getErrorMessage(); // LOG(LogError) << "HTTP request error - " << myRequest.getErrorMessage();
// return; // return;

View file

@ -11,7 +11,7 @@
#include <sstream> #include <sstream>
#define LOG(level) \ #define LOG(level) \
if(level > Log::getReportingLevel()); \ if (level > Log::getReportingLevel()); \
else Log().get(level) else Log().get(level)
enum LogLevel { enum LogLevel {

View file

@ -31,10 +31,10 @@ namespace Scripting
// Check in homepath. // Check in homepath.
test = Utils::FileSystem::getHomePath() + "/.emulationstation/scripts/" + eventName; test = Utils::FileSystem::getHomePath() + "/.emulationstation/scripts/" + eventName;
if(Utils::FileSystem::exists(test)) if (Utils::FileSystem::exists(test))
scriptDirList.push_back(test); scriptDirList.push_back(test);
for(std::list<std::string>::const_iterator dirIt = scriptDirList.cbegin(); for (std::list<std::string>::const_iterator dirIt = scriptDirList.cbegin();
dirIt != scriptDirList.cend(); ++dirIt) { dirIt != scriptDirList.cend(); ++dirIt) {
std::list<std::string> scripts = Utils::FileSystem::getDirContent(*dirIt); std::list<std::string> scripts = Utils::FileSystem::getDirContent(*dirIt);
for (std::list<std::string>::const_iterator it = scripts.cbegin(); for (std::list<std::string>::const_iterator it = scripts.cbegin();

View file

@ -20,7 +20,7 @@ std::map< std::string, std::shared_ptr<Sound> > Sound::sMap;
std::shared_ptr<Sound> Sound::get(const std::string& path) std::shared_ptr<Sound> Sound::get(const std::string& path)
{ {
auto it = sMap.find(path); auto it = sMap.find(path);
if(it != sMap.cend()) if (it != sMap.cend())
return it->second; return it->second;
std::shared_ptr<Sound> sound = std::shared_ptr<Sound>(new Sound(path)); std::shared_ptr<Sound> sound = std::shared_ptr<Sound>(new Sound(path));
@ -36,7 +36,7 @@ std::shared_ptr<Sound> Sound::getFromTheme(const std::shared_ptr<ThemeData>& the
element << "\">."; 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(LogDebug) << "Sound::getFromTheme(): " << "Tag not found, using fallback sound file."; LOG(LogDebug) << "Sound::getFromTheme(): " << "Tag not found, using fallback sound file.";
return get(ResourceManager::getInstance()-> return get(ResourceManager::getInstance()->
getResourcePath(":/sounds/" + element + ".wav")); getResourcePath(":/sounds/" + element + ".wav"));
@ -106,10 +106,10 @@ void Sound::loadFile(const std::string & path)
void Sound::init() void Sound::init()
{ {
if(mSampleData != nullptr) if (mSampleData != nullptr)
deinit(); deinit();
if(mPath.empty()) if (mPath.empty())
return; return;
// Load WAV file via SDL. // Load WAV file via SDL.
@ -153,7 +153,7 @@ void Sound::deinit()
{ {
playing = false; playing = false;
if(mSampleData != nullptr) { if (mSampleData != nullptr) {
SDL_LockAudio(); SDL_LockAudio();
delete[] mSampleData; delete[] mSampleData;
mSampleData = nullptr; mSampleData = nullptr;
@ -165,10 +165,10 @@ void Sound::deinit()
void Sound::play() void Sound::play()
{ {
if(mSampleData == nullptr) if (mSampleData == nullptr)
return; return;
if(!Settings::getInstance()->getBool("NavigationSounds")) if (!Settings::getInstance()->getBool("NavigationSounds"))
return; return;
AudioManager::getInstance(); AudioManager::getInstance();

View file

@ -379,8 +379,7 @@ void ThemeData::parseViews(const pugi::xml_node& root)
size_t prevOff = nameAttr.find_first_not_of(delim, 0); 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);
std::string viewKey; std::string viewKey;
while (off != std::string::npos || prevOff != std::string::npos) while (off != std::string::npos || prevOff != std::string::npos) {
{
viewKey = nameAttr.substr(prevOff, off - prevOff); viewKey = nameAttr.substr(prevOff, off - prevOff);
prevOff = nameAttr.find_first_not_of(delim, off); prevOff = nameAttr.find_first_not_of(delim, off);
off = nameAttr.find_first_of(delim, prevOff); off = nameAttr.find_first_of(delim, prevOff);

View file

@ -33,7 +33,7 @@ bool AnimationController::update(int deltaTime)
{ {
mTime += deltaTime; mTime += deltaTime;
if(mTime < 0) // Are we still in delay? if (mTime < 0) // Are we still in delay?
return false; return false;
float t = (float)mTime / mAnimation->getDuration(); float t = (float)mTime / mAnimation->getDuration();
@ -45,7 +45,7 @@ bool AnimationController::update(int deltaTime)
mAnimation->apply(mReverse ? 1.0f - t : t); mAnimation->apply(mReverse ? 1.0f - t : t);
if(t == 1.0f) if (t == 1.0f)
return true; return true;
return false; return false;

View file

@ -72,7 +72,7 @@ public:
inline std::shared_ptr<GuiComponent> getSelectedComponent() inline std::shared_ptr<GuiComponent> getSelectedComponent()
{ {
const GridEntry* e = getCellAt(mCursor); const GridEntry* e = getCellAt(mCursor);
if(e) if (e)
return e->component; return e->component;
else else
return nullptr; return nullptr;

View file

@ -45,7 +45,7 @@ struct ComponentListRow
inline void makeAcceptInputHandler(const std::function<void()>& func) inline void makeAcceptInputHandler(const std::function<void()>& func)
{ {
input_handler = [func](InputConfig* config, Input input) -> bool { input_handler = [func](InputConfig* config, Input input) -> bool {
if(config->isMappedTo("a", input) && input.value != 0) { if (config->isMappedTo("a", input) && input.value != 0) {
func(); func();
return true; return true;
} }

View file

@ -68,7 +68,7 @@ std::string DateTimeComponent::getDisplayString() const
{ {
if (mDisplayRelative) { if (mDisplayRelative) {
// Relative time. // Relative time.
if(mTime.getTime() == 0) if (mTime.getTime() == 0)
return "never"; return "never";
Utils::Time::DateTime now(Utils::Time::now()); Utils::Time::DateTime now(Utils::Time::now());
@ -76,11 +76,11 @@ std::string DateTimeComponent::getDisplayString() const
char buf[64]; char buf[64];
if(dur.getDays() > 0) if (dur.getDays() > 0)
sprintf(buf, "%d day%s ago", dur.getDays(), (dur.getDays() > 1) ? "s" : ""); sprintf(buf, "%d day%s ago", dur.getDays(), (dur.getDays() > 1) ? "s" : "");
else if(dur.getHours() > 0) else if (dur.getHours() > 0)
sprintf(buf, "%d hour%s ago", dur.getHours(), (dur.getHours() > 1) ? "s" : ""); sprintf(buf, "%d hour%s ago", dur.getHours(), (dur.getHours() > 1) ? "s" : "");
else if(dur.getMinutes() > 0) else if (dur.getMinutes() > 0)
sprintf(buf, "%d minute%s ago", dur.getMinutes(), (dur.getMinutes() > 1) ? "s" : ""); sprintf(buf, "%d minute%s ago", dur.getMinutes(), (dur.getMinutes() > 1) ? "s" : "");
else else
sprintf(buf, "%d second%s ago", dur.getSeconds(), (dur.getSeconds() > 1) ? "s" : ""); sprintf(buf, "%d second%s ago", dur.getSeconds(), (dur.getSeconds() > 1) ? "s" : "");
@ -88,7 +88,7 @@ std::string DateTimeComponent::getDisplayString() const
return std::string(buf); return std::string(buf);
} }
if(mTime.getTime() == 0) if (mTime.getTime() == 0)
return "unknown"; return "unknown";
return Utils::Time::timeToString(mTime.getTime(), mFormat); return Utils::Time::timeToString(mTime.getTime(), mFormat);
@ -107,13 +107,13 @@ void DateTimeComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
using namespace ThemeFlags; using namespace ThemeFlags;
const ThemeData::ThemeElement* elem = theme->getElement(view, element, "datetime"); const ThemeData::ThemeElement* elem = theme->getElement(view, element, "datetime");
if(!elem) if (!elem)
return; return;
if(elem->has("displayRelative")) if (elem->has("displayRelative"))
setDisplayRelative(elem->get<bool>("displayRelative")); setDisplayRelative(elem->get<bool>("displayRelative"));
if(elem->has("format")) if (elem->has("format"))
setFormat(elem->get<std::string>("format")); setFormat(elem->get<std::string>("format"));
if (properties & COLOR && elem->has("color")) if (properties & COLOR && elem->has("color"))
@ -125,22 +125,22 @@ void DateTimeComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
setRenderBackground(true); setRenderBackground(true);
} }
if(properties & ALIGNMENT && elem->has("alignment")) { if (properties & ALIGNMENT && elem->has("alignment")) {
std::string str = elem->get<std::string>("alignment"); std::string str = elem->get<std::string>("alignment");
if(str == "left") if (str == "left")
setHorizontalAlignment(ALIGN_LEFT); setHorizontalAlignment(ALIGN_LEFT);
else if(str == "center") else if (str == "center")
setHorizontalAlignment(ALIGN_CENTER); setHorizontalAlignment(ALIGN_CENTER);
else if(str == "right") else if (str == "right")
setHorizontalAlignment(ALIGN_RIGHT); setHorizontalAlignment(ALIGN_RIGHT);
else else
LOG(LogError) << "Unknown text alignment string: " << str; LOG(LogError) << "Unknown text alignment string: " << str;
} }
if(properties & FORCE_UPPERCASE && elem->has("forceUppercase")) if (properties & FORCE_UPPERCASE && elem->has("forceUppercase"))
setUppercase(elem->get<bool>("forceUppercase")); setUppercase(elem->get<bool>("forceUppercase"));
if(properties & LINE_SPACING && elem->has("lineSpacing")) if (properties & LINE_SPACING && elem->has("lineSpacing"))
setLineSpacing(elem->get<float>("lineSpacing")); setLineSpacing(elem->get<float>("lineSpacing"));
setFont(Font::getFromTheme(elem, properties, mFont)); setFont(Font::getFromTheme(elem, properties, mFont));

View file

@ -50,7 +50,7 @@ public:
mLeftArrow.setResize(0, mText.getFont()->getLetterHeight()); mLeftArrow.setResize(0, mText.getFont()->getLetterHeight());
mRightArrow.setResize(0, mText.getFont()->getLetterHeight()); mRightArrow.setResize(0, mText.getFont()->getLetterHeight());
if(mMultiSelect) { if (mMultiSelect) {
mRightArrow.setImage(":/graphics/arrow.svg"); mRightArrow.setImage(":/graphics/arrow.svg");
addChild(&mRightArrow); addChild(&mRightArrow);
} }
@ -72,7 +72,7 @@ public:
mLeftArrow.setResize(0, mText.getFont()->getLetterHeight()); mLeftArrow.setResize(0, mText.getFont()->getLetterHeight());
mRightArrow.setResize(0, mText.getFont()->getLetterHeight()); mRightArrow.setResize(0, mText.getFont()->getLetterHeight());
if(mSize.x() < (mLeftArrow.getSize().x() + mRightArrow.getSize().x())) { if (mSize.x() < (mLeftArrow.getSize().x() + mRightArrow.getSize().x())) {
LOG(LogWarning) << "OptionListComponent too narrow!"; LOG(LogWarning) << "OptionListComponent too narrow!";
} }
@ -89,17 +89,17 @@ public:
bool input(InputConfig* config, Input input) override bool input(InputConfig* config, Input input) override
{ {
if(input.value != 0) { if (input.value != 0) {
if(config->isMappedTo("a", input)) { if (config->isMappedTo("a", input)) {
open(); open();
return true; return true;
} }
if(!mMultiSelect) { if (!mMultiSelect) {
if(config->isMappedLike("left", input)) { if (config->isMappedLike("left", input)) {
// Move selection to previous. // Move selection to previous.
unsigned int i = getSelectedId(); unsigned int i = getSelectedId();
int next = (int)i - 1; int next = (int)i - 1;
if(next < 0) if (next < 0)
next += (int)mEntries.size(); next += (int)mEntries.size();
mEntries.at(i).selected = false; mEntries.at(i).selected = false;
@ -108,7 +108,7 @@ public:
return true; return true;
} }
else if(config->isMappedLike("right", input)) { else if (config->isMappedLike("right", input)) {
// Move selection to next. // Move selection to next.
unsigned int i = getSelectedId(); unsigned int i = getSelectedId();
int next = (i + 1) % mEntries.size(); int next = (i + 1) % mEntries.size();
@ -125,8 +125,8 @@ public:
std::vector<T> getSelectedObjects() std::vector<T> getSelectedObjects()
{ {
std::vector<T> ret; std::vector<T> ret;
for(auto it = mEntries.cbegin(); it != mEntries.cend(); it++) { for (auto it = mEntries.cbegin(); it != mEntries.cend(); it++) {
if(it->selected) if (it->selected)
ret.push_back(it->object); ret.push_back(it->object);
} }
@ -178,14 +178,14 @@ public:
void selectAll() void selectAll()
{ {
for(unsigned int i = 0; i < mEntries.size(); i++) for (unsigned int i = 0; i < mEntries.size(); i++)
mEntries.at(i).selected = true; mEntries.at(i).selected = true;
onSelectedChanged(); onSelectedChanged();
} }
void selectNone() void selectNone()
{ {
for(unsigned int i = 0; i < mEntries.size(); i++) for (unsigned int i = 0; i < mEntries.size(); i++)
mEntries.at(i).selected = false; mEntries.at(i).selected = false;
onSelectedChanged(); onSelectedChanged();
} }
@ -204,8 +204,8 @@ private:
unsigned int getSelectedId() unsigned int getSelectedId()
{ {
assert(mMultiSelect == false); assert(mMultiSelect == false);
for(unsigned int i = 0; i < mEntries.size(); i++) { for (unsigned int i = 0; i < mEntries.size(); i++) {
if(mEntries.at(i).selected) if (mEntries.at(i).selected)
return i; return i;
} }
@ -221,25 +221,25 @@ private:
void onSelectedChanged() void onSelectedChanged()
{ {
if(mMultiSelect) { if (mMultiSelect) {
// Display # selected. // Display # selected.
std::stringstream ss; std::stringstream ss;
ss << getSelectedObjects().size() << " SELECTED"; ss << getSelectedObjects().size() << " SELECTED";
mText.setText(ss.str()); mText.setText(ss.str());
mText.setSize(0, mText.getSize().y()); mText.setSize(0, mText.getSize().y());
setSize(mText.getSize().x() + mRightArrow.getSize().x() + 24, mText.getSize().y()); setSize(mText.getSize().x() + mRightArrow.getSize().x() + 24, mText.getSize().y());
if(mParent) // Hack since theres no "on child size changed" callback atm... if (mParent) // Hack since theres no "on child size changed" callback atm...
mParent->onSizeChanged(); mParent->onSizeChanged();
} }
else { else {
// Display currently selected + l/r cursors. // Display currently selected + l/r cursors.
for(auto it = mEntries.cbegin(); it != mEntries.cend(); it++) { for (auto it = mEntries.cbegin(); it != mEntries.cend(); it++) {
if(it->selected) { if (it->selected) {
mText.setText(Utils::String::toUpper(it->name)); mText.setText(Utils::String::toUpper(it->name));
mText.setSize(0, mText.getSize().y()); mText.setSize(0, mText.getSize().y());
setSize(mText.getSize().x() + mLeftArrow.getSize().x() + setSize(mText.getSize().x() + mLeftArrow.getSize().x() +
mRightArrow.getSize().x() + 24, mText.getSize().y()); mRightArrow.getSize().x() + 24, mText.getSize().y());
if(mParent) // Hack since theres no "on child size changed" callback atm... if (mParent) // Hack since theres no "on child size changed" callback atm...
mParent->onSizeChanged(); mParent->onSizeChanged();
break; break;
} }
@ -250,7 +250,7 @@ private:
std::vector<HelpPrompt> getHelpPrompts() override std::vector<HelpPrompt> getHelpPrompts() override
{ {
std::vector<HelpPrompt> prompts; std::vector<HelpPrompt> prompts;
if(!mMultiSelect) if (!mMultiSelect)
prompts.push_back(HelpPrompt("left/right", "change value")); prompts.push_back(HelpPrompt("left/right", "change value"));
prompts.push_back(HelpPrompt("a", "select")); prompts.push_back(HelpPrompt("a", "select"));
@ -286,14 +286,14 @@ private:
// For select all/none. // For select all/none.
std::vector<ImageComponent*> checkboxes; std::vector<ImageComponent*> checkboxes;
for(auto it = mParent->mEntries.begin(); it != mParent->mEntries.end(); it++) { for (auto it = mParent->mEntries.begin(); it != mParent->mEntries.end(); it++) {
row.elements.clear(); row.elements.clear();
row.addElement(std::make_shared<TextComponent> row.addElement(std::make_shared<TextComponent>
(mWindow, Utils::String::toUpper(it->name), font, 0x777777FF), true); (mWindow, Utils::String::toUpper(it->name), font, 0x777777FF), true);
OptionListData& e = *it; OptionListData& e = *it;
if(mParent->mMultiSelect) { if (mParent->mMultiSelect) {
// Add checkbox. // Add checkbox.
auto checkbox = std::make_shared<ImageComponent>(mWindow); auto checkbox = std::make_shared<ImageComponent>(mWindow);
checkbox->setImage(it->selected ? CHECKED_PATH : UNCHECKED_PATH); checkbox->setImage(it->selected ? CHECKED_PATH : UNCHECKED_PATH);
@ -328,9 +328,9 @@ private:
mMenu.addButton("BACK", "back", [this] { delete this; }); mMenu.addButton("BACK", "back", [this] { delete this; });
if(mParent->mMultiSelect) { if (mParent->mMultiSelect) {
mMenu.addButton("SELECT ALL", "select all", [this, checkboxes] { mMenu.addButton("SELECT ALL", "select all", [this, checkboxes] {
for(unsigned int i = 0; i < mParent->mEntries.size(); i++) { for (unsigned int i = 0; i < mParent->mEntries.size(); i++) {
mParent->mEntries.at(i).selected = true; mParent->mEntries.at(i).selected = true;
checkboxes.at(i)->setImage(CHECKED_PATH); checkboxes.at(i)->setImage(CHECKED_PATH);
} }
@ -338,7 +338,7 @@ private:
}); });
mMenu.addButton("SELECT NONE", "select none", [this, checkboxes] { mMenu.addButton("SELECT NONE", "select none", [this, checkboxes] {
for(unsigned int i = 0; i < mParent->mEntries.size(); i++) { for (unsigned int i = 0; i < mParent->mEntries.size(); i++) {
mParent->mEntries.at(i).selected = false; mParent->mEntries.at(i).selected = false;
checkboxes.at(i)->setImage(UNCHECKED_PATH); checkboxes.at(i)->setImage(UNCHECKED_PATH);
} }
@ -353,7 +353,7 @@ private:
bool input(InputConfig* config, Input input) override bool input(InputConfig* config, Input input) override
{ {
if(config->isMappedTo("b", input) && input.value != 0) { if (config->isMappedTo("b", input) && input.value != 0) {
delete this; delete this;
return true; return true;
} }

View file

@ -127,7 +127,7 @@ void RatingComponent::render(const Transform4x4f& parentTrans)
Renderer::setMatrix(trans); Renderer::setMatrix(trans);
if (mOpacity > 0) { if (mOpacity > 0) {
if(Settings::getInstance()->getBool("DebugImage")) { if (Settings::getInstance()->getBool("DebugImage")) {
Renderer::drawRect(0.0f, 0.0f, mSize.y() * NUM_RATING_STARS, Renderer::drawRect(0.0f, 0.0f, mSize.y() * NUM_RATING_STARS,
mSize.y(), 0x00000033, 0x00000033); mSize.y(), 0x00000033, 0x00000033);
} }

View file

@ -27,7 +27,7 @@ void SwitchComponent::onSizeChanged()
bool SwitchComponent::input(InputConfig* config, Input input) bool SwitchComponent::input(InputConfig* config, Input input)
{ {
if(config->isMappedTo("a", input) && input.value) { if (config->isMappedTo("a", input) && input.value) {
mState = !mState; mState = !mState;
onStateChanged(); onStateChanged();
return true; return true;

View file

@ -83,20 +83,20 @@ namespace Math
float bounce(const float _delayTime, const float _scrollTime, float bounce(const float _delayTime, const float _scrollTime,
const float _currentTime, const float _scrollLength) const float _currentTime, const float _scrollLength)
{ {
if(_currentTime < _delayTime) { if (_currentTime < _delayTime) {
// Wait. // Wait.
return 0; return 0;
} }
else if(_currentTime < (_delayTime + _scrollTime)) { else if (_currentTime < (_delayTime + _scrollTime)) {
// Lerp from 0 to scrollLength. // Lerp from 0 to scrollLength.
const float fraction = (_currentTime - _delayTime) / _scrollTime; const float fraction = (_currentTime - _delayTime) / _scrollTime;
return lerp(0.0f, _scrollLength, smootherStep(0, 1, fraction)); return lerp(0.0f, _scrollLength, smootherStep(0, 1, fraction));
} }
else if(_currentTime < (_delayTime + _scrollTime + _delayTime)) { else if (_currentTime < (_delayTime + _scrollTime + _delayTime)) {
// Wait some more. // Wait some more.
return _scrollLength; return _scrollLength;
} }
else if(_currentTime < (_delayTime + _scrollTime + _delayTime + _scrollTime)) { else if (_currentTime < (_delayTime + _scrollTime + _delayTime + _scrollTime)) {
// Lerp back from scrollLength to 0. // Lerp back from scrollLength to 0.
const float fraction = (_currentTime - _delayTime - _scrollTime - const float fraction = (_currentTime - _delayTime - _scrollTime -
_delayTime) / _scrollTime; _delayTime) / _scrollTime;
@ -109,11 +109,11 @@ namespace Math
float loop(const float _delayTime, const float _scrollTime, float loop(const float _delayTime, const float _scrollTime,
const float _currentTime, const float _scrollLength) const float _currentTime, const float _scrollLength)
{ {
if(_currentTime < _delayTime) { if (_currentTime < _delayTime) {
// Wait. // Wait.
return 0; return 0;
} }
else if(_currentTime < (_delayTime + _scrollTime)) { else if (_currentTime < (_delayTime + _scrollTime)) {
// Lerp from 0 to scrollLength. // Lerp from 0 to scrollLength.
const float fraction = (_currentTime - _delayTime) / _scrollTime; const float fraction = (_currentTime - _delayTime) / _scrollTime;
return lerp(0.0f, _scrollLength, fraction); return lerp(0.0f, _scrollLength, fraction);

View file

@ -143,7 +143,7 @@ Transform4x4f& Transform4x4f::invert(const Transform4x4f& _other)
om[ 8] * tm[ 2] + om[ 8] * tm[ 2] +
om[12] * tm[ 3]; om[12] * tm[ 3];
if(Determinant != 0) if (Determinant != 0)
Determinant = 1 / Determinant; Determinant = 1 / Determinant;
tm[ 0] *= Determinant; tm[ 0] *= Determinant;

View file

@ -549,7 +549,7 @@ namespace Utils
return true; return true;
} }
if(isDirectory(_destination_path)) { if (isDirectory(_destination_path)) {
LOG(LogError) << "Error - Destination file is actually a directory:"; LOG(LogError) << "Error - Destination file is actually a directory:";
LOG(LogError) << _destination_path; LOG(LogError) << _destination_path;
return true; return true;
@ -607,7 +607,7 @@ namespace Utils
return true; return true;
} }
if(isDirectory(_destination_path)) { if (isDirectory(_destination_path)) {
LOG(LogError) << "Error - Destination file is actually a directory:"; LOG(LogError) << "Error - Destination file is actually a directory:";
LOG(LogError) << _destination_path; LOG(LogError) << _destination_path;
return true; return true;