From 119dfc90f836d1700fce92c84d5738422b3fe34e Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Tue, 4 Jan 2022 21:49:22 +0100 Subject: [PATCH] Changed ViewController::get() to ViewController::getInstance() --- es-app/src/CollectionSystemsManager.cpp | 74 ++++++++++--------- es-app/src/MediaViewer.cpp | 6 +- es-app/src/SystemData.cpp | 6 +- es-app/src/SystemScreensaver.cpp | 14 ++-- es-app/src/guis/GuiAlternativeEmulators.cpp | 2 +- .../src/guis/GuiCollectionSystemsOptions.cpp | 2 +- es-app/src/guis/GuiGameScraper.cpp | 2 +- es-app/src/guis/GuiGamelistFilter.cpp | 4 +- es-app/src/guis/GuiGamelistOptions.cpp | 28 +++---- es-app/src/guis/GuiMenu.cpp | 13 ++-- es-app/src/guis/GuiMetaDataEd.cpp | 10 +-- es-app/src/guis/GuiOfflineGenerator.cpp | 4 +- es-app/src/guis/GuiScraperMenu.cpp | 2 +- es-app/src/guis/GuiScraperMulti.cpp | 4 +- es-app/src/guis/GuiScraperSearch.cpp | 4 +- es-app/src/guis/GuiSettings.cpp | 22 +++--- es-app/src/main.cpp | 20 ++--- es-app/src/scrapers/Scraper.cpp | 2 +- es-app/src/views/SystemView.cpp | 16 ++-- es-app/src/views/UIModeController.cpp | 4 +- es-app/src/views/ViewController.cpp | 2 +- es-app/src/views/ViewController.h | 2 +- .../src/views/gamelist/BasicGameListView.cpp | 10 +-- .../views/gamelist/DetailedGameListView.cpp | 4 +- .../src/views/gamelist/GridGameListView.cpp | 6 +- es-app/src/views/gamelist/IGameListView.cpp | 4 +- .../views/gamelist/ISimpleGameListView.cpp | 41 +++++----- .../src/views/gamelist/VideoGameListView.cpp | 7 +- 28 files changed, 165 insertions(+), 150 deletions(-) diff --git a/es-app/src/CollectionSystemsManager.cpp b/es-app/src/CollectionSystemsManager.cpp index 02d74d588..bb9f543df 100644 --- a/es-app/src/CollectionSystemsManager.cpp +++ b/es-app/src/CollectionSystemsManager.cpp @@ -264,7 +264,7 @@ void CollectionSystemsManager::updateSystemsList() for (auto sysIt = SystemData::sSystemVector.cbegin(); // Line break. sysIt != SystemData::sSystemVector.cend(); ++sysIt) { if ((*sysIt)->isCollection()) - ViewController::get()->getGameListView((*sysIt)); + ViewController::getInstance()->getGameListView((*sysIt)); } // If we were editing a custom collection, and it's no longer enabled, exit edit mode. @@ -344,20 +344,20 @@ void CollectionSystemsManager::updateCollectionSystem(FileData* file, Collection // Found it, and we are removing it. if (name == "favorites" && file->metadata.get("favorite") == "false") { // Need to check if it is still marked as favorite, if not remove it. - ViewController::get()->getGameListView(curSys).get()->remove(collectionEntry, - false); + ViewController::getInstance()->getGameListView(curSys).get()->remove( + collectionEntry, false); } else if (name == "recent" && file->metadata.get("lastplayed") == "0") { // If lastplayed is set to 0 it means the entry has been cleared, and the // game should therefore be removed. - ViewController::get()->getGameListView(curSys).get()->remove(collectionEntry, - false); - ViewController::get()->onFileChanged(rootFolder, true); + ViewController::getInstance()->getGameListView(curSys).get()->remove( + collectionEntry, false); + ViewController::getInstance()->onFileChanged(rootFolder, true); } else if (curSys->isCollection() && !file->getCountAsGame()) { // If the countasgame flag has been set to false, then remove the game. if (curSys->isGroupedCustomCollection()) { - ViewController::get() + ViewController::getInstance() ->getGameListView(curSys->getRootFolder()->getParent()->getSystem()) .get() ->remove(collectionEntry, false); @@ -374,8 +374,8 @@ void CollectionSystemsManager::updateCollectionSystem(FileData* file, Collection 4000); } else { - ViewController::get()->getGameListView(curSys).get()->remove(collectionEntry, - false); + ViewController::getInstance()->getGameListView(curSys).get()->remove( + collectionEntry, false); } rootFolder->sort(rootFolder->getSortTypeFromString(rootFolder->getSortTypeString()), mFavoritesSorting); @@ -383,7 +383,7 @@ void CollectionSystemsManager::updateCollectionSystem(FileData* file, Collection else { // Re-index with new metadata. fileIndex->addToIndex(collectionEntry); - ViewController::get()->onFileChanged(collectionEntry, true); + ViewController::getInstance()->onFileChanged(collectionEntry, true); } } else { @@ -402,7 +402,8 @@ void CollectionSystemsManager::updateCollectionSystem(FileData* file, Collection CollectionFileData* newGame = new CollectionFileData(file, curSys); rootFolder->addChild(newGame); fileIndex->addToIndex(newGame); - ViewController::get()->getGameListView(curSys)->onFileChanged(newGame, true); + ViewController::getInstance()->getGameListView(curSys)->onFileChanged(newGame, + true); } } @@ -436,7 +437,7 @@ void CollectionSystemsManager::updateCollectionSystem(FileData* file, Collection if (name == "recent") { trimCollectionCount(rootFolder, LAST_PLAYED_MAX); - ViewController::get()->onFileChanged(rootFolder, false); + ViewController::getInstance()->onFileChanged(rootFolder, false); // This is a bit of a hack to prevent a jump to the first line of the gamelist // if an entry is manually adjusted from within the 'recent' gamelist, for example // by toggling a game as favorite. If the time since the last played timestamp is @@ -447,20 +448,21 @@ void CollectionSystemsManager::updateCollectionSystem(FileData* file, Collection auto nTime = Utils::Time::now(); if (nTime - Utils::Time::stringToTime(file->metadata.get("lastplayed")) < 2) { // Select the first row of the gamelist (the game just played). - IGameListView* gameList = - ViewController::get()->getGameListView(getSystemToView(sysData.system)).get(); + IGameListView* gameList = ViewController::getInstance() + ->getGameListView(getSystemToView(sysData.system)) + .get(); gameList->setCursor(gameList->getFirstEntry()); } } else { - ViewController::get()->onFileChanged(rootFolder, true); + ViewController::getInstance()->onFileChanged(rootFolder, true); // For custom collections, update either the actual system or its parent depending // on whether the collection is grouped or not. if (sysData.decl.isCustom) { if (rootFolder->getSystem()->isGroupedCustomCollection()) - ViewController::get()->onFileChanged(rootFolder->getParent(), true); + ViewController::getInstance()->onFileChanged(rootFolder->getParent(), true); else - ViewController::get()->onFileChanged(rootFolder, true); + ViewController::getInstance()->onFileChanged(rootFolder, true); } } } @@ -486,7 +488,7 @@ void CollectionSystemsManager::deleteCollectionFiles(FileData* file) if (found) { FileData* collectionEntry = children.at(key); SystemData* systemViewToUpdate = getSystemToView(sysDataIt->second.system); - ViewController::get() + ViewController::getInstance() ->getGameListView(systemViewToUpdate) .get() ->remove(collectionEntry, false); @@ -621,8 +623,8 @@ void CollectionSystemsManager::exitEditMode(bool showPopup) // Remove all tick marks from the games that are part of the collection. for (auto it = SystemData::sSystemVector.begin(); it != SystemData::sSystemVector.end(); ++it) { - ViewController::get()->getGameListView((*it))->onFileChanged( - ViewController::get()->getGameListView((*it))->getCursor(), false); + ViewController::getInstance()->getGameListView((*it))->onFileChanged( + ViewController::getInstance()->getGameListView((*it))->getCursor(), false); } mEditingCollectionSystemData->system->onMetaDataSavePoint(); @@ -667,14 +669,14 @@ const bool CollectionSystemsManager::toggleGameInCollection(FileData* file) // If we found it, we need to remove it. FileData* collectionEntry = children.at(key); fileIndex->removeFromIndex(collectionEntry); - ViewController::get() + ViewController::getInstance() ->getGameListView(systemViewToUpdate) .get() ->remove(collectionEntry, false); systemViewToUpdate->getRootFolder()->sort( rootFolder->getSortTypeFromString(rootFolder->getSortTypeString()), Settings::getInstance()->getBool("FavFirstCustom")); - ViewController::get()->reloadGameListView(systemViewToUpdate); + ViewController::getInstance()->reloadGameListView(systemViewToUpdate); updateCollectionFolderMetadata(systemViewToUpdate); } @@ -686,7 +688,8 @@ const bool CollectionSystemsManager::toggleGameInCollection(FileData* file) systemViewToUpdate->getRootFolder()->sort( rootFolder->getSortTypeFromString(rootFolder->getSortTypeString()), Settings::getInstance()->getBool("FavFirstCustom")); - ViewController::get()->onFileChanged(systemViewToUpdate->getRootFolder(), true); + ViewController::getInstance()->onFileChanged(systemViewToUpdate->getRootFolder(), + true); fileIndex->addToIndex(newGame); // Add to bundle index as well, if needed. @@ -713,7 +716,7 @@ const bool CollectionSystemsManager::toggleGameInCollection(FileData* file) file->getSourceFileData()->getSystem()->onMetaDataSavePoint(); refreshCollectionSystems(file->getSourceFileData()); if (mAutoCollectionSystemsData["favorites"].isEnabled) - ViewController::get()->reloadGameListView( + ViewController::getInstance()->reloadGameListView( mAutoCollectionSystemsData["favorites"].system); } if (adding) { @@ -904,15 +907,15 @@ void CollectionSystemsManager::deleteCustomCollection(const std::string& collect // The window deletion needs to be located here instead of in GuiCollectionSystemsOptions // (where the custom collection deletions are initiated), as there seems to be some random // issue with accessing mWindow via the lambda expression. - while (mWindow->peekGui() && mWindow->peekGui() != ViewController::get()) + while (mWindow->peekGui() && mWindow->peekGui() != ViewController::getInstance()) delete mWindow->peekGui(); if (collectionEntry != mCustomCollectionSystemsData.end()) { CollectionSystemsManager::getInstance()->loadEnabledListFromSettings(); CollectionSystemsManager::getInstance()->updateSystemsList(); - ViewController::get()->removeGameListView(collectionEntry->second.system); - ViewController::get()->reloadAll(); + ViewController::getInstance()->removeGameListView(collectionEntry->second.system); + ViewController::getInstance()->reloadAll(); delete collectionEntry->second.system; mCustomCollectionSystemsData.erase(collectionName); @@ -999,7 +1002,8 @@ void CollectionSystemsManager::repopulateCollection(SystemData* sysData) // it to something valid. For empty collections we need to first create a placeholder // and then point to this, and for collections with games in them we select the first // entry. - auto autoView = ViewController::get()->getGameListView(autoSystem->system).get(); + auto autoView = + ViewController::getInstance()->getGameListView(autoSystem->system).get(); if (autoSystem->system->getRootFolder()->getChildren().size() == 0) { autoView->addPlaceholder(autoSystem->system->getRootFolder()); autoView->setCursor(autoView->getLastEntry()); @@ -1035,7 +1039,8 @@ void CollectionSystemsManager::repopulateCollection(SystemData* sysData) customSystem->isPopulated = false; populateCustomCollection(customSystem); - auto autoView = ViewController::get()->getGameListView(customSystem->system).get(); + auto autoView = + ViewController::getInstance()->getGameListView(customSystem->system).get(); autoView->setCursor( customSystem->system->getRootFolder()->getChildrenRecursive().front()); autoView->setCursor(autoView->getFirstEntry()); @@ -1154,12 +1159,13 @@ void CollectionSystemsManager::populateAutoCollection(CollectionSystemData* sysD if (rootFolder->getName() == "recent" && !rootFolder->getChildrenRecursive().empty()) { // The following is needed to avoid a crash when repopulating the system as the previous // cursor pointer may point to a random memory address. - auto recentGamelist = ViewController::get()->getGameListView(rootFolder->getSystem()).get(); + auto recentGamelist = + ViewController::getInstance()->getGameListView(rootFolder->getSystem()).get(); recentGamelist->setCursor( rootFolder->getSystem()->getRootFolder()->getChildrenRecursive().front()); recentGamelist->setCursor(recentGamelist->getFirstEntry()); if (rootFolder->getChildren().size() > 0) - ViewController::get() + ViewController::getInstance() ->getGameListView(rootFolder->getSystem()) .get() ->onFileChanged(rootFolder->getChildren().front(), false); @@ -1248,7 +1254,7 @@ void CollectionSystemsManager::removeCollectionsFromDisplayedSystems() // Clear index. mCustomCollectionsBundle->getIndex()->resetIndex(); // Remove view so it's re-created as needed. - ViewController::get()->removeGameListView(mCustomCollectionsBundle); + ViewController::getInstance()->removeGameListView(mCustomCollectionsBundle); } void CollectionSystemsManager::addEnabledCollectionsToDisplayedSystems( @@ -1280,7 +1286,7 @@ void CollectionSystemsManager::addEnabledCollectionsToDisplayedSystems( Settings::getInstance()->getBool("FavFirstCustom")); // Jump to the first row of the game list, assuming it's not empty. IGameListView* gameList = - ViewController::get()->getGameListView((it->second.system)).get(); + ViewController::getInstance()->getGameListView((it->second.system)).get(); if (!gameList->getCursor()->isPlaceHolder()) { gameList->setCursor(gameList->getFirstEntry()); } @@ -1434,7 +1440,7 @@ void CollectionSystemsManager::trimCollectionCount(FileData* rootFolder, int lim while (static_cast(rootFolder->getChildrenListToDisplay().size()) > limit) { CollectionFileData* gameToRemove = (CollectionFileData*)rootFolder->getChildrenListToDisplay().back(); - ViewController::get()->getGameListView(curSys).get()->remove(gameToRemove, false); + ViewController::getInstance()->getGameListView(curSys).get()->remove(gameToRemove, false); } } diff --git a/es-app/src/MediaViewer.cpp b/es-app/src/MediaViewer.cpp index 4a7ae35c2..3013a0546 100644 --- a/es-app/src/MediaViewer.cpp +++ b/es-app/src/MediaViewer.cpp @@ -45,7 +45,7 @@ bool MediaViewer::startMediaViewer(FileData* game) initiateViewer(); if (mHasVideo) - ViewController::get()->onPauseVideo(); + ViewController::getInstance()->onPauseVideo(); if (mHasVideo || mHasImages) return true; @@ -56,7 +56,7 @@ bool MediaViewer::startMediaViewer(FileData* game) void MediaViewer::stopMediaViewer() { NavigationSounds::getInstance().playThemeNavigationSound(SCROLLSOUND); - ViewController::get()->onStopVideo(); + ViewController::getInstance()->onStopVideo(); if (mVideo) { delete mVideo; @@ -255,7 +255,7 @@ void MediaViewer::playVideo() return; mDisplayingImage = false; - ViewController::get()->onStopVideo(); + ViewController::getInstance()->onStopVideo(); mVideo = new VideoFFmpegComponent(mWindow); mVideo->topWindow(true); diff --git a/es-app/src/SystemData.cpp b/es-app/src/SystemData.cpp index 9e3589664..93dd56f9b 100644 --- a/es-app/src/SystemData.cpp +++ b/es-app/src/SystemData.cpp @@ -1127,7 +1127,7 @@ FileData* SystemData::getRandomGame(const FileData* currentGame) gameList = mRootFolder->getParent()->getChildrenListToDisplay(); } else { - gameList = ViewController::get() + gameList = ViewController::getInstance() ->getGameListView(mRootFolder->getSystem()) .get() ->getCursor() @@ -1210,10 +1210,10 @@ void SystemData::sortSystem(bool reloadGamelist, bool jumpToFirstRow) favoritesSorting); if (reloadGamelist) - ViewController::get()->reloadGameListView(this, false); + ViewController::getInstance()->reloadGameListView(this, false); if (jumpToFirstRow) { - IGameListView* gameList = ViewController::get()->getGameListView(this).get(); + IGameListView* gameList = ViewController::getInstance()->getGameListView(this).get(); gameList->setCursor(gameList->getFirstEntry()); } } diff --git a/es-app/src/SystemScreensaver.cpp b/es-app/src/SystemScreensaver.cpp index 09c6c69aa..255ee802c 100644 --- a/es-app/src/SystemScreensaver.cpp +++ b/es-app/src/SystemScreensaver.cpp @@ -209,12 +209,12 @@ void SystemScreensaver::launchGame() { if (mCurrentGame != nullptr) { // Launching game - ViewController::get()->triggerGameLaunch(mCurrentGame); - ViewController::get()->goToGameList(mCurrentGame->getSystem()); + ViewController::getInstance()->triggerGameLaunch(mCurrentGame); + ViewController::getInstance()->goToGameList(mCurrentGame->getSystem()); IGameListView* view = - ViewController::get()->getGameListView(mCurrentGame->getSystem()).get(); + ViewController::getInstance()->getGameListView(mCurrentGame->getSystem()).get(); view->setCursor(mCurrentGame); - ViewController::get()->cancelViewTransitions(); + ViewController::getInstance()->cancelViewTransitions(); } } @@ -222,11 +222,11 @@ void SystemScreensaver::goToGame() { if (mCurrentGame != nullptr) { // Go to the game in the gamelist view, but don't launch it. - ViewController::get()->goToGameList(mCurrentGame->getSystem()); + ViewController::getInstance()->goToGameList(mCurrentGame->getSystem()); IGameListView* view = - ViewController::get()->getGameListView(mCurrentGame->getSystem()).get(); + ViewController::getInstance()->getGameListView(mCurrentGame->getSystem()).get(); view->setCursor(mCurrentGame); - ViewController::get()->cancelViewTransitions(); + ViewController::getInstance()->cancelViewTransitions(); } } diff --git a/es-app/src/guis/GuiAlternativeEmulators.cpp b/es-app/src/guis/GuiAlternativeEmulators.cpp index ed7934053..eb599239c 100644 --- a/es-app/src/guis/GuiAlternativeEmulators.cpp +++ b/es-app/src/guis/GuiAlternativeEmulators.cpp @@ -252,6 +252,6 @@ std::vector GuiAlternativeEmulators::getHelpPrompts() HelpStyle GuiAlternativeEmulators::getHelpStyle() { HelpStyle style = HelpStyle(); - style.applyTheme(ViewController::get()->getState().getSystem()->getTheme(), "system"); + style.applyTheme(ViewController::getInstance()->getState().getSystem()->getTheme(), "system"); return style; } diff --git a/es-app/src/guis/GuiCollectionSystemsOptions.cpp b/es-app/src/guis/GuiCollectionSystemsOptions.cpp index a25a8eb0b..6aef1a9ef 100644 --- a/es-app/src/guis/GuiCollectionSystemsOptions.cpp +++ b/es-app/src/guis/GuiCollectionSystemsOptions.cpp @@ -399,7 +399,7 @@ void GuiCollectionSystemsOptions::createCustomCollection(std::string inName) setNeedsGoToSystem(newCollection); Window* window = mWindow; - while (window->peekGui() && window->peekGui() != ViewController::get()) + while (window->peekGui() && window->peekGui() != ViewController::getInstance()) delete window->peekGui(); CollectionSystemsManager::getInstance()->setEditMode(collectionName); } diff --git a/es-app/src/guis/GuiGameScraper.cpp b/es-app/src/guis/GuiGameScraper.cpp index 54e78d31f..329362df4 100644 --- a/es-app/src/guis/GuiGameScraper.cpp +++ b/es-app/src/guis/GuiGameScraper.cpp @@ -200,7 +200,7 @@ std::vector GuiGameScraper::getHelpPrompts() HelpStyle GuiGameScraper::getHelpStyle() { HelpStyle style = HelpStyle(); - style.applyTheme(ViewController::get()->getState().getSystem()->getTheme(), "system"); + style.applyTheme(ViewController::getInstance()->getState().getSystem()->getTheme(), "system"); return style; } diff --git a/es-app/src/guis/GuiGamelistFilter.cpp b/es-app/src/guis/GuiGamelistFilter.cpp index ded58fd5b..aca3b9617 100644 --- a/es-app/src/guis/GuiGamelistFilter.cpp +++ b/es-app/src/guis/GuiGamelistFilter.cpp @@ -40,7 +40,7 @@ void GuiGamelistFilter::initializeMenu() // If this is a collection and system names are shown per game, then let FileFilterIndex // know about this so the system names will not be included in game name text searches. - if (ViewController::get()->getState().getSystem()->isCollection()) { + if (ViewController::getInstance()->getState().getSystem()->isCollection()) { if (Settings::getInstance()->getBool("CollectionShowSystemInfo")) mFilterIndex->setTextRemoveSystem(true); else @@ -262,6 +262,6 @@ std::vector GuiGamelistFilter::getHelpPrompts() HelpStyle GuiGamelistFilter::getHelpStyle() { HelpStyle style = HelpStyle(); - style.applyTheme(ViewController::get()->getState().getSystem()->getTheme(), "system"); + style.applyTheme(ViewController::getInstance()->getState().getSystem()->getTheme(), "system"); return style; } diff --git a/es-app/src/guis/GuiGamelistOptions.cpp b/es-app/src/guis/GuiGamelistOptions.cpp index bd6bdf2eb..1f7882b11 100644 --- a/es-app/src/guis/GuiGamelistOptions.cpp +++ b/es-app/src/guis/GuiGamelistOptions.cpp @@ -258,20 +258,20 @@ GuiGamelistOptions::~GuiGamelistOptions() // This is required for the situation where scrolling started just before the menu // was openened. Without this, the scrolling would run until manually stopped after // the menu has been closed. - ViewController::get()->stopScrolling(); + ViewController::getInstance()->stopScrolling(); if (mFiltersChanged) { if (!mCustomCollectionSystem) { - ViewController::get()->reloadGameListView(mSystem); + ViewController::getInstance()->reloadGameListView(mSystem); } else { if (!mFromPlaceholder) { - ViewController::get()->reloadGameListView(mSystem); + ViewController::getInstance()->reloadGameListView(mSystem); } else if (!mCustomCollectionSystem->getRootFolder() ->getChildrenListToDisplay() .empty()) { - ViewController::get()->reloadGameListView(mSystem); + ViewController::getInstance()->reloadGameListView(mSystem); getGamelist()->setCursor( mCustomCollectionSystem->getRootFolder()->getChildrenListToDisplay().front()); } @@ -353,8 +353,8 @@ void GuiGamelistOptions::startEditMode() // currently being edited. This is done cheaply using onFileChanged() which will trigger // populateList(). for (auto it = SystemData::sSystemVector.begin(); it != SystemData::sSystemVector.end(); ++it) { - ViewController::get()->getGameListView((*it))->onFileChanged( - ViewController::get()->getGameListView((*it))->getCursor(), false); + ViewController::getInstance()->getGameListView((*it))->onFileChanged( + ViewController::getInstance()->getGameListView((*it))->getCursor(), false); } if (mSystem->getRootFolder()->getChildren().size() == 0) @@ -396,7 +396,7 @@ void GuiGamelistOptions::openMetaDataEd() LOG(LogInfo) << "Deleting the media files and gamelist.xml entry for the file \"" << file->getFullPath() << "\""; } - ViewController::get()->getGameListView(file->getSystem()).get()->removeMedia(file); + ViewController::getInstance()->getGameListView(file->getSystem()).get()->removeMedia(file); // Manually reset all the metadata values, set the name to the actual file/folder name. const std::vector& mdd = file->metadata.getMDD(); @@ -443,10 +443,10 @@ void GuiGamelistOptions::openMetaDataEd() LOG(LogInfo) << "Deleting the game file \"" << file->getFullPath() << "\", all its media files and its gamelist.xml entry."; CollectionSystemsManager::getInstance()->deleteCollectionFiles(file); - ViewController::get()->getGameListView(file->getSystem()).get()->removeMedia(file); - ViewController::get()->getGameListView(file->getSystem()).get()->remove(file, true); + ViewController::getInstance()->getGameListView(file->getSystem()).get()->removeMedia(file); + ViewController::getInstance()->getGameListView(file->getSystem()).get()->remove(file, true); mSystem->getRootFolder()->sort(*mListSort->getSelected(), mFavoritesSorting); - ViewController::get()->reloadGameListView(mSystem); + ViewController::getInstance()->reloadGameListView(mSystem); mWindow->invalidateCachedBackground(); }; @@ -456,7 +456,8 @@ void GuiGamelistOptions::openMetaDataEd() mWindow, &file->metadata, file->metadata.getMDD(FOLDER_METADATA), p, Utils::FileSystem::getFileName(file->getPath()), std::bind(&IGameListView::onFileChanged, - ViewController::get()->getGameListView(file->getSystem()).get(), file, true), + ViewController::getInstance()->getGameListView(file->getSystem()).get(), file, + true), clearGameBtnFunc, deleteGameBtnFunc)); } else { @@ -464,7 +465,8 @@ void GuiGamelistOptions::openMetaDataEd() mWindow, &file->metadata, file->metadata.getMDD(GAME_METADATA), p, Utils::FileSystem::getFileName(file->getPath()), std::bind(&IGameListView::onFileChanged, - ViewController::get()->getGameListView(file->getSystem()).get(), file, true), + ViewController::getInstance()->getGameListView(file->getSystem()).get(), file, + true), clearGameBtnFunc, deleteGameBtnFunc)); } } @@ -568,5 +570,5 @@ std::vector GuiGamelistOptions::getHelpPrompts() IGameListView* GuiGamelistOptions::getGamelist() { - return ViewController::get()->getGameListView(mSystem).get(); + return ViewController::getInstance()->getGameListView(mSystem).get(); } diff --git a/es-app/src/guis/GuiMenu.cpp b/es-app/src/guis/GuiMenu.cpp index e8981263a..117d6b3fb 100644 --- a/es-app/src/guis/GuiMenu.cpp +++ b/es-app/src/guis/GuiMenu.cpp @@ -85,7 +85,7 @@ GuiMenu::~GuiMenu() // This is required for the situation where scrolling started just before the menu // was openened. Without this, the scrolling would run until manually stopped after // the menu has been closed. - ViewController::get()->stopScrolling(); + ViewController::getInstance()->stopScrolling(); } void GuiMenu::openScraperOptions() @@ -266,8 +266,9 @@ void GuiMenu::openUIOptions() (*it)->sortSystem(); (*it)->getIndex()->resetFilters(); } - ViewController::get()->reloadAll(); - ViewController::get()->goToSystem(SystemData::sSystemVector.front(), false); + ViewController::getInstance()->reloadAll(); + ViewController::getInstance()->goToSystem(SystemData::sSystemVector.front(), + false); mWindow->invalidateCachedBackground(); }, "NO", nullptr)); @@ -828,7 +829,7 @@ void GuiMenu::openOtherOptions() auto updateValMediaDir = [this](const std::string& newVal) { Settings::getInstance()->setString("MediaDirectory", newVal); Settings::getInstance()->saveFile(); - ViewController::get()->reloadAll(); + ViewController::getInstance()->reloadAll(); mWindow->invalidateCachedBackground(); }; rowMediaDir.makeAcceptInputHandler([this, titleMediaDir, mediaDirectoryStaticText, @@ -1264,7 +1265,7 @@ void GuiMenu::close(bool closeAllWindows) else { Window* window = mWindow; closeFunc = [window] { - while (window->peekGui() != ViewController::get()) + while (window->peekGui() != ViewController::getInstance()) delete window->peekGui(); }; } @@ -1298,6 +1299,6 @@ std::vector GuiMenu::getHelpPrompts() HelpStyle GuiMenu::getHelpStyle() { HelpStyle style = HelpStyle(); - style.applyTheme(ViewController::get()->getState().getSystem()->getTheme(), "system"); + style.applyTheme(ViewController::getInstance()->getState().getSystem()->getTheme(), "system"); return style; } diff --git a/es-app/src/guis/GuiMetaDataEd.cpp b/es-app/src/guis/GuiMetaDataEd.cpp index 8bfbe7d50..5f342fee1 100644 --- a/es-app/src/guis/GuiMetaDataEd.cpp +++ b/es-app/src/guis/GuiMetaDataEd.cpp @@ -511,7 +511,7 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, buttons.push_back(std::make_shared(mWindow, "SAVE", "save metadata", [&] { save(); - ViewController::get()->onPauseVideo(); + ViewController::getInstance()->onPauseVideo(); delete this; })); buttons.push_back(std::make_shared(mWindow, "CANCEL", "cancel changes", @@ -698,7 +698,7 @@ void GuiMetaDataEd::save() if (std::find(children.begin(), children.end(), hideGame) != children.end()) { sys->getIndex()->removeFromIndex(hideGame); // Reload the gamelist as well as the view style may need to change. - ViewController::get()->reloadGameListView(sys); + ViewController::getInstance()->reloadGameListView(sys); } } } @@ -811,12 +811,12 @@ void GuiMetaDataEd::close() // until the user scrolls up and down the gamelist. TextureResource::manualUnload(mScraperParams.game->getImagePath(), false); TextureResource::manualUnload(mScraperParams.game->getMarqueePath(), false); - ViewController::get()->reloadGameListView(mScraperParams.system); + ViewController::getInstance()->reloadGameListView(mScraperParams.system); // Update all collections where the game is present. CollectionSystemsManager::getInstance()->refreshCollectionSystems(mScraperParams.game); mWindow->invalidateCachedBackground(); } - ViewController::get()->onPauseVideo(); + ViewController::getInstance()->onPauseVideo(); delete this; }; @@ -867,6 +867,6 @@ std::vector GuiMetaDataEd::getHelpPrompts() HelpStyle GuiMetaDataEd::getHelpStyle() { HelpStyle style = HelpStyle(); - style.applyTheme(ViewController::get()->getState().getSystem()->getTheme(), "system"); + style.applyTheme(ViewController::getInstance()->getState().getSystem()->getTheme(), "system"); return style; } diff --git a/es-app/src/guis/GuiOfflineGenerator.cpp b/es-app/src/guis/GuiOfflineGenerator.cpp index acd30b8b1..b46731528 100644 --- a/es-app/src/guis/GuiOfflineGenerator.cpp +++ b/es-app/src/guis/GuiOfflineGenerator.cpp @@ -198,7 +198,7 @@ GuiOfflineGenerator::~GuiOfflineGenerator() mMiximageGenerator.reset(); if (mImagesGenerated > 0) - ViewController::get()->reloadAll(); + ViewController::getInstance()->reloadAll(); } void GuiOfflineGenerator::onSizeChanged() @@ -336,6 +336,6 @@ std::vector GuiOfflineGenerator::getHelpPrompts() HelpStyle GuiOfflineGenerator::getHelpStyle() { HelpStyle style = HelpStyle(); - style.applyTheme(ViewController::get()->getState().getSystem()->getTheme(), "system"); + style.applyTheme(ViewController::getInstance()->getState().getSystem()->getTheme(), "system"); return style; } diff --git a/es-app/src/guis/GuiScraperMenu.cpp b/es-app/src/guis/GuiScraperMenu.cpp index 2df3ec7bb..cb817fc2a 100644 --- a/es-app/src/guis/GuiScraperMenu.cpp +++ b/es-app/src/guis/GuiScraperMenu.cpp @@ -1135,6 +1135,6 @@ std::vector GuiScraperMenu::getHelpPrompts() HelpStyle GuiScraperMenu::getHelpStyle() { HelpStyle style = HelpStyle(); - style.applyTheme(ViewController::get()->getState().getSystem()->getTheme(), "system"); + style.applyTheme(ViewController::getInstance()->getState().getSystem()->getTheme(), "system"); return style; } diff --git a/es-app/src/guis/GuiScraperMulti.cpp b/es-app/src/guis/GuiScraperMulti.cpp index d68704138..7f7d42949 100644 --- a/es-app/src/guis/GuiScraperMulti.cpp +++ b/es-app/src/guis/GuiScraperMulti.cpp @@ -182,7 +182,7 @@ GuiScraperMulti::~GuiScraperMulti() (*it)->sortSystem(); } } - ViewController::get()->onPauseVideo(); + ViewController::getInstance()->onPauseVideo(); } void GuiScraperMulti::onSizeChanged() @@ -324,6 +324,6 @@ std::vector GuiScraperMulti::getHelpPrompts() HelpStyle GuiScraperMulti::getHelpStyle() { HelpStyle style = HelpStyle(); - style.applyTheme(ViewController::get()->getState().getSystem()->getTheme(), "system"); + style.applyTheme(ViewController::getInstance()->getState().getSystem()->getTheme(), "system"); return style; } diff --git a/es-app/src/guis/GuiScraperSearch.cpp b/es-app/src/guis/GuiScraperSearch.cpp index 05eeef9e3..9fb163166 100644 --- a/es-app/src/guis/GuiScraperSearch.cpp +++ b/es-app/src/guis/GuiScraperSearch.cpp @@ -170,7 +170,7 @@ GuiScraperSearch::~GuiScraperSearch() mMiximageGeneratorThread.join(); mMiximageGenerator.reset(); TextureResource::manualUnload(mLastSearch.game->getMiximagePath(), false); - ViewController::get()->onFileChanged(mLastSearch.game, true); + ViewController::getInstance()->onFileChanged(mLastSearch.game, true); } } @@ -1017,6 +1017,6 @@ std::vector GuiScraperSearch::getHelpPrompts() HelpStyle GuiScraperSearch::getHelpStyle() { HelpStyle style = HelpStyle(); - style.applyTheme(ViewController::get()->getState().getSystem()->getTheme(), "system"); + style.applyTheme(ViewController::getInstance()->getState().getSystem()->getTheme(), "system"); return style; } diff --git a/es-app/src/guis/GuiSettings.cpp b/es-app/src/guis/GuiSettings.cpp index d28578def..31f90de9b 100644 --- a/es-app/src/guis/GuiSettings.cpp +++ b/es-app/src/guis/GuiSettings.cpp @@ -77,7 +77,7 @@ void GuiSettings::save() (*it)->sortSystem(true); // Jump to the first row of the gamelist. - IGameListView* gameList = ViewController::get()->getGameListView((*it)).get(); + IGameListView* gameList = ViewController::getInstance()->getGameListView((*it)).get(); gameList->setCursor(gameList->getFirstEntry()); } } @@ -94,38 +94,38 @@ void GuiSettings::save() } if (mNeedsReloading) - ViewController::get()->reloadAll(); + ViewController::getInstance()->reloadAll(); if (mNeedsGoToStart) - ViewController::get()->goToStart(true); + ViewController::getInstance()->goToStart(true); if (mNeedsGoToSystem) - ViewController::get()->goToSystem(mGoToSystem, false); + ViewController::getInstance()->goToSystem(mGoToSystem, false); if (mNeedsGoToGroupedCollections) { bool groupedSystemExists = false; for (SystemData* system : SystemData::sSystemVector) { if (system->getThemeFolder() == "custom-collections") { - ViewController::get()->goToSystem(system, false); + ViewController::getInstance()->goToSystem(system, false); groupedSystemExists = true; continue; } } if (!groupedSystemExists) // No grouped custom collection system exists, so go to the first system instead. - ViewController::get()->goToSystem(SystemData::sSystemVector.front(), false); + ViewController::getInstance()->goToSystem(SystemData::sSystemVector.front(), false); } if (mNeedsCollectionsUpdate) { - auto state = ViewController::get()->getState(); + auto state = ViewController::getInstance()->getState(); // If we're in any view other than the grouped custom collections, always jump to the // system view in case of any collection updates. This is overkill in some instances but // these views can behave a bit strange during collection changes so it's better to be on // the safe side. if (state.getSystem()->isCollection() && state.getSystem()->getThemeFolder() != "custom-collections") { - ViewController::get()->goToStart(false); - ViewController::get()->goToSystem(SystemData::sSystemVector.front(), false); + ViewController::getInstance()->goToStart(false); + ViewController::getInstance()->goToSystem(SystemData::sSystemVector.front(), false); // We don't want to invalidate the cached background when there has been a collection // systen change as that may show a black screen in some circumstances. return; @@ -134,7 +134,7 @@ void GuiSettings::save() // system view). if (std::find(SystemData::sSystemVector.begin(), SystemData::sSystemVector.end(), state.getSystem()) == SystemData::sSystemVector.end()) { - ViewController::get()->goToStart(false); + ViewController::getInstance()->goToStart(false); return; } } @@ -237,7 +237,7 @@ bool GuiSettings::input(InputConfig* config, Input input) HelpStyle GuiSettings::getHelpStyle() { HelpStyle style = HelpStyle(); - style.applyTheme(ViewController::get()->getState().getSystem()->getTheme(), "system"); + style.applyTheme(ViewController::getInstance()->getState().getSystem()->getTheme(), "system"); return style; } diff --git a/es-app/src/main.cpp b/es-app/src/main.cpp index ea5fc9684..9a6ac09dd 100644 --- a/es-app/src/main.cpp +++ b/es-app/src/main.cpp @@ -530,7 +530,7 @@ int main(int argc, char* argv[]) Window* window = Window::getInstance(); - ViewController::get(); + ViewController::getInstance(); CollectionSystemsManager::getInstance(); SystemScreensaver screensaver; @@ -542,7 +542,7 @@ int main(int argc, char* argv[]) return 1; } - window->pushGui(ViewController::get()); + window->pushGui(ViewController::getInstance()); bool splashScreen = Settings::getInstance()->getBool("SplashScreen"); bool splashScreenProgress = Settings::getInstance()->getBool("SplashScreenProgress"); @@ -587,10 +587,10 @@ int main(int argc, char* argv[]) // configure a different ROM directory as well as to generate the game systems // directory structure. if (loadSystemsStatus == INVALID_FILE) { - ViewController::get()->invalidSystemsFileDialog(); + ViewController::getInstance()->invalidSystemsFileDialog(); } else if (loadSystemsStatus == NO_ROMS) { - ViewController::get()->noGamesDialog(); + ViewController::getInstance()->noGamesDialog(); } } @@ -599,7 +599,7 @@ int main(int argc, char* argv[]) // any command tag in es_systems.xml. for (auto system : SystemData::sSystemVector) { if (system->getAlternativeEmulator().substr(0, 9) == "") { - ViewController::get()->invalidAlternativeEmulatorDialog(); + ViewController::getInstance()->invalidAlternativeEmulatorDialog(); break; } } @@ -609,7 +609,7 @@ int main(int argc, char* argv[]) // Preload what we can right away instead of waiting for the user to select it. // This makes for no delays when accessing content, but a longer startup time. - ViewController::get()->preload(); + ViewController::getInstance()->preload(); if (splashScreen && splashScreenProgress) window->renderLoadingScreen("Done"); @@ -617,11 +617,11 @@ int main(int argc, char* argv[]) // Open the input configuration GUI if the flag to force this was passed from the command line. if (!loadSystemsStatus) { if (forceInputConfig) { - window->pushGui(new GuiDetectDevice(window, false, true, - [] { ViewController::get()->goToStart(true); })); + window->pushGui(new GuiDetectDevice( + window, false, true, [] { ViewController::getInstance()->goToStart(true); })); } else { - ViewController::get()->goToStart(true); + ViewController::getInstance()->goToStart(true); } } @@ -679,7 +679,7 @@ int main(int argc, char* argv[]) Log::flush(); } - while (window->peekGui() != ViewController::get()) + while (window->peekGui() != ViewController::getInstance()) delete window->peekGui(); window->deinit(); diff --git a/es-app/src/scrapers/Scraper.cpp b/es-app/src/scrapers/Scraper.cpp index 7d38179e4..98948883e 100644 --- a/es-app/src/scrapers/Scraper.cpp +++ b/es-app/src/scrapers/Scraper.cpp @@ -253,7 +253,7 @@ MDResolveHandle::MDResolveHandle(const ScraperSearchResult& result, scrapeFiles.push_back(mediaFileInfo); #if defined(_WIN64) // Required due to the idiotic file locking that exists on this operating system. - ViewController::get()->onStopVideo(); + ViewController::getInstance()->onStopVideo(); #endif } diff --git a/es-app/src/views/SystemView.cpp b/es-app/src/views/SystemView.cpp index f52c67890..029a4360b 100644 --- a/es-app/src/views/SystemView.cpp +++ b/es-app/src/views/SystemView.cpp @@ -247,7 +247,7 @@ bool SystemView::input(InputConfig* config, Input input) if (config->getDeviceId() == DEVICE_KEYBOARD && input.value && input.id == SDLK_r && SDL_GetModState() & KMOD_LCTRL && Settings::getInstance()->getBool("Debug")) { LOG(LogDebug) << "SystemView::input(): Reloading all"; - ViewController::get()->reloadAll(); + ViewController::getInstance()->reloadAll(); return true; } @@ -255,12 +255,12 @@ bool SystemView::input(InputConfig* config, Input input) case VERTICAL: case VERTICAL_WHEEL: if (config->isMappedLike("up", input)) { - ViewController::get()->cancelViewTransitions(); + ViewController::getInstance()->cancelViewTransitions(); listInput(-1); return true; } if (config->isMappedLike("down", input)) { - ViewController::get()->cancelViewTransitions(); + ViewController::getInstance()->cancelViewTransitions(); listInput(1); return true; } @@ -269,12 +269,12 @@ bool SystemView::input(InputConfig* config, Input input) case HORIZONTAL_WHEEL: default: if (config->isMappedLike("left", input)) { - ViewController::get()->cancelViewTransitions(); + ViewController::getInstance()->cancelViewTransitions(); listInput(-1); return true; } if (config->isMappedLike("right", input)) { - ViewController::get()->cancelViewTransitions(); + ViewController::getInstance()->cancelViewTransitions(); listInput(1); return true; } @@ -283,7 +283,7 @@ bool SystemView::input(InputConfig* config, Input input) if (config->isMappedTo("a", input)) { stopScrolling(); - ViewController::get()->goToGameList(getSelected()); + ViewController::getInstance()->goToGameList(getSelected()); NavigationSounds::getInstance().playThemeNavigationSound(SELECTSOUND); return true; } @@ -299,8 +299,8 @@ bool SystemView::input(InputConfig* config, Input input) if (!UIModeController::getInstance()->isUIModeKid() && config->isMappedTo("back", input) && Settings::getInstance()->getBool("ScreensaverControls")) { if (!mWindow->isScreensaverActive()) { - ViewController::get()->stopScrolling(); - ViewController::get()->cancelViewTransitions(); + ViewController::getInstance()->stopScrolling(); + ViewController::getInstance()->cancelViewTransitions(); mWindow->startScreensaver(); mWindow->renderScreensaver(); } diff --git a/es-app/src/views/UIModeController.cpp b/es-app/src/views/UIModeController.cpp index 968405b4d..7b32318fc 100644 --- a/es-app/src/views/UIModeController.cpp +++ b/es-app/src/views/UIModeController.cpp @@ -39,7 +39,7 @@ void UIModeController::monitorUIMode() { std::string uimode = Settings::getInstance()->getString("UIMode"); // UI mode was changed. - if (uimode != mCurrentUIMode && !ViewController::get()->isCameraMoving()) { + if (uimode != mCurrentUIMode && !ViewController::getInstance()->isCameraMoving()) { mCurrentUIMode = uimode; // Reset filters and sort gamelists (which will update the game counter). for (auto it = SystemData::sSystemVector.cbegin(); // Line break. @@ -51,7 +51,7 @@ void UIModeController::monitorUIMode() customSystem->getSystem()->getIndex()->resetFilters(); } } - ViewController::get()->ReloadAndGoToStart(); + ViewController::getInstance()->ReloadAndGoToStart(); } } diff --git a/es-app/src/views/ViewController.cpp b/es-app/src/views/ViewController.cpp index 295fb5978..5fa2e0f01 100644 --- a/es-app/src/views/ViewController.cpp +++ b/es-app/src/views/ViewController.cpp @@ -55,7 +55,7 @@ const std::string ViewController::KEYBOARD_CHAR = "\uf11c"; const std::string ViewController::TICKMARK_CHAR = "\uf14a"; #endif -ViewController* ViewController::get() +ViewController* ViewController::getInstance() { static ViewController instance; return &instance; diff --git a/es-app/src/views/ViewController.h b/es-app/src/views/ViewController.h index 53eb3601c..29419c849 100644 --- a/es-app/src/views/ViewController.h +++ b/es-app/src/views/ViewController.h @@ -29,7 +29,7 @@ class SystemView; class ViewController : public GuiComponent { public: - static ViewController* get(); + static ViewController* getInstance(); // These functions are called from main(). void invalidSystemsFileDialog(); diff --git a/es-app/src/views/gamelist/BasicGameListView.cpp b/es-app/src/views/gamelist/BasicGameListView.cpp index f3eee0f1f..543676734 100644 --- a/es-app/src/views/gamelist/BasicGameListView.cpp +++ b/es-app/src/views/gamelist/BasicGameListView.cpp @@ -40,7 +40,7 @@ void BasicGameListView::onFileChanged(FileData* file, bool reloadGameList) { if (reloadGameList) { // Might switch to a detailed view. - ViewController::get()->reloadGameListView(this); + ViewController::getInstance()->reloadGameListView(this); return; } @@ -162,7 +162,7 @@ void BasicGameListView::addPlaceholder(FileData* firstEntry) void BasicGameListView::launch(FileData* game) { // This triggers ViewController to launch the game. - ViewController::get()->triggerGameLaunch(game); + ViewController::getInstance()->triggerGameLaunch(game); } void BasicGameListView::remove(FileData* game, bool deleteFile) @@ -310,7 +310,7 @@ std::vector BasicGameListView::getHelpPrompts() prompts.push_back(HelpPrompt("left/right", "system")); if (mRoot->getSystem()->getThemeFolder() == "custom-collections" && mCursorStack.empty() && - ViewController::get()->getState().viewing == ViewController::GAME_LIST) + ViewController::getInstance()->getState().viewing == ViewController::GAME_LIST) prompts.push_back(HelpPrompt("a", "enter")); else prompts.push_back(HelpPrompt("a", "launch")); @@ -325,8 +325,8 @@ std::vector BasicGameListView::getHelpPrompts() if (mRoot->getSystem()->getThemeFolder() == "custom-collections" && !CollectionSystemsManager::getInstance()->isEditing() && mCursorStack.empty() && - ViewController::get()->getState().viewing == ViewController::GAME_LIST && - ViewController::get()->getState().viewstyle != ViewController::BASIC) { + ViewController::getInstance()->getState().viewing == ViewController::GAME_LIST && + ViewController::getInstance()->getState().viewstyle != ViewController::BASIC) { prompts.push_back(HelpPrompt("y", "jump to game")); } else if (mRoot->getSystem()->isGameSystem() && diff --git a/es-app/src/views/gamelist/DetailedGameListView.cpp b/es-app/src/views/gamelist/DetailedGameListView.cpp index 855ccec9a..8c83264fc 100644 --- a/es-app/src/views/gamelist/DetailedGameListView.cpp +++ b/es-app/src/views/gamelist/DetailedGameListView.cpp @@ -476,7 +476,7 @@ void DetailedGameListView::updateInfoPanel() void DetailedGameListView::launch(FileData* game) { - ViewController::get()->triggerGameLaunch(game); + ViewController::getInstance()->triggerGameLaunch(game); } std::vector DetailedGameListView::getMDLabels() @@ -512,7 +512,7 @@ void DetailedGameListView::update(int deltaTime) BasicGameListView::update(deltaTime); mImage.update(deltaTime); - if (ViewController::get()->getGameLaunchTriggered() && mImage.isAnimationPlaying(0)) + if (ViewController::getInstance()->getGameLaunchTriggered() && mImage.isAnimationPlaying(0)) mImage.finishAnimation(0); } diff --git a/es-app/src/views/gamelist/GridGameListView.cpp b/es-app/src/views/gamelist/GridGameListView.cpp index ac14451ca..335772cd6 100644 --- a/es-app/src/views/gamelist/GridGameListView.cpp +++ b/es-app/src/views/gamelist/GridGameListView.cpp @@ -130,7 +130,7 @@ void GridGameListView::onFileChanged(FileData* file, bool reloadGameList) { if (reloadGameList) { // Might switch to a detailed view. - ViewController::get()->reloadGameListView(this); + ViewController::getInstance()->reloadGameListView(this); return; } @@ -519,7 +519,7 @@ void GridGameListView::addPlaceholder(FileData* firstEntry) void GridGameListView::launch(FileData* game) { // This triggers ViewController to launch the game. - ViewController::get()->triggerGameLaunch(game); + ViewController::getInstance()->triggerGameLaunch(game); } void GridGameListView::remove(FileData* game, bool deleteFile) @@ -687,7 +687,7 @@ std::vector GridGameListView::getHelpPrompts() prompts.push_back(HelpPrompt("up/down/left/right", "choose")); if (mRoot->getSystem()->getThemeFolder() == "custom-collections" && mCursorStack.empty() && - ViewController::get()->getState().viewing == ViewController::GAME_LIST) + ViewController::getInstance()->getState().viewing == ViewController::GAME_LIST) prompts.push_back(HelpPrompt("a", "enter")); else prompts.push_back(HelpPrompt("a", "launch")); diff --git a/es-app/src/views/gamelist/IGameListView.cpp b/es-app/src/views/gamelist/IGameListView.cpp index 1addc67a8..dcd86aaab 100644 --- a/es-app/src/views/gamelist/IGameListView.cpp +++ b/es-app/src/views/gamelist/IGameListView.cpp @@ -33,7 +33,7 @@ bool IGameListView::input(InputConfig* config, Input input) // Select button opens GuiGamelistOptions. if (!UIModeController::getInstance()->isUIModeKid() && // Line break. config->isMappedTo("back", input) && input.value) { - ViewController::get()->cancelViewTransitions(); + ViewController::getInstance()->cancelViewTransitions(); stopListScrolling(); mWindow->pushGui(new GuiGamelistOptions(mWindow, this->mRoot->getSystem())); return true; @@ -45,7 +45,7 @@ bool IGameListView::input(InputConfig* config, Input input) (SDL_GetModState() & (KMOD_LCTRL | KMOD_RCTRL)) && input.id == SDLK_r && input.value != 0) { LOG(LogDebug) << "IGameListView::input(): Reloading view"; - ViewController::get()->reloadGameListView(this, true); + ViewController::getInstance()->reloadGameListView(this, true); return true; } diff --git a/es-app/src/views/gamelist/ISimpleGameListView.cpp b/es-app/src/views/gamelist/ISimpleGameListView.cpp index 6e52707dd..66ddb9bc6 100644 --- a/es-app/src/views/gamelist/ISimpleGameListView.cpp +++ b/es-app/src/views/gamelist/ISimpleGameListView.cpp @@ -106,14 +106,14 @@ bool ISimpleGameListView::input(InputConfig* config, Input input) FileData* cursor = getCursor(); if (cursor->getType() == GAME) { onPauseVideo(); - ViewController::get()->cancelViewTransitions(); + ViewController::getInstance()->cancelViewTransitions(); stopListScrolling(); launch(cursor); } else { // It's a folder. if (cursor->getChildren().size() > 0) { - ViewController::get()->cancelViewTransitions(); + ViewController::getInstance()->cancelViewTransitions(); NavigationSounds::getInstance().playThemeNavigationSound(SELECTSOUND); mCursorStack.push(cursor); populateList(cursor->getChildrenListToDisplay(), cursor); @@ -147,7 +147,7 @@ bool ISimpleGameListView::input(InputConfig* config, Input input) return true; } else if (config->isMappedTo("b", input)) { - ViewController::get()->cancelViewTransitions(); + ViewController::getInstance()->cancelViewTransitions(); if (mCursorStack.size()) { // Save the position to the cursor stack history. mCursorStackHistory.push_back(getCursor()); @@ -168,10 +168,10 @@ bool ISimpleGameListView::input(InputConfig* config, Input input) SystemData* systemToView = getCursor()->getSystem(); if (systemToView->isCustomCollection() && systemToView->getRootFolder()->getParent()) - ViewController::get()->goToSystemView( + ViewController::getInstance()->goToSystemView( systemToView->getRootFolder()->getParent()->getSystem(), true); else - ViewController::get()->goToSystemView(systemToView, true); + ViewController::getInstance()->goToSystemView(systemToView, true); } return true; @@ -184,19 +184,20 @@ bool ISimpleGameListView::input(InputConfig* config, Input input) else if (config->isMappedTo("x", input) && mRoot->getSystem()->getThemeFolder() == "custom-collections" && mCursorStack.empty() && - ViewController::get()->getState().viewing == ViewController::GAME_LIST) { + ViewController::getInstance()->getState().viewing == + ViewController::GAME_LIST) { NavigationSounds::getInstance().playThemeNavigationSound(SCROLLSOUND); // Jump to the randomly selected game. if (mRandomGame) { stopListScrolling(); - ViewController::get()->cancelViewTransitions(); + ViewController::getInstance()->cancelViewTransitions(); mWindow->startMediaViewer(mRandomGame); return true; } } else if (mRoot->getSystem()->isGameSystem()) { stopListScrolling(); - ViewController::get()->cancelViewTransitions(); + ViewController::getInstance()->cancelViewTransitions(); NavigationSounds::getInstance().playThemeNavigationSound(SCROLLSOUND); mWindow->startMediaViewer(getCursor()); return true; @@ -208,7 +209,7 @@ bool ISimpleGameListView::input(InputConfig* config, Input input) onPauseVideo(); onFocusLost(); stopListScrolling(); - ViewController::get()->goToNextGameList(); + ViewController::getInstance()->goToNextGameList(); return true; } } @@ -218,7 +219,7 @@ bool ISimpleGameListView::input(InputConfig* config, Input input) onPauseVideo(); onFocusLost(); stopListScrolling(); - ViewController::get()->goToPrevGameList(); + ViewController::getInstance()->goToPrevGameList(); return true; } } @@ -238,7 +239,7 @@ bool ISimpleGameListView::input(InputConfig* config, Input input) else if (config->isMappedTo("y", input) && mRoot->getSystem()->getThemeFolder() == "custom-collections" && !CollectionSystemsManager::getInstance()->isEditing() && mCursorStack.empty() && - ViewController::get()->getState().viewing == ViewController::GAME_LIST) { + ViewController::getInstance()->getState().viewing == ViewController::GAME_LIST) { // Jump to the randomly selected game. if (mRandomGame) { NavigationSounds::getInstance().playThemeNavigationSound(SELECTSOUND); @@ -420,15 +421,15 @@ bool ISimpleGameListView::input(InputConfig* config, Input input) mRoot->getSortTypeFromString(mRoot->getSortTypeString()), Settings::getInstance()->getBool("FavoritesFirst")); - ViewController::get()->onFileChanged(getCursor(), false); + ViewController::getInstance()->onFileChanged(getCursor(), false); // Always jump to the first entry in the gamelist if the last favorite // was unmarked. We couldn't do this earlier as we didn't have the list // sorted yet. if (removedLastFavorite) { - ViewController::get() + ViewController::getInstance() ->getGameListView(entryToUpdate->getSystem()) - ->setCursor(ViewController::get() + ->setCursor(ViewController::getInstance() ->getGameListView(entryToUpdate->getSystem()) ->getFirstEntry()); } @@ -444,13 +445,14 @@ bool ISimpleGameListView::input(InputConfig* config, Input input) // As the toggling of the game destroyed this object, we need to get the view // from ViewController instead of using the reference that existed before the // destruction. Otherwise we get random crashes. - IGameListView* view = ViewController::get()->getGameListView(system).get(); + IGameListView* view = + ViewController::getInstance()->getGameListView(system).get(); // Jump to the first entry in the gamelist if the last favorite was unmarked. if (foldersOnTop && removedLastFavorite && !entryToUpdate->getSystem()->isCustomCollection()) { - ViewController::get() + ViewController::getInstance() ->getGameListView(entryToUpdate->getSystem()) - ->setCursor(ViewController::get() + ->setCursor(ViewController::getInstance() ->getGameListView(entryToUpdate->getSystem()) ->getFirstGameEntry()); } @@ -467,8 +469,9 @@ bool ISimpleGameListView::input(InputConfig* config, Input input) if (isEditing) { for (auto it = SystemData::sSystemVector.begin(); it != SystemData::sSystemVector.end(); ++it) { - ViewController::get()->getGameListView((*it))->onFileChanged( - ViewController::get()->getGameListView((*it))->getCursor(), false); + ViewController::getInstance()->getGameListView((*it))->onFileChanged( + ViewController::getInstance()->getGameListView((*it))->getCursor(), + false); } } return true; diff --git a/es-app/src/views/gamelist/VideoGameListView.cpp b/es-app/src/views/gamelist/VideoGameListView.cpp index c3b81ba4e..e11b6093f 100644 --- a/es-app/src/views/gamelist/VideoGameListView.cpp +++ b/es-app/src/views/gamelist/VideoGameListView.cpp @@ -502,7 +502,10 @@ void VideoGameListView::updateInfoPanel() } } -void VideoGameListView::launch(FileData* game) { ViewController::get()->triggerGameLaunch(game); } +void VideoGameListView::launch(FileData* game) +{ + ViewController::getInstance()->triggerGameLaunch(game); +} std::vector VideoGameListView::getMDLabels() { @@ -542,7 +545,7 @@ void VideoGameListView::update(int deltaTime) BasicGameListView::update(deltaTime); mVideo->update(deltaTime); - if (ViewController::get()->getGameLaunchTriggered() && mVideo->isAnimationPlaying(0)) + if (ViewController::getInstance()->getGameLaunchTriggered() && mVideo->isAnimationPlaying(0)) mVideo->finishAnimation(0); }