Skip to content

Commit

Permalink
Update Discord rich presence when the title changes
Browse files Browse the repository at this point in the history
This allows us to update the rich presence description if a channel
is launched from the Wii Menu. It also handles other PPC title
launches, e.g. Smash Bros. Masterpieces.

Host.h: Added Host_TitleChanged().

DolphinNoGUI/MainNoGUI.cpp: Implemented Host_TitleChanged().
DolphinQt/Host.cpp: Implemented Host_TitleChanged().

Android/jni/MainAndroid.cpp: Stubbed Host_TitleChanged().
DSPTool/StubHost.cpp: Stubbed Host_TitleChanged().
UnitTests/StubHost.cpp: Stubbed Host_TitleChanged().
  • Loading branch information
GerbilSoft authored and leoetlino committed May 24, 2019
1 parent 3ab06dc commit 8417c78
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Source/Android/jni/MainAndroid.cpp
Expand Up @@ -155,6 +155,10 @@ void Host_UpdateProgressDialog(const char* caption, int position, int total)
{ {
} }


void Host_TitleChanged()
{
}

static bool MsgAlert(const char* caption, const char* text, bool yes_no, MsgType /*style*/) static bool MsgAlert(const char* caption, const char* text, bool yes_no, MsgType /*style*/)
{ {
__android_log_print(ANDROID_LOG_ERROR, DOLPHIN_TAG, "%s:%s", caption, text); __android_log_print(ANDROID_LOG_ERROR, DOLPHIN_TAG, "%s:%s", caption, text);
Expand Down
1 change: 1 addition & 0 deletions Source/Core/Core/ConfigManager.cpp
Expand Up @@ -725,6 +725,7 @@ void SConfig::SetRunningGameMetadata(const std::string& game_id, const std::stri
GetCurrentLanguage(bWii); GetCurrentLanguage(bWii);
m_title_description = title_database.Describe(m_gametdb_id, language); m_title_description = title_database.Describe(m_gametdb_id, language);
NOTICE_LOG(CORE, "Active title: %s", m_title_description.c_str()); NOTICE_LOG(CORE, "Active title: %s", m_title_description.c_str());
Host_TitleChanged();


Config::AddLayer(ConfigLoaders::GenerateGlobalGameConfigLoader(game_id, revision)); Config::AddLayer(ConfigLoaders::GenerateGlobalGameConfigLoader(game_id, revision));
Config::AddLayer(ConfigLoaders::GenerateLocalGameConfigLoader(game_id, revision)); Config::AddLayer(ConfigLoaders::GenerateLocalGameConfigLoader(game_id, revision));
Expand Down
1 change: 1 addition & 0 deletions Source/Core/Core/Host.h
Expand Up @@ -45,3 +45,4 @@ void Host_UpdateMainFrame();
void Host_UpdateTitle(const std::string& title); void Host_UpdateTitle(const std::string& title);
void Host_YieldToUI(); void Host_YieldToUI();
void Host_UpdateProgressDialog(const char* caption, int position, int total); void Host_UpdateProgressDialog(const char* caption, int position, int total);
void Host_TitleChanged();
7 changes: 7 additions & 0 deletions Source/Core/DolphinNoGUI/MainNoGUI.cpp
Expand Up @@ -105,6 +105,13 @@ void Host_UpdateProgressDialog(const char* caption, int position, int total)
{ {
} }


void Host_TitleChanged()
{
#ifdef USE_DISCORD_PRESENCE
Discord::UpdateDiscordPresence();
#endif
}

static std::unique_ptr<Platform> GetPlatform(const optparse::Values& options) static std::unique_ptr<Platform> GetPlatform(const optparse::Values& options)
{ {
std::string platform_name = static_cast<const char*>(options.get("platform")); std::string platform_name = static_cast<const char*>(options.get("platform"));
Expand Down
12 changes: 12 additions & 0 deletions Source/Core/DolphinQt/Host.cpp
Expand Up @@ -17,13 +17,16 @@
#include "Core/Core.h" #include "Core/Core.h"
#include "Core/Debugger/PPCDebugInterface.h" #include "Core/Debugger/PPCDebugInterface.h"
#include "Core/Host.h" #include "Core/Host.h"
#include "Core/NetPlayProto.h"
#include "Core/PowerPC/PowerPC.h" #include "Core/PowerPC/PowerPC.h"


#include "DolphinQt/QtUtils/QueueOnObject.h" #include "DolphinQt/QtUtils/QueueOnObject.h"
#include "DolphinQt/Settings.h" #include "DolphinQt/Settings.h"


#include "InputCommon/ControllerInterface/ControllerInterface.h" #include "InputCommon/ControllerInterface/ControllerInterface.h"


#include "UICommon/DiscordPresence.h"

#include "VideoCommon/RenderBase.h" #include "VideoCommon/RenderBase.h"
#include "VideoCommon/VideoConfig.h" #include "VideoCommon/VideoConfig.h"


Expand Down Expand Up @@ -164,3 +167,12 @@ bool Host_UIBlocksControllerState()
void Host_RefreshDSPDebuggerWindow() void Host_RefreshDSPDebuggerWindow()
{ {
} }

void Host_TitleChanged()
{
#ifdef USE_DISCORD_PRESENCE
// TODO: Not sure if the NetPlay check is needed.
if (!NetPlay::IsNetPlayRunning())
Discord::UpdateDiscordPresence();
#endif
}
3 changes: 3 additions & 0 deletions Source/DSPTool/StubHost.cpp
Expand Up @@ -52,3 +52,6 @@ void Host_YieldToUI()
void Host_UpdateProgressDialog(const char* caption, int position, int total) void Host_UpdateProgressDialog(const char* caption, int position, int total)
{ {
} }
void Host_TitleChanged()
{
}
3 changes: 3 additions & 0 deletions Source/UnitTests/StubHost.cpp
Expand Up @@ -53,3 +53,6 @@ void Host_YieldToUI()
void Host_UpdateProgressDialog(const char* caption, int position, int total) void Host_UpdateProgressDialog(const char* caption, int position, int total)
{ {
} }
void Host_TitleChanged()
{
}

0 comments on commit 8417c78

Please sign in to comment.