mirror of
https://github.com/libretro/RetroArch
synced 2025-03-03 04:14:00 +00:00
[discord] add user avatar to ozone
This commit is contained in:
parent
3cedc83bfa
commit
9aa7b2bd62
@ -54,13 +54,14 @@ static int64_t pause_time = 0;
|
||||
static int64_t ellapsed_time = 0;
|
||||
|
||||
static bool discord_ready = false;
|
||||
static bool discord_avatar_ready = false;
|
||||
static unsigned discord_status = 0;
|
||||
|
||||
struct netplay_room *room;
|
||||
|
||||
static char user_id[128];
|
||||
static char user_name[128];
|
||||
static char avatar_path[PATH_MAX_LENGTH];
|
||||
static char user_avatar[PATH_MAX_LENGTH];
|
||||
|
||||
static char cdn_url[] = "https://cdn.discordapp.com/avatars";
|
||||
|
||||
@ -73,7 +74,17 @@ char* discord_get_own_username(void)
|
||||
|
||||
char* discord_get_own_avatar(void)
|
||||
{
|
||||
return avatar_path;
|
||||
return user_avatar;
|
||||
}
|
||||
|
||||
bool discord_avatar_is_ready()
|
||||
{
|
||||
return discord_avatar_ready;
|
||||
}
|
||||
|
||||
void discord_avatar_set_ready(bool ready)
|
||||
{
|
||||
discord_avatar_ready = ready;
|
||||
}
|
||||
|
||||
bool discord_is_ready()
|
||||
@ -85,7 +96,7 @@ static bool discord_download_avatar(const char* user_id, const char* avatar_id)
|
||||
{
|
||||
static char url[PATH_MAX_LENGTH];
|
||||
static char url_encoded[PATH_MAX_LENGTH];
|
||||
static char avatar_path[PATH_MAX_LENGTH];
|
||||
static char full_path[PATH_MAX_LENGTH];
|
||||
|
||||
static char buf[PATH_MAX_LENGTH];
|
||||
|
||||
@ -94,9 +105,10 @@ static bool discord_download_avatar(const char* user_id, const char* avatar_id)
|
||||
fill_pathname_application_special(buf,
|
||||
sizeof(buf),
|
||||
APPLICATION_SPECIAL_DIRECTORY_THUMBNAILS_DISCORD_AVATARS);
|
||||
fill_pathname_join(avatar_path, buf, avatar_id, sizeof(avatar_path));
|
||||
fill_pathname_join(full_path, buf, avatar_id, sizeof(full_path));
|
||||
strlcpy(user_avatar, avatar_id, sizeof(user_avatar));
|
||||
|
||||
if(filestream_exists(avatar_path))
|
||||
if(filestream_exists(full_path))
|
||||
return true;
|
||||
else
|
||||
{
|
||||
@ -342,7 +354,7 @@ void discord_init(void)
|
||||
|
||||
RARCH_LOG("[Discord] registering startup command: %s\n", command);
|
||||
Discord_Register(settings->arrays.discord_app_id, command);
|
||||
discord_ready = true;
|
||||
discord_ready = true;
|
||||
}
|
||||
|
||||
void discord_shutdown(void)
|
||||
|
@ -57,6 +57,10 @@ void discord_run_callbacks();
|
||||
|
||||
bool discord_is_ready();
|
||||
|
||||
void discord_avatar_set_ready(bool ready);
|
||||
|
||||
bool discord_avatar_is_ready();
|
||||
|
||||
char* discord_get_own_username(void);
|
||||
|
||||
char* discord_get_own_avatar(void);
|
||||
|
@ -26,6 +26,10 @@
|
||||
#include "../../config.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_DISCORD
|
||||
#include "../../discord/discord.h"
|
||||
#endif
|
||||
|
||||
#include "../../config.def.h"
|
||||
#include "../../config.def.keybinds.h"
|
||||
#include "../../wifi/wifi_driver.h"
|
||||
@ -3504,6 +3508,10 @@ finish:
|
||||
RARCH_ERR("Download of '%s' failed: %s\n",
|
||||
(transf ? transf->path: "unknown"), err);
|
||||
}
|
||||
#ifdef HAVE_DISCORD
|
||||
else if (transf->enum_idx == MENU_ENUM_LABEL_CB_DISCORD_AVATAR)
|
||||
discord_avatar_set_ready(true);
|
||||
#endif
|
||||
|
||||
if (data)
|
||||
{
|
||||
|
@ -23,6 +23,10 @@
|
||||
#include "ozone_texture.h"
|
||||
#include "ozone_sidebar.h"
|
||||
|
||||
#ifdef HAVE_DISCORD
|
||||
#include "discord/discord.h"
|
||||
#endif
|
||||
|
||||
#include <file/file_path.h>
|
||||
#include <string/stdstring.h>
|
||||
#include <encodings/utf.h>
|
||||
@ -348,14 +352,37 @@ static void ozone_context_reset(void *data, bool is_threaded)
|
||||
for (i = 0; i < OZONE_TEXTURE_LAST; i++)
|
||||
{
|
||||
char filename[PATH_MAX_LENGTH];
|
||||
strlcpy(filename, OZONE_TEXTURES_FILES[i], sizeof(filename));
|
||||
#ifdef HAVE_DISCORD
|
||||
if (i == OZONE_TEXTURE_DISCORD_OWN_AVATAR)
|
||||
strlcpy(filename, discord_get_own_avatar(), sizeof(filename));
|
||||
else
|
||||
#endif
|
||||
strlcpy(filename, OZONE_TEXTURES_FILES[i], sizeof(filename));
|
||||
|
||||
strlcat(filename, ".png", sizeof(filename));
|
||||
|
||||
if (!menu_display_reset_textures_list(filename, ozone->png_path, &ozone->textures[i], TEXTURE_FILTER_MIPMAP_LINEAR))
|
||||
|
||||
#ifdef HAVE_DISCORD
|
||||
if (i == OZONE_TEXTURE_DISCORD_OWN_AVATAR && discord_avatar_is_ready())
|
||||
{
|
||||
ozone->has_all_assets = false;
|
||||
RARCH_WARN("[OZONE] Asset missing: %s%s%s\n", ozone->png_path, path_default_slash(), filename);
|
||||
char buf[PATH_MAX_LENGTH];
|
||||
fill_pathname_application_special(buf,
|
||||
sizeof(buf),
|
||||
APPLICATION_SPECIAL_DIRECTORY_THUMBNAILS_DISCORD_AVATARS);
|
||||
if (!menu_display_reset_textures_list(filename, buf, &ozone->textures[i], TEXTURE_FILTER_MIPMAP_LINEAR))
|
||||
RARCH_WARN("[OZONE] Asset missing: %s%s%s\n", ozone->png_path, path_default_slash(), filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
#endif
|
||||
if (!menu_display_reset_textures_list(filename, ozone->png_path, &ozone->textures[i], TEXTURE_FILTER_MIPMAP_LINEAR))
|
||||
{
|
||||
ozone->has_all_assets = false;
|
||||
RARCH_WARN("[OZONE] Asset missing: %s%s%s\n", ozone->png_path, path_default_slash(), filename);
|
||||
}
|
||||
#ifdef HAVE_DISCORD
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Sidebar textures */
|
||||
@ -930,7 +957,12 @@ static void ozone_draw_header(ozone_handle_t *ozone, video_frame_info_t *video_i
|
||||
|
||||
/* Icon */
|
||||
menu_display_blend_begin(video_info);
|
||||
ozone_draw_icon(video_info, 60, 60, ozone->textures[OZONE_TEXTURE_RETROARCH], 47, 14, video_info->width, video_info->height, 0, 1, ozone->theme->entries_icon);
|
||||
#ifdef HAVE_DISCORD
|
||||
if (discord_avatar_is_ready())
|
||||
ozone_draw_icon(video_info, 60, 60, ozone->textures[OZONE_TEXTURE_DISCORD_OWN_AVATAR], 47, 14, video_info->width, video_info->height, 0, 1, ozone->theme->entries_icon);
|
||||
else
|
||||
#endif
|
||||
ozone_draw_icon(video_info, 60, 60, ozone->textures[OZONE_TEXTURE_RETROARCH], 47, 14, video_info->width, video_info->height, 0, 1, ozone->theme->entries_icon);
|
||||
menu_display_blend_end(video_info);
|
||||
|
||||
/* Battery */
|
||||
@ -1117,6 +1149,16 @@ static void ozone_frame(void *data, video_frame_info_t *video_info)
|
||||
bool draw_osk = menu_input_dialog_get_display_kb();
|
||||
static bool draw_osk_old = false;
|
||||
|
||||
#ifdef HAVE_DISCORD
|
||||
static bool reset = false;
|
||||
|
||||
if (discord_avatar_is_ready() && !reset)
|
||||
{
|
||||
ozone_context_reset(data, false);
|
||||
reset = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
menu_animation_ctx_entry_t entry;
|
||||
|
||||
if (!ozone)
|
||||
|
@ -28,7 +28,9 @@
|
||||
enum OZONE_TEXTURE {
|
||||
OZONE_TEXTURE_RETROARCH = 0,
|
||||
OZONE_TEXTURE_CURSOR_BORDER,
|
||||
|
||||
#ifdef HAVE_DISCORD
|
||||
OZONE_TEXTURE_DISCORD_OWN_AVATAR,
|
||||
#endif
|
||||
OZONE_TEXTURE_LAST
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user