mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2025-01-18 22:35:39 +00:00
CommonHostInterface: Make RunLater()/ApplySettings() virtual
This commit is contained in:
parent
ec60fa3c9d
commit
41be96ef93
|
@ -306,6 +306,11 @@ void QtHostInterface::applySettings(bool display_osd_messages /* = false */)
|
|||
return;
|
||||
}
|
||||
|
||||
ApplySettings(display_osd_messages);
|
||||
}
|
||||
|
||||
void QtHostInterface::ApplySettings(bool display_osd_messages)
|
||||
{
|
||||
Settings old_settings(std::move(g_settings));
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> guard(m_settings_mutex);
|
||||
|
@ -1168,7 +1173,7 @@ void QtHostInterface::executeOnEmulationThread(std::function<void()> callback, b
|
|||
}
|
||||
|
||||
QMetaObject::invokeMethod(this, "executeOnEmulationThread", Qt::QueuedConnection,
|
||||
Q_ARG(std::function<void()>, callback), Q_ARG(bool, wait));
|
||||
Q_ARG(std::function<void()>, std::move(callback)), Q_ARG(bool, wait));
|
||||
if (wait)
|
||||
{
|
||||
// don't deadlock
|
||||
|
@ -1178,6 +1183,12 @@ void QtHostInterface::executeOnEmulationThread(std::function<void()> callback, b
|
|||
}
|
||||
}
|
||||
|
||||
void QtHostInterface::RunLater(std::function<void()> func)
|
||||
{
|
||||
QMetaObject::invokeMethod(this, "executeOnEmulationThread", Qt::QueuedConnection,
|
||||
Q_ARG(std::function<void()>, std::move(func)), Q_ARG(bool, false));
|
||||
}
|
||||
|
||||
void QtHostInterface::loadState(const QString& filename)
|
||||
{
|
||||
if (!isOnWorkerThread())
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include "common/event.h"
|
||||
#include "core/host_interface.h"
|
||||
#include "core/system.h"
|
||||
#include "qtutils.h"
|
||||
#include "frontend-common/common_host_interface.h"
|
||||
#include <QtCore/QByteArray>
|
||||
#include <QtCore/QObject>
|
||||
|
@ -205,10 +206,12 @@ protected:
|
|||
void OnSystemStateSaved(bool global, s32 slot) override;
|
||||
|
||||
void LoadSettings() override;
|
||||
void ApplySettings(bool display_osd_messages) override;
|
||||
void SetDefaultSettings(SettingsInterface& si) override;
|
||||
void UpdateInputMap() override;
|
||||
|
||||
void SetMouseMode(bool relative, bool hide_cursor) override;
|
||||
void RunLater(std::function<void()> func) override;
|
||||
|
||||
private:
|
||||
enum : u32
|
||||
|
|
|
@ -325,15 +325,20 @@ void SDLHostInterface::SaveAndUpdateSettings()
|
|||
{
|
||||
m_settings_copy.Save(*m_settings_interface.get());
|
||||
|
||||
Settings old_settings(std::move(g_settings));
|
||||
CommonHostInterface::LoadSettings(*m_settings_interface.get());
|
||||
CommonHostInterface::ApplyGameSettings(false);
|
||||
CommonHostInterface::FixIncompatibleSettings(false);
|
||||
CheckForSettingsChanges(old_settings);
|
||||
ApplySettings(false);
|
||||
|
||||
m_settings_interface->Save();
|
||||
}
|
||||
|
||||
void SDLHostInterface::ApplySettings(bool display_osd_messages)
|
||||
{
|
||||
Settings old_settings(std::move(g_settings));
|
||||
CommonHostInterface::LoadSettings(*m_settings_interface.get());
|
||||
CommonHostInterface::ApplyGameSettings(display_osd_messages);
|
||||
CommonHostInterface::FixIncompatibleSettings(display_osd_messages);
|
||||
CheckForSettingsChanges(old_settings);
|
||||
}
|
||||
|
||||
bool SDLHostInterface::IsFullscreen() const
|
||||
{
|
||||
return m_fullscreen;
|
||||
|
|
|
@ -40,6 +40,12 @@ public:
|
|||
|
||||
bool RequestRenderWindowSize(s32 new_window_width, s32 new_window_height) override;
|
||||
|
||||
bool IsFullscreen() const override;
|
||||
bool SetFullscreen(bool enabled) override;
|
||||
|
||||
void RunLater(std::function<void()> callback) override;
|
||||
void ApplySettings(bool display_osd_messages) override;
|
||||
|
||||
void Run();
|
||||
|
||||
protected:
|
||||
|
@ -67,14 +73,8 @@ private:
|
|||
void CreateImGuiContext();
|
||||
void UpdateFramebufferScale();
|
||||
|
||||
/// Executes a callback later, after the UI has finished rendering. Needed to boot while rendering ImGui.
|
||||
void RunLater(std::function<void()> callback);
|
||||
|
||||
void SaveAndUpdateSettings();
|
||||
|
||||
bool IsFullscreen() const override;
|
||||
bool SetFullscreen(bool enabled) override;
|
||||
|
||||
// We only pass mouse input through if it's grabbed
|
||||
void DrawImGuiWindows() override;
|
||||
void DoStartDisc();
|
||||
|
|
|
@ -88,6 +88,12 @@ public:
|
|||
/// Request the frontend to exit.
|
||||
virtual void RequestExit() = 0;
|
||||
|
||||
/// Runs an event next frame as part of the event loop.
|
||||
virtual void RunLater(std::function<void()> func) = 0;
|
||||
|
||||
/// Loads new settings and applies them.
|
||||
virtual void ApplySettings(bool display_osd_messages) = 0;
|
||||
|
||||
virtual bool IsFullscreen() const;
|
||||
virtual bool SetFullscreen(bool enabled);
|
||||
|
||||
|
|
Loading…
Reference in a new issue