void drawFrame() { u8* bufAdr=gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL); int i, j; for(i=1;i<400;i++) { for(j=1;j<240;j++) { u32 v=(j+i*240)*3; bufAdr[v]=(pcCos(i+cnt)+4096)/32; bufAdr[v+1]=(pcCos(j-256+cnt)+4096)/64; bufAdr[v+2]=(pcCos(i+128-cnt)+4096)/32; } } gfxDrawText(GFX_TOP, GFX_LEFT, NULL, "ftPONY v0.0003 gamma\n", 240-fontDefault.height*1, 10); u32 ip = gethostid(); char bof[256]; sprintf(bof, "IP: %lu.%lu.%lu.%lu\n", ip & 0xFF, (ip>>8)&0xFF, (ip>>16)&0xFF, (ip>>24)&0xFF); gfxDrawText(GFX_TOP, GFX_LEFT, NULL, bof, 240-fontDefault.height*2, 10); gfxDrawText(GFX_TOP, GFX_LEFT, NULL, quotes[curQuote], 240-fontDefault.height*3, 10); i = countLines(superStr); while(i>240/fontDefault.height-3){cutLine(superStr);i--;} gfxDrawText(GFX_TOP, GFX_LEFT, NULL, superStr, 240-fontDefault.height*4, 20); cnt++; gfxFlushBuffers(); gfxSwapBuffers(); }
void guiTopMenu() { //Prints the background! drawFillRect(0, 0, 399, 239, 166, 221, 238, screenTopLeft); //Prints the DPAD drawFillRect(23, 54, 68, 205, 255, 255, 255, screenTopLeft); drawFillRect(0, 110, 120, 153, 255, 255, 255, screenTopLeft); drawFillRect(0, 129, 17, 134, 166, 221, 238, screenTopLeft); drawFillRect(42, 69, 48, 106, 166, 221, 238, screenTopLeft); drawFillRect(72, 129, 107, 134, 166, 221, 238, screenTopLeft); drawFillRect(42, 159, 48, 196, 166, 221, 238, screenTopLeft); //Blue rect drawFillRect(254, 37, 399, 100, 51, 153, 255, screenTopLeft); //Text sprintf(buffer, "3DS Paint"); gfxDrawText(GFX_TOP, GFX_LEFT, NULL, buffer, 265, 230 - fontDefault.height * 3); sprintf(buffer, "Coded by"); gfxDrawText(GFX_TOP, GFX_LEFT, NULL, buffer, 265, 240 - fontDefault.height * 5); sprintf(buffer, "AlbertoSONIC"); gfxDrawText(GFX_TOP, GFX_LEFT, NULL, buffer, 265, 240 - fontDefault.height * 6); }
void guiDebug(int mode, int state, int color, int rendered, int sound, int printFPS, int posX, int posY) { //Todo drawFillRect(79, 163, 250, 239, 0, 0, 0, screenTopLeft); sprintf(buffer, "mode = %d state = %d", mode, state); gfxDrawText(GFX_TOP, GFX_LEFT, NULL, buffer, 85, 250 - fontDefault.height * 12); sprintf(buffer, "color = %d rendered = %d", color, rendered); gfxDrawText(GFX_TOP, GFX_LEFT, NULL, buffer, 85, 250 - fontDefault.height * 13); sprintf(buffer, "sound = %d FPS = %d", sound, printFPS); gfxDrawText(GFX_TOP, GFX_LEFT, NULL, buffer, 85, 250 - fontDefault.height * 14); sprintf(buffer, "TouchX = %d Touch = %d", posX, posY); gfxDrawText(GFX_TOP, GFX_LEFT, NULL, buffer, 85, 240 - fontDefault.height * 15); }
static void renderFrame(void) { u8 bluish[] = { 0, 0, 127 }; gfxFillColor(GFX_TOP, GFX_LEFT, bluish); gfxFillColor(GFX_BOTTOM, GFX_LEFT, bluish); gfxDrawText(GFX_TOP, GFX_LEFT, top.console, 240-8, 0); gfxDrawText(GFX_BOTTOM, GFX_LEFT, bot.console, 240-8, 0); gfxFlushBuffers(); gspWaitForVBlank(); gfxSwapBuffers(); }
void GUI_FileExplorer(){ if (count != 0) { int n = 0; int divisions = count % 10 == 0 ? count / 10 : count / 10 + 1; int list[divisions]; for (n = 0; n < divisions; n++) { if (n == divisions - 1 && count % 10 != 0)list[n] = count - (count / 10) * 10; else list[n] = 10; } int i = 0; itemShown = list[(pointer / 10)]; for (i = beginning; i < beginning + list[(pointer / 10)]; i++) { char filename[100]; strcpy(filename, files[i]); if (strlen(filename)>39) { filename[39] = '\0'; strcat(filename, "..."); } sprintf(buffer, "%s%s", i == pointer ? "> " : "", filename); if (pointer == i) drawFillRect(35, fontBlack.height * (i - beginning + 1), 275, fontBlack.height * (i - beginning + 1) + 15, 226, 226, 226, screenBottom); gfxDrawText(GFX_BOTTOM, GFX_LEFT, &fontBlack, filename, 40, 238 - fontBlack.height * (i - beginning + 1) - 15); } //Draw the next/prev page button if there's one if (beginning != 0) gfxDrawSprite(GFX_BOTTOM, GFX_LEFT, (u8*)PrevFM_bin, 71, 23, 9, 109); // <-- if (count > beginning + 10) gfxDrawSprite(GFX_BOTTOM, GFX_LEFT, (u8*)NextFM_bin, 72, 22, 289, 109); // --> } }
void drawStatusBar(bool wifiStatus, bool charging, int batteryLevel) { u64 timeInSeconds = osGetTime() / 1000; u64 dayTime = timeInSeconds % SECONDS_IN_DAY; u8 hour = dayTime / SECONDS_IN_HOUR; u8 min = (dayTime % SECONDS_IN_HOUR) / SECONDS_IN_MINUTE; u8 seconds = dayTime % SECONDS_IN_MINUTE; char timeString[9]; sprintf(timeString, "%02d:%02d:%02d", hour, min, seconds); gfxDrawText(GFX_TOP, GFX_LEFT, NULL, timeString, 240 - 18, 400 / 2 - 16); if(wifiStatus) { gfxDrawSpriteAlphaBlend(GFX_TOP, GFX_LEFT, (u8*)wifi_full_bin, 18, 20, 240 - 18, 0); } else { gfxDrawSpriteAlphaBlend(GFX_TOP, GFX_LEFT, (u8*)wifi_none_bin, 18, 20, 240 - 18, 0); } if(charging) { gfxDrawSpriteAlphaBlend(GFX_TOP, GFX_LEFT, (u8*)battery_charging_bin, 18, 27, 240 - 18, 400 - 27); } else { gfxDrawSpriteAlphaBlend(GFX_TOP, GFX_LEFT, batteryLevels[batteryLevel], 18, 27, 240 - 18, 400 - 27); } }
int file_list(const char *path, char ***ls) { int count = 0; DIR *dp = NULL; struct dirent *ep = NULL; dp = opendir(path); if (NULL == dp) { gfxDrawText(GFX_BOTTOM, GFX_LEFT, &fontBlack, "AEEE", 5, 238 - fontBlack.height); return 0; } *ls = NULL; *ls = calloc(1000, sizeof(char *)); count = 0; ep = readdir(dp); while (NULL != ep) { (*ls)[count++] = strdup(ep->d_name); ep = readdir(dp); } closedir(dp); return count; }
void GUI_Clock() { u64 timeInSeconds = osGetTime() / 1000; u64 dayTime = timeInSeconds % SECONDS_IN_DAY; sprintf(buffer, "%02llu:%02llu", dayTime / SECONDS_IN_HOUR, (dayTime % SECONDS_IN_HOUR) / SECONDS_IN_MINUTE); gfxDrawText(GFX_TOP, GFX_LEFT, &fontBlack, buffer, 365, 238 - fontBlack.height * 1); }
void guiBottomMenu() { //Prints a background! drawFillRect(0, 0, 320, 240, 166, 221, 238, screenBottom); //Prints the buttons drawFillRect(9, 6, 92, 33, 192, 192, 192, screenBottom); drawFillRect(220, 6, 303, 33, 192, 192, 192, screenBottom); drawFillRect(14, 68, 302, 131, 51, 153, 255, screenBottom); drawFillRect(14, 149, 302, 212, 255, 0, 0, screenBottom); //Prints the text sprintf(buffer, "About"); gfxDrawText(GFX_BOTTOM, GFX_LEFT, NULL, buffer, 30, 245- fontDefault.height * 2); sprintf(buffer, " Debug"); gfxDrawText(GFX_BOTTOM, GFX_LEFT, NULL, buffer, 235, 245 - fontDefault.height * 2); sprintf(buffer, "START PAINTING"); gfxDrawText(GFX_BOTTOM, GFX_LEFT, NULL, buffer, 108, 240 - fontDefault.height * 6); sprintf(buffer, "Start painting right now!"); gfxDrawText(GFX_BOTTOM, GFX_LEFT, NULL, buffer, 88, 240 - fontDefault.height * 7); sprintf(buffer, "EXIT 3DS PAINT"); gfxDrawText(GFX_BOTTOM, GFX_LEFT, NULL, buffer, 110, 240 - fontDefault.height * 11); sprintf(buffer, "Go back to homebrew launcher"); gfxDrawText(GFX_BOTTOM, GFX_LEFT, NULL, buffer, 70, 240 - fontDefault.height * 12); sprintf(buffer, "or 3DS Main Menu"); gfxDrawText(GFX_BOTTOM, GFX_LEFT, NULL, buffer, 100, 240 - fontDefault.height * 13); }
void guiPopup(char* title, char* line1, char* line2, char* line3, char* button1, char* button2, bool closeonly) { //Prints a dark grey rectangle! drawFillRect(36, 60, 272, 85, 128, 128, 128, screenBottom); //Prints a light grey rectangle! drawFillRect(36, 85, 272, 189, 160, 160, 160, screenBottom); //Prints text gfxDrawText(GFX_BOTTOM, GFX_LEFT, NULL, title, 124, 240 - fontDefault.height * 5); gfxDrawText(GFX_BOTTOM, GFX_LEFT, NULL, line1, 50, 245 - fontDefault.height * 7); gfxDrawText(GFX_BOTTOM, GFX_LEFT, NULL, line2, 50, 245 - fontDefault.height * 8); gfxDrawText(GFX_BOTTOM, GFX_LEFT, NULL, line3, 50, 245 - fontDefault.height * 9); //Prints the buttons! if (closeonly) { drawFillRect(107, 155, 198, 183, 192, 192, 192, screenBottom); gfxDrawText(GFX_BOTTOM, GFX_LEFT, NULL, button1, 130, 240 - fontDefault.height * 11); } else { drawFillRect(50, 151, 141, 179, 192, 192, 192, screenBottom); drawFillRect(166, 151, 257, 179, 192, 192, 192, screenBottom); gfxDrawText(GFX_BOTTOM, GFX_LEFT, NULL, button1, 60, 240 - fontDefault.height * 11); gfxDrawText(GFX_BOTTOM, GFX_LEFT, NULL, button2, 180, 240 - fontDefault.height * 11); } }
void debug(const char *fmt, ...) { char s[512]; memset(s, 0, 512); va_list args; va_start(args, fmt); vsprintf(s, fmt, args); va_end(args); while (aptMainLoop()) { hidScanInput(); if (hidKeysDown()) break; drawBg(); gfxDrawText(GFX_TOP, GFX_LEFT, &fontDefault, s, MENU_MIN_X + 16, MENU_MIN_Y + 16); gfxDrawText(GFX_TOP, GFX_LEFT, &fontDefault, "Press any key to continue...", MENU_MIN_X + 16, MENU_MIN_Y + 64); gfxSwap(); } }
void drawError(gfxScreen_t screen, char* title, char* body, int offset) { int i; int numLines=countLines(body); int width=numLines*8+32; int height=300; int x=240-width-12+offset, y=4; //main frame for(i=0; i<9; i++)gfxDrawRectangle(screen, GFX_LEFT, ENTRY_BGCOLOR, x+roundLutError[i], y+i, width-roundLutError[i]*2, 1); gfxDrawRectangle(screen, GFX_LEFT, ENTRY_BGCOLOR, x, y+9, width, height-9*2); for(i=0; i<9; i++)gfxDrawRectangle(screen, GFX_LEFT, ENTRY_BGCOLOR, x+roundLutError[i], y+height-1-i, width-roundLutError[i]*2, 1); //content gfxDrawText(screen, GFX_LEFT, &fontTitle, title, x+width-6-16, y+6); gfxDrawText(screen, GFX_LEFT, &fontDescription, body, x+width-5-16-13, y+8); }
//--------------------------------------------------------------------------- int CConsoleWindow::EraseBkgnd(u8 *screen) { if(!CDialog::EraseBkgnd(screen)){ if(text){ gfxSetTextColor(color); gfxDrawText(screen,font,text,&rcWin,0); } return 0; } return -1; }
void guiClock() { //CLOCK drawFillRect(276, 196, 399, 219, 255, 0, 0, screenTopLeft); u64 timeInSeconds = osGetTime() / 1000; u64 dayTime = timeInSeconds % SECONDS_IN_DAY; sprintf(buffer, "%.2llu:%.2llu:%.2llu", dayTime / SECONDS_IN_HOUR, (dayTime % SECONDS_IN_HOUR) / SECONDS_IN_MINUTE, dayTime % SECONDS_IN_MINUTE); gfxDrawText(GFX_TOP, GFX_LEFT, NULL, buffer, 300, 248 - fontDefault.height * 14); }
void guiTopAnimation() { //Prints the brown background! drawFillRect(0, 0, 399, 239, 255, 185, 15, screenTopLeft); //Prints the DPAD drawFillRect(23, 54, 68, 205, 255, 255, 255, screenTopLeft); drawFillRect(0, 110, 120, 153, 255, 255, 255, screenTopLeft); drawFillRect(0, 129, 17, 134, 242, 204, 146, screenTopLeft); drawFillRect(42, 69, 48, 106, 242, 204, 146, screenTopLeft); drawFillRect(72, 129, 107, 134, 242, 204, 146, screenTopLeft); drawFillRect(42, 159, 48, 196, 242, 204, 146, screenTopLeft); //Blue rect drawFillRect(254, 37, 399, 100, 51, 153, 255, screenTopLeft); //Green rect (save) drawFillRect(257, 138, 399, 168, 69, 206, 48, screenTopLeft); //Text sprintf(buffer, "More fps"); gfxDrawText(GFX_TOP, GFX_RIGHT, NULL, buffer, 27, 240 - fontDefault.height * 3); sprintf(buffer, "3DS Paint"); gfxDrawText(GFX_TOP, GFX_LEFT, NULL, buffer, 265, 230 - fontDefault.height * 3); sprintf(buffer, "Coded by"); gfxDrawText(GFX_TOP, GFX_LEFT, NULL, buffer, 265, 240 - fontDefault.height * 5); sprintf(buffer, "AlbertoSONIC and norips"); gfxDrawText(GFX_TOP, GFX_LEFT, NULL, buffer, 265, 240 - fontDefault.height * 6); sprintf(buffer, "Less fps"); gfxDrawText(GFX_TOP, GFX_LEFT, NULL, buffer, 27, 240 - fontDefault.height * 14); sprintf(buffer, "CHANGE COLOR"); gfxDrawText(GFX_TOP, GFX_LEFT, NULL, buffer, 130, 235 - fontDefault.height * 8); sprintf(buffer, "SELECT ERASER"); gfxDrawText(GFX_TOP, GFX_LEFT, NULL, buffer, 130, 235 - fontDefault.height * 9); sprintf(buffer, "Press SELECT to export"); gfxDrawText(GFX_TOP, GFX_LEFT, NULL, buffer, 265, 245 - fontDefault.height * 10); sprintf(buffer, "your anim to SDCARD"); gfxDrawText(GFX_TOP, GFX_LEFT, NULL, buffer, 265, 248 - fontDefault.height * 11); }
bool confirm(int confirmButton, const char *fmt, ...) { char s[512]; memset(s, 0, 512); va_list args; va_start(args, fmt); vsprintf(s, fmt, args); va_end(args); while (aptMainLoop()) { hidScanInput(); u32 key = hidKeysDown(); if (key & BIT(confirmButton)) { return true; } else if (key) { return false; } drawBg(); gfxDrawText(GFX_TOP, GFX_LEFT, &fontDefault, s, MENU_MIN_X + 16, MENU_MIN_Y + 16); gfxDrawText(GFX_TOP, GFX_LEFT, &fontDefault, "Press any key to cancel...", MENU_MIN_X + 16, MENU_MIN_Y + 64); gfxDrawTextf(GFX_TOP, GFX_LEFT, &fontDefault, MENU_MIN_X + 16, MENU_MIN_Y + 84, "Press (%s) to confirm...", get_button(confirmButton)); gfxSwap(); } }
static void drawFrame(gfxScreen_t screen, char b, char g, char r) { int screenHeight = 240; int screenWidth = (screen == GFX_TOP) ? 400 : 320; std::string& textBuffer = (screen == GFX_TOP) ? bufferTop : bufferBottom; u8* bufAdr = gfxGetFramebuffer(screen, GFX_LEFT, nullptr, nullptr); for (int i = 0; i < screenWidth * screenHeight * 3; i += 3) { bufAdr[i] = b; bufAdr[i+1] = g; bufAdr[i+2] = r; } int lines = countLines(textBuffer); while (lines > (screenHeight / fontDefault.height - 3)) { deleteFirstLine(&textBuffer); lines--; } gfxDrawText(screen, GFX_LEFT, nullptr, textBuffer, screenHeight - fontDefault.height * 3, 10); }
void guiBottomPaintAnimation(int cTable[][ctablesize],canvas* canvasarray,int frame, int fps) { //Prints a white screen! char buffer[256]; drawFillRect(0, 0, 320, 240, 255, 255, 255, screenBottom); if(canvasarray!=NULL) { int size=canvasarray->size; for(int i=0;i<size;i++) { drawPixel( canvasarray->point[i].x, canvasarray->point[i].y, cTable[canvasarray->point[i].color][0], cTable[canvasarray->point[i].color][1], cTable[canvasarray->point[i].color][2], screenBottom); } } sprintf(buffer,"FPS = %03d",fps); gfxDrawText(GFX_BOTTOM,GFX_LEFT,&fontBlack,buffer,5,235- fontDefault.height*2); }
void GUI_StatusBar(char* title) { ACU_GetWifiStatus(NULL, &wifiStatus); PTMU_GetBatteryLevel(NULL, &batteryLevel); PTMU_GetBatteryChargeState(NULL, &charging); //Wifi icon if (wifiStatus) gfxDrawSprite(GFX_TOP, GFX_LEFT, (u8*)Wifi_bin, 20, 40, 0, 220); //Battery icon if (charging) { gfxDrawSprite(GFX_TOP, GFX_LEFT, batteryLevels[charging_animation/9], 19, 17, 0, 221); if(charging_animation!=49)charging_animation++; else charging_animation = 1; } else gfxDrawSprite(GFX_TOP, GFX_LEFT, batteryLevels[batteryLevel], 19, 17, 0, 221); //Clock GUI_Clock(); //Title gfxDrawText(GFX_TOP, GFX_LEFT, &fontBlack, title, 80, 238 - fontBlack.height * 1); }
void GUI_TextView(char* path, int page, bool greyScale) { //Draw BKG gfxDrawSprite(GFX_TOP, GFX_LEFT, (u8*)TextBKG_bin, 240, 400, 0, 0); if (greyScale) { drawFillRect(40, 20, 359, 239, 255, 255, 255, screenTopLeft); drawFillRect(0, 0, 319, 239, 255, 255, 255, screenBottom); } else { drawFillRect(40, 20, 359, 239, 243, 231, 189, screenTopLeft); drawFillRect(0, 0, 319, 239, 243, 231, 189, screenBottom); } //Draw page sprintf(buffer, "PG: %i", page + 1); gfxDrawText(GFX_TOP, GFX_LEFT, &fontBlack, buffer, 5, 238 - fontBlack.height * 15); //Read the page int c; FILE *file; nextAvailable = true; file = fopen(path, "r"); if (file) { //Show bookmark (with animation) if (page == TextView_GetBookmark(path)) { if (bookmark_animation != 24) bookmark_animation+=4; } else bookmark_animation = 0; if(bookmark_animation != 0) drawFillRect(368, 20, 385, 20 + bookmark_animation, 255, 0, 0, screenTopLeft); //Start reading the page fseek(file, !page ? 4 : offsets[page], SEEK_SET); int i = 0; for (i = 0; i < 29; i++) { //Loads the line int j = 0; char line[55]; for (j = 0; j < 55; j++) { if ((c = getc(file)) != EOF && c != '\n') line[j] = c; else { if (c == EOF) nextAvailable = false; line[j] = '\0'; break; } } //Prints text gfxDrawText( i < 14 ? GFX_TOP : GFX_BOTTOM, GFX_LEFT, //Screen on which to print the text greyScale ? &fontBlack : &fontBrown, line, //Line of text to print i < 14 ? 44 : 5, //Horizzontal position of the text 238 - fontBlack.height * (i < 14 ? i + 2 : i + 1 - 14) //Vertical position of the text ); } //Save the current offset in file, for every page fflush(file); offsets[page+1] = ftell(file); fclose(file); } else { //Error } //Next/Previous Page buttons: if (page!=0) gfxDrawSprite(GFX_TOP, GFX_LEFT, (u8*)PrevPG_bin, 71, 23, 0, 85); // <-- if (nextAvailable) gfxDrawSprite(GFX_TOP, GFX_LEFT, (u8*)NextPG_bin, 72, 22, 378, 85); // --> }
int menu_boot() { time_t start, end, elapsed; int boot_index = config->index; hidScanInput(); if (config->timeout < 0 || hidKeysHeld() & BIT(config->recovery)) { // disable autoboot timer = false; } else if (config->timeout == 0 && config->count > boot_index) { // autoboot return autoBootFix(boot_index); } time(&start); while (aptMainLoop()) { hidScanInput(); u32 kDown = hidKeysDown(); if (timer) { time(&end); elapsed = end - start; if (elapsed >= config->timeout && config->count > boot_index) { return autoBootFix(boot_index); } } if (kDown & KEY_DOWN) { timer = false; boot_index++; if (boot_index > config->count) boot_index = 0; } if (kDown & KEY_UP) { timer = false; boot_index--; if (boot_index < 0) boot_index = config->count; } if (kDown & KEY_A) { timer = false; if (boot_index == config->count) { if (menu_more() == 0) { break; } } else { if (load(config->entries[boot_index].path, config->entries[boot_index].offset) == 0) { break; } } } if (kDown & KEY_X) { timer = false; if (boot_index != config->count) { if (confirm(3, "Delete boot entry: \"%s\" ?\n", config->entries[boot_index].title)) { configRemoveEntry(boot_index); boot_index--; } } } gfxClear(); if (!timer) { gfxDrawText(GFX_TOP, GFX_LEFT, &fontTitle, "*** Grub for CTR beta ***", 120, 20); } else { gfxDrawTextf(GFX_TOP, GFX_LEFT, &fontTitle, 100, 20, "*** Booting %s in %i ***", config->entries[boot_index].title, config->timeout - elapsed); } int minX = 16, maxX = 400 - 16; int minY = 32, maxY = 240 - 8; drawRect(GFX_TOP, GFX_LEFT, minX, minY, maxX, maxY, 0xFF, 0xFF, 0xFF); minY += 20; int i; for (i = 0; i < config->count; i++) { if (i >= config->count) break; if (i == boot_index) { gfxDrawRectangle(GFX_TOP, GFX_LEFT, (u8[]) {0xDC, 0xDC, 0xDC}, minX + 4, minY + (16 * i), maxX - 23, 15); gfxDrawTextf(GFX_TOP, GFX_LEFT, &fontSelected, minX + 6, minY + (16 * i), "%s", config->entries[i].title); gfxDrawText(GFX_BOTTOM, GFX_LEFT, &fontTitle, "Informations", minX + 6, 20); gfxDrawTextf(GFX_BOTTOM, GFX_LEFT, &fontDefault, minX + 12, 40, "Name: %s\nPath: %s\nOffset: 0x%lx\n\n\nPress (A) to launch\nPress (X) to remove entry\n", config->entries[i].title, config->entries[i].path, config->entries[i].offset); } else gfxDrawText(GFX_TOP, GFX_LEFT, &fontDefault, config->entries[i].title, minX + 6, minY + (16 * i)); }
void pick_file(file_s *picked, const char *path) { picker = malloc(sizeof(picker_s)); get_dir(path); // key repeat timer static time_t t_start = 0, t_end = 0, t_elapsed = 0; while (aptMainLoop()) { hidScanInput(); u32 kHeld = hidKeysHeld(); u32 kDown = hidKeysDown(); if (hidKeysUp()) { time(&t_start); // reset held timer } if (kDown & KEY_DOWN) { picker->file_index++; if (picker->file_index >= picker->file_count) picker->file_index = 0; time(&t_start); } else if (kHeld & KEY_DOWN) { time(&t_end); t_elapsed = t_end - t_start; if (t_elapsed > 0) { picker->file_index++; if (picker->file_index >= picker->file_count) picker->file_index = 0; svcSleep(100); } } if (kDown & KEY_UP) { picker->file_index--; if (picker->file_index < 0) picker->file_index = picker->file_count - 1; time(&t_start); } else if (kHeld & KEY_UP) { time(&t_end); t_elapsed = t_end - t_start; if (t_elapsed > 0) { picker->file_index--; if (picker->file_index < 0) picker->file_index = picker->file_count - 1; svcSleep(100); } } if (kDown & KEY_A) { int index = picker->file_index; if (!picker->files[index].isDir) { if (confirm(0, "Launch \"%s\" ?", picker->files[index].name)) { strncpy(picked->name, picker->files[index].name, 512); strncpy(picked->path, picker->files[index].path, 512); picked->isDir = picker->files[index].isDir; picked->size = picker->files[index].size; break; } } else { get_dir(picker->files[index].path); } } else if (kDown & KEY_X) { int index = picker->file_index; if (!picker->files[index].isDir) { const char *ext = get_filename_ext(picker->files[index].name); if (strcasecmp(ext, "3dsx") == 0) { if (confirm(3, "Add entry to boot menu: \"%s\" ?", picker->files[index].name)) { if (config->count > CONFIG_MAX_ENTRIES - 1) { debug("Maximum entries reached (%i)\n", CONFIG_MAX_ENTRIES); } else if (configAddEntry(picker->files[index].name, picker->files[index].path, 0) == 0) { debug("Added entry: %s\n", picker->files[index].name); } else { debug("Error adding entry: %s\n", picker->files[index].name); } } } } } else if (kDown & KEY_B) { // exit if we can't go back if (strlen(picker->now_path) <= 1) break; // remove slash if needed if (end_with(picker->now_path, '/')) picker->now_path[strlen(picker->now_path) - 1] = '\0'; // build path char *slash = strrchr(picker->now_path, '/'); if (slash == NULL) break; int len = (int) (slash - picker->now_path); picker->now_path[len] = '\0'; // enter new dir get_dir(picker->now_path); } gfxClear(); gfxDrawText(GFX_TOP, GFX_LEFT, &fontTitle, "*** Select a file ***", 130, 20); int minX = 16; int maxX = 400 - 16; int minY = 32; int maxY = 240 - 16; drawRect(GFX_TOP, GFX_LEFT, minX, minY, maxX, maxY, (u8) 0xFF, (u8) 0xFF, (u8) 0xFF); minY += 20; int i, y = 0; int page = picker->file_index / MAX_LINE; for (i = page * MAX_LINE; i < page * MAX_LINE + MAX_LINE; i++) { if (i >= picker->file_count) break; if (i == picker->file_index) { gfxDrawRectangle(GFX_TOP, GFX_LEFT, (u8[]) {0xDC, 0xDC, 0xDC}, minX + 4, minY + 16 * y, maxX - 23, 15); gfxDrawTextN(GFX_TOP, GFX_LEFT, &fontSelected, picker->files[i].name, 47, minX + 6, minY + 16 * y); if (!picker->files[i].isDir) { gfxDrawText(GFX_BOTTOM, GFX_LEFT, &fontTitle, "Informations", minX + 6, 20); gfxDrawText(GFX_BOTTOM, GFX_LEFT, &fontDefault, "Press (A) to launch\nPress (X) to add to boot menu", minX + 12, 40); } } else { gfxDrawTextN(GFX_TOP, GFX_LEFT, &fontDefault, picker->files[i].name, 47, minX + 6, minY + 16 * y); } y++; }
void guiFrame() { drawFillRect(276, 169, 399, 200, 0, 204, 146, screenTopLeft); sprintf(buffer,"Frame = %03d/%03d",frame+1,canvassize+1); gfxDrawText(GFX_TOP, GFX_LEFT ,NULL, buffer, 300, 65 - fontDefault.height ); }
void drawDebug() { char str[256]; sprintf(str, "hello3 %d %d %d %d\n", debugValues[0], debugValues[1], debugValues[2], debugValues[3]); gfxDrawText(GFX_TOP, GFX_LEFT, NULL, str, 32, 100); }
int menu_more() { menu_index = 0; while (aptMainLoop()) { hidScanInput(); u32 kDown = hidKeysDown(); if (kDown & KEY_DOWN) { menu_index++; if (menu_index >= menu_count) menu_index = 0; } if (kDown & KEY_UP) { menu_index--; if (menu_index < 0) menu_index = menu_count - 1; } if (kDown & KEY_A) { if (menu_index == 0 && menu_choose() == 0) { return 0; } else if (menu_index == 1 && menu_netloader() == 0) { return 0; } else if (menu_index == 2) { menu_config(); } else if (menu_index == 3) { reboot(); } else if (menu_index == 4) { poweroff(); } } if (kDown & KEY_B) { return -1; } gfxClear(); gfxDrawText(GFX_TOP, GFX_LEFT, &fontDefault, "*** Select an option ***", 140, 20); int minX = 16; int maxX = 400 - 16; int minY = 32; int maxY = 240 - 16; drawRect(GFX_TOP, GFX_LEFT, minX, minY, maxX, maxY, 0xFF, 0xFF, 0xFF); minY += 20; int i; for (i = 0; i < menu_count; i++) { if (i >= menu_count) break; if (i == menu_index) { gfxDrawRectangle(GFX_TOP, GFX_LEFT, (u8[]) { 0xDC, 0xDC, 0xDC }, minX + 4, minY + (16 * i), maxX - 23, 15); gfxDrawText(GFX_TOP, GFX_LEFT, &fontSelected, menu_item[i], minX + 6, minY + (16 * i)); } else gfxDrawText(GFX_TOP, GFX_LEFT, &fontDefault, menu_item[i], minX + 6, minY + (16 * i)); }