Merge pull request #1821 from lakkatv/boxarts

(XMB) Add boxarts support
This commit is contained in:
Twinaphex 2015-06-18 04:43:10 +02:00
commit b89ebebb42
7 changed files with 86 additions and 5 deletions

View File

@ -549,6 +549,7 @@ static void config_set_defaults(void)
settings->menu.timedate_enable = true;
settings->menu.core_enable = true;
settings->menu.dynamic_wallpaper_enable = false;
settings->menu.boxart_enable = false;
*settings->menu.wallpaper = '\0';
settings->menu.collapse_subgroups_enable = collapse_subgroups_enable;
settings->menu.show_advanced_settings = show_advanced_settings;
@ -674,6 +675,7 @@ static void config_set_defaults(void)
*settings->core_assets_directory = '\0';
*settings->assets_directory = '\0';
*settings->dynamic_wallpapers_directory = '\0';
*settings->boxarts_directory = '\0';
*settings->playlist_directory = '\0';
*settings->video.shader_path = '\0';
*settings->video.shader_dir = '\0';
@ -1216,6 +1218,7 @@ static bool config_load_file(const char *path, bool set_defaults)
CONFIG_GET_BOOL_BASE(conf, settings, menu.timedate_enable, "menu_timedate_enable");
CONFIG_GET_BOOL_BASE(conf, settings, menu.core_enable, "menu_core_enable");
CONFIG_GET_BOOL_BASE(conf, settings, menu.dynamic_wallpaper_enable, "menu_dynamic_wallpaper_enable");
CONFIG_GET_BOOL_BASE(conf, settings, menu.boxart_enable, "menu_boxart_enable");
CONFIG_GET_BOOL_BASE(conf, settings, menu.navigation.wraparound.horizontal_enable, "menu_navigation_wraparound_horizontal_enable");
CONFIG_GET_BOOL_BASE(conf, settings, menu.navigation.wraparound.vertical_enable, "menu_navigation_wraparound_vertical_enable");
CONFIG_GET_BOOL_BASE(conf, settings, menu.navigation.browser.filter.supported_extensions_enable, "menu_navigation_browser_filter_supported_extensions_enable");
@ -1450,6 +1453,7 @@ static bool config_load_file(const char *path, bool set_defaults)
config_get_path(conf, "core_assets_directory", settings->core_assets_directory, sizeof(settings->core_assets_directory));
config_get_path(conf, "assets_directory", settings->assets_directory, sizeof(settings->assets_directory));
config_get_path(conf, "dynamic_wallpapers_directory", settings->dynamic_wallpapers_directory, sizeof(settings->dynamic_wallpapers_directory));
config_get_path(conf, "boxarts_directory", settings->boxarts_directory, sizeof(settings->boxarts_directory));
config_get_path(conf, "playlist_directory", settings->playlist_directory, sizeof(settings->playlist_directory));
if (!strcmp(settings->core_assets_directory, "default"))
*settings->core_assets_directory = '\0';
@ -1457,6 +1461,8 @@ static bool config_load_file(const char *path, bool set_defaults)
*settings->assets_directory = '\0';
if (!strcmp(settings->dynamic_wallpapers_directory, "default"))
*settings->dynamic_wallpapers_directory = '\0';
if (!strcmp(settings->boxarts_directory, "default"))
*settings->boxarts_directory = '\0';
if (!strcmp(settings->playlist_directory, "default"))
*settings->playlist_directory = '\0';
#ifdef HAVE_MENU
@ -2341,6 +2347,7 @@ bool config_save_file(const char *path)
config_set_bool(conf,"menu_timedate_enable", settings->menu.timedate_enable);
config_set_bool(conf,"menu_core_enable", settings->menu.core_enable);
config_set_bool(conf,"menu_dynamic_wallpaper_enable", settings->menu.dynamic_wallpaper_enable);
config_set_bool(conf,"menu_boxart_enable", settings->menu.boxart_enable);
config_set_path(conf, "menu_wallpaper", settings->menu.wallpaper);
#endif
config_set_bool(conf, "video_vsync", settings->video.vsync);
@ -2427,9 +2434,9 @@ bool config_save_file(const char *path)
config_set_path(conf, "dynamic_wallpapers_directory",
*settings->dynamic_wallpapers_directory ?
settings->dynamic_wallpapers_directory : "default");
config_set_path(conf, "dynamic_wallpapers_directory",
*settings->dynamic_wallpapers_directory ?
settings->dynamic_wallpapers_directory : "default");
config_set_path(conf, "boxarts_directory",
*settings->boxarts_directory ?
settings->boxarts_directory : "default");
config_set_path(conf, "playlist_directory",
*settings->playlist_directory ?
settings->playlist_directory : "default");

View File

@ -112,6 +112,7 @@ typedef struct settings
bool timedate_enable;
bool core_enable;
bool dynamic_wallpaper_enable;
bool boxart_enable;
bool throttle;
char wallpaper[PATH_MAX_LENGTH];
@ -313,6 +314,7 @@ typedef struct settings
char core_assets_directory[PATH_MAX_LENGTH];
char assets_directory[PATH_MAX_LENGTH];
char dynamic_wallpapers_directory[PATH_MAX_LENGTH];
char boxarts_directory[PATH_MAX_LENGTH];
char menu_config_directory[PATH_MAX_LENGTH];
#if defined(HAVE_MENU)
char menu_content_directory[PATH_MAX_LENGTH];

View File

@ -106,6 +106,7 @@ typedef struct xmb_handle
char box_message[PATH_MAX_LENGTH];
float x;
float alpha;
GLuint boxart;
struct
{
@ -522,6 +523,26 @@ end:
string_list_free(list);
}
static void xmb_update_boxart(xmb_handle_t *xmb, unsigned i)
{
settings_t *settings = config_get_ptr();
menu_list_t *menu_list = menu_list_get_ptr();
menu_entry_t entry;
menu_entry_get(&entry, i, menu_list->selection_buf, true);
char path[PATH_MAX_LENGTH] = {0};
fill_pathname_join(path, settings->boxarts_directory, entry.path, sizeof(path));
strlcat(path, ".png", sizeof(path));
if (path_file_exists(path))
rarch_main_data_msg_queue_push(DATA_TYPE_IMAGE, path,
"cb_menu_boxart", 0, 1, true);
else
xmb->boxart = 0;
}
static void xmb_selection_pointer_changed(void)
{
unsigned i, current, end;
@ -530,6 +551,7 @@ static void xmb_selection_pointer_changed(void)
menu_display_t *disp = menu_display_get_ptr();
menu_navigation_t *nav = menu_navigation_get_ptr();
menu_list_t *menu_list = menu_list_get_ptr();
settings_t *settings = config_get_ptr();
if (!menu)
return;
@ -559,6 +581,9 @@ static void xmb_selection_pointer_changed(void)
{
ia = xmb->item.active.alpha;
iz = xmb->item.active.zoom;
if (settings->menu.boxart_enable)
xmb_update_boxart(xmb, i);
}
menu_animation_push(disp->animation,
@ -819,6 +844,7 @@ static void xmb_list_switch(xmb_handle_t *xmb)
menu_display_t *disp = menu_display_get_ptr();
menu_navigation_t *nav = menu_navigation_get_ptr();
menu_list_t *menu_list = menu_list_get_ptr();
settings_t *settings = config_get_ptr();
if (!menu)
return;
@ -843,6 +869,9 @@ static void xmb_list_switch(xmb_handle_t *xmb)
xmb_list_switch_new(xmb, menu_list->selection_buf,
dir, nav->selection_ptr);
xmb->categories.active.idx_old = xmb->categories.selection_ptr;
if (settings->menu.boxart_enable)
xmb_update_boxart(xmb, 0);
}
static void xmb_list_open_horizontal_list(xmb_handle_t *xmb, menu_handle_t *menu)
@ -948,7 +977,7 @@ static void xmb_populate_entries(const char *path,
}
static GLuint xmb_icon_get_id(xmb_handle_t *xmb,
xmb_node_t *core_node, unsigned type)
xmb_node_t *core_node, xmb_node_t *node, unsigned type, bool active)
{
switch(type)
{
@ -957,6 +986,8 @@ static GLuint xmb_icon_get_id(xmb_handle_t *xmb,
case MENU_FILE_PLAIN:
return xmb->textures.list[XMB_TEXTURE_FILE].id;
case MENU_FILE_PLAYLIST_ENTRY:
if (xmb->boxart && active && node && node->zoom == 1)
return xmb->boxart;
if (core_node)
return core_node->content_icon;
return xmb->textures.list[XMB_TEXTURE_FILE].id;
@ -1079,7 +1110,7 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl,
if (entry.type == MENU_FILE_CONTENTLIST_ENTRY)
strlcpy(entry.path, path_basename(entry.path), sizeof(entry.path));
icon = xmb_icon_get_id(xmb, core_node, entry.type);
icon = xmb_icon_get_id(xmb, core_node, node, entry.type, (i == current));
switch (hash_label)
{
@ -1670,6 +1701,8 @@ static bool xmb_load_image(void *data, menu_image_type_t type)
TEXTURE_BACKEND_OPENGL, TEXTURE_FILTER_MIPMAP_LINEAR);
break;
case MENU_IMAGE_BOXART:
xmb->boxart = video_texture_load(data,
TEXTURE_BACKEND_OPENGL, TEXTURE_FILTER_MIPMAP_LINEAR);
break;
}

View File

@ -75,6 +75,8 @@ const char *menu_hash_to_str(uint32_t hash)
return "Menu Wallpaper";
case MENU_LABEL_VALUE_DYNAMIC_WALLPAPER:
return "Dynamic Wallpaper";
case MENU_LABEL_VALUE_BOXART:
return "Display Boxart";
}
return "null";

View File

@ -81,6 +81,7 @@ extern "C" {
#define MENU_LABEL_VALUE_MENU_WALLPAPER 0x4555d2a2U
#define MENU_LABEL_VALUE_DYNAMIC_WALLPAPER 0x66928c32U
#define MENU_LABEL_VALUE_BOXART 0x716441ebU
#define MENU_LABEL_PAL60_ENABLE 0x62bc416eU
#define MENU_LABEL_SYSTEM_BGM_ENABLE 0x9287a1c5U
@ -143,6 +144,7 @@ extern "C" {
#define MENU_LABEL_SAVESTATE_DIRECTORY 0x90551289U
#define MENU_LABEL_ASSETS_DIRECTORY 0xde1ae8ecU
#define MENU_LABEL_DYNAMIC_WALLPAPERS_DIRECTORY 0x62f975b8U
#define MENU_LABEL_BOXARTS_DIRECTORY 0x9e2bdbddU
#define MENU_LABEL_SLOWMOTION_RATIO 0x626b3ffeU
#define MENU_LABEL_INPUT_AXIS_THRESHOLD 0xe95c2095U

View File

@ -5723,6 +5723,19 @@ static bool setting_append_list_menu_options(
general_write_handler,
general_read_handler);
CONFIG_BOOL(
settings->menu.boxart_enable,
"menu_boxart_enable",
menu_hash_to_str(MENU_LABEL_VALUE_BOXART),
true,
"OFF",
"ON",
group_info.name,
subgroup_info.name,
parent_group,
general_write_handler,
general_read_handler);
CONFIG_BOOL(
settings->menu.pause_libretro,
"menu_pause_libretro",
@ -6543,6 +6556,22 @@ static bool setting_append_list_directory_options(
list_info,
SD_FLAG_ALLOW_EMPTY | SD_FLAG_PATH_DIR | SD_FLAG_BROWSER_ACTION);
CONFIG_DIR(
settings->boxarts_directory,
"boxarts_directory",
"Boxarts Directory",
"",
"<default>",
group_info.name,
subgroup_info.name,
parent_group,
general_write_handler,
general_read_handler);
settings_data_list_current_add_flags(
list,
list_info,
SD_FLAG_ALLOW_EMPTY | SD_FLAG_PATH_DIR | SD_FLAG_BROWSER_ACTION);
CONFIG_DIR(
settings->menu_content_directory,
"rgui_browser_directory",

View File

@ -93,6 +93,9 @@
# loaded by the menu depending on context.
# dynamic_wallpapers_directory =
# Boxarts directory. To store boxart PNG files.
# boxarts_directory =
# Sets start directory for menu config browser.
# rgui_config_directory =
@ -622,6 +625,9 @@
# Dynamically load a new wallpaper depending on context.
# menu_dynamic_wallpaper_enable = false
# Display boxart in place of the content icon if available
# menu_boxart_enable = false
# Wrap-around toe beginning and/or end if boundary of list reached horizontally
# menu_navigation_wraparound_horizontal_enable = false