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:
43
include/colors.h
Normal file
43
include/colors.h
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of Anemone3DS
|
||||||
|
* Copyright (C) 2016-2017 Alex Taber ("astronautlevel"), Dawid Eckert ("daedreth")
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||||
|
* * Requiring preservation of specified reasonable legal notices or
|
||||||
|
* author attributions in that material or in the Appropriate Legal
|
||||||
|
* Notices displayed by works containing it.
|
||||||
|
* * Prohibiting misrepresentation of the origin of that material,
|
||||||
|
* or requiring that modified versions of such material be marked in
|
||||||
|
* reasonable ways as different from the original version.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef COLORS_H
|
||||||
|
#define COLORS_H
|
||||||
|
|
||||||
|
#define ABGR8(a, b, g, r) ((((a)&0xFF)<<0) | (((b)&0xFF)<<8) | (((g)&0xFF)<<16) | (((r)&0xFF)<<24))
|
||||||
|
#define RGBA8(r, g, b, a) ((((r)&0xFF)<<0) | (((g)&0xFF)<<8) | (((b)&0xFF)<<16) | (((a)&0xFF)<<24))
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
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),
|
||||||
|
} Color;
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "loading.h"
|
#include "loading.h"
|
||||||
|
#include "colors.h"
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
INSTALL_SPLASH,
|
INSTALL_SPLASH,
|
||||||
@@ -67,14 +68,15 @@ enum {
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const wchar_t * info_line;
|
const wchar_t * info_line;
|
||||||
|
Color info_line_color;
|
||||||
const wchar_t * instructions[BUTTONS_INFO_LINES][BUTTONS_INFO_COLUNMNS];
|
const wchar_t * instructions[BUTTONS_INFO_LINES][BUTTONS_INFO_COLUNMNS];
|
||||||
} Instructions_s;
|
} Instructions_s;
|
||||||
|
|
||||||
void init_screens(void);
|
void init_screens(void);
|
||||||
void exit_screens(void);
|
void exit_screens(void);
|
||||||
|
|
||||||
void draw_themext_error(void);
|
|
||||||
void throw_error(char* error, ErrorLevel level);
|
void throw_error(char* error, ErrorLevel level);
|
||||||
|
bool draw_confirm(const char* conf_msg, Entry_List_s* list, EntryMode current_mode);
|
||||||
|
|
||||||
void draw_preview(int preview_offset);
|
void draw_preview(int preview_offset);
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
#define INSTRUCTIONS_H
|
#define INSTRUCTIONS_H
|
||||||
|
|
||||||
#include "draw.h"
|
#include "draw.h"
|
||||||
|
#include "colors.h"
|
||||||
|
|
||||||
Instructions_s normal_instructions[MODE_AMOUNT] = {
|
Instructions_s normal_instructions[MODE_AMOUNT] = {
|
||||||
{
|
{
|
||||||
@@ -76,6 +77,7 @@ Instructions_s normal_instructions[MODE_AMOUNT] = {
|
|||||||
|
|
||||||
Instructions_s install_instructions = {
|
Instructions_s install_instructions = {
|
||||||
.info_line = L"Release \uE000 to cancel or hold \uE006 and release \uE000 to install",
|
.info_line = L"Release \uE000 to cancel or hold \uE006 and release \uE000 to install",
|
||||||
|
.info_line_color = COLOR_WHITE,
|
||||||
.instructions = {
|
.instructions = {
|
||||||
{
|
{
|
||||||
L"\uE079 Normal install",
|
L"\uE079 Normal install",
|
||||||
|
|||||||
@@ -26,21 +26,12 @@
|
|||||||
|
|
||||||
#include "draw.h"
|
#include "draw.h"
|
||||||
#include "unicode.h"
|
#include "unicode.h"
|
||||||
|
#include "colors.h"
|
||||||
|
|
||||||
#include "pp2d/pp2d/pp2d.h"
|
#include "pp2d/pp2d/pp2d.h"
|
||||||
|
|
||||||
#include <time.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)
|
void init_screens(void)
|
||||||
{
|
{
|
||||||
pp2d_init();
|
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)
|
void draw_preview(int preview_offset)
|
||||||
{
|
{
|
||||||
pp2d_begin_draw(GFX_TOP, GFX_LEFT);
|
pp2d_begin_draw(GFX_TOP, GFX_LEFT);
|
||||||
@@ -201,7 +211,7 @@ void draw_instructions(Instructions_s instructions)
|
|||||||
pp2d_draw_on(GFX_TOP, GFX_LEFT);
|
pp2d_draw_on(GFX_TOP, GFX_LEFT);
|
||||||
|
|
||||||
if(instructions.info_line != NULL)
|
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] = {
|
const int y_lines[BUTTONS_INFO_LINES-1] = {
|
||||||
BUTTONS_Y_LINE_1,
|
BUTTONS_Y_LINE_1,
|
||||||
|
|||||||
@@ -295,8 +295,11 @@ int main(void)
|
|||||||
current_entry->in_shuffle = !current_entry->in_shuffle;
|
current_entry->in_shuffle = !current_entry->in_shuffle;
|
||||||
break;
|
break;
|
||||||
case MODE_SPLASHES:
|
case MODE_SPLASHES:
|
||||||
draw_install(INSTALL_SPLASH_DELETE);
|
if(draw_confirm("Are you sure you would like to delete\nthe installed splash?", current_list, current_mode))
|
||||||
splash_delete();
|
{
|
||||||
|
draw_install(INSTALL_SPLASH_DELETE);
|
||||||
|
splash_delete();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -316,9 +319,12 @@ int main(void)
|
|||||||
}
|
}
|
||||||
else if(kDown & KEY_SELECT)
|
else if(kDown & KEY_SELECT)
|
||||||
{
|
{
|
||||||
draw_install(INSTALL_ENTRY_DELETE);
|
if(draw_confirm("Are you sure you would like to delete this?", current_list, current_mode))
|
||||||
delete_entry(*current_entry);
|
{
|
||||||
load_lists(lists);
|
draw_install(INSTALL_ENTRY_DELETE);
|
||||||
|
delete_entry(*current_entry);
|
||||||
|
load_lists(lists);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Movement in the UI
|
// Movement in the UI
|
||||||
|
|||||||
Reference in New Issue
Block a user