From bf98664b15188db5b4b08b33dd6e22ac65456128 Mon Sep 17 00:00:00 2001 From: natinusala Date: Tue, 29 Jan 2019 10:32:22 +0100 Subject: [PATCH] menu_entry: hide password values --- menu/drivers/ozone/ozone_entries.c | 1 + menu/drivers/xmb.c | 5 ++++- menu/widgets/menu_entry.c | 18 +++++++++++++++++- menu/widgets/menu_entry.h | 2 ++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/menu/drivers/ozone/ozone_entries.c b/menu/drivers/ozone/ozone_entries.c index 9e842347db..49698e9d3f 100644 --- a/menu/drivers/ozone/ozone_entries.c +++ b/menu/drivers/ozone/ozone_entries.c @@ -302,6 +302,7 @@ border_iterate: ticker.len = (entry_width - 60 - ((int)utf8len(entry_rich_label) * ozone->entry_font_glyph_width)) / ozone->entry_font_glyph_width; menu_animation_ticker(&ticker); + ozone_draw_entry_value(ozone, video_info, entry_value_ticker, x_offset + 426 + entry_width, y + FONT_SIZE_ENTRIES_LABEL + 8 - 1 + scroll_y,alpha_uint32, &entry); free(entry_rich_label); diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 8308ac8829..6d3fb4cfe9 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -2962,7 +2962,10 @@ static int xmb_draw_item( if (!string_is_empty(entry->value)) { - ticker.str = entry->value; + char entry_value[255]; + menu_entry_get_value(entry, entry_value, sizeof(entry_value)); + ticker.str = entry_value; + menu_animation_ticker(&ticker); } diff --git a/menu/widgets/menu_entry.c b/menu/widgets/menu_entry.c index 2ad026d4b3..0d42ff79d7 100644 --- a/menu/widgets/menu_entry.c +++ b/menu/widgets/menu_entry.c @@ -266,9 +266,20 @@ void menu_entry_reset(uint32_t i) void menu_entry_get_value(menu_entry_t *entry, char *s, size_t len) { + size_t size, i; + if (!entry || string_is_empty(entry->value)) return; - strlcpy(s, entry->value, len); + + size = strlcpy(s, entry->value, len); + + if (menu_entry_is_password(entry)) + { + for (i = 0; i < size; i++) + { + s[i] = '*'; + } + } } void menu_entry_set_value(uint32_t i, const char *s) @@ -277,6 +288,11 @@ void menu_entry_set_value(uint32_t i, const char *s) setting_set_with_string_representation(setting, s); } +bool menu_entry_is_password(menu_entry_t *entry) +{ + return entry->enum_idx == MENU_ENUM_LABEL_CHEEVOS_PASSWORD; +} + uint32_t menu_entry_num_has_range(uint32_t i) { rarch_setting_t *setting = menu_entries_get_setting(i); diff --git a/menu/widgets/menu_entry.h b/menu/widgets/menu_entry.h index c4307bb38e..de1cd11cf9 100644 --- a/menu/widgets/menu_entry.h +++ b/menu/widgets/menu_entry.h @@ -101,6 +101,8 @@ void menu_entry_get_value(menu_entry_t *entry, char *s, size_t len); void menu_entry_set_value(uint32_t i, const char *s); +bool menu_entry_is_password(menu_entry_t *entry); + uint32_t menu_entry_num_has_range(uint32_t i); float menu_entry_num_min(uint32_t i);