diff --git a/source/gfx/gfx.c b/source/gfx/gfx.c index 665a7d2..f6f8a0e 100644 --- a/source/gfx/gfx.c +++ b/source/gfx/gfx.c @@ -217,7 +217,7 @@ void gfx_putc(char c) } } gfx_con.x += 16; - if (gfx_con.x >= gfx_ctxt.width - 16) { + if (gfx_con.x >= gfx_ctxt.width - 8) { gfx_con.x = 0; gfx_con.y += 16; } diff --git a/source/meme/graphics.c b/source/meme/graphics.c index 7b88440..a74c8ff 100644 --- a/source/meme/graphics.c +++ b/source/meme/graphics.c @@ -56,7 +56,7 @@ void meme_clearscreen(){ gfx_printf("%k%pTegraExplorer, by SuchMemeManySkill\n%k%p", COLOR_DEFAULT, COLOR_WHITE, COLOR_WHITE, COLOR_DEFAULT); } -void _printwithhighlight(int offset, int folderamount, char *items[], int highlight, unsigned int *muhbits){ +void _printwithhighlight(int offset, int folderamount, char *items[], int highlight, unsigned int *muhbits, const char path[]){ char temp[39]; int i = 0; int ret = 0; @@ -73,9 +73,16 @@ void _printwithhighlight(int offset, int folderamount, char *items[], int highli ret = ret - 1; } - gfx_con.x = 720 - (16 * 6); - if (muhbits[i + offset] & OPTION1) gfx_printf("DIR"); - else gfx_printf("FILE"); + gfx_con.x = 720 - (16 * 7); + if (!(muhbits[i + offset] & OPTION1)) { //should change later + char temp[6]; + char temppath[PATHSIZE]; + strcpy(temppath, path); + strcat(temppath, "/"); + strcat(temppath, items[i + offset]); + return_readable_byte_amounts(getfilesize(temppath), temp); + gfx_printf("%s", temp); + } i++; } } @@ -91,7 +98,7 @@ int fileexplorergui(char *items[], unsigned int *muhbits, const char path[], int gfx_printf("%k%s\n%k", COLOR_GREEN, temp, COLOR_WHITE); while(1){ if (change){ - _printwithhighlight(offset, folderamount, items, select, muhbits); + _printwithhighlight(offset, folderamount, items, select, muhbits, path); change = false; msleep(sleepvalue); } diff --git a/source/meme/mainfunctions.c b/source/meme/mainfunctions.c index 4629fa2..97bcc0f 100644 --- a/source/meme/mainfunctions.c +++ b/source/meme/mainfunctions.c @@ -23,8 +23,11 @@ int _openfilemenu(const char *path, char *clipboardpath){ addchartoarray("Delete file", options, 3); gfx_printf("%kPath: %s%k\n\n", COLOR_GREEN, path, COLOR_WHITE); - int temp = (fno.fsize / 1024 / 1024); - gfx_printf("Size MB: %d", temp); + + char size[6]; + return_readable_byte_amounts(fno.fsize, size); + + gfx_printf("Size: %s", size); res = gfx_menulist(160, options, 4); switch(res){ @@ -52,8 +55,8 @@ void sdexplorer(char *items[], unsigned int *muhbits){ int value = 1; int copymode = -1; int folderamount = 0; - char path[255] = "sd:/"; - char clipboard[255] = ""; + char path[PATHSIZE] = "sd:/"; + char clipboard[PATHSIZE] = ""; int temp = -1; //static const u32 colors[8] = {COLOR_RED, COLOR_ORANGE, COLOR_YELLOW, COLOR_GREEN, COLOR_BLUE, COLOR_VIOLET, COLOR_DEFAULT, COLOR_WHITE}; while(1){ diff --git a/source/meme/utils.c b/source/meme/utils.c index 1959d21..d23496f 100644 --- a/source/meme/utils.c +++ b/source/meme/utils.c @@ -27,6 +27,39 @@ void addpartpath(char *path, char *add){ strcat(path, add); } +void return_readable_byte_amounts(int size, char *in){ + char type[3]; + int sizetemp = size; + int muhbytes = 0; + strcpy(type, "B"); + while(sizetemp > 1024){ + muhbytes++; + sizetemp = sizetemp / 1024; + } + + switch(muhbytes){ + case 0: + strcpy(type, "B"); + break; + case 1: + strcpy(type, "KB"); + break; + case 2: + strcpy(type, "MB"); + break; + default: + strcpy(type, "GB"); + break; + } + sprintf(in, "%d%s", sizetemp, type); +} + +int getfilesize(const char *path){ + FILINFO fno; + f_stat(path, &fno); + return fno.fsize; +} + void utils_waitforpower(){ u32 btn = btn_wait(); if (btn & BTN_VOL_UP) @@ -118,7 +151,7 @@ int copy(const char *src, const char *dst){ int copywithpath(const char *src, const char *dstpath, int mode){ FILINFO fno; f_stat(src, &fno); - char dst[255]; + char dst[PATHSIZE]; strcpy(dst, dstpath); if (strcmp(dstpath, "sd:/") != 0) strcat(dst, "/"); strcat(dst, fno.fname); diff --git a/source/meme/utils.h b/source/meme/utils.h index fe0cf40..44efd3a 100644 --- a/source/meme/utils.h +++ b/source/meme/utils.h @@ -5,6 +5,8 @@ #define OPTION3 (1 << 2) #define OPTION4 (1 << 3) +#define PATHSIZE 512 + void utils_gfx_init(); void utils_waitforpower(); void removepartpath(char *path); @@ -12,4 +14,6 @@ void addpartpath(char *path, char *add); int readfolder(char *items[], unsigned int *muhbits, const char *path); int copy(const char *src, const char *dst); void addchartoarray(char *add, char *items[], int spot); -int copywithpath(const char *src, const char *dstpath, int mode); \ No newline at end of file +int copywithpath(const char *src, const char *dstpath, int mode); +void return_readable_byte_amounts(int size, char *in); +int getfilesize(const char *path); \ No newline at end of file