mirror of
https://github.com/suchmememanyskill/TegraExplorer.git
synced 2024-11-26 13:52:06 +00:00
Change menu around a bit
This commit is contained in:
parent
f8394ae323
commit
abf814686d
2 changed files with 58 additions and 51 deletions
|
@ -18,6 +18,9 @@ extern bool sd_inited;
|
||||||
#pragma GCC optimize ("O2")
|
#pragma GCC optimize ("O2")
|
||||||
|
|
||||||
void _printentry(menu_entry *entry, bool highlighted, bool refresh, const char *path){
|
void _printentry(menu_entry *entry, bool highlighted, bool refresh, const char *path){
|
||||||
|
if (entry->isHide)
|
||||||
|
return;
|
||||||
|
|
||||||
u32 color = (entry->isMenu) ? entry->storage : ((entry->isDir) ? COLOR_WHITE : COLOR_VIOLET);
|
u32 color = (entry->isMenu) ? entry->storage : ((entry->isDir) ? COLOR_WHITE : COLOR_VIOLET);
|
||||||
|
|
||||||
SWAPALLCOLOR((highlighted) ? COLOR_DEFAULT : color, (highlighted) ? color : COLOR_DEFAULT);
|
SWAPALLCOLOR((highlighted) ? COLOR_DEFAULT : color, (highlighted) ? color : COLOR_DEFAULT);
|
||||||
|
@ -62,7 +65,7 @@ void _printentry(menu_entry *entry, bool highlighted, bool refresh, const char *
|
||||||
|
|
||||||
bool disableB = false;
|
bool disableB = false;
|
||||||
int menu_make(menu_entry *entries, int amount, const char *toptext){
|
int menu_make(menu_entry *entries, int amount, const char *toptext){
|
||||||
int currentpos = 0, offset = 0, delay = 300, minscreen = 0, maxscreen = 39, calculatedamount = 0;
|
int currentpos = 0, offset = 0, delay = 300, minscreen = 0, calculatedamount = 0, cursub = 0, temp;
|
||||||
u32 scrolltimer, timer, sideY;
|
u32 scrolltimer, timer, sideY;
|
||||||
bool refresh = true;
|
bool refresh = true;
|
||||||
Inputs *input = hidRead();
|
Inputs *input = hidRead();
|
||||||
|
@ -95,56 +98,53 @@ int menu_make(menu_entry *entries, int amount, const char *toptext){
|
||||||
gfx_sideprintf("\n\n\n");
|
gfx_sideprintf("\n\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx_drawScrollBar(minscreen, maxscreen, amount);
|
for (;;){
|
||||||
|
|
||||||
while (!(input->a)){
|
|
||||||
gfx_con_setpos(0, 48);
|
gfx_con_setpos(0, 48);
|
||||||
timer = get_tmr_ms();
|
timer = get_tmr_ms();
|
||||||
|
|
||||||
if (!currentpos){
|
if (!currentpos)
|
||||||
while (currentpos < amount && entries[currentpos].property & (ISSKIP | ISHIDE))
|
cursub = 1;
|
||||||
currentpos++;
|
else if (currentpos == amount - 1)
|
||||||
}
|
cursub = -1;
|
||||||
if (currentpos == amount - 1){
|
else
|
||||||
while (currentpos >= 1 && entries[currentpos].property & (ISSKIP | ISHIDE))
|
cursub = 0;
|
||||||
currentpos--;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (currentpos > maxscreen){
|
while (entries[currentpos].property & (ISSKIP | ISHIDE))
|
||||||
offset += currentpos - maxscreen;
|
currentpos += cursub;
|
||||||
minscreen += currentpos - maxscreen;
|
|
||||||
maxscreen += currentpos - maxscreen;
|
|
||||||
|
if (currentpos > (minscreen + SCREENMAXOFFSET)){
|
||||||
|
offset += currentpos - (minscreen + SCREENMAXOFFSET);
|
||||||
|
minscreen += currentpos - (minscreen + SCREENMAXOFFSET);
|
||||||
refresh = true;
|
refresh = true;
|
||||||
}
|
}
|
||||||
|
else if (currentpos < minscreen){
|
||||||
if (currentpos < minscreen){
|
|
||||||
offset -= minscreen - currentpos;
|
offset -= minscreen - currentpos;
|
||||||
maxscreen -= minscreen - currentpos;
|
|
||||||
minscreen -= minscreen - currentpos;
|
minscreen -= minscreen - currentpos;
|
||||||
refresh = true;
|
refresh = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (refresh || currentfolder == NULL || !calculatedamount){
|
if (refresh || currentfolder == NULL || !calculatedamount){
|
||||||
for (int i = 0 + offset; i < amount && i < 40 + offset; i++)
|
for (int i = 0 + offset; i < amount && i < SCREENMAXOFFSET + 1 + offset; i++)
|
||||||
if (!(entries[i].isHide))
|
|
||||||
_printentry(&entries[i], (i == currentpos), refresh, toptext);
|
_printentry(&entries[i], (i == currentpos), refresh, toptext);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (currentpos - minscreen > 0){
|
temp = (currentpos - minscreen > 0) ? 0 : 16;
|
||||||
gfx_con_setpos(0, 32 + (currentpos - minscreen) * 16);
|
gfx_con_setpos(0, 32 + temp + (currentpos - minscreen) * 16);
|
||||||
|
|
||||||
|
if (!temp)
|
||||||
_printentry(&entries[currentpos - 1], false, false, toptext);
|
_printentry(&entries[currentpos - 1], false, false, toptext);
|
||||||
}
|
|
||||||
else
|
|
||||||
gfx_con_setpos(0, 48 + (currentpos - minscreen) * 16);
|
|
||||||
|
|
||||||
_printentry(&entries[currentpos], true, false, toptext);
|
_printentry(&entries[currentpos], true, false, toptext);
|
||||||
|
|
||||||
if (currentpos < amount - 1 && currentpos < maxscreen)
|
if (currentpos < MIN(amount - 1, minscreen + SCREENMAXOFFSET))
|
||||||
_printentry(&entries[currentpos + 1], false, false, toptext);
|
_printentry(&entries[currentpos + 1], false, false, toptext);
|
||||||
}
|
}
|
||||||
|
|
||||||
RESETCOLOR;
|
RESETCOLOR;
|
||||||
|
|
||||||
|
|
||||||
sideY = gfx_sideGetY();
|
sideY = gfx_sideGetY();
|
||||||
if (!(entries[currentpos].isMenu)){
|
if (!(entries[currentpos].isMenu)){
|
||||||
gfx_sideprintf("Current selection:\n");
|
gfx_sideprintf("Current selection:\n");
|
||||||
|
@ -158,12 +158,14 @@ int menu_make(menu_entry *entries, int amount, const char *toptext){
|
||||||
gfx_boxGrey(800, sideY, 1279, sideY + 48, 0x1B);
|
gfx_boxGrey(800, sideY, 1279, sideY + 48, 0x1B);
|
||||||
|
|
||||||
gfx_con_setpos(0, 703);
|
gfx_con_setpos(0, 703);
|
||||||
SWAPCOLOR(COLOR_DEFAULT);
|
SWAPALLCOLOR(COLOR_DEFAULT, COLOR_WHITE);
|
||||||
SWAPBGCOLOR(COLOR_WHITE);
|
|
||||||
gfx_printf("Time taken for screen draw: %dms ", get_tmr_ms() - timer);
|
gfx_printf("Time taken for screen draw: %dms ", get_tmr_ms() - timer);
|
||||||
|
|
||||||
if (refresh)
|
if (refresh)
|
||||||
gfx_drawScrollBar(minscreen, maxscreen, amount);
|
gfx_drawScrollBar(minscreen, minscreen + SCREENMAXOFFSET, amount);
|
||||||
|
|
||||||
|
refresh = false;
|
||||||
|
|
||||||
|
|
||||||
while (hidRead()->buttons & (KEY_B | KEY_A));
|
while (hidRead()->buttons & (KEY_B | KEY_A));
|
||||||
|
|
||||||
|
@ -182,14 +184,12 @@ int menu_make(menu_entry *entries, int amount, const char *toptext){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (input->buttons & (KEY_RDOWN | KEY_RUP)){
|
if (input->buttons & (KEY_RDOWN | KEY_RUP)){
|
||||||
delay = 1;
|
delay = 1;
|
||||||
input->Lup = input->Rup;
|
input->Lup = input->Rup;
|
||||||
input->Ldown = input->Rdown;
|
input->Ldown = input->Rdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (delay < 300){
|
if (delay < 300){
|
||||||
if (scrolltimer + delay < get_tmr_ms()){
|
if (scrolltimer + delay < get_tmr_ms()){
|
||||||
break;
|
break;
|
||||||
|
@ -200,27 +200,32 @@ int menu_make(menu_entry *entries, int amount, const char *toptext){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (delay > 46)
|
|
||||||
delay -= 45;
|
|
||||||
|
|
||||||
if (input->Lup && currentpos >= 1){
|
if (input->a){
|
||||||
currentpos--;
|
break;
|
||||||
while(entries[currentpos].property & (ISSKIP | ISHIDE) && currentpos >= 1)
|
|
||||||
currentpos--;
|
|
||||||
}
|
}
|
||||||
|
if (input->b && !disableB){
|
||||||
else if (input->Ldown && currentpos < amount - 1){
|
|
||||||
currentpos++;
|
|
||||||
while(entries[currentpos].property & (ISSKIP | ISHIDE) && currentpos < amount - 1)
|
|
||||||
currentpos++;
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (input->b && !disableB){
|
|
||||||
currentpos = 0;
|
currentpos = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
refresh = false;
|
|
||||||
|
if (delay > 46)
|
||||||
|
delay -= 45;
|
||||||
|
|
||||||
|
|
||||||
|
if (input->Lup && currentpos > 0)
|
||||||
|
cursub = -1;
|
||||||
|
else if (input->Ldown && currentpos < amount - 1)
|
||||||
|
cursub = 1;
|
||||||
|
else
|
||||||
|
cursub = 0;
|
||||||
|
|
||||||
|
if (cursub){
|
||||||
|
do {
|
||||||
|
currentpos += cursub;
|
||||||
|
} while (currentpos < amount - 1 && currentpos > 0 && entries[currentpos].property & (ISSKIP | ISHIDE));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
minerva_periodic_training();
|
minerva_periodic_training();
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "../common/types.h"
|
#include "../common/types.h"
|
||||||
|
|
||||||
|
#define SCREENMAXOFFSET 39
|
||||||
|
|
||||||
int menu_make(menu_entry *entries, int amount, const char *toptext);
|
int menu_make(menu_entry *entries, int amount, const char *toptext);
|
Loading…
Reference in a new issue