Skip to content

Commit

Permalink
Fix disable-rgui
Browse files Browse the repository at this point in the history
  • Loading branch information
inactive123 committed Jan 6, 2019
1 parent ad3e66d commit 2686cf1
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 71 deletions.
35 changes: 24 additions & 11 deletions Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -778,9 +778,12 @@ ifeq ($(HAVE_MENU_COMMON), 1)
menu/cbs/menu_cbs_contentlist_switch.o \
menu/menu_displaylist.o \
menu/menu_animation.o \
menu/drivers_display/menu_display_null.o \
menu/drivers/menu_generic.o \
menu/drivers/null.o

ifeq ($(HAVE_MENU_COMMON),1)
OBJ += menu/drivers_display/menu_display_null.o
endif
endif

ifeq ($(HAVE_OVERLAY), 1)
Expand Down Expand Up @@ -830,7 +833,7 @@ ifeq ($(HAVE_VITA2D), 1)
$(DEPS_DIR)/libvita2d/shader/texture_f_gxp.o \
$(DEPS_DIR)/libvita2d/shader/texture_tint_f_gxp.o

ifeq ($(HAVE_MENU),1)
ifeq ($(HAVE_MENU_COMMON),1)
OBJ += menu/drivers_display/menu_display_vita2d.o
endif

Expand Down Expand Up @@ -1114,8 +1117,10 @@ ifeq ($(HAVE_GL_CONTEXT), 1)
gfx/common/metal/MenuDisplay.o \
gfx/common/metal_common.o \
gfx/drivers/metal.o \
menu/drivers_display/menu_display_metal.o \
gfx/drivers_font/metal_raster_font.o
ifeq ($(HAVE_MENU_COMMON), 1)
OBJ += menu/drivers_display/menu_display_metal.o
endif
endif

ifeq ($(HAVE_MPV), 1)
Expand Down Expand Up @@ -1297,16 +1302,20 @@ endif
ifeq ($(HAVE_D3D10), 1)
OBJ += gfx/drivers/d3d10.o \
gfx/common/d3d10_common.o \
gfx/drivers_font/d3d10_font.o \
menu/drivers_display/menu_display_d3d10.o
gfx/drivers_font/d3d10_font.o
ifeq ($(HAVE_MENU_COMMON), 1)
OBJ += menu/drivers_display/menu_display_d3d10.o
endif
DEFINES += -DHAVE_D3D10
endif

ifeq ($(HAVE_D3D11), 1)
OBJ += gfx/drivers/d3d11.o \
gfx/common/d3d11_common.o \
gfx/drivers_font/d3d11_font.o \
menu/drivers_display/menu_display_d3d11.o
gfx/drivers_font/d3d11_font.o
ifeq ($(HAVE_MENU_COMMON), 1)
OBJ += menu/drivers_display/menu_display_d3d11.o
endif
DEFINES += -DHAVE_D3D11
HAVE_SLANG = 1
HAVE_GLSLANG = 1
Expand All @@ -1316,8 +1325,10 @@ endif
ifeq ($(HAVE_D3D12), 1)
OBJ += gfx/drivers/d3d12.o \
gfx/common/d3d12_common.o \
gfx/drivers_font/d3d12_font.o \
menu/drivers_display/menu_display_d3d12.o
gfx/drivers_font/d3d12_font.o
ifeq ($(HAVE_MENU_COMMON), 1)
OBJ += menu/drivers_display/menu_display_d3d12.o
endif
DEFINES += -DHAVE_D3D12
HAVE_SLANG = 1
HAVE_GLSLANG = 1
Expand Down Expand Up @@ -1757,9 +1768,11 @@ ifneq ($(findstring Win32,$(OS)),)
OBJ += gfx/drivers/gdi_gfx.o \
gfx/drivers_context/gdi_ctx.o \
gfx/drivers_font/gdi_font.o \
gfx/display_servers/dispserv_win32.o \
menu/drivers_display/menu_display_gdi.o
gfx/display_servers/dispserv_win32.o

ifeq ($(HAVE_MENU_COMMON), 1)
OBJ += menu/drivers_display/menu_display_gdi.o
endif
LIBS += -lmsimg32 -lhid -lsetupapi
endif

Expand Down
120 changes: 64 additions & 56 deletions discord/discord.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ char* discord_get_own_avatar(void)
return user_avatar;
}

bool discord_avatar_is_ready()
bool discord_avatar_is_ready(void)
{
return discord_avatar_ready;
}
Expand All @@ -87,12 +87,14 @@ void discord_avatar_set_ready(bool ready)
discord_avatar_ready = ready;
}

bool discord_is_ready()
bool discord_is_ready(void)
{
return discord_ready;
}

static bool discord_download_avatar(const char* user_id, const char* avatar_id)
#ifdef HAVE_MENU
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];
Expand All @@ -110,22 +112,21 @@ static bool discord_download_avatar(const char* user_id, const char* avatar_id)

if(filestream_exists(full_path))
return true;
else
{
snprintf(url, sizeof(url), "%s/%s/%s.png", cdn_url, user_id, avatar_id);
net_http_urlencode_full(url_encoded, url, sizeof(url_encoded));
snprintf(buf, sizeof(buf), "%s.png", avatar_id);

transf = (file_transfer_t*)calloc(1, sizeof(*transf));
transf->enum_idx = MENU_ENUM_LABEL_CB_DISCORD_AVATAR;
strlcpy(transf->path, buf, sizeof(transf->path));
snprintf(url, sizeof(url), "%s/%s/%s.png", cdn_url, user_id, avatar_id);
net_http_urlencode_full(url_encoded, url, sizeof(url_encoded));
snprintf(buf, sizeof(buf), "%s.png", avatar_id);

RARCH_LOG("[Discord] downloading avatar from: %s\n", url_encoded);
task_push_http_transfer(url_encoded, true, NULL, cb_generic_download, transf);
transf = (file_transfer_t*)calloc(1, sizeof(*transf));
transf->enum_idx = MENU_ENUM_LABEL_CB_DISCORD_AVATAR;
strlcpy(transf->path, buf, sizeof(transf->path));

return false;
}
RARCH_LOG("[Discord] downloading avatar from: %s\n", url_encoded);
task_push_http_transfer(url_encoded, true, NULL, cb_generic_download, transf);

return false;
}
#endif

static void handle_discord_ready(const DiscordUser* connectedUser)
{
Expand All @@ -134,7 +135,9 @@ static void handle_discord_ready(const DiscordUser* connectedUser)
connectedUser->username,
connectedUser->discriminator,
connectedUser->userId);
#ifdef HAVE_MENU
discord_download_avatar(connectedUser->userId, connectedUser->avatar);
#endif
}

static void handle_discord_disconnected(int errcode, const char* message)
Expand All @@ -149,11 +152,12 @@ static void handle_discord_error(int errcode, const char* message)

static void handle_discord_join(const char* secret)
{
RARCH_LOG("[Discord] join (%s)\n", secret);
char tmp_hostname[32];
static struct string_list *list = NULL;

RARCH_LOG("[Discord] join (%s)\n", secret);
list = string_split(secret, "|");

char tmp_hostname[32];
snprintf(tmp_hostname,
sizeof(tmp_hostname),
"%s|%s", list->elems[0].data, list->elems[1].data);
Expand Down Expand Up @@ -193,32 +197,33 @@ static void handle_discord_join_request(const DiscordUser* request)
static char url_encoded[PATH_MAX_LENGTH];
static char filename[PATH_MAX_LENGTH];
char buf[PATH_MAX_LENGTH];
#ifdef HAVE_MENU
menu_input_ctx_line_t line;
#endif

RARCH_LOG("[Discord] join request from %s#%s - %s %s\n",
request->username,
request->discriminator,
request->userId,
request->avatar);

discord_download_avatar(request->userId, request->avatar);

#ifdef HAVE_MENU
menu_input_ctx_line_t line;
/* To-Do: needs in-game widgets
discord_download_avatar(request->userId, request->avatar);
/* To-Do: needs in-game widgets
rarch_menu_running();
*/

memset(&line, 0, sizeof(line));
snprintf(buf, sizeof(buf), "%s %s?", msg_hash_to_str(MSG_DISCORD_CONNECTION_REQUEST), request->username);
line.label = buf;
line.label_setting = "no_setting";
line.cb = handle_discord_join_response;
memset(&line, 0, sizeof(line));
snprintf(buf, sizeof(buf), "%s %s?", msg_hash_to_str(MSG_DISCORD_CONNECTION_REQUEST), request->username);
line.label = buf;
line.label_setting = "no_setting";
line.cb = handle_discord_join_response;

/* To-Do: needs in-game widgets
To-Do: bespoke dialog, should show while in-game and have a hotkey to accept
To-Do: show avatar of the user connecting
/* To-Do: needs in-game widgets
To-Do: bespoke dialog, should show while in-game and have a hotkey to accept
To-Do: show avatar of the user connecting
if (!menu_input_dialog_start(&line))
return;
return;
*/
#endif
}
Expand All @@ -241,8 +246,8 @@ void discord_update(enum discord_presence presence)
switch (presence)
{
case DISCORD_PRESENCE_MENU:
discord_presence.details = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DISCORD_IN_MENU);
discord_presence.largeImageKey = "base";
discord_presence.details = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DISCORD_IN_MENU);
discord_presence.largeImageKey = "base";
discord_presence.largeImageText = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_CORE);
discord_presence.instance = 0;
break;
Expand All @@ -257,9 +262,9 @@ void discord_update(enum discord_presence presence)
case DISCORD_PRESENCE_GAME:
if (core_info)
{
const char *system_id = core_info->system_id ? core_info->system_id : "core";

char *label = NULL;
const char *system_id = core_info->system_id
? core_info->system_id : "core";
char *label = NULL;
playlist_t *current_playlist = playlist_get_cached();

if (current_playlist)
Expand All @@ -284,13 +289,13 @@ void discord_update(enum discord_presence presence)
pause_time = 0;
ellapsed_time = 0;

discord_presence.smallImageKey = "playing";
discord_presence.smallImageKey = "playing";
discord_presence.smallImageText = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DISCORD_STATUS_PLAYING);
discord_presence.startTimestamp = start_time;
discord_presence.details = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DISCORD_IN_GAME);
discord_presence.details = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DISCORD_IN_GAME);

discord_presence.state = label;
discord_presence.instance = 0;
discord_presence.state = label;
discord_presence.instance = 0;
}
break;
case DISCORD_PRESENCE_NETPLAY_HOSTING:
Expand All @@ -303,20 +308,22 @@ void discord_update(enum discord_presence presence)
room->host_method == NETPLAY_HOST_METHOD_MITM ? room->mitm_address : room->address,
room->host_method == NETPLAY_HOST_METHOD_MITM ? room->mitm_port : room->port);

char party_id[128];
snprintf(party_id, sizeof(party_id), "%d|%s", room->id, room->nickname);
char join_secret[128];
snprintf(join_secret, sizeof(join_secret), "%s|%d|%s|%u|%s",
room->host_method == NETPLAY_HOST_METHOD_MITM ? room->mitm_address : room->address,
room->host_method == NETPLAY_HOST_METHOD_MITM ? room->mitm_port : room->port,
room->gamename, room->gamecrc, room->corename);
RARCH_LOG("%s\n", join_secret);
discord_presence.joinSecret = strdup(join_secret);
/* discord_presence.spectateSecret = "SPECSPECSPEC"; */
discord_presence.partyId = strdup(party_id);
discord_presence.partyMax = 0;
discord_presence.partySize = 0;
RARCH_LOG("[Discord] joining: \n Secret: %s\n Party: %s\n", discord_presence.joinSecret, discord_presence.partyId);
{
char party_id[128];
char join_secret[128];
snprintf(party_id, sizeof(party_id), "%d|%s", room->id, room->nickname);
snprintf(join_secret, sizeof(join_secret), "%s|%d|%s|%u|%s",
room->host_method == NETPLAY_HOST_METHOD_MITM ? room->mitm_address : room->address,
room->host_method == NETPLAY_HOST_METHOD_MITM ? room->mitm_port : room->port,
room->gamename, room->gamecrc, room->corename);
RARCH_LOG("%s\n", join_secret);
discord_presence.joinSecret = strdup(join_secret);
/* discord_presence.spectateSecret = "SPECSPECSPEC"; */
discord_presence.partyId = strdup(party_id);
discord_presence.partyMax = 0;
discord_presence.partySize = 0;
RARCH_LOG("[Discord] joining: \n Secret: %s\n Party: %s\n", discord_presence.joinSecret, discord_presence.partyId);
}
break;
case DISCORD_PRESENCE_NETPLAY_HOSTING_STOPPED:
case DISCORD_PRESENCE_NETPLAY_CLIENT:
Expand All @@ -333,7 +340,9 @@ void discord_update(enum discord_presence presence)

void discord_init(void)
{
char command[PATH_MAX_LENGTH];
settings_t *settings = config_get_ptr();

DiscordEventHandlers handlers;

RARCH_LOG("[Discord] initializing ..\n");
Expand All @@ -349,7 +358,6 @@ void discord_init(void)

Discord_Initialize(settings->arrays.discord_app_id, &handlers, 0, NULL);

char command[PATH_MAX_LENGTH];
strlcpy(command, get_retroarch_launch_arguments(), sizeof(command));

RARCH_LOG("[Discord] registering startup command: %s\n", command);
Expand All @@ -365,7 +373,7 @@ void discord_shutdown(void)
discord_ready = false;
}

void discord_run_callbacks()
void discord_run_callbacks(void)
{
Discord_RunCallbacks();
}
}
5 changes: 4 additions & 1 deletion gfx/drivers/d3d11.c
Original file line number Diff line number Diff line change
Expand Up @@ -1402,13 +1402,16 @@ static bool d3d11_gfx_frame(

d3d11->sprites.enabled = true;

#ifdef HAVE_MENU
if (d3d11->menu.enabled)
{
D3D11SetViewports(context, 1, &d3d11->viewport);
D3D11SetVertexBuffer(context, 0, d3d11->sprites.vbo, sizeof(d3d11_sprite_t), 0);
menu_driver_frame(video_info);
}
else if (video_info->statistics_show)
else
#endif
if (video_info->statistics_show)
{
struct font_params* osd_params = (struct font_params*)&video_info->osd_stat_params;

Expand Down
5 changes: 4 additions & 1 deletion gfx/drivers/d3d12.c
Original file line number Diff line number Diff line change
Expand Up @@ -1470,14 +1470,17 @@ static bool d3d12_gfx_frame(

d3d12->sprites.enabled = true;

#ifdef HAVE_MENU
if (d3d12->menu.enabled)
{
D3D12RSSetViewports(d3d12->queue.cmd, 1, &d3d12->chain.viewport);
D3D12RSSetScissorRects(d3d12->queue.cmd, 1, &d3d12->chain.scissorRect);
D3D12IASetVertexBuffers(d3d12->queue.cmd, 0, 1, &d3d12->sprites.vbo_view);
menu_driver_frame(video_info);
}
else if (video_info->statistics_show)
else
#endif
if (video_info->statistics_show)
{
struct font_params *osd_params = (struct font_params*)
&video_info->osd_stat_params;
Expand Down
4 changes: 2 additions & 2 deletions retroarch.c
Original file line number Diff line number Diff line change
Expand Up @@ -2590,10 +2590,10 @@ static enum runloop_state runloop_check_state(
bool focused = true;
bool pause_nonactive = settings->bools.pause_nonactive;
bool fs_toggle_triggered = false;
static uint64_t seq = 0;
#ifdef HAVE_MENU
bool menu_driver_binding_state = menu_driver_is_binding_state();
bool menu_is_alive = menu_driver_is_alive();
static uint64_t seq = 0;
#endif

#ifdef HAVE_LIBNX
Expand Down Expand Up @@ -3716,4 +3716,4 @@ struct retro_system_info *runloop_get_libretro_system_info(void)
char *get_retroarch_launch_arguments(void)
{
return launch_arguments;
}
}

0 comments on commit 2686cf1

Please sign in to comment.