mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-30 09:35:40 +00:00
CommonHostInterface: Move save state on exit logic to base class
This commit is contained in:
parent
7645ca3836
commit
c58227752d
|
@ -374,11 +374,7 @@ void AndroidHostInterface::EmulationThreadEntryPoint(JNIEnv* env, jobject emulat
|
||||||
{
|
{
|
||||||
// System is ready to go.
|
// System is ready to go.
|
||||||
EmulationThreadLoop(env);
|
EmulationThreadLoop(env);
|
||||||
|
PowerOffSystem(ShouldSaveResumeState());
|
||||||
if (g_settings.save_state_on_exit)
|
|
||||||
SaveResumeSaveState();
|
|
||||||
|
|
||||||
PowerOffSystem();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Drain any callbacks so we don't leave things in a screwed-up state for next boot.
|
// Drain any callbacks so we don't leave things in a screwed-up state for next boot.
|
||||||
|
|
|
@ -142,11 +142,6 @@ void HostInterface::ResetSystem()
|
||||||
AddOSDMessage(TranslateStdString("OSDMessage", "System reset."));
|
AddOSDMessage(TranslateStdString("OSDMessage", "System reset."));
|
||||||
}
|
}
|
||||||
|
|
||||||
void HostInterface::PowerOffSystem()
|
|
||||||
{
|
|
||||||
DestroySystem();
|
|
||||||
}
|
|
||||||
|
|
||||||
void HostInterface::PauseSystem(bool paused)
|
void HostInterface::PauseSystem(bool paused)
|
||||||
{
|
{
|
||||||
if (paused == System::IsPaused() || System::IsShutdown())
|
if (paused == System::IsPaused() || System::IsShutdown())
|
||||||
|
|
|
@ -52,7 +52,6 @@ public:
|
||||||
virtual void Shutdown();
|
virtual void Shutdown();
|
||||||
|
|
||||||
virtual bool BootSystem(const SystemBootParameters& parameters);
|
virtual bool BootSystem(const SystemBootParameters& parameters);
|
||||||
virtual void PowerOffSystem();
|
|
||||||
virtual void PauseSystem(bool paused);
|
virtual void PauseSystem(bool paused);
|
||||||
virtual void ResetSystem();
|
virtual void ResetSystem();
|
||||||
virtual void DestroySystem();
|
virtual void DestroySystem();
|
||||||
|
|
|
@ -238,11 +238,7 @@ void NoGUIHostInterface::Run()
|
||||||
|
|
||||||
// Save state on exit so it can be resumed
|
// Save state on exit so it can be resumed
|
||||||
if (!System::IsShutdown())
|
if (!System::IsShutdown())
|
||||||
{
|
PowerOffSystem(ShouldSaveResumeState());
|
||||||
if (g_settings.save_state_on_exit)
|
|
||||||
SaveResumeSaveState();
|
|
||||||
DestroySystem();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NoGUIHostInterface::ReportMessage(const char* message)
|
void NoGUIHostInterface::ReportMessage(const char* message)
|
||||||
|
|
|
@ -812,10 +812,7 @@ void QtHostInterface::powerOffSystem()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_settings.save_state_on_exit)
|
PowerOffSystem(ShouldSaveResumeState());
|
||||||
SaveResumeSaveState();
|
|
||||||
|
|
||||||
PowerOffSystem();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtHostInterface::powerOffSystemWithoutSaving()
|
void QtHostInterface::powerOffSystemWithoutSaving()
|
||||||
|
@ -827,7 +824,7 @@ void QtHostInterface::powerOffSystemWithoutSaving()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PowerOffSystem();
|
PowerOffSystem(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtHostInterface::synchronousPowerOffSystem()
|
void QtHostInterface::synchronousPowerOffSystem()
|
||||||
|
|
|
@ -199,12 +199,15 @@ void CommonHostInterface::DestroySystem()
|
||||||
HostInterface::DestroySystem();
|
HostInterface::DestroySystem();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommonHostInterface::PowerOffSystem()
|
void CommonHostInterface::PowerOffSystem(bool save_resume_state)
|
||||||
{
|
{
|
||||||
if (System::IsShutdown())
|
if (System::IsShutdown())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
HostInterface::PowerOffSystem();
|
if (save_resume_state)
|
||||||
|
SaveResumeSaveState();
|
||||||
|
|
||||||
|
DestroySystem();
|
||||||
|
|
||||||
if (InBatchMode())
|
if (InBatchMode())
|
||||||
RequestExit();
|
RequestExit();
|
||||||
|
@ -753,6 +756,11 @@ bool CommonHostInterface::ResumeSystemFromMostRecentState()
|
||||||
return LoadState(path.c_str());
|
return LoadState(path.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CommonHostInterface::ShouldSaveResumeState() const
|
||||||
|
{
|
||||||
|
return g_settings.save_state_on_exit;
|
||||||
|
}
|
||||||
|
|
||||||
bool CommonHostInterface::IsRunningAtNonStandardSpeed() const
|
bool CommonHostInterface::IsRunningAtNonStandardSpeed() const
|
||||||
{
|
{
|
||||||
if (!System::IsValid())
|
if (!System::IsValid())
|
||||||
|
@ -1810,7 +1818,7 @@ void CommonHostInterface::RegisterGeneralHotkeys()
|
||||||
{
|
{
|
||||||
SmallString confirmation_message(
|
SmallString confirmation_message(
|
||||||
TranslateString("CommonHostInterface", "Are you sure you want to stop emulation?"));
|
TranslateString("CommonHostInterface", "Are you sure you want to stop emulation?"));
|
||||||
if (g_settings.save_state_on_exit)
|
if (ShouldSaveResumeState())
|
||||||
{
|
{
|
||||||
confirmation_message.AppendString("\n\n");
|
confirmation_message.AppendString("\n\n");
|
||||||
confirmation_message.AppendString(
|
confirmation_message.AppendString(
|
||||||
|
@ -1824,10 +1832,7 @@ void CommonHostInterface::RegisterGeneralHotkeys()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_settings.save_state_on_exit)
|
PowerOffSystem(ShouldSaveResumeState());
|
||||||
SaveResumeSaveState();
|
|
||||||
|
|
||||||
PowerOffSystem();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -125,7 +125,6 @@ public:
|
||||||
virtual void Shutdown() override;
|
virtual void Shutdown() override;
|
||||||
|
|
||||||
virtual bool BootSystem(const SystemBootParameters& parameters) override;
|
virtual bool BootSystem(const SystemBootParameters& parameters) override;
|
||||||
virtual void PowerOffSystem() override;
|
|
||||||
virtual void ResetSystem() override;
|
virtual void ResetSystem() override;
|
||||||
virtual void DestroySystem() override;
|
virtual void DestroySystem() override;
|
||||||
|
|
||||||
|
@ -169,6 +168,9 @@ public:
|
||||||
/// Saves the current input configuration to the specified profile name.
|
/// Saves the current input configuration to the specified profile name.
|
||||||
bool SaveInputProfile(const char* profile_path);
|
bool SaveInputProfile(const char* profile_path);
|
||||||
|
|
||||||
|
/// Powers off the system, optionally saving the resume state.
|
||||||
|
void PowerOffSystem(bool save_resume_state);
|
||||||
|
|
||||||
/// Loads state from the specified filename.
|
/// Loads state from the specified filename.
|
||||||
bool LoadState(const char* filename);
|
bool LoadState(const char* filename);
|
||||||
|
|
||||||
|
@ -184,8 +186,7 @@ public:
|
||||||
/// Loads the most recent resume save state. This may be global or per-game.
|
/// Loads the most recent resume save state. This may be global or per-game.
|
||||||
bool ResumeSystemFromMostRecentState();
|
bool ResumeSystemFromMostRecentState();
|
||||||
|
|
||||||
/// Saves the resume save state, call when shutting down. Not called automatically on DestroySystem() since that can
|
/// Saves the resume save state, call when shutting down.
|
||||||
/// be called as a result of an error.
|
|
||||||
bool SaveResumeSaveState();
|
bool SaveResumeSaveState();
|
||||||
|
|
||||||
/// Returns a list of save states for the specified game code.
|
/// Returns a list of save states for the specified game code.
|
||||||
|
@ -268,6 +269,9 @@ public:
|
||||||
/// Converts a fullscreen mode to a string.
|
/// Converts a fullscreen mode to a string.
|
||||||
static std::string GetFullscreenModeString(u32 width, u32 height, float refresh_rate);
|
static std::string GetFullscreenModeString(u32 width, u32 height, float refresh_rate);
|
||||||
|
|
||||||
|
/// Returns true if the state should be saved on shutdown.
|
||||||
|
bool ShouldSaveResumeState() const;
|
||||||
|
|
||||||
/// Returns true if fast forwarding or slow motion is currently active.
|
/// Returns true if fast forwarding or slow motion is currently active.
|
||||||
bool IsRunningAtNonStandardSpeed() const;
|
bool IsRunningAtNonStandardSpeed() const;
|
||||||
|
|
||||||
|
|
|
@ -550,9 +550,7 @@ static void DoPowerOff()
|
||||||
if (!System::IsValid())
|
if (!System::IsValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (g_settings.save_state_on_exit)
|
s_host_interface->PowerOffSystem(s_host_interface->ShouldSaveResumeState());
|
||||||
s_host_interface->SaveResumeSaveState();
|
|
||||||
s_host_interface->PowerOffSystem();
|
|
||||||
|
|
||||||
ReturnToMainWindow();
|
ReturnToMainWindow();
|
||||||
});
|
});
|
||||||
|
|
|
@ -45,7 +45,7 @@ bool HTTPDownloaderWinHttp::Initialize()
|
||||||
if (WinHttpSetStatusCallback(m_hSession, HTTPStatusCallback, notification_flags, NULL) ==
|
if (WinHttpSetStatusCallback(m_hSession, HTTPStatusCallback, notification_flags, NULL) ==
|
||||||
WINHTTP_INVALID_STATUS_CALLBACK)
|
WINHTTP_INVALID_STATUS_CALLBACK)
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("WinHttpSetStatusCallback() failed: %u", GetLastError());
|
Log_ErrorPrintf("WinHttpSetStatusCallback() failed: %u", GetLastError());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue