From c9e1420a00547f1e4111cb85b189f450badde3af Mon Sep 17 00:00:00 2001 From: Alex Taber Date: Thu, 24 Dec 2020 16:58:06 -0500 Subject: [PATCH] re-add s upport for themes without an SMDH Also change theme dump random color algo --- include/loading.h | 4 ++-- source/draw.c | 5 ----- source/loading.c | 6 ++---- source/themes.c | 6 +++++- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/include/loading.h b/include/loading.h index 2a8b072..430b066 100644 --- a/include/loading.h +++ b/include/loading.h @@ -65,7 +65,7 @@ typedef struct { u16 desc[0x81]; u16 author[0x41]; - // u32 placeholder_color; + u32 placeholder_color; u16 path[0x106]; bool is_zip; @@ -127,4 +127,4 @@ void handle_scrolling(Entry_List_s * list); void load_icons_thread(void * void_arg); u32 load_data(char * filename, Entry_s entry, char ** buf); -#endif \ No newline at end of file +#endif diff --git a/source/draw.c b/source/draw.c index e42d3cd..2fa33dd 100644 --- a/source/draw.c +++ b/source/draw.c @@ -719,24 +719,19 @@ void draw_interface(Entry_List_s* list, Instructions_s instructions) C2D_DrawSpriteTinted(&sprite_installed, &tint); } - // no icons not allowed anymore - /* if(!current_entry->placeholder_color) { - */ C2D_Image * image = NULL; if(list->entries_count > list->entries_loaded*ICONS_OFFSET_AMOUNT) image = list->icons[ICONS_VISIBLE*list->entries_loaded + (i - list->scroll)]; else image = list->icons[i]; C2D_DrawImageAt(*image, horizontal_offset, vertical_offset, 0.5f, NULL, 1.0f, 1.0f); - /* } else { C2D_DrawRectSolid(horizontal_offset, vertical_offset, 0.5f, list->entry_size, list->entry_size, current_entry->placeholder_color); } - */ } char entries_count_str[0x20] = {0}; diff --git a/source/loading.c b/source/loading.c index ae42a56..84dbd58 100644 --- a/source/loading.c +++ b/source/loading.c @@ -83,7 +83,7 @@ C2D_Image * loadTextureIcon(Icon_s *icon) void parse_smdh(Icon_s *icon, Entry_s * entry, const u16 * fallback_name) { - /* + if(icon == NULL) { memcpy(entry->name, fallback_name, 0x80); @@ -92,7 +92,7 @@ void parse_smdh(Icon_s *icon, Entry_s * entry, const u16 * fallback_name) entry->placeholder_color = C2D_Color32(rand() % 255, rand() % 255, rand() % 255, 255); return; } - */ + memcpy(entry->name, icon->name, 0x40*sizeof(u16)); memcpy(entry->desc, icon->desc, 0x80*sizeof(u16)); @@ -186,14 +186,12 @@ Result load_entries(const char * loading_path, Entry_List_s * list) if (!strcmp(dir_entry.shortExt, "ZIP")) { u32 size = zip_file_to_buf("info.smdh", path, &buf); - if (size == 0) continue; } else { const ssize_t len = strulen(path, 0x106); struacat(path, "/info.smdh"); u32 size = file_to_buf(fsMakePath(PATH_UTF16, path), ArchiveSD, &buf); - if (size == 0) continue; memset(&path[len], 0, (0x106 - len) * sizeof(u16)); } diff --git a/source/themes.c b/source/themes.c index 6e5dc71..3603e2e 100644 --- a/source/themes.c +++ b/source/themes.c @@ -393,7 +393,11 @@ Result dump_theme(void) free(output_dir); - u16 color = rand() % 65535; + u8 r = rand() % 255; + u8 g = rand() % 255; + u8 b = rand() % 255; + + u16 color = ((r & 0b11111000) << 8) | ((g & 0b11111100) << 3) | (b >> 3); for (int i = 0x2040; i < 0x36c0; i += 2) {