Merge remote-tracking branch 'origin/master' into d3d12
This commit is contained in:
56
src/xenia/app/discord/discord_presence.cc
Normal file
56
src/xenia/app/discord/discord_presence.cc
Normal file
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2015 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include "discord_presence.h"
|
||||
#include "third_party/discord-rpc/include/discord_rpc.h"
|
||||
#include "xenia/base/string.h"
|
||||
|
||||
namespace xe {
|
||||
namespace discord {
|
||||
|
||||
void HandleDiscordReady(const DiscordUser* request) {}
|
||||
void HandleDiscordError(int errorCode, const char* message) {}
|
||||
void HandleDiscordJoinGame(const char* joinSecret) {}
|
||||
void HandleDiscordJoinRequest(const DiscordUser* request) {}
|
||||
void HandleDiscordSpectateGame(const char* spectateSecret) {}
|
||||
|
||||
void DiscordPresence::InitializeDiscord() {
|
||||
DiscordEventHandlers handlers = {};
|
||||
handlers.ready = &HandleDiscordReady;
|
||||
handlers.errored = &HandleDiscordError;
|
||||
handlers.joinGame = &HandleDiscordJoinGame;
|
||||
handlers.joinRequest = &HandleDiscordJoinRequest;
|
||||
handlers.spectateGame = &HandleDiscordSpectateGame;
|
||||
Discord_Initialize("606840046649081857", &handlers, 0, "");
|
||||
}
|
||||
|
||||
void DiscordPresence::NotPlaying() {
|
||||
DiscordRichPresence discordPresence = {};
|
||||
discordPresence.state = "Idle";
|
||||
discordPresence.details = "Standby";
|
||||
discordPresence.largeImageKey = "default";
|
||||
discordPresence.instance = 1;
|
||||
Discord_UpdatePresence(&discordPresence);
|
||||
}
|
||||
|
||||
void DiscordPresence::PlayingTitle(std::wstring game_title) {
|
||||
auto discord_game_title = xe::to_string(game_title);
|
||||
DiscordRichPresence discordPresence = {};
|
||||
discordPresence.state = "In Game";
|
||||
discordPresence.details = discord_game_title.c_str();
|
||||
discordPresence.smallImageKey = "default";
|
||||
discordPresence.largeImageKey = "defaultgame";
|
||||
discordPresence.instance = 1;
|
||||
Discord_UpdatePresence(&discordPresence);
|
||||
}
|
||||
|
||||
void DiscordPresence::ShutdownDiscord() { Discord_Shutdown(); }
|
||||
|
||||
} // namespace discord
|
||||
} // namespace xe
|
||||
29
src/xenia/app/discord/discord_presence.h
Normal file
29
src/xenia/app/discord/discord_presence.h
Normal file
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2015 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_DISCORD_DISCORD_PRESENCE_H_
|
||||
#define XENIA_DISCORD_DISCORD_PRESENCE_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace xe {
|
||||
namespace discord {
|
||||
|
||||
class DiscordPresence {
|
||||
public:
|
||||
static void InitializeDiscord();
|
||||
static void NotPlaying();
|
||||
static void PlayingTitle(std::wstring game_title);
|
||||
static void ShutdownDiscord();
|
||||
};
|
||||
|
||||
} // namespace discord
|
||||
} // namespace xe
|
||||
|
||||
#endif // XENIA_DISCORD_DISCORD_PRESENCE_H_
|
||||
20
src/xenia/app/discord/premake5.lua
Normal file
20
src/xenia/app/discord/premake5.lua
Normal file
@@ -0,0 +1,20 @@
|
||||
project_root = "../../../.."
|
||||
include(project_root.."/tools/build")
|
||||
|
||||
group("src")
|
||||
project("xenia-app-discord")
|
||||
uuid("d14c0885-22d2-40de-ab28-7b234ef2b949")
|
||||
kind("StaticLib")
|
||||
language("C++")
|
||||
links({
|
||||
"discord-rpc"
|
||||
})
|
||||
defines({
|
||||
})
|
||||
includedirs({
|
||||
project_root.."/third_party/discord-rpc/src"
|
||||
})
|
||||
files({
|
||||
"discord_presence.cc",
|
||||
"discord_presence.h"
|
||||
})
|
||||
@@ -7,12 +7,15 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include <gflags/gflags.h>
|
||||
|
||||
#include "xenia/app/emulator_window.h"
|
||||
|
||||
// Autogenerated by `xb premake`.
|
||||
#include "build/version.h"
|
||||
|
||||
#include "third_party/imgui/imgui.h"
|
||||
#include "xenia/app/discord/discord_presence.h"
|
||||
#include "xenia/base/clock.h"
|
||||
#include "xenia/base/debugging.h"
|
||||
#include "xenia/base/logging.h"
|
||||
@@ -26,6 +29,8 @@
|
||||
#include "xenia/ui/imgui_dialog.h"
|
||||
#include "xenia/ui/imgui_drawer.h"
|
||||
|
||||
DEFINE_bool(discord, false, "Enable Discord rich presence");
|
||||
|
||||
namespace xe {
|
||||
namespace app {
|
||||
|
||||
@@ -80,6 +85,11 @@ bool EmulatorWindow::Initialize() {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (FLAGS_discord) {
|
||||
discord::DiscordPresence::InitializeDiscord();
|
||||
discord::DiscordPresence::NotPlaying();
|
||||
}
|
||||
|
||||
UpdateTitle();
|
||||
|
||||
window_->on_closed.AddListener([this](UIEvent* e) { loop_->Quit(); });
|
||||
@@ -334,6 +344,9 @@ void EmulatorWindow::FileOpen() {
|
||||
void EmulatorWindow::FileClose() {
|
||||
if (emulator_->is_title_open()) {
|
||||
emulator_->TerminateTitle();
|
||||
if (FLAGS_discord) {
|
||||
discord::DiscordPresence::NotPlaying();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -431,6 +444,9 @@ void EmulatorWindow::UpdateTitle() {
|
||||
auto game_title = emulator()->game_title();
|
||||
title += xe::format_string(L" | [%.8X] %s", emulator()->title_id(),
|
||||
game_title.c_str());
|
||||
if (FLAGS_discord) {
|
||||
discord::DiscordPresence::PlayingTitle(game_title);
|
||||
}
|
||||
}
|
||||
|
||||
auto graphics_system = emulator()->graphics_system();
|
||||
|
||||
@@ -11,6 +11,7 @@ project("xenia-app")
|
||||
"aes_128",
|
||||
"capstone",
|
||||
"dxbc",
|
||||
"discord-rpc",
|
||||
"gflags",
|
||||
"glew",
|
||||
"glslang-spirv",
|
||||
@@ -21,6 +22,7 @@ project("xenia-app")
|
||||
"snappy",
|
||||
"spirv-tools",
|
||||
"volk",
|
||||
"xenia-app-discord",
|
||||
"xenia-apu",
|
||||
"xenia-apu-nop",
|
||||
"xenia-base",
|
||||
|
||||
Reference in New Issue
Block a user