diff --git a/Common/UI/ViewGroup.cpp b/Common/UI/ViewGroup.cpp index 4c21baeb5e..60685b8b80 100644 --- a/Common/UI/ViewGroup.cpp +++ b/Common/UI/ViewGroup.cpp @@ -860,7 +860,7 @@ void ScrollView::PersistData(PersistStatus status, std::string anonId, PersistMa void ScrollView::SetVisibility(Visibility visibility) { ViewGroup::SetVisibility(visibility); - if (visibility == V_GONE) { + if (visibility == V_GONE && !rememberPosition_) { // Since this is no longer shown, forget the scroll position. // For example, this happens when switching tabs. ScrollTo(0.0f); diff --git a/Common/UI/ViewGroup.h b/Common/UI/ViewGroup.h index 0d17642617..7e093d775b 100644 --- a/Common/UI/ViewGroup.h +++ b/Common/UI/ViewGroup.h @@ -222,8 +222,8 @@ private: // A scrollview usually contains just a single child - a linear layout or similar. class ScrollView : public ViewGroup { public: - ScrollView(Orientation orientation, LayoutParams *layoutParams = 0) - : ViewGroup(layoutParams), orientation_(orientation) {} + ScrollView(Orientation orientation, LayoutParams *layoutParams = 0, bool rememberPosition = false) + : ViewGroup(layoutParams), orientation_(orientation), rememberPosition_(rememberPosition) {} void Measure(const UIContext &dc, MeasureSpec horiz, MeasureSpec vert) override; void Layout() override; @@ -262,6 +262,7 @@ private: float pull_ = 0.0f; float lastViewSize_ = 0.0f; bool scrollToTopOnSizeChange_ = false; + bool rememberPosition_; }; class ViewPager : public ScrollView { diff --git a/Core/Config.cpp b/Core/Config.cpp index e6e0c0adf1..62632824c9 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -450,6 +450,7 @@ static ConfigSetting generalSettings[] = { ReportedConfigSetting("EnableCheats", &g_Config.bEnableCheats, false, true, true), ConfigSetting("CwCheatRefreshRate", &g_Config.iCwCheatRefreshRate, 77, true, true), ConfigSetting("CwCheatScrollPosition", &g_Config.fCwCheatScrollPosition, 0.0f, true, true), + ConfigSetting("GameListScrollPosition", &g_Config.fGameListScrollPosition, 0.0f), ConfigSetting("ScreenshotsAsPNG", &g_Config.bScreenshotsAsPNG, false, true, true), ConfigSetting("UseFFV1", &g_Config.bUseFFV1, false), diff --git a/Core/Config.h b/Core/Config.h index e876e40227..13bce8a366 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -207,6 +207,7 @@ public: bool bReloadCheats; int iCwCheatRefreshRate; float fCwCheatScrollPosition; + float fGameListScrollPosition; int iBloomHack; //0 = off, 1 = safe, 2 = balanced, 3 = aggressive bool bBlockTransferGPU; bool bDisableSlowFramebufEffects; diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index bf7dd25107..1fd5df3f43 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -988,8 +988,8 @@ void MainScreen::CreateViews() { Button *focusButton = nullptr; if (hasStorageAccess) { - ScrollView *scrollAllGames = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT)); - scrollAllGames->SetTag("MainScreenAllGames"); + scrollAllGames_ = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT), true); + scrollAllGames_->SetTag("MainScreenAllGames"); ScrollView *scrollHomebrew = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT)); scrollHomebrew->SetTag("MainScreenHomebrew"); @@ -1000,13 +1000,14 @@ void MainScreen::CreateViews() { mm->T("How to get homebrew & demos", "How to get homebrew && demos"), "https://www.ppsspp.org/gethomebrew.html", new LinearLayoutParams(FILL_PARENT, FILL_PARENT)); - scrollAllGames->Add(tabAllGames); + scrollAllGames_->Add(tabAllGames); gameBrowsers_.push_back(tabAllGames); scrollHomebrew->Add(tabHomebrew); gameBrowsers_.push_back(tabHomebrew); - tabHolder_->AddTab(mm->T("Games"), scrollAllGames); + tabHolder_->AddTab(mm->T("Games"), scrollAllGames_); tabHolder_->AddTab(mm->T("Homebrew & Demos"), scrollHomebrew); + scrollAllGames_->ScrollTo(g_Config.fGameListScrollPosition); tabAllGames->OnChoice.Handle(this, &MainScreen::OnGameSelectedInstant); tabHomebrew->OnChoice.Handle(this, &MainScreen::OnGameSelectedInstant); @@ -1202,6 +1203,7 @@ void MainScreen::update() { RecreateViews(); lastVertical_ = vertical; } + g_Config.fGameListScrollPosition = scrollAllGames_->GetScrollPosition(); } bool MainScreen::UseVerticalLayout() const { diff --git a/UI/MainScreen.h b/UI/MainScreen.h index e1297cb8d8..f25fa3f12c 100644 --- a/UI/MainScreen.h +++ b/UI/MainScreen.h @@ -138,6 +138,7 @@ protected: bool lockBackgroundAudio_ = false; bool lastVertical_; bool confirmedTemporary_ = false; + UI::ScrollView *scrollAllGames_ = nullptr; friend class RemoteISOBrowseScreen; };