diff --git a/README.md b/README.md index 49ff0c533..7543220f6 100644 --- a/README.md +++ b/README.md @@ -98,20 +98,20 @@ The new configuration will be added to the `~/.emulationstation/es_input.cfg` fi You can use `--help` or `-h` to view a list of command-line options. Briefly outlined here: ``` ---resolution [width] [height] try and force a particular resolution ---gamelist-only skip automatic game search, only read from gamelist.xml ---ignore-gamelist ignore the gamelist (useful for troubleshooting) ---draw-framerate display the framerate ---no-exit don't show the exit option in the menu ---no-splash don't show the splash screen ---debug more logging, show console on Windows ---scrape scrape using command line interface ---windowed not fullscreen, should be used with --resolution ---vsync [1/on or 0/off] turn vsync on or off (default is on) ---max-vram [size] Max VRAM to use in Mb before swapping. 0 for unlimited ---force-kid Force the UI mode to be Kid ---force-kiosk Force the UI mode to be Kiosk ---force-disable-filters Force the UI to ignore applied filters in gamelist +--resolution [width] [height] try and force a particular resolution +--gamelist-only skip automatic game search, only read from gamelist.xml +--ignore-gamelist ignore the gamelist (useful for troubleshooting) +--draw-framerate display the framerate +--no-exit don't show the exit option in the menu +--no-splash don't show the splash screen +--debug more logging, show console on Windows +--scrape scrape using command line interface +--windowed not fullscreen, should be used with --resolution +--vsync [1/on or 0/off] turn vsync on or off (default is on) +--max-vram [size] Max VRAM to use in Mb before swapping. 0 for unlimited +--force-kid Force the UI mode to be Kid +--force-kiosk Force the UI mode to be Kiosk +--force-disable-filters Force the UI to ignore applied filters in gamelist --help, -h summon a sentient, angry tuba ``` diff --git a/es-app/src/CollectionSystemManager.cpp b/es-app/src/CollectionSystemManager.cpp index ea3f629da..6b665df78 100644 --- a/es-app/src/CollectionSystemManager.cpp +++ b/es-app/src/CollectionSystemManager.cpp @@ -284,7 +284,7 @@ void CollectionSystemManager::updateCollectionSystem(FileData* file, CollectionS trimCollectionCount(rootFolder, LAST_PLAYED_MAX); ViewController::get()->onFileChanged(rootFolder, FILE_METADATA_CHANGED); } - else + else ViewController::get()->onFileChanged(rootFolder, FILE_SORTED); } } diff --git a/es-app/src/FileData.cpp b/es-app/src/FileData.cpp index 2238c60f9..f4781d13d 100644 --- a/es-app/src/FileData.cpp +++ b/es-app/src/FileData.cpp @@ -345,17 +345,17 @@ void CollectionFileData::refreshMetadata() mDirty = true; } -const std::string& CollectionFileData::getName() -{ - if (mDirty) { - mCollectionFileName = Utils::String::removeParenthesis(mSourceFileData->metadata.get("name")); - mCollectionFileName += " [" + Utils::String::toUpper(mSourceFileData->getSystem()->getName()) + "]"; - mDirty = false; - } - - if (Settings::getInstance()->getBool("CollectionShowSystemInfo")) - return mCollectionFileName; - return mSourceFileData->metadata.get("name"); +const std::string& CollectionFileData::getName() +{ + if (mDirty) { + mCollectionFileName = Utils::String::removeParenthesis(mSourceFileData->metadata.get("name")); + mCollectionFileName += " [" + Utils::String::toUpper(mSourceFileData->getSystem()->getName()) + "]"; + mDirty = false; + } + + if (Settings::getInstance()->getBool("CollectionShowSystemInfo")) + return mCollectionFileName; + return mSourceFileData->metadata.get("name"); } // returns Sort Type based on a string description diff --git a/es-app/src/FileFilterIndex.cpp b/es-app/src/FileFilterIndex.cpp index bb077f878..4ddf6b830 100644 --- a/es-app/src/FileFilterIndex.cpp +++ b/es-app/src/FileFilterIndex.cpp @@ -280,10 +280,10 @@ void FileFilterIndex::debugPrintIndexes() } for (auto x: favoritesIndexAllKeys) { LOG(LogInfo) << "Favorites Index: " << x.first << ": " << x.second; - } + } for (auto x : hiddenIndexAllKeys) { LOG(LogInfo) << "Hidden Index: " << x.first << ": " << x.second; - } + } for (auto x : kidGameIndexAllKeys) { LOG(LogInfo) << "KidGames Index: " << x.first << ": " << x.second; } diff --git a/es-app/src/MetaData.cpp b/es-app/src/MetaData.cpp index 8a977e950..27ef542af 100644 --- a/es-app/src/MetaData.cpp +++ b/es-app/src/MetaData.cpp @@ -108,7 +108,7 @@ void MetaDataList::appendToXML(pugi::xml_node& parent, bool ignoreDefaults, cons // if it's just the default (and we ignore defaults), don't write it if(ignoreDefaults && mapIter->second == mddIter->defaultValue) continue; - + // try and make paths relative if we can std::string value = mapIter->second; if (mddIter->type == MD_PATH) diff --git a/es-app/src/MetaData.h b/es-app/src/MetaData.h index 6ed8f6d44..717f24bfd 100644 --- a/es-app/src/MetaData.h +++ b/es-app/src/MetaData.h @@ -48,7 +48,7 @@ public: void appendToXML(pugi::xml_node& parent, bool ignoreDefaults, const std::string& relativeTo) const; MetaDataList(MetaDataListType type); - + void set(const std::string& key, const std::string& value); const std::string& get(const std::string& key) const; diff --git a/es-app/src/ScraperCmdLine.cpp b/es-app/src/ScraperCmdLine.cpp index 768808fcc..dda563595 100644 --- a/es-app/src/ScraperCmdLine.cpp +++ b/es-app/src/ScraperCmdLine.cpp @@ -64,7 +64,7 @@ int run_scraper_cmdline() std::string system_choice; std::getline(std::cin, system_choice); - + if(system_choice == "y" || system_choice == "Y") { out << "Will scrape all platforms.\n"; @@ -92,7 +92,7 @@ int run_scraper_cmdline() } std::getline(std::cin, sys_name); - + if(sys_name.empty()) break; @@ -209,7 +209,7 @@ int run_scraper_cmdline() int choice = -1; std::string choice_str; - + out << "Your choice: "; std::getline(std::cin, choice_str); diff --git a/es-app/src/SystemData.cpp b/es-app/src/SystemData.cpp index d6e72cfd3..65c4fc975 100644 --- a/es-app/src/SystemData.cpp +++ b/es-app/src/SystemData.cpp @@ -346,7 +346,7 @@ std::string SystemData::getConfigPath(bool forWrite) bool SystemData::isVisible() { - return (getDisplayedGameCount() > 0 || + return (getDisplayedGameCount() > 0 || (UIModeController::getInstance()->isUIModeFull() && mIsCollectionSystem) || (mIsCollectionSystem && mName == "favorites")); } @@ -494,7 +494,7 @@ void SystemData::loadTheme() sysData.insert(std::pair("system.name", getName())); sysData.insert(std::pair("system.theme", getThemeFolder())); sysData.insert(std::pair("system.fullName", getFullName())); - + mTheme->loadFile(sysData, path); } catch(ThemeException& e) { diff --git a/es-app/src/SystemData.h b/es-app/src/SystemData.h index ad0456b3c..63bf667fe 100644 --- a/es-app/src/SystemData.h +++ b/es-app/src/SystemData.h @@ -58,7 +58,7 @@ public: inline bool isGameSystem() { return mIsGameSystem; }; bool isVisible(); - + SystemData* getNext() const; SystemData* getPrev() const; static SystemData* getRandomSystem(); diff --git a/es-app/src/VolumeControl.cpp b/es-app/src/VolumeControl.cpp index 862f1eaf5..9153523ed 100644 --- a/es-app/src/VolumeControl.cpp +++ b/es-app/src/VolumeControl.cpp @@ -184,7 +184,7 @@ void VolumeControl::init() } } } - else + else { //Windows Vista or above. use EndpointVolume API. get device enumerator if (endpointVolume == nullptr) @@ -299,7 +299,7 @@ int VolumeControl::getVolume() const mixerControlDetails.cMultipleItems = 0; //always 0 except for a MIXERCONTROL_CONTROLF_MULTIPLE control mixerControlDetails.paDetails = &value; mixerControlDetails.cbDetails = sizeof(MIXERCONTROLDETAILS_UNSIGNED); - if (mixerGetControlDetails((HMIXEROBJ)mixerHandle, &mixerControlDetails, MIXER_GETCONTROLDETAILSF_VALUE) == MMSYSERR_NOERROR) + if (mixerGetControlDetails((HMIXEROBJ)mixerHandle, &mixerControlDetails, MIXER_GETCONTROLDETAILSF_VALUE) == MMSYSERR_NOERROR) { volume = (int)Math::round((value.dwValue * 100) / 65535.0f); } @@ -321,7 +321,7 @@ int VolumeControl::getVolume() const { LOG(LogError) << "VolumeControl::getVolume() - Failed to get master volume!"; } - + } #endif //clamp to 0-100 range @@ -361,7 +361,7 @@ void VolumeControl::setVolume(int volume) { //ok. bring into minVolume-maxVolume range and set long rawVolume = (volume * (maxVolume - minVolume) / 100) + minVolume; - if (snd_mixer_selem_set_playback_volume(mixerElem, SND_MIXER_SCHN_FRONT_LEFT, rawVolume) < 0 + if (snd_mixer_selem_set_playback_volume(mixerElem, SND_MIXER_SCHN_FRONT_LEFT, rawVolume) < 0 || snd_mixer_selem_set_playback_volume(mixerElem, SND_MIXER_SCHN_FRONT_RIGHT, rawVolume) < 0) { LOG(LogError) << "VolumeControl::getVolume() - Failed to set mixer volume!"; diff --git a/es-app/src/animations/LaunchAnimation.h b/es-app/src/animations/LaunchAnimation.h index 40d9f093d..2c548afb8 100644 --- a/es-app/src/animations/LaunchAnimation.h +++ b/es-app/src/animations/LaunchAnimation.h @@ -32,7 +32,7 @@ class LaunchAnimation : public Animation { public: //Target is a centerpoint - LaunchAnimation(Transform4x4f& camera, float& fade, const Vector3f& target, int duration) : + LaunchAnimation(Transform4x4f& camera, float& fade, const Vector3f& target, int duration) : mCameraStart(camera), mTarget(target), mDuration(duration), cameraOut(camera), fadeOut(fade) {} int getDuration() const override { return mDuration; } @@ -51,7 +51,7 @@ public: const Vector2f centerPoint = Vector2f().lerp(startPoint, Vector2f(mTarget), Math::smootherStep(0.0, 1.0, t)); cameraOut.translate(Vector3f((sw / 2) - centerPoint.x(), (sh / 2) - centerPoint.y(), 0)); - + fadeOut = Math::lerp(0.0, 1.0, t*t); } diff --git a/es-app/src/components/AsyncReqComponent.cpp b/es-app/src/components/AsyncReqComponent.cpp index a4e5ff572..6c811dcf8 100644 --- a/es-app/src/components/AsyncReqComponent.cpp +++ b/es-app/src/components/AsyncReqComponent.cpp @@ -3,11 +3,11 @@ #include "renderers/Renderer.h" #include "HttpReq.h" -AsyncReqComponent::AsyncReqComponent(Window* window, std::shared_ptr req, std::function)> onSuccess, std::function onCancel) - : GuiComponent(window), +AsyncReqComponent::AsyncReqComponent(Window* window, std::shared_ptr req, std::function)> onSuccess, std::function onCancel) + : GuiComponent(window), mSuccessFunc(onSuccess), mCancelFunc(onCancel), mTime(0), mRequest(req) { - + } bool AsyncReqComponent::input(InputConfig* config, Input input) diff --git a/es-app/src/components/AsyncReqComponent.h b/es-app/src/components/AsyncReqComponent.h index 35cb01734..6b051157b 100644 --- a/es-app/src/components/AsyncReqComponent.h +++ b/es-app/src/components/AsyncReqComponent.h @@ -6,7 +6,7 @@ class HttpReq; -/* +/* Used to asynchronously run an HTTP request. Displays a simple animation on the UI to show the application hasn't frozen. Can be canceled by the user pressing B. diff --git a/es-app/src/components/ScraperSearchComponent.cpp b/es-app/src/components/ScraperSearchComponent.cpp index 87aacba10..bc28d3b26 100644 --- a/es-app/src/components/ScraperSearchComponent.cpp +++ b/es-app/src/components/ScraperSearchComponent.cpp @@ -15,7 +15,7 @@ #include "Window.h" ScraperSearchComponent::ScraperSearchComponent(Window* window, SearchType type) : GuiComponent(window), - mGrid(window, Vector2i(4, 3)), mBusyAnim(window), + mGrid(window, Vector2i(4, 3)), mBusyAnim(window), mSearchType(type) { addChild(&mGrid); @@ -37,7 +37,7 @@ ScraperSearchComponent::ScraperSearchComponent(Window* window, SearchType type) mResultDesc = std::make_shared(mWindow, "Result desc", Font::get(FONT_SIZE_SMALL), 0x777777FF); mDescContainer->addChild(mResultDesc.get()); mDescContainer->setAutoScroll(true); - + // metadata auto font = Font::get(FONT_SIZE_SMALL); // this gets replaced in onSizeChanged() so its just a placeholder const unsigned int mdColor = 0x777777FF; @@ -78,7 +78,7 @@ ScraperSearchComponent::ScraperSearchComponent(Window* window, SearchType type) void ScraperSearchComponent::onSizeChanged() { mGrid.setSize(mSize); - + if(mSize.x() == 0 || mSize.y() == 0) return; @@ -87,10 +87,10 @@ void ScraperSearchComponent::onSizeChanged() mGrid.setColWidthPerc(0, 0.02f); // looks better when this is higher in auto mode else mGrid.setColWidthPerc(0, 0.01f); - + mGrid.setColWidthPerc(1, 0.25f); mGrid.setColWidthPerc(2, 0.25f); - + // row heights if(mSearchType == ALWAYS_ACCEPT_FIRST_RESULT) // show name mGrid.setRowHeightPerc(0, (mResultName->getFont()->getHeight() * 1.6f) / mGrid.getSize().y()); // result name @@ -112,12 +112,12 @@ void ScraperSearchComponent::onSizeChanged() // metadata resizeMetadata(); - + if(mSearchType != ALWAYS_ACCEPT_FIRST_RESULT) mDescContainer->setSize(mGrid.getColWidth(1)*boxartCellScale + mGrid.getColWidth(2), mResultDesc->getFont()->getHeight() * 3); else mDescContainer->setSize(mGrid.getColWidth(3)*boxartCellScale, mResultDesc->getFont()->getHeight() * 8); - + mResultDesc->setSize(mDescContainer->getSize().x(), 0); // make desc text wrap at edge of container mGrid.onSizeChanged(); @@ -299,7 +299,7 @@ void ScraperSearchComponent::updateInfoPane() { i = 0; } - + if(i != -1 && (int)mScraperResults.size() > i) { ScraperSearchResult& res = mScraperResults.at(i); @@ -401,7 +401,7 @@ void ScraperSearchComponent::update(int deltaTime) auto results = mSearchHandle->getResults(); auto statusString = mSearchHandle->getStatusString(); - // we reset here because onSearchDone in auto mode can call mSkipCallback() which can call + // we reset here because onSearchDone in auto mode can call mSkipCallback() which can call // another search() which will set our mSearchHandle to something important mSearchHandle.reset(); @@ -455,9 +455,9 @@ void ScraperSearchComponent::openInputScreen(ScraperSearchParams& params) }; stop(); - mWindow->pushGui(new GuiTextEditPopup(mWindow, "SEARCH FOR", + mWindow->pushGui(new GuiTextEditPopup(mWindow, "SEARCH FOR", // initial value is last search if there was one, otherwise the clean path name - params.nameOverride.empty() ? params.game->getCleanName() : params.nameOverride, + params.nameOverride.empty() ? params.game->getCleanName() : params.nameOverride, searchForFunc, false, "SEARCH")); } @@ -466,7 +466,7 @@ std::vector ScraperSearchComponent::getHelpPrompts() std::vector prompts = mGrid.getHelpPrompts(); if(getSelectedIndex() != -1) prompts.push_back(HelpPrompt("a", "accept result")); - + return prompts; } diff --git a/es-app/src/components/ScraperSearchComponent.h b/es-app/src/components/ScraperSearchComponent.h index b2924a7a1..6af36e795 100644 --- a/es-app/src/components/ScraperSearchComponent.h +++ b/es-app/src/components/ScraperSearchComponent.h @@ -40,7 +40,7 @@ public: void update(int deltaTime) override; void render(const Transform4x4f& parentTrans) override; std::vector getHelpPrompts() override; - void onSizeChanged() override; + void onSizeChanged() override; void onFocusGained() override; void onFocusLost() override; @@ -84,7 +84,7 @@ private: MetaDataPair(const std::shared_ptr& f, const std::shared_ptr& s, bool r = true) : first(f), second(s), resize(r) {}; }; - + std::vector mMD_Pairs; SearchType mSearchType; diff --git a/es-app/src/components/TextListComponent.h b/es-app/src/components/TextListComponent.h index c90329883..5e4c26b8e 100644 --- a/es-app/src/components/TextListComponent.h +++ b/es-app/src/components/TextListComponent.h @@ -37,14 +37,14 @@ public: using IList::stopScrolling; TextListComponent(Window* window); - + bool input(InputConfig* config, Input input) override; void update(int deltaTime) override; void render(const Transform4x4f& parentTrans) override; void applyTheme(const std::shared_ptr& theme, const std::string& view, const std::string& element, unsigned int properties) override; void add(const std::string& name, const T& obj, unsigned int colorId); - + enum Alignment { ALIGN_LEFT, @@ -63,7 +63,7 @@ public: it->data.textCache.reset(); } - inline void setUppercase(bool /*uppercase*/) + inline void setUppercase(bool /*uppercase*/) { mUppercase = true; for(auto it = mEntries.begin(); it != mEntries.end(); it++) @@ -106,7 +106,7 @@ private: }; template -TextListComponent::TextListComponent(Window* window) : +TextListComponent::TextListComponent(Window* window) : IList(window), mSelectorImage(window) { mMarqueeOffset = 0; @@ -131,7 +131,7 @@ template void TextListComponent::render(const Transform4x4f& parentTrans) { Transform4x4f trans = parentTrans * getTransform(); - + std::shared_ptr& font = mFont; if(size() == 0) @@ -143,7 +143,7 @@ void TextListComponent::render(const Transform4x4f& parentTrans) //number of entries that can fit on the screen simultaniously int screenCount = (int)(mSize.y() / entrySize + 0.5f); - + if(size() >= screenCount) { startEntry = mCursor - screenCount/2; @@ -174,7 +174,7 @@ void TextListComponent::render(const Transform4x4f& parentTrans) // clip to inside margins Vector3f dim(mSize.x(), mSize.y(), 0); dim = trans * dim - trans.translation(); - Renderer::pushClipRect(Vector2i((int)(trans.translation().x() + mHorizontalMargin), (int)trans.translation().y()), + Renderer::pushClipRect(Vector2i((int)(trans.translation().x() + mHorizontalMargin), (int)trans.translation().y()), Vector2i((int)(dim.x() - mHorizontalMargin*2), (int)dim.y())); for(int i = startEntry; i < listCutoff; i++) @@ -274,7 +274,7 @@ bool TextListComponent::input(InputConfig* config, Input input) return true; } }else{ - if(config->isMappedLike("down", input) || config->isMappedLike("up", input) || + if(config->isMappedLike("down", input) || config->isMappedLike("up", input) || config->isMappedTo("pagedown", input) || config->isMappedTo("pageup", input)) { stopScrolling(); diff --git a/es-app/src/guis/GuiFastSelect.cpp b/es-app/src/guis/GuiFastSelect.cpp index 3bf0af8cd..b6d16d456 100644 --- a/es-app/src/guis/GuiFastSelect.cpp +++ b/es-app/src/guis/GuiFastSelect.cpp @@ -6,7 +6,7 @@ static const std::string LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; -GuiFastSelect::GuiFastSelect(Window* window, IGameListView* gamelist) : GuiComponent(window), +GuiFastSelect::GuiFastSelect(Window* window, IGameListView* gamelist) : GuiComponent(window), mBackground(window), mSortText(window), mLetterText(window), mGameList(gamelist) { setPosition(Renderer::getScreenWidth() * 0.2f, Renderer::getScreenHeight() * 0.2f); diff --git a/es-app/src/guis/GuiGamelistFilter.cpp b/es-app/src/guis/GuiGamelistFilter.cpp index 8a3625a1e..f7a68b67c 100644 --- a/es-app/src/guis/GuiGamelistFilter.cpp +++ b/es-app/src/guis/GuiGamelistFilter.cpp @@ -50,7 +50,7 @@ GuiGamelistFilter::~GuiGamelistFilter() void GuiGamelistFilter::addFiltersToMenu() { std::vector decls = mFilterIndex->getFilterDataDecls(); - + int skip = 0; if (!UIModeController::getInstance()->isUIModeFull()) skip = 1; diff --git a/es-app/src/guis/GuiGamelistOptions.cpp b/es-app/src/guis/GuiGamelistOptions.cpp index 7510f0c5c..764ef0b3f 100644 --- a/es-app/src/guis/GuiGamelistOptions.cpp +++ b/es-app/src/guis/GuiGamelistOptions.cpp @@ -83,7 +83,7 @@ GuiGamelistOptions::GuiGamelistOptions(Window* window, SystemData* system) : Gui row.addElement(std::make_shared(mWindow, "FILTER GAMELIST", Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true); row.addElement(makeArrow(mWindow), false); row.makeAcceptInputHandler(std::bind(&GuiGamelistOptions::openGamelistFilter, this)); - mMenu.addRow(row); + mMenu.addRow(row); } std::map customCollections = CollectionSystemManager::get()->getCustomCollectionSystems(); diff --git a/es-app/src/guis/GuiGeneralScreensaverOptions.cpp b/es-app/src/guis/GuiGeneralScreensaverOptions.cpp index 30688c566..69817db9a 100644 --- a/es-app/src/guis/GuiGeneralScreensaverOptions.cpp +++ b/es-app/src/guis/GuiGeneralScreensaverOptions.cpp @@ -18,12 +18,12 @@ GuiGeneralScreensaverOptions::GuiGeneralScreensaverOptions(Window* window, const Settings::getInstance()->setInt("ScreenSaverTime", (int)Math::round(screensaver_time->getValue()) * (1000 * 60)); PowerSaver::updateTimeouts(); }); - + // Allow ScreenSaver Controls - ScreenSaverControls auto ss_controls = std::make_shared(mWindow); ss_controls->setState(Settings::getInstance()->getBool("ScreenSaverControls")); addWithLabel("SCREENSAVER CONTROLS", ss_controls); - addSaveFunc([ss_controls] { Settings::getInstance()->setBool("ScreenSaverControls", ss_controls->getState()); }); + addSaveFunc([ss_controls] { Settings::getInstance()->setBool("ScreenSaverControls", ss_controls->getState()); }); // screensaver behavior auto screensaver_behavior = std::make_shared< OptionListComponent >(mWindow, "SCREENSAVER BEHAVIOR", false); diff --git a/es-app/src/guis/GuiMenu.cpp b/es-app/src/guis/GuiMenu.cpp index 8d46080e2..8e588989f 100644 --- a/es-app/src/guis/GuiMenu.cpp +++ b/es-app/src/guis/GuiMenu.cpp @@ -222,7 +222,7 @@ void GuiMenu::openUISettings() msg += "To unlock and return to the full UI, enter this code: \n"; msg += "\"" + UIModeController::getInstance()->getFormattedPassKeyStr() + "\"\n\n"; msg += "Do you want to proceed?"; - window->pushGui(new GuiMsgBox(window, msg, + window->pushGui(new GuiMsgBox(window, msg, "YES", [selectedMode] { LOG(LogDebug) << "Setting UI mode to " << selectedMode; Settings::getInstance()->setString("UIMode", selectedMode); @@ -360,9 +360,9 @@ void GuiMenu::openUISettings() auto enable_filter = std::make_shared(mWindow); enable_filter->setState(!Settings::getInstance()->getBool("ForceDisableFilters")); s->addWithLabel("ENABLE FILTERS", enable_filter); - s->addSaveFunc([enable_filter] { + s->addSaveFunc([enable_filter] { bool filter_is_enabled = !Settings::getInstance()->getBool("ForceDisableFilters"); - Settings::getInstance()->setBool("ForceDisableFilters", !enable_filter->getState()); + Settings::getInstance()->setBool("ForceDisableFilters", !enable_filter->getState()); if (enable_filter->getState() != filter_is_enabled) ViewController::get()->ReloadAndGoToStart(); }); diff --git a/es-app/src/guis/GuiMetaDataEd.cpp b/es-app/src/guis/GuiMetaDataEd.cpp index f07a5061e..fe7d29a96 100644 --- a/es-app/src/guis/GuiMetaDataEd.cpp +++ b/es-app/src/guis/GuiMetaDataEd.cpp @@ -155,7 +155,7 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, MetaDataList* md, const std::vector mButtons = makeButtonGrid(mWindow, buttons); mGrid.setEntry(mButtons, Vector2i(0, 2), true, false); - // resize + center + // resize + center float width = (float)Math::min(Renderer::getScreenHeight(), (int)(Renderer::getScreenWidth() * 0.90f)); setSize(width, Renderer::getScreenHeight() * 0.82f); setPosition((Renderer::getScreenWidth() - mSize.x()) / 2, (Renderer::getScreenHeight() - mSize.y()) / 2); diff --git a/es-app/src/guis/GuiMetaDataEd.h b/es-app/src/guis/GuiMetaDataEd.h index ee192f982..b7b7665be 100644 --- a/es-app/src/guis/GuiMetaDataEd.h +++ b/es-app/src/guis/GuiMetaDataEd.h @@ -14,9 +14,9 @@ class TextComponent; class GuiMetaDataEd : public GuiComponent { public: - GuiMetaDataEd(Window* window, MetaDataList* md, const std::vector& mdd, ScraperSearchParams params, + GuiMetaDataEd(Window* window, MetaDataList* md, const std::vector& mdd, ScraperSearchParams params, const std::string& header, std::function savedCallback, std::function deleteFunc); - + bool input(InputConfig* config, Input input) override; void onSizeChanged() override; virtual std::vector getHelpPrompts() override; @@ -29,7 +29,7 @@ private: NinePatchComponent mBackground; ComponentGrid mGrid; - + std::shared_ptr mTitle; std::shared_ptr mSubtitle; std::shared_ptr mHeaderGrid; diff --git a/es-app/src/guis/GuiScraperMulti.h b/es-app/src/guis/GuiScraperMulti.h index 39d4d5213..6622f0b8c 100644 --- a/es-app/src/guis/GuiScraperMulti.h +++ b/es-app/src/guis/GuiScraperMulti.h @@ -23,7 +23,7 @@ private: void acceptResult(const ScraperSearchResult& result); void skip(); void doNextSearch(); - + void finish(); unsigned int mTotalGames; diff --git a/es-app/src/guis/GuiScraperStart.cpp b/es-app/src/guis/GuiScraperStart.cpp index 10c2a9b86..224204690 100644 --- a/es-app/src/guis/GuiScraperStart.cpp +++ b/es-app/src/guis/GuiScraperStart.cpp @@ -15,9 +15,9 @@ GuiScraperStart::GuiScraperStart(Window* window) : GuiComponent(window), // add filters (with first one selected) mFilters = std::make_shared< OptionListComponent >(mWindow, "SCRAPE THESE GAMES", false); - mFilters->add("All Games", + mFilters->add("All Games", [](SystemData*, FileData*) -> bool { return true; }, false); - mFilters->add("Only missing image", + mFilters->add("Only missing image", [](SystemData*, FileData* g) -> bool { return g->metadata.get("image").empty(); }, true); mMenu.addWithLabel("Filter", mFilters); @@ -47,9 +47,9 @@ void GuiScraperStart::pressedStart() { if((*it)->getPlatformIds().empty()) { - mWindow->pushGui(new GuiMsgBox(mWindow, - Utils::String::toUpper("Warning: some of your selected systems do not have a platform set. Results may be even more inaccurate than usual!\nContinue anyway?"), - "YES", std::bind(&GuiScraperStart::start, this), + mWindow->pushGui(new GuiMsgBox(mWindow, + Utils::String::toUpper("Warning: some of your selected systems do not have a platform set. Results may be even more inaccurate than usual!\nContinue anyway?"), + "YES", std::bind(&GuiScraperStart::start, this), "NO", nullptr)); return; } @@ -86,7 +86,7 @@ std::queue GuiScraperStart::getSearches(std::vectorisMappedTo("b", input)) { delete this; diff --git a/es-app/src/guis/GuiSettings.cpp b/es-app/src/guis/GuiSettings.cpp index 53f96c439..98e4c0fd5 100644 --- a/es-app/src/guis/GuiSettings.cpp +++ b/es-app/src/guis/GuiSettings.cpp @@ -47,7 +47,7 @@ bool GuiSettings::input(InputConfig* config, Input input) delete window->peekGui(); return true; } - + return GuiComponent::input(config, input); } diff --git a/es-app/src/main.cpp b/es-app/src/main.cpp index 47323fee0..dd6538b8f 100644 --- a/es-app/src/main.cpp +++ b/es-app/src/main.cpp @@ -36,19 +36,19 @@ bool parseArgs(int argc, char* argv[]) // We need to process --home before any call to Settings::getInstance(), because settings are loaded from homepath for(int i = 1; i < argc; i++) { - if (strcmp(argv[i], "--home") == 0) + if(strcmp(argv[i], "--home") == 0) { - if (i >= argc - 1) + if(i >= argc - 1) { std::cerr << "Invalid home path supplied."; return false; } - + Utils::FileSystem::setHomePath(argv[i + 1]); break; } } - + for(int i = 1; i < argc; i++) { if(strcmp(argv[i], "--resolution") == 0) diff --git a/es-app/src/scrapers/Scraper.cpp b/es-app/src/scrapers/Scraper.cpp index 76d3fc963..bc3e6b00d 100644 --- a/es-app/src/scrapers/Scraper.cpp +++ b/es-app/src/scrapers/Scraper.cpp @@ -105,7 +105,7 @@ ScraperRequest::ScraperRequest(std::vector& resultsWrite) : // ScraperHttpRequest -ScraperHttpRequest::ScraperHttpRequest(std::vector& resultsWrite, const std::string& url) +ScraperHttpRequest::ScraperHttpRequest(std::vector& resultsWrite, const std::string& url) : ScraperRequest(resultsWrite) { setStatus(ASYNC_IN_PROGRESS); @@ -148,7 +148,7 @@ MDResolveHandle::MDResolveHandle(const ScraperSearchResult& result, const Scrape // If we have a file extension returned by the scraper, then use it. // Otherwise, try to guess it by the name of the URL, which point to an image. - if (!result.imageType.empty()) + if (!result.imageType.empty()) { ext = result.imageType; }else{ @@ -158,7 +158,7 @@ MDResolveHandle::MDResolveHandle(const ScraperSearchResult& result, const Scrape ext = result.imageUrl.substr(dot, std::string::npos); } - std::string imgPath = getSaveAsPath(search, "image", ext); + std::string imgPath = getSaveAsPath(search, "image", ext); mFuncs.push_back(ResolvePair(downloadImageAsync(result.imageUrl, imgPath), [this, imgPath] { @@ -172,7 +172,7 @@ void MDResolveHandle::update() { if(mStatus == ASYNC_DONE || mStatus == ASYNC_ERROR) return; - + auto it = mFuncs.cbegin(); while(it != mFuncs.cend()) { @@ -195,11 +195,11 @@ void MDResolveHandle::update() std::unique_ptr downloadImageAsync(const std::string& url, const std::string& saveAs) { - return std::unique_ptr(new ImageDownloadHandle(url, saveAs, + return std::unique_ptr(new ImageDownloadHandle(url, saveAs, Settings::getInstance()->getInt("ScraperResizeWidth"), Settings::getInstance()->getInt("ScraperResizeHeight"))); } -ImageDownloadHandle::ImageDownloadHandle(const std::string& url, const std::string& path, int maxWidth, int maxHeight) : +ImageDownloadHandle::ImageDownloadHandle(const std::string& url, const std::string& path, int maxWidth, int maxHeight) : mSavePath(path), mMaxWidth(maxWidth), mMaxHeight(maxHeight), mReq(new HttpReq(url)) { } @@ -253,7 +253,7 @@ bool resizeImage(const std::string& path, int maxWidth, int maxHeight) FREE_IMAGE_FORMAT format = FIF_UNKNOWN; FIBITMAP* image = NULL; - + //detect the filetype format = FreeImage_GetFileType(path.c_str(), 0); if(format == FIF_UNKNOWN) diff --git a/es-app/src/scrapers/Scraper.h b/es-app/src/scrapers/Scraper.h index c6dd6a261..b86fc9080 100644 --- a/es-app/src/scrapers/Scraper.h +++ b/es-app/src/scrapers/Scraper.h @@ -53,8 +53,8 @@ struct ScraperSearchResult // We could do this if we used threads. Right now ES doesn't because I'm pretty sure I'll fuck it up, // and I'm not sure of the performance of threads on the Pi (single-core ARM). -// We could also do this if we used coroutines. -// I can't find a really good cross-platform coroutine library (x86/64/ARM Linux + Windows), +// We could also do this if we used coroutines. +// I can't find a really good cross-platform coroutine library (x86/64/ARM Linux + Windows), // and I don't want to spend more time chasing libraries than just writing it the long way once. // So, I did it the "long" way. @@ -71,7 +71,7 @@ public: // returns "true" once we're done virtual void update() = 0; - + protected: std::vector& mResults; }; diff --git a/es-app/src/scrapers/ScreenScraper.cpp b/es-app/src/scrapers/ScreenScraper.cpp index 75dc4eea1..7be4ebbe4 100644 --- a/es-app/src/scrapers/ScreenScraper.cpp +++ b/es-app/src/scrapers/ScreenScraper.cpp @@ -195,7 +195,7 @@ void ScreenScraperRequest::processGame(const pugi::xml_document& xmldoc, std::ve std::string region = Utils::String::toLower(ssConfig.region).c_str(); std::string language = Utils::String::toLower(ssConfig.language).c_str(); - // Name fallback: US, WOR(LD). ( Xpath: Data/jeu[0]/noms/nom[*] ). + // Name fallback: US, WOR(LD). ( Xpath: Data/jeu[0]/noms/nom[*] ). result.mdl.set("name", find_child_by_attribute_list(game.child("noms"), "nom", "region", { region, "wor", "us" , "ss", "eu", "jp" }).text().get()); // Description fallback language: EN, WOR(LD) @@ -256,7 +256,7 @@ void ScreenScraperRequest::processGame(const pugi::xml_document& xmldoc, std::ve // Do an XPath query for media[type='$media_type'], then filter by region // We need to do this because any child of 'medias' has the form - // + // // and we need to find the right media for the region. pugi::xpath_node_set results = media_list.select_nodes((static_cast("media[@type='") + ssConfig.media_name + "']").c_str()); @@ -281,7 +281,7 @@ void ScreenScraperRequest::processGame(const pugi::xml_document& xmldoc, std::ve if (art) { - // Sending a 'softname' containing space will make the image URLs returned by the API also contain the space. + // Sending a 'softname' containing space will make the image URLs returned by the API also contain the space. // Escape any spaces in the URL here result.imageUrl = Utils::String::replace(art.text().get(), " ", "%20"); diff --git a/es-app/src/scrapers/ScreenScraper.h b/es-app/src/scrapers/ScreenScraper.h index 4c749008f..2999a4649 100644 --- a/es-app/src/scrapers/ScreenScraper.h +++ b/es-app/src/scrapers/ScreenScraper.h @@ -46,7 +46,7 @@ public: std::string media_name = "box-2D"; // Which Region to use when selecting the artwork - // Applies to: artwork, name of the game, date of release + // Applies to: artwork, name of the game, date of release std::string region = "US"; // Which Language to use when selecting the textual information diff --git a/es-app/src/views/UIModeController.h b/es-app/src/views/UIModeController.h index 9746a1d79..04913a190 100644 --- a/es-app/src/views/UIModeController.h +++ b/es-app/src/views/UIModeController.h @@ -17,7 +17,7 @@ public: // Monitor input for UI mode change, returns true (consumes input) when UI mode change is triggered. bool listen(InputConfig* config, Input input); - + // Get the current Passphrase as a (unicode) formatted, comma-separated, string. std::string getFormattedPassKeyStr(); @@ -33,13 +33,13 @@ private: bool inputIsMatch(InputConfig * config, Input input); bool isValidInput(InputConfig * config, Input input); void logInput(InputConfig * config, Input input); - + // Return UI mode to 'FULL' - void unlockUIMode(); + void unlockUIMode(); static UIModeController * sInstance; const std::vector mUIModes = { "Full", "Kiosk", "Kid" }; - + // default passkeyseq = "uuddlrlrba", as defined in the setting 'UIMode_passkey'. std::string mPassKeySequence; int mPassKeyCounter; diff --git a/es-app/src/views/ViewController.h b/es-app/src/views/ViewController.h index d1735edf1..c5a4d3aca 100644 --- a/es-app/src/views/ViewController.h +++ b/es-app/src/views/ViewController.h @@ -91,11 +91,11 @@ private: void playViewTransition(); int getSystemId(SystemData* system); - + std::shared_ptr mCurrentView; std::map< SystemData*, std::shared_ptr > mGameListViews; std::shared_ptr mSystemListView; - + Transform4x4f mCamera; float mFadeOpacity; bool mLockInput; diff --git a/es-app/src/views/gamelist/DetailedGameListView.cpp b/es-app/src/views/gamelist/DetailedGameListView.cpp index 87d2893f5..bf332e54c 100644 --- a/es-app/src/views/gamelist/DetailedGameListView.cpp +++ b/es-app/src/views/gamelist/DetailedGameListView.cpp @@ -3,15 +3,15 @@ #include "animations/LambdaAnimation.h" #include "views/ViewController.h" -DetailedGameListView::DetailedGameListView(Window* window, FileData* root) : - BasicGameListView(window, root), - mDescContainer(window), mDescription(window), +DetailedGameListView::DetailedGameListView(Window* window, FileData* root) : + BasicGameListView(window, root), + mDescContainer(window), mDescription(window), mImage(window), - mLblRating(window), mLblReleaseDate(window), mLblDeveloper(window), mLblPublisher(window), + mLblRating(window), mLblReleaseDate(window), mLblDeveloper(window), mLblPublisher(window), mLblGenre(window), mLblPlayers(window), mLblLastPlayed(window), mLblPlayCount(window), - mRating(window), mReleaseDate(window), mDeveloper(window), mPublisher(window), + mRating(window), mReleaseDate(window), mDeveloper(window), mPublisher(window), mGenre(window), mPlayers(window), mLastPlayed(window), mPlayCount(window), mName(window) { @@ -93,7 +93,7 @@ void DetailedGameListView::onThemeChanged(const std::shared_ptr& them std::vector labels = getMDLabels(); assert(labels.size() == 8); const char* lblElements[8] = { - "md_lbl_rating", "md_lbl_releasedate", "md_lbl_developer", "md_lbl_publisher", + "md_lbl_rating", "md_lbl_releasedate", "md_lbl_developer", "md_lbl_publisher", "md_lbl_genre", "md_lbl_players", "md_lbl_lastplayed", "md_lbl_playcount" }; @@ -107,7 +107,7 @@ void DetailedGameListView::onThemeChanged(const std::shared_ptr& them std::vector values = getMDValues(); assert(values.size() == 8); const char* valElements[8] = { - "md_rating", "md_releasedate", "md_developer", "md_publisher", + "md_rating", "md_releasedate", "md_developer", "md_publisher", "md_genre", "md_players", "md_lastplayed", "md_playcount" }; @@ -131,7 +131,7 @@ void DetailedGameListView::initMDLabels() const unsigned int rowCount = (int)(components.size() / 2); Vector3f start(mSize.x() * 0.01f, mSize.y() * 0.625f, 0.0f); - + const float colSize = (mSize.x() * 0.48f) / colCount; const float rowPadding = 0.01f * mSize.y(); @@ -216,7 +216,7 @@ void DetailedGameListView::updateInfoPanel() mLastPlayed.setValue(file->metadata.get("lastplayed")); mPlayCount.setValue(file->metadata.get("playcount")); } - + fadingOut = false; } @@ -234,7 +234,7 @@ void DetailedGameListView::updateInfoPanel() // 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) || + 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.cpp b/es-app/src/views/gamelist/IGameListView.cpp index 5fd5dbf07..4b48bdd37 100644 --- a/es-app/src/views/gamelist/IGameListView.cpp +++ b/es-app/src/views/gamelist/IGameListView.cpp @@ -16,7 +16,7 @@ bool IGameListView::input(InputConfig* config, Input input) return true; // Ctrl-R to reload a view when debugging - }else if(Settings::getInstance()->getBool("Debug") && config->getDeviceId() == DEVICE_KEYBOARD && + }else if(Settings::getInstance()->getBool("Debug") && config->getDeviceId() == DEVICE_KEYBOARD && (SDL_GetModState() & (KMOD_LCTRL | KMOD_RCTRL)) && input.id == SDLK_r && input.value != 0) { LOG(LogDebug) << "reloading view"; diff --git a/es-app/src/views/gamelist/IGameListView.h b/es-app/src/views/gamelist/IGameListView.h index 0c65897bb..da6299d27 100644 --- a/es-app/src/views/gamelist/IGameListView.h +++ b/es-app/src/views/gamelist/IGameListView.h @@ -22,7 +22,7 @@ public: // 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. virtual void onFileChanged(FileData* file, FileChangeType change) = 0; - + // Called whenever the theme changes. virtual void onThemeChanged(const std::shared_ptr& theme) = 0; diff --git a/es-app/src/views/gamelist/ISimpleGameListView.cpp b/es-app/src/views/gamelist/ISimpleGameListView.cpp index 64f482e30..7d361fc94 100644 --- a/es-app/src/views/gamelist/ISimpleGameListView.cpp +++ b/es-app/src/views/gamelist/ISimpleGameListView.cpp @@ -15,7 +15,7 @@ ISimpleGameListView::ISimpleGameListView(Window* window, FileData* root) : IGame mHeaderText.setPosition(0, 0); mHeaderText.setHorizontalAlignment(ALIGN_CENTER); mHeaderText.setDefaultZIndex(50); - + mHeaderImage.setResize(0, mSize.y() * 0.185f); mHeaderImage.setOrigin(0.5f, 0.0f); mHeaderImage.setPosition(mSize.x() / 2, 0); diff --git a/es-app/src/views/gamelist/ISimpleGameListView.h b/es-app/src/views/gamelist/ISimpleGameListView.h index f161eadd0..785f3992c 100644 --- a/es-app/src/views/gamelist/ISimpleGameListView.h +++ b/es-app/src/views/gamelist/ISimpleGameListView.h @@ -17,7 +17,7 @@ public: // 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. virtual void onFileChanged(FileData* file, FileChangeType change); - + // Called whenever the theme changes. virtual void onThemeChanged(const std::shared_ptr& theme); diff --git a/es-core/src/HttpReq.cpp b/es-core/src/HttpReq.cpp index 9bdeedf79..feaea8a3c 100644 --- a/es-core/src/HttpReq.cpp +++ b/es-core/src/HttpReq.cpp @@ -33,7 +33,7 @@ std::string HttpReq::urlEncode(const std::string &s) bool HttpReq::isUrl(const std::string& str) { //the worst guess - return (!str.empty() && !Utils::FileSystem::exists(str) && + return (!str.empty() && !Utils::FileSystem::exists(str) && (str.find("http://") != std::string::npos || str.find("https://") != std::string::npos || str.find("www.") != std::string::npos)); } @@ -77,7 +77,7 @@ HttpReq::HttpReq(const std::string& url) } //set curl restrict redirect protocols - err = curl_easy_setopt(mHandle, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS); + err = curl_easy_setopt(mHandle, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS); if(err != CURLE_OK) { mStatus = REQ_IO_ERROR; @@ -150,7 +150,7 @@ HttpReq::Status HttpReq::status() if(msg->msg == CURLMSG_DONE) { HttpReq* req = s_requests[msg->easy_handle]; - + if(req == NULL) { LOG(LogError) << "Cannot find easy handle!"; @@ -201,5 +201,5 @@ size_t HttpReq::write_content(void* buff, size_t size, size_t nmemb, void* req_p //used as a curl callback /*int HttpReq::update_progress(void* req_ptr, double dlTotal, double dlNow, double ulTotal, double ulNow) { - + }*/ diff --git a/es-core/src/HttpReq.h b/es-core/src/HttpReq.h index 238efc544..f6032a3c7 100644 --- a/es-core/src/HttpReq.h +++ b/es-core/src/HttpReq.h @@ -10,7 +10,7 @@ * HttpReq myRequest("www.google.com", "/index.html"); * //for blocking behavior: 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 - * + * * //once one of those completes, the request is ready * if(myRequest.status() != REQ_SUCCESS) * { diff --git a/es-core/src/InputConfig.cpp b/es-core/src/InputConfig.cpp index dd56dd30e..7cb669746 100644 --- a/es-core/src/InputConfig.cpp +++ b/es-core/src/InputConfig.cpp @@ -93,7 +93,7 @@ bool InputConfig::isMappedTo(const std::string& name, Input input) Input comp; if(!getInputByName(name, &comp)) return false; - + if(comp.configured && comp.type == input.type && comp.id == input.id) { if(comp.type == TYPE_HAT) diff --git a/es-core/src/InputManager.cpp b/es-core/src/InputManager.cpp index d074367eb..441812ca9 100644 --- a/es-core/src/InputManager.cpp +++ b/es-core/src/InputManager.cpp @@ -20,7 +20,7 @@ // It can change even if the device is the same, and is only used to open joysticks (required to receive SDL events). // 2. SDL_JoystickID - this is an ID for each joystick that is supposed to remain consistent between plugging and unplugging. // ES doesn't care if it does, though. -// 3. "Device ID" - this is something I made up and is what InputConfig's getDeviceID() returns. +// 3. "Device ID" - this is something I made up and is what InputConfig's getDeviceID() returns. // This is actually just an SDL_JoystickID (also called instance ID), but -1 means "keyboard" instead of "error." // 4. Joystick GUID - this is some squashed version of joystick vendor, version, and a bunch of other device-specific things. // It should remain the same across runs of the program/system restarts/device reordering and is what I use to identify which joystick to load. @@ -53,7 +53,7 @@ void InputManager::init() if(initialized()) deinit(); - SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, + SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, Settings::getInstance()->getBool("BackgroundJoystickInput") ? "1" : "0"); SDL_InitSubSystem(SDL_INIT_JOYSTICK); SDL_JoystickEventState(SDL_ENABLE); @@ -78,7 +78,7 @@ void InputManager::init() void InputManager::addJoystickByDeviceIndex(int id) { assert(id >= 0 && id < SDL_NumJoysticks()); - + // open joystick & add to our list SDL_Joystick* joy = SDL_JoystickOpen(id); assert(joy); @@ -287,7 +287,7 @@ bool InputManager::loadInputConfig(InputConfig* config) std::string path = getConfigPath(); if(!Utils::FileSystem::exists(path)) return false; - + pugi::xml_document doc; pugi::xml_parse_result res = doc.load_file(path.c_str()); @@ -392,7 +392,7 @@ void InputManager::writeDeviceConfig(InputConfig* config) Scripting::fireEvent("config-changed"); Scripting::fireEvent("controls-changed"); - + // execute any onFinish commands and re-load the config for changes doOnFinish(); loadInputConfig(config); diff --git a/es-core/src/MameNames.cpp b/es-core/src/MameNames.cpp index 7821af366..e0dee5c4b 100644 --- a/es-core/src/MameNames.cpp +++ b/es-core/src/MameNames.cpp @@ -57,45 +57,45 @@ MameNames::MameNames() NamePair namePair = { gameNode.child("mamename").text().get(), gameNode.child("realname").text().get() }; mNamePairs.push_back(namePair); } - + // Read bios xmlpath = ResourceManager::getInstance()->getResourcePath(":/mamebioses.xml"); - + if(!Utils::FileSystem::exists(xmlpath)) return; - + LOG(LogInfo) << "Parsing XML file \"" << xmlpath << "\"..."; - + result = doc.load_file(xmlpath.c_str()); - + if(!result) { LOG(LogError) << "Error parsing XML file \"" << xmlpath << "\"!\n " << result.description(); return; } - + for(pugi::xml_node biosNode = doc.child("bios"); biosNode; biosNode = biosNode.next_sibling("bios")) { std::string bios = biosNode.text().get(); mMameBioses.push_back(bios); } - + // Read devices xmlpath = ResourceManager::getInstance()->getResourcePath(":/mamedevices.xml"); - + if(!Utils::FileSystem::exists(xmlpath)) return; - + LOG(LogInfo) << "Parsing XML file \"" << xmlpath << "\"..."; - + result = doc.load_file(xmlpath.c_str()); - + if(!result) { LOG(LogError) << "Error parsing XML file \"" << xmlpath << "\"!\n " << result.description(); return; } - + for(pugi::xml_node deviceNode = doc.child("device"); deviceNode; deviceNode = deviceNode.next_sibling("device")) { std::string device = deviceNode.text().get(); @@ -137,7 +137,7 @@ const bool MameNames::isBios(const std::string& _biosName) const bool MameNames::isDevice(const std::string& _deviceName) { return MameNames::find(mMameDevices, _deviceName); - + } // isDevice const bool MameNames::find(std::vector devices, const std::string& name) @@ -156,5 +156,5 @@ const bool MameNames::find(std::vector devices, const std::string& } return false; - + } diff --git a/es-core/src/MameNames.h b/es-core/src/MameNames.h index 6f0ae2181..02036d65d 100644 --- a/es-core/src/MameNames.h +++ b/es-core/src/MameNames.h @@ -34,7 +34,7 @@ private: namePairVector mNamePairs; std::vector mMameBioses; std::vector mMameDevices; - + const bool find(const std::vector devices, const std::string& name); }; // MameNames diff --git a/es-core/src/Settings.cpp b/es-core/src/Settings.cpp index e2c128645..3ad7f6586 100644 --- a/es-core/src/Settings.cpp +++ b/es-core/src/Settings.cpp @@ -33,7 +33,7 @@ std::vector settings_dont_save { { "ScreenHeight" }, { "ScreenOffsetX" }, { "ScreenOffsetY" }, - { "ScreenRotate" } + { "ScreenRotate" } }; Settings::Settings() diff --git a/es-core/src/Sound.cpp b/es-core/src/Sound.cpp index af0b63f90..e3f46e279 100644 --- a/es-core/src/Sound.cpp +++ b/es-core/src/Sound.cpp @@ -122,7 +122,7 @@ void Sound::play() { //replay from start. rewind the sample to the beginning mSamplePos = 0; - + } else { diff --git a/es-core/src/ThemeData.cpp b/es-core/src/ThemeData.cpp index cf2548089..ce55194b3 100644 --- a/es-core/src/ThemeData.cpp +++ b/es-core/src/ThemeData.cpp @@ -298,12 +298,12 @@ void ThemeData::parseVariables(const pugi::xml_node& root) { ThemeException error; error.setFiles(mPaths); - + pugi::xml_node variables = root.child("variables"); if(!variables) return; - + for(pugi::xml_node_iterator it = variables.begin(); it != variables.end(); ++it) { std::string key = it->name(); @@ -335,7 +335,7 @@ void ThemeData::parseViews(const pugi::xml_node& root) viewKey = nameAttr.substr(prevOff, off - prevOff); prevOff = nameAttr.find_first_not_of(delim, off); off = nameAttr.find_first_of(delim, prevOff); - + if (std::find(sSupportedViews.cbegin(), sSupportedViews.cend(), viewKey) != sSupportedViews.cend()) { ThemeView& view = mViews.insert(std::pair(viewKey, ThemeView())).first->second; @@ -368,8 +368,8 @@ void ThemeData::parseView(const pugi::xml_node& root, ThemeView& view) std::string elemKey = nameAttr.substr(prevOff, off - prevOff); prevOff = nameAttr.find_first_not_of(delim, off); off = nameAttr.find_first_of(delim, prevOff); - - parseElement(node, elemTypeIt->second, + + parseElement(node, elemTypeIt->second, view.elements.insert(std::pair(elemKey, ThemeElement())).first->second); if(std::find(view.orderedKeys.cbegin(), view.orderedKeys.cend(), elemKey) == view.orderedKeys.cend()) @@ -386,7 +386,7 @@ void ThemeData::parseElement(const pugi::xml_node& root, const std::mapsecond.type != expectedType && !expectedType.empty()) { - LOG(LogWarning) << " requested mismatched theme type for [" << view << "." << element << "] - expected \"" + LOG(LogWarning) << " requested mismatched theme type for [" << view << "." << element << "] - expected \"" << expectedType << "\", got \"" << elemIt->second.type << "\""; return NULL; } @@ -512,7 +512,7 @@ std::vector ThemeData::makeExtras(const std::shared_ptrmViews.find(view); if(viewIt == theme->mViews.cend()) return comps; - + for(auto it = viewIt->second.orderedKeys.cbegin(); it != viewIt->second.orderedKeys.cend(); it++) { ThemeElement& elem = viewIt->second.elements.at(*it); @@ -540,9 +540,9 @@ std::map ThemeData::getThemeSets() static const size_t pathCount = 2; std::string paths[pathCount] = - { - "/etc/emulationstation/themes", - Utils::FileSystem::getHomePath() + "/.emulationstation/themes" + { + "/etc/emulationstation/themes", + Utils::FileSystem::getHomePath() + "/.emulationstation/themes" }; for(size_t i = 0; i < pathCount; i++) diff --git a/es-core/src/ThemeData.h b/es-core/src/ThemeData.h index 4fc9faa74..b6cc6fb90 100644 --- a/es-core/src/ThemeData.h +++ b/es-core/src/ThemeData.h @@ -54,7 +54,7 @@ public: template friend ThemeException& operator<<(ThemeException& e, T msg); - + inline void setFiles(const std::deque& deque) { *this << "from theme \"" << deque.front() << "\"\n"; diff --git a/es-core/src/Window.cpp b/es-core/src/Window.cpp index d3873a215..0a510a5c1 100644 --- a/es-core/src/Window.cpp +++ b/es-core/src/Window.cpp @@ -221,7 +221,7 @@ void Window::update(int deltaTime) if(peekGui()) peekGui()->update(deltaTime); - + // Update the screensaver if (mScreenSaver) mScreenSaver->update(deltaTime); @@ -259,7 +259,7 @@ void Window::render() unsigned int screensaverTime = (unsigned int)Settings::getInstance()->getInt("ScreenSaverTime"); if(mTimeSinceLastInput >= screensaverTime && screensaverTime != 0) startScreenSaver(); - + // Always call the screensaver render function regardless of whether the screensaver is active // or not because it may perform a fade on transition renderScreenSaver(); @@ -268,7 +268,7 @@ void Window::render() { mInfoPopup->render(transform); } - + if(mTimeSinceLastInput >= screensaverTime && screensaverTime != 0) { if (!isProcessing() && mAllowSleep && (!mScreenSaver || mScreenSaver->allowSleep())) diff --git a/es-core/src/components/AnimatedImageComponent.cpp b/es-core/src/components/AnimatedImageComponent.cpp index 347fc3c7a..b0332fe65 100644 --- a/es-core/src/components/AnimatedImageComponent.cpp +++ b/es-core/src/components/AnimatedImageComponent.cpp @@ -25,7 +25,7 @@ void AnimatedImageComponent::load(const AnimationDef* def) auto img = std::unique_ptr(new ImageComponent(mWindow)); img->setResize(mSize.x(), mSize.y()); img->setImage(std::string(def->frames[i].path), false); - + mFrames.push_back(ImageFrame(std::move(img), def->frames[i].time)); } diff --git a/es-core/src/components/AnimatedImageComponent.h b/es-core/src/components/AnimatedImageComponent.h index dce1b9079..c128ed30b 100644 --- a/es-core/src/components/AnimatedImageComponent.h +++ b/es-core/src/components/AnimatedImageComponent.h @@ -23,7 +23,7 @@ class AnimatedImageComponent : public GuiComponent { public: AnimatedImageComponent(Window* window); - + void load(const AnimationDef* def); // no reference to def is kept after loading is complete void reset(); // set to frame 0 diff --git a/es-core/src/components/BusyComponent.cpp b/es-core/src/components/BusyComponent.cpp index a3049811f..a37d690be 100644 --- a/es-core/src/components/BusyComponent.cpp +++ b/es-core/src/components/BusyComponent.cpp @@ -45,7 +45,7 @@ void BusyComponent::onSizeChanged() mGrid.setColWidthPerc(3, textWidth / mSize.x()); mGrid.setRowHeightPerc(1, textHeight / mSize.y()); - + mBackground.fitTo(Vector2f(mGrid.getColWidth(1) + mGrid.getColWidth(2) + mGrid.getColWidth(3), textHeight + 2), mAnimation->getPosition(), Vector2f(0, 0)); } diff --git a/es-core/src/components/ButtonComponent.cpp b/es-core/src/components/ButtonComponent.cpp index 21e235bb4..0ada6ece6 100644 --- a/es-core/src/components/ButtonComponent.cpp +++ b/es-core/src/components/ButtonComponent.cpp @@ -5,9 +5,9 @@ ButtonComponent::ButtonComponent(Window* window, const std::string& text, const std::string& helpText, const std::function& func) : GuiComponent(window), mBox(window, ":/button.png"), - mFont(Font::get(FONT_SIZE_MEDIUM)), - mFocused(false), - mEnabled(true), + mFont(Font::get(FONT_SIZE_MEDIUM)), + mFocused(false), + mEnabled(true), mTextColorFocused(0xFFFFFFFF), mTextColorUnfocused(0x777777FF) { setPressedFunc(func); @@ -41,7 +41,7 @@ void ButtonComponent::setText(const std::string& text, const std::string& helpTe { mText = Utils::String::toUpper(text); mHelpText = helpText; - + mTextCache = std::unique_ptr(mFont->buildTextCache(mText, 0, 0, getCurTextColor())); float minWidth = mFont->sizeText("DELETE").x() + 12; @@ -87,7 +87,7 @@ void ButtonComponent::render(const Transform4x4f& parentTrans) { Transform4x4f trans = parentTrans * getTransform(); trans.round(); - + mBox.render(trans); if(mTextCache) diff --git a/es-core/src/components/ButtonComponent.h b/es-core/src/components/ButtonComponent.h index 65288209c..2c25881f0 100644 --- a/es-core/src/components/ButtonComponent.h +++ b/es-core/src/components/ButtonComponent.h @@ -38,7 +38,7 @@ private: bool mEnabled; unsigned int mTextColorFocused; unsigned int mTextColorUnfocused; - + unsigned int getCurTextColor() const; void updateImage(); diff --git a/es-core/src/components/ComponentGrid.cpp b/es-core/src/components/ComponentGrid.cpp index 10d2fdd14..90b6162d9 100644 --- a/es-core/src/components/ComponentGrid.cpp +++ b/es-core/src/components/ComponentGrid.cpp @@ -4,7 +4,7 @@ using namespace GridFlags; -ComponentGrid::ComponentGrid(Window* window, const Vector2i& gridDimensions) : GuiComponent(window), +ComponentGrid::ComponentGrid(Window* window, const Vector2i& gridDimensions) : GuiComponent(window), mGridSize(gridDimensions), mCursor(0, 0) { assert(gridDimensions.x() > 0 && gridDimensions.y() > 0); @@ -39,7 +39,7 @@ float ComponentGrid::getColWidth(int col) if(mColWidths[x] == 0) between++; } - + return (freeWidthPerc * mSize.x()) / between; } @@ -57,7 +57,7 @@ float ComponentGrid::getRowHeight(int row) if(mRowHeights[y] == 0) between++; } - + return (freeHeightPerc * mSize.y()) / between; } @@ -142,7 +142,7 @@ void ComponentGrid::updateCellComponent(const GridEntry& cell) // center component pos[0] = pos.x() + (size.x() - cell.component->getSize().x()) / 2; pos[1] = pos.y() + (size.y() - cell.component->getSize().y()) / 2; - + cell.component->setPosition(pos); } @@ -206,7 +206,7 @@ void ComponentGrid::onSizeChanged() const ComponentGrid::GridEntry* ComponentGrid::getCellAt(int x, int y) const { assert(x >= 0 && x < mGridSize.x() && y >= 0 && y < mGridSize.y()); - + for(auto it = mCells.cbegin(); it != mCells.cend(); it++) { int xmin = it->pos.x(); @@ -276,7 +276,7 @@ bool ComponentGrid::moveCursor(Vector2i dir) const GridEntry* currentCursorEntry = getCellAt(mCursor); Vector2i searchAxis(dir.x() == 0, dir.y() == 0); - + while(mCursor.x() >= 0 && mCursor.y() >= 0 && mCursor.x() < mGridSize.x() && mCursor.y() < mGridSize.y()) { mCursor = mCursor + dir; @@ -357,7 +357,7 @@ void ComponentGrid::render(const Transform4x4f& parentTrans) Transform4x4f trans = parentTrans * getTransform(); renderChildren(trans); - + // draw cell separators if(mLines.size()) { @@ -410,7 +410,7 @@ std::vector ComponentGrid::getHelpPrompts() const GridEntry* e = getCellAt(mCursor); if(e) prompts = e->component->getHelpPrompts(); - + bool canScrollVert = mGridSize.y() > 1; bool canScrollHoriz = mGridSize.x() > 1; for(auto it = prompts.cbegin(); it != prompts.cend(); it++) diff --git a/es-core/src/components/ComponentGrid.h b/es-core/src/components/ComponentGrid.h index 567f5d919..5fad30e0e 100644 --- a/es-core/src/components/ComponentGrid.h +++ b/es-core/src/components/ComponentGrid.h @@ -35,7 +35,7 @@ public: bool removeEntry(const std::shared_ptr& comp); - void setEntry(const std::shared_ptr& comp, const Vector2i& pos, bool canFocus, bool resize = true, + void setEntry(const std::shared_ptr& comp, const Vector2i& pos, bool canFocus, bool resize = true, const Vector2i& size = Vector2i(1, 1), unsigned int border = GridFlags::BORDER_NONE, GridFlags::UpdateType updateType = GridFlags::UPDATE_ALWAYS); void textInput(const char* text) override; @@ -83,8 +83,8 @@ private: unsigned int border; GridEntry(const Vector2i& p = Vector2i::Zero(), const Vector2i& d = Vector2i::Zero(), - const std::shared_ptr& cmp = nullptr, bool f = false, bool r = true, - GridFlags::UpdateType u = GridFlags::UPDATE_ALWAYS, unsigned int b = GridFlags::BORDER_NONE) : + const std::shared_ptr& cmp = nullptr, bool f = false, bool r = true, + GridFlags::UpdateType u = GridFlags::UPDATE_ALWAYS, unsigned int b = GridFlags::BORDER_NONE) : pos(p), dim(d), component(cmp), canFocus(f), resize(r), updateType(u), border(b) {}; @@ -96,7 +96,7 @@ private: float* mRowHeights; float* mColWidths; - + std::vector mLines; // Update position & size @@ -105,7 +105,7 @@ private: const GridEntry* getCellAt(int x, int y) const; inline const GridEntry* getCellAt(const Vector2i& pos) const { return getCellAt(pos.x(), pos.y()); } - + Vector2i mGridSize; std::vector mCells; diff --git a/es-core/src/components/ComponentList.h b/es-core/src/components/ComponentList.h index 429b5f5d6..c5c0f9c2e 100644 --- a/es-core/src/components/ComponentList.h +++ b/es-core/src/components/ComponentList.h @@ -20,10 +20,10 @@ struct ComponentListRow // The input handler is called when the user enters any input while this row is highlighted (including up/down). // Return false to let the list try to use it or true if the input has been consumed. - // If no input handler is supplied (input_handler == nullptr), the default behavior is to forward the input to + // If no input handler is supplied (input_handler == nullptr), the default behavior is to forward the input to // the rightmost element in the currently selected row. std::function input_handler; - + inline void addElement(const std::shared_ptr& component, bool resize_width, bool invert_when_selected = true) { elements.push_back(ComponentListElement(component, resize_width, invert_when_selected)); @@ -62,7 +62,7 @@ public: bool moveCursor(int amt); inline int getCursorId() const { return mCursor; } - + float getTotalRowHeight() const; inline float getRowHeight(int row) const { return getRowHeight(mEntries.at(row).data); } @@ -78,7 +78,7 @@ private: void updateCameraOffset(); void updateElementPosition(const ComponentListRow& row); void updateElementSize(const ComponentListRow& row); - + float getRowHeight(const ComponentListRow& row) const; float mSelectorBarOffset; diff --git a/es-core/src/components/DateTimeEditComponent.cpp b/es-core/src/components/DateTimeEditComponent.cpp index efe5a9443..fef38aa47 100644 --- a/es-core/src/components/DateTimeEditComponent.cpp +++ b/es-core/src/components/DateTimeEditComponent.cpp @@ -3,8 +3,8 @@ #include "resources/Font.h" #include "utils/StringUtil.h" -DateTimeEditComponent::DateTimeEditComponent(Window* window, DisplayMode dispMode) : GuiComponent(window), - mEditing(false), mEditIndex(0), mDisplayMode(dispMode), mRelativeUpdateAccumulator(0), +DateTimeEditComponent::DateTimeEditComponent(Window* window, DisplayMode dispMode) : GuiComponent(window), + mEditing(false), mEditIndex(0), mDisplayMode(dispMode), mRelativeUpdateAccumulator(0), mColor(0x777777FF), mFont(Font::get(FONT_SIZE_SMALL, FONT_PATH_LIGHT)), mUppercase(false), mAutoSize(true) { updateTextCache(); @@ -70,7 +70,7 @@ bool DateTimeEditComponent::input(InputConfig* config, Input input) new_tm.tm_mon = 0; else if(new_tm.tm_mon < 0) new_tm.tm_mon = 11; - + } else if(mEditIndex == 1) { @@ -97,7 +97,7 @@ bool DateTimeEditComponent::input(InputConfig* config, Input input) new_tm.tm_mday = days_in_month; mTime = new_tm; - + updateTextCache(); return true; } @@ -109,7 +109,7 @@ bool DateTimeEditComponent::input(InputConfig* config, Input input) mEditIndex--; return true; } - + if(config->isMappedLike("left", input)) { mEditIndex--; @@ -159,7 +159,7 @@ void DateTimeEditComponent::render(const Transform4x4f& parentTrans) { if(mEditIndex >= 0 && (unsigned int)mEditIndex < mCursorBoxes.size()) { - Renderer::drawRect((int)mCursorBoxes[mEditIndex][0], (int)mCursorBoxes[mEditIndex][1], + Renderer::drawRect((int)mCursorBoxes[mEditIndex][0], (int)mCursorBoxes[mEditIndex][1], (int)mCursorBoxes[mEditIndex][2], (int)mCursorBoxes[mEditIndex][3], 0x00000022); } } @@ -221,12 +221,12 @@ std::string DateTimeEditComponent::getDisplayString(DisplayMode mode) const 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" : ""); - + return std::string(buf); } break; } - + if(mTime.getTime() == 0) return "unknown"; @@ -316,7 +316,7 @@ void DateTimeEditComponent::applyTheme(const std::shared_ptr& theme, return; // We set mAutoSize BEFORE calling GuiComponent::applyTheme because it calls - // setSize(), which will call updateTextCache(), which will reset mSize if + // setSize(), which will call updateTextCache(), which will reset mSize if // mAutoSize == true, ignoring the theme's value. if(properties & ThemeFlags::SIZE) mAutoSize = !elem->has("size"); diff --git a/es-core/src/components/DateTimeEditComponent.h b/es-core/src/components/DateTimeEditComponent.h index 535ba2f86..55a010a1b 100644 --- a/es-core/src/components/DateTimeEditComponent.h +++ b/es-core/src/components/DateTimeEditComponent.h @@ -46,7 +46,7 @@ private: std::string getDisplayString(DisplayMode mode) const; DisplayMode getCurrentDisplayMode() const; - + void updateTextCache(); Utils::Time::DateTime mTime; diff --git a/es-core/src/components/HelpComponent.cpp b/es-core/src/components/HelpComponent.cpp index a64cc1733..1d7ef5529 100644 --- a/es-core/src/components/HelpComponent.cpp +++ b/es-core/src/components/HelpComponent.cpp @@ -63,7 +63,7 @@ void HelpComponent::updateGrid() mGrid = std::make_shared(mWindow, Vector2i((int)mPrompts.size() * 4, 1)); // [icon] [spacer1] [text] [spacer2] - + std::vector< std::shared_ptr > icons; std::vector< std::shared_ptr > labels; @@ -105,7 +105,7 @@ std::shared_ptr HelpComponent::getIconTexture(const char* name) auto it = mIconCache.find(name); if(it != mIconCache.cend()) return it->second; - + auto pathLookup = ICON_PATH_MAP.find(name); if(pathLookup == ICON_PATH_MAP.cend()) { @@ -136,7 +136,7 @@ void HelpComponent::setOpacity(unsigned char opacity) void HelpComponent::render(const Transform4x4f& parentTrans) { Transform4x4f trans = parentTrans * getTransform(); - + if(mGrid) mGrid->render(trans); } diff --git a/es-core/src/components/IList.h b/es-core/src/components/IList.h index 4b75e0138..93f61ce9a 100644 --- a/es-core/src/components/IList.h +++ b/es-core/src/components/IList.h @@ -75,9 +75,9 @@ protected: const ListLoopType mLoopType; std::vector mEntries; - + public: - IList(Window* window, const ScrollTierList& tierList = LIST_SCROLL_STYLE_QUICK, const ListLoopType& loopType = LIST_PAUSE_AT_END) : GuiComponent(window), + IList(Window* window, const ScrollTierList& tierList = LIST_SCROLL_STYLE_QUICK, const ListLoopType& loopType = LIST_PAUSE_AT_END) : GuiComponent(window), mGradient(window), mTierList(tierList), mLoopType(loopType) { mCursor = 0; @@ -85,7 +85,7 @@ public: mScrollVelocity = 0; mScrollTierAccumulator = 0; mScrollCursorAccumulator = 0; - + mTitleOverlayOpacity = 0x00; mTitleOverlayColor = 0xFFFFFF00; mGradient.setResize((float)Renderer::getScreenWidth(), (float)Renderer::getScreenHeight()); @@ -98,7 +98,7 @@ public: return (mScrollVelocity != 0 && mScrollTier > 0); } - int getScrollingVelocity() + int getScrollingVelocity() { return mScrollVelocity; } @@ -151,7 +151,7 @@ public: return false; } - + // entry management void add(const Entry& e) { @@ -255,7 +255,7 @@ protected: Vector2f off = mTitleOverlayFont->sizeText(text); off[0] = (Renderer::getScreenWidth() - off.x()) * 0.5f; off[1] = (Renderer::getScreenHeight() - off.y()) * 0.5f; - + Transform4x4f identTrans = Transform4x4f::Identity(); mGradient.setOpacity(mTitleOverlayOpacity); diff --git a/es-core/src/components/ImageComponent.cpp b/es-core/src/components/ImageComponent.cpp index df86447a9..b42021ddb 100644 --- a/es-core/src/components/ImageComponent.cpp +++ b/es-core/src/components/ImageComponent.cpp @@ -45,7 +45,7 @@ void ImageComponent::resize() }else{ // SVG rasterization is determined by height (see SVGResource.cpp), and rasterization is done in terms of pixels // if rounding is off enough in the rasterization step (for images with extreme aspect ratios), it can cause cutoff when the aspect ratio breaks - // so, we always make sure the resultant height is an integer to make sure cutoff doesn't happen, and scale width from that + // so, we always make sure the resultant height is an integer to make sure cutoff doesn't happen, and scale width from that // (you'll see this scattered throughout the function) // this is probably not the best way, so if you're familiar with this problem and have a better solution, please make a pull request! @@ -62,7 +62,7 @@ void ImageComponent::resize() mSize[1] = Math::min(Math::round(mSize[1] *= resizeScale.x()), mTargetSize.y()); }else{ mSize[1] = Math::round(mSize[1] * resizeScale.y()); // this will be mTargetSize.y(). We can't exceed it. - + // for SVG rasterization, always calculate width from rounded height (see comment above) // we need to make sure we're not creating an image larger than max size mSize[0] = Math::min((mSize[1] / textureSize.y()) * textureSize.x(), mTargetSize.x()); @@ -151,7 +151,7 @@ void ImageComponent::setImage(const char* path, size_t length, bool tile) mTexture = TextureResource::get("", tile); mTexture->initFromMemory(path, length); - + resize(); } @@ -386,7 +386,7 @@ void ImageComponent::applyTheme(const std::shared_ptr& theme, const s } Vector2f scale = getParent() ? getParent()->getSize() : Vector2f((float)Renderer::getScreenWidth(), (float)Renderer::getScreenHeight()); - + if(properties & POSITION && elem->has("pos")) { Vector2f denormalized = elem->get("pos") * scale; diff --git a/es-core/src/components/NinePatchComponent.cpp b/es-core/src/components/NinePatchComponent.cpp index d6c55ed0b..e546fb57e 100644 --- a/es-core/src/components/NinePatchComponent.cpp +++ b/es-core/src/components/NinePatchComponent.cpp @@ -96,7 +96,7 @@ void NinePatchComponent::render(const Transform4x4f& parentTrans) { Transform4x4f trans = parentTrans * getTransform(); trans.round(); - + if(mTexture && mVertices != NULL) { Renderer::setMatrix(trans); diff --git a/es-core/src/components/ScrollableContainer.cpp b/es-core/src/components/ScrollableContainer.cpp index c0e6e6961..eed40827a 100644 --- a/es-core/src/components/ScrollableContainer.cpp +++ b/es-core/src/components/ScrollableContainer.cpp @@ -7,7 +7,7 @@ #define AUTO_SCROLL_DELAY 1000 // ms to wait before we start to scroll #define AUTO_SCROLL_SPEED 50 // ms between scrolls -ScrollableContainer::ScrollableContainer(Window* window) : GuiComponent(window), +ScrollableContainer::ScrollableContainer(Window* window) : GuiComponent(window), mAutoScrollDelay(0), mAutoScrollSpeed(0), mAutoScrollAccumulator(0), mScrollPos(0, 0), mScrollDir(0, 0), mAutoScrollResetAccumulator(0) { } diff --git a/es-core/src/components/SliderComponent.cpp b/es-core/src/components/SliderComponent.cpp index c3b49ed18..bc4fa8d91 100644 --- a/es-core/src/components/SliderComponent.cpp +++ b/es-core/src/components/SliderComponent.cpp @@ -15,7 +15,7 @@ SliderComponent::SliderComponent(Window* window, float min, float max, float inc mKnob.setOrigin(0.5f, 0.5f); mKnob.setImage(":/slider_knob.svg"); - + setSize(Renderer::getScreenWidth() * 0.15f, Font::get(FONT_SIZE_MEDIUM)->getLetterHeight()); } @@ -54,7 +54,7 @@ void SliderComponent::update(int deltaTime) mMoveAccumulator -= MOVE_REPEAT_RATE; } } - + GuiComponent::update(deltaTime); } @@ -76,7 +76,7 @@ void SliderComponent::render(const Transform4x4f& parentTrans) //render knob mKnob.render(trans); - + GuiComponent::renderChildren(trans); } @@ -100,7 +100,7 @@ void SliderComponent::onSizeChanged() { if(!mSuffix.empty()) mFont = Font::get((int)(mSize.y()), FONT_PATH_LIGHT); - + onValueChanged(); } diff --git a/es-core/src/components/SliderComponent.h b/es-core/src/components/SliderComponent.h index e4297d5b7..f3ae181fc 100644 --- a/es-core/src/components/SliderComponent.h +++ b/es-core/src/components/SliderComponent.h @@ -21,9 +21,9 @@ public: bool input(InputConfig* config, Input input) override; void update(int deltaTime) override; void render(const Transform4x4f& parentTrans) override; - + void onSizeChanged() override; - + virtual std::vector getHelpPrompts() override; private: diff --git a/es-core/src/components/SwitchComponent.cpp b/es-core/src/components/SwitchComponent.cpp index dd01b1807..ac413c2fc 100644 --- a/es-core/src/components/SwitchComponent.cpp +++ b/es-core/src/components/SwitchComponent.cpp @@ -29,7 +29,7 @@ bool SwitchComponent::input(InputConfig* config, Input input) void SwitchComponent::render(const Transform4x4f& parentTrans) { Transform4x4f trans = parentTrans * getTransform(); - + mImage.render(trans); renderChildren(trans); diff --git a/es-core/src/components/TextComponent.cpp b/es-core/src/components/TextComponent.cpp index b5a22760a..9e61d5e14 100644 --- a/es-core/src/components/TextComponent.cpp +++ b/es-core/src/components/TextComponent.cpp @@ -4,7 +4,7 @@ #include "Log.h" #include "Settings.h" -TextComponent::TextComponent(Window* window) : GuiComponent(window), +TextComponent::TextComponent(Window* window) : GuiComponent(window), mFont(Font::get(FONT_SIZE_MEDIUM)), mUppercase(false), mColor(0x000000FF), mAutoCalcExtent(true, true), mHorizontalAlignment(ALIGN_LEFT), mVerticalAlignment(ALIGN_CENTER), mLineSpacing(1.5f), mBgColor(0), mRenderBackground(false) @@ -12,7 +12,7 @@ TextComponent::TextComponent(Window* window) : GuiComponent(window), } TextComponent::TextComponent(Window* window, const std::string& text, const std::shared_ptr& font, unsigned int color, Alignment align, - Vector3f pos, Vector2f size, unsigned int bgcolor) : GuiComponent(window), + Vector3f pos, Vector2f size, unsigned int bgcolor) : GuiComponent(window), mFont(NULL), mUppercase(false), mColor(0x000000FF), mAutoCalcExtent(true, true), mHorizontalAlignment(align), mVerticalAlignment(ALIGN_CENTER), mLineSpacing(1.5f), mBgColor(0), mRenderBackground(false) @@ -255,7 +255,7 @@ void TextComponent::applyTheme(const std::shared_ptr& theme, const st return; if (properties & COLOR && elem->has("color")) - setColor(elem->get("color")); + setColor(elem->get("color")); setRenderBackground(false); if (properties & COLOR && elem->has("backgroundColor")) { diff --git a/es-core/src/components/TextEditComponent.cpp b/es-core/src/components/TextEditComponent.cpp index c5b2bce5b..d30c293c8 100644 --- a/es-core/src/components/TextEditComponent.cpp +++ b/es-core/src/components/TextEditComponent.cpp @@ -10,12 +10,12 @@ #define CURSOR_REPEAT_SPEED 28 // lower is faster TextEditComponent::TextEditComponent(Window* window) : GuiComponent(window), - mBox(window, ":/textinput_ninepatch.png"), mFocused(false), - mScrollOffset(0.0f, 0.0f), mCursor(0), mEditing(false), mFont(Font::get(FONT_SIZE_MEDIUM, FONT_PATH_LIGHT)), + mBox(window, ":/textinput_ninepatch.png"), mFocused(false), + mScrollOffset(0.0f, 0.0f), mCursor(0), mEditing(false), mFont(Font::get(FONT_SIZE_MEDIUM, FONT_PATH_LIGHT)), mCursorRepeatDir(0) { addChild(&mBox); - + onFocusLost(); setSize(4096, mFont->getHeight() + TEXT_PADDING_VERT); @@ -217,7 +217,7 @@ void TextEditComponent::onCursorChanged() { if(isMultiline()) { - Vector2f textSize = mFont->getWrappedTextCursorOffset(mText, getTextAreaSize().x(), mCursor); + Vector2f textSize = mFont->getWrappedTextCursorOffset(mText, getTextAreaSize().x(), mCursor); if(mScrollOffset.y() + getTextAreaSize().y() < textSize.y() + mFont->getHeight()) //need to scroll down? { diff --git a/es-core/src/components/TextEditComponent.h b/es-core/src/components/TextEditComponent.h index 74e743a2e..c388b30aa 100644 --- a/es-core/src/components/TextEditComponent.h +++ b/es-core/src/components/TextEditComponent.h @@ -13,7 +13,7 @@ class TextEditComponent : public GuiComponent { public: TextEditComponent(Window* window); - + void textInput(const char* text) override; bool input(InputConfig* config, Input input) override; void update(int deltaTime) override; diff --git a/es-core/src/guis/GuiDetectDevice.cpp b/es-core/src/guis/GuiDetectDevice.cpp index 6632945e6..45d9a6bd2 100644 --- a/es-core/src/guis/GuiDetectDevice.cpp +++ b/es-core/src/guis/GuiDetectDevice.cpp @@ -10,7 +10,7 @@ #define HOLD_TIME 1000 -GuiDetectDevice::GuiDetectDevice(Window* window, bool firstRun, const std::function& doneCallback) : GuiComponent(window), mFirstRun(firstRun), +GuiDetectDevice::GuiDetectDevice(Window* window, bool firstRun, const std::function& doneCallback) : GuiComponent(window), mFirstRun(firstRun), mBackground(window, ":/frame.png"), mGrid(window, Vector2i(1, 5)) { mHoldingConfig = NULL; @@ -19,16 +19,16 @@ GuiDetectDevice::GuiDetectDevice(Window* window, bool firstRun, const std::funct addChild(&mBackground); addChild(&mGrid); - + // title - mTitle = std::make_shared(mWindow, firstRun ? "WELCOME" : "CONFIGURE INPUT", + mTitle = std::make_shared(mWindow, firstRun ? "WELCOME" : "CONFIGURE INPUT", Font::get(FONT_SIZE_LARGE), 0x555555FF, ALIGN_CENTER); mGrid.setEntry(mTitle, Vector2i(0, 0), false, true, Vector2i(1, 1), GridFlags::BORDER_BOTTOM); // device info std::stringstream deviceInfo; int numDevices = InputManager::getInstance()->getNumJoysticks(); - + if(numDevices > 0) deviceInfo << numDevices << " GAMEPAD" << (numDevices > 1 ? "S" : "") << " DETECTED"; else diff --git a/es-core/src/guis/GuiInputConfig.cpp b/es-core/src/guis/GuiInputConfig.cpp index 29111a484..474ca4f26 100755 --- a/es-core/src/guis/GuiInputConfig.cpp +++ b/es-core/src/guis/GuiInputConfig.cpp @@ -50,8 +50,8 @@ static const InputConfigStructure GUI_INPUT_CONFIG_LIST[inputCount] = #define HOLD_TO_SKIP_MS 1000 -GuiInputConfig::GuiInputConfig(Window* window, InputConfig* target, bool reconfigureAll, const std::function& okCallback) : GuiComponent(window), - mBackground(window, ":/frame.png"), mGrid(window, Vector2i(1, 7)), +GuiInputConfig::GuiInputConfig(Window* window, InputConfig* target, bool reconfigureAll, const std::function& okCallback) : GuiComponent(window), + mBackground(window, ":/frame.png"), mGrid(window, Vector2i(1, 7)), mTargetConfig(target), mHoldingInput(false), mBusyAnim(window) { LOG(LogInfo) << "Configuring device " << target->getDeviceId() << " (" << target->getDeviceName() << ")."; @@ -70,7 +70,7 @@ GuiInputConfig::GuiInputConfig(Window* window, InputConfig* target, bool reconfi mTitle = std::make_shared(mWindow, "CONFIGURING", Font::get(FONT_SIZE_LARGE), 0x555555FF, ALIGN_CENTER); mGrid.setEntry(mTitle, Vector2i(0, 1), false, true); - + std::stringstream ss; if(target->getDeviceId() == DEVICE_KEYBOARD) ss << "KEYBOARD"; @@ -91,7 +91,7 @@ GuiInputConfig::GuiInputConfig(Window* window, InputConfig* target, bool reconfi for(int i = 0; i < inputCount; i++) { ComponentListRow row; - + // icon auto icon = std::make_shared(mWindow); icon->setImage(GUI_INPUT_CONFIG_LIST[i].icon); @@ -128,7 +128,7 @@ GuiInputConfig::GuiInputConfig(Window* window, InputConfig* target, bool reconfi setPress(mapping); return true; } - + // we're not configuring and they didn't press A to start, so ignore this return false; } @@ -185,7 +185,7 @@ GuiInputConfig::GuiInputConfig(Window* window, InputConfig* target, bool reconfi InputManager::getInstance()->writeDeviceConfig(mTargetConfig); // save if(okCallback) okCallback(); - delete this; + delete this; }; buttons.push_back(std::make_shared(mWindow, "OK", "ok", [this, okFunction] { // check if the hotkey enable button is set. if not prompt the user to use select or nothing. @@ -263,7 +263,7 @@ void GuiInputConfig::update(int deltaTime) } } -// move cursor to the next thing if we're configuring all, +// move cursor to the next thing if we're configuring all, // or come out of "configure mode" if we were only configuring one row void GuiInputConfig::rowDone() { @@ -322,7 +322,7 @@ bool GuiInputConfig::assign(Input input, int inputId) } setAssignedTo(mMappings.at(inputId), input); - + input.configured = true; mTargetConfig->mapInput(GUI_INPUT_CONFIG_LIST[inputId].name, input); @@ -357,6 +357,10 @@ bool GuiInputConfig::filterTrigger(Input input, InputConfig* config, int inputId mSkipAxis = true; return true; } +#else + (void)input; + (void)config; + (void)inputId; #endif return false; diff --git a/es-core/src/guis/GuiInputConfig.h b/es-core/src/guis/GuiInputConfig.h index d33a8fad7..3cdf0f910 100644 --- a/es-core/src/guis/GuiInputConfig.h +++ b/es-core/src/guis/GuiInputConfig.h @@ -52,7 +52,7 @@ private: int mHeldInputId; bool mSkipAxis; - BusyComponent mBusyAnim; + BusyComponent mBusyAnim; }; #endif // ES_CORE_GUIS_GUI_INPUT_CONFIG_H diff --git a/es-core/src/guis/GuiMsgBox.cpp b/es-core/src/guis/GuiMsgBox.cpp index 7f0560320..9db9ffff1 100644 --- a/es-core/src/guis/GuiMsgBox.cpp +++ b/es-core/src/guis/GuiMsgBox.cpp @@ -5,10 +5,10 @@ #define HORIZONTAL_PADDING_PX 20 -GuiMsgBox::GuiMsgBox(Window* window, const std::string& text, +GuiMsgBox::GuiMsgBox(Window* window, const std::string& text, const std::string& name1, const std::function& func1, - const std::string& name2, const std::function& func2, - const std::string& name3, const std::function& func3) : GuiComponent(window), + const std::string& name2, const std::function& func2, + const std::string& name3, const std::function& func3) : GuiComponent(window), mBackground(window, ":/frame.png"), mGrid(window, Vector2i(1, 2)) { float width = Renderer::getScreenWidth() * 0.6f; // max width @@ -66,7 +66,7 @@ GuiMsgBox::GuiMsgBox(Window* window, const std::string& text, bool GuiMsgBox::input(InputConfig* config, Input input) { // special case for when GuiMsgBox comes up to report errors before anything has been configured - if(config->getDeviceId() == DEVICE_KEYBOARD && !config->isConfigured() && input.value && + if(config->getDeviceId() == DEVICE_KEYBOARD && !config->isConfigured() && input.value && (input.id == SDLK_RETURN || input.id == SDLK_ESCAPE || input.id == SDLK_SPACE)) { mAcceleratorFunc(); @@ -86,7 +86,7 @@ void GuiMsgBox::onSizeChanged() { mGrid.setSize(mSize); mGrid.setRowHeightPerc(1, mButtonGrid->getSize().y() / mSize.y()); - + // update messagebox size mMsg->setSize(mSize.x() - HORIZONTAL_PADDING_PX*2, mGrid.getRowHeight(0)); mGrid.onSizeChanged(); diff --git a/es-core/src/guis/GuiMsgBox.h b/es-core/src/guis/GuiMsgBox.h index 071918345..cd9883244 100644 --- a/es-core/src/guis/GuiMsgBox.h +++ b/es-core/src/guis/GuiMsgBox.h @@ -12,9 +12,9 @@ class TextComponent; class GuiMsgBox : public GuiComponent { public: - GuiMsgBox(Window* window, const std::string& text, + GuiMsgBox(Window* window, const std::string& text, const std::string& name1 = "OK", const std::function& func1 = nullptr, - const std::string& name2 = "", const std::function& func2 = nullptr, + const std::string& name2 = "", const std::function& func2 = nullptr, const std::string& name3 = "", const std::function& func3 = nullptr); bool input(InputConfig* config, Input input) override; diff --git a/es-core/src/guis/GuiTextEditPopup.cpp b/es-core/src/guis/GuiTextEditPopup.cpp index 267939430..4c14bddb4 100644 --- a/es-core/src/guis/GuiTextEditPopup.cpp +++ b/es-core/src/guis/GuiTextEditPopup.cpp @@ -4,7 +4,7 @@ #include "components/MenuComponent.h" #include "components/TextEditComponent.h" -GuiTextEditPopup::GuiTextEditPopup(Window* window, const std::string& title, const std::string& initValue, +GuiTextEditPopup::GuiTextEditPopup(Window* window, const std::string& title, const std::string& initValue, const std::function& okCallback, bool multiLine, const char* acceptBtnText) : GuiComponent(window), mBackground(window, ":/frame.png"), mGrid(window, Vector2i(1, 3)), mMultiLine(multiLine) { diff --git a/es-core/src/guis/GuiTextEditPopup.h b/es-core/src/guis/GuiTextEditPopup.h index eca29ec41..4658fca4a 100644 --- a/es-core/src/guis/GuiTextEditPopup.h +++ b/es-core/src/guis/GuiTextEditPopup.h @@ -12,7 +12,7 @@ class TextEditComponent; class GuiTextEditPopup : public GuiComponent { public: - GuiTextEditPopup(Window* window, const std::string& title, const std::string& initValue, + GuiTextEditPopup(Window* window, const std::string& title, const std::string& initValue, const std::function& okCallback, bool multiLine, const char* acceptBtnText = "OK"); bool input(InputConfig* config, Input input); diff --git a/es-core/src/platform.cpp b/es-core/src/platform.cpp index d3b87fb27..81262310b 100644 --- a/es-core/src/platform.cpp +++ b/es-core/src/platform.cpp @@ -71,15 +71,15 @@ void processQuitMode() { switch (quitMode) { - case QuitMode::RESTART: + case QuitMode::RESTART: LOG(LogInfo) << "Restarting EmulationStation"; touch("/tmp/es-restart"); - break; - case QuitMode::REBOOT: + break; + case QuitMode::REBOOT: LOG(LogInfo) << "Rebooting system"; touch("/tmp/es-sysrestart"); runRestartCommand(); - break; + break; case QuitMode::SHUTDOWN: LOG(LogInfo) << "Shutting system down"; touch("/tmp/es-shutdown"); diff --git a/es-core/src/renderers/Renderer.cpp b/es-core/src/renderers/Renderer.cpp index b107f1d29..65b5fedf9 100644 --- a/es-core/src/renderers/Renderer.cpp +++ b/es-core/src/renderers/Renderer.cpp @@ -47,7 +47,7 @@ namespace Renderer #endif // try creating SDL surface from logo data SDL_Surface* logoSurface = SDL_CreateRGBSurfaceFrom((void*)rawData.data(), (int)width, (int)height, 32, (int)(width * 4), rmask, gmask, bmask, amask); - + if(logoSurface != nullptr) { SDL_SetWindowIcon(sdlWindow, logoSurface); diff --git a/es-core/src/renderers/Renderer.h b/es-core/src/renderers/Renderer.h index 3a409d7a7..f54238575 100644 --- a/es-core/src/renderers/Renderer.h +++ b/es-core/src/renderers/Renderer.h @@ -62,13 +62,13 @@ namespace Renderer }; // Vertex - bool init (); - void deinit (); + bool init (); + void deinit (); void pushClipRect (const Vector2i& _pos, const Vector2i& _size); void popClipRect (); - void drawRect (const float _x, const float _y, const float _w, const float _h, const unsigned int _color, const Blend::Factor _srcBlendFactor = Blend::SRC_ALPHA, const Blend::Factor _dstBlendFactor = Blend::ONE_MINUS_SRC_ALPHA); - void drawRect (const int _x, const int _y, const int _w, const int _h, const unsigned int _color, const Blend::Factor _srcBlendFactor = Blend::SRC_ALPHA, const Blend::Factor _dstBlendFactor = Blend::ONE_MINUS_SRC_ALPHA); - + void drawRect (const float _x, const float _y, const float _w, const float _h, const unsigned int _color, const Blend::Factor _srcBlendFactor = Blend::SRC_ALPHA, const Blend::Factor _dstBlendFactor = Blend::ONE_MINUS_SRC_ALPHA); + void drawRect (const int _x, const int _y, const int _w, const int _h, const unsigned int _color, const Blend::Factor _srcBlendFactor = Blend::SRC_ALPHA, const Blend::Factor _dstBlendFactor = Blend::ONE_MINUS_SRC_ALPHA); + SDL_Window* getSDLWindow (); int getWindowWidth (); int getWindowHeight (); diff --git a/es-core/src/renderers/Renderer_GL21.cpp b/es-core/src/renderers/Renderer_GL21.cpp index 479940981..f3b4247ec 100644 --- a/es-core/src/renderers/Renderer_GL21.cpp +++ b/es-core/src/renderers/Renderer_GL21.cpp @@ -225,8 +225,8 @@ namespace Renderer // vsync if(Settings::getInstance()->getBool("VSync")) { - // SDL_GL_SetSwapInterval(0) for immediate updates (no vsync, default), - // 1 for updates synchronized with the vertical retrace, + // SDL_GL_SetSwapInterval(0) for immediate updates (no vsync, default), + // 1 for updates synchronized with the vertical retrace, // or -1 for late swap tearing. // SDL_GL_SetSwapInterval returns 0 on success, -1 on error. // if vsync is requested, try normal vsync; if that doesn't work, try late swap tearing diff --git a/es-core/src/renderers/Renderer_GLES10.cpp b/es-core/src/renderers/Renderer_GLES10.cpp index 1d402822e..3a99b45d1 100644 --- a/es-core/src/renderers/Renderer_GLES10.cpp +++ b/es-core/src/renderers/Renderer_GLES10.cpp @@ -225,8 +225,8 @@ namespace Renderer // vsync if(Settings::getInstance()->getBool("VSync")) { - // SDL_GL_SetSwapInterval(0) for immediate updates (no vsync, default), - // 1 for updates synchronized with the vertical retrace, + // SDL_GL_SetSwapInterval(0) for immediate updates (no vsync, default), + // 1 for updates synchronized with the vertical retrace, // or -1 for late swap tearing. // SDL_GL_SetSwapInterval returns 0 on success, -1 on error. // if vsync is requested, try normal vsync; if that doesn't work, try late swap tearing diff --git a/es-core/src/resources/Font.cpp b/es-core/src/resources/Font.cpp index c84f059bd..ad8e671d4 100644 --- a/es-core/src/resources/Font.cpp +++ b/es-core/src/resources/Font.cpp @@ -19,7 +19,7 @@ Font::FontFace::FontFace(ResourceData&& d, int size) : data(d) { int err = FT_New_Memory_Face(sLibrary, data.ptr.get(), (FT_Long)data.length, 0, &face); assert(!err); - + if(!err) FT_Set_Pixel_Sizes(face, 0, size); } @@ -75,7 +75,7 @@ size_t Font::getTotalMemUsage() Font::Font(int size, const std::string& path) : mSize(size), mPath(path) { assert(mSize > 0); - + mMaxGlyphHeight = 0; if(!sLibrary) @@ -204,7 +204,7 @@ void Font::getTextureForNewGlyph(const Vector2i& glyphSize, FontTexture*& tex_ou mTextures.push_back(FontTexture()); tex_out = &mTextures.back(); tex_out->initTexture(); - + bool ok = tex_out->findEmpty(glyphSize, cursor_out); if(!ok) { @@ -248,7 +248,7 @@ std::vector getFallbackFontPaths() #else // Linux - const char* paths[] = { + const char* paths[] = { "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", "/usr/share/fonts/truetype/freefont/FreeMono.ttf", "/usr/share/fonts/truetype/droid/DroidSansFallbackFull.ttf" // japanese, chinese, present on Debian @@ -337,7 +337,7 @@ Font::Glyph* Font::getGlyph(unsigned int id) // create glyph Glyph& glyph = mGlyphMap[id]; - + glyph.texture = tex; glyph.texPos = Vector2f(cursor.x() / (float)tex->textureSize.x(), cursor.y() / (float)tex->textureSize.y()); glyph.texSize = Vector2f(glyphSize.x() / (float)tex->textureSize.x(), glyphSize.y() / (float)tex->textureSize.y()); @@ -375,11 +375,11 @@ void Font::rebuildTextures() FT_Load_Char(face, it->first, FT_LOAD_RENDER); FontTexture* tex = it->second.texture; - + // find the position/size Vector2i cursor((int)(it->second.texPos.x() * tex->textureSize.x()), (int)(it->second.texPos.y() * tex->textureSize.y())); Vector2i glyphSize((int)(it->second.texSize.x() * tex->textureSize.x()), (int)(it->second.texSize.y() * tex->textureSize.y())); - + // upload to texture Renderer::updateTexture(tex->textureId, Renderer::Texture::ALPHA, cursor.x(), cursor.y(), glyphSize.x(), glyphSize.y(), glyphSlot->bitmap.buffer); } @@ -566,7 +566,7 @@ float Font::getNewlineStartOffset(const std::string& text, const unsigned int& c TextCache* Font::buildTextCache(const std::string& text, Vector2f offset, unsigned int color, float xLen, Alignment alignment, float lineSpacing) { float x = offset[0] + (xLen != 0 ? getNewlineStartOffset(text, 0, xLen, alignment) : 0); - + float yTop = getGlyph('S')->bearing.y(); float yBot = getHeight(lineSpacing); float y = offset[1] + (yBot + yTop)/2.0f; @@ -656,13 +656,13 @@ std::shared_ptr Font::getFromTheme(const ThemeData::ThemeElement* elem, un using namespace ThemeFlags; if(!(properties & FONT_PATH) && !(properties & FONT_SIZE)) return orig; - + std::shared_ptr font; int size = (orig ? orig->mSize : FONT_SIZE_MEDIUM); std::string path = (orig ? orig->mPath : getDefaultPath()); float sh = (float)Renderer::getScreenHeight(); - if(properties & FONT_SIZE && elem->has("fontSize")) + if(properties & FONT_SIZE && elem->has("fontSize")) size = (int)(sh * elem->get("fontSize")); if(properties & FONT_PATH && elem->has("fontPath")) path = elem->get("fontPath"); diff --git a/es-core/src/resources/Font.h b/es-core/src/resources/Font.h index 72a201f9c..448ab5f9b 100644 --- a/es-core/src/resources/Font.h +++ b/es-core/src/resources/Font.h @@ -45,7 +45,7 @@ public: TextCache* buildTextCache(const std::string& text, float offsetX, float offsetY, unsigned int color); TextCache* buildTextCache(const std::string& text, Vector2f offset, unsigned int color, float xLen, Alignment alignment = ALIGN_LEFT, float lineSpacing = 1.5f); void renderTextCache(TextCache* cache); - + std::string wrapText(std::string text, float xLen); // Inserts newlines into text to make it wrap properly. Vector2f sizeWrappedText(std::string text, float xLen, float lineSpacing = 1.5f); // Returns the expected size of a string after wrapping is applied. Vector2f getWrappedTextCursorOffset(std::string text, float xLen, size_t cursor, float lineSpacing = 1.5f); // Returns the position of of the cursor after moving "cursor" characters. @@ -112,7 +112,7 @@ private: struct Glyph { FontTexture* texture; - + Vector2f texPos; Vector2f texSize; // in texels! @@ -125,7 +125,7 @@ private: Glyph* getGlyph(unsigned int id); int mMaxGlyphHeight; - + const int mSize; const std::string mPath; diff --git a/es-core/src/utils/FileSystemUtil.cpp b/es-core/src/utils/FileSystemUtil.cpp index bd2c84ba6..a30d0ca2d 100644 --- a/es-core/src/utils/FileSystemUtil.cpp +++ b/es-core/src/utils/FileSystemUtil.cpp @@ -25,8 +25,8 @@ namespace Utils { namespace FileSystem { - static std::string homePath; - static std::string exePath; + static std::string homePath = ""; + static std::string exePath = ""; #if defined(_WIN32) static std::string convertFromWideString(const std::wstring wstring) @@ -142,18 +142,20 @@ namespace Utils void setHomePath(const std::string& _path) { homePath = getGenericPath(_path); - } + + } // setHomePath std::string getHomePath() { + // only construct the homepath once if(homePath.length()) return homePath; - // Is it a portable installation ? Check if ".emulationstation/es_systems.cfg" exists in the exe's path - if(Utils::FileSystem::exists(getExePath() + "/.emulationstation/es_systems.cfg")) + // check if "getExePath()/.emulationstation/es_systems.cfg" exists + if(Utils::FileSystem::exists(getExePath() + "/.emulationstation/es_systems.cfg")) homePath = getExePath(); - // Check for HOME environment variable + // check for HOME environment variable if(!homePath.length()) { char* envHome = getenv("HOME"); @@ -162,8 +164,7 @@ namespace Utils } #if defined(_WIN32) - // On Windows, HOME is not the system's user path but a user environment variable. - // Instead we get the home user's path using %HOMEDRIVE%/%HOMEPATH% which are system variables. + // on Windows we need to check HOMEDRIVE and HOMEPATH if(!homePath.length()) { char* envHomeDrive = getenv("HOMEDRIVE"); @@ -175,7 +176,7 @@ namespace Utils // no homepath found, fall back to current working directory if(!homePath.length()) - homePath = getCWDPath(); + homePath = getCWDPath(); // return constructed homepath return homePath; @@ -193,15 +194,16 @@ namespace Utils void setExePath(const std::string& _path) { - std::string path = getCanonicalPath(_path); - if(isRegularFile(path)) - path = getParent(path); + exePath = getCanonicalPath(_path); + + if(isRegularFile(exePath)) + exePath = getParent(exePath); - exePath = path; } // setExePath std::string getExePath() - { + { + // return constructed exepath return exePath; } // getExePath @@ -451,21 +453,17 @@ namespace Utils bool contains = false; std::string path = removeCommonPath(_path, _relativeTo, contains); + // success if(contains) - { - // success return ("./" + path); - } if(_allowHome) { path = removeCommonPath(_path, getHomePath(), contains); + // success if(contains) - { - // success return ("~/" + path); - } } // nothing to resolve diff --git a/es-core/src/utils/FileSystemUtil.h b/es-core/src/utils/FileSystemUtil.h index bb6ea6764..db45a1c53 100644 --- a/es-core/src/utils/FileSystemUtil.h +++ b/es-core/src/utils/FileSystemUtil.h @@ -39,6 +39,7 @@ namespace Utils bool isDirectory (const std::string& _path); bool isSymlink (const std::string& _path); bool isHidden (const std::string& _path); + } // FileSystem:: } // Utils:: diff --git a/es-core/src/utils/StringUtil.cpp b/es-core/src/utils/StringUtil.cpp index 8d35f9701..b9ba8cbe6 100644 --- a/es-core/src/utils/StringUtil.cpp +++ b/es-core/src/utils/StringUtil.cpp @@ -205,7 +205,7 @@ namespace Utils { done = true; - for(int i = 0; i < sizeof(remove); i += 2) + for(size_t i = 0; i < sizeof(remove); i += 2) { end = string.find_first_of(remove[i + 1]); start = string.find_last_of( remove[i + 0], end); @@ -280,14 +280,13 @@ namespace Utils } // format - // Simple XOR scrambling of a string, with an accompanying key - std::string scramble(const std::string& _input, const std::string& key) + std::string scramble(const std::string& _input, const std::string& _key) { std::string buffer = _input; - - for (size_t i = 0; i < _input.size(); ++i) - { - buffer[i] = _input[i] ^ key[i]; + + for(size_t i = 0; i < _input.size(); ++i) + { + buffer[i] = _input[i] ^ _key[i]; } return buffer; diff --git a/es-core/src/utils/StringUtil.h b/es-core/src/utils/StringUtil.h index 5fffa1d76..39fd9559d 100644 --- a/es-core/src/utils/StringUtil.h +++ b/es-core/src/utils/StringUtil.h @@ -25,7 +25,7 @@ namespace Utils std::string removeParenthesis (const std::string& _string); stringVector commaStringToVector(const std::string& _string); std::string vectorToCommaString(stringVector _vector); - std::string format (const char* _string, ...); + std::string format (const char* _string, ...); std::string scramble (const std::string& _input, const std::string& key); } // String:: diff --git a/es-core/src/utils/TimeUtil.cpp b/es-core/src/utils/TimeUtil.cpp index 2b10eeb4a..3bad4eb37 100644 --- a/es-core/src/utils/TimeUtil.cpp +++ b/es-core/src/utils/TimeUtil.cpp @@ -95,7 +95,7 @@ namespace Utils if(*f == '%') { ++f; - + switch(*f++) { case 'Y': // The year [1970,xxxx] @@ -200,7 +200,7 @@ namespace Utils if(*f == '%') { ++f; - + switch(*f++) { case 'Y': // The year, including the century (1900)