Day2 of restructuring/rewriting

This commit is contained in:
Such Meme, Many Skill
2020-03-18 23:58:32 +01:00
parent ff618bc285
commit 9d36f741d9
30 changed files with 981 additions and 1503 deletions

View File

@@ -42,7 +42,7 @@ int gfx_message(u32 color, const char* message, ...){
return btn_wait();
}
int gfx_errprint(char *src_func, int err, int loc){
int gfx_errDisplay(char *src_func, int err, int loc){
gfx_clearscreen();
SWAPCOLOR(COLOR_ORANGE);
gfx_printf("\nAn error occured:\n\n");
@@ -50,6 +50,8 @@ int gfx_errprint(char *src_func, int err, int loc){
if (err < 15)
gfx_printf("Desc: %s\n", utils_err_codes[err]);
else if (err >= 50 && err <= ERR_DEST_PART_OF_SRC)
gfx_printf("Desc: %s\n", utils_err_codes_te[err - 50]);
if (loc)
gfx_printf("Loc: %d\n", loc);
@@ -104,8 +106,18 @@ void gfx_printandclear(char *in, int length){
gfx_printlength(length, in);
gfx_con_getpos(&x, &y);
RESETCOLOR;
gfx_box(x, y, 719, y + 16, COLOR_DEFAULT);
for (int i = (703 - x) / 16; i > 0; i--)
gfx_printf(" ");
gfx_con_setpos(x, y);
//gfx_box(x, y, 719, y + 16, COLOR_DEFAULT);
/*
u8 color = 0x1B;
gfx_set_rect_grey(&color, 719 - x, 16, x, y);
*/
}
void gfx_printfilesize(int size, char *type){

View File

@@ -8,7 +8,7 @@
void gfx_clearscreen();
int gfx_message(u32 color, const char* message, ...);
int gfx_errprint(char *src_func, int err, int loc);
int gfx_errDisplay(char *src_func, int err, int loc);
int gfx_makewaitmenu(char *hiddenmessage, int timer);
void gfx_printlength(int size, char *toprint);
void gfx_printandclear(char *in, int length);

View File

@@ -40,12 +40,13 @@ void _printentry(menu_entry entry, bool highlighted, bool refresh){
gfx_printf("\n");
else {
SWAPCOLOR(COLOR_BLUE);
SWAPBGCOLOR(COLOR_DEFAULT);
gfx_printf("\a%d\e%s", entry.storage, gfx_file_size_names[size - 4]);
}
}
int menu_make(menu_entry *entries, int amount, char *toptext){
int currentpos = 0, i, res = 0, offset = 0, delay = 300;
int currentpos = 0, i, res = 0, offset = 0, delay = 300, minscreen = 0, maxscreen = 59;
u32 scrolltimer, timer;
bool refresh = false;
@@ -64,6 +65,7 @@ int menu_make(menu_entry *entries, int amount, char *toptext){
while (!(res & BTN_POWER)){
gfx_con_setpos(0, 47);
timer = get_tmr_ms();
refresh = false;
if (!currentpos){
while (currentpos < amount && entries[currentpos].property & (ISSKIP | ISHIDE))
@@ -74,11 +76,25 @@ int menu_make(menu_entry *entries, int amount, char *toptext){
currentpos--;
}
if (currentpos > maxscreen){
offset += currentpos - maxscreen;
minscreen += currentpos - maxscreen;
maxscreen += currentpos - maxscreen;
refresh = true;
}
if (currentpos < minscreen){
offset -= minscreen - currentpos;
maxscreen -= minscreen - currentpos;
minscreen -= minscreen - currentpos;
refresh = true;
}
for (int i = 0 + offset; i < amount && i < 60 + offset; i++)
if (!(entries[i].property & ISHIDE))
_printentry(entries[i], (i == currentpos), refresh);
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);
gfx_printf("\n%k%K %s %s\n\nTime taken for screen draw: %dms\n%d", COLOR_BLUE, COLOR_DEFAULT, (offset + 60 < amount) ? "v" : " ", (offset > 0) ? "^" : " ", get_tmr_ms() - timer, currentpos);
while (btn_read() & BTN_POWER);