core: Eliminate remaining usages of the global system instance

Removes all remaining usages of the global system instance. After this,
migration can begin to migrate to being constructed and managed entirely
by the various frontends.
This commit is contained in:
Lioncash
2020-11-27 10:50:48 -05:00
parent f397edff0e
commit 5bc4eabe36
21 changed files with 59 additions and 1594 deletions

View File

@@ -7,6 +7,7 @@
#include <QSettings>
#include "common/common_paths.h"
#include "common/file_util.h"
#include "core/core.h"
#include "core/hle/service/acc/profile_manager.h"
#include "core/hle/service/hid/controllers/npad.h"
#include "input_common/main.h"
@@ -1598,7 +1599,7 @@ void Config::Reload() {
Settings::Sanitize();
// To apply default value changes
SaveValues();
Settings::Apply();
Settings::Apply(Core::System::GetInstance());
}
void Config::Save() {

View File

@@ -5,6 +5,7 @@
#include <QHash>
#include <QListWidgetItem>
#include <QSignalBlocker>
#include "core/core.h"
#include "core/settings.h"
#include "ui_configure.h"
#include "yuzu/configuration/config.h"
@@ -54,7 +55,7 @@ void ConfigureDialog::ApplyConfiguration() {
ui->debugTab->ApplyConfiguration();
ui->webTab->ApplyConfiguration();
ui->serviceTab->ApplyConfiguration();
Settings::Apply();
Settings::Apply(Core::System::GetInstance());
Settings::LogSettings();
}

View File

@@ -57,7 +57,7 @@ void ConfigurePerGame::ApplyConfiguration() {
ui->graphicsAdvancedTab->ApplyConfiguration();
ui->audioTab->ApplyConfiguration();
Settings::Apply();
Settings::Apply(Core::System::GetInstance());
Settings::LogSettings();
game_config->Save();

View File

@@ -180,7 +180,7 @@ void ConfigureProfileManager::ApplyConfiguration() {
return;
}
Settings::Apply();
Settings::Apply(Core::System::GetInstance());
}
void ConfigureProfileManager::SelectUser(const QModelIndex& index) {

View File

@@ -105,16 +105,18 @@ void ConfigureSystem::SetConfiguration() {
void ConfigureSystem::ReadSystemSettings() {}
void ConfigureSystem::ApplyConfiguration() {
// Allow setting custom RTC even if system is powered on, to allow in-game time to be fast
// forwared
auto& system = Core::System::GetInstance();
// Allow setting custom RTC even if system is powered on,
// to allow in-game time to be fast forwarded
if (Settings::values.custom_rtc.UsingGlobal()) {
if (ui->custom_rtc_checkbox->isChecked()) {
Settings::values.custom_rtc.SetValue(
std::chrono::seconds(ui->custom_rtc_edit->dateTime().toSecsSinceEpoch()));
if (Core::System::GetInstance().IsPoweredOn()) {
if (system.IsPoweredOn()) {
const s64 posix_time{Settings::values.custom_rtc.GetValue()->count() +
Service::Time::TimeManager::GetExternalTimeZoneOffset()};
Core::System::GetInstance().GetTimeManager().UpdateLocalSystemClockTime(posix_time);
system.GetTimeManager().UpdateLocalSystemClockTime(posix_time);
}
} else {
Settings::values.custom_rtc.SetValue(std::nullopt);
@@ -197,7 +199,7 @@ void ConfigureSystem::ApplyConfiguration() {
}
}
Settings::Apply();
Settings::Apply(system);
}
void ConfigureSystem::RefreshConsoleID() {

View File

@@ -9,6 +9,7 @@
#include <QDirIterator>
#include "common/common_types.h"
#include "common/file_util.h"
#include "core/core.h"
#include "core/settings.h"
#include "ui_configure_ui.h"
#include "yuzu/configuration/configure_ui.h"
@@ -84,7 +85,7 @@ void ConfigureUi::ApplyConfiguration() {
UISettings::values.enable_screenshot_save_as = ui->enable_screenshot_save_as->isChecked();
Common::FS::GetUserPath(Common::FS::UserPath::ScreenshotsDir,
ui->screenshot_path_edit->text().toStdString());
Settings::Apply();
Settings::Apply(Core::System::GetInstance());
}
void ConfigureUi::RequestGameListUpdate() {

View File

@@ -172,7 +172,7 @@ void GMainWindow::ShowTelemetryCallout() {
"<br/><br/>Would you like to share your usage data with us?");
if (QMessageBox::question(this, tr("Telemetry"), telemetry_message) != QMessageBox::Yes) {
Settings::values.enable_telemetry = false;
Settings::Apply();
Settings::Apply(Core::System::GetInstance());
}
}
@@ -302,7 +302,7 @@ void GMainWindow::ControllerSelectorReconfigureControllers(
emit ControllerSelectorReconfigureFinished();
// Don't forget to apply settings.
Settings::Apply();
Settings::Apply(Core::System::GetInstance());
config->Save();
UpdateStatusButtons();
@@ -571,11 +571,11 @@ void GMainWindow::InitializeWidgets() {
if (emulation_running) {
return;
}
bool is_async = !Settings::values.use_asynchronous_gpu_emulation.GetValue() ||
Settings::values.use_multi_core.GetValue();
const bool is_async = !Settings::values.use_asynchronous_gpu_emulation.GetValue() ||
Settings::values.use_multi_core.GetValue();
Settings::values.use_asynchronous_gpu_emulation.SetValue(is_async);
async_status_button->setChecked(Settings::values.use_asynchronous_gpu_emulation.GetValue());
Settings::Apply();
Settings::Apply(Core::System::GetInstance());
});
async_status_button->setText(tr("ASYNC"));
async_status_button->setCheckable(true);
@@ -590,12 +590,12 @@ void GMainWindow::InitializeWidgets() {
return;
}
Settings::values.use_multi_core.SetValue(!Settings::values.use_multi_core.GetValue());
bool is_async = Settings::values.use_asynchronous_gpu_emulation.GetValue() ||
Settings::values.use_multi_core.GetValue();
const bool is_async = Settings::values.use_asynchronous_gpu_emulation.GetValue() ||
Settings::values.use_multi_core.GetValue();
Settings::values.use_asynchronous_gpu_emulation.SetValue(is_async);
async_status_button->setChecked(Settings::values.use_asynchronous_gpu_emulation.GetValue());
multicore_status_button->setChecked(Settings::values.use_multi_core.GetValue());
Settings::Apply();
Settings::Apply(Core::System::GetInstance());
});
multicore_status_button->setText(tr("MULTICORE"));
multicore_status_button->setCheckable(true);
@@ -630,7 +630,7 @@ void GMainWindow::InitializeWidgets() {
Settings::values.renderer_backend.SetValue(Settings::RendererBackend::OpenGL);
}
Settings::Apply();
Settings::Apply(Core::System::GetInstance());
});
#endif // HAS_VULKAN
statusBar()->insertPermanentWidget(0, renderer_status_button);
@@ -2130,14 +2130,14 @@ void GMainWindow::OnPauseGame() {
}
void GMainWindow::OnStopGame() {
Core::System& system{Core::System::GetInstance()};
auto& system{Core::System::GetInstance()};
if (system.GetExitLock() && !ConfirmForceLockedExit()) {
return;
}
ShutdownGame();
Settings::RestoreGlobalState();
Settings::RestoreGlobalState(system.IsPoweredOn());
UpdateStatusButtons();
}
@@ -2312,10 +2312,11 @@ void GMainWindow::OnConfigurePerGame() {
void GMainWindow::OpenPerGameConfiguration(u64 title_id, const std::string& file_name) {
const auto v_file = Core::GetGameFileFromPath(vfs, file_name);
const auto& system = Core::System::GetInstance();
ConfigurePerGame dialog(this, title_id);
dialog.LoadFromFile(v_file);
auto result = dialog.exec();
const auto result = dialog.exec();
if (result == QDialog::Accepted) {
dialog.ApplyConfiguration();
@@ -2325,13 +2326,14 @@ void GMainWindow::OpenPerGameConfiguration(u64 title_id, const std::string& file
}
// Do not cause the global config to write local settings into the config file
Settings::RestoreGlobalState();
const bool is_powered_on = system.IsPoweredOn();
Settings::RestoreGlobalState(is_powered_on);
if (!Core::System::GetInstance().IsPoweredOn()) {
if (!is_powered_on) {
config->Save();
}
} else {
Settings::RestoreGlobalState();
Settings::RestoreGlobalState(system.IsPoweredOn());
}
}
@@ -2602,7 +2604,7 @@ void GMainWindow::OnCoreError(Core::System::ResultStatus result, std::string det
if (emu_thread) {
ShutdownGame();
Settings::RestoreGlobalState();
Settings::RestoreGlobalState(Core::System::GetInstance().IsPoweredOn());
UpdateStatusButtons();
}
} else {
@@ -2774,7 +2776,7 @@ void GMainWindow::closeEvent(QCloseEvent* event) {
if (emu_thread != nullptr) {
ShutdownGame();
Settings::RestoreGlobalState();
Settings::RestoreGlobalState(Core::System::GetInstance().IsPoweredOn());
UpdateStatusButtons();
}