diff --git a/Common/UI/PopupScreens.cpp b/Common/UI/PopupScreens.cpp index 4be6d1467b..cd0441c149 100644 --- a/Common/UI/PopupScreens.cpp +++ b/Common/UI/PopupScreens.cpp @@ -10,17 +10,187 @@ #include "Common/Data/Text/I18n.h" #include "Common/System/System.h" #include "Common/System/Request.h" +#include "Common/System/Display.h" +#include "Common/Math/curves.h" +#include "Common/Render/DrawBuffer.h" namespace UI { +PopupScreen::PopupScreen(std::string_view title, std::string_view button1, std::string_view button2) + : title_(title) { + auto di = GetI18NCategory(I18NCat::DIALOG); + if (!button1.empty()) + button1_ = di->T(button1); + if (!button2.empty()) + button2_ = di->T(button2); + alpha_ = 0.0f; // inherited +} + +void PopupScreen::touch(const TouchInput &touch) { + if (!box_ || (touch.flags & TOUCH_DOWN) == 0) { + // Handle down-presses here. + UIDialogScreen::touch(touch); + return; + } + + // Extra bounds to avoid closing the dialog while trying to aim for something + // near the edge. Now that we only close on actual down-events, we can shrink + // this border a bit. + if (!box_->GetBounds().Expand(30.0f, 30.0f).Contains(touch.x, touch.y)) { + TriggerFinish(DR_CANCEL); + } + + UIDialogScreen::touch(touch); +} + +bool PopupScreen::key(const KeyInput &key) { + if (key.flags & KEY_DOWN) { + if ((key.keyCode == NKCODE_ENTER || key.keyCode == NKCODE_NUMPAD_ENTER) && defaultButton_) { + UI::EventParams e{}; + defaultButton_->OnClick.Trigger(e); + return true; + } + } + + return UIDialogScreen::key(key); +} + +void PopupScreen::update() { + UIDialogScreen::update(); + + if (defaultButton_) + defaultButton_->SetEnabled(CanComplete(DR_OK)); + + float animatePos = 1.0f; + + ++frames_; + if (finishFrame_ >= 0) { + float leadOut = bezierEaseInOut((frames_ - finishFrame_) * (1.0f / (float)FRAMES_LEAD_OUT)); + animatePos = 1.0f - leadOut; + + if (frames_ >= finishFrame_ + FRAMES_LEAD_OUT) { + // Actual finish happens here. + screenManager()->finishDialog(this, finishResult_); + } + } else if (frames_ < FRAMES_LEAD_IN) { + float leadIn = bezierEaseInOut(frames_ * (1.0f / (float)FRAMES_LEAD_IN)); + animatePos = leadIn; + } + + if (animatePos < 1.0f) { + alpha_ = animatePos; + scale_.x = 0.9f + animatePos * 0.1f; + scale_.y = 0.9f + animatePos * 0.1f; + + if (hasPopupOrigin_) { + float xoff = popupOrigin_.x - g_display.dp_xres / 2; + float yoff = popupOrigin_.y - g_display.dp_yres / 2; + + // Pull toward the origin a bit. + translation_.x = xoff * (1.0f - animatePos) * 0.2f; + translation_.y = yoff * (1.0f - animatePos) * 0.2f; + } else { + translation_.y = -g_display.dp_yres * (1.0f - animatePos) * 0.2f; + } + } else { + alpha_ = 1.0f; + scale_.x = 1.0f; + scale_.y = 1.0f; + translation_.x = 0.0f; + translation_.y = 0.0f; + } +} + +void PopupScreen::SetPopupOrigin(const UI::View *view) { + hasPopupOrigin_ = true; + popupOrigin_ = view->GetBounds().Center(); +} + +void PopupScreen::TriggerFinish(DialogResult result) { + if (CanComplete(result)) { + ignoreInput_ = true; + finishFrame_ = frames_; + finishResult_ = result; + + OnCompleted(result); + } + // Inform UI that popup close to hide OSK (if visible) + System_NotifyUIEvent(UIEventNotification::POPUP_CLOSED); +} + +void PopupScreen::CreateViews() { + using namespace UI; + UIContext &dc = *screenManager()->getUIContext(); + + AnchorLayout *anchor = new AnchorLayout(new LayoutParams(FILL_PARENT, FILL_PARENT)); + anchor->Overflow(false); + root_ = anchor; + + float yres = screenManager()->getUIContext()->GetBounds().h; + + AnchorLayoutParams *anchorParams; + if (!alignTop_) { + // Standard centering etc. + anchorParams = new AnchorLayoutParams(PopupWidth(), FillVertical() ? yres - 30 : WRAP_CONTENT, + dc.GetBounds().centerX(), dc.GetBounds().centerY() + offsetY_, NONE, NONE, true); + } else { + // Top-aligned, for dialogs where we need to pop a keyboard below. + anchorParams = new AnchorLayoutParams(PopupWidth(), FillVertical() ? yres - 30 : WRAP_CONTENT, + NONE, 0, NONE, NONE, false); + } + + box_ = new LinearLayout(ORIENT_VERTICAL, anchorParams); + + root_->Add(box_); + box_->SetBG(dc.GetTheme().popupStyle.background); + box_->SetHasDropShadow(hasDropShadow_); + // Since we scale a bit, make the dropshadow bleed past the edges. + box_->SetDropShadowExpand(std::max(g_display.dp_xres, g_display.dp_yres)); + box_->SetSpacing(0.0f); + + if (!title_.empty()) { + View *title = new PopupHeader(title_); + box_->Add(title); + } + + CreatePopupContents(box_); + root_->Recurse([](View *view) { + view->SetPopupStyle(true); + }); + + root_->SetDefaultFocusView(box_); + if (ShowButtons() && !button1_.empty()) { + // And the two buttons at the bottom. + LinearLayout *buttonRow = new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(200, WRAP_CONTENT)); + buttonRow->SetSpacing(0); + Margins buttonMargins(5, 5); + + // Adjust button order to the platform default. + if (System_GetPropertyBool(SYSPROP_OK_BUTTON_LEFT)) { + defaultButton_ = buttonRow->Add(new Button(button1_, new LinearLayoutParams(1.0f, buttonMargins))); + defaultButton_->OnClick.Handle(this, &UIScreen::OnOK); + if (!button2_.empty()) + buttonRow->Add(new Button(button2_, new LinearLayoutParams(1.0f, buttonMargins)))->OnClick.Handle(this, &UIScreen::OnCancel); + } else { + if (!button2_.empty()) + buttonRow->Add(new Button(button2_, new LinearLayoutParams(1.0f)))->OnClick.Handle(this, &UIScreen::OnCancel); + defaultButton_ = buttonRow->Add(new Button(button1_, new LinearLayoutParams(1.0f))); + defaultButton_->OnClick.Handle(this, &UIScreen::OnOK); + } + + box_->Add(buttonRow); + } +} + void MessagePopupScreen::CreatePopupContents(UI::ViewGroup *parent) { using namespace UI; UIContext &dc = *screenManager()->getUIContext(); std::vector messageLines; SplitString(message_, '\n', messageLines); - for (auto lineOfText : messageLines) - parent->Add(new UI::TextView(lineOfText, ALIGN_LEFT | ALIGN_VCENTER, false)); + for (auto lineOfText : messageLines) { + parent->Add(new UI::TextView(lineOfText, ALIGN_LEFT | ALIGN_VCENTER | FLAG_WRAP_TEXT, false, new LinearLayoutParams(Margins(8)))); + } } void MessagePopupScreen::OnCompleted(DialogResult result) { diff --git a/Common/UI/PopupScreens.h b/Common/UI/PopupScreens.h index b93ff85f8e..fd5a05fc42 100644 --- a/Common/UI/PopupScreens.h +++ b/Common/UI/PopupScreens.h @@ -16,6 +16,61 @@ namespace UI { static const float NO_DEFAULT_FLOAT = -1000000.0f; static const int NO_DEFAULT_INT = -1000000; +class PopupScreen : public UIDialogScreen { +public: + PopupScreen(std::string_view title, std::string_view button1 = "", std::string_view button2 = ""); + + virtual void CreatePopupContents(UI::ViewGroup *parent) = 0; + void CreateViews() override; + bool isTransparent() const override { return true; } + void touch(const TouchInput &touch) override; + bool key(const KeyInput &key) override; + + void TriggerFinish(DialogResult result) override; + + void SetPopupOrigin(const UI::View *view); + void SetPopupOffset(float y) { offsetY_ = y; } + + void SetAlignTop(bool alignTop) { alignTop_ = alignTop; } + + void SetHasDropShadow(bool has) { hasDropShadow_ = has; } + + // For the postproc param sliders on DisplayLayoutScreen + bool wantBrightBackground() const override { return !hasDropShadow_; } + +protected: + virtual bool FillVertical() const { return false; } + virtual UI::Size PopupWidth() const { return 550; } + virtual bool ShowButtons() const { return true; } + virtual bool CanComplete(DialogResult result) { return true; } + virtual void OnCompleted(DialogResult result) {} + std::string_view Title() { return title_; } + + void update() override; + +private: + UI::LinearLayout *box_ = nullptr; + UI::Button *defaultButton_ = nullptr; + std::string title_; + std::string button1_; + std::string button2_; + + enum { + FRAMES_LEAD_IN = 6, + FRAMES_LEAD_OUT = 4, + }; + + int frames_ = 0; + int finishFrame_ = -1; + DialogResult finishResult_ = DR_CANCEL; + bool hasPopupOrigin_ = false; + Point2D popupOrigin_; + float offsetY_ = 0.0f; + bool alignTop_ = false; + + bool hasDropShadow_ = true; +}; + class ListPopupScreen : public PopupScreen { public: ListPopupScreen(std::string_view title) : PopupScreen(title) {} @@ -60,7 +115,7 @@ private: class MessagePopupScreen : public PopupScreen { public: - MessagePopupScreen(std::string_view title, std::string message, std::string button1, std::string button2, std::function callback) + MessagePopupScreen(std::string_view title, std::string_view message, std::string_view button1, std::string_view button2, std::function callback) : PopupScreen(title, button1, button2), message_(message), callback_(callback) {} const char *tag() const override { return "MessagePopupScreen"; } @@ -195,9 +250,6 @@ public: UI::Event OnChoice; -protected: - bool HasTitleBar() const override { return false; } - private: const ContextMenuItem *items_; size_t itemCount_; diff --git a/Common/UI/UIScreen.cpp b/Common/UI/UIScreen.cpp index c5e299708e..be5eec16fe 100644 --- a/Common/UI/UIScreen.cpp +++ b/Common/UI/UIScreen.cpp @@ -6,12 +6,10 @@ #include "Common/System/Request.h" #include "Common/Input/InputState.h" #include "Common/Input/KeyCodes.h" -#include "Common/Math/curves.h" #include "Common/UI/UIScreen.h" #include "Common/UI/Context.h" #include "Common/UI/Screen.h" #include "Common/UI/Root.h" -#include "Common/Data/Text/I18n.h" #include "Common/Render/DrawBuffer.h" static const bool ClickDebug = false; @@ -300,169 +298,3 @@ void UIScreen::OnOK(UI::EventParams &e) { void UIScreen::OnCancel(UI::EventParams &e) { TriggerFinish(DR_CANCEL); } - -PopupScreen::PopupScreen(std::string_view title, std::string_view button1, std::string_view button2) - : title_(title) { - auto di = GetI18NCategory(I18NCat::DIALOG); - if (!button1.empty()) - button1_ = di->T(button1); - if (!button2.empty()) - button2_ = di->T(button2); - alpha_ = 0.0f; // inherited -} - -void PopupScreen::touch(const TouchInput &touch) { - if (!box_ || (touch.flags & TOUCH_DOWN) == 0) { - // Handle down-presses here. - UIDialogScreen::touch(touch); - return; - } - - // Extra bounds to avoid closing the dialog while trying to aim for something - // near the edge. Now that we only close on actual down-events, we can shrink - // this border a bit. - if (!box_->GetBounds().Expand(30.0f, 30.0f).Contains(touch.x, touch.y)) { - TriggerFinish(DR_CANCEL); - } - - UIDialogScreen::touch(touch); -} - -bool PopupScreen::key(const KeyInput &key) { - if (key.flags & KEY_DOWN) { - if ((key.keyCode == NKCODE_ENTER || key.keyCode == NKCODE_NUMPAD_ENTER) && defaultButton_) { - UI::EventParams e{}; - defaultButton_->OnClick.Trigger(e); - return true; - } - } - - return UIDialogScreen::key(key); -} - -void PopupScreen::update() { - UIDialogScreen::update(); - - if (defaultButton_) - defaultButton_->SetEnabled(CanComplete(DR_OK)); - - float animatePos = 1.0f; - - ++frames_; - if (finishFrame_ >= 0) { - float leadOut = bezierEaseInOut((frames_ - finishFrame_) * (1.0f / (float)FRAMES_LEAD_OUT)); - animatePos = 1.0f - leadOut; - - if (frames_ >= finishFrame_ + FRAMES_LEAD_OUT) { - // Actual finish happens here. - screenManager()->finishDialog(this, finishResult_); - } - } else if (frames_ < FRAMES_LEAD_IN) { - float leadIn = bezierEaseInOut(frames_ * (1.0f / (float)FRAMES_LEAD_IN)); - animatePos = leadIn; - } - - if (animatePos < 1.0f) { - alpha_ = animatePos; - scale_.x = 0.9f + animatePos * 0.1f; - scale_.y = 0.9f + animatePos * 0.1f; - - if (hasPopupOrigin_) { - float xoff = popupOrigin_.x - g_display.dp_xres / 2; - float yoff = popupOrigin_.y - g_display.dp_yres / 2; - - // Pull toward the origin a bit. - translation_.x = xoff * (1.0f - animatePos) * 0.2f; - translation_.y = yoff * (1.0f - animatePos) * 0.2f; - } else { - translation_.y = -g_display.dp_yres * (1.0f - animatePos) * 0.2f; - } - } else { - alpha_ = 1.0f; - scale_.x = 1.0f; - scale_.y = 1.0f; - translation_.x = 0.0f; - translation_.y = 0.0f; - } -} - -void PopupScreen::SetPopupOrigin(const UI::View *view) { - hasPopupOrigin_ = true; - popupOrigin_ = view->GetBounds().Center(); -} - -void PopupScreen::TriggerFinish(DialogResult result) { - if (CanComplete(result)) { - ignoreInput_ = true; - finishFrame_ = frames_; - finishResult_ = result; - - OnCompleted(result); - } - // Inform UI that popup close to hide OSK (if visible) - System_NotifyUIEvent(UIEventNotification::POPUP_CLOSED); -} - -void PopupScreen::CreateViews() { - using namespace UI; - UIContext &dc = *screenManager()->getUIContext(); - - AnchorLayout *anchor = new AnchorLayout(new LayoutParams(FILL_PARENT, FILL_PARENT)); - anchor->Overflow(false); - root_ = anchor; - - float yres = screenManager()->getUIContext()->GetBounds().h; - - AnchorLayoutParams *anchorParams; - if (!alignTop_) { - // Standard centering etc. - anchorParams = new AnchorLayoutParams(PopupWidth(), FillVertical() ? yres - 30 : WRAP_CONTENT, - dc.GetBounds().centerX(), dc.GetBounds().centerY() + offsetY_, NONE, NONE, true); - } else { - // Top-aligned, for dialogs where we need to pop a keyboard below. - anchorParams = new AnchorLayoutParams(PopupWidth(), FillVertical() ? yres - 30 : WRAP_CONTENT, - NONE, 0, NONE, NONE, false); - } - - box_ = new LinearLayout(ORIENT_VERTICAL, anchorParams); - - root_->Add(box_); - box_->SetBG(dc.GetTheme().popupStyle.background); - box_->SetHasDropShadow(hasDropShadow_); - // Since we scale a bit, make the dropshadow bleed past the edges. - box_->SetDropShadowExpand(std::max(g_display.dp_xres, g_display.dp_yres)); - box_->SetSpacing(0.0f); - - if (HasTitleBar()) { - View *title = new PopupHeader(title_); - box_->Add(title); - } - - CreatePopupContents(box_); - root_->Recurse([](View *view) { - view->SetPopupStyle(true); - }); - - root_->SetDefaultFocusView(box_); - if (ShowButtons() && !button1_.empty()) { - // And the two buttons at the bottom. - LinearLayout *buttonRow = new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(200, WRAP_CONTENT)); - buttonRow->SetSpacing(0); - Margins buttonMargins(5, 5); - - // Adjust button order to the platform default. - if (System_GetPropertyBool(SYSPROP_OK_BUTTON_LEFT)) { - defaultButton_ = buttonRow->Add(new Button(button1_, new LinearLayoutParams(1.0f, buttonMargins))); - defaultButton_->OnClick.Handle(this, &UIScreen::OnOK); - if (!button2_.empty()) - buttonRow->Add(new Button(button2_, new LinearLayoutParams(1.0f, buttonMargins)))->OnClick.Handle(this, &UIScreen::OnCancel); - } else { - if (!button2_.empty()) - buttonRow->Add(new Button(button2_, new LinearLayoutParams(1.0f)))->OnClick.Handle(this, &UIScreen::OnCancel); - defaultButton_ = buttonRow->Add(new Button(button1_, new LinearLayoutParams(1.0f))); - defaultButton_->OnClick.Handle(this, &UIScreen::OnOK); - } - - box_->Add(buttonRow); - } -} diff --git a/Common/UI/UIScreen.h b/Common/UI/UIScreen.h index 5fc9dea39e..c6b55cc679 100644 --- a/Common/UI/UIScreen.h +++ b/Common/UI/UIScreen.h @@ -97,59 +97,3 @@ public: private: bool finished_; }; - -class PopupScreen : public UIDialogScreen { -public: - PopupScreen(std::string_view title, std::string_view button1 = "", std::string_view button2 = ""); - - virtual void CreatePopupContents(UI::ViewGroup *parent) = 0; - void CreateViews() override; - bool isTransparent() const override { return true; } - void touch(const TouchInput &touch) override; - bool key(const KeyInput &key) override; - - void TriggerFinish(DialogResult result) override; - - void SetPopupOrigin(const UI::View *view); - void SetPopupOffset(float y) { offsetY_ = y; } - - void SetAlignTop(bool alignTop) { alignTop_ = alignTop; } - - void SetHasDropShadow(bool has) { hasDropShadow_ = has; } - - // For the postproc param sliders on DisplayLayoutScreen - bool wantBrightBackground() const override { return !hasDropShadow_; } - -protected: - virtual bool FillVertical() const { return false; } - virtual UI::Size PopupWidth() const { return 550; } - virtual bool ShowButtons() const { return true; } - virtual bool CanComplete(DialogResult result) { return true; } - virtual void OnCompleted(DialogResult result) {} - virtual bool HasTitleBar() const { return true; } - const std::string &Title() { return title_; } - - void update() override; - -private: - UI::LinearLayout *box_ = nullptr; - UI::Button *defaultButton_ = nullptr; - std::string title_; - std::string button1_; - std::string button2_; - - enum { - FRAMES_LEAD_IN = 6, - FRAMES_LEAD_OUT = 4, - }; - - int frames_ = 0; - int finishFrame_ = -1; - DialogResult finishResult_ = DR_CANCEL; - bool hasPopupOrigin_ = false; - Point2D popupOrigin_; - float offsetY_ = 0.0f; - bool alignTop_ = false; - - bool hasDropShadow_ = true; -}; diff --git a/UI/ControlMappingScreen.h b/UI/ControlMappingScreen.h index 18760ef1a7..43bb825085 100644 --- a/UI/ControlMappingScreen.h +++ b/UI/ControlMappingScreen.h @@ -26,6 +26,7 @@ #include "Common/UI/View.h" #include "Common/UI/UIScreen.h" +#include "Common/UI/PopupScreens.h" #include "Common/Data/Text/I18n.h" #include "Core/ControlMapper.h" @@ -64,7 +65,7 @@ private: bool categoryToggles_[10]{}; }; -class KeyMappingNewKeyDialog : public PopupScreen { +class KeyMappingNewKeyDialog : public UI::PopupScreen { public: explicit KeyMappingNewKeyDialog(int btn, bool replace, std::function callback, I18NCat i18n) : PopupScreen(T(i18n, "Map Key"), "Cancel", ""), pspBtn_(btn), callback_(callback) {} @@ -97,7 +98,7 @@ private: double delayUntil_ = 0.0f; }; -class KeyMappingNewMouseKeyDialog : public PopupScreen { +class KeyMappingNewMouseKeyDialog : public UI::PopupScreen { public: KeyMappingNewMouseKeyDialog(int btn, bool replace, std::function callback, I18NCat i18n) : PopupScreen(T(i18n, "Map Mouse"), "", ""), callback_(callback) {} diff --git a/UI/CustomButtonMappingScreen.cpp b/UI/CustomButtonMappingScreen.cpp index 4456a00831..5fa114bdf4 100644 --- a/UI/CustomButtonMappingScreen.cpp +++ b/UI/CustomButtonMappingScreen.cpp @@ -22,6 +22,7 @@ #include "Common/UI/View.h" #include "Common/UI/ViewGroup.h" #include "Common/UI/ScrollView.h" +#include "Common/UI/PopupScreens.h" #include "Common/Data/Text/I18n.h" #include "Common/Data/Color/RGBAUtil.h" @@ -32,7 +33,7 @@ #include "UI/CustomButtonMappingScreen.h" -class ButtonShapeScreen : public PopupScreen { +class ButtonShapeScreen : public UI::PopupScreen { public: ButtonShapeScreen(std::string_view title, int *setting) : PopupScreen(title), setting_(setting) {} @@ -61,7 +62,7 @@ private: int *setting_; }; -class ButtonIconScreen : public PopupScreen { +class ButtonIconScreen : public UI::PopupScreen { public: ButtonIconScreen(std::string_view title, int *setting) : PopupScreen(title), setting_(setting) {} diff --git a/UI/DevScreens.h b/UI/DevScreens.h index 9bc256dcad..026e86ce85 100644 --- a/UI/DevScreens.h +++ b/UI/DevScreens.h @@ -29,7 +29,7 @@ #include "UI/PopupScreens.h" #include "GPU/Common/ShaderCommon.h" -class DevMenuScreen : public PopupScreen { +class DevMenuScreen : public UI::PopupScreen { public: DevMenuScreen(const Path &gamePath, I18NCat cat) : PopupScreen(T(cat, "Dev Tools")), gamePath_(gamePath) {} @@ -100,7 +100,7 @@ private: void OnCompleted(DialogResult result) override; }; -class GPIGPOScreen : public PopupScreen { +class GPIGPOScreen : public UI::PopupScreen { public: GPIGPOScreen(std::string_view title) : PopupScreen(title, "OK") {} const char *tag() const override { return "GPIGPO"; } diff --git a/UI/GameScreen.cpp b/UI/GameScreen.cpp index 49cb3b9ce7..9fd0d1ad63 100644 --- a/UI/GameScreen.cpp +++ b/UI/GameScreen.cpp @@ -23,7 +23,7 @@ #include "Common/UI/Context.h" #include "Common/UI/View.h" #include "Common/UI/ViewGroup.h" - +#include "Common/UI/PopupScreens.h" #include "Common/Data/Text/I18n.h" #include "Common/Data/Text/Parsers.h" #include "Common/Data/Encoding/Utf8.h" @@ -526,7 +526,7 @@ void GameScreen::OnRemoveFromRecent(UI::EventParams &e) { screenManager()->switchScreen(new MainScreen()); } -class SetBackgroundPopupScreen : public PopupScreen { +class SetBackgroundPopupScreen : public UI::PopupScreen { public: SetBackgroundPopupScreen(std::string_view title, const Path &gamePath) : PopupScreen(title), gamePath_(gamePath) { diff --git a/UI/GameSettingsScreen.h b/UI/GameSettingsScreen.h index 8f41c59ce9..63e9c7683d 100644 --- a/UI/GameSettingsScreen.h +++ b/UI/GameSettingsScreen.h @@ -122,10 +122,10 @@ private: std::string pendingMemstickFolder_; }; -class HostnameSelectScreen : public PopupScreen { +class HostnameSelectScreen : public UI::PopupScreen { public: HostnameSelectScreen(std::string *value, std::vector *listItems, std::string_view title) - : PopupScreen(title, "OK", "Cancel"), listItems_(listItems), value_(value) { + : UI::PopupScreen(title, "OK", "Cancel"), listItems_(listItems), value_(value) { resolver_ = std::thread([](HostnameSelectScreen *thiz) { thiz->ResolverThread(); }, this); @@ -194,7 +194,7 @@ protected: void CreateGestureTab(UI::LinearLayout *parent); }; -class RestoreSettingsScreen : public PopupScreen { +class RestoreSettingsScreen : public UI::PopupScreen { public: RestoreSettingsScreen(std::string_view title); void CreatePopupContents(UI::ViewGroup *parent) override; diff --git a/UI/IAPScreen.h b/UI/IAPScreen.h index 51dd91a740..831a8a9962 100644 --- a/UI/IAPScreen.h +++ b/UI/IAPScreen.h @@ -5,6 +5,7 @@ #include "ppsspp_config.h" #include "UI/BaseScreens.h" +#include "UI/SimpleDialogScreen.h" class IAPScreen : public UIBaseDialogScreen { public: diff --git a/UI/JitCompareScreen.h b/UI/JitCompareScreen.h index 189f47426f..a93d57184e 100644 --- a/UI/JitCompareScreen.h +++ b/UI/JitCompareScreen.h @@ -1,5 +1,6 @@ #pragma once #include "Common/UI/UIScreen.h" +#include "Common/UI/PopupScreens.h" #include "UI/BaseScreens.h" #include "UI/TabbedDialogScreen.h" @@ -57,7 +58,7 @@ private: UI::TextView *globalStats_ = nullptr; }; -class AddressPromptScreen : public PopupScreen { +class AddressPromptScreen : public UI::PopupScreen { public: AddressPromptScreen(std::string_view title) : PopupScreen(title, "OK", "Cancel") {} diff --git a/UI/MainScreen.h b/UI/MainScreen.h index ff199aec91..5c9a694ee6 100644 --- a/UI/MainScreen.h +++ b/UI/MainScreen.h @@ -24,6 +24,7 @@ #include "Common/UI/UIScreen.h" #include "Common/UI/ViewGroup.h" #include "Common/UI/TabHolder.h" +#include "Common/UI/PopupScreens.h" #include "UI/BaseScreens.h" #include "Common/File/PathBrowser.h" @@ -193,7 +194,7 @@ private: void OnGameSettings(UI::EventParams &e); }; -class GridSettingsPopupScreen : public PopupScreen { +class GridSettingsPopupScreen : public UI::PopupScreen { public: GridSettingsPopupScreen(std::string_view label) : PopupScreen(label) {} void CreatePopupContents(UI::ViewGroup *parent) override; diff --git a/UI/PauseScreen.cpp b/UI/PauseScreen.cpp index 40ab3d73d0..db2f4463bc 100644 --- a/UI/PauseScreen.cpp +++ b/UI/PauseScreen.cpp @@ -23,6 +23,7 @@ #include "Common/UI/ViewGroup.h" #include "Common/UI/Context.h" #include "Common/UI/UIScreen.h" +#include "Common/UI/PopupScreens.h" #include "Common/GPU/thin3d.h" #include "Common/Data/Text/I18n.h" @@ -32,6 +33,7 @@ #include "Common/System/Request.h" #include "Common/VR/PPSSPPVR.h" #include "Common/UI/AsyncImageFileView.h" +#include "Common/UI/PopupScreens.h" #include "Core/KeyMap.h" #include "Core/Reporting.h" @@ -72,7 +74,7 @@ static void AfterSaveStateAction(SaveState::Status status, std::string_view mess } } -class ScreenshotViewScreen : public PopupScreen { +class ScreenshotViewScreen : public UI::PopupScreen { public: ScreenshotViewScreen(const Path &filename, std::string title, int slot, Path gamePath) : PopupScreen(title), filename_(filename), slot_(slot), gamePath_(gamePath), title_(title) {} // PopupScreen will translate Back on its own @@ -748,18 +750,6 @@ void GamePauseScreen::OnLastSaveUndo(UI::EventParams &e) { RecreateViews(); } -void GamePauseScreen::CallbackDeleteConfig(bool yes) { - if (yes) { - std::shared_ptr info = g_gameInfoCache->GetInfo(NULL, gamePath_, GameInfoFlags::PARAM_SFO); - if (info->Ready(GameInfoFlags::PARAM_SFO)) { - g_Config.UnloadGameConfig(); - g_Config.DeleteGameConfig(info->id); - info->hasConfig = false; - screenManager()->RecreateAllViews(); - } - } -} - void GamePauseScreen::OnCreateConfig(UI::EventParams &e) { std::shared_ptr info = g_gameInfoCache->GetInfo(NULL, gamePath_, GameInfoFlags::PARAM_SFO); if (info->Ready(GameInfoFlags::PARAM_SFO)) { @@ -777,6 +767,17 @@ void GamePauseScreen::OnCreateConfig(UI::EventParams &e) { void GamePauseScreen::OnDeleteConfig(UI::EventParams &e) { auto di = GetI18NCategory(I18NCat::DIALOG); screenManager()->push( - new PromptScreen(gamePath_, di->T("DeleteConfirmGameConfig", "Do you really want to delete the settings for this game?"), di->T("Delete"), di->T("Cancel"), - std::bind(&GamePauseScreen::CallbackDeleteConfig, this, std::placeholders::_1))); + new UI::MessagePopupScreen("", di->T("DeleteConfirmGameConfig", "Do you really want to delete the settings for this game?"), + di->T("Delete"), di->T("Cancel"), [this](bool yes) { + if (!yes) { + return; + } + std::shared_ptr info = g_gameInfoCache->GetInfo(NULL, gamePath_, GameInfoFlags::PARAM_SFO); + if (info->Ready(GameInfoFlags::PARAM_SFO)) { + g_Config.UnloadGameConfig(); + g_Config.DeleteGameConfig(info->id); + info->hasConfig = false; + screenManager()->RecreateAllViews(); + } + })); } diff --git a/UI/PauseScreen.h b/UI/PauseScreen.h index 9cd3b7e66f..4f091a2e3d 100644 --- a/UI/PauseScreen.h +++ b/UI/PauseScreen.h @@ -39,7 +39,6 @@ public: protected: void CreateViews() override; void update() override; - void CallbackDeleteConfig(bool yes); UI::Margins RootMargins() const override; private: diff --git a/UI/SavedataScreen.cpp b/UI/SavedataScreen.cpp index f0a5970b28..033223027f 100644 --- a/UI/SavedataScreen.cpp +++ b/UI/SavedataScreen.cpp @@ -28,6 +28,7 @@ #include "Common/System/Request.h" #include "Common/UI/Context.h" #include "Common/UI/View.h" +#include "Common/UI/PopupScreens.h" #include "Common/UI/ViewGroup.h" #include "Common/UI/AsyncImageFileView.h" #include "UI/SavedataScreen.h" @@ -130,7 +131,7 @@ SavedataView::SavedataView(UIContext &dc, GameInfo *ginfo, IdentifiedFileType ty } } -class SavedataPopupScreen : public PopupScreen { +class SavedataPopupScreen : public UI::PopupScreen { public: SavedataPopupScreen(Path gamePath, Path savePath, std::string_view title) : PopupScreen(StripSpaces(title)), savePath_(savePath), gamePath_(gamePath) { } diff --git a/Windows/main.cpp b/Windows/main.cpp index ec2ce66450..d9ab4c470a 100644 --- a/Windows/main.cpp +++ b/Windows/main.cpp @@ -447,6 +447,8 @@ bool System_GetPropertyBool(SystemProperty prop) { #endif case SYSPROP_HAS_ACCELEROMETER: return g_InputManager.AnyAccelerometer(); + case SYSPROP_USE_IAP: + return true; default: return false; }