Merge branch 'master' into d3d12
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include "xenia/app/discord/discord_presence.h"
|
||||
#include "xenia/app/emulator_window.h"
|
||||
#include "xenia/base/cvar.h"
|
||||
#include "xenia/base/debugging.h"
|
||||
@@ -59,6 +60,8 @@ DEFINE_bool(mount_cache, false, "Enable cache mount", "General");
|
||||
CmdVar(target, "", "Specifies the target .xex or .iso to execute.");
|
||||
DECLARE_bool(debug);
|
||||
|
||||
DEFINE_bool(discord, true, "Enable Discord rich presence", "General");
|
||||
|
||||
namespace xe {
|
||||
namespace app {
|
||||
|
||||
@@ -160,6 +163,11 @@ int xenia_main(const std::vector<std::wstring>& args) {
|
||||
Profiler::Initialize();
|
||||
Profiler::ThreadEnter("main");
|
||||
|
||||
if (cvars::discord) {
|
||||
discord::DiscordPresence::Initialize();
|
||||
discord::DiscordPresence::NotPlaying();
|
||||
}
|
||||
|
||||
// Figure out where content should go.
|
||||
std::wstring content_root = xe::to_wstring(cvars::content_root);
|
||||
std::wstring config_folder;
|
||||
@@ -271,11 +279,21 @@ int xenia_main(const std::vector<std::wstring>& args) {
|
||||
}
|
||||
|
||||
auto evt = xe::threading::Event::CreateAutoResetEvent(false);
|
||||
emulator->on_launch.AddListener([&]() {
|
||||
emulator->on_launch.AddListener([&](auto title_id, const auto& game_title) {
|
||||
if (cvars::discord) {
|
||||
discord::DiscordPresence::PlayingTitle(
|
||||
game_title.empty() ? L"Unknown Title" : game_title);
|
||||
}
|
||||
emulator_window->UpdateTitle();
|
||||
evt->Set();
|
||||
});
|
||||
|
||||
emulator->on_terminate.AddListener([&]() {
|
||||
if (cvars::discord) {
|
||||
discord::DiscordPresence::NotPlaying();
|
||||
}
|
||||
});
|
||||
|
||||
emulator_window->window()->on_closing.AddListener([&](ui::UIEvent* e) {
|
||||
// This needs to shut down before the graphics context.
|
||||
Profiler::Shutdown();
|
||||
@@ -286,6 +304,10 @@ int xenia_main(const std::vector<std::wstring>& args) {
|
||||
exiting = true;
|
||||
evt->Set();
|
||||
|
||||
if (cvars::discord) {
|
||||
discord::DiscordPresence::Shutdown();
|
||||
}
|
||||
|
||||
// TODO(DrChat): Remove this code and do a proper exit.
|
||||
XELOGI("Cheap-skate exit!");
|
||||
exit(0);
|
||||
@@ -333,6 +355,10 @@ int xenia_main(const std::vector<std::wstring>& args) {
|
||||
debug_window.reset();
|
||||
emulator.reset();
|
||||
|
||||
if (cvars::discord) {
|
||||
discord::DiscordPresence::Shutdown();
|
||||
}
|
||||
|
||||
Profiler::Dump();
|
||||
Profiler::Shutdown();
|
||||
emulator_window.reset();
|
||||
|
||||
Reference in New Issue
Block a user