Skip to content

Commit

Permalink
Further improve path
Browse files Browse the repository at this point in the history
Add compatibility for 4 char ID.
  • Loading branch information
networkfusion committed Aug 6, 2024
1 parent e85ad50 commit aa30f1e
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/menu/components/boxart.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down

0 comments on commit aa30f1e

Please sign in to comment.