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

Add some options to FileMenu

!Warning, there is no confirmation yet on deletions
This commit is contained in:
SuchMemeManySkill 2020-12-25 22:19:04 +01:00
parent 9588ffb89a
commit 9c47d11843
4 changed files with 42 additions and 5 deletions

View file

@ -9,6 +9,7 @@
#include "filemenu.h" #include "filemenu.h"
#include <string.h> #include <string.h>
#include <mem/heap.h> #include <mem/heap.h>
#include "../../tegraexplorer/tconf.h"
MenuEntry_t topEntries[] = { MenuEntry_t topEntries[] = {
{.optionUnion = COLORTORGB(COLOR_GREEN) | SKIPBIT}, {.optionUnion = COLORTORGB(COLOR_GREEN) | SKIPBIT},
@ -38,6 +39,8 @@ void FileExplorer(char *path){
int res = 0; int res = 0;
while (1){ while (1){
topEntries[2].optionUnion = COLORTORGB(((TConf.explorerCopyMode != CMODE_None) ? COLOR_ORANGE : COLOR_GREY)) | SKIPBIT;
gfx_clearscreen(); gfx_clearscreen();
gfx_printf("Loading...\r"); gfx_printf("Loading...\r");
//gfx_printf(" "); //gfx_printf(" ");
@ -83,7 +86,6 @@ void FileExplorer(char *path){
FileMenu(storedPath, fsEntries[res - ARR_LEN(topEntries)]); FileMenu(storedPath, fsEntries[res - ARR_LEN(topEntries)]);
} }
clearFileVector(&fileVec); clearFileVector(&fileVec);
} }
} }

View file

@ -8,6 +8,8 @@
#include <utils/sprintf.h> #include <utils/sprintf.h>
#include "../../tegraexplorer/tconf.h" #include "../../tegraexplorer/tconf.h"
#include "../../hid/hid.h" #include "../../hid/hid.h"
#include <libs/fatfs/ff.h>
#include "../../utils/utils.h"
MenuEntry_t FileMenuEntries[] = { MenuEntry_t FileMenuEntries[] = {
// Still have to think up the options // Still have to think up the options
@ -36,11 +38,31 @@ void LaunchPayload(char *path, FSEntry_t entry){
launch_payload(CombinePaths(path, entry.name)); launch_payload(CombinePaths(path, entry.name));
} }
void CopyClipboard(char *path, FSEntry_t entry){
char *thing = CombinePaths(path, entry.name);
SetCopyParams(thing, CMODE_Copy);
free(thing);
}
void MoveClipboard(char *path, FSEntry_t entry){
char *thing = CombinePaths(path, entry.name);
SetCopyParams(thing, CMODE_Copy);
free(thing);
}
void DeleteFile(char *path, FSEntry_t entry){
char *thing = CombinePaths(path, entry.name);
int res = f_unlink(thing);
if (res)
DrawError(newErrCode(res));
free(thing);
}
menuPaths FileMenuPaths[] = { menuPaths FileMenuPaths[] = {
CopyClipboard,
MoveClipboard,
UnimplementedException, UnimplementedException,
UnimplementedException, DeleteFile,
UnimplementedException,
UnimplementedException,
UnimplementedException, UnimplementedException,
LaunchPayload, LaunchPayload,
UnimplementedException UnimplementedException
@ -55,6 +77,9 @@ void FileMenu(char *path, FSEntry_t entry){
free(attribList); free(attribList);
FileMenuEntries[2].name = attribs; FileMenuEntries[2].name = attribs;
FileMenuEntries[10].hide = !StrEndsWith(entry.name, ".bin");
FileMenuEntries[11].hide = !StrEndsWith(entry.name, ".te");
Vector_t ent = vecFromArray(FileMenuEntries, ARR_LEN(FileMenuEntries), sizeof(MenuEntry_t)); Vector_t ent = vecFromArray(FileMenuEntries, ARR_LEN(FileMenuEntries), sizeof(MenuEntry_t));
gfx_boxGrey(384, 200, 384 + 512, 200 + 320, 0x33); gfx_boxGrey(384, 200, 384 + 512, 200 + 320, 0x33);
gfx_con_setpos(384 + 16, 200 + 16); gfx_con_setpos(384 + 16, 200 + 16);

View file

@ -21,3 +21,12 @@ void MaskIn(char *mod, u32 bitstream, char mask){
mod++; mod++;
} }
} }
// non-zero is yes, zero is no
bool StrEndsWith(char *begin, char *end){
begin = strrchr(begin, *end);
if (begin != NULL)
return !strcmp(begin, end);
return 0;
}

View file

@ -3,3 +3,4 @@
char *CpyStr(const char* in); char *CpyStr(const char* in);
void MaskIn(char *mod, u32 bitstream, char mask); void MaskIn(char *mod, u32 bitstream, char mask);
bool StrEndsWith(char *begin, char *end);