2016-02-09 16:12:39 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
|
|
|
* Copyright (C) 2011-2016 - Higor Euripedes
|
|
|
|
* Copyright (C) 2011-2016 - Daniel De Matteis
|
|
|
|
*
|
|
|
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
2016-02-09 17:11:11 +00:00
|
|
|
#include "tasks_internal.h"
|
2016-02-09 16:12:39 +00:00
|
|
|
|
|
|
|
#include "../msg_hash.h"
|
|
|
|
#include "../runloop.h"
|
|
|
|
|
2016-02-09 17:11:11 +00:00
|
|
|
static void task_queue_msg_push(unsigned prio, unsigned duration,
|
2016-02-09 16:12:39 +00:00
|
|
|
bool flush, const char *fmt, ...)
|
|
|
|
{
|
|
|
|
char buf[1024];
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
va_start(ap, fmt);
|
|
|
|
vsnprintf(buf, sizeof(buf), fmt, ap);
|
|
|
|
va_end(ap);
|
|
|
|
runloop_msg_queue_push(buf, prio, duration, flush);
|
|
|
|
}
|
|
|
|
|
2016-02-09 16:56:36 +00:00
|
|
|
void task_queue_push_progress(retro_task_t *task)
|
2016-02-09 16:12:39 +00:00
|
|
|
{
|
|
|
|
if (task->title)
|
|
|
|
{
|
|
|
|
if (task->finished)
|
|
|
|
{
|
|
|
|
if (task->error)
|
2016-02-09 17:11:11 +00:00
|
|
|
task_queue_msg_push(1, 60, true, "%s: %s",
|
2016-02-09 16:12:39 +00:00
|
|
|
msg_hash_to_str(MSG_TASK_FAILED), task->title);
|
|
|
|
else
|
2016-02-09 17:11:11 +00:00
|
|
|
task_queue_msg_push(1, 60, true, "100%%: %s", task->title);
|
2016-02-09 16:12:39 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (task->progress >= 0 && task->progress <= 100)
|
2016-02-09 17:11:11 +00:00
|
|
|
task_queue_msg_push(1, 60, true, "%i%%: %s",
|
2016-02-09 16:12:39 +00:00
|
|
|
task->progress, task->title);
|
|
|
|
else
|
2016-02-09 17:11:11 +00:00
|
|
|
task_queue_msg_push(1, 60, true, "%s...", task->title);
|
2016-02-09 16:12:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|