Remove some global usages of system (#6688)
This commit is contained in:
parent
943d5eeddf
commit
d702915624
|
@ -151,7 +151,7 @@ static Core::System::ResultStatus RunCitra(const std::string& filepath) {
|
|||
Camera::RegisterFactory("ndk", std::move(ndk_factory));
|
||||
|
||||
// Register frontend applets
|
||||
Frontend::RegisterDefaultApplets();
|
||||
Frontend::RegisterDefaultApplets(system);
|
||||
system.RegisterMiiSelector(std::make_shared<MiiSelector::AndroidMiiSelector>());
|
||||
system.RegisterSoftwareKeyboard(std::make_shared<SoftwareKeyboard::AndroidKeyboard>());
|
||||
|
||||
|
|
|
@ -346,7 +346,7 @@ int main(int argc, char** argv) {
|
|||
system.ApplySettings();
|
||||
|
||||
// Register frontend applets
|
||||
Frontend::RegisterDefaultApplets();
|
||||
Frontend::RegisterDefaultApplets(system);
|
||||
|
||||
EmuWindow_SDL2::InitializeSDL2();
|
||||
|
||||
|
@ -354,12 +354,12 @@ int main(int argc, char** argv) {
|
|||
bool is_secondary) -> std::unique_ptr<EmuWindow_SDL2> {
|
||||
switch (Settings::values.graphics_api.GetValue()) {
|
||||
case Settings::GraphicsAPI::OpenGL:
|
||||
return std::make_unique<EmuWindow_SDL2_GL>(fullscreen, is_secondary);
|
||||
return std::make_unique<EmuWindow_SDL2_GL>(system, fullscreen, is_secondary);
|
||||
case Settings::GraphicsAPI::Software:
|
||||
return std::make_unique<EmuWindow_SDL2_SW>(system, fullscreen, is_secondary);
|
||||
}
|
||||
LOG_ERROR(Frontend, "Invalid Graphics API, using OpenGL");
|
||||
return std::make_unique<EmuWindow_SDL2_GL>(fullscreen, is_secondary);
|
||||
return std::make_unique<EmuWindow_SDL2_GL>(system, fullscreen, is_secondary);
|
||||
};
|
||||
|
||||
const auto emu_window{create_emu_window(fullscreen, false)};
|
||||
|
|
|
@ -109,7 +109,8 @@ void EmuWindow_SDL2::Fullscreen() {
|
|||
SDL_MaximizeWindow(render_window);
|
||||
}
|
||||
|
||||
EmuWindow_SDL2::EmuWindow_SDL2(bool is_secondary) : EmuWindow(is_secondary) {}
|
||||
EmuWindow_SDL2::EmuWindow_SDL2(Core::System& system_, bool is_secondary)
|
||||
: EmuWindow(is_secondary), system(system_) {}
|
||||
|
||||
EmuWindow_SDL2::~EmuWindow_SDL2() {
|
||||
SDL_Quit();
|
||||
|
@ -202,7 +203,7 @@ void EmuWindow_SDL2::OnMinimalClientAreaChangeRequest(std::pair<u32, u32> minima
|
|||
void EmuWindow_SDL2::UpdateFramerateCounter() {
|
||||
const u32 current_time = SDL_GetTicks();
|
||||
if (current_time > last_time + 2000) {
|
||||
const auto results = Core::System::GetInstance().GetAndResetPerfStats();
|
||||
const auto results = system.GetAndResetPerfStats();
|
||||
const auto title =
|
||||
fmt::format("Citra {} | {}-{} | FPS: {:.0f} ({:.0f}%)", Common::g_build_fullname,
|
||||
Common::g_scm_branch, Common::g_scm_desc, results.game_fps,
|
||||
|
|
|
@ -10,9 +10,13 @@
|
|||
|
||||
struct SDL_Window;
|
||||
|
||||
namespace Core {
|
||||
class System;
|
||||
}
|
||||
|
||||
class EmuWindow_SDL2 : public Frontend::EmuWindow {
|
||||
public:
|
||||
explicit EmuWindow_SDL2(bool is_secondary);
|
||||
explicit EmuWindow_SDL2(Core::System& system_, bool is_secondary);
|
||||
~EmuWindow_SDL2();
|
||||
|
||||
/// Initializes SDL2
|
||||
|
@ -78,4 +82,6 @@ protected:
|
|||
|
||||
/// Keeps track of how often to update the title bar during gameplay
|
||||
u32 last_time = 0;
|
||||
|
||||
Core::System& system;
|
||||
};
|
||||
|
|
|
@ -42,8 +42,8 @@ private:
|
|||
SDL_GLContext context;
|
||||
};
|
||||
|
||||
EmuWindow_SDL2_GL::EmuWindow_SDL2_GL(bool fullscreen, bool is_secondary)
|
||||
: EmuWindow_SDL2{is_secondary} {
|
||||
EmuWindow_SDL2_GL::EmuWindow_SDL2_GL(Core::System& system_, bool fullscreen, bool is_secondary)
|
||||
: EmuWindow_SDL2{system_, is_secondary} {
|
||||
// Initialize the window
|
||||
if (Settings::values.use_gles) {
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
|
||||
|
|
|
@ -9,9 +9,13 @@
|
|||
|
||||
struct SDL_Window;
|
||||
|
||||
namespace Core {
|
||||
class System;
|
||||
}
|
||||
|
||||
class EmuWindow_SDL2_GL : public EmuWindow_SDL2 {
|
||||
public:
|
||||
explicit EmuWindow_SDL2_GL(bool fullscreen, bool is_secondary);
|
||||
explicit EmuWindow_SDL2_GL(Core::System& system_, bool fullscreen, bool is_secondary);
|
||||
~EmuWindow_SDL2_GL();
|
||||
|
||||
void Present() override;
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
class DummyContext : public Frontend::GraphicsContext {};
|
||||
|
||||
EmuWindow_SDL2_SW::EmuWindow_SDL2_SW(Core::System& system_, bool fullscreen, bool is_secondary)
|
||||
: EmuWindow_SDL2{is_secondary}, system{system_} {
|
||||
: EmuWindow_SDL2{system_, is_secondary}, system{system_} {
|
||||
std::string window_title = fmt::format("Citra {} | {}-{}", Common::g_build_fullname,
|
||||
Common::g_scm_branch, Common::g_scm_desc);
|
||||
render_window =
|
||||
|
|
|
@ -44,7 +44,8 @@
|
|||
|
||||
static Frontend::WindowSystemType GetWindowSystemType();
|
||||
|
||||
EmuThread::EmuThread(Frontend::GraphicsContext& core_context) : core_context(core_context) {}
|
||||
EmuThread::EmuThread(Core::System& system_, Frontend::GraphicsContext& core_context)
|
||||
: system{system_}, core_context(core_context) {}
|
||||
|
||||
EmuThread::~EmuThread() = default;
|
||||
|
||||
|
@ -62,7 +63,6 @@ static GMainWindow* GetMainWindow() {
|
|||
void EmuThread::run() {
|
||||
MicroProfileOnThreadCreate("EmuThread");
|
||||
const auto scope = core_context.Acquire();
|
||||
Core::System& system = Core::System::GetInstance();
|
||||
|
||||
if (Settings::values.preload_textures) {
|
||||
emit LoadProgress(VideoCore::LoadCallbackStage::Preload, 0, 0);
|
||||
|
@ -107,7 +107,7 @@ void EmuThread::run() {
|
|||
}
|
||||
if (result != Core::System::ResultStatus::Success) {
|
||||
this->SetRunning(false);
|
||||
emit ErrorThrown(result, Core::System::GetInstance().GetStatusDetails());
|
||||
emit ErrorThrown(result, system.GetStatusDetails());
|
||||
}
|
||||
|
||||
was_active = running || exec_step;
|
||||
|
@ -248,8 +248,8 @@ public:
|
|||
#ifdef HAS_OPENGL
|
||||
class OpenGLRenderWidget : public RenderWidget {
|
||||
public:
|
||||
explicit OpenGLRenderWidget(GRenderWindow* parent, bool is_secondary)
|
||||
: RenderWidget(parent), is_secondary(is_secondary) {
|
||||
explicit OpenGLRenderWidget(GRenderWindow* parent, Core::System& system_, bool is_secondary)
|
||||
: RenderWidget(parent), system(system_), is_secondary(is_secondary) {
|
||||
setAttribute(Qt::WA_NativeWindow);
|
||||
setAttribute(Qt::WA_PaintOnScreen);
|
||||
if (GetWindowSystemType() == Frontend::WindowSystemType::Wayland) {
|
||||
|
@ -266,7 +266,7 @@ public:
|
|||
if (!isVisible()) {
|
||||
return;
|
||||
}
|
||||
if (!Core::System::GetInstance().IsPoweredOn()) {
|
||||
if (!system.IsPoweredOn()) {
|
||||
return;
|
||||
}
|
||||
context->MakeCurrent();
|
||||
|
@ -284,6 +284,7 @@ public:
|
|||
|
||||
private:
|
||||
std::unique_ptr<Frontend::GraphicsContext> context{};
|
||||
Core::System& system;
|
||||
bool is_secondary;
|
||||
};
|
||||
#endif
|
||||
|
@ -296,7 +297,7 @@ struct SoftwareRenderWidget : public RenderWidget {
|
|||
if (!isVisible()) {
|
||||
return;
|
||||
}
|
||||
if (!Core::System::GetInstance().IsPoweredOn()) {
|
||||
if (!system.IsPoweredOn()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -666,7 +667,7 @@ bool GRenderWindow::InitializeOpenGL() {
|
|||
|
||||
// TODO: One of these flags might be interesting: WA_OpaquePaintEvent, WA_NoBackground,
|
||||
// WA_DontShowOnScreen, WA_DeleteOnClose
|
||||
auto child = new OpenGLRenderWidget(this, is_secondary);
|
||||
auto child = new OpenGLRenderWidget(this, system, is_secondary);
|
||||
child_widget = child;
|
||||
child_widget->windowHandle()->create();
|
||||
|
||||
|
|
|
@ -18,6 +18,10 @@ class QTouchEvent;
|
|||
|
||||
class GRenderWindow;
|
||||
|
||||
namespace Core {
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace VideoCore {
|
||||
enum class LoadCallbackStage;
|
||||
}
|
||||
|
@ -26,7 +30,7 @@ class EmuThread final : public QThread {
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit EmuThread(Frontend::GraphicsContext& context);
|
||||
explicit EmuThread(Core::System& system_, Frontend::GraphicsContext& context);
|
||||
~EmuThread() override;
|
||||
|
||||
/**
|
||||
|
@ -80,6 +84,7 @@ private:
|
|||
std::mutex running_mutex;
|
||||
std::condition_variable running_cv;
|
||||
|
||||
Core::System& system;
|
||||
Frontend::GraphicsContext& core_context;
|
||||
|
||||
signals:
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
#include "core/core.h"
|
||||
#include "ui_compatdb.h"
|
||||
|
||||
CompatDB::CompatDB(QWidget* parent)
|
||||
CompatDB::CompatDB(Core::TelemetrySession& telemetry_session_, QWidget* parent)
|
||||
: QWizard(parent, Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::WindowSystemMenuHint),
|
||||
ui{std::make_unique<Ui::CompatDB>()} {
|
||||
ui{std::make_unique<Ui::CompatDB>()}, telemetry_session{telemetry_session_} {
|
||||
ui->setupUi(this);
|
||||
connect(ui->radioButton_Perfect, &QRadioButton::clicked, this, &CompatDB::EnableNext);
|
||||
connect(ui->radioButton_Great, &QRadioButton::clicked, this, &CompatDB::EnableNext);
|
||||
|
@ -51,16 +51,15 @@ void CompatDB::Submit() {
|
|||
case CompatDBPage::Final:
|
||||
back();
|
||||
LOG_DEBUG(Frontend, "Compatibility Rating: {}", compatibility->checkedId());
|
||||
Core::System::GetInstance().TelemetrySession().AddField(
|
||||
Common::Telemetry::FieldType::UserFeedback, "Compatibility",
|
||||
telemetry_session.AddField(Common::Telemetry::FieldType::UserFeedback, "Compatibility",
|
||||
compatibility->checkedId());
|
||||
|
||||
button(NextButton)->setEnabled(false);
|
||||
button(NextButton)->setText(tr("Submitting"));
|
||||
button(CancelButton)->setVisible(false);
|
||||
|
||||
testcase_watcher.setFuture(QtConcurrent::run(
|
||||
[] { return Core::System::GetInstance().TelemetrySession().SubmitTestcase(); }));
|
||||
testcase_watcher.setFuture(
|
||||
QtConcurrent::run([this] { return telemetry_session.SubmitTestcase(); }));
|
||||
break;
|
||||
default:
|
||||
LOG_ERROR(Frontend, "Unexpected page: {}", currentId());
|
||||
|
|
|
@ -8,6 +8,10 @@
|
|||
#include <QFutureWatcher>
|
||||
#include <QWizard>
|
||||
|
||||
namespace Core {
|
||||
class TelemetrySession;
|
||||
}
|
||||
|
||||
namespace Ui {
|
||||
class CompatDB;
|
||||
}
|
||||
|
@ -16,7 +20,7 @@ class CompatDB : public QWizard {
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CompatDB(QWidget* parent = nullptr);
|
||||
explicit CompatDB(Core::TelemetrySession& telemetry_session_, QWidget* parent = nullptr);
|
||||
~CompatDB();
|
||||
|
||||
private:
|
||||
|
@ -27,4 +31,6 @@ private:
|
|||
void Submit();
|
||||
void OnTestcaseSubmitted();
|
||||
void EnableNext();
|
||||
|
||||
Core::TelemetrySession& telemetry_session;
|
||||
};
|
||||
|
|
|
@ -1223,7 +1223,7 @@ void GMainWindow::BootGame(const QString& filename) {
|
|||
}
|
||||
|
||||
// Create and start the emulation thread
|
||||
emu_thread = std::make_unique<EmuThread>(*render_window);
|
||||
emu_thread = std::make_unique<EmuThread>(system, *render_window);
|
||||
emit EmulationStarting(emu_thread.get());
|
||||
emu_thread->start();
|
||||
|
||||
|
@ -1814,7 +1814,7 @@ void GMainWindow::OnLoadComplete() {
|
|||
|
||||
void GMainWindow::OnMenuReportCompatibility() {
|
||||
if (!NetSettings::values.citra_token.empty() && !NetSettings::values.citra_username.empty()) {
|
||||
CompatDB compatdb{this};
|
||||
CompatDB compatdb{system.TelemetrySession(), this};
|
||||
compatdb.exec();
|
||||
} else {
|
||||
QMessageBox::critical(this, tr("Missing Citra Account"),
|
||||
|
@ -2931,7 +2931,7 @@ int main(int argc, char* argv[]) {
|
|||
GMainWindow main_window(system);
|
||||
|
||||
// Register frontend applets
|
||||
Frontend::RegisterDefaultApplets();
|
||||
Frontend::RegisterDefaultApplets(system);
|
||||
|
||||
system.RegisterMiiSelector(std::make_shared<QtMiiSelector>(main_window));
|
||||
system.RegisterSoftwareKeyboard(std::make_shared<QtKeyboard>(main_window));
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
#include "core/frontend/applets/swkbd.h"
|
||||
|
||||
namespace Frontend {
|
||||
void RegisterDefaultApplets() {
|
||||
Core::System::GetInstance().RegisterSoftwareKeyboard(std::make_shared<DefaultKeyboard>());
|
||||
Core::System::GetInstance().RegisterMiiSelector(std::make_shared<DefaultMiiSelector>());
|
||||
void RegisterDefaultApplets(Core::System& system) {
|
||||
system.RegisterSoftwareKeyboard(std::make_shared<DefaultKeyboard>());
|
||||
system.RegisterMiiSelector(std::make_shared<DefaultMiiSelector>());
|
||||
}
|
||||
} // namespace Frontend
|
||||
|
|
|
@ -9,5 +9,5 @@ namespace Frontend {
|
|||
* Registers default, frontend-independent applet implementations.
|
||||
* Will be replaced later if any frontend-specific implementation is available.
|
||||
*/
|
||||
void RegisterDefaultApplets();
|
||||
void RegisterDefaultApplets(Core::System& system);
|
||||
} // namespace Frontend
|
||||
|
|
Reference in New Issue