mirror of
https://github.com/suchmememanyskill/TegraExplorer.git
synced 2024-11-09 13:41:45 +00:00
implement offsets
// Weird bug, every time the screen is interacted with the time to draw the screen increases?
This commit is contained in:
parent
79027591ac
commit
d33bf83138
1 changed files with 38 additions and 8 deletions
|
@ -1,9 +1,13 @@
|
|||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "../gfx/gfx.h"
|
||||
#include "te.h"
|
||||
#include "../utils/btn.h"
|
||||
#include "../utils/util.h"
|
||||
#include "gfx.h"
|
||||
#include "fs.h"
|
||||
#include "../mem/minerva.h"
|
||||
|
||||
const char fixedoptions[3][50] = {
|
||||
"Folder -> previous folder",
|
||||
|
@ -78,6 +82,17 @@ int makemenu(menu_item menu[], int menuamount){
|
|||
|
||||
void printfsentry(fs_entry file, bool highlight){
|
||||
int size = 0;
|
||||
char *display;
|
||||
|
||||
display = (char*) malloc (38);
|
||||
memset(display + 37, '\0', 1);
|
||||
|
||||
if (strlen(file.name) > 37){
|
||||
strlcpy(display, file.name, 37);
|
||||
memset(display + 34, '.', 3);
|
||||
}
|
||||
else // make option to clear the screen gracefully line by line
|
||||
strcpy(display, file.name);
|
||||
|
||||
if (highlight)
|
||||
gfx_printf("%K%k", COLOR_WHITE, COLOR_DEFAULT);
|
||||
|
@ -85,34 +100,38 @@ void printfsentry(fs_entry file, bool highlight){
|
|||
gfx_printf("%K%k", COLOR_DEFAULT, COLOR_WHITE);
|
||||
|
||||
if (file.property & ISDIR)
|
||||
gfx_printf("%s\n", file.name);
|
||||
gfx_printf("%s\n", display);
|
||||
else {
|
||||
for (size = 4; size < 8; size++)
|
||||
if ((file.property & (1 << size)))
|
||||
break;
|
||||
|
||||
gfx_printf("%k%s%K\a%d\e%s", COLOR_VIOLET, file.name, COLOR_DEFAULT, file.size, sizevalues[size - 4]);
|
||||
gfx_printf("%k%s%K\a%d\e%s", COLOR_VIOLET, display, COLOR_DEFAULT, file.size, sizevalues[size - 4]);
|
||||
}
|
||||
}
|
||||
|
||||
int makefilemenu(fs_entry *files, int amount, char *path){
|
||||
int currentpos = 1, i, res = 0, offset = 0, quickoffset = 300;
|
||||
u32 timer;
|
||||
clearscreen();
|
||||
gfx_con_setpos(544, 0);
|
||||
gfx_printf("%K%k%d / 500\n%K%k%s%k\n\n", COLOR_WHITE, COLOR_DEFAULT, amount, COLOR_DEFAULT, COLOR_GREEN, path, COLOR_DEFAULT);
|
||||
while (1){
|
||||
gfx_con_setpos(0, 47);
|
||||
for (i = -3 + offset; i < amount; i++){
|
||||
timer = get_tmr_ms();
|
||||
for (i = -3 + offset; i < amount && i < 30 + offset; i++){
|
||||
if (i < 0){
|
||||
if (i == currentpos - 1)
|
||||
gfx_printf("%k%K%s%K\n", COLOR_ORANGE, COLOR_WHITE, fixedoptions[i + 3], COLOR_DEFAULT);
|
||||
else
|
||||
gfx_printf("%k%s\n", COLOR_ORANGE, fixedoptions[i + 3]);
|
||||
gfx_printf("%k%K%s\n", COLOR_ORANGE, COLOR_DEFAULT, fixedoptions[i + 3]);
|
||||
}
|
||||
else
|
||||
printfsentry(files[i], (i == currentpos - 1));
|
||||
}
|
||||
|
||||
gfx_printf("\n%k%K %s %s\nTime taken: %dms", COLOR_BLUE, COLOR_DEFAULT, (offset + 30 < amount) ? "v" : " ", (offset > 0) ? "^" : " ", get_tmr_ms() - timer);
|
||||
|
||||
if (quickoffset == 300)
|
||||
res = btn_wait();
|
||||
else {
|
||||
|
@ -122,14 +141,25 @@ int makefilemenu(fs_entry *files, int amount, char *path){
|
|||
|
||||
if (res == 0)
|
||||
quickoffset = 300;
|
||||
else if (quickoffset > 50)
|
||||
quickoffset -= 50;
|
||||
else if (quickoffset > 46)
|
||||
quickoffset -= 45;
|
||||
|
||||
if ((res & BTN_VOL_UP) && currentpos > -2)
|
||||
if ((res & BTN_VOL_UP) && currentpos > -2){
|
||||
currentpos--;
|
||||
if ((res & BTN_VOL_DOWN) && currentpos < amount)
|
||||
if (offset != 0 && currentpos < offset - 2){
|
||||
offset--;
|
||||
gfx_box(0, 47, 719, 576, COLOR_DEFAULT);
|
||||
}
|
||||
}
|
||||
if ((res & BTN_VOL_DOWN) && currentpos < amount){
|
||||
currentpos++;
|
||||
if (currentpos - offset > 30){
|
||||
offset++;
|
||||
gfx_box(0, 47, 719, 576, COLOR_DEFAULT);
|
||||
}
|
||||
}
|
||||
if (res & BTN_POWER)
|
||||
return currentpos;
|
||||
}
|
||||
minerva_periodic_training();
|
||||
}
|
Loading…
Reference in a new issue