mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-27 08:05:41 +00:00
Refactor SystemBootParameters ownership
This commit is contained in:
parent
4e282cd172
commit
e21f2644d0
|
@ -83,14 +83,14 @@ s32 HostInterface::GetAudioOutputVolume() const
|
||||||
return g_settings.audio_output_muted ? 0 : g_settings.audio_output_volume;
|
return g_settings.audio_output_muted ? 0 : g_settings.audio_output_volume;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HostInterface::BootSystem(const SystemBootParameters& parameters)
|
bool HostInterface::BootSystem(std::shared_ptr<SystemBootParameters> parameters)
|
||||||
{
|
{
|
||||||
if (!parameters.state_stream)
|
if (!parameters->state_stream)
|
||||||
{
|
{
|
||||||
if (parameters.filename.empty())
|
if (parameters->filename.empty())
|
||||||
Log_InfoPrintf("Boot Filename: <BIOS/Shell>");
|
Log_InfoPrintf("Boot Filename: <BIOS/Shell>");
|
||||||
else
|
else
|
||||||
Log_InfoPrintf("Boot Filename: %s", parameters.filename.c_str());
|
Log_InfoPrintf("Boot Filename: %s", parameters->filename.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!AcquireHostDisplay())
|
if (!AcquireHostDisplay())
|
||||||
|
@ -108,7 +108,7 @@ bool HostInterface::BootSystem(const SystemBootParameters& parameters)
|
||||||
// create the audio stream. this will never fail, since we'll just fall back to null
|
// create the audio stream. this will never fail, since we'll just fall back to null
|
||||||
CreateAudioStream();
|
CreateAudioStream();
|
||||||
|
|
||||||
if (!System::Boot(parameters))
|
if (!System::Boot(*parameters))
|
||||||
{
|
{
|
||||||
if (!System::IsStartupCancelled())
|
if (!System::IsStartupCancelled())
|
||||||
{
|
{
|
||||||
|
@ -417,9 +417,9 @@ bool HostInterface::LoadState(const char* filename)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SystemBootParameters boot_params;
|
auto boot_params = std::make_shared<SystemBootParameters>();
|
||||||
boot_params.state_stream = std::move(stream);
|
boot_params->state_stream = std::move(stream);
|
||||||
if (!BootSystem(boot_params))
|
if (!BootSystem(std::move(boot_params)))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1164,9 +1164,9 @@ void HostInterface::RecreateSystem()
|
||||||
|
|
||||||
DestroySystem();
|
DestroySystem();
|
||||||
|
|
||||||
SystemBootParameters boot_params;
|
auto boot_params = std::make_shared<SystemBootParameters>();
|
||||||
boot_params.state_stream = std::move(stream);
|
boot_params->state_stream = std::move(stream);
|
||||||
if (!BootSystem(boot_params))
|
if (!BootSystem(std::move(boot_params)))
|
||||||
{
|
{
|
||||||
ReportError("Failed to boot system after recreation.");
|
ReportError("Failed to boot system after recreation.");
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -51,7 +51,7 @@ public:
|
||||||
/// Shuts down the emulator frontend.
|
/// Shuts down the emulator frontend.
|
||||||
virtual void Shutdown();
|
virtual void Shutdown();
|
||||||
|
|
||||||
virtual bool BootSystem(const SystemBootParameters& parameters);
|
virtual bool BootSystem(std::shared_ptr<SystemBootParameters> parameters);
|
||||||
virtual void PauseSystem(bool paused);
|
virtual void PauseSystem(bool paused);
|
||||||
virtual void ResetSystem();
|
virtual void ResetSystem();
|
||||||
virtual void DestroySystem();
|
virtual void DestroySystem();
|
||||||
|
|
|
@ -68,8 +68,7 @@ static int Run(std::unique_ptr<NoGUIHostInterface> host_interface, std::unique_p
|
||||||
}
|
}
|
||||||
|
|
||||||
if (boot_params)
|
if (boot_params)
|
||||||
host_interface->BootSystem(*boot_params);
|
host_interface->BootSystem(std::move(boot_params));
|
||||||
boot_params.reset(); // Need to free resume file handle so auto save on exit works
|
|
||||||
|
|
||||||
int result;
|
int result;
|
||||||
if (System::IsValid() || !host_interface->InBatchMode())
|
if (System::IsValid() || !host_interface->InBatchMode())
|
||||||
|
|
|
@ -478,12 +478,12 @@ void MainWindow::onStartDiscActionTriggered()
|
||||||
if (filename.isEmpty())
|
if (filename.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_host_interface->bootSystem(std::make_shared<const SystemBootParameters>(filename.toStdString()));
|
m_host_interface->bootSystem(std::make_shared<SystemBootParameters>(filename.toStdString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onStartBIOSActionTriggered()
|
void MainWindow::onStartBIOSActionTriggered()
|
||||||
{
|
{
|
||||||
m_host_interface->bootSystem(std::make_shared<const SystemBootParameters>());
|
m_host_interface->bootSystem(std::make_shared<SystemBootParameters>());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onChangeDiscFromFileActionTriggered()
|
void MainWindow::onChangeDiscFromFileActionTriggered()
|
||||||
|
@ -655,9 +655,8 @@ void MainWindow::onGameListContextMenuRequested(const QPoint& point, const GameL
|
||||||
m_host_interface->populateGameListContextMenu(entry, this, &menu);
|
m_host_interface->populateGameListContextMenu(entry, this, &menu);
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
|
|
||||||
connect(menu.addAction(tr("Default Boot")), &QAction::triggered, [this, entry]() {
|
connect(menu.addAction(tr("Default Boot")), &QAction::triggered,
|
||||||
m_host_interface->bootSystem(std::make_shared<const SystemBootParameters>(entry->path));
|
[this, entry]() { m_host_interface->bootSystem(std::make_shared<SystemBootParameters>(entry->path)); });
|
||||||
});
|
|
||||||
|
|
||||||
connect(menu.addAction(tr("Fast Boot")), &QAction::triggered, [this, entry]() {
|
connect(menu.addAction(tr("Fast Boot")), &QAction::triggered, [this, entry]() {
|
||||||
auto boot_params = std::make_shared<SystemBootParameters>(entry->path);
|
auto boot_params = std::make_shared<SystemBootParameters>(entry->path);
|
||||||
|
@ -976,7 +975,7 @@ void MainWindow::startGameOrChangeDiscs(const std::string& path)
|
||||||
if (m_host_interface->CanResumeSystemFromFile(path.c_str()))
|
if (m_host_interface->CanResumeSystemFromFile(path.c_str()))
|
||||||
m_host_interface->resumeSystemFromState(QString::fromStdString(path), true);
|
m_host_interface->resumeSystemFromState(QString::fromStdString(path), true);
|
||||||
else
|
else
|
||||||
m_host_interface->bootSystem(std::make_shared<const SystemBootParameters>(path));
|
m_host_interface->bootSystem(std::make_shared<SystemBootParameters>(path));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -52,7 +52,7 @@ Log_SetChannel(QtHostInterface);
|
||||||
|
|
||||||
QtHostInterface::QtHostInterface(QObject* parent) : QObject(parent), CommonHostInterface()
|
QtHostInterface::QtHostInterface(QObject* parent) : QObject(parent), CommonHostInterface()
|
||||||
{
|
{
|
||||||
qRegisterMetaType<std::shared_ptr<const SystemBootParameters>>();
|
qRegisterMetaType<std::shared_ptr<SystemBootParameters>>();
|
||||||
qRegisterMetaType<const GameListEntry*>();
|
qRegisterMetaType<const GameListEntry*>();
|
||||||
qRegisterMetaType<GPURenderer>();
|
qRegisterMetaType<GPURenderer>();
|
||||||
}
|
}
|
||||||
|
@ -333,17 +333,17 @@ void QtHostInterface::setMainWindow(MainWindow* window)
|
||||||
m_main_window = window;
|
m_main_window = window;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtHostInterface::bootSystem(std::shared_ptr<const SystemBootParameters> params)
|
void QtHostInterface::bootSystem(std::shared_ptr<SystemBootParameters> params)
|
||||||
{
|
{
|
||||||
if (!isOnWorkerThread())
|
if (!isOnWorkerThread())
|
||||||
{
|
{
|
||||||
QMetaObject::invokeMethod(this, "bootSystem", Qt::QueuedConnection,
|
QMetaObject::invokeMethod(this, "bootSystem", Qt::QueuedConnection,
|
||||||
Q_ARG(std::shared_ptr<const SystemBootParameters>, std::move(params)));
|
Q_ARG(std::shared_ptr<SystemBootParameters>, std::move(params)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
emit emulationStarting();
|
emit emulationStarting();
|
||||||
if (!BootSystem(*params))
|
if (!BootSystem(std::move(params)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// force a frame to be drawn to repaint the window
|
// force a frame to be drawn to repaint the window
|
||||||
|
|
|
@ -32,7 +32,7 @@ class INISettingsInterface;
|
||||||
class MainWindow;
|
class MainWindow;
|
||||||
class QtDisplayWidget;
|
class QtDisplayWidget;
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(std::shared_ptr<const SystemBootParameters>);
|
Q_DECLARE_METATYPE(std::shared_ptr<SystemBootParameters>);
|
||||||
Q_DECLARE_METATYPE(const GameListEntry*);
|
Q_DECLARE_METATYPE(const GameListEntry*);
|
||||||
Q_DECLARE_METATYPE(GPURenderer);
|
Q_DECLARE_METATYPE(GPURenderer);
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ public Q_SLOTS:
|
||||||
void applySettings(bool display_osd_messages = false);
|
void applySettings(bool display_osd_messages = false);
|
||||||
void updateInputMap();
|
void updateInputMap();
|
||||||
void applyInputProfile(const QString& profile_path);
|
void applyInputProfile(const QString& profile_path);
|
||||||
void bootSystem(std::shared_ptr<const SystemBootParameters> params);
|
void bootSystem(std::shared_ptr<SystemBootParameters> params);
|
||||||
void resumeSystemFromState(const QString& filename, bool boot_on_failure);
|
void resumeSystemFromState(const QString& filename, bool boot_on_failure);
|
||||||
void resumeSystemFromMostRecentState();
|
void resumeSystemFromMostRecentState();
|
||||||
void powerOffSystem();
|
void powerOffSystem();
|
||||||
|
|
|
@ -168,13 +168,13 @@ void CommonHostInterface::InitializeUserDirectory()
|
||||||
ReportError("Failed to create one or more user directories. This may cause issues at runtime.");
|
ReportError("Failed to create one or more user directories. This may cause issues at runtime.");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CommonHostInterface::BootSystem(const SystemBootParameters& parameters)
|
bool CommonHostInterface::BootSystem(std::shared_ptr<SystemBootParameters> parameters)
|
||||||
{
|
{
|
||||||
// If the fullscreen UI is enabled, make sure it's finished loading the game list so we don't race it.
|
// If the fullscreen UI is enabled, make sure it's finished loading the game list so we don't race it.
|
||||||
if (m_display && m_fullscreen_ui_enabled)
|
if (m_display && m_fullscreen_ui_enabled)
|
||||||
FullscreenUI::EnsureGameListLoaded();
|
FullscreenUI::EnsureGameListLoaded();
|
||||||
|
|
||||||
ApplyRendererFromGameSettings(parameters.filename);
|
ApplyRendererFromGameSettings(parameters->filename);
|
||||||
|
|
||||||
if (!HostInterface::BootSystem(parameters))
|
if (!HostInterface::BootSystem(parameters))
|
||||||
{
|
{
|
||||||
|
@ -186,8 +186,8 @@ bool CommonHostInterface::BootSystem(const SystemBootParameters& parameters)
|
||||||
}
|
}
|
||||||
|
|
||||||
// enter fullscreen if requested in the parameters
|
// enter fullscreen if requested in the parameters
|
||||||
if (!g_settings.start_paused && ((parameters.override_fullscreen.has_value() && *parameters.override_fullscreen) ||
|
if (!g_settings.start_paused && ((parameters->override_fullscreen.has_value() && *parameters->override_fullscreen) ||
|
||||||
(!parameters.override_fullscreen.has_value() && g_settings.start_fullscreen)))
|
(!parameters->override_fullscreen.has_value() && g_settings.start_fullscreen)))
|
||||||
{
|
{
|
||||||
SetFullscreen(true);
|
SetFullscreen(true);
|
||||||
}
|
}
|
||||||
|
@ -739,9 +739,7 @@ bool CommonHostInterface::CanResumeSystemFromFile(const char* filename)
|
||||||
|
|
||||||
bool CommonHostInterface::ResumeSystemFromState(const char* filename, bool boot_on_failure)
|
bool CommonHostInterface::ResumeSystemFromState(const char* filename, bool boot_on_failure)
|
||||||
{
|
{
|
||||||
SystemBootParameters boot_params;
|
if (!BootSystem(std::make_shared<SystemBootParameters>(filename)))
|
||||||
boot_params.filename = filename;
|
|
||||||
if (!BootSystem(boot_params))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const bool global = System::GetRunningCode().empty();
|
const bool global = System::GetRunningCode().empty();
|
||||||
|
|
|
@ -129,7 +129,7 @@ public:
|
||||||
|
|
||||||
virtual void Shutdown() override;
|
virtual void Shutdown() override;
|
||||||
|
|
||||||
virtual bool BootSystem(const SystemBootParameters& parameters) override;
|
virtual bool BootSystem(std::shared_ptr<SystemBootParameters> parameters) override;
|
||||||
virtual void ResetSystem() override;
|
virtual void ResetSystem() override;
|
||||||
virtual void DestroySystem() override;
|
virtual void DestroySystem() override;
|
||||||
|
|
||||||
|
|
|
@ -551,9 +551,7 @@ static void DoStartPath(const std::string& path, bool allow_resume)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemBootParameters params;
|
s_host_interface->BootSystem(std::make_shared<SystemBootParameters>(path));
|
||||||
params.filename = path;
|
|
||||||
s_host_interface->BootSystem(params);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DoStartFile()
|
static void DoStartFile()
|
||||||
|
@ -571,10 +569,7 @@ static void DoStartFile()
|
||||||
|
|
||||||
static void DoStartBIOS()
|
static void DoStartBIOS()
|
||||||
{
|
{
|
||||||
s_host_interface->RunLater([]() {
|
s_host_interface->RunLater([]() { s_host_interface->BootSystem(std::make_shared<SystemBootParameters>()); });
|
||||||
SystemBootParameters boot_params;
|
|
||||||
s_host_interface->BootSystem(boot_params);
|
|
||||||
});
|
|
||||||
ClearImGuiFocus();
|
ClearImGuiFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue