From 499d61cb3de680c3908024e33775af1ae878d1eb Mon Sep 17 00:00:00 2001 From: retrotails Date: Tue, 23 Apr 2019 04:33:10 -0400 Subject: [PATCH 1/2] added rgui snow --- config.def.h | 1 + configuration.c | 1 + configuration.h | 1 + intl/msg_hash_lbl.h | 2 ++ intl/msg_hash_us.h | 8 ++++++++ menu/cbs/menu_cbs_sublabel.c | 4 ++++ menu/drivers/rgui.c | 33 +++++++++++++++++++++++++++++++++ menu/menu_displaylist.c | 1 + menu/menu_setting.c | 15 +++++++++++++++ msg_hash.h | 1 + 10 files changed, 67 insertions(+) diff --git a/config.def.h b/config.def.h index da181acbd0..ca91b51560 100644 --- a/config.def.h +++ b/config.def.h @@ -398,6 +398,7 @@ static bool rgui_full_width_layout = true; static unsigned rgui_aspect = RGUI_ASPECT_RATIO_4_3; static unsigned rgui_aspect_lock = RGUI_ASPECT_RATIO_LOCK_NONE; static bool rgui_shadows = false; +static bool rgui_snow = false; static bool rgui_extended_ascii = false; #else diff --git a/configuration.c b/configuration.c index f6f2a90c65..dfe65bbea3 100644 --- a/configuration.c +++ b/configuration.c @@ -1509,6 +1509,7 @@ static struct config_bool_setting *populate_settings_bool(settings_t *settings, SETTING_BOOL("rgui_border_filler_thickness_enable", &settings->bools.menu_rgui_border_filler_thickness_enable, true, true, false); SETTING_BOOL("rgui_border_filler_enable", &settings->bools.menu_rgui_border_filler_enable, true, true, false); SETTING_BOOL("menu_rgui_shadows", &settings->bools.menu_rgui_shadows, true, rgui_shadows, false); + SETTING_BOOL("menu_rgui_snow", &settings->bools.menu_rgui_snow, true, rgui_snow, false); SETTING_BOOL("menu_rgui_full_width_layout", &settings->bools.menu_rgui_full_width_layout, true, rgui_full_width_layout, false); SETTING_BOOL("rgui_inline_thumbnails", &settings->bools.menu_rgui_inline_thumbnails, true, rgui_inline_thumbnails, false); SETTING_BOOL("rgui_swap_thumbnails", &settings->bools.menu_rgui_swap_thumbnails, true, rgui_swap_thumbnails, false); diff --git a/configuration.h b/configuration.h index fee6d81663..199361ffcc 100644 --- a/configuration.h +++ b/configuration.h @@ -173,6 +173,7 @@ typedef struct settings bool menu_rgui_border_filler_enable; bool menu_rgui_full_width_layout; bool menu_rgui_shadows; + bool menu_rgui_snow; bool menu_rgui_inline_thumbnails; bool menu_rgui_swap_thumbnails; bool menu_rgui_extended_ascii; diff --git a/intl/msg_hash_lbl.h b/intl/msg_hash_lbl.h index f270b20e18..083258a442 100644 --- a/intl/msg_hash_lbl.h +++ b/intl/msg_hash_lbl.h @@ -1627,6 +1627,8 @@ MSG_HASH(MENU_ENUM_LABEL_MENU_RGUI_FULL_WIDTH_LAYOUT, "menu_rgui_full_width_layout") MSG_HASH(MENU_ENUM_LABEL_MENU_RGUI_SHADOWS, "menu_rgui_shadows") +MSG_HASH(MENU_ENUM_LABEL_MENU_RGUI_SNOW, + "menu_rgui_snow") MSG_HASH(MENU_ENUM_LABEL_MENU_RGUI_EXTENDED_ASCII, "rgui_extended_ascii") MSG_HASH(MENU_ENUM_LABEL_CONTENT_SHOW_REWIND, diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index 4718895150..7a911cafeb 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -6958,6 +6958,14 @@ MSG_HASH( MENU_ENUM_SUBLABEL_MENU_RGUI_SHADOWS, "Enable drop shadows for menu text, borders and thumbnails. Has a modest performance impact." ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_MENU_RGUI_SNOW, + "Snow" + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_MENU_RGUI_SNOW, + "Enable snow, forces menu to update every frame" + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_MENU_RGUI_EXTENDED_ASCII, "Extended ASCII Support" diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c index 06ebd27a3b..4c11c837a2 100644 --- a/menu/cbs/menu_cbs_sublabel.c +++ b/menu/cbs/menu_cbs_sublabel.c @@ -535,6 +535,7 @@ default_sublabel_macro(action_bind_sublabel_menu_rgui_aspect_ratio_lock, default_sublabel_macro(action_bind_sublabel_rgui_menu_color_theme, MENU_ENUM_SUBLABEL_RGUI_MENU_COLOR_THEME) default_sublabel_macro(action_bind_sublabel_rgui_menu_theme_preset, MENU_ENUM_SUBLABEL_RGUI_MENU_THEME_PRESET) default_sublabel_macro(action_bind_sublabel_menu_rgui_shadows, MENU_ENUM_SUBLABEL_MENU_RGUI_SHADOWS) +default_sublabel_macro(action_bind_sublabel_menu_rgui_snow, MENU_ENUM_SUBLABEL_MENU_RGUI_SNOW) default_sublabel_macro(action_bind_sublabel_menu_rgui_inline_thumbnails, MENU_ENUM_SUBLABEL_MENU_RGUI_INLINE_THUMBNAILS) default_sublabel_macro(action_bind_sublabel_menu_rgui_swap_thumbnails, MENU_ENUM_SUBLABEL_MENU_RGUI_SWAP_THUMBNAILS) default_sublabel_macro(action_bind_sublabel_menu_rgui_thumbnail_downscaler, MENU_ENUM_SUBLABEL_MENU_RGUI_THUMBNAIL_DOWNSCALER) @@ -2451,6 +2452,9 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs, case MENU_ENUM_LABEL_MENU_RGUI_SHADOWS: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_menu_rgui_shadows); break; + case MENU_ENUM_LABEL_MENU_RGUI_SNOW: + BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_menu_rgui_snow); + break; case MENU_ENUM_LABEL_MENU_RGUI_INLINE_THUMBNAILS: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_menu_rgui_inline_thumbnails); break; diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index 176a64b40d..d4a1b293cc 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -484,6 +484,7 @@ typedef struct bool border_thickness; bool border_enable; bool shadow_enable; + bool snow_enable; bool extended_ascii_enable; float scroll_y; char *msgbox; @@ -518,6 +519,8 @@ static unsigned mini_thumbnail_max_height = 0; static bool font_lut[NUM_FONT_GLYPHS_EXTENDED][FONT_WIDTH * FONT_HEIGHT]; +float snowflakes[1024]; + /* ============================== * Custom Symbols (glyphs) START * ============================== */ @@ -1553,6 +1556,14 @@ static void rgui_cache_background(rgui_t *rgui) 6, fb_height - 5, fb_width - 10, 1, rgui->colors.shadow_color); } } + if (rgui->snow_enable) { + for (int i = 0; i < 1024; i += 4) { + snowflakes[i ] = rand()%fb_width; + snowflakes[i + 1] = rand()%fb_height; + snowflakes[i + 2] = (rand()%64 - 16)*.1; + snowflakes[i + 3] = (rand()%64 - 48)*.1; + } + } } static void prepare_rgui_colors(rgui_t *rgui, settings_t *settings) @@ -2428,6 +2439,19 @@ static void rgui_render(void *data, bool is_idle) /* Render background */ rgui_render_background(); + + /* Snow */ + if (rgui->snow_enable) { + for (int i = 0; i < 1024; i += 4) { + snowflakes[i + 2] = fmin(fmax(snowflakes[i + 2] + (rand()%16 - 9)*.01, -0.4), 0.1); + snowflakes[i + 3] = fmin(fmax(snowflakes[i + 3] + (rand()%16 - 7)*.01, -0.1), 0.4); + snowflakes[i ] = fmod(snowflakes[i ] + snowflakes[i + 2], fb_width); + snowflakes[i + 1] = fmod(snowflakes[i + 1] + snowflakes[i + 3], fb_height); + if (snowflakes[i ] < 0) snowflakes[i ] += fb_width; + if (snowflakes[i + 1] < 0) snowflakes[i + 1] += fb_height; + rgui_frame_buf.data[ (int) snowflakes[i+1] * (fb_pitch >> 1) + (int) snowflakes[i]] = rgui->colors.normal_color; + } + } /* We use a single ticker for all text animations, * with the following configuration: */ @@ -3143,6 +3167,7 @@ static void *rgui_init(void **userdata, bool video_is_threaded) rgui->border_thickness = settings->bools.menu_rgui_border_filler_thickness_enable; rgui->border_enable = settings->bools.menu_rgui_border_filler_enable; rgui->shadow_enable = settings->bools.menu_rgui_shadows; + rgui->snow_enable = settings->bools.menu_rgui_snow; rgui->extended_ascii_enable = settings->bools.menu_rgui_extended_ascii; rgui->last_width = rgui_frame_buf.width; @@ -3637,6 +3662,8 @@ static void rgui_frame(void *data, video_frame_info_t *video_info) { rgui_t *rgui = (rgui_t*)data; settings_t *settings = config_get_ptr(); + if (rgui->snow_enable) + rgui->force_redraw = true; if (settings->bools.menu_rgui_background_filler_thickness_enable != rgui->bg_thickness) { @@ -3669,6 +3696,12 @@ static void rgui_frame(void *data, video_frame_info_t *video_info) rgui->force_redraw = true; } + if (settings->bools.menu_rgui_snow != rgui->snow_enable) + { + rgui->snow_enable = settings->bools.menu_rgui_snow; + rgui->bg_modified = true; + } + if (settings->bools.menu_rgui_extended_ascii != rgui->extended_ascii_enable) { rgui_set_blit_functions( diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 8b3ec7ebe1..d098ba3d73 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -4411,6 +4411,7 @@ unsigned menu_displaylist_build_list(file_list_t *list, enum menu_displaylist_ct {MENU_ENUM_LABEL_RGUI_MENU_COLOR_THEME, PARSE_ONLY_UINT}, {MENU_ENUM_LABEL_RGUI_MENU_THEME_PRESET, PARSE_ONLY_PATH}, {MENU_ENUM_LABEL_MENU_RGUI_SHADOWS, PARSE_ONLY_BOOL}, + {MENU_ENUM_LABEL_MENU_RGUI_SNOW, PARSE_ONLY_BOOL}, {MENU_ENUM_LABEL_DPI_OVERRIDE_ENABLE, PARSE_ONLY_BOOL}, {MENU_ENUM_LABEL_DPI_OVERRIDE_VALUE, PARSE_ONLY_UINT}, {MENU_ENUM_LABEL_XMB_ALPHA_FACTOR, PARSE_ONLY_UINT}, diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 9f4c137f95..91e2d4fec3 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -8599,6 +8599,21 @@ static bool setting_append_list( general_read_handler, SD_FLAG_NONE); + CONFIG_BOOL( + list, list_info, + &settings->bools.menu_rgui_snow, + MENU_ENUM_LABEL_MENU_RGUI_SNOW, + MENU_ENUM_LABEL_VALUE_MENU_RGUI_SNOW, + rgui_snow, + 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); + CONFIG_BOOL( list, list_info, &settings->bools.menu_rgui_extended_ascii, diff --git a/msg_hash.h b/msg_hash.h index 15e20520be..c6302d7190 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -873,6 +873,7 @@ enum msg_hash_enums MENU_LABEL(MENU_RGUI_ASPECT_RATIO_LOCK), MENU_LABEL(MENU_RGUI_FULL_WIDTH_LAYOUT), MENU_LABEL(MENU_RGUI_SHADOWS), + MENU_LABEL(MENU_RGUI_SNOW), MENU_LABEL(MENU_RGUI_EXTENDED_ASCII), MENU_LABEL(MENU_LINEAR_FILTER), MENU_LABEL(MENU_HORIZONTAL_ANIMATION), From b69c005c8591f6a58f0a471369400b6554c5eb5e Mon Sep 17 00:00:00 2001 From: retrotails Date: Tue, 23 Apr 2019 13:48:06 -0400 Subject: [PATCH 2/2] fix compiler errors --- menu/drivers/rgui.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index d4a1b293cc..ce637c524e 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -1557,7 +1557,8 @@ static void rgui_cache_background(rgui_t *rgui) } } if (rgui->snow_enable) { - for (int i = 0; i < 1024; i += 4) { + size_t i = 0; + for (i = 0; i < 1024; i += 4) { snowflakes[i ] = rand()%fb_width; snowflakes[i + 1] = rand()%fb_height; snowflakes[i + 2] = (rand()%64 - 16)*.1; @@ -2441,10 +2442,14 @@ static void rgui_render(void *data, bool is_idle) rgui_render_background(); /* Snow */ - if (rgui->snow_enable) { - for (int i = 0; i < 1024; i += 4) { - snowflakes[i + 2] = fmin(fmax(snowflakes[i + 2] + (rand()%16 - 9)*.01, -0.4), 0.1); - snowflakes[i + 3] = fmin(fmax(snowflakes[i + 3] + (rand()%16 - 7)*.01, -0.1), 0.4); + if (rgui->snow_enable && rgui_frame_buf.data) { + for (i = 0; i < 1024; i += 4) { + snowflakes[i + 2] = snowflakes[i + 2] + (rand()%16 - 9)*.01; + snowflakes[i + 3] = snowflakes[i + 3] + (rand()%16 - 7)*.01; + if (snowflakes[i + 2] < -0.4) snowflakes[i + 2] = -0.4; + if (snowflakes[i + 2] > 0.1) snowflakes[i + 2] = 0.1; + if (snowflakes[i + 3] < -0.1) snowflakes[i + 3] = -0.1; + if (snowflakes[i + 3] > 0.4) snowflakes[i + 3] = 0.4; snowflakes[i ] = fmod(snowflakes[i ] + snowflakes[i + 2], fb_width); snowflakes[i + 1] = fmod(snowflakes[i + 1] + snowflakes[i + 3], fb_height); if (snowflakes[i ] < 0) snowflakes[i ] += fb_width;