mirror of
https://github.com/libretro/RetroArch.git
synced 2025-05-13 08:46:10 +00:00
Refactor menu driver's 'load wallpaper' function
This commit is contained in:
parent
3536ac86e4
commit
6ce7e5b571
@ -512,9 +512,8 @@ static void glui_context_destroy(void)
|
|||||||
glDeleteTextures(1, &glui->textures.bg.id);
|
glDeleteTextures(1, &glui->textures.bg.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool glui_load_wallpaper(const char *path)
|
static bool glui_load_wallpaper(void *data)
|
||||||
{
|
{
|
||||||
struct texture_image ti = {0};
|
|
||||||
glui_handle_t *glui = NULL;
|
glui_handle_t *glui = NULL;
|
||||||
menu_handle_t *menu = menu_driver_resolve();
|
menu_handle_t *menu = menu_driver_resolve();
|
||||||
|
|
||||||
@ -525,29 +524,19 @@ static bool glui_load_wallpaper(const char *path)
|
|||||||
|
|
||||||
if (!glui)
|
if (!glui)
|
||||||
return false;
|
return false;
|
||||||
if (!path)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (glui->textures.bg.id)
|
if (glui->textures.bg.id)
|
||||||
glDeleteTextures(1, &glui->textures.bg.id);
|
glDeleteTextures(1, &glui->textures.bg.id);
|
||||||
|
|
||||||
if (! path_file_exists(path))
|
glui->textures.bg.id = menu_texture_load(data,
|
||||||
return false;
|
|
||||||
|
|
||||||
texture_image_load(&ti, path);
|
|
||||||
|
|
||||||
strlcpy(glui->textures.bg.path, path, sizeof(glui->textures.bg.path));
|
|
||||||
|
|
||||||
glui->textures.bg.id = menu_texture_load(&ti,
|
|
||||||
TEXTURE_BACKEND_OPENGL, TEXTURE_FILTER_MIPMAP_LINEAR);
|
TEXTURE_BACKEND_OPENGL, TEXTURE_FILTER_MIPMAP_LINEAR);
|
||||||
|
|
||||||
texture_image_free(&ti);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void glui_context_reset(void)
|
static void glui_context_reset(void)
|
||||||
{
|
{
|
||||||
|
const char *path = NULL;
|
||||||
glui_handle_t *glui = NULL;
|
glui_handle_t *glui = NULL;
|
||||||
menu_handle_t *menu = menu_driver_resolve();
|
menu_handle_t *menu = menu_driver_resolve();
|
||||||
|
|
||||||
@ -570,8 +559,19 @@ static void glui_context_reset(void)
|
|||||||
glui->textures.bg.path, "bg.png",
|
glui->textures.bg.path, "bg.png",
|
||||||
sizeof(glui->textures.bg.path));
|
sizeof(glui->textures.bg.path));
|
||||||
|
|
||||||
if (path_file_exists(glui->textures.bg.path))
|
path = glui->textures.bg.path;
|
||||||
glui_load_wallpaper(glui->textures.bg.path);
|
|
||||||
|
if (path_file_exists(path))
|
||||||
|
{
|
||||||
|
struct texture_image ti = {0};
|
||||||
|
texture_image_load(&ti, path);
|
||||||
|
|
||||||
|
strlcpy(glui->textures.bg.path, path, sizeof(glui->textures.bg.path));
|
||||||
|
|
||||||
|
glui_load_wallpaper(&ti);
|
||||||
|
|
||||||
|
texture_image_free(&ti);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void glui_navigation_clear(bool pending_push)
|
static void glui_navigation_clear(bool pending_push)
|
||||||
|
@ -1391,9 +1391,8 @@ static bool xmb_font_init_first(const gl_font_renderer_t **font_driver,
|
|||||||
font_path, xmb_font_size);
|
font_path, xmb_font_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool xmb_load_wallpaper(const char *path)
|
static bool xmb_load_wallpaper(void *data)
|
||||||
{
|
{
|
||||||
struct texture_image ti = {0};
|
|
||||||
xmb_handle_t *xmb = NULL;
|
xmb_handle_t *xmb = NULL;
|
||||||
menu_handle_t *menu = menu_driver_resolve();
|
menu_handle_t *menu = menu_driver_resolve();
|
||||||
|
|
||||||
@ -1404,23 +1403,15 @@ static bool xmb_load_wallpaper(const char *path)
|
|||||||
|
|
||||||
if (!xmb)
|
if (!xmb)
|
||||||
return false;
|
return false;
|
||||||
if (!path)
|
if (!data)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (xmb->textures.bg.id)
|
if (xmb->textures.bg.id)
|
||||||
glDeleteTextures(1, &xmb->textures.bg.id);
|
glDeleteTextures(1, &xmb->textures.bg.id);
|
||||||
|
|
||||||
if (! path_file_exists(path))
|
xmb->textures.bg.id = menu_texture_load(data,
|
||||||
return false;
|
|
||||||
|
|
||||||
texture_image_load(&ti, path);
|
|
||||||
|
|
||||||
strlcpy(xmb->textures.bg.path, path, sizeof(xmb->textures.bg.path));
|
|
||||||
|
|
||||||
xmb->textures.bg.id = menu_texture_load(&ti,
|
|
||||||
TEXTURE_BACKEND_OPENGL, TEXTURE_FILTER_MIPMAP_LINEAR);
|
TEXTURE_BACKEND_OPENGL, TEXTURE_FILTER_MIPMAP_LINEAR);
|
||||||
|
|
||||||
texture_image_free(&ti);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1467,12 +1458,6 @@ static void xmb_context_reset(void)
|
|||||||
|
|
||||||
xmb_font_init_first(&gl->font_driver, &xmb->font.buf, gl, fontpath, xmb->font.size);
|
xmb_font_init_first(&gl->font_driver, &xmb->font.buf, gl, fontpath, xmb->font.size);
|
||||||
|
|
||||||
if (*g_settings.menu.wallpaper)
|
|
||||||
strlcpy(xmb->textures.bg.path, g_settings.menu.wallpaper,
|
|
||||||
sizeof(xmb->textures.bg.path));
|
|
||||||
else
|
|
||||||
fill_pathname_join(xmb->textures.bg.path, iconpath,
|
|
||||||
"bg.png", sizeof(xmb->textures.bg.path));
|
|
||||||
fill_pathname_join(xmb->textures.list[XMB_TEXTURE_SETTINGS].path, iconpath,
|
fill_pathname_join(xmb->textures.list[XMB_TEXTURE_SETTINGS].path, iconpath,
|
||||||
"settings.png", sizeof(xmb->textures.list[XMB_TEXTURE_SETTINGS].path));
|
"settings.png", sizeof(xmb->textures.list[XMB_TEXTURE_SETTINGS].path));
|
||||||
fill_pathname_join(xmb->textures.list[XMB_TEXTURE_SETTING].path, iconpath,
|
fill_pathname_join(xmb->textures.list[XMB_TEXTURE_SETTING].path, iconpath,
|
||||||
@ -1536,7 +1521,26 @@ static void xmb_context_reset(void)
|
|||||||
texture_image_free(&ti);
|
texture_image_free(&ti);
|
||||||
}
|
}
|
||||||
|
|
||||||
xmb_load_wallpaper(xmb->textures.bg.path);
|
{
|
||||||
|
char path[PATH_MAX_LENGTH];
|
||||||
|
struct texture_image ti = {0};
|
||||||
|
|
||||||
|
fill_pathname_join(path, iconpath,
|
||||||
|
"bg.png", sizeof(path));
|
||||||
|
|
||||||
|
if (*g_settings.menu.wallpaper)
|
||||||
|
strlcpy(path, g_settings.menu.wallpaper,
|
||||||
|
sizeof(path));
|
||||||
|
|
||||||
|
if ( path_file_exists(path))
|
||||||
|
{
|
||||||
|
texture_image_load(&ti, path);
|
||||||
|
|
||||||
|
xmb_load_wallpaper(&ti);
|
||||||
|
|
||||||
|
texture_image_free(&ti);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
xmb->settings_node.icon = xmb->textures.list[XMB_TEXTURE_SETTINGS].id;
|
xmb->settings_node.icon = xmb->textures.list[XMB_TEXTURE_SETTINGS].id;
|
||||||
xmb->settings_node.alpha = xmb->categories.active.alpha;
|
xmb->settings_node.alpha = xmb->categories.active.alpha;
|
||||||
|
@ -228,7 +228,7 @@ typedef struct menu_ctx_driver
|
|||||||
void (*list_cache)(bool, unsigned);
|
void (*list_cache)(bool, unsigned);
|
||||||
void (*list_set_selection)(file_list_t *list);
|
void (*list_set_selection)(file_list_t *list);
|
||||||
int (*entry_iterate)(unsigned);
|
int (*entry_iterate)(unsigned);
|
||||||
bool (*load_background)(const char * path);
|
bool (*load_background)(void *data);
|
||||||
const char *ident;
|
const char *ident;
|
||||||
} menu_ctx_driver_t;
|
} menu_ctx_driver_t;
|
||||||
|
|
||||||
|
@ -607,15 +607,20 @@ static int action_ok_menu_wallpaper_load(const char *path,
|
|||||||
|
|
||||||
fill_pathname_join(wallpaper_path, menu_path, path, sizeof(wallpaper_path));
|
fill_pathname_join(wallpaper_path, menu_path, path, sizeof(wallpaper_path));
|
||||||
|
|
||||||
if (!path_file_exists(wallpaper_path))
|
if (path_file_exists(wallpaper_path))
|
||||||
goto end;
|
{
|
||||||
|
struct texture_image ti = {0};
|
||||||
|
|
||||||
strlcpy(g_settings.menu.wallpaper, wallpaper_path, sizeof(g_settings.menu.wallpaper));
|
strlcpy(g_settings.menu.wallpaper, wallpaper_path, sizeof(g_settings.menu.wallpaper));
|
||||||
|
|
||||||
if (driver.menu_ctx && driver.menu_ctx->load_background)
|
texture_image_load(&ti, wallpaper_path);
|
||||||
driver.menu_ctx->load_background(wallpaper_path);
|
|
||||||
|
if (driver.menu_ctx && driver.menu_ctx->load_background)
|
||||||
|
driver.menu_ctx->load_background(&ti);
|
||||||
|
|
||||||
|
texture_image_free(&ti);
|
||||||
|
}
|
||||||
|
|
||||||
end:
|
|
||||||
menu_list_pop_stack_by_needle(menu->menu_list, setting->name);
|
menu_list_pop_stack_by_needle(menu->menu_list, setting->name);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user