mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-07-11 01:25:07 +02:00
Fix issue with the current tab not being saved through screen recreation
This commit is contained in:
@@ -209,7 +209,10 @@ bool TabHolder::SetCurrentTab(int tab, bool skipTween) {
|
||||
tabs_[tab]->SetVisibility(V_VISIBLE);
|
||||
|
||||
currentTab_ = tab;
|
||||
|
||||
UI::EventParams e{};
|
||||
e.v = this;
|
||||
e.a = currentTab_;
|
||||
OnChangeTab.Trigger(e);
|
||||
return created;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,6 +52,8 @@ public:
|
||||
}
|
||||
bool EnsureTab(int index); // return true if it actually created a tab.
|
||||
|
||||
Event OnChangeTab;
|
||||
|
||||
private:
|
||||
void AddTabContents(std::string_view title, ImageID imageId, ViewGroup *tabContents);
|
||||
void OnTabClick(EventParams &e);
|
||||
|
||||
@@ -13,6 +13,9 @@
|
||||
#include "Common/UI/Context.h"
|
||||
#include "UI/TabbedDialogScreen.h"
|
||||
|
||||
UITabbedBaseDialogScreen::UITabbedBaseDialogScreen(const Path &gamePath, int *currentTabSetting, TabDialogFlags flags)
|
||||
: UIBaseDialogScreen(gamePath), currentTabSetting_(currentTabSetting), flags_(flags) {}
|
||||
|
||||
void UITabbedBaseDialogScreen::AddTab(const char *tag, std::string_view title, ImageID imageId, std::function<void(UI::LinearLayout *)> createCallback, TabFlags flags) {
|
||||
using namespace UI;
|
||||
|
||||
@@ -106,6 +109,12 @@ void UITabbedBaseDialogScreen::CreateViews() {
|
||||
}
|
||||
tabHolder_->EnsureTab(tabHolder_->GetCurrentTab());
|
||||
|
||||
tabHolder_->OnChangeTab.Add([this](UI::EventParams &e) {
|
||||
if (currentTabSetting_) {
|
||||
*currentTabSetting_ = e.a;
|
||||
}
|
||||
});
|
||||
|
||||
if (System_GetPropertyBool(SYSPROP_HAS_KEYBOARD) || System_GetPropertyBool(SYSPROP_HAS_TEXT_INPUT_DIALOG)) {
|
||||
// Hide search if screen is too small.
|
||||
int deviceType = System_GetPropertyInt(SYSPROP_DEVICE_TYPE);
|
||||
@@ -137,12 +146,6 @@ void UITabbedBaseDialogScreen::CreateViews() {
|
||||
}
|
||||
}
|
||||
|
||||
UITabbedBaseDialogScreen::~UITabbedBaseDialogScreen() {
|
||||
if (currentTabSetting_) {
|
||||
*currentTabSetting_ = GetCurrentTab();
|
||||
}
|
||||
}
|
||||
|
||||
void UITabbedBaseDialogScreen::sendMessage(UIMessage message, const char *value) {
|
||||
UIBaseDialogScreen::sendMessage(message, value);
|
||||
if (message == UIMessage::GAMESETTINGS_SEARCH) {
|
||||
|
||||
@@ -31,8 +31,7 @@ ENUM_CLASS_BITOPS(TabFlags);
|
||||
class UITabbedBaseDialogScreen : public UIBaseDialogScreen {
|
||||
public:
|
||||
// currentTabSetting can be null if you don't want to persist the current tab.
|
||||
UITabbedBaseDialogScreen(const Path &gamePath, int *currentTabSetting = nullptr, TabDialogFlags flags = TabDialogFlags::Default) : UIBaseDialogScreen(gamePath), currentTabSetting_(currentTabSetting), flags_(flags) {}
|
||||
~UITabbedBaseDialogScreen() override;
|
||||
UITabbedBaseDialogScreen(const Path &gamePath, int *currentTabSetting = nullptr, TabDialogFlags flags = TabDialogFlags::Default);
|
||||
void AddTab(const char *tag, std::string_view title, ImageID imageId, std::function<void(UI::LinearLayout *)> createCallback, TabFlags flags = TabFlags::Default);
|
||||
void AddTab(const char *tag, std::string_view title, std::function<void(UI::LinearLayout *)> createCallback, TabFlags flags = TabFlags::Default) {
|
||||
AddTab(tag, title, ImageID::invalid(), createCallback, flags);
|
||||
|
||||
Reference in New Issue
Block a user