discord_impl: Remove global system instances
This commit is contained in:
parent
4ce53ffe6a
commit
b6894bfc5b
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
namespace DiscordRPC {
|
namespace DiscordRPC {
|
||||||
|
|
||||||
DiscordImpl::DiscordImpl() {
|
DiscordImpl::DiscordImpl(Core::System& system_) : system{system_} {
|
||||||
DiscordEventHandlers handlers{};
|
DiscordEventHandlers handlers{};
|
||||||
|
|
||||||
// The number is the client ID for yuzu, it's used for images and the
|
// 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())
|
std::chrono::system_clock::now().time_since_epoch())
|
||||||
.count();
|
.count();
|
||||||
std::string title;
|
std::string title;
|
||||||
if (Core::System::GetInstance().IsPoweredOn())
|
if (system.IsPoweredOn()) {
|
||||||
Core::System::GetInstance().GetAppLoader().ReadTitle(title);
|
system.GetAppLoader().ReadTitle(title);
|
||||||
|
}
|
||||||
DiscordRichPresence presence{};
|
DiscordRichPresence presence{};
|
||||||
presence.largeImageKey = "yuzu_logo";
|
presence.largeImageKey = "yuzu_logo";
|
||||||
presence.largeImageText = "yuzu is an emulator for the Nintendo Switch";
|
presence.largeImageText = "yuzu is an emulator for the Nintendo Switch";
|
||||||
if (Core::System::GetInstance().IsPoweredOn()) {
|
if (system.IsPoweredOn()) {
|
||||||
presence.state = title.c_str();
|
presence.state = title.c_str();
|
||||||
presence.details = "Currently in game";
|
presence.details = "Currently in game";
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -6,15 +6,21 @@
|
||||||
|
|
||||||
#include "yuzu/discord.h"
|
#include "yuzu/discord.h"
|
||||||
|
|
||||||
|
namespace Core {
|
||||||
|
class System;
|
||||||
|
}
|
||||||
|
|
||||||
namespace DiscordRPC {
|
namespace DiscordRPC {
|
||||||
|
|
||||||
class DiscordImpl : public DiscordInterface {
|
class DiscordImpl : public DiscordInterface {
|
||||||
public:
|
public:
|
||||||
DiscordImpl();
|
DiscordImpl(Core::System& system_);
|
||||||
~DiscordImpl() override;
|
~DiscordImpl() override;
|
||||||
|
|
||||||
void Pause() override;
|
void Pause() override;
|
||||||
void Update() override;
|
void Update() override;
|
||||||
|
|
||||||
|
Core::System& system;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace DiscordRPC
|
} // namespace DiscordRPC
|
||||||
|
|
|
@ -3431,7 +3431,7 @@ void GMainWindow::OnLanguageChanged(const QString& locale) {
|
||||||
void GMainWindow::SetDiscordEnabled([[maybe_unused]] bool state) {
|
void GMainWindow::SetDiscordEnabled([[maybe_unused]] bool state) {
|
||||||
#ifdef USE_DISCORD_PRESENCE
|
#ifdef USE_DISCORD_PRESENCE
|
||||||
if (state) {
|
if (state) {
|
||||||
discord_rpc = std::make_unique<DiscordRPC::DiscordImpl>();
|
discord_rpc = std::make_unique<DiscordRPC::DiscordImpl>(system);
|
||||||
} else {
|
} else {
|
||||||
discord_rpc = std::make_unique<DiscordRPC::NullImpl>();
|
discord_rpc = std::make_unique<DiscordRPC::NullImpl>();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue