From 7022786f3439e8b003acb20bad7c384f0f017ff9 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 8 Feb 2019 07:26:43 +0100 Subject: [PATCH] Revert parts of menu_widgets that were causing breakage, but leave all the hooks in so we can add them back piece by piece again --- audio/audio_driver.c | 2 +- cheevos/cheevos.c | 3 +- command.c | 27 +- discord/discord.c | 2 +- driver.c | 19 - gfx/video_driver.c | 11 +- input/input_overlay.c | 4 +- input/input_overlay.h | 3 +- libretro-common/include/queues/task_queue.h | 9 +- libretro-common/queues/task_queue.c | 14 +- menu/cbs/menu_cbs_ok.c | 17 +- menu/cbs/menu_cbs_scan.c | 2 +- menu/drivers/materialui.c | 12 +- menu/drivers/menu_generic.c | 12 - menu/drivers/ozone/ozone.c | 35 +- menu/drivers/ozone/ozone.h | 6 +- menu/drivers/ozone/ozone_display.c | 3 + menu/drivers/ozone/ozone_entries.c | 16 +- menu/drivers/ozone/ozone_sidebar.c | 4 +- menu/drivers/ozone/ozone_theme.h | 4 - menu/drivers/rgui.c | 21 +- menu/drivers/stripes.c | 12 +- menu/drivers/xmb.c | 39 +- menu/drivers/xui.cpp | 2 +- menu/menu_animation.c | 38 +- menu/menu_animation.h | 12 +- menu/menu_cbs.h | 2 +- menu/menu_displaylist.c | 2 +- menu/menu_driver.c | 32 +- menu/menu_driver.h | 14 +- menu/menu_input.c | 8 +- menu/menu_networking.c | 4 +- menu/menu_networking.h | 5 +- menu/widgets/menu_widgets.c | 2048 ------------------- menu/widgets/menu_widgets.h | 55 - network/netplay/netplay_frontend.c | 3 +- retroarch.c | 78 +- retroarch.h | 2 +- tasks/task_audio_mixer.c | 23 +- tasks/task_content.c | 82 - tasks/task_content.h | 3 - tasks/task_database.c | 2 +- tasks/task_decompress.c | 2 +- tasks/task_powerstate.c | 2 +- tasks/task_save.c | 10 +- tasks/task_screenshot.c | 19 - ui/drivers/qt/thumbnailpackdownload.cpp | 3 +- ui/drivers/qt/ui_qt_window.cpp | 3 +- ui/drivers/qt/updateretroarch.cpp | 3 +- 49 files changed, 187 insertions(+), 2547 deletions(-) diff --git a/audio/audio_driver.c b/audio/audio_driver.c index 7f1b331a34..b1746ebacc 100644 --- a/audio/audio_driver.c +++ b/audio/audio_driver.c @@ -1406,7 +1406,7 @@ static void audio_driver_mixer_play_stream_internal(unsigned i, unsigned type) audio_mixer_streams[i].state = (enum audio_mixer_state)type; } -static void audio_driver_load_menu_bgm_callback(retro_task_t *task, void *task_data, void *user_data, const char *error) +static void audio_driver_load_menu_bgm_callback(void *task_data, void *user_data, const char *error) { bool contentless = false; bool is_inited = false; diff --git a/cheevos/cheevos.c b/cheevos/cheevos.c index bfdd4b030e..4b5e4267ba 100644 --- a/cheevos/cheevos.c +++ b/cheevos/cheevos.c @@ -28,7 +28,6 @@ #include #include #include -#include #ifdef HAVE_CONFIG_H #include "../config.h" @@ -1590,7 +1589,7 @@ static void cheevos_make_unlock_url(const cheevo_t *cheevo, #endif } -static void cheevos_unlocked(retro_task_t *task, void *task_data, void *user_data, +static void cheevos_unlocked(void *task_data, void *user_data, const char *error) { cheevo_t *cheevo = (cheevo_t *)user_data; diff --git a/command.c b/command.c index c0344318a5..5ca0b21b9e 100644 --- a/command.c +++ b/command.c @@ -59,9 +59,6 @@ #include "menu/menu_content.h" #include "menu/menu_shader.h" #include "menu/widgets/menu_dialog.h" -#ifdef HAVE_MENU_WIDGETS -#include "menu/widgets/menu_widgets.h" -#endif #endif #ifdef HAVE_NETWORKING @@ -1000,10 +997,7 @@ static void command_event_set_volume(float gain) msg_hash_to_str(MSG_AUDIO_VOLUME), new_volume); -#if defined(HAVE_MENU) && defined(HAVE_MENU_WIDGETS) - if (!video_driver_has_widgets() || !menu_widgets_volume_update_and_show()) -#endif - runloop_msg_queue_push(msg, 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); + runloop_msg_queue_push(msg, 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); RARCH_LOG("%s\n", msg); @@ -2131,10 +2125,7 @@ TODO: Add a setting for these tweaks */ return false; } -#if defined(HAVE_MENU) && defined(HAVE_MENU_WIDGETS) - if (!video_driver_has_widgets() || !menu_widgets_volume_update_and_show()) -#endif - runloop_msg_queue_push(msg, 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); + runloop_msg_queue_push(msg, 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); RARCH_LOG("%s\n", msg); } @@ -2504,12 +2495,9 @@ TODO: Add a setting for these tweaks */ RARCH_LOG("%s\n", msg_hash_to_str(MSG_PAUSED)); command_event(CMD_EVENT_AUDIO_STOP, NULL); -#if defined(HAVE_MENU) && defined(HAVE_MENU_WIDGETS) - if (!video_driver_has_widgets() || !menu_widgets_set_paused(is_paused)) -#endif - runloop_msg_queue_push(msg_hash_to_str(MSG_PAUSED), 1, - 1, true, - NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); + runloop_msg_queue_push(msg_hash_to_str(MSG_PAUSED), 1, + 1, true, + NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); if (!is_idle) video_driver_cached_frame(); @@ -2523,11 +2511,6 @@ TODO: Add a setting for these tweaks */ } else { -#if defined(HAVE_MENU) && defined(HAVE_MENU_WIDGETS) - if (video_driver_has_widgets()) - menu_widgets_set_paused(is_paused); -#endif - RARCH_LOG("%s\n", msg_hash_to_str(MSG_UNPAUSED)); command_event(CMD_EVENT_AUDIO_START, NULL); } diff --git a/discord/discord.c b/discord/discord.c index 88a9651a02..0043438e41 100644 --- a/discord/discord.c +++ b/discord/discord.c @@ -182,7 +182,7 @@ static void handle_discord_error(int errcode, const char* message) RARCH_LOG("[discord] error (%d: %s)\n", errcode, message); } -static void handle_discord_join_cb(retro_task_t *task, void *task_data, void *user_data, const char *err) +static void handle_discord_join_cb(void *task_data, void *user_data, const char *err) { struct netplay_room *room; char join_hostname[PATH_MAX_LENGTH]; diff --git a/driver.c b/driver.c index a551074d34..9cc25e40aa 100644 --- a/driver.c +++ b/driver.c @@ -26,9 +26,6 @@ #ifdef HAVE_MENU #include "menu/menu_driver.h" -#ifdef HAVE_MENU_WIDGETS -#include "menu/widgets/menu_widgets.h" -#endif #endif #include "dynamic.h" @@ -388,13 +385,6 @@ void drivers_init(int flags) core_info_init_current_core(); #ifdef HAVE_MENU -#ifdef HAVE_MENU_WIDGETS - if (video_driver_has_widgets()) - { - menu_widgets_init(video_is_threaded); - menu_widgets_context_reset(video_is_threaded); - } -#endif if (flags & DRIVER_VIDEO_MASK) { @@ -496,15 +486,6 @@ bool driver_ctl(enum driver_ctl_state state, void *data) switch (state) { case RARCH_DRIVER_CTL_DEINIT: -#if defined(HAVE_MENU) && defined(HAVE_MENU_WIDGETS) - /* Tear down menu widgets no matter what - * 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(); - -#endif video_driver_destroy(); audio_driver_destroy(); input_driver_destroy(); diff --git a/gfx/video_driver.c b/gfx/video_driver.c index fff35f6fcb..9d7e308a0b 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -33,7 +33,6 @@ #include "../audio/audio_driver.h" #include "../menu/menu_shader.h" -#include "../menu/menu_animation.h" #ifdef HAVE_CONFIG_H #include "../config.h" @@ -48,9 +47,6 @@ #ifdef HAVE_MENU #include "../menu/menu_driver.h" #include "../menu/menu_setting.h" -#ifdef HAVE_MENU_WIDGETS -#include "../menu/widgets/menu_widgets.h" -#endif #endif #include "video_thread_wrapper.h" @@ -2653,10 +2649,7 @@ void video_driver_frame(const void *data, unsigned width, /* Display the FPS, with a higher priority. */ if (video_info.fps_show || video_info.framecount_show) -#if defined(HAVE_MENU) && defined(HAVE_MENU_WIDGETS) - if (!video_driver_has_widgets() || !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); + runloop_msg_queue_push(video_info.fps_text, 2, 1, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); /* trigger set resolution*/ if (video_info.crt_switch_resolution) @@ -3582,4 +3575,4 @@ bool video_driver_has_widgets(void) return current_video && current_video->menu_widgets_enabled && current_video->menu_widgets_enabled(video_driver_data); } -#endif \ No newline at end of file +#endif diff --git a/input/input_overlay.c b/input/input_overlay.c index 645fd806f9..fcf39cff5b 100644 --- a/input/input_overlay.c +++ b/input/input_overlay.c @@ -34,8 +34,6 @@ #include "../gfx/video_driver.h" #include "input_overlay.h" -#include - #define OVERLAY_GET_KEY(state, key) (((state)->keys[(key) / 32] >> ((key) % 32)) & 1) #define OVERLAY_SET_KEY(state, key) (state)->keys[(key) / 32] |= 1 << ((key) % 32) @@ -597,7 +595,7 @@ void input_overlay_free(input_overlay_t *ol) } /* task_data = overlay_task_data_t* */ -void input_overlay_loaded(retro_task_t *task, void *task_data, void *user_data, const char *err) +void input_overlay_loaded(void *task_data, void *user_data, const char *err) { size_t i; overlay_task_data_t *data = (overlay_task_data_t*)task_data; diff --git a/input/input_overlay.h b/input/input_overlay.h index 907612dc5f..ed70af4cd6 100644 --- a/input/input_overlay.h +++ b/input/input_overlay.h @@ -23,7 +23,6 @@ #include #include #include -#include #include "input_driver.h" @@ -257,7 +256,7 @@ bool input_overlay_key_pressed(input_overlay_t *ol, unsigned key); bool input_overlay_is_alive(input_overlay_t *ol); -void input_overlay_loaded(retro_task_t *task, void *task_data, void *user_data, const char *err); +void input_overlay_loaded(void *task_data, void *user_data, const char *err); void input_overlay_set_visibility(int overlay_idx,enum overlay_visibility vis); diff --git a/libretro-common/include/queues/task_queue.h b/libretro-common/include/queues/task_queue.h index 6acbb86df9..7e48626e73 100644 --- a/libretro-common/include/queues/task_queue.h +++ b/libretro-common/include/queues/task_queue.h @@ -43,16 +43,15 @@ enum task_type }; typedef struct retro_task retro_task_t; -typedef void (*retro_task_callback_t)(retro_task_t *task, - void *task_data, void *user_data, - const char *error); +typedef void (*retro_task_callback_t)(void *task_data, + void *user_data, const char *error); typedef void (*retro_task_handler_t)(retro_task_t *task); typedef bool (*retro_task_finder_t)(retro_task_t *task, void *userdata); -typedef void (*retro_task_queue_msg_t)(retro_task_t *task, const char *msg, +typedef void (*retro_task_queue_msg_t)(const char *msg, unsigned prio, unsigned duration, bool flush); typedef bool (*retro_task_retriever_t)(retro_task_t *task, void *data); @@ -239,7 +238,7 @@ void task_queue_deinit(void); * This must only be called from the main thread. */ void task_queue_init(bool threaded, retro_task_queue_msg_t msg_push); -/* Allocs and inits a new retro_task_t */ +/* Allocates and inits a new retro_task_t */ retro_task_t *task_init(void); RETRO_END_DECLS diff --git a/libretro-common/queues/task_queue.c b/libretro-common/queues/task_queue.c index 3071104307..e4b41ee92a 100644 --- a/libretro-common/queues/task_queue.c +++ b/libretro-common/queues/task_queue.c @@ -62,7 +62,7 @@ static task_queue_t tasks_finished = {NULL, NULL}; static struct retro_task_impl *impl_current = NULL; static bool task_threaded_enable = false; -static uint32_t task_count = 0; +static uint32_t task_count = 0; static void task_queue_msg_push(retro_task_t *task, unsigned prio, unsigned duration, @@ -78,7 +78,7 @@ static void task_queue_msg_push(retro_task_t *task, va_end(ap); if (impl_current->msg_push) - impl_current->msg_push(task, buf, prio, duration, flush); + impl_current->msg_push(buf, prio, duration, flush); } static void task_queue_push_progress(retro_task_t *task) @@ -140,7 +140,7 @@ static void retro_task_internal_gather(void) task_queue_push_progress(task); if (task->callback) - task->callback(task, task->task_data, task->user_data, task->error); + task->callback(task->task_data, task->user_data, task->error); if (task->cleanup) task->cleanup(task); @@ -823,17 +823,17 @@ char* task_get_title(retro_task_t *task) return title; } -static uint32_t task_get_next_ident() +static uint32_t task_get_next_ident(void) { return task_count++; } -retro_task_t *task_init() +retro_task_t *task_init(void) { - retro_task_t *task = (retro_task_t*)calloc(1, sizeof(*task)); + retro_task_t *task = (retro_task_t*)calloc(1, sizeof(*task)); task->ident = task_get_next_ident(); task->frontend_userdata = NULL; return task; -} \ No newline at end of file +} diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index ed46de3e66..0aba900e89 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -1082,7 +1082,7 @@ static bool menu_content_find_first_core(menu_content_ctx_defer_info_t *def_info } #ifdef HAVE_LIBRETRODB -void handle_dbscan_finished(retro_task_t *task, void *task_data, void *user_data, const char *err); +void handle_dbscan_finished(void *task_data, void *user_data, const char *err); #endif static void content_add_to_playlist(const char *path) @@ -3259,7 +3259,7 @@ static int action_ok_undo_save_state(const char *path, #ifdef HAVE_NETWORKING #ifdef HAVE_ZLIB -static void cb_decompressed(retro_task_t *task, void *task_data, void *user_data, const char *err) +static void cb_decompressed(void *task_data, void *user_data, const char *err) { decompress_task_data_t *dec = (decompress_task_data_t*)task_data; @@ -3392,7 +3392,7 @@ default_action_ok_list(action_ok_core_updater_list, MENU_ENUM_LABEL_CB_CORE_UPDA default_action_ok_list(action_ok_thumbnails_updater_list, MENU_ENUM_LABEL_CB_THUMBNAILS_UPDATER_LIST) default_action_ok_list(action_ok_lakka_list, MENU_ENUM_LABEL_CB_LAKKA_LIST) -static void cb_generic_dir_download(retro_task_t *task, void *task_data, +static void cb_generic_dir_download(void *task_data, void *user_data, const char *err) { file_transfer_t *transf = (file_transfer_t*)user_data; @@ -3406,7 +3406,7 @@ static void cb_generic_dir_download(retro_task_t *task, void *task_data, } /* expects http_transfer_t*, file_transfer_t* */ -void cb_generic_download(retro_task_t *task, void *task_data, +void cb_generic_download(void *task_data, void *user_data, const char *err) { char output_path[PATH_MAX_LENGTH]; @@ -3541,14 +3541,11 @@ void cb_generic_download(retro_task_t *task, void *task_data, if (path_is_compressed_file(output_path)) { - void *frontend_userdata = task->frontend_userdata; - task->frontend_userdata = NULL; - if (!task_push_decompress(output_path, dir_path, NULL, NULL, NULL, cb_decompressed, (void*)(uintptr_t) msg_hash_calculate(msg_hash_to_str(transf->enum_idx)), - frontend_userdata)) + NULL)) { err = msg_hash_to_str(MSG_DECOMPRESSION_FAILED); goto finish; @@ -4278,7 +4275,7 @@ void netplay_refresh_rooms_menu(file_list_t *list) #define INET6_ADDRSTRLEN 46 #endif -static void netplay_refresh_rooms_cb(retro_task_t *task, void *task_data, void *user_data, const char *err) +static void netplay_refresh_rooms_cb(void *task_data, void *user_data, const char *err) { char *new_data = NULL; const char *path = NULL; @@ -4405,7 +4402,7 @@ finish: } -static void netplay_lan_scan_callback(retro_task_t *task, void *task_data, +static void netplay_lan_scan_callback(void *task_data, void *user_data, const char *error) { struct netplay_host_list *netplay_hosts = NULL; diff --git a/menu/cbs/menu_cbs_scan.c b/menu/cbs/menu_cbs_scan.c index 059778ed96..6f1490a90e 100644 --- a/menu/cbs/menu_cbs_scan.c +++ b/menu/cbs/menu_cbs_scan.c @@ -37,7 +37,7 @@ #endif #ifdef HAVE_LIBRETRODB -void handle_dbscan_finished(retro_task_t *task, void *task_data, void *user_data, const char *err) +void handle_dbscan_finished(void *task_data, void *user_data, const char *err) { menu_ctx_environment_t menu_environ; menu_environ.type = MENU_ENVIRON_RESET_HORIZONTAL_LIST; diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index 534292d607..e274c95ab5 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -641,6 +641,7 @@ static void materialui_compute_entries_box(materialui_handle_t* mui, int width) with acceleration */ static void materialui_render(void *data, bool is_idle) { + menu_animation_ctx_delta_t delta; unsigned bottom, width, height, header_height; size_t i = 0; materialui_handle_t *mui = (materialui_handle_t*)data; @@ -659,6 +660,11 @@ static void materialui_render(void *data, bool is_idle) mui->need_compute = false; } + delta.current = menu_animation_get_delta_time(); + + if (menu_animation_get_ideal_delta_time(&delta)) + menu_animation_update(delta.ideal); + menu_display_set_width(width); menu_display_set_height(height); header_height = menu_display_get_header_height(); @@ -1519,7 +1525,7 @@ static void materialui_frame(void *data, video_frame_info_t *video_info) ticker.s = title_buf; ticker.len = ticker_limit; - ticker.idx = menu_animation_get_ticker_time() / 5.0f; + ticker.idx = mui->frame_count / 100; ticker.str = title; ticker.selected = true; @@ -1541,7 +1547,7 @@ static void materialui_frame(void *data, video_frame_info_t *video_info) ticker.s = title_buf_msg_tmp; ticker.len = ticker_limit; - ticker.idx = menu_animation_get_ticker_time(); + ticker.idx = mui->frame_count / 20; ticker.str = title_buf_msg; ticker.selected = true; @@ -1795,7 +1801,7 @@ static void materialui_navigation_set(void *data, bool scroll) if (!mui || !scroll) return; - entry.duration = 166; + entry.duration = 10; entry.target_value = scroll_pos; entry.subject = &mui->scroll_y; entry.easing_enum = EASING_IN_OUT_QUAD; diff --git a/menu/drivers/menu_generic.c b/menu/drivers/menu_generic.c index bb9745621d..f263ea16ad 100644 --- a/menu/drivers/menu_generic.c +++ b/menu/drivers/menu_generic.c @@ -29,8 +29,6 @@ #include "../../content.h" #include "../../retroarch.h" -#include "../../tasks/task_content.h" - static enum action_iterate_type action_iterate_type(const char *label) { if (string_is_equal(label, "info_screen")) @@ -78,16 +76,6 @@ int generic_menu_iterate(menu_handle_t *menu, void *userdata, enum menu_action a if (!menu) return 0; -#if defined(HAVE_MENU) && defined(HAVE_MENU_WIDGETS) - if (task_load_content_is_pending()) - { - if (task_load_content_should_resume()) - action = MENU_ACTION_OK; - else - return 0; - } -#endif - menu_entries_get_last_stack(NULL, &label, &file_type, &enum_idx, NULL); menu->menu_state_msg[0] = '\0'; diff --git a/menu/drivers/ozone/ozone.c b/menu/drivers/ozone/ozone.c index 0ed940eee4..d7ce363818 100644 --- a/menu/drivers/ozone/ozone.c +++ b/menu/drivers/ozone/ozone.c @@ -932,6 +932,7 @@ static void ozone_compute_entries_position(ozone_handle_t *ozone) static void ozone_render(void *data, bool is_idle) { size_t i; + menu_animation_ctx_delta_t delta; unsigned end = (unsigned)menu_entries_get_size(); ozone_handle_t *ozone = (ozone_handle_t*)data; if (!data) @@ -945,6 +946,11 @@ static void ozone_render(void *data, bool is_idle) ozone->selection = menu_navigation_get_selection(); + delta.current = menu_animation_get_delta_time(); + + if (menu_animation_get_ideal_delta_time(&delta)) + menu_animation_update(delta.ideal); + /* TODO Handle pointer & mouse */ menu_entries_ctl(MENU_ENTRIES_CTL_START_GET, &i); @@ -971,7 +977,7 @@ static void ozone_draw_header(ozone_handle_t *ozone, video_frame_info_t *video_i /* Title */ ticker.s = title; ticker.len = (video_info->width - 128 - 47 - 130) / ozone->title_font_glyph_width; - ticker.idx = menu_animation_get_ticker_time(); + ticker.idx = ozone->frame_count / 20; ticker.str = ozone->title; ticker.selected = true; @@ -1848,28 +1854,6 @@ static int ozone_list_bind_init(menu_file_list_cbs_t *cbs, return -1; } -#ifdef HAVE_MENU_WIDGETS -static bool ozone_get_load_content_animation_data(void *userdata, menu_texture_item *icon, char **playlist_name) -{ - ozone_handle_t *ozone = (ozone_handle_t*) userdata; - - if (ozone->categories_selection_ptr > ozone->system_tab_end) - { - ozone_node_t *node = file_list_get_userdata_at_offset(ozone->horizontal_list, ozone->categories_selection_ptr - ozone->system_tab_end-1); - - *icon = node->icon; - *playlist_name = node->console_name; - } - else - { - *icon = ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_QUICKMENU]; - *playlist_name = "RetroArch"; - } - - return true; -} -#endif - menu_ctx_driver_t menu_ctx_ozone = { NULL, /* set_texture */ ozone_messagebox, @@ -1913,8 +1897,5 @@ menu_ctx_driver_t menu_ctx_ozone = { NULL, /* update_savestate_thumbnail_path */ NULL, /* update_savestate_thumbnail_image */ NULL, - NULL, -#ifdef HAVE_MENU_WIDGETS - ozone_get_load_content_animation_data -#endif + NULL }; diff --git a/menu/drivers/ozone/ozone.h b/menu/drivers/ozone/ozone.h index 833719497b..911d8f1c01 100644 --- a/menu/drivers/ozone/ozone.h +++ b/menu/drivers/ozone/ozone.h @@ -33,9 +33,9 @@ typedef struct ozone_handle ozone_handle_t; #define FONT_SIZE_ENTRIES_SUBLABEL 18 #define FONT_SIZE_SIDEBAR 24 -#define ANIMATION_PUSH_ENTRY_DURATION 166 -#define ANIMATION_CURSOR_DURATION 133 -#define ANIMATION_CURSOR_PULSE 500 +#define ANIMATION_PUSH_ENTRY_DURATION 10 +#define ANIMATION_CURSOR_DURATION 8 +#define ANIMATION_CURSOR_PULSE 30 #define ENTRIES_START_Y 127 diff --git a/menu/drivers/ozone/ozone_display.c b/menu/drivers/ozone/ozone_display.c index c302cbe369..ca6eb2b950 100644 --- a/menu/drivers/ozone/ozone_display.c +++ b/menu/drivers/ozone/ozone_display.c @@ -107,6 +107,9 @@ void ozone_draw_text( uint32_t color, bool draw_outside) { + if ((color & 0x000000FF) == 0) + return; + menu_display_draw_text(font, str, x, y, width, height, color, text_align, 1.0f, false, diff --git a/menu/drivers/ozone/ozone_entries.c b/menu/drivers/ozone/ozone_entries.c index b1a3c45e0c..4d09e6d3cf 100644 --- a/menu/drivers/ozone/ozone_entries.c +++ b/menu/drivers/ozone/ozone_entries.c @@ -227,11 +227,11 @@ border_iterate: /* Prepare text */ entry_rich_label = menu_entry_get_rich_label(&entry); - ticker.idx = menu_animation_get_ticker_time(); - ticker.s = rich_label; - ticker.str = entry_rich_label; + ticker.idx = ozone->frame_count / 20; + ticker.s = rich_label; + ticker.str = entry_rich_label; ticker.selected = entry_selected && !ozone->cursor_in_sidebar; - ticker.len = (entry_width - 60 - text_offset) / ozone->entry_font_glyph_width; + ticker.len = (entry_width - 60 - text_offset) / ozone->entry_font_glyph_width; menu_animation_ticker(&ticker); @@ -295,11 +295,11 @@ border_iterate: ozone_draw_text(video_info, ozone, sublabel_str, x_offset + 470, y + FONT_SIZE_ENTRIES_SUBLABEL + 80 - 20 - 3 + scroll_y, TEXT_ALIGN_LEFT, video_info->width, video_info->height, ozone->fonts.entries_sublabel, COLOR_TEXT_ALPHA(ozone->theme->text_sublabel_rgba, alpha_uint32), false); /* Value */ - ticker.idx = menu_animation_get_ticker_time(); - ticker.s = entry_value_ticker; - ticker.str = entry_value; + ticker.idx = ozone->frame_count / 20; + ticker.s = entry_value_ticker; + ticker.str = entry_value; ticker.selected = entry_selected && !ozone->cursor_in_sidebar; - ticker.len = (entry_width - 60 - ((int)utf8len(entry_rich_label) * ozone->entry_font_glyph_width)) / ozone->entry_font_glyph_width; + ticker.len = (entry_width - 60 - ((int)utf8len(entry_rich_label) * ozone->entry_font_glyph_width)) / ozone->entry_font_glyph_width; menu_animation_ticker(&ticker); diff --git a/menu/drivers/ozone/ozone_sidebar.c b/menu/drivers/ozone/ozone_sidebar.c index fddaaaa9a8..ff368adc84 100644 --- a/menu/drivers/ozone/ozone_sidebar.c +++ b/menu/drivers/ozone/ozone_sidebar.c @@ -206,10 +206,10 @@ void ozone_draw_sidebar(ozone_handle_t *ozone, video_frame_info_t *video_info) goto console_iterate; /* Icon */ - ozone_draw_icon(video_info, 46, 46, node->icon, ozone->sidebar_offset + 41 + 10 - 3, y - 5 - 3 + ozone->animations.scroll_y_sidebar, video_info->width, video_info->height, 0, 1, (selected ? ozone->theme->text_selected : ozone->theme->entries_icon)); + ozone_draw_icon(video_info, 40, 40, node->icon, ozone->sidebar_offset + 41 + 10 - 3, y - 5 - 3 + ozone->animations.scroll_y_sidebar, video_info->width, video_info->height, 0, 1, (selected ? ozone->theme->text_selected : ozone->theme->entries_icon)); /* Text */ - ticker.idx = menu_animation_get_ticker_time(); + ticker.idx = ozone->frame_count / 20; ticker.len = 19; ticker.s = console_title; ticker.selected = selected; diff --git a/menu/drivers/ozone/ozone_theme.h b/menu/drivers/ozone/ozone_theme.h index bb4c53c54a..9b34d6fd89 100644 --- a/menu/drivers/ozone/ozone_theme.h +++ b/menu/drivers/ozone/ozone_theme.h @@ -20,10 +20,6 @@ #include "ozone.h" #include "ozone_texture.h" -#ifdef HAVE_MENU_WIDGETS -#include "../../widgets/menu_widgets.h" -#endif - #include "../../../retroarch.h" static float ozone_pure_white[16] = { diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index a0a2702642..b4ebb92daf 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -1585,11 +1585,10 @@ static void rgui_render(void *data, bool is_idle) /* Format thumbnail title */ ticker.s = thumbnail_title_buf; ticker.len = RGUI_TERM_WIDTH(fb_width) - 10; - ticker.idx = menu_animation_get_ticker_time(); + ticker.idx = frame_count / RGUI_TERM_START_X(fb_width); ticker.str = rgui->thumbnail_content; ticker.selected = true; - if (menu_animation_ticker(&ticker)) - rgui->force_redraw = true; + menu_animation_ticker(&ticker); title_width = utf8len(thumbnail_title_buf) * FONT_WIDTH_STRIDE; title_x = RGUI_TERM_START_X(fb_width) + ((RGUI_TERM_WIDTH(fb_width) * FONT_WIDTH_STRIDE) - title_width) / 2; @@ -1620,12 +1619,11 @@ static void rgui_render(void *data, bool is_idle) ticker.s = title_buf; ticker.len = RGUI_TERM_WIDTH(fb_width) - 10; - ticker.idx = menu_animation_get_ticker_time(); + ticker.idx = frame_count / RGUI_TERM_START_X(fb_width);; ticker.str = title; ticker.selected = true; - if (menu_animation_ticker(&ticker)) - rgui->force_redraw = true; + menu_animation_ticker(&ticker); string_to_upper(title_buf); @@ -1645,8 +1643,7 @@ static void rgui_render(void *data, bool is_idle) ticker.str = core_title; ticker.selected = true; - if (menu_animation_ticker(&ticker)) - rgui->force_redraw = true; + menu_animation_ticker(&ticker); if (rgui_framebuf_data) blit_line( @@ -1712,19 +1709,17 @@ static void rgui_render(void *data, bool is_idle) ticker.s = entry_title_buf; ticker.len = RGUI_TERM_WIDTH(fb_width) - (entry_spacing + 1 + 2); - ticker.idx = menu_animation_get_ticker_time(); + ticker.idx = frame_count / RGUI_TERM_START_X(fb_width); ticker.str = entry_path; ticker.selected = entry_selected; - if (menu_animation_ticker(&ticker)) - rgui->force_redraw = true; + menu_animation_ticker(&ticker); ticker.s = type_str_buf; ticker.len = entry_spacing; ticker.str = entry_value; - if (menu_animation_ticker(&ticker)) - rgui->force_redraw = true; + menu_animation_ticker(&ticker); entry_title_buf_utf8len = utf8len(entry_title_buf); entry_title_buf_len = strlen(entry_title_buf); diff --git a/menu/drivers/stripes.c b/menu/drivers/stripes.c index a72a4db822..2b6689ac85 100644 --- a/menu/drivers/stripes.c +++ b/menu/drivers/stripes.c @@ -69,7 +69,7 @@ #define STRIPES_RIBBON_VERTICES 2*STRIPES_RIBBON_COLS*STRIPES_RIBBON_ROWS-2*STRIPES_RIBBON_COLS #ifndef STRIPES_DELAY -#define STRIPES_DELAY 166 +#define STRIPES_DELAY 10 #endif #define BATTERY_LEVEL_CHECK_INTERVAL (30 * 1000000) @@ -2450,7 +2450,7 @@ static int stripes_draw_item( ticker.s = tmp; ticker.len = ticker_limit; - ticker.idx = menu_animation_get_ticker_time(); + ticker.idx = frame_count / 20; ticker.str = ticker_str; ticker.selected = (i == current); @@ -2486,7 +2486,7 @@ static int stripes_draw_item( ticker.s = tmp; ticker.len = 35 * stripes_scale_mod[7]; - ticker.idx = menu_animation_get_ticker_time(); + ticker.idx = frame_count / 20; ticker.selected = (i == current); if (!string_is_empty(entry->value)) @@ -2654,6 +2654,7 @@ static void stripes_draw_items( static void stripes_render(void *data, bool is_idle) { size_t i; + menu_animation_ctx_delta_t delta; settings_t *settings = config_get_ptr(); stripes_handle_t *stripes = (stripes_handle_t*)data; unsigned end = (unsigned)menu_entries_get_size(); @@ -2663,6 +2664,11 @@ static void stripes_render(void *data, bool is_idle) if (!stripes) return; + delta.current = menu_animation_get_delta_time(); + + if (menu_animation_get_ideal_delta_time(&delta)) + menu_animation_update(delta.ideal); + if (pointer_enable || mouse_enable) { size_t selection = menu_navigation_get_selection(); diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index e0e08482e3..dabab6c530 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -71,7 +71,7 @@ #define XMB_RIBBON_VERTICES 2*XMB_RIBBON_COLS*XMB_RIBBON_ROWS-2*XMB_RIBBON_COLS #ifndef XMB_DELAY -#define XMB_DELAY 166 +#define XMB_DELAY 10 #endif #define BATTERY_LEVEL_CHECK_INTERVAL (30 * 1000000) @@ -2923,7 +2923,7 @@ static int xmb_draw_item( ticker.s = tmp; ticker.len = ticker_limit; - ticker.idx = menu_animation_get_ticker_time(); + ticker.idx = frame_count / 20; ticker.str = ticker_str; ticker.selected = (i == current); @@ -2959,7 +2959,7 @@ static int xmb_draw_item( ticker.s = tmp; ticker.len = 35 * scale_mod[7]; - ticker.idx = menu_animation_get_ticker_time(); + ticker.idx = frame_count / 20; ticker.selected = (i == current); if (!string_is_empty(entry->value)) @@ -3140,6 +3140,7 @@ static void xmb_context_reset_internal(xmb_handle_t *xmb, static void xmb_render(void *data, bool is_idle) { size_t i; + menu_animation_ctx_delta_t delta; settings_t *settings = config_get_ptr(); xmb_handle_t *xmb = (xmb_handle_t*)data; unsigned end = (unsigned)menu_entries_get_size(); @@ -3162,6 +3163,11 @@ static void xmb_render(void *data, bool is_idle) xmb->previous_scale_factor = scale_factor; + delta.current = menu_animation_get_delta_time(); + + if (menu_animation_get_ideal_delta_time(&delta)) + menu_animation_update(delta.ideal); + if (pointer_enable || mouse_enable) { unsigned height; @@ -5765,28 +5771,6 @@ static int xmb_pointer_tap(void *userdata, return 0; } -#ifdef HAVE_MENU_WIDGETS -static bool xmb_get_load_content_animation_data(void *userdata, menu_texture_item *icon, char **playlist_name) -{ - xmb_handle_t *xmb = (xmb_handle_t*) userdata; - - if (xmb->categories_selection_ptr > xmb->system_tab_end) - { - xmb_node_t *node = file_list_get_userdata_at_offset(xmb->horizontal_list, xmb->categories_selection_ptr - xmb->system_tab_end-1); - - *icon = node->icon; - *playlist_name = xmb->title_name; - } - else - { - *icon = xmb->textures.list[XMB_TEXTURE_QUICKMENU]; - *playlist_name = "RetroArch"; - } - - return true; -} -#endif - menu_ctx_driver_t menu_ctx_xmb = { NULL, xmb_messagebox, @@ -5830,8 +5814,5 @@ menu_ctx_driver_t menu_ctx_xmb = { xmb_update_savestate_thumbnail_path, xmb_update_savestate_thumbnail_image, NULL, - NULL, -#ifdef HAVE_MENU_WIDGETS - xmb_get_load_content_animation_data -#endif + NULL }; diff --git a/menu/drivers/xui.cpp b/menu/drivers/xui.cpp index 3657678be3..f47ee97dcb 100644 --- a/menu/drivers/xui.cpp +++ b/menu/drivers/xui.cpp @@ -571,7 +571,7 @@ static void xui_render(void *data, bool is_idle) ticker.s = title; ticker.len = RXUI_TERM_WIDTH(fb_width) - 3; - ticker.idx = menu_animation_get_ticker_time(); + ticker.idx = (unsigned int)frame_count / 15; ticker.str = title; ticker.selected = true; diff --git a/menu/menu_animation.c b/menu/menu_animation.c index 32e3ba1d62..d7bc7bd707 100644 --- a/menu/menu_animation.c +++ b/menu/menu_animation.c @@ -34,6 +34,8 @@ #include "../configuration.h" #include "../performance_counters.h" +#define IDEAL_DELTA_TIME (1.0 / 60.0 * 1000000.0) + struct tween { float duration; @@ -64,7 +66,6 @@ static menu_animation_t anim; static retro_time_t cur_time = 0; static retro_time_t old_time = 0; static float delta_time = 0.0f; -static float ticker_time = 0.0f; static bool animation_is_active = false; /* from https://github.com/kikito/tween.lua/blob/master/tween.lua */ @@ -495,12 +496,9 @@ bool menu_animation_push(menu_animation_ctx_entry_t *entry) return true; } -bool menu_animation_update(void) +bool menu_animation_update(float anim_delta_time) { unsigned i; - settings_t *settings = config_get_ptr(); - - menu_animation_update_time(settings->bools.menu_timedate_enable); anim.in_update = true; anim.pending_deletes = false; @@ -508,7 +506,7 @@ bool menu_animation_update(void) for(i = 0; i < da_count(anim.list); i++) { struct tween *tween = da_getptr(anim.list, i); - tween->running_since += delta_time; + tween->running_since += anim_delta_time; *tween->subject = tween->easing( tween->running_since, @@ -593,17 +591,30 @@ bool menu_animation_ticker(const menu_animation_ctx_ticker_t *ticker) return true; } +bool menu_animation_get_ideal_delta_time(menu_animation_ctx_delta_t *delta) +{ + if (!delta) + return false; + delta->ideal = delta->current / IDEAL_DELTA_TIME; + return true; +} + void menu_animation_update_time(bool timedate_enable) { static retro_time_t last_clock_update = 0; - cur_time = cpu_features_get_time_usec() / 1000.0f; - delta_time = old_time == 0 ? 0 : cur_time - old_time; - old_time = cur_time; - ticker_time = (cur_time / 1000.0f) * 3.0f; + cur_time = cpu_features_get_time_usec(); + delta_time = cur_time - old_time; - if (((cur_time - last_clock_update) > 1000) + if (delta_time >= IDEAL_DELTA_TIME* 4) + delta_time = IDEAL_DELTA_TIME * 4; + if (delta_time <= IDEAL_DELTA_TIME / 4) + delta_time = IDEAL_DELTA_TIME / 4; + + old_time = cur_time; + + if (((cur_time - last_clock_update) > 1000000) && timedate_enable) { animation_is_active = true; @@ -742,8 +753,3 @@ void menu_timer_kill(menu_timer_t *timer) menu_animation_ctx_tag tag = (uintptr_t) timer; menu_animation_kill_by_tag(&tag); } - -float menu_animation_get_ticker_time(void) -{ - return ticker_time; -} diff --git a/menu/menu_animation.h b/menu/menu_animation.h index 5dfc601d6b..64ca8a454e 100644 --- a/menu/menu_animation.h +++ b/menu/menu_animation.h @@ -84,6 +84,12 @@ enum menu_animation_easing_type EASING_LAST }; +typedef struct menu_animation_ctx_delta +{ + float current; + float ideal; +} menu_animation_ctx_delta_t; + typedef uintptr_t menu_animation_ctx_tag; typedef struct menu_animation_ctx_subject @@ -135,7 +141,9 @@ void menu_animation_init(void); void menu_animation_free(void); -bool menu_animation_update(void); +bool menu_animation_update(float delta_time); + +bool menu_animation_get_ideal_delta_time(menu_animation_ctx_delta_t *delta); bool menu_animation_ticker(const menu_animation_ctx_ticker_t *ticker); @@ -155,8 +163,6 @@ float menu_animation_get_delta_time(void); bool menu_animation_ctl(enum menu_animation_ctl_state state, void *data); -float menu_animation_get_ticker_time(void); - RETRO_END_DECLS #endif diff --git a/menu/menu_cbs.h b/menu/menu_cbs.h index abe9b3ae84..440f30e37e 100644 --- a/menu/menu_cbs.h +++ b/menu/menu_cbs.h @@ -288,7 +288,7 @@ void menu_cbs_init(void *data, int menu_cbs_exit(void); -void cb_generic_download(retro_task_t *task, void *task_data, +void cb_generic_download(void *task_data, void *user_data, const char *err); RETRO_END_DECLS diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 3fbf5563a2..6846bc8cf5 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -4139,7 +4139,7 @@ static void menu_displaylist_parse_playlist_generic( } #ifdef HAVE_NETWORKING -static void wifi_scan_callback(retro_task_t *task, void *task_data, +static void wifi_scan_callback(void *task_data, void *user_data, const char *error) { unsigned i; diff --git a/menu/menu_driver.c b/menu/menu_driver.c index 926ca4b728..1841c78177 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -44,10 +44,6 @@ #include "../gfx/video_driver.h" -#ifdef HAVE_MENU_WIDGETS -#include "widgets/menu_widgets.h" -#endif - #include "menu_animation.h" #include "menu_driver.h" #include "menu_cbs.h" @@ -1257,7 +1253,7 @@ static bool menu_driver_load_image(menu_ctx_load_image_t *load_image_info) return false; } -void menu_display_handle_thumbnail_upload(retro_task_t *task, void *task_data, +void menu_display_handle_thumbnail_upload(void *task_data, void *user_data, const char *err) { menu_ctx_load_image_t load_image_info; @@ -1273,7 +1269,7 @@ void menu_display_handle_thumbnail_upload(retro_task_t *task, void *task_data, free(user_data); } -void menu_display_handle_left_thumbnail_upload(retro_task_t *task, void *task_data, +void menu_display_handle_left_thumbnail_upload(void *task_data, void *user_data, const char *err) { menu_ctx_load_image_t load_image_info; @@ -1289,7 +1285,7 @@ void menu_display_handle_left_thumbnail_upload(retro_task_t *task, void *task_da free(user_data); } -void menu_display_handle_savestate_thumbnail_upload(retro_task_t *task, void *task_data, +void menu_display_handle_savestate_thumbnail_upload(void *task_data, void *user_data, const char *err) { menu_ctx_load_image_t load_image_info; @@ -1308,7 +1304,7 @@ void menu_display_handle_savestate_thumbnail_upload(retro_task_t *task, void *ta /* Function that gets called when we want to load in a * new menu wallpaper. */ -void menu_display_handle_wallpaper_upload(retro_task_t *task, void *task_data, +void menu_display_handle_wallpaper_upload(void *task_data, void *user_data, const char *err) { menu_ctx_load_image_t load_image_info; @@ -1579,10 +1575,6 @@ void menu_display_draw_text( { struct font_params params; - /* Don't draw is alpha is 0 */ - if ((color & 0x000000FF) == 0) - return; - /* Don't draw outside of the screen */ if ( ((x < -64 || x > width + 64) || (y < -64 || y > height + 64)) @@ -1704,7 +1696,7 @@ const char *config_get_menu_driver_options(void) * when we need to extract the APK contents/zip file. This * file contains assets which then get extracted to the * user's asset directories. */ -static void bundle_decompressed(retro_task_t *task, void *task_data, +static void bundle_decompressed(void *task_data, void *user_data, const char *err) { settings_t *settings = config_get_ptr(); @@ -1910,14 +1902,6 @@ void menu_driver_frame(video_frame_info_t *video_info) menu_driver_ctx->frame(menu_userdata, video_info); } -#ifdef HAVE_MENU_WIDGETS -bool menu_driver_get_load_content_animation_data(menu_texture_item *icon, char **playlist_name) -{ - return menu_driver_ctx && menu_driver_ctx->get_load_content_animation_data - && menu_driver_ctx->get_load_content_animation_data(menu_userdata, icon, playlist_name); -} -#endif - bool menu_driver_render(bool is_idle, bool rarch_is_inited, bool rarch_is_dummy_core) { @@ -1948,6 +1932,9 @@ bool menu_driver_render(bool is_idle, bool rarch_is_inited, if (BIT64_GET(menu_driver_data->state, MENU_STATE_BLIT)) { + settings_t *settings = config_get_ptr(); + menu_animation_update_time(settings->bools.menu_timedate_enable); + if (menu_driver_ctx->render) menu_driver_ctx->render(menu_userdata, is_idle); } @@ -2304,9 +2291,6 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) case RARCH_MENU_CTL_OWNS_DRIVER: return menu_driver_data_own; case RARCH_MENU_CTL_DEINIT: -#ifdef HAVE_MENU_WIDGETS - menu_widgets_context_destroy(); -#endif if (menu_driver_ctx && menu_driver_ctx->context_destroy) menu_driver_ctx->context_destroy(menu_userdata); diff --git a/menu/menu_driver.h b/menu/menu_driver.h index c47688897a..45acdc8238 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -27,7 +27,6 @@ #include #include #include -#include #include "menu_defines.h" #include "menu_input.h" @@ -388,9 +387,6 @@ typedef struct menu_ctx_driver int (*pointer_up)(void *data, unsigned x, unsigned y, unsigned ptr, menu_file_list_cbs_t *cbs, menu_entry_t *entry, unsigned action); -#ifdef HAVE_MENU_WIDGETS - bool (*get_load_content_animation_data)(void *userdata, menu_texture_item *icon, char **playlist_name); -#endif } menu_ctx_driver_t; typedef struct menu_ctx_displaylist @@ -496,8 +492,6 @@ void menu_driver_set_binding_state(bool on); void menu_driver_frame(video_frame_info_t *video_info); -bool menu_driver_get_load_content_animation_data(menu_texture_item *icon, char **playlist_name); - /* Is a background texture set for the current menu driver? Should * return true for RGUI, for instance. */ bool menu_driver_is_texture_set(void); @@ -628,16 +622,16 @@ bool menu_display_get_tex_coords(menu_display_ctx_coord_draw_t *draw); void menu_display_timedate(menu_display_ctx_datetime_t *datetime); -void menu_display_handle_wallpaper_upload(retro_task_t *task, void *task_data, +void menu_display_handle_wallpaper_upload(void *task_data, void *user_data, const char *err); -void menu_display_handle_thumbnail_upload(retro_task_t *task, void *task_data, +void menu_display_handle_thumbnail_upload(void *task_data, void *user_data, const char *err); -void menu_display_handle_left_thumbnail_upload(retro_task_t *task, void *task_data, +void menu_display_handle_left_thumbnail_upload(void *task_data, void *user_data, const char *err); -void menu_display_handle_savestate_thumbnail_upload(retro_task_t *task, void *task_data, +void menu_display_handle_savestate_thumbnail_upload(void *task_data, void *user_data, const char *err); void menu_display_push_quad( diff --git a/menu/menu_input.c b/menu/menu_input.c index 2ce35f2ada..70a8b4e127 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -162,6 +162,7 @@ void menu_event_kb_set(bool down, enum retro_key key) */ unsigned menu_event(input_bits_t *p_input, input_bits_t *p_trigger_input) { + menu_animation_ctx_delta_t delta; /* Used for key repeat */ static float delay_timer = 0.0f; static float delay_count = 0.0f; @@ -197,7 +198,7 @@ unsigned menu_event(input_bits_t *p_input, input_bits_t *p_trigger_input) * for old_input_state. */ first_held = true; - delay_timer = initial_held ? 200 : 100; + delay_timer = initial_held ? 12 : 6; delay_count = 0; } @@ -234,7 +235,10 @@ unsigned menu_event(input_bits_t *p_input, input_bits_t *p_trigger_input) menu_driver_ctl(MENU_NAVIGATION_CTL_SET_SCROLL_ACCEL, &new_scroll_accel); - delay_count += menu_animation_get_delta_time(); + delta.current = menu_animation_get_delta_time(); + + if (menu_animation_get_ideal_delta_time(&delta)) + delay_count += delta.ideal; if (menu_input_dialog_get_display_kb()) { diff --git a/menu/menu_networking.c b/menu/menu_networking.c index 9080a663d9..4504aac070 100644 --- a/menu/menu_networking.c +++ b/menu/menu_networking.c @@ -180,7 +180,7 @@ void print_buf_lines(file_list_t *list, char *buf, * with a newline, just ignore the partial last line. */ } -void cb_net_generic_subdir(retro_task_t *task, void *task_data, void *user_data, const char *err) +void cb_net_generic_subdir(void *task_data, void *user_data, const char *err) { #ifdef HAVE_NETWORKING char subdir_path[PATH_MAX_LENGTH]; @@ -222,7 +222,7 @@ finish: #endif } -void cb_net_generic(retro_task_t *task, void *task_data, void *user_data, const char *err) +void cb_net_generic(void *task_data, void *user_data, const char *err) { #ifdef HAVE_NETWORKING bool refresh = false; diff --git a/menu/menu_networking.h b/menu/menu_networking.h index bf26b9a16e..042af4dd50 100644 --- a/menu/menu_networking.h +++ b/menu/menu_networking.h @@ -22,7 +22,6 @@ #include #include -#include #include @@ -34,10 +33,10 @@ void print_buf_lines(file_list_t *list, char *buf, const char *label, int buf_size, enum msg_file_type type, bool append, bool extended); -void cb_net_generic_subdir(retro_task_t *task, void *task_data, void *user_data, +void cb_net_generic_subdir(void *task_data, void *user_data, const char *err); -void cb_net_generic(retro_task_t *task, void *task_data, void *user_data, const char *err); +void cb_net_generic(void *task_data, void *user_data, const char *err); RETRO_END_DECLS diff --git a/menu/widgets/menu_widgets.c b/menu/widgets/menu_widgets.c index f24baae1a7..edac4c2647 100644 --- a/menu/widgets/menu_widgets.c +++ b/menu/widgets/menu_widgets.c @@ -36,2051 +36,3 @@ #include #include -#define PI 3.14159265359f - -/* TODO: Fix context reset freezing everything in place (probably kills animations when it shouldn't anymore) */ - - -static float msg_queue_background[16] = COLOR_HEX_TO_FLOAT(0x3A3A3A, 1.0f); -static float msg_queue_info[16] = COLOR_HEX_TO_FLOAT(0x12ACF8, 1.0f); - -/* TODO: Colors for warning, error and success */ - -static float msg_queue_task_progress_1[16] = COLOR_HEX_TO_FLOAT(0x55AE99, 1.0f); /* Color of first progress bar in a task message */ -static float msg_queue_task_progress_2[16] = COLOR_HEX_TO_FLOAT(0x388BBD, 1.0f); /* Color of second progress bar in a task message (for multiple tasks with same message) */ - -static float color_task_progress_bar[16] = COLOR_HEX_TO_FLOAT(0x22B14C, 1.0f); - -static unsigned text_color_info = 0xD8EEFFFF; -static unsigned text_color_success = 0x22B14CFF; -static unsigned text_color_error = 0xC23B22FF; -static unsigned text_color_faint = 0x878787FF; - -static float volume_bar_background[16] = COLOR_HEX_TO_FLOAT(0x1A1A1A, 1.0f); -static float volume_bar_normal[16] = COLOR_HEX_TO_FLOAT(0x198AC6, 1.0f); -static float volume_bar_loud[16] = COLOR_HEX_TO_FLOAT(0xF5DD19, 1.0f); -static float volume_bar_loudest[16] = COLOR_HEX_TO_FLOAT(0xC23B22, 1.0f); - -static bool menu_widgets_inited = false; -static uint64_t menu_widgets_frame_count = 0; -static menu_animation_ctx_tag generic_tag = (uintptr_t) &menu_widgets_inited; - -/* Font data */ -static font_data_t *font_regular; -static font_data_t *font_bold; - -static video_font_raster_block_t font_raster_regular; -static video_font_raster_block_t font_raster_bold; - -static float menu_widgets_pure_white[16] = { - 1.00, 1.00, 1.00, 1.00, - 1.00, 1.00, 1.00, 1.00, - 1.00, 1.00, 1.00, 1.00, - 1.00, 1.00, 1.00, 1.00, -}; - -/* Load content animation */ -#define ANIMATION_LOAD_CONTENT_DURATION 333 - -#define LOAD_CONTENT_ANIMATION_INITIAL_ICON_SIZE 320 -#define LOAD_CONTENT_ANIMATION_TARGET_ICON_SIZE 240 - -static bool load_content_animation_running = false; -static char *load_content_animation_content_name = NULL; -static char *load_content_animation_playlist_name = NULL; -static menu_texture_item load_content_animation_icon = 0; - -static float load_content_animation_icon_color[16]; -static float load_content_animation_icon_size; -static float load_content_animation_icon_alpha; -static float load_content_animation_fade_alpha; -static float load_content_animation_final_fade_alpha; - -static menu_timer_t load_content_animation_end_timer; - -static float menu_widgets_backdrop_orig[16] = { - 0.00, 0.00, 0.00, 0.75, - 0.00, 0.00, 0.00, 0.75, - 0.00, 0.00, 0.00, 0.75, - 0.00, 0.00, 0.00, 0.75, -}; - -static float menu_widgets_backdrop[16] = { - 0.00, 0.00, 0.00, 0.75, - 0.00, 0.00, 0.00, 0.75, - 0.00, 0.00, 0.00, 0.75, - 0.00, 0.00, 0.00, 0.75, -}; - -/* Messages queue */ - -typedef struct menu_widget_msg -{ - char *msg; - char *msg_new; - float msg_transition_animation; - unsigned msg_len; - unsigned duration; - - unsigned text_height; - - float offset_y; - - float alpha; - - bool dying; /* is it currently doing the fade out animation ? */ - - unsigned width; - bool expired; /* has the timer expired ? if so, should be set to dying */ - - menu_timer_t expiration_timer; - bool expiration_timer_started; - - retro_task_t *task_ptr; - char *task_title_ptr; /* used to detect title change */ - uint8_t task_count; /* how many tasks have used this notification? */ - - int8_t task_progress; - bool task_finished; - bool task_error; - bool task_cancelled; - uint32_t task_ident; - - bool unfolded; /* unfold animation */ - bool unfolding; - float unfold; - - float hourglass_rotation; - menu_timer_t hourglass_timer; -} menu_widget_msg_t; - -static fifo_buffer_t *msg_queue = NULL; -static file_list_t *current_msgs = NULL; -static unsigned msg_queue_kill = 0; - -static unsigned msg_queue_tasks_count = 0; /* count of messages bound to a taskin current_msgs */ - -/* TODO: Don't display icons if assets are missing */ - -static menu_texture_item msg_queue_icon = 0; -static menu_texture_item msg_queue_icon_outline = 0; -static menu_texture_item msg_queue_icon_rect = 0; -static bool msg_queue_has_icons = false; - -/* there can only be one message animation at a time to avoid confusing users */ -static bool widgets_moving = false; - -/* Icons */ -enum menu_widgets_icon -{ - MENU_WIDGETS_ICON_VOLUME_MED = 0, - MENU_WIDGETS_ICON_VOLUME_MAX, - MENU_WIDGETS_ICON_VOLUME_MIN, - MENU_WIDGETS_ICON_VOLUME_MUTE, - - MENU_WIDGETS_ICON_PAUSED, - MENU_WIDGETS_ICON_FAST_FORWARD, - MENU_WIDGETS_ICON_REWIND, - MENU_WIDGETS_ICON_SLOW_MOTION, - - MENU_WIDGETS_ICON_HOURGLASS, - MENU_WIDGETS_ICON_CHECK, - - MENU_WIDGETS_ICON_INFO, - - MENU_WIDGETS_ICON_LAST -}; - -static char *menu_widgets_icons_names[MENU_WIDGETS_ICON_LAST] = { - "menu_volume_med.png", - "menu_volume_max.png", - "menu_volume_min.png", - "menu_volume_mute.png", - - "menu_pause.png", - "menu_frameskip.png", - "menu_rewind.png", - "resume.png", - - "menu_hourglass.png", - "menu_check.png", - - "menu_info.png" -}; - -static menu_texture_item menu_widgets_icons_textures[MENU_WIDGETS_ICON_LAST]; - -/* Volume */ -static float volume_db = 0.0f; -static float volume_percent = 1.0f; -static menu_timer_t volume_timer = 0.0f; - -static float volume_alpha = 0.0f; -static float volume_text_alpha = 0.0f; -static menu_animation_ctx_tag volume_tag = (uintptr_t) &volume_alpha; -static bool volume_mute = false; - -/* FPS */ -static char menu_widgets_fps_text[255]; - -/* Status icons */ -static bool menu_widgets_paused = false; -static bool menu_widgets_fast_forward = false; -static bool menu_widgets_rewinding = false; - -/* Screenshot */ -static float screenshot_alpha = 0.0f; -static menu_texture_item screenshot_texture = 0; -static unsigned screenshot_texture_width = 0; -static unsigned screenshot_texture_height = 0; -static char screenshot_shotname[256] = {0}; -static char screenshot_filename[256] = {0}; -static bool screenshot_loaded = false; - -static unsigned screenshot_height; -static unsigned screenshot_width; -static float screenshot_scale_factor; -static unsigned screenshot_thumbnail_width; -static unsigned screenshot_thumbnail_height; -static float screenshot_y; -static menu_timer_t screenshot_timer; - -static unsigned screenshot_shotname_length; - -/* Metrics */ -static unsigned simple_widget_padding; -static unsigned simple_widget_height; -static unsigned glyph_width; - -static unsigned msg_queue_height; -static unsigned msg_queue_icon_size_x; -static unsigned msg_queue_icon_size_y; -static float msg_queue_text_scale_factor; -static unsigned msg_queue_base_width; -static unsigned msg_queue_spacing; -static unsigned msg_queue_glyph_width; -static unsigned msg_queue_rect_start_x; -static unsigned msg_queue_internal_icon_size; -static unsigned msg_queue_internal_icon_offset; -static unsigned msg_queue_icon_offset_y; -static unsigned msg_queue_scissor_start_x; -static unsigned msg_queue_default_rect_width; -static unsigned msg_queue_task_text_start_x; -static unsigned msg_queue_regular_padding_x; -static unsigned msg_queue_regular_text_start; -static unsigned msg_queue_regular_text_base_y; -static unsigned msg_queue_task_rect_start_x; -static unsigned msg_queue_task_hourglass_x; - -bool menu_widgets_set_paused(bool is_paused) -{ - if (!menu_widgets_inited) - return false; - - menu_widgets_paused = is_paused; - return true; -} - -static void msg_widget_msg_transition_animation_done(void *userdata) -{ - menu_widget_msg_t *msg = (menu_widget_msg_t*) userdata; - - free(msg->msg); - - msg->msg = msg->msg_new; - msg->msg_new = NULL; - msg->msg_transition_animation = 0.0f; -} - -static bool menu_widgets_msg_queue_push_internal(retro_task_t *task, const char *msg, - unsigned duration, - char *title, - enum message_queue_icon icon, enum message_queue_category category, - unsigned prio, bool flush) -{ - menu_widget_msg_t* msg_widget = NULL; - - if (!menu_widgets_inited) - return false; - - #ifdef HAVE_THREADS - runloop_msg_queue_lock(); - #endif - - ui_companion_driver_msg_queue_push(msg, - prio, task ? duration : duration * 60 / 1000, flush); - - if (fifo_write_avail(msg_queue) > 0) - { - /* Get current msg if it exists */ - if (task != NULL && task->frontend_userdata) - { - msg_widget = (menu_widget_msg_t*) task->frontend_userdata; - msg_widget->task_ptr = task; /* msg_widgets can be passed between tasks */ - } - - /* Spawn a new notification */ - if (msg_widget == NULL) - { - const char *title; - - msg_widget = (menu_widget_msg_t*) calloc(1, sizeof(*msg_widget)); - - title = task != NULL ? task->title : msg; - - msg_widget->duration = duration; - msg_widget->offset_y = 0; - msg_widget->alpha = 1.0f; - - msg_widget->dying = false; - msg_widget->expired = false; - - msg_widget->expiration_timer = 0; - msg_widget->task_ptr = task; - msg_widget->expiration_timer_started = false; - - msg_widget->msg_new = NULL; - msg_widget->msg_transition_animation = 0.0f; - - msg_widget->text_height = 0; - - if (msg_queue_has_icons) - { - msg_widget->unfolded = false; - msg_widget->unfolding = false; - msg_widget->unfold = 0.0f; - } - else - { - msg_widget->unfolded = true; - msg_widget->unfolding = false; - msg_widget->unfold = 1.0f; - } - - if (task) - { - msg_widget->msg = strdup(title); - msg_widget->msg_len = strlen(title); - - msg_widget->task_error = task->error; - msg_widget->task_cancelled = task->cancelled; - msg_widget->task_finished = task->finished; - msg_widget->task_progress = task->progress; - msg_widget->task_ident = task->ident; - msg_widget->task_title_ptr = task->title; - msg_widget->task_count = 1; - - msg_widget->unfolded = true; - - msg_widget->width = font_driver_get_message_width(font_regular, title, msg_widget->msg_len, msg_queue_text_scale_factor) + simple_widget_padding/2; - - task->frontend_userdata = msg_widget; - - msg_widget->hourglass_rotation = 0; - } - else - { - /* Compute rect width, wrap if necessary */ - /* Single line text > two lines text > two lines text with expanded width */ - unsigned title_length = strlen(title); - char *msg = strdup(title); - unsigned width = msg_queue_default_rect_width; - unsigned text_width = font_driver_get_message_width(font_regular, title, title_length, msg_queue_text_scale_factor); - settings_t *settings = config_get_ptr(); - - msg_widget->text_height = msg_queue_text_scale_factor * settings->floats.video_font_size; - - /* Text is too wide, split it into two lines */ - if (text_width > width) - { - if (text_width/2 > width) - { - width = text_width/2; - width += 10 * msg_queue_glyph_width; - } - - word_wrap(msg, msg, title_length/2 + 10, false); - - msg_widget->text_height *= 2.5f; - } - else - { - width = text_width; - msg_widget->text_height *= 1.35f; - } - - msg_widget->msg = msg; - msg_widget->msg_len = strlen(msg); - msg_widget->width = width + simple_widget_padding/2; - } - - fifo_write(msg_queue, &msg_widget, sizeof(msg_widget)); - } - /* Update task info */ - else - { - if (msg_widget->expiration_timer_started) - { - menu_timer_kill(&msg_widget->expiration_timer); - msg_widget->expiration_timer_started = false; - } - - if (task->title != msg_widget->task_title_ptr) - { - menu_animation_ctx_entry_t entry; - unsigned len = strlen(task->title); - unsigned new_width = font_driver_get_message_width(font_regular, task->title, len, msg_queue_text_scale_factor); - - if (msg_widget->msg_new) - free(msg_widget->msg_new); - - msg_widget->msg_new = strdup(task->title); - msg_widget->msg_len = len; - msg_widget->task_title_ptr = task->title; - msg_widget->msg_transition_animation = 0; - - entry.easing_enum = EASING_OUT_QUAD; - entry.tag = (uintptr_t) NULL; - entry.duration = MSG_QUEUE_ANIMATION_DURATION*2; - entry.target_value = msg_queue_height/2.0f; - entry.subject = &msg_widget->msg_transition_animation; - entry.cb = msg_widget_msg_transition_animation_done; - entry.userdata = msg_widget; - - menu_animation_push(&entry); - - msg_widget->task_count++; - - if (new_width > msg_widget->width) - msg_widget->width = new_width; - } - - msg_widget->task_error = task->error; - msg_widget->task_cancelled = task->cancelled; - msg_widget->task_finished = task->finished; - msg_widget->task_progress = task->progress; - } - } - - #ifdef HAVE_THREADS - runloop_msg_queue_unlock(); - #endif - - return true; -} - -bool menu_widgets_msg_queue_push(const char *msg, - unsigned duration, - char *title, - enum message_queue_icon icon, enum message_queue_category category, - unsigned prio, bool flush) -{ - return menu_widgets_msg_queue_push_internal(NULL, msg, duration, title, icon, category, prio, flush); -} - -static void menu_widgets_unfold_end(void *userdata) -{ - menu_widget_msg_t *unfold = (menu_widget_msg_t*) userdata; - - unfold->unfolding = false; - widgets_moving = false; -} - -static void menu_widgets_move_end(void *userdata) -{ - if (userdata) - { - menu_widget_msg_t *unfold = (menu_widget_msg_t*) userdata; - - menu_animation_ctx_entry_t entry; - - entry.cb = menu_widgets_unfold_end; - entry.duration = MSG_QUEUE_ANIMATION_DURATION; - entry.easing_enum = EASING_OUT_QUAD; - entry.subject = &unfold->unfold; - entry.tag = generic_tag; - entry.target_value = 1.0f; - entry.userdata = unfold; - - menu_animation_push(&entry); - - unfold->unfolded = true; - unfold->unfolding = true; - } - else - widgets_moving = false; -} - -static void menu_widgets_msg_queue_expired(void *userdata) -{ - menu_widget_msg_t *msg = (menu_widget_msg_t *) userdata; - - if (msg && !msg->expired) - msg->expired = true; -} - -static void menu_widgets_msg_queue_move(void) -{ - int i; - float y = 0; - - menu_widget_msg_t *unfold = NULL; /* there should always be one and only one unfolded message */ - - if (current_msgs->size == 0) - return; - - for (i = current_msgs->size-1; i >= 0; i--) - { - menu_widget_msg_t *msg; - - msg = file_list_get_userdata_at_offset(current_msgs, i); - - if (!msg || msg->dying) - continue; - - y += msg_queue_height / (msg->task_ptr ? 2 : 1) + msg_queue_spacing; - - if (!msg->unfolded) - unfold = msg; - - if (msg->offset_y != y) - { - menu_animation_ctx_entry_t entry; - - entry.cb = i == 0 ? menu_widgets_move_end : NULL; - entry.duration = MSG_QUEUE_ANIMATION_DURATION; - entry.easing_enum = EASING_OUT_QUAD; - entry.subject = &msg->offset_y; - entry.tag = generic_tag; - entry.target_value = y; - entry.userdata = unfold; - - menu_animation_push(&entry); - - widgets_moving = true; - } - } -} - -static void menu_widgets_msg_queue_free(menu_widget_msg_t *msg, bool touch_list) -{ - int i; - menu_animation_ctx_tag tag = (uintptr_t) msg; - - /* Update tasks count */ - if (msg->task_ptr) - msg_queue_tasks_count--; - - /* Kill all animations */ - menu_timer_kill(&msg->hourglass_timer); - menu_animation_kill_by_tag(&tag); - - /* Free it */ - if (msg->msg) - free(msg->msg); - - /* Remove it from the list */ - if (touch_list) - { - file_list_free_userdata(current_msgs, msg_queue_kill); - - for (i = msg_queue_kill; i < current_msgs->size-1; i++) - { - current_msgs->list[i] = current_msgs->list[i+1]; - } - - current_msgs->size--; - } - - widgets_moving = false; -} - -static void menu_widgets_msg_queue_kill_end(void *userdata) -{ - menu_widget_msg_t *msg = file_list_get_userdata_at_offset(current_msgs, msg_queue_kill); - - if (!msg) - return; - - menu_widgets_msg_queue_free(msg, true); -} - -static void menu_widgets_msg_queue_kill(unsigned idx) -{ - menu_animation_ctx_entry_t entry; - - menu_widget_msg_t *msg = file_list_get_userdata_at_offset(current_msgs, idx); - - if (!msg) - return; - - widgets_moving = true; - msg->dying = true; - - msg_queue_kill = idx; - - /* Drop down */ - entry.cb = NULL; - entry.duration = MSG_QUEUE_ANIMATION_DURATION; - entry.easing_enum = EASING_OUT_QUAD; - entry.tag = generic_tag; - entry.userdata = NULL; - entry.subject = &msg->offset_y; - entry.target_value = msg->offset_y - msg_queue_height/4; - - menu_animation_push(&entry); - - /* Fade out */ - entry.cb = menu_widgets_msg_queue_kill_end; - entry.subject = &msg->alpha; - entry.target_value = 0.0f; - - menu_animation_push(&entry); - - /* Move all messages back to their correct position */ - menu_widgets_msg_queue_move(); -} - -static void color_alpha(float *color, float alpha) -{ - color[3] = color[7] = color[11] = color[15] = alpha; -} - -static void menu_widgets_draw_icon( - video_frame_info_t *video_info, - unsigned icon_width, - unsigned icon_height, - uintptr_t texture, - float x, float y, - unsigned width, unsigned height, - float rotation, float scale_factor, - float *color) -{ - menu_display_ctx_rotate_draw_t rotate_draw; - menu_display_ctx_draw_t draw; - struct video_coords coords; - math_matrix_4x4 mymat; - - if (!texture) - return; - - rotate_draw.matrix = &mymat; - rotate_draw.rotation = rotation; - rotate_draw.scale_x = scale_factor; - rotate_draw.scale_y = scale_factor; - rotate_draw.scale_z = 1; - rotate_draw.scale_enable = true; - - menu_display_rotate_z(&rotate_draw, video_info); - - coords.vertices = 4; - coords.vertex = NULL; - coords.tex_coord = NULL; - coords.lut_tex_coord = NULL; - coords.color = color; - - draw.x = x; - draw.y = height - y - icon_height; - draw.width = icon_width; - draw.height = icon_height; - draw.scale_factor = scale_factor; - draw.rotation = rotation; - draw.coords = &coords; - draw.matrix_data = &mymat; - draw.texture = texture; - draw.prim_type = MENU_DISPLAY_PRIM_TRIANGLESTRIP; - draw.pipeline.id = 0; - - menu_display_draw(&draw, video_info); -} - -static float menu_widgets_get_thumbnail_scale_factor(const float dst_width, const float dst_height, - const float image_width, const float image_height) -{ - float dst_ratio = dst_width / dst_height; - float image_ratio = image_width / image_height; - - return (dst_ratio > image_ratio) ? dst_height / image_height : dst_width / image_width; -} - -static void menu_widgets_screenshot_dispose(void *userdata) -{ - screenshot_loaded = false; - video_driver_texture_unload(&screenshot_texture); -} - -static void menu_widgets_screenshot_end(void *userdata) -{ - menu_animation_ctx_entry_t entry; - - entry.cb = menu_widgets_screenshot_dispose; - entry.duration = MSG_QUEUE_ANIMATION_DURATION; - entry.easing_enum = EASING_OUT_QUAD; - entry.subject = &screenshot_y; - entry.tag = generic_tag; - entry.target_value = -((float)screenshot_height); - entry.userdata = NULL; - - menu_animation_push(&entry); -} - -static void menu_widgets_start_msg_expiration_timer(menu_widget_msg_t *msg_widget, unsigned duration) -{ - if (msg_widget->expiration_timer_started) - return; - - menu_timer_ctx_entry_t timer; - - timer.cb = menu_widgets_msg_queue_expired; - timer.duration = duration; - timer.userdata = msg_widget; - - menu_timer_start(&msg_widget->expiration_timer, &timer); - - msg_widget->expiration_timer_started = true; -} - -static void menu_widgets_hourglass_tick(void *userdata); - -static void menu_widgets_hourglass_end(void *userdata) -{ - menu_widget_msg_t *msg = (menu_widget_msg_t*) userdata; - - msg->hourglass_rotation = 0.0f; - - menu_timer_ctx_entry_t timer; - timer.cb = menu_widgets_hourglass_tick; - timer.duration = HOURGLASS_INTERVAL; - timer.userdata = msg; - - menu_timer_start(&msg->hourglass_timer, &timer); -} - -static void menu_widgets_hourglass_tick(void *userdata) -{ - menu_widget_msg_t *msg = (menu_widget_msg_t*) userdata; - menu_animation_ctx_tag tag = (uintptr_t) msg; - - menu_animation_ctx_entry_t entry; - - entry.easing_enum = EASING_OUT_QUAD; - entry.tag = tag; - entry.duration = HOURGLASS_DURATION; - entry.target_value = -(2 * PI); - entry.subject = &msg->hourglass_rotation; - entry.cb = menu_widgets_hourglass_end; - entry.userdata = msg; - - menu_animation_push(&entry); -} - -void menu_widgets_iterate(void) -{ - int i; - settings_t *settings = config_get_ptr(); - - if (!menu_widgets_inited) - return; - - /* Messages queue */ -#ifdef HAVE_THREADS - runloop_msg_queue_lock(); -#endif - - /* Consume one message if available */ - if (fifo_read_avail(msg_queue) > 0 && !widgets_moving && current_msgs->size < MSG_QUEUE_ONSCREEN_MAX) - { - menu_widget_msg_t *msg_widget; - - fifo_read(msg_queue, &msg_widget, sizeof(msg_widget)); - - /* Task messages always appear from the bottom of the screen */ - if (msg_queue_tasks_count == 0 || msg_widget->task_ptr) - { - file_list_append(current_msgs, - NULL, - NULL, - 0, - 0, - 0 - ); - - file_list_set_userdata(current_msgs, current_msgs->size-1, msg_widget); - } - /* Regular messages are always above tasks */ - else - { - unsigned idx = current_msgs->size - msg_queue_tasks_count; - file_list_insert(current_msgs, - NULL, - NULL, - 0, - 0, - 0, - idx - ); - - file_list_set_userdata(current_msgs, idx, msg_widget); - } - - /* Start expiration timer if not associated to a task */ - if (msg_widget->task_ptr == NULL) - { - menu_widgets_start_msg_expiration_timer(msg_widget, MSG_QUEUE_ANIMATION_DURATION*2 + msg_widget->duration); - } - /* Else, start hourglass animation timer */ - else - { - msg_queue_tasks_count++; - menu_widgets_hourglass_end(msg_widget); - } - - menu_widgets_msg_queue_move(); - } - -#ifdef HAVE_THREADS - runloop_msg_queue_unlock(); -#endif - - /* Kill first expired message */ - /* Start expiration timer of dead tasks */ - for (i = 0; i < current_msgs->size ; i++) - { - menu_widget_msg_t *msg = file_list_get_userdata_at_offset(current_msgs, i); - - if (!msg) - continue; - - if (msg->task_ptr != NULL && (msg->task_finished || msg->task_cancelled)) - menu_widgets_start_msg_expiration_timer(msg, TASK_FINISHED_DURATION); - - if (msg->expired && !widgets_moving) - { - menu_widgets_msg_queue_kill(i); - break; - } - } - - /* Load screenshot and start its animation */ - if (screenshot_filename[0] != '\0') - { - menu_animation_ctx_entry_t entry; - menu_timer_ctx_entry_t timer; - unsigned width; - - video_driver_texture_unload(&screenshot_texture); - menu_display_reset_textures_list(screenshot_filename, "", &screenshot_texture, TEXTURE_FILTER_MIPMAP_LINEAR, &screenshot_texture_width, &screenshot_texture_height); - - video_driver_get_size(&width, NULL); - - screenshot_height = settings->floats.video_font_size * 4; - screenshot_width = width; - - screenshot_scale_factor = menu_widgets_get_thumbnail_scale_factor( - width, screenshot_height, - screenshot_texture_width, screenshot_texture_height - ); - - screenshot_thumbnail_width = screenshot_texture_width * screenshot_scale_factor; - screenshot_thumbnail_height = screenshot_texture_height * screenshot_scale_factor; - - screenshot_shotname_length = (width - screenshot_thumbnail_width - simple_widget_padding*2) / glyph_width; - - screenshot_y = -((float)screenshot_height); - - entry.cb = NULL; - entry.duration = MSG_QUEUE_ANIMATION_DURATION; - entry.easing_enum = EASING_OUT_QUAD; - entry.subject = &screenshot_y; - entry.tag = generic_tag; - entry.target_value = 0.0f; - entry.userdata = NULL; - - menu_animation_push(&entry); - - timer.cb = menu_widgets_screenshot_end; - timer.duration = SCREENSHOT_NOTIFICATION_DURATION; - timer.userdata = NULL; - - menu_timer_start(&screenshot_timer, &timer); - - screenshot_loaded = true; - screenshot_filename[0] = '\0'; - } -} - -static int menu_widgets_draw_indicator(video_frame_info_t *video_info, - menu_texture_item icon, int y, int top_right_x_advance, - enum msg_hash_enums msg) -{ - unsigned width; - settings_t *settings = config_get_ptr(); - - color_alpha(menu_widgets_backdrop_orig, DEFAULT_BACKDROP); - - if (icon) - { - unsigned height = simple_widget_height * 2; - width = height; - - menu_display_draw_quad(video_info, - top_right_x_advance - width, y, - width, height, - video_info->width, video_info->height, - menu_widgets_backdrop_orig - ); - - color_alpha(menu_widgets_pure_white, 1.0f); - - menu_display_blend_begin(video_info); - menu_widgets_draw_icon(video_info, width, height, - icon, top_right_x_advance - width, y, - video_info->width, video_info->height, - 0, 1, menu_widgets_pure_white - ); - menu_display_blend_end(video_info); - } - else - { - unsigned height = simple_widget_height; - const char *txt = msg_hash_to_str(msg); - width = font_driver_get_message_width(font_regular, txt, strlen(txt), 1) + simple_widget_padding*2; - - menu_display_draw_quad(video_info, - top_right_x_advance - width, y, - width, height, - video_info->width, video_info->height, - menu_widgets_backdrop_orig - ); - - menu_display_draw_text(font_regular, - txt, - top_right_x_advance - width + simple_widget_padding, settings->floats.video_font_size + simple_widget_padding/4, - video_info->width, video_info->height, - 0xFFFFFFFF, TEXT_ALIGN_LEFT, - 1.0f, - false, 0, false - ); - } - - return width; -} - -static void menu_widgets_draw_task_msg(menu_widget_msg_t *msg, video_frame_info_t *video_info) -{ - unsigned text_color; - unsigned bar_width; - - unsigned rect_x; - unsigned rect_y; - unsigned rect_width; - unsigned rect_height; - - float *msg_queue_current_background; - float *msg_queue_current_bar; - - unsigned task_percentage_offset = 0; - char task_percentage[256] = {0}; - settings_t *settings = config_get_ptr(); - - task_percentage_offset = glyph_width * (msg->task_error ? 12 : 5) + simple_widget_padding * 1.25f; /*11 = strlen("Task failed")+1 */ - - if (msg->task_finished) - { - if (msg->task_error) - { - snprintf(task_percentage, sizeof(task_percentage), "Task failed"); - } - else - { - snprintf(task_percentage, sizeof(task_percentage), " "); - } - } - else if (msg->task_progress >= 0 && msg->task_progress <= 100) - { - snprintf(task_percentage, sizeof(task_percentage), "%i%%", msg->task_progress); - } - - rect_width = simple_widget_padding + msg->width + task_percentage_offset; - bar_width = rect_width * msg->task_progress/100.0f; - text_color = COLOR_TEXT_ALPHA(0xFFFFFF00, (unsigned)(msg->alpha*255.0f)); - - /* Rect */ - if (msg->task_finished) - if (msg->task_count == 1) - msg_queue_current_background = msg_queue_task_progress_1; - else - msg_queue_current_background = msg_queue_task_progress_2; - else - if (msg->task_count == 1) - msg_queue_current_background = msg_queue_background; - else - msg_queue_current_background = msg_queue_task_progress_1; - - rect_x = msg_queue_rect_start_x - msg_queue_icon_size_x; - rect_y = video_info->height - msg->offset_y; - rect_height = msg_queue_height/2; - - color_alpha(msg_queue_current_background, msg->alpha); - menu_display_draw_quad(video_info, - rect_x, rect_y, - rect_width, rect_height, - video_info->width, video_info->height, - msg_queue_current_background - ); - - /* Progress bar */ - if (!msg->task_finished && msg->task_progress >= 0 && msg->task_progress <= 100) - { - if (msg->task_count == 1) - msg_queue_current_bar = msg_queue_task_progress_1; - else - msg_queue_current_bar = msg_queue_task_progress_2; - - color_alpha(msg_queue_current_bar, 1.0f); - menu_display_draw_quad(video_info, - msg_queue_task_rect_start_x, video_info->height - msg->offset_y, - bar_width, rect_height, - video_info->width, video_info->height, - msg_queue_current_bar - ); - } - - /* Icon */ - color_alpha(menu_widgets_pure_white, msg->alpha); - menu_display_blend_begin(video_info); - menu_widgets_draw_icon(video_info, - msg_queue_height/2, - msg_queue_height/2, - menu_widgets_icons_textures[msg->task_finished ? MENU_WIDGETS_ICON_CHECK : MENU_WIDGETS_ICON_HOURGLASS], - msg_queue_task_hourglass_x, - video_info->height - msg->offset_y, - video_info->width, - video_info->height, - msg->task_finished ? 0 : msg->hourglass_rotation, - 1, menu_widgets_pure_white); - menu_display_blend_end(video_info); - - /* Text */ - if (msg->msg_new) - { - font_driver_flush(video_info->width, video_info->height, font_regular, video_info); - font_raster_regular.carr.coords.vertices = 0; - - menu_display_scissor_begin(video_info, rect_x, rect_y, rect_width, rect_height); - menu_display_draw_text(font_regular, - msg->msg_new, - msg_queue_task_text_start_x, - video_info->height - msg->offset_y + msg_queue_text_scale_factor * settings->floats.video_font_size + msg_queue_height/4 - settings->floats.video_font_size/2.25f - msg_queue_height/2 + msg->msg_transition_animation, - video_info->width, video_info->height, - text_color, - TEXT_ALIGN_LEFT, - msg_queue_text_scale_factor, - false, - 0, - true - ); - } - - menu_display_draw_text(font_regular, - msg->msg, - msg_queue_task_text_start_x, - video_info->height - msg->offset_y + msg_queue_text_scale_factor * settings->floats.video_font_size + msg_queue_height/4 - settings->floats.video_font_size/2.25f + msg->msg_transition_animation, - video_info->width, video_info->height, - text_color, - TEXT_ALIGN_LEFT, - msg_queue_text_scale_factor, - false, - 0, - true - ); - - if (msg->msg_new) - { - font_driver_flush(video_info->width, video_info->height, font_regular, video_info); - font_raster_regular.carr.coords.vertices = 0; - - menu_display_scissor_end(video_info); - } - - /* Progress text */ - text_color = COLOR_TEXT_ALPHA(0xFFFFFF00, (unsigned)(msg->alpha/2*255.0f)); - menu_display_draw_text(font_regular, - task_percentage, - msg_queue_rect_start_x - msg_queue_icon_size_x + rect_width - msg_queue_glyph_width, - video_info->height - msg->offset_y + msg_queue_text_scale_factor * settings->floats.video_font_size + msg_queue_height/4 - settings->floats.video_font_size/2.25f, - video_info->width, video_info->height, - text_color, - TEXT_ALIGN_RIGHT, - msg_queue_text_scale_factor, - false, - 0, - true - ); -} - -static void menu_widgets_draw_regular_msg(menu_widget_msg_t *msg, video_frame_info_t *video_info) -{ - menu_texture_item icon = 0; - - unsigned bar_width; - unsigned text_color; - - if (!icon) - icon = menu_widgets_icons_textures[MENU_WIDGETS_ICON_INFO]; /* TODO: Real icon logic here */ - - /* Icon */ - color_alpha(msg_queue_info, msg->alpha); - color_alpha(menu_widgets_pure_white, msg->alpha); - color_alpha(msg_queue_background, msg->alpha); - - if (!msg->unfolded || msg->unfolding) - { - font_driver_flush(video_info->width, video_info->height, font_regular, video_info); - font_driver_flush(video_info->width, video_info->height, font_bold, video_info); - - font_raster_regular.carr.coords.vertices = 0; - font_raster_bold.carr.coords.vertices = 0; - - menu_display_scissor_begin(video_info, msg_queue_scissor_start_x, 0, - (msg_queue_scissor_start_x + msg->width - simple_widget_padding*2) * msg->unfold, video_info->height); - } - - - if (msg_queue_has_icons) - { - menu_display_blend_begin(video_info); - /* (int) cast is to be consistent with the rect drawing and prevent alignment - * issues, don't remove it */ - menu_widgets_draw_icon(video_info, - msg_queue_icon_size_x, msg_queue_icon_size_y, - msg_queue_icon_rect, msg_queue_spacing, (int)(video_info->height - msg->offset_y - msg_queue_icon_offset_y), - video_info->width, video_info->height, - 0, 1, msg_queue_background); - - menu_display_blend_end(video_info); - } - - /* Background */ - bar_width = simple_widget_padding + msg->width; - - menu_display_draw_quad(video_info, - msg_queue_rect_start_x, video_info->height - msg->offset_y, - bar_width, msg_queue_height, - video_info->width, video_info->height, - msg_queue_background - ); - - /* Text */ - text_color = COLOR_TEXT_ALPHA(0xFFFFFF00, (unsigned)(msg->alpha*255.0f)); - - menu_display_draw_text(font_regular, - msg->msg, - msg_queue_regular_text_start - ((1.0f-msg->unfold) * msg->width/2), - video_info->height - msg->offset_y + msg_queue_regular_text_base_y - msg->text_height/2, - video_info->width, video_info->height, - text_color, - TEXT_ALIGN_LEFT, - msg_queue_text_scale_factor, false, 0, true - ); - - if (!msg->unfolded || msg->unfolding) - { - font_driver_flush(video_info->width, video_info->height, font_regular, video_info); - font_driver_flush(video_info->width, video_info->height, font_bold, video_info); - - font_raster_regular.carr.coords.vertices = 0; - font_raster_bold.carr.coords.vertices = 0; - - menu_display_scissor_end(video_info); - } - - if (msg_queue_has_icons) - { - menu_display_blend_begin(video_info); - - menu_widgets_draw_icon(video_info, - msg_queue_icon_size_x, msg_queue_icon_size_y, - msg_queue_icon, msg_queue_spacing, video_info->height - msg->offset_y - msg_queue_icon_offset_y, - video_info->width, video_info->height, - 0, 1, msg_queue_info); - - menu_widgets_draw_icon(video_info, - msg_queue_icon_size_x, msg_queue_icon_size_y, - msg_queue_icon_outline, msg_queue_spacing, video_info->height - msg->offset_y - msg_queue_icon_offset_y, - video_info->width, video_info->height, - 0, 1, menu_widgets_pure_white); - - menu_widgets_draw_icon(video_info, - msg_queue_internal_icon_size, msg_queue_internal_icon_size, - icon, msg_queue_spacing + msg_queue_internal_icon_offset, video_info->height - msg->offset_y - msg_queue_icon_offset_y + msg_queue_internal_icon_offset, - video_info->width, video_info->height, - 0, 1, menu_widgets_pure_white); - - menu_display_blend_end(video_info); - } -} - -static void menu_widgets_draw_backdrop(video_frame_info_t *video_info, float alpha) -{ - color_alpha(menu_widgets_backdrop, alpha); - menu_display_draw_quad(video_info, 0, 0, video_info->width, video_info->height, video_info->width, video_info->height, menu_widgets_backdrop); -} - -static void menu_widgets_draw_load_content_animation(video_frame_info_t *video_info) -{ - /* TODO: scale this right ? (change metrics) */ - - int icon_size = (int) load_content_animation_icon_size; - uint32_t text_alpha = load_content_animation_fade_alpha * 255.0f; - uint32_t text_color = COLOR_TEXT_ALPHA(0xB8B8B800, text_alpha); - unsigned text_offset = -25 * load_content_animation_fade_alpha; - float *icon_color = load_content_animation_icon_color; - - /* Fade out */ - menu_widgets_draw_backdrop(video_info, load_content_animation_fade_alpha); - - /* Icon */ - color_alpha(icon_color, load_content_animation_icon_alpha); - menu_display_blend_begin(video_info); - menu_widgets_draw_icon(video_info, icon_size, - icon_size, load_content_animation_icon, - video_info->width/2 - icon_size/2, - video_info->height/2 - icon_size/2, - video_info->width, - video_info->height, - 0, 1, icon_color - ); - menu_display_blend_end(video_info); - - /* Text */ - menu_display_draw_text(font_bold, - load_content_animation_content_name, - video_info->width/2, - video_info->height/2 + 175 + 25 + text_offset, - video_info->width, - video_info->height, - text_color, - TEXT_ALIGN_CENTER, - 1, - false, - 0, - false - ); - - /* Flush text layer */ - font_driver_flush(video_info->width, video_info->height, font_regular, video_info); - font_driver_flush(video_info->width, video_info->height, font_bold, video_info); - - font_raster_regular.carr.coords.vertices = 0; - font_raster_bold.carr.coords.vertices = 0; - - /* Everything disappears */ - menu_widgets_draw_backdrop(video_info, load_content_animation_final_fade_alpha); -} - - -void menu_widgets_frame(video_frame_info_t *video_info) -{ - int i; - int top_right_x_advance = video_info->width; - - 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); - - /* Font setup */ - font_driver_bind_block(font_regular, &font_raster_regular); - font_driver_bind_block(font_bold, &font_raster_bold); - - font_raster_regular.carr.coords.vertices = 0; - font_raster_bold.carr.coords.vertices = 0; - - /* Screenshot */ - if (screenshot_loaded) - { - char shotname[256]; - menu_animation_ctx_ticker_t ticker; - - color_alpha(menu_widgets_backdrop_orig, DEFAULT_BACKDROP); - - menu_display_draw_quad(video_info, - 0, screenshot_y, - screenshot_width, screenshot_height, - video_info->width, video_info->height, - menu_widgets_backdrop_orig - ); - - color_alpha(menu_widgets_pure_white, 1.0f); - menu_widgets_draw_icon(video_info, - screenshot_thumbnail_width, screenshot_thumbnail_height, - screenshot_texture, - 0, screenshot_y, - video_info->width, video_info->height, - 0, 1, menu_widgets_pure_white - ); - - menu_display_draw_text(font_regular, - msg_hash_to_str(MSG_SCREENSHOT_SAVED), - screenshot_thumbnail_width + simple_widget_padding, settings->floats.video_font_size * 1.9f + screenshot_y, - video_info->width, video_info->height, - text_color_faint, - TEXT_ALIGN_LEFT, - 1, false, 0, true - ); - - ticker.idx = menu_animation_get_ticker_time(); - ticker.len = screenshot_shotname_length; - ticker.s = shotname; - ticker.selected = true; - ticker.str = screenshot_shotname; - - menu_animation_ticker(&ticker); - - menu_display_draw_text(font_regular, - shotname, - screenshot_thumbnail_width + simple_widget_padding, settings->floats.video_font_size * 2.9f + screenshot_y, - video_info->width, video_info->height, - text_color_info, - TEXT_ALIGN_LEFT, - 1, false, 0, true - ); - } - - /* Volume */ - if (volume_alpha > 0.0f) - { - char msg[255]; - char percentage_msg[255]; - - menu_texture_item volume_icon = 0; - - unsigned volume_width = video_info->width / 3; - unsigned volume_height = settings->floats.video_font_size * 4; - unsigned icon_size = menu_widgets_icons_textures[MENU_WIDGETS_ICON_VOLUME_MED] ? volume_height : simple_widget_padding; - unsigned text_color = COLOR_TEXT_ALPHA(0xffffffff, (unsigned)(volume_text_alpha*255.0f)); - unsigned text_color_db = COLOR_TEXT_ALPHA(text_color_faint, (unsigned)(volume_text_alpha*255.0f)); - - unsigned bar_x = icon_size; - unsigned bar_height = settings->floats.video_font_size/2; - unsigned bar_width = volume_width - bar_x - simple_widget_padding; - unsigned bar_y = volume_height / 2 + bar_height/2; - - float *bar_background = NULL; - float *bar_foreground = NULL; - float bar_percentage = 0.0f; - - if (volume_mute) - { - volume_icon = menu_widgets_icons_textures[MENU_WIDGETS_ICON_VOLUME_MUTE]; - } - else if (volume_percent <= 1.0f) - { - if (volume_percent <= 0.5f) - volume_icon = menu_widgets_icons_textures[MENU_WIDGETS_ICON_VOLUME_MIN]; - else - volume_icon = menu_widgets_icons_textures[MENU_WIDGETS_ICON_VOLUME_MED]; - - bar_background = volume_bar_background; - bar_foreground = volume_bar_normal; - bar_percentage = volume_percent; - } - else if (volume_percent > 1.0f && volume_percent <= 2.0f) - { - volume_icon = menu_widgets_icons_textures[MENU_WIDGETS_ICON_VOLUME_MAX]; - - bar_background = volume_bar_normal; - bar_foreground = volume_bar_loud; - bar_percentage = volume_percent - 1.0f; - } - else - { - volume_icon = menu_widgets_icons_textures[MENU_WIDGETS_ICON_VOLUME_MAX]; - - bar_background = volume_bar_loud; - bar_foreground = volume_bar_loudest; - bar_percentage = volume_percent - 2.0f; - } - - if (bar_percentage > 1.0f) - bar_percentage = 1.0f; - - /* Backdrop */ - color_alpha(menu_widgets_backdrop_orig, volume_alpha); - - menu_display_draw_quad(video_info, - 0, 0, - volume_width, - volume_height, - video_info->width, - video_info->height, - menu_widgets_backdrop_orig - ); - - /* Icon */ - if (volume_icon) - { - color_alpha(menu_widgets_pure_white, volume_text_alpha); - - menu_display_blend_begin(video_info); - menu_widgets_draw_icon(video_info, - icon_size, icon_size, - volume_icon, - 0, 0, - video_info->width, video_info->height, - 0, 1, menu_widgets_pure_white - ); - menu_display_blend_end(video_info); - } - - if (volume_mute) - { - if (!menu_widgets_icons_textures[MENU_WIDGETS_ICON_VOLUME_MUTE]) - { - const char *text = msg_hash_to_str(MSG_AUDIO_MUTED); - menu_display_draw_text(font_regular, - text, - volume_width/2, volume_height/2 + settings->floats.video_font_size/3, - video_info->width, video_info->height, - text_color, TEXT_ALIGN_CENTER, - 1, false, 0, false - ); - } - } - else - { - /* Bar */ - color_alpha(bar_background, volume_text_alpha); - color_alpha(bar_foreground, volume_text_alpha); - - menu_display_draw_quad(video_info, - bar_x + bar_percentage * bar_width, bar_y, - bar_width - bar_percentage * bar_width, bar_height, - video_info->width, video_info->height, - bar_background - ); - - menu_display_draw_quad(video_info, - bar_x, bar_y, - bar_percentage * bar_width, bar_height, - video_info->width, video_info->height, - bar_foreground - ); - - /* Text */ - snprintf(msg, sizeof(msg), (volume_db >= 0 ? "+%.1f dB" : "%.1f dB"), - volume_db); - - snprintf(percentage_msg, sizeof(percentage_msg), "%d%%", - (int)(volume_percent * 100.0f)); - - menu_display_draw_text(font_regular, - msg, - volume_width - simple_widget_padding, settings->floats.video_font_size * 2, - video_info->width, video_info->height, - text_color_db, - TEXT_ALIGN_RIGHT, - 1, false, 0, false - ); - - menu_display_draw_text(font_regular, - percentage_msg, - icon_size, settings->floats.video_font_size * 2, - video_info->width, video_info->height, - text_color, - TEXT_ALIGN_LEFT, - 1, false, 0, false - ); - } - } - - /* Draw all messages */ - for (i = 0; i < current_msgs->size; i++) - { - menu_widget_msg_t *msg = file_list_get_userdata_at_offset(current_msgs, i); - - if (!msg) - continue; - - if (msg->task_ptr) - menu_widgets_draw_task_msg(msg, video_info); - else - menu_widgets_draw_regular_msg(msg, video_info); - } - - /* FPS Counter */ - if (video_info->fps_show || video_info->framecount_show) - { - char *text = *menu_widgets_fps_text == '\0' ? "n/a" : menu_widgets_fps_text; - - int text_width = font_driver_get_message_width(font_regular, text, strlen(text), 1.0f); - int total_width = text_width + simple_widget_padding * 2; - - color_alpha(menu_widgets_backdrop_orig, DEFAULT_BACKDROP); - - menu_display_draw_quad(video_info, - top_right_x_advance - total_width, 0, - total_width, simple_widget_height, - video_info->width, video_info->height, - menu_widgets_backdrop_orig - ); - - menu_display_draw_text(font_regular, - text, - top_right_x_advance - simple_widget_padding - text_width, settings->floats.video_font_size + simple_widget_padding/4, - video_info->width, video_info->height, - 0xFFFFFFFF, - TEXT_ALIGN_LEFT, - 1, false,0, true - ); - } - - /* Indicators */ - if (menu_widgets_paused) - top_right_x_advance -= menu_widgets_draw_indicator(video_info, - menu_widgets_icons_textures[MENU_WIDGETS_ICON_PAUSED], (video_info->fps_show ? simple_widget_height : 0), top_right_x_advance, - MSG_PAUSED); - - if (menu_widgets_fast_forward) - top_right_x_advance -= menu_widgets_draw_indicator(video_info, - menu_widgets_icons_textures[MENU_WIDGETS_ICON_FAST_FORWARD], (video_info->fps_show ? simple_widget_height : 0), top_right_x_advance, - MSG_PAUSED); - - if (menu_widgets_rewinding) - top_right_x_advance -= menu_widgets_draw_indicator(video_info, - menu_widgets_icons_textures[MENU_WIDGETS_ICON_REWIND], (video_info->fps_show ? simple_widget_height : 0), top_right_x_advance, - MSG_REWINDING); - - if (video_info->runloop_is_slowmotion) - top_right_x_advance -= menu_widgets_draw_indicator(video_info, - menu_widgets_icons_textures[MENU_WIDGETS_ICON_SLOW_MOTION], (video_info->fps_show ? simple_widget_height : 0), top_right_x_advance, - MSG_SLOW_MOTION); - - /* Screenshot */ - if (screenshot_alpha > 0.0f) - { - color_alpha(menu_widgets_pure_white, screenshot_alpha); - menu_display_draw_quad(video_info, - 0, 0, - video_info->width, video_info->height, - video_info->width, video_info->height, - menu_widgets_pure_white - ); - } - - /* Load content animation */ - if (load_content_animation_running) - menu_widgets_draw_load_content_animation(video_info); - else - { - font_driver_flush(video_info->width, video_info->height, font_regular, video_info); - font_driver_flush(video_info->width, video_info->height, font_bold, video_info); - - font_raster_regular.carr.coords.vertices = 0; - font_raster_bold.carr.coords.vertices = 0; - } - - menu_display_unset_viewport(video_info->width, video_info->height); -} - -void menu_widgets_init(bool video_is_threaded) -{ - if (menu_widgets_inited) - return; - - menu_widgets_inited = true; - - if (!menu_display_init_first_driver(video_is_threaded)) - goto err; - - menu_widgets_frame_count = 0; - - menu_widgets_fps_text[0] = '\0'; - - msg_queue = fifo_new(MSG_QUEUE_PENDING_MAX * sizeof(menu_widget_msg_t*)); - - if (!msg_queue) - goto err; - - current_msgs = (file_list_t*)calloc(1, sizeof(file_list_t)); - - if (!current_msgs) - goto err; - - file_list_reserve(current_msgs, MSG_QUEUE_ONSCREEN_MAX); - - return; -err: - menu_widgets_free(); -} - -void menu_widgets_context_reset(bool is_threaded) -{ - char xmb_path[PATH_MAX_LENGTH]; - char menu_widgets_path[PATH_MAX_LENGTH]; - char theme_path[PATH_MAX_LENGTH]; - int i; - - char monochrome_png_path[PATH_MAX_LENGTH]; - - char ozone_path[PATH_MAX_LENGTH]; - char font_path[PATH_MAX_LENGTH]; - - settings_t *settings = config_get_ptr(); - - unsigned video_info_width; - - video_driver_get_size(&video_info_width, NULL); - - /* Textures paths */ - fill_pathname_join( - menu_widgets_path, - settings->paths.directory_assets, - "menu_widgets", - sizeof(menu_widgets_path) - ); - - fill_pathname_join( - xmb_path, - settings->paths.directory_assets, - "xmb", - sizeof(xmb_path) - ); - - /* Monochrome */ - fill_pathname_join( - theme_path, - xmb_path, - "monochrome", - sizeof(theme_path) - ); - - fill_pathname_join( - monochrome_png_path, - theme_path, - "png", - sizeof(monochrome_png_path) - ); - - /* Load textures */ - /* Icons */ - for (i = 0; i < MENU_WIDGETS_ICON_LAST; i++) - { - menu_display_reset_textures_list(menu_widgets_icons_names[i], monochrome_png_path, &menu_widgets_icons_textures[i], TEXTURE_FILTER_MIPMAP_LINEAR, NULL, NULL); - } - - /* Message queue */ - menu_display_reset_textures_list("msg_queue_icon.png", menu_widgets_path, &msg_queue_icon, TEXTURE_FILTER_LINEAR, NULL, NULL); - menu_display_reset_textures_list("msg_queue_icon_outline.png", menu_widgets_path, &msg_queue_icon_outline, TEXTURE_FILTER_LINEAR, NULL, NULL); - menu_display_reset_textures_list("msg_queue_icon_rect.png", menu_widgets_path, &msg_queue_icon_rect, TEXTURE_FILTER_NEAREST, NULL, NULL); - - msg_queue_has_icons = msg_queue_icon && msg_queue_icon_outline && msg_queue_icon_rect; - - /* Fonts paths */ - fill_pathname_join( - ozone_path, - settings->paths.directory_assets, - "ozone", - sizeof(ozone_path) - ); - - /* Fonts */ - if (settings->paths.path_font[0] == '\0') - { - fill_pathname_join(font_path, ozone_path, "regular.ttf", sizeof(font_path)); - font_regular = menu_display_font_file(font_path, settings->floats.video_font_size, is_threaded); - - fill_pathname_join(font_path, ozone_path, "bold.ttf", sizeof(font_path)); - font_bold = menu_display_font_file(font_path, settings->floats.video_font_size, is_threaded); - } - else - { - font_regular = menu_display_font_file(settings->paths.path_font, settings->floats.video_font_size, is_threaded); - font_bold = menu_display_font_file(settings->paths.path_font, settings->floats.video_font_size, is_threaded); - } - - /* Metrics */ - simple_widget_padding = settings->floats.video_font_size * 2/3; - simple_widget_height = settings->floats.video_font_size + simple_widget_padding; - glyph_width = font_driver_get_message_width(font_regular, "a", 1, 1); - - msg_queue_height = settings->floats.video_font_size * 2.5f; - - if (msg_queue_has_icons) - { - msg_queue_icon_size_y = msg_queue_height * 1.2347826087f; /* original image is 280x284 */ - msg_queue_icon_size_x = 0.98591549295f * msg_queue_icon_size_y; - } - else - { - msg_queue_icon_size_x = 0; - msg_queue_icon_size_y = 0; - } - - msg_queue_text_scale_factor = 0.69f; - msg_queue_base_width = video_info_width / 4; - msg_queue_spacing = msg_queue_height / 3; - msg_queue_glyph_width = glyph_width * msg_queue_text_scale_factor; - msg_queue_rect_start_x = msg_queue_spacing + msg_queue_icon_size_x; - msg_queue_internal_icon_size = msg_queue_icon_size_y; - msg_queue_internal_icon_offset = (msg_queue_icon_size_y - msg_queue_internal_icon_size)/2; - msg_queue_icon_offset_y = (msg_queue_icon_size_y - msg_queue_height)/2; - msg_queue_scissor_start_x = msg_queue_spacing + msg_queue_icon_size_x - (msg_queue_icon_size_x * 0.28928571428f); - msg_queue_default_rect_width = msg_queue_glyph_width * 40; - - if (msg_queue_has_icons) - msg_queue_regular_padding_x = simple_widget_padding/2; - else - msg_queue_regular_padding_x = simple_widget_padding; - - msg_queue_task_rect_start_x = msg_queue_rect_start_x - msg_queue_icon_size_x; - - msg_queue_task_text_start_x = msg_queue_task_rect_start_x + msg_queue_height/2; - - if (!menu_widgets_icons_textures[MENU_WIDGETS_ICON_HOURGLASS]) - msg_queue_task_text_start_x -= msg_queue_glyph_width*2; - - msg_queue_regular_text_start = msg_queue_rect_start_x + msg_queue_regular_padding_x; - msg_queue_regular_text_base_y = settings->floats.video_font_size * msg_queue_text_scale_factor + msg_queue_height/2; - - msg_queue_task_hourglass_x = msg_queue_rect_start_x - msg_queue_icon_size_x; -} - -void menu_widgets_context_destroy(void) -{ - int i; - if (!menu_widgets_inited) - return; - - /* TODO: Dismiss onscreen notifications that have been freed */ - - /* Textures */ - for (i = 0; i < MENU_WIDGETS_ICON_LAST; i++) - { - video_driver_texture_unload(&menu_widgets_icons_textures[i]); - } - - video_driver_texture_unload(&msg_queue_icon); - video_driver_texture_unload(&msg_queue_icon_outline); - video_driver_texture_unload(&msg_queue_icon_rect); - - /* Fonts */ - menu_display_font_free(font_regular); - menu_display_font_free(font_bold); - - font_regular = NULL; - font_bold = NULL; -} - -void menu_widgets_free(void) -{ - int i; - - menu_widgets_inited = false; - - /* Kill any pending animation */ - menu_animation_kill_by_tag(&volume_tag); - menu_animation_kill_by_tag(&generic_tag); - - /* Purge everything from the fifo */ - if (msg_queue) - { - while (fifo_read_avail(msg_queue) > 0) - { - menu_widget_msg_t *msg_widget; - - fifo_read(msg_queue, &msg_widget, sizeof(msg_widget)); - - menu_widgets_msg_queue_free(msg_widget, false); - free(msg_widget); - } - - fifo_free(msg_queue); - } - - /* Purge everything from the list */ - if (current_msgs) - { - for (i = 0; i < current_msgs->size; i++) - { - menu_widget_msg_t *msg = file_list_get_userdata_at_offset(current_msgs, i); - - menu_widgets_msg_queue_free(msg, false); - } - file_list_free(current_msgs); - } - - video_driver_texture_unload(&screenshot_texture); - - /* Font */ - video_coord_array_free(&font_raster_regular.carr); - video_coord_array_free(&font_raster_bold.carr); - - font_driver_bind_block(NULL, NULL); -} - -static void menu_widgets_volume_timer_end(void *userdata) -{ - menu_animation_ctx_entry_t entry; - - entry.cb = NULL; - entry.duration = MSG_QUEUE_ANIMATION_DURATION; - entry.easing_enum = EASING_OUT_QUAD; - entry.subject = &volume_alpha; - entry.tag = volume_tag; - entry.target_value = 0.0f; - entry.userdata = NULL; - - menu_animation_push(&entry); - - entry.subject = &volume_text_alpha; - - menu_animation_push(&entry); -} - -bool menu_widgets_volume_update_and_show(void) -{ - settings_t *settings = config_get_ptr(); - bool mute = *(audio_get_bool_ptr(AUDIO_ACTION_MUTE_ENABLE)); - 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; - volume_percent = pow(10, new_volume/20); - volume_alpha = DEFAULT_BACKDROP; - volume_text_alpha = 1.0f; - volume_mute = mute; - - /* TODO/FIXME - natinusula - - * -menu/widgets/menu_widgets.c: In function 'menu_widgets_volume_update_and_show': -menu/widgets/menu_widgets.c:1859:19: warning: assignment to 'tween_cb' {aka 'void (*)(void *)'} from incompatible pointer type 'void (*)(void)' [-Wincompatible-pointer-types] - entry.cb = menu_widgets_volume_timer_end; - ^ - * - * - */ - entry.cb = menu_widgets_volume_timer_end; - entry.duration = VOLUME_DURATION; - entry.userdata = NULL; - - menu_timer_start(&volume_timer, &entry); - - return true; -} - -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)); - - return true; -} - -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; -} - -static void menu_widgets_screenshot_fadeout(void *userdata) -{ - menu_animation_ctx_entry_t entry; - - if (!menu_widgets_inited) - return; - - entry.cb = menu_widgets_screenshot_fadeout; - entry.duration = SCREENSHOT_DURATION_OUT; - entry.easing_enum = EASING_OUT_QUAD; - entry.subject = &screenshot_alpha; - entry.tag = generic_tag; - entry.target_value = 0.0f; - entry.userdata = NULL; - - menu_animation_push(&entry); -} - -void menu_widgets_screenshot_taken(const char *shotname, const char *filename) -{ - strlcpy(screenshot_filename, filename, sizeof(screenshot_filename)); - strlcpy(screenshot_shotname, shotname, sizeof(screenshot_shotname)); -} - -void menu_widgets_take_screenshot(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; - entry.subject = &screenshot_alpha; - entry.tag = generic_tag; - entry.target_value = 1.0f; - entry.userdata = NULL; - - menu_animation_push(&entry); -} - -bool menu_widgets_task_msg_queue_push(retro_task_t *task, - const char *msg, - unsigned prio, unsigned duration, - bool flush) -{ - if (!menu_widgets_inited) - return false; - - if (task->title != NULL && !task->mute) - menu_widgets_msg_queue_push_internal(task, msg, duration, NULL, MESSAGE_QUEUE_CATEGORY_INFO, MESSAGE_QUEUE_ICON_DEFAULT, prio, flush); - - return true; -} - -static void menu_widgets_end_load_content_animation(void *userdata) -{ - task_load_content_resume(); -} - -void menu_widgets_cleanup_load_content_animation(void) -{ - load_content_animation_running = false; - free(load_content_animation_content_name); -} - -void menu_widgets_start_load_content_animation(const char *content_name, bool remove_extension) -{ - /* TODO: finish the animation based on design, correct all timings */ - /* TODO: scale the icon correctly */ - menu_animation_ctx_entry_t entry; - menu_timer_ctx_entry_t timer_entry; - int i; - - float icon_color[16] = COLOR_HEX_TO_FLOAT(0x0473C9, 1.0f); /* TODO: random color */ - unsigned timing = 0; - - /* Prepare data */ - load_content_animation_icon = 0; - - /* Abort animation if we don't have an icon */ - if (!menu_driver_get_load_content_animation_data(&load_content_animation_icon, - &load_content_animation_playlist_name) || !load_content_animation_icon) - { - menu_widgets_end_load_content_animation(NULL); - return; - } - - load_content_animation_content_name = strdup(content_name); - - if (remove_extension) - path_remove_extension(load_content_animation_content_name); - - /* Reset animation state */ - load_content_animation_icon_size = LOAD_CONTENT_ANIMATION_INITIAL_ICON_SIZE; - load_content_animation_icon_alpha = 0.0f; - load_content_animation_fade_alpha = 0.0f; - load_content_animation_final_fade_alpha = 0.0f; - - memcpy(load_content_animation_icon_color, icon_color, sizeof(load_content_animation_icon_color)); - - /* Setup the animation */ - entry.cb = NULL; - entry.easing_enum = EASING_OUT_QUAD; - entry.tag = (uintptr_t) NULL; - entry.userdata = NULL; - - /* Stage one: icon animation */ - /* Position */ - entry.duration = ANIMATION_LOAD_CONTENT_DURATION; - entry.subject = &load_content_animation_icon_size; - entry.target_value = LOAD_CONTENT_ANIMATION_TARGET_ICON_SIZE; - - menu_animation_push(&entry); - - /* Alpha */ - entry.subject = &load_content_animation_icon_alpha; - entry.target_value = 1.0f; - - menu_animation_push(&entry); - timing += entry.duration; - - /* Stage two: backdrop + text */ - entry.duration = ANIMATION_LOAD_CONTENT_DURATION*1.5; - entry.subject = &load_content_animation_fade_alpha; - entry.target_value = 1.0f; - - menu_animation_push_delayed(timing, &entry); - timing += entry.duration; - - /* Stage three: wait then color transition */ - timing += ANIMATION_LOAD_CONTENT_DURATION*1.5; - - entry.duration = ANIMATION_LOAD_CONTENT_DURATION*3; - - for (i = 0; i < 16; i++) - { - if (i == 3 || i == 7 || i == 11 || i == 15) - continue; - - entry.subject = &load_content_animation_icon_color[i]; - entry.target_value = menu_widgets_pure_white[i]; - - menu_animation_push_delayed(timing, &entry); - } - - timing += entry.duration; - - /* Stage four: wait then make everything disappear */ - timing += ANIMATION_LOAD_CONTENT_DURATION*2; - - entry.duration = ANIMATION_LOAD_CONTENT_DURATION*1.5; - entry.subject = &load_content_animation_final_fade_alpha; - entry.target_value = 1.0f; - - menu_animation_push_delayed(timing, &entry); - timing += entry.duration; - - /* Setup end */ - timer_entry.cb = menu_widgets_end_load_content_animation; - timer_entry.duration = timing; - timer_entry.userdata = NULL; - - menu_timer_start(&load_content_animation_end_timer, &timer_entry); - - /* Draw all the things */ - load_content_animation_running = true; -} - -bool menu_widgets_ready(void) -{ - return menu_widgets_inited; -} diff --git a/menu/widgets/menu_widgets.h b/menu/widgets/menu_widgets.h index 2df2b62aac..fdec3063e9 100644 --- a/menu/widgets/menu_widgets.h +++ b/menu/widgets/menu_widgets.h @@ -21,59 +21,4 @@ #include #include -#define DEFAULT_BACKDROP 0.75f - -#define MSG_QUEUE_PENDING_MAX 32 -#define MSG_QUEUE_ONSCREEN_MAX 4 - -#define MSG_QUEUE_ANIMATION_DURATION 330 -#define VOLUME_DURATION 3000 -#define SCREENSHOT_DURATION_IN 66 -#define SCREENSHOT_DURATION_OUT SCREENSHOT_DURATION_IN*10 -#define SCREENSHOT_NOTIFICATION_DURATION 4000 -#define TASK_FINISHED_DURATION 3000 -#define HOURGLASS_INTERVAL 5000 -#define HOURGLASS_DURATION 1000 - -void menu_widgets_init(bool video_is_threaded); -void menu_widgets_free(void); -bool menu_widgets_ready(void); - -bool menu_widgets_msg_queue_push(const char *msg, - unsigned duration, - char *title, - enum message_queue_icon icon, enum message_queue_category category, - unsigned prio, bool flush); - -bool menu_widgets_volume_update_and_show(void); - -bool menu_widgets_set_fps_text(char *fps_text); - -void menu_widgets_iterate(void); - -bool menu_widgets_set_paused(bool is_paused); -bool menu_widgets_set_fast_forward(bool is_fast_forward); -bool menu_widgets_set_rewind(bool is_rewind); - -bool menu_widgets_task_msg_queue_push(retro_task_t *task, - const char *msg, - unsigned prio, unsigned duration, - bool flush); - -void menu_widgets_take_screenshot(void); - -void menu_widgets_screenshot_taken(const char *shotname, const char *filename); - -void menu_widgets_start_load_content_animation(const char *content_name, bool remove_extension); -void menu_widgets_cleanup_load_content_animation(void); - -void menu_widgets_context_reset(bool is_threaded); - -void menu_widgets_context_destroy(void); - -/* All the functions below should be called in - * the video driver - once they are all added, set - * enable_menu_widgets to true for that driver */ -void menu_widgets_frame(video_frame_info_t *video_info); - #endif diff --git a/network/netplay/netplay_frontend.c b/network/netplay/netplay_frontend.c index 63b15b614f..d8757a939f 100644 --- a/network/netplay/netplay_frontend.c +++ b/network/netplay/netplay_frontend.c @@ -25,7 +25,6 @@ #include #include #include -#include #ifdef HAVE_DISCORD #include @@ -639,7 +638,7 @@ static int16_t netplay_input_state(netplay_t *netplay, } } -static void netplay_announce_cb(retro_task_t *task, void *task_data, void *user_data, const char *error) +static void netplay_announce_cb(void *task_data, void *user_data, const char *error) { RARCH_LOG("[netplay] announcing netplay game... \n"); diff --git a/retroarch.c b/retroarch.c index 7459cb79c3..8166c752f2 100644 --- a/retroarch.c +++ b/retroarch.c @@ -62,9 +62,6 @@ #include "menu/menu_driver.h" #include "menu/menu_animation.h" #include "menu/menu_input.h" -#ifdef HAVE_MENU_WIDGETS -#include "menu/widgets/menu_widgets.h" -#endif #include "menu/widgets/menu_dialog.h" #include "menu/widgets/menu_input_dialog.h" #endif @@ -2440,14 +2437,11 @@ global_t *global_get_ptr(void) return &g_extern; } -void runloop_task_msg_queue_push(retro_task_t *task, const char *msg, +void runloop_task_msg_queue_push(const char *msg, unsigned prio, unsigned duration, bool flush) { -#if defined(HAVE_MENU) && defined(HAVE_MENU_WIDGETS) - if (!video_driver_has_widgets() || !menu_widgets_task_msg_queue_push(task, msg, prio, duration, flush)) -#endif - runloop_msg_queue_push(msg, prio, duration, flush, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); + runloop_msg_queue_push(msg, prio, duration, flush, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); } void runloop_msg_queue_push(const char *msg, @@ -2458,12 +2452,6 @@ void runloop_msg_queue_push(const char *msg, { runloop_ctx_msg_info_t msg_info; -#if defined(HAVE_MENU) && defined(HAVE_MENU_WIDGETS) - /* People have 60FPS in mind when they use runloop_msg_queue_push */ - if (video_driver_has_widgets() && menu_widgets_msg_queue_push(msg, duration / 60 * 1000, title, icon, category, prio, flush)) - return; -#endif - #ifdef HAVE_THREADS runloop_msg_queue_lock(); #endif @@ -2839,12 +2827,6 @@ static enum runloop_state runloop_check_state( } #if defined(HAVE_MENU) -#ifdef HAVE_MENU_WIDGETS - menu_widgets_iterate(); -#endif - - menu_animation_update(); - if (menu_is_alive) { enum menu_action action; @@ -3260,16 +3242,9 @@ static enum runloop_state runloop_check_state( /* Display the fast forward state to the user, if needed. */ if (runloop_fastmotion) { -#if defined(HAVE_MENU) && defined(HAVE_MENU_WIDGETS) - if (!video_driver_has_widgets() || !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); + runloop_msg_queue_push( + msg_hash_to_str(MSG_FAST_FORWARD), 1, 1, false, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); } -#if defined(HAVE_MENU) && defined(HAVE_MENU_WIDGETS) - else - menu_widgets_set_fast_forward(false); -#endif old_button_state = new_button_state; old_hold_button_state = new_hold_button_state; @@ -3354,27 +3329,13 @@ static enum runloop_state runloop_check_state( { char s[128]; unsigned t = 0; -#if defined(HAVE_MENU) && defined(HAVE_MENU_WIDGETS) - bool rewinding = state_manager_check_rewind( - BIT256_GET(current_input, RARCH_REWIND), - settings->uints.rewind_granularity, - runloop_paused, s, sizeof(s), &t); -#endif s[0] = '\0'; -#if defined(HAVE_MENU) && defined(HAVE_MENU_WIDGETS) - if (!video_driver_has_widgets()) -#endif - if (state_manager_check_rewind(BIT256_GET(current_input, RARCH_REWIND), - settings->uints.rewind_granularity, runloop_is_paused, s, sizeof(s), &t)) - runloop_msg_queue_push(s, 0, t, true, NULL, - MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); - - -#if defined(HAVE_MENU) && defined(HAVE_MENU_WIDGETS) - menu_widgets_set_rewind(rewinding); -#endif + if (state_manager_check_rewind(BIT256_GET(current_input, RARCH_REWIND), + settings->uints.rewind_granularity, runloop_is_paused, s, sizeof(s), &t)) + runloop_msg_queue_push(s, 0, t, true, NULL, + MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); } /* Checks if slowmotion toggle/hold was being pressed and/or held. */ @@ -3412,22 +3373,15 @@ static enum runloop_state runloop_check_state( video_driver_cached_frame(); } -#if defined(HAVE_MENU) && defined(HAVE_MENU_WIDGETS) - if (!video_driver_has_widgets()) - { -#endif - if (state_manager_frame_is_reversed()) - runloop_msg_queue_push( - msg_hash_to_str(MSG_SLOW_MOTION_REWIND), 1, 1, false, NULL, - MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); - else - runloop_msg_queue_push( - msg_hash_to_str(MSG_SLOW_MOTION), 1, 1, false, - NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); - } -#if defined(HAVE_MENU) && defined(HAVE_MENU_WIDGETS) + if (state_manager_frame_is_reversed()) + runloop_msg_queue_push( + msg_hash_to_str(MSG_SLOW_MOTION_REWIND), 1, 1, false, NULL, + MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); + else + runloop_msg_queue_push( + msg_hash_to_str(MSG_SLOW_MOTION), 1, 1, false, + NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); } -#endif old_slowmotion_button_state = new_slowmotion_button_state; old_slowmotion_hold_button_state = new_slowmotion_hold_button_state; diff --git a/retroarch.h b/retroarch.h index feea51625b..2801ab7d6c 100644 --- a/retroarch.h +++ b/retroarch.h @@ -377,7 +377,7 @@ global_t *global_get_ptr(void); **/ int runloop_iterate(unsigned *sleep_ms); -void runloop_task_msg_queue_push(retro_task_t *task, const char *msg, +void runloop_task_msg_queue_push(const char *msg, unsigned prio, unsigned duration, bool flush); diff --git a/tasks/task_audio_mixer.c b/tasks/task_audio_mixer.c index cffe0913a8..525b627eb6 100644 --- a/tasks/task_audio_mixer.c +++ b/tasks/task_audio_mixer.c @@ -26,7 +26,6 @@ #include #include #include -#include #include "../audio/audio_driver.h" @@ -75,7 +74,7 @@ static void task_audio_mixer_load_free(retro_task_t *task) } if (mixer->cb) - mixer->cb(task, NULL, NULL, NULL); + mixer->cb(NULL, NULL, NULL); } if (!string_is_empty(nbio->path)) @@ -105,7 +104,7 @@ static int cb_nbio_audio_mixer_load(void *data, size_t len) return 0; } -static void task_audio_mixer_handle_upload_ogg(retro_task_t *task, void *task_data, +static void task_audio_mixer_handle_upload_ogg(void *task_data, void *user_data, const char *err) { audio_mixer_stream_params_t params; @@ -135,7 +134,7 @@ static void task_audio_mixer_handle_upload_ogg(retro_task_t *task, void *task_da free(user_data); } -static void task_audio_mixer_handle_upload_ogg_and_play(retro_task_t *task, void *task_data, +static void task_audio_mixer_handle_upload_ogg_and_play(void *task_data, void *user_data, const char *err) { audio_mixer_stream_params_t params; @@ -166,7 +165,7 @@ static void task_audio_mixer_handle_upload_ogg_and_play(retro_task_t *task, void free(user_data); } -static void task_audio_mixer_handle_upload_flac(retro_task_t *task, void *task_data, +static void task_audio_mixer_handle_upload_flac(void *task_data, void *user_data, const char *err) { audio_mixer_stream_params_t params; @@ -197,7 +196,7 @@ static void task_audio_mixer_handle_upload_flac(retro_task_t *task, void *task_d free(user_data); } -static void task_audio_mixer_handle_upload_flac_and_play(retro_task_t *task, void *task_data, +static void task_audio_mixer_handle_upload_flac_and_play(void *task_data, void *user_data, const char *err) { audio_mixer_stream_params_t params; @@ -228,7 +227,7 @@ static void task_audio_mixer_handle_upload_flac_and_play(retro_task_t *task, voi free(user_data); } -static void task_audio_mixer_handle_upload_mp3(retro_task_t *task, void *task_data, +static void task_audio_mixer_handle_upload_mp3(void *task_data, void *user_data, const char *err) { audio_mixer_stream_params_t params; @@ -259,7 +258,7 @@ static void task_audio_mixer_handle_upload_mp3(retro_task_t *task, void *task_da free(user_data); } -static void task_audio_mixer_handle_upload_mp3_and_play(retro_task_t *task, void *task_data, +static void task_audio_mixer_handle_upload_mp3_and_play(void *task_data, void *user_data, const char *err) { audio_mixer_stream_params_t params; @@ -290,7 +289,7 @@ static void task_audio_mixer_handle_upload_mp3_and_play(retro_task_t *task, void free(user_data); } -static void task_audio_mixer_handle_upload_mod(retro_task_t *task, void *task_data, +static void task_audio_mixer_handle_upload_mod(void *task_data, void *user_data, const char *err) { audio_mixer_stream_params_t params; @@ -321,7 +320,7 @@ static void task_audio_mixer_handle_upload_mod(retro_task_t *task, void *task_da free(user_data); } -static void task_audio_mixer_handle_upload_mod_and_play(retro_task_t *task, void *task_data, +static void task_audio_mixer_handle_upload_mod_and_play(void *task_data, void *user_data, const char *err) { audio_mixer_stream_params_t params; @@ -352,7 +351,7 @@ static void task_audio_mixer_handle_upload_mod_and_play(retro_task_t *task, void free(user_data); } -static void task_audio_mixer_handle_upload_wav(retro_task_t *task, void *task_data, +static void task_audio_mixer_handle_upload_wav(void *task_data, void *user_data, const char *err) { audio_mixer_stream_params_t params; @@ -383,7 +382,7 @@ static void task_audio_mixer_handle_upload_wav(retro_task_t *task, void *task_da free(user_data); } -static void task_audio_mixer_handle_upload_wav_and_play(retro_task_t *task, void *task_data, +static void task_audio_mixer_handle_upload_wav_and_play(void *task_data, void *user_data, const char *err) { audio_mixer_stream_params_t params; diff --git a/tasks/task_content.c b/tasks/task_content.c index 01fa34dbc3..2a96f198ba 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -65,9 +65,6 @@ #ifdef HAVE_MENU #include "../menu/menu_driver.h" -#ifdef HAVE_MENU_WIDGETS -#include "../menu/widgets/menu_widgets.h" -#endif #endif #include "../menu/menu_shader.h" @@ -166,11 +163,6 @@ static char pending_subsystem_extensions[PATH_MAX_LENGTH]; #endif static char *pending_subsystem_roms[RARCH_MAX_SUBSYSTEM_ROMS]; -#if defined(HAVE_MENU) && defined(HAVE_MENU_WIDGETS) -static bool pending_load_content_pending = false; -static bool pending_load_content_resume = false; -#endif - static int64_t content_file_read(const char *path, void **buf, int64_t *length) { #ifdef HAVE_COMPRESSION @@ -1256,27 +1248,6 @@ bool task_push_start_dummy_core(content_ctx_info_t *content_info) } #ifdef HAVE_MENU -#ifdef HAVE_MENU_WIDGETS -bool task_load_content_is_pending(void) -{ - return pending_load_content_pending; -} - -bool task_load_content_should_resume(void) -{ - /* Avoid having one menu frame before running content - once the animation is finished */ - if (pending_load_content_resume) - menu_widgets_cleanup_load_content_animation(); - - return pending_load_content_resume; -} - -void task_load_content_resume(void) -{ - pending_load_content_resume = true; -} -#endif bool task_push_load_content_from_playlist_from_menu( const char *core_path, @@ -1294,23 +1265,6 @@ bool task_push_load_content_from_playlist_from_menu( settings_t *settings = config_get_ptr(); rarch_system_info_t *sys_info = runloop_get_system_info(); -#ifdef HAVE_MENU_WIDGETS - if (video_driver_has_widgets() && menu_widgets_ready() && !pending_load_content_resume) - { - pending_load_content_pending = true; - - if (label) - menu_widgets_start_load_content_animation(label, false); - else - menu_widgets_start_load_content_animation(path_basename(fullpath), true); - - return true; - } - - pending_load_content_resume = false; - pending_load_content_pending = false; -#endif - content_ctx.check_firmware_before_loading = settings->bools.check_firmware_before_loading; content_ctx.is_ips_pref = rarch_ctl(RARCH_CTL_IS_IPS_PREF, NULL); content_ctx.is_bps_pref = rarch_ctl(RARCH_CTL_IS_BPS_PREF, NULL); @@ -1537,18 +1491,6 @@ bool task_push_load_content_with_new_core_from_menu( global_t *global = global_get_ptr(); settings_t *settings = config_get_ptr(); -#ifdef HAVE_MENU_WIDGETS - if (video_driver_has_widgets() && menu_widgets_ready() && !pending_load_content_resume) - { - pending_load_content_pending = true; - menu_widgets_start_load_content_animation(path_basename(fullpath), true); - return true; - } - - pending_load_content_resume = false; - pending_load_content_pending = false; -#endif - content_ctx.check_firmware_before_loading = settings->bools.check_firmware_before_loading; content_ctx.is_ips_pref = rarch_ctl(RARCH_CTL_IS_IPS_PREF, NULL); content_ctx.is_bps_pref = rarch_ctl(RARCH_CTL_IS_BPS_PREF, NULL); @@ -1849,18 +1791,6 @@ bool task_push_load_content_with_current_core_from_companion_ui( retro_task_callback_t cb, void *user_data) { -#if defined(HAVE_MENU) && defined(HAVE_MENU_WIDGETS) - if (video_driver_has_widgets() && menu_widgets_ready() && !pending_load_content_resume) - { - pending_load_content_pending = true; - menu_widgets_start_load_content_animation(path_basename(fullpath), true); - return true; - } - - pending_load_content_resume = false; - pending_load_content_pending = false; -#endif - /* Set content path */ path_set(RARCH_PATH_CONTENT, fullpath); @@ -1910,18 +1840,6 @@ bool task_push_load_subsystem_with_core_from_menu( retro_task_callback_t cb, void *user_data) { -#if defined(HAVE_MENU) && defined(HAVE_MENU_WIDGETS) - if (video_driver_has_widgets() && menu_widgets_ready() && !pending_load_content_resume) - { - pending_load_content_pending = true; - menu_widgets_start_load_content_animation(path_basename(fullpath), true); - return true; - } - - pending_load_content_resume = false; - pending_load_content_pending = false; -#endif - pending_subsystem_init = true; /* Load content */ diff --git a/tasks/task_content.h b/tasks/task_content.h index 4b50768044..d1f4d52162 100644 --- a/tasks/task_content.h +++ b/tasks/task_content.h @@ -82,9 +82,6 @@ bool task_push_load_content_with_new_core_from_companion_ui( void *user_data); #ifdef HAVE_MENU -bool task_load_content_is_pending(void); -bool task_load_content_should_resume(void); -void task_load_content_resume(void); bool task_push_load_content_with_new_core_from_menu( const char *core_path, diff --git a/tasks/task_database.c b/tasks/task_database.c index a6cb1f0593..27212146e6 100644 --- a/tasks/task_database.c +++ b/tasks/task_database.c @@ -1313,7 +1313,7 @@ bool task_push_dbscan( bool db_dir_show_hidden_files, retro_task_callback_t cb) { - retro_task_t *t = task_init(); + retro_task_t *t = (retro_task_t*)calloc(1, sizeof(*t)); db_handle_t *db = (db_handle_t*)calloc(1, sizeof(db_handle_t)); if (!t || !db) diff --git a/tasks/task_decompress.c b/tasks/task_decompress.c index 4810cbf822..66fa9462ea 100644 --- a/tasks/task_decompress.c +++ b/tasks/task_decompress.c @@ -335,7 +335,7 @@ bool task_push_decompress( s->archive.type = ARCHIVE_TRANSFER_INIT; s->userdata = (struct archive_extract_userdata*)calloc(1, sizeof(*s->userdata)); - t = task_init(); + t = (retro_task_t*)calloc(1, sizeof(*t)); if (!t) goto error; diff --git a/tasks/task_powerstate.c b/tasks/task_powerstate.c index e4e783a045..5c1ffc0982 100644 --- a/tasks/task_powerstate.c +++ b/tasks/task_powerstate.c @@ -39,7 +39,7 @@ enum frontend_powerstate get_last_powerstate(int *percent) return state; } -static void task_powerstate_cb(retro_task_t* task, void *task_data, +static void task_powerstate_cb(void *task_data, void *user_data, const char *error) { powerstate_t *powerstate = (powerstate_t*)task_data; diff --git a/tasks/task_save.c b/tasks/task_save.c index 957e261eef..36fb889537 100644 --- a/tasks/task_save.c +++ b/tasks/task_save.c @@ -507,7 +507,7 @@ bool content_undo_load_state(void) return ret; } -static void undo_save_state_cb(retro_task_t *task, void *task_data, +static void undo_save_state_cb(void *task_data, void *user_data, const char *error) { /* Wipe the save file buffer as it's intended to be one use only */ @@ -892,7 +892,7 @@ error: * Load a state from disk to memory. * **/ -static void content_load_state_cb(retro_task_t *task, void *task_data, +static void content_load_state_cb(void *task_data, void *user_data, const char *error) { retro_ctx_serialize_info_t serial_info; @@ -1041,7 +1041,7 @@ error: * * Called after the save state is done. Takes a screenshot if needed. **/ -static void save_state_cb(retro_task_t *task, void *task_data, +static void save_state_cb(void *task_data, void *user_data, const char *error) { save_task_state_t *state = (save_task_state_t*)task_data; @@ -1105,7 +1105,7 @@ error: * Load then save a state. * **/ -static void content_load_and_save_state_cb(retro_task_t *task, void *task_data, +static void content_load_and_save_state_cb(void *task_data, void *user_data, const char *error) { load_task_data_t *load_data = (load_task_data_t*)task_data; @@ -1114,7 +1114,7 @@ static void content_load_and_save_state_cb(retro_task_t *task, void *task_data, size_t size = load_data->undo_size; bool autosave = load_data->autosave; - content_load_state_cb(NULL, task_data, user_data, error); + content_load_state_cb(task_data, user_data, error); task_push_save_state(path, data, size, autosave); diff --git a/tasks/task_screenshot.c b/tasks/task_screenshot.c index b24c53fd0d..9788640c0d 100644 --- a/tasks/task_screenshot.c +++ b/tasks/task_screenshot.c @@ -43,10 +43,6 @@ #define IMG_EXT "bmp" #endif -#if defined(HAVE_MENU) && defined(HAVE_MENU_WIDGETS) -#include "../../menu/widgets/menu_widgets.h" -#endif - #include "../defaults.h" #include "../command.h" #include "../configuration.h" @@ -129,11 +125,6 @@ static bool screenshot_dump_direct(screenshot_task_state_t *state) bmp_type); #endif -#if defined(HAVE_MENU) && defined(HAVE_MENU_WIDGETS) - if (!state->silence) - menu_widgets_screenshot_taken(state->shotname, state->filename); -#endif - return ret; } @@ -288,11 +279,6 @@ static bool screenshot_dump( if (use_thread) { -#if defined(HAVE_MENU) && defined(HAVE_MENU_WIDGETS) - if (video_driver_has_widgets()) - task_free_title(task); - else -#endif if (!savestate) task->title = strdup(msg_hash_to_str(MSG_TAKING_SCREENSHOT)); @@ -429,11 +415,6 @@ bool take_screenshot(const char *name_base, bool silence, bool has_valid_framebu bool is_perfcnt_enable = false; bool ret = false; -#if defined(HAVE_MENU) && defined(HAVE_MENU_WIDGETS) - if (!silence) - menu_widgets_take_screenshot(); -#endif - runloop_get_status(&is_paused, &is_idle, &is_slowmotion, &is_perfcnt_enable); ret = take_screenshot_choice(name_base, silence, is_paused, is_idle, diff --git a/ui/drivers/qt/thumbnailpackdownload.cpp b/ui/drivers/qt/thumbnailpackdownload.cpp index 160ed5cec8..cdaf32d203 100644 --- a/ui/drivers/qt/thumbnailpackdownload.cpp +++ b/ui/drivers/qt/thumbnailpackdownload.cpp @@ -28,8 +28,7 @@ extern "C" { #define THUMBNAILPACK_URL_HEADER "http://thumbnailpacks.libretro.com/" #define THUMBNAILPACK_EXTENSION ".zip" -static void extractThumbnailPackCB(retro_task_t *task, - void *task_data, void *user_data, const char *err) +static void extractThumbnailPackCB(void *task_data, void *user_data, const char *err) { decompress_task_data_t *dec = (decompress_task_data_t*)task_data; MainWindow *mainwindow = (MainWindow*)user_data; diff --git a/ui/drivers/qt/ui_qt_window.cpp b/ui/drivers/qt/ui_qt_window.cpp index 2a554ca50e..0b0154ea0b 100644 --- a/ui/drivers/qt/ui_qt_window.cpp +++ b/ui/drivers/qt/ui_qt_window.cpp @@ -120,8 +120,7 @@ static const QPixmap getInvader() } #ifdef HAVE_LIBRETRODB -static void scan_finished_handler(retro_task_t *task, - void *task_data, void *user_data, const char *err) +static void scan_finished_handler(void *task_data, void *user_data, const char *err) { bool dontAsk = false; bool answer = false; diff --git a/ui/drivers/qt/updateretroarch.cpp b/ui/drivers/qt/updateretroarch.cpp index b691725edc..f5834d917c 100644 --- a/ui/drivers/qt/updateretroarch.cpp +++ b/ui/drivers/qt/updateretroarch.cpp @@ -24,8 +24,7 @@ extern "C" { #define TEMP_EXTENSION ".update_tmp" #define RETROARCH_NIGHTLY_UPDATE_PATH "../RetroArch_update.zip" -static void extractUpdateCB(retro_task_t *task, - void *task_data, void *user_data, const char *err) +static void extractUpdateCB(void *task_data, void *user_data, const char *err) { decompress_task_data_t *dec = (decompress_task_data_t*)task_data; MainWindow *mainwindow = (MainWindow*)user_data;