mirror of https://github.com/PCSX2/pcsx2.git
Qt: Add save state loading/loaded/saved events
This commit is contained in:
parent
8b9eee4961
commit
3caebb31ae
|
@ -42,6 +42,7 @@
|
|||
#include "EmuThread.h"
|
||||
#include "MainWindow.h"
|
||||
#include "QtHost.h"
|
||||
#include "QtUtils.h"
|
||||
|
||||
EmuThread* g_emu_thread = nullptr;
|
||||
WindowInfo g_gs_window_info;
|
||||
|
@ -708,6 +709,21 @@ void Host::OnGameChanged(const std::string& disc_path, const std::string& game_s
|
|||
QString::fromStdString(game_name), game_crc);
|
||||
}
|
||||
|
||||
void Host::OnSaveStateLoading(const std::string_view& filename)
|
||||
{
|
||||
emit g_emu_thread->onSaveStateLoading(QtUtils::StringViewToQString(filename));
|
||||
}
|
||||
|
||||
void Host::OnSaveStateLoaded(const std::string_view& filename, bool was_successful)
|
||||
{
|
||||
emit g_emu_thread->onSaveStateLoaded(QtUtils::StringViewToQString(filename), was_successful);
|
||||
}
|
||||
|
||||
void Host::OnSaveStateSaved(const std::string_view& filename)
|
||||
{
|
||||
emit g_emu_thread->onSaveStateSaved(QtUtils::StringViewToQString(filename));
|
||||
}
|
||||
|
||||
void Host::PumpMessagesOnCPUThread()
|
||||
{
|
||||
g_emu_thread->getEventLoop()->processEvents(QEventLoop::AllEvents);
|
||||
|
|
|
@ -80,17 +80,40 @@ Q_SIGNALS:
|
|||
DisplayWidget* onUpdateDisplayRequested(bool fullscreen, bool render_to_main);
|
||||
void onResizeDisplayRequested(qint32 width, qint32 height);
|
||||
void onDestroyDisplayRequested();
|
||||
|
||||
/// Called when the VM is starting initialization, but has not been completed yet.
|
||||
void onVMStarting();
|
||||
|
||||
/// Called when the VM is created.
|
||||
void onVMStarted();
|
||||
|
||||
/// Called when the VM is paused.
|
||||
void onVMPaused();
|
||||
|
||||
/// Called when the VM is resumed after being paused.
|
||||
void onVMResumed();
|
||||
|
||||
/// Called when the VM is shut down or destroyed.
|
||||
void onVMStopped();
|
||||
|
||||
/// Provided by the host; called when the running executable changes.
|
||||
void onGameChanged(const QString& path, const QString& serial, const QString& name, quint32 crc);
|
||||
|
||||
void onInputDevicesEnumerated(const QList<QPair<QString, QString>>& devices);
|
||||
void onInputDeviceConnected(const QString& identifier, const QString& device_name);
|
||||
void onInputDeviceDisconnected(const QString& identifier);
|
||||
void onVibrationMotorsEnumerated(const QList<InputBindingKey>& motors);
|
||||
|
||||
/// Called when a save state is loading, before the file is processed.
|
||||
void onSaveStateLoading(const QString& path);
|
||||
|
||||
/// Called after a save state is successfully loaded. If the save state was invalid, was_successful will be false.
|
||||
void onSaveStateLoaded(const QString& path, bool was_successful);
|
||||
|
||||
/// Called when a save state is being created/saved. The compression/write to disk is asynchronous, so this callback
|
||||
/// just signifies that the save has started, not necessarily completed.
|
||||
void onSaveStateSaved(const QString& path);
|
||||
|
||||
protected:
|
||||
void run();
|
||||
|
||||
|
|
|
@ -784,13 +784,16 @@ bool VMManager::DoLoadState(const char* filename)
|
|||
{
|
||||
try
|
||||
{
|
||||
Host::OnSaveStateLoading(filename);
|
||||
SaveState_UnzipFromDisk(wxString::FromUTF8(filename));
|
||||
UpdateRunningGame(false);
|
||||
Host::OnSaveStateLoaded(filename, true);
|
||||
return true;
|
||||
}
|
||||
catch (Exception::BaseException& e)
|
||||
{
|
||||
Host::ReportErrorAsync("Failed to load save state", static_cast<const char*>(e.UserMsg().c_str()));
|
||||
Host::OnSaveStateLoaded(filename, false);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -803,6 +806,7 @@ bool VMManager::DoSaveState(const char* filename, s32 slot_for_message)
|
|||
SaveState_DownloadState(elist.get());
|
||||
SaveState_ZipToDisk(elist.release(), SaveState_SaveScreenshot(), wxString::FromUTF8(filename), slot_for_message);
|
||||
Host::InvalidateSaveStateCache();
|
||||
Host::OnSaveStateSaved(filename);
|
||||
return true;
|
||||
}
|
||||
catch (Exception::BaseException& e)
|
||||
|
|
|
@ -173,6 +173,16 @@ namespace Host
|
|||
/// Called when the VM is resumed after being paused.
|
||||
void OnVMResumed();
|
||||
|
||||
/// Called when a save state is loading, before the file is processed.
|
||||
void OnSaveStateLoading(const std::string_view& filename);
|
||||
|
||||
/// Called after a save state is successfully loaded. If the save state was invalid, was_successful will be false.
|
||||
void OnSaveStateLoaded(const std::string_view& filename, bool was_successful);
|
||||
|
||||
/// Called when a save state is being created/saved. The compression/write to disk is asynchronous, so this callback
|
||||
/// just signifies that the save has started, not necessarily completed.
|
||||
void OnSaveStateSaved(const std::string_view& filename);
|
||||
|
||||
/// Provided by the host; called when the running executable changes.
|
||||
void OnGameChanged(const std::string& disc_path, const std::string& game_serial, const std::string& game_name, u32 game_crc);
|
||||
|
||||
|
|
Loading…
Reference in New Issue