diff --git a/es-app/src/FileData.cpp b/es-app/src/FileData.cpp index 731dde70a..b68258d94 100644 --- a/es-app/src/FileData.cpp +++ b/es-app/src/FileData.cpp @@ -774,8 +774,10 @@ const FileData::SortType& FileData::getSortTypeFromString(const std::string& des return FileSorts::SortTypes.at(0); } -void FileData::launchGame(Window* window) +void FileData::launchGame() { + Window* window {Window::getInstance()}; + LOG(LogInfo) << "Launching game \"" << this->metadata.get("name") << "\"..."; SystemData* gameSystem = nullptr; diff --git a/es-app/src/FileData.h b/es-app/src/FileData.h index 4a195046e..73332be6f 100644 --- a/es-app/src/FileData.h +++ b/es-app/src/FileData.h @@ -106,7 +106,7 @@ public: // As above, but also remove parenthesis. std::string getCleanName() const; - void launchGame(Window* window); + void launchGame(); const std::string findEmulatorPath(std::string& command); using ComparisonFunction = bool(const FileData* a, const FileData* b); diff --git a/es-app/src/MediaViewer.cpp b/es-app/src/MediaViewer.cpp index 3b3276762..dbe279207 100644 --- a/es-app/src/MediaViewer.cpp +++ b/es-app/src/MediaViewer.cpp @@ -13,11 +13,10 @@ #include "views/ViewController.h" MediaViewer::MediaViewer() - : mWindow {Window::getInstance()} - , mVideo {nullptr} + : mVideo {nullptr} , mImage {nullptr} { - mWindow->setMediaViewer(this); + Window::getInstance()->setMediaViewer(this); } MediaViewer::~MediaViewer() @@ -260,7 +259,7 @@ void MediaViewer::playVideo() mDisplayingImage = false; ViewController::getInstance()->onStopVideo(); - mVideo = new VideoFFmpegComponent(mWindow); + mVideo = new VideoFFmpegComponent; mVideo->topWindow(true); mVideo->setOrigin(0.5f, 0.5f); mVideo->setPosition(Renderer::getScreenWidth() / 2.0f, Renderer::getScreenHeight() / 2.0f); @@ -285,7 +284,7 @@ void MediaViewer::showImage(int index) mDisplayingImage = true; if (!mImageFiles.empty() && static_cast(mImageFiles.size()) >= index) { - mImage = new ImageComponent(mWindow, false, false); + mImage = new ImageComponent(false, false); mImage->setImage(mImageFiles[index]); mImage->setOrigin(0.5f, 0.5f); mImage->setPosition(Renderer::getScreenWidth() / 2.0f, Renderer::getScreenHeight() / 2.0f); diff --git a/es-app/src/MediaViewer.h b/es-app/src/MediaViewer.h index d2b4b445e..371c9445d 100644 --- a/es-app/src/MediaViewer.h +++ b/es-app/src/MediaViewer.h @@ -36,7 +36,6 @@ private: void showNext() override; void showPrevious() override; - Window* mWindow; FileData* mGame; bool mHasVideo; diff --git a/es-app/src/Screensaver.cpp b/es-app/src/Screensaver.cpp index 2115346f9..3ceb763ef 100644 --- a/es-app/src/Screensaver.cpp +++ b/es-app/src/Screensaver.cpp @@ -116,7 +116,7 @@ void Screensaver::startScreensaver(bool generateMediaList) generateOverlayInfo(); if (!mImageScreensaver) - mImageScreensaver = new ImageComponent(mWindow, false, false); + mImageScreensaver = new ImageComponent(false, false); mTimer = 0; @@ -156,7 +156,7 @@ void Screensaver::startScreensaver(bool generateMediaList) if (Settings::getInstance()->getBool("ScreensaverVideoGameInfo")) generateOverlayInfo(); - mVideoScreensaver = new VideoFFmpegComponent(mWindow); + mVideoScreensaver = new VideoFFmpegComponent; mVideoScreensaver->topWindow(true); mVideoScreensaver->setOrigin(0.5f, 0.5f); mVideoScreensaver->setPosition(Renderer::getScreenWidth() / 2.0f, diff --git a/es-app/src/guis/GuiAlternativeEmulators.cpp b/es-app/src/guis/GuiAlternativeEmulators.cpp index 43143b835..801ab3806 100644 --- a/es-app/src/guis/GuiAlternativeEmulators.cpp +++ b/es-app/src/guis/GuiAlternativeEmulators.cpp @@ -13,9 +13,8 @@ #include "SystemData.h" #include "views/ViewController.h" -GuiAlternativeEmulators::GuiAlternativeEmulators(Window* window) - : GuiComponent {window} - , mMenu {window, "ALTERNATIVE EMULATORS"} +GuiAlternativeEmulators::GuiAlternativeEmulators() + : mMenu {"ALTERNATIVE EMULATORS"} , mHasSystems {false} { addChild(&mMenu); @@ -36,8 +35,8 @@ GuiAlternativeEmulators::GuiAlternativeEmulators(Window* window) ComponentListRow row; std::string name {(*it)->getName()}; - std::shared_ptr systemText {std::make_shared( - mWindow, name, Font::get(FONT_SIZE_MEDIUM), 0x777777FF)}; + std::shared_ptr systemText { + std::make_shared(name, Font::get(FONT_SIZE_MEDIUM), 0x777777FF)}; systemText->setSize(systemSizeX, systemText->getSize().y); row.addElement(systemText, false); @@ -68,13 +67,12 @@ GuiAlternativeEmulators::GuiAlternativeEmulators(Window* window) if (label == (*it)->getSystemEnvData()->mLaunchCommands.front().second) { labelText = std::make_shared( - mWindow, label, Font::get(FONT_SIZE_MEDIUM, FONT_PATH_LIGHT), 0x777777FF, - ALIGN_RIGHT); + label, Font::get(FONT_SIZE_MEDIUM, FONT_PATH_LIGHT), 0x777777FF, ALIGN_RIGHT); } else { // Mark any non-default value with bold and add a gear symbol as well. labelText = std::make_shared( - mWindow, label + (!invalidEntry ? " " + ViewController::GEAR_CHAR : ""), + label + (!invalidEntry ? " " + ViewController::GEAR_CHAR : ""), Font::get(FONT_SIZE_MEDIUM, FONT_PATH_BOLD), 0x777777FF, ALIGN_RIGHT); } @@ -103,7 +101,7 @@ GuiAlternativeEmulators::GuiAlternativeEmulators(Window* window) if (!mHasSystems) { ComponentListRow row; std::shared_ptr systemText = std::make_shared( - mWindow, ViewController::EXCLAMATION_CHAR + " NO ALTERNATIVE EMULATORS DEFINED", + ViewController::EXCLAMATION_CHAR + " NO ALTERNATIVE EMULATORS DEFINED", Font::get(FONT_SIZE_MEDIUM), 0x777777FF, ALIGN_CENTER); row.addElement(systemText, true); mMenu.addRow(row); @@ -133,7 +131,7 @@ void GuiAlternativeEmulators::updateMenu(const std::string& systemName, void GuiAlternativeEmulators::selectorWindow(SystemData* system) { - auto s = new GuiSettings(mWindow, system->getFullName()); + auto s = new GuiSettings(system->getFullName()); std::string selectedLabel = system->getAlternativeEmulator(); std::string label; @@ -147,7 +145,7 @@ void GuiAlternativeEmulators::selectorWindow(SystemData* system) label = entry.second; std::shared_ptr labelText = std::make_shared( - mWindow, label, Font::get(FONT_SIZE_MEDIUM), 0x777777FF, ALIGN_LEFT); + label, Font::get(FONT_SIZE_MEDIUM), 0x777777FF, ALIGN_LEFT); labelText->setSelectable(true); if (system->getSystemEnvData()->mLaunchCommands.front().second == label) diff --git a/es-app/src/guis/GuiAlternativeEmulators.h b/es-app/src/guis/GuiAlternativeEmulators.h index ac8a5e8a7..b819d0c57 100644 --- a/es-app/src/guis/GuiAlternativeEmulators.h +++ b/es-app/src/guis/GuiAlternativeEmulators.h @@ -18,7 +18,7 @@ template class OptionListComponent; class GuiAlternativeEmulators : public GuiComponent { public: - GuiAlternativeEmulators(Window* window); + GuiAlternativeEmulators(); private: void updateMenu(const std::string& systemName, const std::string& label, bool defaultEmulator); diff --git a/es-app/src/guis/GuiCollectionSystemsOptions.cpp b/es-app/src/guis/GuiCollectionSystemsOptions.cpp index 1f623fc03..38c518a44 100644 --- a/es-app/src/guis/GuiCollectionSystemsOptions.cpp +++ b/es-app/src/guis/GuiCollectionSystemsOptions.cpp @@ -19,8 +19,8 @@ #include "utils/StringUtil.h" #include "views/ViewController.h" -GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(Window* window, std::string title) - : GuiSettings {window, title} +GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(std::string title) + : GuiSettings {title} , mAddedCustomCollection {false} , mDeletedCustomCollection {false} { @@ -29,7 +29,6 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(Window* window, std::st ComponentListRow row; row.addElement( std::make_shared( - mWindow, "FINISH EDITING '" + Utils::String::toUpper( CollectionSystemsManager::getInstance()->getEditingCollection()) + @@ -46,7 +45,7 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(Window* window, std::st // Automatic collections. collection_systems_auto = std::make_shared>( - mWindow, getHelpStyle(), "SELECT COLLECTIONS", true); + getHelpStyle(), "SELECT COLLECTIONS", true); std::map autoSystems = CollectionSystemsManager::getInstance()->getAutoCollectionSystems(); // Add automatic systems. @@ -95,7 +94,7 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(Window* window, std::st // Custom collections. collection_systems_custom = std::make_shared>( - mWindow, getHelpStyle(), "SELECT COLLECTIONS", true); + getHelpStyle(), "SELECT COLLECTIONS", true); std::map customSystems = CollectionSystemsManager::getInstance()->getCustomCollectionSystems(); // Add custom systems. @@ -163,20 +162,19 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(Window* window, std::st CollectionSystemsManager::getInstance()->getUnusedSystemsFromTheme(); if (unusedFolders.size() > 0) { ComponentListRow row; - auto themeCollection = - std::make_shared(mWindow, "CREATE NEW CUSTOM COLLECTION FROM THEME", - Font::get(FONT_SIZE_MEDIUM), 0x777777FF); - auto bracketThemeCollection = std::make_shared(mWindow); + auto themeCollection = std::make_shared( + "CREATE NEW CUSTOM COLLECTION FROM THEME", Font::get(FONT_SIZE_MEDIUM), 0x777777FF); + auto bracketThemeCollection = std::make_shared(); bracketThemeCollection->setImage(":/graphics/arrow.svg"); bracketThemeCollection->setResize( glm::vec2 {0.0f, Font::get(FONT_SIZE_MEDIUM)->getLetterHeight()}); row.addElement(themeCollection, true); row.addElement(bracketThemeCollection, false); row.makeAcceptInputHandler([this, unusedFolders] { - auto ss = new GuiSettings(mWindow, "SELECT THEME FOLDER"); - std::shared_ptr> folderThemes = - std::make_shared>(mWindow, getHelpStyle(), - "SELECT THEME FOLDER", true); + auto ss = new GuiSettings("SELECT THEME FOLDER"); + std::shared_ptr> folderThemes { + std::make_shared>(getHelpStyle(), + "SELECT THEME FOLDER", true)}; // Add custom systems. for (auto it = unusedFolders.cbegin(); it != unusedFolders.cend(); ++it) { ComponentListRow row; @@ -186,7 +184,7 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(Window* window, std::st }; row.makeAcceptInputHandler(createCollectionCall); auto themeFolder = std::make_shared( - mWindow, Utils::String::toUpper(name), Font::get(FONT_SIZE_SMALL), 0x777777FF); + Utils::String::toUpper(name), Font::get(FONT_SIZE_SMALL), 0x777777FF); themeFolder->setSelectable(true); row.addElement(themeFolder, true); ss->addRow(row); @@ -198,35 +196,35 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(Window* window, std::st // Create new custom collection. ComponentListRow row; - auto newCollection = std::make_shared(mWindow, "CREATE NEW CUSTOM COLLECTION", + auto newCollection = std::make_shared("CREATE NEW CUSTOM COLLECTION", Font::get(FONT_SIZE_MEDIUM), 0x777777FF); - auto bracketNewCollection = std::make_shared(mWindow); + auto bracketNewCollection = std::make_shared(); bracketNewCollection->setImage(":/graphics/arrow.svg"); bracketNewCollection->setResize( glm::vec2 {0.0f, Font::get(FONT_SIZE_MEDIUM)->getLetterHeight()}); row.addElement(newCollection, true); row.addElement(bracketNewCollection, false); auto createCollectionCall = [this](const std::string& newVal) { - std::string name = newVal; + std::string name {newVal}; // We need to store the first GUI and remove it, as it'll be deleted // by the actual GUI. - Window* window = mWindow; - GuiComponent* topGui = window->peekGui(); + Window* window {mWindow}; + GuiComponent* topGui {window->peekGui()}; window->removeGui(topGui); createCustomCollection(name); }; if (Settings::getInstance()->getBool("VirtualKeyboard")) { row.makeAcceptInputHandler([this, createCollectionCall] { - mWindow->pushGui(new GuiTextEditKeyboardPopup( - mWindow, getHelpStyle(), "New Collection Name", "", createCollectionCall, false, - "CREATE", "CREATE COLLECTION?")); + mWindow->pushGui(new GuiTextEditKeyboardPopup(getHelpStyle(), "New Collection Name", "", + createCollectionCall, false, "CREATE", + "CREATE COLLECTION?")); }); } else { row.makeAcceptInputHandler([this, createCollectionCall] { - mWindow->pushGui(new GuiTextEditPopup(mWindow, getHelpStyle(), "New Collection Name", - "", createCollectionCall, false, "CREATE", + mWindow->pushGui(new GuiTextEditPopup(getHelpStyle(), "New Collection Name", "", + createCollectionCall, false, "CREATE", "CREATE COLLECTION?")); }); } @@ -235,17 +233,17 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(Window* window, std::st // Delete custom collection. row.elements.clear(); auto deleteCollection = std::make_shared( - mWindow, "DELETE CUSTOM COLLECTION", Font::get(FONT_SIZE_MEDIUM), 0x777777FF); - auto bracketDeleteCollection = std::make_shared(mWindow); + "DELETE CUSTOM COLLECTION", Font::get(FONT_SIZE_MEDIUM), 0x777777FF); + auto bracketDeleteCollection = std::make_shared(); bracketDeleteCollection->setImage(":/graphics/arrow.svg"); bracketDeleteCollection->setResize( glm::vec2 {0.0f, Font::get(FONT_SIZE_MEDIUM)->getLetterHeight()}); row.addElement(deleteCollection, true); row.addElement(bracketDeleteCollection, false); row.makeAcceptInputHandler([this, customSystems] { - auto ss = new GuiSettings(mWindow, "SELECT COLLECTION TO DELETE"); - std::shared_ptr> customCollections = - std::make_shared>(mWindow, getHelpStyle(), "", true); + auto ss = new GuiSettings("SELECT COLLECTION TO DELETE"); + std::shared_ptr> customCollections { + std::make_shared>(getHelpStyle(), "", true)}; for (std::map::const_iterator it = customSystems.cbegin(); it != customSystems.cend(); ++it) { @@ -253,7 +251,7 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(Window* window, std::st std::string name = (*it).first; std::function deleteCollectionCall = [this, name] { mWindow->pushGui(new GuiMsgBox( - mWindow, getHelpStyle(), + getHelpStyle(), "THIS WILL PERMANENTLY\nDELETE THE COLLECTION\n'" + Utils::String::toUpper(name) + "'\n" @@ -297,7 +295,7 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(Window* window, std::st }; row.makeAcceptInputHandler(deleteCollectionCall); auto customCollection = std::make_shared( - mWindow, Utils::String::toUpper(name), Font::get(FONT_SIZE_MEDIUM), 0x777777FF); + Utils::String::toUpper(name), Font::get(FONT_SIZE_MEDIUM), 0x777777FF); customCollection->setSelectable(true); row.addElement(customCollection, true); ss->addRow(row); @@ -313,7 +311,7 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(Window* window, std::st addRow(row); // Sort favorites on top for custom collections. - auto fav_first_custom = std::make_shared(mWindow); + auto fav_first_custom = std::make_shared(); fav_first_custom->setState(Settings::getInstance()->getBool("FavFirstCustom")); addWithLabel("SORT FAVORITES ON TOP FOR CUSTOM COLLECTIONS", fav_first_custom); addSaveFunc([this, fav_first_custom] { @@ -328,7 +326,7 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(Window* window, std::st }); // Display star markings for custom collections. - auto fav_star_custom = std::make_shared(mWindow); + auto fav_star_custom = std::make_shared(); fav_star_custom->setState(Settings::getInstance()->getBool("FavStarCustom")); addWithLabel("DISPLAY STAR MARKINGS FOR CUSTOM COLLECTIONS", fav_star_custom); addSaveFunc([this, fav_star_custom] { @@ -341,7 +339,7 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(Window* window, std::st }); // Group unthemed custom collections. - auto use_custom_collections_system = std::make_shared(mWindow); + auto use_custom_collections_system = std::make_shared(); use_custom_collections_system->setState( Settings::getInstance()->getBool("UseCustomCollectionsSystem")); addWithLabel("GROUP UNTHEMED CUSTOM COLLECTIONS", use_custom_collections_system); @@ -363,7 +361,7 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(Window* window, std::st }); // Show system names in collections. - auto collection_show_system_info = std::make_shared(mWindow); + auto collection_show_system_info = std::make_shared(); collection_show_system_info->setState( Settings::getInstance()->getBool("CollectionShowSystemInfo")); addWithLabel("SHOW SYSTEM NAMES IN COLLECTIONS", collection_show_system_info); @@ -384,10 +382,10 @@ void GuiCollectionSystemsOptions::createCustomCollection(std::string inName) if (CollectionSystemsManager::getInstance()->isEditing()) CollectionSystemsManager::getInstance()->exitEditMode(); - std::string collectionName = - CollectionSystemsManager::getInstance()->getValidNewCollectionName(inName); - SystemData* newCollection = - CollectionSystemsManager::getInstance()->addNewCustomCollection(collectionName); + std::string collectionName { + CollectionSystemsManager::getInstance()->getValidNewCollectionName(inName)}; + SystemData* newCollection { + CollectionSystemsManager::getInstance()->addNewCustomCollection(collectionName)}; CollectionSystemsManager::getInstance()->saveCustomCollection(newCollection); collection_systems_custom->add(collectionName, collectionName, true); @@ -400,7 +398,7 @@ void GuiCollectionSystemsOptions::createCustomCollection(std::string inName) else setNeedsGoToSystem(newCollection); - Window* window = mWindow; + Window* window {mWindow}; while (window->peekGui() && window->peekGui() != ViewController::getInstance()) delete window->peekGui(); CollectionSystemsManager::getInstance()->setEditMode(collectionName); diff --git a/es-app/src/guis/GuiCollectionSystemsOptions.h b/es-app/src/guis/GuiCollectionSystemsOptions.h index 734d99211..61f43ac81 100644 --- a/es-app/src/guis/GuiCollectionSystemsOptions.h +++ b/es-app/src/guis/GuiCollectionSystemsOptions.h @@ -17,7 +17,7 @@ template class OptionListComponent; class GuiCollectionSystemsOptions : public GuiSettings { public: - GuiCollectionSystemsOptions(Window* window, std::string title); + GuiCollectionSystemsOptions(std::string title); private: void createCustomCollection(std::string inName); diff --git a/es-app/src/guis/GuiGamelistFilter.cpp b/es-app/src/guis/GuiGamelistFilter.cpp index a9cdb10be..cc52be154 100644 --- a/es-app/src/guis/GuiGamelistFilter.cpp +++ b/es-app/src/guis/GuiGamelistFilter.cpp @@ -19,11 +19,9 @@ #include "utils/StringUtil.h" #include "views/ViewController.h" -GuiGamelistFilter::GuiGamelistFilter(Window* window, - SystemData* system, +GuiGamelistFilter::GuiGamelistFilter(SystemData* system, std::function filterChangedCallback) - : GuiComponent {window} - , mMenu {window, "FILTER GAMELIST"} + : mMenu {"FILTER GAMELIST"} , mSystem {system} , mFiltersChangedCallback {filterChangedCallback} , mFiltersChanged {false} @@ -51,8 +49,8 @@ void GuiGamelistFilter::initializeMenu() // Show filtered menu. row.elements.clear(); - row.addElement(std::make_shared(mWindow, "RESET ALL FILTERS", - Font::get(FONT_SIZE_MEDIUM), 0x777777FF), + row.addElement(std::make_shared("RESET ALL FILTERS", Font::get(FONT_SIZE_MEDIUM), + 0x777777FF), true); row.makeAcceptInputHandler(std::bind(&GuiGamelistFilter::resetAllFilters, this)); mMenu.addRow(row); @@ -99,22 +97,22 @@ void GuiGamelistFilter::addFiltersToMenu() ComponentListRow row; auto lbl = std::make_shared( - mWindow, Utils::String::toUpper(ViewController::KEYBOARD_CHAR + " GAME NAME"), + Utils::String::toUpper(ViewController::KEYBOARD_CHAR + " GAME NAME"), Font::get(FONT_SIZE_MEDIUM), 0x777777FF); - mTextFilterField = std::make_shared(mWindow, "", Font::get(FONT_SIZE_MEDIUM), - 0x777777FF, ALIGN_RIGHT); + mTextFilterField = + std::make_shared("", Font::get(FONT_SIZE_MEDIUM), 0x777777FF, ALIGN_RIGHT); // Don't show the free text filter entry unless there are any games in the system. if (mSystem->getRootFolder()->getChildren().size() > 0) { row.addElement(lbl, true); row.addElement(mTextFilterField, true); - auto spacer = std::make_shared(mWindow); + auto spacer = std::make_shared(); spacer->setSize(Renderer::getScreenWidth() * 0.005f, 0.0f); row.addElement(spacer, false); - auto bracket = std::make_shared(mWindow); + auto bracket = std::make_shared(); bracket->setImage(":/graphics/arrow.svg"); bracket->setResize(glm::vec2 {0.0f, lbl->getFont()->getLetterHeight()}); row.addElement(bracket, false); @@ -130,14 +128,14 @@ void GuiGamelistFilter::addFiltersToMenu() if (Settings::getInstance()->getBool("VirtualKeyboard")) { row.makeAcceptInputHandler([this, updateVal] { - mWindow->pushGui(new GuiTextEditKeyboardPopup(mWindow, getHelpStyle(), "GAME NAME", + mWindow->pushGui(new GuiTextEditKeyboardPopup(getHelpStyle(), "GAME NAME", mTextFilterField->getValue(), updateVal, false, "OK", "APPLY CHANGES?")); }); } else { row.makeAcceptInputHandler([this, updateVal] { - mWindow->pushGui(new GuiTextEditPopup(mWindow, getHelpStyle(), "GAME NAME", + mWindow->pushGui(new GuiTextEditPopup(getHelpStyle(), "GAME NAME", mTextFilterField->getValue(), updateVal, false, "OK", "APPLY CHANGES?")); }); @@ -178,10 +176,10 @@ void GuiGamelistFilter::addFiltersToMenu() // For bool values, make the selection exclusive so that both True and False can't be // selected at the same time. This should be changed to a SwitchComponent at some point. if (exclusiveSelect) - optionList = std::make_shared>(mWindow, getHelpStyle(), + optionList = std::make_shared>(getHelpStyle(), menuLabel, true, true); else - optionList = std::make_shared>(mWindow, getHelpStyle(), + optionList = std::make_shared>(getHelpStyle(), menuLabel, true, false); // Still display fields that can't be filtered in the menu, but notify the user and set diff --git a/es-app/src/guis/GuiGamelistFilter.h b/es-app/src/guis/GuiGamelistFilter.h index 2a0c4d48c..eb21fd69f 100644 --- a/es-app/src/guis/GuiGamelistFilter.h +++ b/es-app/src/guis/GuiGamelistFilter.h @@ -21,10 +21,7 @@ class SystemData; class GuiGamelistFilter : public GuiComponent { public: - GuiGamelistFilter(Window* window, - SystemData* system, - std::function filtersChangedCallback); - + GuiGamelistFilter(SystemData* system, std::function filtersChangedCallback); ~GuiGamelistFilter() { mFilterOptions.clear(); } bool input(InputConfig* config, Input input) override; diff --git a/es-app/src/guis/GuiGamelistOptions.cpp b/es-app/src/guis/GuiGamelistOptions.cpp index 5fb4eb2eb..6cb7c9904 100644 --- a/es-app/src/guis/GuiGamelistOptions.cpp +++ b/es-app/src/guis/GuiGamelistOptions.cpp @@ -24,9 +24,8 @@ #include "scrapers/Scraper.h" #include "views/ViewController.h" -GuiGamelistOptions::GuiGamelistOptions(Window* window, SystemData* system) - : GuiComponent {window} - , mMenu {window, "OPTIONS"} +GuiGamelistOptions::GuiGamelistOptions(SystemData* system) + : mMenu {"OPTIONS"} , mSystem {system} , mFiltersChanged {false} , mCancelled {false} @@ -95,8 +94,7 @@ GuiGamelistOptions::GuiGamelistOptions(Window* window, SystemData* system) mCurrentFirstCharacter = Utils::String::getFirstCharacter(file->getSortName()); } - mJumpToLetterList = - std::make_shared(mWindow, getHelpStyle(), "JUMP TO...", false); + mJumpToLetterList = std::make_shared(getHelpStyle(), "JUMP TO...", false); // Enable key repeat so that the left or right button can be held to cycle through // the letters. @@ -115,7 +113,7 @@ GuiGamelistOptions::GuiGamelistOptions(Window* window, SystemData* system) // Add the sorting entry, unless this is the grouped custom collections list. if (!mIsCustomCollectionGroup) { // Sort list by selected sort type (persistent throughout the program session). - mListSort = std::make_shared(mWindow, getHelpStyle(), "SORT GAMES BY", false); + mListSort = std::make_shared(getHelpStyle(), "SORT GAMES BY", false); FileData* root; if (mIsCustomCollection) root = getGamelist()->getCursor()->getSystem()->getRootFolder(); @@ -151,10 +149,10 @@ GuiGamelistOptions::GuiGamelistOptions(Window* window, SystemData* system) if (!mIsCustomCollectionGroup && system->getRootFolder()->getChildren().size() > 0) { if (system->getName() != "recent" && Settings::getInstance()->getBool("GamelistFilters")) { row.elements.clear(); - row.addElement(std::make_shared(mWindow, "FILTER GAMELIST", + row.addElement(std::make_shared("FILTER GAMELIST", Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true); - row.addElement(makeArrow(mWindow), false); + row.addElement(makeArrow(), false); row.makeAcceptInputHandler(std::bind(&GuiGamelistOptions::openGamelistFilter, this)); mMenu.addRow(row); } @@ -164,7 +162,7 @@ GuiGamelistOptions::GuiGamelistOptions(Window* window, SystemData* system) mSystem->getRootFolder()->getChildren().size() == 0 && !mIsCustomCollectionGroup && !mIsCustomCollection) { row.elements.clear(); - row.addElement(std::make_shared(mWindow, "THIS SYSTEM HAS NO GAMES", + row.addElement(std::make_shared("THIS SYSTEM HAS NO GAMES", Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true); mMenu.addRow(row); @@ -180,8 +178,7 @@ GuiGamelistOptions::GuiGamelistOptions(Window* window, SystemData* system) (mIsCustomCollection || mIsCustomCollectionGroup)) { if (CollectionSystemsManager::getInstance()->getEditingCollection() != customSystem) { row.elements.clear(); - row.addElement(std::make_shared(mWindow, - "ADD/REMOVE GAMES TO THIS COLLECTION", + row.addElement(std::make_shared("ADD/REMOVE GAMES TO THIS COLLECTION", Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true); row.makeAcceptInputHandler(std::bind(&GuiGamelistOptions::startEditMode, this)); @@ -194,7 +191,6 @@ GuiGamelistOptions::GuiGamelistOptions(Window* window, SystemData* system) row.elements.clear(); row.addElement( std::make_shared( - mWindow, "FINISH EDITING '" + Utils::String::toUpper( CollectionSystemsManager::getInstance()->getEditingCollection()) + @@ -209,10 +205,10 @@ GuiGamelistOptions::GuiGamelistOptions(Window* window, SystemData* system) if (UIModeController::getInstance()->isUIModeFull() && !mFromPlaceholder && !(mSystem->isCollection() && file->getType() == FOLDER)) { row.elements.clear(); - row.addElement(std::make_shared(mWindow, "EDIT THIS FOLDER'S METADATA", + row.addElement(std::make_shared("EDIT THIS FOLDER'S METADATA", Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true); - row.addElement(makeArrow(mWindow), false); + row.addElement(makeArrow(), false); row.makeAcceptInputHandler(std::bind(&GuiGamelistOptions::openMetaDataEd, this)); mMenu.addRow(row); } @@ -221,10 +217,10 @@ GuiGamelistOptions::GuiGamelistOptions(Window* window, SystemData* system) if (UIModeController::getInstance()->isUIModeFull() && !mFromPlaceholder && !(mSystem->isCollection() && file->getType() == FOLDER)) { row.elements.clear(); - row.addElement(std::make_shared(mWindow, "EDIT THIS GAME'S METADATA", + row.addElement(std::make_shared("EDIT THIS GAME'S METADATA", Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true); - row.addElement(makeArrow(mWindow), false); + row.addElement(makeArrow(), false); row.makeAcceptInputHandler(std::bind(&GuiGamelistOptions::openMetaDataEd, this)); mMenu.addRow(row); } @@ -323,10 +319,9 @@ void GuiGamelistOptions::openGamelistFilter() }; if (mIsCustomCollection) - ggf = new GuiGamelistFilter(mWindow, getGamelist()->getCursor()->getSystem(), - filtersChangedFunc); + ggf = new GuiGamelistFilter(getGamelist()->getCursor()->getSystem(), filtersChangedFunc); else - ggf = new GuiGamelistFilter(mWindow, mSystem, filtersChangedFunc); + ggf = new GuiGamelistFilter(mSystem, filtersChangedFunc); mWindow->pushGui(ggf); } @@ -452,7 +447,7 @@ void GuiGamelistOptions::openMetaDataEd() if (file->getType() == FOLDER) { mWindow->pushGui(new GuiMetaDataEd( - mWindow, &file->metadata, file->metadata.getMDD(FOLDER_METADATA), p, + &file->metadata, file->metadata.getMDD(FOLDER_METADATA), p, std::bind(&GamelistView::onFileChanged, ViewController::getInstance()->getGamelistView(file->getSystem()).get(), file, true), @@ -460,7 +455,7 @@ void GuiGamelistOptions::openMetaDataEd() } else { mWindow->pushGui(new GuiMetaDataEd( - mWindow, &file->metadata, file->metadata.getMDD(GAME_METADATA), p, + &file->metadata, file->metadata.getMDD(GAME_METADATA), p, std::bind(&GamelistView::onFileChanged, ViewController::getInstance()->getGamelistView(file->getSystem()).get(), file, true), @@ -470,7 +465,7 @@ void GuiGamelistOptions::openMetaDataEd() void GuiGamelistOptions::jumpToLetter() { - char letter = mJumpToLetterList->getSelected().front(); + char letter {mJumpToLetterList->getSelected().front()}; // Get the gamelist. const std::vector& files = diff --git a/es-app/src/guis/GuiGamelistOptions.h b/es-app/src/guis/GuiGamelistOptions.h index 3fb6b167a..45cb54fba 100644 --- a/es-app/src/guis/GuiGamelistOptions.h +++ b/es-app/src/guis/GuiGamelistOptions.h @@ -25,7 +25,7 @@ class SystemData; class GuiGamelistOptions : public GuiComponent { public: - GuiGamelistOptions(Window* window, SystemData* system); + GuiGamelistOptions(SystemData* system); virtual ~GuiGamelistOptions(); bool input(InputConfig* config, Input input) override; diff --git a/es-app/src/guis/GuiLaunchScreen.cpp b/es-app/src/guis/GuiLaunchScreen.cpp index c5505ca80..a661ab76d 100644 --- a/es-app/src/guis/GuiLaunchScreen.cpp +++ b/es-app/src/guis/GuiLaunchScreen.cpp @@ -15,9 +15,7 @@ #include "utils/StringUtil.h" GuiLaunchScreen::GuiLaunchScreen() - : GuiComponent {Window::getInstance()} - , mWindow {Window::getInstance()} - , mBackground {mWindow, ":/graphics/frame.svg"} + : mBackground {":/graphics/frame.svg"} , mGrid {nullptr} , mMarquee {nullptr} { @@ -33,7 +31,7 @@ GuiLaunchScreen::~GuiLaunchScreen() void GuiLaunchScreen::displayLaunchScreen(FileData* game) { - mGrid = new ComponentGrid(mWindow, glm::ivec2 {3, 8}); + mGrid = new ComponentGrid(glm::ivec2 {3, 8}); addChild(mGrid); mImagePath = game->getMarqueePath(); @@ -42,7 +40,7 @@ void GuiLaunchScreen::displayLaunchScreen(FileData* game) // which would lead to the wrong size when using the image here. if (mImagePath != "") { TextureResource::manualUnload(mImagePath, false); - mMarquee = new ImageComponent(mWindow); + mMarquee = new ImageComponent; } mScaleUp = 0.5f; @@ -50,52 +48,52 @@ void GuiLaunchScreen::displayLaunchScreen(FileData* game) const float gameNameFontSize = 0.073f; // Spacer row. - mGrid->setEntry(std::make_shared(mWindow), glm::ivec2 {1, 0}, false, false, + mGrid->setEntry(std::make_shared(), glm::ivec2 {1, 0}, false, false, glm::ivec2 {1, 1}); // Title. mTitle = std::make_shared( - mWindow, "LAUNCHING GAME", + "LAUNCHING GAME", Font::get(static_cast( titleFontSize * std::min(Renderer::getScreenHeight(), Renderer::getScreenWidth()))), 0x666666FF, ALIGN_CENTER); mGrid->setEntry(mTitle, glm::ivec2 {1, 1}, false, true, glm::ivec2 {1, 1}); // Spacer row. - mGrid->setEntry(std::make_shared(mWindow), glm::ivec2 {1, 2}, false, false, + mGrid->setEntry(std::make_shared(), glm::ivec2 {1, 2}, false, false, glm::ivec2 {1, 1}); // Row for the marquee. - mGrid->setEntry(std::make_shared(mWindow), glm::ivec2 {1, 3}, false, false, + mGrid->setEntry(std::make_shared(), glm::ivec2 {1, 3}, false, false, glm::ivec2 {1, 1}); // Spacer row. - mGrid->setEntry(std::make_shared(mWindow), glm::ivec2 {1, 4}, false, false, + mGrid->setEntry(std::make_shared(), glm::ivec2 {1, 4}, false, false, glm::ivec2 {1, 1}); // Game name. mGameName = std::make_shared( - mWindow, "GAME NAME", + "GAME NAME", Font::get(static_cast( gameNameFontSize * std::min(Renderer::getScreenHeight(), Renderer::getScreenWidth()))), 0x444444FF, ALIGN_CENTER); mGrid->setEntry(mGameName, glm::ivec2 {1, 5}, false, true, glm::ivec2 {1, 1}); // System name. - mSystemName = std::make_shared( - mWindow, "SYSTEM NAME", Font::get(FONT_SIZE_MEDIUM), 0x666666FF, ALIGN_CENTER); + mSystemName = std::make_shared("SYSTEM NAME", Font::get(FONT_SIZE_MEDIUM), + 0x666666FF, ALIGN_CENTER); mGrid->setEntry(mSystemName, glm::ivec2 {1, 6}, false, true, glm::ivec2 {1, 1}); // Spacer row. - mGrid->setEntry(std::make_shared(mWindow), glm::ivec2 {1, 7}, false, false, + mGrid->setEntry(std::make_shared(), glm::ivec2 {1, 7}, false, false, glm::ivec2 {1, 1}); // Left spacer. - mGrid->setEntry(std::make_shared(mWindow), glm::ivec2 {0, 0}, false, false, + mGrid->setEntry(std::make_shared(), glm::ivec2 {0, 0}, false, false, glm::ivec2 {1, 8}); // Right spacer. - mGrid->setEntry(std::make_shared(mWindow), glm::ivec2 {2, 0}, false, false, + mGrid->setEntry(std::make_shared(), glm::ivec2 {2, 0}, false, false, glm::ivec2 {1, 8}); // Adjust the width depending on the aspect ratio of the screen, to make the screen look diff --git a/es-app/src/guis/GuiLaunchScreen.h b/es-app/src/guis/GuiLaunchScreen.h index 00e5e2272..abda4f32a 100644 --- a/es-app/src/guis/GuiLaunchScreen.h +++ b/es-app/src/guis/GuiLaunchScreen.h @@ -33,7 +33,6 @@ public: void render(const glm::mat4& parentTrans) override; private: - Window* mWindow; NinePatchComponent mBackground; ComponentGrid* mGrid; diff --git a/es-app/src/guis/GuiMediaViewerOptions.cpp b/es-app/src/guis/GuiMediaViewerOptions.cpp index ff4bc32e4..0c0b9878f 100644 --- a/es-app/src/guis/GuiMediaViewerOptions.cpp +++ b/es-app/src/guis/GuiMediaViewerOptions.cpp @@ -12,11 +12,11 @@ #include "Settings.h" #include "components/SwitchComponent.h" -GuiMediaViewerOptions::GuiMediaViewerOptions(Window* window, const std::string& title) - : GuiSettings {window, title} +GuiMediaViewerOptions::GuiMediaViewerOptions(const std::string& title) + : GuiSettings {title} { // Keep videos running when viewing images. - auto keep_video_running = std::make_shared(mWindow); + auto keep_video_running = std::make_shared(); keep_video_running->setState(Settings::getInstance()->getBool("MediaViewerKeepVideoRunning")); addWithLabel("KEEP VIDEOS RUNNING WHEN VIEWING IMAGES", keep_video_running); addSaveFunc([keep_video_running, this] { @@ -29,7 +29,7 @@ GuiMediaViewerOptions::GuiMediaViewerOptions(Window* window, const std::string& }); // Stretch videos to screen resolution. - auto stretch_videos = std::make_shared(mWindow); + auto stretch_videos = std::make_shared(); stretch_videos->setState(Settings::getInstance()->getBool("MediaViewerStretchVideos")); addWithLabel("STRETCH VIDEOS TO SCREEN RESOLUTION", stretch_videos); addSaveFunc([stretch_videos, this] { @@ -43,7 +43,7 @@ GuiMediaViewerOptions::GuiMediaViewerOptions(Window* window, const std::string& #if defined(USE_OPENGL_21) // Render scanlines for videos using a shader. - auto video_scanlines = std::make_shared(mWindow); + auto video_scanlines = std::make_shared(); video_scanlines->setState(Settings::getInstance()->getBool("MediaViewerVideoScanlines")); addWithLabel("RENDER SCANLINES FOR VIDEOS", video_scanlines); addSaveFunc([video_scanlines, this] { @@ -56,7 +56,7 @@ GuiMediaViewerOptions::GuiMediaViewerOptions(Window* window, const std::string& }); // Render blur for videos using a shader. - auto video_blur = std::make_shared(mWindow); + auto video_blur = std::make_shared(); video_blur->setState(Settings::getInstance()->getBool("MediaViewerVideoBlur")); addWithLabel("RENDER BLUR FOR VIDEOS", video_blur); addSaveFunc([video_blur, this] { @@ -67,7 +67,7 @@ GuiMediaViewerOptions::GuiMediaViewerOptions(Window* window, const std::string& }); // Render scanlines for screenshots and title screens using a shader. - auto screenshot_scanlines = std::make_shared(mWindow); + auto screenshot_scanlines = std::make_shared(); screenshot_scanlines->setState( Settings::getInstance()->getBool("MediaViewerScreenshotScanlines")); addWithLabel("RENDER SCANLINES FOR SCREENSHOTS AND TITLES", screenshot_scanlines); diff --git a/es-app/src/guis/GuiMediaViewerOptions.h b/es-app/src/guis/GuiMediaViewerOptions.h index 5b5b0a834..686c6ea12 100644 --- a/es-app/src/guis/GuiMediaViewerOptions.h +++ b/es-app/src/guis/GuiMediaViewerOptions.h @@ -15,7 +15,7 @@ class GuiMediaViewerOptions : public GuiSettings { public: - GuiMediaViewerOptions(Window* window, const std::string& title); + GuiMediaViewerOptions(const std::string& title); }; #endif // ES_APP_GUIS_GUI_MEDIA_VIEWER_OPTIONS_H diff --git a/es-app/src/guis/GuiMenu.cpp b/es-app/src/guis/GuiMenu.cpp index 52836bd22..3d83700b6 100644 --- a/es-app/src/guis/GuiMenu.cpp +++ b/es-app/src/guis/GuiMenu.cpp @@ -39,10 +39,8 @@ #include #include -GuiMenu::GuiMenu(Window* window) - : GuiComponent {window} - , mMenu {window, "MAIN MENU"} - , mVersion {window} +GuiMenu::GuiMenu() + : mMenu {"MAIN MENU"} { bool isFullUI = UIModeController::getInstance()->isUIModeFull(); @@ -94,16 +92,16 @@ GuiMenu::~GuiMenu() void GuiMenu::openScraperOptions() { // Open the scraper menu. - mWindow->pushGui(new GuiScraperMenu(mWindow, "SCRAPER")); + mWindow->pushGui(new GuiScraperMenu("SCRAPER")); } void GuiMenu::openUIOptions() { - auto s = new GuiSettings(mWindow, "UI SETTINGS"); + auto s = new GuiSettings("UI SETTINGS"); // Optionally start in selected system/gamelist. auto startupSystem = std::make_shared>( - mWindow, getHelpStyle(), "GAMELIST ON STARTUP", false); + getHelpStyle(), "GAMELIST ON STARTUP", false); startupSystem->add("NONE", "", Settings::getInstance()->getString("StartupSystem") == ""); for (auto it = SystemData::sSystemVector.cbegin(); // Line break. it != SystemData::sSystemVector.cend(); ++it) { @@ -130,7 +128,7 @@ void GuiMenu::openUIOptions() // Gamelist view style. auto gamelist_view_style = std::make_shared>( - mWindow, getHelpStyle(), "GAMELIST VIEW STYLE", false); + getHelpStyle(), "GAMELIST VIEW STYLE", false); std::string selectedViewStyle = Settings::getInstance()->getString("GamelistViewStyle"); gamelist_view_style->add("automatic", "automatic", selectedViewStyle == "automatic"); gamelist_view_style->add("basic", "basic", selectedViewStyle == "basic"); @@ -154,7 +152,7 @@ void GuiMenu::openUIOptions() // Transition style. auto transition_style = std::make_shared>( - mWindow, getHelpStyle(), "TRANSITION STYLE", false); + getHelpStyle(), "TRANSITION STYLE", false); std::vector transitions; transitions.push_back("slide"); transitions.push_back("fade"); @@ -178,8 +176,8 @@ void GuiMenu::openUIOptions() themeSets.find(Settings::getInstance()->getString("ThemeSet")); if (selectedSet == themeSets.cend()) selectedSet = themeSets.cbegin(); - auto theme_set = std::make_shared>(mWindow, getHelpStyle(), - "THEME SET", false); + auto theme_set = + std::make_shared>(getHelpStyle(), "THEME SET", false); for (auto it = themeSets.cbegin(); it != themeSets.cend(); ++it) { // If required, abbreviate the theme set name so it doesn't overlap the setting name. float maxNameLength = mSize.x * 0.62f; @@ -208,8 +206,8 @@ void GuiMenu::openUIOptions() } // UI mode. - auto ui_mode = std::make_shared>(mWindow, getHelpStyle(), - "UI MODE", false); + auto ui_mode = + std::make_shared>(getHelpStyle(), "UI MODE", false); std::vector uiModes; uiModes.push_back("full"); uiModes.push_back("kiosk"); @@ -248,7 +246,7 @@ void GuiMenu::openUIOptions() msg += UIModeController::getInstance()->getFormattedPassKeyStr() + "\n\n"; msg += "DO YOU WANT TO PROCEED?"; mWindow->pushGui(new GuiMsgBox( - mWindow, this->getHelpStyle(), msg, "YES", + this->getHelpStyle(), msg, "YES", [this, selectedMode] { LOG(LogDebug) << "GuiMenu::openUISettings(): Setting UI mode to '" << selectedMode << "'."; @@ -296,7 +294,7 @@ void GuiMenu::openUIOptions() // Default gamelist sort order. std::string sortOrder; auto default_sort_order = std::make_shared>( - mWindow, getHelpStyle(), "DEFAULT SORT ORDER", false); + getHelpStyle(), "DEFAULT SORT ORDER", false); // Exclude the System sort options. unsigned int numSortTypes = static_cast(FileSorts::SortTypes.size() - 2); for (unsigned int i = 0; i < numSortTypes; ++i) { @@ -331,7 +329,7 @@ void GuiMenu::openUIOptions() // Open menu effect. auto menu_opening_effect = std::make_shared>( - mWindow, getHelpStyle(), "MENU OPENING EFFECT", false); + getHelpStyle(), "MENU OPENING EFFECT", false); std::string selectedMenuEffect = Settings::getInstance()->getString("MenuOpeningEffect"); menu_opening_effect->add("SCALE-UP", "scale-up", selectedMenuEffect == "scale-up"); menu_opening_effect->add("NONE", "none", selectedMenuEffect == "none"); @@ -351,7 +349,7 @@ void GuiMenu::openUIOptions() // Launch screen duration. auto launch_screen_duration = std::make_shared>( - mWindow, getHelpStyle(), "LAUNCH SCREEN DURATION", false); + getHelpStyle(), "LAUNCH SCREEN DURATION", false); std::string selectedDuration = Settings::getInstance()->getString("LaunchScreenDuration"); launch_screen_duration->add("NORMAL", "normal", selectedDuration == "normal"); launch_screen_duration->add("BRIEF", "brief", selectedDuration == "brief"); @@ -374,28 +372,27 @@ void GuiMenu::openUIOptions() // Media viewer. ComponentListRow media_viewer_row; media_viewer_row.elements.clear(); - media_viewer_row.addElement(std::make_shared(mWindow, "MEDIA VIEWER SETTINGS", + media_viewer_row.addElement(std::make_shared("MEDIA VIEWER SETTINGS", Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true); - media_viewer_row.addElement(makeArrow(mWindow), false); + media_viewer_row.addElement(makeArrow(), false); media_viewer_row.makeAcceptInputHandler(std::bind(&GuiMenu::openMediaViewerOptions, this)); s->addRow(media_viewer_row); // Screensaver. ComponentListRow screensaver_row; screensaver_row.elements.clear(); - screensaver_row.addElement(std::make_shared(mWindow, "SCREENSAVER SETTINGS", - Font::get(FONT_SIZE_MEDIUM), - 0x777777FF), + screensaver_row.addElement(std::make_shared( + "SCREENSAVER SETTINGS", Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true); - screensaver_row.addElement(makeArrow(mWindow), false); + screensaver_row.addElement(makeArrow(), false); screensaver_row.makeAcceptInputHandler(std::bind(&GuiMenu::openScreensaverOptions, this)); s->addRow(screensaver_row); #if defined(USE_OPENGL_21) // Blur background when the menu is open. - auto menu_blur_background = std::make_shared(mWindow); + auto menu_blur_background = std::make_shared(); menu_blur_background->setState(Settings::getInstance()->getBool("MenuBlurBackground")); s->addWithLabel("BLUR BACKGROUND WHEN MENU IS OPEN", menu_blur_background); s->addSaveFunc([menu_blur_background, s] { @@ -410,7 +407,7 @@ void GuiMenu::openUIOptions() #endif // Display pillarboxes (and letterboxes) for videos in the gamelists. - auto gamelist_video_pillarbox = std::make_shared(mWindow); + auto gamelist_video_pillarbox = std::make_shared(); gamelist_video_pillarbox->setState(Settings::getInstance()->getBool("GamelistVideoPillarbox")); s->addWithLabel("DISPLAY PILLARBOXES FOR GAMELIST VIDEOS", gamelist_video_pillarbox); s->addSaveFunc([gamelist_video_pillarbox, s] { @@ -424,7 +421,7 @@ void GuiMenu::openUIOptions() #if defined(USE_OPENGL_21) // Render scanlines for videos in the gamelists. - auto gamelist_video_scanlines = std::make_shared(mWindow); + auto gamelist_video_scanlines = std::make_shared(); gamelist_video_scanlines->setState(Settings::getInstance()->getBool("GamelistVideoScanlines")); s->addWithLabel("RENDER SCANLINES FOR GAMELIST VIDEOS", gamelist_video_scanlines); s->addSaveFunc([gamelist_video_scanlines, s] { @@ -438,7 +435,7 @@ void GuiMenu::openUIOptions() #endif // Sort folders on top of the gamelists. - auto folders_on_top = std::make_shared(mWindow); + auto folders_on_top = std::make_shared(); folders_on_top->setState(Settings::getInstance()->getBool("FoldersOnTop")); s->addWithLabel("SORT FOLDERS ON TOP OF GAMELISTS", folders_on_top); s->addSaveFunc([folders_on_top, s] { @@ -451,7 +448,7 @@ void GuiMenu::openUIOptions() }); // Sort favorites on top of non-favorites in the gamelists. - auto favorites_first = std::make_shared(mWindow); + auto favorites_first = std::make_shared(); favorites_first->setState(Settings::getInstance()->getBool("FavoritesFirst")); s->addWithLabel("SORT FAVORITE GAMES ABOVE NON-FAVORITES", favorites_first); s->addSaveFunc([favorites_first, s] { @@ -465,7 +462,7 @@ void GuiMenu::openUIOptions() }); // Enable gamelist star markings for favorite games. - auto favorites_star = std::make_shared(mWindow); + auto favorites_star = std::make_shared(); favorites_star->setState(Settings::getInstance()->getBool("FavoritesStar")); s->addWithLabel("ADD STAR MARKINGS TO FAVORITE GAMES", favorites_star); s->addSaveFunc([favorites_star, s] { @@ -478,7 +475,7 @@ void GuiMenu::openUIOptions() }); // Use ASCII for special characters in the gamelist view instead of the Font Awesome symbols. - auto special_chars_ascii = std::make_shared(mWindow); + auto special_chars_ascii = std::make_shared(); special_chars_ascii->setState(Settings::getInstance()->getBool("SpecialCharsASCII")); s->addWithLabel("USE PLAIN ASCII FOR SPECIAL GAMELIST CHARACTERS", special_chars_ascii); s->addSaveFunc([special_chars_ascii, s] { @@ -492,7 +489,7 @@ void GuiMenu::openUIOptions() }); // Enable quick list scrolling overlay. - auto list_scroll_overlay = std::make_shared(mWindow); + auto list_scroll_overlay = std::make_shared(); list_scroll_overlay->setState(Settings::getInstance()->getBool("ListScrollOverlay")); s->addWithLabel("ENABLE QUICK LIST SCROLLING OVERLAY", list_scroll_overlay); s->addSaveFunc([list_scroll_overlay, s] { @@ -504,7 +501,7 @@ void GuiMenu::openUIOptions() }); // Enable virtual (on-screen) keyboard. - auto virtual_keyboard = std::make_shared(mWindow); + auto virtual_keyboard = std::make_shared(); virtual_keyboard->setState(Settings::getInstance()->getBool("VirtualKeyboard")); s->addWithLabel("ENABLE VIRTUAL KEYBOARD", virtual_keyboard); s->addSaveFunc([virtual_keyboard, s] { @@ -516,7 +513,7 @@ void GuiMenu::openUIOptions() }); // Enable menu scroll indicators. - auto scroll_indicators = std::make_shared(mWindow); + auto scroll_indicators = std::make_shared(); scroll_indicators->setState(Settings::getInstance()->getBool("ScrollIndicators")); s->addWithLabel("ENABLE MENU SCROLL INDICATORS", scroll_indicators); s->addSaveFunc([scroll_indicators, s] { @@ -528,7 +525,7 @@ void GuiMenu::openUIOptions() }); // Enable the 'Y' button for tagging games as favorites. - auto favorites_add_button = std::make_shared(mWindow); + auto favorites_add_button = std::make_shared(); favorites_add_button->setState(Settings::getInstance()->getBool("FavoritesAddButton")); s->addWithLabel("ENABLE TOGGLE FAVORITES BUTTON", favorites_add_button); s->addSaveFunc([favorites_add_button, s] { @@ -541,7 +538,7 @@ void GuiMenu::openUIOptions() }); // Enable the thumbstick click buttons for jumping to a random system or game. - auto random_add_button = std::make_shared(mWindow); + auto random_add_button = std::make_shared(); random_add_button->setState(Settings::getInstance()->getBool("RandomAddButton")); s->addWithLabel("ENABLE RANDOM SYSTEM OR GAME BUTTON", random_add_button); s->addSaveFunc([random_add_button, s] { @@ -552,7 +549,7 @@ void GuiMenu::openUIOptions() }); // Gamelist filters. - auto gamelist_filters = std::make_shared(mWindow); + auto gamelist_filters = std::make_shared(); gamelist_filters->setState(Settings::getInstance()->getBool("GamelistFilters")); s->addWithLabel("ENABLE GAMELIST FILTERS", gamelist_filters); s->addSaveFunc([gamelist_filters, s] { @@ -564,7 +561,7 @@ void GuiMenu::openUIOptions() }); // Quick system select (navigate left/right in gamelist view). - auto quick_system_select = std::make_shared(mWindow); + auto quick_system_select = std::make_shared(); quick_system_select->setState(Settings::getInstance()->getBool("QuickSystemSelect")); s->addWithLabel("ENABLE QUICK SYSTEM SELECT", quick_system_select); s->addSaveFunc([quick_system_select, s] { @@ -576,7 +573,7 @@ void GuiMenu::openUIOptions() }); // On-screen help prompts. - auto show_help_prompts = std::make_shared(mWindow); + auto show_help_prompts = std::make_shared(); show_help_prompts->setState(Settings::getInstance()->getBool("ShowHelpPrompts")); s->addWithLabel("DISPLAY ON-SCREEN HELP", show_help_prompts); s->addSaveFunc([show_help_prompts, s] { @@ -587,7 +584,7 @@ void GuiMenu::openUIOptions() }); // Play videos immediately (overrides theme setting). - auto play_videos_immediately = std::make_shared(mWindow); + auto play_videos_immediately = std::make_shared(); play_videos_immediately->setState(Settings::getInstance()->getBool("PlayVideosImmediately")); s->addWithLabel("PLAY VIDEOS IMMEDIATELY (OVERRIDE THEME)", play_videos_immediately); s->addSaveFunc([play_videos_immediately, s] { @@ -605,7 +602,7 @@ void GuiMenu::openUIOptions() void GuiMenu::openSoundOptions() { - auto s = new GuiSettings(mWindow, "SOUND SETTINGS"); + auto s = new GuiSettings("SOUND SETTINGS"); // TODO: Hide the volume slider on macOS and BSD Unix until the volume control logic has been // implemented for these operating systems. @@ -618,7 +615,7 @@ void GuiMenu::openSoundOptions() VolumeControl volumeControl; int currentVolume = volumeControl.getVolume(); - auto systemVolume = std::make_shared(mWindow, 0.f, 100.f, 1.f, "%"); + auto systemVolume = std::make_shared(0.f, 100.f, 1.f, "%"); systemVolume->setValue(static_cast(currentVolume)); s->addWithLabel("SYSTEM VOLUME", systemVolume); s->addSaveFunc([systemVolume, currentVolume] { @@ -631,7 +628,7 @@ void GuiMenu::openSoundOptions() #endif // Volume for navigation sounds. - auto sound_volume_navigation = std::make_shared(mWindow, 0.f, 100.f, 1.f, "%"); + auto sound_volume_navigation = std::make_shared(0.f, 100.f, 1.f, "%"); sound_volume_navigation->setValue( static_cast(Settings::getInstance()->getInt("SoundVolumeNavigation"))); s->addWithLabel("NAVIGATION SOUNDS VOLUME", sound_volume_navigation); @@ -645,7 +642,7 @@ void GuiMenu::openSoundOptions() }); // Volume for videos. - auto sound_volume_videos = std::make_shared(mWindow, 0.f, 100.f, 1.f, "%"); + auto sound_volume_videos = std::make_shared(0.f, 100.f, 1.f, "%"); sound_volume_videos->setValue( static_cast(Settings::getInstance()->getInt("SoundVolumeVideos"))); s->addWithLabel("VIDEO PLAYER VOLUME", sound_volume_videos); @@ -660,7 +657,7 @@ void GuiMenu::openSoundOptions() if (UIModeController::getInstance()->isUIModeFull()) { // Play audio for gamelist videos. - auto gamelist_video_audio = std::make_shared(mWindow); + auto gamelist_video_audio = std::make_shared(); gamelist_video_audio->setState(Settings::getInstance()->getBool("GamelistVideoAudio")); s->addWithLabel("PLAY AUDIO FOR VIDEOS IN THE GAMELIST VIEW", gamelist_video_audio); s->addSaveFunc([gamelist_video_audio, s] { @@ -673,7 +670,7 @@ void GuiMenu::openSoundOptions() }); // Play audio for media viewer videos. - auto media_viewer_video_audio = std::make_shared(mWindow); + auto media_viewer_video_audio = std::make_shared(); media_viewer_video_audio->setState( Settings::getInstance()->getBool("MediaViewerVideoAudio")); s->addWithLabel("PLAY AUDIO FOR MEDIA VIEWER VIDEOS", media_viewer_video_audio); @@ -687,7 +684,7 @@ void GuiMenu::openSoundOptions() }); // Play audio for screensaver videos. - auto screensaver_video_audio = std::make_shared(mWindow); + auto screensaver_video_audio = std::make_shared(); screensaver_video_audio->setState( Settings::getInstance()->getBool("ScreensaverVideoAudio")); s->addWithLabel("PLAY AUDIO FOR SCREENSAVER VIDEOS", screensaver_video_audio); @@ -701,7 +698,7 @@ void GuiMenu::openSoundOptions() }); // Navigation sounds. - auto navigation_sounds = std::make_shared(mWindow); + auto navigation_sounds = std::make_shared(); navigation_sounds->setState(Settings::getInstance()->getBool("NavigationSounds")); s->addWithLabel("ENABLE NAVIGATION SOUNDS", navigation_sounds); s->addSaveFunc([navigation_sounds, s] { @@ -719,11 +716,11 @@ void GuiMenu::openSoundOptions() void GuiMenu::openInputDeviceOptions() { - auto s = new GuiSettings(mWindow, "INPUT DEVICE SETTINGS"); + auto s = new GuiSettings("INPUT DEVICE SETTINGS"); // Controller type. auto input_controller_type = std::make_shared>( - mWindow, getHelpStyle(), "CONTROLLER TYPE", false); + getHelpStyle(), "CONTROLLER TYPE", false); std::string selectedPlayer = Settings::getInstance()->getString("InputControllerType"); input_controller_type->add("XBOX", "xbox", selectedPlayer == "xbox"); input_controller_type->add("XBOX 360", "xbox360", selectedPlayer == "xbox360"); @@ -746,7 +743,7 @@ void GuiMenu::openInputDeviceOptions() }); // Whether to only accept input from the first controller. - auto input_only_first_controller = std::make_shared(mWindow); + auto input_only_first_controller = std::make_shared(); input_only_first_controller->setState( Settings::getInstance()->getBool("InputOnlyFirstController")); s->addWithLabel("ONLY ACCEPT INPUT FROM FIRST CONTROLLER", input_only_first_controller); @@ -763,10 +760,10 @@ void GuiMenu::openInputDeviceOptions() ComponentListRow configure_input_row; configure_input_row.elements.clear(); configure_input_row.addElement( - std::make_shared(mWindow, "CONFIGURE KEYBOARD AND CONTROLLERS", + std::make_shared("CONFIGURE KEYBOARD AND CONTROLLERS", Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true); - configure_input_row.addElement(makeArrow(mWindow), false); + configure_input_row.addElement(makeArrow(), false); configure_input_row.makeAcceptInputHandler(std::bind(&GuiMenu::openConfigInput, this, s)); s->addRow(configure_input_row); @@ -789,34 +786,33 @@ void GuiMenu::openConfigInput(GuiSettings* settings) "(THIS WILL NOT AFFECT THE HELP PROMPTS)\n" "CONTINUE?"; - Window* window = mWindow; + Window* window {mWindow}; window->pushGui(new GuiMsgBox( - window, getHelpStyle(), message, "YES", - [window] { window->pushGui(new GuiDetectDevice(window, false, false, nullptr)); }, "NO", - nullptr)); + getHelpStyle(), message, "YES", + [window] { window->pushGui(new GuiDetectDevice(false, false, nullptr)); }, "NO", nullptr)); } void GuiMenu::openOtherOptions() { - auto s = new GuiSettings(mWindow, "OTHER SETTINGS"); + auto s = new GuiSettings("OTHER SETTINGS"); // Alternative emulators GUI. ComponentListRow alternativeEmulatorsRow; alternativeEmulatorsRow.elements.clear(); - alternativeEmulatorsRow.addElement( - std::make_shared(mWindow, "ALTERNATIVE EMULATORS", - Font::get(FONT_SIZE_MEDIUM), 0x777777FF), - true); - alternativeEmulatorsRow.addElement(makeArrow(mWindow), false); + alternativeEmulatorsRow.addElement(std::make_shared("ALTERNATIVE EMULATORS", + Font::get(FONT_SIZE_MEDIUM), + 0x777777FF), + true); + alternativeEmulatorsRow.addElement(makeArrow(), false); alternativeEmulatorsRow.makeAcceptInputHandler( - std::bind([this] { mWindow->pushGui(new GuiAlternativeEmulators(mWindow)); })); + std::bind([this] { mWindow->pushGui(new GuiAlternativeEmulators); })); s->addRow(alternativeEmulatorsRow); // Game media directory. ComponentListRow rowMediaDir; - auto media_directory = std::make_shared(mWindow, "GAME MEDIA DIRECTORY", + auto media_directory = std::make_shared("GAME MEDIA DIRECTORY", Font::get(FONT_SIZE_MEDIUM), 0x777777FF); - auto bracketMediaDirectory = std::make_shared(mWindow); + auto bracketMediaDirectory = std::make_shared(); bracketMediaDirectory->setImage(":/graphics/arrow.svg"); bracketMediaDirectory->setResize( glm::vec2 {0.0f, Font::get(FONT_SIZE_MEDIUM)->getLetterHeight()}); @@ -838,23 +834,21 @@ void GuiMenu::openOtherOptions() multiLineMediaDir] { if (Settings::getInstance()->getBool("VirtualKeyboard")) { mWindow->pushGui(new GuiTextEditKeyboardPopup( - mWindow, getHelpStyle(), titleMediaDir, - Settings::getInstance()->getString("MediaDirectory"), updateValMediaDir, - multiLineMediaDir, "SAVE", "SAVE CHANGES?", mediaDirectoryStaticText, - defaultDirectoryText, "load default directory")); + getHelpStyle(), titleMediaDir, Settings::getInstance()->getString("MediaDirectory"), + updateValMediaDir, multiLineMediaDir, "SAVE", "SAVE CHANGES?", + mediaDirectoryStaticText, defaultDirectoryText, "load default directory")); } else { mWindow->pushGui(new GuiTextEditPopup( - mWindow, getHelpStyle(), titleMediaDir, - Settings::getInstance()->getString("MediaDirectory"), updateValMediaDir, - multiLineMediaDir, "SAVE", "SAVE CHANGES?", mediaDirectoryStaticText, - defaultDirectoryText, "load default directory")); + getHelpStyle(), titleMediaDir, Settings::getInstance()->getString("MediaDirectory"), + updateValMediaDir, multiLineMediaDir, "SAVE", "SAVE CHANGES?", + mediaDirectoryStaticText, defaultDirectoryText, "load default directory")); } }); s->addRow(rowMediaDir); // Maximum VRAM. - auto max_vram = std::make_shared(mWindow, 80.f, 1024.f, 8.f, "MiB"); + auto max_vram = std::make_shared(80.f, 1024.f, 8.f, "MiB"); max_vram->setValue(static_cast(Settings::getInstance()->getInt("MaxVRAM"))); s->addWithLabel("VRAM LIMIT", max_vram); s->addSaveFunc([max_vram, s] { @@ -867,7 +861,7 @@ void GuiMenu::openOtherOptions() // Display/monitor. auto display_index = std::make_shared>( - mWindow, getHelpStyle(), "DISPLAY/MONITOR INDEX", false); + getHelpStyle(), "DISPLAY/MONITOR INDEX", false); std::vector displayIndex; displayIndex.push_back("1"); displayIndex.push_back("2"); @@ -888,7 +882,7 @@ void GuiMenu::openOtherOptions() // Exit button configuration. auto exit_button_config = std::make_shared>( - mWindow, getHelpStyle(), "EXIT BUTTON COMBO", false); + getHelpStyle(), "EXIT BUTTON COMBO", false); std::string selectedExitButtonCombo = Settings::getInstance()->getString("ExitButtonCombo"); exit_button_config->add("F4", "F4", selectedExitButtonCombo == "F4"); exit_button_config->add("Alt + F4", "AltF4", selectedExitButtonCombo == "AltF4"); @@ -910,7 +904,7 @@ void GuiMenu::openOtherOptions() // When to save game metadata. auto save_gamelist_mode = std::make_shared>( - mWindow, getHelpStyle(), "WHEN TO SAVE METADATA", false); + getHelpStyle(), "WHEN TO SAVE METADATA", false); std::vector saveModes; saveModes.push_back("on exit"); saveModes.push_back("always"); @@ -938,7 +932,7 @@ void GuiMenu::openOtherOptions() #if defined(_WIN64) // Hide taskbar during the program session. - auto hide_taskbar = std::make_shared(mWindow); + auto hide_taskbar = std::make_shared(); hide_taskbar->setState(Settings::getInstance()->getBool("HideTaskbar")); s->addWithLabel("HIDE TASKBAR (REQUIRES RESTART)", hide_taskbar); s->addSaveFunc([hide_taskbar, s] { @@ -950,7 +944,7 @@ void GuiMenu::openOtherOptions() #endif // Run ES in the background when a game has been launched. - auto run_in_background = std::make_shared(mWindow); + auto run_in_background = std::make_shared(); run_in_background->setState(Settings::getInstance()->getBool("RunInBackground")); s->addWithLabel("RUN IN BACKGROUND (WHILE GAME IS LAUNCHED)", run_in_background); s->addSaveFunc([run_in_background, s] { @@ -962,7 +956,7 @@ void GuiMenu::openOtherOptions() #if defined(VIDEO_HW_DECODING) // Whether to enable hardware decoding for the FFmpeg video player. - auto video_hardware_decoding = std::make_shared(mWindow); + auto video_hardware_decoding = std::make_shared(); video_hardware_decoding->setState(Settings::getInstance()->getBool("VideoHardwareDecoding")); s->addWithLabel("VIDEO HARDWARE DECODING (EXPERIMENTAL)", video_hardware_decoding); s->addSaveFunc([video_hardware_decoding, s] { @@ -976,7 +970,7 @@ void GuiMenu::openOtherOptions() #endif // Whether to upscale the video frame rate to 60 FPS. - auto video_upscale_frame_rate = std::make_shared(mWindow); + auto video_upscale_frame_rate = std::make_shared(); video_upscale_frame_rate->setState(Settings::getInstance()->getBool("VideoUpscaleFrameRate")); s->addWithLabel("UPSCALE VIDEO FRAME RATE TO 60 FPS", video_upscale_frame_rate); s->addSaveFunc([video_upscale_frame_rate, s] { @@ -989,7 +983,7 @@ void GuiMenu::openOtherOptions() }); // Whether to preload the gamelists on application startup. - auto preloadGamelists = std::make_shared(mWindow); + auto preloadGamelists = std::make_shared(); preloadGamelists->setState(Settings::getInstance()->getBool("PreloadGamelists")); s->addWithLabel("PRELOAD GAMELISTS ON STARTUP", preloadGamelists); s->addSaveFunc([preloadGamelists, s] { @@ -1001,7 +995,7 @@ void GuiMenu::openOtherOptions() // Whether to enable alternative emulators per game (the option to disable this is intended // primarily for testing purposes). - auto alternativeEmulatorPerGame = std::make_shared(mWindow); + auto alternativeEmulatorPerGame = std::make_shared(); alternativeEmulatorPerGame->setState( Settings::getInstance()->getBool("AlternativeEmulatorPerGame")); s->addWithLabel("ENABLE ALTERNATIVE EMULATORS PER GAME", alternativeEmulatorPerGame); @@ -1017,7 +1011,7 @@ void GuiMenu::openOtherOptions() }); // Show hidden files. - auto show_hidden_files = std::make_shared(mWindow); + auto show_hidden_files = std::make_shared(); show_hidden_files->setState(Settings::getInstance()->getBool("ShowHiddenFiles")); s->addWithLabel("SHOW HIDDEN FILES AND FOLDERS (REQUIRES RESTART)", show_hidden_files); s->addSaveFunc([show_hidden_files, s] { @@ -1028,7 +1022,7 @@ void GuiMenu::openOtherOptions() }); // Show hidden games. - auto show_hidden_games = std::make_shared(mWindow); + auto show_hidden_games = std::make_shared(); show_hidden_games->setState(Settings::getInstance()->getBool("ShowHiddenGames")); s->addWithLabel("SHOW HIDDEN GAMES (REQUIRES RESTART)", show_hidden_games); s->addSaveFunc([show_hidden_games, s] { @@ -1039,7 +1033,7 @@ void GuiMenu::openOtherOptions() }); // Custom event scripts, fired using Scripting::fireEvent(). - auto custom_eventscripts = std::make_shared(mWindow); + auto custom_eventscripts = std::make_shared(); custom_eventscripts->setState(Settings::getInstance()->getBool("CustomEventScripts")); s->addWithLabel("ENABLE CUSTOM EVENT SCRIPTS", custom_eventscripts); s->addSaveFunc([custom_eventscripts, s] { @@ -1051,7 +1045,7 @@ void GuiMenu::openOtherOptions() }); // Only show ROMs included in the gamelist.xml files. - auto parse_gamelist_only = std::make_shared(mWindow); + auto parse_gamelist_only = std::make_shared(); parse_gamelist_only->setState(Settings::getInstance()->getBool("ParseGamelistOnly")); s->addWithLabel("ONLY SHOW ROMS FROM GAMELIST.XML FILES", parse_gamelist_only); s->addSaveFunc([parse_gamelist_only, s] { @@ -1064,7 +1058,7 @@ void GuiMenu::openOtherOptions() #if defined(__unix__) // Whether to disable desktop composition. - auto disable_composition = std::make_shared(mWindow); + auto disable_composition = std::make_shared(); disable_composition->setState(Settings::getInstance()->getBool("DisableComposition")); s->addWithLabel("DISABLE DESKTOP COMPOSITION (REQUIRES RESTART)", disable_composition); s->addSaveFunc([disable_composition, s] { @@ -1077,7 +1071,7 @@ void GuiMenu::openOtherOptions() #endif // GPU statistics overlay. - auto display_gpu_statistics = std::make_shared(mWindow); + auto display_gpu_statistics = std::make_shared(); display_gpu_statistics->setState(Settings::getInstance()->getBool("DisplayGPUStatistics")); s->addWithLabel("DISPLAY GPU STATISTICS OVERLAY", display_gpu_statistics); s->addSaveFunc([display_gpu_statistics, s] { @@ -1090,7 +1084,7 @@ void GuiMenu::openOtherOptions() }); // Whether to enable the menu in Kid mode. - auto enable_menu_kid_mode = std::make_shared(mWindow); + auto enable_menu_kid_mode = std::make_shared(); enable_menu_kid_mode->setState(Settings::getInstance()->getBool("EnableMenuKidMode")); s->addWithLabel("ENABLE MENU IN KID MODE", enable_menu_kid_mode); s->addSaveFunc([enable_menu_kid_mode, s] { @@ -1105,7 +1099,7 @@ void GuiMenu::openOtherOptions() // sense to enable this setting and menu entry for that operating system. #if !defined(__APPLE__) // Whether to show the quit menu with the options to reboot and shutdown the computer. - auto show_quit_menu = std::make_shared(mWindow); + auto show_quit_menu = std::make_shared(); show_quit_menu->setState(Settings::getInstance()->getBool("ShowQuitMenu")); s->addWithLabel("SHOW QUIT MENU (REBOOT AND POWER OFF ENTRIES)", show_quit_menu); s->addSaveFunc([this, show_quit_menu, s] { @@ -1123,7 +1117,7 @@ void GuiMenu::openOtherOptions() void GuiMenu::openUtilitiesMenu() { - auto s = new GuiSettings(mWindow, "UTILITIES"); + auto s = new GuiSettings("UTILITIES"); s->setSize(mSize); mWindow->pushGui(s); } @@ -1132,7 +1126,7 @@ void GuiMenu::openQuitMenu() { if (!Settings::getInstance()->getBool("ShowQuitMenu")) { mWindow->pushGui(new GuiMsgBox( - mWindow, this->getHelpStyle(), "REALLY QUIT?", "YES", + this->getHelpStyle(), "REALLY QUIT?", "YES", [this] { Scripting::fireEvent("quit"); close(true); @@ -1141,16 +1135,16 @@ void GuiMenu::openQuitMenu() "NO", nullptr)); } else { - auto s = new GuiSettings(mWindow, "QUIT"); + auto s = new GuiSettings("QUIT"); - Window* window = mWindow; + Window* window {mWindow}; HelpStyle style = getHelpStyle(); ComponentListRow row; row.makeAcceptInputHandler([window, this] { window->pushGui(new GuiMsgBox( - window, this->getHelpStyle(), "REALLY QUIT?", "YES", + this->getHelpStyle(), "REALLY QUIT?", "YES", [this] { Scripting::fireEvent("quit"); close(true); @@ -1158,7 +1152,7 @@ void GuiMenu::openQuitMenu() }, "NO", nullptr)); }); - auto quitText = std::make_shared(window, "QUIT EMULATIONSTATION", + auto quitText = std::make_shared("QUIT EMULATIONSTATION", Font::get(FONT_SIZE_MEDIUM), 0x777777FF); quitText->setSelectable(true); row.addElement(quitText, true); @@ -1167,7 +1161,7 @@ void GuiMenu::openQuitMenu() row.elements.clear(); row.makeAcceptInputHandler([window, this] { window->pushGui(new GuiMsgBox( - window, this->getHelpStyle(), "REALLY REBOOT?", "YES", + this->getHelpStyle(), "REALLY REBOOT?", "YES", [] { Scripting::fireEvent("quit", "reboot"); Scripting::fireEvent("reboot"); @@ -1177,7 +1171,7 @@ void GuiMenu::openQuitMenu() }, "NO", nullptr)); }); - auto rebootText = std::make_shared(window, "REBOOT SYSTEM", + auto rebootText = std::make_shared("REBOOT SYSTEM", Font::get(FONT_SIZE_MEDIUM), 0x777777FF); rebootText->setSelectable(true); row.addElement(rebootText, true); @@ -1186,7 +1180,7 @@ void GuiMenu::openQuitMenu() row.elements.clear(); row.makeAcceptInputHandler([window, this] { window->pushGui(new GuiMsgBox( - window, this->getHelpStyle(), "REALLY POWER OFF?", "YES", + this->getHelpStyle(), "REALLY POWER OFF?", "YES", [] { Scripting::fireEvent("quit", "poweroff"); Scripting::fireEvent("poweroff"); @@ -1197,7 +1191,7 @@ void GuiMenu::openQuitMenu() "NO", nullptr)); }); auto powerOffText = std::make_shared( - window, "POWER OFF SYSTEM", Font::get(FONT_SIZE_MEDIUM), 0x777777FF); + "POWER OFF SYSTEM", Font::get(FONT_SIZE_MEDIUM), 0x777777FF); powerOffText->setSelectable(true); row.addElement(powerOffText, true); s->addRow(row); @@ -1218,17 +1212,17 @@ void GuiMenu::addVersionInfo() void GuiMenu::openMediaViewerOptions() { - mWindow->pushGui(new GuiMediaViewerOptions(mWindow, "MEDIA VIEWER SETTINGS")); + mWindow->pushGui(new GuiMediaViewerOptions("MEDIA VIEWER SETTINGS")); } void GuiMenu::openScreensaverOptions() { - mWindow->pushGui(new GuiScreensaverOptions(mWindow, "SCREENSAVER SETTINGS")); + mWindow->pushGui(new GuiScreensaverOptions("SCREENSAVER SETTINGS")); } void GuiMenu::openCollectionSystemOptions() { - mWindow->pushGui(new GuiCollectionSystemsOptions(mWindow, "GAME COLLECTION SETTINGS")); + mWindow->pushGui(new GuiCollectionSystemsOptions("GAME COLLECTION SETTINGS")); } void GuiMenu::onSizeChanged() @@ -1246,10 +1240,10 @@ void GuiMenu::addEntry(const std::string& name, // Populate the list. ComponentListRow row; - row.addElement(std::make_shared(mWindow, name, font, color), true); + row.addElement(std::make_shared(name, font, color), true); if (add_arrow) { - std::shared_ptr bracket = makeArrow(mWindow); + std::shared_ptr bracket {makeArrow()}; row.addElement(bracket, false); } @@ -1264,7 +1258,7 @@ void GuiMenu::close(bool closeAllWindows) closeFunc = [this] { delete this; }; } else { - Window* window = mWindow; + Window* window {mWindow}; closeFunc = [window] { while (window->peekGui() != ViewController::getInstance()) delete window->peekGui(); diff --git a/es-app/src/guis/GuiMenu.h b/es-app/src/guis/GuiMenu.h index 4b361d770..87c68297d 100644 --- a/es-app/src/guis/GuiMenu.h +++ b/es-app/src/guis/GuiMenu.h @@ -17,7 +17,7 @@ class GuiMenu : public GuiComponent { public: - GuiMenu(Window* window); + GuiMenu(); ~GuiMenu(); bool input(InputConfig* config, Input input) override; diff --git a/es-app/src/guis/GuiMetaDataEd.cpp b/es-app/src/guis/GuiMetaDataEd.cpp index 7d4a1ae6b..d59bceaee 100644 --- a/es-app/src/guis/GuiMetaDataEd.cpp +++ b/es-app/src/guis/GuiMetaDataEd.cpp @@ -34,16 +34,14 @@ #define TITLE_HEIGHT (mTitle->getFont()->getLetterHeight() + Renderer::getScreenHeight() * 0.060f) -GuiMetaDataEd::GuiMetaDataEd(Window* window, - MetaDataList* md, +GuiMetaDataEd::GuiMetaDataEd(MetaDataList* md, const std::vector& mdd, ScraperSearchParams scraperParams, std::function saveCallback, std::function clearGameFunc, std::function deleteGameFunc) - : GuiComponent {window} - , mBackground {window, ":/graphics/frame.svg"} - , mGrid {window, glm::ivec2 {2, 6}} + : mBackground {":/graphics/frame.svg"} + , mGrid {glm::ivec2 {2, 6}} , mScraperParams {scraperParams} , mControllerBadges {BadgeComponent::getGameControllers()} , mMetaDataDecl {mdd} @@ -68,7 +66,7 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, addChild(&mBackground); addChild(&mGrid); - mTitle = std::make_shared(mWindow, "EDIT METADATA", Font::get(FONT_SIZE_LARGE), + mTitle = std::make_shared("EDIT METADATA", Font::get(FONT_SIZE_LARGE), 0x555555FF, ALIGN_CENTER); mGrid.setEntry(mTitle, glm::ivec2 {0, 0}, false, true, glm::ivec2 {2, 2}); @@ -88,7 +86,6 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, } mSubtitle = std::make_shared( - mWindow, folderPath + Utils::FileSystem::getFileName(scraperParams.game->getPath()) + " [" + Utils::String::toUpper(scraperParams.system->getName()) + "]" + (scraperParams.game->getType() == FOLDER ? " " + ViewController::FOLDER_CHAR : ""), @@ -96,12 +93,12 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, mGrid.setEntry(mSubtitle, glm::ivec2 {0, 2}, false, true, glm::ivec2 {2, 1}); - mList = std::make_shared(mWindow); + mList = std::make_shared(); mGrid.setEntry(mList, glm::ivec2 {0, 4}, true, true, glm::ivec2 {2, 1}); // Set up scroll indicators. - mScrollUp = std::make_shared(mWindow); - mScrollDown = std::make_shared(mWindow); + mScrollUp = std::make_shared(); + mScrollDown = std::make_shared(); mScrollIndicator = std::make_shared(mList, mScrollUp, mScrollDown); mScrollUp->setResize(0.0f, mTitle->getFont()->getLetterHeight() / 2.0f); @@ -132,8 +129,8 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, // Don't show the alternative emulator entry if the corresponding option has been disabled. if (!Settings::getInstance()->getBool("AlternativeEmulatorPerGame") && it->type == MD_ALT_EMULATOR) { - ed = std::make_shared( - window, "", Font::get(FONT_SIZE_SMALL, FONT_PATH_LIGHT), 0x777777FF, ALIGN_RIGHT); + ed = std::make_shared("", Font::get(FONT_SIZE_SMALL, FONT_PATH_LIGHT), + 0x777777FF, ALIGN_RIGHT); assert(ed); ed->setValue(mMetaData->get(it->key)); mEditors.push_back(ed); @@ -144,13 +141,13 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, // entry instead of for instance the spacer. That is so because ComponentList // always looks for the help prompt at the back of the element stack. ComponentListRow row; - auto lbl = std::make_shared(mWindow, Utils::String::toUpper(it->displayName), + auto lbl = std::make_shared(Utils::String::toUpper(it->displayName), Font::get(FONT_SIZE_SMALL), 0x777777FF); row.addElement(lbl, true); // Label. switch (it->type) { case MD_BOOL: { - ed = std::make_shared(window); + ed = std::make_shared(); // Make the switches slightly smaller. glm::vec2 switchSize {ed->getSize() * 0.9f}; ed->setResize(ceilf(switchSize.x), switchSize.y); @@ -160,11 +157,11 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, break; } case MD_RATING: { - auto spacer = std::make_shared(mWindow); + auto spacer = std::make_shared(); spacer->setSize(Renderer::getScreenWidth() * 0.0025f, 0.0f); row.addElement(spacer, false); - ed = std::make_shared(window, true); + ed = std::make_shared(true); ed->setChangedColor(ICONCOLOR_USERMARKED); const float height = lbl->getSize().y * 0.71f; ed->setSize(0.0f, height); @@ -176,11 +173,11 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, break; } case MD_DATE: { - auto spacer = std::make_shared(mWindow); + auto spacer = std::make_shared(); spacer->setSize(Renderer::getScreenWidth() * 0.0025f, 0.0f); row.addElement(spacer, false); - ed = std::make_shared(window, true); + ed = std::make_shared(true); ed->setOriginalColor(DEFAULT_TEXTCOLOR); ed->setChangedColor(TEXTCOLOR_USERMARKED); row.addElement(ed, false); @@ -191,16 +188,15 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, break; } case MD_CONTROLLER: { - ed = std::make_shared(window, "", - Font::get(FONT_SIZE_SMALL, FONT_PATH_LIGHT), - 0x777777FF, ALIGN_RIGHT); + ed = std::make_shared( + "", Font::get(FONT_SIZE_SMALL, FONT_PATH_LIGHT), 0x777777FF, ALIGN_RIGHT); row.addElement(ed, true); - auto spacer = std::make_shared(mWindow); + auto spacer = std::make_shared(); spacer->setSize(Renderer::getScreenWidth() * 0.005f, 0.0f); row.addElement(spacer, false); - auto bracket = std::make_shared(mWindow); + auto bracket = std::make_shared(); bracket->setImage(":/graphics/arrow.svg"); bracket->setResize(glm::vec2 {0.0f, lbl->getFont()->getLetterHeight()}); row.addElement(bracket, false); @@ -217,7 +213,7 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, }; row.makeAcceptInputHandler([this, title, ed, updateVal] { - GuiSettings* s = new GuiSettings(mWindow, title); + GuiSettings* s = new GuiSettings(title); for (auto controller : mControllerBadges) { std::string selectedLabel = ed->getValue(); @@ -225,7 +221,7 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, ComponentListRow row; std::shared_ptr labelText = std::make_shared( - mWindow, label, Font::get(FONT_SIZE_MEDIUM), 0x777777FF); + label, Font::get(FONT_SIZE_MEDIUM), 0x777777FF); labelText->setSelectable(true); labelText->setValue(controller.displayName); @@ -249,7 +245,7 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, if (ed->getValue() != "") { ComponentListRow row; std::shared_ptr clearText = std::make_shared( - mWindow, ViewController::CROSSEDCIRCLE_CHAR + " CLEAR ENTRY", + ViewController::CROSSEDCIRCLE_CHAR + " CLEAR ENTRY", Font::get(FONT_SIZE_MEDIUM), 0x777777FF); clearText->setSelectable(true); row.addElement(clearText, true); @@ -275,16 +271,15 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, case MD_ALT_EMULATOR: { mInvalidEmulatorEntry = false; - ed = std::make_shared(window, "", - Font::get(FONT_SIZE_SMALL, FONT_PATH_LIGHT), - 0x777777FF, ALIGN_RIGHT); + ed = std::make_shared( + "", Font::get(FONT_SIZE_SMALL, FONT_PATH_LIGHT), 0x777777FF, ALIGN_RIGHT); row.addElement(ed, true); - auto spacer = std::make_shared(mWindow); + auto spacer = std::make_shared(); spacer->setSize(Renderer::getScreenWidth() * 0.005f, 0.0f); row.addElement(spacer, false); - auto bracket = std::make_shared(mWindow); + auto bracket = std::make_shared(); bracket->setImage(":/graphics/arrow.svg"); bracket->setResize(glm::vec2 {0.0f, lbl->getFont()->getLetterHeight()}); row.addElement(bracket, false); @@ -326,9 +321,9 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, scraperParams.system->getSystemEnvData()->mLaunchCommands.size() == 1; if (mInvalidEmulatorEntry && singleEntry) - s = new GuiSettings(mWindow, "CLEAR INVALID ENTRY"); + s = new GuiSettings("CLEAR INVALID ENTRY"); else - s = new GuiSettings(mWindow, title); + s = new GuiSettings(title); if (!mInvalidEmulatorEntry && ed->getValue() == "" && singleEntry) return; @@ -359,8 +354,8 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, label = entry.second; std::shared_ptr labelText = - std::make_shared( - mWindow, label, Font::get(FONT_SIZE_MEDIUM), 0x777777FF); + std::make_shared(label, Font::get(FONT_SIZE_MEDIUM), + 0x777777FF); labelText->setSelectable(true); if (scraperParams.system->getAlternativeEmulator() == "" && @@ -413,16 +408,15 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, case MD_MULTILINE_STRING: default: { // MD_STRING. - ed = std::make_shared(window, "", - Font::get(FONT_SIZE_SMALL, FONT_PATH_LIGHT), - 0x777777FF, ALIGN_RIGHT); + ed = std::make_shared( + "", Font::get(FONT_SIZE_SMALL, FONT_PATH_LIGHT), 0x777777FF, ALIGN_RIGHT); row.addElement(ed, true); - auto spacer = std::make_shared(mWindow); + auto spacer = std::make_shared(); spacer->setSize(Renderer::getScreenWidth() * 0.005f, 0.0f); row.addElement(spacer, false); - auto bracket = std::make_shared(mWindow); + auto bracket = std::make_shared(); bracket->setImage(":/graphics/arrow.svg"); bracket->setResize(glm::vec2 {0.0f, lbl->getFont()->getLetterHeight()}); row.addElement(bracket, false); @@ -477,15 +471,15 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, if (Settings::getInstance()->getBool("VirtualKeyboard")) { row.makeAcceptInputHandler([this, title, ed, updateVal, multiLine] { mWindow->pushGui(new GuiTextEditKeyboardPopup( - mWindow, getHelpStyle(), title, ed->getValue(), updateVal, multiLine, - "apply", "APPLY CHANGES?", "", "")); + getHelpStyle(), title, ed->getValue(), updateVal, multiLine, "apply", + "APPLY CHANGES?", "", "")); }); } else { row.makeAcceptInputHandler([this, title, ed, updateVal, multiLine] { - mWindow->pushGui(new GuiTextEditPopup(mWindow, getHelpStyle(), title, - ed->getValue(), updateVal, multiLine, - "APPLY", "APPLY CHANGES?")); + mWindow->pushGui(new GuiTextEditPopup(getHelpStyle(), title, ed->getValue(), + updateVal, multiLine, "APPLY", + "APPLY CHANGES?")); }); } break; @@ -516,15 +510,15 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, if (!scraperParams.system->hasPlatformId(PlatformIds::PLATFORM_IGNORE)) buttons.push_back(std::make_shared( - mWindow, "SCRAPE", "scrape", std::bind(&GuiMetaDataEd::fetch, this))); + "SCRAPE", "scrape", std::bind(&GuiMetaDataEd::fetch, this))); - buttons.push_back(std::make_shared(mWindow, "SAVE", "save metadata", [&] { + buttons.push_back(std::make_shared("SAVE", "save metadata", [&] { save(); ViewController::getInstance()->onPauseVideo(); delete this; })); - buttons.push_back(std::make_shared(mWindow, "CANCEL", "cancel changes", - [&] { delete this; })); + buttons.push_back( + std::make_shared("CANCEL", "cancel changes", [&] { delete this; })); if (scraperParams.game->getType() == FOLDER) { if (mClearGameFunc) { auto clearSelf = [&] { @@ -532,7 +526,7 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, delete this; }; auto clearSelfBtnFunc = [this, clearSelf] { - mWindow->pushGui(new GuiMsgBox(mWindow, getHelpStyle(), + mWindow->pushGui(new GuiMsgBox(getHelpStyle(), "THIS WILL DELETE ANY MEDIA FILES AND\n" "THE GAMELIST.XML ENTRY FOR THIS FOLDER,\n" "BUT NEITHER THE FOLDER ITSELF OR ANY\n" @@ -540,8 +534,8 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, "ARE YOU SURE?", "YES", clearSelf, "NO", nullptr)); }; - buttons.push_back(std::make_shared(mWindow, "CLEAR", "clear folder", - clearSelfBtnFunc)); + buttons.push_back( + std::make_shared("CLEAR", "clear folder", clearSelfBtnFunc)); } } else { @@ -551,7 +545,7 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, delete this; }; auto clearSelfBtnFunc = [this, clearSelf] { - mWindow->pushGui(new GuiMsgBox(mWindow, getHelpStyle(), + mWindow->pushGui(new GuiMsgBox(getHelpStyle(), "THIS WILL DELETE ANY MEDIA FILES\n" "AND THE GAMELIST.XML ENTRY FOR\n" "THIS GAME, BUT THE GAME FILE\n" @@ -559,8 +553,8 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, "ARE YOU SURE?", "YES", clearSelf, "NO", nullptr)); }; - buttons.push_back(std::make_shared(mWindow, "CLEAR", "clear file", - clearSelfBtnFunc)); + buttons.push_back( + std::make_shared("CLEAR", "clear file", clearSelfBtnFunc)); } // For the special case where a directory has a supported file extension and is therefore @@ -571,19 +565,19 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, delete this; }; auto deleteGameBtnFunc = [this, deleteFilesAndSelf] { - mWindow->pushGui(new GuiMsgBox(mWindow, getHelpStyle(), + mWindow->pushGui(new GuiMsgBox(getHelpStyle(), "THIS WILL DELETE THE GAME\n" "FILE, ANY MEDIA FILES AND\n" "THE GAMELIST.XML ENTRY\n" "ARE YOU SURE?", "YES", deleteFilesAndSelf, "NO", nullptr)); }; - buttons.push_back(std::make_shared(mWindow, "DELETE", "delete game", - deleteGameBtnFunc)); + buttons.push_back( + std::make_shared("DELETE", "delete game", deleteGameBtnFunc)); } } - mButtons = makeButtonGrid(mWindow, buttons); + mButtons = makeButtonGrid(buttons); mGrid.setEntry(mButtons, glm::ivec2 {0, 5}, true, false, glm::ivec2 {2, 1}); // Resize + center. @@ -748,7 +742,7 @@ void GuiMetaDataEd::save() void GuiMetaDataEd::fetch() { GuiScraperSingle* scr = new GuiScraperSingle( - mWindow, mScraperParams, std::bind(&GuiMetaDataEd::fetchDone, this, std::placeholders::_1), + mScraperParams, std::bind(&GuiMetaDataEd::fetchDone, this, std::placeholders::_1), mSavedMediaAndAborted); mWindow->pushGui(scr); } @@ -856,7 +850,7 @@ void GuiMetaDataEd::close() if (metadataUpdated) { // Changes were made, ask if the user wants to save them. mWindow->pushGui(new GuiMsgBox( - mWindow, getHelpStyle(), "SAVE CHANGES?", "YES", + getHelpStyle(), "SAVE CHANGES?", "YES", [this, closeFunc] { save(); closeFunc(); diff --git a/es-app/src/guis/GuiMetaDataEd.h b/es-app/src/guis/GuiMetaDataEd.h index aace57dd9..81b802099 100644 --- a/es-app/src/guis/GuiMetaDataEd.h +++ b/es-app/src/guis/GuiMetaDataEd.h @@ -26,8 +26,7 @@ class TextComponent; class GuiMetaDataEd : public GuiComponent { public: - GuiMetaDataEd(Window* window, - MetaDataList* md, + GuiMetaDataEd(MetaDataList* md, const std::vector& mdd, ScraperSearchParams params, std::function savedCallback, diff --git a/es-app/src/guis/GuiOfflineGenerator.cpp b/es-app/src/guis/GuiOfflineGenerator.cpp index 7704f4198..938a03093 100644 --- a/es-app/src/guis/GuiOfflineGenerator.cpp +++ b/es-app/src/guis/GuiOfflineGenerator.cpp @@ -13,11 +13,10 @@ #include "components/MenuComponent.h" #include "views/ViewController.h" -GuiOfflineGenerator::GuiOfflineGenerator(Window* window, const std::queue& gameQueue) - : GuiComponent {window} - , mGameQueue {gameQueue} - , mBackground {window, ":/graphics/frame.svg"} - , mGrid {window, glm::ivec2 {6, 13}} +GuiOfflineGenerator::GuiOfflineGenerator(const std::queue& gameQueue) + : mGameQueue {gameQueue} + , mBackground {":/graphics/frame.svg"} + , mGrid {glm::ivec2 {6, 13}} { addChild(&mBackground); addChild(&mGrid); @@ -36,133 +35,129 @@ GuiOfflineGenerator::GuiOfflineGenerator(Window* window, const std::queue(mWindow, "MIXIMAGE OFFLINE GENERATOR", + mTitle = std::make_shared("MIXIMAGE OFFLINE GENERATOR", Font::get(FONT_SIZE_LARGE), 0x555555FF, ALIGN_CENTER); mGrid.setEntry(mTitle, glm::ivec2 {0, 0}, false, true, glm::ivec2 {6, 1}); - mStatus = std::make_shared(mWindow, "NOT STARTED", Font::get(FONT_SIZE_MEDIUM), + mStatus = std::make_shared("NOT STARTED", Font::get(FONT_SIZE_MEDIUM), 0x777777FF, ALIGN_CENTER); mGrid.setEntry(mStatus, glm::ivec2 {0, 1}, false, true, glm::ivec2 {6, 1}); mGameCounter = std::make_shared( - mWindow, std::to_string(mGamesProcessed) + " OF " + std::to_string(mTotalGames) + (mTotalGames == 1 ? " GAME " : " GAMES ") + "PROCESSED", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_CENTER); mGrid.setEntry(mGameCounter, glm::ivec2 {0, 2}, false, true, glm::ivec2 {6, 1}); // Spacer row with top border. - mGrid.setEntry(std::make_shared(mWindow), glm::ivec2 {0, 3}, false, false, + mGrid.setEntry(std::make_shared(), glm::ivec2 {0, 3}, false, false, glm::ivec2 {6, 1}, GridFlags::BORDER_TOP); // Left spacer. - mGrid.setEntry(std::make_shared(mWindow), glm::ivec2 {0, 4}, false, false, + mGrid.setEntry(std::make_shared(), glm::ivec2 {0, 4}, false, false, glm::ivec2 {1, 7}); // Generated label. - mGeneratedLbl = std::make_shared( - mWindow, "Generated:", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT); + mGeneratedLbl = std::make_shared("Generated:", Font::get(FONT_SIZE_SMALL), + 0x888888FF, ALIGN_LEFT); mGrid.setEntry(mGeneratedLbl, glm::ivec2 {1, 4}, false, true, glm::ivec2 {1, 1}); // Generated value/counter. - mGeneratedVal = - std::make_shared(mWindow, std::to_string(mGamesProcessed), - Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT); + mGeneratedVal = std::make_shared( + std::to_string(mGamesProcessed), Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT); mGrid.setEntry(mGeneratedVal, glm::ivec2 {2, 4}, false, true, glm::ivec2 {1, 1}); // Overwritten label. - mOverwrittenLbl = std::make_shared( - mWindow, "Overwritten:", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT); + mOverwrittenLbl = std::make_shared("Overwritten:", Font::get(FONT_SIZE_SMALL), + 0x888888FF, ALIGN_LEFT); mGrid.setEntry(mOverwrittenLbl, glm::ivec2 {1, 5}, false, true, glm::ivec2 {1, 1}); // Overwritten value/counter. - mOverwrittenVal = - std::make_shared(mWindow, std::to_string(mImagesOverwritten), - Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT); + mOverwrittenVal = std::make_shared( + std::to_string(mImagesOverwritten), Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT); mGrid.setEntry(mOverwrittenVal, glm::ivec2 {2, 5}, false, true, glm::ivec2 {1, 1}); // Skipping label. - mSkippedLbl = std::make_shared( - mWindow, "Skipped (existing):", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT); + mSkippedLbl = std::make_shared("Skipped (existing):", Font::get(FONT_SIZE_SMALL), + 0x888888FF, ALIGN_LEFT); mGrid.setEntry(mSkippedLbl, glm::ivec2 {1, 6}, false, true, glm::ivec2 {1, 1}); // Skipping value/counter. mSkippedVal = std::make_shared( - mWindow, std::to_string(mGamesSkipped), Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT); + std::to_string(mGamesSkipped), Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT); mGrid.setEntry(mSkippedVal, glm::ivec2 {2, 6}, false, true, glm::ivec2 {1, 1}); // Failed label. - mFailedLbl = std::make_shared(mWindow, "Failed:", Font::get(FONT_SIZE_SMALL), - 0x888888FF, ALIGN_LEFT); + mFailedLbl = std::make_shared("Failed:", Font::get(FONT_SIZE_SMALL), 0x888888FF, + ALIGN_LEFT); mGrid.setEntry(mFailedLbl, glm::ivec2 {1, 7}, false, true, glm::ivec2 {1, 1}); // Failed value/counter. mFailedVal = std::make_shared( - mWindow, std::to_string(mGamesFailed), Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT); + std::to_string(mGamesFailed), Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT); mGrid.setEntry(mFailedVal, glm::ivec2 {2, 7}, false, true, glm::ivec2 {1, 1}); // Processing label. - mProcessingLbl = std::make_shared( - mWindow, "Processing: ", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT); + mProcessingLbl = std::make_shared("Processing: ", Font::get(FONT_SIZE_SMALL), + 0x888888FF, ALIGN_LEFT); mGrid.setEntry(mProcessingLbl, glm::ivec2 {3, 4}, false, true, glm::ivec2 {1, 1}); // Processing value. - mProcessingVal = std::make_shared(mWindow, "", Font::get(FONT_SIZE_SMALL), - 0x888888FF, ALIGN_LEFT); + mProcessingVal = + std::make_shared("", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT); mGrid.setEntry(mProcessingVal, glm::ivec2 {4, 4}, false, true, glm::ivec2 {1, 1}); // Spacer row. - mGrid.setEntry(std::make_shared(mWindow), glm::ivec2 {1, 8}, false, false, + mGrid.setEntry(std::make_shared(), glm::ivec2 {1, 8}, false, false, glm::ivec2 {4, 1}); // Last error message label. mLastErrorLbl = std::make_shared( - mWindow, "Last error message:", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT); + "Last error message:", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT); mGrid.setEntry(mLastErrorLbl, glm::ivec2 {1, 9}, false, true, glm::ivec2 {4, 1}); // Last error message value. - mLastErrorVal = std::make_shared(mWindow, "", Font::get(FONT_SIZE_SMALL), - 0x888888FF, ALIGN_LEFT); + mLastErrorVal = + std::make_shared("", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT); mGrid.setEntry(mLastErrorVal, glm::ivec2 {1, 10}, false, true, glm::ivec2 {4, 1}); // Right spacer. - mGrid.setEntry(std::make_shared(mWindow), glm::ivec2 {5, 4}, false, false, + mGrid.setEntry(std::make_shared(), glm::ivec2 {5, 4}, false, false, glm::ivec2 {1, 7}); // Spacer row with bottom border. - mGrid.setEntry(std::make_shared(mWindow), glm::ivec2 {0, 11}, false, false, + mGrid.setEntry(std::make_shared(), glm::ivec2 {0, 11}, false, false, glm::ivec2 {6, 1}, GridFlags::BORDER_BOTTOM); // Buttons. std::vector> buttons; - mStartPauseButton = - std::make_shared(mWindow, "START", "start processing", [this]() { - if (!mProcessing) { - mProcessing = true; - mPaused = false; - mStartPauseButton->setText("PAUSE", "pause processing"); - mCloseButton->setText("CLOSE", "close (abort processing)"); - mStatus->setText("RUNNING..."); - if (mGamesProcessed == 0) { - LOG(LogInfo) << "GuiOfflineGenerator: Processing " << mTotalGames << " games"; - } + mStartPauseButton = std::make_shared("START", "start processing", [this]() { + if (!mProcessing) { + mProcessing = true; + mPaused = false; + mStartPauseButton->setText("PAUSE", "pause processing"); + mCloseButton->setText("CLOSE", "close (abort processing)"); + mStatus->setText("RUNNING..."); + if (mGamesProcessed == 0) { + LOG(LogInfo) << "GuiOfflineGenerator: Processing " << mTotalGames << " games"; } - else { - if (mMiximageGeneratorThread.joinable()) - mMiximageGeneratorThread.join(); - mPaused = true; - update(1); - mProcessing = false; - this->mStartPauseButton->setText("START", "start processing"); - this->mCloseButton->setText("CLOSE", "close (abort processing)"); - mStatus->setText("PAUSED"); - } - }); + } + else { + if (mMiximageGeneratorThread.joinable()) + mMiximageGeneratorThread.join(); + mPaused = true; + update(1); + mProcessing = false; + this->mStartPauseButton->setText("START", "start processing"); + this->mCloseButton->setText("CLOSE", "close (abort processing)"); + mStatus->setText("PAUSED"); + } + }); buttons.push_back(mStartPauseButton); - mCloseButton = std::make_shared(mWindow, "CLOSE", "close", [this]() { + mCloseButton = std::make_shared("CLOSE", "close", [this]() { if (mGamesProcessed != 0 && mGamesProcessed != mTotalGames) { LOG(LogInfo) << "GuiOfflineGenerator: Aborted after processing " << mGamesProcessed << (mGamesProcessed == 1 ? " game (" : " games (") << mImagesGenerated @@ -175,7 +170,7 @@ GuiOfflineGenerator::GuiOfflineGenerator(Window* window, const std::queue& gameQueue); + GuiOfflineGenerator(const std::queue& gameQueue); ~GuiOfflineGenerator(); private: diff --git a/es-app/src/guis/GuiScraperMenu.cpp b/es-app/src/guis/GuiScraperMenu.cpp index 2c6438f57..a89e478e3 100644 --- a/es-app/src/guis/GuiScraperMenu.cpp +++ b/es-app/src/guis/GuiScraperMenu.cpp @@ -20,13 +20,12 @@ #include "guis/GuiScraperMulti.h" #include "views/ViewController.h" -GuiScraperMenu::GuiScraperMenu(Window* window, std::string title) - : GuiComponent {window} - , mMenu {window, title} +GuiScraperMenu::GuiScraperMenu(std::string title) + : mMenu {title} { // Scraper service. - mScraper = std::make_shared>(mWindow, getHelpStyle(), - "SCRAPE FROM", false); + mScraper = + std::make_shared>(getHelpStyle(), "SCRAPE FROM", false); std::vector scrapers = getScraperList(); // Select either the first entry or the one read from the settings, // just in case the scraper from settings has vanished. @@ -41,7 +40,7 @@ GuiScraperMenu::GuiScraperMenu(Window* window, std::string title) // Search filters, getSearches() will generate a queue of games to scrape // based on the outcome of the checks below. - mFilters = std::make_shared>(mWindow, getHelpStyle(), + mFilters = std::make_shared>(getHelpStyle(), "SCRAPE THESE GAMES", false); mFilters->add( "ALL GAMES", @@ -102,7 +101,7 @@ GuiScraperMenu::GuiScraperMenu(Window* window, std::string title) }); // Add systems (all systems with an existing platform ID are listed). - mSystems = std::make_shared>(mWindow, getHelpStyle(), + mSystems = std::make_shared>(getHelpStyle(), "SCRAPE THESE SYSTEMS", true); for (unsigned int i = 0; i < SystemData::sSystemVector.size(); ++i) { if (!SystemData::sSystemVector[i]->hasPlatformId(PlatformIds::PLATFORM_IGNORE)) { @@ -166,11 +165,11 @@ GuiScraperMenu::~GuiScraperMenu() void GuiScraperMenu::openAccountOptions() { - auto s = new GuiSettings(mWindow, "ACCOUNT SETTINGS"); + auto s = new GuiSettings("ACCOUNT SETTINGS"); // ScreenScraper username. - auto scraper_username_screenscraper = std::make_shared( - mWindow, "", Font::get(FONT_SIZE_MEDIUM), 0x777777FF, ALIGN_RIGHT); + auto scraper_username_screenscraper = + std::make_shared("", Font::get(FONT_SIZE_MEDIUM), 0x777777FF, ALIGN_RIGHT); s->addEditableTextComponent("SCREENSCRAPER USERNAME", scraper_username_screenscraper, Settings::getInstance()->getString("ScraperUsernameScreenScraper")); s->addSaveFunc([scraper_username_screenscraper, s] { @@ -183,8 +182,8 @@ void GuiScraperMenu::openAccountOptions() }); // ScreenScraper password. - auto scraper_password_screenscraper = std::make_shared( - mWindow, "", Font::get(FONT_SIZE_MEDIUM), 0x777777FF, ALIGN_RIGHT); + auto scraper_password_screenscraper = + std::make_shared("", Font::get(FONT_SIZE_MEDIUM), 0x777777FF, ALIGN_RIGHT); std::string passwordMasked; if (Settings::getInstance()->getString("ScraperPasswordScreenScraper") != "") { passwordMasked = "********"; @@ -203,7 +202,7 @@ void GuiScraperMenu::openAccountOptions() }); // Whether to use the ScreenScraper account when scraping. - auto scraper_use_account_screenscraper = std::make_shared(mWindow); + auto scraper_use_account_screenscraper = std::make_shared(); scraper_use_account_screenscraper->setState( Settings::getInstance()->getBool("ScraperUseAccountScreenScraper")); s->addWithLabel("USE THIS ACCOUNT FOR SCREENSCRAPER", scraper_use_account_screenscraper); @@ -221,10 +220,10 @@ void GuiScraperMenu::openAccountOptions() void GuiScraperMenu::openContentOptions() { - auto s = new GuiSettings(mWindow, "CONTENT SETTINGS"); + auto s = new GuiSettings("CONTENT SETTINGS"); // Scrape game names. - auto scrape_game_names = std::make_shared(mWindow); + auto scrape_game_names = std::make_shared(); scrape_game_names->setState(Settings::getInstance()->getBool("ScrapeGameNames")); s->addWithLabel("GAME NAMES", scrape_game_names); s->addSaveFunc([scrape_game_names, s] { @@ -235,7 +234,7 @@ void GuiScraperMenu::openContentOptions() }); // Scrape ratings. - auto scrape_ratings = std::make_shared(mWindow); + auto scrape_ratings = std::make_shared(); scrape_ratings->setState(Settings::getInstance()->getBool("ScrapeRatings")); s->addWithLabel("RATINGS", scrape_ratings); s->addSaveFunc([scrape_ratings, s] { @@ -255,7 +254,7 @@ void GuiScraperMenu::openContentOptions() } // Scrape controllers (arcade systems only). - auto scrapeControllers = std::make_shared(mWindow); + auto scrapeControllers = std::make_shared(); scrapeControllers->setState(Settings::getInstance()->getBool("ScrapeControllers")); s->addWithLabel("CONTROLLERS (ARCADE SYSTEMS ONLY)", scrapeControllers); s->addSaveFunc([scrapeControllers, s] { @@ -277,7 +276,7 @@ void GuiScraperMenu::openContentOptions() } // Scrape other metadata. - auto scrape_metadata = std::make_shared(mWindow); + auto scrape_metadata = std::make_shared(); scrape_metadata->setState(Settings::getInstance()->getBool("ScrapeMetadata")); s->addWithLabel("OTHER METADATA", scrape_metadata); s->addSaveFunc([scrape_metadata, s] { @@ -288,7 +287,7 @@ void GuiScraperMenu::openContentOptions() }); // Scrape videos. - auto scrape_videos = std::make_shared(mWindow); + auto scrape_videos = std::make_shared(); scrape_videos->setState(Settings::getInstance()->getBool("ScrapeVideos")); s->addWithLabel("VIDEOS", scrape_videos); s->addSaveFunc([scrape_videos, s] { @@ -308,7 +307,7 @@ void GuiScraperMenu::openContentOptions() } // Scrape screenshots images. - auto scrape_screenshots = std::make_shared(mWindow); + auto scrape_screenshots = std::make_shared(); scrape_screenshots->setState(Settings::getInstance()->getBool("ScrapeScreenshots")); s->addWithLabel("SCREENSHOT IMAGES", scrape_screenshots); s->addSaveFunc([scrape_screenshots, s] { @@ -320,7 +319,7 @@ void GuiScraperMenu::openContentOptions() }); // Scrape title screen images. - auto scrapeTitleScreens = std::make_shared(mWindow); + auto scrapeTitleScreens = std::make_shared(); scrapeTitleScreens->setState(Settings::getInstance()->getBool("ScrapeTitleScreens")); s->addWithLabel("TITLE SCREEN IMAGES", scrapeTitleScreens); s->addSaveFunc([scrapeTitleScreens, s] { @@ -332,7 +331,7 @@ void GuiScraperMenu::openContentOptions() }); // Scrape box cover images. - auto scrape_covers = std::make_shared(mWindow); + auto scrape_covers = std::make_shared(); scrape_covers->setState(Settings::getInstance()->getBool("ScrapeCovers")); s->addWithLabel("BOX COVER IMAGES", scrape_covers); s->addSaveFunc([scrape_covers, s] { @@ -343,7 +342,7 @@ void GuiScraperMenu::openContentOptions() }); // Scrape box back cover images. - auto scrapeBackCovers = std::make_shared(mWindow); + auto scrapeBackCovers = std::make_shared(); scrapeBackCovers->setState(Settings::getInstance()->getBool("ScrapeBackCovers")); s->addWithLabel("BOX BACK COVER IMAGES", scrapeBackCovers); s->addSaveFunc([scrapeBackCovers, s] { @@ -354,7 +353,7 @@ void GuiScraperMenu::openContentOptions() }); // Scrape marquee images. - auto scrape_marquees = std::make_shared(mWindow); + auto scrape_marquees = std::make_shared(); scrape_marquees->setState(Settings::getInstance()->getBool("ScrapeMarquees")); s->addWithLabel("MARQUEE (WHEEL) IMAGES", scrape_marquees); s->addSaveFunc([scrape_marquees, s] { @@ -365,7 +364,7 @@ void GuiScraperMenu::openContentOptions() }); // Scrape 3D box images. - auto scrape_3dboxes = std::make_shared(mWindow); + auto scrape_3dboxes = std::make_shared(); scrape_3dboxes->setState(Settings::getInstance()->getBool("Scrape3DBoxes")); s->addWithLabel("3D BOX IMAGES", scrape_3dboxes); s->addSaveFunc([scrape_3dboxes, s] { @@ -386,7 +385,7 @@ void GuiScraperMenu::openContentOptions() } // Scrape physical media images. - auto scrapePhysicalMedia = std::make_shared(mWindow); + auto scrapePhysicalMedia = std::make_shared(); scrapePhysicalMedia->setState(Settings::getInstance()->getBool("ScrapePhysicalMedia")); s->addWithLabel("PHYSICAL MEDIA IMAGES", scrapePhysicalMedia); s->addSaveFunc([scrapePhysicalMedia, s] { @@ -409,7 +408,7 @@ void GuiScraperMenu::openContentOptions() } // Scrape fan art images. - auto scrapeFanArt = std::make_shared(mWindow); + auto scrapeFanArt = std::make_shared(); scrapeFanArt->setState(Settings::getInstance()->getBool("ScrapeFanArt")); s->addWithLabel("FAN ART IMAGES", scrapeFanArt); s->addSaveFunc([scrapeFanArt, s] { @@ -424,11 +423,11 @@ void GuiScraperMenu::openContentOptions() void GuiScraperMenu::openMiximageOptions() { - auto s = new GuiSettings(mWindow, "MIXIMAGE SETTINGS"); + auto s = new GuiSettings("MIXIMAGE SETTINGS"); // Miximage resolution. auto miximage_resolution = std::make_shared>( - mWindow, getHelpStyle(), "MIXIMAGE RESOLUTION", false); + getHelpStyle(), "MIXIMAGE RESOLUTION", false); std::string selectedResolution = Settings::getInstance()->getString("MiximageResolution"); miximage_resolution->add("1280x960", "1280x960", selectedResolution == "1280x960"); miximage_resolution->add("1920x1440", "1920x1440", selectedResolution == "1920x1440"); @@ -449,7 +448,7 @@ void GuiScraperMenu::openMiximageOptions() // Screenshot scaling method. auto miximage_scaling = std::make_shared>( - mWindow, getHelpStyle(), "SCREENSHOT SCALING", false); + getHelpStyle(), "SCREENSHOT SCALING", false); std::string selectedScaling = Settings::getInstance()->getString("MiximageScreenshotScaling"); miximage_scaling->add("sharp", "sharp", selectedScaling == "sharp"); miximage_scaling->add("smooth", "smooth", selectedScaling == "smooth"); @@ -468,8 +467,8 @@ void GuiScraperMenu::openMiximageOptions() }); // Box/cover size. - auto miximageBoxSize = std::make_shared>( - mWindow, getHelpStyle(), "BOX SIZE", false); + auto miximageBoxSize = + std::make_shared>(getHelpStyle(), "BOX SIZE", false); std::string selectedBoxSize = Settings::getInstance()->getString("MiximageBoxSize"); miximageBoxSize->add("small", "small", selectedBoxSize == "small"); miximageBoxSize->add("medium", "medium", selectedBoxSize == "medium"); @@ -489,7 +488,7 @@ void GuiScraperMenu::openMiximageOptions() // Physical media size. auto miximagePhysicalMediaSize = std::make_shared>( - mWindow, getHelpStyle(), "PHYSICAL MEDIA SIZE", false); + getHelpStyle(), "PHYSICAL MEDIA SIZE", false); std::string selectedPhysicalMediaSize = Settings::getInstance()->getString("MiximagePhysicalMediaSize"); miximagePhysicalMediaSize->add("small", "small", selectedPhysicalMediaSize == "small"); @@ -510,7 +509,7 @@ void GuiScraperMenu::openMiximageOptions() }); // Whether to generate miximages when scraping. - auto miximage_generate = std::make_shared(mWindow); + auto miximage_generate = std::make_shared(); miximage_generate->setState(Settings::getInstance()->getBool("MiximageGenerate")); s->addWithLabel("GENERATE MIXIMAGES WHEN SCRAPING", miximage_generate); s->addSaveFunc([miximage_generate, s] { @@ -521,7 +520,7 @@ void GuiScraperMenu::openMiximageOptions() }); // Whether to overwrite miximages (both for the scraper and offline generator). - auto miximage_overwrite = std::make_shared(mWindow); + auto miximage_overwrite = std::make_shared(); miximage_overwrite->setState(Settings::getInstance()->getBool("MiximageOverwrite")); s->addWithLabel("OVERWRITE MIXIMAGES (SCRAPER/OFFLINE GENERATOR)", miximage_overwrite); s->addSaveFunc([miximage_overwrite, s] { @@ -533,7 +532,7 @@ void GuiScraperMenu::openMiximageOptions() }); // Whether to remove letterboxes from the screenshots. - auto remove_letterboxes = std::make_shared(mWindow); + auto remove_letterboxes = std::make_shared(); remove_letterboxes->setState(Settings::getInstance()->getBool("MiximageRemoveLetterboxes")); s->addWithLabel("REMOVE LETTERBOXES FROM SCREENSHOTS", remove_letterboxes); s->addSaveFunc([remove_letterboxes, s] { @@ -546,7 +545,7 @@ void GuiScraperMenu::openMiximageOptions() }); // Whether to remove pillarboxes from the screenshots. - auto remove_pillarboxes = std::make_shared(mWindow); + auto remove_pillarboxes = std::make_shared(); remove_pillarboxes->setState(Settings::getInstance()->getBool("MiximageRemovePillarboxes")); s->addWithLabel("REMOVE PILLARBOXES FROM SCREENSHOTS", remove_pillarboxes); s->addSaveFunc([remove_pillarboxes, s] { @@ -559,7 +558,7 @@ void GuiScraperMenu::openMiximageOptions() }); // Whether to rotate horizontally oriented boxes. - auto miximageRotateBoxes = std::make_shared(mWindow); + auto miximageRotateBoxes = std::make_shared(); miximageRotateBoxes->setState( Settings::getInstance()->getBool("MiximageRotateHorizontalBoxes")); s->addWithLabel("ROTATE HORIZONTALLY ORIENTED BOXES", miximageRotateBoxes); @@ -573,7 +572,7 @@ void GuiScraperMenu::openMiximageOptions() }); // Whether to include marquee images. - auto miximage_marquee = std::make_shared(mWindow); + auto miximage_marquee = std::make_shared(); miximage_marquee->setState(Settings::getInstance()->getBool("MiximageIncludeMarquee")); s->addWithLabel("INCLUDE MARQUEE IMAGE", miximage_marquee); s->addSaveFunc([miximage_marquee, s] { @@ -586,7 +585,7 @@ void GuiScraperMenu::openMiximageOptions() }); // Whether to include box images. - auto miximage_box = std::make_shared(mWindow); + auto miximage_box = std::make_shared(); miximage_box->setState(Settings::getInstance()->getBool("MiximageIncludeBox")); s->addWithLabel("INCLUDE BOX IMAGE", miximage_box); s->addSaveFunc([miximage_box, s] { @@ -597,7 +596,7 @@ void GuiScraperMenu::openMiximageOptions() }); // Whether to use cover image if there is no 3D box image. - auto miximage_cover_fallback = std::make_shared(mWindow); + auto miximage_cover_fallback = std::make_shared(); miximage_cover_fallback->setState(Settings::getInstance()->getBool("MiximageCoverFallback")); s->addWithLabel("USE COVER IMAGE IF 3D BOX IS MISSING", miximage_cover_fallback); s->addSaveFunc([miximage_cover_fallback, s] { @@ -610,7 +609,7 @@ void GuiScraperMenu::openMiximageOptions() }); // Whether to include physical media images. - auto miximagePhysicalMedia = std::make_shared(mWindow); + auto miximagePhysicalMedia = std::make_shared(); miximagePhysicalMedia->setState( Settings::getInstance()->getBool("MiximageIncludePhysicalMedia")); s->addWithLabel("INCLUDE PHYSICAL MEDIA IMAGE", miximagePhysicalMedia); @@ -626,11 +625,11 @@ void GuiScraperMenu::openMiximageOptions() // Miximage offline generator. ComponentListRow offline_generator_row; offline_generator_row.elements.clear(); - offline_generator_row.addElement(std::make_shared(mWindow, "OFFLINE GENERATOR", + offline_generator_row.addElement(std::make_shared("OFFLINE GENERATOR", Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true); - offline_generator_row.addElement(makeArrow(mWindow), false); + offline_generator_row.addElement(makeArrow(), false); offline_generator_row.makeAcceptInputHandler( std::bind(&GuiScraperMenu::openOfflineGenerator, this, s)); s->addRow(offline_generator_row); @@ -641,7 +640,7 @@ void GuiScraperMenu::openMiximageOptions() void GuiScraperMenu::openOfflineGenerator(GuiSettings* settings) { if (mSystems->getSelectedObjects().empty()) { - mWindow->pushGui(new GuiMsgBox(mWindow, getHelpStyle(), + mWindow->pushGui(new GuiMsgBox(getHelpStyle(), "THE OFFLINE GENERATOR USES THE SAME SYSTEM\n" "SELECTIONS AS THE SCRAPER, SO PLEASE SELECT\n" "AT LEAST ONE SYSTEM TO GENERATE IMAGES FOR")); @@ -669,16 +668,16 @@ void GuiScraperMenu::openOfflineGenerator(GuiSettings* settings) gameQueue.push(game); } - mWindow->pushGui(new GuiOfflineGenerator(mWindow, gameQueue)); + mWindow->pushGui(new GuiOfflineGenerator(gameQueue)); } void GuiScraperMenu::openOtherOptions() { - auto s = new GuiSettings(mWindow, "OTHER SETTINGS"); + auto s = new GuiSettings("OTHER SETTINGS"); // Scraper region. - auto scraper_region = std::make_shared>( - mWindow, getHelpStyle(), "REGION", false); + auto scraper_region = + std::make_shared>(getHelpStyle(), "REGION", false); std::string selectedScraperRegion = Settings::getInstance()->getString("ScraperRegion"); // clang-format off scraper_region->add("Europe", "eu", selectedScraperRegion == "eu"); @@ -709,7 +708,7 @@ void GuiScraperMenu::openOtherOptions() // Scraper language. auto scraper_language = std::make_shared>( - mWindow, getHelpStyle(), "PREFERRED LANGUAGE", false); + getHelpStyle(), "PREFERRED LANGUAGE", false); std::string selectedScraperLanguage = Settings::getInstance()->getString("ScraperLanguage"); // clang-format off scraper_language->add("English", "en", selectedScraperLanguage == "en"); @@ -757,7 +756,7 @@ void GuiScraperMenu::openOtherOptions() } // Overwrite files and data. - auto scraper_overwrite_data = std::make_shared(mWindow); + auto scraper_overwrite_data = std::make_shared(); scraper_overwrite_data->setState(Settings::getInstance()->getBool("ScraperOverwriteData")); s->addWithLabel("OVERWRITE FILES AND DATA", scraper_overwrite_data); s->addSaveFunc([scraper_overwrite_data, s] { @@ -770,7 +769,7 @@ void GuiScraperMenu::openOtherOptions() }); // Halt scraping on invalid media files. - auto scraper_halt_on_invalid_media = std::make_shared(mWindow); + auto scraper_halt_on_invalid_media = std::make_shared(); scraper_halt_on_invalid_media->setState( Settings::getInstance()->getBool("ScraperHaltOnInvalidMedia")); s->addWithLabel("HALT ON INVALID MEDIA FILES", scraper_halt_on_invalid_media); @@ -784,7 +783,7 @@ void GuiScraperMenu::openOtherOptions() }); // Search using metadata names. - auto scraper_search_metadata_name = std::make_shared(mWindow); + auto scraper_search_metadata_name = std::make_shared(); scraper_search_metadata_name->setState( Settings::getInstance()->getBool("ScraperSearchMetadataName")); s->addWithLabel("SEARCH USING METADATA NAMES", scraper_search_metadata_name); @@ -798,7 +797,7 @@ void GuiScraperMenu::openOtherOptions() }); // Include actual folders when scraping. - auto scraper_include_folders = std::make_shared(mWindow); + auto scraper_include_folders = std::make_shared(); scraper_include_folders->setState(Settings::getInstance()->getBool("ScraperIncludeFolders")); s->addWithLabel("SCRAPE ACTUAL FOLDERS", scraper_include_folders); s->addSaveFunc([scraper_include_folders, s] { @@ -811,7 +810,7 @@ void GuiScraperMenu::openOtherOptions() }); // Interactive scraping. - auto scraper_interactive = std::make_shared(mWindow); + auto scraper_interactive = std::make_shared(); scraper_interactive->setState(Settings::getInstance()->getBool("ScraperInteractive")); s->addWithLabel("INTERACTIVE MODE", scraper_interactive); s->addSaveFunc([scraper_interactive, s] { @@ -823,7 +822,7 @@ void GuiScraperMenu::openOtherOptions() }); // Semi-automatic scraping. - auto scraper_semiautomatic = std::make_shared(mWindow); + auto scraper_semiautomatic = std::make_shared(); scraper_semiautomatic->setState(Settings::getInstance()->getBool("ScraperSemiautomatic")); s->addWithLabel("AUTO-ACCEPT SINGLE GAME MATCHES", scraper_semiautomatic); s->addSaveFunc([scraper_semiautomatic, s] { @@ -845,7 +844,7 @@ void GuiScraperMenu::openOtherOptions() } // Respect the per-file multi-scraper exclusion flag. - auto scraper_respect_exclusions = std::make_shared(mWindow); + auto scraper_respect_exclusions = std::make_shared(); scraper_respect_exclusions->setState( Settings::getInstance()->getBool("ScraperRespectExclusions")); s->addWithLabel("RESPECT PER-FILE SCRAPER EXCLUSIONS", scraper_respect_exclusions); @@ -859,7 +858,7 @@ void GuiScraperMenu::openOtherOptions() }); // Exclude files recursively for excluded folders. - auto scraper_exclude_recursively = std::make_shared(mWindow); + auto scraper_exclude_recursively = std::make_shared(); scraper_exclude_recursively->setState( Settings::getInstance()->getBool("ScraperExcludeRecursively")); s->addWithLabel("EXCLUDE FOLDERS RECURSIVELY", scraper_exclude_recursively); @@ -882,7 +881,7 @@ void GuiScraperMenu::openOtherOptions() } // Retry search on peer verification errors (TLS/certificate issues). - auto retry_peer_verification = std::make_shared(mWindow); + auto retry_peer_verification = std::make_shared(); retry_peer_verification->setState( Settings::getInstance()->getBool("ScraperRetryPeerVerification")); s->addWithLabel("AUTO-RETRY ON PEER VERIFICATION ERRORS", retry_peer_verification); @@ -968,9 +967,9 @@ void GuiScraperMenu::pressedStart() "set, results may be inaccurate\n" "Continue anyway?"; } - mWindow->pushGui(new GuiMsgBox(mWindow, getHelpStyle(), - Utils::String::toUpper(warningString), "YES", - std::bind(&GuiScraperMenu::start, this), "NO", nullptr)); + mWindow->pushGui(new GuiMsgBox(getHelpStyle(), Utils::String::toUpper(warningString), + "YES", std::bind(&GuiScraperMenu::start, this), "NO", + nullptr)); return; } } @@ -981,7 +980,7 @@ void GuiScraperMenu::start() { if (mSystems->getSelectedObjects().empty()) { mWindow->pushGui( - new GuiMsgBox(mWindow, getHelpStyle(), "PLEASE SELECT AT LEAST ONE SYSTEM TO SCRAPE")); + new GuiMsgBox(getHelpStyle(), "PLEASE SELECT AT LEAST ONE SYSTEM TO SCRAPE")); return; } @@ -1049,8 +1048,8 @@ void GuiScraperMenu::start() } while (0); if (!contentToScrape) { - mWindow->pushGui(new GuiMsgBox(mWindow, getHelpStyle(), - "PLEASE SELECT AT LEAST ONE CONTENT TYPE TO SCRAPE")); + mWindow->pushGui( + new GuiMsgBox(getHelpStyle(), "PLEASE SELECT AT LEAST ONE CONTENT TYPE TO SCRAPE")); return; } @@ -1059,11 +1058,11 @@ void GuiScraperMenu::start() if (searches.empty()) { mWindow->pushGui( - new GuiMsgBox(mWindow, getHelpStyle(), "ALL GAMES WERE FILTERED, NOTHING TO SCRAPE")); + new GuiMsgBox(getHelpStyle(), "ALL GAMES WERE FILTERED, NOTHING TO SCRAPE")); } else { - GuiScraperMulti* gsm = new GuiScraperMulti( - mWindow, searches, Settings::getInstance()->getBool("ScraperInteractive")); + GuiScraperMulti* gsm = + new GuiScraperMulti(searches, Settings::getInstance()->getBool("ScraperInteractive")); mWindow->pushGui(gsm); mMenu.setCursorToList(); mMenu.setCursorToFirstListEntry(); @@ -1101,10 +1100,10 @@ void GuiScraperMenu::addEntry(const std::string& name, // Populate the list. ComponentListRow row; - row.addElement(std::make_shared(mWindow, name, font, color), true); + row.addElement(std::make_shared(name, font, color), true); if (add_arrow) { - std::shared_ptr bracket = makeArrow(mWindow); + std::shared_ptr bracket {makeArrow()}; row.addElement(bracket, false); } diff --git a/es-app/src/guis/GuiScraperMenu.h b/es-app/src/guis/GuiScraperMenu.h index f54444857..ac54693a1 100644 --- a/es-app/src/guis/GuiScraperMenu.h +++ b/es-app/src/guis/GuiScraperMenu.h @@ -25,7 +25,7 @@ using GameFilterFunc = std::function; class GuiScraperMenu : public GuiComponent { public: - GuiScraperMenu(Window* window, std::string title); + GuiScraperMenu(std::string title); ~GuiScraperMenu(); bool input(InputConfig* config, Input input) override; diff --git a/es-app/src/guis/GuiScraperMulti.cpp b/es-app/src/guis/GuiScraperMulti.cpp index abd8ee9c0..3cfa62ffb 100644 --- a/es-app/src/guis/GuiScraperMulti.cpp +++ b/es-app/src/guis/GuiScraperMulti.cpp @@ -24,12 +24,10 @@ #include "guis/GuiScraperSearch.h" #include "views/ViewController.h" -GuiScraperMulti::GuiScraperMulti(Window* window, - const std::queue& searches, +GuiScraperMulti::GuiScraperMulti(const std::queue& searches, bool approveResults) - : GuiComponent {window} - , mBackground {window, ":/graphics/frame.svg"} - , mGrid {window, glm::ivec2 {2, 6}} + : mBackground {":/graphics/frame.svg"} + , mGrid {glm::ivec2 {2, 6}} , mSearchQueue {searches} , mApproveResults {approveResults} { @@ -46,27 +44,27 @@ GuiScraperMulti::GuiScraperMulti(Window* window, mTotalSkipped = 0; // Set up grid. - mTitle = std::make_shared(mWindow, "SCRAPING IN PROGRESS", - Font::get(FONT_SIZE_LARGE), 0x555555FF, ALIGN_CENTER); + mTitle = std::make_shared("SCRAPING IN PROGRESS", Font::get(FONT_SIZE_LARGE), + 0x555555FF, ALIGN_CENTER); mGrid.setEntry(mTitle, glm::ivec2 {0, 0}, false, true, glm::ivec2 {2, 2}); - mSystem = std::make_shared(mWindow, "SYSTEM", Font::get(FONT_SIZE_MEDIUM), - 0x777777FF, ALIGN_CENTER); + mSystem = std::make_shared("SYSTEM", Font::get(FONT_SIZE_MEDIUM), 0x777777FF, + ALIGN_CENTER); mGrid.setEntry(mSystem, glm::ivec2 {0, 2}, false, true, glm::ivec2 {2, 1}); - mSubtitle = std::make_shared( - mWindow, "subtitle text", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_CENTER); + mSubtitle = std::make_shared("subtitle text", Font::get(FONT_SIZE_SMALL), + 0x888888FF, ALIGN_CENTER); mGrid.setEntry(mSubtitle, glm::ivec2 {0, 3}, false, true, glm::ivec2 {2, 1}); if (mApproveResults && !Settings::getInstance()->getBool("ScraperSemiautomatic")) - mSearchComp = std::make_shared( - mWindow, GuiScraperSearch::NEVER_AUTO_ACCEPT, mTotalGames); + mSearchComp = + std::make_shared(GuiScraperSearch::NEVER_AUTO_ACCEPT, mTotalGames); else if (mApproveResults && Settings::getInstance()->getBool("ScraperSemiautomatic")) - mSearchComp = std::make_shared( - mWindow, GuiScraperSearch::ACCEPT_SINGLE_MATCHES, mTotalGames); + mSearchComp = std::make_shared(GuiScraperSearch::ACCEPT_SINGLE_MATCHES, + mTotalGames); else if (!mApproveResults) mSearchComp = std::make_shared( - mWindow, GuiScraperSearch::ALWAYS_ACCEPT_FIRST_RESULT, mTotalGames); + GuiScraperSearch::ALWAYS_ACCEPT_FIRST_RESULT, mTotalGames); mSearchComp->setAcceptCallback( std::bind(&GuiScraperMulti::acceptResult, this, std::placeholders::_1)); mSearchComp->setSkipCallback(std::bind(&GuiScraperMulti::skip, this)); @@ -84,8 +82,8 @@ GuiScraperMulti::GuiScraperMulti(Window* window, mResultList = mSearchComp->getResultList(); // Set up scroll indicators. - mScrollUp = std::make_shared(mWindow); - mScrollDown = std::make_shared(mWindow); + mScrollUp = std::make_shared(); + mScrollDown = std::make_shared(); mScrollIndicator = std::make_shared(mResultList, mScrollUp, mScrollDown); @@ -102,42 +100,38 @@ GuiScraperMulti::GuiScraperMulti(Window* window, std::vector> buttons; if (mApproveResults) { - buttons.push_back( - std::make_shared(mWindow, "REFINE SEARCH", "refine search", [&] { - // Check whether we should allow a refine of the game name. - if (!mSearchComp->getAcceptedResult()) { - bool allowRefine = false; + buttons.push_back(std::make_shared("REFINE SEARCH", "refine search", [&] { + // Check whether we should allow a refine of the game name. + if (!mSearchComp->getAcceptedResult()) { + bool allowRefine = false; - // Previously refined. - if (mSearchComp->getRefinedSearch()) - allowRefine = true; - // Interactive mode and "Auto-accept single game matches" not enabled. - else if (mSearchComp->getSearchType() != - GuiScraperSearch::ACCEPT_SINGLE_MATCHES) - allowRefine = true; - // Interactive mode with "Auto-accept single game matches" enabled and more - // than one result. - else if (mSearchComp->getSearchType() == - GuiScraperSearch::ACCEPT_SINGLE_MATCHES && - mSearchComp->getScraperResultsSize() > 1) - allowRefine = true; - // Dito but there were no games found, or the search has not been completed. - else if (mSearchComp->getSearchType() == - GuiScraperSearch::ACCEPT_SINGLE_MATCHES && - !mSearchComp->getFoundGame()) - allowRefine = true; + // Previously refined. + if (mSearchComp->getRefinedSearch()) + allowRefine = true; + // Interactive mode and "Auto-accept single game matches" not enabled. + else if (mSearchComp->getSearchType() != GuiScraperSearch::ACCEPT_SINGLE_MATCHES) + allowRefine = true; + // Interactive mode with "Auto-accept single game matches" enabled and more + // than one result. + else if (mSearchComp->getSearchType() == GuiScraperSearch::ACCEPT_SINGLE_MATCHES && + mSearchComp->getScraperResultsSize() > 1) + allowRefine = true; + // Dito but there were no games found, or the search has not been completed. + else if (mSearchComp->getSearchType() == GuiScraperSearch::ACCEPT_SINGLE_MATCHES && + !mSearchComp->getFoundGame()) + allowRefine = true; - if (allowRefine) { - // Copy any search refine that may have been previously entered by opening - // the input screen using the "Y" button shortcut. - mSearchQueue.front().nameOverride = mSearchComp->getNameOverride(); - mSearchComp->openInputScreen(mSearchQueue.front()); - mGrid.resetCursor(); - } + if (allowRefine) { + // Copy any search refine that may have been previously entered by opening + // the input screen using the "Y" button shortcut. + mSearchQueue.front().nameOverride = mSearchComp->getNameOverride(); + mSearchComp->openInputScreen(mSearchQueue.front()); + mGrid.resetCursor(); } - })); + } + })); - buttons.push_back(std::make_shared(mWindow, "SKIP", "skip game", [&] { + buttons.push_back(std::make_shared("SKIP", "skip game", [&] { // Skip game, unless the result has already been accepted. if (!mSearchComp->getAcceptedResult()) { skip(); @@ -146,10 +140,10 @@ GuiScraperMulti::GuiScraperMulti(Window* window, })); } - buttons.push_back(std::make_shared(mWindow, "STOP", "stop", + buttons.push_back(std::make_shared("STOP", "stop", std::bind(&GuiScraperMulti::finish, this))); - mButtonGrid = makeButtonGrid(mWindow, buttons); + mButtonGrid = makeButtonGrid(buttons); mGrid.setEntry(mButtonGrid, glm::ivec2 {0, 5}, true, false, glm::ivec2 {2, 1}); // Limit the width of the GUI on ultrawide monitors. The 1.778 aspect ratio value is @@ -309,7 +303,7 @@ void GuiScraperMulti::finish() << mTotalSkipped << " GAME" << ((mTotalSkipped > 1) ? "S" : "") << " SKIPPED"; } - mWindow->pushGui(new GuiMsgBox(mWindow, getHelpStyle(), ss.str(), "OK", [&] { + mWindow->pushGui(new GuiMsgBox(getHelpStyle(), ss.str(), "OK", [&] { mIsProcessing = false; delete this; })); diff --git a/es-app/src/guis/GuiScraperMulti.h b/es-app/src/guis/GuiScraperMulti.h index d71525086..03747d46e 100644 --- a/es-app/src/guis/GuiScraperMulti.h +++ b/es-app/src/guis/GuiScraperMulti.h @@ -25,9 +25,7 @@ class TextComponent; class GuiScraperMulti : public GuiComponent { public: - GuiScraperMulti(Window* window, - const std::queue& searches, - bool approveResults); + GuiScraperMulti(const std::queue& searches, bool approveResults); virtual ~GuiScraperMulti(); diff --git a/es-app/src/guis/GuiScraperSearch.cpp b/es-app/src/guis/GuiScraperSearch.cpp index d4df09628..6c0229709 100644 --- a/es-app/src/guis/GuiScraperSearch.cpp +++ b/es-app/src/guis/GuiScraperSearch.cpp @@ -37,15 +37,13 @@ #define FAILED_VERIFICATION_RETRIES 8 -GuiScraperSearch::GuiScraperSearch(Window* window, SearchType type, unsigned int scrapeCount) - : GuiComponent {window} - , mGrid {window, glm::ivec2 {5, 3}} +GuiScraperSearch::GuiScraperSearch(SearchType type, unsigned int scrapeCount) + : mGrid {glm::ivec2 {5, 3}} , mSearchType {type} , mScrapeCount {scrapeCount} , mRefinedSearch {false} , mFoundGame {false} , mScrapeRatings {false} - , mBusyAnim {window} { addChild(&mGrid); @@ -55,19 +53,19 @@ GuiScraperSearch::GuiScraperSearch(Window* window, SearchType type, unsigned int mRetryCount = 0; // Left spacer (empty component, needed for borders). - mGrid.setEntry(std::make_shared(mWindow), glm::ivec2 {0, 0}, false, false, + mGrid.setEntry(std::make_shared(), glm::ivec2 {0, 0}, false, false, glm::ivec2 {1, 3}, GridFlags::BORDER_TOP | GridFlags::BORDER_BOTTOM); // Selected result name. - mResultName = std::make_shared(mWindow, "Result name", - Font::get(FONT_SIZE_MEDIUM), 0x777777FF); + mResultName = + std::make_shared("Result name", Font::get(FONT_SIZE_MEDIUM), 0x777777FF); // Selected result thumbnail. - mResultThumbnail = std::make_shared(mWindow); + mResultThumbnail = std::make_shared(); mGrid.setEntry(mResultThumbnail, glm::ivec2 {1, 1}, false, false, glm::ivec2 {1, 1}); // Selected result description and container. - mDescContainer = std::make_shared(mWindow); + mDescContainer = std::make_shared(); // Adjust the game description text scrolling parameters depending on the search type. if (mSearchType == NEVER_AUTO_ACCEPT) @@ -75,8 +73,8 @@ GuiScraperSearch::GuiScraperSearch(Window* window, SearchType type, unsigned int else mDescContainer->setScrollParameters(6000.0f, 3000.0f, 0.8f); - mResultDesc = std::make_shared(mWindow, "Result desc", - Font::get(FONT_SIZE_SMALL), 0x777777FF); + mResultDesc = + std::make_shared("Result desc", Font::get(FONT_SIZE_SMALL), 0x777777FF); mDescContainer->addChild(mResultDesc.get()); mDescContainer->setAutoScroll(true); @@ -84,44 +82,42 @@ GuiScraperSearch::GuiScraperSearch(Window* window, SearchType type, unsigned int auto font = Font::get(FONT_SIZE_SMALL); // Placeholder, gets replaced in onSizeChanged(). const unsigned int mdColor = 0x777777FF; const unsigned int mdLblColor = 0x666666FF; - mMD_Rating = std::make_shared(mWindow); - mMD_ReleaseDate = std::make_shared(mWindow); + mMD_Rating = std::make_shared(); + mMD_ReleaseDate = std::make_shared(); mMD_ReleaseDate->setColor(mdColor); mMD_ReleaseDate->setUppercase(true); - mMD_Developer = std::make_shared(mWindow, "", font, mdColor, ALIGN_LEFT); - mMD_Publisher = std::make_shared(mWindow, "", font, mdColor, ALIGN_LEFT); - mMD_Genre = - std::make_shared(mWindow, "", font, mdColor, ALIGN_LEFT, glm::vec3 {}); - mMD_Players = std::make_shared(mWindow, "", font, mdColor, ALIGN_LEFT); - mMD_Filler = std::make_shared(mWindow, "", font, mdColor); + mMD_Developer = std::make_shared("", font, mdColor, ALIGN_LEFT); + mMD_Publisher = std::make_shared("", font, mdColor, ALIGN_LEFT); + mMD_Genre = std::make_shared("", font, mdColor, ALIGN_LEFT, glm::vec3 {}); + mMD_Players = std::make_shared("", font, mdColor, ALIGN_LEFT); + mMD_Filler = std::make_shared("", font, mdColor); if (Settings::getInstance()->getString("Scraper") != "thegamesdb") mScrapeRatings = true; if (mScrapeRatings) - mMD_Pairs.push_back( - MetaDataPair(std::make_shared(mWindow, "RATING:", font, mdLblColor), - mMD_Rating, false)); + mMD_Pairs.push_back(MetaDataPair( + std::make_shared("RATING:", font, mdLblColor), mMD_Rating, false)); + mMD_Pairs.push_back(MetaDataPair(std::make_shared("RELEASED:", font, mdLblColor), + mMD_ReleaseDate)); mMD_Pairs.push_back(MetaDataPair( - std::make_shared(mWindow, "RELEASED:", font, mdLblColor), mMD_ReleaseDate)); + std::make_shared("DEVELOPER:", font, mdLblColor), mMD_Developer)); mMD_Pairs.push_back(MetaDataPair( - std::make_shared(mWindow, "DEVELOPER:", font, mdLblColor), mMD_Developer)); - mMD_Pairs.push_back(MetaDataPair( - std::make_shared(mWindow, "PUBLISHER:", font, mdLblColor), mMD_Publisher)); - mMD_Pairs.push_back(MetaDataPair( - std::make_shared(mWindow, "GENRE:", font, mdLblColor), mMD_Genre)); - mMD_Pairs.push_back(MetaDataPair( - std::make_shared(mWindow, "PLAYERS:", font, mdLblColor), mMD_Players)); + std::make_shared("PUBLISHER:", font, mdLblColor), mMD_Publisher)); + mMD_Pairs.push_back( + MetaDataPair(std::make_shared("GENRE:", font, mdLblColor), mMD_Genre)); + mMD_Pairs.push_back( + MetaDataPair(std::make_shared("PLAYERS:", font, mdLblColor), mMD_Players)); // If no rating is being scraped, add a filler to make sure that the fonts keep the same // size so the GUI looks consistent. if (!mScrapeRatings) - mMD_Pairs.push_back(MetaDataPair( - std::make_shared(mWindow, "", font, mdLblColor), mMD_Filler)); + mMD_Pairs.push_back( + MetaDataPair(std::make_shared("", font, mdLblColor), mMD_Filler)); - mMD_Grid = std::make_shared( - mWindow, glm::ivec2 {2, static_cast(mMD_Pairs.size() * 2 - 1)}); + mMD_Grid = + std::make_shared(glm::ivec2 {2, static_cast(mMD_Pairs.size() * 2 - 1)}); unsigned int i = 0; for (auto it = mMD_Pairs.cbegin(); it != mMD_Pairs.cend(); ++it) { mMD_Grid->setEntry(it->first, glm::ivec2 {0, i}, false, true); @@ -132,7 +128,7 @@ GuiScraperSearch::GuiScraperSearch(Window* window, SearchType type, unsigned int mGrid.setEntry(mMD_Grid, glm::ivec2 {2, 1}, false, false); // Result list. - mResultList = std::make_shared(mWindow); + mResultList = std::make_shared(); mResultList->setCursorChangedCallback([this](CursorState state) { if (state == CURSOR_STOPPED) updateInfoPane(); @@ -292,7 +288,7 @@ void GuiScraperSearch::updateViewStyle() GridFlags::BORDER_TOP); // Need a border on the bottom left. - mGrid.setEntry(std::make_shared(mWindow), glm::ivec2 {0, 2}, false, false, + mGrid.setEntry(std::make_shared(), glm::ivec2 {0, 2}, false, false, glm::ivec2 {4, 1}, GridFlags::BORDER_BOTTOM); // Show description on the right. @@ -303,7 +299,7 @@ void GuiScraperSearch::updateViewStyle() } else { // Fake row where name would be. - mGrid.setEntry(std::make_shared(mWindow), glm::ivec2 {1, 0}, false, true, + mGrid.setEntry(std::make_shared(), glm::ivec2 {1, 0}, false, true, glm::ivec2 {3, 1}, GridFlags::BORDER_TOP); // Show result list on the right. @@ -364,7 +360,7 @@ void GuiScraperSearch::onSearchDone(std::vector& results) // Check if the scraper used is still valid. if (!isValidConfiguredScraper()) { mWindow->pushGui(new GuiMsgBox( - mWindow, getHelpStyle(), + getHelpStyle(), Utils::String::toUpper("Configured scraper is no longer available.\n" "Please change the scraping source in the settings."), "FINISH", mSkipCallback)); @@ -372,8 +368,7 @@ void GuiScraperSearch::onSearchDone(std::vector& results) else { mFoundGame = false; ComponentListRow row; - row.addElement(std::make_shared(mWindow, "NO GAMES FOUND", font, color), - true); + row.addElement(std::make_shared("NO GAMES FOUND", font, color), true); if (mSkipCallback) row.makeAcceptInputHandler(mSkipCallback); @@ -434,9 +429,9 @@ void GuiScraperSearch::onSearchDone(std::vector& results) gameName.append(" [").append(otherPlatforms).append("]"); row.elements.clear(); - row.addElement(std::make_shared( - mWindow, Utils::String::toUpper(gameName), font, color), - false); + row.addElement( + std::make_shared(Utils::String::toUpper(gameName), font, color), + false); row.makeAcceptInputHandler([this, i] { returnResult(mScraperResults.at(i)); }); mResultList->addRow(row); } @@ -498,15 +493,13 @@ void GuiScraperSearch::onSearchError(const std::string& error, HttpReq::Status s if (mScrapeCount > 1) { LOG(LogError) << "GuiScraperSearch: " << Utils::String::replace(error, "\n", ""); - mWindow->pushGui(new GuiMsgBox(mWindow, getHelpStyle(), Utils::String::toUpper(error), - "RETRY", + mWindow->pushGui(new GuiMsgBox(getHelpStyle(), Utils::String::toUpper(error), "RETRY", std::bind(&GuiScraperSearch::search, this, mLastSearch), "SKIP", mSkipCallback, "CANCEL", mCancelCallback, true)); } else { LOG(LogError) << "GuiScraperSearch: " << Utils::String::replace(error, "\n", ""); - mWindow->pushGui(new GuiMsgBox(mWindow, getHelpStyle(), Utils::String::toUpper(error), - "RETRY", + mWindow->pushGui(new GuiMsgBox(getHelpStyle(), Utils::String::toUpper(error), "RETRY", std::bind(&GuiScraperSearch::search, this, mLastSearch), "CANCEL", mCancelCallback, "", nullptr, true)); } @@ -899,13 +892,13 @@ void GuiScraperSearch::openInputScreen(ScraperSearchParams& params) } if (Settings::getInstance()->getBool("VirtualKeyboard")) { - mWindow->pushGui(new GuiTextEditKeyboardPopup(mWindow, getHelpStyle(), "REFINE SEARCH", - searchString, searchForFunc, false, "SEARCH", + mWindow->pushGui(new GuiTextEditKeyboardPopup(getHelpStyle(), "REFINE SEARCH", searchString, + searchForFunc, false, "SEARCH", "SEARCH USING REFINED NAME?")); } else { - mWindow->pushGui(new GuiTextEditPopup(mWindow, getHelpStyle(), "REFINE SEARCH", - searchString, searchForFunc, false, "SEARCH", + mWindow->pushGui(new GuiTextEditPopup(getHelpStyle(), "REFINE SEARCH", searchString, + searchForFunc, false, "SEARCH", "SEARCH USING REFINED NAME?")); } } diff --git a/es-app/src/guis/GuiScraperSearch.h b/es-app/src/guis/GuiScraperSearch.h index 354f4a3e8..8184ea37a 100644 --- a/es-app/src/guis/GuiScraperSearch.h +++ b/es-app/src/guis/GuiScraperSearch.h @@ -41,7 +41,7 @@ public: NEVER_AUTO_ACCEPT // Manual mode. }; - GuiScraperSearch(Window* window, SearchType searchType, unsigned int scrapeCount = 1); + GuiScraperSearch(SearchType searchType, unsigned int scrapeCount = 1); ~GuiScraperSearch(); void search(const ScraperSearchParams& params); diff --git a/es-app/src/guis/GuiScraperSingle.cpp b/es-app/src/guis/GuiScraperSingle.cpp index f7cae22b6..4d4ca40b6 100644 --- a/es-app/src/guis/GuiScraperSingle.cpp +++ b/es-app/src/guis/GuiScraperSingle.cpp @@ -18,18 +18,16 @@ #include "components/TextComponent.h" #include "views/ViewController.h" -GuiScraperSingle::GuiScraperSingle(Window* window, - ScraperSearchParams& params, +GuiScraperSingle::GuiScraperSingle(ScraperSearchParams& params, std::function doneFunc, bool& savedMediaAndAborted) - : GuiComponent {window} - , mClose {false} - , mGrid {window, glm::ivec2 {2, 6}} - , mBox {window, ":/graphics/frame.svg"} + : mClose {false} + , mGrid {glm::ivec2 {2, 6}} + , mBackground {":/graphics/frame.svg"} , mSearchParams {params} , mSavedMediaAndAborted {savedMediaAndAborted} { - addChild(&mBox); + addChild(&mBackground); addChild(&mGrid); std::string scrapeName; @@ -48,29 +46,28 @@ GuiScraperSingle::GuiScraperSingle(Window* window, } mGameName = std::make_shared( - mWindow, scrapeName + ((mSearchParams.game->getType() == FOLDER) ? " " + ViewController::FOLDER_CHAR : ""), Font::get(FONT_SIZE_LARGE), 0x777777FF, ALIGN_CENTER); mGameName->setColor(0x555555FF); mGrid.setEntry(mGameName, glm::ivec2 {0, 0}, false, true, glm::ivec2 {2, 2}); - mSystemName = std::make_shared( - mWindow, Utils::String::toUpper(mSearchParams.system->getFullName()), - Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_CENTER); + mSystemName = + std::make_shared(Utils::String::toUpper(mSearchParams.system->getFullName()), + Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_CENTER); mGrid.setEntry(mSystemName, glm::ivec2 {0, 2}, false, true, glm::ivec2 {2, 1}); // Row 3 is a spacer. // GuiScraperSearch. - mSearch = std::make_shared(window, GuiScraperSearch::NEVER_AUTO_ACCEPT, 1); + mSearch = std::make_shared(GuiScraperSearch::NEVER_AUTO_ACCEPT, 1); mGrid.setEntry(mSearch, glm::ivec2 {0, 4}, true, true, glm::ivec2 {2, 1}); mResultList = mSearch->getResultList(); // Set up scroll indicators. - mScrollUp = std::make_shared(mWindow); - mScrollDown = std::make_shared(mWindow); + mScrollUp = std::make_shared(); + mScrollDown = std::make_shared(); mScrollIndicator = std::make_shared(mResultList, mScrollUp, mScrollDown); @@ -86,18 +83,17 @@ GuiScraperSingle::GuiScraperSingle(Window* window, // Buttons std::vector> buttons; - buttons.push_back( - std::make_shared(mWindow, "REFINE SEARCH", "refine search", [&] { - // Refine the search, unless the result has already been accepted. - if (!mSearch->getAcceptedResult()) { - // Copy any search refine that may have been previously entered by opening - // the input screen using the "Y" button shortcut. - mSearchParams.nameOverride = mSearch->getNameOverride(); - mSearch->openInputScreen(mSearchParams); - mGrid.resetCursor(); - } - })); - buttons.push_back(std::make_shared(mWindow, "CANCEL", "cancel", [&] { + buttons.push_back(std::make_shared("REFINE SEARCH", "refine search", [&] { + // Refine the search, unless the result has already been accepted. + if (!mSearch->getAcceptedResult()) { + // Copy any search refine that may have been previously entered by opening + // the input screen using the "Y" button shortcut. + mSearchParams.nameOverride = mSearch->getNameOverride(); + mSearch->openInputScreen(mSearchParams); + mGrid.resetCursor(); + } + })); + buttons.push_back(std::make_shared("CANCEL", "cancel", [&] { if (mSearch->getSavedNewMedia()) { // If the user aborted the scraping but there was still some media downloaded, // then flag to GuiMetaDataEd that the image and marquee textures need to be @@ -107,7 +103,7 @@ GuiScraperSingle::GuiScraperSingle(Window* window, } delete this; })); - mButtonGrid = makeButtonGrid(mWindow, buttons); + mButtonGrid = makeButtonGrid(buttons); mGrid.setEntry(mButtonGrid, glm::ivec2 {0, 5}, true, false, glm::ivec2 {2, 1}); @@ -156,7 +152,7 @@ void GuiScraperSingle::onSizeChanged() mGrid.setColWidthPerc(1, 0.04f); mGrid.setSize(glm::round(mSize)); - mBox.fitTo(mSize, glm::vec3 {}, glm::vec2 {-32.0f, -32.0f}); + mBackground.fitTo(mSize, glm::vec3 {}, glm::vec2 {-32.0f, -32.0f}); // Add some extra margins to the game name. const float newSizeX = mSize.x * 0.96f; diff --git a/es-app/src/guis/GuiScraperSingle.h b/es-app/src/guis/GuiScraperSingle.h index 6d837a3d0..0775f56f7 100644 --- a/es-app/src/guis/GuiScraperSingle.h +++ b/es-app/src/guis/GuiScraperSingle.h @@ -19,8 +19,7 @@ class GuiScraperSingle : public GuiComponent { public: - GuiScraperSingle(Window* window, - ScraperSearchParams& params, + GuiScraperSingle(ScraperSearchParams& params, std::function doneFunc, bool& savedMediaAndAborted); @@ -37,7 +36,7 @@ private: void close(); ComponentGrid mGrid; - NinePatchComponent mBox; + NinePatchComponent mBackground; std::shared_ptr mGameName; std::shared_ptr mScrollUp; diff --git a/es-app/src/guis/GuiScreensaverOptions.cpp b/es-app/src/guis/GuiScreensaverOptions.cpp index 359db1158..9ec6cf0e1 100644 --- a/es-app/src/guis/GuiScreensaverOptions.cpp +++ b/es-app/src/guis/GuiScreensaverOptions.cpp @@ -10,17 +10,17 @@ #include "guis/GuiScreensaverOptions.h" #include "Settings.h" +#include "Window.h" #include "components/OptionListComponent.h" #include "components/SliderComponent.h" #include "components/SwitchComponent.h" #include "guis/GuiMsgBox.h" -GuiScreensaverOptions::GuiScreensaverOptions(Window* window, const std::string& title) - : GuiSettings {window, title} - , mWindow {window} +GuiScreensaverOptions::GuiScreensaverOptions(const std::string& title) + : GuiSettings {title} { // Screensaver timer. - auto screensaver_timer = std::make_shared(mWindow, 0.0f, 30.0f, 1.0f, "m"); + auto screensaver_timer = std::make_shared(0.0f, 30.0f, 1.0f, "m"); screensaver_timer->setValue( static_cast(Settings::getInstance()->getInt("ScreensaverTimer") / (1000 * 60))); addWithLabel("START SCREENSAVER AFTER (MINUTES)", screensaver_timer); @@ -36,7 +36,7 @@ GuiScreensaverOptions::GuiScreensaverOptions(Window* window, const std::string& // Screensaver type. auto screensaver_type = std::make_shared>( - mWindow, getHelpStyle(), "SCREENSAVER TYPE", false); + getHelpStyle(), "SCREENSAVER TYPE", false); std::vector screensavers; screensavers.push_back("dim"); screensavers.push_back("black"); @@ -52,7 +52,7 @@ GuiScreensaverOptions::GuiScreensaverOptions(Window* window, const std::string& if (screensaver_type->getSelected() == "video") { // If before it wasn't risky but now there's a risk of problems, show warning. mWindow->pushGui(new GuiMsgBox( - mWindow, getHelpStyle(), + getHelpStyle(), "THE 'VIDEO' SCREENSAVER SHOWS\n" "VIDEOS FROM YOUR GAMELISTS\n\n" "IF YOU DO NOT HAVE ANY VIDEOS, THE\n" @@ -65,7 +65,7 @@ GuiScreensaverOptions::GuiScreensaverOptions(Window* window, const std::string& }); // Whether to enable screensaver controls. - auto screensaver_controls = std::make_shared(mWindow); + auto screensaver_controls = std::make_shared(); screensaver_controls->setState(Settings::getInstance()->getBool("ScreensaverControls")); addWithLabel("ENABLE SCREENSAVER CONTROLS", screensaver_controls); addSaveFunc([screensaver_controls, this] { @@ -80,19 +80,19 @@ GuiScreensaverOptions::GuiScreensaverOptions(Window* window, const std::string& // Show filtered menu. ComponentListRow row; row.elements.clear(); - row.addElement(std::make_shared(mWindow, "SLIDESHOW SCREENSAVER SETTINGS", + row.addElement(std::make_shared("SLIDESHOW SCREENSAVER SETTINGS", Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true); - row.addElement(makeArrow(mWindow), false); + row.addElement(makeArrow(), false); row.makeAcceptInputHandler( std::bind(&GuiScreensaverOptions::openSlideshowScreensaverOptions, this)); addRow(row); row.elements.clear(); - row.addElement(std::make_shared(mWindow, "VIDEO SCREENSAVER SETTINGS", + row.addElement(std::make_shared("VIDEO SCREENSAVER SETTINGS", Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true); - row.addElement(makeArrow(mWindow), false); + row.addElement(makeArrow(), false); row.makeAcceptInputHandler( std::bind(&GuiScreensaverOptions::openVideoScreensaverOptions, this)); addRow(row); @@ -102,11 +102,11 @@ GuiScreensaverOptions::GuiScreensaverOptions(Window* window, const std::string& void GuiScreensaverOptions::openSlideshowScreensaverOptions() { - auto s = new GuiSettings(mWindow, "SLIDESHOW SCREENSAVER"); + auto s = new GuiSettings("SLIDESHOW SCREENSAVER"); // Timer for swapping images (in seconds). auto screensaver_swap_image_timeout = - std::make_shared(mWindow, 2.0f, 120.0f, 2.0f, "s"); + std::make_shared(2.0f, 120.0f, 2.0f, "s"); screensaver_swap_image_timeout->setValue(static_cast( Settings::getInstance()->getInt("ScreensaverSwapImageTimeout") / (1000))); s->addWithLabel("SWAP IMAGES AFTER (SECONDS)", screensaver_swap_image_timeout); @@ -122,7 +122,7 @@ void GuiScreensaverOptions::openSlideshowScreensaverOptions() }); // Stretch images to screen resolution. - auto screensaver_stretch_images = std::make_shared(mWindow); + auto screensaver_stretch_images = std::make_shared(); screensaver_stretch_images->setState( Settings::getInstance()->getBool("ScreensaverStretchImages")); s->addWithLabel("STRETCH IMAGES TO SCREEN RESOLUTION", screensaver_stretch_images); @@ -136,7 +136,7 @@ void GuiScreensaverOptions::openSlideshowScreensaverOptions() }); // Show game info overlay for slideshow screensaver. - auto screensaver_slideshow_game_info = std::make_shared(mWindow); + auto screensaver_slideshow_game_info = std::make_shared(); screensaver_slideshow_game_info->setState( Settings::getInstance()->getBool("ScreensaverSlideshowGameInfo")); s->addWithLabel("DISPLAY GAME INFO OVERLAY", screensaver_slideshow_game_info); @@ -151,7 +151,7 @@ void GuiScreensaverOptions::openSlideshowScreensaverOptions() #if defined(USE_OPENGL_21) // Render scanlines using a shader. - auto screensaver_slideshow_scanlines = std::make_shared(mWindow); + auto screensaver_slideshow_scanlines = std::make_shared(); screensaver_slideshow_scanlines->setState( Settings::getInstance()->getBool("ScreensaverSlideshowScanlines")); s->addWithLabel("RENDER SCANLINES", screensaver_slideshow_scanlines); @@ -166,7 +166,7 @@ void GuiScreensaverOptions::openSlideshowScreensaverOptions() #endif // Whether to use custom images. - auto screensaver_slideshow_custom_images = std::make_shared(mWindow); + auto screensaver_slideshow_custom_images = std::make_shared(); screensaver_slideshow_custom_images->setState( Settings::getInstance()->getBool("ScreensaverSlideshowCustomImages")); s->addWithLabel("USE CUSTOM IMAGES", screensaver_slideshow_custom_images); @@ -180,7 +180,7 @@ void GuiScreensaverOptions::openSlideshowScreensaverOptions() }); // Whether to recurse the custom image directory. - auto screensaver_slideshow_recurse = std::make_shared(mWindow); + auto screensaver_slideshow_recurse = std::make_shared(); screensaver_slideshow_recurse->setState( Settings::getInstance()->getBool("ScreensaverSlideshowRecurse")); s->addWithLabel("CUSTOM IMAGE DIRECTORY RECURSIVE SEARCH", screensaver_slideshow_recurse); @@ -194,8 +194,8 @@ void GuiScreensaverOptions::openSlideshowScreensaverOptions() }); // Custom image directory. - auto screensaver_slideshow_image_dir = std::make_shared( - mWindow, "", Font::get(FONT_SIZE_SMALL), 0x777777FF, ALIGN_RIGHT); + auto screensaver_slideshow_image_dir = + std::make_shared("", Font::get(FONT_SIZE_SMALL), 0x777777FF, ALIGN_RIGHT); s->addEditableTextComponent( "CUSTOM IMAGE DIRECTORY", screensaver_slideshow_image_dir, Settings::getInstance()->getString("ScreensaverSlideshowImageDir"), @@ -215,11 +215,11 @@ void GuiScreensaverOptions::openSlideshowScreensaverOptions() void GuiScreensaverOptions::openVideoScreensaverOptions() { - auto s = new GuiSettings(mWindow, "VIDEO SCREENSAVER"); + auto s = new GuiSettings("VIDEO SCREENSAVER"); // Timer for swapping videos (in seconds). auto screensaver_swap_video_timeout = - std::make_shared(mWindow, 0.0f, 120.0f, 2.0f, "s"); + std::make_shared(0.0f, 120.0f, 2.0f, "s"); screensaver_swap_video_timeout->setValue(static_cast( Settings::getInstance()->getInt("ScreensaverSwapVideoTimeout") / (1000))); s->addWithLabel("SWAP VIDEOS AFTER (SECONDS)", screensaver_swap_video_timeout); @@ -235,7 +235,7 @@ void GuiScreensaverOptions::openVideoScreensaverOptions() }); // Stretch videos to screen resolution. - auto screensaver_stretch_videos = std::make_shared(mWindow); + auto screensaver_stretch_videos = std::make_shared(); screensaver_stretch_videos->setState( Settings::getInstance()->getBool("ScreensaverStretchVideos")); s->addWithLabel("STRETCH VIDEOS TO SCREEN RESOLUTION", screensaver_stretch_videos); @@ -249,7 +249,7 @@ void GuiScreensaverOptions::openVideoScreensaverOptions() }); // Show game info overlay for video screensaver. - auto screensaver_video_game_info = std::make_shared(mWindow); + auto screensaver_video_game_info = std::make_shared(); screensaver_video_game_info->setState( Settings::getInstance()->getBool("ScreensaverVideoGameInfo")); s->addWithLabel("DISPLAY GAME INFO OVERLAY", screensaver_video_game_info); @@ -264,7 +264,7 @@ void GuiScreensaverOptions::openVideoScreensaverOptions() #if defined(USE_OPENGL_21) // Render scanlines using a shader. - auto screensaver_video_scanlines = std::make_shared(mWindow); + auto screensaver_video_scanlines = std::make_shared(); screensaver_video_scanlines->setState( Settings::getInstance()->getBool("ScreensaverVideoScanlines")); s->addWithLabel("RENDER SCANLINES", screensaver_video_scanlines); @@ -278,7 +278,7 @@ void GuiScreensaverOptions::openVideoScreensaverOptions() }); // Render blur using a shader. - auto screensaver_video_blur = std::make_shared(mWindow); + auto screensaver_video_blur = std::make_shared(); screensaver_video_blur->setState(Settings::getInstance()->getBool("ScreensaverVideoBlur")); s->addWithLabel("RENDER BLUR", screensaver_video_blur); s->addSaveFunc([screensaver_video_blur, s] { diff --git a/es-app/src/guis/GuiScreensaverOptions.h b/es-app/src/guis/GuiScreensaverOptions.h index 1fe1993e3..74f47112f 100644 --- a/es-app/src/guis/GuiScreensaverOptions.h +++ b/es-app/src/guis/GuiScreensaverOptions.h @@ -15,11 +15,9 @@ class GuiScreensaverOptions : public GuiSettings { public: - GuiScreensaverOptions(Window* window, const std::string& title); + GuiScreensaverOptions(const std::string& title); private: - Window* mWindow; - void openSlideshowScreensaverOptions(); void openVideoScreensaverOptions(); }; diff --git a/es-app/src/guis/GuiSettings.cpp b/es-app/src/guis/GuiSettings.cpp index 0a1d3bcd7..e5ffd94c0 100644 --- a/es-app/src/guis/GuiSettings.cpp +++ b/es-app/src/guis/GuiSettings.cpp @@ -21,21 +21,20 @@ #include "views/GamelistView.h" #include "views/ViewController.h" -GuiSettings::GuiSettings(Window* window, std::string title) - : GuiComponent(window) - , mMenu(window, title) - , mGoToSystem(nullptr) - , mNeedsSaving(false) - , mNeedsReloadHelpPrompts(false) - , mNeedsCollectionsUpdate(false) - , mNeedsSorting(false) - , mNeedsSortingCollections(false) - , mNeedsResetFilters(false) - , mNeedsReloading(false) - , mNeedsGoToStart(false) - , mNeedsGoToSystem(false) - , mNeedsGoToGroupedCollections(false) - , mInvalidateCachedBackground(false) +GuiSettings::GuiSettings(std::string title) + : mMenu {title} + , mGoToSystem {nullptr} + , mNeedsSaving {false} + , mNeedsReloadHelpPrompts {false} + , mNeedsCollectionsUpdate {false} + , mNeedsSorting {false} + , mNeedsSortingCollections {false} + , mNeedsResetFilters {false} + , mNeedsReloading {false} + , mNeedsGoToStart {false} + , mNeedsGoToSystem {false} + , mNeedsGoToGroupedCollections {false} + , mInvalidateCachedBackground {false} { addChild(&mMenu); mMenu.addButton("BACK", "back", [this] { delete this; }); @@ -159,17 +158,17 @@ void GuiSettings::addEditableTextComponent(const std::string label, ComponentListRow row; row.elements.clear(); - auto lbl = std::make_shared(mWindow, Utils::String::toUpper(label), + auto lbl = std::make_shared(Utils::String::toUpper(label), Font::get(FONT_SIZE_MEDIUM), 0x777777FF); row.addElement(lbl, true); row.addElement(ed, true); - auto spacer = std::make_shared(mWindow); + auto spacer = std::make_shared(); spacer->setSize(Renderer::getScreenWidth() * 0.005f, 0); row.addElement(spacer, false); - auto bracket = std::make_shared(mWindow); + auto bracket = std::make_shared(); bracket->setImage(":/graphics/arrow.svg"); bracket->setResize(glm::vec2 {0.0f, lbl->getFont()->getLetterHeight()}); row.addElement(bracket, false); @@ -198,23 +197,22 @@ void GuiSettings::addEditableTextComponent(const std::string label, row.makeAcceptInputHandler([this, label, ed, updateVal, isPassword] { // Never display the value if it's a password, instead set it to blank. if (isPassword) - mWindow->pushGui(new GuiTextEditKeyboardPopup( - mWindow, getHelpStyle(), label, "", updateVal, false, "SAVE", "SAVE CHANGES?")); + mWindow->pushGui(new GuiTextEditKeyboardPopup(getHelpStyle(), label, "", updateVal, + false, "SAVE", "SAVE CHANGES?")); else - mWindow->pushGui(new GuiTextEditKeyboardPopup(mWindow, getHelpStyle(), label, - ed->getValue(), updateVal, false, - "SAVE", "SAVE CHANGES?")); + mWindow->pushGui(new GuiTextEditKeyboardPopup(getHelpStyle(), label, ed->getValue(), + updateVal, false, "SAVE", + "SAVE CHANGES?")); }); } else { row.makeAcceptInputHandler([this, label, ed, updateVal, isPassword] { if (isPassword) - mWindow->pushGui(new GuiTextEditPopup(mWindow, getHelpStyle(), label, "", updateVal, - false, "SAVE", "SAVE CHANGES?")); + mWindow->pushGui(new GuiTextEditPopup(getHelpStyle(), label, "", updateVal, false, + "SAVE", "SAVE CHANGES?")); else - mWindow->pushGui(new GuiTextEditPopup(mWindow, getHelpStyle(), label, - ed->getValue(), updateVal, false, "SAVE", - "SAVE CHANGES?")); + mWindow->pushGui(new GuiTextEditPopup(getHelpStyle(), label, ed->getValue(), + updateVal, false, "SAVE", "SAVE CHANGES?")); }); } diff --git a/es-app/src/guis/GuiSettings.h b/es-app/src/guis/GuiSettings.h index b526d3e9d..49ae729a5 100644 --- a/es-app/src/guis/GuiSettings.h +++ b/es-app/src/guis/GuiSettings.h @@ -18,7 +18,7 @@ class GuiSettings : public GuiComponent { public: - GuiSettings(Window* window, std::string title); + GuiSettings(std::string title); virtual ~GuiSettings(); void save(); diff --git a/es-app/src/main.cpp b/es-app/src/main.cpp index 752338bcf..205ecde65 100644 --- a/es-app/src/main.cpp +++ b/es-app/src/main.cpp @@ -437,7 +437,7 @@ void applicationLoop() #endif if (SDL_PollEvent(&event)) { do { - InputManager::getInstance().parseEvent(event, window); + InputManager::getInstance().parseEvent(event); if (event.type == SDL_QUIT) #if !defined(__EMSCRIPTEN__) @@ -611,7 +611,7 @@ int main(int argc, char* argv[]) bool splashScreen = Settings::getInstance()->getBool("SplashScreen"); bool splashScreenProgress = Settings::getInstance()->getBool("SplashScreenProgress"); - InputManager::getInstance().parseEvent(event, window); + InputManager::getInstance().parseEvent(event); if (event.type == SDL_QUIT) return 1; @@ -681,7 +681,7 @@ int main(int argc, char* argv[]) if (!loadSystemsStatus) { if (forceInputConfig) { window->pushGui(new GuiDetectDevice( - window, false, true, [] { ViewController::getInstance()->goToStart(true); })); + false, true, [] { ViewController::getInstance()->goToStart(true); })); } else { ViewController::getInstance()->goToStart(true); diff --git a/es-app/src/views/GamelistBase.cpp b/es-app/src/views/GamelistBase.cpp index e9fbe2260..c0a0cf90b 100644 --- a/es-app/src/views/GamelistBase.cpp +++ b/es-app/src/views/GamelistBase.cpp @@ -14,10 +14,8 @@ #include "guis/GuiGamelistOptions.h" #include "views/ViewController.h" -GamelistBase::GamelistBase(Window* window, FileData* root) - : GuiComponent {window} - , mRoot {root} - , mList {window} +GamelistBase::GamelistBase(FileData* root) + : mRoot {root} , mRandomGame {nullptr} , mLastUpdated {nullptr} , mGameCount {0} @@ -460,7 +458,7 @@ bool GamelistBase::input(InputConfig* config, Input input) config->isMappedTo("back", input) && input.value) { ViewController::getInstance()->cancelViewTransitions(); stopListScrolling(); - mWindow->pushGui(new GuiGamelistOptions(mWindow, this->mRoot->getSystem())); + mWindow->pushGui(new GuiGamelistOptions(this->mRoot->getSystem())); return true; } diff --git a/es-app/src/views/GamelistBase.h b/es-app/src/views/GamelistBase.h index 9027827f5..89d55b494 100644 --- a/es-app/src/views/GamelistBase.h +++ b/es-app/src/views/GamelistBase.h @@ -57,7 +57,7 @@ public: const std::vector& getFirstLetterIndex() { return mFirstLetterIndex; } protected: - GamelistBase(Window* window, FileData* root); + GamelistBase(FileData* root); ~GamelistBase(); // Called when a FileData* is added, has its metadata changed, or is removed. diff --git a/es-app/src/views/GamelistView.cpp b/es-app/src/views/GamelistView.cpp index e9fa8f3ce..58c8509c5 100644 --- a/es-app/src/views/GamelistView.cpp +++ b/es-app/src/views/GamelistView.cpp @@ -15,37 +15,10 @@ #define FADE_IN_START_OPACITY 0.5f #define FADE_IN_TIME 650 -GamelistView::GamelistView(Window* window, FileData* root) - : GamelistBase {window, root} +GamelistView::GamelistView(FileData* root) + : GamelistBase {root} , mViewStyle {ViewController::BASIC} - , mHeaderText {window} - , mHeaderImage {window} - , mBackground {window} - , mThumbnail {window} - , mMarquee {window} - , mImage {window} - , mVideo(nullptr) - , mLblRating {window} - , mLblReleaseDate {window} - , mLblDeveloper {window} - , mLblPublisher {window} - , mLblGenre {window} - , mLblPlayers {window} - , mLblLastPlayed {window} - , mLblPlayCount {window} - , mRating {window} - , mReleaseDate {window} - , mDeveloper {window} - , mPublisher {window} - , mGenre {window} - , mPlayers {window} - , mLastPlayed {window} - , mPlayCount {window} - , mName {window} - , mBadges {window} - , mDescContainer {window} - , mDescription {window} - , mGamelistInfo {window} + , mVideo {nullptr} { mViewStyle = ViewController::getInstance()->getState().viewstyle; @@ -72,7 +45,7 @@ GamelistView::GamelistView(Window* window, FileData* root) if (mViewStyle == ViewController::VIDEO) { // Create the video window. - mVideo = new VideoFFmpegComponent(window); + mVideo = new VideoFFmpegComponent; } mList.setPosition(mSize.x * (0.50f + padding), mList.getPosition().y); @@ -235,7 +208,7 @@ void GamelistView::onThemeChanged(const std::shared_ptr& theme) mThemeExtras.clear(); // Add new theme extras. - mThemeExtras = ThemeData::makeExtras(theme, getName(), mWindow); + mThemeExtras = ThemeData::makeExtras(theme, getName()); for (auto extra : mThemeExtras) addChild(extra); @@ -304,8 +277,6 @@ void GamelistView::onThemeChanged(const std::shared_ptr& theme) void GamelistView::update(int deltaTime) { - mImage.update(deltaTime); - if (ViewController::getInstance()->getGameLaunchTriggered() && mImage.isAnimationPlaying(0)) mImage.finishAnimation(0); @@ -315,12 +286,12 @@ void GamelistView::update(int deltaTime) else if (mVideoPlaying && !mVideo->isVideoPaused() && !mWindow->isScreensaverActive()) mVideo->onShow(); - mVideo->update(deltaTime); - if (ViewController::getInstance()->getGameLaunchTriggered() && mVideo->isAnimationPlaying(0)) mVideo->finishAnimation(0); } + + updateChildren(deltaTime); } void GamelistView::render(const glm::mat4& parentTrans) diff --git a/es-app/src/views/GamelistView.h b/es-app/src/views/GamelistView.h index 05645c020..13916eb8d 100644 --- a/es-app/src/views/GamelistView.h +++ b/es-app/src/views/GamelistView.h @@ -17,7 +17,7 @@ class GamelistView : public GamelistBase { public: - GamelistView(Window* window, FileData* root); + GamelistView(FileData* root); ~GamelistView(); // Called when a FileData* is added, has its metadata changed, or is removed. diff --git a/es-app/src/views/SystemView.cpp b/es-app/src/views/SystemView.cpp index a473ab142..2ce73d1d2 100644 --- a/es-app/src/views/SystemView.cpp +++ b/es-app/src/views/SystemView.cpp @@ -22,13 +22,17 @@ #include #endif -// Buffer values for scrolling velocity (left, stopped, right). -const int logoBuffersLeft[] = {-5, -2, -1}; -const int logoBuffersRight[] = {1, 2, 5}; +namespace +{ + // Buffer values for scrolling velocity (left, stopped, right). + const int logoBuffersLeft[] = {-5, -2, -1}; + const int logoBuffersRight[] = {1, 2, 5}; -SystemView::SystemView(Window* window) - : IList {window, LIST_SCROLL_STYLE_SLOW, LIST_ALWAYS_LOOP} - , mSystemInfo {window, "SYSTEM INFO", Font::get(FONT_SIZE_SMALL), 0x33333300, ALIGN_CENTER} +} // namespace + +SystemView::SystemView() + : IList {LIST_SCROLL_STYLE_SLOW, LIST_ALWAYS_LOOP} + , mSystemInfo {"SYSTEM INFO", Font::get(FONT_SIZE_SMALL), 0x33333300, ALIGN_CENTER} , mPreviousScrollVelocity {0} , mUpdatedGameCount {false} , mViewNeedsReload {true} @@ -80,7 +84,7 @@ void SystemView::populate() if ((!path.empty() && ResourceManager::getInstance().fileExists(path)) || (!defaultPath.empty() && ResourceManager::getInstance().fileExists(defaultPath))) { - auto* logo = new ImageComponent(mWindow, false, false); + auto* logo = new ImageComponent(false, false); logo->setMaxSize(glm::round(mCarousel.logoSize * mCarousel.logoScale)); logo->applyTheme(theme, "system", "logo", ThemeFlags::PATH | ThemeFlags::COLOR); logo->setRotateByTargetSize(true); @@ -104,7 +108,7 @@ void SystemView::populate() if ((!path.empty() && ResourceManager::getInstance().fileExists(path)) || (!defaultPath.empty() && ResourceManager::getInstance().fileExists(defaultPath))) { - auto* logo = new ImageComponent(mWindow, false, false); + auto* logo = new ImageComponent(false, false); logo->applyTheme(theme, "system", "logoPlaceholderImage", ThemeFlags::ALL); if (!logoElem->has("size")) logo->setMaxSize(mCarousel.logoSize * mCarousel.logoScale); @@ -119,9 +123,8 @@ void SystemView::populate() theme->getElement("system", "logoPlaceholderText", "text"); if (logoPlaceholderText) { // Element 'logoPlaceholderText' found in theme: place text - auto* text = - new TextComponent(mWindow, it->getName(), Font::get(FONT_SIZE_LARGE), - 0x000000FF, ALIGN_CENTER); + auto* text = new TextComponent(it->getName(), Font::get(FONT_SIZE_LARGE), + 0x000000FF, ALIGN_CENTER); text->setSize(mCarousel.logoSize * mCarousel.logoScale); if (mCarousel.type == VERTICAL || mCarousel.type == VERTICAL_WHEEL) { text->setHorizontalAlignment(mCarousel.logoAlignment); @@ -144,9 +147,8 @@ void SystemView::populate() } else { // Fallback to legacy centered placeholder text. - auto* text = - new TextComponent(mWindow, it->getName(), Font::get(FONT_SIZE_LARGE), - 0x000000FF, ALIGN_CENTER); + auto* text = new TextComponent(it->getName(), Font::get(FONT_SIZE_LARGE), + 0x000000FF, ALIGN_CENTER); text->setSize(mCarousel.logoSize * mCarousel.logoScale); text->applyTheme(it->getTheme(), "system", "logoText", ThemeFlags::FONT_PATH | ThemeFlags::FONT_SIZE | @@ -189,7 +191,7 @@ void SystemView::populate() e.data.logoPlaceholderText->setPosition(v + offsetLogoPlaceholderText); // Make background extras. - e.data.backgroundExtras = ThemeData::makeExtras(it->getTheme(), "system", mWindow); + e.data.backgroundExtras = ThemeData::makeExtras(it->getTheme(), "system"); // Sort the extras by z-index. std::stable_sort( @@ -204,7 +206,7 @@ void SystemView::populate() if (!UIModeController::getInstance()->isUIModeFull()) { Settings::getInstance()->setString("UIMode", "full"); mWindow->pushGui(new GuiMsgBox( - mWindow, getHelpStyle(), + getHelpStyle(), "The selected UI mode has nothing to show,\n returning to UI mode \"Full\"", "OK", nullptr)); } diff --git a/es-app/src/views/SystemView.h b/es-app/src/views/SystemView.h index ab1663097..ff0e76b43 100644 --- a/es-app/src/views/SystemView.h +++ b/es-app/src/views/SystemView.h @@ -17,7 +17,6 @@ #include -class AnimatedImageComponent; class SystemData; enum CarouselType : unsigned int { @@ -54,7 +53,7 @@ struct SystemViewCarousel { class SystemView : public IList { public: - SystemView(Window* window); + SystemView(); ~SystemView(); void onShow() override { mShowing = true; } diff --git a/es-app/src/views/ViewController.cpp b/es-app/src/views/ViewController.cpp index dc219e818..882dea7f2 100644 --- a/es-app/src/views/ViewController.cpp +++ b/es-app/src/views/ViewController.cpp @@ -30,15 +30,8 @@ #include "views/GamelistView.h" #include "views/SystemView.h" -ViewController* ViewController::getInstance() -{ - static ViewController instance; - return &instance; -} - ViewController::ViewController() noexcept - : GuiComponent {Window::getInstance()} - , mNoGamesMessageBox {nullptr} + : mNoGamesMessageBox {nullptr} , mCurrentView {nullptr} , mPreviousView {nullptr} , mSkipView {nullptr} @@ -55,6 +48,12 @@ ViewController::ViewController() noexcept mState.viewstyle = AUTOMATIC; } +ViewController* ViewController::getInstance() +{ + static ViewController instance; + return &instance; +} + void ViewController::invalidSystemsFileDialog() { std::string errorMessage = "COULDN'T PARSE THE SYSTEMS CONFIGURATION FILE.\n" @@ -65,7 +64,7 @@ void ViewController::invalidSystemsFileDialog() "APPLICATION LOG FILE es_log.txt FOR ADDITIONAL INFO."; mWindow->pushGui(new GuiMsgBox( - mWindow, HelpStyle(), errorMessage.c_str(), "QUIT", + HelpStyle(), errorMessage.c_str(), "QUIT", [] { SDL_Event quit; quit.type = SDL_QUIT; @@ -91,7 +90,7 @@ void ViewController::noGamesDialog() #endif mNoGamesMessageBox = new GuiMsgBox( - mWindow, HelpStyle(), mNoGamesErrorMessage + mRomDirectory, "CHANGE ROM DIRECTORY", + HelpStyle(), mNoGamesErrorMessage + mRomDirectory, "CHANGE ROM DIRECTORY", [this] { std::string currentROMDirectory; #if defined(_WIN64) @@ -101,7 +100,7 @@ void ViewController::noGamesDialog() #endif if (Settings::getInstance()->getBool("VirtualKeyboard")) { mWindow->pushGui(new GuiTextEditKeyboardPopup( - mWindow, HelpStyle(), "ENTER ROM DIRECTORY PATH", currentROMDirectory, + HelpStyle(), "ENTER ROM DIRECTORY PATH", currentROMDirectory, [this](const std::string& newROMDirectory) { Settings::getInstance()->setString("ROMDirectory", Utils::String::trim(newROMDirectory)); @@ -113,7 +112,7 @@ void ViewController::noGamesDialog() mRomDirectory = FileData::getROMDirectory(); #endif mNoGamesMessageBox->changeText(mNoGamesErrorMessage + mRomDirectory); - mWindow->pushGui(new GuiMsgBox(mWindow, HelpStyle(), + mWindow->pushGui(new GuiMsgBox(HelpStyle(), "ROM DIRECTORY SETTING SAVED, RESTART\n" "THE APPLICATION TO RESCAN THE SYSTEMS", "OK", nullptr, "", nullptr, "", nullptr, @@ -125,7 +124,7 @@ void ViewController::noGamesDialog() } else { mWindow->pushGui(new GuiTextEditPopup( - mWindow, HelpStyle(), "ENTER ROM DIRECTORY PATH", currentROMDirectory, + HelpStyle(), "ENTER ROM DIRECTORY PATH", currentROMDirectory, [this](const std::string& newROMDirectory) { Settings::getInstance()->setString("ROMDirectory", Utils::String::trim(newROMDirectory)); @@ -137,7 +136,7 @@ void ViewController::noGamesDialog() mRomDirectory = FileData::getROMDirectory(); #endif mNoGamesMessageBox->changeText(mNoGamesErrorMessage + mRomDirectory); - mWindow->pushGui(new GuiMsgBox(mWindow, HelpStyle(), + mWindow->pushGui(new GuiMsgBox(HelpStyle(), "ROM DIRECTORY SETTING SAVED, RESTART\n" "THE APPLICATION TO RESCAN THE SYSTEMS", "OK", nullptr, "", nullptr, "", nullptr, @@ -151,7 +150,7 @@ void ViewController::noGamesDialog() "CREATE DIRECTORIES", [this] { mWindow->pushGui(new GuiMsgBox( - mWindow, HelpStyle(), + HelpStyle(), "THIS WILL CREATE DIRECTORIES FOR ALL THE\n" "GAME SYSTEMS DEFINED IN es_systems.xml\n\n" "THIS MAY CREATE A LOT OF FOLDERS SO IT'S\n" @@ -160,7 +159,7 @@ void ViewController::noGamesDialog() "YES", [this] { if (!SystemData::createSystemDirectories()) { - mWindow->pushGui(new GuiMsgBox(mWindow, HelpStyle(), + mWindow->pushGui(new GuiMsgBox(HelpStyle(), "THE SYSTEM DIRECTORIES WERE SUCCESSFULLY\n" "GENERATED, EXIT THE APPLICATION AND PLACE\n" "YOUR GAMES IN THE NEWLY CREATED FOLDERS", @@ -168,7 +167,7 @@ void ViewController::noGamesDialog() true)); } else { - mWindow->pushGui(new GuiMsgBox(mWindow, HelpStyle(), + mWindow->pushGui(new GuiMsgBox(HelpStyle(), "ERROR CREATING THE SYSTEM DIRECTORIES,\n" "PERMISSION PROBLEMS OR DISK FULL?\n\n" "SEE THE LOG FILE FOR MORE DETAILS", @@ -191,13 +190,12 @@ void ViewController::noGamesDialog() void ViewController::invalidAlternativeEmulatorDialog() { - mWindow->pushGui(new GuiMsgBox(mWindow, getHelpStyle(), - "AT LEAST ONE OF YOUR SYSTEMS HAS AN\n" - "INVALID ALTERNATIVE EMULATOR CONFIGURED\n" - "WITH NO MATCHING ENTRY IN THE SYSTEMS\n" - "CONFIGURATION FILE, PLEASE REVIEW YOUR\n" - "SETUP USING THE 'ALTERNATIVE EMULATORS'\n" - "INTERFACE IN THE 'OTHER SETTINGS' MENU")); + mWindow->pushGui(new GuiMsgBox(getHelpStyle(), "AT LEAST ONE OF YOUR SYSTEMS HAS AN\n" + "INVALID ALTERNATIVE EMULATOR CONFIGURED\n" + "WITH NO MATCHING ENTRY IN THE SYSTEMS\n" + "CONFIGURATION FILE, PLEASE REVIEW YOUR\n" + "SETUP USING THE 'ALTERNATIVE EMULATORS'\n" + "INTERFACE IN THE 'OTHER SETTINGS' MENU")); } void ViewController::goToStart(bool playTransition) @@ -694,7 +692,7 @@ void ViewController::launch(FileData* game) // to be displayed briefly, and for the navigation sound playing to be able to complete. // During this time period, all user input is blocked. setAnimation(new LambdaAnimation([](float t) {}, duration), 0, [this, game] { - game->launchGame(mWindow); + game->launchGame(); // If the launch screen is disabled then this will do nothing. mWindow->closeLaunchScreen(); onFileChanged(game, true); @@ -769,7 +767,7 @@ std::shared_ptr ViewController::getGamelistView(SystemData* system } } - view = std::shared_ptr(new GamelistView(mWindow, system->getRootFolder())); + view = std::shared_ptr(new GamelistView(system->getRootFolder())); view->setTheme(system->getTheme()); @@ -790,7 +788,7 @@ std::shared_ptr ViewController::getSystemListView() if (mSystemListView) return mSystemListView; - mSystemListView = std::shared_ptr(new SystemView(mWindow)); + mSystemListView = std::shared_ptr(new SystemView); addChild(mSystemListView.get()); mSystemListView->setPosition(0, static_cast(Renderer::getScreenHeight())); return mSystemListView; @@ -835,7 +833,7 @@ bool ViewController::input(InputConfig* config, Input input) // Finally, if the camera is currently moving, reset its position. cancelViewTransitions(); - mWindow->pushGui(new GuiMenu(mWindow)); + mWindow->pushGui(new GuiMenu); return true; } diff --git a/es-core/src/GuiComponent.cpp b/es-core/src/GuiComponent.cpp index c2b907d33..78189a906 100644 --- a/es-core/src/GuiComponent.cpp +++ b/es-core/src/GuiComponent.cpp @@ -16,8 +16,8 @@ #include -GuiComponent::GuiComponent(Window* window) - : mWindow {window} +GuiComponent::GuiComponent() + : mWindow {Window::getInstance()} , mParent {nullptr} , mOpacity {255} , mColor {0} diff --git a/es-core/src/GuiComponent.h b/es-core/src/GuiComponent.h index bf691c4f1..eaa5e74bb 100644 --- a/es-core/src/GuiComponent.h +++ b/es-core/src/GuiComponent.h @@ -37,7 +37,7 @@ class Window; class GuiComponent { public: - GuiComponent(Window* window); + GuiComponent(); virtual ~GuiComponent(); virtual void textInput(const std::string& text); diff --git a/es-core/src/HttpReq.cpp b/es-core/src/HttpReq.cpp index ee84cd8cd..33776f20b 100644 --- a/es-core/src/HttpReq.cpp +++ b/es-core/src/HttpReq.cpp @@ -21,10 +21,10 @@ std::map HttpReq::s_requests; std::string HttpReq::urlEncode(const std::string& s) { - const std::string unreserved = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.~"; + const std::string unreserved { + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.~"}; - std::string escaped = ""; + std::string escaped {""}; for (size_t i = 0; i < s.length(); ++i) { if (unreserved.find_first_of(s[i]) != std::string::npos) { escaped.push_back(s[i]); diff --git a/es-core/src/InputManager.cpp b/es-core/src/InputManager.cpp index 56c8a6ad6..65851abd3 100644 --- a/es-core/src/InputManager.cpp +++ b/es-core/src/InputManager.cpp @@ -28,11 +28,12 @@ int SDL_USER_CECBUTTONDOWN = -1; int SDL_USER_CECBUTTONUP = -1; // Save button states for combo-button exit support and predefine exit option-function map. -static bool sAltDown = false; -static bool sLguiDown = false; +static bool sAltDown {false}; +static bool sLguiDown {false}; InputManager::InputManager() noexcept - : mKeyboardInputConfig(nullptr) + : mWindow {Window::getInstance()} + , mKeyboardInputConfig {nullptr} { } @@ -331,7 +332,7 @@ InputConfig* InputManager::getInputConfigByDevice(int device) return mInputConfigs[device].get(); } -bool InputManager::parseEvent(const SDL_Event& event, Window* window) +bool InputManager::parseEvent(const SDL_Event& event) { bool causedEvent = false; int32_t axisValue; @@ -380,7 +381,7 @@ bool InputManager::parseEvent(const SDL_Event& event, Window* window) normValue = -1; } - window->input( + mWindow->input( getInputConfigByDevice(event.caxis.which), Input(event.caxis.which, TYPE_AXIS, event.caxis.axis, normValue, false)); causedEvent = true; @@ -410,9 +411,9 @@ bool InputManager::parseEvent(const SDL_Event& event, Window* window) mPrevButtonValues[std::make_pair(event.cbutton.which, event.cbutton.button)] = event.cbutton.state; - window->input(getInputConfigByDevice(event.cbutton.which), - Input(event.cbutton.which, TYPE_BUTTON, event.cbutton.button, - event.cbutton.state == SDL_PRESSED, false)); + mWindow->input(getInputConfigByDevice(event.cbutton.which), + Input(event.cbutton.which, TYPE_BUTTON, event.cbutton.button, + event.cbutton.state == SDL_PRESSED, false)); return true; } @@ -425,7 +426,7 @@ bool InputManager::parseEvent(const SDL_Event& event, Window* window) sLguiDown = true; if (event.key.keysym.sym == SDLK_BACKSPACE && SDL_IsTextInputActive()) - window->textInput("\b"); + mWindow->textInput("\b"); if (event.key.repeat) return false; @@ -448,8 +449,8 @@ bool InputManager::parseEvent(const SDL_Event& event, Window* window) return false; } - window->input(getInputConfigByDevice(DEVICE_KEYBOARD), - Input(DEVICE_KEYBOARD, TYPE_KEY, event.key.keysym.sym, 1, false)); + mWindow->input(getInputConfigByDevice(DEVICE_KEYBOARD), + Input(DEVICE_KEYBOARD, TYPE_KEY, event.key.keysym.sym, 1, false)); return true; } case SDL_KEYUP: { @@ -460,30 +461,30 @@ bool InputManager::parseEvent(const SDL_Event& event, Window* window) if (event.key.keysym.sym == SDLK_LGUI) sLguiDown = false; - window->input(getInputConfigByDevice(DEVICE_KEYBOARD), - Input(DEVICE_KEYBOARD, TYPE_KEY, event.key.keysym.sym, 0, false)); + mWindow->input(getInputConfigByDevice(DEVICE_KEYBOARD), + Input(DEVICE_KEYBOARD, TYPE_KEY, event.key.keysym.sym, 0, false)); return true; } case SDL_TEXTINPUT: { - window->textInput(event.text.text); + mWindow->textInput(event.text.text); break; } case SDL_CONTROLLERDEVICEADDED: { - addControllerByDeviceIndex(window, event.cdevice.which); + addControllerByDeviceIndex(mWindow, event.cdevice.which); return true; } case SDL_CONTROLLERDEVICEREMOVED: { - removeControllerByJoystickID(window, event.cdevice.which); + removeControllerByJoystickID(mWindow, event.cdevice.which); return false; } } if ((event.type == static_cast(SDL_USER_CECBUTTONDOWN)) || (event.type == static_cast(SDL_USER_CECBUTTONUP))) { - window->input(getInputConfigByDevice(DEVICE_CEC), - Input(DEVICE_CEC, TYPE_CEC_BUTTON, event.user.code, - event.type == static_cast(SDL_USER_CECBUTTONDOWN), - false)); + mWindow->input(getInputConfigByDevice(DEVICE_CEC), + Input(DEVICE_CEC, TYPE_CEC_BUTTON, event.user.code, + event.type == static_cast(SDL_USER_CECBUTTONDOWN), + false)); return true; } diff --git a/es-core/src/InputManager.h b/es-core/src/InputManager.h index 20a4aa507..d68fa0b53 100644 --- a/es-core/src/InputManager.h +++ b/es-core/src/InputManager.h @@ -45,7 +45,7 @@ public: std::string getDeviceGUIDString(int deviceId); InputConfig* getInputConfigByDevice(int deviceId); - bool parseEvent(const SDL_Event& event, Window* window); + bool parseEvent(const SDL_Event& event); int getNumJoysticks() { return static_cast(mJoysticks.size()); } @@ -62,6 +62,7 @@ private: void addControllerByDeviceIndex(Window* window, int deviceIndex); void removeControllerByJoystickID(Window* window, SDL_JoystickID joyID); + Window* mWindow; CECInput mCECInput; static const int DEADZONE_TRIGGERS = 18000; diff --git a/es-core/src/MameNames.cpp b/es-core/src/MameNames.cpp index 173b3a323..7d78b6e90 100644 --- a/es-core/src/MameNames.cpp +++ b/es-core/src/MameNames.cpp @@ -26,7 +26,7 @@ MameNames& MameNames::getInstance() MameNames::MameNames() { - std::string xmlpath = ResourceManager::getInstance().getResourcePath(":/MAME/mamenames.xml"); + std::string xmlpath {ResourceManager::getInstance().getResourcePath(":/MAME/mamenames.xml")}; if (!Utils::FileSystem::exists(xmlpath)) return; diff --git a/es-core/src/ThemeData.cpp b/es-core/src/ThemeData.cpp index 3ef9fb5a4..111965bfe 100644 --- a/es-core/src/ThemeData.cpp +++ b/es-core/src/ThemeData.cpp @@ -644,8 +644,7 @@ const std::shared_ptr ThemeData::getDefault() } std::vector ThemeData::makeExtras(const std::shared_ptr& theme, - const std::string& view, - Window* window) + const std::string& view) { std::vector comps; @@ -655,16 +654,16 @@ std::vector ThemeData::makeExtras(const std::shared_ptrsecond.orderedKeys.cbegin(); // Line break. it != viewIt->second.orderedKeys.cend(); ++it) { - ThemeElement& elem = viewIt->second.elements.at(*it); + ThemeElement& elem {viewIt->second.elements.at(*it)}; if (elem.extra) { - GuiComponent* comp = nullptr; - const std::string& t = elem.type; + GuiComponent* comp {nullptr}; + const std::string& t {elem.type}; if (t == "image") - comp = new ImageComponent(window); + comp = new ImageComponent; else if (t == "text") - comp = new TextComponent(window); + comp = new TextComponent; else if (t == "animation") - comp = new LottieComponent(window); + comp = new LottieComponent; if (comp) { comp->setDefaultZIndex(10.0f); diff --git a/es-core/src/ThemeData.h b/es-core/src/ThemeData.h index 971e50dd4..04f3f1219 100644 --- a/es-core/src/ThemeData.h +++ b/es-core/src/ThemeData.h @@ -196,8 +196,7 @@ public: const std::string& expectedType) const; static std::vector makeExtras(const std::shared_ptr& theme, - const std::string& view, - Window* window); + const std::string& view); static const std::shared_ptr getDefault(); diff --git a/es-core/src/Window.cpp b/es-core/src/Window.cpp index d4b8f698b..1ee087921 100644 --- a/es-core/src/Window.cpp +++ b/es-core/src/Window.cpp @@ -119,8 +119,8 @@ bool Window::init() ResourceManager::getInstance().reloadAll(); - mHelp = new HelpComponent(this); - mBackgroundOverlay = new ImageComponent(this); + mHelp = new HelpComponent; + mBackgroundOverlay = new ImageComponent; mBackgroundOverlayOpacity = 0; // Keep a reference to the default fonts, so they don't keep getting destroyed/recreated. @@ -367,8 +367,8 @@ void Window::update(int deltaTime) if (!popupIsRunning) { delete mInfoPopup; - mInfoPopup = new GuiInfoPopup(this, mInfoPopupQueue.front().first, - mInfoPopupQueue.front().second); + mInfoPopup = + new GuiInfoPopup(mInfoPopupQueue.front().first, mInfoPopupQueue.front().second); mInfoPopupQueue.pop(); } } @@ -618,7 +618,7 @@ void Window::renderLoadingScreen(std::string text) Renderer::drawRect(0.0f, 0.0f, static_cast(Renderer::getScreenWidth()), static_cast(Renderer::getScreenHeight()), 0x000000FF, 0x000000FF); - ImageComponent splash(this, true); + ImageComponent splash(true); splash.setImage(":/graphics/splash.svg"); splash.setResize(Renderer::getScreenWidth() * 0.6f, 0.0f); splash.setPosition((Renderer::getScreenWidth() - splash.getSize().x) / 2.0f, @@ -723,7 +723,7 @@ void Window::reloadHelpPrompts() { if (mHelp) { delete mHelp; - mHelp = new HelpComponent(this); + mHelp = new HelpComponent; } } diff --git a/es-core/src/animations/LambdaAnimation.h b/es-core/src/animations/LambdaAnimation.h index 974d3d5c4..79bbb3acc 100644 --- a/es-core/src/animations/LambdaAnimation.h +++ b/es-core/src/animations/LambdaAnimation.h @@ -19,8 +19,8 @@ class LambdaAnimation : public Animation { public: LambdaAnimation(const std::function& func, int duration) - : mFunction(func) - , mDuration(duration) + : mFunction {func} + , mDuration {duration} { } diff --git a/es-core/src/animations/MoveCameraAnimation.h b/es-core/src/animations/MoveCameraAnimation.h index 7c4bc7f08..ca3e47e3d 100644 --- a/es-core/src/animations/MoveCameraAnimation.h +++ b/es-core/src/animations/MoveCameraAnimation.h @@ -16,9 +16,9 @@ class MoveCameraAnimation : public Animation { public: MoveCameraAnimation(glm::mat4& camera, const glm::vec3& target) - : mCameraStart(camera) - , cameraPosition(camera) - , mTarget(target) + : mCameraStart {camera} + , cameraPosition {camera} + , mTarget {target} { } diff --git a/es-core/src/components/AnimatedImageComponent.cpp b/es-core/src/components/AnimatedImageComponent.cpp index 1ae79e274..b1745954d 100644 --- a/es-core/src/components/AnimatedImageComponent.cpp +++ b/es-core/src/components/AnimatedImageComponent.cpp @@ -12,9 +12,8 @@ #include "components/ImageComponent.h" #include "resources/ResourceManager.h" -AnimatedImageComponent::AnimatedImageComponent(Window* window) - : GuiComponent {window} - , mEnabled {false} +AnimatedImageComponent::AnimatedImageComponent() + : mEnabled {false} { } @@ -32,7 +31,7 @@ void AnimatedImageComponent::load(const AnimationDef* def) continue; } - auto img = std::unique_ptr(new ImageComponent(mWindow)); + auto img = std::unique_ptr(new ImageComponent); img->setResize(mSize.x, mSize.y); img->setImage(std::string(def->frames[i].path), false); diff --git a/es-core/src/components/AnimatedImageComponent.h b/es-core/src/components/AnimatedImageComponent.h index 5f878a9d7..00704a0ea 100644 --- a/es-core/src/components/AnimatedImageComponent.h +++ b/es-core/src/components/AnimatedImageComponent.h @@ -27,7 +27,7 @@ struct AnimationDef { class AnimatedImageComponent : public GuiComponent { public: - AnimatedImageComponent(Window* window); + AnimatedImageComponent(); void load(const AnimationDef* def); // No reference to def is kept after loading is complete. diff --git a/es-core/src/components/BadgeComponent.cpp b/es-core/src/components/BadgeComponent.cpp index 4ae69d7fb..a4033c35c 100644 --- a/es-core/src/components/BadgeComponent.cpp +++ b/es-core/src/components/BadgeComponent.cpp @@ -17,7 +17,9 @@ #include "components/BadgeComponent.h" #include "Log.h" +#include "Settings.h" #include "ThemeData.h" +#include "resources/TextureResource.h" #include "utils/StringUtil.h" namespace @@ -61,10 +63,9 @@ namespace // clang-format on } // namespace -BadgeComponent::BadgeComponent(Window* window) - : GuiComponent {window} - , mFlexboxItems {} - , mFlexboxComponent {window, mFlexboxItems} +BadgeComponent::BadgeComponent() + : mFlexboxItems {} + , mFlexboxComponent {mFlexboxItems} , mBadgeTypes {{SLOT_FAVORITE, SLOT_COMPLETED, SLOT_KIDGAME, SLOT_BROKEN, SLOT_CONTROLLER, SLOT_ALTEMULATOR}} { @@ -295,10 +296,10 @@ void BadgeComponent::applyTheme(const std::shared_ptr& theme, FlexboxComponent::FlexboxItem item; item.label = slot; - ImageComponent badgeImage {mWindow, false, false}; + ImageComponent badgeImage {false, false}; badgeImage.setImage(mBadgeIcons[slot]); item.baseImage = badgeImage; - item.overlayImage = ImageComponent {mWindow}; + item.overlayImage = ImageComponent {}; mFlexboxItems.emplace_back(std::move(item)); } diff --git a/es-core/src/components/BadgeComponent.h b/es-core/src/components/BadgeComponent.h index cb7981bb9..4cac9ee95 100644 --- a/es-core/src/components/BadgeComponent.h +++ b/es-core/src/components/BadgeComponent.h @@ -22,7 +22,7 @@ struct GameControllers { class BadgeComponent : public GuiComponent { public: - BadgeComponent(Window* window); + BadgeComponent(); struct BadgeInfo { std::string badgeType; diff --git a/es-core/src/components/BusyComponent.cpp b/es-core/src/components/BusyComponent.cpp index 0b5e8c12f..796094ada 100644 --- a/es-core/src/components/BusyComponent.cpp +++ b/es-core/src/components/BusyComponent.cpp @@ -22,15 +22,13 @@ AnimationFrame BUSY_ANIMATION_FRAMES[] { const AnimationDef BUSY_ANIMATION_DEF = {BUSY_ANIMATION_FRAMES, 4, true}; -BusyComponent::BusyComponent(Window* window) - : GuiComponent {window} - , mBackground {window, ":/graphics/frame.png"} - , mGrid {window, glm::ivec2 {5, 3}} +BusyComponent::BusyComponent() + : mBackground {":/graphics/frame.png"} + , mGrid {glm::ivec2 {5, 3}} { - mAnimation = std::make_shared(mWindow); + mAnimation = std::make_shared(); mAnimation->load(&BUSY_ANIMATION_DEF); - mText = std::make_shared(mWindow, "WORKING...", Font::get(FONT_SIZE_MEDIUM), - 0x777777FF); + mText = std::make_shared("WORKING...", Font::get(FONT_SIZE_MEDIUM), 0x777777FF); // Col 0 = animation, col 1 = spacer, col 2 = text. mGrid.setEntry(mAnimation, glm::ivec2 {1, 1}, false, true); diff --git a/es-core/src/components/BusyComponent.h b/es-core/src/components/BusyComponent.h index e3c361905..d0b957df2 100644 --- a/es-core/src/components/BusyComponent.h +++ b/es-core/src/components/BusyComponent.h @@ -19,7 +19,7 @@ class TextComponent; class BusyComponent : public GuiComponent { public: - BusyComponent(Window* window); + BusyComponent(); void onSizeChanged() override; diff --git a/es-core/src/components/ButtonComponent.cpp b/es-core/src/components/ButtonComponent.cpp index d829e8cd7..da878ae2c 100644 --- a/es-core/src/components/ButtonComponent.cpp +++ b/es-core/src/components/ButtonComponent.cpp @@ -12,14 +12,12 @@ #include "resources/Font.h" #include "utils/StringUtil.h" -ButtonComponent::ButtonComponent(Window* window, - const std::string& text, +ButtonComponent::ButtonComponent(const std::string& text, const std::string& helpText, const std::function& func, bool upperCase, bool flatStyle) - : GuiComponent {window} - , mBox {window, ":/graphics/button.svg"} + : mBox {":/graphics/button.svg"} , mFont {Font::get(FONT_SIZE_MEDIUM)} , mPadding {0.0f, 0.0f, 0.0f, 0.0f} , mFocused {false} diff --git a/es-core/src/components/ButtonComponent.h b/es-core/src/components/ButtonComponent.h index e55f979ba..57add5f38 100644 --- a/es-core/src/components/ButtonComponent.h +++ b/es-core/src/components/ButtonComponent.h @@ -17,8 +17,7 @@ class TextCache; class ButtonComponent : public GuiComponent { public: - ButtonComponent(Window* window, - const std::string& text = "", + ButtonComponent(const std::string& text = "", const std::string& helpText = "", const std::function& func = nullptr, bool upperCase = true, diff --git a/es-core/src/components/ComponentGrid.cpp b/es-core/src/components/ComponentGrid.cpp index aa3ef4408..3e6f45b7b 100644 --- a/es-core/src/components/ComponentGrid.cpp +++ b/es-core/src/components/ComponentGrid.cpp @@ -12,9 +12,8 @@ using namespace GridFlags; -ComponentGrid::ComponentGrid(Window* window, const glm::ivec2& gridDimensions) - : GuiComponent {window} - , mGridSize {gridDimensions} +ComponentGrid::ComponentGrid(const glm::ivec2& gridDimensions) + : mGridSize {gridDimensions} , mCursor {0, 0} { assert(gridDimensions.x > 0 && gridDimensions.y > 0); diff --git a/es-core/src/components/ComponentGrid.h b/es-core/src/components/ComponentGrid.h index f7689536f..aeb6c8584 100644 --- a/es-core/src/components/ComponentGrid.h +++ b/es-core/src/components/ComponentGrid.h @@ -33,7 +33,7 @@ namespace GridFlags class ComponentGrid : public GuiComponent { public: - ComponentGrid(Window* window, const glm::ivec2& gridDimensions); + ComponentGrid(const glm::ivec2& gridDimensions); virtual ~ComponentGrid(); bool removeEntry(const std::shared_ptr& comp); diff --git a/es-core/src/components/ComponentList.cpp b/es-core/src/components/ComponentList.cpp index 1b269c58c..a9e36f6f2 100644 --- a/es-core/src/components/ComponentList.cpp +++ b/es-core/src/components/ComponentList.cpp @@ -12,8 +12,8 @@ #define TOTAL_HORIZONTAL_PADDING_PX 20.0f -ComponentList::ComponentList(Window* window) - : IList {window, LIST_SCROLL_STYLE_SLOW, LIST_NEVER_LOOP} +ComponentList::ComponentList() + : IList {LIST_SCROLL_STYLE_SLOW, LIST_NEVER_LOOP} , mFocused {false} , mSetupCompleted {false} , mBottomCameraOffset {false} diff --git a/es-core/src/components/ComponentList.h b/es-core/src/components/ComponentList.h index 7884c8156..ac71e025c 100644 --- a/es-core/src/components/ComponentList.h +++ b/es-core/src/components/ComponentList.h @@ -59,7 +59,7 @@ struct ComponentListRow { class ComponentList : public IList { public: - ComponentList(Window* window); + ComponentList(); enum ScrollIndicator { SCROLL_NONE, // Replace with AllowShortEnumsOnASingleLine: false (clang-format >=11.0). diff --git a/es-core/src/components/DateTimeComponent.cpp b/es-core/src/components/DateTimeComponent.cpp index 07d116d1e..04a1c7433 100644 --- a/es-core/src/components/DateTimeComponent.cpp +++ b/es-core/src/components/DateTimeComponent.cpp @@ -14,23 +14,21 @@ #include "Settings.h" #include "utils/StringUtil.h" -DateTimeComponent::DateTimeComponent(Window* window) - : TextComponent {window} - , mDisplayRelative {false} +DateTimeComponent::DateTimeComponent() + : mDisplayRelative {false} { // ISO 8601 date format. setFormat("%Y-%m-%d"); } -DateTimeComponent::DateTimeComponent(Window* window, - const std::string& text, +DateTimeComponent::DateTimeComponent(const std::string& text, const std::shared_ptr& font, unsigned int color, Alignment align, glm::vec3 pos, glm::vec2 size, unsigned int bgcolor) - : TextComponent {window, text, font, color, align, pos, size, bgcolor} + : TextComponent {text, font, color, align, pos, size, bgcolor} , mDisplayRelative {false} { // ISO 8601 date format. diff --git a/es-core/src/components/DateTimeComponent.h b/es-core/src/components/DateTimeComponent.h index 30076fe5b..71bebca2d 100644 --- a/es-core/src/components/DateTimeComponent.h +++ b/es-core/src/components/DateTimeComponent.h @@ -20,9 +20,8 @@ class ThemeData; class DateTimeComponent : public TextComponent { public: - DateTimeComponent(Window* window); - DateTimeComponent(Window* window, - const std::string& text, + DateTimeComponent(); + DateTimeComponent(const std::string& text, const std::shared_ptr& font, unsigned int color = 0x000000FF, Alignment align = ALIGN_LEFT, diff --git a/es-core/src/components/DateTimeEditComponent.cpp b/es-core/src/components/DateTimeEditComponent.cpp index eb493948c..c21df7d46 100644 --- a/es-core/src/components/DateTimeEditComponent.cpp +++ b/es-core/src/components/DateTimeEditComponent.cpp @@ -15,9 +15,8 @@ #include "resources/Font.h" #include "utils/StringUtil.h" -DateTimeEditComponent::DateTimeEditComponent(Window* window, bool alignRight, DisplayMode dispMode) - : GuiComponent {window} - , mEditing {false} +DateTimeEditComponent::DateTimeEditComponent(bool alignRight, DisplayMode dispMode) + : mEditing {false} , mEditIndex {0} , mDisplayMode {dispMode} , mKeyRepeatDir {0} diff --git a/es-core/src/components/DateTimeEditComponent.h b/es-core/src/components/DateTimeEditComponent.h index 185af568e..356ada80f 100644 --- a/es-core/src/components/DateTimeEditComponent.h +++ b/es-core/src/components/DateTimeEditComponent.h @@ -24,9 +24,7 @@ public: DISP_RELATIVE_TO_NOW }; - DateTimeEditComponent(Window* window, - bool alignRight = false, - DisplayMode dispMode = DISP_DATE); + DateTimeEditComponent(bool alignRight = false, DisplayMode dispMode = DISP_DATE); void onSizeChanged() override; diff --git a/es-core/src/components/FlexboxComponent.cpp b/es-core/src/components/FlexboxComponent.cpp index fdbf09294..9d31b3c7c 100644 --- a/es-core/src/components/FlexboxComponent.cpp +++ b/es-core/src/components/FlexboxComponent.cpp @@ -19,9 +19,8 @@ #include "Settings.h" #include "ThemeData.h" -FlexboxComponent::FlexboxComponent(Window* window, std::vector& items) - : GuiComponent {window} - , mItems {items} +FlexboxComponent::FlexboxComponent(std::vector& items) + : mItems {items} , mDirection {DEFAULT_DIRECTION} , mAlignment {DEFAULT_ALIGNMENT} , mLines {DEFAULT_LINES} diff --git a/es-core/src/components/FlexboxComponent.h b/es-core/src/components/FlexboxComponent.h index bd5486613..8e1bbad98 100644 --- a/es-core/src/components/FlexboxComponent.h +++ b/es-core/src/components/FlexboxComponent.h @@ -10,7 +10,6 @@ #define ES_CORE_COMPONENTS_FLEXBOX_COMPONENT_H #include "GuiComponent.h" -#include "Window.h" #include "components/ImageComponent.h" class FlexboxComponent : public GuiComponent @@ -20,13 +19,13 @@ public: // Optional label, mostly a convenience for the calling class to track items. std::string label; // Main image that governs grid sizing and placement. - ImageComponent baseImage {nullptr}; + ImageComponent baseImage; // Optional overlay image that can be sized and positioned relative to the base image. - ImageComponent overlayImage {nullptr}; + ImageComponent overlayImage; bool visible = false; }; - FlexboxComponent(Window* window, std::vector& items); + FlexboxComponent(std::vector& items); // Getters/setters for the layout. const std::string& getDirection() const { return mDirection; } diff --git a/es-core/src/components/GridTileComponent.cpp b/es-core/src/components/GridTileComponent.cpp index f65c52e2b..98125252b 100644 --- a/es-core/src/components/GridTileComponent.cpp +++ b/es-core/src/components/GridTileComponent.cpp @@ -12,9 +12,8 @@ #include "animations/LambdaAnimation.h" #include "resources/TextureResource.h" -GridTileComponent::GridTileComponent(Window* window) - : GuiComponent {window} - , mBackground {window, ":/graphics/frame.png"} +GridTileComponent::GridTileComponent() + : mBackground {":/graphics/frame.png"} { mDefaultProperties.mSize = getDefaultTileSize(); mDefaultProperties.mPadding = glm::vec2 {16.0f * Renderer::getScreenWidthModifier(), @@ -34,7 +33,7 @@ GridTileComponent::GridTileComponent(Window* window) mSelectedProperties.mBackgroundCenterColor = 0xFFFFFFFF; mSelectedProperties.mBackgroundEdgeColor = 0xFFFFFFFF; - mImage = std::make_shared(mWindow); + mImage = std::make_shared(); mImage->setOrigin(0.5f, 0.5f); mBackground.setOrigin(0.5f, 0.5f); diff --git a/es-core/src/components/GridTileComponent.h b/es-core/src/components/GridTileComponent.h index 5cf570214..f0b0b2df6 100644 --- a/es-core/src/components/GridTileComponent.h +++ b/es-core/src/components/GridTileComponent.h @@ -25,7 +25,7 @@ struct GridTileProperties { class GridTileComponent : public GuiComponent { public: - GridTileComponent(Window* window); + GridTileComponent(); void render(const glm::mat4& parentTrans) override; void applyTheme(const std::shared_ptr& theme, diff --git a/es-core/src/components/HelpComponent.cpp b/es-core/src/components/HelpComponent.cpp index 73f77562c..04e532052 100644 --- a/es-core/src/components/HelpComponent.cpp +++ b/es-core/src/components/HelpComponent.cpp @@ -19,17 +19,17 @@ static std::map sIconPathMap {}; -HelpComponent::HelpComponent(Window* window) - : GuiComponent {window} +HelpComponent::HelpComponent() { + // Assign icons. assignIcons(); } void HelpComponent::assignIcons() { - std::string controllerType = Settings::getInstance()->getString("InputControllerType"); + std::string controllerType {Settings::getInstance()->getString("InputControllerType")}; - std::map sIconPathMapOld(sIconPathMap); + std::map sIconPathMapOld {sIconPathMap}; sIconPathMap.clear(); // These graphics files are common between all controller types. @@ -202,8 +202,7 @@ void HelpComponent::updateGrid() std::shared_ptr& font = mStyle.font; - mGrid = std::make_shared(mWindow, - glm::ivec2 {static_cast(mPrompts.size()) * 4, 1}); + mGrid = std::make_shared(glm::ivec2 {static_cast(mPrompts.size()) * 4, 1}); // [icon] [spacer1] [text] [spacer2] @@ -217,7 +216,7 @@ void HelpComponent::updateGrid() bool isDimmed = mWindow->isBackgroundDimmed(); for (auto it = mPrompts.cbegin(); it != mPrompts.cend(); ++it) { - auto icon = std::make_shared(mWindow); + auto icon = std::make_shared(); icon->setImage(getIconTexture(it->first.c_str()), false); icon->setColorShift(isDimmed ? mStyle.iconColorDimmed : mStyle.iconColor); icon->setResize(0, height); @@ -232,7 +231,7 @@ void HelpComponent::updateGrid() else lblInput = Utils::String::toUpper(lblInput); auto lbl = std::make_shared( - mWindow, lblInput, font, isDimmed ? mStyle.textColorDimmed : mStyle.textColor); + lblInput, font, isDimmed ? mStyle.textColorDimmed : mStyle.textColor); labels.push_back(lbl); width += diff --git a/es-core/src/components/HelpComponent.h b/es-core/src/components/HelpComponent.h index aa80eb170..d78416383 100644 --- a/es-core/src/components/HelpComponent.h +++ b/es-core/src/components/HelpComponent.h @@ -19,7 +19,7 @@ class TextureResource; class HelpComponent : public GuiComponent { public: - HelpComponent(Window* window); + HelpComponent(); void assignIcons(); diff --git a/es-core/src/components/IList.h b/es-core/src/components/IList.h index 4cae7de9c..b8e4e96d6 100644 --- a/es-core/src/components/IList.h +++ b/es-core/src/components/IList.h @@ -83,13 +83,11 @@ protected: Window* mWindow; public: - IList(Window* window, - const ScrollTierList& tierList = LIST_SCROLL_STYLE_QUICK, + IList(const ScrollTierList& tierList = LIST_SCROLL_STYLE_QUICK, const ListLoopType& loopType = LIST_PAUSE_AT_END) - : GuiComponent {window} - , mTierList {tierList} + : mTierList {tierList} , mLoopType {loopType} - , mWindow {window} + , mWindow {Window::getInstance()} { mCursor = 0; mScrollTier = 0; diff --git a/es-core/src/components/ImageComponent.cpp b/es-core/src/components/ImageComponent.cpp index 3d4fd427e..885eb6b55 100644 --- a/es-core/src/components/ImageComponent.cpp +++ b/es-core/src/components/ImageComponent.cpp @@ -28,9 +28,8 @@ glm::vec2 ImageComponent::getSize() const return GuiComponent::getSize() * (mBottomRightCrop - mTopLeftCrop); } -ImageComponent::ImageComponent(Window* window, bool forceLoad, bool dynamic) - : GuiComponent {window} - , mTargetSize {0, 0} +ImageComponent::ImageComponent(bool forceLoad, bool dynamic) + : mTargetSize {0, 0} , mFlipX {false} , mFlipY {false} , mTargetIsMax {false} diff --git a/es-core/src/components/ImageComponent.h b/es-core/src/components/ImageComponent.h index ac3ca53ae..be91b2fbf 100644 --- a/es-core/src/components/ImageComponent.h +++ b/es-core/src/components/ImageComponent.h @@ -17,7 +17,7 @@ class TextureResource; class ImageComponent : public GuiComponent { public: - ImageComponent(Window* window, bool forceLoad = false, bool dynamic = true); + ImageComponent(bool forceLoad = false, bool dynamic = true); virtual ~ImageComponent() {} void setDefaultImage(const std::string& path) { mDefaultPath = path; } diff --git a/es-core/src/components/ImageGridComponent.h b/es-core/src/components/ImageGridComponent.h index af83979d6..0175f512d 100644 --- a/es-core/src/components/ImageGridComponent.h +++ b/es-core/src/components/ImageGridComponent.h @@ -55,7 +55,7 @@ public: using IList::isScrolling; using IList::stopScrolling; - ImageGridComponent(Window* window); + ImageGridComponent(); void add(const std::string& name, const std::string& imagePath, const T& obj); @@ -122,9 +122,7 @@ private: std::function mCursorChangedCallback; }; -template -ImageGridComponent::ImageGridComponent(Window* window) - : IList(window) +template ImageGridComponent::ImageGridComponent() { glm::vec2 screen {static_cast(Renderer::getScreenWidth()), static_cast(Renderer::getScreenHeight())}; @@ -556,7 +554,7 @@ template void ImageGridComponent::buildTiles() for (int y = 0; y < (vert ? mGridDimension.y : mGridDimension.x); ++y) { for (int x = 0; x < (vert ? mGridDimension.x : mGridDimension.y); ++x) { // Create tiles. - auto tile = std::make_shared(mWindow); + auto tile = std::make_shared(); // In Vertical mode, tiles are ordered from left to right, then from top to bottom. // In Horizontal mode, tiles are ordered from top to bottom, then from left to right. diff --git a/es-core/src/components/LottieComponent.cpp b/es-core/src/components/LottieComponent.cpp index f72f3f618..b767d0f4b 100644 --- a/es-core/src/components/LottieComponent.cpp +++ b/es-core/src/components/LottieComponent.cpp @@ -18,9 +18,8 @@ #include -LottieComponent::LottieComponent(Window* window) - : GuiComponent {window} - , mCacheFrames {true} +LottieComponent::LottieComponent() + : mCacheFrames {true} , mMaxCacheSize {0} , mCacheSize {0} , mFrameSize {0} diff --git a/es-core/src/components/LottieComponent.h b/es-core/src/components/LottieComponent.h index c7a675d6b..c19e4db16 100644 --- a/es-core/src/components/LottieComponent.h +++ b/es-core/src/components/LottieComponent.h @@ -23,7 +23,7 @@ class LottieComponent : public GuiComponent { public: - LottieComponent(Window* window); + LottieComponent(); ~LottieComponent(); void setAnimation(const std::string& path); diff --git a/es-core/src/components/MenuComponent.cpp b/es-core/src/components/MenuComponent.cpp index 991fb0f45..3b7dd20f9 100644 --- a/es-core/src/components/MenuComponent.cpp +++ b/es-core/src/components/MenuComponent.cpp @@ -17,12 +17,8 @@ #define TITLE_HEIGHT (mTitle->getFont()->getLetterHeight() + Renderer::getScreenHeight() * 0.0637f) -MenuComponent::MenuComponent(Window* window, - std::string title, - const std::shared_ptr& titleFont) - : GuiComponent {window} - , mBackground {window} - , mGrid {window, glm::ivec2 {2, 4}} +MenuComponent::MenuComponent(std::string title, const std::shared_ptr& titleFont) + : mGrid {glm::ivec2 {2, 4}} , mNeedsSaving {false} { addChild(&mBackground); @@ -31,19 +27,19 @@ MenuComponent::MenuComponent(Window* window, mBackground.setImagePath(":/graphics/frame.svg"); // Set up title. - mTitle = std::make_shared(mWindow); + mTitle = std::make_shared(); mTitle->setHorizontalAlignment(ALIGN_CENTER); mTitle->setColor(0x555555FF); setTitle(title, titleFont); mGrid.setEntry(mTitle, glm::ivec2 {0, 0}, false, true, glm::ivec2 {2, 2}); // Set up list which will never change (externally, anyway). - mList = std::make_shared(mWindow); + mList = std::make_shared(); mGrid.setEntry(mList, glm::ivec2 {0, 2}, true, true, glm::ivec2 {2, 1}); // Set up scroll indicators. - mScrollUp = std::make_shared(mWindow); - mScrollDown = std::make_shared(mWindow); + mScrollUp = std::make_shared(); + mScrollDown = std::make_shared(); mScrollIndicator = std::make_shared(mList, mScrollUp, mScrollDown); mScrollUp->setResize(0.0f, mTitle->getFont()->getLetterHeight() / 2.0f); @@ -136,8 +132,8 @@ void MenuComponent::addButton(const std::string& name, const std::string& helpText, const std::function& callback) { - mButtons.push_back(std::make_shared(mWindow, Utils::String::toUpper(name), - helpText, callback)); + mButtons.push_back( + std::make_shared(Utils::String::toUpper(name), helpText, callback)); updateGrid(); updateSize(); } @@ -150,16 +146,16 @@ void MenuComponent::updateGrid() mButtonGrid.reset(); if (mButtons.size()) { - mButtonGrid = makeButtonGrid(mWindow, mButtons); + mButtonGrid = makeButtonGrid(mButtons); mGrid.setEntry(mButtonGrid, glm::ivec2 {0, 3}, true, false, glm::ivec2 {2, 1}); } } std::shared_ptr makeButtonGrid( - Window* window, const std::vector>& buttons) + const std::vector>& buttons) { std::shared_ptr buttonGrid = - std::make_shared(window, glm::ivec2 {static_cast(buttons.size()), 2}); + std::make_shared(glm::ivec2 {static_cast(buttons.size()), 2}); // Initialize to padding. float buttonGridWidth = BUTTON_GRID_HORIZ_PADDING * buttons.size(); @@ -180,9 +176,9 @@ std::shared_ptr makeButtonGrid( return buttonGrid; } -std::shared_ptr makeArrow(Window* window) +std::shared_ptr makeArrow() { - auto bracket = std::make_shared(window); + auto bracket = std::make_shared(); bracket->setImage(":/graphics/arrow.svg"); bracket->setResize(0, std::round(Font::get(FONT_SIZE_MEDIUM)->getLetterHeight())); return bracket; diff --git a/es-core/src/components/MenuComponent.h b/es-core/src/components/MenuComponent.h index b9685d1d1..ee9b7a050 100644 --- a/es-core/src/components/MenuComponent.h +++ b/es-core/src/components/MenuComponent.h @@ -22,14 +22,13 @@ class ButtonComponent; class ImageComponent; std::shared_ptr makeButtonGrid( - Window* window, const std::vector>& buttons); -std::shared_ptr makeArrow(Window* window); + const std::vector>& buttons); +std::shared_ptr makeArrow(); class MenuComponent : public GuiComponent { public: - MenuComponent(Window* window, - std::string title, + MenuComponent(std::string title, const std::shared_ptr& titleFont = Font::get(FONT_SIZE_LARGE)); virtual ~MenuComponent(); @@ -51,7 +50,7 @@ public: bool invert_when_selected = true) { ComponentListRow row; - row.addElement(std::make_shared(mWindow, Utils::String::toUpper(label), + row.addElement(std::make_shared(Utils::String::toUpper(label), Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true); row.addElement(comp, false, invert_when_selected); diff --git a/es-core/src/components/NinePatchComponent.cpp b/es-core/src/components/NinePatchComponent.cpp index e799d92d3..2403c3961 100644 --- a/es-core/src/components/NinePatchComponent.cpp +++ b/es-core/src/components/NinePatchComponent.cpp @@ -13,12 +13,10 @@ #include "resources/Font.h" #include "resources/TextureResource.h" -NinePatchComponent::NinePatchComponent(Window* window, - const std::string& path, +NinePatchComponent::NinePatchComponent(const std::string& path, unsigned int edgeColor, unsigned int centerColor) - : GuiComponent {window} - , mVertices {nullptr} + : mVertices {nullptr} , mPath {path} , mCornerSize {16.0f, 16.0f} , mSharpCorners {false} diff --git a/es-core/src/components/NinePatchComponent.h b/es-core/src/components/NinePatchComponent.h index ce19cab43..2b05d7998 100644 --- a/es-core/src/components/NinePatchComponent.h +++ b/es-core/src/components/NinePatchComponent.h @@ -29,8 +29,7 @@ class TextureResource; class NinePatchComponent : public GuiComponent { public: - NinePatchComponent(Window* window, - const std::string& path = "", + NinePatchComponent(const std::string& path = "", unsigned int edgeColor = 0xFFFFFFFF, unsigned int centerColor = 0xFFFFFFFF); virtual ~NinePatchComponent(); diff --git a/es-core/src/components/OptionListComponent.h b/es-core/src/components/OptionListComponent.h index 03ee3b3ef..d7eead14e 100644 --- a/es-core/src/components/OptionListComponent.h +++ b/es-core/src/components/OptionListComponent.h @@ -27,14 +27,12 @@ template class OptionListComponent : public GuiComponent { public: - OptionListComponent(Window* window, - const HelpStyle& helpstyle, + OptionListComponent(const HelpStyle& helpstyle, const std::string& name, bool multiSelect = false, bool multiExclusiveSelect = false, bool multiShowTotal = false) - : GuiComponent {window} - , mHelpStyle {helpstyle} + : mHelpStyle {helpstyle} , mMultiSelect {multiSelect} , mMultiExclusiveSelect {multiExclusiveSelect} , mMultiShowTotal {multiShowTotal} @@ -44,9 +42,6 @@ public: , mKeyRepeatStartDelay {OPTIONLIST_REPEAT_START_DELAY} , mKeyRepeatSpeed {OPTIONLIST_REPEAT_SPEED} , mName {name} - , mText {window} - , mLeftArrow {window} - , mRightArrow {window} { auto font {Font::get(FONT_SIZE_MEDIUM, FONT_PATH_LIGHT)}; mText.setFont(font); @@ -306,7 +301,7 @@ private: void open() { // Open the list popup. - mWindow->pushGui(new OptionListPopup(mWindow, getHelpStyle(), this, mName)); + mWindow->pushGui(new OptionListPopup(getHelpStyle(), this, mName)); } void onSelectedChanged() @@ -412,12 +407,10 @@ private: class OptionListPopup : public GuiComponent { public: - OptionListPopup(Window* window, - const HelpStyle& helpstyle, + OptionListPopup(const HelpStyle& helpstyle, OptionListComponent* parent, const std::string& title) - : GuiComponent(window) - , mMenu(window, title.c_str()) + : mMenu(title.c_str()) , mParent(parent) , mHelpStyle(helpstyle) { @@ -444,7 +437,7 @@ private: for (auto it = mParent->mEntries.begin(); it != mParent->mEntries.end(); ++it) { row.elements.clear(); auto textComponent = std::make_shared( - mWindow, Utils::String::toUpper(it->name), font, 0x777777FF); + Utils::String::toUpper(it->name), font, 0x777777FF); row.addElement(textComponent, true); if (mParent->mMultiExclusiveSelect && hasSelectedRow && !(*it).selected) { @@ -456,7 +449,7 @@ private: if (mParent->mMultiSelect) { // Add checkbox. - auto checkbox = std::make_shared(mWindow); + auto checkbox = std::make_shared(); checkbox->setImage(it->selected ? CHECKED_PATH : UNCHECKED_PATH); checkbox->setResize(0, font->getLetterHeight()); row.addElement(checkbox, false); diff --git a/es-core/src/components/RatingComponent.cpp b/es-core/src/components/RatingComponent.cpp index 38e0a006b..81bf7d73c 100644 --- a/es-core/src/components/RatingComponent.cpp +++ b/es-core/src/components/RatingComponent.cpp @@ -13,9 +13,8 @@ #include "ThemeData.h" #include "resources/TextureResource.h" -RatingComponent::RatingComponent(Window* window, bool colorizeChanges) - : GuiComponent {window} - , mColorOriginalValue {DEFAULT_COLORSHIFT} +RatingComponent::RatingComponent(bool colorizeChanges) + : mColorOriginalValue {DEFAULT_COLORSHIFT} , mColorChangedValue {DEFAULT_COLORSHIFT} , mColorShift {DEFAULT_COLORSHIFT} , mColorShiftEnd {DEFAULT_COLORSHIFT} diff --git a/es-core/src/components/RatingComponent.h b/es-core/src/components/RatingComponent.h index 0898b1a48..3f514b591 100644 --- a/es-core/src/components/RatingComponent.h +++ b/es-core/src/components/RatingComponent.h @@ -20,7 +20,7 @@ class TextureResource; class RatingComponent : public GuiComponent { public: - RatingComponent(Window* window, bool colorizeChanges = false); + RatingComponent(bool colorizeChanges = false); std::string getValue() const override; // Should be a normalized float (in the range [0..1]) - if it's not, it will be clamped. diff --git a/es-core/src/components/ScrollableContainer.cpp b/es-core/src/components/ScrollableContainer.cpp index 73dcfac2d..9f230f333 100644 --- a/es-core/src/components/ScrollableContainer.cpp +++ b/es-core/src/components/ScrollableContainer.cpp @@ -14,9 +14,8 @@ #include "renderers/Renderer.h" #include "resources/Font.h" -ScrollableContainer::ScrollableContainer(Window* window) - : GuiComponent {window} - , mScrollPos {0.0f, 0.0f} +ScrollableContainer::ScrollableContainer() + : mScrollPos {0.0f, 0.0f} , mScrollDir {0.0f, 0.0f} , mClipSpacing {0.0f} , mAutoScrollDelay {0} diff --git a/es-core/src/components/ScrollableContainer.h b/es-core/src/components/ScrollableContainer.h index fb80b7eea..500f7fd3c 100644 --- a/es-core/src/components/ScrollableContainer.h +++ b/es-core/src/components/ScrollableContainer.h @@ -22,7 +22,7 @@ class ScrollableContainer : public GuiComponent { public: - ScrollableContainer(Window* window); + ScrollableContainer(); glm::vec2 getScrollPos() const { return mScrollPos; } void setScrollPos(const glm::vec2& pos) { mScrollPos = pos; } diff --git a/es-core/src/components/SliderComponent.cpp b/es-core/src/components/SliderComponent.cpp index 6ebb193cf..a84034fa0 100644 --- a/es-core/src/components/SliderComponent.cpp +++ b/es-core/src/components/SliderComponent.cpp @@ -14,15 +14,12 @@ #define MOVE_REPEAT_DELAY 500 #define MOVE_REPEAT_RATE 40 -SliderComponent::SliderComponent( - Window* window, float min, float max, float increment, const std::string& suffix) - : GuiComponent {window} - , mMin {min} +SliderComponent::SliderComponent(float min, float max, float increment, const std::string& suffix) + : mMin {min} , mMax {max} , mSingleIncrement {increment} , mMoveRate {0.0f} , mBarHeight {0.0f} - , mKnob {window} , mSuffix {suffix} { assert((min - max) != 0.0f); @@ -33,7 +30,8 @@ SliderComponent::SliderComponent( mKnob.setOrigin(0.5f, 0.5f); mKnob.setImage(":/graphics/slider_knob.svg"); - setSize(window->peekGui()->getSize().x * 0.26f, Font::get(FONT_SIZE_MEDIUM)->getLetterHeight()); + setSize(mWindow->peekGui()->getSize().x * 0.26f, + Font::get(FONT_SIZE_MEDIUM)->getLetterHeight()); } bool SliderComponent::input(InputConfig* config, Input input) diff --git a/es-core/src/components/SliderComponent.h b/es-core/src/components/SliderComponent.h index 45be7c15a..3c6fde6b1 100644 --- a/es-core/src/components/SliderComponent.h +++ b/es-core/src/components/SliderComponent.h @@ -15,17 +15,16 @@ class Font; class TextCache; -// Used to display/edit a value between some min and max values. +// Slider to set value in a predefined range. class SliderComponent : public GuiComponent { public: using GuiComponent::getValue; using GuiComponent::setValue; - // Minimum value (far left of the slider), maximum value (far right of the slider), - // increment size (how much pressing L/R moves by), unit to display (optional). - SliderComponent( - Window* window, float min, float max, float increment, const std::string& suffix = ""); + // Minimum and maximum values, how much to increment each step the knob is moved and + // an optional unit. + SliderComponent(float min, float max, float increment, const std::string& suffix = ""); void setValue(float value); float getValue() { return mValue; } diff --git a/es-core/src/components/SwitchComponent.cpp b/es-core/src/components/SwitchComponent.cpp index 2e773c990..375554869 100644 --- a/es-core/src/components/SwitchComponent.cpp +++ b/es-core/src/components/SwitchComponent.cpp @@ -10,10 +10,8 @@ #include "resources/Font.h" -SwitchComponent::SwitchComponent(Window* window, bool state) - : GuiComponent {window} - , mImage {window} - , mState {state} +SwitchComponent::SwitchComponent(bool state) + : mState {state} , mOriginalValue {state} , mColorOriginalValue {DEFAULT_COLORSHIFT} , mColorChangedValue {DEFAULT_COLORSHIFT} diff --git a/es-core/src/components/SwitchComponent.h b/es-core/src/components/SwitchComponent.h index a21d40354..c3b660ba9 100644 --- a/es-core/src/components/SwitchComponent.h +++ b/es-core/src/components/SwitchComponent.h @@ -16,7 +16,7 @@ class SwitchComponent : public GuiComponent { public: - SwitchComponent(Window* window, bool state = false); + SwitchComponent(bool state = false); bool input(InputConfig* config, Input input) override; void render(const glm::mat4& parentTrans) override; diff --git a/es-core/src/components/TextComponent.cpp b/es-core/src/components/TextComponent.cpp index 65e8e35e4..cf6d16ec0 100644 --- a/es-core/src/components/TextComponent.cpp +++ b/es-core/src/components/TextComponent.cpp @@ -12,9 +12,8 @@ #include "Settings.h" #include "utils/StringUtil.h" -TextComponent::TextComponent(Window* window) - : GuiComponent {window} - , mFont {Font::get(FONT_SIZE_MEDIUM)} +TextComponent::TextComponent() + : mFont {Font::get(FONT_SIZE_MEDIUM)} , mColor {0x000000FF} , mBgColor {0} , mRenderBackground {false} @@ -28,16 +27,14 @@ TextComponent::TextComponent(Window* window) { } -TextComponent::TextComponent(Window* window, - const std::string& text, +TextComponent::TextComponent(const std::string& text, const std::shared_ptr& font, unsigned int color, Alignment align, glm::vec3 pos, glm::vec2 size, unsigned int bgcolor) - : GuiComponent {window} - , mFont {nullptr} + : mFont {nullptr} , mColor {0x000000FF} , mBgColor {0} , mRenderBackground {false} diff --git a/es-core/src/components/TextComponent.h b/es-core/src/components/TextComponent.h index 000829970..05854a524 100644 --- a/es-core/src/components/TextComponent.h +++ b/es-core/src/components/TextComponent.h @@ -24,9 +24,8 @@ class ThemeData; class TextComponent : public GuiComponent { public: - TextComponent(Window* window); - TextComponent(Window* window, - const std::string& text, + TextComponent(); + TextComponent(const std::string& text, const std::shared_ptr& font, unsigned int color = 0x000000FF, Alignment align = ALIGN_LEFT, diff --git a/es-core/src/components/TextEditComponent.cpp b/es-core/src/components/TextEditComponent.cpp index 5fea9d0e9..614fe527e 100644 --- a/es-core/src/components/TextEditComponent.cpp +++ b/es-core/src/components/TextEditComponent.cpp @@ -18,15 +18,14 @@ #define BLINKTIME 1000 -TextEditComponent::TextEditComponent(Window* window) - : GuiComponent {window} - , mFocused {false} +TextEditComponent::TextEditComponent() + : mFocused {false} , mEditing {false} , mCursor {0} , mBlinkTime {0} , mCursorRepeatDir {0} , mScrollOffset {0.0f, 0.0f} - , mBox {window, ":/graphics/textinput.svg"} + , mBox {":/graphics/textinput.svg"} , mFont {Font::get(FONT_SIZE_MEDIUM, FONT_PATH_LIGHT)} { mBox.setSharpCorners(true); diff --git a/es-core/src/components/TextEditComponent.h b/es-core/src/components/TextEditComponent.h index 6cd212ff6..4587be988 100644 --- a/es-core/src/components/TextEditComponent.h +++ b/es-core/src/components/TextEditComponent.h @@ -20,7 +20,7 @@ class TextCache; class TextEditComponent : public GuiComponent { public: - TextEditComponent(Window* window); + TextEditComponent(); void textInput(const std::string& text) override; bool input(InputConfig* config, Input input) override; diff --git a/es-core/src/components/TextListComponent.h b/es-core/src/components/TextListComponent.h index b86f072dd..34ce13a79 100644 --- a/es-core/src/components/TextListComponent.h +++ b/es-core/src/components/TextListComponent.h @@ -39,7 +39,7 @@ public: using GuiComponent::setColor; using List::size; - TextListComponent(Window* window); + TextListComponent(); bool input(InputConfig* config, Input input) override; void update(int deltaTime) override; @@ -128,10 +128,7 @@ private: ImageComponent mSelectorImage; }; -template -TextListComponent::TextListComponent(Window* window) - : IList {window} - , mSelectorImage {window} +template TextListComponent::TextListComponent() { mLoopOffset = 0; mLoopOffset2 = 0; diff --git a/es-core/src/components/VideoComponent.cpp b/es-core/src/components/VideoComponent.cpp index 7830e1115..fccc756f4 100644 --- a/es-core/src/components/VideoComponent.cpp +++ b/es-core/src/components/VideoComponent.cpp @@ -18,11 +18,8 @@ #define SCREENSAVER_FADE_IN_TIME 1100 #define MEDIA_VIEWER_FADE_IN_TIME 600 -VideoComponent::VideoComponent(Window* window) - : GuiComponent {window} - , mWindow {window} - , mStaticImage {window} - , mVideoWidth {0} +VideoComponent::VideoComponent() + : mVideoWidth {0} , mVideoHeight {0} , mTargetSize {0.0f, 0.0f} , mVideoAreaPos {0.0f, 0.0f} diff --git a/es-core/src/components/VideoComponent.h b/es-core/src/components/VideoComponent.h index 32102419d..09bf88737 100644 --- a/es-core/src/components/VideoComponent.h +++ b/es-core/src/components/VideoComponent.h @@ -29,7 +29,7 @@ class VideoComponent : public GuiComponent }; public: - VideoComponent(Window* window); + VideoComponent(); virtual ~VideoComponent(); // Loads the video at the given filepath. @@ -108,7 +108,6 @@ private: friend MediaViewer; protected: - Window* mWindow; ImageComponent mStaticImage; unsigned mVideoWidth; diff --git a/es-core/src/components/VideoFFmpegComponent.cpp b/es-core/src/components/VideoFFmpegComponent.cpp index d952bfc1f..f79a2d09b 100644 --- a/es-core/src/components/VideoFFmpegComponent.cpp +++ b/es-core/src/components/VideoFFmpegComponent.cpp @@ -23,9 +23,8 @@ enum AVPixelFormat VideoFFmpegComponent::sPixelFormat = AV_PIX_FMT_NONE; std::vector VideoFFmpegComponent::sHWDecodedVideos; std::vector VideoFFmpegComponent::sSWDecodedVideos; -VideoFFmpegComponent::VideoFFmpegComponent(Window* window) - : VideoComponent {window} - , mFrameProcessingThread {nullptr} +VideoFFmpegComponent::VideoFFmpegComponent() + : mFrameProcessingThread {nullptr} , mFormatContext {nullptr} , mVideoStream {nullptr} , mAudioStream {nullptr} diff --git a/es-core/src/components/VideoFFmpegComponent.h b/es-core/src/components/VideoFFmpegComponent.h index 6285e0dde..06522b22d 100644 --- a/es-core/src/components/VideoFFmpegComponent.h +++ b/es-core/src/components/VideoFFmpegComponent.h @@ -32,7 +32,7 @@ extern "C" { class VideoFFmpegComponent : public VideoComponent { public: - VideoFFmpegComponent(Window* window); + VideoFFmpegComponent(); virtual ~VideoFFmpegComponent(); // Resize the video to fit this size. If one axis is zero, scale that axis to maintain diff --git a/es-core/src/guis/GuiDetectDevice.cpp b/es-core/src/guis/GuiDetectDevice.cpp index eaad81285..6a12563b8 100644 --- a/es-core/src/guis/GuiDetectDevice.cpp +++ b/es-core/src/guis/GuiDetectDevice.cpp @@ -17,15 +17,13 @@ #define HOLD_TIME 1000 -GuiDetectDevice::GuiDetectDevice(Window* window, - bool firstRun, +GuiDetectDevice::GuiDetectDevice(bool firstRun, bool forcedConfig, const std::function& doneCallback) - : GuiComponent {window} - , mFirstRun {firstRun} + : mFirstRun {firstRun} , mForcedConfig {forcedConfig} - , mBackground {window, ":/graphics/frame.svg"} - , mGrid {window, glm::ivec2 {1, 5}} + , mBackground {":/graphics/frame.svg"} + , mGrid {glm::ivec2 {1, 5}} { mHoldingConfig = nullptr; mHoldTime = 0; @@ -35,9 +33,8 @@ GuiDetectDevice::GuiDetectDevice(Window* window, addChild(&mGrid); // Title. - mTitle = - std::make_shared(mWindow, firstRun ? "WELCOME" : "CONFIGURE INPUT DEVICE", - Font::get(FONT_SIZE_LARGE), 0x555555FF, ALIGN_CENTER); + mTitle = std::make_shared(firstRun ? "WELCOME" : "CONFIGURE INPUT DEVICE", + Font::get(FONT_SIZE_LARGE), 0x555555FF, ALIGN_CENTER); mGrid.setEntry(mTitle, glm::ivec2 {0, 0}, false, true, glm::ivec2 {1, 1}, GridFlags::BORDER_BOTTOM); @@ -53,33 +50,33 @@ GuiDetectDevice::GuiDetectDevice(Window* window, if (numDevices > 1 && Settings::getInstance()->getBool("InputOnlyFirstController")) deviceInfo << " (ONLY ACCEPTING INPUT FROM FIRST CONTROLLER)"; - mDeviceInfo = std::make_shared( - mWindow, deviceInfo.str(), Font::get(FONT_SIZE_SMALL), 0x999999FF, ALIGN_CENTER); + mDeviceInfo = std::make_shared(deviceInfo.str(), Font::get(FONT_SIZE_SMALL), + 0x999999FF, ALIGN_CENTER); mGrid.setEntry(mDeviceInfo, glm::ivec2 {0, 1}, false, true); // Message. if (numDevices > 0) { mMsg1 = std::make_shared( - mWindow, "HOLD A BUTTON ON YOUR GAMEPAD OR KEYBOARD TO CONFIGURE IT", - Font::get(FONT_SIZE_SMALL), 0x777777FF, ALIGN_CENTER); + "HOLD A BUTTON ON YOUR GAMEPAD OR KEYBOARD TO CONFIGURE IT", Font::get(FONT_SIZE_SMALL), + 0x777777FF, ALIGN_CENTER); } else { - mMsg1 = std::make_shared( - mWindow, "HOLD A BUTTON ON YOUR KEYBOARD TO CONFIGURE IT", Font::get(FONT_SIZE_SMALL), - 0x777777FF, ALIGN_CENTER); + mMsg1 = + std::make_shared("HOLD A BUTTON ON YOUR KEYBOARD TO CONFIGURE IT", + Font::get(FONT_SIZE_SMALL), 0x777777FF, ALIGN_CENTER); } mGrid.setEntry(mMsg1, glm::ivec2 {0, 2}, false, true); const std::string msg2str = firstRun ? "PRESS ESC TO SKIP (OR F4 TO QUIT AT ANY TIME)" : "PRESS ESC TO CANCEL"; - mMsg2 = std::make_shared(mWindow, msg2str, Font::get(FONT_SIZE_SMALL), - 0x777777FF, ALIGN_CENTER); + mMsg2 = std::make_shared(msg2str, Font::get(FONT_SIZE_SMALL), 0x777777FF, + ALIGN_CENTER); mGrid.setEntry(mMsg2, glm::ivec2 {0, 3}, false, true); // Currently held device. - mDeviceHeld = std::make_shared(mWindow, "", Font::get(FONT_SIZE_MEDIUM), - 0xFFFFFFFF, ALIGN_CENTER); + mDeviceHeld = + std::make_shared("", Font::get(FONT_SIZE_MEDIUM), 0xFFFFFFFF, ALIGN_CENTER); mGrid.setEntry(mDeviceHeld, glm::ivec2 {0, 4}, false, true); // Adjust the width relative to the aspect ratio of the screen to make the GUI look coherent @@ -160,7 +157,7 @@ void GuiDetectDevice::update(int deltaTime) mDeviceHeld->setColor((c << 24) | (c << 16) | (c << 8) | 0xFF); if (mHoldTime <= 0) { // Picked one! - mWindow->pushGui(new GuiInputConfig(mWindow, mHoldingConfig, true, mDoneCallback)); + mWindow->pushGui(new GuiInputConfig(mHoldingConfig, true, mDoneCallback)); delete this; } } diff --git a/es-core/src/guis/GuiDetectDevice.h b/es-core/src/guis/GuiDetectDevice.h index a9a6da560..ea91cba72 100644 --- a/es-core/src/guis/GuiDetectDevice.h +++ b/es-core/src/guis/GuiDetectDevice.h @@ -18,10 +18,7 @@ class TextComponent; class GuiDetectDevice : public GuiComponent { public: - GuiDetectDevice(Window* window, - bool firstRun, - bool forcedConfig, - const std::function& doneCallback); + GuiDetectDevice(bool firstRun, bool forcedConfig, const std::function& doneCallback); bool input(InputConfig* config, Input input) override; void update(int deltaTime) override; diff --git a/es-core/src/guis/GuiInfoPopup.cpp b/es-core/src/guis/GuiInfoPopup.cpp index e5ffc83a0..b332bb442 100644 --- a/es-core/src/guis/GuiInfoPopup.cpp +++ b/es-core/src/guis/GuiInfoPopup.cpp @@ -14,18 +14,17 @@ #include -GuiInfoPopup::GuiInfoPopup(Window* window, std::string message, int duration) - : GuiComponent {window} - , mMessage {message} +GuiInfoPopup::GuiInfoPopup(std::string message, int duration) + : mMessage {message} , mDuration {duration} , mRunning {true} { - mFrame = new NinePatchComponent(window); + mFrame = new NinePatchComponent; float maxWidth {Renderer::getScreenWidth() * 0.9f}; float maxHeight {Renderer::getScreenHeight() * 0.2f}; - std::shared_ptr s {std::make_shared( - mWindow, "", Font::get(FONT_SIZE_MINI), 0x444444FF, ALIGN_CENTER)}; + std::shared_ptr s { + std::make_shared("", Font::get(FONT_SIZE_MINI), 0x444444FF, ALIGN_CENTER)}; // We do this to force the text container to resize and return the actual expected popup size. s->setSize(0.0f, 0.0f); @@ -60,7 +59,7 @@ GuiInfoPopup::GuiInfoPopup(Window* window, std::string message, int duration) // We only initialize the actual time when we first start to render. mStartTime = 0; - mGrid = new ComponentGrid(window, glm::ivec2 {1, 3}); + mGrid = new ComponentGrid(glm::ivec2 {1, 3}); mGrid->setSize(mSize); mGrid->setEntry(s, glm::ivec2 {0, 1}, false, true); addChild(mGrid); diff --git a/es-core/src/guis/GuiInfoPopup.h b/es-core/src/guis/GuiInfoPopup.h index 67f1df084..e5b2fe4a4 100644 --- a/es-core/src/guis/GuiInfoPopup.h +++ b/es-core/src/guis/GuiInfoPopup.h @@ -10,7 +10,6 @@ #define ES_APP_GUIS_GUI_INFO_POPUP_H #include "GuiComponent.h" -#include "Window.h" class ComponentGrid; class NinePatchComponent; @@ -18,7 +17,7 @@ class NinePatchComponent; class GuiInfoPopup : public GuiComponent { public: - GuiInfoPopup(Window* window, std::string message, int duration); + GuiInfoPopup(std::string message, int duration); ~GuiInfoPopup(); void render(const glm::mat4& parentTrans); diff --git a/es-core/src/guis/GuiInputConfig.cpp b/es-core/src/guis/GuiInputConfig.cpp index ef76d8d49..7036036dd 100644 --- a/es-core/src/guis/GuiInputConfig.cpp +++ b/es-core/src/guis/GuiInputConfig.cpp @@ -10,7 +10,6 @@ #include "InputManager.h" #include "Log.h" -#include "Window.h" #include "components/ButtonComponent.h" #include "components/MenuComponent.h" #include "guis/GuiMsgBox.h" @@ -27,13 +26,11 @@ struct InputConfigStructure { static const int inputCount = 24; static InputConfigStructure sGuiInputConfigList[inputCount]; -GuiInputConfig::GuiInputConfig(Window* window, - InputConfig* target, +GuiInputConfig::GuiInputConfig(InputConfig* target, bool reconfigureAll, const std::function& okCallback) - : GuiComponent {window} - , mBackground {window, ":/graphics/frame.svg"} - , mGrid {window, glm::ivec2 {1, 7}} + : mBackground {":/graphics/frame.svg"} + , mGrid {glm::ivec2 {1, 7}} , mTargetConfig {target} , mHoldingInput {false} { @@ -54,10 +51,10 @@ GuiInputConfig::GuiInputConfig(Window* window, addChild(&mGrid); // 0 is a spacer row. - mGrid.setEntry(std::make_shared(mWindow), glm::ivec2 {0, 0}, false); + mGrid.setEntry(std::make_shared(), glm::ivec2 {0, 0}, false); - mTitle = std::make_shared(mWindow, "CONFIGURING", Font::get(FONT_SIZE_LARGE), - 0x555555FF, ALIGN_CENTER); + mTitle = std::make_shared("CONFIGURING", Font::get(FONT_SIZE_LARGE), 0x555555FF, + ALIGN_CENTER); mGrid.setEntry(mTitle, glm::ivec2 {0, 1}, false, true); std::stringstream ss; @@ -67,45 +64,42 @@ GuiInputConfig::GuiInputConfig(Window* window, ss << "CEC"; else ss << "GAMEPAD " << (target->getDeviceId() + 1) << " (" << target->getDeviceName() << ")"; - mSubtitle1 = - std::make_shared(mWindow, Utils::String::toUpper(ss.str()), - Font::get(FONT_SIZE_MEDIUM), 0x555555FF, ALIGN_CENTER); + mSubtitle1 = std::make_shared( + Utils::String::toUpper(ss.str()), Font::get(FONT_SIZE_MEDIUM), 0x555555FF, ALIGN_CENTER); mGrid.setEntry(mSubtitle1, glm::ivec2 {0, 2}, false, true); - mSubtitle2 = - std::make_shared(mWindow, "HOLD ANY BUTTON 1 SECOND TO SKIP", - Font::get(FONT_SIZE_SMALL), 0x999999FF, ALIGN_CENTER); + mSubtitle2 = std::make_shared( + "HOLD ANY BUTTON 1 SECOND TO SKIP", Font::get(FONT_SIZE_SMALL), 0x999999FF, ALIGN_CENTER); // The opacity will be set to visible for any row that is skippable. mSubtitle2->setOpacity(0); mGrid.setEntry(mSubtitle2, glm::ivec2 {0, 3}, false, true); // 4 is a spacer row. - mList = std::make_shared(mWindow); + mList = std::make_shared(); mGrid.setEntry(mList, glm::ivec2 {0, 5}, true, true); for (int i = 0; i < inputCount; ++i) { ComponentListRow row; // Icon. - auto icon = std::make_shared(mWindow); + auto icon = std::make_shared(); icon->setImage(sGuiInputConfigList[i].icon); icon->setColorShift(0x777777FF); icon->setResize(0, Font::get(FONT_SIZE_MEDIUM)->getLetterHeight() * 1.25f); row.addElement(icon, false); // Spacer between icon and text. - auto spacer = std::make_shared(mWindow); + auto spacer = std::make_shared(); spacer->setSize(16, 0); row.addElement(spacer, false); - auto text = std::make_shared(mWindow, sGuiInputConfigList[i].dispName, + auto text = std::make_shared(sGuiInputConfigList[i].dispName, Font::get(FONT_SIZE_MEDIUM), 0x777777FF); row.addElement(text, true); - auto mapping = std::make_shared(mWindow, "-NOT DEFINED-", - Font::get(FONT_SIZE_MEDIUM, FONT_PATH_LIGHT), - 0x999999FF, ALIGN_RIGHT); + auto mapping = std::make_shared( + "-NOT DEFINED-", Font::get(FONT_SIZE_MEDIUM, FONT_PATH_LIGHT), 0x999999FF, ALIGN_RIGHT); setNotDefined(mapping); // Overrides the text and color set above. row.addElement(mapping, true); mMappings.push_back(mapping); @@ -181,9 +175,9 @@ GuiInputConfig::GuiInputConfig(Window* window, }; buttons.push_back( - std::make_shared(mWindow, "OK", "ok", [okFunction] { okFunction(); })); + std::make_shared("OK", "ok", [okFunction] { okFunction(); })); - mButtonGrid = makeButtonGrid(mWindow, buttons); + mButtonGrid = makeButtonGrid(buttons); mGrid.setEntry(mButtonGrid, glm::ivec2 {0, 6}, true, false); // Adjust the width relative to the aspect ratio of the screen to make the GUI look coherent diff --git a/es-core/src/guis/GuiInputConfig.h b/es-core/src/guis/GuiInputConfig.h index a58524030..f526c747d 100644 --- a/es-core/src/guis/GuiInputConfig.h +++ b/es-core/src/guis/GuiInputConfig.h @@ -19,8 +19,7 @@ class TextComponent; class GuiInputConfig : public GuiComponent { public: - GuiInputConfig(Window* window, - InputConfig* target, + GuiInputConfig(InputConfig* target, bool reconfigureAll, const std::function& okCallback); diff --git a/es-core/src/guis/GuiMsgBox.cpp b/es-core/src/guis/GuiMsgBox.cpp index 44c72b28b..8a94d09f8 100644 --- a/es-core/src/guis/GuiMsgBox.cpp +++ b/es-core/src/guis/GuiMsgBox.cpp @@ -15,8 +15,7 @@ #define HORIZONTAL_PADDING_PX 20.0f #define VERTICAL_PADDING_MODIFIER 1.225f -GuiMsgBox::GuiMsgBox(Window* window, - const HelpStyle& helpstyle, +GuiMsgBox::GuiMsgBox(const HelpStyle& helpstyle, const std::string& text, const std::string& name1, const std::function& func1, @@ -26,9 +25,8 @@ GuiMsgBox::GuiMsgBox(Window* window, const std::function& func3, bool disableBackButton, bool deleteOnButtonPress) - : GuiComponent {window} - , mBackground {window, ":/graphics/frame.svg"} - , mGrid {window, glm::ivec2 {1, 2}} + : mBackground {":/graphics/frame.svg"} + , mGrid {glm::ivec2 {1, 2}} , mHelpStyle {helpstyle} , mDisableBackButton {disableBackButton} , mDeleteOnButtonPress {deleteOnButtonPress} @@ -42,19 +40,19 @@ GuiMsgBox::GuiMsgBox(Window* window, float minWidth { floorf(glm::clamp(0.30f * aspectValue, 0.10f, 0.50f) * Renderer::getScreenWidth())}; - mMsg = std::make_shared(mWindow, text, Font::get(FONT_SIZE_MEDIUM), 0x777777FF, + mMsg = std::make_shared(text, Font::get(FONT_SIZE_MEDIUM), 0x777777FF, ALIGN_CENTER); mGrid.setEntry(mMsg, glm::ivec2 {0, 0}, false, false); // Create the buttons. mButtons.push_back(std::make_shared( - mWindow, name1, name1, std::bind(&GuiMsgBox::deleteMeAndCall, this, func1))); + name1, name1, std::bind(&GuiMsgBox::deleteMeAndCall, this, func1))); if (!name2.empty()) mButtons.push_back(std::make_shared( - mWindow, name2, name2, std::bind(&GuiMsgBox::deleteMeAndCall, this, func2))); + name2, name2, std::bind(&GuiMsgBox::deleteMeAndCall, this, func2))); if (!name3.empty()) mButtons.push_back(std::make_shared( - mWindow, name3, name3, std::bind(&GuiMsgBox::deleteMeAndCall, this, func3))); + name3, name3, std::bind(&GuiMsgBox::deleteMeAndCall, this, func3))); // Set accelerator automatically (button to press when "B" is pressed). if (mButtons.size() == 1) { @@ -71,7 +69,7 @@ GuiMsgBox::GuiMsgBox(Window* window, } // Put the buttons into a ComponentGrid. - mButtonGrid = makeButtonGrid(mWindow, mButtons); + mButtonGrid = makeButtonGrid(mButtons); mGrid.setEntry(mButtonGrid, glm::ivec2 {0, 1}, true, false, glm::ivec2 {1, 1}, GridFlags::BORDER_TOP); diff --git a/es-core/src/guis/GuiMsgBox.h b/es-core/src/guis/GuiMsgBox.h index edb04b697..1bcc19fa4 100644 --- a/es-core/src/guis/GuiMsgBox.h +++ b/es-core/src/guis/GuiMsgBox.h @@ -20,8 +20,7 @@ class TextComponent; class GuiMsgBox : public GuiComponent { public: - GuiMsgBox(Window* window, - const HelpStyle& helpstyle, + GuiMsgBox(const HelpStyle& helpstyle, const std::string& text, const std::string& name1 = "OK", const std::function& func1 = nullptr, diff --git a/es-core/src/guis/GuiTextEditKeyboardPopup.cpp b/es-core/src/guis/GuiTextEditKeyboardPopup.cpp index 3dd978cb1..9398b9fe4 100644 --- a/es-core/src/guis/GuiTextEditKeyboardPopup.cpp +++ b/es-core/src/guis/GuiTextEditKeyboardPopup.cpp @@ -74,7 +74,6 @@ std::vector> kbLastRowLoad { // clang-format on GuiTextEditKeyboardPopup::GuiTextEditKeyboardPopup( - Window* window, const HelpStyle& helpstyle, const std::string& title, const std::string& initValue, @@ -87,9 +86,8 @@ GuiTextEditKeyboardPopup::GuiTextEditKeyboardPopup( const std::string& loadBtnHelpText, const std::string& clearBtnHelpText, const std::string& cancelBtnHelpText) - : GuiComponent {window} - , mBackground {window, ":/graphics/frame.svg"} - , mGrid {window, glm::ivec2 {1, (infoString != "" && defaultValue != "" ? 8 : 6)}} + : mBackground {":/graphics/frame.svg"} + , mGrid {glm::ivec2 {1, (infoString != "" && defaultValue != "" ? 8 : 6)}} , mHelpStyle {helpstyle} , mInitValue {initValue} , mAcceptBtnHelpText {acceptBtnHelpText} @@ -111,7 +109,7 @@ GuiTextEditKeyboardPopup::GuiTextEditKeyboardPopup( addChild(&mBackground); addChild(&mGrid); - mTitle = std::make_shared(mWindow, Utils::String::toUpper(title), + mTitle = std::make_shared(Utils::String::toUpper(title), Font::get(FONT_SIZE_LARGE), 0x555555FF, ALIGN_CENTER); std::vector> kbLayout; @@ -128,9 +126,9 @@ GuiTextEditKeyboardPopup::GuiTextEditKeyboardPopup( mHorizontalKeyCount = static_cast(kbLayout[0].size()); mKeyboardGrid = std::make_shared( - mWindow, glm::ivec2(mHorizontalKeyCount, static_cast(kbLayout.size()) / 3)); + glm::ivec2(mHorizontalKeyCount, static_cast(kbLayout.size()) / 3)); - mText = std::make_shared(mWindow); + mText = std::make_shared(); mText->setValue(initValue); // Header. @@ -139,12 +137,12 @@ GuiTextEditKeyboardPopup::GuiTextEditKeyboardPopup( int yPos = 1; if (mComplexMode) { - mInfoString = std::make_shared( - mWindow, infoString, Font::get(FONT_SIZE_MEDIUM), 0x555555FF, ALIGN_CENTER); + mInfoString = std::make_shared(infoString, Font::get(FONT_SIZE_MEDIUM), + 0x555555FF, ALIGN_CENTER); mGrid.setEntry(mInfoString, glm::ivec2 {0, yPos}, false, true); - mDefaultValue = std::make_shared( - mWindow, defaultValue, Font::get(FONT_SIZE_SMALL), 0x555555FF, ALIGN_CENTER); + mDefaultValue = std::make_shared(defaultValue, Font::get(FONT_SIZE_SMALL), + 0x555555FF, ALIGN_CENTER); mGrid.setEntry(mDefaultValue, glm::ivec2 {0, yPos + 1}, false, true); yPos += 2; } @@ -197,12 +195,12 @@ GuiTextEditKeyboardPopup::GuiTextEditKeyboardPopup( if (lower == "SHIFT") { mShiftButton = std::make_shared( - mWindow, (SHIFT_SYMBOL), ("SHIFT"), [this] { shiftKeys(); }, false, true); + (SHIFT_SYMBOL), ("SHIFT"), [this] { shiftKeys(); }, false, true); button = mShiftButton; } else if (lower == "ALT") { - mAltButton = std::make_shared( - mWindow, (ALT_SYMBOL), ("ALT"), [this] { altKeys(); }, false, true); + mAltButton = std::make_shared((ALT_SYMBOL), ("ALT"), + [this] { altKeys(); }, false, true); button = mAltButton; } else { @@ -354,7 +352,7 @@ bool GuiTextEditKeyboardPopup::input(InputConfig* config, Input input) if (mText->getValue() != mInitValue) { // Changes were made, ask if the user wants to save them. mWindow->pushGui(new GuiMsgBox( - mWindow, mHelpStyle, mSaveConfirmationText, "YES", + mHelpStyle, mSaveConfirmationText, "YES", [this] { this->mOkCallback(mText->getValue()); delete this; @@ -645,7 +643,7 @@ std::shared_ptr GuiTextEditKeyboardPopup::makeButton( const std::string& altshiftedKey) { std::shared_ptr button = std::make_shared( - mWindow, key, key, + key, key, [this, key, shiftedKey, altedKey, altshiftedKey] { if (key == (OK_SYMBOL) || key.find("OK") != std::string::npos) { mOkCallback(mText->getValue()); diff --git a/es-core/src/guis/GuiTextEditKeyboardPopup.h b/es-core/src/guis/GuiTextEditKeyboardPopup.h index dcd7c766b..cb575f446 100644 --- a/es-core/src/guis/GuiTextEditKeyboardPopup.h +++ b/es-core/src/guis/GuiTextEditKeyboardPopup.h @@ -18,8 +18,7 @@ class GuiTextEditKeyboardPopup : public GuiComponent { public: - GuiTextEditKeyboardPopup(Window* window, - const HelpStyle& helpstyle, + GuiTextEditKeyboardPopup(const HelpStyle& helpstyle, const std::string& title, const std::string& initValue, const std::function& okCallback, diff --git a/es-core/src/guis/GuiTextEditPopup.cpp b/es-core/src/guis/GuiTextEditPopup.cpp index 43d8fc765..5465b8f18 100644 --- a/es-core/src/guis/GuiTextEditPopup.cpp +++ b/es-core/src/guis/GuiTextEditPopup.cpp @@ -15,8 +15,7 @@ #include "components/MenuComponent.h" #include "guis/GuiMsgBox.h" -GuiTextEditPopup::GuiTextEditPopup(Window* window, - const HelpStyle& helpstyle, +GuiTextEditPopup::GuiTextEditPopup(const HelpStyle& helpstyle, const std::string& title, const std::string& initValue, const std::function& okCallback, @@ -28,9 +27,8 @@ GuiTextEditPopup::GuiTextEditPopup(Window* window, const std::string& loadBtnHelpText, const std::string& clearBtnHelpText, const std::string& cancelBtnHelpText) - : GuiComponent {window} - , mBackground {window, ":/graphics/frame.svg"} - , mGrid {window, glm::ivec2 {1, (infoString != "" && defaultValue != "" ? 5 : 3)}} + : mBackground {":/graphics/frame.svg"} + , mGrid {glm::ivec2 {1, (infoString != "" && defaultValue != "" ? 5 : 3)}} , mHelpStyle {helpstyle} , mInitValue {initValue} , mAcceptBtnText {acceptBtnText} @@ -47,41 +45,41 @@ GuiTextEditPopup::GuiTextEditPopup(Window* window, addChild(&mBackground); addChild(&mGrid); - mTitle = std::make_shared(mWindow, Utils::String::toUpper(title), + mTitle = std::make_shared(Utils::String::toUpper(title), Font::get(FONT_SIZE_MEDIUM), 0x555555FF, ALIGN_CENTER); if (mComplexMode) { - mInfoString = std::make_shared( - mWindow, infoString, Font::get(FONT_SIZE_SMALL), 0x555555FF, ALIGN_CENTER); - mDefaultValue = std::make_shared( - mWindow, defaultValue, Font::get(FONT_SIZE_SMALL), 0x555555FF, ALIGN_CENTER); + mInfoString = std::make_shared(infoString, Font::get(FONT_SIZE_SMALL), + 0x555555FF, ALIGN_CENTER); + mDefaultValue = std::make_shared(defaultValue, Font::get(FONT_SIZE_SMALL), + 0x555555FF, ALIGN_CENTER); } - mText = std::make_shared(mWindow); + mText = std::make_shared(); mText->setValue(initValue); std::vector> buttons; - buttons.push_back(std::make_shared(mWindow, acceptBtnText, acceptBtnText, - [this, okCallback] { - okCallback(mText->getValue()); - delete this; - })); + buttons.push_back( + std::make_shared(acceptBtnText, acceptBtnText, [this, okCallback] { + okCallback(mText->getValue()); + delete this; + })); if (mComplexMode) { - buttons.push_back(std::make_shared( - mWindow, "load", loadBtnHelpText, [this, defaultValue] { + buttons.push_back( + std::make_shared("load", loadBtnHelpText, [this, defaultValue] { mText->setValue(defaultValue); mText->setCursor(0); mText->setCursor(defaultValue.size()); })); } - buttons.push_back(std::make_shared(mWindow, "clear", clearBtnHelpText, + buttons.push_back(std::make_shared("clear", clearBtnHelpText, [this] { mText->setValue(""); })); - buttons.push_back(std::make_shared(mWindow, "CANCEL", "discard changes", - [this] { delete this; })); + buttons.push_back( + std::make_shared("CANCEL", "discard changes", [this] { delete this; })); - mButtonGrid = makeButtonGrid(mWindow, buttons); + mButtonGrid = makeButtonGrid(buttons); mGrid.setEntry(mTitle, glm::ivec2 {0, 0}, false, true); @@ -179,7 +177,7 @@ bool GuiTextEditPopup::input(InputConfig* config, Input input) if (mText->getValue() != mInitValue) { // Changes were made, ask if the user wants to save them. mWindow->pushGui(new GuiMsgBox( - mWindow, mHelpStyle, mSaveConfirmationText, "YES", + mHelpStyle, mSaveConfirmationText, "YES", [this] { this->mOkCallback(mText->getValue()); delete this; diff --git a/es-core/src/guis/GuiTextEditPopup.h b/es-core/src/guis/GuiTextEditPopup.h index a77623704..97443f678 100644 --- a/es-core/src/guis/GuiTextEditPopup.h +++ b/es-core/src/guis/GuiTextEditPopup.h @@ -18,8 +18,7 @@ class GuiTextEditPopup : public GuiComponent { public: - GuiTextEditPopup(Window* window, - const HelpStyle& helpstyle, + GuiTextEditPopup(const HelpStyle& helpstyle, const std::string& title, const std::string& initValue, const std::function& okCallback, diff --git a/es-core/src/renderers/Shader_GL21.cpp b/es-core/src/renderers/Shader_GL21.cpp index ce1a4cf10..51818b7e2 100644 --- a/es-core/src/renderers/Shader_GL21.cpp +++ b/es-core/src/renderers/Shader_GL21.cpp @@ -40,7 +40,7 @@ namespace Renderer std::string shaderCode; // This will load the entire GLSL source code into the string variable. - const ResourceData& shaderData = ResourceManager::getInstance().getFileData(path); + const ResourceData& shaderData {ResourceManager::getInstance().getFileData(path)}; shaderCode.assign(reinterpret_cast(shaderData.ptr.get()), shaderData.length); // Define the GLSL version (version 120 = OpenGL 2.1). diff --git a/es-core/src/resources/Font.cpp b/es-core/src/resources/Font.cpp index 92f75a536..f5c24aca1 100644 --- a/es-core/src/resources/Font.cpp +++ b/es-core/src/resources/Font.cpp @@ -14,15 +14,15 @@ #include "utils/FileSystemUtil.h" #include "utils/StringUtil.h" -FT_Library Font::sLibrary = nullptr; +FT_Library Font::sLibrary {nullptr}; std::map, std::weak_ptr> Font::sFontMap; Font::FontFace::FontFace(ResourceData&& d, int size) : data {d} { - int err = - FT_New_Memory_Face(sLibrary, data.ptr.get(), static_cast(data.length), 0, &face); + int err { + FT_New_Memory_Face(sLibrary, data.ptr.get(), static_cast(data.length), 0, &face)}; assert(!err); if (!err) diff --git a/es-core/src/resources/ResourceManager.cpp b/es-core/src/resources/ResourceManager.cpp index 209bb1ebc..677f0ab5b 100644 --- a/es-core/src/resources/ResourceManager.cpp +++ b/es-core/src/resources/ResourceManager.cpp @@ -31,9 +31,8 @@ std::string ResourceManager::getResourcePath(const std::string& path, bool termi if ((path[0] == ':') && (path[1] == '/')) { // Check under the home directory. - std::string testHome; - - testHome = Utils::FileSystem::getHomePath() + "/.emulationstation/resources/" + &path[2]; + std::string testHome = + Utils::FileSystem::getHomePath() + "/.emulationstation/resources/" + &path[2]; if (Utils::FileSystem::exists(testHome)) return testHome;