From d83ad781ee9e3cc6b765d6f1fc66fc92a3994f52 Mon Sep 17 00:00:00 2001 From: d0k3 Date: Fri, 10 Jun 2016 16:21:25 +0200 Subject: [PATCH] Show wait message when deleting --- source/godmode.c | 10 ++++++++-- source/ui.c | 22 ++++++++++++++++++++++ source/ui.h | 1 + 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/source/godmode.c b/source/godmode.c index 3b35940..ecc1864 100644 --- a/source/godmode.c +++ b/source/godmode.c @@ -580,16 +580,22 @@ u32 GodMode() { if (n_marked) { if (ShowPrompt(true, "Delete %u path(s)?", n_marked)) { u32 n_errors = 0; + ShowString("Deleting files, please wait..."); for (u32 c = 0; c < current_dir->n_entries; c++) if (current_dir->entry[c].marked && !PathDelete(current_dir->entry[c].path)) n_errors++; + ClearScreenF(true, false, COLOR_STD_BG); if (n_errors) ShowPrompt(false, "Failed deleting %u/%u path(s)", n_errors, n_marked); } } else if (curr_entry->type != T_DOTDOT) { char namestr[36+1]; TruncateString(namestr, curr_entry->name, 36, 12); - if ((ShowPrompt(true, "Delete \"%s\"?", namestr)) && !PathDelete(curr_entry->path)) - ShowPrompt(false, "Failed deleting:\n%s", namestr); + if (ShowPrompt(true, "Delete \"%s\"?", namestr)) { + ShowString("Deleting %s\nPlease wait...", namestr); + if (!PathDelete(curr_entry->path)) + ShowPrompt(false, "Failed deleting:\n%s", namestr); + ClearScreenF(true, false, COLOR_STD_BG); + } } GetDirContents(current_dir, current_path); } else if ((pad_state & BUTTON_Y) && (clipboard->n_entries == 0)) { // fill clipboard diff --git a/source/ui.c b/source/ui.c index e5bdda9..42480be 100644 --- a/source/ui.c +++ b/source/ui.c @@ -155,6 +155,28 @@ void FormatBytes(char* str, u64 bytes) { // str should be 32 byte in size, just } } +void ShowString(const char *format, ...) +{ + if (format && *format) { // only if there is something in there + u32 str_width, str_height; + u32 x, y; + + char str[STRBUF_SIZE] = { 0 }; + va_list va; + va_start(va, format); + vsnprintf(str, STRBUF_SIZE, format, va); + va_end(va); + + str_width = GetDrawStringWidth(str); + str_height = GetDrawStringHeight(str); + x = (str_width >= SCREEN_WIDTH_TOP) ? 0 : (SCREEN_WIDTH_TOP - str_width) / 2; + y = (str_height >= SCREEN_HEIGHT) ? 0 : (SCREEN_HEIGHT - str_height) / 2; + + ClearScreenF(true, false, COLOR_STD_BG); + DrawStringF(TOP_SCREEN, x, y, COLOR_STD_FONT, COLOR_STD_BG, str); + } else ClearScreenF(true, false, COLOR_STD_BG); +} + bool ShowPrompt(bool ask, const char *format, ...) { u32 str_width, str_height; diff --git a/source/ui.h b/source/ui.h index 2fcafc0..116f2fb 100644 --- a/source/ui.h +++ b/source/ui.h @@ -66,6 +66,7 @@ void TruncateString(char* dest, const char* orig, int nsize, int tpos); void FormatNumber(char* str, u64 number); void FormatBytes(char* str, u64 bytes); +void ShowString(const char *format, ...); bool ShowPrompt(bool ask, const char *format, ...); bool ShowUnlockSequence(u32 seqlvl, const char *format, ...); u32 ShowSelectPrompt(u32 n, const char** options, const char *format, ...);