From 49f566dc9fe7720482ff1edc163821bbdf0dcf00 Mon Sep 17 00:00:00 2001 From: Gauvain 'GovanifY' Roussel-Tarbouriech Date: Sun, 7 Mar 2021 14:29:58 +0100 Subject: [PATCH] gsdump: add automatic fs watcher for dumps list & remove todo --- pcsx2/gui/Dialogs/GSDumpDialog.cpp | 11 ++++++++++- pcsx2/gui/Dialogs/ModalPopups.h | 3 +++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/pcsx2/gui/Dialogs/GSDumpDialog.cpp b/pcsx2/gui/Dialogs/GSDumpDialog.cpp index 43ef6b375b..5217ea7568 100644 --- a/pcsx2/gui/Dialogs/GSDumpDialog.cpp +++ b/pcsx2/gui/Dialogs/GSDumpDialog.cpp @@ -61,7 +61,6 @@ Dialogs::GSDumpDialog::GSDumpDialog(wxWindow* parent) , m_vsync(new wxButton(this, ID_RUN_START, _("Go to next VSync"), wxDefaultPosition, wxSize(150, 50))) , m_thread(std::make_unique(this)) { - //TODO: figure out how to fix sliders so the destructor doesn't segfault wxBoxSizer& dump_info(*new wxBoxSizer(wxVERTICAL)); wxBoxSizer& dump_preview(*new wxBoxSizer(wxVERTICAL)); wxFlexGridSizer& debugger(*new wxFlexGridSizer(3, StdPadding, StdPadding)); @@ -114,6 +113,10 @@ Dialogs::GSDumpDialog::GSDumpDialog(wxWindow* parent) m_vsync->Disable(); GetDumpsList(); + m_fs_watcher.SetOwner(this); + m_fs_watcher.Add(wxFileName(g_Conf->Folders.Snapshots.ToAscii())); + wxEvtHandler::Connect(wxEVT_FSWATCHER, wxFileSystemWatcherEventHandler(Dialogs::GSDumpDialog::PathChanged)); + Bind(wxEVT_LIST_ITEM_SELECTED, &Dialogs::GSDumpDialog::SelectedDump, this, ID_DUMP_LIST); Bind(wxEVT_BUTTON, &Dialogs::GSDumpDialog::RunDump, this, ID_RUN_DUMP); Bind(wxEVT_BUTTON, &Dialogs::GSDumpDialog::ToStart, this, ID_RUN_START); @@ -126,6 +129,7 @@ Dialogs::GSDumpDialog::GSDumpDialog(wxWindow* parent) void Dialogs::GSDumpDialog::GetDumpsList() { + m_dump_list->ClearAll(); wxDir snaps(g_Conf->Folders.Snapshots.ToAscii()); wxString filename; bool cont = snaps.GetFirst(&filename, "*.gs", wxDIR_DEFAULT); @@ -766,3 +770,8 @@ void Dialogs::GSDumpDialog::GSThread::ExecuteTaskInThread() OnStop(); return; } + +void Dialogs::GSDumpDialog::PathChanged(wxFileSystemWatcherEvent& event) +{ + GetDumpsList(); +} diff --git a/pcsx2/gui/Dialogs/ModalPopups.h b/pcsx2/gui/Dialogs/ModalPopups.h index adedeff221..207f845e2d 100644 --- a/pcsx2/gui/Dialogs/ModalPopups.h +++ b/pcsx2/gui/Dialogs/ModalPopups.h @@ -22,6 +22,7 @@ #include #include +#include // clang-format off #define GSDUMP_GIFREG(X) \ @@ -160,6 +161,7 @@ namespace Dialogs wxButton* m_step; wxButton* m_selection; wxButton* m_vsync; + wxFileSystemWatcher m_fs_watcher; void GetDumpsList(); void SelectedDump(wxListEvent& evt); @@ -170,6 +172,7 @@ namespace Dialogs void ToVSync(wxCommandEvent& event); void ParsePacket(wxTreeEvent& event); void CheckDebug(wxCommandEvent& event); + void PathChanged(wxFileSystemWatcherEvent& event); enum { ID_DUMP_LIST,