gsdump: add automatic fs watcher for dumps list & remove todo

This commit is contained in:
Gauvain 'GovanifY' Roussel-Tarbouriech 2021-03-07 14:29:58 +01:00 committed by Kojin
parent 4280ee1f0a
commit 49f566dc9f
2 changed files with 13 additions and 1 deletions

View File

@ -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<GSThread>(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();
}

View File

@ -22,6 +22,7 @@
#include <wx/wizard.h>
#include <wx/treectrl.h>
#include <wx/fswatcher.h>
// 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,