Changed ViewController::get() to ViewController::getInstance()

This commit is contained in:
Leon Styhre 2022-01-04 21:49:22 +01:00
parent 5d79c3d77e
commit 119dfc90f8
28 changed files with 165 additions and 150 deletions

View file

@ -264,7 +264,7 @@ void CollectionSystemsManager::updateSystemsList()
for (auto sysIt = SystemData::sSystemVector.cbegin(); // Line break. for (auto sysIt = SystemData::sSystemVector.cbegin(); // Line break.
sysIt != SystemData::sSystemVector.cend(); ++sysIt) { sysIt != SystemData::sSystemVector.cend(); ++sysIt) {
if ((*sysIt)->isCollection()) 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. // 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. // Found it, and we are removing it.
if (name == "favorites" && file->metadata.get("favorite") == "false") { if (name == "favorites" && file->metadata.get("favorite") == "false") {
// Need to check if it is still marked as favorite, if not remove it. // Need to check if it is still marked as favorite, if not remove it.
ViewController::get()->getGameListView(curSys).get()->remove(collectionEntry, ViewController::getInstance()->getGameListView(curSys).get()->remove(
false); collectionEntry, false);
} }
else if (name == "recent" && file->metadata.get("lastplayed") == "0") { else if (name == "recent" && file->metadata.get("lastplayed") == "0") {
// If lastplayed is set to 0 it means the entry has been cleared, and the // If lastplayed is set to 0 it means the entry has been cleared, and the
// game should therefore be removed. // game should therefore be removed.
ViewController::get()->getGameListView(curSys).get()->remove(collectionEntry, ViewController::getInstance()->getGameListView(curSys).get()->remove(
false); collectionEntry, false);
ViewController::get()->onFileChanged(rootFolder, true); ViewController::getInstance()->onFileChanged(rootFolder, true);
} }
else if (curSys->isCollection() && !file->getCountAsGame()) { else if (curSys->isCollection() && !file->getCountAsGame()) {
// If the countasgame flag has been set to false, then remove the game. // If the countasgame flag has been set to false, then remove the game.
if (curSys->isGroupedCustomCollection()) { if (curSys->isGroupedCustomCollection()) {
ViewController::get() ViewController::getInstance()
->getGameListView(curSys->getRootFolder()->getParent()->getSystem()) ->getGameListView(curSys->getRootFolder()->getParent()->getSystem())
.get() .get()
->remove(collectionEntry, false); ->remove(collectionEntry, false);
@ -374,8 +374,8 @@ void CollectionSystemsManager::updateCollectionSystem(FileData* file, Collection
4000); 4000);
} }
else { else {
ViewController::get()->getGameListView(curSys).get()->remove(collectionEntry, ViewController::getInstance()->getGameListView(curSys).get()->remove(
false); collectionEntry, false);
} }
rootFolder->sort(rootFolder->getSortTypeFromString(rootFolder->getSortTypeString()), rootFolder->sort(rootFolder->getSortTypeFromString(rootFolder->getSortTypeString()),
mFavoritesSorting); mFavoritesSorting);
@ -383,7 +383,7 @@ void CollectionSystemsManager::updateCollectionSystem(FileData* file, Collection
else { else {
// Re-index with new metadata. // Re-index with new metadata.
fileIndex->addToIndex(collectionEntry); fileIndex->addToIndex(collectionEntry);
ViewController::get()->onFileChanged(collectionEntry, true); ViewController::getInstance()->onFileChanged(collectionEntry, true);
} }
} }
else { else {
@ -402,7 +402,8 @@ void CollectionSystemsManager::updateCollectionSystem(FileData* file, Collection
CollectionFileData* newGame = new CollectionFileData(file, curSys); CollectionFileData* newGame = new CollectionFileData(file, curSys);
rootFolder->addChild(newGame); rootFolder->addChild(newGame);
fileIndex->addToIndex(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") { if (name == "recent") {
trimCollectionCount(rootFolder, LAST_PLAYED_MAX); 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 // 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 // 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 // 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(); auto nTime = Utils::Time::now();
if (nTime - Utils::Time::stringToTime(file->metadata.get("lastplayed")) < 2) { if (nTime - Utils::Time::stringToTime(file->metadata.get("lastplayed")) < 2) {
// Select the first row of the gamelist (the game just played). // Select the first row of the gamelist (the game just played).
IGameListView* gameList = IGameListView* gameList = ViewController::getInstance()
ViewController::get()->getGameListView(getSystemToView(sysData.system)).get(); ->getGameListView(getSystemToView(sysData.system))
.get();
gameList->setCursor(gameList->getFirstEntry()); gameList->setCursor(gameList->getFirstEntry());
} }
} }
else { else {
ViewController::get()->onFileChanged(rootFolder, true); ViewController::getInstance()->onFileChanged(rootFolder, true);
// For custom collections, update either the actual system or its parent depending // For custom collections, update either the actual system or its parent depending
// on whether the collection is grouped or not. // on whether the collection is grouped or not.
if (sysData.decl.isCustom) { if (sysData.decl.isCustom) {
if (rootFolder->getSystem()->isGroupedCustomCollection()) if (rootFolder->getSystem()->isGroupedCustomCollection())
ViewController::get()->onFileChanged(rootFolder->getParent(), true); ViewController::getInstance()->onFileChanged(rootFolder->getParent(), true);
else else
ViewController::get()->onFileChanged(rootFolder, true); ViewController::getInstance()->onFileChanged(rootFolder, true);
} }
} }
} }
@ -486,7 +488,7 @@ void CollectionSystemsManager::deleteCollectionFiles(FileData* file)
if (found) { if (found) {
FileData* collectionEntry = children.at(key); FileData* collectionEntry = children.at(key);
SystemData* systemViewToUpdate = getSystemToView(sysDataIt->second.system); SystemData* systemViewToUpdate = getSystemToView(sysDataIt->second.system);
ViewController::get() ViewController::getInstance()
->getGameListView(systemViewToUpdate) ->getGameListView(systemViewToUpdate)
.get() .get()
->remove(collectionEntry, false); ->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. // Remove all tick marks from the games that are part of the collection.
for (auto it = SystemData::sSystemVector.begin(); it != SystemData::sSystemVector.end(); ++it) { for (auto it = SystemData::sSystemVector.begin(); it != SystemData::sSystemVector.end(); ++it) {
ViewController::get()->getGameListView((*it))->onFileChanged( ViewController::getInstance()->getGameListView((*it))->onFileChanged(
ViewController::get()->getGameListView((*it))->getCursor(), false); ViewController::getInstance()->getGameListView((*it))->getCursor(), false);
} }
mEditingCollectionSystemData->system->onMetaDataSavePoint(); mEditingCollectionSystemData->system->onMetaDataSavePoint();
@ -667,14 +669,14 @@ const bool CollectionSystemsManager::toggleGameInCollection(FileData* file)
// If we found it, we need to remove it. // If we found it, we need to remove it.
FileData* collectionEntry = children.at(key); FileData* collectionEntry = children.at(key);
fileIndex->removeFromIndex(collectionEntry); fileIndex->removeFromIndex(collectionEntry);
ViewController::get() ViewController::getInstance()
->getGameListView(systemViewToUpdate) ->getGameListView(systemViewToUpdate)
.get() .get()
->remove(collectionEntry, false); ->remove(collectionEntry, false);
systemViewToUpdate->getRootFolder()->sort( systemViewToUpdate->getRootFolder()->sort(
rootFolder->getSortTypeFromString(rootFolder->getSortTypeString()), rootFolder->getSortTypeFromString(rootFolder->getSortTypeString()),
Settings::getInstance()->getBool("FavFirstCustom")); Settings::getInstance()->getBool("FavFirstCustom"));
ViewController::get()->reloadGameListView(systemViewToUpdate); ViewController::getInstance()->reloadGameListView(systemViewToUpdate);
updateCollectionFolderMetadata(systemViewToUpdate); updateCollectionFolderMetadata(systemViewToUpdate);
} }
@ -686,7 +688,8 @@ const bool CollectionSystemsManager::toggleGameInCollection(FileData* file)
systemViewToUpdate->getRootFolder()->sort( systemViewToUpdate->getRootFolder()->sort(
rootFolder->getSortTypeFromString(rootFolder->getSortTypeString()), rootFolder->getSortTypeFromString(rootFolder->getSortTypeString()),
Settings::getInstance()->getBool("FavFirstCustom")); Settings::getInstance()->getBool("FavFirstCustom"));
ViewController::get()->onFileChanged(systemViewToUpdate->getRootFolder(), true); ViewController::getInstance()->onFileChanged(systemViewToUpdate->getRootFolder(),
true);
fileIndex->addToIndex(newGame); fileIndex->addToIndex(newGame);
// Add to bundle index as well, if needed. // Add to bundle index as well, if needed.
@ -713,7 +716,7 @@ const bool CollectionSystemsManager::toggleGameInCollection(FileData* file)
file->getSourceFileData()->getSystem()->onMetaDataSavePoint(); file->getSourceFileData()->getSystem()->onMetaDataSavePoint();
refreshCollectionSystems(file->getSourceFileData()); refreshCollectionSystems(file->getSourceFileData());
if (mAutoCollectionSystemsData["favorites"].isEnabled) if (mAutoCollectionSystemsData["favorites"].isEnabled)
ViewController::get()->reloadGameListView( ViewController::getInstance()->reloadGameListView(
mAutoCollectionSystemsData["favorites"].system); mAutoCollectionSystemsData["favorites"].system);
} }
if (adding) { 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 // 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 // (where the custom collection deletions are initiated), as there seems to be some random
// issue with accessing mWindow via the lambda expression. // 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(); delete mWindow->peekGui();
if (collectionEntry != mCustomCollectionSystemsData.end()) { if (collectionEntry != mCustomCollectionSystemsData.end()) {
CollectionSystemsManager::getInstance()->loadEnabledListFromSettings(); CollectionSystemsManager::getInstance()->loadEnabledListFromSettings();
CollectionSystemsManager::getInstance()->updateSystemsList(); CollectionSystemsManager::getInstance()->updateSystemsList();
ViewController::get()->removeGameListView(collectionEntry->second.system); ViewController::getInstance()->removeGameListView(collectionEntry->second.system);
ViewController::get()->reloadAll(); ViewController::getInstance()->reloadAll();
delete collectionEntry->second.system; delete collectionEntry->second.system;
mCustomCollectionSystemsData.erase(collectionName); 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 // 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 // and then point to this, and for collections with games in them we select the first
// entry. // entry.
auto autoView = ViewController::get()->getGameListView(autoSystem->system).get(); auto autoView =
ViewController::getInstance()->getGameListView(autoSystem->system).get();
if (autoSystem->system->getRootFolder()->getChildren().size() == 0) { if (autoSystem->system->getRootFolder()->getChildren().size() == 0) {
autoView->addPlaceholder(autoSystem->system->getRootFolder()); autoView->addPlaceholder(autoSystem->system->getRootFolder());
autoView->setCursor(autoView->getLastEntry()); autoView->setCursor(autoView->getLastEntry());
@ -1035,7 +1039,8 @@ void CollectionSystemsManager::repopulateCollection(SystemData* sysData)
customSystem->isPopulated = false; customSystem->isPopulated = false;
populateCustomCollection(customSystem); populateCustomCollection(customSystem);
auto autoView = ViewController::get()->getGameListView(customSystem->system).get(); auto autoView =
ViewController::getInstance()->getGameListView(customSystem->system).get();
autoView->setCursor( autoView->setCursor(
customSystem->system->getRootFolder()->getChildrenRecursive().front()); customSystem->system->getRootFolder()->getChildrenRecursive().front());
autoView->setCursor(autoView->getFirstEntry()); autoView->setCursor(autoView->getFirstEntry());
@ -1154,12 +1159,13 @@ void CollectionSystemsManager::populateAutoCollection(CollectionSystemData* sysD
if (rootFolder->getName() == "recent" && !rootFolder->getChildrenRecursive().empty()) { if (rootFolder->getName() == "recent" && !rootFolder->getChildrenRecursive().empty()) {
// The following is needed to avoid a crash when repopulating the system as the previous // The following is needed to avoid a crash when repopulating the system as the previous
// cursor pointer may point to a random memory address. // 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( recentGamelist->setCursor(
rootFolder->getSystem()->getRootFolder()->getChildrenRecursive().front()); rootFolder->getSystem()->getRootFolder()->getChildrenRecursive().front());
recentGamelist->setCursor(recentGamelist->getFirstEntry()); recentGamelist->setCursor(recentGamelist->getFirstEntry());
if (rootFolder->getChildren().size() > 0) if (rootFolder->getChildren().size() > 0)
ViewController::get() ViewController::getInstance()
->getGameListView(rootFolder->getSystem()) ->getGameListView(rootFolder->getSystem())
.get() .get()
->onFileChanged(rootFolder->getChildren().front(), false); ->onFileChanged(rootFolder->getChildren().front(), false);
@ -1248,7 +1254,7 @@ void CollectionSystemsManager::removeCollectionsFromDisplayedSystems()
// Clear index. // Clear index.
mCustomCollectionsBundle->getIndex()->resetIndex(); mCustomCollectionsBundle->getIndex()->resetIndex();
// Remove view so it's re-created as needed. // Remove view so it's re-created as needed.
ViewController::get()->removeGameListView(mCustomCollectionsBundle); ViewController::getInstance()->removeGameListView(mCustomCollectionsBundle);
} }
void CollectionSystemsManager::addEnabledCollectionsToDisplayedSystems( void CollectionSystemsManager::addEnabledCollectionsToDisplayedSystems(
@ -1280,7 +1286,7 @@ void CollectionSystemsManager::addEnabledCollectionsToDisplayedSystems(
Settings::getInstance()->getBool("FavFirstCustom")); Settings::getInstance()->getBool("FavFirstCustom"));
// Jump to the first row of the game list, assuming it's not empty. // Jump to the first row of the game list, assuming it's not empty.
IGameListView* gameList = IGameListView* gameList =
ViewController::get()->getGameListView((it->second.system)).get(); ViewController::getInstance()->getGameListView((it->second.system)).get();
if (!gameList->getCursor()->isPlaceHolder()) { if (!gameList->getCursor()->isPlaceHolder()) {
gameList->setCursor(gameList->getFirstEntry()); gameList->setCursor(gameList->getFirstEntry());
} }
@ -1434,7 +1440,7 @@ void CollectionSystemsManager::trimCollectionCount(FileData* rootFolder, int lim
while (static_cast<int>(rootFolder->getChildrenListToDisplay().size()) > limit) { while (static_cast<int>(rootFolder->getChildrenListToDisplay().size()) > limit) {
CollectionFileData* gameToRemove = CollectionFileData* gameToRemove =
(CollectionFileData*)rootFolder->getChildrenListToDisplay().back(); (CollectionFileData*)rootFolder->getChildrenListToDisplay().back();
ViewController::get()->getGameListView(curSys).get()->remove(gameToRemove, false); ViewController::getInstance()->getGameListView(curSys).get()->remove(gameToRemove, false);
} }
} }

View file

@ -45,7 +45,7 @@ bool MediaViewer::startMediaViewer(FileData* game)
initiateViewer(); initiateViewer();
if (mHasVideo) if (mHasVideo)
ViewController::get()->onPauseVideo(); ViewController::getInstance()->onPauseVideo();
if (mHasVideo || mHasImages) if (mHasVideo || mHasImages)
return true; return true;
@ -56,7 +56,7 @@ bool MediaViewer::startMediaViewer(FileData* game)
void MediaViewer::stopMediaViewer() void MediaViewer::stopMediaViewer()
{ {
NavigationSounds::getInstance().playThemeNavigationSound(SCROLLSOUND); NavigationSounds::getInstance().playThemeNavigationSound(SCROLLSOUND);
ViewController::get()->onStopVideo(); ViewController::getInstance()->onStopVideo();
if (mVideo) { if (mVideo) {
delete mVideo; delete mVideo;
@ -255,7 +255,7 @@ void MediaViewer::playVideo()
return; return;
mDisplayingImage = false; mDisplayingImage = false;
ViewController::get()->onStopVideo(); ViewController::getInstance()->onStopVideo();
mVideo = new VideoFFmpegComponent(mWindow); mVideo = new VideoFFmpegComponent(mWindow);
mVideo->topWindow(true); mVideo->topWindow(true);

View file

@ -1127,7 +1127,7 @@ FileData* SystemData::getRandomGame(const FileData* currentGame)
gameList = mRootFolder->getParent()->getChildrenListToDisplay(); gameList = mRootFolder->getParent()->getChildrenListToDisplay();
} }
else { else {
gameList = ViewController::get() gameList = ViewController::getInstance()
->getGameListView(mRootFolder->getSystem()) ->getGameListView(mRootFolder->getSystem())
.get() .get()
->getCursor() ->getCursor()
@ -1210,10 +1210,10 @@ void SystemData::sortSystem(bool reloadGamelist, bool jumpToFirstRow)
favoritesSorting); favoritesSorting);
if (reloadGamelist) if (reloadGamelist)
ViewController::get()->reloadGameListView(this, false); ViewController::getInstance()->reloadGameListView(this, false);
if (jumpToFirstRow) { if (jumpToFirstRow) {
IGameListView* gameList = ViewController::get()->getGameListView(this).get(); IGameListView* gameList = ViewController::getInstance()->getGameListView(this).get();
gameList->setCursor(gameList->getFirstEntry()); gameList->setCursor(gameList->getFirstEntry());
} }
} }

View file

@ -209,12 +209,12 @@ void SystemScreensaver::launchGame()
{ {
if (mCurrentGame != nullptr) { if (mCurrentGame != nullptr) {
// Launching game // Launching game
ViewController::get()->triggerGameLaunch(mCurrentGame); ViewController::getInstance()->triggerGameLaunch(mCurrentGame);
ViewController::get()->goToGameList(mCurrentGame->getSystem()); ViewController::getInstance()->goToGameList(mCurrentGame->getSystem());
IGameListView* view = IGameListView* view =
ViewController::get()->getGameListView(mCurrentGame->getSystem()).get(); ViewController::getInstance()->getGameListView(mCurrentGame->getSystem()).get();
view->setCursor(mCurrentGame); view->setCursor(mCurrentGame);
ViewController::get()->cancelViewTransitions(); ViewController::getInstance()->cancelViewTransitions();
} }
} }
@ -222,11 +222,11 @@ void SystemScreensaver::goToGame()
{ {
if (mCurrentGame != nullptr) { if (mCurrentGame != nullptr) {
// Go to the game in the gamelist view, but don't launch it. // 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 = IGameListView* view =
ViewController::get()->getGameListView(mCurrentGame->getSystem()).get(); ViewController::getInstance()->getGameListView(mCurrentGame->getSystem()).get();
view->setCursor(mCurrentGame); view->setCursor(mCurrentGame);
ViewController::get()->cancelViewTransitions(); ViewController::getInstance()->cancelViewTransitions();
} }
} }

View file

@ -252,6 +252,6 @@ std::vector<HelpPrompt> GuiAlternativeEmulators::getHelpPrompts()
HelpStyle GuiAlternativeEmulators::getHelpStyle() HelpStyle GuiAlternativeEmulators::getHelpStyle()
{ {
HelpStyle style = HelpStyle(); HelpStyle style = HelpStyle();
style.applyTheme(ViewController::get()->getState().getSystem()->getTheme(), "system"); style.applyTheme(ViewController::getInstance()->getState().getSystem()->getTheme(), "system");
return style; return style;
} }

View file

@ -399,7 +399,7 @@ void GuiCollectionSystemsOptions::createCustomCollection(std::string inName)
setNeedsGoToSystem(newCollection); setNeedsGoToSystem(newCollection);
Window* window = mWindow; Window* window = mWindow;
while (window->peekGui() && window->peekGui() != ViewController::get()) while (window->peekGui() && window->peekGui() != ViewController::getInstance())
delete window->peekGui(); delete window->peekGui();
CollectionSystemsManager::getInstance()->setEditMode(collectionName); CollectionSystemsManager::getInstance()->setEditMode(collectionName);
} }

View file

@ -200,7 +200,7 @@ std::vector<HelpPrompt> GuiGameScraper::getHelpPrompts()
HelpStyle GuiGameScraper::getHelpStyle() HelpStyle GuiGameScraper::getHelpStyle()
{ {
HelpStyle style = HelpStyle(); HelpStyle style = HelpStyle();
style.applyTheme(ViewController::get()->getState().getSystem()->getTheme(), "system"); style.applyTheme(ViewController::getInstance()->getState().getSystem()->getTheme(), "system");
return style; return style;
} }

View file

@ -40,7 +40,7 @@ void GuiGamelistFilter::initializeMenu()
// If this is a collection and system names are shown per game, then let FileFilterIndex // 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. // 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")) if (Settings::getInstance()->getBool("CollectionShowSystemInfo"))
mFilterIndex->setTextRemoveSystem(true); mFilterIndex->setTextRemoveSystem(true);
else else
@ -262,6 +262,6 @@ std::vector<HelpPrompt> GuiGamelistFilter::getHelpPrompts()
HelpStyle GuiGamelistFilter::getHelpStyle() HelpStyle GuiGamelistFilter::getHelpStyle()
{ {
HelpStyle style = HelpStyle(); HelpStyle style = HelpStyle();
style.applyTheme(ViewController::get()->getState().getSystem()->getTheme(), "system"); style.applyTheme(ViewController::getInstance()->getState().getSystem()->getTheme(), "system");
return style; return style;
} }

View file

@ -258,20 +258,20 @@ GuiGamelistOptions::~GuiGamelistOptions()
// This is required for the situation where scrolling started just before the menu // 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 // was openened. Without this, the scrolling would run until manually stopped after
// the menu has been closed. // the menu has been closed.
ViewController::get()->stopScrolling(); ViewController::getInstance()->stopScrolling();
if (mFiltersChanged) { if (mFiltersChanged) {
if (!mCustomCollectionSystem) { if (!mCustomCollectionSystem) {
ViewController::get()->reloadGameListView(mSystem); ViewController::getInstance()->reloadGameListView(mSystem);
} }
else { else {
if (!mFromPlaceholder) { if (!mFromPlaceholder) {
ViewController::get()->reloadGameListView(mSystem); ViewController::getInstance()->reloadGameListView(mSystem);
} }
else if (!mCustomCollectionSystem->getRootFolder() else if (!mCustomCollectionSystem->getRootFolder()
->getChildrenListToDisplay() ->getChildrenListToDisplay()
.empty()) { .empty()) {
ViewController::get()->reloadGameListView(mSystem); ViewController::getInstance()->reloadGameListView(mSystem);
getGamelist()->setCursor( getGamelist()->setCursor(
mCustomCollectionSystem->getRootFolder()->getChildrenListToDisplay().front()); mCustomCollectionSystem->getRootFolder()->getChildrenListToDisplay().front());
} }
@ -353,8 +353,8 @@ void GuiGamelistOptions::startEditMode()
// currently being edited. This is done cheaply using onFileChanged() which will trigger // currently being edited. This is done cheaply using onFileChanged() which will trigger
// populateList(). // populateList().
for (auto it = SystemData::sSystemVector.begin(); it != SystemData::sSystemVector.end(); ++it) { for (auto it = SystemData::sSystemVector.begin(); it != SystemData::sSystemVector.end(); ++it) {
ViewController::get()->getGameListView((*it))->onFileChanged( ViewController::getInstance()->getGameListView((*it))->onFileChanged(
ViewController::get()->getGameListView((*it))->getCursor(), false); ViewController::getInstance()->getGameListView((*it))->getCursor(), false);
} }
if (mSystem->getRootFolder()->getChildren().size() == 0) 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 \"" LOG(LogInfo) << "Deleting the media files and gamelist.xml entry for the file \""
<< file->getFullPath() << "\""; << 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. // Manually reset all the metadata values, set the name to the actual file/folder name.
const std::vector<MetaDataDecl>& mdd = file->metadata.getMDD(); const std::vector<MetaDataDecl>& mdd = file->metadata.getMDD();
@ -443,10 +443,10 @@ void GuiGamelistOptions::openMetaDataEd()
LOG(LogInfo) << "Deleting the game file \"" << file->getFullPath() LOG(LogInfo) << "Deleting the game file \"" << file->getFullPath()
<< "\", all its media files and its gamelist.xml entry."; << "\", all its media files and its gamelist.xml entry.";
CollectionSystemsManager::getInstance()->deleteCollectionFiles(file); CollectionSystemsManager::getInstance()->deleteCollectionFiles(file);
ViewController::get()->getGameListView(file->getSystem()).get()->removeMedia(file); ViewController::getInstance()->getGameListView(file->getSystem()).get()->removeMedia(file);
ViewController::get()->getGameListView(file->getSystem()).get()->remove(file, true); ViewController::getInstance()->getGameListView(file->getSystem()).get()->remove(file, true);
mSystem->getRootFolder()->sort(*mListSort->getSelected(), mFavoritesSorting); mSystem->getRootFolder()->sort(*mListSort->getSelected(), mFavoritesSorting);
ViewController::get()->reloadGameListView(mSystem); ViewController::getInstance()->reloadGameListView(mSystem);
mWindow->invalidateCachedBackground(); mWindow->invalidateCachedBackground();
}; };
@ -456,7 +456,8 @@ void GuiGamelistOptions::openMetaDataEd()
mWindow, &file->metadata, file->metadata.getMDD(FOLDER_METADATA), p, mWindow, &file->metadata, file->metadata.getMDD(FOLDER_METADATA), p,
Utils::FileSystem::getFileName(file->getPath()), Utils::FileSystem::getFileName(file->getPath()),
std::bind(&IGameListView::onFileChanged, std::bind(&IGameListView::onFileChanged,
ViewController::get()->getGameListView(file->getSystem()).get(), file, true), ViewController::getInstance()->getGameListView(file->getSystem()).get(), file,
true),
clearGameBtnFunc, deleteGameBtnFunc)); clearGameBtnFunc, deleteGameBtnFunc));
} }
else { else {
@ -464,7 +465,8 @@ void GuiGamelistOptions::openMetaDataEd()
mWindow, &file->metadata, file->metadata.getMDD(GAME_METADATA), p, mWindow, &file->metadata, file->metadata.getMDD(GAME_METADATA), p,
Utils::FileSystem::getFileName(file->getPath()), Utils::FileSystem::getFileName(file->getPath()),
std::bind(&IGameListView::onFileChanged, std::bind(&IGameListView::onFileChanged,
ViewController::get()->getGameListView(file->getSystem()).get(), file, true), ViewController::getInstance()->getGameListView(file->getSystem()).get(), file,
true),
clearGameBtnFunc, deleteGameBtnFunc)); clearGameBtnFunc, deleteGameBtnFunc));
} }
} }
@ -568,5 +570,5 @@ std::vector<HelpPrompt> GuiGamelistOptions::getHelpPrompts()
IGameListView* GuiGamelistOptions::getGamelist() IGameListView* GuiGamelistOptions::getGamelist()
{ {
return ViewController::get()->getGameListView(mSystem).get(); return ViewController::getInstance()->getGameListView(mSystem).get();
} }

View file

@ -85,7 +85,7 @@ GuiMenu::~GuiMenu()
// This is required for the situation where scrolling started just before the menu // 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 // was openened. Without this, the scrolling would run until manually stopped after
// the menu has been closed. // the menu has been closed.
ViewController::get()->stopScrolling(); ViewController::getInstance()->stopScrolling();
} }
void GuiMenu::openScraperOptions() void GuiMenu::openScraperOptions()
@ -266,8 +266,9 @@ void GuiMenu::openUIOptions()
(*it)->sortSystem(); (*it)->sortSystem();
(*it)->getIndex()->resetFilters(); (*it)->getIndex()->resetFilters();
} }
ViewController::get()->reloadAll(); ViewController::getInstance()->reloadAll();
ViewController::get()->goToSystem(SystemData::sSystemVector.front(), false); ViewController::getInstance()->goToSystem(SystemData::sSystemVector.front(),
false);
mWindow->invalidateCachedBackground(); mWindow->invalidateCachedBackground();
}, },
"NO", nullptr)); "NO", nullptr));
@ -828,7 +829,7 @@ void GuiMenu::openOtherOptions()
auto updateValMediaDir = [this](const std::string& newVal) { auto updateValMediaDir = [this](const std::string& newVal) {
Settings::getInstance()->setString("MediaDirectory", newVal); Settings::getInstance()->setString("MediaDirectory", newVal);
Settings::getInstance()->saveFile(); Settings::getInstance()->saveFile();
ViewController::get()->reloadAll(); ViewController::getInstance()->reloadAll();
mWindow->invalidateCachedBackground(); mWindow->invalidateCachedBackground();
}; };
rowMediaDir.makeAcceptInputHandler([this, titleMediaDir, mediaDirectoryStaticText, rowMediaDir.makeAcceptInputHandler([this, titleMediaDir, mediaDirectoryStaticText,
@ -1264,7 +1265,7 @@ void GuiMenu::close(bool closeAllWindows)
else { else {
Window* window = mWindow; Window* window = mWindow;
closeFunc = [window] { closeFunc = [window] {
while (window->peekGui() != ViewController::get()) while (window->peekGui() != ViewController::getInstance())
delete window->peekGui(); delete window->peekGui();
}; };
} }
@ -1298,6 +1299,6 @@ std::vector<HelpPrompt> GuiMenu::getHelpPrompts()
HelpStyle GuiMenu::getHelpStyle() HelpStyle GuiMenu::getHelpStyle()
{ {
HelpStyle style = HelpStyle(); HelpStyle style = HelpStyle();
style.applyTheme(ViewController::get()->getState().getSystem()->getTheme(), "system"); style.applyTheme(ViewController::getInstance()->getState().getSystem()->getTheme(), "system");
return style; return style;
} }

View file

@ -511,7 +511,7 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
buttons.push_back(std::make_shared<ButtonComponent>(mWindow, "SAVE", "save metadata", [&] { buttons.push_back(std::make_shared<ButtonComponent>(mWindow, "SAVE", "save metadata", [&] {
save(); save();
ViewController::get()->onPauseVideo(); ViewController::getInstance()->onPauseVideo();
delete this; delete this;
})); }));
buttons.push_back(std::make_shared<ButtonComponent>(mWindow, "CANCEL", "cancel changes", buttons.push_back(std::make_shared<ButtonComponent>(mWindow, "CANCEL", "cancel changes",
@ -698,7 +698,7 @@ void GuiMetaDataEd::save()
if (std::find(children.begin(), children.end(), hideGame) != children.end()) { if (std::find(children.begin(), children.end(), hideGame) != children.end()) {
sys->getIndex()->removeFromIndex(hideGame); sys->getIndex()->removeFromIndex(hideGame);
// Reload the gamelist as well as the view style may need to change. // 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. // until the user scrolls up and down the gamelist.
TextureResource::manualUnload(mScraperParams.game->getImagePath(), false); TextureResource::manualUnload(mScraperParams.game->getImagePath(), false);
TextureResource::manualUnload(mScraperParams.game->getMarqueePath(), 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. // Update all collections where the game is present.
CollectionSystemsManager::getInstance()->refreshCollectionSystems(mScraperParams.game); CollectionSystemsManager::getInstance()->refreshCollectionSystems(mScraperParams.game);
mWindow->invalidateCachedBackground(); mWindow->invalidateCachedBackground();
} }
ViewController::get()->onPauseVideo(); ViewController::getInstance()->onPauseVideo();
delete this; delete this;
}; };
@ -867,6 +867,6 @@ std::vector<HelpPrompt> GuiMetaDataEd::getHelpPrompts()
HelpStyle GuiMetaDataEd::getHelpStyle() HelpStyle GuiMetaDataEd::getHelpStyle()
{ {
HelpStyle style = HelpStyle(); HelpStyle style = HelpStyle();
style.applyTheme(ViewController::get()->getState().getSystem()->getTheme(), "system"); style.applyTheme(ViewController::getInstance()->getState().getSystem()->getTheme(), "system");
return style; return style;
} }

View file

@ -198,7 +198,7 @@ GuiOfflineGenerator::~GuiOfflineGenerator()
mMiximageGenerator.reset(); mMiximageGenerator.reset();
if (mImagesGenerated > 0) if (mImagesGenerated > 0)
ViewController::get()->reloadAll(); ViewController::getInstance()->reloadAll();
} }
void GuiOfflineGenerator::onSizeChanged() void GuiOfflineGenerator::onSizeChanged()
@ -336,6 +336,6 @@ std::vector<HelpPrompt> GuiOfflineGenerator::getHelpPrompts()
HelpStyle GuiOfflineGenerator::getHelpStyle() HelpStyle GuiOfflineGenerator::getHelpStyle()
{ {
HelpStyle style = HelpStyle(); HelpStyle style = HelpStyle();
style.applyTheme(ViewController::get()->getState().getSystem()->getTheme(), "system"); style.applyTheme(ViewController::getInstance()->getState().getSystem()->getTheme(), "system");
return style; return style;
} }

View file

@ -1135,6 +1135,6 @@ std::vector<HelpPrompt> GuiScraperMenu::getHelpPrompts()
HelpStyle GuiScraperMenu::getHelpStyle() HelpStyle GuiScraperMenu::getHelpStyle()
{ {
HelpStyle style = HelpStyle(); HelpStyle style = HelpStyle();
style.applyTheme(ViewController::get()->getState().getSystem()->getTheme(), "system"); style.applyTheme(ViewController::getInstance()->getState().getSystem()->getTheme(), "system");
return style; return style;
} }

View file

@ -182,7 +182,7 @@ GuiScraperMulti::~GuiScraperMulti()
(*it)->sortSystem(); (*it)->sortSystem();
} }
} }
ViewController::get()->onPauseVideo(); ViewController::getInstance()->onPauseVideo();
} }
void GuiScraperMulti::onSizeChanged() void GuiScraperMulti::onSizeChanged()
@ -324,6 +324,6 @@ std::vector<HelpPrompt> GuiScraperMulti::getHelpPrompts()
HelpStyle GuiScraperMulti::getHelpStyle() HelpStyle GuiScraperMulti::getHelpStyle()
{ {
HelpStyle style = HelpStyle(); HelpStyle style = HelpStyle();
style.applyTheme(ViewController::get()->getState().getSystem()->getTheme(), "system"); style.applyTheme(ViewController::getInstance()->getState().getSystem()->getTheme(), "system");
return style; return style;
} }

View file

@ -170,7 +170,7 @@ GuiScraperSearch::~GuiScraperSearch()
mMiximageGeneratorThread.join(); mMiximageGeneratorThread.join();
mMiximageGenerator.reset(); mMiximageGenerator.reset();
TextureResource::manualUnload(mLastSearch.game->getMiximagePath(), false); TextureResource::manualUnload(mLastSearch.game->getMiximagePath(), false);
ViewController::get()->onFileChanged(mLastSearch.game, true); ViewController::getInstance()->onFileChanged(mLastSearch.game, true);
} }
} }
@ -1017,6 +1017,6 @@ std::vector<HelpPrompt> GuiScraperSearch::getHelpPrompts()
HelpStyle GuiScraperSearch::getHelpStyle() HelpStyle GuiScraperSearch::getHelpStyle()
{ {
HelpStyle style = HelpStyle(); HelpStyle style = HelpStyle();
style.applyTheme(ViewController::get()->getState().getSystem()->getTheme(), "system"); style.applyTheme(ViewController::getInstance()->getState().getSystem()->getTheme(), "system");
return style; return style;
} }

View file

@ -77,7 +77,7 @@ void GuiSettings::save()
(*it)->sortSystem(true); (*it)->sortSystem(true);
// Jump to the first row of the gamelist. // 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()); gameList->setCursor(gameList->getFirstEntry());
} }
} }
@ -94,38 +94,38 @@ void GuiSettings::save()
} }
if (mNeedsReloading) if (mNeedsReloading)
ViewController::get()->reloadAll(); ViewController::getInstance()->reloadAll();
if (mNeedsGoToStart) if (mNeedsGoToStart)
ViewController::get()->goToStart(true); ViewController::getInstance()->goToStart(true);
if (mNeedsGoToSystem) if (mNeedsGoToSystem)
ViewController::get()->goToSystem(mGoToSystem, false); ViewController::getInstance()->goToSystem(mGoToSystem, false);
if (mNeedsGoToGroupedCollections) { if (mNeedsGoToGroupedCollections) {
bool groupedSystemExists = false; bool groupedSystemExists = false;
for (SystemData* system : SystemData::sSystemVector) { for (SystemData* system : SystemData::sSystemVector) {
if (system->getThemeFolder() == "custom-collections") { if (system->getThemeFolder() == "custom-collections") {
ViewController::get()->goToSystem(system, false); ViewController::getInstance()->goToSystem(system, false);
groupedSystemExists = true; groupedSystemExists = true;
continue; continue;
} }
} }
if (!groupedSystemExists) if (!groupedSystemExists)
// No grouped custom collection system exists, so go to the first system instead. // 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) { 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 // 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 // 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 // these views can behave a bit strange during collection changes so it's better to be on
// the safe side. // the safe side.
if (state.getSystem()->isCollection() && if (state.getSystem()->isCollection() &&
state.getSystem()->getThemeFolder() != "custom-collections") { state.getSystem()->getThemeFolder() != "custom-collections") {
ViewController::get()->goToStart(false); ViewController::getInstance()->goToStart(false);
ViewController::get()->goToSystem(SystemData::sSystemVector.front(), false); ViewController::getInstance()->goToSystem(SystemData::sSystemVector.front(), false);
// We don't want to invalidate the cached background when there has been a collection // 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. // systen change as that may show a black screen in some circumstances.
return; return;
@ -134,7 +134,7 @@ void GuiSettings::save()
// system view). // system view).
if (std::find(SystemData::sSystemVector.begin(), SystemData::sSystemVector.end(), if (std::find(SystemData::sSystemVector.begin(), SystemData::sSystemVector.end(),
state.getSystem()) == SystemData::sSystemVector.end()) { state.getSystem()) == SystemData::sSystemVector.end()) {
ViewController::get()->goToStart(false); ViewController::getInstance()->goToStart(false);
return; return;
} }
} }
@ -237,7 +237,7 @@ bool GuiSettings::input(InputConfig* config, Input input)
HelpStyle GuiSettings::getHelpStyle() HelpStyle GuiSettings::getHelpStyle()
{ {
HelpStyle style = HelpStyle(); HelpStyle style = HelpStyle();
style.applyTheme(ViewController::get()->getState().getSystem()->getTheme(), "system"); style.applyTheme(ViewController::getInstance()->getState().getSystem()->getTheme(), "system");
return style; return style;
} }

View file

@ -530,7 +530,7 @@ int main(int argc, char* argv[])
Window* window = Window::getInstance(); Window* window = Window::getInstance();
ViewController::get(); ViewController::getInstance();
CollectionSystemsManager::getInstance(); CollectionSystemsManager::getInstance();
SystemScreensaver screensaver; SystemScreensaver screensaver;
@ -542,7 +542,7 @@ int main(int argc, char* argv[])
return 1; return 1;
} }
window->pushGui(ViewController::get()); window->pushGui(ViewController::getInstance());
bool splashScreen = Settings::getInstance()->getBool("SplashScreen"); bool splashScreen = Settings::getInstance()->getBool("SplashScreen");
bool splashScreenProgress = Settings::getInstance()->getBool("SplashScreenProgress"); 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 // configure a different ROM directory as well as to generate the game systems
// directory structure. // directory structure.
if (loadSystemsStatus == INVALID_FILE) { if (loadSystemsStatus == INVALID_FILE) {
ViewController::get()->invalidSystemsFileDialog(); ViewController::getInstance()->invalidSystemsFileDialog();
} }
else if (loadSystemsStatus == NO_ROMS) { 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. // any command tag in es_systems.xml.
for (auto system : SystemData::sSystemVector) { for (auto system : SystemData::sSystemVector) {
if (system->getAlternativeEmulator().substr(0, 9) == "<INVALID>") { if (system->getAlternativeEmulator().substr(0, 9) == "<INVALID>") {
ViewController::get()->invalidAlternativeEmulatorDialog(); ViewController::getInstance()->invalidAlternativeEmulatorDialog();
break; 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. // 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. // This makes for no delays when accessing content, but a longer startup time.
ViewController::get()->preload(); ViewController::getInstance()->preload();
if (splashScreen && splashScreenProgress) if (splashScreen && splashScreenProgress)
window->renderLoadingScreen("Done"); 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. // Open the input configuration GUI if the flag to force this was passed from the command line.
if (!loadSystemsStatus) { if (!loadSystemsStatus) {
if (forceInputConfig) { if (forceInputConfig) {
window->pushGui(new GuiDetectDevice(window, false, true, window->pushGui(new GuiDetectDevice(
[] { ViewController::get()->goToStart(true); })); window, false, true, [] { ViewController::getInstance()->goToStart(true); }));
} }
else { else {
ViewController::get()->goToStart(true); ViewController::getInstance()->goToStart(true);
} }
} }
@ -679,7 +679,7 @@ int main(int argc, char* argv[])
Log::flush(); Log::flush();
} }
while (window->peekGui() != ViewController::get()) while (window->peekGui() != ViewController::getInstance())
delete window->peekGui(); delete window->peekGui();
window->deinit(); window->deinit();

View file

@ -253,7 +253,7 @@ MDResolveHandle::MDResolveHandle(const ScraperSearchResult& result,
scrapeFiles.push_back(mediaFileInfo); scrapeFiles.push_back(mediaFileInfo);
#if defined(_WIN64) #if defined(_WIN64)
// Required due to the idiotic file locking that exists on this operating system. // Required due to the idiotic file locking that exists on this operating system.
ViewController::get()->onStopVideo(); ViewController::getInstance()->onStopVideo();
#endif #endif
} }

View file

@ -247,7 +247,7 @@ bool SystemView::input(InputConfig* config, Input input)
if (config->getDeviceId() == DEVICE_KEYBOARD && input.value && input.id == SDLK_r && if (config->getDeviceId() == DEVICE_KEYBOARD && input.value && input.id == SDLK_r &&
SDL_GetModState() & KMOD_LCTRL && Settings::getInstance()->getBool("Debug")) { SDL_GetModState() & KMOD_LCTRL && Settings::getInstance()->getBool("Debug")) {
LOG(LogDebug) << "SystemView::input(): Reloading all"; LOG(LogDebug) << "SystemView::input(): Reloading all";
ViewController::get()->reloadAll(); ViewController::getInstance()->reloadAll();
return true; return true;
} }
@ -255,12 +255,12 @@ bool SystemView::input(InputConfig* config, Input input)
case VERTICAL: case VERTICAL:
case VERTICAL_WHEEL: case VERTICAL_WHEEL:
if (config->isMappedLike("up", input)) { if (config->isMappedLike("up", input)) {
ViewController::get()->cancelViewTransitions(); ViewController::getInstance()->cancelViewTransitions();
listInput(-1); listInput(-1);
return true; return true;
} }
if (config->isMappedLike("down", input)) { if (config->isMappedLike("down", input)) {
ViewController::get()->cancelViewTransitions(); ViewController::getInstance()->cancelViewTransitions();
listInput(1); listInput(1);
return true; return true;
} }
@ -269,12 +269,12 @@ bool SystemView::input(InputConfig* config, Input input)
case HORIZONTAL_WHEEL: case HORIZONTAL_WHEEL:
default: default:
if (config->isMappedLike("left", input)) { if (config->isMappedLike("left", input)) {
ViewController::get()->cancelViewTransitions(); ViewController::getInstance()->cancelViewTransitions();
listInput(-1); listInput(-1);
return true; return true;
} }
if (config->isMappedLike("right", input)) { if (config->isMappedLike("right", input)) {
ViewController::get()->cancelViewTransitions(); ViewController::getInstance()->cancelViewTransitions();
listInput(1); listInput(1);
return true; return true;
} }
@ -283,7 +283,7 @@ bool SystemView::input(InputConfig* config, Input input)
if (config->isMappedTo("a", input)) { if (config->isMappedTo("a", input)) {
stopScrolling(); stopScrolling();
ViewController::get()->goToGameList(getSelected()); ViewController::getInstance()->goToGameList(getSelected());
NavigationSounds::getInstance().playThemeNavigationSound(SELECTSOUND); NavigationSounds::getInstance().playThemeNavigationSound(SELECTSOUND);
return true; return true;
} }
@ -299,8 +299,8 @@ bool SystemView::input(InputConfig* config, Input input)
if (!UIModeController::getInstance()->isUIModeKid() && config->isMappedTo("back", input) && if (!UIModeController::getInstance()->isUIModeKid() && config->isMappedTo("back", input) &&
Settings::getInstance()->getBool("ScreensaverControls")) { Settings::getInstance()->getBool("ScreensaverControls")) {
if (!mWindow->isScreensaverActive()) { if (!mWindow->isScreensaverActive()) {
ViewController::get()->stopScrolling(); ViewController::getInstance()->stopScrolling();
ViewController::get()->cancelViewTransitions(); ViewController::getInstance()->cancelViewTransitions();
mWindow->startScreensaver(); mWindow->startScreensaver();
mWindow->renderScreensaver(); mWindow->renderScreensaver();
} }

View file

@ -39,7 +39,7 @@ void UIModeController::monitorUIMode()
{ {
std::string uimode = Settings::getInstance()->getString("UIMode"); std::string uimode = Settings::getInstance()->getString("UIMode");
// UI mode was changed. // UI mode was changed.
if (uimode != mCurrentUIMode && !ViewController::get()->isCameraMoving()) { if (uimode != mCurrentUIMode && !ViewController::getInstance()->isCameraMoving()) {
mCurrentUIMode = uimode; mCurrentUIMode = uimode;
// Reset filters and sort gamelists (which will update the game counter). // Reset filters and sort gamelists (which will update the game counter).
for (auto it = SystemData::sSystemVector.cbegin(); // Line break. for (auto it = SystemData::sSystemVector.cbegin(); // Line break.
@ -51,7 +51,7 @@ void UIModeController::monitorUIMode()
customSystem->getSystem()->getIndex()->resetFilters(); customSystem->getSystem()->getIndex()->resetFilters();
} }
} }
ViewController::get()->ReloadAndGoToStart(); ViewController::getInstance()->ReloadAndGoToStart();
} }
} }

View file

@ -55,7 +55,7 @@ const std::string ViewController::KEYBOARD_CHAR = "\uf11c";
const std::string ViewController::TICKMARK_CHAR = "\uf14a"; const std::string ViewController::TICKMARK_CHAR = "\uf14a";
#endif #endif
ViewController* ViewController::get() ViewController* ViewController::getInstance()
{ {
static ViewController instance; static ViewController instance;
return &instance; return &instance;

View file

@ -29,7 +29,7 @@ class SystemView;
class ViewController : public GuiComponent class ViewController : public GuiComponent
{ {
public: public:
static ViewController* get(); static ViewController* getInstance();
// These functions are called from main(). // These functions are called from main().
void invalidSystemsFileDialog(); void invalidSystemsFileDialog();

View file

@ -40,7 +40,7 @@ void BasicGameListView::onFileChanged(FileData* file, bool reloadGameList)
{ {
if (reloadGameList) { if (reloadGameList) {
// Might switch to a detailed view. // Might switch to a detailed view.
ViewController::get()->reloadGameListView(this); ViewController::getInstance()->reloadGameListView(this);
return; return;
} }
@ -162,7 +162,7 @@ void BasicGameListView::addPlaceholder(FileData* firstEntry)
void BasicGameListView::launch(FileData* game) void BasicGameListView::launch(FileData* game)
{ {
// This triggers ViewController to launch the game. // This triggers ViewController to launch the game.
ViewController::get()->triggerGameLaunch(game); ViewController::getInstance()->triggerGameLaunch(game);
} }
void BasicGameListView::remove(FileData* game, bool deleteFile) void BasicGameListView::remove(FileData* game, bool deleteFile)
@ -310,7 +310,7 @@ std::vector<HelpPrompt> BasicGameListView::getHelpPrompts()
prompts.push_back(HelpPrompt("left/right", "system")); prompts.push_back(HelpPrompt("left/right", "system"));
if (mRoot->getSystem()->getThemeFolder() == "custom-collections" && mCursorStack.empty() && 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")); prompts.push_back(HelpPrompt("a", "enter"));
else else
prompts.push_back(HelpPrompt("a", "launch")); prompts.push_back(HelpPrompt("a", "launch"));
@ -325,8 +325,8 @@ std::vector<HelpPrompt> BasicGameListView::getHelpPrompts()
if (mRoot->getSystem()->getThemeFolder() == "custom-collections" && if (mRoot->getSystem()->getThemeFolder() == "custom-collections" &&
!CollectionSystemsManager::getInstance()->isEditing() && mCursorStack.empty() && !CollectionSystemsManager::getInstance()->isEditing() && mCursorStack.empty() &&
ViewController::get()->getState().viewing == ViewController::GAME_LIST && ViewController::getInstance()->getState().viewing == ViewController::GAME_LIST &&
ViewController::get()->getState().viewstyle != ViewController::BASIC) { ViewController::getInstance()->getState().viewstyle != ViewController::BASIC) {
prompts.push_back(HelpPrompt("y", "jump to game")); prompts.push_back(HelpPrompt("y", "jump to game"));
} }
else if (mRoot->getSystem()->isGameSystem() && else if (mRoot->getSystem()->isGameSystem() &&

View file

@ -476,7 +476,7 @@ void DetailedGameListView::updateInfoPanel()
void DetailedGameListView::launch(FileData* game) void DetailedGameListView::launch(FileData* game)
{ {
ViewController::get()->triggerGameLaunch(game); ViewController::getInstance()->triggerGameLaunch(game);
} }
std::vector<TextComponent*> DetailedGameListView::getMDLabels() std::vector<TextComponent*> DetailedGameListView::getMDLabels()
@ -512,7 +512,7 @@ void DetailedGameListView::update(int deltaTime)
BasicGameListView::update(deltaTime); BasicGameListView::update(deltaTime);
mImage.update(deltaTime); mImage.update(deltaTime);
if (ViewController::get()->getGameLaunchTriggered() && mImage.isAnimationPlaying(0)) if (ViewController::getInstance()->getGameLaunchTriggered() && mImage.isAnimationPlaying(0))
mImage.finishAnimation(0); mImage.finishAnimation(0);
} }

View file

@ -130,7 +130,7 @@ void GridGameListView::onFileChanged(FileData* file, bool reloadGameList)
{ {
if (reloadGameList) { if (reloadGameList) {
// Might switch to a detailed view. // Might switch to a detailed view.
ViewController::get()->reloadGameListView(this); ViewController::getInstance()->reloadGameListView(this);
return; return;
} }
@ -519,7 +519,7 @@ void GridGameListView::addPlaceholder(FileData* firstEntry)
void GridGameListView::launch(FileData* game) void GridGameListView::launch(FileData* game)
{ {
// This triggers ViewController to launch the game. // This triggers ViewController to launch the game.
ViewController::get()->triggerGameLaunch(game); ViewController::getInstance()->triggerGameLaunch(game);
} }
void GridGameListView::remove(FileData* game, bool deleteFile) void GridGameListView::remove(FileData* game, bool deleteFile)
@ -687,7 +687,7 @@ std::vector<HelpPrompt> GridGameListView::getHelpPrompts()
prompts.push_back(HelpPrompt("up/down/left/right", "choose")); prompts.push_back(HelpPrompt("up/down/left/right", "choose"));
if (mRoot->getSystem()->getThemeFolder() == "custom-collections" && mCursorStack.empty() && 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")); prompts.push_back(HelpPrompt("a", "enter"));
else else
prompts.push_back(HelpPrompt("a", "launch")); prompts.push_back(HelpPrompt("a", "launch"));

View file

@ -33,7 +33,7 @@ bool IGameListView::input(InputConfig* config, Input input)
// Select button opens GuiGamelistOptions. // Select button opens GuiGamelistOptions.
if (!UIModeController::getInstance()->isUIModeKid() && // Line break. if (!UIModeController::getInstance()->isUIModeKid() && // Line break.
config->isMappedTo("back", input) && input.value) { config->isMappedTo("back", input) && input.value) {
ViewController::get()->cancelViewTransitions(); ViewController::getInstance()->cancelViewTransitions();
stopListScrolling(); stopListScrolling();
mWindow->pushGui(new GuiGamelistOptions(mWindow, this->mRoot->getSystem())); mWindow->pushGui(new GuiGamelistOptions(mWindow, this->mRoot->getSystem()));
return true; return true;
@ -45,7 +45,7 @@ bool IGameListView::input(InputConfig* config, Input input)
(SDL_GetModState() & (KMOD_LCTRL | KMOD_RCTRL)) && input.id == SDLK_r && (SDL_GetModState() & (KMOD_LCTRL | KMOD_RCTRL)) && input.id == SDLK_r &&
input.value != 0) { input.value != 0) {
LOG(LogDebug) << "IGameListView::input(): Reloading view"; LOG(LogDebug) << "IGameListView::input(): Reloading view";
ViewController::get()->reloadGameListView(this, true); ViewController::getInstance()->reloadGameListView(this, true);
return true; return true;
} }

View file

@ -106,14 +106,14 @@ bool ISimpleGameListView::input(InputConfig* config, Input input)
FileData* cursor = getCursor(); FileData* cursor = getCursor();
if (cursor->getType() == GAME) { if (cursor->getType() == GAME) {
onPauseVideo(); onPauseVideo();
ViewController::get()->cancelViewTransitions(); ViewController::getInstance()->cancelViewTransitions();
stopListScrolling(); stopListScrolling();
launch(cursor); launch(cursor);
} }
else { else {
// It's a folder. // It's a folder.
if (cursor->getChildren().size() > 0) { if (cursor->getChildren().size() > 0) {
ViewController::get()->cancelViewTransitions(); ViewController::getInstance()->cancelViewTransitions();
NavigationSounds::getInstance().playThemeNavigationSound(SELECTSOUND); NavigationSounds::getInstance().playThemeNavigationSound(SELECTSOUND);
mCursorStack.push(cursor); mCursorStack.push(cursor);
populateList(cursor->getChildrenListToDisplay(), cursor); populateList(cursor->getChildrenListToDisplay(), cursor);
@ -147,7 +147,7 @@ bool ISimpleGameListView::input(InputConfig* config, Input input)
return true; return true;
} }
else if (config->isMappedTo("b", input)) { else if (config->isMappedTo("b", input)) {
ViewController::get()->cancelViewTransitions(); ViewController::getInstance()->cancelViewTransitions();
if (mCursorStack.size()) { if (mCursorStack.size()) {
// Save the position to the cursor stack history. // Save the position to the cursor stack history.
mCursorStackHistory.push_back(getCursor()); mCursorStackHistory.push_back(getCursor());
@ -168,10 +168,10 @@ bool ISimpleGameListView::input(InputConfig* config, Input input)
SystemData* systemToView = getCursor()->getSystem(); SystemData* systemToView = getCursor()->getSystem();
if (systemToView->isCustomCollection() && if (systemToView->isCustomCollection() &&
systemToView->getRootFolder()->getParent()) systemToView->getRootFolder()->getParent())
ViewController::get()->goToSystemView( ViewController::getInstance()->goToSystemView(
systemToView->getRootFolder()->getParent()->getSystem(), true); systemToView->getRootFolder()->getParent()->getSystem(), true);
else else
ViewController::get()->goToSystemView(systemToView, true); ViewController::getInstance()->goToSystemView(systemToView, true);
} }
return true; return true;
@ -184,19 +184,20 @@ bool ISimpleGameListView::input(InputConfig* config, Input input)
else if (config->isMappedTo("x", input) && else if (config->isMappedTo("x", input) &&
mRoot->getSystem()->getThemeFolder() == "custom-collections" && mRoot->getSystem()->getThemeFolder() == "custom-collections" &&
mCursorStack.empty() && mCursorStack.empty() &&
ViewController::get()->getState().viewing == ViewController::GAME_LIST) { ViewController::getInstance()->getState().viewing ==
ViewController::GAME_LIST) {
NavigationSounds::getInstance().playThemeNavigationSound(SCROLLSOUND); NavigationSounds::getInstance().playThemeNavigationSound(SCROLLSOUND);
// Jump to the randomly selected game. // Jump to the randomly selected game.
if (mRandomGame) { if (mRandomGame) {
stopListScrolling(); stopListScrolling();
ViewController::get()->cancelViewTransitions(); ViewController::getInstance()->cancelViewTransitions();
mWindow->startMediaViewer(mRandomGame); mWindow->startMediaViewer(mRandomGame);
return true; return true;
} }
} }
else if (mRoot->getSystem()->isGameSystem()) { else if (mRoot->getSystem()->isGameSystem()) {
stopListScrolling(); stopListScrolling();
ViewController::get()->cancelViewTransitions(); ViewController::getInstance()->cancelViewTransitions();
NavigationSounds::getInstance().playThemeNavigationSound(SCROLLSOUND); NavigationSounds::getInstance().playThemeNavigationSound(SCROLLSOUND);
mWindow->startMediaViewer(getCursor()); mWindow->startMediaViewer(getCursor());
return true; return true;
@ -208,7 +209,7 @@ bool ISimpleGameListView::input(InputConfig* config, Input input)
onPauseVideo(); onPauseVideo();
onFocusLost(); onFocusLost();
stopListScrolling(); stopListScrolling();
ViewController::get()->goToNextGameList(); ViewController::getInstance()->goToNextGameList();
return true; return true;
} }
} }
@ -218,7 +219,7 @@ bool ISimpleGameListView::input(InputConfig* config, Input input)
onPauseVideo(); onPauseVideo();
onFocusLost(); onFocusLost();
stopListScrolling(); stopListScrolling();
ViewController::get()->goToPrevGameList(); ViewController::getInstance()->goToPrevGameList();
return true; return true;
} }
} }
@ -238,7 +239,7 @@ bool ISimpleGameListView::input(InputConfig* config, Input input)
else if (config->isMappedTo("y", input) && else if (config->isMappedTo("y", input) &&
mRoot->getSystem()->getThemeFolder() == "custom-collections" && mRoot->getSystem()->getThemeFolder() == "custom-collections" &&
!CollectionSystemsManager::getInstance()->isEditing() && mCursorStack.empty() && !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. // Jump to the randomly selected game.
if (mRandomGame) { if (mRandomGame) {
NavigationSounds::getInstance().playThemeNavigationSound(SELECTSOUND); NavigationSounds::getInstance().playThemeNavigationSound(SELECTSOUND);
@ -420,15 +421,15 @@ bool ISimpleGameListView::input(InputConfig* config, Input input)
mRoot->getSortTypeFromString(mRoot->getSortTypeString()), mRoot->getSortTypeFromString(mRoot->getSortTypeString()),
Settings::getInstance()->getBool("FavoritesFirst")); 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 // 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 // was unmarked. We couldn't do this earlier as we didn't have the list
// sorted yet. // sorted yet.
if (removedLastFavorite) { if (removedLastFavorite) {
ViewController::get() ViewController::getInstance()
->getGameListView(entryToUpdate->getSystem()) ->getGameListView(entryToUpdate->getSystem())
->setCursor(ViewController::get() ->setCursor(ViewController::getInstance()
->getGameListView(entryToUpdate->getSystem()) ->getGameListView(entryToUpdate->getSystem())
->getFirstEntry()); ->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 // 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 // from ViewController instead of using the reference that existed before the
// destruction. Otherwise we get random crashes. // 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. // Jump to the first entry in the gamelist if the last favorite was unmarked.
if (foldersOnTop && removedLastFavorite && if (foldersOnTop && removedLastFavorite &&
!entryToUpdate->getSystem()->isCustomCollection()) { !entryToUpdate->getSystem()->isCustomCollection()) {
ViewController::get() ViewController::getInstance()
->getGameListView(entryToUpdate->getSystem()) ->getGameListView(entryToUpdate->getSystem())
->setCursor(ViewController::get() ->setCursor(ViewController::getInstance()
->getGameListView(entryToUpdate->getSystem()) ->getGameListView(entryToUpdate->getSystem())
->getFirstGameEntry()); ->getFirstGameEntry());
} }
@ -467,8 +469,9 @@ bool ISimpleGameListView::input(InputConfig* config, Input input)
if (isEditing) { if (isEditing) {
for (auto it = SystemData::sSystemVector.begin(); for (auto it = SystemData::sSystemVector.begin();
it != SystemData::sSystemVector.end(); ++it) { it != SystemData::sSystemVector.end(); ++it) {
ViewController::get()->getGameListView((*it))->onFileChanged( ViewController::getInstance()->getGameListView((*it))->onFileChanged(
ViewController::get()->getGameListView((*it))->getCursor(), false); ViewController::getInstance()->getGameListView((*it))->getCursor(),
false);
} }
} }
return true; return true;

View file

@ -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<TextComponent*> VideoGameListView::getMDLabels() std::vector<TextComponent*> VideoGameListView::getMDLabels()
{ {
@ -542,7 +545,7 @@ void VideoGameListView::update(int deltaTime)
BasicGameListView::update(deltaTime); BasicGameListView::update(deltaTime);
mVideo->update(deltaTime); mVideo->update(deltaTime);
if (ViewController::get()->getGameLaunchTriggered() && mVideo->isAnimationPlaying(0)) if (ViewController::getInstance()->getGameLaunchTriggered() && mVideo->isAnimationPlaying(0))
mVideo->finishAnimation(0); mVideo->finishAnimation(0);
} }