mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-23 14:25:37 +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;
|
||||
}
|
||||
|
||||
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>");
|
||||
else
|
||||
Log_InfoPrintf("Boot Filename: %s", parameters.filename.c_str());
|
||||
Log_InfoPrintf("Boot Filename: %s", parameters->filename.c_str());
|
||||
}
|
||||
|
||||
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
|
||||
CreateAudioStream();
|
||||
|
||||
if (!System::Boot(parameters))
|
||||
if (!System::Boot(*parameters))
|
||||
{
|
||||
if (!System::IsStartupCancelled())
|
||||
{
|
||||
|
@ -417,9 +417,9 @@ bool HostInterface::LoadState(const char* filename)
|
|||
}
|
||||
else
|
||||
{
|
||||
SystemBootParameters boot_params;
|
||||
boot_params.state_stream = std::move(stream);
|
||||
if (!BootSystem(boot_params))
|
||||
auto boot_params = std::make_shared<SystemBootParameters>();
|
||||
boot_params->state_stream = std::move(stream);
|
||||
if (!BootSystem(std::move(boot_params)))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1164,9 +1164,9 @@ void HostInterface::RecreateSystem()
|
|||
|
||||
DestroySystem();
|
||||
|
||||
SystemBootParameters boot_params;
|
||||
boot_params.state_stream = std::move(stream);
|
||||
if (!BootSystem(boot_params))
|
||||
auto boot_params = std::make_shared<SystemBootParameters>();
|
||||
boot_params->state_stream = std::move(stream);
|
||||
if (!BootSystem(std::move(boot_params)))
|
||||
{
|
||||
ReportError("Failed to boot system after recreation.");
|
||||
return;
|
||||
|
|
|
@ -51,7 +51,7 @@ public:
|
|||
/// Shuts down the emulator frontend.
|
||||
virtual void Shutdown();
|
||||
|
||||
virtual bool BootSystem(const SystemBootParameters& parameters);
|
||||
virtual bool BootSystem(std::shared_ptr<SystemBootParameters> parameters);
|
||||
virtual void PauseSystem(bool paused);
|
||||
virtual void ResetSystem();
|
||||
virtual void DestroySystem();
|
||||
|
|
|
@ -68,8 +68,7 @@ static int Run(std::unique_ptr<NoGUIHostInterface> host_interface, std::unique_p
|
|||
}
|
||||
|
||||
if (boot_params)
|
||||
host_interface->BootSystem(*boot_params);
|
||||
boot_params.reset(); // Need to free resume file handle so auto save on exit works
|
||||
host_interface->BootSystem(std::move(boot_params));
|
||||
|
||||
int result;
|
||||
if (System::IsValid() || !host_interface->InBatchMode())
|
||||
|
|
|
@ -478,12 +478,12 @@ void MainWindow::onStartDiscActionTriggered()
|
|||
if (filename.isEmpty())
|
||||
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()
|
||||
{
|
||||
m_host_interface->bootSystem(std::make_shared<const SystemBootParameters>());
|
||||
m_host_interface->bootSystem(std::make_shared<SystemBootParameters>());
|
||||
}
|
||||
|
||||
void MainWindow::onChangeDiscFromFileActionTriggered()
|
||||
|
@ -655,9 +655,8 @@ void MainWindow::onGameListContextMenuRequested(const QPoint& point, const GameL
|
|||
m_host_interface->populateGameListContextMenu(entry, this, &menu);
|
||||
menu.addSeparator();
|
||||
|
||||
connect(menu.addAction(tr("Default Boot")), &QAction::triggered, [this, entry]() {
|
||||
m_host_interface->bootSystem(std::make_shared<const SystemBootParameters>(entry->path));
|
||||
});
|
||||
connect(menu.addAction(tr("Default Boot")), &QAction::triggered,
|
||||
[this, entry]() { m_host_interface->bootSystem(std::make_shared<SystemBootParameters>(entry->path)); });
|
||||
|
||||
connect(menu.addAction(tr("Fast Boot")), &QAction::triggered, [this, entry]() {
|
||||
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()))
|
||||
m_host_interface->resumeSystemFromState(QString::fromStdString(path), true);
|
||||
else
|
||||
m_host_interface->bootSystem(std::make_shared<const SystemBootParameters>(path));
|
||||
m_host_interface->bootSystem(std::make_shared<SystemBootParameters>(path));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -52,7 +52,7 @@ Log_SetChannel(QtHostInterface);
|
|||
|
||||
QtHostInterface::QtHostInterface(QObject* parent) : QObject(parent), CommonHostInterface()
|
||||
{
|
||||
qRegisterMetaType<std::shared_ptr<const SystemBootParameters>>();
|
||||
qRegisterMetaType<std::shared_ptr<SystemBootParameters>>();
|
||||
qRegisterMetaType<const GameListEntry*>();
|
||||
qRegisterMetaType<GPURenderer>();
|
||||
}
|
||||
|
@ -333,17 +333,17 @@ void QtHostInterface::setMainWindow(MainWindow* window)
|
|||
m_main_window = window;
|
||||
}
|
||||
|
||||
void QtHostInterface::bootSystem(std::shared_ptr<const SystemBootParameters> params)
|
||||
void QtHostInterface::bootSystem(std::shared_ptr<SystemBootParameters> params)
|
||||
{
|
||||
if (!isOnWorkerThread())
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
emit emulationStarting();
|
||||
if (!BootSystem(*params))
|
||||
if (!BootSystem(std::move(params)))
|
||||
return;
|
||||
|
||||
// force a frame to be drawn to repaint the window
|
||||
|
|
|
@ -32,7 +32,7 @@ class INISettingsInterface;
|
|||
class MainWindow;
|
||||
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(GPURenderer);
|
||||
|
||||
|
@ -149,7 +149,7 @@ public Q_SLOTS:
|
|||
void applySettings(bool display_osd_messages = false);
|
||||
void updateInputMap();
|
||||
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 resumeSystemFromMostRecentState();
|
||||
void powerOffSystem();
|
||||
|
|
|
@ -168,13 +168,13 @@ void CommonHostInterface::InitializeUserDirectory()
|
|||
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 (m_display && m_fullscreen_ui_enabled)
|
||||
FullscreenUI::EnsureGameListLoaded();
|
||||
|
||||
ApplyRendererFromGameSettings(parameters.filename);
|
||||
ApplyRendererFromGameSettings(parameters->filename);
|
||||
|
||||
if (!HostInterface::BootSystem(parameters))
|
||||
{
|
||||
|
@ -186,8 +186,8 @@ bool CommonHostInterface::BootSystem(const SystemBootParameters& parameters)
|
|||
}
|
||||
|
||||
// enter fullscreen if requested in the parameters
|
||||
if (!g_settings.start_paused && ((parameters.override_fullscreen.has_value() && *parameters.override_fullscreen) ||
|
||||
(!parameters.override_fullscreen.has_value() && g_settings.start_fullscreen)))
|
||||
if (!g_settings.start_paused && ((parameters->override_fullscreen.has_value() && *parameters->override_fullscreen) ||
|
||||
(!parameters->override_fullscreen.has_value() && g_settings.start_fullscreen)))
|
||||
{
|
||||
SetFullscreen(true);
|
||||
}
|
||||
|
@ -739,9 +739,7 @@ bool CommonHostInterface::CanResumeSystemFromFile(const char* filename)
|
|||
|
||||
bool CommonHostInterface::ResumeSystemFromState(const char* filename, bool boot_on_failure)
|
||||
{
|
||||
SystemBootParameters boot_params;
|
||||
boot_params.filename = filename;
|
||||
if (!BootSystem(boot_params))
|
||||
if (!BootSystem(std::make_shared<SystemBootParameters>(filename)))
|
||||
return false;
|
||||
|
||||
const bool global = System::GetRunningCode().empty();
|
||||
|
|
|
@ -129,7 +129,7 @@ public:
|
|||
|
||||
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 DestroySystem() override;
|
||||
|
||||
|
|
|
@ -551,9 +551,7 @@ static void DoStartPath(const std::string& path, bool allow_resume)
|
|||
return;
|
||||
}
|
||||
|
||||
SystemBootParameters params;
|
||||
params.filename = path;
|
||||
s_host_interface->BootSystem(params);
|
||||
s_host_interface->BootSystem(std::make_shared<SystemBootParameters>(path));
|
||||
}
|
||||
|
||||
static void DoStartFile()
|
||||
|
@ -571,10 +569,7 @@ static void DoStartFile()
|
|||
|
||||
static void DoStartBIOS()
|
||||
{
|
||||
s_host_interface->RunLater([]() {
|
||||
SystemBootParameters boot_params;
|
||||
s_host_interface->BootSystem(boot_params);
|
||||
});
|
||||
s_host_interface->RunLater([]() { s_host_interface->BootSystem(std::make_shared<SystemBootParameters>()); });
|
||||
ClearImGuiFocus();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue