Reset tint/saturation on theme change

As requested in #18802
This commit is contained in:
Henrik Rydgård 2024-10-23 15:30:16 +02:00
parent 671ba6356b
commit abe27dcb64
3 changed files with 15 additions and 4 deletions

View File

@ -141,12 +141,12 @@ void PopupMultiChoice::ChoiceCallback(int num) {
UI::EventParams e{};
e.v = this;
e.a = num;
e.b = PostChoiceCallback(num);
OnChoice.Trigger(e);
if (restoreFocus_) {
SetFocusedView(this);
}
PostChoiceCallback(num);
}
}

View File

@ -238,7 +238,7 @@ private:
UI::EventReturn HandleClick(UI::EventParams &e);
void ChoiceCallback(int num);
virtual void PostChoiceCallback(int num) {}
virtual bool PostChoiceCallback(int num) { return true; }
I18NCat category_;
ScreenManager *screenManager_;
@ -274,9 +274,15 @@ public:
}
protected:
void PostChoiceCallback(int num) override {
if (valueStr_) {
bool PostChoiceCallback(int num) override {
if (!valueStr_) {
return true;
}
if (*valueStr_ != choices_[num]) {
*valueStr_ = choices_[num];
return true;
} else {
return false;
}
}

View File

@ -1098,6 +1098,11 @@ void GameSettingsScreen::CreateSystemSettings(UI::ViewGroup *systemSettings) {
PopupMultiChoiceDynamic *theme = systemSettings->Add(new PopupMultiChoiceDynamic(&g_Config.sThemeName, sy->T("Theme"), GetThemeInfoNames(), I18NCat::THEMES, screenManager()));
theme->OnChoice.Add([=](EventParams &e) {
UpdateTheme(screenManager()->getUIContext());
// Reset the tint/saturation if the theme changed.
if (e.b) {
g_Config.fUITint = 0.0f;
g_Config.fUISaturation = 1.0f;
}
return UI::EVENT_CONTINUE;
});