Files
AllgemeinerProblemLoeser/source/tegraexplorer/mainmenu.c

159 lines
5.5 KiB
C

#include "mainmenu.h"
#include "../gfx/gfx.h"
#include "../gfx/gfxutils.h"
#include "../gfx/menu.h"
#include "tools.h"
#include "../hid/hid.h"
#include "../fs/menus/explorer.h"
#include <utils/btn.h>
#include <storage/sd.h>
#include "tconf.h"
#include "../keys/keys.h"
#include "../storage/mountmanager.h"
#include "../storage/gptmenu.h"
#include "../storage/emummc.h"
#include <utils/util.h>
#include "../fs/fsutils.h"
#include <soc/fuse.h>
#include "../utils/utils.h"
#include "../config.h"
#include "../fs/readers/folderReader.h"
#include "../fs/fstypes.h"
#include "../fs/fscopy.h"
#include <utils/sprintf.h>
#include <stdlib.h>
#include <string.h>
#include "../apl/apl.h"
extern hekate_config h_cfg;
enum {
MainExplore = 0,
DeleteBootFlags,
DeleteThemes,
FixClingWrap,
FixAIOUpdaterBoot,
FixArchiveBitA,
FixArchiveBitN,
// FixAll,
MainConvenience,
FixMacSpecialFolders,
MainOther,
MainViewStillNoBootInfo,
MainViewCredits,
MainExit,
MainPowerOff,
MainRebootRCM,
// MainRebootNormal,
MainRebootHekate,
};
MenuEntry_t mainMenuEntries[] = {
[MainExplore] = {.optionUnion = COLORTORGB(COLOR_WHITE) | SKIPBIT, .name = "-- Behebe Start Probleme --"},
[DeleteBootFlags] = {.optionUnion = COLORTORGB(COLOR_GREEN), .name = "Automatisches starten der sysmodule deaktivieren"},
[DeleteThemes] = {.optionUnion = COLORTORGB(COLOR_GREEN), .name = "Loesche installierte Themes"},
[FixClingWrap] = {.optionUnion = COLORTORGB(COLOR_GREEN), .name = "Repariere SigPatches"},
[FixAIOUpdaterBoot] = {.optionUnion = COLORTORGB(COLOR_GREEN), .name = "Behebe fehlerhaftes AIO-switch-updater Update"},
[FixArchiveBitA] = {.optionUnion = COLORTORGB(COLOR_GREEN), .name = "Behebe Archive Bit (alle Ordner ausser Nintendo)"},
[FixArchiveBitN] = {.optionUnion = COLORTORGB(COLOR_GREEN), .name = "Behebe Archive Bit (Nintendo Ordner)"},
// [FixAll] = {.optionUnion = COLORTORGB(COLOR_GREEN), .name = "Try everything"},
[MainConvenience] = {.optionUnion = COLORTORGB(COLOR_WHITE) | SKIPBIT, .name = "\n-- Bequemlichkeit --"},
[FixMacSpecialFolders] = {.optionUnion = COLORTORGB(COLOR_ORANGE), .name = "Entferne spezielle MacOS Dateien"},
[MainOther] = {.optionUnion = COLORTORGB(COLOR_WHITE) | SKIPBIT, .name = "\n-- Sonstiges --"},
[MainViewStillNoBootInfo] = {.optionUnion = COLORTORGB(COLOR_YELLOW), .name = "Meine Switch startet nicht mehr"},
[MainViewCredits] = {.optionUnion = COLORTORGB(COLOR_YELLOW), .name = "Ueber"},
[MainExit] = {.optionUnion = COLORTORGB(COLOR_WHITE) | SKIPBIT, .name = "\n-- Beenden --"},
[MainPowerOff] = {.optionUnion = COLORTORGB(COLOR_PURPLE), .name = "Ausschalten"},
[MainRebootRCM] = {.optionUnion = COLORTORGB(COLOR_PURPLE), .name = "Neustart in RCM-Modus"},
// [MainRebootNormal] = {.optionUnion = COLORTORGB(COLOR_VIOLET), .name = "Normaler Neustart"},
[MainRebootHekate] = {.optionUnion = COLORTORGB(COLOR_PURPLE), .name = "Neustart in hekate"}
// [MainBrowseSd] = {.optionUnion = COLORTORGB(COLOR_GREEN), .name = "Browse SD"},
// [MainMountSd] = {.optionUnion = COLORTORGB(COLOR_YELLOW)}, // To mount/unmount the SD
// [MainBrowseEmmc] = {.optionUnion = COLORTORGB(COLOR_BLUE), .name = "Browse EMMC"},
// [MainBrowseEmummc] = {.optionUnion = COLORTORGB(COLOR_BLUE), .name = "Browse EMUMMC"},
// [MainTools] = {.optionUnion = COLORTORGB(COLOR_WHITE) | SKIPBIT, .name = "\n-- Tools --"},
// [MainPartitionSd] = {.optionUnion = COLORTORGB(COLOR_ORANGE), .name = "Partition the sd"},
// [MainDumpFw] = {.optionUnion = COLORTORGB(COLOR_BLUE), .name = "Dump Firmware"},
// [MainViewKeys] = {.optionUnion = COLORTORGB(COLOR_YELLOW), .name = "View dumped keys"},
};
void HandleSD(){
gfx_clearscreen();
TConf.curExplorerLoc = LOC_SD;
if (!sd_mount() || sd_get_card_removed()){
gfx_printf("Sd is not mounted!");
hidWait();
}
else
FileExplorer("sd:/");
}
extern bool is_sd_inited;
extern int launch_payload(char *path);
void RebootToHekate(){
launch_payload("sd:/bootloader/update.bin");
}
void MountOrUnmountSD(){
gfx_clearscreen();
if (sd_get_card_mounted())
sd_unmount();
else if (!sd_mount())
hidWait();
}
void archBitHelperA(){
m_entry_fixArchiveBit(0);
}
void archBitHelperN(){
m_entry_fixArchiveBit(1);
}
menuPaths mainMenuPaths[] = {
[DeleteBootFlags] = m_entry_deleteBootFlags,
[DeleteThemes] = m_entry_deleteInstalledThemes,
[FixClingWrap] = m_entry_fixClingWrap,
[FixAIOUpdaterBoot] = m_entry_fixAIOUpdate,
[FixArchiveBitA] = archBitHelperA,
[FixArchiveBitN] = archBitHelperN,
[FixMacSpecialFolders] = m_entry_fixMacSpecialFolders,
// [FixAll] = m_entry_fixAll,
[MainViewStillNoBootInfo] = m_entry_stillNoBootInfo,
[MainRebootHekate] = RebootToHekate,
[MainRebootRCM] = reboot_rcm,
[MainPowerOff] = power_off,
[MainViewCredits] = m_entry_ViewCredits,
};
void EnterMainMenu(){
int res = 0;
while (1){
if (sd_get_card_removed())
sd_unmount();
// // -- Exit --
mainMenuEntries[MainRebootHekate].hide = (!sd_get_card_mounted() || !FileExists("sd:/bootloader/update.bin"));
mainMenuEntries[MainRebootRCM].hide = h_cfg.t210b01;
gfx_clearscreen();
gfx_putc('\n');
Vector_t ent = vecFromArray(mainMenuEntries, ARR_LEN(mainMenuEntries), sizeof(MenuEntry_t));
res = newMenu(&ent, res, 79, 30, ALWAYSREDRAW, 0);
if (mainMenuPaths[res] != NULL)
mainMenuPaths[res]();
}
}