Add way to hide message for screenshot tasks

This commit is contained in:
twinaphex 2016-12-01 20:22:28 +01:00
parent 711e4ea634
commit 0aca3d04c0
3 changed files with 27 additions and 21 deletions

View File

@ -1899,7 +1899,7 @@ bool command_event(enum event_command cmd, void *data)
settings->state_slot++; settings->state_slot++;
break; break;
case CMD_EVENT_TAKE_SCREENSHOT: case CMD_EVENT_TAKE_SCREENSHOT:
if (!take_screenshot()) if (!take_screenshot(false))
return false; return false;
break; break;
case CMD_EVENT_UNLOAD_CORE: case CMD_EVENT_UNLOAD_CORE:

View File

@ -75,6 +75,7 @@ typedef struct
int pitch; int pitch;
bool bgr24; bool bgr24;
void *userbuf; void *userbuf;
bool hide_msg;
} screenshot_task_state_t; } screenshot_task_state_t;
/** /**
@ -174,7 +175,8 @@ static bool screenshot_dump(
const void *frame, const void *frame,
unsigned width, unsigned width,
unsigned height, unsigned height,
int pitch, bool bgr24, void *userbuf) int pitch, bool bgr24, bool hide_msg,
void *userbuf)
{ {
#ifdef _XBOX1 #ifdef _XBOX1
d3d_video_t *d3d = (d3d_video_t*)video_driver_get_ptr(true); d3d_video_t *d3d = (d3d_video_t*)video_driver_get_ptr(true);
@ -184,12 +186,13 @@ static bool screenshot_dump(
screenshot_task_state_t *state = (screenshot_task_state_t*) screenshot_task_state_t *state = (screenshot_task_state_t*)
calloc(1, sizeof(*state)); calloc(1, sizeof(*state));
state->bgr24 = bgr24; state->hide_msg = hide_msg;
state->height = height; state->bgr24 = bgr24;
state->width = width; state->height = height;
state->pitch = pitch; state->width = width;
state->frame = frame; state->pitch = pitch;
state->userbuf = userbuf; state->frame = frame;
state->userbuf = userbuf;
if (settings->auto_screenshot_filename) if (settings->auto_screenshot_filename)
fill_str_dated_filename(state->shotname, path_basename(name_base), fill_str_dated_filename(state->shotname, path_basename(name_base),
@ -215,14 +218,17 @@ static bool screenshot_dump(
task->type = TASK_TYPE_BLOCKING; task->type = TASK_TYPE_BLOCKING;
task->state = state; task->state = state;
task->handler = task_screenshot_handler; task->handler = task_screenshot_handler;
task->title = strdup(msg_hash_to_str(MSG_TAKING_SCREENSHOT));
if (!hide_msg)
task->title = strdup(msg_hash_to_str(MSG_TAKING_SCREENSHOT));
task_queue_ctl(TASK_QUEUE_CTL_PUSH, task); task_queue_ctl(TASK_QUEUE_CTL_PUSH, task);
return true; return true;
} }
#if !defined(VITA) #if !defined(VITA)
static bool take_screenshot_viewport(const char *name_base) static bool take_screenshot_viewport(const char *name_base, bool hide_msg)
{ {
char screenshot_path[PATH_MAX_LENGTH]; char screenshot_path[PATH_MAX_LENGTH];
const char *screenshot_dir = NULL; const char *screenshot_dir = NULL;
@ -257,7 +263,7 @@ static bool take_screenshot_viewport(const char *name_base)
/* Data read from viewport is in bottom-up order, suitable for BMP. */ /* Data read from viewport is in bottom-up order, suitable for BMP. */
if (!screenshot_dump(name_base, screenshot_dir, buffer, vp.width, vp.height, if (!screenshot_dump(name_base, screenshot_dir, buffer, vp.width, vp.height,
vp.width * 3, true, buffer)) vp.width * 3, true, hide_msg, buffer))
goto error; goto error;
return true; return true;
@ -269,7 +275,7 @@ error:
} }
#endif #endif
static bool take_screenshot_raw(const char *name_base, void *userbuf) static bool take_screenshot_raw(const char *name_base, bool hide_msg, void *userbuf)
{ {
size_t pitch; size_t pitch;
unsigned width, height; unsigned width, height;
@ -294,13 +300,13 @@ static bool take_screenshot_raw(const char *name_base, void *userbuf)
*/ */
if (!screenshot_dump(name_base, screenshot_dir, if (!screenshot_dump(name_base, screenshot_dir,
(const uint8_t*)data + (height - 1) * pitch, (const uint8_t*)data + (height - 1) * pitch,
width, height, -pitch, false, userbuf)) width, height, -pitch, false, hide_msg, userbuf))
return false; return false;
return true; return true;
} }
static bool take_screenshot_choice(const char *name_base) static bool take_screenshot_choice(const char *name_base, bool hide_msg)
{ {
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
@ -316,14 +322,14 @@ static bool take_screenshot_choice(const char *name_base)
if (!runloop_ctl(RUNLOOP_CTL_IS_IDLE, NULL)) if (!runloop_ctl(RUNLOOP_CTL_IS_IDLE, NULL))
video_driver_cached_frame(); video_driver_cached_frame();
#if defined(VITA) #if defined(VITA)
return take_screenshot_raw(name_base, NULL); return take_screenshot_raw(name_base, hide__msg, NULL);
#else #else
return take_screenshot_viewport(name_base); return take_screenshot_viewport(name_base, hide_msg);
#endif #endif
} }
if (!video_driver_cached_frame_has_valid_framebuffer()) if (!video_driver_cached_frame_has_valid_framebuffer())
return take_screenshot_raw(name_base, NULL); return take_screenshot_raw(name_base, hide_msg, NULL);
if (video_driver_supports_read_frame_raw()) if (video_driver_supports_read_frame_raw())
{ {
@ -345,7 +351,7 @@ static bool take_screenshot_choice(const char *name_base)
if (frame_data) if (frame_data)
{ {
video_driver_set_cached_frame_ptr(frame_data); video_driver_set_cached_frame_ptr(frame_data);
if (take_screenshot_raw(name_base, frame_data)) if (take_screenshot_raw(name_base, hide_msg, frame_data))
ret = true; ret = true;
} }
@ -360,11 +366,11 @@ static bool take_screenshot_choice(const char *name_base)
* *
* Returns: true (1) if successful, otherwise false (0). * Returns: true (1) if successful, otherwise false (0).
**/ **/
bool take_screenshot(void) bool take_screenshot(bool hide_msg)
{ {
char *name_base = strdup(path_get(RARCH_PATH_BASENAME)); char *name_base = strdup(path_get(RARCH_PATH_BASENAME));
bool is_paused = runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL); bool is_paused = runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL);
bool ret = take_screenshot_choice(name_base); bool ret = take_screenshot_choice(name_base, hide_msg);
const char *msg_screenshot = ret const char *msg_screenshot = ret
? msg_hash_to_str(MSG_TAKING_SCREENSHOT) : ? msg_hash_to_str(MSG_TAKING_SCREENSHOT) :
msg_hash_to_str(MSG_FAILED_TO_TAKE_SCREENSHOT); msg_hash_to_str(MSG_FAILED_TO_TAKE_SCREENSHOT);

View File

@ -145,7 +145,7 @@ bool content_push_to_history_playlist(
const char *core_path); const char *core_path);
/* TODO/FIXME - turn this into actual task */ /* TODO/FIXME - turn this into actual task */
bool take_screenshot(void); bool take_screenshot(bool hide_msg);
bool event_load_save_files(void); bool event_load_save_files(void);