From 4d2fe14c1d908936af906e77f068f5fecce8ed17 Mon Sep 17 00:00:00 2001 From: Ryunam Date: Mon, 20 Jul 2020 19:44:55 +0200 Subject: [PATCH] Adjustments to Screenshot Notification options --- config.def.h | 6 ++-- configuration.c | 2 +- configuration.h | 2 +- gfx/gfx_widgets.h | 8 +++++ gfx/widgets/gfx_widget_screenshot.c | 56 ++++++++++++++++++++++++----- intl/msg_hash_us.h | 10 +++++- menu/menu_displaylist.c | 11 ++++-- menu/menu_setting.c | 39 ++++++++++++++++---- msg_hash.h | 3 ++ 9 files changed, 113 insertions(+), 24 deletions(-) diff --git a/config.def.h b/config.def.h index 49c6a1a07d..70564d37e7 100644 --- a/config.def.h +++ b/config.def.h @@ -773,9 +773,9 @@ static const bool audio_enable_menu_bgm = false; /*Desired duration of the screenshot notification*/ #define DEFAULT_NOTIFICATION_SHOW_SCREENSHOT_DURATION 0 -/* Display a white flashing effect when - * taking a screenshot*/ -#define DEFAULT_NOTIFICATION_SHOW_SCREENSHOT_FLASH true +/* Display a white flashing effect with the desired + * duration when taking a screenshot*/ +#define DEFAULT_NOTIFICATION_SHOW_SCREENSHOT_FLASH 0 /* Output samplerate. */ #ifdef GEKKO diff --git a/configuration.c b/configuration.c index f941096956..994a2a792c 100644 --- a/configuration.c +++ b/configuration.c @@ -1481,7 +1481,6 @@ static struct config_bool_setting *populate_settings_bool( SETTING_BOOL("notification_show_fast_forward", &settings->bools.notification_show_fast_forward, true, DEFAULT_NOTIFICATION_SHOW_FAST_FORWARD, false); #ifdef HAVE_SCREENSHOTS SETTING_BOOL("notification_show_screenshot", &settings->bools.notification_show_screenshot, true, DEFAULT_NOTIFICATION_SHOW_SCREENSHOT, false); - SETTING_BOOL("notification_show_screenshot_flash", &settings->bools.notification_show_screenshot_flash, true, DEFAULT_NOTIFICATION_SHOW_SCREENSHOT_FLASH, false); #endif SETTING_BOOL("menu_widget_scale_auto", &settings->bools.menu_widget_scale_auto, true, DEFAULT_MENU_WIDGET_SCALE_AUTO, false); SETTING_BOOL("audio_enable_menu", &settings->bools.audio_enable_menu, true, audio_enable_menu, false); @@ -1923,6 +1922,7 @@ static struct config_uint_setting *populate_settings_uint( SETTING_UINT("aspect_ratio_index", &settings->uints.video_aspect_ratio_idx, true, DEFAULT_ASPECT_RATIO_IDX, false); #ifdef HAVE_SCREENSHOTS SETTING_UINT("notification_show_screenshot_duration", &settings->uints.notification_show_screenshot_duration, true, DEFAULT_NOTIFICATION_SHOW_SCREENSHOT_DURATION, false); + SETTING_UINT("notification_show_screenshot_flash", &settings->uints.notification_show_screenshot_flash, true, DEFAULT_NOTIFICATION_SHOW_SCREENSHOT_FLASH, false); #endif #ifdef HAVE_NETWORKING SETTING_UINT("netplay_ip_port", &settings->uints.netplay_port, true, RARCH_DEFAULT_PORT, false); diff --git a/configuration.h b/configuration.h index 8ea9dc8108..5836115473 100644 --- a/configuration.h +++ b/configuration.h @@ -166,7 +166,6 @@ typedef struct settings bool notification_show_set_initial_disk; bool notification_show_fast_forward; bool notification_show_screenshot; - bool notification_show_screenshot_flash; bool menu_widget_scale_auto; bool menu_show_start_screen; bool menu_pause_libretro; @@ -563,6 +562,7 @@ typedef struct settings #endif unsigned video_shader_delay; unsigned notification_show_screenshot_duration; + unsigned notification_show_screenshot_flash; /* Accessibility */ unsigned accessibility_narrator_speech_speed; diff --git a/gfx/gfx_widgets.h b/gfx/gfx_widgets.h index d222e59706..1e5d37b2e5 100644 --- a/gfx/gfx_widgets.h +++ b/gfx/gfx_widgets.h @@ -77,6 +77,14 @@ enum notification_show_screenshot_duration NOTIFICATION_SHOW_SCREENSHOT_DURATION_LAST }; +enum notification_show_screenshot_flash +{ + NOTIFICATION_SHOW_SCREENSHOT_FLASH_NORMAL = 0, + NOTIFICATION_SHOW_SCREENSHOT_FLASH_FAST, + NOTIFICATION_SHOW_SCREENSHOT_FLASH_OFF, + NOTIFICATION_SHOW_SCREENSHOT_FLASH_LAST +}; + /* This structure holds all objects + metadata * corresponding to a particular font */ typedef struct diff --git a/gfx/widgets/gfx_widget_screenshot.c b/gfx/widgets/gfx_widget_screenshot.c index 5c999f138d..7921726888 100644 --- a/gfx/widgets/gfx_widget_screenshot.c +++ b/gfx/widgets/gfx_widget_screenshot.c @@ -74,35 +74,57 @@ static gfx_widget_screenshot_state_t* gfx_widget_screenshot_get_ptr(void) static void gfx_widget_screenshot_fadeout(void *userdata) { + settings_t *settings = config_get_ptr(); dispgfx_widget_t *p_dispwidget = (dispgfx_widget_t*)userdata; gfx_widget_screenshot_state_t* state = gfx_widget_screenshot_get_ptr(); gfx_animation_ctx_entry_t entry; entry.cb = NULL; - entry.duration = SCREENSHOT_DURATION_OUT; entry.easing_enum = EASING_OUT_QUAD; entry.subject = &state->alpha; entry.tag = gfx_widgets_get_generic_tag(p_dispwidget); entry.target_value = 0.0f; entry.userdata = NULL; + switch (settings->uints.notification_show_screenshot_flash) + { + case NOTIFICATION_SHOW_SCREENSHOT_FLASH_FAST: + entry.duration = SCREENSHOT_DURATION_OUT/2; + break; + case NOTIFICATION_SHOW_SCREENSHOT_FLASH_NORMAL: + default: + entry.duration = SCREENSHOT_DURATION_OUT; + break; + } + gfx_animation_push(&entry); } static void gfx_widgets_play_screenshot_flash(void *data) { + settings_t *settings = config_get_ptr(); dispgfx_widget_t *p_dispwidget = (dispgfx_widget_t*)data; gfx_widget_screenshot_state_t* state = gfx_widget_screenshot_get_ptr(); gfx_animation_ctx_entry_t entry; entry.cb = gfx_widget_screenshot_fadeout; - entry.duration = SCREENSHOT_DURATION_IN; entry.easing_enum = EASING_IN_QUAD; entry.subject = &state->alpha; entry.tag = gfx_widgets_get_generic_tag(p_dispwidget); entry.target_value = 1.0f; entry.userdata = p_dispwidget; + switch (settings->uints.notification_show_screenshot_flash) + { + case NOTIFICATION_SHOW_SCREENSHOT_FLASH_FAST: + entry.duration = SCREENSHOT_DURATION_IN/2; + break; + case NOTIFICATION_SHOW_SCREENSHOT_FLASH_NORMAL: + default: + entry.duration = SCREENSHOT_DURATION_IN; + break; + } + gfx_animation_push(&entry); } @@ -110,11 +132,11 @@ void gfx_widget_screenshot_taken( void *data, const char *shotname, const char *filename) { - settings_t *settings = config_get_ptr(); + settings_t *settings = config_get_ptr(); dispgfx_widget_t *p_dispwidget = (dispgfx_widget_t*)data; gfx_widget_screenshot_state_t* state = gfx_widget_screenshot_get_ptr(); - if (settings->bools.notification_show_screenshot_flash) + if (settings->uints.notification_show_screenshot_flash != NOTIFICATION_SHOW_SCREENSHOT_FLASH_OFF) gfx_widgets_play_screenshot_flash(p_dispwidget); if (settings->bools.notification_show_screenshot) @@ -135,18 +157,33 @@ static void gfx_widget_screenshot_dispose(void *userdata) static void gfx_widget_screenshot_end(void *userdata) { - gfx_animation_ctx_entry_t entry; + settings_t *settings = config_get_ptr(); dispgfx_widget_t *p_dispwidget = (dispgfx_widget_t*)userdata; gfx_widget_screenshot_state_t* state = gfx_widget_screenshot_get_ptr(); + gfx_animation_ctx_entry_t entry; entry.cb = gfx_widget_screenshot_dispose; - entry.duration = MSG_QUEUE_ANIMATION_DURATION; entry.easing_enum = EASING_OUT_QUAD; entry.subject = &state->y; entry.tag = gfx_widgets_get_generic_tag(p_dispwidget); entry.target_value = -((float)state->height); entry.userdata = NULL; + switch (settings->uints.notification_show_screenshot_duration) + { + case NOTIFICATION_SHOW_SCREENSHOT_DURATION_FAST: + entry.duration = MSG_QUEUE_ANIMATION_DURATION/1.25; + break; + case NOTIFICATION_SHOW_SCREENSHOT_DURATION_VERY_FAST: + case NOTIFICATION_SHOW_SCREENSHOT_DURATION_INSTANT: + entry.duration = MSG_QUEUE_ANIMATION_DURATION/1.5; + break; + case NOTIFICATION_SHOW_SCREENSHOT_DURATION_NORMAL: + default: + entry.duration = MSG_QUEUE_ANIMATION_DURATION; + break; + } + gfx_animation_push(&entry); } @@ -285,9 +322,6 @@ static void gfx_widget_screenshot_iterate( switch (settings->uints.notification_show_screenshot_duration) { - case NOTIFICATION_SHOW_SCREENSHOT_DURATION_NORMAL: - timer.duration = 6000; - break; case NOTIFICATION_SHOW_SCREENSHOT_DURATION_FAST: timer.duration = 2000; break; @@ -297,6 +331,10 @@ static void gfx_widget_screenshot_iterate( case NOTIFICATION_SHOW_SCREENSHOT_DURATION_INSTANT: timer.duration = 1; break; + case NOTIFICATION_SHOW_SCREENSHOT_DURATION_NORMAL: + default: + timer.duration = 6000; + break; } timer.userdata = p_dispwidget; diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index 530dc07b46..2164a93f3a 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -3490,7 +3490,15 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_SUBLABEL_NOTIFICATION_SHOW_SCREENSHOT_FLASH, - "Display a white flashing effect on-screen when taking a screenshot." + "Display a white flashing effect on-screen with the desired duration when taking a screenshot." + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_NOTIFICATION_SHOW_SCREENSHOT_FLASH_NORMAL, + "ON (Normal)" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_NOTIFICATION_SHOW_SCREENSHOT_FLASH_FAST, + "ON (Fast)" ) MSG_HASH( MENU_ENUM_LABEL_VALUE_VIDEO_FONT_PATH, diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index a27b292d2e..805768cb00 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -7574,7 +7574,7 @@ unsigned menu_displaylist_build_list( #ifdef HAVE_SCREENSHOTS {MENU_ENUM_LABEL_NOTIFICATION_SHOW_SCREENSHOT, PARSE_ONLY_BOOL, true }, {MENU_ENUM_LABEL_NOTIFICATION_SHOW_SCREENSHOT_DURATION, PARSE_ONLY_UINT, false }, - {MENU_ENUM_LABEL_NOTIFICATION_SHOW_SCREENSHOT_FLASH, PARSE_ONLY_BOOL, true }, + {MENU_ENUM_LABEL_NOTIFICATION_SHOW_SCREENSHOT_FLASH, PARSE_ONLY_UINT, false }, #endif }; @@ -7600,15 +7600,20 @@ unsigned menu_displaylist_build_list( menu_enable_widgets) build_list[i].checked = true; break; - case MENU_ENUM_LABEL_NOTIFICATION_SHOW_SCREENSHOT_DURATION: #ifdef HAVE_SCREENSHOTS + case MENU_ENUM_LABEL_NOTIFICATION_SHOW_SCREENSHOT_DURATION: if ( widgets_supported && menu_enable_widgets && notification_show_screenshot ) build_list[i].checked = true; -#endif break; + case MENU_ENUM_LABEL_NOTIFICATION_SHOW_SCREENSHOT_FLASH: + if ( widgets_supported && + menu_enable_widgets) + build_list[i].checked = true; + break; +#endif #endif default: break; diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 66c0ac3d29..a9571e54e9 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -4537,6 +4537,31 @@ static void setting_get_string_representation_uint_notification_show_screenshot_ #endif #endif +#ifdef HAVE_SCREENSHOTS +#ifdef HAVE_GFX_WIDGETS +static void setting_get_string_representation_uint_notification_show_screenshot_flash( + rarch_setting_t *setting, + char *s, size_t len) +{ + if (!setting) + return; + + switch (*setting->value.target.unsigned_integer) + { + case NOTIFICATION_SHOW_SCREENSHOT_FLASH_NORMAL: + strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOTIFICATION_SHOW_SCREENSHOT_FLASH_NORMAL), len); + break; + case NOTIFICATION_SHOW_SCREENSHOT_FLASH_FAST: + strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOTIFICATION_SHOW_SCREENSHOT_FLASH_FAST), len); + break; + case NOTIFICATION_SHOW_SCREENSHOT_FLASH_OFF: + strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF), len); + break; + } +} +#endif +#endif + static void setting_get_string_representation_uint_video_monitor_index(rarch_setting_t *setting, char *s, size_t len) { @@ -12749,20 +12774,22 @@ static bool setting_append_list( menu_settings_list_current_add_range(list, list_info, 0, NOTIFICATION_SHOW_SCREENSHOT_DURATION_LAST-1, 1, true, true); (*list)[list_info->index - 1].ui_type = ST_UI_TYPE_UINT_COMBOBOX; - CONFIG_BOOL( + CONFIG_UINT( list, list_info, - &settings->bools.notification_show_screenshot_flash, + &settings->uints.notification_show_screenshot_flash, MENU_ENUM_LABEL_NOTIFICATION_SHOW_SCREENSHOT_FLASH, MENU_ENUM_LABEL_VALUE_NOTIFICATION_SHOW_SCREENSHOT_FLASH, DEFAULT_NOTIFICATION_SHOW_SCREENSHOT_FLASH, - MENU_ENUM_LABEL_VALUE_OFF, - MENU_ENUM_LABEL_VALUE_ON, &group_info, &subgroup_info, parent_group, general_write_handler, - general_read_handler, - SD_FLAG_NONE); + general_read_handler); + (*list)[list_info->index - 1].action_ok = &setting_action_ok_uint; + (*list)[list_info->index - 1].get_string_representation = + &setting_get_string_representation_uint_notification_show_screenshot_flash; + menu_settings_list_current_add_range(list, list_info, 0, NOTIFICATION_SHOW_SCREENSHOT_FLASH_LAST-1, 1, true, true); + (*list)[list_info->index - 1].ui_type = ST_UI_TYPE_UINT_COMBOBOX; #endif #endif diff --git a/msg_hash.h b/msg_hash.h index 5e37d1b7b1..9263eb4e76 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -2579,6 +2579,9 @@ enum msg_hash_enums MENU_ENUM_LABEL_VALUE_NOTIFICATION_SHOW_SCREENSHOT_DURATION_VERY_FAST, MENU_ENUM_LABEL_VALUE_NOTIFICATION_SHOW_SCREENSHOT_DURATION_INSTANT, + MENU_ENUM_LABEL_VALUE_NOTIFICATION_SHOW_SCREENSHOT_FLASH_NORMAL, + MENU_ENUM_LABEL_VALUE_NOTIFICATION_SHOW_SCREENSHOT_FLASH_FAST, + MENU_LABEL(SELECT_FILE), MENU_LABEL(SELECT_FROM_PLAYLIST),