Reintroduce DiscordRPC

This commit is contained in:
SimoneN64
2024-08-27 21:47:42 +02:00
parent 17b7cc333a
commit bba5037da6
3 changed files with 15 additions and 3 deletions

View File

@@ -16,12 +16,13 @@ include_directories(
../backend/core/mmio/PIF
../backend/core/registers
../backend/core/rsp
../../external/
../../external/discord_rpc/include
../../external/xbyak
../../external/mio/include
../../external/fmt/include
../../external/json/include
../../external/parallel-rdp
../../external/parallel-rdp
../../external/parallel-rdp/parallel-rdp-standalone/parallel-rdp
../../external/parallel-rdp/parallel-rdp-standalone/volk
../../external/parallel-rdp/parallel-rdp-standalone/spirv-cross
@@ -38,6 +39,7 @@ option(RAPIDJSON_BUILD_DOC "Build rapidjson documentation." OFF)
option(RAPIDJSON_BUILD_EXAMPLES "Build rapidjson examples." OFF)
option(RAPIDJSON_BUILD_TESTS "Build rapidjson perftests and unittests." OFF)
add_subdirectory(../../external/discord_rpc discord_rpc)
add_subdirectory(../../external/json json)
add_subdirectory(../../external/fmt fmt)
add_subdirectory(../../external/mio mio)
@@ -70,7 +72,7 @@ add_executable(kaizen-qt
InputSettings.hpp
InputSettings.cpp)
target_link_libraries(kaizen-qt PUBLIC Qt6::Core Qt6::Gui Qt6::Widgets fmt mio nlohmann_json parallel-rdp backend)
target_link_libraries(kaizen-qt PUBLIC Qt6::Core Qt6::Gui Qt6::Widgets discord-rpc fmt mio nlohmann_json parallel-rdp backend)
target_compile_definitions(kaizen-qt PUBLIC SDL_MAIN_HANDLED)
file(COPY ../../resources/ DESTINATION ${PROJECT_BINARY_DIR}/resources/)

View File

@@ -1,5 +1,6 @@
#pragma once
#include <Core.hpp>
#include <Discord.hpp>
#include <QThread>
#include <RenderWidget.hpp>
#include <SDL2/SDL_gamecontroller.h>
@@ -24,7 +25,10 @@ public:
n64::Core core;
SettingsWindow &settings;
void TogglePause() { core.pause = !core.pause; }
void TogglePause() {
core.pause = !core.pause;
Util::UpdateRPC(core.pause ? Util::Idling : Util::Playing);
}
void SetRender(bool v) { core.render = v; }
@@ -36,6 +40,7 @@ public:
}
void Stop() {
Discord_ClearPresence();
core.rom = {};
core.pause = true;
core.Stop();

View File

@@ -52,19 +52,24 @@ void KaizenQt::LoadROM(const QString &fileName) noexcept {
mainWindow->view.actionStop->setEnabled(true);
emuThread->start();
emuThread->core.LoadROM(fileName.toStdString());
auto gameNameDB = emuThread->core.cpu->GetMem().rom.gameNameDB;
mainWindow->setWindowTitle(emuThread->core.cpu->GetMem().rom.gameNameDB.c_str());
UpdateRPC(Util::Playing, gameNameDB);
}
void KaizenQt::Quit() noexcept {
if (emuThread) {
emuThread->SetRender(false);
emuThread->Stop();
emuThread->quit();
}
QApplication::quit();
}
void KaizenQt::LoadTAS(const QString &fileName) const noexcept {
emuThread->core.LoadTAS(fs::path(fileName.toStdString()));
auto gameNameDB = emuThread->core.cpu->GetMem().rom.gameNameDB;
UpdateRPC(Util::MovieReplay, gameNameDB, fileName.toStdString());
}
void KaizenQt::keyPressEvent(QKeyEvent *e) {