From e63a4066a129af24ae35230c0ad6e5b19a7c79fe Mon Sep 17 00:00:00 2001 From: ZetaDesigns Date: Thu, 7 Sep 2017 22:43:32 +0200 Subject: [PATCH 1/3] error codes now properly pause --- source/draw.c | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/source/draw.c b/source/draw.c index 0e09a44..8f50ad7 100644 --- a/source/draw.c +++ b/source/draw.c @@ -25,12 +25,14 @@ */ #include "draw.h" +#include "common.h" #include "pp2d/pp2d/pp2d.h" #include "quirc/quirc.h" #include + enum Colors { COLOR_BACKGROUND = ABGR8(255, 32, 28, 35), //silver-y black COLOR_ACCENT = RGBA8(55, 122, 168, 255), @@ -150,13 +152,36 @@ void draw_base_interface(void) pp2d_draw_on(GFX_TOP); } void throw_error(char* error, int error_type) { - draw_base_interface(); + switch (error_type) { case ERROR: - pp2d_draw_text(70, 120, 0.8, 0.8, COLOR_RED, error); - break; - case WARNING: - pp2d_draw_text(70, 120, 0.8, 0.8, COLOR_YELLOW, error); + while (1) + { + hidScanInput(); + u32 kDown = hidKeysDown(); + draw_base_interface(); + pp2d_draw_text(70, 120, 0.8, 0.8, COLOR_RED, error); + pp2d_draw_wtext(70, 150, 0.8, 0.8, COLOR_WHITE, L"Press \uE000 to shut down."); + pp2d_end_draw(); + if (kDown & KEY_A) { + if (homebrew) + APT_HardwareResetAsync(); + else { + srvPublishToSubscriber(0x202, 0); + } + } + } + case WARNING: + while (1) + { + hidScanInput(); + u32 kDown = hidKeysDown(); + draw_base_interface(); + pp2d_draw_text(70, 120, 0.8, 0.8, COLOR_YELLOW, error); + pp2d_draw_wtext(70, 150, 0.8, 0.8, COLOR_WHITE, L"Press \uE000 to continue."); + pp2d_end_draw(); + if (kDown & KEY_A) break; + } break; } pp2d_end_draw(); From dc1cbda2325f90563e28a1daae75aac84746494b Mon Sep 17 00:00:00 2001 From: ZetaDesigns Date: Thu, 7 Sep 2017 22:45:15 +0200 Subject: [PATCH 2/3] you saw nothing --- source/draw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/draw.c b/source/draw.c index 8f50ad7..1773e3f 100644 --- a/source/draw.c +++ b/source/draw.c @@ -155,7 +155,7 @@ void throw_error(char* error, int error_type) { switch (error_type) { case ERROR: - while (1) + while (aptMainLoop()) { hidScanInput(); u32 kDown = hidKeysDown(); @@ -172,7 +172,7 @@ void throw_error(char* error, int error_type) { } } case WARNING: - while (1) + while (aptMainLoop()) { hidScanInput(); u32 kDown = hidKeysDown(); From 6b5b391d7b05cc26d521496105b76be69a58fc45 Mon Sep 17 00:00:00 2001 From: Helloman892 <1565516+Helloman892@users.noreply.github.com> Date: Thu, 7 Sep 2017 22:36:44 +0100 Subject: [PATCH 3/3] finally got theme deletion working + qr stuff Theme deletion [SDMC] now works, although no button currently has it assigned. The QR reader now works properly with Unicode filenames. --- include/themes.h | 2 +- source/camera.c | 2 +- source/main.c | 3 +++ source/themes.c | 37 +++++++++++++++++++------------------ 4 files changed, 24 insertions(+), 20 deletions(-) diff --git a/include/themes.h b/include/themes.h index 2f75126..a7c58ea 100644 --- a/include/themes.h +++ b/include/themes.h @@ -51,7 +51,7 @@ int theme_count; void load_theme_preview(Theme_s *theme); Result get_themes(Theme_s **themes_list, int *theme_count); -void add_theme(Theme_s **themes_list, int *theme_count, char *path, char *filename); +void del_theme(u16 *path); Result single_install(Theme_s theme); Result shuffle_install(Theme_s *themes_list, int theme_count); Result bgm_install(Theme_s bgm_to_install); diff --git a/source/camera.c b/source/camera.c index d10235e..0a32d9a 100644 --- a/source/camera.c +++ b/source/camera.c @@ -221,7 +221,7 @@ Result http_get(char *url, char *path) remake_file(path_to_file, ArchiveSD, size); buf_to_file(size, path_to_file, ArchiveSD, (char*)buf); - add_theme(&themes_list, &theme_count, path_to_file, filename); + get_themes(&themes_list, &theme_count); exit_qr(); diff --git a/source/main.c b/source/main.c index c992461..4c03e1f 100644 --- a/source/main.c +++ b/source/main.c @@ -194,6 +194,9 @@ int main(void) draw_theme_install(SINGLE_INSTALL); single_install(*current_theme); } + //these two are here just so I don't forget how to implement them - HM + //del_theme(current_theme->path); + //get_themes(&themes_list, &theme_count); } else if (kDown & KEY_B) diff --git a/source/themes.c b/source/themes.c index 3d78b7d..38c2ab9 100644 --- a/source/themes.c +++ b/source/themes.c @@ -158,7 +158,15 @@ Result get_themes(Theme_s **themes_list, int *theme_count) if (R_FAILED(res)) return res; + if (*themes_list != NULL) //used for QR reading and also for theme deletion + { + free(*themes_list); + *themes_list = NULL; + *theme_count = 0; + } + u32 entries_read = 1; + while (entries_read) { FS_DirectoryEntry entry = {0}; @@ -196,25 +204,18 @@ Result get_themes(Theme_s **themes_list, int *theme_count) return res; } -void add_theme(Theme_s **themes_list, int *theme_count, char *path, char *filename) +void del_theme(u16 *path) { - *theme_count += 1; - *themes_list = realloc(*themes_list, (*theme_count) * sizeof(Theme_s)); - - Theme_s *current_theme = &(*themes_list)[*theme_count - 1]; - memset(current_theme, 0, sizeof(Theme_s)); - - u16 theme_path[0x106] = {0}; - utf8_to_utf16(theme_path, (u8*)path, 0x106); - - u16 ufilename[0x106] = {0}; - utf8_to_utf16(ufilename, (u8*)filename, 0x106); - - memcpy(current_theme->path, theme_path, 0x106 * sizeof(u16)); - current_theme->is_zip = true; - - ssize_t iconID = TEXTURE_PREVIEW + *theme_count; - parse_smdh(current_theme, iconID, ufilename); + Handle dir_handle; + Result res = FSUSER_OpenDirectory(&dir_handle, ArchiveSD, fsMakePath(PATH_UTF16, path)); + if (R_SUCCEEDED(res)) + { + FSDIR_Close(dir_handle); + FSUSER_DeleteDirectoryRecursively(ArchiveSD, fsMakePath(PATH_UTF16, path)); + } else + { + FSUSER_DeleteFile(ArchiveSD, fsMakePath(PATH_UTF16, path)); + } } Result bgm_install(Theme_s bgm_to_install)