From f1df1de64f52b4a9e46fa4524f75b48e0aac01d8 Mon Sep 17 00:00:00 2001 From: Gauvain 'GovanifY' Roussel-Tarbouriech Date: Sat, 30 Jan 2021 04:46:04 +0100 Subject: [PATCH] GSDump: implement dump preview --- pcsx2/gui/Dialogs/GSDumpDialog.cpp | 32 +++++++++++++++++------------- pcsx2/gui/Dialogs/ModalPopups.h | 3 ++- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/pcsx2/gui/Dialogs/GSDumpDialog.cpp b/pcsx2/gui/Dialogs/GSDumpDialog.cpp index c0cedc3a7b..8ab8ff076a 100644 --- a/pcsx2/gui/Dialogs/GSDumpDialog.cpp +++ b/pcsx2/gui/Dialogs/GSDumpDialog.cpp @@ -35,6 +35,7 @@ #include #include #include +#include using namespace pxSizerFlags; @@ -44,7 +45,8 @@ using namespace pxSizerFlags; Dialogs::GSDumpDialog::GSDumpDialog(wxWindow* parent) : wxDialogWithHelpers(parent, _("GSDumpGov"), pxDialogFlags()) - , m_dump_list(new wxListView(this, wxID_ANY, wxDefaultPosition, wxSize(250, 200))) + , m_dump_list(new wxListView(this, ID_DUMP_LIST, wxDefaultPosition, wxSize(250, 200))) + , m_preview_image(new wxStaticBitmap(this, wxID_ANY, wxBitmap(EmbeddedImage().Get()))) { const float scale = MSW_GetDPIScale(); SetMinWidth(scale * 460); @@ -90,9 +92,7 @@ Dialogs::GSDumpDialog::GSDumpDialog(wxWindow* parent) dumps_list += m_dump_list; dump_preview += new wxStaticText(this, wxID_ANY, _("Preview")); - wxImage img = EmbeddedImage().Get(); - img.Rescale(250 * scale, 200 * scale, wxIMAGE_QUALITY_HIGH); - dump_preview += new wxStaticBitmap(this, wxID_ANY, wxBitmap(img)); + dump_preview += m_preview_image; dumps += dumps_list; @@ -113,26 +113,30 @@ Dialogs::GSDumpDialog::GSDumpDialog(wxWindow* parent) void Dialogs::GSDumpDialog::GetDumpsList() { - wxDir snaps(g_Conf->Folders.Snapshots.GetFilename().GetName()); + wxDir snaps(g_Conf->Folders.Snapshots.ToAscii()); wxString filename; bool cont = snaps.GetFirst(&filename, "*.gs", wxDIR_DEFAULT); int i = 0; + m_dump_list->AppendColumn("Dumps"); while (cont) { - m_dump_list->InsertItem(i, filename.c_str()); + m_dump_list->InsertItem(i, filename.substr(0, filename.find_last_of("."))); i++; cont = snaps.GetNext(&filename); } } -Dialogs::GSDumpDialog::~GSDumpDialog() -{ - // we can't use smart pointers because of wxWidgets operator overload so we - // do the next best thing and handle the manual memory management ourselves - delete m_dump_list; -} - void Dialogs::GSDumpDialog::SelectedDump(wxListEvent& evt) { - //evt->GetText(); + wxString filename = g_Conf->Folders.Snapshots.ToAscii() + ("/" + evt.GetText()) + ".png"; + if (wxFileExists(filename)) + { + auto img = wxImage(filename); + img.Rescale(250 * MSW_GetDPIScale(), 200 * MSW_GetDPIScale(), wxIMAGE_QUALITY_HIGH); + m_preview_image->SetBitmap(wxBitmap(img)); + } + else + { + m_preview_image->SetBitmap(EmbeddedImage().Get()); + } } diff --git a/pcsx2/gui/Dialogs/ModalPopups.h b/pcsx2/gui/Dialogs/ModalPopups.h index 32c32fde57..cb004771d1 100644 --- a/pcsx2/gui/Dialogs/ModalPopups.h +++ b/pcsx2/gui/Dialogs/ModalPopups.h @@ -72,7 +72,7 @@ namespace Dialogs { public: GSDumpDialog(wxWindow* parent = NULL); - virtual ~GSDumpDialog(); + virtual ~GSDumpDialog() = default; static wxString GetNameStatic() { @@ -85,6 +85,7 @@ namespace Dialogs protected: wxListView* m_dump_list; + wxStaticBitmap* m_preview_image; void GetDumpsList(); void SelectedDump(wxListEvent& evt); enum