mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-24 08:30:16 +00:00
Start preparing for menu_widgets_ready to be moved to retroarch.c
This commit is contained in:
parent
d5c7ada96d
commit
6c671faed6
@ -504,7 +504,7 @@ static void rcheevos_award(rcheevos_cheevo_t* cheevo, int mode)
|
||||
|
||||
/* Show the OSD message. */
|
||||
#if defined(HAVE_MENU) && defined(HAVE_MENU_WIDGETS)
|
||||
if (!menu_widgets_push_achievement(cheevo->info->title, cheevo->info->badge))
|
||||
if (!menu_widgets_ready() || !menu_widgets_push_achievement(cheevo->info->title, cheevo->info->badge))
|
||||
#endif
|
||||
{
|
||||
snprintf(buffer, sizeof(buffer), "Achievement Unlocked: %s", cheevo->info->title);
|
||||
|
@ -297,7 +297,8 @@
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
#ifdef HAVE_MENU_WIDGETS
|
||||
menu_widgets_frame(video_info);
|
||||
if (video_info->widgets_inited)
|
||||
menu_widgets_frame(video_info);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -1501,7 +1501,8 @@ static bool d3d10_gfx_frame(
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
#ifdef HAVE_MENU_WIDGETS
|
||||
menu_widgets_frame(video_info);
|
||||
if (video_info->widgets_inited)
|
||||
menu_widgets_frame(video_info);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -1567,7 +1567,8 @@ static bool d3d11_gfx_frame(
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
#ifdef HAVE_MENU_WIDGETS
|
||||
menu_widgets_frame(video_info);
|
||||
if (video_info->widgets_inited)
|
||||
menu_widgets_frame(video_info);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -1558,7 +1558,8 @@ static bool d3d12_gfx_frame(
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
#ifdef HAVE_MENU_WIDGETS
|
||||
menu_widgets_frame(video_info);
|
||||
if (video_info->widgets_inited)
|
||||
menu_widgets_frame(video_info);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -1658,7 +1658,8 @@ static bool d3d9_frame(void *data, const void *frame,
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
#ifdef HAVE_MENU_WIDGETS
|
||||
menu_widgets_frame(video_info);
|
||||
if (video_info->widgets_inited)
|
||||
menu_widgets_frame(video_info);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -3048,7 +3048,8 @@ static bool gl2_frame(void *data, const void *frame,
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MENU_WIDGETS
|
||||
menu_widgets_frame(video_info);
|
||||
if (video_info->widgets_inited)
|
||||
menu_widgets_frame(video_info);
|
||||
#endif
|
||||
|
||||
if (!string_is_empty(msg))
|
||||
|
@ -836,7 +836,8 @@ static bool gl1_gfx_frame(void *data, const void *frame,
|
||||
}
|
||||
|
||||
#ifdef HAVE_MENU_WIDGETS
|
||||
menu_widgets_frame(video_info);
|
||||
if (video_info->widgets_inited)
|
||||
menu_widgets_frame(video_info);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -1698,7 +1698,8 @@ static bool gl_core_frame(void *data, const void *frame,
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MENU_WIDGETS
|
||||
menu_widgets_frame(video_info);
|
||||
if (video_info->widgets_inited)
|
||||
menu_widgets_frame(video_info);
|
||||
#endif
|
||||
|
||||
if (!string_is_empty(msg))
|
||||
|
@ -1346,7 +1346,8 @@ static bool wiiu_gfx_frame(void *data, const void *frame,
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
#ifdef HAVE_MENU_WIDGETS
|
||||
menu_widgets_frame(video_info);
|
||||
if (video_info->widgets_inited)
|
||||
menu_widgets_frame(video_info);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -1943,7 +1943,8 @@ static bool vulkan_frame(void *data, const void *frame,
|
||||
font_driver_render_msg(video_info, NULL, msg, NULL);
|
||||
|
||||
#ifdef HAVE_MENU_WIDGETS
|
||||
menu_widgets_frame(video_info);
|
||||
if (video_info->widgets_inited)
|
||||
menu_widgets_frame(video_info);
|
||||
#endif
|
||||
|
||||
/* End the render pass. We're done rendering to backbuffer now. */
|
||||
|
@ -311,9 +311,6 @@ static unsigned generic_message_height; /* used for both generic and libretro me
|
||||
|
||||
bool menu_widgets_set_paused(bool is_paused)
|
||||
{
|
||||
if (!menu_widgets_inited)
|
||||
return false;
|
||||
|
||||
menu_widgets_paused = is_paused;
|
||||
return true;
|
||||
}
|
||||
@ -811,9 +808,6 @@ void menu_widgets_iterate(unsigned width, unsigned height)
|
||||
size_t i;
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
if (!menu_widgets_inited)
|
||||
return;
|
||||
|
||||
/* Messages queue */
|
||||
|
||||
/* Consume one message if available */
|
||||
@ -1297,9 +1291,6 @@ void menu_widgets_frame(video_frame_info_t *video_info)
|
||||
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
if (!menu_widgets_inited)
|
||||
return;
|
||||
|
||||
menu_widgets_frame_count++;
|
||||
|
||||
menu_display_set_viewport(video_info->width, video_info->height);
|
||||
@ -1722,13 +1713,10 @@ void menu_widgets_frame(video_frame_info_t *video_info)
|
||||
menu_display_unset_viewport(video_info->width, video_info->height);
|
||||
}
|
||||
|
||||
void menu_widgets_init(bool video_is_threaded)
|
||||
bool menu_widgets_init(bool video_is_threaded)
|
||||
{
|
||||
if (menu_widgets_inited)
|
||||
return;
|
||||
|
||||
if (!menu_display_init_first_driver(video_is_threaded))
|
||||
goto err;
|
||||
goto error;
|
||||
|
||||
menu_widgets_frame_count = 0;
|
||||
|
||||
@ -1737,21 +1725,24 @@ void menu_widgets_init(bool video_is_threaded)
|
||||
msg_queue = fifo_new(MSG_QUEUE_PENDING_MAX * sizeof(menu_widget_msg_t*));
|
||||
|
||||
if (!msg_queue)
|
||||
goto err;
|
||||
goto error;
|
||||
|
||||
current_msgs = (file_list_t*)calloc(1, sizeof(file_list_t));
|
||||
|
||||
if (!current_msgs)
|
||||
goto err;
|
||||
goto error;
|
||||
|
||||
if (!file_list_reserve(current_msgs, MSG_QUEUE_ONSCREEN_MAX))
|
||||
goto err;
|
||||
goto error;
|
||||
|
||||
menu_widgets_inited = true;
|
||||
|
||||
return;
|
||||
err:
|
||||
menu_widgets_free();
|
||||
return true;
|
||||
|
||||
error:
|
||||
if (menu_widgets_inited)
|
||||
menu_widgets_free();
|
||||
return false;
|
||||
}
|
||||
|
||||
void menu_widgets_context_reset(bool is_threaded,
|
||||
@ -1766,9 +1757,6 @@ void menu_widgets_context_reset(bool is_threaded,
|
||||
char font_path[PATH_MAX_LENGTH];
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
if (!menu_widgets_inited)
|
||||
return;
|
||||
|
||||
/* Textures paths */
|
||||
fill_pathname_join(
|
||||
menu_widgets_path,
|
||||
@ -1889,8 +1877,6 @@ void menu_widgets_context_reset(bool is_threaded,
|
||||
void menu_widgets_context_destroy(void)
|
||||
{
|
||||
int i;
|
||||
if (!menu_widgets_inited)
|
||||
return;
|
||||
|
||||
/* TODO: Dismiss onscreen notifications that have been freed */
|
||||
|
||||
@ -1932,9 +1918,6 @@ void menu_widgets_free(void)
|
||||
size_t i;
|
||||
menu_animation_ctx_tag libretro_tag;
|
||||
|
||||
if (!menu_widgets_inited)
|
||||
return;
|
||||
|
||||
menu_widgets_inited = false;
|
||||
|
||||
/* Kill any pending animation */
|
||||
@ -2027,9 +2010,6 @@ bool menu_widgets_volume_update_and_show(void)
|
||||
float new_volume = settings->floats.audio_volume;
|
||||
menu_timer_ctx_entry_t entry;
|
||||
|
||||
if (!menu_widgets_inited)
|
||||
return false;
|
||||
|
||||
menu_animation_kill_by_tag(&volume_tag);
|
||||
|
||||
volume_db = new_volume;
|
||||
@ -2049,9 +2029,6 @@ bool menu_widgets_volume_update_and_show(void)
|
||||
|
||||
bool menu_widgets_set_fps_text(char *new_fps_text)
|
||||
{
|
||||
if (!menu_widgets_inited)
|
||||
return false;
|
||||
|
||||
strlcpy(menu_widgets_fps_text,
|
||||
new_fps_text, sizeof(menu_widgets_fps_text));
|
||||
|
||||
@ -2060,19 +2037,12 @@ bool menu_widgets_set_fps_text(char *new_fps_text)
|
||||
|
||||
bool menu_widgets_set_fast_forward(bool is_fast_forward)
|
||||
{
|
||||
if (!menu_widgets_inited)
|
||||
return false;
|
||||
|
||||
menu_widgets_fast_forward = is_fast_forward;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool menu_widgets_set_rewind(bool is_rewind)
|
||||
{
|
||||
if (!menu_widgets_inited)
|
||||
return false;
|
||||
|
||||
menu_widgets_rewinding = is_rewind;
|
||||
|
||||
return true;
|
||||
@ -2082,9 +2052,6 @@ static void menu_widgets_screenshot_fadeout(void *userdata)
|
||||
{
|
||||
menu_animation_ctx_entry_t entry;
|
||||
|
||||
if (!menu_widgets_inited)
|
||||
return;
|
||||
|
||||
entry.cb = NULL;
|
||||
entry.duration = SCREENSHOT_DURATION_OUT;
|
||||
entry.easing_enum = EASING_OUT_QUAD;
|
||||
@ -2100,9 +2067,6 @@ static void menu_widgets_play_screenshot_flash(void)
|
||||
{
|
||||
menu_animation_ctx_entry_t entry;
|
||||
|
||||
if (!menu_widgets_inited)
|
||||
return;
|
||||
|
||||
entry.cb = menu_widgets_screenshot_fadeout;
|
||||
entry.duration = SCREENSHOT_DURATION_IN;
|
||||
entry.easing_enum = EASING_IN_QUAD;
|
||||
@ -2116,9 +2080,6 @@ static void menu_widgets_play_screenshot_flash(void)
|
||||
|
||||
void menu_widgets_screenshot_taken(const char *shotname, const char *filename)
|
||||
{
|
||||
if (!menu_widgets_inited)
|
||||
return;
|
||||
|
||||
menu_widgets_play_screenshot_flash();
|
||||
strlcpy(screenshot_filename, filename, sizeof(screenshot_filename));
|
||||
strlcpy(screenshot_shotname, shotname, sizeof(screenshot_shotname));
|
||||
@ -2344,9 +2305,6 @@ static void menu_widgets_get_badge_texture(menu_texture_item *tex, const char *b
|
||||
|
||||
bool menu_widgets_push_achievement(const char *title, const char *badge)
|
||||
{
|
||||
if (!menu_widgets_inited)
|
||||
return false;
|
||||
|
||||
menu_widgets_achievement_free(NULL);
|
||||
|
||||
/* TODO: Make a queue of notifications to display */
|
||||
@ -2381,9 +2339,6 @@ bool menu_widgets_set_message(char *msg)
|
||||
menu_animation_ctx_tag tag = (uintptr_t) &generic_message_timer;
|
||||
menu_timer_ctx_entry_t timer;
|
||||
|
||||
if (!menu_widgets_inited)
|
||||
return false;
|
||||
|
||||
snprintf(generic_message, GENERIC_MESSAGE_SIZE, "%s", msg);
|
||||
|
||||
generic_message_alpha = DEFAULT_BACKDROP;
|
||||
@ -2423,9 +2378,6 @@ bool menu_widgets_set_libretro_message(const char *msg, unsigned duration)
|
||||
menu_animation_ctx_tag tag = (uintptr_t) &libretro_message_timer;
|
||||
menu_timer_ctx_entry_t timer;
|
||||
|
||||
if (!menu_widgets_inited)
|
||||
return false;
|
||||
|
||||
snprintf(libretro_message, LIBRETRO_MESSAGE_SIZE, "%s", msg);
|
||||
|
||||
libretro_message_alpha = DEFAULT_BACKDROP;
|
||||
|
@ -37,7 +37,7 @@
|
||||
#define HOURGLASS_DURATION 1000
|
||||
#define GENERIC_MESSAGE_DURATION 3000
|
||||
|
||||
void menu_widgets_init(bool video_is_threaded);
|
||||
bool menu_widgets_init(bool video_is_threaded);
|
||||
void menu_widgets_free(void);
|
||||
bool menu_widgets_ready(void);
|
||||
|
||||
|
60
retroarch.c
60
retroarch.c
@ -2182,7 +2182,7 @@ bool command_set_shader(const char *arg)
|
||||
snprintf(msg, sizeof(msg),
|
||||
"Shader: \"%s\"", arg ? path_basename(arg) : "null");
|
||||
#ifdef HAVE_MENU_WIDGETS
|
||||
if (!menu_widgets_set_message(msg))
|
||||
if (!menu_widgets_ready() || !menu_widgets_set_message(msg))
|
||||
#endif
|
||||
runloop_msg_queue_push(msg, 1, 120, true, NULL,
|
||||
MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
||||
@ -2846,7 +2846,7 @@ static void command_event_set_volume(float gain)
|
||||
new_volume);
|
||||
|
||||
#if defined(HAVE_MENU) && defined(HAVE_MENU_WIDGETS)
|
||||
if (!menu_widgets_volume_update_and_show())
|
||||
if (!menu_widgets_ready() || !menu_widgets_volume_update_and_show())
|
||||
#endif
|
||||
runloop_msg_queue_push(msg, 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
||||
|
||||
@ -3752,7 +3752,7 @@ static void retroarch_pause_checks(void)
|
||||
command_event(CMD_EVENT_AUDIO_STOP, NULL);
|
||||
|
||||
#if defined(HAVE_MENU) && defined(HAVE_MENU_WIDGETS)
|
||||
if (!menu_widgets_set_paused(is_paused))
|
||||
if (!menu_widgets_ready() || !menu_widgets_set_paused(is_paused))
|
||||
#endif
|
||||
runloop_msg_queue_push(msg_hash_to_str(MSG_PAUSED), 1,
|
||||
1, true,
|
||||
@ -3769,7 +3769,8 @@ static void retroarch_pause_checks(void)
|
||||
else
|
||||
{
|
||||
#if defined(HAVE_MENU) && defined(HAVE_MENU_WIDGETS)
|
||||
menu_widgets_set_paused(is_paused);
|
||||
if (menu_widgets_ready())
|
||||
menu_widgets_set_paused(is_paused);
|
||||
#endif
|
||||
RARCH_LOG("%s\n", msg_hash_to_str(MSG_UNPAUSED));
|
||||
command_event(CMD_EVENT_AUDIO_START, NULL);
|
||||
@ -6703,7 +6704,7 @@ static bool rarch_environment_cb(unsigned cmd, void *data)
|
||||
const struct retro_message *msg = (const struct retro_message*)data;
|
||||
RARCH_LOG("Environ SET_MESSAGE: %s\n", msg->msg);
|
||||
#ifdef HAVE_MENU_WIDGETS
|
||||
if (!menu_widgets_set_libretro_message(msg->msg, roundf((float)msg->frames / 60.0f * 1000.0f)))
|
||||
if (!menu_widgets_ready() || !menu_widgets_set_libretro_message(msg->msg, roundf((float)msg->frames / 60.0f * 1000.0f)))
|
||||
#endif
|
||||
runloop_msg_queue_push(msg->msg, 3, msg->frames, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
||||
break;
|
||||
@ -18300,7 +18301,7 @@ void video_driver_frame(const void *data, unsigned width,
|
||||
if (video_info.fps_show || video_info.framecount_show)
|
||||
{
|
||||
#if defined(HAVE_MENU) && defined(HAVE_MENU_WIDGETS)
|
||||
if (!menu_widgets_set_fps_text(video_info.fps_text))
|
||||
if (!menu_widgets_ready() || !menu_widgets_set_fps_text(video_info.fps_text))
|
||||
#endif
|
||||
runloop_msg_queue_push(video_info.fps_text, 2, 1, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
||||
}
|
||||
@ -18454,6 +18455,12 @@ void video_driver_build_info(video_frame_info_t *video_info)
|
||||
|
||||
video_info->fps_text[0] = '\0';
|
||||
|
||||
#ifdef HAVE_MENU_WIDGETS
|
||||
video_info->widgets_inited = menu_widgets_ready();
|
||||
#else
|
||||
video_info->widgets_inited = false;
|
||||
#endif
|
||||
|
||||
video_info->width = video_driver_width;
|
||||
video_info->height = video_driver_height;
|
||||
|
||||
@ -19801,9 +19808,22 @@ static void drivers_init(int flags)
|
||||
if (settings->bools.menu_enable_widgets
|
||||
&& video_driver_has_widgets())
|
||||
{
|
||||
menu_widgets_init(video_is_threaded);
|
||||
menu_widgets_context_reset(video_is_threaded,
|
||||
video_driver_width, video_driver_height);
|
||||
/* TODO/FIXME - get rid of this local variable
|
||||
* once we have moved it over */
|
||||
bool widgets_inited = menu_widgets_ready();
|
||||
|
||||
if (!widgets_inited)
|
||||
{
|
||||
if (menu_widgets_init(video_is_threaded))
|
||||
{
|
||||
/* TODO/FIXME - set menu_widgets_inited to true here */
|
||||
}
|
||||
}
|
||||
|
||||
widgets_inited = menu_widgets_ready();
|
||||
if (widgets_inited)
|
||||
menu_widgets_context_reset(video_is_threaded,
|
||||
video_driver_width, video_driver_height);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -19861,8 +19881,11 @@ static void driver_uninit(int flags)
|
||||
/* This absolutely has to be done before video_driver_free()
|
||||
* is called/completes, otherwise certain menu drivers
|
||||
* (e.g. Vulkan) will segfault */
|
||||
menu_widgets_context_destroy();
|
||||
menu_widgets_free();
|
||||
if (menu_widgets_ready())
|
||||
{
|
||||
menu_widgets_context_destroy();
|
||||
menu_widgets_free();
|
||||
}
|
||||
#endif
|
||||
menu_driver_ctl(RARCH_MENU_CTL_DEINIT, NULL);
|
||||
}
|
||||
@ -19929,8 +19952,11 @@ bool driver_ctl(enum driver_ctl_state state, void *data)
|
||||
* in case the handle is lost in the threaded
|
||||
* video driver in the meantime
|
||||
* (breaking video_driver_has_widgets) */
|
||||
menu_widgets_context_destroy();
|
||||
menu_widgets_free();
|
||||
if (menu_widgets_ready())
|
||||
{
|
||||
menu_widgets_context_destroy();
|
||||
menu_widgets_free();
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Video */
|
||||
@ -23149,7 +23175,7 @@ static void update_fastforwarding_state(void)
|
||||
if (runloop_fastmotion)
|
||||
{
|
||||
#if defined(HAVE_MENU) && defined(HAVE_MENU_WIDGETS)
|
||||
if (!menu_widgets_set_fast_forward(true))
|
||||
if (!menu_widgets_ready() || !menu_widgets_set_fast_forward(true))
|
||||
#endif
|
||||
runloop_msg_queue_push(
|
||||
msg_hash_to_str(MSG_FAST_FORWARD), 1, 1, false, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
||||
@ -23157,7 +23183,8 @@ static void update_fastforwarding_state(void)
|
||||
#if defined(HAVE_MENU) && defined(HAVE_MENU_WIDGETS)
|
||||
else
|
||||
{
|
||||
menu_widgets_set_fast_forward(false);
|
||||
if (menu_widgets_ready())
|
||||
menu_widgets_set_fast_forward(false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -23859,7 +23886,8 @@ static enum runloop_state runloop_check_state(void)
|
||||
MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
||||
|
||||
#if defined(HAVE_MENU) && defined(HAVE_MENU_WIDGETS)
|
||||
menu_widgets_set_rewind(rewinding);
|
||||
if (menu_widgets_ready())
|
||||
menu_widgets_set_rewind(rewinding);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1122,6 +1122,7 @@ typedef struct video_info
|
||||
|
||||
typedef struct video_frame_info
|
||||
{
|
||||
bool widgets_inited;
|
||||
bool input_menu_swap_ok_cancel_buttons;
|
||||
bool input_driver_nonblock_state;
|
||||
bool shared_context;
|
||||
|
@ -204,7 +204,7 @@ static void task_screenshot_callback(retro_task_t *task,
|
||||
if (!state->widgets_ready)
|
||||
return;
|
||||
|
||||
if (state && !state->silence)
|
||||
if (state && !state->silence && state->widgets_ready)
|
||||
menu_widgets_screenshot_taken(state->shotname, state->filename);
|
||||
|
||||
free(state);
|
||||
|
Loading…
Reference in New Issue
Block a user