Merge pull request #21228 from hrydgard/more-screenshot-cleanup

Fix the report screen (screenshot + background), minor UI changes
This commit is contained in:
Henrik Rydgård authored and GitHub committed 2026-02-09 16:13:58 +01:00
commit 6f22c1bd18
12 files changed
+71 -80

No files matched your search

+1
View File
@@ -6,6 +6,7 @@
#include "Common/TimeUtil.h"
#include "Common/Input/GestureDetector.h"
#include "Common/System/Display.h"
const float estimatedInertiaDamping = 0.75f;
+30 -24
View File
@@ -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<void(EventParams &)> callback) {
Choice *choice = (Choice *)view;
choice->OnClick.Add(callback);
Clickable *choice = dynamic_cast<Clickable *>(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<void(EventParams &)> callback) {
Choice *choice = (Choice *)view;
choice->OnClick.Add(callback);
Clickable *choice = dynamic_cast<Clickable *>(view);
if (choice) {
choice->OnClick.Add(callback);
}
}
} // namespace
+3 -3
View File
@@ -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<void(EventParams &)> 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<void(EventParams &)> callback) override;
@@ -118,7 +118,7 @@ class StringVectorListAdaptor : public ListAdaptor {
public:
StringVectorListAdaptor() : selected_(-1) {}
StringVectorListAdaptor(const std::vector<std::string> &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<void(EventParams &)> callback) override;
void SetSelected(int sel) override { selected_ = sel; }
+1 -1
View File
@@ -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);
}
}
+4 -1
View File
@@ -468,7 +468,7 @@ public:
return t;
}
virtual void Recurse(void (*func)(View *view)) {}
virtual void Recurse(std::function<void(View *)> func) {}
virtual void SetAutoResult(DialogResult result) {
hasAutoResult_ = true;
autoResult_ = result;
@@ -757,6 +757,9 @@ public:
void SetIconOnly(bool iconOnly) {
iconOnly_ = iconOnly;
}
void SetSelectedIndicator(bool selected) {
selected_ = selected;
}
protected:
void ClickInternal() override;
+1 -1
View File
@@ -48,7 +48,7 @@ ViewGroup::~ViewGroup() {
Clear();
}
void ViewGroup::Recurse(void (*func)(View *view)) {
void ViewGroup::Recurse(std::function<void(View *)> func) {
for (View *view : views_) {
func(view);
view->Recurse(func);
+1 -1
View File
@@ -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<void(View *)> func) override;
protected:
std::string DescribeListUnordered(std::string_view heading) const;
-1
View File
@@ -28,7 +28,6 @@
typedef int SceUID;
typedef u32_le SceSize_le;
// typedef void (*PspGeCallback)(int id, void *arg);
struct PspGeCallbackData
{
+1
View File
@@ -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;
+10 -10
View File
@@ -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<PendingMessage> 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);
+18 -34
View File
@@ -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() {
+1 -4
View File
@@ -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;