Ask for confirmation before deletion from SD (#113)

* added awful way to confirm deletion

* improve solution for asking for confirmation
based on throw_error

* fix COLOR_WHITE evaluating to -1 (outside the u32 range)

* add confirmation for splash deletion
This commit is contained in:
Dylan G
2017-12-10 23:55:55 +00:00
committed by GitHub
parent 6eabfc84ab
commit b59e5fc078
5 changed files with 80 additions and 17 deletions

View File

@@ -26,21 +26,12 @@
#include "draw.h"
#include "unicode.h"
#include "colors.h"
#include "pp2d/pp2d/pp2d.h"
#include <time.h>
enum Colors {
COLOR_BACKGROUND = ABGR8(255, 32, 28, 35), //silver-y black
COLOR_ACCENT = RGBA8(55, 122, 168, 255),
COLOR_WHITE = RGBA8(255, 255, 255, 255),
COLOR_CURSOR = RGBA8(200, 200, 200, 255),
COLOR_BLACK = RGBA8(0, 0, 0, 255),
COLOR_RED = RGBA8(200, 0, 0, 255),
COLOR_YELLOW = RGBA8(239, 220, 11, 255),
};
void init_screens(void)
{
pp2d_init();
@@ -153,6 +144,25 @@ void throw_error(char* error, ErrorLevel level)
}
}
bool draw_confirm(const char* conf_msg, Entry_List_s* list, EntryMode current_mode)
{
while(aptMainLoop())
{
draw_interface(list, current_mode);
pp2d_draw_on(GFX_TOP, GFX_LEFT);
draw_text_center(GFX_TOP, BUTTONS_Y_LINE_1, 0.7, 0.7, COLOR_YELLOW, conf_msg);
pp2d_draw_wtext_center(GFX_TOP, BUTTONS_Y_LINE_3, 0.6, 0.6, COLOR_WHITE, L"\uE000 Yes \uE001 No");
pp2d_end_draw();
hidScanInput();
u32 kDown = hidKeysDown();
if(kDown & KEY_A) return true;
if(kDown & KEY_B) return false;
}
return false;
}
void draw_preview(int preview_offset)
{
pp2d_begin_draw(GFX_TOP, GFX_LEFT);
@@ -201,7 +211,7 @@ void draw_instructions(Instructions_s instructions)
pp2d_draw_on(GFX_TOP, GFX_LEFT);
if(instructions.info_line != NULL)
pp2d_draw_wtext_center(GFX_TOP, BUTTONS_Y_INFO, 0.55, 0.55, COLOR_WHITE, instructions.info_line);
pp2d_draw_wtext_center(GFX_TOP, BUTTONS_Y_INFO, 0.55, 0.55, instructions.info_line_color, instructions.info_line);
const int y_lines[BUTTONS_INFO_LINES-1] = {
BUTTONS_Y_LINE_1,

View File

@@ -295,8 +295,11 @@ int main(void)
current_entry->in_shuffle = !current_entry->in_shuffle;
break;
case MODE_SPLASHES:
draw_install(INSTALL_SPLASH_DELETE);
splash_delete();
if(draw_confirm("Are you sure you would like to delete\nthe installed splash?", current_list, current_mode))
{
draw_install(INSTALL_SPLASH_DELETE);
splash_delete();
}
break;
default:
break;
@@ -316,9 +319,12 @@ int main(void)
}
else if(kDown & KEY_SELECT)
{
draw_install(INSTALL_ENTRY_DELETE);
delete_entry(*current_entry);
load_lists(lists);
if(draw_confirm("Are you sure you would like to delete this?", current_list, current_mode))
{
draw_install(INSTALL_ENTRY_DELETE);
delete_entry(*current_entry);
load_lists(lists);
}
}
// Movement in the UI