remove discord rpc
This commit is contained in:
@@ -1,80 +0,0 @@
|
||||
#pragma once
|
||||
#include <common.hpp>
|
||||
#include <ctime>
|
||||
#include <discord_rpc.h>
|
||||
#include <string>
|
||||
|
||||
namespace Util {
|
||||
struct RPC {
|
||||
enum State {
|
||||
Idling,
|
||||
Playing,
|
||||
MovieReplay,
|
||||
Paused,
|
||||
};
|
||||
|
||||
RPC() {
|
||||
Discord_Initialize("1049669178124148806", &handlers, 1, nullptr);
|
||||
startTimestamp = time(nullptr);
|
||||
}
|
||||
|
||||
static RPC &GetInstance() {
|
||||
static RPC instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
[[nodiscard]] FORCE_INLINE const State &GetState() const { return currentState; }
|
||||
|
||||
FORCE_INLINE void Update(State state, const std::string &game = "", const std::string &movieName = "") {
|
||||
DiscordRichPresence presence{};
|
||||
std::string textState, textDetails;
|
||||
currentState = state == Paused ? currentState : state;
|
||||
|
||||
switch (state) {
|
||||
case Idling:
|
||||
textDetails = "Idling";
|
||||
break;
|
||||
case Playing:
|
||||
textDetails = "In-game";
|
||||
textState = "Playing \"" + game + "\"";
|
||||
break;
|
||||
case MovieReplay:
|
||||
textDetails = "In-game";
|
||||
textState = "Replaying movie \"" + movieName + "\" in \"" + game + "\"";
|
||||
break;
|
||||
case Paused:
|
||||
switch (currentState) {
|
||||
case Playing:
|
||||
textDetails = "In-game";
|
||||
textState = "Playing \"" + game + "\"";
|
||||
break;
|
||||
case MovieReplay:
|
||||
textDetails = "In-game";
|
||||
textState = "Replaying movie \"" + movieName + "\" in \"" + game + "\"";
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
textState += " (Paused)";
|
||||
break;
|
||||
}
|
||||
|
||||
presence.details = textDetails.c_str();
|
||||
presence.state = textState.c_str();
|
||||
presence.startTimestamp = startTimestamp;
|
||||
presence.largeImageText = "Kaizen";
|
||||
presence.largeImageKey = "logo";
|
||||
Discord_UpdatePresence(&presence);
|
||||
}
|
||||
|
||||
FORCE_INLINE void Clear() { Discord_ClearPresence(); }
|
||||
FORCE_INLINE void Shutdown() {
|
||||
Clear();
|
||||
Discord_Shutdown();
|
||||
}
|
||||
|
||||
private:
|
||||
DiscordEventHandlers handlers{};
|
||||
s64 startTimestamp{};
|
||||
State currentState;
|
||||
};
|
||||
} // namespace Util
|
||||
@@ -43,9 +43,6 @@ void EmuThread::run() noexcept {
|
||||
|
||||
void EmuThread::TogglePause() const noexcept {
|
||||
core->TogglePause();
|
||||
Util::RPC::GetInstance().Update(core->pause ? Util::RPC::Paused : Util::RPC::GetInstance().GetState(),
|
||||
core->cpu->GetMem().rom.gameNameDB,
|
||||
core->cpu->GetMem().mmio.si.pif.movie.GetFilename());
|
||||
}
|
||||
|
||||
void EmuThread::Reset() const noexcept {
|
||||
@@ -54,7 +51,6 @@ void EmuThread::Reset() const noexcept {
|
||||
}
|
||||
|
||||
void EmuThread::Stop() const noexcept {
|
||||
Util::RPC::GetInstance().Update(Util::RPC::Idling);
|
||||
core->Stop();
|
||||
core->rom = {};
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#pragma once
|
||||
#include <Discord.hpp>
|
||||
#include <RenderWidget.hpp>
|
||||
#include <SettingsWindow.hpp>
|
||||
#include <memory>
|
||||
@@ -13,9 +12,7 @@ class EmuThread final {
|
||||
bool started = false;
|
||||
public:
|
||||
explicit EmuThread(const std::shared_ptr<n64::Core> &, double &, RenderWidget &, SettingsWindow &) noexcept;
|
||||
~EmuThread() {
|
||||
Util::RPC::GetInstance().Shutdown();
|
||||
}
|
||||
~EmuThread() = default;
|
||||
void run() noexcept;
|
||||
void TogglePause() const noexcept;
|
||||
void Reset() const noexcept;
|
||||
|
||||
@@ -243,7 +243,6 @@ void KaizenGui::RenderUI() {
|
||||
void KaizenGui::LoadROM(const std::string &path) noexcept {
|
||||
emuThread.core->LoadROM(path);
|
||||
const auto gameNameDB = emuThread.core->cpu->GetMem().rom.gameNameDB;
|
||||
Util::RPC::GetInstance().Update(Util::RPC::Playing, gameNameDB);
|
||||
}
|
||||
|
||||
void KaizenGui::run() {
|
||||
@@ -270,7 +269,6 @@ void KaizenGui::LoadTAS(const std::string &path) const noexcept {
|
||||
if (emuThread.core->LoadTAS(fs::path(path))) {
|
||||
const auto gameNameDB = emuThread.core->cpu->GetMem().rom.gameNameDB;
|
||||
const auto movieName = fs::path(path).stem().string();
|
||||
Util::RPC::GetInstance().Update(Util::RPC::MovieReplay, gameNameDB, movieName);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include <NativeWindow.hpp>
|
||||
#include <Debugger.hpp>
|
||||
#include <EmuThread.hpp>
|
||||
#include <Discord.hpp>
|
||||
#include <SDL3/SDL_gamepad.h>
|
||||
|
||||
class KaizenGui final {
|
||||
|
||||
Reference in New Issue
Block a user