summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlat9nq <22451773+lat9nq@users.noreply.github.com>2021-09-04 02:16:20 +0200
committerMorph <39850852+Morph1984@users.noreply.github.com>2021-10-07 19:50:13 +0200
commitb6894bfc5b86c2fae0b401f2cfc294a08994781d (patch)
tree31f616dbc048740209668a15947b04c10c31caca
parentgame_list: Remove global instances of Core::System (diff)
downloadyuzu-b6894bfc5b86c2fae0b401f2cfc294a08994781d.tar
yuzu-b6894bfc5b86c2fae0b401f2cfc294a08994781d.tar.gz
yuzu-b6894bfc5b86c2fae0b401f2cfc294a08994781d.tar.bz2
yuzu-b6894bfc5b86c2fae0b401f2cfc294a08994781d.tar.lz
yuzu-b6894bfc5b86c2fae0b401f2cfc294a08994781d.tar.xz
yuzu-b6894bfc5b86c2fae0b401f2cfc294a08994781d.tar.zst
yuzu-b6894bfc5b86c2fae0b401f2cfc294a08994781d.zip
-rw-r--r--src/yuzu/discord_impl.cpp9
-rw-r--r--src/yuzu/discord_impl.h8
-rw-r--r--src/yuzu/main.cpp2
3 files changed, 13 insertions, 6 deletions
diff --git a/src/yuzu/discord_impl.cpp b/src/yuzu/discord_impl.cpp
index a93733b26..66f928af6 100644
--- a/src/yuzu/discord_impl.cpp
+++ b/src/yuzu/discord_impl.cpp
@@ -13,7 +13,7 @@
namespace DiscordRPC {
-DiscordImpl::DiscordImpl() {
+DiscordImpl::DiscordImpl(Core::System& system_) : system{system_} {
DiscordEventHandlers handlers{};
// The number is the client ID for yuzu, it's used for images and the
@@ -35,12 +35,13 @@ void DiscordImpl::Update() {
std::chrono::system_clock::now().time_since_epoch())
.count();
std::string title;
- if (Core::System::GetInstance().IsPoweredOn())
- Core::System::GetInstance().GetAppLoader().ReadTitle(title);
+ if (system.IsPoweredOn()) {
+ system.GetAppLoader().ReadTitle(title);
+ }
DiscordRichPresence presence{};
presence.largeImageKey = "yuzu_logo";
presence.largeImageText = "yuzu is an emulator for the Nintendo Switch";
- if (Core::System::GetInstance().IsPoweredOn()) {
+ if (system.IsPoweredOn()) {
presence.state = title.c_str();
presence.details = "Currently in game";
} else {
diff --git a/src/yuzu/discord_impl.h b/src/yuzu/discord_impl.h
index 4bfda8cdf..03ad42681 100644
--- a/src/yuzu/discord_impl.h
+++ b/src/yuzu/discord_impl.h
@@ -6,15 +6,21 @@
#include "yuzu/discord.h"
+namespace Core {
+class System;
+}
+
namespace DiscordRPC {
class DiscordImpl : public DiscordInterface {
public:
- DiscordImpl();
+ DiscordImpl(Core::System& system_);
~DiscordImpl() override;
void Pause() override;
void Update() override;
+
+ Core::System& system;
};
} // namespace DiscordRPC
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index 1d9e0f79d..8140e659b 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -3431,7 +3431,7 @@ void GMainWindow::OnLanguageChanged(const QString& locale) {
void GMainWindow::SetDiscordEnabled([[maybe_unused]] bool state) {
#ifdef USE_DISCORD_PRESENCE
if (state) {
- discord_rpc = std::make_unique<DiscordRPC::DiscordImpl>();
+ discord_rpc = std::make_unique<DiscordRPC::DiscordImpl>(system);
} else {
discord_rpc = std::make_unique<DiscordRPC::NullImpl>();
}