mirror of
https://github.com/suchmememanyskill/TegraExplorer.git
synced 2024-11-22 11:56:42 +00:00
Small optimizations
This commit is contained in:
parent
6681a35b2c
commit
9799e2b47e
19 changed files with 302 additions and 288 deletions
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
#include "../utils/types.h"
|
||||
|
||||
#define BIT(n) (1 << n)
|
||||
#define BIT(n) (1U << n)
|
||||
#define KEY_A BIT(3)
|
||||
#define KEY_B BIT(2)
|
||||
#define KEY_Y BIT(0)
|
||||
|
|
|
@ -2,74 +2,74 @@
|
|||
#include "types.h"
|
||||
|
||||
menu_entry mainmenu_main[] = {
|
||||
{"[SD:/] SD CARD", COLOR_GREEN, ISMENU},
|
||||
{"[EMMC:/] EMMC", COLOR_ORANGE, ISMENU},
|
||||
{"[EMMC:/] EMUMMC", COLOR_BLUE, ISMENU},
|
||||
{"\nMount/Unmount SD", COLOR_WHITE, ISMENU},
|
||||
{"Tools", COLOR_VIOLET, ISMENU},
|
||||
{"SD format", COLOR_VIOLET, ISMENU},
|
||||
{"\nCredits", COLOR_WHITE, ISMENU},
|
||||
{"Exit", COLOR_WHITE, ISMENU}
|
||||
{"[SD:/] SD CARD", COLOR_GREEN, {ISMENU}},
|
||||
{"[EMMC:/] EMMC", COLOR_ORANGE, {ISMENU}},
|
||||
{"[EMMC:/] EMUMMC", COLOR_BLUE, {ISMENU}},
|
||||
{"\nMount/Unmount SD", COLOR_WHITE, {ISMENU}},
|
||||
{"Tools", COLOR_VIOLET, {ISMENU}},
|
||||
{"SD format", COLOR_VIOLET, {ISMENU}},
|
||||
{"\nCredits", COLOR_WHITE, {ISMENU}},
|
||||
{"Exit", COLOR_WHITE, {ISMENU}}
|
||||
};
|
||||
|
||||
menu_entry mainmenu_shutdown[] = {
|
||||
{"Back", COLOR_WHITE, ISMENU},
|
||||
{"\nReboot to RCM", COLOR_VIOLET, ISMENU},
|
||||
{"Reboot normally", COLOR_ORANGE, ISMENU},
|
||||
{"Power off\n", COLOR_BLUE, ISMENU},
|
||||
{"Reboot to Hekate", COLOR_GREEN, ISMENU},
|
||||
{"Reboot to Atmosphere", COLOR_GREEN, ISMENU}
|
||||
{"Back", COLOR_WHITE, {ISMENU}},
|
||||
{"\nReboot to RCM", COLOR_VIOLET, {ISMENU}},
|
||||
{"Reboot normally", COLOR_ORANGE, {ISMENU}},
|
||||
{"Power off\n", COLOR_BLUE, {ISMENU}},
|
||||
{"Reboot to Hekate", COLOR_GREEN, {ISMENU}},
|
||||
{"Reboot to Atmosphere", COLOR_GREEN, {ISMENU}}
|
||||
};
|
||||
|
||||
menu_entry mainmenu_tools[] = {
|
||||
{"Back", COLOR_WHITE, ISMENU},
|
||||
{"\nDisplay Console Info", COLOR_GREEN, ISMENU},
|
||||
{"Display GPIO pins", COLOR_VIOLET, ISMENU},
|
||||
{"Dump Firmware", COLOR_BLUE, ISMENU},
|
||||
{"Dump User Saves", COLOR_YELLOW, ISMENU}
|
||||
{"Back", COLOR_WHITE, {ISMENU}},
|
||||
{"\nDisplay Console Info", COLOR_GREEN, {ISMENU}},
|
||||
{"Display GPIO pins", COLOR_VIOLET, {ISMENU}},
|
||||
{"Dump Firmware", COLOR_BLUE, {ISMENU}},
|
||||
{"Dump User Saves", COLOR_YELLOW, {ISMENU}}
|
||||
};
|
||||
|
||||
menu_entry mainmenu_format[] = {
|
||||
{"Back\n", COLOR_WHITE, ISMENU},
|
||||
{"Format entire SD to FAT32", COLOR_RED, ISMENU},
|
||||
{"Format for EmuMMC setup (FAT32/RAW)", COLOR_RED, ISMENU}
|
||||
{"Back\n", COLOR_WHITE, {ISMENU}},
|
||||
{"Format entire SD to FAT32", COLOR_RED, {ISMENU}},
|
||||
{"Format for EmuMMC setup (FAT32/RAW)", COLOR_RED, {ISMENU}}
|
||||
};
|
||||
|
||||
menu_entry utils_mmcChoice[] = {
|
||||
{"Back\n", COLOR_WHITE, ISMENU},
|
||||
{"SysMMC", COLOR_ORANGE, ISMENU},
|
||||
{"EmuMMC", COLOR_BLUE, ISMENU}
|
||||
{"Back\n", COLOR_WHITE, {ISMENU}},
|
||||
{"SysMMC", COLOR_ORANGE, {ISMENU}},
|
||||
{"EmuMMC", COLOR_BLUE, {ISMENU}}
|
||||
};
|
||||
|
||||
menu_entry fs_menu_file[] = {
|
||||
{NULL, COLOR_GREEN, ISMENU | ISSKIP},
|
||||
{NULL, COLOR_VIOLET, ISMENU | ISSKIP},
|
||||
{NULL, COLOR_VIOLET, ISMENU | ISSKIP},
|
||||
{"\n\n\nBack", COLOR_WHITE, ISMENU},
|
||||
{"\nCopy to clipboard", COLOR_BLUE, ISMENU},
|
||||
{"Move to clipboard", COLOR_BLUE, ISMENU},
|
||||
{"Rename file", COLOR_BLUE, ISMENU},
|
||||
{"\nDelete file\n", COLOR_RED, ISMENU},
|
||||
{"Launch Payload", COLOR_ORANGE, ISMENU},
|
||||
{"Launch Script", COLOR_YELLOW, ISMENU},
|
||||
{"View Hex", COLOR_GREEN, ISMENU},
|
||||
{"\nExtract BIS", COLOR_YELLOW, ISMENU}
|
||||
{NULL, COLOR_GREEN, {ISMENU | ISSKIP}},
|
||||
{NULL, COLOR_VIOLET, {ISMENU | ISSKIP}},
|
||||
{NULL, COLOR_VIOLET, {ISMENU | ISSKIP}},
|
||||
{"\n\n\nBack", COLOR_WHITE, {ISMENU}},
|
||||
{"\nCopy to clipboard", COLOR_BLUE, {ISMENU}},
|
||||
{"Move to clipboard", COLOR_BLUE, {ISMENU}},
|
||||
{"Rename file", COLOR_BLUE, {ISMENU}},
|
||||
{"\nDelete file\n", COLOR_RED, {ISMENU}},
|
||||
{"Launch Payload", COLOR_ORANGE, {ISMENU}},
|
||||
{"Launch Script", COLOR_YELLOW, {ISMENU}},
|
||||
{"View Hex", COLOR_GREEN, {ISMENU}},
|
||||
{"\nExtract BIS", COLOR_YELLOW, {ISMENU}}
|
||||
};
|
||||
|
||||
menu_entry fs_menu_folder[] = {
|
||||
{NULL, COLOR_VIOLET, ISMENU | ISSKIP},
|
||||
{"\nBack", COLOR_WHITE, ISMENU},
|
||||
{"Return to main menu\n", COLOR_BLUE, ISMENU},
|
||||
{"Copy to clipboard", COLOR_VIOLET, ISMENU},
|
||||
{"Delete folder\n", COLOR_RED, ISMENU},
|
||||
{"Rename folder", COLOR_BLUE, ISMENU},
|
||||
{"Create folder", COLOR_BLUE, ISMENU}
|
||||
{NULL, COLOR_VIOLET, {ISMENU | ISSKIP}},
|
||||
{"\nBack", COLOR_WHITE, {ISMENU}},
|
||||
{"Return to main menu\n", COLOR_BLUE, {ISMENU}},
|
||||
{"Copy to clipboard", COLOR_VIOLET, {ISMENU}},
|
||||
{"Delete folder\n", COLOR_RED, {ISMENU}},
|
||||
{"Rename folder", COLOR_BLUE, {ISMENU}},
|
||||
{"Create folder", COLOR_BLUE, {ISMENU}}
|
||||
};
|
||||
|
||||
menu_entry fs_menu_startdir[] = {
|
||||
{"Folder -> previous folder ", COLOR_ORANGE, ISMENU},
|
||||
{"Clipboard -> Current folder", COLOR_ORANGE, ISMENU},
|
||||
{"Current folder menu ", COLOR_ORANGE, ISMENU}
|
||||
{"Folder -> previous folder ", COLOR_ORANGE, {ISMENU}},
|
||||
{"Clipboard -> Current folder", COLOR_ORANGE, {ISMENU}},
|
||||
{"Current folder menu ", COLOR_ORANGE, {ISMENU}}
|
||||
};
|
||||
|
||||
gpt_entry_rule gpt_fs_rules[] = {
|
||||
|
@ -81,15 +81,15 @@ gpt_entry_rule gpt_fs_rules[] = {
|
|||
};
|
||||
|
||||
menu_entry mmcmenu_start[] = {
|
||||
{"Back", COLOR_ORANGE, ISMENU},
|
||||
{"Dump File Partitions", COLOR_ORANGE, ISMENU},
|
||||
{"Clipboard -> Partition\n", COLOR_ORANGE, ISMENU},
|
||||
{"BOOT0/1", COLOR_BLUE, isBOOT | ISMENU}
|
||||
{"Back", COLOR_ORANGE, {ISMENU}},
|
||||
{"Dump File Partitions", COLOR_ORANGE, {ISMENU}},
|
||||
{"Clipboard -> Partition\n", COLOR_ORANGE, {ISMENU}},
|
||||
{"BOOT0/1", COLOR_BLUE, {ISNULL | ISMENU}}
|
||||
};
|
||||
|
||||
menu_entry mmcmenu_filemenu[] = {
|
||||
{"Part:", COLOR_ORANGE, ISSKIP | ISMENU},
|
||||
{NULL, COLOR_VIOLET, ISSKIP | ISMENU},
|
||||
{"\nBack", COLOR_WHITE, ISMENU},
|
||||
{"Dump to SD", COLOR_YELLOW, ISMENU}
|
||||
{"Part:", COLOR_ORANGE, {ISSKIP | ISMENU}},
|
||||
{NULL, COLOR_VIOLET, {ISSKIP | ISMENU}},
|
||||
{"\nBack", COLOR_WHITE, {ISMENU}},
|
||||
{"Dump to SD", COLOR_YELLOW, {ISMENU}}
|
||||
};
|
|
@ -1,18 +1,14 @@
|
|||
#pragma once
|
||||
#include "../../utils/types.h"
|
||||
|
||||
#define ISDIR (1 << 0)
|
||||
#define ISARC (1 << 1)
|
||||
#define BIT(n) (1U << n)
|
||||
|
||||
#define ISHIDE (1 << 8)
|
||||
#define ISMENU (1 << 9)
|
||||
#define ISSKIP (1 << 10)
|
||||
|
||||
#define ISGB (1 << 7)
|
||||
#define ISMB (1 << 6)
|
||||
#define ISKB (1 << 5)
|
||||
#define ISB (1 << 4)
|
||||
#define ISNULL (1 << 3)
|
||||
#define ISDIR BIT(0)
|
||||
#define ISMENU BIT(1)
|
||||
#define SETSIZE(x) (x << 2)
|
||||
#define ISNULL BIT(4)
|
||||
#define ISHIDE BIT(5)
|
||||
#define ISSKIP BIT(6)
|
||||
|
||||
#define SETBIT(object, shift, value) ((value) ? (object |= shift) : (object &= ~shift))
|
||||
|
||||
|
@ -43,7 +39,17 @@
|
|||
typedef struct {
|
||||
char *name;
|
||||
u32 storage;
|
||||
u16 property;
|
||||
union {
|
||||
u8 property;
|
||||
struct {
|
||||
u8 isDir:1;
|
||||
u8 isMenu:1;
|
||||
u8 size:2;
|
||||
u8 isNull:1;
|
||||
u8 isHide:1;
|
||||
u8 isSkip:1;
|
||||
};
|
||||
};
|
||||
} menu_entry;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -16,12 +16,12 @@
|
|||
#include "../../utils/list.h"
|
||||
#include "../../mem/heap.h"
|
||||
#include "emmcmenu.h"
|
||||
#include "../fs/fsreader.h"
|
||||
#include "../utils/utils.h"
|
||||
#include "../gfx/menu.h"
|
||||
#include "../fs/fsmenu.h"
|
||||
#include "emmcoperations.h"
|
||||
#include "../fs/fsutils.h"
|
||||
#include "../utils/menuUtils.h"
|
||||
|
||||
menu_entry *mmcMenuEntries = NULL;
|
||||
extern sdmmc_storage_t storage;
|
||||
|
@ -30,21 +30,18 @@ extern char *clipboard;
|
|||
extern u8 clipboardhelper;
|
||||
|
||||
|
||||
void addEntry(emmc_part_t *part, u8 property, int spot){
|
||||
if (mmcMenuEntries[spot].name != NULL){
|
||||
free(mmcMenuEntries[spot].name);
|
||||
}
|
||||
void addEntry(emmc_part_t *part, u8 property_GPT, int spot){
|
||||
u32 storage = 0;
|
||||
u8 property = 0;
|
||||
|
||||
utils_copystring(part->name, &mmcMenuEntries[spot].name);
|
||||
|
||||
if (property & isFS){
|
||||
mmcMenuEntries[spot].storage = (u32)(property & 0x7F);
|
||||
mmcMenuEntries[spot].property = ISDIR;
|
||||
if (property_GPT & isFS){
|
||||
storage = (u32)(property_GPT & 0x7F);
|
||||
property = ISDIR;
|
||||
}
|
||||
else {
|
||||
u64 size = 0;
|
||||
int sizes = 0;
|
||||
mmcMenuEntries[spot].property = 0;
|
||||
u32 sizes = 0;
|
||||
|
||||
size = (u64)(part->lba_end + 1 - part->lba_start);
|
||||
size *= (u64)NX_EMMC_BLOCKSIZE;
|
||||
|
||||
|
@ -54,31 +51,30 @@ void addEntry(emmc_part_t *part, u8 property, int spot){
|
|||
}
|
||||
|
||||
if (sizes > 3)
|
||||
sizes = 0;
|
||||
sizes = 3;
|
||||
|
||||
mmcMenuEntries[spot].property |= (1 << (4 + sizes));
|
||||
mmcMenuEntries[spot].storage = (u32)size;
|
||||
property |= SETSIZE(sizes);
|
||||
storage = (u32)size;
|
||||
}
|
||||
|
||||
mu_copySingle(part->name, storage, property, &mmcMenuEntries[spot]);
|
||||
}
|
||||
|
||||
int fillMmcMenu(short mmcType){
|
||||
int count = 4, i;
|
||||
|
||||
if (mmcMenuEntries != NULL)
|
||||
clearfileobjects(&mmcMenuEntries);
|
||||
mu_clearObjects(&mmcMenuEntries);
|
||||
|
||||
link_t *gpt = selectGpt(mmcType);
|
||||
|
||||
LIST_FOREACH_ENTRY(emmc_part_t, part, gpt, link)
|
||||
count++;
|
||||
|
||||
createfileobjects(count, &mmcMenuEntries);
|
||||
mu_createObjects(count, &mmcMenuEntries);
|
||||
|
||||
for (i = 0; i < 4; i++){
|
||||
utils_copystring(mmcmenu_start[i].name, &mmcMenuEntries[i].name);
|
||||
mmcMenuEntries[i].property = mmcmenu_start[i].property;
|
||||
mmcMenuEntries[i].storage = mmcmenu_start[i].storage;
|
||||
}
|
||||
for (i = 0; i < 4; i++)
|
||||
mu_copySingle(mmcmenu_start[i].name, mmcmenu_start[i].storage, mmcmenu_start[i].property, &mmcMenuEntries[i]);
|
||||
|
||||
LIST_FOREACH_ENTRY(emmc_part_t, part, gpt, link){
|
||||
addEntry(part, checkGptRules(part->name), i++);
|
||||
|
@ -99,10 +95,14 @@ int handleEntries(short mmcType, menu_entry part){
|
|||
fileexplorer("emmc:/", 1);
|
||||
}
|
||||
else {
|
||||
/*
|
||||
if (mmcmenu_filemenu[1].name != NULL)
|
||||
free(mmcmenu_filemenu[1].name);
|
||||
|
||||
utils_copystring(part.name, &mmcmenu_filemenu[1].name);
|
||||
*/
|
||||
|
||||
mu_copySingle(part.name, mmcmenu_filemenu[1].storage, mmcmenu_filemenu[1].property, &mmcmenu_filemenu[1]);
|
||||
|
||||
if ((menu_make(mmcmenu_filemenu, 4, "-- RAW PARTITION --")) < 3)
|
||||
return 0;
|
||||
|
@ -112,7 +112,7 @@ int handleEntries(short mmcType, menu_entry part){
|
|||
|
||||
gfx_clearscreen();
|
||||
|
||||
if (part.property & isBOOT){
|
||||
if (part.isNull){
|
||||
res = emmcDumpBoot("sd:/tegraexplorer/partition_dumps");
|
||||
}
|
||||
else {
|
||||
|
@ -146,7 +146,7 @@ int makeMmcMenu(short mmcType){
|
|||
f_mkdir("sd:/tegraexplorer/partition_dumps");
|
||||
|
||||
for (int i = 0; i < count; i++){
|
||||
if (mmcMenuEntries[i].property & ISMENU || mmcMenuEntries[i].property & ISDIR)
|
||||
if (mmcMenuEntries[i].property & (ISMENU | ISDIR))
|
||||
continue;
|
||||
|
||||
//gfx_printf("Dumping %s...\n", mmcMenuEntries[i].name);
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "../script/parser.h"
|
||||
#include "../emmc/emmcoperations.h"
|
||||
#include "../../hid/hid.h"
|
||||
#include "../utils/menuUtils.h"
|
||||
|
||||
extern char *currentpath;
|
||||
extern char *clipboard;
|
||||
|
@ -120,38 +121,42 @@ void copyfile(const char *src_in, const char *outfolder){
|
|||
|
||||
int filemenu(menu_entry file){
|
||||
int temp;
|
||||
FILINFO attribs;
|
||||
char *tempchar;
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
/*
|
||||
for (int i = 0; i < 2; i++)
|
||||
if (fs_menu_file[i].name != NULL)
|
||||
free(fs_menu_file[i].name);
|
||||
|
||||
utils_copystring(file.name, &fs_menu_file[0].name);
|
||||
*/
|
||||
mu_copySingle(file.name, fs_menu_file[0].storage, fs_menu_file[0].property, &fs_menu_file[0]);
|
||||
|
||||
|
||||
if (fs_menu_file[1].name != NULL)
|
||||
free(fs_menu_file[1].name);
|
||||
|
||||
fs_menu_file[1].name = malloc(16);
|
||||
fs_menu_file[2].name = malloc(16);
|
||||
sprintf(fs_menu_file[1].name, "\nSize: %d %s", file.storage, gfx_file_size_names[file.size]);
|
||||
|
||||
for (temp = 4; temp < 8; temp++)
|
||||
if ((file.property & (1 << temp)))
|
||||
break;
|
||||
|
||||
|
||||
sprintf(fs_menu_file[1].name, "\nSize: %d %s", file.storage, gfx_file_size_names[temp - 4]);
|
||||
|
||||
if (f_stat(fsutil_getnextloc(currentpath, file.name), &attribs))
|
||||
SETBIT(fs_menu_file[2].property, ISHIDE, 1);
|
||||
if ((tempchar = fsutil_formatFileAttribs(fsutil_getnextloc(currentpath, file.name))) == NULL)
|
||||
fs_menu_file[2].isHide = 1;
|
||||
else {
|
||||
SETBIT(fs_menu_file[2].property, ISHIDE, 0);
|
||||
sprintf(fs_menu_file[2].name, "Attribs: %c%c%c%c",
|
||||
(attribs.fattrib & AM_RDO) ? 'R' : '-',
|
||||
(attribs.fattrib & AM_SYS) ? 'S' : '-',
|
||||
(attribs.fattrib & AM_HID) ? 'H' : '-',
|
||||
(attribs.fattrib & AM_ARC) ? 'A' : '-');
|
||||
fs_menu_file[2].isHide = 0;
|
||||
mu_copySingle(tempchar, fs_menu_file[2].storage, fs_menu_file[2].property, &fs_menu_file[2]);
|
||||
}
|
||||
|
||||
fs_menu_file[6].isHide = !hidConnected();
|
||||
fs_menu_file[8].isHide = (!(strstr(file.name, ".bin") != NULL && file.size == 1) && strstr(file.name, ".rom") == NULL);
|
||||
fs_menu_file[9].isHide = (strstr(file.name, ".te") == NULL);
|
||||
fs_menu_file[11].isHide = (strstr(file.name, ".bis") == NULL);
|
||||
|
||||
/*
|
||||
SETBIT(fs_menu_file[6].property, ISHIDE, !hidConnected());
|
||||
SETBIT(fs_menu_file[8].property, ISHIDE, !(strstr(file.name, ".bin") != NULL && file.property & ISKB) && strstr(file.name, ".rom") == NULL);
|
||||
SETBIT(fs_menu_file[8].property, ISHIDE, !(strstr(file.name, ".bin") != NULL && file.size == 1) && strstr(file.name, ".rom") == NULL);
|
||||
SETBIT(fs_menu_file[9].property, ISHIDE, strstr(file.name, ".te") == NULL);
|
||||
SETBIT(fs_menu_file[11].property, ISHIDE, strstr(file.name, ".bis") == NULL);
|
||||
*/
|
||||
|
||||
temp = menu_make(fs_menu_file, 12, "-- File Menu --");
|
||||
switch (temp){
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "../../utils/sprintf.h"
|
||||
#include "../utils/utils.h"
|
||||
#include "../../hid/hid.h"
|
||||
#include "../utils/menuUtils.h"
|
||||
|
||||
extern char *currentpath;
|
||||
extern char *clipboard;
|
||||
|
@ -42,16 +43,18 @@ void copyfolder(char *in, char *out){
|
|||
int foldermenu(){
|
||||
int res, hidConn;
|
||||
char *name;
|
||||
FILINFO attribs;
|
||||
|
||||
if (fs_menu_folder[0].name != NULL)
|
||||
free(fs_menu_folder[0].name);
|
||||
|
||||
fs_menu_folder[0].name = malloc(16);
|
||||
|
||||
hidConn = hidConnected();
|
||||
|
||||
res = strlen(currentpath);
|
||||
|
||||
fs_menu_folder[3].isHide = (*(currentpath + res - 1) == '/');
|
||||
fs_menu_folder[4].isHide = (*(currentpath + res - 1) == '/');
|
||||
fs_menu_folder[5].isHide = (*(currentpath + res - 1) == '/' || !hidConn);
|
||||
fs_menu_folder[6].isHide = !hidConn;
|
||||
|
||||
/*
|
||||
|
||||
SETBIT(fs_menu_folder[3].property, ISHIDE, (*(currentpath + res - 1) == '/'));
|
||||
SETBIT(fs_menu_folder[4].property, ISHIDE, (*(currentpath + res - 1) == '/'));
|
||||
SETBIT(fs_menu_folder[5].property, ISHIDE, (*(currentpath + res - 1) == '/') || !hidConn);
|
||||
|
@ -67,6 +70,17 @@ int foldermenu(){
|
|||
(attribs.fattrib & AM_HID) ? 'H' : '-',
|
||||
(attribs.fattrib & AM_ARC) ? 'A' : '-');
|
||||
}
|
||||
*/
|
||||
|
||||
if ((name = fsutil_formatFileAttribs(currentpath)) == NULL){
|
||||
fs_menu_folder[0].isHide = 1;
|
||||
}
|
||||
else {
|
||||
fs_menu_folder[0].isHide = 0;
|
||||
mu_copySingle(name, fs_menu_folder[0].storage, fs_menu_folder[0].property, &fs_menu_folder[0]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
res = menu_make(fs_menu_folder, 7, currentpath);
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "../common/common.h"
|
||||
#include "../../libs/fatfs/ff.h"
|
||||
#include "entrymenu.h"
|
||||
#include "../utils/menuUtils.h"
|
||||
|
||||
extern char *currentpath;
|
||||
extern char *clipboard;
|
||||
|
@ -35,7 +36,7 @@ void fileexplorer(const char *startpath, int type){
|
|||
*/
|
||||
|
||||
while (1){
|
||||
res = menu_make(fsreader_files, fsutil_getfileobjamount(fsreader_files), currentpath);
|
||||
res = menu_make(fsreader_files, mu_countObjects(fsreader_files, 0), currentpath);
|
||||
switch (res){
|
||||
case FILEMENU_RETURN:
|
||||
if (!strcmp(startpath, currentpath))
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "../gfx/gfxutils.h"
|
||||
#include "../utils/utils.h"
|
||||
#include "../../mem/heap.h"
|
||||
#include "../utils/menuUtils.h"
|
||||
|
||||
menu_entry *fsreader_files = NULL;
|
||||
char *currentpath = NULL;
|
||||
|
@ -29,59 +30,16 @@ void fsreader_writeclipboard(const char *in, u8 args){
|
|||
utils_copystring(in, &clipboard);
|
||||
}
|
||||
|
||||
void clearfileobjects(menu_entry **menu){
|
||||
if ((*menu) != NULL){
|
||||
for (int i = 0; (*menu)[i].name != NULL; i++){
|
||||
free((*menu)[i].name);
|
||||
(*menu)[i].name = NULL;
|
||||
}
|
||||
free((*menu));
|
||||
(*menu) = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void createfileobjects(int size, menu_entry **menu){
|
||||
(*menu) = calloc (size + 1, sizeof(menu_entry));
|
||||
(*menu)[size].name = NULL;
|
||||
}
|
||||
|
||||
void addobject(char* name, int spot, u8 attribs){
|
||||
/*
|
||||
u64 size = 0;
|
||||
int sizes = 0;
|
||||
*/
|
||||
fsreader_files[spot].property = 0;
|
||||
|
||||
if (fsreader_files[spot].name != NULL){
|
||||
free(fsreader_files[spot].name);
|
||||
fsreader_files[spot].name = NULL;
|
||||
}
|
||||
|
||||
utils_copystring(name, &(fsreader_files[spot].name));
|
||||
u8 property = 0;
|
||||
|
||||
if (attribs & AM_DIR)
|
||||
fsreader_files[spot].property |= (ISDIR);
|
||||
else {
|
||||
/*
|
||||
size = fsutil_getfilesize(fsutil_getnextloc(currentpath, name));
|
||||
property |= ISDIR;
|
||||
else
|
||||
property |= ISNULL;
|
||||
|
||||
while (size > 1024){
|
||||
size /= 1024;
|
||||
sizes++;
|
||||
}
|
||||
|
||||
if (sizes > 3)
|
||||
sizes = 0;
|
||||
|
||||
fsreader_files[spot].property |= (1 << (4 + sizes));
|
||||
fsreader_files[spot].storage = size;
|
||||
*/
|
||||
fsreader_files[spot].storage = 0;
|
||||
fsreader_files[spot].property = ISNULL;
|
||||
}
|
||||
|
||||
if (attribs & AM_ARC)
|
||||
fsreader_files[spot].property |= (ISARC);
|
||||
mu_copySingle(name, 0, property, &fsreader_files[spot]);
|
||||
}
|
||||
|
||||
int fsreader_readfolder(const char *path){
|
||||
|
@ -89,14 +47,13 @@ int fsreader_readfolder(const char *path){
|
|||
FILINFO fno;
|
||||
int folderamount, res;
|
||||
|
||||
clearfileobjects(&fsreader_files);
|
||||
createfileobjects(fsutil_getfolderentryamount(path) + 3, &fsreader_files);
|
||||
mu_clearObjects(&fsreader_files);
|
||||
mu_createObjects(fsutil_getfolderentryamount(path) + 3, &fsreader_files);
|
||||
|
||||
for (folderamount = 0; folderamount < 3; folderamount++){
|
||||
utils_copystring(fs_menu_startdir[folderamount].name, &(fsreader_files[folderamount].name));
|
||||
fsreader_files[folderamount].storage = fs_menu_startdir[folderamount].storage;
|
||||
fsreader_files[folderamount].property = fs_menu_startdir[folderamount].property;
|
||||
}
|
||||
|
||||
|
||||
for (folderamount = 0; folderamount < 3; folderamount++)
|
||||
mu_copySingle(fs_menu_startdir[folderamount].name, fs_menu_startdir[folderamount].storage, fs_menu_startdir[folderamount].property, &fsreader_files[folderamount]);
|
||||
|
||||
if ((res = f_opendir(&dir, path))){
|
||||
gfx_errDisplay("readfolder", res, 0);
|
||||
|
|
|
@ -47,15 +47,6 @@ char *fsutil_getprevloc(char *current){
|
|||
return ret;
|
||||
}
|
||||
|
||||
int fsutil_getfileobjamount(menu_entry *entries){
|
||||
int amount = 0;
|
||||
|
||||
while (entries[amount].name != NULL)
|
||||
amount++;
|
||||
|
||||
return amount;
|
||||
}
|
||||
|
||||
bool fsutil_checkfile(char* path){
|
||||
FRESULT fr;
|
||||
FILINFO fno;
|
||||
|
@ -88,3 +79,20 @@ int fsutil_getfolderentryamount(const char *path){
|
|||
f_closedir(&dir);
|
||||
return folderamount;
|
||||
}
|
||||
|
||||
char *fsutil_formatFileAttribs(char *path){
|
||||
FILINFO attribs;
|
||||
char *out;
|
||||
out = malloc(16);
|
||||
|
||||
if (f_stat(path, &attribs))
|
||||
return NULL;
|
||||
|
||||
sprintf(out, "Attribs: %c%c%c%c",
|
||||
(attribs.fattrib & AM_RDO) ? 'R' : '-',
|
||||
(attribs.fattrib & AM_SYS) ? 'S' : '-',
|
||||
(attribs.fattrib & AM_HID) ? 'H' : '-',
|
||||
(attribs.fattrib & AM_ARC) ? 'A' : '-');
|
||||
|
||||
return out;
|
||||
}
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
char *fsutil_getnextloc(const char *current, const char *add);
|
||||
char *fsutil_getprevloc(char *current);
|
||||
int fsutil_getfileobjamount(menu_entry *entries);
|
||||
bool fsutil_checkfile(char* path);
|
||||
u64 fsutil_getfilesize(char *path);
|
||||
int fsutil_getfolderentryamount(const char *path);
|
||||
int extract_bis_file(char *path, char *outfolder);
|
||||
char *fsutil_formatFileAttribs(char *path);
|
|
@ -41,7 +41,7 @@ u32 gfx_message(u32 color, const char* message, ...){
|
|||
return hidWait()->buttons;
|
||||
}
|
||||
|
||||
u32 gfx_errDisplay(char *src_func, int err, int loc){
|
||||
u32 gfx_errDisplay(const char *src_func, int err, int loc){
|
||||
if (!printerrors)
|
||||
return 0;
|
||||
|
||||
|
@ -58,14 +58,14 @@ u32 gfx_errDisplay(char *src_func, int err, int loc){
|
|||
if (loc)
|
||||
gfx_printf("Loc: %d\n", loc);
|
||||
|
||||
gfx_printf("\nPress any button to return");
|
||||
gfx_printf("\nPress any button to return\n");
|
||||
|
||||
RESETCOLOR;
|
||||
|
||||
return hidWait()->buttons;
|
||||
}
|
||||
|
||||
int gfx_makewaitmenu(char *hiddenmessage, int timer){
|
||||
int gfx_makewaitmenu(const char *hiddenmessage, int timer){
|
||||
u32 start = get_tmr_s();
|
||||
Inputs *input = NULL;
|
||||
|
||||
|
@ -86,7 +86,7 @@ int gfx_makewaitmenu(char *hiddenmessage, int timer){
|
|||
}
|
||||
}
|
||||
|
||||
void gfx_printlength(int size, char *toprint){
|
||||
void gfx_printlength(int size, const char *toprint){
|
||||
char *temp;
|
||||
temp = (char*) malloc (size + 1);
|
||||
|
||||
|
@ -102,7 +102,7 @@ void gfx_printlength(int size, char *toprint){
|
|||
free(temp);
|
||||
}
|
||||
|
||||
void gfx_printandclear(char *in, int length, int endX){
|
||||
void gfx_printandclear(const char *in, int length, int endX){
|
||||
u32 x, y;
|
||||
|
||||
gfx_printlength(length, in);
|
||||
|
@ -126,12 +126,6 @@ void gfx_printandclear(char *in, int length, int endX){
|
|||
*/
|
||||
}
|
||||
|
||||
void gfx_printfilesize(int size, char *type){
|
||||
SWAPCOLOR(COLOR_VIOLET);
|
||||
gfx_printf("\a%4d\e%s", size, type);
|
||||
RESETCOLOR;
|
||||
}
|
||||
|
||||
static u32 sideY = 0;
|
||||
void _gfx_sideSetYAuto(){
|
||||
u32 getX, getY;
|
||||
|
@ -147,7 +141,7 @@ u32 gfx_sideGetY(){
|
|||
return sideY;
|
||||
}
|
||||
|
||||
void gfx_sideprintf(char* message, ...){
|
||||
void gfx_sideprintf(const char* message, ...){
|
||||
va_list ap;
|
||||
va_start(ap, message);
|
||||
|
||||
|
@ -158,7 +152,7 @@ void gfx_sideprintf(char* message, ...){
|
|||
va_end(ap);
|
||||
}
|
||||
|
||||
void gfx_sideprintandclear(char* message, int length){
|
||||
void gfx_sideprintandclear(const char* message, int length){
|
||||
gfx_con_setpos(800, sideY);
|
||||
gfx_printandclear(message, length, 1279);
|
||||
gfx_putc('\n');
|
||||
|
@ -180,7 +174,7 @@ void gfx_drawScrollBar(int minView, int maxView, int count){
|
|||
gfx_boxGrey(740, 16 + offsetSize, 755, 16 + barSize + offsetSize, 0x66);
|
||||
}
|
||||
|
||||
int gfx_defaultWaitMenu(char *message, int time){
|
||||
int gfx_defaultWaitMenu(const char *message, int time){
|
||||
gfx_clearscreen();
|
||||
SWAPCOLOR(COLOR_ORANGE);
|
||||
gfx_printf("\n%s\n\nPress B to return\n", message);
|
||||
|
|
|
@ -4,20 +4,20 @@
|
|||
|
||||
#define SWAPCOLOR(color) gfx_printf("%k", color)
|
||||
#define SWAPBGCOLOR(color) gfx_printf("%K", color)
|
||||
#define SWAPALLCOLOR(fg, bg) gfx_printf("%k%K", fg, bg)
|
||||
#define RESETCOLOR gfx_printf("%k%K", COLOR_WHITE, COLOR_DEFAULT)
|
||||
|
||||
void gfx_clearscreen();
|
||||
u32 gfx_message(u32 color, const char* message, ...);
|
||||
u32 gfx_errDisplay(char *src_func, int err, int loc);
|
||||
int gfx_makewaitmenu(char *hiddenmessage, int timer);
|
||||
void gfx_printlength(int size, char *toprint);
|
||||
void gfx_printandclear(char *in, int length, int endX);
|
||||
void gfx_printfilesize(int size, char *type);
|
||||
u32 gfx_errDisplay(const char *src_func, int err, int loc);
|
||||
int gfx_makewaitmenu(const char *hiddenmessage, int timer);
|
||||
void gfx_printlength(int size, const char *toprint);
|
||||
void gfx_printandclear(const char *in, int length, int endX);
|
||||
void gfx_sideSetY(u32 setY);
|
||||
u32 gfx_sideGetY();
|
||||
void gfx_sideprintf(char* message, ...);
|
||||
void gfx_sideprintandclear(char* message, int length);
|
||||
void gfx_sideprintf(const char* message, ...);
|
||||
void gfx_sideprintandclear(const char* message, int length);
|
||||
void gfx_drawScrollBar(int minView, int maxView, int count);
|
||||
int gfx_defaultWaitMenu(char *message, int time);
|
||||
int gfx_defaultWaitMenu(const char *message, int time);
|
||||
|
||||
extern int printerrors;
|
|
@ -9,81 +9,59 @@
|
|||
#include "../../soc/gpio.h"
|
||||
#include "../../hid/hid.h"
|
||||
#include "../fs/fsutils.h"
|
||||
#include "../utils/menuUtils.h"
|
||||
|
||||
extern void sd_unmount();
|
||||
extern bool sd_inited;
|
||||
|
||||
void _printentry(menu_entry *entry, bool highlighted, bool refresh, char *path){
|
||||
u64 size;
|
||||
u16 sizes = 0;
|
||||
u32 color = (entry->property & ISMENU) ? entry->storage : ((entry->property & ISDIR) ? COLOR_WHITE : COLOR_VIOLET);
|
||||
/*
|
||||
if (entry.property & ISMENU)
|
||||
SWAPCOLOR(entry.storage);
|
||||
else if (entry.property & ISDIR)
|
||||
SWAPCOLOR(COLOR_WHITE);
|
||||
else {
|
||||
SWAPCOLOR(COLOR_VIOLET);
|
||||
}
|
||||
*/
|
||||
#pragma GCC push_options
|
||||
#pragma GCC optimize ("O2")
|
||||
|
||||
if (!(entry->property & ISMENU && entry->property & ISDIR)){
|
||||
if (entry->property & ISNULL){
|
||||
size = fsutil_getfilesize(fsutil_getnextloc(path, entry->name));
|
||||
void _printentry(menu_entry *entry, bool highlighted, bool refresh, const char *path){
|
||||
u32 color = (entry->isMenu) ? entry->storage : ((entry->isDir) ? COLOR_WHITE : COLOR_VIOLET);
|
||||
|
||||
while (size > 1024){
|
||||
size /= 1024;
|
||||
sizes++;
|
||||
}
|
||||
SWAPALLCOLOR((highlighted) ? COLOR_DEFAULT : color, (highlighted) ? color : COLOR_DEFAULT);
|
||||
|
||||
if (sizes > 3)
|
||||
sizes = 0;
|
||||
|
||||
entry->property |= (1 << (4 + sizes));
|
||||
entry->storage = size;
|
||||
SETBIT(entry->property, ISNULL, 0);
|
||||
}
|
||||
|
||||
for (sizes = 4; sizes < 8; sizes++)
|
||||
if ((entry->property & (1 << sizes)))
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
if (highlighted){
|
||||
SWAPBGCOLOR(COLOR_WHITE);
|
||||
if ((entry.property & ISMENU) ? entry.storage == COLOR_WHITE : entry.property & ISDIR)
|
||||
SWAPCOLOR(COLOR_DEFAULT);
|
||||
}
|
||||
else
|
||||
SWAPBGCOLOR(COLOR_DEFAULT);
|
||||
*/
|
||||
SWAPCOLOR((highlighted) ? COLOR_DEFAULT : color);
|
||||
SWAPBGCOLOR((highlighted) ? color : COLOR_DEFAULT);
|
||||
|
||||
if (!(entry->property & ISMENU))
|
||||
gfx_printf("%c ", (entry->property & ISDIR) ? 30 : 31);
|
||||
if (!(entry->isMenu))
|
||||
gfx_printf("%c ", (entry->isDir) ? 30 : 31);
|
||||
|
||||
if (refresh)
|
||||
gfx_printandclear(entry->name, 37, 720);
|
||||
else
|
||||
gfx_printlength(37, entry->name);
|
||||
|
||||
if (entry->property & ISDIR || entry->property & ISMENU)
|
||||
if (entry->property & (ISMENU | ISDIR))
|
||||
gfx_printf("\n");
|
||||
else {
|
||||
SWAPCOLOR(COLOR_BLUE);
|
||||
SWAPBGCOLOR(COLOR_DEFAULT);
|
||||
if (entry->isNull){
|
||||
u64 totalSize;
|
||||
u32 sizeType = 0;
|
||||
totalSize = fsutil_getfilesize(fsutil_getnextloc(path, entry->name));
|
||||
|
||||
while (totalSize > 1024){
|
||||
totalSize /= 1024;
|
||||
sizeType++;
|
||||
}
|
||||
|
||||
if (sizeType > 3)
|
||||
sizeType = 3;
|
||||
|
||||
entry->size = sizeType;
|
||||
entry->storage = totalSize;
|
||||
SETBIT(entry->property, ISNULL, 0);
|
||||
}
|
||||
|
||||
SWAPALLCOLOR(COLOR_BLUE, COLOR_DEFAULT);
|
||||
gfx_printf("\a%4d", entry->storage);
|
||||
gfx_con.fntsz = 8;
|
||||
gfx_printf("\n\e%s\n", gfx_file_size_names[sizes - 4]);
|
||||
gfx_printf("\n\e%s\n", gfx_file_size_names[entry->size]);
|
||||
gfx_con.fntsz = 16;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool disableB = false;
|
||||
int menu_make(menu_entry *entries, int amount, char *toptext){
|
||||
int menu_make(menu_entry *entries, int amount, const char *toptext){
|
||||
int currentpos = 0, offset = 0, delay = 300, minscreen = 0, maxscreen = 39, calculatedamount = 0;
|
||||
u32 scrolltimer, timer, sideY;
|
||||
bool refresh = true;
|
||||
|
@ -92,23 +70,9 @@ int menu_make(menu_entry *entries, int amount, char *toptext){
|
|||
|
||||
gfx_clearscreen();
|
||||
|
||||
for (int i = 0; i < amount; i++)
|
||||
if (!(entries[i].property & ISMENU))
|
||||
calculatedamount++;
|
||||
calculatedamount = mu_countObjects(entries, ISMENU);
|
||||
|
||||
gfx_con_setpos(0, 16);
|
||||
/*
|
||||
if (calculatedamount){
|
||||
SWAPCOLOR(COLOR_DEFAULT);
|
||||
SWAPBGCOLOR(COLOR_WHITE);
|
||||
gfx_printf("%3d entries\n", calculatedamount);
|
||||
RESETCOLOR;
|
||||
}
|
||||
else
|
||||
gfx_printf("\n");
|
||||
*/
|
||||
|
||||
|
||||
|
||||
SWAPCOLOR(COLOR_GREEN);
|
||||
gfx_printlength(42, toptext);
|
||||
|
@ -162,7 +126,7 @@ int menu_make(menu_entry *entries, int amount, char *toptext){
|
|||
|
||||
if (refresh || currentfolder == NULL || !calculatedamount){
|
||||
for (int i = 0 + offset; i < amount && i < 40 + offset; i++)
|
||||
if (!(entries[i].property & ISHIDE))
|
||||
if (!(entries[i].isHide))
|
||||
_printentry(&entries[i], (i == currentpos), refresh, toptext);
|
||||
}
|
||||
else {
|
||||
|
@ -182,12 +146,12 @@ int menu_make(menu_entry *entries, int amount, char *toptext){
|
|||
RESETCOLOR;
|
||||
|
||||
sideY = gfx_sideGetY();
|
||||
if (!(entries[currentpos].property & ISMENU)){
|
||||
if (!(entries[currentpos].isMenu)){
|
||||
gfx_sideprintf("Current selection:\n");
|
||||
SWAPCOLOR(COLOR_YELLOW);
|
||||
gfx_sideprintandclear(entries[currentpos].name, 28);
|
||||
RESETCOLOR;
|
||||
gfx_sideprintf("Type: %s", (entries[currentpos].property & ISDIR) ? "Dir " : "File");
|
||||
gfx_sideprintf("Type: %s", (entries[currentpos].isDir) ? "Dir " : "File");
|
||||
gfx_sideSetY(sideY);
|
||||
}
|
||||
else
|
||||
|
@ -257,3 +221,5 @@ int menu_make(menu_entry *entries, int amount, char *toptext){
|
|||
//return (mode) ? currentpos : entries[currentpos].property;
|
||||
return currentpos;
|
||||
}
|
||||
|
||||
#pragma GCC pop_options
|
|
@ -1,4 +1,4 @@
|
|||
#pragma once
|
||||
#include "../common/types.h"
|
||||
|
||||
int menu_make(menu_entry *entries, int amount, char *toptext);
|
||||
int menu_make(menu_entry *entries, int amount, const char *toptext);
|
|
@ -131,6 +131,7 @@ void MainMenu_Exit(){
|
|||
case SHUTDOWN_AMS:
|
||||
launch_payload("/atmosphere/reboot_payload.bin");
|
||||
} //todo declock bpmp
|
||||
|
||||
}
|
||||
|
||||
func_void_ptr mainmenu_functions[] = {
|
||||
|
@ -153,27 +154,31 @@ void RunMenuOption(int option){
|
|||
void te_main(){
|
||||
int setter;
|
||||
|
||||
//gfx_printf("Initing controller\n");
|
||||
hidInit();
|
||||
|
||||
//gfx_printf("Getting biskeys\n");
|
||||
if (dump_biskeys() == -1){
|
||||
gfx_errDisplay("dump_biskey", ERR_BISKEY_DUMP_FAILED, 0);
|
||||
//mainmenu_main[1].property |= ISHIDE;
|
||||
}
|
||||
|
||||
//gfx_message(COLOR_ORANGE, "%d %d %d", sd_mount(), sd_mounted, sd_inited);
|
||||
//gfx_printf("Mounting SD\n");
|
||||
sd_mount();
|
||||
|
||||
//gfx_printf("Loading possible EMU\n");
|
||||
if (emummc_load_cfg()){
|
||||
mainmenu_main[2].property |= ISHIDE;
|
||||
}
|
||||
|
||||
//gfx_printf("Dumping gpt\n");
|
||||
dumpGpt();
|
||||
|
||||
//gfx_printf("Disconnecting EMMC\n");
|
||||
disconnect_mmc();
|
||||
|
||||
hidInit();
|
||||
|
||||
//gfx_printf("Entering main menu\n");
|
||||
while (1){
|
||||
//fillmainmenu();
|
||||
|
||||
setter = sd_mounted;
|
||||
|
||||
if (emu_cfg.enabled){
|
||||
|
|
|
@ -64,6 +64,9 @@ int parseStringInput(char *in, char **out){
|
|||
}
|
||||
}
|
||||
|
||||
#pragma GCC push_options
|
||||
#pragma GCC optimize ("Os")
|
||||
|
||||
u32 currentcolor = COLOR_WHITE;
|
||||
int part_printf(){
|
||||
SWAPCOLOR(currentcolor);
|
||||
|
@ -584,6 +587,8 @@ str_fnc_struct functions[] = {
|
|||
{NULL, NULL, 0}
|
||||
};
|
||||
|
||||
#pragma GCC pop_options
|
||||
|
||||
int run_function(char *func_name, int *out){
|
||||
for (u32 i = 0; functions[i].key != NULL; i++){
|
||||
if (!strcmp(functions[i].key, func_name)){
|
||||
|
|
|
@ -64,13 +64,14 @@ u32 splitargs(char* in) {
|
|||
curcount++;
|
||||
current = 0;
|
||||
}
|
||||
else if (in[i] == '@' || in[i] == '$' || in[i] == '?') {
|
||||
while (in[i] != ',' && in[i] != ' ' && in[i] != ')' && i < len) {
|
||||
else if (in[i] == '@' || in[i] == '$') {
|
||||
while (strrchr(", )", in[i]) == NULL && i < len) {
|
||||
argv[curcount][current++] = in[i++];
|
||||
}
|
||||
i--;
|
||||
}
|
||||
else if ((in[i] >= '0' && in[i] <= '9') || (in[i] >= '<' && in[i] <= '>') || in[i] == '+' || in[i] == '-' || in[i] == '*' || in[i] == '/')
|
||||
//else if ((in[i] >= '0' && in[i] <= '9') || (in[i] >= '<' && in[i] <= '>') || in[i] == '+' || in[i] == '-' || in[i] == '*' || in[i] == '/')
|
||||
else if (strrchr("0123456789<=>+-*/", in[i]) != NULL)
|
||||
argv[curcount][current++] = in[i];
|
||||
else if (in[i] == '"') {
|
||||
i++;
|
||||
|
|
44
source/tegraexplorer/utils/menuUtils.c
Normal file
44
source/tegraexplorer/utils/menuUtils.c
Normal file
|
@ -0,0 +1,44 @@
|
|||
#include "menuUtils.h"
|
||||
#include "../../utils/types.h"
|
||||
#include "../common/types.h"
|
||||
#include "../../mem/heap.h"
|
||||
#include "utils.h"
|
||||
|
||||
void mu_clearObjects(menu_entry **menu){
|
||||
if ((*menu) != NULL){
|
||||
for (int i = 0; (*menu)[i].name != NULL; i++){
|
||||
free((*menu)[i].name);
|
||||
(*menu)[i].name = NULL;
|
||||
}
|
||||
free((*menu));
|
||||
(*menu) = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void mu_createObjects(int size, menu_entry **menu){
|
||||
(*menu) = calloc (size + 1, sizeof(menu_entry));
|
||||
(*menu)[size].name = NULL;
|
||||
}
|
||||
|
||||
int mu_countObjects(menu_entry *entries, u8 propertyMask){
|
||||
int amount = 0;
|
||||
|
||||
for (u32 i = 0; entries[i].name != NULL; i++){
|
||||
if (!(entries[i].property & propertyMask))
|
||||
amount++;
|
||||
}
|
||||
|
||||
while (entries[amount].name != NULL)
|
||||
amount++;
|
||||
|
||||
return amount;
|
||||
}
|
||||
|
||||
void mu_copySingle(char *name, u32 storage, u8 property, menu_entry *out){
|
||||
if (out->name != NULL)
|
||||
free(out->name);
|
||||
|
||||
utils_copystring(name, &out->name);
|
||||
out->storage = storage;
|
||||
out->property = property;
|
||||
}
|
8
source/tegraexplorer/utils/menuUtils.h
Normal file
8
source/tegraexplorer/utils/menuUtils.h
Normal file
|
@ -0,0 +1,8 @@
|
|||
#pragma once
|
||||
#include "../../utils/types.h"
|
||||
#include "../common/types.h"
|
||||
|
||||
void mu_createObjects(int size, menu_entry **menu);
|
||||
void mu_clearObjects(menu_entry **menu);
|
||||
int mu_countObjects(menu_entry *entries, u8 propertyMask);
|
||||
void mu_copySingle(char *name, u32 storage, u8 property, menu_entry *out);
|
Loading…
Reference in a new issue