From 802bbcb3216ace34469f37980daa06051b21efcb Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 7 Apr 2014 22:12:23 +0200 Subject: [PATCH] (Menu) Add Font Options --- frontend/menu/menu_common.c | 8 ++++++++ frontend/menu/menu_common.h | 4 ++++ frontend/menu/menu_settings.c | 34 ++++++++++++++++++++++++++++++++++ settings.c | 4 ++++ 4 files changed, 50 insertions(+) diff --git a/frontend/menu/menu_common.c b/frontend/menu/menu_common.c index aed93cf33d..e51e7d3f39 100644 --- a/frontend/menu/menu_common.c +++ b/frontend/menu/menu_common.c @@ -972,6 +972,7 @@ static int menu_settings_iterate(void *data, unsigned action) || menu_type == RGUI_SETTINGS_PRIVACY_OPTIONS || menu_type == RGUI_SETTINGS_GENERAL_OPTIONS || menu_type == RGUI_SETTINGS_VIDEO_OPTIONS + || menu_type == RGUI_SETTINGS_FONT_OPTIONS || menu_type == RGUI_SETTINGS_SHADER_OPTIONS ) menu_populate_entries(rgui, menu_type); @@ -1904,6 +1905,12 @@ void menu_populate_entries(void *data, unsigned menu_type) file_list_push(rgui->selection_buf, "Monitor Index", RGUI_SETTINGS_VIDEO_MONITOR_INDEX, 0); file_list_push(rgui->selection_buf, "Estimated Monitor FPS", RGUI_SETTINGS_VIDEO_REFRESH_RATE_AUTO, 0); break; + case RGUI_SETTINGS_FONT_OPTIONS: + file_list_clear(rgui->selection_buf); + file_list_push(rgui->selection_buf, "OSD Font Enable", RGUI_SETTINGS_FONT_ENABLE, 0); + file_list_push(rgui->selection_buf, "OSD Font Scale to Window", RGUI_SETTINGS_FONT_SCALE, 0); + file_list_push(rgui->selection_buf, "OSD Font Size", RGUI_SETTINGS_FONT_SIZE, 0); + break; case RGUI_SETTINGS_CORE_OPTIONS: file_list_clear(rgui->selection_buf); @@ -1992,6 +1999,7 @@ void menu_populate_entries(void *data, unsigned menu_type) #ifdef HAVE_SHADER_MANAGER file_list_push(rgui->selection_buf, "Shader Options", RGUI_SETTINGS_SHADER_OPTIONS, 0); #endif + file_list_push(rgui->selection_buf, "Font Options", RGUI_SETTINGS_FONT_OPTIONS, 0); file_list_push(rgui->selection_buf, "Audio Options", RGUI_SETTINGS_AUDIO_OPTIONS, 0); file_list_push(rgui->selection_buf, "Input Options", RGUI_SETTINGS_INPUT_OPTIONS, 0); #ifdef HAVE_OVERLAY diff --git a/frontend/menu/menu_common.h b/frontend/menu/menu_common.h index 72aea820b6..0c7a85ed0a 100644 --- a/frontend/menu/menu_common.h +++ b/frontend/menu/menu_common.h @@ -89,6 +89,10 @@ typedef enum RGUI_SETTINGS_VIDEO_REFRESH_RATE_AUTO, RGUI_SETTINGS_VIDEO_MONITOR_INDEX, RGUI_SETTINGS_VIDEO_OPTIONS_LAST, + RGUI_SETTINGS_FONT_OPTIONS, + RGUI_SETTINGS_FONT_ENABLE, + RGUI_SETTINGS_FONT_SCALE, + RGUI_SETTINGS_FONT_SIZE, RGUI_SETTINGS_SHADER_OPTIONS, RGUI_SETTINGS_SHADER_FILTER, RGUI_SETTINGS_SHADER_PRESET, diff --git a/frontend/menu/menu_settings.c b/frontend/menu/menu_settings.c index 6f4f047f8b..1b26a3cfa0 100644 --- a/frontend/menu/menu_settings.c +++ b/frontend/menu/menu_settings.c @@ -95,6 +95,7 @@ unsigned menu_type_is(unsigned type) type == RGUI_SETTINGS_CORE_OPTIONS || type == RGUI_SETTINGS_CORE_INFO || type == RGUI_SETTINGS_VIDEO_OPTIONS || + type == RGUI_SETTINGS_FONT_OPTIONS || type == RGUI_SETTINGS_SHADER_OPTIONS || type == RGUI_SETTINGS_AUDIO_OPTIONS || type == RGUI_SETTINGS_DISK_OPTIONS || @@ -1876,6 +1877,29 @@ int menu_set_settings(void *data, unsigned setting, unsigned action) g_settings.location.allow = false; break; #endif + case RGUI_SETTINGS_FONT_ENABLE: + if (action == RGUI_ACTION_OK || action == RGUI_ACTION_LEFT || action == RGUI_ACTION_RIGHT) + g_settings.video.font_enable = !g_settings.video.font_enable; + else if (action == RGUI_ACTION_START) + g_settings.video.font_enable = true; + break; + case RGUI_SETTINGS_FONT_SCALE: + if (action == RGUI_ACTION_OK || action == RGUI_ACTION_LEFT || action == RGUI_ACTION_RIGHT) + g_settings.video.font_scale = !g_settings.video.font_scale; + else if (action == RGUI_ACTION_START) + g_settings.video.font_scale = true; + break; + case RGUI_SETTINGS_FONT_SIZE: + if (action == RGUI_ACTION_LEFT) + { + if (g_settings.video.font_size >= 0) + g_settings.video.font_size--; + } + else if (action == RGUI_ACTION_RIGHT) + g_settings.video.font_size++; + else if (action == RGUI_ACTION_START) + g_settings.video.font_size = 0; + break; default: break; } @@ -2118,6 +2142,7 @@ void menu_set_settings_label(char *type_str, size_t type_str_size, unsigned *w, case RGUI_SETTINGS_CUSTOM_VIEWPORT: case RGUI_SETTINGS_TOGGLE_FULLSCREEN: case RGUI_SETTINGS_VIDEO_OPTIONS: + case RGUI_SETTINGS_FONT_OPTIONS: case RGUI_SETTINGS_AUDIO_OPTIONS: case RGUI_SETTINGS_DISK_OPTIONS: #ifdef HAVE_SHADER_MANAGER @@ -2324,6 +2349,15 @@ void menu_set_settings_label(char *type_str, size_t type_str_size, unsigned *w, snprintf(type_str, type_str_size, g_settings.osk.enable ? "ON" : "OFF"); break; #endif + case RGUI_SETTINGS_FONT_ENABLE: + snprintf(type_str, type_str_size, g_settings.video.font_enable ? "ON" : "OFF"); + break; + case RGUI_SETTINGS_FONT_SCALE: + snprintf(type_str, type_str_size, g_settings.video.font_scale ? "ON" : "OFF"); + break; + case RGUI_SETTINGS_FONT_SIZE: + snprintf(type_str, type_str_size, "%.1f", g_settings.video.font_size); + break; default: *type_str = '\0'; *w = 0; diff --git a/settings.c b/settings.c index 31cc0c5f28..228c7d1efc 100644 --- a/settings.c +++ b/settings.c @@ -1298,6 +1298,10 @@ bool config_save_file(const char *path) config_set_bool(conf, "location_allow", g_settings.location.allow); #endif + config_set_bool(conf, "video_font_scale", g_settings.video.font_scale); + config_set_float(conf, "video_font_size", g_settings.video.font_size); + config_set_bool(conf, "video_font_enable", g_settings.video.font_enable); + config_set_path(conf, "system_directory", *g_settings.system_directory ? g_settings.system_directory : "default"); config_set_path(conf, "extraction_directory", g_settings.extraction_directory); config_set_string(conf, "audio_resampler", g_settings.audio.resampler);