From 2b9f2672bb46335179834dc7fab2bf68a5d667ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 29 Oct 2025 00:15:41 +0100 Subject: [PATCH] UI screens header cleanup --- UI/Background.h | 2 + UI/ControlMappingScreen.cpp | 1 + UI/ControlMappingScreen.h | 2 +- UI/CustomButtonMappingScreen.cpp | 1 + UI/CustomButtonMappingScreen.h | 2 +- UI/CwCheatScreen.cpp | 1 + UI/CwCheatScreen.h | 2 +- UI/DevScreens.cpp | 3 +- UI/DevScreens.h | 3 +- UI/DisplayLayoutScreen.cpp | 1 + UI/DisplayLayoutScreen.h | 4 +- UI/DriverManagerScreen.cpp | 4 ++ UI/DriverManagerScreen.h | 2 +- UI/EmuScreen.cpp | 3 +- UI/GPUDriverTestScreen.h | 2 +- UI/GameScreen.cpp | 1 + UI/GameScreen.h | 2 +- UI/GameSettingsScreen.cpp | 2 +- UI/GameSettingsScreen.h | 3 +- UI/IAPScreen.cpp | 8 ++-- UI/IAPScreen.h | 2 +- UI/InstallZipScreen.h | 2 +- UI/JitCompareScreen.cpp | 5 ++- UI/JitCompareScreen.h | 2 +- UI/MainScreen.cpp | 2 +- UI/MainScreen.h | 2 +- UI/MemStickScreen.cpp | 3 +- UI/MemStickScreen.h | 3 +- UI/MiscScreens.cpp | 65 ---------------------------- UI/MiscScreens.h | 27 ------------ UI/MiscViews.cpp | 67 +++++++++++++++++++++++++++++ UI/MiscViews.h | 25 +++++++++++ UI/NativeApp.cpp | 1 + UI/PauseScreen.h | 2 +- UI/RemoteISOScreen.cpp | 1 + UI/RemoteISOScreen.h | 2 +- UI/ReportScreen.cpp | 6 +-- UI/ReportScreen.h | 2 +- UI/RetroAchievementScreens.cpp | 3 +- UI/RetroAchievementScreens.h | 2 +- UI/SavedataScreen.cpp | 2 +- UI/SavedataScreen.h | 2 +- UI/Store.cpp | 1 + UI/Store.h | 2 +- UI/SystemInfoScreen.cpp | 3 +- UI/TabbedDialogScreen.cpp | 6 +++ UI/TabbedDialogScreen.h | 4 +- UI/TiltAnalogSettingsScreen.cpp | 2 + UI/TiltAnalogSettingsScreen.h | 2 +- UI/TouchControlLayoutScreen.cpp | 1 + UI/TouchControlLayoutScreen.h | 2 +- UI/TouchControlVisibilityScreen.cpp | 3 +- UI/TouchControlVisibilityScreen.h | 4 +- UI/UploadScreen.cpp | 1 + UI/UploadScreen.h | 2 +- 55 files changed, 176 insertions(+), 134 deletions(-) diff --git a/UI/Background.h b/UI/Background.h index ab4c19259b..db4805f3ba 100644 --- a/UI/Background.h +++ b/UI/Background.h @@ -10,3 +10,5 @@ void UIBackgroundInit(UIContext &dc); void UIBackgroundShutdown(); void DrawGameBackground(UIContext &dc, const Path &gamePath, float x, float y, float z); void DrawBackground(UIContext &dc, float alpha, float x, float y, float z); + +uint32_t GetBackgroundColorWithAlpha(const UIContext &dc); diff --git a/UI/ControlMappingScreen.cpp b/UI/ControlMappingScreen.cpp index ae96df6b2e..e8febfa471 100644 --- a/UI/ControlMappingScreen.cpp +++ b/UI/ControlMappingScreen.cpp @@ -44,6 +44,7 @@ #include "Core/System.h" #include "Core/Config.h" #include "UI/ControlMappingScreen.h" +#include "UI/PopupScreens.h" #include "UI/GameSettingsScreen.h" #include "UI/JoystickHistoryView.h" #include "UI/OnScreenDisplay.h" diff --git a/UI/ControlMappingScreen.h b/UI/ControlMappingScreen.h index d26d093c8f..9ab95fe23f 100644 --- a/UI/ControlMappingScreen.h +++ b/UI/ControlMappingScreen.h @@ -30,7 +30,7 @@ #include "Core/ControlMapper.h" -#include "UI/MiscScreens.h" +#include "UI/BaseScreens.h" class SingleControlMapper; diff --git a/UI/CustomButtonMappingScreen.cpp b/UI/CustomButtonMappingScreen.cpp index 9481c83b11..8039a7badb 100644 --- a/UI/CustomButtonMappingScreen.cpp +++ b/UI/CustomButtonMappingScreen.cpp @@ -21,6 +21,7 @@ #include "Common/UI/Context.h" #include "Common/UI/View.h" #include "Common/UI/ViewGroup.h" +#include "Common/UI/ScrollView.h" #include "Common/Data/Text/I18n.h" #include "Common/Data/Color/RGBAUtil.h" diff --git a/UI/CustomButtonMappingScreen.h b/UI/CustomButtonMappingScreen.h index 5270cfaeaf..56b6996111 100644 --- a/UI/CustomButtonMappingScreen.h +++ b/UI/CustomButtonMappingScreen.h @@ -17,7 +17,7 @@ #pragma once -#include "MiscScreens.h" +#include "UI/BaseScreens.h" #include "UI/GamepadEmu.h" namespace UI { diff --git a/UI/CwCheatScreen.cpp b/UI/CwCheatScreen.cpp index ba35817036..060c6d3cb9 100644 --- a/UI/CwCheatScreen.cpp +++ b/UI/CwCheatScreen.cpp @@ -25,6 +25,7 @@ #include "Common/StringUtils.h" #include "Common/System/System.h" #include "Common/System/Request.h" +#include "Common/UI/PopupScreens.h" #include "Core/System.h" #include "Core/Config.h" #include "Core/CwCheat.h" diff --git a/UI/CwCheatScreen.h b/UI/CwCheatScreen.h index 4106fe8dd8..4e1f0a98ed 100644 --- a/UI/CwCheatScreen.h +++ b/UI/CwCheatScreen.h @@ -23,7 +23,7 @@ #include "Common/UI/View.h" #include "Common/UI/UIScreen.h" #include "Common/UI/Context.h" -#include "UI/MiscScreens.h" +#include "UI/BaseScreens.h" struct CheatFileInfo; class CWCheatEngine; diff --git a/UI/DevScreens.cpp b/UI/DevScreens.cpp index 6ac21ce4f4..5a47e977d5 100644 --- a/UI/DevScreens.cpp +++ b/UI/DevScreens.cpp @@ -38,6 +38,7 @@ #include "Common/Data/Encoding/Utf8.h" #include "Common/Net/HTTPClient.h" #include "Common/UI/Context.h" +#include "Common/UI/PopupScreens.h" #include "Common/UI/View.h" #include "Common/UI/ViewGroup.h" #include "Common/UI/UI.h" @@ -65,7 +66,7 @@ #include "GPU/Debugger/Record.h" #include "GPU/GPUCommon.h" #include "GPU/GPUState.h" -#include "UI/MiscScreens.h" +#include "UI/BaseScreens.h" #include "UI/DevScreens.h" #include "UI/MainScreen.h" #include "UI/EmuScreen.h" diff --git a/UI/DevScreens.h b/UI/DevScreens.h index d63f2dde1e..a3fdf6a2ff 100644 --- a/UI/DevScreens.h +++ b/UI/DevScreens.h @@ -25,7 +25,8 @@ #include "Common/Net/HTTPClient.h" #include "Common/UI/UIScreen.h" #include "UI/TabbedDialogScreen.h" -#include "UI/MiscScreens.h" +#include "UI/BaseScreens.h" +#include "UI/PopupScreens.h" #include "GPU/Common/ShaderCommon.h" class DevMenuScreen : public PopupScreen { diff --git a/UI/DisplayLayoutScreen.cpp b/UI/DisplayLayoutScreen.cpp index a1182bfe49..9ce8cd08cd 100644 --- a/UI/DisplayLayoutScreen.cpp +++ b/UI/DisplayLayoutScreen.cpp @@ -33,6 +33,7 @@ #include "Common/Data/Color/RGBAUtil.h" #include "Common/Data/Text/I18n.h" #include "UI/DisplayLayoutScreen.h" +#include "UI/Background.h" #include "Core/Config.h" #include "Core/ConfigValues.h" #include "Core/System.h" diff --git a/UI/DisplayLayoutScreen.h b/UI/DisplayLayoutScreen.h index 8290c45456..ac9b07e8c5 100644 --- a/UI/DisplayLayoutScreen.h +++ b/UI/DisplayLayoutScreen.h @@ -21,9 +21,9 @@ #include "Common/UI/View.h" #include "Common/UI/ViewGroup.h" +#include "Common/UI/PopupScreens.h" #include "GPU/Common/PostShader.h" - -#include "MiscScreens.h" +#include "UI/MiscScreens.h" namespace UI { class ChoiceStrip; diff --git a/UI/DriverManagerScreen.cpp b/UI/DriverManagerScreen.cpp index de9c9ad06d..fd1209b876 100644 --- a/UI/DriverManagerScreen.cpp +++ b/UI/DriverManagerScreen.cpp @@ -1,8 +1,11 @@ #include "Common/File/VFS/ZipFileReader.h" #include "Common/Data/Format/JSONReader.h" +#include "Common/Data/Text/I18n.h" +#include "Common/System/Request.h" #include "Common/System/OSD.h" #include "Common/Log.h" #include "Common/StringUtils.h" +#include "Common/UI/PopupScreens.h" #include "Core/Config.h" #include "Core/System.h" @@ -11,6 +14,7 @@ #include "UI/DriverManagerScreen.h" #include "UI/GameSettingsScreen.h" // for triggerrestart #include "UI/OnScreenDisplay.h" +#include "UI/MiscScreens.h" static Path GetDriverPath() { if (g_Config.internalDataDirectory.empty()) { diff --git a/UI/DriverManagerScreen.h b/UI/DriverManagerScreen.h index 8a9fff68cc..42e666be16 100644 --- a/UI/DriverManagerScreen.h +++ b/UI/DriverManagerScreen.h @@ -3,7 +3,7 @@ #include "ppsspp_config.h" #include "Common/UI/UIScreen.h" -#include "UI/MiscScreens.h" +#include "UI/BaseScreens.h" #include "UI/TabbedDialogScreen.h" // Per-game settings screen - enables you to configure graphic options, control options, etc diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index 2880ef7c5d..e691364e64 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -84,10 +84,11 @@ using namespace std::placeholders; #include "UI/GamepadEmu.h" #include "UI/PauseScreen.h" #include "UI/MainScreen.h" +#include "UI/Background.h" #include "UI/EmuScreen.h" #include "UI/DevScreens.h" #include "UI/GameInfoCache.h" -#include "UI/MiscScreens.h" +#include "UI/BaseScreens.h" #include "UI/ControlMappingScreen.h" #include "UI/DisplayLayoutScreen.h" #include "UI/GameSettingsScreen.h" diff --git a/UI/GPUDriverTestScreen.h b/UI/GPUDriverTestScreen.h index b77862b8cf..66e28b9779 100644 --- a/UI/GPUDriverTestScreen.h +++ b/UI/GPUDriverTestScreen.h @@ -7,7 +7,7 @@ #include "Common/UI/TabHolder.h" #include "Common/Log.h" -#include "UI/MiscScreens.h" +#include "UI/BaseScreens.h" #include "Common/GPU/thin3d.h" class GPUDriverTestScreen : public UIBaseDialogScreen { diff --git a/UI/GameScreen.cpp b/UI/GameScreen.cpp index e45b1cded6..9068ec7d3a 100644 --- a/UI/GameScreen.cpp +++ b/UI/GameScreen.cpp @@ -47,6 +47,7 @@ #include "UI/GameScreen.h" #include "UI/GameSettingsScreen.h" #include "UI/GameInfoCache.h" +#include "UI/BaseScreens.h" #include "UI/MiscScreens.h" #include "UI/MainScreen.h" #include "UI/BackgroundAudio.h" diff --git a/UI/GameScreen.h b/UI/GameScreen.h index f1b35e7b9e..c308171e9c 100644 --- a/UI/GameScreen.h +++ b/UI/GameScreen.h @@ -19,7 +19,7 @@ #include -#include "UI/MiscScreens.h" +#include "UI/BaseScreens.h" #include "Common/UI/UIScreen.h" #include "Common/File/Path.h" diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 284f8632f3..83397b83fe 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -40,11 +40,11 @@ #include "Common/Math/curves.h" #include "Common/Data/Text/I18n.h" #include "Common/Data/Encoding/Utf8.h" +#include "Common/UI/PopupScreens.h" #include "UI/EmuScreen.h" #include "UI/GameSettingsScreen.h" #include "UI/GameInfoCache.h" #include "UI/GamepadEmu.h" -#include "UI/MiscScreens.h" #include "UI/ControlMappingScreen.h" #include "UI/DevScreens.h" #include "UI/DeveloperToolsScreen.h" diff --git a/UI/GameSettingsScreen.h b/UI/GameSettingsScreen.h index 3ebfb674f9..bbf46e7bde 100644 --- a/UI/GameSettingsScreen.h +++ b/UI/GameSettingsScreen.h @@ -23,8 +23,9 @@ #include #include "Common/UI/UIScreen.h" +#include "Common/UI/PopupScreens.h" #include "Core/ConfigValues.h" -#include "UI/MiscScreens.h" +#include "UI/BaseScreens.h" #include "UI/TabbedDialogScreen.h" class Path; diff --git a/UI/IAPScreen.cpp b/UI/IAPScreen.cpp index 86e9b56f4c..d9ed734045 100644 --- a/UI/IAPScreen.cpp +++ b/UI/IAPScreen.cpp @@ -1,11 +1,13 @@ // NOTE: This currently only used on iOS, to present the availablility of getting PPSSPP Gold through IAP. -#include "UI/IAPScreen.h" -#include "UI/OnScreenDisplay.h" -#include "UI/MiscScreens.h" #include "Common/System/System.h" +#include "Common/System/Request.h" #include "Common/Data/Text/I18n.h" #include "Common/System/OSD.h" +#include "Common/Render/DrawBuffer.h" +#include "UI/IAPScreen.h" +#include "UI/OnScreenDisplay.h" +#include "UI/MiscViews.h" void IAPScreen::CreateViews() { using namespace UI; diff --git a/UI/IAPScreen.h b/UI/IAPScreen.h index b48aab8433..51dd91a740 100644 --- a/UI/IAPScreen.h +++ b/UI/IAPScreen.h @@ -4,7 +4,7 @@ #include "ppsspp_config.h" -#include "UI/MiscScreens.h" +#include "UI/BaseScreens.h" class IAPScreen : public UIBaseDialogScreen { public: diff --git a/UI/InstallZipScreen.h b/UI/InstallZipScreen.h index f14fe8e692..87231de943 100644 --- a/UI/InstallZipScreen.h +++ b/UI/InstallZipScreen.h @@ -24,7 +24,7 @@ #include "Common/UI/View.h" #include "Common/UI/UIScreen.h" -#include "UI/MiscScreens.h" +#include "UI/BaseScreens.h" class SavedataView; diff --git a/UI/JitCompareScreen.cpp b/UI/JitCompareScreen.cpp index d7499a15c8..2060abdf7e 100644 --- a/UI/JitCompareScreen.cpp +++ b/UI/JitCompareScreen.cpp @@ -1,12 +1,15 @@ #include #include "UI/JitCompareScreen.h" - +#include "Common/Data/Text/I18n.h" +#include "Common/UI/ViewGroup.h" +#include "Common/Render/DrawBuffer.h" #include "Core/MemMap.h" #include "Core/MIPS/MIPSTables.h" #include "Core/MIPS/JitCommon/JitBlockCache.h" #include "Core/MIPS/JitCommon/JitCommon.h" #include "Core/MIPS/JitCommon/JitState.h" +#include "UI/PopupScreens.h" JitCompareScreen::JitCompareScreen() : UITabbedBaseDialogScreen(Path()) { if (!MIPSComp::jit) { diff --git a/UI/JitCompareScreen.h b/UI/JitCompareScreen.h index 78aba0375e..189f47426f 100644 --- a/UI/JitCompareScreen.h +++ b/UI/JitCompareScreen.h @@ -1,6 +1,6 @@ #pragma once #include "Common/UI/UIScreen.h" -#include "UI/MiscScreens.h" +#include "UI/BaseScreens.h" #include "UI/TabbedDialogScreen.h" class JitCompareScreen : public UITabbedBaseDialogScreen { diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index 844ac03eef..922b1a8703 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -55,7 +55,7 @@ #include "UI/GameScreen.h" #include "UI/GameInfoCache.h" #include "UI/GameSettingsScreen.h" -#include "UI/MiscScreens.h" +#include "UI/BaseScreens.h" #include "UI/ControlMappingScreen.h" #include "UI/IAPScreen.h" #include "UI/RemoteISOScreen.h" diff --git a/UI/MainScreen.h b/UI/MainScreen.h index bf52775f67..ff199aec91 100644 --- a/UI/MainScreen.h +++ b/UI/MainScreen.h @@ -24,7 +24,7 @@ #include "Common/UI/UIScreen.h" #include "Common/UI/ViewGroup.h" #include "Common/UI/TabHolder.h" -#include "UI/MiscScreens.h" +#include "UI/BaseScreens.h" #include "Common/File/PathBrowser.h" enum GameBrowserFlags { diff --git a/UI/MemStickScreen.cpp b/UI/MemStickScreen.cpp index 0b1b6050b9..7fa93907c2 100644 --- a/UI/MemStickScreen.cpp +++ b/UI/MemStickScreen.cpp @@ -39,6 +39,7 @@ #include "Common/File/DiskFree.h" #include "Common/Thread/ThreadManager.h" +#include "Common/UI/ScrollView.h" #include "Core/Config.h" #include "Core/Reporting.h" @@ -48,7 +49,7 @@ #include "UI/MemStickScreen.h" #include "UI/MainScreen.h" -#include "UI/MiscScreens.h" +#include "UI/BaseScreens.h" #include "UI/OnScreenDisplay.h" static std::string FormatSpaceString(int64_t space) { diff --git a/UI/MemStickScreen.h b/UI/MemStickScreen.h index 6e385972d9..b014b49024 100644 --- a/UI/MemStickScreen.h +++ b/UI/MemStickScreen.h @@ -29,7 +29,8 @@ #include "Core/Util/MemStick.h" -#include "UI/MiscScreens.h" +#include "UI/BaseScreens.h" +#include "UI/MiscViews.h" class NoticeView; diff --git a/UI/MiscScreens.cpp b/UI/MiscScreens.cpp index d6a685849a..1efa2ce861 100644 --- a/UI/MiscScreens.cpp +++ b/UI/MiscScreens.cpp @@ -736,68 +736,3 @@ void CreditsScroller::Draw(UIContext &dc) { dc.Flush(); } - -SettingInfoMessage::SettingInfoMessage(int align, float cutOffY, UI::AnchorLayoutParams *lp) - : UI::LinearLayout(ORIENT_HORIZONTAL, lp), cutOffY_(cutOffY) { - using namespace UI; - SetSpacing(0.0f); - Add(new Spacer(10.0f)); - text_ = Add(new TextView("", align, false, new LinearLayoutParams(1.0, Margins(0, 10)))); - Add(new Spacer(10.0f)); -} - -void SettingInfoMessage::Show(std::string_view text, const UI::View *refView) { - if (refView) { - Bounds b = refView->GetBounds(); - const UI::AnchorLayoutParams *lp = GetLayoutParams()->As(); - if (lp) { - if (cutOffY_ != -1.0f && b.y >= cutOffY_) { - ReplaceLayoutParams(new UI::AnchorLayoutParams(lp->width, lp->height, lp->left, 80.0f, lp->right, lp->bottom, lp->center)); - } else { - ReplaceLayoutParams(new UI::AnchorLayoutParams(lp->width, lp->height, lp->left, g_display.dp_yres - 80.0f - 40.0f, lp->right, lp->bottom, lp->center)); - } - } - } - if (text_) { - text_->SetText(text); - } - timeShown_ = time_now_d(); -} - -void SettingInfoMessage::Draw(UIContext &dc) { - static const double FADE_TIME = 1.0; - static const float MAX_ALPHA = 0.9f; - - // Let's show longer messages for more time (guesstimate at reading speed.) - // Note: this will give multibyte characters more time, but they often have shorter words anyway. - double timeToShow = std::max(1.5, text_->GetText().size() * 0.05); - - double sinceShow = time_now_d() - timeShown_; - float alpha = MAX_ALPHA; - if (timeShown_ == 0.0 || sinceShow > timeToShow + FADE_TIME) { - alpha = 0.0f; - } else if (sinceShow > timeToShow) { - alpha = MAX_ALPHA - MAX_ALPHA * (float)((sinceShow - timeToShow) / FADE_TIME); - } - - UI::Style style = dc.GetTheme().tooltipStyle; - - if (alpha >= 0.001f) { - uint32_t bgColor = alphaMul(style.background.color, alpha); - dc.FillRect(UI::Drawable(bgColor), bounds_); - } - - uint32_t textColor = alphaMul(style.fgColor, alpha); - text_->SetTextColor(textColor); - ViewGroup::Draw(dc); - showing_ = sinceShow <= timeToShow; // Don't consider fade time -} - -std::string SettingInfoMessage::GetText() const { - return (showing_ && text_) ? text_->GetText() : ""; -} - -void ShinyIcon::Draw(UIContext &dc) { - UI::DrawIconShine(dc, bounds_, 1.0f, animated_); - UI::ImageView::Draw(dc); -} diff --git a/UI/MiscScreens.h b/UI/MiscScreens.h index 0cd340a95e..bf8593d57c 100644 --- a/UI/MiscScreens.h +++ b/UI/MiscScreens.h @@ -124,30 +124,3 @@ protected: void CreateViews() override; const char *tag() const override { return "Credits"; } }; - -class SettingInfoMessage : public UI::LinearLayout { -public: - SettingInfoMessage(int align, float cutOffY, UI::AnchorLayoutParams *lp); - - void Show(std::string_view text, const UI::View *refView = nullptr); - - void Draw(UIContext &dc) override; - std::string GetText() const; - -private: - UI::TextView *text_ = nullptr; - double timeShown_ = 0.0; - float cutOffY_; - bool showing_ = false; -}; - -class ShinyIcon : public UI::ImageView { -public: - ShinyIcon(ImageID atlasImage, UI::LayoutParams *layoutParams = 0) : UI::ImageView(atlasImage, "", UI::IS_DEFAULT, layoutParams) {} - void Draw(UIContext &dc) override; - void SetAnimated(bool anim) { animated_ = anim; } -private: - bool animated_ = true; -}; - -uint32_t GetBackgroundColorWithAlpha(const UIContext &dc); diff --git a/UI/MiscViews.cpp b/UI/MiscViews.cpp index a2edaf2927..341f1dac67 100644 --- a/UI/MiscViews.cpp +++ b/UI/MiscViews.cpp @@ -1,6 +1,9 @@ #include "Common/UI/View.h" +#include "Common/UI/Context.h" #include "Common/Render/DrawBuffer.h" #include "Common/System/Request.h" +#include "Common/System/Display.h" +#include "Common/TimeUtil.h" #include "UI/MiscViews.h" TextWithImage::TextWithImage(ImageID imageID, std::string_view text, UI::LinearLayoutParams *layoutParams) : UI::LinearLayout(ORIENT_HORIZONTAL, layoutParams) { @@ -53,3 +56,67 @@ TopBar::TopBar(std::string_view title, UI::LayoutParams *layoutParams) : UI::Lin Add(new Spacer(50.0f)); } } +SettingInfoMessage::SettingInfoMessage(int align, float cutOffY, UI::AnchorLayoutParams *lp) + : UI::LinearLayout(ORIENT_HORIZONTAL, lp), cutOffY_(cutOffY) { + using namespace UI; + SetSpacing(0.0f); + Add(new Spacer(10.0f)); + text_ = Add(new TextView("", align, false, new LinearLayoutParams(1.0, Margins(0, 10)))); + Add(new Spacer(10.0f)); +} + +void SettingInfoMessage::Show(std::string_view text, const UI::View *refView) { + if (refView) { + Bounds b = refView->GetBounds(); + const UI::AnchorLayoutParams *lp = GetLayoutParams()->As(); + if (lp) { + if (cutOffY_ != -1.0f && b.y >= cutOffY_) { + ReplaceLayoutParams(new UI::AnchorLayoutParams(lp->width, lp->height, lp->left, 80.0f, lp->right, lp->bottom, lp->center)); + } else { + ReplaceLayoutParams(new UI::AnchorLayoutParams(lp->width, lp->height, lp->left, g_display.dp_yres - 80.0f - 40.0f, lp->right, lp->bottom, lp->center)); + } + } + } + if (text_) { + text_->SetText(text); + } + timeShown_ = time_now_d(); +} + +void SettingInfoMessage::Draw(UIContext &dc) { + static const double FADE_TIME = 1.0; + static const float MAX_ALPHA = 0.9f; + + // Let's show longer messages for more time (guesstimate at reading speed.) + // Note: this will give multibyte characters more time, but they often have shorter words anyway. + double timeToShow = std::max(1.5, text_->GetText().size() * 0.05); + + double sinceShow = time_now_d() - timeShown_; + float alpha = MAX_ALPHA; + if (timeShown_ == 0.0 || sinceShow > timeToShow + FADE_TIME) { + alpha = 0.0f; + } else if (sinceShow > timeToShow) { + alpha = MAX_ALPHA - MAX_ALPHA * (float)((sinceShow - timeToShow) / FADE_TIME); + } + + UI::Style style = dc.GetTheme().tooltipStyle; + + if (alpha >= 0.001f) { + uint32_t bgColor = alphaMul(style.background.color, alpha); + dc.FillRect(UI::Drawable(bgColor), bounds_); + } + + uint32_t textColor = alphaMul(style.fgColor, alpha); + text_->SetTextColor(textColor); + ViewGroup::Draw(dc); + showing_ = sinceShow <= timeToShow; // Don't consider fade time +} + +std::string SettingInfoMessage::GetText() const { + return (showing_ && text_) ? text_->GetText() : ""; +} + +void ShinyIcon::Draw(UIContext &dc) { + UI::DrawIconShine(dc, bounds_, 1.0f, animated_); + UI::ImageView::Draw(dc); +} diff --git a/UI/MiscViews.h b/UI/MiscViews.h index 1697c9edad..296d398666 100644 --- a/UI/MiscViews.h +++ b/UI/MiscViews.h @@ -22,3 +22,28 @@ public: private: UI::Choice *backButton_ = nullptr; }; + +class SettingInfoMessage : public UI::LinearLayout { +public: + SettingInfoMessage(int align, float cutOffY, UI::AnchorLayoutParams *lp); + + void Show(std::string_view text, const UI::View *refView = nullptr); + + void Draw(UIContext &dc) override; + std::string GetText() const; + +private: + UI::TextView *text_ = nullptr; + double timeShown_ = 0.0; + float cutOffY_; + bool showing_ = false; +}; + +class ShinyIcon : public UI::ImageView { +public: + ShinyIcon(ImageID atlasImage, UI::LayoutParams *layoutParams = 0) : UI::ImageView(atlasImage, "", UI::IS_DEFAULT, layoutParams) {} + void Draw(UIContext &dc) override; + void SetAnimated(bool anim) { animated_ = anim; } +private: + bool animated_ = true; +}; diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 0454e5526a..bde1e425cf 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -87,6 +87,7 @@ #include "Common/VR/PPSSPPVR.h" #include "Common/Thread/ThreadManager.h" #include "Common/Audio/AudioBackend.h" +#include "Common/UI/PopupScreens.h" #include "Core/ControlMapper.h" #include "Core/Config.h" #include "Core/ConfigValues.h" diff --git a/UI/PauseScreen.h b/UI/PauseScreen.h index c6b534a65b..90a99f94bf 100644 --- a/UI/PauseScreen.h +++ b/UI/PauseScreen.h @@ -23,7 +23,7 @@ #include "Common/File/Path.h" #include "Common/UI/UIScreen.h" #include "Common/UI/ViewGroup.h" -#include "UI/MiscScreens.h" +#include "UI/BaseScreens.h" #include "UI/Screen.h" class GamePauseScreen : public UIBaseDialogScreen { diff --git a/UI/RemoteISOScreen.cpp b/UI/RemoteISOScreen.cpp index 17392d941c..e81b66eb96 100644 --- a/UI/RemoteISOScreen.cpp +++ b/UI/RemoteISOScreen.cpp @@ -35,6 +35,7 @@ #include "Common/System/Request.h" #include "Common/File/PathBrowser.h" +#include "Common/UI/PopupScreens.h" #include "Common/Data/Format/JSONReader.h" #include "Common/Data/Text/I18n.h" #include "Common/Common.h" diff --git a/UI/RemoteISOScreen.h b/UI/RemoteISOScreen.h index ecf143aee9..37476af39d 100644 --- a/UI/RemoteISOScreen.h +++ b/UI/RemoteISOScreen.h @@ -22,7 +22,7 @@ #include "Common/UI/UIScreen.h" #include "Common/UI/ViewGroup.h" -#include "UI/MiscScreens.h" +#include "UI/BaseScreens.h" #include "UI/MainScreen.h" #include "UI/TabbedDialogScreen.h" diff --git a/UI/ReportScreen.cpp b/UI/ReportScreen.cpp index 2e347c6821..13039a0663 100644 --- a/UI/ReportScreen.cpp +++ b/UI/ReportScreen.cpp @@ -22,9 +22,7 @@ #include "Common/GPU/thin3d.h" #include "Common/UI/AsyncImageFileView.h" #include "Common/UI/Context.h" -#include "UI/PauseScreen.h" -#include "UI/ReportScreen.h" - +#include "Common/UI/ScrollView.h" #include "Common/Data/Text/I18n.h" #include "Common/File/FileUtil.h" #include "Common/Log.h" @@ -36,6 +34,8 @@ #include "Core/Reporting.h" #include "Core/Screenshot.h" #include "Core/System.h" +#include "UI/PauseScreen.h" +#include "UI/ReportScreen.h" using namespace UI; diff --git a/UI/ReportScreen.h b/UI/ReportScreen.h index 23282887f5..786b44324c 100644 --- a/UI/ReportScreen.h +++ b/UI/ReportScreen.h @@ -21,7 +21,7 @@ #include "Common/UI/UIScreen.h" #include "Common/UI/ViewGroup.h" -#include "UI/MiscScreens.h" +#include "UI/BaseScreens.h" #include "Common/File/Path.h" enum class ReportingOverallScore : int { diff --git a/UI/RetroAchievementScreens.cpp b/UI/RetroAchievementScreens.cpp index ea32beeb0c..154b43a580 100644 --- a/UI/RetroAchievementScreens.cpp +++ b/UI/RetroAchievementScreens.cpp @@ -1,11 +1,12 @@ +#include "Common/Data/Text/I18n.h" #include "Common/System/OSD.h" #include "Common/System/Request.h" #include "Common/UI/View.h" #include "Common/UI/ViewGroup.h" #include "Common/UI/TabHolder.h" #include "Common/UI/Context.h" -#include "Common/Data/Text/I18n.h" #include "Common/UI/IconCache.h" +#include "Common/UI/PopupScreens.h" #include "Common/StringUtils.h" #include "Core/Config.h" diff --git a/UI/RetroAchievementScreens.h b/UI/RetroAchievementScreens.h index 1fb9224dce..5debfd8b9c 100644 --- a/UI/RetroAchievementScreens.h +++ b/UI/RetroAchievementScreens.h @@ -7,7 +7,7 @@ #include "Common/UI/UIScreen.h" #include "Common/UI/ViewGroup.h" #include "Core/RetroAchievements.h" -#include "UI/MiscScreens.h" +#include "UI/BaseScreens.h" #include "UI/TabbedDialogScreen.h" #include "ext/rcheevos/include/rc_client.h" diff --git a/UI/SavedataScreen.cpp b/UI/SavedataScreen.cpp index d274f9dd5e..ca0316054d 100644 --- a/UI/SavedataScreen.cpp +++ b/UI/SavedataScreen.cpp @@ -26,7 +26,6 @@ #include "Common/Data/Text/Parsers.h" #include "Common/System/NativeApp.h" #include "Common/System/Request.h" -#include "Common/Data/Encoding/Utf8.h" #include "Common/UI/Context.h" #include "Common/UI/View.h" #include "Common/UI/ViewGroup.h" @@ -35,6 +34,7 @@ #include "UI/MainScreen.h" #include "UI/GameInfoCache.h" #include "UI/PauseScreen.h" +#include "UI/MiscScreens.h" #include "Common/File/FileUtil.h" #include "Common/TimeUtil.h" diff --git a/UI/SavedataScreen.h b/UI/SavedataScreen.h index a0785df039..68fcfd8023 100644 --- a/UI/SavedataScreen.h +++ b/UI/SavedataScreen.h @@ -26,7 +26,7 @@ #include "Common/UI/View.h" #include "Common/UI/ViewGroup.h" -#include "UI/MiscScreens.h" +#include "UI/BaseScreens.h" #include "UI/GameInfoCache.h" #include "UI/TabbedDialogScreen.h" diff --git a/UI/Store.cpp b/UI/Store.cpp index fbc1c4dd73..48278658f9 100644 --- a/UI/Store.cpp +++ b/UI/Store.cpp @@ -21,6 +21,7 @@ #include "Common/UI/Context.h" #include "Common/UI/ViewGroup.h" #include "Common/UI/IconCache.h" +#include "Common/UI/ScrollView.h" #include "Common/Render/DrawBuffer.h" #include "Common/Log.h" diff --git a/UI/Store.h b/UI/Store.h index f971dd3a64..2fc592eaa1 100644 --- a/UI/Store.h +++ b/UI/Store.h @@ -23,7 +23,7 @@ #include "Common/UI/ViewGroup.h" #include "Common/Net/HTTPClient.h" -#include "UI/MiscScreens.h" +#include "UI/BaseScreens.h" // Game screen: Allows you to start a game, delete saves, delete the game, // set game specific settings, etc. diff --git a/UI/SystemInfoScreen.cpp b/UI/SystemInfoScreen.cpp index 0360dc82cf..524e7ce43b 100644 --- a/UI/SystemInfoScreen.cpp +++ b/UI/SystemInfoScreen.cpp @@ -16,13 +16,14 @@ #include "Common/Data/Text/Parsers.h" #include "Common/Data/Encoding/Utf8.h" #include "Common/Render/Text/draw_text.h" +#include "Common/System/Request.h" #include "Common/UI/Context.h" #include "Core/System.h" #include "Core/Config.h" #include "GPU/GPUState.h" // ugh #include "UI/SystemInfoScreen.h" #include "UI/IconCache.h" -#include "UI/MiscScreens.h" +#include "UI/BaseScreens.h" #include "UI/OnScreenDisplay.h" #include "android/jni/app-android.h" diff --git a/UI/TabbedDialogScreen.cpp b/UI/TabbedDialogScreen.cpp index 62a3d53cfe..f63bfb9d1e 100644 --- a/UI/TabbedDialogScreen.cpp +++ b/UI/TabbedDialogScreen.cpp @@ -1,16 +1,22 @@ #include +#include "Common/Data/Text/I18n.h" #include "Common/StringUtils.h" #include "Common/System/NativeApp.h" #include "Common/System/Request.h" #include "Common/System/Display.h" #include "Common/UI/TabHolder.h" +#include "Common/UI/ViewGroup.h" +#include "Common/UI/ScrollView.h" +#include "Common/UI/PopupScreens.h" +#include "UI/MiscViews.h" #include "UI/TabbedDialogScreen.h" void UITabbedBaseDialogScreen::AddTab(const char *tag, std::string_view title, std::function createCallback, TabFlags flags) { using namespace UI; tabHolder_->AddTabDeferred(title, [createCallback = std::move(createCallback), tag, flags]() -> UI::ViewGroup * { + using namespace UI; ViewGroup *scroll = nullptr; if (!(flags & TabFlags::NonScrollable)) { scroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, FILL_PARENT)); diff --git a/UI/TabbedDialogScreen.h b/UI/TabbedDialogScreen.h index de135f88bc..1193354c13 100644 --- a/UI/TabbedDialogScreen.h +++ b/UI/TabbedDialogScreen.h @@ -6,7 +6,9 @@ #include "Common/UI/UIScreen.h" #include "Common/System/System.h" #include "Core/ConfigValues.h" -#include "UI/MiscScreens.h" +#include "UI/BaseScreens.h" + +class SettingInfoMessage; namespace UI { class TabHolder; diff --git a/UI/TiltAnalogSettingsScreen.cpp b/UI/TiltAnalogSettingsScreen.cpp index a7247ee648..5a4093d430 100644 --- a/UI/TiltAnalogSettingsScreen.cpp +++ b/UI/TiltAnalogSettingsScreen.cpp @@ -23,6 +23,8 @@ #include "Common/Math/math_util.h" #include "Common/Log.h" #include "Common/Data/Text/I18n.h" +#include "Common/UI/ScrollView.h" +#include "Common/UI/PopupScreens.h" #include "UI/JoystickHistoryView.h" #include "UI/GamepadEmu.h" diff --git a/UI/TiltAnalogSettingsScreen.h b/UI/TiltAnalogSettingsScreen.h index f8e00d916b..a28ea659f6 100644 --- a/UI/TiltAnalogSettingsScreen.h +++ b/UI/TiltAnalogSettingsScreen.h @@ -19,7 +19,7 @@ #include "Common/Math/math_util.h" #include "Common/UI/View.h" -#include "MiscScreens.h" +#include "BaseScreens.h" class JoystickHistoryView; class GamepadView; diff --git a/UI/TouchControlLayoutScreen.cpp b/UI/TouchControlLayoutScreen.cpp index c972b4c4d3..538d6bac2b 100644 --- a/UI/TouchControlLayoutScreen.cpp +++ b/UI/TouchControlLayoutScreen.cpp @@ -24,6 +24,7 @@ #include "Common/Math/math_util.h" #include "Common/System/Display.h" #include "Common/UI/Context.h" +#include "Common/UI/PopupScreens.h" #include "Common/CommonTypes.h" #include "Common/Log.h" diff --git a/UI/TouchControlLayoutScreen.h b/UI/TouchControlLayoutScreen.h index e10c7568b4..50202d81a0 100644 --- a/UI/TouchControlLayoutScreen.h +++ b/UI/TouchControlLayoutScreen.h @@ -20,7 +20,7 @@ #include "Common/UI/View.h" #include "Common/UI/ViewGroup.h" #include "Common/UI/TabHolder.h" -#include "MiscScreens.h" +#include "BaseScreens.h" class ControlLayoutView; diff --git a/UI/TouchControlVisibilityScreen.cpp b/UI/TouchControlVisibilityScreen.cpp index bb04391d4f..cbd83e322a 100644 --- a/UI/TouchControlVisibilityScreen.cpp +++ b/UI/TouchControlVisibilityScreen.cpp @@ -15,11 +15,12 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. -#include "Common/UI/TabHolder.h" #include "Common/System/Display.h" #include "Common/Render/TextureAtlas.h" #include "Common/Data/Text/I18n.h" #include "Common/StringUtils.h" +#include "Common/UI/TabHolder.h" +#include "Common/UI/PopupScreens.h" #include "Core/Config.h" diff --git a/UI/TouchControlVisibilityScreen.h b/UI/TouchControlVisibilityScreen.h index dca6aa635e..b9718c5268 100644 --- a/UI/TouchControlVisibilityScreen.h +++ b/UI/TouchControlVisibilityScreen.h @@ -17,8 +17,10 @@ #pragma once +#include +#include #include "Common/Render/TextureAtlas.h" -#include "UI/MiscScreens.h" +#include "UI/BaseScreens.h" #include "UI/TabbedDialogScreen.h" namespace UI { diff --git a/UI/UploadScreen.cpp b/UI/UploadScreen.cpp index 1f0aba0c98..9400dd7374 100644 --- a/UI/UploadScreen.cpp +++ b/UI/UploadScreen.cpp @@ -4,6 +4,7 @@ #include "Common/File/DiskFree.h" #include "Common/StringUtils.h" #include "Common/Data/Text/Parsers.h" +#include "Common/Data/Text/I18n.h" #include "Core/WebServer.h" #include "UI/UploadScreen.h" #include "UI/MiscViews.h" diff --git a/UI/UploadScreen.h b/UI/UploadScreen.h index 161a574cbd..6cb75008dd 100644 --- a/UI/UploadScreen.h +++ b/UI/UploadScreen.h @@ -25,7 +25,7 @@ #include "Common/UI/UIScreen.h" #include "Common/UI/ViewGroup.h" -#include "UI/MiscScreens.h" +#include "UI/BaseScreens.h" #include "Common/TimeUtil.h" // Upload screen: Shows the user an ip address to go to in a web browser on the same network,