diff options
| author | 2021-09-03 20:16:20 -0400 | |
|---|---|---|
| committer | 2021-10-07 13:50:13 -0400 | |
| commit | b6894bfc5b86c2fae0b401f2cfc294a08994781d (patch) | |
| tree | 31f616dbc048740209668a15947b04c10c31caca | |
| parent | game_list: Remove global instances of Core::System (diff) | |
| download | yuzu-b6894bfc5b86c2fae0b401f2cfc294a08994781d.tar.gz yuzu-b6894bfc5b86c2fae0b401f2cfc294a08994781d.tar.xz yuzu-b6894bfc5b86c2fae0b401f2cfc294a08994781d.zip | |
discord_impl: Remove global system instances
Diffstat (limited to '')
| -rw-r--r-- | src/yuzu/discord_impl.cpp | 9 | ||||
| -rw-r--r-- | src/yuzu/discord_impl.h | 8 | ||||
| -rw-r--r-- | src/yuzu/main.cpp | 2 |
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 @@ | |||
| 13 | 13 | ||
| 14 | namespace DiscordRPC { | 14 | namespace DiscordRPC { |
| 15 | 15 | ||
| 16 | DiscordImpl::DiscordImpl() { | 16 | DiscordImpl::DiscordImpl(Core::System& system_) : system{system_} { |
| 17 | DiscordEventHandlers handlers{}; | 17 | DiscordEventHandlers handlers{}; |
| 18 | 18 | ||
| 19 | // The number is the client ID for yuzu, it's used for images and the | 19 | // The number is the client ID for yuzu, it's used for images and the |
| @@ -35,12 +35,13 @@ void DiscordImpl::Update() { | |||
| 35 | std::chrono::system_clock::now().time_since_epoch()) | 35 | std::chrono::system_clock::now().time_since_epoch()) |
| 36 | .count(); | 36 | .count(); |
| 37 | std::string title; | 37 | std::string title; |
| 38 | if (Core::System::GetInstance().IsPoweredOn()) | 38 | if (system.IsPoweredOn()) { |
| 39 | Core::System::GetInstance().GetAppLoader().ReadTitle(title); | 39 | system.GetAppLoader().ReadTitle(title); |
| 40 | } | ||
| 40 | DiscordRichPresence presence{}; | 41 | DiscordRichPresence presence{}; |
| 41 | presence.largeImageKey = "yuzu_logo"; | 42 | presence.largeImageKey = "yuzu_logo"; |
| 42 | presence.largeImageText = "yuzu is an emulator for the Nintendo Switch"; | 43 | presence.largeImageText = "yuzu is an emulator for the Nintendo Switch"; |
| 43 | if (Core::System::GetInstance().IsPoweredOn()) { | 44 | if (system.IsPoweredOn()) { |
| 44 | presence.state = title.c_str(); | 45 | presence.state = title.c_str(); |
| 45 | presence.details = "Currently in game"; | 46 | presence.details = "Currently in game"; |
| 46 | } else { | 47 | } 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 @@ | |||
| 6 | 6 | ||
| 7 | #include "yuzu/discord.h" | 7 | #include "yuzu/discord.h" |
| 8 | 8 | ||
| 9 | namespace Core { | ||
| 10 | class System; | ||
| 11 | } | ||
| 12 | |||
| 9 | namespace DiscordRPC { | 13 | namespace DiscordRPC { |
| 10 | 14 | ||
| 11 | class DiscordImpl : public DiscordInterface { | 15 | class DiscordImpl : public DiscordInterface { |
| 12 | public: | 16 | public: |
| 13 | DiscordImpl(); | 17 | DiscordImpl(Core::System& system_); |
| 14 | ~DiscordImpl() override; | 18 | ~DiscordImpl() override; |
| 15 | 19 | ||
| 16 | void Pause() override; | 20 | void Pause() override; |
| 17 | void Update() override; | 21 | void Update() override; |
| 22 | |||
| 23 | Core::System& system; | ||
| 18 | }; | 24 | }; |
| 19 | 25 | ||
| 20 | } // namespace DiscordRPC | 26 | } // 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) { | |||
| 3431 | void GMainWindow::SetDiscordEnabled([[maybe_unused]] bool state) { | 3431 | void GMainWindow::SetDiscordEnabled([[maybe_unused]] bool state) { |
| 3432 | #ifdef USE_DISCORD_PRESENCE | 3432 | #ifdef USE_DISCORD_PRESENCE |
| 3433 | if (state) { | 3433 | if (state) { |
| 3434 | discord_rpc = std::make_unique<DiscordRPC::DiscordImpl>(); | 3434 | discord_rpc = std::make_unique<DiscordRPC::DiscordImpl>(system); |
| 3435 | } else { | 3435 | } else { |
| 3436 | discord_rpc = std::make_unique<DiscordRPC::NullImpl>(); | 3436 | discord_rpc = std::make_unique<DiscordRPC::NullImpl>(); |
| 3437 | } | 3437 | } |