diff --git a/source/fs/fscopy.c b/source/fs/fscopy.c new file mode 100644 index 0000000..e69de29 diff --git a/source/fs/fscopy.h b/source/fs/fscopy.h new file mode 100644 index 0000000..e69de29 diff --git a/source/fs/menus/filemenu.c b/source/fs/menus/filemenu.c index d0a5296..d1da910 100644 --- a/source/fs/menus/filemenu.c +++ b/source/fs/menus/filemenu.c @@ -50,7 +50,46 @@ void MoveClipboard(char *path, FSEntry_t entry){ free(thing); } +MenuEntry_t DeleteEntries[] = { + {.optionUnion = COLORTORGB(COLOR_YELLOW), .name = "No"}, + {.R = 255, .name = "Yes"} +}; + 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); int res = f_unlink(thing); if (res) diff --git a/source/gfx/gfxutils.c b/source/gfx/gfxutils.c index 372baf6..9347a43 100644 --- a/source/gfx/gfxutils.c +++ b/source/gfx/gfxutils.c @@ -1,6 +1,7 @@ #include "gfx.h" #include "gfxutils.h" #include +#include "../hid/hid.h" void gfx_clearscreen(){ int battery = 0; @@ -18,6 +19,26 @@ void gfx_clearscreen(){ RESETCOLOR; } -u32 FromRGBtoU32(u8 r, u8 g, u8 b){ - return 0xFF000000 | r << 16 | g << 8 | b; +int MakeHorizontalMenu(MenuEntry_t *entries, int len, int spacesBetween, u32 bg){ + 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++; + } } \ No newline at end of file diff --git a/source/gfx/gfxutils.h b/source/gfx/gfxutils.h index 0e3d0a4..66b20a8 100644 --- a/source/gfx/gfxutils.h +++ b/source/gfx/gfxutils.h @@ -1,5 +1,6 @@ #pragma once #include "gfx.h" +#include "menu.h" #define COLOR_WHITE 0xFFFFFFFF #define COLOR_DEFAULT 0xFF1B1B1B @@ -10,6 +11,7 @@ #define SETCOLOR(fg, bg) gfx_con_setcol(fg, 1, bg) #define RESETCOLOR SETCOLOR(COLOR_WHITE, COLOR_DEFAULT); -u32 FromRGBtoU32(u8 r, u8 g, u8 b); +#define RGBUnionToU32(optionUnion) (optionUnion | 0xFF000000) -void gfx_clearscreen(); \ No newline at end of file +void gfx_clearscreen(); +int MakeHorizontalMenu(MenuEntry_t *entries, int len, int spacesBetween, u32 bg); \ No newline at end of file diff --git a/source/gfx/menu.c b/source/gfx/menu.c index 8b12cda..0658e5e 100644 --- a/source/gfx/menu.c +++ b/source/gfx/menu.c @@ -19,7 +19,7 @@ void _printEntry(MenuEntry_t entry, u32 maxLen, u8 highlighted, u32 bg){ if (entry.hide) 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){ gfx_putc(entry.icon);