diff --git a/CMakeLists.txt b/CMakeLists.txt index 42d4e9f75d..a8f0b3c06c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1550,8 +1550,12 @@ list(APPEND NativeAppSource UI/NativeApp.cpp UI/BackgroundAudio.h UI/BackgroundAudio.cpp + UI/Background.h + UI/Background.cpp UI/ChatScreen.h UI/ChatScreen.cpp + UI/BaseScreens.h + UI/BaseScreens.cpp UI/DebugOverlay.cpp UI/DebugOverlay.h UI/DevScreens.cpp diff --git a/UI/Background.cpp b/UI/Background.cpp new file mode 100644 index 0000000000..9bf86a4f7c --- /dev/null +++ b/UI/Background.cpp @@ -0,0 +1,468 @@ +#include +#include "Common/GPU/thin3d.h" +#include "Common/Data/Text/I18n.h" +#include "Common/Math/geom2d.h" +#include "Common/Math/curves.h" +#include "Common/Data/Random/Rng.h" +#include "Common/Data/Color/RGBAUtil.h" +#include "Common/UI/Context.h" +#include "Common/UI/UI.h" +#include "Common/File/Path.h" +#include "Common/File/FileUtil.h" +#include "Common/TimeUtil.h" +#include "Common/Render/ManagedTexture.h" +#include "Common/System/System.h" +#include "Common/System/Display.h" +#include "Common/System/Request.h" +#include "Core/ConfigValues.h" +#include "Core/Config.h" +#include "Core/System.h" +#include "Core/Util/RecentFiles.h" +#include "UI/Background.h" +#include "UI/GameInfoCache.h" + + +#ifdef _MSC_VER +#pragma execution_character_set("utf-8") +#endif + +static Draw::Texture *bgTexture; + +class Animation { +public: + virtual ~Animation() = default; + virtual void Draw(UIContext &dc, double t, float alpha, float x, float y, float z) = 0; +}; + +class MovingBackground : public Animation { +public: + void Draw(UIContext &dc, double t, float alpha, float x, float y, float z) override { + if (!bgTexture) + return; + + dc.Flush(); + dc.GetDrawContext()->BindTexture(0, bgTexture); + Bounds bounds = dc.GetBounds(); + + x = std::min(std::max(x / bounds.w, 0.0f), 1.0f) * XFAC; + y = std::min(std::max(y / bounds.h, 0.0f), 1.0f) * YFAC; + z = 1.0f + std::max(XFAC, YFAC) + (z - 1.0f) * ZFAC; + + lastX_ = abs(x - lastX_) > 0.001f ? x * XSPEED + lastX_ * (1.0f - XSPEED) : x; + lastY_ = abs(y - lastY_) > 0.001f ? y * YSPEED + lastY_ * (1.0f - YSPEED) : y; + lastZ_ = abs(z - lastZ_) > 0.001f ? z * ZSPEED + lastZ_ * (1.0f - ZSPEED) : z; + + float u1 = lastX_ / lastZ_; + float v1 = lastY_ / lastZ_; + float u2 = (1.0f + lastX_) / lastZ_; + float v2 = (1.0f + lastY_) / lastZ_; + + dc.Draw()->DrawTexRect(bounds, u1, v1, u2, v2, whiteAlpha(alpha)); + + dc.Flush(); + dc.RebindTexture(); + } + +private: + static constexpr float XFAC = 0.3f; + static constexpr float YFAC = 0.3f; + static constexpr float ZFAC = 0.12f; + static constexpr float XSPEED = 0.05f; + static constexpr float YSPEED = 0.05f; + static constexpr float ZSPEED = 0.1f; + + float lastX_ = 0.0f; + float lastY_ = 0.0f; + float lastZ_ = 1.0f + std::max(XFAC, YFAC); +}; + +class WaveAnimation : public Animation { +public: + void Draw(UIContext &dc, double t, float alpha, float x, float y, float z) override { + const uint32_t color = colorAlpha(0xFFFFFFFF, alpha * 0.2f); + const float speed = 1.0; + + Bounds bounds = dc.GetBounds(); + dc.Flush(); + dc.BeginNoTex(); + + // 500 is enough for any resolution really. 24 * 500 = 12000 which fits handily in our UI vertex buffer (max 65536 per flush). + const int steps = std::max(20, std::min((int)g_display.dp_xres, 500)); + float step = (float)g_display.dp_xres / (float)steps; + t *= speed; + + for (int n = 0; n < steps; n++) { + float x = (float)n * step; + float nextX = (float)(n + 1) * step; + float i = x * 1280 / bounds.w; + + float wave0 = sin(i * 0.005 + t * 0.8) * 0.05 + sin(i * 0.002 + t * 0.25) * 0.02 + sin(i * 0.001 + t * 0.3) * 0.03 + 0.625; + float wave1 = sin(i * 0.0044 + t * 0.4) * 0.07 + sin(i * 0.003 + t * 0.1) * 0.02 + sin(i * 0.001 + t * 0.3) * 0.01 + 0.625; + dc.Draw()->RectVGradient(x, wave0 * bounds.h, nextX, bounds.h, color, 0x00000000); + dc.Draw()->RectVGradient(x, wave1 * bounds.h, nextX, bounds.h, color, 0x00000000); + + // Add some "antialiasing" + dc.Draw()->RectVGradient(x, wave0 * bounds.h - 3.0f * g_display.pixel_in_dps_y, nextX, wave0 * bounds.h, 0x00000000, color); + dc.Draw()->RectVGradient(x, wave1 * bounds.h - 3.0f * g_display.pixel_in_dps_y, nextX, wave1 * bounds.h, 0x00000000, color); + } + + dc.Flush(); + dc.Begin(); + } +}; + +class FloatingSymbolsAnimation : public Animation { +public: + FloatingSymbolsAnimation(bool is_colored) { + this->is_colored = is_colored; + } + + void Draw(UIContext &dc, double t, float alpha, float x, float y, float z) override { + dc.Flush(); + dc.Begin(); + float xres = dc.GetBounds().w; + float yres = dc.GetBounds().h; + if (last_xres != xres || last_yres != yres) { + Regenerate(xres, yres); + } + + for (int i = 0; i < COUNT; i++) { + float x = xbase[i] + dc.GetBounds().x; + float y = ybase[i] + dc.GetBounds().y + 40 * cosf(i * 7.2f + t * 1.3f); + float angle = (float)sin(i + t); + int n = i & 3; + Color color = is_colored ? colorAlpha(COLORS[n], alpha * 0.25f) : colorAlpha(DEFAULT_COLOR, alpha * 0.1f); + ui_draw2d.DrawImageRotated(SYMBOLS[n], x, y, 1.0f, angle, color); + } + dc.Flush(); + } + +private: + static constexpr int COUNT = 100; + static constexpr Color DEFAULT_COLOR = 0xC0FFFFFF; + static constexpr Color COLORS[4] = {0xFFE3B56F, 0xFF615BFF, 0xFFAA88F3, 0xFFC2CC7A,}; // X O D A + static const ImageID SYMBOLS[4]; + + bool is_colored = false; + float xbase[COUNT]{}; + float ybase[COUNT]{}; + float last_xres = 0; + float last_yres = 0; + + void Regenerate(int xres, int yres) { + GMRng rng; + for (int i = 0; i < COUNT; i++) { + xbase[i] = rng.F() * xres; + ybase[i] = rng.F() * yres; + } + + last_xres = xres; + last_yres = yres; + } +}; + +const ImageID FloatingSymbolsAnimation::SYMBOLS[4] = { + ImageID("I_CROSS"), + ImageID("I_CIRCLE"), + ImageID("I_SQUARE"), + ImageID("I_TRIANGLE"), +}; + +class RecentGamesAnimation : public Animation { +public: + void Draw(UIContext &dc, double t, float alpha, float x, float y, float z) override { + if (lastIndex_ == nextIndex_) { + CheckNext(dc, t); + } else if (t > nextT_) { + lastIndex_ = nextIndex_; + } + + if (g_recentFiles.HasAny()) { + std::shared_ptr lastInfo = GetInfo(dc, lastIndex_); + std::shared_ptr nextInfo = GetInfo(dc, nextIndex_); + dc.Flush(); + + float lastAmount = Clamp((float)(nextT_ - t) * 1.0f / TRANSITION, 0.0f, 1.0f); + DrawTex(dc, lastInfo, lastAmount * alpha * 0.2f); + + float nextAmount = lastAmount <= 0.0f ? 1.0f : 1.0f - lastAmount; + DrawTex(dc, nextInfo, nextAmount * alpha * 0.2f); + + dc.RebindTexture(); + } + } + +private: + void CheckNext(UIContext &dc, double t) { + if (!g_recentFiles.HasAny()) { + return; + } + + std::vector recents = g_recentFiles.GetRecentFiles(); + + for (int index = lastIndex_ + 1; index != lastIndex_; ++index) { + if (index < 0 || index >= (int)recents.size()) { + if (lastIndex_ == -1) + break; + index = 0; + } + + std::shared_ptr ginfo = GetInfo(dc, index); + if (ginfo && !ginfo->Ready(GameInfoFlags::PIC1)) { + // Wait for it to load. It might be the next one. + break; + } + if (ginfo && ginfo->pic1.texture) { + nextIndex_ = index; + nextT_ = t + INTERVAL; + break; + } + + // Otherwise, keep going. This skips games with no BG. + } + } + + static std::shared_ptr GetInfo(UIContext &dc, int index) { + if (index < 0) { + return nullptr; + } + const auto recentIsos = g_recentFiles.GetRecentFiles(); + if (index >= (int)recentIsos.size()) + return std::shared_ptr(); + return g_gameInfoCache->GetInfo(dc.GetDrawContext(), Path(recentIsos[index]), GameInfoFlags::PIC1); + } + + static void DrawTex(UIContext &dc, std::shared_ptr &ginfo, float amount) { + if (!ginfo || amount <= 0.0f) + return; + GameInfoTex *pic = ginfo->GetPIC1(); + if (!pic) + return; + + dc.GetDrawContext()->BindTexture(0, pic->texture); + uint32_t color = whiteAlpha(amount) & 0xFFc0c0c0; + dc.Draw()->DrawTexRect(dc.GetBounds(), 0, 0, 1, 1, color); + dc.Flush(); + } + + static constexpr double INTERVAL = 8.0; + static constexpr float TRANSITION = 3.0f; + + int lastIndex_ = -1; + int nextIndex_ = -1; + double nextT_ = -INTERVAL; +}; + +class BouncingIconAnimation : public Animation { +public: + void Draw(UIContext &dc, double t, float alpha, float x, float y, float z) override { + dc.Flush(); + dc.Begin(); + + // Handle change in resolution. + float xres = dc.GetBounds().w; + float yres = dc.GetBounds().h; + if (last_xres != xres || last_yres != yres) { + Recalculate(xres, yres); + } + + // Draw the image. + float xpos = xbase + dc.GetBounds().x; + float ypos = ybase + dc.GetBounds().y; + ImageID icon = !color_ix && System_GetPropertyBool(SYSPROP_APP_GOLD) ? ImageID("I_ICON_GOLD") : ImageID("I_ICON"); + ui_draw2d.DrawImage(icon, xpos, ypos, scale, COLORS[color_ix], ALIGN_CENTER); + dc.Flush(); + + // Switch direction if within border. + bool should_recolor = true; + if (xbase > xres - border || xbase < border) { + xspeed *= -1.0f; + RandomizeColor(); + should_recolor = false; + } + + if (ybase > yres - border || ybase < border) { + yspeed *= -1.0f; + + if (should_recolor) { + RandomizeColor(); + } + } + + // Place to border if out of bounds. + if (xbase > xres - border) xbase = xres - border; + else if (xbase < border) xbase = border; + if (ybase > yres - border) ybase = yres - border; + else if (ybase < border) ybase = border; + + // Update location. + xbase += xspeed; + ybase += yspeed; + } + +private: + static constexpr int COLOR_COUNT = 11; + static constexpr Color COLORS[COLOR_COUNT] = {0xFFFFFFFF, 0xFFFFFF00, 0xFFFF0000, 0xFF00FF00, 0xFF0000FF, + 0xFF00FFFF, 0xFFFF00FF, 0xFF4111D1, 0xFF3577F3, 0xFFAA77FF, 0xFF623B84}; + + float xbase = 0.0f; + float ybase = 0.0f; + float last_xres = 0.0f; + float last_yres = 0.0f; + float xspeed = 1.0f; + float yspeed = 1.0f; + float scale = 1.0f; + float border = 35.0f; + int color_ix = 0; + int last_color_ix = -1; + GMRng rng; + + void Recalculate(int xres, int yres) { + // First calculation. + if (last_color_ix == -1) { + xbase = xres / 2.0f; + ybase = yres / 2.0f; + last_color_ix = 0; + + // Determine initial direction. + if ((int)(rng.F() * xres) % 2) xspeed *= -1.0f; + if ((int)(rng.F() * yres) % 2) yspeed *= -1.0f; + } + + // Scale certain attributes to resolution. + scale = std::min(xres, yres) / 400.0f; + float speed = scale < 2.5f ? scale * 0.58f : scale * 0.46f; + xspeed = std::signbit(xspeed) ? speed * -1.0f : speed; + yspeed = std::signbit(yspeed) ? speed * -1.0f : speed; + border = 35.0f * scale; + + last_xres = xres; + last_yres = yres; + } + + void RandomizeColor() { + do { + color_ix = (int)(rng.F() * xbase) % COLOR_COUNT; + } while (color_ix == last_color_ix); + + last_color_ix = color_ix; + } +}; + +// TODO: Add more styles. Remember to add to the enum in ConfigValues.h and the selector in GameSettings too. + +static BackgroundAnimation g_CurBackgroundAnimation = BackgroundAnimation::OFF; +static std::unique_ptr g_Animation; +static bool bgTextureInited = false; // Separate variable because init could fail. + +void UIBackgroundInit(UIContext &dc) { + const Path bgPng = GetSysDirectory(DIRECTORY_SYSTEM) / "background.png"; + const Path bgJpg = GetSysDirectory(DIRECTORY_SYSTEM) / "background.jpg"; + if (File::Exists(bgPng) || File::Exists(bgJpg)) { + const Path &bgFile = File::Exists(bgPng) ? bgPng : bgJpg; + bgTexture = CreateTextureFromFile(dc.GetDrawContext(), bgFile.c_str(), ImageFileType::DETECT, true); + } +} + +void UIBackgroundShutdown() { + if (bgTexture) { + bgTexture->Release(); + bgTexture = nullptr; + } + bgTextureInited = false; + g_Animation.reset(nullptr); + g_CurBackgroundAnimation = BackgroundAnimation::OFF; +} + +void DrawBackground(UIContext &dc, float alpha, float x, float y, float z) { + if (!bgTextureInited) { + UIBackgroundInit(dc); + bgTextureInited = true; + } + if (g_CurBackgroundAnimation != (BackgroundAnimation)g_Config.iBackgroundAnimation) { + g_CurBackgroundAnimation = (BackgroundAnimation)g_Config.iBackgroundAnimation; + + switch (g_CurBackgroundAnimation) { + case BackgroundAnimation::FLOATING_SYMBOLS: + g_Animation.reset(new FloatingSymbolsAnimation(false)); + break; + case BackgroundAnimation::RECENT_GAMES: + g_Animation.reset(new RecentGamesAnimation()); + break; + case BackgroundAnimation::WAVE: + g_Animation.reset(new WaveAnimation()); + break; + case BackgroundAnimation::MOVING_BACKGROUND: + g_Animation.reset(new MovingBackground()); + break; + case BackgroundAnimation::BOUNCING_ICON: + g_Animation.reset(new BouncingIconAnimation()); + break; + case BackgroundAnimation::FLOATING_SYMBOLS_COLORED: + g_Animation.reset(new FloatingSymbolsAnimation(true)); + break; + default: + g_Animation.reset(nullptr); + } + } + + uint32_t bgColor = whiteAlpha(alpha); + + if (bgTexture != nullptr) { + dc.Flush(); + dc.Begin(); + dc.GetDrawContext()->BindTexture(0, bgTexture); + dc.Draw()->DrawTexRect(dc.GetBounds(), 0, 0, 1, 1, bgColor); + + dc.Flush(); + dc.RebindTexture(); + } else { + // I_BG original color: 0xFF754D24 + ImageID img = ImageID("I_BG"); + dc.Begin(); + dc.Draw()->DrawImageStretch(img, dc.GetBounds(), bgColor & dc.GetTheme().backgroundColor); + dc.Flush(); + } + +#if PPSSPP_PLATFORM(IOS) + // iOS uses an old screenshot when restoring the task, so to avoid an ugly + // jitter we accumulate time instead. + static int frameCount = 0.0; + frameCount++; + double t = (double)frameCount / System_GetPropertyFloat(SYSPROP_DISPLAY_REFRESH_RATE); +#else + double t = time_now_d(); +#endif + + if (g_Animation) { + g_Animation->Draw(dc, t, alpha, x, y, z); + } +} + +uint32_t GetBackgroundColorWithAlpha(const UIContext &dc) { + return colorAlpha(colorBlend(dc.GetTheme().backgroundColor, 0, 0.5f), 0.65f); // 0.65 = 166 = A6 +} + +void DrawGameBackground(UIContext &dc, const Path &gamePath, float x, float y, float z) { + using namespace Draw; + using namespace UI; + dc.Flush(); + + std::shared_ptr ginfo; + if (!gamePath.empty()) { + ginfo = g_gameInfoCache->GetInfo(dc.GetDrawContext(), gamePath, GameInfoFlags::PIC1); + } + + GameInfoTex *pic = (ginfo && ginfo->Ready(GameInfoFlags::PIC1)) ? ginfo->GetPIC1() : nullptr; + if (pic) { + dc.GetDrawContext()->BindTexture(0, pic->texture); + uint32_t color = whiteAlpha(ease((time_now_d() - pic->timeLoaded) * 3)) & 0xFFc0c0c0; + dc.Draw()->DrawTexRect(dc.GetBounds(), 0, 0, 1, 1, color); + dc.Flush(); + dc.RebindTexture(); + } else { + ::DrawBackground(dc, 1.0f, x, y, z); + dc.RebindTexture(); + dc.Flush(); + } +} diff --git a/UI/Background.h b/UI/Background.h new file mode 100644 index 0000000000..db4805f3ba --- /dev/null +++ b/UI/Background.h @@ -0,0 +1,14 @@ +#pragma once + +#include "Common/File/Path.h" + +class UIContext; + +extern Path boot_filename; + +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/BaseScreens.cpp b/UI/BaseScreens.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/UI/BaseScreens.h b/UI/BaseScreens.h new file mode 100644 index 0000000000..5ed87b6c69 --- /dev/null +++ b/UI/BaseScreens.h @@ -0,0 +1,23 @@ +#pragma once + +#include "Common/File/Path.h" +#include "Common/UI/UIScreen.h" + +// This doesn't have anything to do with the background anymore. It's just a PPSSPP UIScreen +// that knows how handle sendMessage properly. Same for all the below. +class UIBaseScreen : public UIScreen { +public: + UIBaseScreen() : UIScreen() {} +protected: + void sendMessage(UIMessage message, const char *value) override; +}; + +class UIBaseDialogScreen : public UIDialogScreen { +public: + UIBaseDialogScreen() : UIDialogScreen(), gamePath_() {} + explicit UIBaseDialogScreen(const Path &gamePath) : UIDialogScreen(), gamePath_(gamePath) {} +protected: + void sendMessage(UIMessage message, const char *value) override; + void AddStandardBack(UI::ViewGroup *parent); + Path gamePath_; +}; diff --git a/UI/ControlMappingScreen.cpp b/UI/ControlMappingScreen.cpp index 6a11266ba4..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" @@ -318,7 +319,7 @@ void ControlMappingScreen::update() { RecreateViews(); } - UIDialogScreenWithGameBackground::update(); + UIBaseDialogScreen::update(); SetVRAppMode(VRAppMode::VR_MENU_MODE); } @@ -504,7 +505,7 @@ void KeyMappingNewMouseKeyDialog::axis(const AxisInput &axis) { } } -AnalogCalibrationScreen::AnalogCalibrationScreen(const Path &gamePath) : UIDialogScreenWithGameBackground(gamePath) { +AnalogCalibrationScreen::AnalogCalibrationScreen(const Path &gamePath) : UIBaseDialogScreen(gamePath) { mapper_.SetCallbacks( [](int vkey, bool down) {}, [](int vkey, float analogValue) {}, @@ -953,7 +954,7 @@ bool VisualMappingScreen::key(const KeyInput &key) { } } } - return UIDialogScreenWithGameBackground::key(key); + return UIBaseDialogScreen::key(key); } void VisualMappingScreen::axis(const AxisInput &axis) { @@ -976,11 +977,11 @@ void VisualMappingScreen::axis(const AxisInput &axis) { break; } } - UIDialogScreenWithGameBackground::axis(axis); + UIBaseDialogScreen::axis(axis); } void VisualMappingScreen::resized() { - UIDialogScreenWithGameBackground::resized(); + UIBaseDialogScreen::resized(); RecreateViews(); } diff --git a/UI/ControlMappingScreen.h b/UI/ControlMappingScreen.h index 8ceabcfed0..9ab95fe23f 100644 --- a/UI/ControlMappingScreen.h +++ b/UI/ControlMappingScreen.h @@ -30,13 +30,13 @@ #include "Core/ControlMapper.h" -#include "UI/MiscScreens.h" +#include "UI/BaseScreens.h" class SingleControlMapper; -class ControlMappingScreen : public UIDialogScreenWithGameBackground { +class ControlMappingScreen : public UIBaseDialogScreen { public: - explicit ControlMappingScreen(const Path &gamePath) : UIDialogScreenWithGameBackground(gamePath) { + explicit ControlMappingScreen(const Path &gamePath) : UIBaseDialogScreen(gamePath) { categoryToggles_[0] = true; categoryToggles_[1] = true; categoryToggles_[2] = true; @@ -120,7 +120,7 @@ private: class JoystickHistoryView; -class AnalogCalibrationScreen : public UIDialogScreenWithGameBackground { +class AnalogCalibrationScreen : public UIBaseDialogScreen { public: AnalogCalibrationScreen(const Path &gamePath); @@ -149,9 +149,9 @@ private: class MockPSP; -class VisualMappingScreen : public UIDialogScreenWithGameBackground { +class VisualMappingScreen : public UIBaseDialogScreen { public: - VisualMappingScreen(const Path &gamePath) : UIDialogScreenWithGameBackground(gamePath) {} + VisualMappingScreen(const Path &gamePath) : UIBaseDialogScreen(gamePath) {} const char *tag() const override { return "VisualMapping"; } 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 2200e6e803..56b6996111 100644 --- a/UI/CustomButtonMappingScreen.h +++ b/UI/CustomButtonMappingScreen.h @@ -17,16 +17,16 @@ #pragma once -#include "MiscScreens.h" +#include "UI/BaseScreens.h" #include "UI/GamepadEmu.h" namespace UI { class CheckBox; } -class CustomButtonMappingScreen : public UIDialogScreenWithGameBackground { +class CustomButtonMappingScreen : public UIBaseDialogScreen { public: - CustomButtonMappingScreen(const Path &gamePath, int id) : UIDialogScreenWithGameBackground(gamePath), id_(id) {} + CustomButtonMappingScreen(const Path &gamePath, int id) : UIBaseDialogScreen(gamePath), id_(id) {} const char *tag() const override { return "CustomButton"; } diff --git a/UI/CwCheatScreen.cpp b/UI/CwCheatScreen.cpp index 8cbeed314f..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" @@ -40,7 +41,7 @@ static Path GetGlobalCheatFilePath() { } CwCheatScreen::CwCheatScreen(const Path &gamePath) - : UIDialogScreenWithGameBackground(gamePath) { + : UIBaseDialogScreen(gamePath) { } CwCheatScreen::~CwCheatScreen() { @@ -155,7 +156,7 @@ void CwCheatScreen::update() { fileCheckCounter_ = 0; } - UIDialogScreenWithGameBackground::update(); + UIBaseDialogScreen::update(); } void CwCheatScreen::onFinish(DialogResult result) { diff --git a/UI/CwCheatScreen.h b/UI/CwCheatScreen.h index 0a6118bc87..4e1f0a98ed 100644 --- a/UI/CwCheatScreen.h +++ b/UI/CwCheatScreen.h @@ -23,12 +23,12 @@ #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; -class CwCheatScreen : public UIDialogScreenWithGameBackground { +class CwCheatScreen : public UIBaseDialogScreen { public: CwCheatScreen(const Path &gamePath); ~CwCheatScreen(); diff --git a/UI/DevScreens.cpp b/UI/DevScreens.cpp index 956916330e..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" @@ -253,7 +254,7 @@ void LogViewScreen::UpdateLog() { } void LogViewScreen::update() { - UIDialogScreenWithBackground::update(); + UIBaseDialogScreen::update(); if (toBottom_) { toBottom_ = false; scroll_->ScrollToBottom(); @@ -524,7 +525,7 @@ bool ShaderViewScreen::key(const KeyInput &ki) { System_CopyStringToClipboard(gpu->DebugGetShaderString(id_, type_, SHADER_STRING_SHORT_DESC)); } } - return UIDialogScreenWithBackground::key(ki); + return UIBaseDialogScreen::key(ki); } @@ -616,7 +617,7 @@ void FrameDumpTestScreen::update() { } void TouchTestScreen::touch(const TouchInput &touch) { - UIDialogScreenWithGameBackground::touch(touch); + UIBaseDialogScreen::touch(touch); if (touch.flags & TOUCH_DOWN) { bool found = false; for (int i = 0; i < MAX_TOUCH_POINTS; i++) { diff --git a/UI/DevScreens.h b/UI/DevScreens.h index 0b51afeb84..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 { @@ -47,7 +48,7 @@ private: Path gamePath_; }; -class JitDebugScreen : public UIDialogScreenWithBackground { +class JitDebugScreen : public UIBaseDialogScreen { public: JitDebugScreen() {} void CreateViews() override; @@ -59,7 +60,7 @@ private: void OnDisableAll(UI::EventParams &e); }; -class LogConfigScreen : public UIDialogScreenWithBackground { +class LogConfigScreen : public UIBaseDialogScreen { public: LogConfigScreen() {} void CreateViews() override; @@ -74,7 +75,7 @@ private: void OnLogLevelChange(UI::EventParams &e); }; -class LogViewScreen : public UIDialogScreenWithBackground { +class LogViewScreen : public UIBaseDialogScreen { public: void CreateViews() override; void update() override; @@ -108,9 +109,9 @@ protected: void CreatePopupContents(UI::ViewGroup *parent) override; }; -class ShaderListScreen : public TabbedUIDialogScreenWithGameBackground { +class ShaderListScreen : public UITabbedBaseDialogScreen { public: - ShaderListScreen() : TabbedUIDialogScreenWithGameBackground(Path()) {} + ShaderListScreen() : UITabbedBaseDialogScreen(Path()) {} void CreateTabs() override; const char *tag() const override { return "ShaderList"; } @@ -122,7 +123,7 @@ private: void OnShaderClick(UI::EventParams &e); }; -class ShaderViewScreen : public UIDialogScreenWithBackground { +class ShaderViewScreen : public UIBaseDialogScreen { public: ShaderViewScreen(std::string id, DebugShaderType type) : id_(id), type_(type) {} @@ -137,7 +138,7 @@ private: DebugShaderType type_; }; -class FrameDumpTestScreen : public UIDialogScreenWithBackground { +class FrameDumpTestScreen : public UIBaseDialogScreen { public: FrameDumpTestScreen(); ~FrameDumpTestScreen(); @@ -155,9 +156,9 @@ private: std::shared_ptr dumpDownload_; }; -class TouchTestScreen : public UIDialogScreenWithGameBackground { +class TouchTestScreen : public UIBaseDialogScreen { public: - TouchTestScreen(const Path &gamePath) : UIDialogScreenWithGameBackground(gamePath) { + TouchTestScreen(const Path &gamePath) : UIBaseDialogScreen(gamePath) { for (int i = 0; i < MAX_TOUCH_POINTS; i++) { touches_[i].id = -1; } diff --git a/UI/DeveloperToolsScreen.cpp b/UI/DeveloperToolsScreen.cpp index 3977bb2350..0d43ad237e 100644 --- a/UI/DeveloperToolsScreen.cpp +++ b/UI/DeveloperToolsScreen.cpp @@ -711,7 +711,7 @@ void DeveloperToolsScreen::OnMIPSTracerClearTracer(UI::EventParams &e) { } void DeveloperToolsScreen::update() { - UIDialogScreenWithBackground::update(); + UIBaseDialogScreen::update(); allowDebugger_ = !WebServerStopped(WebServerFlags::DEBUGGER); canAllowDebugger_ = !WebServerStopping(WebServerFlags::DEBUGGER); } diff --git a/UI/DeveloperToolsScreen.h b/UI/DeveloperToolsScreen.h index dbbef1babb..009963da40 100644 --- a/UI/DeveloperToolsScreen.h +++ b/UI/DeveloperToolsScreen.h @@ -4,9 +4,9 @@ #include "UI/TabbedDialogScreen.h" -class DeveloperToolsScreen : public TabbedUIDialogScreenWithGameBackground { +class DeveloperToolsScreen : public UITabbedBaseDialogScreen { public: - DeveloperToolsScreen(const Path &gamePath) : TabbedUIDialogScreenWithGameBackground(gamePath) {} + DeveloperToolsScreen(const Path &gamePath) : UITabbedBaseDialogScreen(gamePath) {} void CreateTabs() override; void update() override; diff --git a/UI/DisplayLayoutScreen.cpp b/UI/DisplayLayoutScreen.cpp index c06c343269..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" @@ -117,7 +118,7 @@ private: float startDisplayOffsetY_ = -1.0f; }; -DisplayLayoutScreen::DisplayLayoutScreen(const Path &filename) : UIDialogScreenWithGameBackground(filename) {} +DisplayLayoutScreen::DisplayLayoutScreen(const Path &filename) : UIBaseDialogScreen(filename) {} void DisplayLayoutScreen::DrawBackground(UIContext &dc) { if (PSP_GetBootState() == BootState::Complete && !g_Config.bSkipBufferEffects) { @@ -181,7 +182,7 @@ static std::string PostShaderTranslateName(std::string_view value) { } void DisplayLayoutScreen::sendMessage(UIMessage message, const char *value) { - UIDialogScreenWithGameBackground::sendMessage(message, value); + UIBaseDialogScreen::sendMessage(message, value); if (message == UIMessage::POSTSHADER_UPDATED) { g_Config.bShaderChainRequires60FPS = PostShaderChainRequires60FPS(GetFullPostShadersChain(g_Config.vPostShaderNames)); RecreateViews(); diff --git a/UI/DisplayLayoutScreen.h b/UI/DisplayLayoutScreen.h index be6e875770..ac9b07e8c5 100644 --- a/UI/DisplayLayoutScreen.h +++ b/UI/DisplayLayoutScreen.h @@ -21,15 +21,15 @@ #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; } -class DisplayLayoutScreen : public UIDialogScreenWithGameBackground { +class DisplayLayoutScreen : public UIBaseDialogScreen { public: DisplayLayoutScreen(const Path &filename); void CreateViews() override; diff --git a/UI/DriverManagerScreen.cpp b/UI/DriverManagerScreen.cpp index 05924d2136..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()) { @@ -142,7 +146,7 @@ DriverChoice::DriverChoice(const std::string &driverName, bool current, UI::Layo } } -DriverManagerScreen::DriverManagerScreen(const Path & gamePath) : TabbedUIDialogScreenWithGameBackground(gamePath) {} +DriverManagerScreen::DriverManagerScreen(const Path & gamePath) : UITabbedBaseDialogScreen(gamePath) {} void DriverManagerScreen::CreateTabs() { using namespace UI; diff --git a/UI/DriverManagerScreen.h b/UI/DriverManagerScreen.h index 2570e104f2..42e666be16 100644 --- a/UI/DriverManagerScreen.h +++ b/UI/DriverManagerScreen.h @@ -3,12 +3,12 @@ #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 // per game. -class DriverManagerScreen : public TabbedUIDialogScreenWithGameBackground { +class DriverManagerScreen : public UITabbedBaseDialogScreen { public: DriverManagerScreen(const Path &gamePath); 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 7421603de8..66e28b9779 100644 --- a/UI/GPUDriverTestScreen.h +++ b/UI/GPUDriverTestScreen.h @@ -7,10 +7,10 @@ #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 UIDialogScreenWithBackground { +class GPUDriverTestScreen : public UIBaseDialogScreen { public: GPUDriverTestScreen(); ~GPUDriverTestScreen(); diff --git a/UI/GameScreen.cpp b/UI/GameScreen.cpp index b5fa6e1f1b..9068ec7d3a 100644 --- a/UI/GameScreen.cpp +++ b/UI/GameScreen.cpp @@ -41,11 +41,13 @@ #include "Core/HLE/Plugins.h" #include "Core/Util/RecentFiles.h" #include "UI/OnScreenDisplay.h" +#include "UI/Background.h" #include "UI/CwCheatScreen.h" #include "UI/EmuScreen.h" #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" @@ -53,7 +55,7 @@ constexpr GameInfoFlags g_desiredFlags = GameInfoFlags::PARAM_SFO | GameInfoFlags::ICON | GameInfoFlags::PIC0 | GameInfoFlags::PIC1 | GameInfoFlags::UNCOMPRESSED_SIZE | GameInfoFlags::SIZE; -GameScreen::GameScreen(const Path &gamePath, bool inGame) : UIDialogScreenWithGameBackground(gamePath), inGame_(inGame) { +GameScreen::GameScreen(const Path &gamePath, bool inGame) : UIBaseDialogScreen(gamePath), inGame_(inGame) { g_BackgroundAudio.SetGame(gamePath); System_PostUIMessage(UIMessage::GAME_SELECTED, gamePath.ToString()); diff --git a/UI/GameScreen.h b/UI/GameScreen.h index 1024f08b90..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" @@ -33,7 +33,7 @@ class NoticeView; // Uses GameInfoCache heavily to implement the functionality. // Should possibly merge this with the PauseScreen. -class GameScreen : public UIDialogScreenWithGameBackground { +class GameScreen : public UIBaseDialogScreen { public: GameScreen(const Path &gamePath, bool inGame); ~GameScreen(); diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 285d369857..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" @@ -60,6 +60,7 @@ #include "UI/RetroAchievementScreens.h" #include "UI/OnScreenDisplay.h" #include "UI/DiscordIntegration.h" +#include "UI/Background.h" #include "UI/BackgroundAudio.h" #include "Common/File/FileUtil.h" @@ -115,7 +116,7 @@ void SetMemStickDirDarwin(int requesterToken) { #endif GameSettingsScreen::GameSettingsScreen(const Path &gamePath, std::string gameID, bool editThenRestore) - : TabbedUIDialogScreenWithGameBackground(gamePath), gameID_(gameID), editThenRestore_(editThenRestore) { + : UITabbedBaseDialogScreen(gamePath), gameID_(gameID), editThenRestore_(editThenRestore) { prevInflightFrames_ = g_Config.iInflightFrames; analogSpeedMapped_ = KeyMap::InputMappingsFromPspButton(VIRTKEY_SPEED_ANALOG, nullptr, true); } diff --git a/UI/GameSettingsScreen.h b/UI/GameSettingsScreen.h index 8cec893d88..bbf46e7bde 100644 --- a/UI/GameSettingsScreen.h +++ b/UI/GameSettingsScreen.h @@ -23,15 +23,16 @@ #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; // Per-game settings screen - enables you to configure graphic options, control options, etc // per game. -class GameSettingsScreen : public TabbedUIDialogScreenWithGameBackground { +class GameSettingsScreen : public UITabbedBaseDialogScreen { public: GameSettingsScreen(const Path &gamePath, std::string gameID = "", bool editThenRestore = false); @@ -183,9 +184,9 @@ private: }; -class GestureMappingScreen : public UIDialogScreenWithGameBackground { +class GestureMappingScreen : public UIBaseDialogScreen { public: - GestureMappingScreen(const Path &gamePath) : UIDialogScreenWithGameBackground(gamePath) {} + GestureMappingScreen(const Path &gamePath) : UIBaseDialogScreen(gamePath) {} void CreateViews() override; const char *tag() const override { return "GestureMapping"; } 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 f4143bbd95..51dd91a740 100644 --- a/UI/IAPScreen.h +++ b/UI/IAPScreen.h @@ -4,9 +4,9 @@ #include "ppsspp_config.h" -#include "UI/MiscScreens.h" +#include "UI/BaseScreens.h" -class IAPScreen : public UIDialogScreenWithBackground { +class IAPScreen : public UIBaseDialogScreen { public: void CreateViews() override; const char *tag() const override { return "IAP"; } diff --git a/UI/InstallZipScreen.cpp b/UI/InstallZipScreen.cpp index a64c7ee573..81667099f7 100644 --- a/UI/InstallZipScreen.cpp +++ b/UI/InstallZipScreen.cpp @@ -258,5 +258,5 @@ void InstallZipScreen::update() { std::shared_ptr ginfo = g_gameInfoCache->GetInfo(screenManager()->getDrawContext(), savedataToOverwrite_, GameInfoFlags::FILE_TYPE | GameInfoFlags::PARAM_SFO | GameInfoFlags::ICON | GameInfoFlags::SIZE); existingSaveView_->UpdateGame(ginfo.get()); } - UIDialogScreenWithBackground::update(); + UIBaseDialogScreen::update(); } diff --git a/UI/InstallZipScreen.h b/UI/InstallZipScreen.h index 6a6be5e4ab..87231de943 100644 --- a/UI/InstallZipScreen.h +++ b/UI/InstallZipScreen.h @@ -24,11 +24,11 @@ #include "Common/UI/View.h" #include "Common/UI/UIScreen.h" -#include "UI/MiscScreens.h" +#include "UI/BaseScreens.h" class SavedataView; -class InstallZipScreen : public UIDialogScreenWithBackground { +class InstallZipScreen : public UIBaseDialogScreen { public: InstallZipScreen(const Path &zipPath); void update() override; diff --git a/UI/JitCompareScreen.cpp b/UI/JitCompareScreen.cpp index 5386b5ec15..2060abdf7e 100644 --- a/UI/JitCompareScreen.cpp +++ b/UI/JitCompareScreen.cpp @@ -1,14 +1,17 @@ #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() : TabbedUIDialogScreenWithGameBackground(Path()) { +JitCompareScreen::JitCompareScreen() : UITabbedBaseDialogScreen(Path()) { if (!MIPSComp::jit) { return; } diff --git a/UI/JitCompareScreen.h b/UI/JitCompareScreen.h index 8b1278b29d..189f47426f 100644 --- a/UI/JitCompareScreen.h +++ b/UI/JitCompareScreen.h @@ -1,9 +1,9 @@ #pragma once #include "Common/UI/UIScreen.h" -#include "UI/MiscScreens.h" +#include "UI/BaseScreens.h" #include "UI/TabbedDialogScreen.h" -class JitCompareScreen : public TabbedUIDialogScreenWithGameBackground { +class JitCompareScreen : public UITabbedBaseDialogScreen { public: JitCompareScreen(); void CreateTabs() override; diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index bf16d1ad22..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" @@ -1200,8 +1200,9 @@ void MainScreen::CreateMainButtons(UI::ViewGroup *parent, bool vertical) { parent->Add(new Spacer(25.0)); } -#if !PPSSPP_PLATFORM(IOS_APP_STORE) +#if !PPSSPP_PLATFORM(IOS_APP_STORE) && !PPSSPP_PLATFORM(ANDROID) // Officially, iOS apps should not have exit buttons. Remove it to maximize app store review chances. + // Additionally, the Exit button creates problems on Android. parent->Add(new Choice(mm->T("Exit"), vertical ? new LinearLayoutParams() : nullptr))->OnClick.Handle(this, &MainScreen::OnExit); #endif } @@ -1365,7 +1366,7 @@ bool MainScreen::key(const KeyInput &touch) { searchKeyModifier_ = false; } - return UIScreenWithBackground::key(touch); + return UIBaseScreen::key(touch); } void MainScreen::OnAllowStorage(UI::EventParams &e) { @@ -1374,7 +1375,7 @@ void MainScreen::OnAllowStorage(UI::EventParams &e) { void MainScreen::sendMessage(UIMessage message, const char *value) { // Always call the base class method first to handle the most common messages. - UIScreenWithBackground::sendMessage(message, value); + UIBaseScreen::sendMessage(message, value); if (message == UIMessage::REQUEST_GAME_BOOT) { LaunchFile(screenManager(), this, Path(value)); diff --git a/UI/MainScreen.h b/UI/MainScreen.h index ed918b6142..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 { @@ -118,7 +118,7 @@ private: class RemoteISOBrowseScreen; -class MainScreen : public UIScreenWithBackground { +class MainScreen : public UIBaseScreen { public: MainScreen(); ~MainScreen(); @@ -180,7 +180,7 @@ protected: friend class RemoteISOBrowseScreen; }; -class UmdReplaceScreen : public UIDialogScreenWithBackground { +class UmdReplaceScreen : public UIBaseDialogScreen { public: const char *tag() const override { return "UmdReplace"; } diff --git a/UI/MemStickScreen.cpp b/UI/MemStickScreen.cpp index aa1f6ccb22..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) { @@ -447,7 +448,7 @@ void MemStickScreen::dialogFinished(const Screen *dialog, DialogResult result) { } void MemStickScreen::update() { - UIDialogScreenWithBackground::update(); + UIBaseDialogScreen::update(); if (done_) { TriggerFinish(DialogResult::DR_OK); done_ = false; @@ -567,7 +568,7 @@ void ConfirmMemstickMoveScreen::OnMoveDataClick(UI::EventParams ¶ms) { } void ConfirmMemstickMoveScreen::update() { - UIDialogScreenWithBackground::update(); + UIBaseDialogScreen::update(); auto ms = GetI18NCategory(I18NCat::MEMSTICK); if (moveDataTask_) { diff --git a/UI/MemStickScreen.h b/UI/MemStickScreen.h index d8ddb88c00..b014b49024 100644 --- a/UI/MemStickScreen.h +++ b/UI/MemStickScreen.h @@ -29,13 +29,14 @@ #include "Core/Util/MemStick.h" -#include "UI/MiscScreens.h" +#include "UI/BaseScreens.h" +#include "UI/MiscViews.h" class NoticeView; // MemStickScreen - let's you configure your memory stick directory. // Currently only useful for Android. -class MemStickScreen : public UIDialogScreenWithBackground { +class MemStickScreen : public UIBaseDialogScreen { public: MemStickScreen(bool initialSetup); ~MemStickScreen() = default; @@ -58,7 +59,7 @@ protected: // Simple anti-flicker due to delayed finish. if (!done_) { // render as usual. - return UIDialogScreenWithBackground::render(mode); + return UIBaseDialogScreen::render(mode); } else { // no render. black frame insertion is better than flicker. } @@ -97,7 +98,7 @@ struct SpaceResult { int64_t bytesFree; }; -class ConfirmMemstickMoveScreen : public UIDialogScreenWithBackground { +class ConfirmMemstickMoveScreen : public UIBaseDialogScreen { public: ConfirmMemstickMoveScreen(const Path &newMemstickFolder, bool initialSetup); ~ConfirmMemstickMoveScreen(); diff --git a/UI/MiscScreens.cpp b/UI/MiscScreens.cpp index f3c5be363a..1efa2ce861 100644 --- a/UI/MiscScreens.cpp +++ b/UI/MiscScreens.cpp @@ -37,7 +37,6 @@ #include "Common/Data/Color/RGBAUtil.h" #include "Common/Data/Encoding/Utf8.h" #include "Common/Data/Text/I18n.h" -#include "Common/Data/Random/Rng.h" #include "Common/TimeUtil.h" #include "Common/File/FileUtil.h" #include "Common/Render/ManagedTexture.h" @@ -52,460 +51,15 @@ #include "GPU/Common/PostShader.h" #include "UI/ControlMappingScreen.h" +#include "UI/Background.h" #include "UI/DisplayLayoutScreen.h" #include "UI/EmuScreen.h" -#include "UI/GameInfoCache.h" #include "UI/GameSettingsScreen.h" #include "UI/MainScreen.h" #include "UI/MiscScreens.h" #include "UI/MemStickScreen.h" #include "UI/MiscViews.h" -#ifdef _MSC_VER -#pragma execution_character_set("utf-8") -#endif - -static Draw::Texture *bgTexture; - -class Animation { -public: - virtual ~Animation() = default; - virtual void Draw(UIContext &dc, double t, float alpha, float x, float y, float z) = 0; -}; - -class MovingBackground : public Animation { -public: - void Draw(UIContext &dc, double t, float alpha, float x, float y, float z) override { - if (!bgTexture) - return; - - dc.Flush(); - dc.GetDrawContext()->BindTexture(0, bgTexture); - Bounds bounds = dc.GetBounds(); - - x = std::min(std::max(x/bounds.w, 0.0f), 1.0f) * XFAC; - y = std::min(std::max(y/bounds.h, 0.0f), 1.0f) * YFAC; - z = 1.0f + std::max(XFAC, YFAC) + (z-1.0f) * ZFAC; - - lastX_ = abs(x-lastX_) > 0.001f ? x*XSPEED+lastX_*(1.0f-XSPEED) : x; - lastY_ = abs(y-lastY_) > 0.001f ? y*YSPEED+lastY_*(1.0f-YSPEED) : y; - lastZ_ = abs(z-lastZ_) > 0.001f ? z*ZSPEED+lastZ_*(1.0f-ZSPEED) : z; - - float u1 = lastX_/lastZ_; - float v1 = lastY_/lastZ_; - float u2 = (1.0f+lastX_)/lastZ_; - float v2 = (1.0f+lastY_)/lastZ_; - - dc.Draw()->DrawTexRect(bounds, u1, v1, u2, v2, whiteAlpha(alpha)); - - dc.Flush(); - dc.RebindTexture(); - } - -private: - static constexpr float XFAC = 0.3f; - static constexpr float YFAC = 0.3f; - static constexpr float ZFAC = 0.12f; - static constexpr float XSPEED = 0.05f; - static constexpr float YSPEED = 0.05f; - static constexpr float ZSPEED = 0.1f; - - float lastX_ = 0.0f; - float lastY_ = 0.0f; - float lastZ_ = 1.0f + std::max(XFAC, YFAC); -}; - -class WaveAnimation : public Animation { -public: - void Draw(UIContext &dc, double t, float alpha, float x, float y, float z) override { - const uint32_t color = colorAlpha(0xFFFFFFFF, alpha * 0.2f); - const float speed = 1.0; - - Bounds bounds = dc.GetBounds(); - dc.Flush(); - dc.BeginNoTex(); - - // 500 is enough for any resolution really. 24 * 500 = 12000 which fits handily in our UI vertex buffer (max 65536 per flush). - const int steps = std::max(20, std::min((int)g_display.dp_xres, 500)); - float step = (float)g_display.dp_xres / (float)steps; - t *= speed; - - for (int n = 0; n < steps; n++) { - float x = (float)n * step; - float nextX = (float)(n + 1) * step; - float i = x * 1280 / bounds.w; - - float wave0 = sin(i*0.005+t*0.8)*0.05 + sin(i*0.002+t*0.25)*0.02 + sin(i*0.001+t*0.3)*0.03 + 0.625; - float wave1 = sin(i*0.0044+t*0.4)*0.07 + sin(i*0.003+t*0.1)*0.02 + sin(i*0.001+t*0.3)*0.01 + 0.625; - dc.Draw()->RectVGradient(x, wave0*bounds.h, nextX, bounds.h, color, 0x00000000); - dc.Draw()->RectVGradient(x, wave1*bounds.h, nextX, bounds.h, color, 0x00000000); - - // Add some "antialiasing" - dc.Draw()->RectVGradient(x, wave0*bounds.h-3.0f * g_display.pixel_in_dps_y, nextX, wave0 * bounds.h, 0x00000000, color); - dc.Draw()->RectVGradient(x, wave1*bounds.h-3.0f * g_display.pixel_in_dps_y, nextX, wave1 * bounds.h, 0x00000000, color); - } - - dc.Flush(); - dc.Begin(); - } -}; - -class FloatingSymbolsAnimation : public Animation { -public: - FloatingSymbolsAnimation(bool is_colored) { - this->is_colored = is_colored; - } - - void Draw(UIContext &dc, double t, float alpha, float x, float y, float z) override { - dc.Flush(); - dc.Begin(); - float xres = dc.GetBounds().w; - float yres = dc.GetBounds().h; - if (last_xres != xres || last_yres != yres) { - Regenerate(xres, yres); - } - - for (int i = 0; i < COUNT; i++) { - float x = xbase[i] + dc.GetBounds().x; - float y = ybase[i] + dc.GetBounds().y + 40 * cosf(i * 7.2f + t * 1.3f); - float angle = (float)sin(i + t); - int n = i & 3; - Color color = is_colored ? colorAlpha(COLORS[n], alpha * 0.25f) : colorAlpha(DEFAULT_COLOR, alpha * 0.1f); - ui_draw2d.DrawImageRotated(SYMBOLS[n], x, y, 1.0f, angle, color); - } - dc.Flush(); - } - -private: - static constexpr int COUNT = 100; - static constexpr Color DEFAULT_COLOR = 0xC0FFFFFF; - static constexpr Color COLORS[4] = { 0xFFE3B56F, 0xFF615BFF, 0xFFAA88F3, 0xFFC2CC7A, }; // X O D A - static const ImageID SYMBOLS[4]; - - bool is_colored = false; - float xbase[COUNT]{}; - float ybase[COUNT]{}; - float last_xres = 0; - float last_yres = 0; - - void Regenerate(int xres, int yres) { - GMRng rng; - for (int i = 0; i < COUNT; i++) { - xbase[i] = rng.F() * xres; - ybase[i] = rng.F() * yres; - } - - last_xres = xres; - last_yres = yres; - } -}; - -const ImageID FloatingSymbolsAnimation::SYMBOLS[4] = { - ImageID("I_CROSS"), - ImageID("I_CIRCLE"), - ImageID("I_SQUARE"), - ImageID("I_TRIANGLE"), -}; - -class RecentGamesAnimation : public Animation { -public: - void Draw(UIContext &dc, double t, float alpha, float x, float y, float z) override { - if (lastIndex_ == nextIndex_) { - CheckNext(dc, t); - } else if (t > nextT_) { - lastIndex_ = nextIndex_; - } - - if (g_recentFiles.HasAny()) { - std::shared_ptr lastInfo = GetInfo(dc, lastIndex_); - std::shared_ptr nextInfo = GetInfo(dc, nextIndex_); - dc.Flush(); - - float lastAmount = Clamp((float)(nextT_ - t) * 1.0f / TRANSITION, 0.0f, 1.0f); - DrawTex(dc, lastInfo, lastAmount * alpha * 0.2f); - - float nextAmount = lastAmount <= 0.0f ? 1.0f : 1.0f - lastAmount; - DrawTex(dc, nextInfo, nextAmount * alpha * 0.2f); - - dc.RebindTexture(); - } - } - -private: - void CheckNext(UIContext &dc, double t) { - if (!g_recentFiles.HasAny()) { - return; - } - - std::vector recents = g_recentFiles.GetRecentFiles(); - - for (int index = lastIndex_ + 1; index != lastIndex_; ++index) { - if (index < 0 || index >= (int)recents.size()) { - if (lastIndex_ == -1) - break; - index = 0; - } - - std::shared_ptr ginfo = GetInfo(dc, index); - if (ginfo && !ginfo->Ready(GameInfoFlags::PIC1)) { - // Wait for it to load. It might be the next one. - break; - } - if (ginfo && ginfo->pic1.texture) { - nextIndex_ = index; - nextT_ = t + INTERVAL; - break; - } - - // Otherwise, keep going. This skips games with no BG. - } - } - - static std::shared_ptr GetInfo(UIContext &dc, int index) { - if (index < 0) { - return nullptr; - } - const auto recentIsos = g_recentFiles.GetRecentFiles(); - if (index >= (int)recentIsos.size()) - return std::shared_ptr(); - return g_gameInfoCache->GetInfo(dc.GetDrawContext(), Path(recentIsos[index]), GameInfoFlags::PIC1); - } - - static void DrawTex(UIContext &dc, std::shared_ptr &ginfo, float amount) { - if (!ginfo || amount <= 0.0f) - return; - GameInfoTex *pic = ginfo->GetPIC1(); - if (!pic) - return; - - dc.GetDrawContext()->BindTexture(0, pic->texture); - uint32_t color = whiteAlpha(amount) & 0xFFc0c0c0; - dc.Draw()->DrawTexRect(dc.GetBounds(), 0, 0, 1, 1, color); - dc.Flush(); - } - - static constexpr double INTERVAL = 8.0; - static constexpr float TRANSITION = 3.0f; - - int lastIndex_ = -1; - int nextIndex_ = -1; - double nextT_ = -INTERVAL; -}; - -class BouncingIconAnimation : public Animation { - public: - void Draw(UIContext &dc, double t, float alpha, float x, float y, float z) override { - dc.Flush(); - dc.Begin(); - - // Handle change in resolution. - float xres = dc.GetBounds().w; - float yres = dc.GetBounds().h; - if (last_xres != xres || last_yres != yres) { - Recalculate(xres, yres); - } - - // Draw the image. - float xpos = xbase + dc.GetBounds().x; - float ypos = ybase + dc.GetBounds().y; - ImageID icon = !color_ix && System_GetPropertyBool(SYSPROP_APP_GOLD) ? ImageID("I_ICON_GOLD") : ImageID("I_ICON"); - ui_draw2d.DrawImage(icon, xpos, ypos, scale, COLORS[color_ix], ALIGN_CENTER); - dc.Flush(); - - // Switch direction if within border. - bool should_recolor = true; - if (xbase > xres - border || xbase < border) { - xspeed *= -1.0f; - RandomizeColor(); - should_recolor = false; - } - - if (ybase > yres - border || ybase < border) { - yspeed *= -1.0f; - - if (should_recolor) { - RandomizeColor(); - } - } - - // Place to border if out of bounds. - if (xbase > xres - border) xbase = xres - border; - else if (xbase < border) xbase = border; - if (ybase > yres - border) ybase = yres - border; - else if (ybase < border) ybase = border; - - // Update location. - xbase += xspeed; - ybase += yspeed; - } - - private: - static constexpr int COLOR_COUNT = 11; - static constexpr Color COLORS[COLOR_COUNT] = { 0xFFFFFFFF, 0xFFFFFF00, 0xFFFF0000, 0xFF00FF00, 0xFF0000FF, - 0xFF00FFFF, 0xFFFF00FF, 0xFF4111D1, 0xFF3577F3, 0xFFAA77FF, 0xFF623B84 }; - - float xbase = 0.0f; - float ybase = 0.0f; - float last_xres = 0.0f; - float last_yres = 0.0f; - float xspeed = 1.0f; - float yspeed = 1.0f; - float scale = 1.0f; - float border = 35.0f; - int color_ix = 0; - int last_color_ix = -1; - GMRng rng; - - void Recalculate(int xres, int yres) { - // First calculation. - if (last_color_ix == -1) { - xbase = xres / 2.0f; - ybase = yres / 2.0f; - last_color_ix = 0; - - // Determine initial direction. - if ((int)(rng.F() * xres) % 2) xspeed *= -1.0f; - if ((int)(rng.F() * yres) % 2) yspeed *= -1.0f; - } - - // Scale certain attributes to resolution. - scale = std::min(xres, yres) / 400.0f; - float speed = scale < 2.5f ? scale * 0.58f : scale * 0.46f; - xspeed = std::signbit(xspeed) ? speed * -1.0f : speed; - yspeed = std::signbit(yspeed) ? speed * -1.0f : speed; - border = 35.0f * scale; - - last_xres = xres; - last_yres = yres; - } - - void RandomizeColor() { - do { - color_ix = (int)(rng.F() * xbase) % COLOR_COUNT; - } while (color_ix == last_color_ix); - - last_color_ix = color_ix; - } -}; - -// TODO: Add more styles. Remember to add to the enum in ConfigValues.h and the selector in GameSettings too. - -static BackgroundAnimation g_CurBackgroundAnimation = BackgroundAnimation::OFF; -static std::unique_ptr g_Animation; -static bool bgTextureInited = false; // Separate variable because init could fail. - -void UIBackgroundInit(UIContext &dc) { - const Path bgPng = GetSysDirectory(DIRECTORY_SYSTEM) / "background.png"; - const Path bgJpg = GetSysDirectory(DIRECTORY_SYSTEM) / "background.jpg"; - if (File::Exists(bgPng) || File::Exists(bgJpg)) { - const Path &bgFile = File::Exists(bgPng) ? bgPng : bgJpg; - bgTexture = CreateTextureFromFile(dc.GetDrawContext(), bgFile.c_str(), ImageFileType::DETECT, true); - } -} - -void UIBackgroundShutdown() { - if (bgTexture) { - bgTexture->Release(); - bgTexture = nullptr; - } - bgTextureInited = false; - g_Animation.reset(nullptr); - g_CurBackgroundAnimation = BackgroundAnimation::OFF; -} - -void DrawBackground(UIContext &dc, float alpha, float x, float y, float z) { - if (!bgTextureInited) { - UIBackgroundInit(dc); - bgTextureInited = true; - } - if (g_CurBackgroundAnimation != (BackgroundAnimation)g_Config.iBackgroundAnimation) { - g_CurBackgroundAnimation = (BackgroundAnimation)g_Config.iBackgroundAnimation; - - switch (g_CurBackgroundAnimation) { - case BackgroundAnimation::FLOATING_SYMBOLS: - g_Animation.reset(new FloatingSymbolsAnimation(false)); - break; - case BackgroundAnimation::RECENT_GAMES: - g_Animation.reset(new RecentGamesAnimation()); - break; - case BackgroundAnimation::WAVE: - g_Animation.reset(new WaveAnimation()); - break; - case BackgroundAnimation::MOVING_BACKGROUND: - g_Animation.reset(new MovingBackground()); - break; - case BackgroundAnimation::BOUNCING_ICON: - g_Animation.reset(new BouncingIconAnimation()); - break; - case BackgroundAnimation::FLOATING_SYMBOLS_COLORED: - g_Animation.reset(new FloatingSymbolsAnimation(true)); - break; - default: - g_Animation.reset(nullptr); - } - } - - uint32_t bgColor = whiteAlpha(alpha); - - if (bgTexture != nullptr) { - dc.Flush(); - dc.Begin(); - dc.GetDrawContext()->BindTexture(0, bgTexture); - dc.Draw()->DrawTexRect(dc.GetBounds(), 0, 0, 1, 1, bgColor); - - dc.Flush(); - dc.RebindTexture(); - } else { - // I_BG original color: 0xFF754D24 - ImageID img = ImageID("I_BG"); - dc.Begin(); - dc.Draw()->DrawImageStretch(img, dc.GetBounds(), bgColor & dc.GetTheme().backgroundColor); - dc.Flush(); - } - -#if PPSSPP_PLATFORM(IOS) - // iOS uses an old screenshot when restoring the task, so to avoid an ugly - // jitter we accumulate time instead. - static int frameCount = 0.0; - frameCount++; - double t = (double)frameCount / System_GetPropertyFloat(SYSPROP_DISPLAY_REFRESH_RATE); -#else - double t = time_now_d(); -#endif - - if (g_Animation) { - g_Animation->Draw(dc, t, alpha, x, y, z); - } -} - -uint32_t GetBackgroundColorWithAlpha(const UIContext &dc) { - return colorAlpha(colorBlend(dc.GetTheme().backgroundColor, 0, 0.5f), 0.65f); // 0.65 = 166 = A6 -} - -void DrawGameBackground(UIContext &dc, const Path &gamePath, float x, float y, float z) { - using namespace Draw; - using namespace UI; - dc.Flush(); - - std::shared_ptr ginfo; - if (!gamePath.empty()) { - ginfo = g_gameInfoCache->GetInfo(dc.GetDrawContext(), gamePath, GameInfoFlags::PIC1); - } - - GameInfoTex *pic = (ginfo && ginfo->Ready(GameInfoFlags::PIC1)) ? ginfo->GetPIC1() : nullptr; - if (pic) { - dc.GetDrawContext()->BindTexture(0, pic->texture); - uint32_t color = whiteAlpha(ease((time_now_d() - pic->timeLoaded) * 3)) & 0xFFc0c0c0; - dc.Draw()->DrawTexRect(dc.GetBounds(), 0,0,1,1, color); - dc.Flush(); - dc.RebindTexture(); - } else { - ::DrawBackground(dc, 1.0f, x, y, z); - dc.RebindTexture(); - dc.Flush(); - } -} - void HandleCommonMessages(UIMessage message, const char *value, ScreenManager *manager, const Screen *activeScreen) { bool isActiveScreen = manager->topScreen() == activeScreen; @@ -585,38 +139,26 @@ void BackgroundScreen::sendMessage(UIMessage message, const char *value) { } } -void UIScreenWithGameBackground::sendMessage(UIMessage message, const char *value) { +void UIBaseDialogScreen::sendMessage(UIMessage message, const char *value) { if (message == UIMessage::SHOW_SETTINGS && screenManager()->topScreen() == this) { screenManager()->push(new GameSettingsScreen(gamePath_)); } else { - UIScreenWithBackground::sendMessage(message, value); + HandleCommonMessages(message, value, screenManager(), this); } } -void UIDialogScreenWithGameBackground::sendMessage(UIMessage message, const char *value) { - if (message == UIMessage::SHOW_SETTINGS && screenManager()->topScreen() == this) { - screenManager()->push(new GameSettingsScreen(gamePath_)); - } else { - UIDialogScreenWithBackground::sendMessage(message, value); - } -} - -void UIScreenWithBackground::sendMessage(UIMessage message, const char *value) { +void UIBaseScreen::sendMessage(UIMessage message, const char *value) { HandleCommonMessages(message, value, screenManager(), this); } -void UIDialogScreenWithBackground::AddStandardBack(UI::ViewGroup *parent) { +void UIBaseDialogScreen::AddStandardBack(UI::ViewGroup *parent) { using namespace UI; auto di = GetI18NCategory(I18NCat::DIALOG); parent->Add(new Choice(di->T("Back"), "", false, new AnchorLayoutParams(190, WRAP_CONTENT, 10, NONE, NONE, 10)))->OnClick.Handle(this, &UIScreen::OnBack); } -void UIDialogScreenWithBackground::sendMessage(UIMessage message, const char *value) { - HandleCommonMessages(message, value, screenManager(), this); -} - PromptScreen::PromptScreen(const Path &gamePath, std::string_view message, std::string_view yesButtonText, std::string_view noButtonText, std::function callback) - : UIDialogScreenWithGameBackground(gamePath), message_(message), callback_(callback) { + : UIBaseDialogScreen(gamePath), message_(message), callback_(callback) { yesButtonText_ = yesButtonText; noButtonText_ = noButtonText; } @@ -670,7 +212,7 @@ void PromptScreen::TriggerFinish(DialogResult result) { if (callback_) { callback_(result == DR_OK || result == DR_YES); } - UIDialogScreenWithBackground::TriggerFinish(result); + UIBaseDialogScreen::TriggerFinish(result); } TextureShaderScreen::TextureShaderScreen(std::string_view title) : ListPopupScreen(title) {} @@ -1194,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 078323f736..bf8593d57c 100644 --- a/UI/MiscScreens.h +++ b/UI/MiscScreens.h @@ -26,14 +26,11 @@ #include "Common/UI/PopupScreens.h" #include "Common/File/DirListing.h" #include "Common/File/Path.h" +#include "UI/BaseScreens.h" struct ShaderInfo; struct TextureShaderInfo; -extern Path boot_filename; -void UIBackgroundInit(UIContext &dc); -void UIBackgroundShutdown(); - inline void NoOpVoidBool(bool) {} class BackgroundScreen : public UIScreen { @@ -48,46 +45,9 @@ private: Path gamePath_; }; -// This doesn't have anything to do with the background anymore. It's just a PPSSPP UIScreen -// that knows how handle sendMessage properly. Same for all the below. -class UIScreenWithBackground : public UIScreen { +class PromptScreen : public UIBaseDialogScreen { public: - UIScreenWithBackground() : UIScreen() {} -protected: - void sendMessage(UIMessage message, const char *value) override; -}; - -class UIScreenWithGameBackground : public UIScreenWithBackground { -public: - UIScreenWithGameBackground(const Path &gamePath) : UIScreenWithBackground(), gamePath_(gamePath) {} - void sendMessage(UIMessage message, const char *value) override; -protected: - Path gamePath_; - - bool forceTransparent_ = false; - bool darkenGameBackground_ = true; -}; - -class UIDialogScreenWithBackground : public UIDialogScreen { -public: - UIDialogScreenWithBackground() : UIDialogScreen() {} -protected: - void sendMessage(UIMessage message, const char *value) override; - void AddStandardBack(UI::ViewGroup *parent); -}; - -class UIDialogScreenWithGameBackground : public UIDialogScreenWithBackground { -public: - UIDialogScreenWithGameBackground(const Path &gamePath) - : UIDialogScreenWithBackground(), gamePath_(gamePath) {} - void sendMessage(UIMessage message, const char *value) override; -protected: - Path gamePath_; -}; - -class PromptScreen : public UIDialogScreenWithGameBackground { -public: - PromptScreen(const Path& gamePath, std::string_view message, std::string_view yesButtonText, std::string_view noButtonText, + PromptScreen(const Path &gamePath, std::string_view message, std::string_view yesButtonText, std::string_view noButtonText, std::function callback = &NoOpVoidBool); void CreateViews() override; @@ -156,7 +116,7 @@ private: AfterLogoScreen afterLogoScreen_; }; -class CreditsScreen : public UIDialogScreenWithBackground { +class CreditsScreen : public UIBaseDialogScreen { public: void update() override; @@ -164,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 ccbb3460ca..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" @@ -116,6 +117,7 @@ #include "GPU/GPUCommon.h" #include "GPU/Common/PresentationCommon.h" #include "UI/AudioCommon.h" +#include "UI/Background.h" #include "UI/BackgroundAudio.h" #include "UI/ControlMappingScreen.h" #include "UI/DevScreens.h" diff --git a/UI/PauseScreen.cpp b/UI/PauseScreen.cpp index 1621db9da7..3f9f8fe809 100644 --- a/UI/PauseScreen.cpp +++ b/UI/PauseScreen.cpp @@ -328,7 +328,7 @@ void GamePauseScreen::update() { } GamePauseScreen::GamePauseScreen(const Path &filename, bool bootPending) - : UIDialogScreenWithGameBackground(filename), bootPending_(bootPending) { + : UIBaseDialogScreen(filename), bootPending_(bootPending) { // So we can tell if something blew up while on the pause screen. std::string assertStr = "PauseScreen: " + filename.GetFilename(); SetExtraAssertInfo(assertStr.c_str()); diff --git a/UI/PauseScreen.h b/UI/PauseScreen.h index 02da801069..90a99f94bf 100644 --- a/UI/PauseScreen.h +++ b/UI/PauseScreen.h @@ -23,10 +23,10 @@ #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 UIDialogScreenWithGameBackground { +class GamePauseScreen : public UIBaseDialogScreen { public: GamePauseScreen(const Path &filename, bool bootPending); ~GamePauseScreen(); diff --git a/UI/RemoteISOScreen.cpp b/UI/RemoteISOScreen.cpp index 0735ab70c4..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" @@ -270,7 +271,7 @@ static bool LoadGameList(const Path &url, std::vector &games) { return !games.empty(); } -RemoteISOScreen::RemoteISOScreen(const Path &filename) : TabbedUIDialogScreenWithGameBackground(filename) {} +RemoteISOScreen::RemoteISOScreen(const Path &filename) : UITabbedBaseDialogScreen(filename) {} void RemoteISOScreen::CreateTabs() { @@ -287,7 +288,7 @@ void RemoteISOScreen::CreateTabs() { } void RemoteISOScreen::update() { - TabbedUIDialogScreenWithGameBackground::update(); + UITabbedBaseDialogScreen::update(); frameCount_++; @@ -499,7 +500,7 @@ void RemoteISOConnectScreen::CreateViews() { void RemoteISOConnectScreen::update() { auto ri = GetI18NCategory(I18NCat::REMOTEISO); - UIDialogScreenWithBackground::update(); + UIBaseDialogScreen::update(); ScanStatus s = GetStatus(); switch (s) { diff --git a/UI/RemoteISOScreen.h b/UI/RemoteISOScreen.h index 401a6c96e9..37476af39d 100644 --- a/UI/RemoteISOScreen.h +++ b/UI/RemoteISOScreen.h @@ -22,11 +22,11 @@ #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" -class RemoteISOScreen : public TabbedUIDialogScreenWithGameBackground { +class RemoteISOScreen : public UITabbedBaseDialogScreen { public: RemoteISOScreen(const Path &filename); @@ -62,7 +62,7 @@ enum class ScanStatus { LOADED, }; -class RemoteISOConnectScreen : public UIDialogScreenWithBackground { +class RemoteISOConnectScreen : public UIBaseDialogScreen { public: RemoteISOConnectScreen(); ~RemoteISOConnectScreen(); 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 061e044b0b..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" @@ -177,7 +178,7 @@ RetroAchievementsLeaderboardScreen::~RetroAchievementsLeaderboardScreen() { } RetroAchievementsLeaderboardScreen::RetroAchievementsLeaderboardScreen(const Path &gamePath, int leaderboardID) - : TabbedUIDialogScreenWithGameBackground(gamePath), leaderboardID_(leaderboardID) { + : UITabbedBaseDialogScreen(gamePath), leaderboardID_(leaderboardID) { FetchEntries(); } @@ -253,7 +254,7 @@ void RetroAchievementsLeaderboardScreen::Poll() { } void RetroAchievementsLeaderboardScreen::update() { - TabbedUIDialogScreenWithGameBackground::update(); + UITabbedBaseDialogScreen::update(); Poll(); } @@ -279,7 +280,7 @@ void RetroAchievementsSettingsScreen::CreateTabs() { } void RetroAchievementsSettingsScreen::sendMessage(UIMessage message, const char *value) { - TabbedUIDialogScreenWithGameBackground::sendMessage(message, value); + UITabbedBaseDialogScreen::sendMessage(message, value); if (message == UIMessage::ACHIEVEMENT_LOGIN_STATE_CHANGE) { RecreateViews(); diff --git a/UI/RetroAchievementScreens.h b/UI/RetroAchievementScreens.h index 83db9bf811..5debfd8b9c 100644 --- a/UI/RetroAchievementScreens.h +++ b/UI/RetroAchievementScreens.h @@ -7,15 +7,15 @@ #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" // Lists the achievements and leaderboards for one game. -class RetroAchievementsListScreen : public TabbedUIDialogScreenWithGameBackground { +class RetroAchievementsListScreen : public UITabbedBaseDialogScreen { public: - RetroAchievementsListScreen(const Path &gamePath) : TabbedUIDialogScreenWithGameBackground(gamePath) {} + RetroAchievementsListScreen(const Path &gamePath) : UITabbedBaseDialogScreen(gamePath) {} const char *tag() const override { return "RetroAchievementsListScreen"; } void CreateTabs() override; @@ -30,9 +30,9 @@ private: }; // Lets you manage your account, and shows some achievement stats and stuff. -class RetroAchievementsSettingsScreen : public TabbedUIDialogScreenWithGameBackground { +class RetroAchievementsSettingsScreen : public UITabbedBaseDialogScreen { public: - RetroAchievementsSettingsScreen(const Path &gamePath) : TabbedUIDialogScreenWithGameBackground(gamePath) {} + RetroAchievementsSettingsScreen(const Path &gamePath) : UITabbedBaseDialogScreen(gamePath) {} ~RetroAchievementsSettingsScreen(); const char *tag() const override { return "RetroAchievementsSettingsScreen"; } @@ -50,7 +50,7 @@ private: std::string password_; }; -class RetroAchievementsLeaderboardScreen : public TabbedUIDialogScreenWithGameBackground { +class RetroAchievementsLeaderboardScreen : public UITabbedBaseDialogScreen { public: RetroAchievementsLeaderboardScreen(const Path &gamePath, int leaderboardID); ~RetroAchievementsLeaderboardScreen(); diff --git a/UI/SavedataScreen.cpp b/UI/SavedataScreen.cpp index 0d6c62f6dc..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" @@ -711,7 +711,7 @@ void SavedataScreen::dialogFinished(const Screen *dialog, DialogResult result) { } void SavedataScreen::sendMessage(UIMessage message, const char *value) { - UIDialogScreenWithGameBackground::sendMessage(message, value); + UIBaseDialogScreen::sendMessage(message, value); if (message == UIMessage::SAVEDATA_SEARCH) { EnsureTabs(); diff --git a/UI/SavedataScreen.h b/UI/SavedataScreen.h index c7912f722e..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" @@ -67,10 +67,10 @@ private: bool searchPending_ = false; }; -class SavedataScreen : public TabbedUIDialogScreenWithGameBackground { +class SavedataScreen : public UITabbedBaseDialogScreen { public: // gamePath can be empty, in that case this screen will show all savedata in the save directory. - SavedataScreen(const Path &gamePath) : TabbedUIDialogScreenWithGameBackground(gamePath) {} + SavedataScreen(const Path &gamePath) : UITabbedBaseDialogScreen(gamePath) {} ~SavedataScreen(); void dialogFinished(const Screen *dialog, DialogResult result) override; diff --git a/UI/Store.cpp b/UI/Store.cpp index 1eab2a69c3..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" @@ -436,7 +437,7 @@ StoreScreen::~StoreScreen() { // Handle async download tasks void StoreScreen::update() { - UIDialogScreenWithBackground::update(); + UIBaseDialogScreen::update(); g_DownloadManager.Update(); @@ -515,7 +516,7 @@ void StoreScreen::CreateViews() { // Top bar LinearLayout *topBar = root_->Add(new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(FILL_PARENT, 64.0f))); - topBar->Add(new Choice(di->T("Back"), new LinearLayoutParams(WRAP_CONTENT, FILL_PARENT)))->OnClick.Handle(this, &UIScreen::OnBack); + topBar->Add(new Choice(ImageID("I_NAVIGATE_BACK"), new LinearLayoutParams(WRAP_CONTENT, FILL_PARENT)))->OnClick.Handle(this, &UIScreen::OnBack); titleText_ = new TextView(mm->T("PPSSPP Homebrew Store"), ALIGN_VCENTER, false, new LinearLayoutParams(WRAP_CONTENT, FILL_PARENT)); titleText_->SetTextColor(screenManager()->getUIContext()->GetTheme().itemDownStyle.fgColor); topBar->Add(titleText_); @@ -528,9 +529,7 @@ void StoreScreen::CreateViews() { content->Add(new TextView(loading_ ? std::string(st->T("Loading...")) : StringFromFormat("%s: %d", st->T_cstr("Connection Error"), resultCode_))); if (!loading_) { content->Add(new Button(di->T("Retry")))->OnClick.Handle(this, &StoreScreen::OnRetry); - } - content->Add(new Button(di->T("Back")))->OnClick.Handle(this, &UIScreen::OnBack); scrollItemView_ = nullptr; productPanel_ = nullptr; diff --git a/UI/Store.h b/UI/Store.h index 2b18d9de21..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. @@ -60,7 +60,7 @@ struct StoreEntry { u64 size; }; -class StoreScreen : public UIDialogScreenWithBackground { +class StoreScreen : public UIBaseDialogScreen { public: StoreScreen(); ~StoreScreen(); diff --git a/UI/SystemInfoScreen.cpp b/UI/SystemInfoScreen.cpp index 8b78f4245d..524e7ce43b 100644 --- a/UI/SystemInfoScreen.cpp +++ b/UI/SystemInfoScreen.cpp @@ -16,18 +16,19 @@ #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" void SystemInfoScreen::update() { - TabbedUIDialogScreenWithGameBackground::update(); + UITabbedBaseDialogScreen::update(); g_OSD.NudgeSidebar(); } diff --git a/UI/SystemInfoScreen.h b/UI/SystemInfoScreen.h index 626614f8e4..079b8be3a0 100644 --- a/UI/SystemInfoScreen.h +++ b/UI/SystemInfoScreen.h @@ -7,9 +7,9 @@ #include "Common/UI/UIScreen.h" #include "UI/TabbedDialogScreen.h" -class SystemInfoScreen : public TabbedUIDialogScreenWithGameBackground { +class SystemInfoScreen : public UITabbedBaseDialogScreen { public: - SystemInfoScreen(const Path &filename) : TabbedUIDialogScreenWithGameBackground(filename) {} + SystemInfoScreen(const Path &filename) : UITabbedBaseDialogScreen(filename) {} const char *tag() const override { return "SystemInfo"; } diff --git a/UI/TabbedDialogScreen.cpp b/UI/TabbedDialogScreen.cpp index 414daeddd3..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 TabbedUIDialogScreenWithGameBackground::AddTab(const char *tag, std::string_view title, std::function createCallback, TabFlags flags) { +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)); @@ -28,7 +34,7 @@ void TabbedUIDialogScreenWithGameBackground::AddTab(const char *tag, std::string }); } -void TabbedUIDialogScreenWithGameBackground::CreateViews() { +void UITabbedBaseDialogScreen::CreateViews() { PreCreateViews(); bool portrait = UsePortraitLayout() || ForceHorizontalTabs(); @@ -104,8 +110,8 @@ void TabbedUIDialogScreenWithGameBackground::CreateViews() { } } -void TabbedUIDialogScreenWithGameBackground::sendMessage(UIMessage message, const char *value) { - UIDialogScreenWithGameBackground::sendMessage(message, value); +void UITabbedBaseDialogScreen::sendMessage(UIMessage message, const char *value) { + UIBaseDialogScreen::sendMessage(message, value); if (message == UIMessage::GAMESETTINGS_SEARCH) { std::string filter = value ? value : ""; searchFilter_.resize(filter.size()); @@ -115,27 +121,27 @@ void TabbedUIDialogScreenWithGameBackground::sendMessage(UIMessage message, cons } } -void TabbedUIDialogScreenWithGameBackground::RecreateViews() { +void UITabbedBaseDialogScreen::RecreateViews() { oldSettingInfo_ = settingInfo_ ? settingInfo_->GetText() : "N/A"; UIScreen::RecreateViews(); } -void TabbedUIDialogScreenWithGameBackground::EnsureTabs() { +void UITabbedBaseDialogScreen::EnsureTabs() { _dbg_assert_(tabHolder_); if (tabHolder_) { tabHolder_->EnsureAllCreated(); } } -int TabbedUIDialogScreenWithGameBackground::GetCurrentTab() const { +int UITabbedBaseDialogScreen::GetCurrentTab() const { return tabHolder_->GetCurrentTab(); } -void TabbedUIDialogScreenWithGameBackground::SetCurrentTab(int tab) { +void UITabbedBaseDialogScreen::SetCurrentTab(int tab) { tabHolder_->SetCurrentTab(tab); } -void TabbedUIDialogScreenWithGameBackground::ApplySearchFilter() { +void UITabbedBaseDialogScreen::ApplySearchFilter() { using namespace UI; auto se = GetI18NCategory(I18NCat::SEARCH); diff --git a/UI/TabbedDialogScreen.h b/UI/TabbedDialogScreen.h index d191e8123c..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; @@ -18,9 +20,9 @@ enum class TabFlags { }; ENUM_CLASS_BITOPS(TabFlags); -class TabbedUIDialogScreenWithGameBackground : public UIDialogScreenWithGameBackground { +class UITabbedBaseDialogScreen : public UIBaseDialogScreen { public: - TabbedUIDialogScreenWithGameBackground(const Path &gamePath) : UIDialogScreenWithGameBackground(gamePath) { + UITabbedBaseDialogScreen(const Path &gamePath) : UIBaseDialogScreen(gamePath) { ignoreBottomInset_ = true; } diff --git a/UI/TiltAnalogSettingsScreen.cpp b/UI/TiltAnalogSettingsScreen.cpp index 1931d8c433..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" @@ -151,7 +153,7 @@ void TiltAnalogSettingsScreen::OnCalibrate(UI::EventParams &e) { } void TiltAnalogSettingsScreen::update() { - UIDialogScreenWithGameBackground::update(); + UIBaseDialogScreen::update(); if (tilt_) { tilt_->SetXY( Clamp(TiltEventProcessor::rawTiltAnalogX, -1.0f, 1.0f), diff --git a/UI/TiltAnalogSettingsScreen.h b/UI/TiltAnalogSettingsScreen.h index 62e7e782f7..a28ea659f6 100644 --- a/UI/TiltAnalogSettingsScreen.h +++ b/UI/TiltAnalogSettingsScreen.h @@ -19,14 +19,14 @@ #include "Common/Math/math_util.h" #include "Common/UI/View.h" -#include "MiscScreens.h" +#include "BaseScreens.h" class JoystickHistoryView; class GamepadView; -class TiltAnalogSettingsScreen : public UIDialogScreenWithGameBackground { +class TiltAnalogSettingsScreen : public UIBaseDialogScreen { public: - TiltAnalogSettingsScreen(const Path &gamePath) : UIDialogScreenWithGameBackground(gamePath) {} + TiltAnalogSettingsScreen(const Path &gamePath) : UIBaseDialogScreen(gamePath) {} void CreateViews() override; void update() override; diff --git a/UI/TouchControlLayoutScreen.cpp b/UI/TouchControlLayoutScreen.cpp index 67c0137ccf..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" @@ -605,7 +606,7 @@ void TouchControlLayoutScreen::OnMode(UI::EventParams &e) { } void TouchControlLayoutScreen::update() { - UIDialogScreenWithGameBackground::update(); + UIBaseDialogScreen::update(); if (!layoutView_) { return; diff --git a/UI/TouchControlLayoutScreen.h b/UI/TouchControlLayoutScreen.h index 105463a69f..50202d81a0 100644 --- a/UI/TouchControlLayoutScreen.h +++ b/UI/TouchControlLayoutScreen.h @@ -20,13 +20,13 @@ #include "Common/UI/View.h" #include "Common/UI/ViewGroup.h" #include "Common/UI/TabHolder.h" -#include "MiscScreens.h" +#include "BaseScreens.h" class ControlLayoutView; -class TouchControlLayoutScreen : public UIDialogScreenWithGameBackground { +class TouchControlLayoutScreen : public UIBaseDialogScreen { public: - TouchControlLayoutScreen(const Path &gamePath) : UIDialogScreenWithGameBackground(gamePath) {} + TouchControlLayoutScreen(const Path &gamePath) : UIBaseDialogScreen(gamePath) {} void CreateViews() override; void dialogFinished(const Screen *dialog, DialogResult result) override; 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 3bb5199844..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 { @@ -32,9 +34,9 @@ struct TouchButtonToggle { std::function handle; }; -class TouchControlVisibilityScreen : public TabbedUIDialogScreenWithGameBackground { +class TouchControlVisibilityScreen : public UITabbedBaseDialogScreen { public: - TouchControlVisibilityScreen(const Path &gamePath) : TabbedUIDialogScreenWithGameBackground(gamePath) {} + TouchControlVisibilityScreen(const Path &gamePath) : UITabbedBaseDialogScreen(gamePath) {} void CreateTabs() override; void onFinish(DialogResult result) override; @@ -49,9 +51,9 @@ private: bool nextToggleAll_ = true; }; -class RightAnalogMappingScreen : public UIDialogScreenWithGameBackground { +class RightAnalogMappingScreen : public UIBaseDialogScreen { public: - RightAnalogMappingScreen(const Path &gamePath) : UIDialogScreenWithGameBackground(gamePath) {} + RightAnalogMappingScreen(const Path &gamePath) : UIBaseDialogScreen(gamePath) {} void CreateViews() override; const char *tag() const override { return "RightAnalogMapping"; } diff --git a/UI/UI.vcxproj b/UI/UI.vcxproj index 428cb96e8f..a70d1a2e1c 100644 --- a/UI/UI.vcxproj +++ b/UI/UI.vcxproj @@ -27,7 +27,9 @@ + + @@ -80,7 +82,9 @@ + + diff --git a/UI/UI.vcxproj.filters b/UI/UI.vcxproj.filters index 632c4a3d51..3f404c20af 100644 --- a/UI/UI.vcxproj.filters +++ b/UI/UI.vcxproj.filters @@ -135,6 +135,12 @@ Views + + Screens + + + Screens + @@ -270,6 +276,12 @@ Views + + Screens + + + Screens + 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 b5acafe555..6cb75008dd 100644 --- a/UI/UploadScreen.h +++ b/UI/UploadScreen.h @@ -25,13 +25,13 @@ #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, // in order to upload game files to the current directory. -class UploadScreen : public UIDialogScreenWithBackground { +class UploadScreen : public UIBaseDialogScreen { public: UploadScreen(const Path &targetFolder); ~UploadScreen(); diff --git a/UWP/UI_UWP/UI_UWP.vcxproj b/UWP/UI_UWP/UI_UWP.vcxproj index e6ba7d188e..7337d2cc23 100644 --- a/UWP/UI_UWP/UI_UWP.vcxproj +++ b/UWP/UI_UWP/UI_UWP.vcxproj @@ -86,7 +86,9 @@ + + @@ -139,7 +141,9 @@ + + diff --git a/UWP/UI_UWP/UI_UWP.vcxproj.filters b/UWP/UI_UWP/UI_UWP.vcxproj.filters index 2d19a72344..b0e968fa18 100644 --- a/UWP/UI_UWP/UI_UWP.vcxproj.filters +++ b/UWP/UI_UWP/UI_UWP.vcxproj.filters @@ -130,6 +130,8 @@ Screens + + @@ -261,6 +263,8 @@ Screens + + diff --git a/android/jni/Android.mk b/android/jni/Android.mk index 884a694523..5e6c8697a3 100644 --- a/android/jni/Android.mk +++ b/android/jni/Android.mk @@ -931,6 +931,8 @@ LOCAL_SRC_FILES := \ $(SRC)/UI/TiltAnalogSettingsScreen.cpp \ $(SRC)/UI/TouchControlLayoutScreen.cpp \ $(SRC)/UI/TouchControlVisibilityScreen.cpp \ + $(SRC)/UI/BaseScreens.cpp \ + $(SRC)/UI/Background.cpp \ $(SRC)/UI/CwCheatScreen.cpp \ $(SRC)/UI/InstallZipScreen.cpp \ $(SRC)/UI/JitCompareScreen.cpp \