mirror of
https://github.com/CTCaer/RetroArch.git
synced 2025-01-25 12:46:03 +00:00
Merge pull request #8668 from natinusala/master
Menu widgets and database task improvements
This commit is contained in:
commit
7d72a1b6ab
@ -114,10 +114,15 @@ struct retro_task
|
||||
/* task identifier */
|
||||
uint32_t ident;
|
||||
|
||||
/* frontend userdata
|
||||
/* frontend userdata
|
||||
* (e.g. associate a sticky notification to a task) */
|
||||
void *frontend_userdata;
|
||||
|
||||
/* if set to true, frontend will
|
||||
use an alternative look for the
|
||||
task progress display */
|
||||
bool alternative_look;
|
||||
|
||||
/* don't touch this. */
|
||||
retro_task_t *next;
|
||||
};
|
||||
|
@ -448,7 +448,6 @@ static bool menu_widgets_msg_queue_push_internal(retro_task_t *task, const char
|
||||
|
||||
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);
|
||||
|
||||
@ -460,15 +459,24 @@ static bool menu_widgets_msg_queue_push_internal(retro_task_t *task, const char
|
||||
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;
|
||||
if (!task->alternative_look)
|
||||
{
|
||||
menu_animation_ctx_entry_t entry;
|
||||
|
||||
menu_animation_push(&entry);
|
||||
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);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg_widget_msg_transition_animation_done(msg_widget);
|
||||
}
|
||||
|
||||
msg_widget->task_count++;
|
||||
|
||||
@ -882,7 +890,6 @@ void menu_widgets_iterate(void)
|
||||
/* 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;
|
||||
|
||||
@ -904,17 +911,7 @@ void menu_widgets_iterate(void)
|
||||
|
||||
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);
|
||||
screenshot_y = 0.0f;
|
||||
|
||||
timer.cb = menu_widgets_screenshot_end;
|
||||
timer.duration = SCREENSHOT_NOTIFICATION_DURATION;
|
||||
@ -2029,7 +2026,7 @@ static void menu_widgets_screenshot_fadeout(void *userdata)
|
||||
if (!menu_widgets_inited)
|
||||
return;
|
||||
|
||||
entry.cb = menu_widgets_screenshot_fadeout;
|
||||
entry.cb = NULL;
|
||||
entry.duration = SCREENSHOT_DURATION_OUT;
|
||||
entry.easing_enum = EASING_OUT_QUAD;
|
||||
entry.subject = &screenshot_alpha;
|
||||
@ -2060,6 +2057,9 @@ static void menu_widgets_play_screenshot_flash(void)
|
||||
|
||||
void menu_widgets_screenshot_taken(const char *shotname, const char *filename)
|
||||
{
|
||||
if (!menu_widgets_inited)
|
||||
return;
|
||||
|
||||
menu_widgets_play_screenshot_flash();
|
||||
strlcpy(screenshot_filename, filename, sizeof(screenshot_filename));
|
||||
strlcpy(screenshot_shotname, shotname, sizeof(screenshot_shotname));
|
||||
|
@ -30,7 +30,7 @@
|
||||
#define VOLUME_DURATION 3000
|
||||
#define SCREENSHOT_DURATION_IN 66
|
||||
#define SCREENSHOT_DURATION_OUT SCREENSHOT_DURATION_IN*10
|
||||
#define SCREENSHOT_NOTIFICATION_DURATION 4000
|
||||
#define SCREENSHOT_NOTIFICATION_DURATION 6000
|
||||
#define CHEEVO_NOTIFICATION_DURATION 4000
|
||||
#define TASK_FINISHED_DURATION 3000
|
||||
#define HOURGLASS_INTERVAL 5000
|
||||
|
@ -15,6 +15,7 @@
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <compat/strcasestr.h>
|
||||
#include <compat/strl.h>
|
||||
#include <retro_miscellaneous.h>
|
||||
@ -151,8 +152,10 @@ static int task_database_iterate_start(retro_task_t *task,
|
||||
if (!string_is_empty(msg))
|
||||
{
|
||||
#ifdef RARCH_INTERNAL
|
||||
runloop_msg_queue_push(msg, 1, 180, true, NULL,
|
||||
MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
||||
task_free_title(task);
|
||||
task_set_title(task, strdup(msg));
|
||||
if (db->list->size != 0)
|
||||
task_set_progress(task, roundf((float)db->list_ptr / (float)db->list->size * 100.0f));
|
||||
#else
|
||||
fprintf(stderr, "msg: %s\n", msg);
|
||||
#endif
|
||||
@ -1208,8 +1211,6 @@ static void task_database_handler(retro_task_t *task)
|
||||
db->handle = database_info_file_init(db->fullpath, DATABASE_TYPE_ITERATE, task);
|
||||
}
|
||||
|
||||
task_free_title(task);
|
||||
|
||||
if (db->handle)
|
||||
db->handle->status = DATABASE_STATUS_ITERATE_BEGIN;
|
||||
}
|
||||
@ -1302,7 +1303,9 @@ static void task_database_handler(retro_task_t *task)
|
||||
else
|
||||
msg = msg_hash_to_str(MSG_SCANNING_OF_FILE_FINISHED);
|
||||
#ifdef RARCH_INTERNAL
|
||||
runloop_msg_queue_push(msg, 0, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
||||
task_free_title(task);
|
||||
task_set_title(task, strdup(msg));
|
||||
task_set_progress(task, 100);
|
||||
#else
|
||||
fprintf(stderr, "msg: %s\n", msg);
|
||||
#endif
|
||||
@ -1365,6 +1368,7 @@ bool task_push_dbscan(
|
||||
t->state = db;
|
||||
t->callback = cb;
|
||||
t->title = strdup(msg_hash_to_str(MSG_PREPARING_FOR_CONTENT_SCAN));
|
||||
t->alternative_look = true;
|
||||
|
||||
db->show_hidden_files = db_dir_show_hidden_files;
|
||||
db->is_directory = directory;
|
||||
|
@ -129,11 +129,6 @@ static bool screenshot_dump_direct(screenshot_task_state_t *state)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_MENU) && defined(HAVE_MENU_WIDGETS)
|
||||
if (!state->silence)
|
||||
menu_widgets_screenshot_taken(state->shotname, state->filename);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -158,7 +153,13 @@ static void task_screenshot_handler(retro_task_t *task)
|
||||
if (state->userbuf)
|
||||
free(state->userbuf);
|
||||
|
||||
free(state);
|
||||
#ifdef HAVE_MENU_WIDGETS
|
||||
/* If menu widgets are enabled, state is freed
|
||||
in the callback after the notification
|
||||
is displayed */
|
||||
if (!video_driver_has_widgets())
|
||||
#endif
|
||||
free(state);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -194,6 +195,23 @@ static void task_screenshot_handler(retro_task_t *task)
|
||||
task_free_title(task);
|
||||
}
|
||||
|
||||
#ifdef HAVE_MENU_WIDGETS
|
||||
static void task_screenshot_callback(retro_task_t *task,
|
||||
void *task_data,
|
||||
void *user_data, const char *error)
|
||||
{
|
||||
screenshot_task_state_t *state = (screenshot_task_state_t*)task->state;
|
||||
|
||||
if (!video_driver_has_widgets())
|
||||
return;
|
||||
|
||||
if (state && !state->silence)
|
||||
menu_widgets_screenshot_taken(state->shotname, state->filename);
|
||||
|
||||
free(state);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Take frame bottom-up. */
|
||||
static bool screenshot_dump(
|
||||
const char *name_base,
|
||||
@ -295,6 +313,9 @@ static bool screenshot_dump(
|
||||
task->type = TASK_TYPE_BLOCKING;
|
||||
task->state = state;
|
||||
task->handler = task_screenshot_handler;
|
||||
#ifdef HAVE_MENU_WIDGETS
|
||||
task->callback = task_screenshot_callback;
|
||||
#endif
|
||||
|
||||
if (use_thread)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user