Show wait message when deleting

This commit is contained in:
d0k3 2016-06-10 16:21:25 +02:00
parent c948a5a471
commit d83ad781ee
3 changed files with 31 additions and 2 deletions

View File

@ -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

View File

@ -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;

View File

@ -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, ...);