From bf9a8ac4a08b0afcee75b344fc2a1914712ca5b7 Mon Sep 17 00:00:00 2001 From: Jesse Bryan Date: Tue, 14 Aug 2018 23:12:47 -0500 Subject: [PATCH] discord: general discord-rpc improvements Now, if the content was loaded from a playlist, the content name will be the playlist entry's title instead of the filename of the content. Also, `state` was modified to show the display name of the core, not the library name. The difference is that the display name shows the platform as well, not just the core name (i.e. "NEC - PC Engine SuperGrafx (Beetle SGX)" instead of "Mednafen SuperGrafx"). --- command.c | 6 +++--- discord/discord.c | 24 +++++++++++++++++++----- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/command.c b/command.c index 18ca322b53..1b412a6087 100644 --- a/command.c +++ b/command.c @@ -1336,8 +1336,8 @@ static void command_event_restore_default_shader_preset(void) static void command_event_restore_remaps(void) { - if (rarch_ctl(RARCH_CTL_IS_REMAPS_CORE_ACTIVE, NULL) || - rarch_ctl(RARCH_CTL_IS_REMAPS_CONTENT_DIR_ACTIVE, NULL) || + if (rarch_ctl(RARCH_CTL_IS_REMAPS_CORE_ACTIVE, NULL) || + rarch_ctl(RARCH_CTL_IS_REMAPS_CONTENT_DIR_ACTIVE, NULL) || rarch_ctl(RARCH_CTL_IS_REMAPS_GAME_ACTIVE, NULL)) input_remapping_set_defaults(true); } @@ -2254,7 +2254,7 @@ TODO: Add a setting for these tweaks */ break; case CMD_EVENT_CORE_INFO_DEINIT: core_info_deinit_list(); - core_info_free_current_core(); + //core_info_free_current_core(); break; case CMD_EVENT_CORE_INFO_INIT: { diff --git a/discord/discord.c b/discord/discord.c index 9b7aa2d3bc..d56dcdf6d4 100644 --- a/discord/discord.c +++ b/discord/discord.c @@ -21,6 +21,7 @@ #include "../core.h" #include "../core_info.h" #include "../paths.h" +#include "../playlist.h" #include "../msg_hash.h" @@ -80,7 +81,7 @@ void discord_update(enum discord_presence presence) return; if ( - (discord_status != DISCORD_PRESENCE_MENU) && + (discord_status != DISCORD_PRESENCE_MENU) && (discord_status == presence)) return; @@ -104,16 +105,29 @@ void discord_update(enum discord_presence presence) const char *system_name = string_replace_substring( string_to_lower(core_info->core_name), " ", "_"); + char *label = NULL; + playlist_t *current_playlist = playlist_get_cached(); + + if (current_playlist) + { + playlist_get_index_by_path( + current_playlist, path_get(RARCH_PATH_CONTENT), NULL, &label, NULL, NULL, NULL, NULL); + } + + if (!label) + { + label = (char *)path_basename(path_get(RARCH_PATH_BASENAME)); + } + start_time = time(0); - discord_presence.state = system ? system->info.library_name : "---"; - discord_presence.details = path_basename(path_get(RARCH_PATH_BASENAME)); + discord_presence.state = core_info->display_name; + discord_presence.details = label; #if 1 RARCH_LOG("[Discord] system name: %s\n", system_name); + RARCH_LOG("[Discord] current content: %s\n", label); #endif discord_presence.largeImageKey = system_name; - discord_presence.smallImageKey = "base"; - discord_presence.instance = 0; discord_presence.startTimestamp = start_time;