diff --git a/es-app/src/FileSorts.cpp b/es-app/src/FileSorts.cpp index 1922adaff..f1f8d0145 100644 --- a/es-app/src/FileSorts.cpp +++ b/es-app/src/FileSorts.cpp @@ -53,10 +53,10 @@ namespace FileSorts // appended which messes up the order. std::string name1 = Utils::String::toUpper(file1->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")); } - if(name2.empty()){ + if (name2.empty()){ name2 = Utils::String::toUpper(file2->metadata.get("name")); } return name1.compare(name2) < 0; @@ -70,7 +70,7 @@ namespace FileSorts bool compareTimesPlayed(const FileData* file1, const FileData* file2) { //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 false; diff --git a/es-app/src/guis/GuiCollectionSystemsOptions.cpp b/es-app/src/guis/GuiCollectionSystemsOptions.cpp index 00bc1a94f..d40b93960 100644 --- a/es-app/src/guis/GuiCollectionSystemsOptions.cpp +++ b/es-app/src/guis/GuiCollectionSystemsOptions.cpp @@ -42,7 +42,7 @@ void GuiCollectionSystemsOptions::initializeMenu() (mWindow, getHelpStyle(), "SELECT THEME FOLDER", true); // Add custom systems. - for(auto it = unusedFolders.cbegin() ; it != unusedFolders.cend() ; it++ ) { + for (auto it = unusedFolders.cbegin() ; it != unusedFolders.cend() ; it++ ) { ComponentListRow row; std::string name = *it; @@ -97,7 +97,7 @@ void GuiCollectionSystemsOptions::initializeMenu() getBool("CollectionShowSystemInfo")); mMenu.addWithLabel("SHOW SYSTEM NAMES IN COLLECTIONS", toggleSystemNameInCollections); - if(CollectionSystemManager::get()->isEditing()) { + if (CollectionSystemManager::get()->isEditing()) { row.elements.clear(); row.addElement(std::make_shared(mWindow, "FINISH EDITING '" + Utils::String::toUpper(CollectionSystemManager::get()->getEditingCollection()) + @@ -120,7 +120,7 @@ void GuiCollectionSystemsOptions::addEntry(const char* name, unsigned int color, ComponentListRow row; row.addElement(std::make_shared(mWindow, name, font, color), true); - if(add_arrow) { + if (add_arrow) { std::shared_ptr bracket = makeArrow(mWindow); row.addElement(bracket, false); } @@ -142,7 +142,7 @@ void GuiCollectionSystemsOptions::createCollection(std::string inName) { Window* window = mWindow; CollectionSystemManager::get()->setEditMode(name); - while(window->peekGui() && window->peekGui() != ViewController::get()) + while (window->peekGui() && window->peekGui() != ViewController::get()) delete window->peekGui(); return; } @@ -166,7 +166,7 @@ void GuiCollectionSystemsOptions::addSystemsToMenu() (mWindow, getHelpStyle(), "SELECT COLLECTIONS", true); // Add automatic systems. - for(std::map::const_iterator it = autoSystems.cbegin(); + for (std::map::const_iterator it = autoSystems.cbegin(); it != autoSystems.cend() ; it++ ) autoOptionList->add(it->second.decl.longName, it->second.decl.name, it->second.isEnabled); mMenu.addWithLabel("AUTOMATIC GAME COLLECTIONS", autoOptionList); @@ -178,7 +178,7 @@ void GuiCollectionSystemsOptions::addSystemsToMenu() (mWindow, getHelpStyle(), "SELECT COLLECTIONS", true); // Add custom systems. - for(std::map::const_iterator it = customSystems.cbegin(); + for (std::map::const_iterator it = customSystems.cbegin(); it != customSystems.cend() ; it++ ) customOptionList->add(it->second.decl.longName, it->second.decl.name, it->second.isEnabled); mMenu.addWithLabel("CUSTOM GAME COLLECTIONS", customOptionList); @@ -228,10 +228,10 @@ bool GuiCollectionSystemsOptions::input(InputConfig* config, Input input) { bool consumed = GuiComponent::input(config, input); - if(consumed) + if (consumed) return true; - if(config->isMappedTo("b", input) && input.value != 0) + if (config->isMappedTo("b", input) && input.value != 0) applySettings(); return false; diff --git a/es-app/src/guis/GuiGameScraper.cpp b/es-app/src/guis/GuiGameScraper.cpp index 93335b7d4..8135cba1b 100644 --- a/es-app/src/guis/GuiGameScraper.cpp +++ b/es-app/src/guis/GuiGameScraper.cpp @@ -86,7 +86,7 @@ GuiGameScraper::GuiGameScraper( // mSearchComponent::update() // acceptCallback -> close() -> mClose = true // it++; // OK. - // if(mClose) + // if (mClose) // delete this; mSearch->setAcceptCallback([this, doneFunc](const ScraperSearchResult& result) { doneFunc(result); close(); }); @@ -117,7 +117,7 @@ void GuiGameScraper::onSizeChanged() bool GuiGameScraper::input(InputConfig* config, Input input) { - if(config->isMappedTo("b", input) && input.value) { + if (config->isMappedTo("b", input) && input.value) { PowerSaver::resume(); delete this; return true; @@ -130,7 +130,7 @@ void GuiGameScraper::update(int deltaTime) { GuiComponent::update(deltaTime); - if(mClose) + if (mClose) delete this; } diff --git a/es-app/src/guis/GuiGameScraper.h b/es-app/src/guis/GuiGameScraper.h index 89aff413a..a957eed11 100644 --- a/es-app/src/guis/GuiGameScraper.h +++ b/es-app/src/guis/GuiGameScraper.h @@ -17,9 +17,7 @@ class GuiGameScraper : public GuiComponent { public: - GuiGameScraper( - Window* window, - ScraperSearchParams params, + GuiGameScraper(Window* window, ScraperSearchParams params, std::function doneFunc); void onSizeChanged() override; diff --git a/es-app/src/guis/GuiGeneralScreensaverOptions.cpp b/es-app/src/guis/GuiGeneralScreensaverOptions.cpp index f3d8ecf90..2ccb037f3 100644 --- a/es-app/src/guis/GuiGeneralScreensaverOptions.cpp +++ b/es-app/src/guis/GuiGeneralScreensaverOptions.cpp @@ -45,7 +45,7 @@ GuiGeneralScreensaverOptions::GuiGeneralScreensaverOptions(Window* window, const screensavers.push_back("black"); screensavers.push_back("random video"); 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()-> getString("ScreenSaverBehavior") == *it); addWithLabel("SCREENSAVER BEHAVIOR", screensaver_behavior); diff --git a/es-app/src/guis/GuiScreensaverOptions.cpp b/es-app/src/guis/GuiScreensaverOptions.cpp index 56f52928c..46fd7ae9f 100644 --- a/es-app/src/guis/GuiScreensaverOptions.cpp +++ b/es-app/src/guis/GuiScreensaverOptions.cpp @@ -29,10 +29,10 @@ GuiScreensaverOptions::~GuiScreensaverOptions() void GuiScreensaverOptions::save() { - if(!mSaveFuncs.size()) + if (!mSaveFuncs.size()) return; - for(auto it = mSaveFuncs.cbegin(); it != mSaveFuncs.cend(); it++) + for (auto it = mSaveFuncs.cbegin(); it != mSaveFuncs.cend(); it++) (*it)(); Settings::getInstance()->saveFile(); diff --git a/es-app/src/guis/GuiVideoScreensaverOptions.cpp b/es-app/src/guis/GuiVideoScreensaverOptions.cpp index 7952a15c6..ef7990f2c 100644 --- a/es-app/src/guis/GuiVideoScreensaverOptions.cpp +++ b/es-app/src/guis/GuiVideoScreensaverOptions.cpp @@ -48,7 +48,7 @@ GuiVideoScreensaverOptions::GuiVideoScreensaverOptions(Window* window, const cha info_type.push_back("always"); info_type.push_back("start & end"); 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); addWithLabel("SHOW GAME INFO ON SCREENSAVER", ss_info); addSaveFunc([ss_info, this] { Settings::getInstance()-> @@ -63,7 +63,7 @@ GuiVideoScreensaverOptions::GuiVideoScreensaverOptions(Window* window, const cha std::vector align_mode; align_mode.push_back("left"); 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()-> getString("SubtitleAlignment") == *it); addWithLabel("GAME INFO ALIGNMENT", ss_omx_subs_align); diff --git a/es-app/src/main.cpp b/es-app/src/main.cpp index 370a47448..8223c7892 100644 --- a/es-app/src/main.cpp +++ b/es-app/src/main.cpp @@ -148,11 +148,11 @@ bool parseArgs(int argc, char* argv[]) std::cerr << "Error: No home path supplied with \'--home'.\n"; 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"; return false; } - if(Utils::FileSystem::isRegularFile(argv[i + 1])) { + if (Utils::FileSystem::isRegularFile(argv[i + 1])) { std::cerr << "Error: Home path \'" << argv[i + 1] << "\' is a file and not a directory.\n"; 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. if (strcmp(argv[i], "--home") == 0) { i++; diff --git a/es-app/src/scrapers/Scraper.cpp b/es-app/src/scrapers/Scraper.cpp index a0e26e23c..14acd9202 100644 --- a/es-app/src/scrapers/Scraper.cpp +++ b/es-app/src/scrapers/Scraper.cpp @@ -233,7 +233,7 @@ MDResolveHandle::MDResolveHandle(const ScraperSearchResult& result, // 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 // game.png) which would lead to two media files for this game. - if(it->existingMediaFile != "") + if (it->existingMediaFile != "") Utils::FileSystem::removeFile(it->existingMediaFile); // 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 // 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. - if(mExistingMediaFile != "") + if (mExistingMediaFile != "") Utils::FileSystem::removeFile(mExistingMediaFile); // If the media directory does not exist, something is wrong, possibly permission diff --git a/es-app/src/views/gamelist/BasicGameListView.cpp b/es-app/src/views/gamelist/BasicGameListView.cpp index fd966ea25..fabaff727 100644 --- a/es-app/src/views/gamelist/BasicGameListView.cpp +++ b/es-app/src/views/gamelist/BasicGameListView.cpp @@ -82,20 +82,17 @@ void BasicGameListView::setCursor(FileData* cursor) // Update our cursor stack in case our cursor just // 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 tmp; FileData* ptr = cursor->getParent(); - while (ptr && ptr != mRoot) - { + while (ptr && ptr != mRoot) { tmp.push(ptr); ptr = ptr->getParent(); } // Flip the stack and put it in mCursorStack. mCursorStack = std::stack(); - while (!tmp.empty()) - { + while (!tmp.empty()) { mCursorStack.push(tmp.top()); tmp.pop(); } @@ -205,8 +202,7 @@ std::vector BasicGameListView::getHelpPrompts() prompts.push_back(HelpPrompt("select", "options")); if (mRoot->getSystem()->isGameSystem()) 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(); prompts.push_back(HelpPrompt("y", prompt)); } diff --git a/es-app/src/views/gamelist/DetailedGameListView.cpp b/es-app/src/views/gamelist/DetailedGameListView.cpp index 63b7320c3..a2c099ee2 100644 --- a/es-app/src/views/gamelist/DetailedGameListView.cpp +++ b/es-app/src/views/gamelist/DetailedGameListView.cpp @@ -274,8 +274,8 @@ void DetailedGameListView::updateInfoPanel() for (auto it = comps.cbegin(); it != comps.cend(); it++) { GuiComponent* comp = *it; - // An animation is playing, then animate if reverse != fadingOut - // An animation is not playing, then animate if opacity != our target opacity + // An animation is playing, then animate if reverse != fadingOut. + // An animation is not playing, then animate if opacity != our target opacity. if ((comp->isAnimationPlaying(0) && comp->isAnimationReversed(0) != fadingOut) || (!comp->isAnimationPlaying(0) && comp->getOpacity() != (fadingOut ? 0 : 255))) { auto func = [comp](float t) { diff --git a/es-app/src/views/gamelist/GridGameListView.cpp b/es-app/src/views/gamelist/GridGameListView.cpp index a1e584872..f92ba71f0 100644 --- a/es-app/src/views/gamelist/GridGameListView.cpp +++ b/es-app/src/views/gamelist/GridGameListView.cpp @@ -54,14 +54,14 @@ GridGameListView::GridGameListView( const float padding = 0.01f; // Create the correct type of video window. -#ifdef _RPI_ + #ifdef _RPI_ if (Settings::getInstance()->getBool("VideoOmxPlayer")) mVideo = new VideoPlayerComponent(window, ""); else mVideo = new VideoVlcComponent(window, getTitlePath()); -#else + #else mVideo = new VideoVlcComponent(window, getTitlePath()); -#endif + #endif mGrid.setPosition(mSize.x() * 0.1f, mSize.y() * 0.1f); mGrid.setDefaultZIndex(20); @@ -228,8 +228,9 @@ void GridGameListView::populateList(const std::vector& files) for (auto it = files.cbegin(); it != files.cend(); it++) mGrid.add((*it)->getName(), getImagePath(*it), *it); } - else + else { addPlaceholder(); + } } void GridGameListView::onThemeChanged(const std::shared_ptr& theme) @@ -237,7 +238,6 @@ void GridGameListView::onThemeChanged(const std::shared_ptr& theme) ISimpleGameListView::onThemeChanged(theme); using namespace ThemeFlags; - mGrid.applyTheme(theme, getName(), "gamegrid", ALL); mName.applyTheme(theme, getName(), "md_name", ALL); mMarquee.applyTheme(theme, getName(), "md_marquee", @@ -354,19 +354,18 @@ void GridGameListView::updateInfoPanel() FileData* file = (mGrid.size() == 0 || mGrid.isScrolling()) ? nullptr : mGrid.getSelected(); bool fadingOut; - if (file == nullptr) - { + if (file == nullptr) { mVideo->setVideo(""); mVideo->setImage(""); mVideoPlaying = false; 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())) -// { // mVideo->setDefaultVideo(); -// } + // mVideoPlaying = true; // mVideo->setImage(file->getThumbnailPath()); @@ -403,8 +402,8 @@ void GridGameListView::updateInfoPanel() for (auto it = comps.cbegin(); it != comps.cend(); it++) { GuiComponent* comp = *it; - // An animation is playing, then animate if reverse != fadingOut - // An animation is not playing, then animate if opacity != our target opacity + // An animation is playing, then animate if reverse != fadingOut. + // An animation is not playing, then animate if opacity != our target opacity. if ((comp->isAnimationPlaying(0) && comp->isAnimationReversed(0) != fadingOut) || (!comp->isAnimationPlaying(0) && comp->getOpacity() != (fadingOut ? 0 : 255))) { auto func = [comp](float t) { diff --git a/es-app/src/views/gamelist/IGameListView.h b/es-app/src/views/gamelist/IGameListView.h index f436361d5..81250c70b 100644 --- a/es-app/src/views/gamelist/IGameListView.h +++ b/es-app/src/views/gamelist/IGameListView.h @@ -55,6 +55,7 @@ public: virtual HelpStyle getHelpStyle() override; void render(const Transform4x4f& parentTrans) override; + protected: FileData* mRoot; std::shared_ptr mTheme; diff --git a/es-app/src/views/gamelist/ISimpleGameListView.cpp b/es-app/src/views/gamelist/ISimpleGameListView.cpp index e89397df3..c10ec9f36 100644 --- a/es-app/src/views/gamelist/ISimpleGameListView.cpp +++ b/es-app/src/views/gamelist/ISimpleGameListView.cpp @@ -47,8 +47,7 @@ void ISimpleGameListView::onThemeChanged(const std::shared_ptr& theme mHeaderText.applyTheme(theme, getName(), "logoText", ALL); // Remove old theme extras. - for (auto extra : mThemeExtras) - { + for (auto extra : mThemeExtras) { removeChild(extra); delete extra; } @@ -78,8 +77,7 @@ void ISimpleGameListView::onFileChanged(FileData* /*file*/, FileChangeType /*cha populateList(cursor->getParent()->getChildrenListToDisplay()); setCursor(cursor); } - else - { + else { populateList(mRoot->getChildrenListToDisplay()); setCursor(cursor); } @@ -118,9 +116,8 @@ bool ISimpleGameListView::input(InputConfig* config, Input input) onFocusLost(); SystemData* systemToView = getCursor()->getSystem(); if (systemToView->isCollection()) - { systemToView = CollectionSystemManager::get()->getSystemToView(systemToView); - } + ViewController::get()->goToSystemView(systemToView); } diff --git a/es-app/src/views/gamelist/ISimpleGameListView.h b/es-app/src/views/gamelist/ISimpleGameListView.h index 6a3764b86..59a53b99d 100644 --- a/es-app/src/views/gamelist/ISimpleGameListView.h +++ b/es-app/src/views/gamelist/ISimpleGameListView.h @@ -23,7 +23,7 @@ public: // Called when a new file is added, a file is removed, a file's metadata changes, // or a file's children are sorted. // 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; // Called whenever the theme changes. diff --git a/es-app/src/views/gamelist/VideoGameListView.cpp b/es-app/src/views/gamelist/VideoGameListView.cpp index 526d180c2..3c0366244 100644 --- a/es-app/src/views/gamelist/VideoGameListView.cpp +++ b/es-app/src/views/gamelist/VideoGameListView.cpp @@ -52,14 +52,14 @@ VideoGameListView::VideoGameListView( const float padding = 0.01f; // Create the correct type of video window. -#ifdef _RPI_ + #ifdef _RPI_ if (Settings::getInstance()->getBool("VideoOmxPlayer")) mVideo = new VideoPlayerComponent(window, ""); else mVideo = new VideoVlcComponent(window, getTitlePath()); -#else + #else mVideo = new VideoVlcComponent(window, getTitlePath()); -#endif + #endif mList.setPosition(mSize.x() * (0.50f + padding), mList.getPosition().y()); mList.setSize(mSize.x() * (0.50f - padding), mList.getSize().y()); diff --git a/es-core/src/AsyncHandle.h b/es-core/src/AsyncHandle.h index 3291f91d9..f0cdab0da 100644 --- a/es-core/src/AsyncHandle.h +++ b/es-core/src/AsyncHandle.h @@ -33,14 +33,14 @@ public: inline std::string getStatusString() { switch (mStatus) { - case ASYNC_IN_PROGRESS: - return "in progress"; - case ASYNC_ERROR: - return mError; - case ASYNC_DONE: - return "done"; - default: - return "something impossible has occured; row, row, fight the power"; + case ASYNC_IN_PROGRESS: + return "in progress"; + case ASYNC_ERROR: + return mError; + case ASYNC_DONE: + return "done"; + default: + return "something impossible has occured; row, row, fight the power"; } } diff --git a/es-core/src/AudioManager.cpp b/es-core/src/AudioManager.cpp index bad9ba604..e6826eb02 100644 --- a/es-core/src/AudioManager.cpp +++ b/es-core/src/AudioManager.cpp @@ -31,7 +31,7 @@ void AudioManager::mixAudio(void* /*unused*/, Uint8 *stream, int len) std::vector>::const_iterator soundIt = sSoundVector.cbegin(); while (soundIt != sSoundVector.cend()) { std::shared_ptr sound = *soundIt; - if(sound->isPlaying()) { + if (sound->isPlaying()) { // Calculate rest length of current sample. Uint32 restLength = (sound->getLength() - sound->getPosition()); if (restLength > (Uint32)len) { @@ -87,8 +87,8 @@ void AudioManager::init() } // Stop playing all Sounds. - for(unsigned int i = 0; i < sSoundVector.size(); i++) { - if(sSoundVector.at(i)->isPlaying()) + for (unsigned int i = 0; i < sSoundVector.size(); i++) { + if (sSoundVector.at(i)->isPlaying()) sSoundVector[i]->stop(); } @@ -127,8 +127,8 @@ void AudioManager::registerSound(std::shared_ptr & sound) void AudioManager::unregisterSound(std::shared_ptr & sound) { getInstance(); - for(unsigned int i = 0; i < sSoundVector.size(); i++) { - if(sSoundVector.at(i) == sound) { + for (unsigned int i = 0; i < sSoundVector.size(); i++) { + if (sSoundVector.at(i) == sound) { sSoundVector[i]->stop(); sSoundVector.erase(sSoundVector.cbegin() + i); return; @@ -148,10 +148,10 @@ void AudioManager::play() void AudioManager::stop() { // Stop playing all Sounds. - for(unsigned int i = 0; i < sSoundVector.size(); i++) { - if(sSoundVector.at(i)->isPlaying()) + for (unsigned int i = 0; i < sSoundVector.size(); i++) { + if (sSoundVector.at(i)->isPlaying()) sSoundVector[i]->stop(); } - // Pause audio + // Pause audio. SDL_PauseAudio(1); } diff --git a/es-core/src/HelpStyle.cpp b/es-core/src/HelpStyle.cpp index 672230117..8f5df3dd3 100644 --- a/es-core/src/HelpStyle.cpp +++ b/es-core/src/HelpStyle.cpp @@ -16,7 +16,7 @@ HelpStyle::HelpStyle() iconColor = 0x777777FF; textColor = 0x777777FF; - if(FONT_SIZE_SMALL != 0) + if (FONT_SIZE_SMALL != 0) font = Font::get(FONT_SIZE_SMALL); else font = nullptr; @@ -25,22 +25,22 @@ HelpStyle::HelpStyle() void HelpStyle::applyTheme(const std::shared_ptr& theme, const std::string& view) { auto elem = theme->getElement(view, "help", "helpsystem"); - if(!elem) + if (!elem) return; - if(elem->has("pos")) + if (elem->has("pos")) position = elem->get("pos") * Vector2f((float)Renderer::getScreenWidth(), (float)Renderer::getScreenHeight()); - if(elem->has("origin")) + if (elem->has("origin")) origin = elem->get("origin"); - if(elem->has("textColor")) + if (elem->has("textColor")) textColor = elem->get("textColor"); - if(elem->has("iconColor")) + if (elem->has("iconColor")) iconColor = elem->get("iconColor"); - if(elem->has("fontPath") || elem->has("fontSize")) + if (elem->has("fontPath") || elem->has("fontSize")) font = Font::getFromTheme(elem, ThemeFlags::ALL, font); } diff --git a/es-core/src/HttpReq.h b/es-core/src/HttpReq.h index 95b964fe0..14132ad10 100644 --- a/es-core/src/HttpReq.h +++ b/es-core/src/HttpReq.h @@ -21,12 +21,12 @@ // while (myRequest.status() == HttpReq::REQ_IN_PROGRESS); // // 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. // // Do something like this to capture errors: -// if(myRequest.status() != REQ_SUCCESS) { +// if (myRequest.status() != REQ_SUCCESS) { // // An error occured. // LOG(LogError) << "HTTP request error - " << myRequest.getErrorMessage(); // return; diff --git a/es-core/src/Log.h b/es-core/src/Log.h index 810d73340..5b5c6358c 100644 --- a/es-core/src/Log.h +++ b/es-core/src/Log.h @@ -11,7 +11,7 @@ #include #define LOG(level) \ -if(level > Log::getReportingLevel()); \ +if (level > Log::getReportingLevel()); \ else Log().get(level) enum LogLevel { diff --git a/es-core/src/Scripting.cpp b/es-core/src/Scripting.cpp index 0a0c6dc76..3d986268c 100644 --- a/es-core/src/Scripting.cpp +++ b/es-core/src/Scripting.cpp @@ -31,10 +31,10 @@ namespace Scripting // Check in homepath. test = Utils::FileSystem::getHomePath() + "/.emulationstation/scripts/" + eventName; - if(Utils::FileSystem::exists(test)) + if (Utils::FileSystem::exists(test)) scriptDirList.push_back(test); - for(std::list::const_iterator dirIt = scriptDirList.cbegin(); + for (std::list::const_iterator dirIt = scriptDirList.cbegin(); dirIt != scriptDirList.cend(); ++dirIt) { std::list scripts = Utils::FileSystem::getDirContent(*dirIt); for (std::list::const_iterator it = scripts.cbegin(); diff --git a/es-core/src/Sound.cpp b/es-core/src/Sound.cpp index a17ab6159..2acd5e3b4 100644 --- a/es-core/src/Sound.cpp +++ b/es-core/src/Sound.cpp @@ -20,7 +20,7 @@ std::map< std::string, std::shared_ptr > Sound::sMap; std::shared_ptr Sound::get(const std::string& path) { auto it = sMap.find(path); - if(it != sMap.cend()) + if (it != sMap.cend()) return it->second; std::shared_ptr sound = std::shared_ptr(new Sound(path)); @@ -36,7 +36,7 @@ std::shared_ptr Sound::getFromTheme(const std::shared_ptr& the element << "\">."; 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."; return get(ResourceManager::getInstance()-> getResourcePath(":/sounds/" + element + ".wav")); @@ -106,10 +106,10 @@ void Sound::loadFile(const std::string & path) void Sound::init() { - if(mSampleData != nullptr) + if (mSampleData != nullptr) deinit(); - if(mPath.empty()) + if (mPath.empty()) return; // Load WAV file via SDL. @@ -153,7 +153,7 @@ void Sound::deinit() { playing = false; - if(mSampleData != nullptr) { + if (mSampleData != nullptr) { SDL_LockAudio(); delete[] mSampleData; mSampleData = nullptr; @@ -165,10 +165,10 @@ void Sound::deinit() void Sound::play() { - if(mSampleData == nullptr) + if (mSampleData == nullptr) return; - if(!Settings::getInstance()->getBool("NavigationSounds")) + if (!Settings::getInstance()->getBool("NavigationSounds")) return; AudioManager::getInstance(); diff --git a/es-core/src/ThemeData.cpp b/es-core/src/ThemeData.cpp index 9b7714967..a79d34067 100644 --- a/es-core/src/ThemeData.cpp +++ b/es-core/src/ThemeData.cpp @@ -379,8 +379,7 @@ void ThemeData::parseViews(const pugi::xml_node& root) size_t prevOff = nameAttr.find_first_not_of(delim, 0); size_t off = nameAttr.find_first_of(delim, prevOff); 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); prevOff = nameAttr.find_first_not_of(delim, off); off = nameAttr.find_first_of(delim, prevOff); diff --git a/es-core/src/animations/AnimationController.cpp b/es-core/src/animations/AnimationController.cpp index 45646b808..f76d5f175 100644 --- a/es-core/src/animations/AnimationController.cpp +++ b/es-core/src/animations/AnimationController.cpp @@ -33,7 +33,7 @@ bool AnimationController::update(int deltaTime) { mTime += deltaTime; - if(mTime < 0) // Are we still in delay? + if (mTime < 0) // Are we still in delay? return false; float t = (float)mTime / mAnimation->getDuration(); @@ -45,7 +45,7 @@ bool AnimationController::update(int deltaTime) mAnimation->apply(mReverse ? 1.0f - t : t); - if(t == 1.0f) + if (t == 1.0f) return true; return false; diff --git a/es-core/src/components/ComponentGrid.h b/es-core/src/components/ComponentGrid.h index 02d1b7436..9b72a31c0 100644 --- a/es-core/src/components/ComponentGrid.h +++ b/es-core/src/components/ComponentGrid.h @@ -72,7 +72,7 @@ public: inline std::shared_ptr getSelectedComponent() { const GridEntry* e = getCellAt(mCursor); - if(e) + if (e) return e->component; else return nullptr; diff --git a/es-core/src/components/ComponentList.h b/es-core/src/components/ComponentList.h index b8f704cc4..a33046211 100644 --- a/es-core/src/components/ComponentList.h +++ b/es-core/src/components/ComponentList.h @@ -45,7 +45,7 @@ struct ComponentListRow inline void makeAcceptInputHandler(const std::function& func) { 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(); return true; } diff --git a/es-core/src/components/DateTimeComponent.cpp b/es-core/src/components/DateTimeComponent.cpp index 5b4f65881..307ba4bcf 100644 --- a/es-core/src/components/DateTimeComponent.cpp +++ b/es-core/src/components/DateTimeComponent.cpp @@ -68,7 +68,7 @@ std::string DateTimeComponent::getDisplayString() const { if (mDisplayRelative) { // Relative time. - if(mTime.getTime() == 0) + if (mTime.getTime() == 0) return "never"; Utils::Time::DateTime now(Utils::Time::now()); @@ -76,11 +76,11 @@ std::string DateTimeComponent::getDisplayString() const char buf[64]; - if(dur.getDays() > 0) + if (dur.getDays() > 0) 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" : ""); - else if(dur.getMinutes() > 0) + else if (dur.getMinutes() > 0) sprintf(buf, "%d minute%s ago", dur.getMinutes(), (dur.getMinutes() > 1) ? "s" : ""); else 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); } - if(mTime.getTime() == 0) + if (mTime.getTime() == 0) return "unknown"; return Utils::Time::timeToString(mTime.getTime(), mFormat); @@ -107,13 +107,13 @@ void DateTimeComponent::applyTheme(const std::shared_ptr& theme, using namespace ThemeFlags; const ThemeData::ThemeElement* elem = theme->getElement(view, element, "datetime"); - if(!elem) + if (!elem) return; - if(elem->has("displayRelative")) + if (elem->has("displayRelative")) setDisplayRelative(elem->get("displayRelative")); - if(elem->has("format")) + if (elem->has("format")) setFormat(elem->get("format")); if (properties & COLOR && elem->has("color")) @@ -125,22 +125,22 @@ void DateTimeComponent::applyTheme(const std::shared_ptr& theme, setRenderBackground(true); } - if(properties & ALIGNMENT && elem->has("alignment")) { + if (properties & ALIGNMENT && elem->has("alignment")) { std::string str = elem->get("alignment"); - if(str == "left") + if (str == "left") setHorizontalAlignment(ALIGN_LEFT); - else if(str == "center") + else if (str == "center") setHorizontalAlignment(ALIGN_CENTER); - else if(str == "right") + else if (str == "right") setHorizontalAlignment(ALIGN_RIGHT); else LOG(LogError) << "Unknown text alignment string: " << str; } - if(properties & FORCE_UPPERCASE && elem->has("forceUppercase")) + if (properties & FORCE_UPPERCASE && elem->has("forceUppercase")) setUppercase(elem->get("forceUppercase")); - if(properties & LINE_SPACING && elem->has("lineSpacing")) + if (properties & LINE_SPACING && elem->has("lineSpacing")) setLineSpacing(elem->get("lineSpacing")); setFont(Font::getFromTheme(elem, properties, mFont)); diff --git a/es-core/src/components/OptionListComponent.h b/es-core/src/components/OptionListComponent.h index fddc20f5a..2249b9909 100644 --- a/es-core/src/components/OptionListComponent.h +++ b/es-core/src/components/OptionListComponent.h @@ -50,7 +50,7 @@ public: mLeftArrow.setResize(0, mText.getFont()->getLetterHeight()); mRightArrow.setResize(0, mText.getFont()->getLetterHeight()); - if(mMultiSelect) { + if (mMultiSelect) { mRightArrow.setImage(":/graphics/arrow.svg"); addChild(&mRightArrow); } @@ -72,7 +72,7 @@ public: mLeftArrow.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!"; } @@ -89,17 +89,17 @@ public: bool input(InputConfig* config, Input input) override { - if(input.value != 0) { - if(config->isMappedTo("a", input)) { + if (input.value != 0) { + if (config->isMappedTo("a", input)) { open(); return true; } - if(!mMultiSelect) { - if(config->isMappedLike("left", input)) { + if (!mMultiSelect) { + if (config->isMappedLike("left", input)) { // Move selection to previous. unsigned int i = getSelectedId(); int next = (int)i - 1; - if(next < 0) + if (next < 0) next += (int)mEntries.size(); mEntries.at(i).selected = false; @@ -108,7 +108,7 @@ public: return true; } - else if(config->isMappedLike("right", input)) { + else if (config->isMappedLike("right", input)) { // Move selection to next. unsigned int i = getSelectedId(); int next = (i + 1) % mEntries.size(); @@ -125,8 +125,8 @@ public: std::vector getSelectedObjects() { std::vector ret; - for(auto it = mEntries.cbegin(); it != mEntries.cend(); it++) { - if(it->selected) + for (auto it = mEntries.cbegin(); it != mEntries.cend(); it++) { + if (it->selected) ret.push_back(it->object); } @@ -178,14 +178,14 @@ public: 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; onSelectedChanged(); } 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; onSelectedChanged(); } @@ -204,8 +204,8 @@ private: unsigned int getSelectedId() { assert(mMultiSelect == false); - for(unsigned int i = 0; i < mEntries.size(); i++) { - if(mEntries.at(i).selected) + for (unsigned int i = 0; i < mEntries.size(); i++) { + if (mEntries.at(i).selected) return i; } @@ -221,25 +221,25 @@ private: void onSelectedChanged() { - if(mMultiSelect) { + if (mMultiSelect) { // Display # selected. std::stringstream ss; ss << getSelectedObjects().size() << " SELECTED"; mText.setText(ss.str()); mText.setSize(0, 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(); } else { // Display currently selected + l/r cursors. - for(auto it = mEntries.cbegin(); it != mEntries.cend(); it++) { - if(it->selected) { + for (auto it = mEntries.cbegin(); it != mEntries.cend(); it++) { + if (it->selected) { mText.setText(Utils::String::toUpper(it->name)); mText.setSize(0, mText.getSize().y()); setSize(mText.getSize().x() + mLeftArrow.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(); break; } @@ -250,7 +250,7 @@ private: std::vector getHelpPrompts() override { std::vector prompts; - if(!mMultiSelect) + if (!mMultiSelect) prompts.push_back(HelpPrompt("left/right", "change value")); prompts.push_back(HelpPrompt("a", "select")); @@ -286,14 +286,14 @@ private: // For select all/none. std::vector 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.addElement(std::make_shared (mWindow, Utils::String::toUpper(it->name), font, 0x777777FF), true); OptionListData& e = *it; - if(mParent->mMultiSelect) { + if (mParent->mMultiSelect) { // Add checkbox. auto checkbox = std::make_shared(mWindow); checkbox->setImage(it->selected ? CHECKED_PATH : UNCHECKED_PATH); @@ -328,9 +328,9 @@ private: mMenu.addButton("BACK", "back", [this] { delete this; }); - if(mParent->mMultiSelect) { + if (mParent->mMultiSelect) { 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; checkboxes.at(i)->setImage(CHECKED_PATH); } @@ -338,7 +338,7 @@ private: }); 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; checkboxes.at(i)->setImage(UNCHECKED_PATH); } @@ -353,7 +353,7 @@ private: 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; return true; } diff --git a/es-core/src/components/RatingComponent.cpp b/es-core/src/components/RatingComponent.cpp index 9c66623d3..faa4c48ab 100644 --- a/es-core/src/components/RatingComponent.cpp +++ b/es-core/src/components/RatingComponent.cpp @@ -127,7 +127,7 @@ void RatingComponent::render(const Transform4x4f& parentTrans) Renderer::setMatrix(trans); if (mOpacity > 0) { - if(Settings::getInstance()->getBool("DebugImage")) { + if (Settings::getInstance()->getBool("DebugImage")) { Renderer::drawRect(0.0f, 0.0f, mSize.y() * NUM_RATING_STARS, mSize.y(), 0x00000033, 0x00000033); } diff --git a/es-core/src/components/SwitchComponent.cpp b/es-core/src/components/SwitchComponent.cpp index 15f7cdaa1..65dacc918 100644 --- a/es-core/src/components/SwitchComponent.cpp +++ b/es-core/src/components/SwitchComponent.cpp @@ -27,7 +27,7 @@ void SwitchComponent::onSizeChanged() bool SwitchComponent::input(InputConfig* config, Input input) { - if(config->isMappedTo("a", input) && input.value) { + if (config->isMappedTo("a", input) && input.value) { mState = !mState; onStateChanged(); return true; diff --git a/es-core/src/math/Misc.cpp b/es-core/src/math/Misc.cpp index b54cc1f15..96578f31a 100644 --- a/es-core/src/math/Misc.cpp +++ b/es-core/src/math/Misc.cpp @@ -83,20 +83,20 @@ namespace Math float bounce(const float _delayTime, const float _scrollTime, const float _currentTime, const float _scrollLength) { - if(_currentTime < _delayTime) { + if (_currentTime < _delayTime) { // Wait. return 0; } - else if(_currentTime < (_delayTime + _scrollTime)) { + else if (_currentTime < (_delayTime + _scrollTime)) { // Lerp from 0 to scrollLength. const float fraction = (_currentTime - _delayTime) / _scrollTime; return lerp(0.0f, _scrollLength, smootherStep(0, 1, fraction)); } - else if(_currentTime < (_delayTime + _scrollTime + _delayTime)) { + else if (_currentTime < (_delayTime + _scrollTime + _delayTime)) { // Wait some more. return _scrollLength; } - else if(_currentTime < (_delayTime + _scrollTime + _delayTime + _scrollTime)) { + else if (_currentTime < (_delayTime + _scrollTime + _delayTime + _scrollTime)) { // Lerp back from scrollLength to 0. const float fraction = (_currentTime - _delayTime - _scrollTime - _delayTime) / _scrollTime; @@ -109,11 +109,11 @@ namespace Math float loop(const float _delayTime, const float _scrollTime, const float _currentTime, const float _scrollLength) { - if(_currentTime < _delayTime) { + if (_currentTime < _delayTime) { // Wait. return 0; } - else if(_currentTime < (_delayTime + _scrollTime)) { + else if (_currentTime < (_delayTime + _scrollTime)) { // Lerp from 0 to scrollLength. const float fraction = (_currentTime - _delayTime) / _scrollTime; return lerp(0.0f, _scrollLength, fraction); diff --git a/es-core/src/math/Transform4x4f.cpp b/es-core/src/math/Transform4x4f.cpp index a0c49dc5a..71d37b704 100644 --- a/es-core/src/math/Transform4x4f.cpp +++ b/es-core/src/math/Transform4x4f.cpp @@ -143,7 +143,7 @@ Transform4x4f& Transform4x4f::invert(const Transform4x4f& _other) om[ 8] * tm[ 2] + om[12] * tm[ 3]; - if(Determinant != 0) + if (Determinant != 0) Determinant = 1 / Determinant; tm[ 0] *= Determinant; diff --git a/es-core/src/utils/FileSystemUtil.cpp b/es-core/src/utils/FileSystemUtil.cpp index 8d195650b..4bf94c034 100644 --- a/es-core/src/utils/FileSystemUtil.cpp +++ b/es-core/src/utils/FileSystemUtil.cpp @@ -549,7 +549,7 @@ namespace Utils return true; } - if(isDirectory(_destination_path)) { + if (isDirectory(_destination_path)) { LOG(LogError) << "Error - Destination file is actually a directory:"; LOG(LogError) << _destination_path; return true; @@ -607,7 +607,7 @@ namespace Utils return true; } - if(isDirectory(_destination_path)) { + if (isDirectory(_destination_path)) { LOG(LogError) << "Error - Destination file is actually a directory:"; LOG(LogError) << _destination_path; return true;