task_database: reimplement task progression

This commit is contained in:
natinusala 2019-04-30 13:22:05 +02:00
parent c59fbbd2f2
commit 486f438cc3
3 changed files with 32 additions and 17 deletions

View File

@ -114,10 +114,15 @@ struct retro_task
/* task identifier */ /* task identifier */
uint32_t ident; uint32_t ident;
/* frontend userdata /* frontend userdata
* (e.g. associate a sticky notification to a task) */ * (e.g. associate a sticky notification to a task) */
void *frontend_userdata; 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. */ /* don't touch this. */
retro_task_t *next; retro_task_t *next;
}; };

View File

@ -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) if (task->title != msg_widget->task_title_ptr)
{ {
menu_animation_ctx_entry_t entry;
unsigned len = strlen(task->title); unsigned len = strlen(task->title);
unsigned new_width = font_driver_get_message_width(font_regular, task->title, len, msg_queue_text_scale_factor); 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->task_title_ptr = task->title;
msg_widget->msg_transition_animation = 0; msg_widget->msg_transition_animation = 0;
entry.easing_enum = EASING_OUT_QUAD; if (!task->alternative_look)
entry.tag = (uintptr_t) NULL; {
entry.duration = MSG_QUEUE_ANIMATION_DURATION*2; menu_animation_ctx_entry_t entry;
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); 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++; msg_widget->task_count++;

View File

@ -15,6 +15,7 @@
* If not, see <http://www.gnu.org/licenses/>. * If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <math.h>
#include <compat/strcasestr.h> #include <compat/strcasestr.h>
#include <compat/strl.h> #include <compat/strl.h>
#include <retro_miscellaneous.h> #include <retro_miscellaneous.h>
@ -151,8 +152,10 @@ static int task_database_iterate_start(retro_task_t *task,
if (!string_is_empty(msg)) if (!string_is_empty(msg))
{ {
#ifdef RARCH_INTERNAL #ifdef RARCH_INTERNAL
runloop_msg_queue_push(msg, 1, 180, true, NULL, task_free_title(task);
MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); 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 #else
fprintf(stderr, "msg: %s\n", msg); fprintf(stderr, "msg: %s\n", msg);
#endif #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); db->handle = database_info_file_init(db->fullpath, DATABASE_TYPE_ITERATE, task);
} }
task_free_title(task);
if (db->handle) if (db->handle)
db->handle->status = DATABASE_STATUS_ITERATE_BEGIN; db->handle->status = DATABASE_STATUS_ITERATE_BEGIN;
} }
@ -1296,14 +1297,14 @@ static void task_database_handler(retro_task_t *task)
} }
else else
{ {
#ifdef RARCH_INTERNAL
task_set_progress(task, 100);
#else
const char *msg = NULL; const char *msg = NULL;
if (db->is_directory) if (db->is_directory)
msg = msg_hash_to_str(MSG_SCANNING_OF_DIRECTORY_FINISHED); msg = msg_hash_to_str(MSG_SCANNING_OF_DIRECTORY_FINISHED);
else else
msg = msg_hash_to_str(MSG_SCANNING_OF_FILE_FINISHED); 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);
#else
fprintf(stderr, "msg: %s\n", msg); fprintf(stderr, "msg: %s\n", msg);
#endif #endif
ui_companion_driver_notify_refresh(); ui_companion_driver_notify_refresh();
@ -1365,6 +1366,7 @@ bool task_push_dbscan(
t->state = db; t->state = db;
t->callback = cb; t->callback = cb;
t->title = strdup(msg_hash_to_str(MSG_PREPARING_FOR_CONTENT_SCAN)); 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->show_hidden_files = db_dir_show_hidden_files;
db->is_directory = directory; db->is_directory = directory;