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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ApplySettings(display_osd_messages);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtHostInterface::ApplySettings(bool display_osd_messages)
|
||||||
|
{
|
||||||
Settings old_settings(std::move(g_settings));
|
Settings old_settings(std::move(g_settings));
|
||||||
{
|
{
|
||||||
std::lock_guard<std::recursive_mutex> guard(m_settings_mutex);
|
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,
|
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)
|
if (wait)
|
||||||
{
|
{
|
||||||
// don't deadlock
|
// 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)
|
void QtHostInterface::loadState(const QString& filename)
|
||||||
{
|
{
|
||||||
if (!isOnWorkerThread())
|
if (!isOnWorkerThread())
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include "common/event.h"
|
#include "common/event.h"
|
||||||
#include "core/host_interface.h"
|
#include "core/host_interface.h"
|
||||||
#include "core/system.h"
|
#include "core/system.h"
|
||||||
|
#include "qtutils.h"
|
||||||
#include "frontend-common/common_host_interface.h"
|
#include "frontend-common/common_host_interface.h"
|
||||||
#include <QtCore/QByteArray>
|
#include <QtCore/QByteArray>
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
|
@ -205,10 +206,12 @@ protected:
|
||||||
void OnSystemStateSaved(bool global, s32 slot) override;
|
void OnSystemStateSaved(bool global, s32 slot) override;
|
||||||
|
|
||||||
void LoadSettings() override;
|
void LoadSettings() override;
|
||||||
|
void ApplySettings(bool display_osd_messages) override;
|
||||||
void SetDefaultSettings(SettingsInterface& si) override;
|
void SetDefaultSettings(SettingsInterface& si) override;
|
||||||
void UpdateInputMap() override;
|
void UpdateInputMap() override;
|
||||||
|
|
||||||
void SetMouseMode(bool relative, bool hide_cursor) override;
|
void SetMouseMode(bool relative, bool hide_cursor) override;
|
||||||
|
void RunLater(std::function<void()> func) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum : u32
|
enum : u32
|
||||||
|
|
|
@ -325,15 +325,20 @@ void SDLHostInterface::SaveAndUpdateSettings()
|
||||||
{
|
{
|
||||||
m_settings_copy.Save(*m_settings_interface.get());
|
m_settings_copy.Save(*m_settings_interface.get());
|
||||||
|
|
||||||
Settings old_settings(std::move(g_settings));
|
ApplySettings(false);
|
||||||
CommonHostInterface::LoadSettings(*m_settings_interface.get());
|
|
||||||
CommonHostInterface::ApplyGameSettings(false);
|
|
||||||
CommonHostInterface::FixIncompatibleSettings(false);
|
|
||||||
CheckForSettingsChanges(old_settings);
|
|
||||||
|
|
||||||
m_settings_interface->Save();
|
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
|
bool SDLHostInterface::IsFullscreen() const
|
||||||
{
|
{
|
||||||
return m_fullscreen;
|
return m_fullscreen;
|
||||||
|
|
|
@ -40,6 +40,12 @@ public:
|
||||||
|
|
||||||
bool RequestRenderWindowSize(s32 new_window_width, s32 new_window_height) override;
|
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();
|
void Run();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -67,14 +73,8 @@ private:
|
||||||
void CreateImGuiContext();
|
void CreateImGuiContext();
|
||||||
void UpdateFramebufferScale();
|
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();
|
void SaveAndUpdateSettings();
|
||||||
|
|
||||||
bool IsFullscreen() const override;
|
|
||||||
bool SetFullscreen(bool enabled) override;
|
|
||||||
|
|
||||||
// We only pass mouse input through if it's grabbed
|
// We only pass mouse input through if it's grabbed
|
||||||
void DrawImGuiWindows() override;
|
void DrawImGuiWindows() override;
|
||||||
void DoStartDisc();
|
void DoStartDisc();
|
||||||
|
|
|
@ -88,6 +88,12 @@ public:
|
||||||
/// Request the frontend to exit.
|
/// Request the frontend to exit.
|
||||||
virtual void RequestExit() = 0;
|
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 IsFullscreen() const;
|
||||||
virtual bool SetFullscreen(bool enabled);
|
virtual bool SetFullscreen(bool enabled);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue