Compare commits

...

2 Commits

Author SHA1 Message Date
RichardDorian
176a9366f2 refactor changements 2022-10-12 07:28:22 +02:00
RichardDorian
40e860fa1e add game image to discord rpc 2022-10-11 20:11:54 +02:00

View File

@@ -4,6 +4,7 @@
#include <chrono>
#include <string>
#include <discord_rpc.h>
#include <fmt/format.h>
#include "common/common_types.h"
#include "core/core.h"
#include "core/loader/loader.h"
@@ -33,17 +34,33 @@ void DiscordImpl::Update() {
s64 start_time = std::chrono::duration_cast<std::chrono::seconds>(
std::chrono::system_clock::now().time_since_epoch())
.count();
std::string default_text = "yuzu is an emulator for the Nintendo Switch";
std::string game_cover_url = "https://tinfoil.media/ti/";
std::string title;
u64 title_id;
if (system.IsPoweredOn()) {
system.GetAppLoader().ReadTitle(title);
system.GetAppLoader().ReadProgramId(title_id);
}
DiscordRichPresence presence{};
presence.largeImageKey = "yuzu_logo";
presence.largeImageText = "yuzu is an emulator for the Nintendo Switch";
if (system.IsPoweredOn()) {
game_cover_url += fmt::format("{:016X}", title_id);
game_cover_url += "/512/512";
presence.largeImageKey = game_cover_url.c_str();
presence.largeImageText = title.c_str();
presence.smallImageKey = "yuzu_logo";
presence.smallImageText = default_text.c_str();
presence.state = title.c_str();
presence.details = "Currently in game";
} else {
presence.largeImageKey = "yuzu_logo";
presence.largeImageText = default_text.c_str();
presence.details = "Not in game";
}
presence.startTimestamp = start_time;