mirror of
https://github.com/suchmememanyskill/TegraExplorer.git
synced 2024-12-26 11:26:05 +00:00
Add a bit of tools + make unselectable menu objects
+ fix compile error + move back to top of menus
This commit is contained in:
parent
7b0faabf38
commit
be79d64deb
5 changed files with 71 additions and 25 deletions
|
@ -24,11 +24,11 @@ int makemenu(menu_item menu[], int menuamount){
|
|||
gfx_con_setpos(0, 31);
|
||||
|
||||
if (currentpos == 1){
|
||||
while (currentpos < menuamount && menu[currentpos - 1].property < 0)
|
||||
while (currentpos < menuamount && menu[currentpos - 1].property < 1)
|
||||
currentpos++;
|
||||
}
|
||||
if (currentpos == menuamount){
|
||||
while (currentpos > 1 && menu[currentpos - 1].property < 0)
|
||||
while (currentpos > 1 && menu[currentpos - 1].property < 1)
|
||||
currentpos--;
|
||||
}
|
||||
|
||||
|
@ -46,13 +46,13 @@ int makemenu(menu_item menu[], int menuamount){
|
|||
|
||||
if (res & BTN_VOL_UP && currentpos > 1){
|
||||
currentpos--;
|
||||
while(menu[currentpos - 1].property < 0 && currentpos > 1)
|
||||
while(menu[currentpos - 1].property < 1 && currentpos > 1)
|
||||
currentpos--;
|
||||
}
|
||||
|
||||
else if (res & BTN_VOL_DOWN && currentpos < menuamount){
|
||||
currentpos++;
|
||||
while(menu[currentpos - 1].property < 0 && currentpos < menuamount)
|
||||
while(menu[currentpos - 1].property < 1 && currentpos < menuamount)
|
||||
currentpos++;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
#pragma once
|
||||
#include "te.h"
|
||||
|
||||
int makemenu(menu_item menu[], int menuamount);
|
||||
int message(char* message, u32 color);
|
||||
int message(char* message, u32 color);
|
||||
void clearscreen();
|
|
@ -3,25 +3,33 @@
|
|||
#include "te.h"
|
||||
#include "gfx.h"
|
||||
#include "../utils/util.h"
|
||||
#include "tools.h"
|
||||
|
||||
extern bool sd_mount();
|
||||
extern void sd_unmount();
|
||||
bool sd_mounted = false;
|
||||
|
||||
menu_item mainmenu[MAINMENU_AMOUNT] = {
|
||||
{"[SD:/] SD CARD", COLOR_GREEN, 1, 0},
|
||||
{"[EMMC:/] ?\n", COLOR_GREEN, 2, 0},
|
||||
{"Mount/Unmount SD", COLOR_WHITE, 3, 0},
|
||||
{"Tools\n", COLOR_VIOLET, 4, 0},
|
||||
{"Credits", COLOR_WHITE, 5, 0},
|
||||
{"Exit", COLOR_WHITE, 6, 0}
|
||||
{"[SD:/] SD CARD", COLOR_GREEN, 1, 1},
|
||||
{"[EMMC:/] ?", COLOR_GREEN, 2, 1},
|
||||
{"\nMount/Unmount SD", COLOR_WHITE, 3, 1},
|
||||
{"Tools", COLOR_VIOLET, 4, 1},
|
||||
{"\nCredits", COLOR_WHITE, 5, 1},
|
||||
{"Exit", COLOR_WHITE, 6, 1}
|
||||
};
|
||||
|
||||
menu_item shutdownmenu[4] = {
|
||||
{"Reboot to RCM", COLOR_VIOLET, 1, 0},
|
||||
{"Reboot normally", COLOR_ORANGE, 2, 0},
|
||||
{"Power off\n", COLOR_BLUE, 3, 0},
|
||||
{"Back", COLOR_WHITE, 4, 0}
|
||||
menu_item shutdownmenu[5] = {
|
||||
{"-- EXIT --\n", COLOR_ORANGE, -1, 0},
|
||||
{"Back", COLOR_WHITE, 1, 1},
|
||||
{"\nReboot to RCM", COLOR_VIOLET, 2, 1},
|
||||
{"Reboot normally", COLOR_ORANGE, 3, 1},
|
||||
{"Power off", COLOR_BLUE, 4, 1}
|
||||
};
|
||||
|
||||
menu_item toolsmenu[3] = {
|
||||
{"-- TOOLS --\n", COLOR_VIOLET, -1, 0},
|
||||
{"Back", COLOR_WHITE, 1, 1},
|
||||
{"\nDisplay Console Info", COLOR_GREEN, 2, 1}
|
||||
};
|
||||
|
||||
void fillmainmenu(){
|
||||
|
@ -37,12 +45,12 @@ void fillmainmenu(){
|
|||
break;
|
||||
case 3:
|
||||
if (sd_mounted){
|
||||
mainmenu[i].property = 1;
|
||||
strcpy(mainmenu[i].name, "Unmount SD");
|
||||
mainmenu[i].property = 2;
|
||||
strcpy(mainmenu[i].name, "\nUnmount SD");
|
||||
}
|
||||
else {
|
||||
mainmenu[i].property = 0;
|
||||
strcpy(mainmenu[i].name, "Mount SD");
|
||||
mainmenu[i].property = 1;
|
||||
strcpy(mainmenu[i].name, "\nMount SD");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -67,17 +75,24 @@ void te_main(){
|
|||
sd_mounted = sd_mount();
|
||||
}
|
||||
|
||||
if (res == 4){
|
||||
res = makemenu(toolsmenu, 3);
|
||||
|
||||
if (res == 2)
|
||||
displayinfo();
|
||||
}
|
||||
|
||||
if (res == 5)
|
||||
message(CREDITS_MESSAGE, COLOR_WHITE);
|
||||
|
||||
if (res == 6){
|
||||
res = makemenu(shutdownmenu, 4);
|
||||
if (res == 1)
|
||||
res = makemenu(shutdownmenu, 5);
|
||||
if (res == 2)
|
||||
reboot_rcm();
|
||||
else if (res == 2)
|
||||
reboot_normal();
|
||||
else if (res == 3)
|
||||
power_off();
|
||||
reboot_normal();
|
||||
else if (res == 4)
|
||||
power_off(); //todo declock bpmp
|
||||
}
|
||||
}
|
||||
}
|
26
source/tegraexplorer/tools.c
Normal file
26
source/tegraexplorer/tools.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
#include "tools.h"
|
||||
#include "gfx.h"
|
||||
#include "../libs/fatfs/ff.h"
|
||||
#include "../gfx/gfx.h"
|
||||
#include "../utils/btn.h"
|
||||
|
||||
void displayinfo(){
|
||||
clearscreen();
|
||||
|
||||
FATFS *fs;
|
||||
DWORD fre_clust, fre_sect, tot_sect;
|
||||
int res;
|
||||
|
||||
gfx_printf("Getting storage info: please wait...");
|
||||
|
||||
res = f_getfree("sd:", &fre_clust, &fs);
|
||||
gfx_printf("\nResult getfree: %d\n\n", res);
|
||||
|
||||
tot_sect = (fs->n_fatent - 2) * fs->csize;
|
||||
fre_sect = fre_clust * fs->csize;
|
||||
|
||||
gfx_printf("%d KiB total\n%d KiB free\n\nPress any key to continue", tot_sect / 2, fre_sect / 2);
|
||||
|
||||
|
||||
btn_wait();
|
||||
}
|
3
source/tegraexplorer/tools.h
Normal file
3
source/tegraexplorer/tools.h
Normal file
|
@ -0,0 +1,3 @@
|
|||
#pragma once
|
||||
|
||||
void displayinfo();
|
Loading…
Reference in a new issue