void drawCommandsBar(unsigned char chCommandsCount,bool blnStatusBar,struct stCommandsBar *stCommandsBarSettings) { int intConsoleColumnsCount,intConsoleRowsCount; CON_GetMetrics(&intConsoleColumnsCount,&intConsoleRowsCount); stCommandsBarSettings->chCommandsCount=chCommandsCount; stCommandsBarSettings->chCommandItemsCount=0; stCommandsBarSettings->stStatusBarLocation.intColumn=0; intConsoleColumnsCount--; saveCursorPosition(); if (blnStatusBar) { intConsoleRowsCount--; stCommandsBarSettings->stStatusBarLocation.intRow=intConsoleRowsCount; setCursorPosition(intConsoleRowsCount,0); printf("%*s",intConsoleColumnsCount,""); intConsoleRowsCount--; setCursorPosition(intConsoleRowsCount,0); printRepeatString(intConsoleColumnsCount,"%c",HORIZONTAL_SINGLE_BORDER); } else { stCommandsBarSettings->stStatusBarLocation.intRow=-1; } if (chCommandsCount) { stCommandsBarSettings->stCommandsBarLocation.intRow=intConsoleRowsCount-getRoundNumber(((double)chCommandsCount)/2); stCommandsBarSettings->stCommandsBarLocation.intColumn=0; while (intConsoleRowsCount>stCommandsBarSettings->stCommandsBarLocation.intRow) { intConsoleRowsCount--; setCursorPosition(intConsoleRowsCount,0); printf("%*s",intConsoleColumnsCount,""); } setCursorPosition(stCommandsBarSettings->stCommandsBarLocation.intRow-1,0); printRepeatString(intConsoleColumnsCount,"%c",HORIZONTAL_SINGLE_BORDER); } resetSavedCursorPosition(); }
void con_fillrow(u32 row, u32 color, u8 bold) { s32 cols, rows; u32 cnt; /* Set color */ printf("\x1b[%u;%um", color + 40, bold); fflush(stdout); /* Get console metrics */ CON_GetMetrics(&cols, &rows); /* Save current row and col */ printf("\x1b[s"); fflush(stdout); /* Move to specified row */ printf("\x1b[%u;0H", row); fflush(stdout); /* Fill row */ for (cnt = 0; cnt < cols; cnt++) { printf(" "); fflush(stdout); } /* Load saved row and col */ printf("\x1b[u"); fflush(stdout); /* Set default color */ con_bgcolor(0, 0); con_fgcolor(7, 1); }
void con_clearline(void) { s32 cols, rows; u32 cnt; printf("\r"); fflush(stdout); /* Save cursor position */ printf("\x1b[s"); fflush(stdout); /* Get console metrics */ CON_GetMetrics(&cols, &rows); /* Erase line */ for (cnt = 0; cnt < cols; cnt++) { printf(" "); fflush(stdout); } /* Load cursor position */ printf("\x1b[u"); fflush(stdout); }
void initConsole(const void *imgBgData,enum CONSOLE_COLORS CONSOLE_COLOR,const char *strSplashScreenMessage,double dbLeft,double dbTop,double dbWidth,double dbHeight) { PNGUPROP imgProperties; IMGCTX imgContext; void *pFramebuffer=NULL; GXRModeObj *pRmode=NULL; double dbConsoleFrameX[2]={dbLeft,dbLeft},dbConsoleFrameY[2]={dbTop,dbTop},dbBgImgXScaleFactor=1,dbBgImgYScaleFactor=1,dbReferenceWidth,dbReferenceHeight; int intConsoleColumnsCount,intConsoleRowsCount; struct stConsoleCursorLocation stTexteLocation; VIDEO_Init(); pRmode=VIDEO_GetPreferredMode(NULL); pFramebuffer=MEM_K0_TO_K1(SYS_AllocateFramebuffer(pRmode)); VIDEO_ClearFrameBuffer(pRmode,pFramebuffer,CONSOLE_COLOR); VIDEO_Configure(pRmode); VIDEO_SetNextFramebuffer(pFramebuffer); VIDEO_SetBlack(FALSE); VIDEO_Flush(); VIDEO_WaitVSync(); if(pRmode->viTVMode&VI_NON_INTERLACE) { VIDEO_WaitVSync(); } dbWidth=fabs(dbWidth); dbHeight=fabs(dbHeight); if ((imgContext=getPngImageRessources(imgBgData,&imgProperties))) { dbReferenceWidth=imgProperties.imgWidth; dbReferenceHeight=imgProperties.imgHeight; dbBgImgXScaleFactor=pRmode->fbWidth/imgProperties.imgWidth; dbBgImgYScaleFactor=pRmode->xfbHeight/imgProperties.imgHeight; } else { dbReferenceWidth=pRmode->fbWidth; dbReferenceHeight=pRmode->xfbHeight; } if (dbWidth<=1) { dbWidth=dbReferenceWidth*dbWidth; dbConsoleFrameX[0]=0; dbConsoleFrameX[1]=dbWidth; } if (dbHeight<=1) { dbHeight=dbReferenceHeight*dbHeight; dbConsoleFrameY[0]=0; dbConsoleFrameY[1]=dbHeight; } CON_InitEx(pRmode,(s32) getRoundNumber(getPolyContainerPosition(&dbConsoleFrameX[0],2,0,dbReferenceWidth,dbLeft)*dbBgImgXScaleFactor),(s32) getRoundNumber(getPolyContainerPosition(&dbConsoleFrameY[0],2,0,dbReferenceHeight,dbTop)*dbBgImgYScaleFactor),(s32) getRoundNumber(dbWidth*dbBgImgXScaleFactor),(s32) getRoundNumber(dbHeight*dbBgImgYScaleFactor)); if (imgContext) { PNGU_DECODE_TO_COORDS_YCbYCr(imgContext,0,0,imgProperties.imgWidth,imgProperties.imgHeight,pRmode->fbWidth,pRmode->xfbHeight,pFramebuffer); PNGU_ReleaseImageContext(imgContext); } resetDefaultFontSyle(); if (*strSplashScreenMessage) { CON_GetMetrics(&intConsoleColumnsCount,&intConsoleRowsCount); printAlignedText(ALIGN_CENTER,ALIGN_MIDDLE,0,0,intConsoleRowsCount-1,intConsoleColumnsCount-1,true,true,&stTexteLocation,"%s",strSplashScreenMessage); } }
void end() { int columns = 0, rows = 0; CON_GetMetrics(&columns, &rows); printf("\x1b[%i;0H",rows); printf("File written... press Home/Start to exit."); while(1) { WPAD_ScanPads(); PAD_ScanPads(); if ((WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) || (PAD_ButtonsDown(0) & PAD_BUTTON_START)) exit(0); VIDEO_WaitVSync(); } }
void printheadline() { int rows, cols; CON_GetMetrics(&cols, &rows); printf("118Channel and IOS118 Installer v1"); char buf[64]; sprintf(buf, "IOS%u (Rev %u)\n", IOS_GetVersion(), IOS_GetRevision()); printf("\x1B[%d;%dH", 0, cols-strlen(buf)-1); printf(buf); }
void printheadline() { int rows, cols; CON_GetMetrics(&cols, &rows); printf("Yet Another BlueDump MOD v%s.", VERSION); char buf[64]; sprintf(buf, "IOS%ld (v%ld)", IOS_GetVersion(), IOS_GetRevision()); printf("\x1b[%d;%dH", 0, cols-strlen(buf)-1); printf(buf); printf("\nOriginal code by nicksasa and WiiPower."); printf("\nUpdated by DarkMatterCore. Additional code by JoostinOnline."); printf("\nHacksDen.com, The Hacking Resource Community (2013-2017).\n\n"); }
void Con_ClearLine() { int cols, rows; u32 cnt; printf("\r"); fflush(stdout); /* Get console metrics */ CON_GetMetrics(&cols, &rows); /* Erase line */ for (cnt = 1; cnt < cols; cnt++) { printf(" "); fflush(stdout); } printf("\r"); fflush(stdout); }
int Menu_Boot_Options(struct discHdr *header) { int ret_val = 0; if (CFG.disable_options) return 0; struct Game_CFG_2 *game_cfg2 = NULL; struct Game_CFG *game_cfg = NULL; int opt_saved, opt_ios_reload; int redraw_cover = 0; int rows, cols, win_size; CON_GetMetrics(&cols, &rows); if ((win_size = rows-9) < 3) win_size = 3; Con_Clear(); FgColor(CFG.color_header); printf_x(gt("Selected Game")); printf(":"); __console_flush(0); printf(" (%.6s)\n", header->id); DefaultColor(); printf(" %s %s\n\n", CFG.cursor_space, __Menu_PrintTitle(get_title(header))); __console_flush(0); // load_dolmenu((char*)header->id); game_cfg2 = CFG_get_game(header->id); if (!game_cfg2) { printf(gt("ERROR game opt")); printf("\n"); sleep(5); return 0; } game_cfg = &game_cfg2->curr; struct Menu menu; const int NUM_OPT = 16; char active[NUM_OPT]; menu_init(&menu, NUM_OPT); for (;;) { /* // fat on 249? if (wbfs_part_fs && !disc) { if (!is_ios_idx_mload(game_cfg->ios_idx)) { game_cfg->ios_idx = CFG_IOS_222_MLOAD; } } */ menu_init_active(&menu, active, sizeof(active)); opt_saved = game_cfg2->is_saved; // if not mload disable block ios reload opt opt_ios_reload = game_cfg->block_ios_reload; // if not ocarina and not wiird, deactivate hooks if (!game_cfg->ocarina && !CFG.wiird) { active[11] = 0; } //if admin lock is off or they're not in admin // mode then they can't hide/unhide games if (!CFG.admin_lock || CFG.admin_mode_locked) { active[14] = 0; } //These things shouldn't be changed if using a disc...maybe active[0] = 0; active[8] = 0; active[9] = 0; active[14] = 0; Con_Clear(); FgColor(CFG.color_header); printf_x(gt("Selected Game")); printf(":"); printf(" (%.6s)\n", header->id); DefaultColor(); printf(" %s %s\n\n", CFG.cursor_space, __Menu_PrintTitle(get_title(header))); FgColor(CFG.color_header); printf_x(gt("Game Options: %s"), CFG_is_changed(header->id) ? gt("[ CHANGED ]") : opt_saved ? gt("[ SAVED ]") : ""); printf("\n"); DefaultColor(); char c1 = '<', c2 = '>'; //if (opt_saved) { c1 = '['; c2 = ']'; } const char *str_vpatch[3]; str_vpatch[0] = gt("Off"); str_vpatch[1] = gt("On"); str_vpatch[2] = gt("All"); // start menu draw menu_begin(&menu); menu_jump_active(&menu); #define PRINT_OPT_S(N,V) \ printf("%s%c %s %c\n", con_align(N,18), c1, V, c2) #define PRINT_OPT_A(N,V) \ printf("%s%c%s%c\n", con_align(N,18), c1, V, c2) #define PRINT_OPT_B(N,V) \ PRINT_OPT_S(N,(V?gt("On"):gt("Off"))) menu_window_begin(&menu, win_size, NUM_OPT); if (menu_window_mark(&menu)) PRINT_OPT_S(gt("Favorite:"), is_favorite(header->id) ? gt("Yes") : gt("No")); if (menu_window_mark(&menu)) PRINT_OPT_S(gt("Language:"), languages[game_cfg->language]); if (menu_window_mark(&menu)) PRINT_OPT_S(gt("Video:"), videos[game_cfg->video]); if (menu_window_mark(&menu)) PRINT_OPT_S(gt("Video Patch:"), str_vpatch[game_cfg->video_patch]); if (menu_window_mark(&menu)) PRINT_OPT_B("VIDTV:", game_cfg->vidtv); if (menu_window_mark(&menu)) PRINT_OPT_B(gt("Country Fix:"), game_cfg->country_patch); if (menu_window_mark(&menu)) PRINT_OPT_B(gt("Anti 002 Fix:"), game_cfg->fix_002); if (menu_window_mark(&menu)) PRINT_OPT_B(gt("Block IOS Reload:"), opt_ios_reload); if (menu_window_mark(&menu)) PRINT_OPT_B(gt("Ocarina (cheats):"), game_cfg->ocarina); if (menu_window_mark(&menu)) PRINT_OPT_S(gt("Hook Type:"), hook_name[game_cfg->hooktype]); if (menu_window_mark(&menu)) PRINT_OPT_A(gt("Cheat Codes:"), gt("Manage")); if (menu_window_mark(&menu)) printf("%s%s\n", con_align(gt("Cover Image:"), 18), imageNotFound ? gt("< DOWNLOAD >") : gt("[ FOUND ]")); if (menu_window_mark(&menu)) PRINT_OPT_S(gt("Hide Game:"), is_hide_game(header->id) ? gt("Yes") : gt("No")); if (menu_window_mark(&menu)) PRINT_OPT_B(gt("Write Playlog:"), game_cfg->write_playlog); DefaultColor(); menu_window_end(&menu, cols); printf_h(gt("Press %s to start game"), (button_names[CFG.button_confirm.num])); printf("\n"); bool need_save = !opt_saved || CFG_is_changed(header->id); if (need_save) printf_h(gt("Press %s to save options"), (button_names[CFG.button_save.num])); else printf_h(gt("Press %s to discard options"), (button_names[CFG.button_save.num])); printf("\n"); printf_h(gt("Press %s for global options"), (button_names[CFG.button_other.num])); DefaultColor(); __console_flush(0); if (redraw_cover) { Gui_DrawCover(header->id); redraw_cover = 0; } u32 buttons = Wpad_WaitButtonsRpt(); int change = 0; menu_move_active(&menu, buttons); if (buttons & WPAD_BUTTON_LEFT) change = -1; if (buttons & WPAD_BUTTON_RIGHT) change = +1; if (change) { switch (menu.current) { case 0: printf("\n\n"); printf_x(gt("Saving Settings... ")); __console_flush(0); if (set_favorite(header->id, change > 0)) { printf(gt("OK")); } else { printf(gt("ERROR")); sleep(1); } __console_flush(0); Gui_DrawCover(header->id); break; case 1: CHANGE(game_cfg->language, CFG_LANG_MAX); break; case 2: CHANGE(game_cfg->video, CFG_VIDEO_MAX); break; case 3: CHANGE(game_cfg->video_patch, 2); break; case 4: CHANGE(game_cfg->vidtv, 1); break; case 5: CHANGE(game_cfg->country_patch, 1); break; case 6: CHANGE(game_cfg->fix_002, 1); break; case 7: CHANGE(game_cfg->block_ios_reload, 1); break; case 8: CHANGE(game_cfg->ocarina, 1); break; case 9: CHANGE(game_cfg->hooktype, NUM_HOOK-1); break; case 10: Menu_Cheats(header); break; case 11: printf("\n\n"); Download_Cover((char*)header->id, change > 0, true); Cache_Invalidate(); Gui_DrawCover(header->id); Menu_PrintWait(); break; case 12: // hide game printf("\n\n"); printf_x(gt("Saving Settings... ")); __console_flush(0); if (set_hide_game(header->id, change > 0)) { printf(gt("OK")); } else { printf(gt("ERROR")); sleep(1); } __console_flush(0); Gui_DrawCover(header->id); break; case 13: CHANGE(game_cfg->write_playlog, 1); break; } } if (buttons & CFG.button_confirm.mask) { CFG.confirm_start = 0; Menu_Boot(); break; } if (buttons & CFG.button_save.mask) { bool ret; printf("\n\n"); if (need_save) { ret = CFG_save_game_opt(header->id); if (ret) { printf_x(gt("Options saved for this game.")); } else printf(gt("Error saving options!")); } else { ret = CFG_discard_game_opt(header->id); if (ret) printf_x(gt("Options discarded for this game.")); else printf(gt("Error discarding options!")); } sleep(1); } // HOME button if (buttons & CFG.button_exit.mask) { Handle_Home(0); } if (buttons & CFG.button_other.mask) { ret_val = 1; break; } if (buttons & CFG.button_cancel.mask) break; } CFG_release_game(game_cfg2); return ret_val; }
int Menu_Global_Options() { int rows, cols, win_size = 11; CON_GetMetrics(&cols, &rows); if (strcmp(LAST_CFG_PATH, USBLOADER_PATH)) win_size += 2; if ((win_size = rows-win_size) < 3) win_size = 3; if (CFG.disable_options) return 0; struct discHdr *header = NULL; int redraw_cover = 0; struct Menu menu; menu_init(&menu, 9); for (;;) { menu.line_count = 0; if (gameCnt) { header = &gameList[gameSelected]; } else { header = NULL; } Con_Clear(); FgColor(CFG.color_header); printf_x(gt("Global Options")); printf(":\n\n"); DefaultColor(); menu_window_begin(&menu, win_size, 9); if (menu_window_mark(&menu)) printf("<%s>\n", gt("Main Menu")); if (menu_window_mark(&menu)) printf("%s%2d/%-2d< %s > (%d)\n", con_align(gt("Profile:"),8), CFG.current_profile + 1, CFG.num_profiles, CFG.profile_names[CFG.current_profile], CFG.num_favorite_game); if (menu_window_mark(&menu)) printf("%s%2d/%2d < %s >\n", con_align(gt("Theme:"),7), cur_theme + 1, num_theme, *CFG.theme ? CFG.theme : gt("none")); if (menu_window_mark(&menu)) printf("%s< %s >\n", con_align(gt("Partition:"),13), CFG.partition); if (menu_window_mark(&menu)) printf("<%s>\n", gt("Download All Missing Covers")); if (menu_window_mark(&menu)) printf("<%s>\n", gt("Update WiiTDB Game Database")); // download database - lustar if (menu_window_mark(&menu)) printf("<%s>\n", gt("Update titles.txt")); if (menu_window_mark(&menu)) printf("<%s>\n", gt("Check For Updates")); DefaultColor(); menu_window_end(&menu, cols); printf_h(gt("Press %s for game options"), (button_names[CFG.button_other.num])); printf("\n"); printf_h(gt("Press %s to save global settings"), (button_names[CFG.button_save.num])); printf("\n\n"); Print_SYS_Info(); DefaultColor(); __console_flush(0); if (redraw_cover) { if (header) Gui_DrawCover(header->id); redraw_cover = 0; } u32 buttons = Wpad_WaitButtonsRpt(); menu_move(&menu, buttons); int change = 0; if (buttons & WPAD_BUTTON_LEFT) change = -1; if (buttons & WPAD_BUTTON_RIGHT) change = +1; if (buttons & CFG.button_confirm.mask) change = +1; if (change) { switch (menu.current) { case 0: Menu_Views(); return 0; case 1: CHANGE(CFG.current_profile, CFG.num_profiles-1); // refresh favorites list Switch_Favorites(enable_favorite); redraw_cover = 1; break; case 2: CFG_switch_theme(cur_theme + change); redraw_cover = 1; Cache_Invalidate(); break; case 3: Menu_Partition(true); return 0; case 4: Download_All_Covers(change > 0); Cache_Invalidate(); if (header) Gui_DrawCover(header->id); Menu_PrintWait(); break; case 5: Download_XML(); break; case 6: Download_Titles(); break; case 7: Online_Update(); break; } } // HOME button if (buttons & CFG.button_exit.mask) { Handle_Home(0); } if (buttons & CFG.button_save.mask) { int ret; printf("\n"); printf_x(gt("Saving Settings... ")); printf("\n"); __console_flush(0); FgColor(CFG.color_inactive); ret = CFG_Save_Global_Settings(); DefaultColor(); if (ret) { printf_(gt("OK")); printf("\n"); Save_Game_List(); } else { printf_(gt("ERROR")); } printf("\n"); //sleep(2); Menu_PrintWait(); } if (buttons & WPAD_BUTTON_PLUS) { printf("\n"); mem_stat(); Menu_PrintWait(); } if (buttons & CFG.button_other.mask) return 1; if (buttons & CFG.button_cancel.mask) break; } return 0; }
int getConsoleRowsCount() { int intConsoleColumnsCount,intConsoleRowsCount; CON_GetMetrics(&intConsoleColumnsCount,&intConsoleRowsCount); return intConsoleRowsCount; }
int Menu_Filter3() { struct discHdr *header = NULL; int redraw_cover = 0; struct Menu menu; int rows, cols, size; CON_GetMetrics(&cols, &rows); if ((size = rows-8) < 3) size = 3; menu_init(&menu, featureCnt+3); for (;;) { menu.line_count = 0; if (gameCnt) { header = &gameList[gameSelected]; } else { header = NULL; } int n; Con_Clear(); FgColor(CFG.color_header); printf_x(gt("Filter by Online Features")); printf(":\n\n"); MENU_MARK(); printf("<%s>\n", gt("Filter by Genre")); MENU_MARK(); printf("<%s>\n", gt("Filter by Controller")); MENU_MARK(); printf("%s %s\n", ((filter_type == -1) ? "*" : " "), gt("All Games")); menu_window_begin(&menu, size, featureCnt); for (n=0;n<featureCnt;n++) { if (menu_window_mark(&menu)) printf("%s %s\n", ((filter_index == n && filter_type == 3) ? "*": " "), featureTypes[n][1]); } DefaultColor(); menu_window_end(&menu, cols); printf_h(gt("Press %s to select filter type"), (button_names[CFG.button_confirm.num])); __console_flush(0); if (redraw_cover) { if (header) Gui_DrawCover(header->id); redraw_cover = 0; } u32 buttons = Wpad_WaitButtonsRpt(); menu_move(&menu, buttons); int change = 0; if (buttons & WPAD_BUTTON_LEFT) change = -1; if (buttons & WPAD_BUTTON_RIGHT || buttons & CFG.button_confirm.mask || buttons & CFG.button_save.mask) change = +1; if (change) { if (0 == menu.current) { Menu_Filter(); redraw_cover = 1; goto end; } else if (1 == menu.current) { Menu_Filter2(); redraw_cover = 1; goto end; } else if (2 == menu.current) { showAllGames(); filter_type = -1; redraw_cover = 1; } for (n=0;n<featureCnt;n++) { if (3+n == menu.current) { redraw_cover = 1; if (filter_games(filter_features, featureTypes[n][0], 0) > -1) { filter_type = 3; filter_index = n; } break; } } } // HOME button if (buttons & CFG.button_exit.mask) { Handle_Home(0); } if (buttons & CFG.button_cancel.mask) break; } end: return 0; }