diff --git a/config.def.h b/config.def.h index 58f03cc018..eb3a82cd48 100644 --- a/config.def.h +++ b/config.def.h @@ -452,6 +452,9 @@ static bool default_block_config_read = true; static bool collapse_subgroups_enable = true; static bool show_advanced_settings = false; +static const uint32_t menu_entry_normal_color = 0xffffffff; +static const uint32_t menu_entry_hover_color = 0xff64ff64; +static const uint32_t menu_title_color = 0xff64ff64; #else static bool default_block_config_read = false; #endif diff --git a/general.h b/general.h index 78c6a20355..93bd52ea23 100644 --- a/general.h +++ b/general.h @@ -223,6 +223,10 @@ struct settings } navigation; bool collapse_subgroups_enable; bool show_advanced_settings; + + unsigned entry_normal_color; + unsigned entry_hover_color; + unsigned title_color; } menu; #endif diff --git a/libretro-common/include/file/config_file_macros.h b/libretro-common/include/file/config_file_macros.h index 844d144203..260fb546fa 100644 --- a/libretro-common/include/file/config_file_macros.h +++ b/libretro-common/include/file/config_file_macros.h @@ -44,6 +44,12 @@ base.var = tmp; \ } while(0) +#define CONFIG_GET_HEX_BASE(conf, base, var, key) do { \ + unsigned tmp = 0; \ + if (config_get_hex(conf, key, &tmp)) \ + base.var = tmp; \ +} while(0) + #define CONFIG_GET_FLOAT_BASE(conf, base, var, key) do { \ float tmp = 0.0f; \ if (config_get_float(conf, key, &tmp)) \ @@ -59,6 +65,7 @@ #define CONFIG_GET_BOOL(var, key) CONFIG_GET_BOOL_BASE(conf, g_settings, var, key) #define CONFIG_GET_INT(var, key) CONFIG_GET_INT_BASE(conf, g_settings, var, key) #define CONFIG_GET_UINT64(var, key) CONFIG_GET_UINT64_BASE(conf, g_settings, var, key) +#define CONFIG_GET_HEX(var, key) CONFIG_GET_HEX_BASE(conf, g_settings, var, key) #define CONFIG_GET_FLOAT(var, key) CONFIG_GET_FLOAT_BASE(conf, g_settings, var, key) #define CONFIG_GET_STRING(var, key) CONFIG_GET_STRING_BASE(conf, g_settings, var, key) #define CONFIG_GET_PATH(var, key) CONFIG_GET_PATH_BASE(conf, g_settings, var, key) diff --git a/menu/drivers/glui.c b/menu/drivers/glui.c index 07b4572c1c..cb7f96d79d 100644 --- a/menu/drivers/glui.c +++ b/menu/drivers/glui.c @@ -77,11 +77,11 @@ static void glui_blit_line(gl_t *gl, float x, float y, const char *message, bool params.x = x / gl->win_width; params.y = 1.0f - y / gl->win_height; params.scale = 1.0; - params.color = FONT_COLOR_RGBA(255, 255, 255, 255); + params.color = g_settings.menu.entry_normal_color; params.full_screen = true; if (green) - params.color = FONT_COLOR_RGBA(100, 255, 100, 255); + params.color = g_settings.menu.entry_hover_color; if (!driver.video_data) return; diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index a733587b83..2837cc470a 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -34,6 +34,17 @@ #define RGUI_TERM_WIDTH (((menu->frame_buf.width - RGUI_TERM_START_X - RGUI_TERM_START_X) / (FONT_WIDTH_STRIDE))) #define RGUI_TERM_HEIGHT (((menu->frame_buf.height - RGUI_TERM_START_Y - RGUI_TERM_START_X) / (FONT_HEIGHT_STRIDE)) - 1) + + +static inline uint16_t argb32_to_rgb565(uint32_t col) +{ + unsigned r = (col & 0xff) >> 4; + unsigned g = ((col >> 8) & 0xff) >> 4; + unsigned b = ((col >> 16) & 0xff) >> 4; + unsigned a = ((col >> 24) & 0xff) >> 4; + return r | g << 4 | b << 8 | a << 12; +} + static int rgui_entry_iterate(unsigned action) { const char *label = NULL; @@ -152,6 +163,12 @@ static void color_rect(menu_handle_t *menu, static void blit_line(menu_handle_t *menu, int x, int y, const char *message, bool green) { unsigned i, j; +#if defined(GEKKO)|| defined(PSP) + const uint16_t color = green ? (3 << 0) | (10 << 4) | (3 << 8) | (7 << 12) : 0x7FFF; +#else + const uint16_t color = green ? argb32_to_rgb565(g_settings.menu.entry_hover_color) : + argb32_to_rgb565(g_settings.menu.entry_normal_color); +#endif while (*message) { @@ -168,12 +185,7 @@ static void blit_line(menu_handle_t *menu, int x, int y, const char *message, bo continue; menu->frame_buf.data[(y + j) * - (menu->frame_buf.pitch >> 1) + (x + i)] = green ? -#if defined(GEKKO)|| defined(PSP) - (3 << 0) | (10 << 4) | (3 << 8) | (7 << 12) : 0x7FFF; -#else - (15 << 0) | (7 << 4) | (15 << 8) | (7 << 12) : 0xFFFF; -#endif + (menu->frame_buf.pitch >> 1) + (x + i)] = color; } } diff --git a/menu/menu_input.c b/menu/menu_input.c index b7f415c6c4..a4581ab7a6 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -96,6 +96,27 @@ void menu_input_st_uint_callback(void *userdata, const char *str) menu_input_key_end_line(); } +void menu_input_st_hex_callback(void *userdata, const char *str) +{ + menu_handle_t *menu = menu_driver_resolve(); + + if (!menu) + return; + + if (str && *str) + { + rarch_setting_t *current_setting = NULL; + if ((current_setting = (rarch_setting_t*) + setting_data_find_setting( + menu->list_settings, menu->keyboard.label_setting))) + if (str[0] == '#') + str++; + *current_setting->value.unsigned_integer = strtoul(str, NULL, 16); + } + + menu_input_key_end_line(); +} + void menu_input_st_string_callback(void *userdata, const char *str) { diff --git a/menu/menu_input.h b/menu/menu_input.h index 126c2d9c91..c50b13a828 100644 --- a/menu/menu_input.h +++ b/menu/menu_input.h @@ -52,6 +52,7 @@ void menu_input_key_start_line(const char *label, input_keyboard_line_complete_t cb); void menu_input_st_uint_callback(void *userdata, const char *str); +void menu_input_st_hex_callback(void *userdata, const char *str); void menu_input_st_string_callback(void *userdata, const char *str); diff --git a/settings.c b/settings.c index e147116027..f80a32512f 100644 --- a/settings.c +++ b/settings.c @@ -499,6 +499,9 @@ static void config_set_defaults(void) g_settings.menu.navigation.browser.filter.supported_extensions_enable = true; g_settings.menu.collapse_subgroups_enable = collapse_subgroups_enable; g_settings.menu.show_advanced_settings = show_advanced_settings; + g_settings.menu.entry_normal_color = menu_entry_normal_color; + g_settings.menu.entry_hover_color = menu_entry_hover_color; + g_settings.menu.title_color = menu_title_color; #endif g_settings.ui.menubar_enable = true; @@ -1124,6 +1127,9 @@ static bool config_load_file(const char *path, bool set_defaults) CONFIG_GET_BOOL(menu.navigation.browser.filter.supported_extensions_enable, "menu_navigation_browser_filter_supported_extensions_enable"); CONFIG_GET_BOOL(menu.collapse_subgroups_enable, "menu_collapse_subgroups_enable"); CONFIG_GET_BOOL(menu.show_advanced_settings, "menu_show_advanced_settings"); + CONFIG_GET_HEX(menu.entry_normal_color, "menu_entry_normal_color"); + CONFIG_GET_HEX(menu.entry_hover_color, "menu_entry_hover_color"); + CONFIG_GET_HEX(menu.title_color, "menu_title_color"); CONFIG_GET_PATH(menu.wallpaper, "menu_wallpaper"); if (!strcmp(g_settings.menu.wallpaper, "default")) *g_settings.menu.wallpaper = '\0'; @@ -1997,6 +2003,12 @@ bool config_save_file(const char *path) g_settings.menu.collapse_subgroups_enable); config_set_bool(conf, "menu_show_advanced_settings", g_settings.menu.show_advanced_settings); + config_set_hex(conf, "menu_entry_normal_color", + g_settings.menu.entry_normal_color); + config_set_hex(conf, "menu_entry_hover_color", + g_settings.menu.entry_hover_color); + config_set_hex(conf, "menu_title_color", + g_settings.menu.title_color); #endif config_set_path(conf, "game_history_path", g_settings.content_history_path); diff --git a/settings_data.c b/settings_data.c index c0d234bee9..1c14619aae 100644 --- a/settings_data.c +++ b/settings_data.c @@ -1014,6 +1014,19 @@ static int setting_data_uint_action_ok_linefeed(void *data, unsigned action) return 0; } +static int setting_data_hex_action_ok_linefeed(void *data, unsigned action) +{ + rarch_setting_t *setting = (rarch_setting_t*)data; + + if (!setting) + return -1; + + menu_input_key_start_line(setting->short_description, + setting->name, 0, 0, menu_input_st_hex_callback); + + return 0; +} + static int setting_data_action_action_ok(void *data, unsigned action) { rarch_setting_t *setting = (rarch_setting_t*)data; @@ -1413,6 +1426,15 @@ static void setting_data_get_string_representation_uint(void *data, *setting->value.unsigned_integer); } +static void setting_data_get_string_representation_hex(void *data, + char *type_str, size_t type_str_size) +{ + rarch_setting_t *setting = (rarch_setting_t*)data; + if (setting) + snprintf(type_str, type_str_size, "%08x", + *setting->value.unsigned_integer); +} + /** ******* LIST BUILDING HELPER FUNCTIONS ******* **/ @@ -1693,6 +1715,51 @@ rarch_setting_t setting_data_uint_setting(const char* name, return result; } +/** + * setting_data_uint_setting: + * @name : name of setting. + * @short_description : Short description of setting. + * @target : Target of unsigned integer setting. + * @default_value : Default value (in unsigned integer format). + * @group : Group that the setting belongs to. + * @subgroup : Subgroup that the setting belongs to. + * @change_handler : Function callback for change handler function pointer. + * @read_handler : Function callback for read handler function pointer. + * + * Initializes a setting of type ST_HEX. + * + * Returns: setting of type ST_HEX. + **/ +rarch_setting_t setting_data_hex_setting(const char* name, + const char* short_description, unsigned int* target, + unsigned int default_value, const char *group, const char *subgroup, + change_handler_t change_handler, change_handler_t read_handler) +{ + rarch_setting_t result; + + memset(&result, 0, sizeof(result)); + + result.type = ST_HEX; + result.name = name; + result.size = sizeof(unsigned int); + result.short_description = short_description; + result.group = group; + result.subgroup = subgroup; + + result.change_handler = change_handler; + result.read_handler = read_handler; + result.value.unsigned_integer = target; + result.original_value.unsigned_integer = *target; + result.default_value.unsigned_integer = default_value; + result.action_start = setting_data_uint_action_start_default; + result.action_toggle = NULL; + result.action_ok = setting_data_uint_action_ok_default; + result.action_cancel = NULL; + result.get_string_representation = &setting_data_get_string_representation_hex; + + return result; +} + /** * setting_data_bind_setting: * @name : name of setting. @@ -3108,7 +3175,10 @@ static void general_write_handler(void *data) if (!(settings_list_append(list, list_info, setting_data_string_setting_options(ST_STRING, NAME, SHORT, TARGET, sizeof(TARGET), DEF, "", OPTS, group_info, subgroup_info, CHANGE_HANDLER, READ_HANDLER)))) return false; \ } -#define CONFIG_HEX(TARGET, NAME, SHORT, group_info, subgroup_info) +#define CONFIG_HEX(TARGET, NAME, SHORT, DEF, group_info, subgroup_info, CHANGE_HANDLER, READ_HANDLER) \ +{ \ + if (!(settings_list_append(list, list_info, setting_data_hex_setting(NAME, SHORT, &TARGET, DEF, group_info, subgroup_info, CHANGE_HANDLER, READ_HANDLER)))) return false; \ +} #define CONFIG_BIND(TARGET, PLAYER, PLAYER_OFFSET, NAME, SHORT, DEF, group_info, subgroup_info) \ { \ @@ -3137,6 +3207,11 @@ static void setting_data_add_special_callbacks( (*list)[idx].action_ok = setting_data_uint_action_ok_linefeed; (*list)[idx].action_cancel = NULL; break; + case ST_HEX: + (*list)[idx].action_start = setting_data_uint_action_start_linefeed; + (*list)[idx].action_ok = setting_data_hex_action_ok_linefeed; + (*list)[idx].action_cancel = NULL; + break; case ST_STRING: (*list)[idx].action_start = setting_data_string_action_start_allow_input; (*list)[idx].action_ok = setting_data_string_action_ok_allow_input; @@ -5175,6 +5250,39 @@ static bool setting_data_append_list_menu_options( general_write_handler, general_read_handler); + CONFIG_HEX( + g_settings.menu.entry_normal_color, + "menu_entry_normal_color", + "Menu entry normal color", + menu_entry_hover_color, + group_info.name, + subgroup_info.name, + general_write_handler, + general_read_handler); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_ALLOW_INPUT); + + CONFIG_HEX( + g_settings.menu.entry_hover_color, + "menu_entry_hover_color", + "Menu entry hover color", + menu_entry_hover_color, + group_info.name, + subgroup_info.name, + general_write_handler, + general_read_handler); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_ALLOW_INPUT); + + CONFIG_HEX( + g_settings.menu.title_color, + "menu_title_color", + "Menu title color", + menu_title_color, + group_info.name, + subgroup_info.name, + general_write_handler, + general_read_handler); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_ALLOW_INPUT); + END_SUB_GROUP(list, list_info); START_SUB_GROUP(list, list_info, "Browser", group_info.name, subgroup_info);