From 2545e9f3e93705563e6b9cdec98e325b720f7c8a Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Sat, 16 Oct 2021 02:35:29 +0200 Subject: [PATCH] early-access version 2139 --- README.md | 2 +- src/common/string_util.cpp | 12 +- src/common/string_util.h | 2 +- src/core/core.cpp | 98 ++-- src/core/core.h | 61 ++- .../hle/service/nvdrv/devices/nvhost_ctrl.cpp | 8 +- src/yuzu/about_dialog.cpp | 3 +- src/yuzu/applets/qt_web_browser.cpp | 1 + src/yuzu/bootmanager.cpp | 6 +- src/yuzu/bootmanager.h | 8 +- src/yuzu/configuration/configure_cpu.cpp | 2 +- .../configuration/configure_cpu_debug.cpp | 2 +- src/yuzu/configuration/configure_debug.cpp | 2 +- .../configuration/configure_debug_tab.cpp | 4 +- src/yuzu/configuration/configure_dialog.cpp | 2 +- src/yuzu/configuration/configure_general.cpp | 2 +- src/yuzu/configuration/configure_graphics.cpp | 2 +- .../configure_graphics_advanced.cpp | 2 +- .../configure_per_game_addons.cpp | 2 +- .../configure_profile_manager.cpp | 2 +- src/yuzu/configuration/configure_system.cpp | 2 +- src/yuzu/configuration/configure_ui.cpp | 2 +- src/yuzu/main.cpp | 447 +++++++++--------- src/yuzu/main.h | 20 +- src/yuzu/uisettings.h | 2 +- src/yuzu_cmd/yuzu.cpp | 21 +- 26 files changed, 358 insertions(+), 359 deletions(-) diff --git a/README.md b/README.md index 24654038b..1f3db0567 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 2134. +This is the source code for early-access 2139. ## Legal Notice diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp index e6344fd41..662171138 100755 --- a/src/common/string_util.cpp +++ b/src/common/string_util.cpp @@ -180,20 +180,20 @@ std::wstring UTF8ToUTF16W(const std::string& input) { #endif -std::string StringFromFixedZeroTerminatedBuffer(const char* buffer, std::size_t max_len) { +std::string StringFromFixedZeroTerminatedBuffer(std::string_view buffer, std::size_t max_len) { std::size_t len = 0; - while (len < max_len && buffer[len] != '\0') + while (len < buffer.length() && len < max_len && buffer[len] != '\0') { ++len; - - return std::string(buffer, len); + } + return std::string(buffer.begin(), buffer.begin() + len); } std::u16string UTF16StringFromFixedZeroTerminatedBuffer(std::u16string_view buffer, std::size_t max_len) { std::size_t len = 0; - while (len < max_len && buffer[len] != '\0') + while (len < buffer.length() && len < max_len && buffer[len] != '\0') { ++len; - + } return std::u16string(buffer.begin(), buffer.begin() + len); } diff --git a/src/common/string_util.h b/src/common/string_util.h index 7e90a9ca5..f0dd632ee 100755 --- a/src/common/string_util.h +++ b/src/common/string_util.h @@ -63,7 +63,7 @@ template * Creates a std::string from a fixed-size NUL-terminated char buffer. If the buffer isn't * NUL-terminated then the string ends at max_len characters. */ -[[nodiscard]] std::string StringFromFixedZeroTerminatedBuffer(const char* buffer, +[[nodiscard]] std::string StringFromFixedZeroTerminatedBuffer(std::string_view buffer, std::size_t max_len); /** diff --git a/src/core/core.cpp b/src/core/core.cpp index 2e2d0938d..3042d611b 100755 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -139,9 +139,9 @@ struct System::Impl { : kernel{system}, fs_controller{system}, memory{system}, cpu_manager{system}, reporter{system}, applet_manager{system}, time_manager{system} {} - ResultStatus Run() { + SystemResultStatus Run() { std::unique_lock lk(suspend_guard); - status = ResultStatus::Success; + status = SystemResultStatus::Success; kernel.Suspend(false); core_timing.SyncPause(false); @@ -151,9 +151,9 @@ struct System::Impl { return status; } - ResultStatus Pause() { + SystemResultStatus Pause() { std::unique_lock lk(suspend_guard); - status = ResultStatus::Success; + status = SystemResultStatus::Success; core_timing.SyncPause(true); kernel.Suspend(true); @@ -163,23 +163,23 @@ struct System::Impl { return status; } - void stallForGPU(bool pause) { - if (pause) { - suspend_guard.lock(); - kernel.Suspend(pause); - core_timing.SyncPause(pause); - cpu_manager.Pause(pause); - } else { - if (!is_paused) { - core_timing.SyncPause(pause); - kernel.Suspend(pause); - cpu_manager.Pause(pause); - } - suspend_guard.unlock(); + std::unique_lock StallCPU() { + std::unique_lock lk(suspend_guard); + kernel.Suspend(true); + core_timing.SyncPause(true); + cpu_manager.Pause(true); + return lk; + } + + void UnstallCPU() { + if (!is_paused) { + core_timing.SyncPause(false); + kernel.Suspend(false); + cpu_manager.Pause(false); } } - ResultStatus Init(System& system, Frontend::EmuWindow& emu_window) { + SystemResultStatus Init(System& system, Frontend::EmuWindow& emu_window) { LOG_DEBUG(Core, "initialized OK"); device_memory = std::make_unique(); @@ -217,7 +217,7 @@ struct System::Impl { gpu_core = VideoCore::CreateGPU(emu_window, system); if (!gpu_core) { - return ResultStatus::ErrorVideoCore; + return SystemResultStatus::ErrorVideoCore; } service_manager = std::make_shared(kernel); @@ -237,21 +237,22 @@ struct System::Impl { LOG_DEBUG(Core, "Initialized OK"); - return ResultStatus::Success; + return SystemResultStatus::Success; } - ResultStatus Load(System& system, Frontend::EmuWindow& emu_window, const std::string& filepath, - u64 program_id, std::size_t program_index) { + SystemResultStatus Load(System& system, Frontend::EmuWindow& emu_window, + const std::string& filepath, u64 program_id, + std::size_t program_index) { app_loader = Loader::GetLoader(system, GetGameFileFromPath(virtual_filesystem, filepath), program_id, program_index); if (!app_loader) { LOG_CRITICAL(Core, "Failed to obtain loader for {}!", filepath); - return ResultStatus::ErrorGetLoader; + return SystemResultStatus::ErrorGetLoader; } - ResultStatus init_result{Init(system, emu_window)}; - if (init_result != ResultStatus::Success) { + SystemResultStatus init_result{Init(system, emu_window)}; + if (init_result != SystemResultStatus::Success) { LOG_CRITICAL(Core, "Failed to initialize system (Error {})!", static_cast(init_result)); Shutdown(); @@ -269,8 +270,8 @@ struct System::Impl { LOG_CRITICAL(Core, "Failed to load ROM (Error {})!", load_result); Shutdown(); - return static_cast(static_cast(ResultStatus::ErrorLoader) + - static_cast(load_result)); + return static_cast( + static_cast(SystemResultStatus::ErrorLoader) + static_cast(load_result)); } AddGlueRegistrationForProcess(*app_loader, *main_process); kernel.MakeCurrentProcess(main_process.get()); @@ -302,7 +303,7 @@ struct System::Impl { GetAndResetPerfStats(); perf_stats->BeginSystemFrame(); - status = ResultStatus::Success; + status = SystemResultStatus::Success; return status; } @@ -375,7 +376,7 @@ struct System::Impl { arp_manager.Register(launch.title_id, launch, std::move(nacp_data)); } - void SetStatus(ResultStatus new_status, const char* details = nullptr) { + void SetStatus(SystemResultStatus new_status, const char* details = nullptr) { status = new_status; if (details) { status_details = details; @@ -434,7 +435,7 @@ struct System::Impl { /// Network instance Network::NetworkInstance network_instance; - ResultStatus status = ResultStatus::Success; + SystemResultStatus status = SystemResultStatus::Success; std::string status_details = ""; std::unique_ptr perf_stats; @@ -451,22 +452,9 @@ struct System::Impl { }; System::System() : impl{std::make_unique(*this)} {} + System::~System() = default; -System& System::GetInstance() { - if (!s_instance) { - throw std::runtime_error("Using System instance before its initialization"); - } - return *s_instance; -} - -void System::InitializeGlobalInstance() { - if (s_instance) { - throw std::runtime_error("Reinitializing Global System instance."); - } - s_instance = std::unique_ptr(new System); -} - CpuManager& System::GetCpuManager() { return impl->cpu_manager; } @@ -475,16 +463,16 @@ const CpuManager& System::GetCpuManager() const { return impl->cpu_manager; } -System::ResultStatus System::Run() { +SystemResultStatus System::Run() { return impl->Run(); } -System::ResultStatus System::Pause() { +SystemResultStatus System::Pause() { return impl->Pause(); } -System::ResultStatus System::SingleStep() { - return ResultStatus::Success; +SystemResultStatus System::SingleStep() { + return SystemResultStatus::Success; } void System::InvalidateCpuInstructionCaches() { @@ -499,12 +487,16 @@ void System::Shutdown() { impl->Shutdown(); } -void System::stallForGPU(bool pause) { - impl->stallForGPU(pause); +std::unique_lock System::StallCPU() { + return impl->StallCPU(); } -System::ResultStatus System::Load(Frontend::EmuWindow& emu_window, const std::string& filepath, - u64 program_id, std::size_t program_index) { +void System::UnstallCPU() { + impl->UnstallCPU(); +} + +SystemResultStatus System::Load(Frontend::EmuWindow& emu_window, const std::string& filepath, + u64 program_id, std::size_t program_index) { return impl->Load(*this, emu_window, filepath, program_id, program_index); } @@ -664,7 +656,7 @@ Loader::ResultStatus System::GetGameName(std::string& out) const { return impl->GetGameName(out); } -void System::SetStatus(ResultStatus new_status, const char* details) { +void System::SetStatus(SystemResultStatus new_status, const char* details) { impl->SetStatus(new_status, details); } diff --git a/src/core/core.h b/src/core/core.h index ebe1f8c4c..1cfe1bba6 100755 --- a/src/core/core.h +++ b/src/core/core.h @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -104,55 +105,49 @@ struct PerfStatsResults; FileSys::VirtualFile GetGameFileFromPath(const FileSys::VirtualFilesystem& vfs, const std::string& path); +/// Enumeration representing the return values of the System Initialize and Load process. +enum class SystemResultStatus : u32 { + Success, ///< Succeeded + ErrorNotInitialized, ///< Error trying to use core prior to initialization + ErrorGetLoader, ///< Error finding the correct application loader + ErrorSystemFiles, ///< Error in finding system files + ErrorSharedFont, ///< Error in finding shared font + ErrorVideoCore, ///< Error in the video core + ErrorUnknown, ///< Any other error + ErrorLoader, ///< The base for loader errors (too many to repeat) +}; + class System { public: using CurrentBuildProcessID = std::array; + explicit System(); + + ~System(); + System(const System&) = delete; System& operator=(const System&) = delete; System(System&&) = delete; System& operator=(System&&) = delete; - ~System(); - - /** - * Gets the instance of the System singleton class. - * @returns Reference to the instance of the System singleton class. - */ - [[deprecated("Use of the global system instance is deprecated")]] static System& GetInstance(); - - static void InitializeGlobalInstance(); - - /// Enumeration representing the return values of the System Initialize and Load process. - enum class ResultStatus : u32 { - Success, ///< Succeeded - ErrorNotInitialized, ///< Error trying to use core prior to initialization - ErrorGetLoader, ///< Error finding the correct application loader - ErrorSystemFiles, ///< Error in finding system files - ErrorSharedFont, ///< Error in finding shared font - ErrorVideoCore, ///< Error in the video core - ErrorUnknown, ///< Any other error - ErrorLoader, ///< The base for loader errors (too many to repeat) - }; - /** * Run the OS and Application * This function will start emulation and run the relevant devices */ - [[nodiscard]] ResultStatus Run(); + [[nodiscard]] SystemResultStatus Run(); /** * Pause the OS and Application * This function will pause emulation and stop the relevant devices */ - [[nodiscard]] ResultStatus Pause(); + [[nodiscard]] SystemResultStatus Pause(); /** * Step the CPU one instruction * @return Result status, indicating whether or not the operation succeeded. */ - [[nodiscard]] ResultStatus SingleStep(); + [[nodiscard]] SystemResultStatus SingleStep(); /** * Invalidate the CPU instruction caches @@ -166,7 +161,8 @@ public: /// Shutdown the emulated system. void Shutdown(); - void stallForGPU(bool pause); + std::unique_lock StallCPU(); + void UnstallCPU(); /** * Load an executable application. @@ -174,10 +170,11 @@ public: * input. * @param filepath String path to the executable application to load on the host file system. * @param program_index Specifies the index within the container of the program to launch. - * @returns ResultStatus code, indicating if the operation succeeded. + * @returns SystemResultStatus code, indicating if the operation succeeded. */ - [[nodiscard]] ResultStatus Load(Frontend::EmuWindow& emu_window, const std::string& filepath, - u64 program_id = 0, std::size_t program_index = 0); + [[nodiscard]] SystemResultStatus Load(Frontend::EmuWindow& emu_window, + const std::string& filepath, u64 program_id = 0, + std::size_t program_index = 0); /** * Indicates if the emulated system is powered on (all subsystems initialized and able to run an @@ -303,7 +300,7 @@ public: /// Gets the name of the current game [[nodiscard]] Loader::ResultStatus GetGameName(std::string& out) const; - void SetStatus(ResultStatus new_status, const char* details); + void SetStatus(SystemResultStatus new_status, const char* details); [[nodiscard]] const std::string& GetStatusDetails() const; @@ -405,12 +402,8 @@ public: void ApplySettings(); private: - System(); - struct Impl; std::unique_ptr impl; - - inline static std::unique_ptr s_instance{}; }; } // namespace Core diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp index b59eae55c..f9b82b504 100755 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp @@ -150,9 +150,11 @@ NvResult nvhost_ctrl::IocCtrlEventWait(const std::vector& input, std::vector params.value |= event_id; event.event->GetWritableEvent().Clear(); if (events_interface.failed[event_id]) { - system.stallForGPU(true); - gpu.WaitFence(params.syncpt_id, target_value); - system.stallForGPU(false); + { + auto lk = system.StallCPU(); + gpu.WaitFence(params.syncpt_id, target_value); + system.UnstallCPU(); + } std::memcpy(output.data(), ¶ms, sizeof(params)); events_interface.failed[event_id] = false; return NvResult::Success; diff --git a/src/yuzu/about_dialog.cpp b/src/yuzu/about_dialog.cpp index 6b0155a78..04ab4ae21 100755 --- a/src/yuzu/about_dialog.cpp +++ b/src/yuzu/about_dialog.cpp @@ -8,7 +8,8 @@ #include "ui_aboutdialog.h" #include "yuzu/about_dialog.h" -AboutDialog::AboutDialog(QWidget* parent) : QDialog(parent), ui(new Ui::AboutDialog) { +AboutDialog::AboutDialog(QWidget* parent) + : QDialog(parent), ui{std::make_unique()} { const auto branch_name = std::string(Common::g_scm_branch); const auto description = std::string(Common::g_scm_desc); const auto build_id = std::string(Common::g_build_id); diff --git a/src/yuzu/applets/qt_web_browser.cpp b/src/yuzu/applets/qt_web_browser.cpp index 7d433ca50..da8c6882a 100755 --- a/src/yuzu/applets/qt_web_browser.cpp +++ b/src/yuzu/applets/qt_web_browser.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #ifdef YUZU_USE_QT_WEB_ENGINE +#include #include #include diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp index c75f5e1ee..40fd47406 100755 --- a/src/yuzu/bootmanager.cpp +++ b/src/yuzu/bootmanager.cpp @@ -86,15 +86,15 @@ void EmuThread::run() { } running_guard = true; - Core::System::ResultStatus result = system.Run(); - if (result != Core::System::ResultStatus::Success) { + Core::SystemResultStatus result = system.Run(); + if (result != Core::SystemResultStatus::Success) { running_guard = false; this->SetRunning(false); emit ErrorThrown(result, system.GetStatusDetails()); } running_wait.Wait(); result = system.Pause(); - if (result != Core::System::ResultStatus::Success) { + if (result != Core::SystemResultStatus::Success) { running_guard = false; this->SetRunning(false); emit ErrorThrown(result, system.GetStatusDetails()); diff --git a/src/yuzu/bootmanager.h b/src/yuzu/bootmanager.h index 8d7ab8c2e..e6a0666e9 100755 --- a/src/yuzu/bootmanager.h +++ b/src/yuzu/bootmanager.h @@ -16,7 +16,6 @@ #include #include "common/thread.h" -#include "core/core.h" #include "core/frontend/emu_window.h" class GRenderWindow; @@ -24,6 +23,11 @@ class GMainWindow; class QKeyEvent; class QStringList; +namespace Core { +enum class SystemResultStatus : u32; +class System; +} // namespace Core + namespace InputCommon { class InputSubsystem; } @@ -123,7 +127,7 @@ signals: */ void DebugModeLeft(); - void ErrorThrown(Core::System::ResultStatus, std::string); + void ErrorThrown(Core::SystemResultStatus, std::string); void LoadProgress(VideoCore::LoadCallbackStage stage, std::size_t value, std::size_t total); }; diff --git a/src/yuzu/configuration/configure_cpu.cpp b/src/yuzu/configuration/configure_cpu.cpp index 27fabef38..f66cab5d4 100755 --- a/src/yuzu/configuration/configure_cpu.cpp +++ b/src/yuzu/configuration/configure_cpu.cpp @@ -14,7 +14,7 @@ #include "yuzu/configuration/configure_cpu.h" ConfigureCpu::ConfigureCpu(const Core::System& system_, QWidget* parent) - : QWidget(parent), ui(new Ui::ConfigureCpu), system{system_} { + : QWidget(parent), ui{std::make_unique()}, system{system_} { ui->setupUi(this); SetupPerGameUI(); diff --git a/src/yuzu/configuration/configure_cpu_debug.cpp b/src/yuzu/configuration/configure_cpu_debug.cpp index 6e910e33e..05a90963d 100755 --- a/src/yuzu/configuration/configure_cpu_debug.cpp +++ b/src/yuzu/configuration/configure_cpu_debug.cpp @@ -12,7 +12,7 @@ #include "yuzu/configuration/configure_cpu_debug.h" ConfigureCpuDebug::ConfigureCpuDebug(const Core::System& system_, QWidget* parent) - : QWidget(parent), ui(new Ui::ConfigureCpuDebug), system{system_} { + : QWidget(parent), ui{std::make_unique()}, system{system_} { ui->setupUi(this); SetConfiguration(); diff --git a/src/yuzu/configuration/configure_debug.cpp b/src/yuzu/configuration/configure_debug.cpp index 40447093e..07bfa0360 100755 --- a/src/yuzu/configuration/configure_debug.cpp +++ b/src/yuzu/configuration/configure_debug.cpp @@ -15,7 +15,7 @@ #include "yuzu/uisettings.h" ConfigureDebug::ConfigureDebug(const Core::System& system_, QWidget* parent) - : QWidget(parent), ui(new Ui::ConfigureDebug), system{system_} { + : QWidget(parent), ui{std::make_unique()}, system{system_} { ui->setupUi(this); SetConfiguration(); diff --git a/src/yuzu/configuration/configure_debug_tab.cpp b/src/yuzu/configuration/configure_debug_tab.cpp index e126eeea9..e69cca1ef 100755 --- a/src/yuzu/configuration/configure_debug_tab.cpp +++ b/src/yuzu/configuration/configure_debug_tab.cpp @@ -9,8 +9,8 @@ #include "yuzu/configuration/configure_debug_tab.h" ConfigureDebugTab::ConfigureDebugTab(const Core::System& system_, QWidget* parent) - : QWidget(parent), - ui(new Ui::ConfigureDebugTab), debug_tab{std::make_unique(system_, this)}, + : QWidget(parent), ui{std::make_unique()}, + debug_tab{std::make_unique(system_, this)}, cpu_debug_tab{std::make_unique(system_, this)} { ui->setupUi(this); diff --git a/src/yuzu/configuration/configure_dialog.cpp b/src/yuzu/configuration/configure_dialog.cpp index 759625ef7..4fa0c4a43 100755 --- a/src/yuzu/configuration/configure_dialog.cpp +++ b/src/yuzu/configuration/configure_dialog.cpp @@ -36,7 +36,7 @@ ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry, InputCommon::InputSubsystem* input_subsystem, Core::System& system_) - : QDialog(parent), ui(new Ui::ConfigureDialog), + : QDialog(parent), ui{std::make_unique()}, registry(registry), system{system_}, audio_tab{std::make_unique(system_, this)}, cpu_tab{std::make_unique(system_, this)}, diff --git a/src/yuzu/configuration/configure_general.cpp b/src/yuzu/configuration/configure_general.cpp index e562e89e5..7af3ea97e 100755 --- a/src/yuzu/configuration/configure_general.cpp +++ b/src/yuzu/configuration/configure_general.cpp @@ -16,7 +16,7 @@ #include "yuzu/uisettings.h" ConfigureGeneral::ConfigureGeneral(const Core::System& system_, QWidget* parent) - : QWidget(parent), ui(new Ui::ConfigureGeneral), system{system_} { + : QWidget(parent), ui{std::make_unique()}, system{system_} { ui->setupUi(this); SetupPerGameUI(); diff --git a/src/yuzu/configuration/configure_graphics.cpp b/src/yuzu/configuration/configure_graphics.cpp index be4e7997b..8e20cc6f3 100755 --- a/src/yuzu/configuration/configure_graphics.cpp +++ b/src/yuzu/configuration/configure_graphics.cpp @@ -20,7 +20,7 @@ #include "yuzu/configuration/configure_graphics.h" ConfigureGraphics::ConfigureGraphics(const Core::System& system_, QWidget* parent) - : QWidget(parent), ui(new Ui::ConfigureGraphics), system{system_} { + : QWidget(parent), ui{std::make_unique()}, system{system_} { vulkan_device = Settings::values.vulkan_device.GetValue(); RetrieveVulkanDevices(); diff --git a/src/yuzu/configuration/configure_graphics_advanced.cpp b/src/yuzu/configuration/configure_graphics_advanced.cpp index 4407e65d3..30c5a3595 100755 --- a/src/yuzu/configuration/configure_graphics_advanced.cpp +++ b/src/yuzu/configuration/configure_graphics_advanced.cpp @@ -9,7 +9,7 @@ #include "yuzu/configuration/configure_graphics_advanced.h" ConfigureGraphicsAdvanced::ConfigureGraphicsAdvanced(const Core::System& system_, QWidget* parent) - : QWidget(parent), ui(new Ui::ConfigureGraphicsAdvanced), system{system_} { + : QWidget(parent), ui{std::make_unique()}, system{system_} { ui->setupUi(this); diff --git a/src/yuzu/configuration/configure_per_game_addons.cpp b/src/yuzu/configuration/configure_per_game_addons.cpp index c8de8e2ff..65e615963 100755 --- a/src/yuzu/configuration/configure_per_game_addons.cpp +++ b/src/yuzu/configuration/configure_per_game_addons.cpp @@ -27,7 +27,7 @@ #include "yuzu/util/util.h" ConfigurePerGameAddons::ConfigurePerGameAddons(Core::System& system_, QWidget* parent) - : QWidget(parent), ui(new Ui::ConfigurePerGameAddons), system{system_} { + : QWidget(parent), ui{std::make_unique()}, system{system_} { ui->setupUi(this); layout = new QVBoxLayout; diff --git a/src/yuzu/configuration/configure_profile_manager.cpp b/src/yuzu/configuration/configure_profile_manager.cpp index 9feec37ff..99d5f4686 100755 --- a/src/yuzu/configuration/configure_profile_manager.cpp +++ b/src/yuzu/configuration/configure_profile_manager.cpp @@ -77,7 +77,7 @@ QString GetProfileUsernameFromUser(QWidget* parent, const QString& description_t } // Anonymous namespace ConfigureProfileManager::ConfigureProfileManager(const Core::System& system_, QWidget* parent) - : QWidget(parent), ui(new Ui::ConfigureProfileManager), + : QWidget(parent), ui{std::make_unique()}, profile_manager(std::make_unique()), system{system_} { ui->setupUi(this); diff --git a/src/yuzu/configuration/configure_system.cpp b/src/yuzu/configuration/configure_system.cpp index 33eb059a3..eea45f8ea 100755 --- a/src/yuzu/configuration/configure_system.cpp +++ b/src/yuzu/configuration/configure_system.cpp @@ -18,7 +18,7 @@ #include "yuzu/configuration/configure_system.h" ConfigureSystem::ConfigureSystem(Core::System& system_, QWidget* parent) - : QWidget(parent), ui(new Ui::ConfigureSystem), system{system_} { + : QWidget(parent), ui{std::make_unique()}, system{system_} { ui->setupUi(this); connect(ui->button_regenerate_console_id, &QPushButton::clicked, this, &ConfigureSystem::RefreshConsoleID); diff --git a/src/yuzu/configuration/configure_ui.cpp b/src/yuzu/configuration/configure_ui.cpp index d01895bf2..46e5409db 100755 --- a/src/yuzu/configuration/configure_ui.cpp +++ b/src/yuzu/configuration/configure_ui.cpp @@ -55,7 +55,7 @@ QString GetTranslatedRowTextName(size_t index) { } // Anonymous namespace ConfigureUi::ConfigureUi(Core::System& system_, QWidget* parent) - : QWidget(parent), ui(new Ui::ConfigureUi), system{system_} { + : QWidget(parent), ui{std::make_unique()}, system{system_} { ui->setupUi(this); InitializeLanguageComboBox(); diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 84e2c5df7..43c6a79ea 100755 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -110,6 +110,7 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual #include "core/telemetry_session.h" #include "input_common/main.h" #include "input_common/tas/tas_input.h" +#include "ui_main.h" #include "util/overlay_dialog.h" #include "video_core/gpu.h" #include "video_core/renderer_base.h" @@ -177,7 +178,7 @@ void GMainWindow::ShowTelemetryCallout() { "

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; - system.ApplySettings(); + system->ApplySettings(); } } @@ -196,16 +197,17 @@ static void RemoveCachedContents() { Common::FS::RemoveDirRecursively(offline_system_data); } -GMainWindow::GMainWindow(Core::System& system_) - : input_subsystem{std::make_shared()}, system{system_}, - config{std::make_unique(system_)}, +GMainWindow::GMainWindow() + : system{std::make_unique()}, + input_subsystem{std::make_shared()}, + config{std::make_unique(*system)}, vfs{std::make_shared()}, provider{std::make_unique()} { Common::Log::Initialize(); LoadTranslation(); setAcceptDrops(true); - ui.setupUi(this); + ui->setupUi(this); statusBar()->hide(); default_theme_paths = QIcon::themeSearchPaths(); @@ -262,10 +264,10 @@ GMainWindow::GMainWindow(Core::System& system_) show(); - system.SetContentProvider(std::make_unique()); - system.RegisterContentProvider(FileSys::ContentProviderUnionSlot::FrontendManual, - provider.get()); - system.GetFileSystemController().CreateFactories(*vfs); + system->SetContentProvider(std::make_unique()); + system->RegisterContentProvider(FileSys::ContentProviderUnionSlot::FrontendManual, + provider.get()); + system->GetFileSystemController().CreateFactories(*vfs); // Remove cached contents generated during the previous session RemoveCachedContents(); @@ -280,16 +282,16 @@ GMainWindow::GMainWindow(Core::System& system_) ShowTelemetryCallout(); // make sure menubar has the arrow cursor instead of inheriting from this - ui.menubar->setCursor(QCursor()); + ui->menubar->setCursor(QCursor()); statusBar()->setCursor(QCursor()); mouse_hide_timer.setInterval(default_mouse_timeout); connect(&mouse_hide_timer, &QTimer::timeout, this, &GMainWindow::HideMouseCursor); - connect(ui.menubar, &QMenuBar::hovered, this, &GMainWindow::ShowMouseCursor); + connect(ui->menubar, &QMenuBar::hovered, this, &GMainWindow::ShowMouseCursor); MigrateConfigFiles(); - ui.action_Fullscreen->setChecked(false); + ui->action_Fullscreen->setChecked(false); QStringList args = QApplication::arguments(); @@ -308,7 +310,7 @@ GMainWindow::GMainWindow(Core::System& system_) // Launch game in fullscreen mode if (args[i] == QStringLiteral("-f")) { - ui.action_Fullscreen->setChecked(true); + ui->action_Fullscreen->setChecked(true); continue; } @@ -411,12 +413,12 @@ void GMainWindow::RegisterMetaTypes() { qRegisterMetaType("Service::AM::Applets::WebExitReason"); // Register loader types - qRegisterMetaType("Core::System::ResultStatus"); + qRegisterMetaType("Core::SystemResultStatus"); } void GMainWindow::ControllerSelectorReconfigureControllers( const Core::Frontend::ControllerParameters& parameters) { - QtControllerSelectorDialog dialog(this, parameters, input_subsystem.get(), system); + QtControllerSelectorDialog dialog(this, parameters, input_subsystem.get(), *system); dialog.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint | Qt::WindowTitleHint | Qt::WindowSystemMenuHint); @@ -426,7 +428,7 @@ void GMainWindow::ControllerSelectorReconfigureControllers( emit ControllerSelectorReconfigureFinished(); // Don't forget to apply settings. - system.ApplySettings(); + system->ApplySettings(); config->Save(); UpdateStatusButtons(); @@ -460,7 +462,7 @@ void GMainWindow::SoftwareKeyboardInitialize( return; } - software_keyboard = new QtSoftwareKeyboardDialog(render_window, system, is_inline, + software_keyboard = new QtSoftwareKeyboardDialog(render_window, *system, is_inline, std::move(initialize_parameters)); if (is_inline) { @@ -572,11 +574,11 @@ void GMainWindow::WebBrowserOpenWebPage(const std::string& main_url, return; } - QtNXWebEngineView web_browser_view(this, system, input_subsystem.get()); + QtNXWebEngineView web_browser_view(this, *system, input_subsystem.get()); - ui.action_Pause->setEnabled(false); - ui.action_Restart->setEnabled(false); - ui.action_Stop->setEnabled(false); + ui->action_Pause->setEnabled(false); + ui->action_Restart->setEnabled(false); + ui->action_Stop->setEnabled(false); { QProgressDialog loading_progress(this); @@ -640,7 +642,7 @@ void GMainWindow::WebBrowserOpenWebPage(const std::string& main_url, web_browser_view.SetFinished(true); } }); - ui.menubar->addAction(exit_action); + ui->menubar->addAction(exit_action); while (!web_browser_view.IsFinished()) { QCoreApplication::processEvents(); @@ -682,11 +684,11 @@ void GMainWindow::WebBrowserOpenWebPage(const std::string& main_url, render_window->show(); } - ui.action_Pause->setEnabled(true); - ui.action_Restart->setEnabled(true); - ui.action_Stop->setEnabled(true); + ui->action_Pause->setEnabled(true); + ui->action_Restart->setEnabled(true); + ui->action_Stop->setEnabled(true); - ui.menubar->removeAction(exit_action); + ui->menubar->removeAction(exit_action); QCoreApplication::processEvents(); @@ -702,21 +704,21 @@ void GMainWindow::WebBrowserOpenWebPage(const std::string& main_url, void GMainWindow::InitializeWidgets() { #ifdef YUZU_ENABLE_COMPATIBILITY_REPORTING - ui.action_Report_Compatibility->setVisible(true); + ui->action_Report_Compatibility->setVisible(true); #endif - render_window = new GRenderWindow(this, emu_thread.get(), input_subsystem, system); + render_window = new GRenderWindow(this, emu_thread.get(), input_subsystem, *system); render_window->hide(); - game_list = new GameList(vfs, provider.get(), system, this); - ui.horizontalLayout->addWidget(game_list); + game_list = new GameList(vfs, provider.get(), *system, this); + ui->horizontalLayout->addWidget(game_list); game_list_placeholder = new GameListPlaceholder(this); - ui.horizontalLayout->addWidget(game_list_placeholder); + ui->horizontalLayout->addWidget(game_list_placeholder); game_list_placeholder->setVisible(false); loading_screen = new LoadingScreen(this); loading_screen->hide(); - ui.horizontalLayout->addWidget(loading_screen); + ui->horizontalLayout->addWidget(loading_screen); connect(loading_screen, &LoadingScreen::Hidden, [&] { loading_screen->Clear(); if (emulation_running) { @@ -773,14 +775,14 @@ void GMainWindow::InitializeWidgets() { tr("Handheld controller can't be used on docked mode. Pro " "controller will be selected.")); controller_type = Settings::ControllerType::ProController; - ConfigureDialog configure_dialog(this, hotkey_registry, input_subsystem.get(), system); + ConfigureDialog configure_dialog(this, hotkey_registry, input_subsystem.get(), *system); configure_dialog.ApplyConfiguration(); controller_dialog->refreshConfiguration(); } Settings::values.use_docked_mode.SetValue(!is_docked); dock_status_button->setChecked(!is_docked); - OnDockedModeChanged(is_docked, !is_docked, system); + OnDockedModeChanged(is_docked, !is_docked, *system); }); dock_status_button->setText(tr("DOCK")); dock_status_button->setCheckable(true); @@ -804,7 +806,7 @@ void GMainWindow::InitializeWidgets() { } } - system.ApplySettings(); + system->ApplySettings(); UpdateGPUAccuracyButton(); }); UpdateGPUAccuracyButton(); @@ -832,7 +834,7 @@ void GMainWindow::InitializeWidgets() { Settings::values.renderer_backend.SetValue(Settings::RendererBackend::OpenGL); } - system.ApplySettings(); + system->ApplySettings(); }); statusBar()->insertPermanentWidget(0, renderer_status_button); @@ -841,7 +843,7 @@ void GMainWindow::InitializeWidgets() { } void GMainWindow::InitializeDebugWidgets() { - QMenu* debug_menu = ui.menu_View_Debugging; + QMenu* debug_menu = ui->menu_View_Debugging; #if MICROPROFILE_ENABLED microProfileDialog = new MicroProfileDialog(this); @@ -849,7 +851,7 @@ void GMainWindow::InitializeDebugWidgets() { debug_menu->addAction(microProfileDialog->toggleViewAction()); #endif - waitTreeWidget = new WaitTreeWidget(system, this); + waitTreeWidget = new WaitTreeWidget(*system, this); addDockWidget(Qt::LeftDockWidgetArea, waitTreeWidget); waitTreeWidget->hide(); debug_menu->addAction(waitTreeWidget->toggleViewAction()); @@ -870,16 +872,16 @@ void GMainWindow::InitializeRecentFileMenuActions() { actions_recent_files[i]->setVisible(false); connect(actions_recent_files[i], &QAction::triggered, this, &GMainWindow::OnMenuRecentFile); - ui.menu_recent_files->addAction(actions_recent_files[i]); + ui->menu_recent_files->addAction(actions_recent_files[i]); } - ui.menu_recent_files->addSeparator(); + ui->menu_recent_files->addSeparator(); QAction* action_clear_recent_files = new QAction(this); action_clear_recent_files->setText(tr("&Clear Recent Files")); connect(action_clear_recent_files, &QAction::triggered, this, [this] { UISettings::values.recent_files.clear(); UpdateRecentFiles(); }); - ui.menu_recent_files->addAction(action_clear_recent_files); + ui->menu_recent_files->addAction(action_clear_recent_files); UpdateRecentFiles(); } @@ -898,43 +900,43 @@ void GMainWindow::InitializeHotkeys() { const QString fullscreen = QStringLiteral("Fullscreen"); const QString capture_screenshot = QStringLiteral("Capture Screenshot"); - ui.action_Load_File->setShortcut(hotkey_registry.GetKeySequence(main_window, load_file)); - ui.action_Load_File->setShortcutContext( + ui->action_Load_File->setShortcut(hotkey_registry.GetKeySequence(main_window, load_file)); + ui->action_Load_File->setShortcutContext( hotkey_registry.GetShortcutContext(main_window, load_file)); - ui.action_Load_Amiibo->setShortcut(hotkey_registry.GetKeySequence(main_window, load_amiibo)); - ui.action_Load_Amiibo->setShortcutContext( + ui->action_Load_Amiibo->setShortcut(hotkey_registry.GetKeySequence(main_window, load_amiibo)); + ui->action_Load_Amiibo->setShortcutContext( hotkey_registry.GetShortcutContext(main_window, load_amiibo)); - ui.action_Exit->setShortcut(hotkey_registry.GetKeySequence(main_window, exit_yuzu)); - ui.action_Exit->setShortcutContext(hotkey_registry.GetShortcutContext(main_window, exit_yuzu)); + ui->action_Exit->setShortcut(hotkey_registry.GetKeySequence(main_window, exit_yuzu)); + ui->action_Exit->setShortcutContext(hotkey_registry.GetShortcutContext(main_window, exit_yuzu)); - ui.action_Restart->setShortcut(hotkey_registry.GetKeySequence(main_window, restart_emulation)); - ui.action_Restart->setShortcutContext( + ui->action_Restart->setShortcut(hotkey_registry.GetKeySequence(main_window, restart_emulation)); + ui->action_Restart->setShortcutContext( hotkey_registry.GetShortcutContext(main_window, restart_emulation)); - ui.action_Stop->setShortcut(hotkey_registry.GetKeySequence(main_window, stop_emulation)); - ui.action_Stop->setShortcutContext( + ui->action_Stop->setShortcut(hotkey_registry.GetKeySequence(main_window, stop_emulation)); + ui->action_Stop->setShortcutContext( hotkey_registry.GetShortcutContext(main_window, stop_emulation)); - ui.action_Show_Filter_Bar->setShortcut( + ui->action_Show_Filter_Bar->setShortcut( hotkey_registry.GetKeySequence(main_window, toggle_filter_bar)); - ui.action_Show_Filter_Bar->setShortcutContext( + ui->action_Show_Filter_Bar->setShortcutContext( hotkey_registry.GetShortcutContext(main_window, toggle_filter_bar)); - ui.action_Show_Status_Bar->setShortcut( + ui->action_Show_Status_Bar->setShortcut( hotkey_registry.GetKeySequence(main_window, toggle_status_bar)); - ui.action_Show_Status_Bar->setShortcutContext( + ui->action_Show_Status_Bar->setShortcutContext( hotkey_registry.GetShortcutContext(main_window, toggle_status_bar)); - ui.action_Capture_Screenshot->setShortcut( + ui->action_Capture_Screenshot->setShortcut( hotkey_registry.GetKeySequence(main_window, capture_screenshot)); - ui.action_Capture_Screenshot->setShortcutContext( + ui->action_Capture_Screenshot->setShortcutContext( hotkey_registry.GetShortcutContext(main_window, capture_screenshot)); - ui.action_Fullscreen->setShortcut( + ui->action_Fullscreen->setShortcut( hotkey_registry.GetHotkey(main_window, fullscreen, this)->key()); - ui.action_Fullscreen->setShortcutContext( + ui->action_Fullscreen->setShortcutContext( hotkey_registry.GetShortcutContext(main_window, fullscreen)); connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Load File"), this), @@ -952,19 +954,19 @@ void GMainWindow::InitializeHotkeys() { }); connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Restart Emulation"), this), &QShortcut::activated, this, [this] { - if (!system.IsPoweredOn()) { + if (!system->IsPoweredOn()) { return; } BootGame(game_path); }); connect(hotkey_registry.GetHotkey(main_window, fullscreen, render_window), - &QShortcut::activated, ui.action_Fullscreen, &QAction::trigger); + &QShortcut::activated, ui->action_Fullscreen, &QAction::trigger); connect(hotkey_registry.GetHotkey(main_window, fullscreen, render_window), - &QShortcut::activatedAmbiguously, ui.action_Fullscreen, &QAction::trigger); + &QShortcut::activatedAmbiguously, ui->action_Fullscreen, &QAction::trigger); connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Exit Fullscreen"), this), &QShortcut::activated, this, [&] { if (emulation_running) { - ui.action_Fullscreen->setChecked(false); + ui->action_Fullscreen->setChecked(false); ToggleFullscreen(); } }); @@ -993,7 +995,7 @@ void GMainWindow::InitializeHotkeys() { }); connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Load Amiibo"), this), &QShortcut::activated, this, [&] { - if (ui.action_Load_Amiibo->isEnabled()) { + if (ui->action_Load_Amiibo->isEnabled()) { OnLoadAmiibo(); } }); @@ -1008,7 +1010,7 @@ void GMainWindow::InitializeHotkeys() { Settings::values.use_docked_mode.SetValue( !Settings::values.use_docked_mode.GetValue()); OnDockedModeChanged(!Settings::values.use_docked_mode.GetValue(), - Settings::values.use_docked_mode.GetValue(), system); + Settings::values.use_docked_mode.GetValue(), *system); dock_status_button->setChecked(Settings::values.use_docked_mode.GetValue()); }); connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Mute Audio"), this), @@ -1074,20 +1076,20 @@ void GMainWindow::RestoreUIState() { game_list->LoadInterfaceLayout(); - ui.action_Single_Window_Mode->setChecked(UISettings::values.single_window_mode.GetValue()); + ui->action_Single_Window_Mode->setChecked(UISettings::values.single_window_mode.GetValue()); ToggleWindowMode(); - ui.action_Fullscreen->setChecked(UISettings::values.fullscreen.GetValue()); + ui->action_Fullscreen->setChecked(UISettings::values.fullscreen.GetValue()); - ui.action_Display_Dock_Widget_Headers->setChecked( + ui->action_Display_Dock_Widget_Headers->setChecked( UISettings::values.display_titlebar.GetValue()); - OnDisplayTitleBars(ui.action_Display_Dock_Widget_Headers->isChecked()); + OnDisplayTitleBars(ui->action_Display_Dock_Widget_Headers->isChecked()); - ui.action_Show_Filter_Bar->setChecked(UISettings::values.show_filter_bar.GetValue()); - game_list->SetFilterVisible(ui.action_Show_Filter_Bar->isChecked()); + ui->action_Show_Filter_Bar->setChecked(UISettings::values.show_filter_bar.GetValue()); + game_list->SetFilterVisible(ui->action_Show_Filter_Bar->isChecked()); - ui.action_Show_Status_Bar->setChecked(UISettings::values.show_status_bar.GetValue()); - statusBar()->setVisible(ui.action_Show_Status_Bar->isChecked()); + ui->action_Show_Status_Bar->setChecked(UISettings::values.show_status_bar.GetValue()); + statusBar()->setVisible(ui->action_Show_Status_Bar->isChecked()); Debugger::ToggleConsole(); } @@ -1099,11 +1101,11 @@ void GMainWindow::OnAppFocusStateChanged(Qt::ApplicationState state) { state != Qt::ApplicationActive) { LOG_DEBUG(Frontend, "ApplicationState unusual flag: {} ", state); } - if (ui.action_Pause->isEnabled() && + if (ui->action_Pause->isEnabled() && (state & (Qt::ApplicationHidden | Qt::ApplicationInactive))) { auto_paused = true; OnPauseGame(); - } else if (ui.action_Start->isEnabled() && auto_paused && state == Qt::ApplicationActive) { + } else if (ui->action_Start->isEnabled() && auto_paused && state == Qt::ApplicationActive) { auto_paused = false; OnStartGame(); } @@ -1148,59 +1150,60 @@ void GMainWindow::ConnectWidgetEvents() { void GMainWindow::ConnectMenuEvents() { // File - connect(ui.action_Load_File, &QAction::triggered, this, &GMainWindow::OnMenuLoadFile); - connect(ui.action_Load_Folder, &QAction::triggered, this, &GMainWindow::OnMenuLoadFolder); - connect(ui.action_Install_File_NAND, &QAction::triggered, this, + connect(ui->action_Load_File, &QAction::triggered, this, &GMainWindow::OnMenuLoadFile); + connect(ui->action_Load_Folder, &QAction::triggered, this, &GMainWindow::OnMenuLoadFolder); + connect(ui->action_Install_File_NAND, &QAction::triggered, this, &GMainWindow::OnMenuInstallToNAND); - connect(ui.action_Exit, &QAction::triggered, this, &QMainWindow::close); - connect(ui.action_Load_Amiibo, &QAction::triggered, this, &GMainWindow::OnLoadAmiibo); + connect(ui->action_Exit, &QAction::triggered, this, &QMainWindow::close); + connect(ui->action_Load_Amiibo, &QAction::triggered, this, &GMainWindow::OnLoadAmiibo); // Emulation - connect(ui.action_Start, &QAction::triggered, this, &GMainWindow::OnStartGame); - connect(ui.action_Pause, &QAction::triggered, this, &GMainWindow::OnPauseGame); - connect(ui.action_Stop, &QAction::triggered, this, &GMainWindow::OnStopGame); - connect(ui.action_Report_Compatibility, &QAction::triggered, this, + connect(ui->action_Start, &QAction::triggered, this, &GMainWindow::OnStartGame); + connect(ui->action_Pause, &QAction::triggered, this, &GMainWindow::OnPauseGame); + connect(ui->action_Stop, &QAction::triggered, this, &GMainWindow::OnStopGame); + connect(ui->action_Report_Compatibility, &QAction::triggered, this, &GMainWindow::OnMenuReportCompatibility); - connect(ui.action_Open_Mods_Page, &QAction::triggered, this, &GMainWindow::OnOpenModsPage); - connect(ui.action_Open_Quickstart_Guide, &QAction::triggered, this, + connect(ui->action_Open_Mods_Page, &QAction::triggered, this, &GMainWindow::OnOpenModsPage); + connect(ui->action_Open_Quickstart_Guide, &QAction::triggered, this, &GMainWindow::OnOpenQuickstartGuide); - connect(ui.action_Open_FAQ, &QAction::triggered, this, &GMainWindow::OnOpenFAQ); - connect(ui.action_Restart, &QAction::triggered, this, [this] { BootGame(QString(game_path)); }); - connect(ui.action_Configure, &QAction::triggered, this, &GMainWindow::OnConfigure); - connect(ui.action_Configure_Tas, &QAction::triggered, this, &GMainWindow::OnConfigureTas); - connect(ui.action_Configure_Current_Game, &QAction::triggered, this, + connect(ui->action_Open_FAQ, &QAction::triggered, this, &GMainWindow::OnOpenFAQ); + connect(ui->action_Restart, &QAction::triggered, this, + [this] { BootGame(QString(game_path)); }); + connect(ui->action_Configure, &QAction::triggered, this, &GMainWindow::OnConfigure); + connect(ui->action_Configure_Tas, &QAction::triggered, this, &GMainWindow::OnConfigureTas); + connect(ui->action_Configure_Current_Game, &QAction::triggered, this, &GMainWindow::OnConfigurePerGame); // View - connect(ui.action_Single_Window_Mode, &QAction::triggered, this, + connect(ui->action_Single_Window_Mode, &QAction::triggered, this, &GMainWindow::ToggleWindowMode); - connect(ui.action_Display_Dock_Widget_Headers, &QAction::triggered, this, + connect(ui->action_Display_Dock_Widget_Headers, &QAction::triggered, this, &GMainWindow::OnDisplayTitleBars); - connect(ui.action_Show_Filter_Bar, &QAction::triggered, this, &GMainWindow::OnToggleFilterBar); - connect(ui.action_Show_Status_Bar, &QAction::triggered, statusBar(), &QStatusBar::setVisible); + connect(ui->action_Show_Filter_Bar, &QAction::triggered, this, &GMainWindow::OnToggleFilterBar); + connect(ui->action_Show_Status_Bar, &QAction::triggered, statusBar(), &QStatusBar::setVisible); - connect(ui.action_Reset_Window_Size_720, &QAction::triggered, this, + connect(ui->action_Reset_Window_Size_720, &QAction::triggered, this, &GMainWindow::ResetWindowSize720); - connect(ui.action_Reset_Window_Size_900, &QAction::triggered, this, + connect(ui->action_Reset_Window_Size_900, &QAction::triggered, this, &GMainWindow::ResetWindowSize900); - connect(ui.action_Reset_Window_Size_1080, &QAction::triggered, this, + connect(ui->action_Reset_Window_Size_1080, &QAction::triggered, this, &GMainWindow::ResetWindowSize1080); - ui.menu_Reset_Window_Size->addAction(ui.action_Reset_Window_Size_720); - ui.menu_Reset_Window_Size->addAction(ui.action_Reset_Window_Size_900); - ui.menu_Reset_Window_Size->addAction(ui.action_Reset_Window_Size_1080); + ui->menu_Reset_Window_Size->addAction(ui->action_Reset_Window_Size_720); + ui->menu_Reset_Window_Size->addAction(ui->action_Reset_Window_Size_900); + ui->menu_Reset_Window_Size->addAction(ui->action_Reset_Window_Size_1080); // Fullscreen - connect(ui.action_Fullscreen, &QAction::triggered, this, &GMainWindow::ToggleFullscreen); + connect(ui->action_Fullscreen, &QAction::triggered, this, &GMainWindow::ToggleFullscreen); // Movie - connect(ui.action_Capture_Screenshot, &QAction::triggered, this, + connect(ui->action_Capture_Screenshot, &QAction::triggered, this, &GMainWindow::OnCaptureScreenshot); // Help - connect(ui.action_Open_yuzu_Folder, &QAction::triggered, this, &GMainWindow::OnOpenYuzuFolder); - connect(ui.action_Rederive, &QAction::triggered, this, + connect(ui->action_Open_yuzu_Folder, &QAction::triggered, this, &GMainWindow::OnOpenYuzuFolder); + connect(ui->action_Rederive, &QAction::triggered, this, std::bind(&GMainWindow::OnReinitializeKeys, this, ReinitializeKeyBehavior::Warning)); - connect(ui.action_About, &QAction::triggered, this, &GMainWindow::OnAbout); + connect(ui->action_About, &QAction::triggered, this, &GMainWindow::OnAbout); } void GMainWindow::OnDisplayTitleBars(bool show) { @@ -1304,9 +1307,9 @@ bool GMainWindow::LoadROM(const QString& filename, u64 program_id, std::size_t p return false; } - system.SetFilesystem(vfs); + system->SetFilesystem(vfs); - system.SetAppletFrontendSet({ + system->SetAppletFrontendSet({ std::make_unique(*this), // Controller Selector std::make_unique(*this), // Error Display nullptr, // Parental Controls @@ -1316,14 +1319,14 @@ bool GMainWindow::LoadROM(const QString& filename, u64 program_id, std::size_t p std::make_unique(*this), // Web Browser }); - const Core::System::ResultStatus result{ - system.Load(*render_window, filename.toStdString(), program_id, program_index)}; + const Core::SystemResultStatus result{ + system->Load(*render_window, filename.toStdString(), program_id, program_index)}; const auto drd_callout = (UISettings::values.callout_flags.GetValue() & static_cast(CalloutFlag::DRDDeprecation)) == 0; - if (result == Core::System::ResultStatus::Success && - system.GetAppLoader().GetFileType() == Loader::FileType::DeconstructedRomDirectory && + if (result == Core::SystemResultStatus::Success && + system->GetAppLoader().GetFileType() == Loader::FileType::DeconstructedRomDirectory && drd_callout) { UISettings::values.callout_flags = UISettings::values.callout_flags.GetValue() | static_cast(CalloutFlag::DRDDeprecation); @@ -1337,14 +1340,14 @@ bool GMainWindow::LoadROM(const QString& filename, u64 program_id, std::size_t p "wiki. This message will not be shown again.")); } - if (result != Core::System::ResultStatus::Success) { + if (result != Core::SystemResultStatus::Success) { switch (result) { - case Core::System::ResultStatus::ErrorGetLoader: + case Core::SystemResultStatus::ErrorGetLoader: LOG_CRITICAL(Frontend, "Failed to obtain loader for {}!", filename.toStdString()); QMessageBox::critical(this, tr("Error while loading ROM!"), tr("The ROM format is not supported.")); break; - case Core::System::ResultStatus::ErrorVideoCore: + case Core::SystemResultStatus::ErrorVideoCore: QMessageBox::critical( this, tr("An error occurred initializing the video core."), tr("yuzu has encountered an error while running the video core, please see the " @@ -1358,8 +1361,8 @@ bool GMainWindow::LoadROM(const QString& filename, u64 program_id, std::size_t p break; default: - if (result > Core::System::ResultStatus::ErrorLoader) { - const u16 loader_id = static_cast(Core::System::ResultStatus::ErrorLoader); + if (result > Core::SystemResultStatus::ErrorLoader) { + const u16 loader_id = static_cast(Core::SystemResultStatus::ErrorLoader); const u16 error_id = static_cast(result) - loader_id; const std::string error_code = fmt::format("({:04X}-{:04X})", loader_id, error_id); LOG_CRITICAL(Frontend, "Failed to load ROM! {}", error_code); @@ -1387,7 +1390,7 @@ bool GMainWindow::LoadROM(const QString& filename, u64 program_id, std::size_t p } game_path = filename; - system.TelemetrySession().AddField(Common::Telemetry::FieldType::App, "Frontend", "Qt"); + system->TelemetrySession().AddField(Common::Telemetry::FieldType::App, "Frontend", "Qt"); return true; } @@ -1414,7 +1417,7 @@ void GMainWindow::BootGame(const QString& filename, u64 program_id, std::size_t last_filename_booted = filename; const auto v_file = Core::GetGameFileFromPath(vfs, filename.toUtf8().constData()); - const auto loader = Loader::GetLoader(system, v_file, program_id, program_index); + const auto loader = Loader::GetLoader(*system, v_file, program_id, program_index); if (loader != nullptr && loader->ReadProgramId(title_id) == Loader::ResultStatus::Success && type == StartGameType::Normal) { @@ -1423,7 +1426,7 @@ void GMainWindow::BootGame(const QString& filename, u64 program_id, std::size_t const auto config_file_name = title_id == 0 ? Common::FS::PathToUTF8String(file_path.filename()) : fmt::format("{:016X}", title_id); - Config per_game_config(system, config_file_name, Config::ConfigType::PerGameConfig); + Config per_game_config(*system, config_file_name, Config::ConfigType::PerGameConfig); } ConfigureVibration::SetAllVibrationDevices(); @@ -1446,16 +1449,16 @@ void GMainWindow::BootGame(const QString& filename, u64 program_id, std::size_t return; // Create and start the emulation thread - emu_thread = std::make_unique(system); + emu_thread = std::make_unique(*system); emit EmulationStarting(emu_thread.get()); emu_thread->start(); // Register an ExecuteProgram callback such that Core can execute a sub-program - system.RegisterExecuteProgramCallback( + system->RegisterExecuteProgramCallback( [this](std::size_t program_index) { render_window->ExecuteProgram(program_index); }); // Register an Exit callback such that Core can exit the currently running application. - system.RegisterExitCallback([this]() { render_window->Exit(); }); + system->RegisterExitCallback([this]() { render_window->Exit(); }); connect(render_window, &GRenderWindow::Closed, this, &GMainWindow::OnStopGame); connect(render_window, &GRenderWindow::MouseActivity, this, &GMainWindow::OnMouseActivity); @@ -1471,7 +1474,7 @@ void GMainWindow::BootGame(const QString& filename, u64 program_id, std::size_t // Update the GUI UpdateStatusButtons(); - if (ui.action_Single_Window_Mode->isChecked()) { + if (ui->action_Single_Window_Mode->isChecked()) { game_list->hide(); game_list_placeholder->hide(); } @@ -1489,11 +1492,11 @@ void GMainWindow::BootGame(const QString& filename, u64 program_id, std::size_t std::string title_name; std::string title_version; - const auto res = system.GetGameName(title_name); + const auto res = system->GetGameName(title_name); const auto metadata = [this, title_id] { - const FileSys::PatchManager pm(title_id, system.GetFileSystemController(), - system.GetContentProvider()); + const FileSys::PatchManager pm(title_id, system->GetFileSystemController(), + system->GetContentProvider()); return pm.GetControlMetadata(); }(); if (metadata.first != nullptr) { @@ -1504,20 +1507,20 @@ void GMainWindow::BootGame(const QString& filename, u64 program_id, std::size_t title_name = Common::FS::PathToUTF8String( std::filesystem::path{filename.toStdU16String()}.filename()); } - const bool is_64bit = system.Kernel().CurrentProcess()->Is64BitProcess(); + const bool is_64bit = system->Kernel().CurrentProcess()->Is64BitProcess(); const auto instruction_set_suffix = is_64bit ? tr("(64-bit)") : tr("(32-bit)"); title_name = tr("%1 %2", "%1 is the title name. %2 indicates if the title is 64-bit or 32-bit") .arg(QString::fromStdString(title_name), instruction_set_suffix) .toStdString(); LOG_INFO(Frontend, "Booting game: {:016X} | {} | {}", title_id, title_name, title_version); - const auto gpu_vendor = system.GPU().Renderer().GetDeviceVendor(); + const auto gpu_vendor = system->GPU().Renderer().GetDeviceVendor(); UpdateWindowTitle(title_name, title_version, gpu_vendor); - loading_screen->Prepare(system.GetAppLoader()); + loading_screen->Prepare(system->GetAppLoader()); loading_screen->show(); emulation_running = true; - if (ui.action_Fullscreen->isChecked()) { + if (ui->action_Fullscreen->isChecked()) { ShowFullscreen(); } OnStartGame(); @@ -1528,7 +1531,7 @@ void GMainWindow::ShutdownGame() { return; } - if (ui.action_Fullscreen->isChecked()) { + if (ui->action_Fullscreen->isChecked()) { HideFullscreen(); } @@ -1549,15 +1552,15 @@ void GMainWindow::ShutdownGame() { disconnect(render_window, &GRenderWindow::Closed, this, &GMainWindow::OnStopGame); // Update the GUI - ui.action_Start->setEnabled(false); - ui.action_Start->setText(tr("Start")); - ui.action_Pause->setEnabled(false); - ui.action_Stop->setEnabled(false); - ui.action_Restart->setEnabled(false); - ui.action_Configure_Current_Game->setEnabled(false); - ui.action_Report_Compatibility->setEnabled(false); - ui.action_Load_Amiibo->setEnabled(false); - ui.action_Capture_Screenshot->setEnabled(false); + ui->action_Start->setEnabled(false); + ui->action_Start->setText(tr("Start")); + ui->action_Pause->setEnabled(false); + ui->action_Stop->setEnabled(false); + ui->action_Restart->setEnabled(false); + ui->action_Configure_Current_Game->setEnabled(false); + ui->action_Report_Compatibility->setEnabled(false); + ui->action_Load_Amiibo->setEnabled(false); + ui->action_Capture_Screenshot->setEnabled(false); render_window->hide(); loading_screen->hide(); loading_screen->Clear(); @@ -1619,7 +1622,7 @@ void GMainWindow::UpdateRecentFiles() { } // Enable the recent files menu if the list isn't empty - ui.menu_recent_files->setEnabled(num_recent_files != 0); + ui->menu_recent_files->setEnabled(num_recent_files != 0); } void GMainWindow::OnGameListLoadFile(QString game_path, u64 program_id) { @@ -1632,15 +1635,15 @@ void GMainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target QString open_target; const auto [user_save_size, device_save_size] = [this, &game_path, &program_id] { - const FileSys::PatchManager pm{program_id, system.GetFileSystemController(), - system.GetContentProvider()}; + const FileSys::PatchManager pm{program_id, system->GetFileSystemController(), + system->GetContentProvider()}; const auto control = pm.GetControlMetadata().first; if (control != nullptr) { return std::make_pair(control->GetDefaultNormalSaveSize(), control->GetDeviceSaveDataSize()); } else { const auto file = Core::GetGameFileFromPath(vfs, game_path); - const auto loader = Loader::GetLoader(system, file); + const auto loader = Loader::GetLoader(*system, file); FileSys::NACP nacp{}; loader->ReadControlData(nacp); @@ -1683,14 +1686,14 @@ void GMainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target ASSERT(user_id); const auto user_save_data_path = FileSys::SaveDataFactory::GetFullPath( - system, FileSys::SaveDataSpaceId::NandUser, FileSys::SaveDataType::SaveData, + *system, FileSys::SaveDataSpaceId::NandUser, FileSys::SaveDataType::SaveData, program_id, user_id->uuid, 0); path = Common::FS::ConcatPathSafe(nand_dir, user_save_data_path); } else { // Device save data const auto device_save_data_path = FileSys::SaveDataFactory::GetFullPath( - system, FileSys::SaveDataSpaceId::NandUser, FileSys::SaveDataType::SaveData, + *system, FileSys::SaveDataSpaceId::NandUser, FileSys::SaveDataType::SaveData, program_id, {}, 0); path = Common::FS::ConcatPathSafe(nand_dir, device_save_data_path); @@ -1817,7 +1820,7 @@ void GMainWindow::OnGameListRemoveInstalledEntry(u64 program_id, InstalledEntryT } void GMainWindow::RemoveBaseContent(u64 program_id, const QString& entry_type) { - const auto& fs_controller = system.GetFileSystemController(); + const auto& fs_controller = system->GetFileSystemController(); const auto res = fs_controller.GetUserNANDContents()->RemoveExistingEntry(program_id) || fs_controller.GetSDMCContents()->RemoveExistingEntry(program_id); @@ -1833,7 +1836,7 @@ void GMainWindow::RemoveBaseContent(u64 program_id, const QString& entry_type) { void GMainWindow::RemoveUpdateContent(u64 program_id, const QString& entry_type) { const auto update_id = program_id | 0x800; - const auto& fs_controller = system.GetFileSystemController(); + const auto& fs_controller = system->GetFileSystemController(); const auto res = fs_controller.GetUserNANDContents()->RemoveExistingEntry(update_id) || fs_controller.GetSDMCContents()->RemoveExistingEntry(update_id); @@ -1848,8 +1851,8 @@ void GMainWindow::RemoveUpdateContent(u64 program_id, const QString& entry_type) void GMainWindow::RemoveAddOnContent(u64 program_id, const QString& entry_type) { u32 count{}; - const auto& fs_controller = system.GetFileSystemController(); - const auto dlc_entries = system.GetContentProvider().ListEntriesFilter( + const auto& fs_controller = system->GetFileSystemController(); + const auto dlc_entries = system->GetContentProvider().ListEntriesFilter( FileSys::TitleType::AOC, FileSys::ContentRecordType::Data); for (const auto& entry : dlc_entries) { @@ -1987,7 +1990,7 @@ void GMainWindow::OnGameListDumpRomFS(u64 program_id, const std::string& game_pa "cancelled the operation.")); }; - const auto loader = Loader::GetLoader(system, vfs->OpenFile(game_path, FileSys::Mode::Read)); + const auto loader = Loader::GetLoader(*system, vfs->OpenFile(game_path, FileSys::Mode::Read)); if (loader == nullptr) { failed(); return; @@ -1999,7 +2002,7 @@ void GMainWindow::OnGameListDumpRomFS(u64 program_id, const std::string& game_pa return; } - const auto& installed = system.GetContentProvider(); + const auto& installed = system->GetContentProvider(); const auto romfs_title_id = SelectRomFSDumpTarget(installed, program_id); if (!romfs_title_id) { @@ -2019,7 +2022,7 @@ void GMainWindow::OnGameListDumpRomFS(u64 program_id, const std::string& game_pa if (*romfs_title_id == program_id) { const u64 ivfc_offset = loader->ReadRomFSIVFCOffset(); - const FileSys::PatchManager pm{program_id, system.GetFileSystemController(), installed}; + const FileSys::PatchManager pm{program_id, system->GetFileSystemController(), installed}; romfs = pm.PatchRomFS(file, ivfc_offset, FileSys::ContentRecordType::Program, nullptr, false); } else { @@ -2145,7 +2148,7 @@ void GMainWindow::OnGameListAddDirectory() { } void GMainWindow::OnGameListShowList(bool show) { - if (emulation_running && ui.action_Single_Window_Mode->isChecked()) + if (emulation_running && ui->action_Single_Window_Mode->isChecked()) return; game_list->setVisible(show); game_list_placeholder->setVisible(!show); @@ -2154,7 +2157,7 @@ void GMainWindow::OnGameListShowList(bool show) { void GMainWindow::OnGameListOpenPerGameProperties(const std::string& file) { u64 title_id{}; const auto v_file = Core::GetGameFileFromPath(vfs, file); - const auto loader = Loader::GetLoader(system, v_file); + const auto loader = Loader::GetLoader(*system, v_file); if (loader == nullptr || loader->ReadProgramId(title_id) != Loader::ResultStatus::Success) { QMessageBox::information(this, tr("Properties"), @@ -2247,7 +2250,7 @@ void GMainWindow::OnMenuInstallToNAND() { QStringList failed_files{}; // Files that failed to install due to errors bool detected_base_install{}; // Whether a base game was attempted to be installed - ui.action_Install_File_NAND->setEnabled(false); + ui->action_Install_File_NAND->setEnabled(false); install_progress = new QProgressDialog(QString{}, tr("Cancel"), 0, total_size, this); install_progress->setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint & @@ -2323,7 +2326,7 @@ void GMainWindow::OnMenuInstallToNAND() { Common::FS::RemoveDirRecursively(Common::FS::GetYuzuPath(Common::FS::YuzuPath::CacheDir) / "game_list"); game_list->PopulateAsync(UISettings::values.game_dirs); - ui.action_Install_File_NAND->setEnabled(true); + ui->action_Install_File_NAND->setEnabled(true); } InstallResult GMainWindow::InstallNSPXCI(const QString& filename) { @@ -2368,7 +2371,7 @@ InstallResult GMainWindow::InstallNSPXCI(const QString& filename) { if (nsp->GetStatus() != Loader::ResultStatus::Success) { return InstallResult::Failure; } - const auto res = system.GetFileSystemController().GetUserNANDContents()->InstallEntry( + const auto res = system->GetFileSystemController().GetUserNANDContents()->InstallEntry( *nsp, true, qt_raw_copy); switch (res) { case FileSys::InstallResult::Success: @@ -2448,7 +2451,7 @@ InstallResult GMainWindow::InstallNCA(const QString& filename) { } const bool is_application = index >= static_cast(FileSys::TitleType::Application); - const auto& fs_controller = system.GetFileSystemController(); + const auto& fs_controller = system->GetFileSystemController(); auto* registered_cache = is_application ? fs_controller.GetUserNANDContents() : fs_controller.GetSystemNANDContents(); @@ -2487,39 +2490,39 @@ void GMainWindow::OnStartGame() { connect(emu_thread.get(), &EmuThread::ErrorThrown, this, &GMainWindow::OnCoreError); - ui.action_Start->setEnabled(false); - ui.action_Start->setText(tr("&Continue")); + ui->action_Start->setEnabled(false); + ui->action_Start->setText(tr("&Continue")); - ui.action_Pause->setEnabled(true); - ui.action_Stop->setEnabled(true); - ui.action_Restart->setEnabled(true); - ui.action_Configure_Current_Game->setEnabled(true); - ui.action_Report_Compatibility->setEnabled(true); + ui->action_Pause->setEnabled(true); + ui->action_Stop->setEnabled(true); + ui->action_Restart->setEnabled(true); + ui->action_Configure_Current_Game->setEnabled(true); + ui->action_Report_Compatibility->setEnabled(true); discord_rpc->Update(); - ui.action_Load_Amiibo->setEnabled(true); - ui.action_Capture_Screenshot->setEnabled(true); + ui->action_Load_Amiibo->setEnabled(true); + ui->action_Capture_Screenshot->setEnabled(true); } void GMainWindow::OnPauseGame() { emu_thread->SetRunning(false); - ui.action_Start->setEnabled(true); - ui.action_Pause->setEnabled(false); - ui.action_Stop->setEnabled(true); - ui.action_Capture_Screenshot->setEnabled(false); + ui->action_Start->setEnabled(true); + ui->action_Pause->setEnabled(false); + ui->action_Stop->setEnabled(true); + ui->action_Capture_Screenshot->setEnabled(false); AllowOSSleep(); } void GMainWindow::OnStopGame() { - if (system.GetExitLock() && !ConfirmForceLockedExit()) { + if (system->GetExitLock() && !ConfirmForceLockedExit()) { return; } ShutdownGame(); - Settings::RestoreGlobalState(system.IsPoweredOn()); + Settings::RestoreGlobalState(system->IsPoweredOn()); UpdateStatusButtons(); } @@ -2537,7 +2540,7 @@ void GMainWindow::OnExit() { } void GMainWindow::ErrorDisplayDisplayError(QString error_code, QString error_text) { - OverlayDialog dialog(render_window, system, error_code, error_text, QString{}, tr("OK"), + OverlayDialog dialog(render_window, *system, error_code, error_text, QString{}, tr("OK"), Qt::AlignLeft | Qt::AlignVCenter); dialog.exec(); @@ -2547,7 +2550,7 @@ void GMainWindow::ErrorDisplayDisplayError(QString error_code, QString error_tex void GMainWindow::OnMenuReportCompatibility() { if (!Settings::values.yuzu_token.GetValue().empty() && !Settings::values.yuzu_username.GetValue().empty()) { - CompatDB compatdb{system.TelemetrySession(), this}; + CompatDB compatdb{system->TelemetrySession(), this}; compatdb.exec(); } else { QMessageBox::critical( @@ -2583,7 +2586,7 @@ void GMainWindow::ToggleFullscreen() { if (!emulation_running) { return; } - if (ui.action_Fullscreen->isChecked()) { + if (ui->action_Fullscreen->isChecked()) { ShowFullscreen(); } else { HideFullscreen(); @@ -2591,10 +2594,10 @@ void GMainWindow::ToggleFullscreen() { } void GMainWindow::ShowFullscreen() { - if (ui.action_Single_Window_Mode->isChecked()) { + if (ui->action_Single_Window_Mode->isChecked()) { UISettings::values.geometry = saveGeometry(); - ui.menubar->hide(); + ui->menubar->hide(); statusBar()->hide(); if (Settings::values.fullscreen_mode.GetValue() == Settings::FullscreenMode::Exclusive) { @@ -2628,7 +2631,7 @@ void GMainWindow::ShowFullscreen() { } void GMainWindow::HideFullscreen() { - if (ui.action_Single_Window_Mode->isChecked()) { + if (ui->action_Single_Window_Mode->isChecked()) { if (Settings::values.fullscreen_mode.GetValue() == Settings::FullscreenMode::Exclusive) { showNormal(); restoreGeometry(UISettings::values.geometry); @@ -2640,8 +2643,8 @@ void GMainWindow::HideFullscreen() { show(); } - statusBar()->setVisible(ui.action_Show_Status_Bar->isChecked()); - ui.menubar->show(); + statusBar()->setVisible(ui->action_Show_Status_Bar->isChecked()); + ui->menubar->show(); } else { if (Settings::values.fullscreen_mode.GetValue() == Settings::FullscreenMode::Exclusive) { render_window->showNormal(); @@ -2657,10 +2660,10 @@ void GMainWindow::HideFullscreen() { } void GMainWindow::ToggleWindowMode() { - if (ui.action_Single_Window_Mode->isChecked()) { + if (ui->action_Single_Window_Mode->isChecked()) { // Render in the main window... render_window->BackupGeometry(); - ui.horizontalLayout->addWidget(render_window); + ui->horizontalLayout->addWidget(render_window); render_window->setFocusPolicy(Qt::StrongFocus); if (emulation_running) { render_window->setVisible(true); @@ -2670,7 +2673,7 @@ void GMainWindow::ToggleWindowMode() { } else { // Render in a separate window... - ui.horizontalLayout->removeWidget(render_window); + ui->horizontalLayout->removeWidget(render_window); render_window->setParent(nullptr); render_window->setFocusPolicy(Qt::NoFocus); if (emulation_running) { @@ -2685,10 +2688,10 @@ void GMainWindow::ResetWindowSize(u32 width, u32 height) { const auto aspect_ratio = Layout::EmulationAspectRatio( static_cast(Settings::values.aspect_ratio.GetValue()), static_cast(height) / width); - if (!ui.action_Single_Window_Mode->isChecked()) { + if (!ui->action_Single_Window_Mode->isChecked()) { render_window->resize(height / aspect_ratio, height); } else { - const bool show_status_bar = ui.action_Show_Status_Bar->isChecked(); + const bool show_status_bar = ui->action_Show_Status_Bar->isChecked(); const auto status_bar_height = show_status_bar ? statusBar()->height() : 0; resize(height / aspect_ratio, height + menuBar()->height() + status_bar_height); } @@ -2711,7 +2714,7 @@ void GMainWindow::OnConfigure() { const bool old_discord_presence = UISettings::values.enable_discord_presence.GetValue(); Settings::SetConfiguringGlobal(true); - ConfigureDialog configure_dialog(this, hotkey_registry, input_subsystem.get(), system); + ConfigureDialog configure_dialog(this, hotkey_registry, input_subsystem.get(), *system); connect(&configure_dialog, &ConfigureDialog::LanguageChanged, this, &GMainWindow::OnLanguageChanged); @@ -2747,7 +2750,7 @@ void GMainWindow::OnConfigure() { Settings::values.disabled_addons.clear(); - config = std::make_unique(system); + config = std::make_unique(*system); UISettings::values.reset_to_defaults = false; UISettings::values.game_dirs = std::move(old_game_dirs); @@ -2796,12 +2799,11 @@ void GMainWindow::OnConfigure() { } void GMainWindow::OnConfigureTas() { - const auto& system = Core::System::GetInstance(); ConfigureTasDialog dialog(this); const auto result = dialog.exec(); if (result != QDialog::Accepted && !UISettings::values.configuration_applied) { - Settings::RestoreGlobalState(system.IsPoweredOn()); + Settings::RestoreGlobalState(system->IsPoweredOn()); return; } else if (result == QDialog::Accepted) { dialog.ApplyConfiguration(); @@ -2809,7 +2811,7 @@ void GMainWindow::OnConfigureTas() { } void GMainWindow::OnConfigurePerGame() { - const u64 title_id = system.CurrentProcess()->GetTitleID(); + const u64 title_id = system->CurrentProcess()->GetTitleID(); OpenPerGameConfiguration(title_id, game_path.toStdString()); } @@ -2817,12 +2819,12 @@ void GMainWindow::OpenPerGameConfiguration(u64 title_id, const std::string& file const auto v_file = Core::GetGameFileFromPath(vfs, file_name); Settings::SetConfiguringGlobal(false); - ConfigurePerGame dialog(this, title_id, file_name, system); + ConfigurePerGame dialog(this, title_id, file_name, *system); dialog.LoadFromFile(v_file); const auto result = dialog.exec(); if (result != QDialog::Accepted && !UISettings::values.configuration_applied) { - Settings::RestoreGlobalState(system.IsPoweredOn()); + Settings::RestoreGlobalState(system->IsPoweredOn()); return; } else if (result == QDialog::Accepted) { dialog.ApplyConfiguration(); @@ -2834,7 +2836,7 @@ void GMainWindow::OpenPerGameConfiguration(u64 title_id, const std::string& file } // Do not cause the global config to write local settings into the config file - const bool is_powered_on = system.IsPoweredOn(); + const bool is_powered_on = system->IsPoweredOn(); Settings::RestoreGlobalState(is_powered_on); UISettings::values.configuration_applied = false; @@ -2857,7 +2859,7 @@ void GMainWindow::OnLoadAmiibo() { } void GMainWindow::LoadAmiibo(const QString& filename) { - Service::SM::ServiceManager& sm = system.ServiceManager(); + Service::SM::ServiceManager& sm = system->ServiceManager(); auto nfc = sm.GetService("nfp:user"); if (nfc == nullptr) { return; @@ -2899,8 +2901,8 @@ void GMainWindow::OnAbout() { } void GMainWindow::OnToggleFilterBar() { - game_list->SetFilterVisible(ui.action_Show_Filter_Bar->isChecked()); - if (ui.action_Show_Filter_Bar->isChecked()) { + game_list->SetFilterVisible(ui->action_Show_Filter_Bar->isChecked()); + if (ui->action_Show_Filter_Bar->isChecked()) { game_list->SetFilterFocus(); } else { game_list->ClearFilter(); @@ -2908,7 +2910,7 @@ void GMainWindow::OnToggleFilterBar() { } void GMainWindow::OnCaptureScreenshot() { - const u64 title_id = system.CurrentProcess()->GetTitleID(); + const u64 title_id = system->CurrentProcess()->GetTitleID(); const auto screenshot_path = QString::fromStdString(Common::FS::GetYuzuPathString(Common::FS::YuzuPath::ScreenshotsDir)); const auto date = @@ -3014,8 +3016,8 @@ void GMainWindow::UpdateStatusBar() { tas_label->clear(); } - auto results = system.GetAndResetPerfStats(); - auto& shader_notify = system.GPU().ShaderNotify(); + auto results = system->GetAndResetPerfStats(); + auto& shader_notify = system->GPU().ShaderNotify(); const int shaders_building = shader_notify.ShadersBuilding(); if (shaders_building > 0) { @@ -3077,7 +3079,7 @@ void GMainWindow::UpdateStatusButtons() { } void GMainWindow::UpdateUISettings() { - if (!ui.action_Fullscreen->isChecked()) { + if (!ui->action_Fullscreen->isChecked()) { UISettings::values.geometry = saveGeometry(); UISettings::values.renderwindow_geometry = render_window->saveGeometry(); } @@ -3086,11 +3088,11 @@ void GMainWindow::UpdateUISettings() { UISettings::values.microprofile_geometry = microProfileDialog->saveGeometry(); UISettings::values.microprofile_visible = microProfileDialog->isVisible(); #endif - UISettings::values.single_window_mode = ui.action_Single_Window_Mode->isChecked(); - UISettings::values.fullscreen = ui.action_Fullscreen->isChecked(); - UISettings::values.display_titlebar = ui.action_Display_Dock_Widget_Headers->isChecked(); - UISettings::values.show_filter_bar = ui.action_Show_Filter_Bar->isChecked(); - UISettings::values.show_status_bar = ui.action_Show_Status_Bar->isChecked(); + UISettings::values.single_window_mode = ui->action_Single_Window_Mode->isChecked(); + UISettings::values.fullscreen = ui->action_Fullscreen->isChecked(); + UISettings::values.display_titlebar = ui->action_Display_Dock_Widget_Headers->isChecked(); + UISettings::values.show_filter_bar = ui->action_Show_Filter_Bar->isChecked(); + UISettings::values.show_status_bar = ui->action_Show_Status_Bar->isChecked(); UISettings::values.first_start = false; } @@ -3116,7 +3118,7 @@ void GMainWindow::OnMouseActivity() { } } -void GMainWindow::OnCoreError(Core::System::ResultStatus result, std::string details) { +void GMainWindow::OnCoreError(Core::SystemResultStatus result, std::string details) { QMessageBox::StandardButton answer; QString status_message; const QString common_message = @@ -3131,7 +3133,7 @@ void GMainWindow::OnCoreError(Core::System::ResultStatus result, std::string det "back to the game list? Continuing emulation may result in crashes, corrupted save " "data, or other bugs."); switch (result) { - case Core::System::ResultStatus::ErrorSystemFiles: { + case Core::SystemResultStatus::ErrorSystemFiles: { QString message; if (details.empty()) { message = @@ -3147,7 +3149,7 @@ void GMainWindow::OnCoreError(Core::System::ResultStatus result, std::string det break; } - case Core::System::ResultStatus::ErrorSharedFont: { + case Core::SystemResultStatus::ErrorSharedFont: { const QString message = tr("yuzu was unable to locate the Switch shared fonts. %1").arg(common_message); answer = QMessageBox::question(this, tr("Shared Fonts Not Found"), message, @@ -3176,7 +3178,7 @@ void GMainWindow::OnCoreError(Core::System::ResultStatus result, std::string det if (emu_thread) { ShutdownGame(); - Settings::RestoreGlobalState(system.IsPoweredOn()); + Settings::RestoreGlobalState(system->IsPoweredOn()); UpdateStatusButtons(); } } else { @@ -3218,8 +3220,8 @@ void GMainWindow::OnReinitializeKeys(ReinitializeKeyBehavior behavior) { const auto function = [this, &keys, &pdm] { keys.PopulateFromPartitionData(pdm); - system.GetFileSystemController().CreateFactories(*vfs); - keys.DeriveETicket(pdm, system.GetContentProvider()); + system->GetFileSystemController().CreateFactories(*vfs); + keys.DeriveETicket(pdm, system->GetContentProvider()); }; QString errors; @@ -3261,7 +3263,7 @@ void GMainWindow::OnReinitializeKeys(ReinitializeKeyBehavior behavior) { prog.close(); } - system.GetFileSystemController().CreateFactories(*vfs); + system->GetFileSystemController().CreateFactories(*vfs); if (behavior == ReinitializeKeyBehavior::Warning) { game_list->PopulateAsync(UISettings::values.game_dirs); @@ -3329,7 +3331,7 @@ void GMainWindow::closeEvent(QCloseEvent* event) { if (emu_thread != nullptr) { ShutdownGame(); - Settings::RestoreGlobalState(system.IsPoweredOn()); + Settings::RestoreGlobalState(system->IsPoweredOn()); UpdateStatusButtons(); } @@ -3404,7 +3406,7 @@ bool GMainWindow::ConfirmForceLockedExit() { } void GMainWindow::RequestGameExit() { - auto& sm{system.ServiceManager()}; + auto& sm{system->ServiceManager()}; auto applet_oe = sm.GetService("appletOE"); auto applet_ae = sm.GetService("appletAE"); bool has_signalled = false; @@ -3420,7 +3422,7 @@ void GMainWindow::RequestGameExit() { } void GMainWindow::filterBarSetChecked(bool state) { - ui.action_Show_Filter_Bar->setChecked(state); + ui->action_Show_Filter_Bar->setChecked(state); emit(OnToggleFilterBar()); } @@ -3488,17 +3490,17 @@ void GMainWindow::OnLanguageChanged(const QString& locale) { UISettings::values.language = locale; LoadTranslation(); - ui.retranslateUi(this); + ui->retranslateUi(this); UpdateWindowTitle(); if (emulation_running) - ui.action_Start->setText(tr("&Continue")); + ui->action_Start->setText(tr("&Continue")); } void GMainWindow::SetDiscordEnabled([[maybe_unused]] bool state) { #ifdef USE_DISCORD_PRESENCE if (state) { - discord_rpc = std::make_unique(system); + discord_rpc = std::make_unique(*system); } else { discord_rpc = std::make_unique(); } @@ -3552,8 +3554,7 @@ int main(int argc, char* argv[]) { // generating shaders setlocale(LC_ALL, "C"); - Core::System::InitializeGlobalInstance(); - GMainWindow main_window{Core::System::GetInstance()}; + GMainWindow main_window{}; // After settings have been loaded by GMainWindow, apply the filter main_window.show(); diff --git a/src/yuzu/main.h b/src/yuzu/main.h index 29c60cd52..1d2741d25 100755 --- a/src/yuzu/main.h +++ b/src/yuzu/main.h @@ -13,9 +13,7 @@ #include #include "common/common_types.h" -#include "core/core.h" #include "core/hle/service/acc/profile_manager.h" -#include "ui_main.h" #include "yuzu/compatibility_list.h" #include "yuzu/hotkeys.h" @@ -45,6 +43,11 @@ enum class StartGameType { Global, // Only uses global configuration }; +namespace Core { +enum class SystemResultStatus : u32; +class System; +} // namespace Core + namespace Core::Frontend { struct ControllerParameters; struct InlineAppearParameters; @@ -73,6 +76,10 @@ enum class SwkbdReplyType : u32; enum class WebExitReason : u32; } // namespace Service::AM::Applets +namespace Ui { +class MainWindow; +} + enum class EmulatedDirectoryTarget { NAND, SDMC, @@ -107,7 +114,7 @@ class GMainWindow : public QMainWindow { public: void filterBarSetChecked(bool state); void UpdateUITheme(); - GMainWindow(Core::System& system_); + explicit GMainWindow(); ~GMainWindow() override; bool DropAction(QDropEvent* event); @@ -277,7 +284,7 @@ private slots: void ResetWindowSize900(); void ResetWindowSize1080(); void OnCaptureScreenshot(); - void OnCoreError(Core::System::ResultStatus, std::string); + void OnCoreError(Core::SystemResultStatus, std::string); void OnReinitializeKeys(ReinitializeKeyBehavior behavior); void OnLanguageChanged(const QString& locale); void OnMouseActivity(); @@ -306,13 +313,12 @@ private: void OpenPerGameConfiguration(u64 title_id, const std::string& file_name); QString GetTasStateDescription() const; - Ui::MainWindow ui; + std::unique_ptr ui; + std::unique_ptr system; std::unique_ptr discord_rpc; std::shared_ptr input_subsystem; - Core::System& system; - GRenderWindow* render_window; GameList* game_list; LoadingScreen* loading_screen; diff --git a/src/yuzu/uisettings.h b/src/yuzu/uisettings.h index 81f741f20..cac19452f 100755 --- a/src/yuzu/uisettings.h +++ b/src/yuzu/uisettings.h @@ -60,7 +60,7 @@ struct Values { Settings::BasicSetting confirm_before_closing{true, "confirmClose"}; Settings::BasicSetting first_start{true, "firstStart"}; Settings::BasicSetting pause_when_in_background{false, "pauseWhenInBackground"}; - Settings::BasicSetting hide_mouse{false, "hideInactiveMouse"}; + Settings::BasicSetting hide_mouse{true, "hideInactiveMouse"}; Settings::BasicSetting select_user_on_boot{false, "select_user_on_boot"}; diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp index ba2c993ba..67587cc54 100755 --- a/src/yuzu_cmd/yuzu.cpp +++ b/src/yuzu_cmd/yuzu.cpp @@ -146,9 +146,8 @@ int main(int argc, char** argv) { return -1; } - Core::System::InitializeGlobalInstance(); - auto& system{Core::System::GetInstance()}; - InputCommon::InputSubsystem input_subsystem; + Core::System system{}; + InputCommon::InputSubsystem input_subsystem{}; // Apply the command line arguments system.ApplySettings(); @@ -167,27 +166,27 @@ int main(int argc, char** argv) { system.SetFilesystem(std::make_shared()); system.GetFileSystemController().CreateFactories(*system.GetFilesystem()); - const Core::System::ResultStatus load_result{system.Load(*emu_window, filepath)}; + const Core::SystemResultStatus load_result{system.Load(*emu_window, filepath)}; switch (load_result) { - case Core::System::ResultStatus::ErrorGetLoader: + case Core::SystemResultStatus::ErrorGetLoader: LOG_CRITICAL(Frontend, "Failed to obtain loader for {}!", filepath); return -1; - case Core::System::ResultStatus::ErrorLoader: + case Core::SystemResultStatus::ErrorLoader: LOG_CRITICAL(Frontend, "Failed to load ROM!"); return -1; - case Core::System::ResultStatus::ErrorNotInitialized: + case Core::SystemResultStatus::ErrorNotInitialized: LOG_CRITICAL(Frontend, "CPUCore not initialized"); return -1; - case Core::System::ResultStatus::ErrorVideoCore: + case Core::SystemResultStatus::ErrorVideoCore: LOG_CRITICAL(Frontend, "Failed to initialize VideoCore!"); return -1; - case Core::System::ResultStatus::Success: + case Core::SystemResultStatus::Success: break; // Expected case default: if (static_cast(load_result) > - static_cast(Core::System::ResultStatus::ErrorLoader)) { - const u16 loader_id = static_cast(Core::System::ResultStatus::ErrorLoader); + static_cast(Core::SystemResultStatus::ErrorLoader)) { + const u16 loader_id = static_cast(Core::SystemResultStatus::ErrorLoader); const u16 error_id = static_cast(load_result) - loader_id; LOG_CRITICAL(Frontend, "While attempting to load the ROM requested, an error occurred. Please "