From 990cba8e6c73faf5fd2d65070d46bf6e408257dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 9 Feb 2026 14:08:04 +0100 Subject: [PATCH 1/3] Fix problem with background image when rotating some dialogs --- Common/UI/View.h | 2 +- Common/UI/ViewGroup.cpp | 2 +- Common/UI/ViewGroup.h | 2 +- Core/HLE/sceGe.h | 1 - UI/NativeApp.cpp | 20 ++++++++++---------- 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/Common/UI/View.h b/Common/UI/View.h index 80f37563f7..706dab75f7 100644 --- a/Common/UI/View.h +++ b/Common/UI/View.h @@ -468,7 +468,7 @@ public: return t; } - virtual void Recurse(void (*func)(View *view)) {} + virtual void Recurse(std::function func) {} virtual void SetAutoResult(DialogResult result) { hasAutoResult_ = true; autoResult_ = result; diff --git a/Common/UI/ViewGroup.cpp b/Common/UI/ViewGroup.cpp index 841badbc7f..19e91f418b 100644 --- a/Common/UI/ViewGroup.cpp +++ b/Common/UI/ViewGroup.cpp @@ -48,7 +48,7 @@ ViewGroup::~ViewGroup() { Clear(); } -void ViewGroup::Recurse(void (*func)(View *view)) { +void ViewGroup::Recurse(std::function func) { for (View *view : views_) { func(view); view->Recurse(func); diff --git a/Common/UI/ViewGroup.h b/Common/UI/ViewGroup.h index cda6ca77a9..54bd051086 100644 --- a/Common/UI/ViewGroup.h +++ b/Common/UI/ViewGroup.h @@ -82,7 +82,7 @@ public: std::string DescribeLog() const override { return "ViewGroup: " + View::DescribeLog(); } std::string DescribeText() const override; - void Recurse(void (*func)(View *view)) override; + void Recurse(std::function func) override; protected: std::string DescribeListUnordered(std::string_view heading) const; diff --git a/Core/HLE/sceGe.h b/Core/HLE/sceGe.h index b0aedaef6b..91fe03491a 100644 --- a/Core/HLE/sceGe.h +++ b/Core/HLE/sceGe.h @@ -28,7 +28,6 @@ typedef int SceUID; typedef u32_le SceSize_le; -// typedef void (*PspGeCallback)(int id, void *arg); struct PspGeCallbackData { diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 9071dd91d7..6345bdd639 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -1086,12 +1086,20 @@ void NativeFrame(GraphicsContext *graphicsContext) { g_iconCache.FrameUpdate(); - g_screenManager->update(); - if (g_audioBackend) { g_audioBackend->FrameUpdate(g_Config.bAutoAudioDevice); } + // NOTE: We must begin the frame before update, so we can do texture size queries and stuff in Measure etc. + Draw::DebugFlags debugFlags = Draw::DebugFlags::NONE; + if ((DebugOverlay)g_Config.iDebugOverlay == DebugOverlay::GPU_PROFILE) + debugFlags |= Draw::DebugFlags::PROFILE_TIMESTAMPS; + if (g_Config.bGpuLogProfiler) + debugFlags |= Draw::DebugFlags::PROFILE_SCOPES; + g_draw->BeginFrame(debugFlags); + + g_screenManager->update(); + // Do this after g_screenManager.update() so we can receive setting changes before rendering. { std::vector toProcess; @@ -1129,17 +1137,9 @@ void NativeFrame(GraphicsContext *graphicsContext) { // Apply the UIContext bounds as a 2D transformation matrix. Matrix4x4 ortho = ComputeOrthoMatrix(g_display.dp_xres, g_display.dp_yres, graphicsContext->GetDrawContext()->GetDeviceCaps().coordConvention); - Draw::DebugFlags debugFlags = Draw::DebugFlags::NONE; - if ((DebugOverlay)g_Config.iDebugOverlay == DebugOverlay::GPU_PROFILE) - debugFlags |= Draw::DebugFlags::PROFILE_TIMESTAMPS; - if (g_Config.bGpuLogProfiler) - debugFlags |= Draw::DebugFlags::PROFILE_SCOPES; - // Can be overridden by sceDisplay which may pass true for the second argument. g_frameTiming.ComputePresentMode(g_draw, false); - g_draw->BeginFrame(debugFlags); - ui_draw2d.PushDrawMatrix(ortho); g_screenManager->getUIContext()->SetTintSaturation(g_Config.fUITint, g_Config.fUISaturation); From 5d4ac87b2b804c575140ff8b9acf888726ece44e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 9 Feb 2026 14:27:07 +0100 Subject: [PATCH 2/3] In PopupMultiChoice lists, indicate the selected item with a checkmark See #21223 --- Common/Input/GestureDetector.cpp | 1 + Common/UI/ScrollView.cpp | 54 ++++++++++++++++++-------------- Common/UI/ScrollView.h | 6 ++-- Common/UI/View.cpp | 2 +- Common/UI/View.h | 3 ++ UI/MiscViews.cpp | 1 + 6 files changed, 39 insertions(+), 28 deletions(-) diff --git a/Common/Input/GestureDetector.cpp b/Common/Input/GestureDetector.cpp index 08f4f8edcb..a8b4a0f23a 100644 --- a/Common/Input/GestureDetector.cpp +++ b/Common/Input/GestureDetector.cpp @@ -6,6 +6,7 @@ #include "Common/TimeUtil.h" #include "Common/Input/GestureDetector.h" +#include "Common/System/Display.h" const float estimatedInertiaDamping = 0.75f; diff --git a/Common/UI/ScrollView.cpp b/Common/UI/ScrollView.cpp index 16b1a08900..c567dcdcf6 100644 --- a/Common/UI/ScrollView.cpp +++ b/Common/UI/ScrollView.cpp @@ -572,17 +572,21 @@ void ListView::CreateAllItems() { linLayout_->Clear(); // Let's not be clever yet, we'll just create them all up front and add them all in. for (int i = 0; i < adaptor_->GetNumItems(); i++) { - if (hidden_.find(i) == hidden_.end()) { - ImageID *imageID = nullptr; - auto iter = icons_.find(i); - if (iter != icons_.end()) { - imageID = &iter->second; - } - View *v = linLayout_->Add(adaptor_->CreateItemView(i, imageID)); - adaptor_->AddEventCallback(v, [this, i](UI::EventParams &e) { - OnItemCallback(i, e); - }); + if (hidden_.count(i)) { + // Item was hidden, skip it. + continue; } + + ImageID *imageID = nullptr; + auto iter = icons_.find(i); + if (iter != icons_.end()) { + imageID = &iter->second; + } + const bool selected = adaptor_->GetSelected() == i; + View *v = linLayout_->Add(adaptor_->CreateItemView(i, selected, imageID)); + adaptor_->AddEventCallback(v, [this, i](UI::EventParams &e) { + OnItemCallback(i, e); + }); } } @@ -607,37 +611,39 @@ void ListView::OnItemCallback(int num, EventParams &e) { CreateAllItems(); } -View *ChoiceListAdaptor::CreateItemView(int index, ImageID *optionalImageID) { +View *ChoiceListAdaptor::CreateItemView(int index, bool selected, ImageID *optionalImageID) { Choice *choice; if (optionalImageID) { choice = new Choice(items_[index], *optionalImageID); } else { choice = new Choice(items_[index]); - //choice->SetIconRight(*optionalImageID); + } + if (selected) { + choice->SetSelectedIndicator(true); } return choice; } void ChoiceListAdaptor::AddEventCallback(View *view, std::function callback) { - Choice *choice = (Choice *)view; - choice->OnClick.Add(callback); + Clickable *choice = dynamic_cast(view); + if (choice) { + choice->OnClick.Add(callback); + } } -View *StringVectorListAdaptor::CreateItemView(int index, ImageID *optionalImageID) { - ImageID temp; - if (optionalImageID) { - temp = *optionalImageID; +View *StringVectorListAdaptor::CreateItemView(int index, bool selected, ImageID *optionalImageID) { + Choice *choice = new Choice(items_[index], optionalImageID ? *optionalImageID : ImageID()); + if (selected) { + choice->SetSelectedIndicator(true); } - Choice *choice = new Choice(items_[index], temp); - // if (optionalImageID) { - // choice->SetIconRight(*optionalImageID); - // } return choice; } void StringVectorListAdaptor::AddEventCallback(View *view, std::function callback) { - Choice *choice = (Choice *)view; - choice->OnClick.Add(callback); + Clickable *choice = dynamic_cast(view); + if (choice) { + choice->OnClick.Add(callback); + } } } // namespace diff --git a/Common/UI/ScrollView.h b/Common/UI/ScrollView.h index 72f4c453f7..9631dc9d4b 100644 --- a/Common/UI/ScrollView.h +++ b/Common/UI/ScrollView.h @@ -93,7 +93,7 @@ private: class ListAdaptor { public: virtual ~ListAdaptor() {} - virtual View *CreateItemView(int index, ImageID *optionalImageID) = 0; + virtual View *CreateItemView(int index, bool selected, ImageID *optionalImageID) = 0; virtual int GetNumItems() = 0; virtual void AddEventCallback(View *view, std::function callback) {} virtual std::string GetTitle(int index) const { return ""; } @@ -104,7 +104,7 @@ public: class ChoiceListAdaptor : public ListAdaptor { public: ChoiceListAdaptor(const char *items[], int numItems) : items_(items), numItems_(numItems) {} - View *CreateItemView(int index, ImageID *optionalImageID) override; + View *CreateItemView(int index, bool selected, ImageID *optionalImageID) override; int GetNumItems() override { return numItems_; } void AddEventCallback(View *view, std::function callback) override; @@ -118,7 +118,7 @@ class StringVectorListAdaptor : public ListAdaptor { public: StringVectorListAdaptor() : selected_(-1) {} StringVectorListAdaptor(const std::vector &items, int selected = -1) : items_(items), selected_(selected) {} - View *CreateItemView(int index, ImageID *optionalImageID) override; + View *CreateItemView(int index, bool selected, ImageID *optionalImageID) override; int GetNumItems() override { return (int)items_.size(); } void AddEventCallback(View *view, std::function callback) override; void SetSelected(int sel) override { selected_ = sel; } diff --git a/Common/UI/View.cpp b/Common/UI/View.cpp index 889e8fa6d2..f9f6d483d6 100644 --- a/Common/UI/View.cpp +++ b/Common/UI/View.cpp @@ -568,7 +568,7 @@ void Choice::Draw(UIContext &dc) { } if (selected_) { - dc.Draw()->DrawImage(dc.GetTheme().checkOn, bounds_.x2() - 40, bounds_.centerY(), 1.0f, style.fgColor, ALIGN_CENTER); + dc.Draw()->DrawImage(ImageID("I_CHECKMARK"), bounds_.x2() - 30, bounds_.centerY(), 1.0f, style.fgColor, ALIGN_CENTER); } } diff --git a/Common/UI/View.h b/Common/UI/View.h index 706dab75f7..20b9578174 100644 --- a/Common/UI/View.h +++ b/Common/UI/View.h @@ -757,6 +757,9 @@ public: void SetIconOnly(bool iconOnly) { iconOnly_ = iconOnly; } + void SetSelectedIndicator(bool selected) { + selected_ = selected; + } protected: void ClickInternal() override; diff --git a/UI/MiscViews.cpp b/UI/MiscViews.cpp index 5703a7c083..c67fba3e70 100644 --- a/UI/MiscViews.cpp +++ b/UI/MiscViews.cpp @@ -171,6 +171,7 @@ void GameImageView::GetContentDimensions(const UIContext &dc, float &w, float &h w = 0; h = 0; if (!tex || !tex->texture) { + // Not ready yet return; } Draw::Texture *texture = tex->texture; From 013a51576af104c0283ace1ce51a0d8a1ef5b15f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 9 Feb 2026 14:32:30 +0100 Subject: [PATCH 3/3] Fix screenshotting and the background of ReportScreen See #21223 --- UI/ReportScreen.cpp | 52 ++++++++++++++++----------------------------- UI/ReportScreen.h | 5 +---- 2 files changed, 19 insertions(+), 38 deletions(-) diff --git a/UI/ReportScreen.cpp b/UI/ReportScreen.cpp index 15f8f780d7..f3dec1ce9e 100644 --- a/UI/ReportScreen.cpp +++ b/UI/ReportScreen.cpp @@ -166,43 +166,27 @@ ReportScreen::ReportScreen(const Path &gamePath) Reporting::QueueCRC(gamePath_); } -ScreenRenderFlags ReportScreen::render(ScreenRenderMode mode) { - _dbg_assert_(mode & ScreenRenderMode::FIRST); - // _dbg_assert_(mode & ScreenRenderMode::TOP); - - if (mode & ScreenRenderMode::TOP) { - // We do this after render because we need it to be within the frame (so the screenshot works). +ScreenRenderFlags ReportScreen::PreRender(ScreenRenderMode mode) { + if ((mode & ScreenRenderMode::TOP) && !tookScreenshot_ && !g_Config.bSkipBufferEffects) { + // We do this in PreRender because we need it to be before the main render pass. // We could do it mid frame, but then we have to reapply viewport/scissor. - if (!tookScreenshot_ && !g_Config.bSkipBufferEffects) { - Path path = GetSysDirectory(DIRECTORY_SCREENSHOT); - if (!File::Exists(path)) { - File::CreateDir(path); - } - screenshotFilename_ = path / ".reporting.jpg"; - ScreenshotResult ignored = TakeGameScreenshot(screenManager()->getDrawContext(), screenshotFilename_, ScreenshotFormat::JPG, SCREENSHOT_RENDER, 4, [this](bool success) { - if (success) { - // Redo the views already, now with a screenshot included. - RecreateViews(); - } else { - // Good news (?), the views are good as-is without a screenshot. - screenshotFilename_.clear(); - } - }); - tookScreenshot_ = true; + Path path = GetSysDirectory(DIRECTORY_SCREENSHOT); + if (!File::Exists(path)) { + File::CreateDir(path); } + screenshotFilename_ = path / ".reporting.jpg"; + ScreenshotResult ignored = TakeGameScreenshot(screenManager()->getDrawContext(), screenshotFilename_, ScreenshotFormat::JPG, SCREENSHOT_RENDER, 4, [this](bool success) { + if (success) { + // Redo the views already, now with a screenshot included. + RecreateViews(); + } else { + // Good news (?), the views are good as-is without a screenshot. + screenshotFilename_.clear(); + } + }); + tookScreenshot_ = true; } - - // We take the screenshot first, then we start rendering. - // We are the only screen visible so this avoid starting and then trying to resume a backbuffer render pass. - return UITwoPaneBaseDialogScreen::render(mode); -} - -// For the screenshotting functionality to work. -ScreenRenderRole ReportScreen::renderRole(bool isTop) const { - // if (tookScreenshot_) { - // return ScreenRenderRole::NONE; - // } - return ScreenRenderRole::MUST_BE_FIRST | ScreenRenderRole::CAN_BE_BACKGROUND; + return ScreenRenderFlags::NONE; } void ReportScreen::update() { diff --git a/UI/ReportScreen.h b/UI/ReportScreen.h index 4e0d359d00..e5ef6db2b3 100644 --- a/UI/ReportScreen.h +++ b/UI/ReportScreen.h @@ -40,11 +40,8 @@ public: const char *tag() const override { return "Report"; } - // For the screenshotting functionality to work. - ScreenRenderRole renderRole(bool isTop) const override; - protected: - ScreenRenderFlags render(ScreenRenderMode mode) override; + ScreenRenderFlags PreRender(ScreenRenderMode mode) override; void update() override; void resized() override; void CreateSettingsViews(UI::ViewGroup *parent) override;