From df4c81c96d2d16f2252fee879c227b520b7f65dd Mon Sep 17 00:00:00 2001 From: Alex Taber Date: Sun, 2 Jun 2024 20:51:39 -0400 Subject: [PATCH] Download SMDH files for badges Thanks to ThemePlaza for providing these to make browser icons work Also fixed badge previews by increasing tex size if the preview image is larger than 512 pixel high --- source/draw.c | 8 +++++++- source/loading.c | 5 +++-- source/remote.c | 11 +++-------- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/source/draw.c b/source/draw.c index 2b4cf13..97f259c 100644 --- a/source/draw.c +++ b/source/draw.c @@ -47,6 +47,12 @@ static const char * mode_switch_char[MODE_AMOUNT] = { "T", }; +static const char *remote_mode_switch_char[REMOTE_MODE_AMOUNT] = { + "T", + "S", + "B", +}; + void init_screens(void) { init_colors(); @@ -544,7 +550,7 @@ void draw_grid_interface(Entry_List_s * list, Instructions_s instructions, int e draw_image(sprites_exit_idx, 320-72, 0); draw_image(sprites_preview_idx, 320-48, 0); - draw_text(320-24+2.5, -3, 0.6, 1.0f, 0.9f, colors[COLOR_WHITE], mode_switch_char[!current_mode]); + draw_text(320-24+2.5, -3, 0.6, 1.0f, 0.9f, colors[COLOR_WHITE], remote_mode_switch_char[current_mode]); draw_image(sprites_arrow_left_idx, 3, 114); draw_image(sprites_arrow_right_idx, 308, 114); diff --git a/source/loading.c b/source/loading.c index 39c8506..80a7d65 100644 --- a/source/loading.c +++ b/source/loading.c @@ -310,6 +310,7 @@ void load_icons_thread(void * void_arg) bool load_preview_from_buffer(char * row_pointers, u32 size, C2D_Image * preview_image, int * preview_offset, int height) { int width = (uint32_t)((size / 4) / height); + u32 tex_height = height > 512 ? 1024 : 512; free_preview(*preview_image); @@ -322,10 +323,10 @@ bool load_preview_from_buffer(char * row_pointers, u32 size, C2D_Image * preview subt3x->left = 0.0f; subt3x->top = 1.0f; subt3x->right = width/512.0f; - subt3x->bottom = 1.0-(height/512.0f); + subt3x->bottom = 1.0-(height/tex_height); preview_image->subtex = subt3x; - C3D_TexInit(preview_image->tex, 512, 512, GPU_RGBA8); + C3D_TexInit(preview_image->tex, 512, tex_height, GPU_RGBA8); memset(preview_image->tex->data, 0, preview_image->tex->size); diff --git a/source/remote.c b/source/remote.c index ccfea89..0748019 100644 --- a/source/remote.c +++ b/source/remote.c @@ -50,6 +50,7 @@ static void free_icons(Entry_List_s * list) } } +/* Unnecessary with ThemePlaza providing smdh files for badges static void load_remote_metadata(Entry_s * entry) { char *page_json = NULL; @@ -84,7 +85,7 @@ static void load_remote_metadata(Entry_s * entry) } } } - +*/ static void load_remote_smdh(Entry_s * entry, C3D_Tex * into_tex, const Entry_Icon_s * icon_info, bool ignore_cache) { bool not_cached = true; @@ -157,13 +158,7 @@ static void load_remote_entries(Entry_List_s * list, json_t * ids_array, bool ig utf8_to_utf16(current_entry->path, (u8 *)entry_path, 0x106); free(entry_path); - if (mode != REMOTE_MODE_BADGES) - load_remote_smdh(current_entry, &list->icons_texture, &list->icons_info[i], ignore_cache); - else - { - list->entries[i].placeholder_color = C2D_Color32(rand() * 255, rand() * 255, rand() * 255, 255); - load_remote_metadata(current_entry); - } + load_remote_smdh(current_entry, &list->icons_texture, &list->icons_info[i], ignore_cache); } }