From aa30f1e9505ca84f8c5b6a81e4853d7b09afd5db Mon Sep 17 00:00:00 2001 From: Robin Jones Date: Tue, 6 Aug 2024 18:43:07 +0100 Subject: [PATCH] Further improve path Add compatibility for 4 char ID. --- src/menu/components/boxart.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/menu/components/boxart.c b/src/menu/components/boxart.c index bc2911e1..e1044cf3 100644 --- a/src/menu/components/boxart.c +++ b/src/menu/components/boxart.c @@ -69,14 +69,40 @@ component_boxart_t *component_boxart_init (const char *storage_prefix, char *gam path_pop(path); path_pop(path); - sprintf(file_name, "%c%c.png", game_code[1], game_code[2]); + sprintf(file_name, "%c%c%c%c.png", game_code[0], game_code[1], game_code[2], game_code[3]); path_push(path, file_name); + if (file_exists(path_get(path))) { if (png_decoder_start(path_get(path), BOXART_WIDTH, BOXART_HEIGHT, png_decoder_callback, b) == PNG_OK) { path_free(path); return b; } } + + path_pop(path); + sprintf(file_name, "%c%c%c.png", game_code[0], game_code[1], game_code[2]); + path_push(path, file_name); + + if (file_exists(path_get(path))) { + if (file_exists(path_get(path))) { + if (png_decoder_start(path_get(path), BOXART_WIDTH, BOXART_HEIGHT, png_decoder_callback, b) == PNG_OK) { + path_free(path); + return b; + } + } + } + else { + path_pop(path); + + sprintf(file_name, "%c%c.png", game_code[1], game_code[2]); + path_push(path, file_name); + if (file_exists(path_get(path))) { + if (png_decoder_start(path_get(path), BOXART_WIDTH, BOXART_HEIGHT, png_decoder_callback, b) == PNG_OK) { + path_free(path); + return b; + } + } + } } // TODO: return default image.