From 208fa0c23bbea45d39f270f07bce45171b3f9c3b Mon Sep 17 00:00:00 2001 From: Pieter Hulshoff Date: Fri, 10 Jun 2016 13:31:39 +0200 Subject: [PATCH] Fixed remembering last selected game and playlist. --- RetroFE/Source/Graphics/Page.cpp | 14 ++++++++++---- RetroFE/Source/Graphics/Page.h | 3 ++- RetroFE/Source/RetroFE.cpp | 21 ++++++++++++++------- RetroFE/Source/RetroFE.h | 1 + 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/RetroFE/Source/Graphics/Page.cpp b/RetroFE/Source/Graphics/Page.cpp index 078e899..0d6f5e8 100644 --- a/RetroFE/Source/Graphics/Page.cpp +++ b/RetroFE/Source/Graphics/Page.cpp @@ -604,6 +604,12 @@ void Page::exitMenu() } +std::string Page::getPlaylistName() +{ + return playlist_->first; +} + + void Page::nextPlaylist() { MenuInfo_S &info = collections_.back(); @@ -625,7 +631,7 @@ void Page::nextPlaylist() playlistChange(); } -void Page::favPlaylist() +void Page::selectPlaylist(std::string playlist) { MenuInfo_S &info = collections_.back(); info.collection->Save(); @@ -641,11 +647,11 @@ void Page::favPlaylist() if(playlist_ == info.collection->playlists.end()) playlist_ = info.collection->playlists.begin(); // find the first playlist - if(playlist_->second->size() != 0 && playlist_->first == "favorites") break; + if(playlist_->second->size() != 0 && playlist_->first == playlist) break; } - // Do not change playlist if favorites does not exist or if it's empty - if ( playlist_->second->size() == 0 || playlist_->first != "favorites") + // Do not change playlist if it does not exist or if it's empty + if ( playlist_->second->size() == 0 || playlist_->first != playlist) playlist_ = playlist_store; activeMenu_->setItems(playlist_->second); diff --git a/RetroFE/Source/Graphics/Page.h b/RetroFE/Source/Graphics/Page.h index f31e322..3581ab8 100644 --- a/RetroFE/Source/Graphics/Page.h +++ b/RetroFE/Source/Graphics/Page.h @@ -49,8 +49,9 @@ public: bool popCollection(); void enterMenu(); void exitMenu(); + std::string getPlaylistName(); void nextPlaylist(); - void favPlaylist(); + void selectPlaylist(std::string playlist); void pushMenu(ScrollingList *s); bool isMenusFull(); void setLoadSound(Sound *chunk); diff --git a/RetroFE/Source/RetroFE.cpp b/RetroFE/Source/RetroFE.cpp index 6e96806..e599080 100644 --- a/RetroFE/Source/RetroFE.cpp +++ b/RetroFE/Source/RetroFE.cpp @@ -388,18 +388,24 @@ void RetroFE::run() bool rememberMenu = false; config_.getProperty("rememberMenu", rememberMenu); + bool autoFavorites = true; + config_.getProperty("autoFavorites", autoFavorites); + + if (rememberMenu && lastMenuPlaylists_.find(nextPageName) != lastMenuPlaylists_.end()) + { + currentPage_->selectPlaylist(lastMenuPlaylists_[nextPageName]); // Switch to last playlist + } + else if (autoFavorites) + { + currentPage_->selectPlaylist("favorites"); // Switch to favorites playlist + } if(rememberMenu && lastMenuOffsets_.find(nextPageName) != lastMenuOffsets_.end()) { currentPage_->setScrollOffsetIndex(lastMenuOffsets_[nextPageName]); } - bool autoFavorites = true; - config_.getProperty("autoFavorites", autoFavorites); - - if (autoFavorites) - currentPage_->favPlaylist(); // Switch to favorites if it exists - + currentPage_->resetMenuItems(); currentPage_->setNewItemSelected(); currentPage_->enterMenu(); @@ -436,7 +442,8 @@ void RetroFE::run() case RETROFE_BACK_MENU_EXIT: if(currentPage_->isIdle()) { - lastMenuOffsets_[currentPage_->getCollectionName()] = currentPage_->getScrollOffsetIndex(); + lastMenuOffsets_[currentPage_->getCollectionName()] = currentPage_->getScrollOffsetIndex(); + lastMenuPlaylists_[currentPage_->getCollectionName()] = currentPage_->getPlaylistName(); if (currentPage_->getMenuDepth() == 1) { currentPage_->DeInitialize(); diff --git a/RetroFE/Source/RetroFE.h b/RetroFE/Source/RetroFE.h index 296751f..13f3a15 100644 --- a/RetroFE/Source/RetroFE.h +++ b/RetroFE/Source/RetroFE.h @@ -93,5 +93,6 @@ private: FontCache fontcache_; AttractMode attract_; std::map lastMenuOffsets_; + std::map lastMenuPlaylists_; };