mirror of
https://github.com/suchmememanyskill/TegraExplorer.git
synced 2024-11-08 05:01:46 +00:00
Mess with the design a bit, prep for folder menu
This commit is contained in:
parent
5190469e9c
commit
b97bab3661
10 changed files with 73 additions and 21 deletions
|
@ -10,6 +10,7 @@
|
|||
#include <mem/heap.h>
|
||||
|
||||
MenuEntry_t topEntries[] = {
|
||||
{.optionUnion = COLORTORGB(COLOR_GREEN) | SKIPBIT},
|
||||
{.optionUnion = COLORTORGB(COLOR_ORANGE), .name = "Back"},
|
||||
{.optionUnion = COLORTORGB(COLOR_GREY) | SKIPBIT, .name = "Clipboard -> Current folder"},
|
||||
{.optionUnion = COLORTORGB(COLOR_GREY) | SKIPBIT, .name = "Current folder options"}
|
||||
|
@ -23,8 +24,6 @@ MenuEntry_t MakeMenuOutFSEntry(FSEntry_t entry){
|
|||
return out;
|
||||
}
|
||||
|
||||
#define maxYOnScreen 42
|
||||
|
||||
void clearFileVector(Vector_t *v){
|
||||
vecPDefArray(FSEntry_t*, entries, v);
|
||||
for (int i = 0; i < v->count; i++)
|
||||
|
@ -40,21 +39,25 @@ void FileExplorer(char *path){
|
|||
while (1){
|
||||
gfx_clearscreen();
|
||||
gfx_printf("Loading...\r");
|
||||
//gfx_printf(" ");
|
||||
Vector_t fileVec = ReadFolder(storedPath);
|
||||
vecDefArray(FSEntry_t*, fsEntries, fileVec);
|
||||
|
||||
Vector_t entries = newVec(sizeof(MenuEntry_t), maxYOnScreen);
|
||||
entries.count = 3;
|
||||
memcpy(entries.data, topEntries, sizeof(MenuEntry_t) * 3);
|
||||
topEntries[0].name = storedPath;
|
||||
Vector_t entries = newVec(sizeof(MenuEntry_t), fileVec.count + ARR_LEN(topEntries));
|
||||
entries.count = ARR_LEN(topEntries);
|
||||
memcpy(entries.data, topEntries, sizeof(MenuEntry_t) * ARR_LEN(topEntries));
|
||||
|
||||
for (int i = 0; i < fileVec.count; i++){
|
||||
MenuEntry_t a = MakeMenuOutFSEntry(fsEntries[i]);
|
||||
vecAddElem(&entries, a);
|
||||
}
|
||||
|
||||
res = newMenu(&entries, res, 50, maxYOnScreen, ENABLEB | ENABLEPAGECOUNT, (int)fileVec.count);
|
||||
gfx_con_setpos(144, 16);
|
||||
gfx_boxGrey(0, 16, 160, 31, 0x1B);
|
||||
res = newMenu(&entries, res, 60, 42, ENABLEB | ENABLEPAGECOUNT, (int)fileVec.count);
|
||||
|
||||
if (res < 3) {
|
||||
if (res < ARR_LEN(topEntries)) {
|
||||
if (!strcmp(storedPath, path)){
|
||||
clearFileVector(&fileVec);
|
||||
return;
|
||||
|
@ -64,9 +67,9 @@ void FileExplorer(char *path){
|
|||
storedPath = EscapeFolder(copy);
|
||||
free(copy);
|
||||
}
|
||||
else if (fsEntries[res - 3].isDir) {
|
||||
else if (fsEntries[res - ARR_LEN(topEntries)].isDir) {
|
||||
char *copy = CpyStr(storedPath);
|
||||
storedPath = CombinePaths(copy, fsEntries[res - 3].name);
|
||||
storedPath = CombinePaths(copy, fsEntries[res - ARR_LEN(topEntries)].name);
|
||||
free(copy);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,4 @@
|
|||
#pragma once
|
||||
#include "../../utils/vector.h"
|
||||
|
||||
typedef struct {
|
||||
char *curPath;
|
||||
Vector_t *files;
|
||||
} ExplorerCtx_t;
|
||||
|
||||
void FileExplorer(char *path);
|
0
source/fs/menus/filemenu.c
Normal file
0
source/fs/menus/filemenu.c
Normal file
0
source/fs/menus/filemenu.h
Normal file
0
source/fs/menus/filemenu.h
Normal file
|
@ -362,16 +362,22 @@ static void _gfx_putn(u32 v, int base, char fill, int fcnt)
|
|||
v /= base;
|
||||
} while (v);
|
||||
|
||||
if (minus){
|
||||
*--p = '-';
|
||||
c--;
|
||||
}
|
||||
|
||||
if (fill != 0)
|
||||
{
|
||||
gfx_con.y -= c * 16;
|
||||
/*
|
||||
while (c > 0)
|
||||
{
|
||||
*--p = fill;
|
||||
c--;
|
||||
}
|
||||
*/
|
||||
}
|
||||
if (minus)
|
||||
gfx_putc('-');
|
||||
|
||||
gfx_puts(p);
|
||||
}
|
||||
|
|
|
@ -27,9 +27,9 @@ void _printEntry(MenuEntry_t entry, u32 maxLen, u8 highlighted){
|
|||
|
||||
u32 curX = 0, curY = 0;
|
||||
gfx_con_getpos(&curX, &curY);
|
||||
gfx_puts_limit(entry.name, maxLen - 8);
|
||||
gfx_puts_limit(entry.name, maxLen - ((entry.showSize) ? 8 : 0));
|
||||
if (entry.showSize){
|
||||
SETCOLOR(COLOR_BLUE, COLOR_DEFAULT);
|
||||
(highlighted) ? SETCOLOR(COLOR_DEFAULT, COLOR_BLUE) : SETCOLOR(COLOR_BLUE, COLOR_DEFAULT);
|
||||
gfx_con_setpos(curX + (maxLen - 6) * 16, curY);
|
||||
gfx_printf("%4d", entry.size);
|
||||
gfx_puts_small(sizeDefs[entry.sizeDef]);
|
||||
|
@ -77,7 +77,7 @@ int newMenu(Vector_t* vec, int startIndex, int screenLenX, int screenLenY, u8 op
|
|||
if (options & ENABLEPAGECOUNT){
|
||||
gfx_con_setpos(startX, startY - 32);
|
||||
RESETCOLOR;
|
||||
gfx_printf("Page %d / %d | Total %d entries\n", (selected / screenLenY) + 1, (vec->count / screenLenY) + 1, entryCount);
|
||||
gfx_printf("Page %d / %d | Total %d entries ", (selected / screenLenY) + 1, (vec->count / screenLenY) + 1, entryCount);
|
||||
}
|
||||
|
||||
gfx_con_setpos(startX, startY);
|
||||
|
@ -86,8 +86,11 @@ int newMenu(Vector_t* vec, int startIndex, int screenLenX, int screenLenY, u8 op
|
|||
gfx_boxGrey(startX, startY, startX + screenLenX * 16, startY + screenLenY * 16, 0x1B);
|
||||
|
||||
int start = selected / screenLenY * screenLenY;
|
||||
for (int i = start; i < MIN(vec->count, start + screenLenY); i++)
|
||||
for (int i = start; i < MIN(vec->count, start + screenLenY); i++){
|
||||
gfx_con_setpos(startX, startY + ((i % screenLenY) * 16));
|
||||
_printEntry(entries[i], screenLenX, (i == selected));
|
||||
}
|
||||
|
||||
}
|
||||
else if (lastIndex != selected) {
|
||||
u32 minLastCur = MIN(lastIndex, selected);
|
||||
|
|
|
@ -38,5 +38,7 @@ typedef struct _menuEntry {
|
|||
#define ENABLEPAGECOUNT BIT(1)
|
||||
#define ALWAYSREDRAW BIT(2)
|
||||
|
||||
#define ARR_LEN(x) (sizeof(x) / sizeof(*x))
|
||||
|
||||
int newMenu(Vector_t* vec, int startIndex, int screenLenX, int screenLenY, u8 options, int entryCount);
|
||||
void FunctionMenuHandler(MenuEntry_t *entries, int entryCount, menuPaths *paths, u8 options);
|
|
@ -46,6 +46,7 @@
|
|||
#include "utils/vector.h"
|
||||
#include "gfx/gfxutils.h"
|
||||
#include "tegraexplorer/mainmenu.h"
|
||||
#include "tegraexplorer/tconf.h"
|
||||
|
||||
|
||||
hekate_config h_cfg;
|
||||
|
@ -174,8 +175,11 @@ void ipl_main()
|
|||
// Mount SD Card.
|
||||
h_cfg.errors |= !sd_mount() ? ERR_SD_BOOT_EN : 0;
|
||||
|
||||
TConf.minervaEnabled = !minerva_init();
|
||||
TConf.FSBuffSize = (TConf.minervaEnabled) ? 0x400000 : 0x10000;
|
||||
|
||||
// Train DRAM and switch to max frequency.
|
||||
if (minerva_init()) //!TODO: Add Tegra210B01 support to minerva.
|
||||
if (TConf.minervaEnabled) //!TODO: Add Tegra210B01 support to minerva.
|
||||
h_cfg.errors |= ERR_LIBSYS_MTC;
|
||||
minerva_change_freq(FREQ_1600);
|
||||
|
||||
|
|
2
source/tegraexplorer/tconf.c
Normal file
2
source/tegraexplorer/tconf.c
Normal file
|
@ -0,0 +1,2 @@
|
|||
#include "tconf.h"
|
||||
TConf_t TConf = {0};
|
37
source/tegraexplorer/tconf.h
Normal file
37
source/tegraexplorer/tconf.h
Normal file
|
@ -0,0 +1,37 @@
|
|||
#pragma once
|
||||
#include <utils/types.h>
|
||||
|
||||
enum {
|
||||
LOC_SD = 0,
|
||||
LOC_EMMC,
|
||||
LOC_EMUMMC
|
||||
};
|
||||
|
||||
enum {
|
||||
CMODE_None = 0,
|
||||
CMODE_Copy,
|
||||
CMODE_Move
|
||||
};
|
||||
|
||||
enum {
|
||||
M_None = 0,
|
||||
M_EMMC,
|
||||
M_EMUMMC
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
u32 FSBuffSize;
|
||||
char *srcCopy;
|
||||
union {
|
||||
struct {
|
||||
u8 minervaEnabled:1;
|
||||
u8 lastExplorerLoc:2;
|
||||
u8 explorerCopyMode:2;
|
||||
u8 currentlyMounted:2;
|
||||
};
|
||||
u8 optionUnion;
|
||||
};
|
||||
// Add keys here
|
||||
} TConf_t;
|
||||
|
||||
extern TConf_t TConf;
|
Loading…
Reference in a new issue