Add file options menu
This commit is contained in:
@@ -10,9 +10,9 @@
|
||||
#include "../mem/minerva.h"
|
||||
|
||||
const char fixedoptions[3][50] = {
|
||||
"Folder -> previous folder",
|
||||
"Clipboard -> Current folder",
|
||||
"Folder options"
|
||||
"Folder -> previous folder ",
|
||||
"Clipboard -> Current folder ",
|
||||
"Folder options "
|
||||
};
|
||||
|
||||
const char sizevalues[4][3] = {
|
||||
@@ -80,9 +80,10 @@ int makemenu(menu_item menu[], int menuamount){
|
||||
}
|
||||
}
|
||||
|
||||
void printfsentry(fs_entry file, bool highlight){
|
||||
void printfsentry(fs_entry file, bool highlight, bool refresh){
|
||||
int size = 0;
|
||||
char *display;
|
||||
int length;
|
||||
|
||||
display = (char*) malloc (38);
|
||||
memset(display + 37, '\0', 1);
|
||||
@@ -91,7 +92,7 @@ void printfsentry(fs_entry file, bool highlight){
|
||||
strlcpy(display, file.name, 37);
|
||||
memset(display + 34, '.', 3);
|
||||
}
|
||||
else // make option to clear the screen gracefully line by line
|
||||
else
|
||||
strcpy(display, file.name);
|
||||
|
||||
if (highlight)
|
||||
@@ -106,21 +107,32 @@ void printfsentry(fs_entry file, bool highlight){
|
||||
if ((file.property & (1 << size)))
|
||||
break;
|
||||
|
||||
gfx_printf("%k%s%K\a%d\e%s", COLOR_VIOLET, display, COLOR_DEFAULT, file.size, sizevalues[size - 4]);
|
||||
gfx_printf("%k%s%K", COLOR_VIOLET, display, COLOR_DEFAULT);
|
||||
}
|
||||
|
||||
if (refresh){
|
||||
length = strlen(display);
|
||||
for (int i = 0; i < (42 - length); i++)
|
||||
gfx_printf(" ");
|
||||
}
|
||||
|
||||
if (!(file.property & ISDIR))
|
||||
gfx_printf("\a%d\e%s", file.size, sizevalues[size - 4]);
|
||||
|
||||
free(display);
|
||||
}
|
||||
|
||||
int makefilemenu(fs_entry *files, int amount, char *path){
|
||||
int currentpos = 1, i, res = 0, offset = 0, quickoffset = 300;
|
||||
int currentpos = -2, i, res = 0, offset = 0, quickoffset = 300;
|
||||
u32 timer;
|
||||
bool refresh = false;
|
||||
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);
|
||||
timer = get_tmr_ms();
|
||||
for (i = -3 + offset; i < amount && i < 30 + offset; i++){
|
||||
for (i = -3 + offset; i < amount && i < 60 + 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);
|
||||
@@ -128,10 +140,10 @@ int makefilemenu(fs_entry *files, int amount, char *path){
|
||||
gfx_printf("%k%K%s\n", COLOR_ORANGE, COLOR_DEFAULT, fixedoptions[i + 3]);
|
||||
}
|
||||
else
|
||||
printfsentry(files[i], (i == currentpos - 1));
|
||||
printfsentry(files[i], (i == currentpos - 1), refresh);
|
||||
}
|
||||
|
||||
gfx_printf("\n%k%K %s %s\nTime taken: %dms", COLOR_BLUE, COLOR_DEFAULT, (offset + 30 < amount) ? "v" : " ", (offset > 0) ? "^" : " ", get_tmr_ms() - timer);
|
||||
refresh = false;
|
||||
gfx_printf("\n%k%K %s %s\n\nTime taken for screen draw: %dms ", COLOR_BLUE, COLOR_DEFAULT, (offset + 60 < amount) ? "v" : " ", (offset > 0) ? "^" : " ", get_tmr_ms() - timer);
|
||||
|
||||
if (quickoffset == 300)
|
||||
res = btn_wait();
|
||||
@@ -149,14 +161,14 @@ int makefilemenu(fs_entry *files, int amount, char *path){
|
||||
currentpos--;
|
||||
if (offset != 0 && currentpos < offset - 2){
|
||||
offset--;
|
||||
gfx_box(0, 47, 719, 576, COLOR_DEFAULT);
|
||||
refresh = true;
|
||||
}
|
||||
}
|
||||
if ((res & BTN_VOL_DOWN) && currentpos < amount){
|
||||
currentpos++;
|
||||
if (currentpos - offset > 30){
|
||||
if (currentpos - offset > 60){
|
||||
offset++;
|
||||
gfx_box(0, 47, 719, 576, COLOR_DEFAULT);
|
||||
refresh = true;
|
||||
}
|
||||
}
|
||||
if (res & BTN_POWER)
|
||||
|
||||
Reference in New Issue
Block a user