Merge pull request #2705 from fr500/master

xmb && per-game options improvements
This commit is contained in:
Twinaphex 2016-02-08 07:18:11 +01:00
commit 94d227863f
13 changed files with 141 additions and 40 deletions

View File

@ -508,6 +508,9 @@ static const bool overlay_hide_in_menu = true;
#ifdef HAVE_MENU
static bool default_block_config_read = true;
static unsigned xmb_scale_factor = 100;
static unsigned xmb_alpha_factor = 75;
static bool show_advanced_settings = true;
static const uint32_t menu_entry_normal_color = 0xffffffff;
static const uint32_t menu_entry_hover_color = 0xff64ff64;

View File

@ -475,6 +475,9 @@ static void config_set_defaults(void)
if (def_menu)
strlcpy(settings->menu.driver,
def_menu, sizeof(settings->menu.driver));
settings->menu.xmb_scale_factor = xmb_scale_factor;
settings->menu.xmb_alpha_factor = xmb_alpha_factor;
settings->menu.xmb_font[0] = '\0';
#endif
settings->history_list_enable = def_history_list_enable;
@ -1513,6 +1516,9 @@ static bool config_load_file(const char *path, bool set_defaults)
config_get_array(conf, "location_driver", settings->location.driver, sizeof(settings->location.driver));
#ifdef HAVE_MENU
config_get_array(conf, "menu_driver", settings->menu.driver, sizeof(settings->menu.driver));
CONFIG_GET_INT_BASE(conf, settings, menu.xmb_scale_factor, "xmb_scale_factor");
CONFIG_GET_INT_BASE(conf, settings, menu.xmb_alpha_factor, "xmb_alpha_factor");
config_get_path(conf, "xmb_font", settings->menu.xmb_font, sizeof(settings->menu.xmb_font));
#endif
config_get_array(conf, "video_context_driver", settings->video.context_driver, sizeof(settings->video.context_driver));
config_get_array(conf, "audio_driver", settings->audio.driver, sizeof(settings->audio.driver));
@ -2724,6 +2730,10 @@ bool config_save_file(const char *path)
*settings->playlist_directory ?
settings->playlist_directory : "default");
#ifdef HAVE_MENU
config_set_int(conf, "xmb_scale_factor", settings->menu.xmb_scale_factor);
config_set_int(conf, "xmb_alpha_factor", settings->menu.xmb_alpha_factor);
config_set_path(conf, "xmb_font",
!string_is_empty(settings->menu.xmb_font) ? settings->menu.xmb_font : "");
config_set_path(conf, "rgui_browser_directory",
*settings->menu_content_directory ?
settings->menu_content_directory : "default");

View File

@ -164,6 +164,9 @@ typedef struct settings
unsigned entry_normal_color;
unsigned entry_hover_color;
unsigned title_color;
unsigned xmb_scale_factor;
unsigned xmb_alpha_factor;
char xmb_font[PATH_MAX_LENGTH];
} menu;
#endif

View File

@ -541,6 +541,11 @@ static int deferred_push_video_font_path(menu_displaylist_info_t *info)
return deferred_push_dlist(info, DISPLAYLIST_FONTS);
}
static int deferred_push_xmb_font_path(menu_displaylist_info_t *info)
{
return deferred_push_dlist(info, DISPLAYLIST_FONTS);
}
static int deferred_push_content_history_path(menu_displaylist_info_t *info)
{
return deferred_push_dlist(info, DISPLAYLIST_CONTENT_HISTORY);
@ -752,6 +757,9 @@ static int menu_cbs_init_bind_deferred_push_compare_label(
case MENU_LABEL_VIDEO_FONT_PATH:
BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_video_font_path);
break;
case MENU_LABEL_XMB_FONT:
BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_xmb_font_path);
break;
case MENU_LABEL_CONTENT_HISTORY_PATH:
BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_content_history_path);
break;

View File

@ -1535,7 +1535,7 @@ static int action_ok_option_create(const char *path,
rarch_system_info_t *system = NULL;
config_file_t *conf = NULL;
if (!rarch_option_create(game_path, sizeof(game_path)))
if (!rarch_game_options_validate(game_path, sizeof(game_path), true))
{
menu_display_msg_queue_push("Error saving core options file",
1, 100, true);

View File

@ -120,6 +120,12 @@ static int action_get_title_font_path(const char *path, const char *label,
return fill_title(s, "Font", path, len);
}
static int action_get_xmb_font_path(const char *path, const char *label,
unsigned menu_type, char *s, size_t len)
{
return fill_title(s, "Font", path, len);
}
static int action_get_title_video_shader_preset(const char *path, const char *label,
unsigned menu_type, char *s, size_t len)
{
@ -890,6 +896,9 @@ static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs,
case MENU_LABEL_VIDEO_FONT_PATH:
BIND_ACTION_GET_TITLE(cbs, action_get_title_font_path);
break;
case MENU_LABEL_XMB_FONT:
BIND_ACTION_GET_TITLE(cbs, action_get_xmb_font_path);
break;
case MENU_LABEL_VIDEO_FILTER:
BIND_ACTION_GET_TITLE(cbs, action_get_title_video_filter);
break;

View File

@ -1727,8 +1727,9 @@ static void xmb_frame(void *data)
}
/* set alpha components of colors */
coord_color[3] = coord_color[7] = coord_color[11] = coord_color[15] =
(0.75f > xmb->alpha) ? xmb->alpha : 0.75f;
coord_color[3] = coord_color[7] = coord_color[11] = coord_color[15] =
((float)settings->menu.xmb_alpha_factor/100 > xmb->alpha) ?
xmb->alpha : (float)settings->menu.xmb_alpha_factor/100;
coord_color2[3] = coord_color2[7] = coord_color2[11] = coord_color2[15] =
xmb->alpha;
@ -1863,7 +1864,7 @@ static void xmb_frame(void *data)
}
static void xmb_font(void)
static void xmb_font(xmb_handle_t *xmb)
{
int font_size;
char mediapath[PATH_MAX_LENGTH],
@ -1876,8 +1877,10 @@ static void xmb_font(void)
settings->assets_directory, "xmb", sizeof(mediapath));
fill_pathname_join(themepath,
mediapath, XMB_THEME, sizeof(themepath));
fill_pathname_join(fontpath,
themepath, "font.ttf", sizeof(fontpath));
if (string_is_empty(settings->menu.xmb_font))
fill_pathname_join(fontpath, themepath, "font.ttf", sizeof(fontpath));
else
strlcpy(fontpath, settings->menu.xmb_font,sizeof(fontpath));
if (!menu_display_init_main_font(fontpath, font_size))
RARCH_WARN("Failed to load font.");
@ -1890,13 +1893,14 @@ static void xmb_layout(xmb_handle_t *xmb)
float scale_factor;
unsigned width, height, i, current, end, new_header_height;
file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0);
settings_t *settings = config_get_ptr();
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return;
video_driver_get_size(&width, &height);
scale_factor = width / 1920.0;
scale_factor = (settings->menu.xmb_scale_factor * width) / (1920.0 * 100);
new_font_size = 32.0 * scale_factor;
new_header_height = 128.0 * scale_factor;
@ -2022,7 +2026,7 @@ static void *xmb_init(void **userdata)
menu_display_ctl(MENU_DISPLAY_CTL_SET_HEIGHT, &height);
xmb_init_horizontal_list(xmb);
xmb_font();
xmb_font(xmb);
return menu;
@ -2295,7 +2299,7 @@ static void xmb_context_reset(void *data)
fill_pathname_slash(iconpath, sizeof(iconpath));
xmb_layout(xmb);
xmb_font();
xmb_font(xmb);
xmb_context_reset_textures(xmb, iconpath);
xmb_context_reset_background(iconpath);
xmb_context_reset_horizontal_list(xmb, themepath);

View File

@ -284,6 +284,12 @@ static const char *menu_hash_to_str_us_label(uint32_t hash)
return "dpi_override_enable";
case MENU_LABEL_DPI_OVERRIDE_VALUE:
return "dpi_override_value";
case MENU_LABEL_XMB_FONT:
return "xmb_font";
case MENU_LABEL_XMB_SCALE_FACTOR:
return "xmb_scale_factor";
case MENU_LABEL_XMB_ALPHA_FACTOR:
return "xmb_alpha_factor";
case MENU_LABEL_SUSPEND_SCREENSAVER_ENABLE:
return "suspend_screensaver_enable";
case MENU_LABEL_VIDEO_DISABLE_COMPOSITION:
@ -1014,6 +1020,12 @@ const char *menu_hash_to_str_us(uint32_t hash)
return "DPI Override Enable";
case MENU_LABEL_VALUE_DPI_OVERRIDE_VALUE:
return "DPI Override";
case MENU_LABEL_VALUE_XMB_SCALE_FACTOR:
return "XMB Scale Factor";
case MENU_LABEL_VALUE_XMB_ALPHA_FACTOR:
return "XMB Alpha Factor";
case MENU_LABEL_VALUE_XMB_FONT:
return "XMB Font";
case MENU_LABEL_VALUE_SUSPEND_SCREENSAVER_ENABLE:
return "Suspend Screensaver";
case MENU_LABEL_VALUE_VIDEO_DISABLE_COMPOSITION:

View File

@ -373,6 +373,12 @@ extern "C" {
#define MENU_LABEL_VALUE_DPI_OVERRIDE_ENABLE 0xd535f449U
#define MENU_LABEL_DPI_OVERRIDE_VALUE 0x543a3efdU
#define MENU_LABEL_VALUE_DPI_OVERRIDE_VALUE 0x1462aba2U
#define MENU_LABEL_XMB_SCALE_FACTOR 0x0177E8DF1
#define MENU_LABEL_VALUE_XMB_SCALE_FACTOR 0x0DCDBDB13
#define MENU_LABEL_XMB_ALPHA_FACTOR 0x01049C5CF
#define MENU_LABEL_VALUE_XMB_ALPHA_FACTOR 0x0D5A712F1
#define MENU_LABEL_XMB_FONT 0x0ECA56CA2
#define MENU_LABEL_VALUE_XMB_FONT 0x0020337E7
#define MENU_LABEL_VOLUME_UP 0xa66e9681U
#define MENU_LABEL_VOLUME_DOWN 0xfc64f3d4U
#define MENU_LABEL_LOG_VERBOSITY 0x6648c96dU

View File

@ -5815,32 +5815,79 @@ static bool setting_append_list_menu_options(
START_SUB_GROUP(list, list_info, "Display", &group_info, &subgroup_info, parent_group);
CONFIG_BOOL(
list, list_info,
&settings->menu.dpi.override_enable,
menu_hash_to_str(MENU_LABEL_DPI_OVERRIDE_ENABLE),
menu_hash_to_str(MENU_LABEL_VALUE_DPI_OVERRIDE_ENABLE),
menu_dpi_override_enable,
menu_hash_to_str(MENU_VALUE_OFF),
menu_hash_to_str(MENU_VALUE_ON),
&group_info,
&subgroup_info,
parent_group,
general_write_handler,
general_read_handler);
/* only glui uses these values, don't show them on other drivers */
if (!strcmp(settings->menu.driver,"glui"))
{
CONFIG_BOOL(
list, list_info,
&settings->menu.dpi.override_enable,
menu_hash_to_str(MENU_LABEL_DPI_OVERRIDE_ENABLE),
menu_hash_to_str(MENU_LABEL_VALUE_DPI_OVERRIDE_ENABLE),
menu_dpi_override_enable,
menu_hash_to_str(MENU_VALUE_OFF),
menu_hash_to_str(MENU_VALUE_ON),
&group_info,
&subgroup_info,
parent_group,
general_write_handler,
general_read_handler);
CONFIG_UINT(
list, list_info,
&settings->menu.dpi.override_value,
menu_hash_to_str(MENU_LABEL_DPI_OVERRIDE_VALUE),
menu_hash_to_str(MENU_LABEL_VALUE_DPI_OVERRIDE_VALUE),
menu_dpi_override_value,
&group_info,
&subgroup_info,
parent_group,
general_write_handler,
general_read_handler);
menu_settings_list_current_add_range(list, list_info, 72, 999, 1, true, true);
CONFIG_UINT(
list, list_info,
&settings->menu.dpi.override_value,
menu_hash_to_str(MENU_LABEL_DPI_OVERRIDE_VALUE),
menu_hash_to_str(MENU_LABEL_VALUE_DPI_OVERRIDE_VALUE),
menu_dpi_override_value,
&group_info,
&subgroup_info,
parent_group,
general_write_handler,
general_read_handler);
menu_settings_list_current_add_range(list, list_info, 72, 999, 1, true, true);
}
/* only XMB uses these values, don't show them on other drivers */
if (!strcmp(settings->menu.driver,"xmb"))
{
CONFIG_UINT(
list, list_info,
&settings->menu.xmb_alpha_factor,
menu_hash_to_str(MENU_LABEL_XMB_ALPHA_FACTOR),
menu_hash_to_str(MENU_LABEL_VALUE_XMB_ALPHA_FACTOR),
xmb_alpha_factor,
&group_info,
&subgroup_info,
parent_group,
general_write_handler,
general_read_handler);
menu_settings_list_current_add_range(list, list_info, 0, 100, 1, true, true);
CONFIG_UINT(
list, list_info,
&settings->menu.xmb_scale_factor,
menu_hash_to_str(MENU_LABEL_XMB_SCALE_FACTOR),
menu_hash_to_str(MENU_LABEL_VALUE_XMB_SCALE_FACTOR),
xmb_scale_factor,
&group_info,
&subgroup_info,
parent_group,
general_write_handler,
general_read_handler);
menu_settings_list_current_add_range(list, list_info, 0, 100, 1, true, true);
CONFIG_PATH(
list, list_info,
settings->menu.xmb_font,
sizeof(settings->menu.xmb_font),
menu_hash_to_str(MENU_LABEL_XMB_FONT),
menu_hash_to_str(MENU_LABEL_VALUE_XMB_FONT),
settings->menu.xmb_font,
&group_info,
&subgroup_info,
parent_group,
general_write_handler,
general_read_handler);
settings_data_list_current_add_flags(list, list_info, SD_FLAG_ALLOW_EMPTY);
}
CONFIG_BOOL(
list, list_info,

View File

@ -1113,7 +1113,7 @@ static bool init_state(void)
return true;
}
bool rarch_option_create(char *s, size_t len)
bool rarch_game_options_validate(char *s, size_t len, bool mkdir)
{
char core_path[PATH_MAX_LENGTH];
char config_directory[PATH_MAX_LENGTH];
@ -1153,7 +1153,8 @@ bool rarch_option_create(char *s, size_t len)
fill_pathname_join(core_path,
config_directory, core_name, sizeof(core_path));
if (!path_is_directory(core_path))
if (!path_is_directory(core_path) && mkdir)
path_mkdir(core_path);
return true;

View File

@ -172,7 +172,7 @@ enum rarch_content_type rarch_path_is_media_type(const char *path);
const char *rarch_get_current_savefile_dir(void);
bool rarch_option_create(char *s, size_t len);
bool rarch_game_options_validate(char *s, size_t len, bool mkdir);
#ifdef __cplusplus
}

View File

@ -386,8 +386,6 @@ static void check_shader_dir(rarch_dir_list_t *dir_list,
/**
* rarch_game_specific_options:
*
* Environment callback function implementation.
*
* Returns: true (1) if a game specific core
* options path has been found,
* otherwise false (0).
@ -397,7 +395,7 @@ static bool rarch_game_specific_options(char **output)
char game_path[PATH_MAX_LENGTH];
config_file_t *option_file = NULL;
if (!rarch_option_create(game_path, sizeof(game_path)))
if (!rarch_game_options_validate(game_path, sizeof(game_path), false))
return false;
option_file = config_file_new(game_path);