1
0
Fork 0
mirror of https://github.com/suchmememanyskill/TegraExplorer.git synced 2024-11-22 20:06:43 +00:00

Safety first (for deletions)

This commit is contained in:
SuchMemeManySkill 2020-12-25 23:10:23 +01:00
parent 9c47d11843
commit a74a8814e1
6 changed files with 67 additions and 5 deletions

0
source/fs/fscopy.c Normal file
View file

0
source/fs/fscopy.h Normal file
View file

View file

@ -50,7 +50,46 @@ void MoveClipboard(char *path, FSEntry_t entry){
free(thing); free(thing);
} }
MenuEntry_t DeleteEntries[] = {
{.optionUnion = COLORTORGB(COLOR_YELLOW), .name = "No"},
{.R = 255, .name = "Yes"}
};
void DeleteFile(char *path, FSEntry_t entry){ void DeleteFile(char *path, FSEntry_t entry){
/*
u8 left = 0;
while (1){
gfx_con_setpos(384 + 16, 200 + 16 + 9 * 16);
SETCOLOR(COLOR_RED, COLOR_DARKGREY);
gfx_printf("Are you sure? ");
(left) ? SETCOLOR(COLOR_DARKGREY, COLOR_RED) : SETCOLOR(COLOR_RED, COLOR_DARKGREY);
gfx_printf("Yes");
RESETCOLOR;
gfx_printf(" ");
(!left) ? SETCOLOR(COLOR_DARKGREY, COLOR_YELLOW) : SETCOLOR(COLOR_YELLOW, COLOR_DARKGREY);
gfx_printf("No");
Input_t *input = hidWait();
if (input->a && left)
break;
else if (input->right)
left = 0;
else if (input->left)
left = 1;
else if (input->a || input->b)
return;
}
*/
gfx_con_setpos(384 + 16, 200 + 16 + 8 * 16);
SETCOLOR(COLOR_RED, COLOR_DARKGREY);
gfx_printf("Are you sure? ");
if (!MakeHorizontalMenu(DeleteEntries, 2, 3, COLOR_DARKGREY))
return;
char *thing = CombinePaths(path, entry.name); char *thing = CombinePaths(path, entry.name);
int res = f_unlink(thing); int res = f_unlink(thing);
if (res) if (res)

View file

@ -1,6 +1,7 @@
#include "gfx.h" #include "gfx.h"
#include "gfxutils.h" #include "gfxutils.h"
#include <power/max17050.h> #include <power/max17050.h>
#include "../hid/hid.h"
void gfx_clearscreen(){ void gfx_clearscreen(){
int battery = 0; int battery = 0;
@ -18,6 +19,26 @@ void gfx_clearscreen(){
RESETCOLOR; RESETCOLOR;
} }
u32 FromRGBtoU32(u8 r, u8 g, u8 b){ int MakeHorizontalMenu(MenuEntry_t *entries, int len, int spacesBetween, u32 bg){
return 0xFF000000 | r << 16 | g << 8 | b; u32 initialX = 0, initialY = 0;
u32 highlight = 0;
gfx_con_getpos(&initialX, &initialY);
while (1){
for (int i = 0; i < len; i++){
(highlight == i) ? SETCOLOR(bg, entries[i].optionUnion) : SETCOLOR(entries[i].optionUnion, bg);
gfx_puts(entries[i].name);
gfx_con.y -= spacesBetween * 16;
}
gfx_con_setpos(initialX, initialY);
Input_t *input = hidWait();
if (input->a)
return highlight;
else if (input->b)
return 0;
else if (input->left && highlight > 0)
highlight--;
else if (input->right && highlight < len - 1)
highlight++;
}
} }

View file

@ -1,5 +1,6 @@
#pragma once #pragma once
#include "gfx.h" #include "gfx.h"
#include "menu.h"
#define COLOR_WHITE 0xFFFFFFFF #define COLOR_WHITE 0xFFFFFFFF
#define COLOR_DEFAULT 0xFF1B1B1B #define COLOR_DEFAULT 0xFF1B1B1B
@ -10,6 +11,7 @@
#define SETCOLOR(fg, bg) gfx_con_setcol(fg, 1, bg) #define SETCOLOR(fg, bg) gfx_con_setcol(fg, 1, bg)
#define RESETCOLOR SETCOLOR(COLOR_WHITE, COLOR_DEFAULT); #define RESETCOLOR SETCOLOR(COLOR_WHITE, COLOR_DEFAULT);
u32 FromRGBtoU32(u8 r, u8 g, u8 b); #define RGBUnionToU32(optionUnion) (optionUnion | 0xFF000000)
void gfx_clearscreen(); void gfx_clearscreen();
int MakeHorizontalMenu(MenuEntry_t *entries, int len, int spacesBetween, u32 bg);

View file

@ -19,7 +19,7 @@ void _printEntry(MenuEntry_t entry, u32 maxLen, u8 highlighted, u32 bg){
if (entry.hide) if (entry.hide)
return; return;
(highlighted) ? SETCOLOR(bg, FromRGBtoU32(entry.R, entry.G, entry.B)) : SETCOLOR(FromRGBtoU32(entry.R, entry.G, entry.B), bg); (highlighted) ? SETCOLOR(bg, RGBUnionToU32(entry.optionUnion)) : SETCOLOR(RGBUnionToU32(entry.optionUnion), bg);
if (entry.icon){ if (entry.icon){
gfx_putc(entry.icon); gfx_putc(entry.icon);