mirror of
https://github.com/libretro/RetroArch
synced 2025-04-09 21:45:45 +00:00
discord: remove hardcoded values and use new attribute
This commit is contained in:
parent
ea561c8dfe
commit
c276f9349a
@ -149,6 +149,7 @@ static void core_info_list_free(core_info_list_t *core_info_list)
|
|||||||
free(info->path);
|
free(info->path);
|
||||||
free(info->core_name);
|
free(info->core_name);
|
||||||
free(info->systemname);
|
free(info->systemname);
|
||||||
|
free(info->rpc_name);
|
||||||
free(info->system_manufacturer);
|
free(info->system_manufacturer);
|
||||||
free(info->display_name);
|
free(info->display_name);
|
||||||
free(info->display_version);
|
free(info->display_version);
|
||||||
@ -302,6 +303,14 @@ static core_info_list_t *core_info_list_new(const char *path,
|
|||||||
tmp = NULL;
|
tmp = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (config_get_string(conf, "rpcname", &tmp)
|
||||||
|
&& !string_is_empty(tmp))
|
||||||
|
{
|
||||||
|
core_info[i].rpc_name = strdup(tmp);
|
||||||
|
free(tmp);
|
||||||
|
tmp = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (config_get_string(conf, "manufacturer", &tmp)
|
if (config_get_string(conf, "manufacturer", &tmp)
|
||||||
&& !string_is_empty(tmp))
|
&& !string_is_empty(tmp))
|
||||||
{
|
{
|
||||||
|
@ -47,6 +47,7 @@ typedef struct
|
|||||||
char *core_name;
|
char *core_name;
|
||||||
char *system_manufacturer;
|
char *system_manufacturer;
|
||||||
char *systemname;
|
char *systemname;
|
||||||
|
char *rpc_name;
|
||||||
char *supported_extensions;
|
char *supported_extensions;
|
||||||
char *authors;
|
char *authors;
|
||||||
char *permissions;
|
char *permissions;
|
||||||
|
@ -35,27 +35,6 @@ static bool discord_ready = false;
|
|||||||
static bool in_menu = false;
|
static bool in_menu = false;
|
||||||
static unsigned discord_status = 0;
|
static unsigned discord_status = 0;
|
||||||
|
|
||||||
// If you are to add to this list, please use the `corename` attribute
|
|
||||||
// from the core's respective info file. Case sensitivity does not matter.
|
|
||||||
char missing_core_icons[][16] = {
|
|
||||||
"3D Engine",
|
|
||||||
"Cannonball",
|
|
||||||
"Daphne",
|
|
||||||
"FFmpeg",
|
|
||||||
"Game Music Emu",
|
|
||||||
"Imageviewer",
|
|
||||||
"Lutro",
|
|
||||||
"MESS 2014 (Git)",
|
|
||||||
"PocketCDG",
|
|
||||||
"REminiscence",
|
|
||||||
"RemoteJoy",
|
|
||||||
"Rustation",
|
|
||||||
"Theodore",
|
|
||||||
"ThePowderToy",
|
|
||||||
"UME 2014 (Git)",
|
|
||||||
"VeMUlator"
|
|
||||||
};
|
|
||||||
|
|
||||||
DiscordRichPresence discord_presence;
|
DiscordRichPresence discord_presence;
|
||||||
|
|
||||||
static void handle_discord_ready(const DiscordUser* connectedUser)
|
static void handle_discord_ready(const DiscordUser* connectedUser)
|
||||||
@ -136,10 +115,7 @@ void discord_update(enum discord_presence presence)
|
|||||||
case DISCORD_PRESENCE_GAME:
|
case DISCORD_PRESENCE_GAME:
|
||||||
if (core_info)
|
if (core_info)
|
||||||
{
|
{
|
||||||
const char *core_name = core_info->core_name ? core_info->core_name : "core";
|
const char *rpc_name = core_info->rpc_name ? core_info->rpc_name : "core";
|
||||||
|
|
||||||
const char *system_name = string_replace_substring(
|
|
||||||
string_replace_substring(string_to_lower((char *)core_name), " ", "_"), "/", "_");
|
|
||||||
|
|
||||||
char *label = NULL;
|
char *label = NULL;
|
||||||
playlist_t *current_playlist = playlist_get_cached();
|
playlist_t *current_playlist = playlist_get_cached();
|
||||||
@ -151,22 +127,10 @@ void discord_update(enum discord_presence presence)
|
|||||||
if (!label)
|
if (!label)
|
||||||
label = (char *)path_basename(path_get(RARCH_PATH_BASENAME));
|
label = (char *)path_basename(path_get(RARCH_PATH_BASENAME));
|
||||||
#if 1
|
#if 1
|
||||||
RARCH_LOG("[Discord] current core: %s\n", system_name);
|
RARCH_LOG("[Discord] current core: %s\n", rpc_name);
|
||||||
RARCH_LOG("[Discord] current content: %s\n", label);
|
RARCH_LOG("[Discord] current content: %s\n", label);
|
||||||
#endif
|
#endif
|
||||||
discord_presence.largeImageKey = system_name;
|
discord_presence.largeImageKey = rpc_name;
|
||||||
|
|
||||||
for (int i = 0; i < sizeof(missing_core_icons) / sizeof(missing_core_icons[0]); i++)
|
|
||||||
{
|
|
||||||
const char *item = string_replace_substring(
|
|
||||||
string_replace_substring(string_to_lower(missing_core_icons[i]), " ", "_"), "/", "_");
|
|
||||||
|
|
||||||
if (strcmp(item, system_name) == 0)
|
|
||||||
{
|
|
||||||
discord_presence.largeImageKey = "core";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (core_info->display_name)
|
if (core_info->display_name)
|
||||||
discord_presence.largeImageText = core_info->display_name;
|
discord_presence.largeImageText = core_info->display_name;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user