mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-08-03 14:48:56 +00:00
Fix up Discord status
This commit is contained in:
parent
692c25c0b1
commit
7a52883c63
4 changed files with 23 additions and 14 deletions
|
@ -4,6 +4,7 @@
|
||||||
#include <discord_rpc.h>
|
#include <discord_rpc.h>
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace Discord {
|
namespace Discord {
|
||||||
enum class RPCStatus { Idling, Playing };
|
enum class RPCStatus { Idling, Playing };
|
||||||
|
@ -14,7 +15,7 @@ namespace Discord {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void init();
|
void init();
|
||||||
void update(RPCStatus status);
|
void update(RPCStatus status, const std::string& title);
|
||||||
void stop();
|
void stop();
|
||||||
};
|
};
|
||||||
} // namespace Discord
|
} // namespace Discord
|
||||||
|
|
|
@ -67,8 +67,8 @@ class Emulator {
|
||||||
|
|
||||||
#ifdef PANDA3DS_ENABLE_DISCORD_RPC
|
#ifdef PANDA3DS_ENABLE_DISCORD_RPC
|
||||||
Discord::RPC discordRpc;
|
Discord::RPC discordRpc;
|
||||||
void updateDiscord();
|
|
||||||
#endif
|
#endif
|
||||||
|
void updateDiscord();
|
||||||
|
|
||||||
// Keep the handle for the ROM here to reload when necessary and to prevent deleting it
|
// Keep the handle for the ROM here to reload when necessary and to prevent deleting it
|
||||||
// This is currently only used for ELFs, NCSDs use the IOFile API instead
|
// This is currently only used for ELFs, NCSDs use the IOFile API instead
|
||||||
|
|
|
@ -13,11 +13,15 @@ void Discord::RPC::init() {
|
||||||
enabled = true;
|
enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Discord::RPC::update(Discord::RPCStatus status) {
|
void Discord::RPC::update(Discord::RPCStatus status, const std::string& game) {
|
||||||
DiscordRichPresence rpc{};
|
DiscordRichPresence rpc{};
|
||||||
|
|
||||||
rpc.details = "Panda";
|
if (status == Discord::RPCStatus::Playing) {
|
||||||
rpc.state = "Petting a panda";
|
rpc.details = "Playing a game";
|
||||||
|
rpc.state = game.c_str();
|
||||||
|
} else {
|
||||||
|
rpc.details = "Idle";
|
||||||
|
}
|
||||||
|
|
||||||
rpc.largeImageKey = "pand";
|
rpc.largeImageKey = "pand";
|
||||||
rpc.largeImageText = "Panda3DS is a 3DS emulator for Windows, MacOS and Linux";
|
rpc.largeImageText = "Panda3DS is a 3DS emulator for Windows, MacOS and Linux";
|
||||||
|
|
|
@ -13,7 +13,7 @@ __declspec(dllexport) DWORD AmdPowerXpressRequestHighPerformance = 1;
|
||||||
|
|
||||||
Emulator::Emulator()
|
Emulator::Emulator()
|
||||||
: config(std::filesystem::current_path() / "config.toml"), kernel(cpu, memory, gpu), cpu(memory, kernel), gpu(memory, config),
|
: config(std::filesystem::current_path() / "config.toml"), kernel(cpu, memory, gpu), cpu(memory, kernel), gpu(memory, config),
|
||||||
memory(cpu.getTicksRef()), cheats(memory, kernel.getServiceManager().getHID())
|
memory(cpu.getTicksRef()), cheats(memory, kernel.getServiceManager().getHID()), running(false), programRunning(false)
|
||||||
#ifdef PANDA3DS_ENABLE_HTTP_SERVER
|
#ifdef PANDA3DS_ENABLE_HTTP_SERVER
|
||||||
, httpServer(this)
|
, httpServer(this)
|
||||||
#endif
|
#endif
|
||||||
|
@ -37,6 +37,7 @@ Emulator::Emulator()
|
||||||
#ifdef PANDA3DS_ENABLE_DISCORD_RPC
|
#ifdef PANDA3DS_ENABLE_DISCORD_RPC
|
||||||
if (config.discordRpcEnabled) {
|
if (config.discordRpcEnabled) {
|
||||||
discordRpc.init();
|
discordRpc.init();
|
||||||
|
updateDiscord();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -81,8 +82,6 @@ Emulator::Emulator()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
running = false;
|
|
||||||
programRunning = false;
|
|
||||||
reset(ReloadOption::NoReload);
|
reset(ReloadOption::NoReload);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -444,11 +443,8 @@ bool Emulator::loadROM(const std::filesystem::path& path) {
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
romPath = path;
|
romPath = path;
|
||||||
|
|
||||||
#ifdef PANDA3DS_ENABLE_DISCORD_RPC
|
#ifdef PANDA3DS_ENABLE_DISCORD_RPC
|
||||||
if (config.discordRpcEnabled) {
|
updateDiscord();
|
||||||
updateDiscord();
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
romPath = std::nullopt;
|
romPath = std::nullopt;
|
||||||
|
@ -509,7 +505,15 @@ void Emulator::initGraphicsContext() { gpu.initGraphicsContext(window); }
|
||||||
|
|
||||||
#ifdef PANDA3DS_ENABLE_DISCORD_RPC
|
#ifdef PANDA3DS_ENABLE_DISCORD_RPC
|
||||||
void Emulator::updateDiscord() {
|
void Emulator::updateDiscord() {
|
||||||
auto status = running ? Discord::RPCStatus::Playing : Discord::RPCStatus::Idling;
|
if (config.discordRpcEnabled) {
|
||||||
discordRpc.update(status);
|
if (romType != ROMType::None) {
|
||||||
|
const auto name = romPath.value().stem();
|
||||||
|
discordRpc.update(Discord::RPCStatus::Playing, name.string());
|
||||||
|
} else {
|
||||||
|
discordRpc.update(Discord::RPCStatus::Idling, "");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
void Emulator::updateDiscord() {}
|
||||||
#endif
|
#endif
|
Loading…
Add table
Add a link
Reference in a new issue