void CGameTitles::WriteCachedTitles(const char * path) { std::string Cachepath = path; if(path[strlen(path)-1] != '/') Cachepath += '/'; Cachepath += "TitlesCache.bin"; FILE *f = fopen(Cachepath.c_str(), "wb"); if(!f) return; CacheTitle Cache; u32 count = TitleList.size(); u32 revision = atoi(GetRev()); fwrite(&revision, 1, 4, f); fwrite(Settings.db_language, 1, 10, f); fwrite(&count, 1, 4, f); for(u32 i = 0; i < count; ++i) { memset(&Cache, 0, sizeof(CacheTitle)); strncpy(Cache.GameID, TitleList[i].GameID, sizeof(Cache.GameID)-1); strncpy(Cache.Title, TitleList[i].Title.c_str(), sizeof(Cache.Title)-1); Cache.ParentalRating = TitleList[i].ParentalRating; Cache.PlayersCount = TitleList[i].PlayersCount; Cache.FromWiiTDB = TitleList[i].FromWiiTDB; fwrite(&Cache, 1, sizeof(CacheTitle), f); } fclose(f); }
/**************************************************************************** * Update check ***************************************************************************/ int CheckUpdate() { if (!networkinitialized) return -1; int revnumber = 0; int currentrev = atoi(GetRev()); if (Settings.beta_upgrades) { revnumber = CheckForBetaUpdate(); } else { #ifdef FULLCHANNEL struct block file = downloadfile("http://www.techjawa.com/usbloadergx/wadrev.txt"); #else struct block file = downloadfile("http://www.techjawa.com/usbloadergx/rev.txt"); #endif char revtxt[10]; u8 i; if (file.data != NULL) { for (i=0; i<9 || i < file.size; i++) revtxt[i] = file.data[i]; revtxt[i] = 0; revnumber = atoi(revtxt); free(file.data); } } if (revnumber > currentrev) return revnumber; else return -1; }
bool CSettings::Save() { if (!FindConfig()) return false; char filedest[300]; snprintf(filedest, sizeof(filedest), "%sGXGlobal.cfg", ConfigPath); if(!CreateSubfolder(ConfigPath)) return false; FILE * file = fopen(filedest, "w"); if (!file) return false; fprintf(file, "# USB Loader GX R%s - Main settings file\n", GetRev()); fprintf(file, "# Note: This file is automatically generated\n"); fprintf(file, "godmode = %d\n", godmode); fprintf(file, "videomode = %d\n", videomode); fprintf(file, "videopatch = %d\n", videopatch); fprintf(file, "videoPatchDol = %d\n", videoPatchDol); fprintf(file, "language = %d\n", language); fprintf(file, "ocarina = %d\n", ocarina); fprintf(file, "hddinfo = %d\n", hddinfo); fprintf(file, "sinfo = %d\n", sinfo); fprintf(file, "rumble = %d\n", rumble); fprintf(file, "volume = %d\n", volume); fprintf(file, "sfxvolume = %d\n", sfxvolume); fprintf(file, "gamesoundvolume = %d\n", gamesoundvolume); fprintf(file, "tooltips = %d\n", tooltips); fprintf(file, "RememberUnlock = %d\n", RememberUnlock); char EncryptedTxt[50]; EncryptString(unlockCode, EncryptedTxt); fprintf(file, "password = %s\n", EncryptedTxt); fprintf(file, "GameSort = %d\n", GameSort); fprintf(file, "LoaderIOS = %d\n", LoaderIOS); fprintf(file, "cios = %d\n", cios); fprintf(file, "keyset = %d\n", keyset); fprintf(file, "xflip = %d\n", xflip); fprintf(file, "gridRows = %d\n", gridRows); fprintf(file, "quickboot = %d\n", quickboot); fprintf(file, "wsprompt = %d\n", wsprompt); fprintf(file, "parentalcontrol = %d\n", parentalcontrol); fprintf(file, "covers_path = %s\n", covers_path); fprintf(file, "covers2d_path = %s\n", covers2d_path); fprintf(file, "coversFull_path = %s\n", coversFull_path); fprintf(file, "theme_path = %s\n", theme_path); fprintf(file, "theme = %s\n", theme); fprintf(file, "disc_path = %s\n", disc_path); fprintf(file, "language_path = %s\n", language_path); fprintf(file, "languagefiles_path = %s\n", languagefiles_path); fprintf(file, "TxtCheatcodespath = %s\n", TxtCheatcodespath); fprintf(file, "titlestxt_path = %s\n", titlestxt_path); fprintf(file, "gamesound = %d\n", gamesound); fprintf(file, "dolpath = %s\n", dolpath); fprintf(file, "ogg_path = %s\n", ogg_path); fprintf(file, "wiilight = %d\n", wiilight); fprintf(file, "gameDisplay = %d\n", gameDisplay); fprintf(file, "update_path = %s\n", update_path); fprintf(file, "homebrewapps_path = %s\n", homebrewapps_path); fprintf(file, "BNRCachePath = %s\n", BNRCachePath); fprintf(file, "Cheatcodespath = %s\n", Cheatcodespath); fprintf(file, "BcaCodepath = %s\n", BcaCodepath); fprintf(file, "WipCodepath = %s\n", WipCodepath); fprintf(file, "WDMpath = %s\n", WDMpath); fprintf(file, "titlesOverride = %d\n", titlesOverride); fprintf(file, "ForceDiscTitles = %d\n", ForceDiscTitles); fprintf(file, "patchcountrystrings = %d\n", patchcountrystrings); fprintf(file, "screensaver = %d\n", screensaver); fprintf(file, "musicloopmode = %d\n", musicloopmode); fprintf(file, "autonetwork = %d\n", autonetwork); fprintf(file, "discart = %d\n", discart); fprintf(file, "coversfull = %d\n", coversfull); fprintf(file, "partition = %d\n", partition); fprintf(file, "marknewtitles = %d\n", marknewtitles); fprintf(file, "ShowFreeSpace = %d\n", ShowFreeSpace); fprintf(file, "InstallToDir = %d\n", InstallToDir); fprintf(file, "GameSplit = %d\n", GameSplit); fprintf(file, "InstallPartitions = %08X\n", InstallPartitions); fprintf(file, "PlaylogUpdate = %d\n", PlaylogUpdate); fprintf(file, "ParentalBlocks = %08X\n", ParentalBlocks); fprintf(file, "returnTo = %s\n", returnTo); fprintf(file, "HomeMenu = %d\n", HomeMenu); fprintf(file, "MultiplePartitions = %d\n", MultiplePartitions); fprintf(file, "USBPort = %d\n", USBPort); fprintf(file, "USBAutoMount = %d\n", USBAutoMount); fprintf(file, "CacheTitles = %d\n", CacheTitles); fprintf(file, "BlockIOSReload = %d\n", BlockIOSReload); fprintf(file, "WSFactor = %0.3f\n", WSFactor); fprintf(file, "FontScaleFactor = %0.3f\n", FontScaleFactor); fprintf(file, "ClockFontScaleFactor = %0.3f\n", ClockFontScaleFactor); fprintf(file, "EnabledCategories = "); for(u32 i = 0; i < EnabledCategories.size(); ++i) { fprintf(file, "%i", EnabledCategories[i]); if(i+1 < EnabledCategories.size()) fprintf(file, ","); } fprintf(file, "\n"); fprintf(file, "RequiredCategories = "); for(u32 i = 0; i < RequiredCategories.size(); ++i) { fprintf(file, "%i", RequiredCategories[i]); if(i+1 < RequiredCategories.size()) fprintf(file, ","); } fprintf(file, "\n"); fprintf(file, "ForbiddenCategories = "); for(u32 i = 0; i < ForbiddenCategories.size(); ++i) { fprintf(file, "%i", ForbiddenCategories[i]); if(i+1 < ForbiddenCategories.size()) fprintf(file, ","); } fprintf(file, "\n"); fprintf(file, "Wiinnertag = %d\n", Wiinnertag); fprintf(file, "WiinnertagPath = %s\n", WiinnertagPath); fprintf(file, "SelectedGame = %d\n", SelectedGame); fprintf(file, "GameListOffset = %d\n", GameListOffset); fprintf(file, "sneekVideoPatch = %d\n", sneekVideoPatch); fprintf(file, "NandEmuMode = %d\n", NandEmuMode); fprintf(file, "NandEmuChanMode = %d\n", NandEmuChanMode); fprintf(file, "NandEmuPath = %s\n", NandEmuPath); fprintf(file, "NandEmuChanPath = %s\n", NandEmuChanPath); fprintf(file, "UseSystemFont = %d\n", UseSystemFont); fprintf(file, "Hooktype = %d\n", Hooktype); fprintf(file, "WiirdDebugger = %d\n", WiirdDebugger); fprintf(file, "WiirdDebuggerPause = %d\n", WiirdDebuggerPause); fprintf(file, "ShowPlayCount = %d\n", ShowPlayCount); fprintf(file, "LoaderMode = %d\n", LoaderMode); fprintf(file, "SearchMode = %d\n", SearchMode); fprintf(file, "GameAspectRatio = %d\n", GameAspectRatio); fprintf(file, "PointerSpeed = %g\n", PointerSpeed); fprintf(file, "UseChanLauncher = %d\n", UseChanLauncher); fprintf(file, "AdjustOverscanX = %d\n", AdjustOverscanX); fprintf(file, "AdjustOverscanY = %d\n", AdjustOverscanY); fprintf(file, "TooltipDelay = %d\n", TooltipDelay); fprintf(file, "GameWindowMode = %d\n", GameWindowMode); fprintf(file, "CacheBNRFiles = %d\n", CacheBNRFiles); fprintf(file, "BannerAnimStart = %d\n", BannerAnimStart); fprintf(file, "BannerGridSpeed = %g\n", BannerGridSpeed); fprintf(file, "BannerZoomDuration = %d\n", BannerZoomDuration); fprintf(file, "BannerProjectionOffsetX = %g\n", BannerProjectionOffsetX); fprintf(file, "BannerProjectionOffsetY = %g\n", BannerProjectionOffsetY); fprintf(file, "BannerProjectionWidth = %g\n", BannerProjectionWidth); fprintf(file, "BannerProjectionHeight = %g\n", BannerProjectionHeight); fprintf(file, "GCBannerScale = %g\n", GCBannerScale); fprintf(file, "GameCubePath = %s\n", GameCubePath); fprintf(file, "GameCubeSDPath = %s\n", GameCubeSDPath); fprintf(file, "GameCubeMode = %d\n", GameCubeMode); fprintf(file, "GameCubeSource = %d\n", GameCubeSource); fprintf(file, "MultiDiscPrompt = %d\n", MultiDiscPrompt); fprintf(file, "DMLVideo = %d\n", DMLVideo); fprintf(file, "DMLProgPatch = %d\n", DMLProgPatch); fprintf(file, "DMLNMM = %d\n", DMLNMM); fprintf(file, "DMLActivityLED = %d\n", DMLActivityLED); fprintf(file, "DMLPADHOOK = %d\n", DMLPADHOOK); fprintf(file, "DMLNoDisc2 = %d\n", DMLNoDisc2); fprintf(file, "DMLWidescreen = %d\n", DMLWidescreen); fprintf(file, "DMLScreenshot = %d\n", DMLScreenshot); fprintf(file, "DMLJPNPatch = %d\n", DMLJPNPatch); fprintf(file, "DMLDebug = %d\n", DMLDebug); fprintf(file, "NINDeflicker = %d\n", NINDeflicker); fprintf(file, "NINPal50Patch = %d\n", NINPal50Patch); fprintf(file, "NINWiiUWide = %d\n", NINWiiUWide); fprintf(file, "NINVideoScale = %d\n", NINVideoScale); fprintf(file, "NINVideoOffset = %d\n", NINVideoOffset); fprintf(file, "NINRemlimit = %d\n", NINRemlimit); fprintf(file, "NINMCEmulation = %d\n", NINMCEmulation); fprintf(file, "NINMCSize = %d\n", NINMCSize); fprintf(file, "NINAutoboot = %d\n", NINAutoboot); fprintf(file, "NINSettings = %d\n", NINSettings); fprintf(file, "NINUSBHID = %d\n", NINUSBHID); fprintf(file, "NINMaxPads = %d\n", NINMaxPads); fprintf(file, "NINNativeSI = %d\n", NINNativeSI); fprintf(file, "NINOSReport = %d\n", NINOSReport); fprintf(file, "NINLED = %d\n", NINLED); fprintf(file, "NINLog = %d\n", NINLog); fprintf(file, "DEVOMCEmulation = %d\n", DEVOMCEmulation); fprintf(file, "DEVOWidescreen = %d\n", DEVOWidescreen); fprintf(file, "DEVOActivityLED = %d\n", DEVOActivityLED); fprintf(file, "DEVOFZeroAX = %d\n", DEVOFZeroAX); fprintf(file, "DEVOTimerFix = %d\n", DEVOTimerFix); fprintf(file, "DEVODButtons = %d\n", DEVODButtons); fprintf(file, "DEVOCropOverscan = %d\n", DEVOCropOverscan); fprintf(file, "DEVODiscDelay = %d\n", DEVODiscDelay); fprintf(file, "DEVOLoaderPath = %s\n", DEVOLoaderPath); fprintf(file, "NINLoaderPath = %s\n", NINLoaderPath); fprintf(file, "GCInstallCompressed = %d\n", GCInstallCompressed); fprintf(file, "GCInstallAligned = %d\n", GCInstallAligned); fprintf(file, "PrivateServer = %d\n", PrivateServer); fprintf(file, "CustomBannersURL = %s\n", CustomBannersURL); fclose(file); return true; }
int UpdateLanguageFiles() { if(!CreateSubfolder(Settings.languagefiles_path)) { ShowError(tr("Could not create path: %s"), Settings.languagefiles_path); return -1; } if(!IsNetworkInit()) { ShowError(tr("Network is not initiated.")); return -2; } DirList Dir(Settings.languagefiles_path, ".lang"); //give up now if we didn't find any if (Dir.GetFilecount() == 0) { if(WindowPrompt(tr("Error:"), tr("No language files to update on your devices! Do you want to download new language files?"), tr("Yes"), tr("No"))) return DownloadAllLanguageFiles(); return -2; } char savepath[150]; char codeurl[200]; //we assume that the network will already be init by another function // ( that has gui eletents in it because this one doesn't) int done = 0; //build the URL, save path, and download each file and save it for(int i = 0; i < Dir.GetFilecount(); ++i) { snprintf(codeurl, sizeof(codeurl), "%s%s?p=%s", LanguageFilesURL, Dir.GetFilename(i), GetRev()); snprintf(savepath, sizeof(savepath), "%s/%s", Settings.languagefiles_path, Dir.GetFilename(i)); struct block file = downloadfile(codeurl); ShowProgress(tr("Updating Language Files:"), 0, Dir.GetFilename(i), i, Dir.GetFilecount(), false, true); if (file.data != NULL) { FILE * pfile; pfile = fopen(savepath, "wb"); if (pfile != NULL) { fwrite(file.data, 1, file.size, pfile); fclose(pfile); done++; } free(file.data); } } ProgressStop(); // reload current language file if(Settings.language_path[0] != 0) Settings.LoadLanguage(Settings.language_path, CONSOLE_DEFAULT); else Settings.LoadLanguage(NULL, CONSOLE_DEFAULT); // return the number of files we updated return done; }
int DownloadAllLanguageFiles(int revision) { if(!CreateSubfolder(Settings.languagefiles_path)) { ShowError(tr("Could not create path: %s"), Settings.languagefiles_path); return -1; } if(!IsNetworkInit()) { ShowError(tr("Network is not initiated.")); return -2; } char fullURL[300]; URL_List LinkList(LanguageFilesURL); int listsize = LinkList.GetURLCount(); int files_downloaded = 0; char target[6]; if(revision > 0) snprintf(target, sizeof(target), "%d", revision); else snprintf(target, sizeof(target), "%s", GetRev()); ShowProgress(tr("Updating Language Files:"), 0, 0, 0, listsize, false, true); for (int i = 0; i < listsize; i++) { const char * filename = strrchr(LinkList.GetURL(i), '/'); if(filename) filename++; else filename = LinkList.GetURL(i); if(!filename) continue; const char * FileExt = strrchr(filename, '.'); if (!FileExt || strcasecmp(FileExt, ".lang") != 0) continue; debughelper_printf("%s\n", filename); ShowProgress(tr("Updating Language Files:"), 0, filename, i, listsize, false, true); snprintf(fullURL, sizeof(fullURL), "%s%s?p=%s", LanguageFilesURL, filename, target); struct block file = downloadfile(fullURL); if (file.data) { char filepath[300]; snprintf(filepath, sizeof(filepath), "%s/%s", Settings.languagefiles_path, filename); FILE * pfile = fopen(filepath, "wb"); if(pfile) { fwrite(file.data, 1, file.size, pfile); fclose(pfile); files_downloaded++; } free(file.data); } } ProgressStop(); // reload current language file if(Settings.language_path[0] != 0) Settings.LoadLanguage(Settings.language_path, CONSOLE_DEFAULT); else Settings.LoadLanguage(NULL, CONSOLE_DEFAULT); return files_downloaded; }
SettingsMenu::SettingsMenu(int w, int h) : GuiFrame(w, h) , categorySelectionFrame(w, h) , particleBgImage(w, h, 50) , buttonClickSound(Resources::GetSound("settings_click_2.mp3")) , quitImageData(Resources::GetImageData("quitButton.png")) , categoryImageData(Resources::GetImageData("settingsCategoryButton.png")) , categoryBgImageData(Resources::GetImageData("settingsCategoryBg.png")) , quitImage(quitImageData) , quitButton(quitImage.getWidth(), quitImage.getHeight()) , touchTrigger(GuiTrigger::CHANNEL_1, GuiTrigger::VPAD_TOUCH) , wpadTouchTrigger(GuiTrigger::CHANNEL_2 | GuiTrigger::CHANNEL_3 | GuiTrigger::CHANNEL_4 | GuiTrigger::CHANNEL_5, GuiTrigger::BUTTON_A) , buttonATrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_A, true) , buttonBTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_B, true) , buttonLTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_L, true) , buttonRTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_R, true) , buttonLeftTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_LEFT | GuiTrigger::STICK_L_LEFT, true) , buttonRightTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_RIGHT | GuiTrigger::STICK_L_RIGHT, true) , leftArrowImageData(Resources::GetImageData("leftArrow.png")) , rightArrowImageData(Resources::GetImageData("rightArrow.png")) , leftArrowImage(leftArrowImageData) , rightArrowImage(rightArrowImageData) , leftArrowButton(leftArrowImage.getWidth(), leftArrowImage.getHeight()) , rightArrowButton(rightArrowImage.getWidth(), rightArrowImage.getHeight()) , DPADButtons(w,h) { currentPosition = 0; targetPosition = 0; selectedCategory = 0; animationSpeed = 25; bUpdatePositions = true; quitButton.setImage(&quitImage); quitButton.setAlignment(ALIGN_BOTTOM | ALIGN_LEFT); quitButton.clicked.connect(this, &SettingsMenu::OnQuitButtonClick); quitButton.setTrigger(&touchTrigger); quitButton.setTrigger(&wpadTouchTrigger); quitButton.setEffectGrow(); quitButton.setSoundClick(buttonClickSound); categorySelectionFrame.append(&quitButton); versionText.setColor(glm::vec4(0.6f, 0.6f, 0.6f, 1.0f)); versionText.setFontSize(42); versionText.setAlignment(ALIGN_TOP | ALIGN_RIGHT); versionText.setPosition(-50, -80); versionText.setTextf("Loadiine GX2 %s (build %s)", LOADIINE_VERSION, GetRev()); categorySelectionFrame.append(&versionText); const u32 cuCategoriesCount = sizeof(stSettingsCategories) / sizeof(stSettingsCategories[0]); if(cuCategoriesCount > 0) selectedCategory = 0; for(u32 idx = 0; idx < cuCategoriesCount; idx++) { settingsCategories.resize(idx + 1); GuiSettingsCategory & category = settingsCategories[idx]; std::vector<std::string> splitDescriptions = stringSplit(stSettingsCategories[idx].descriptions, "\n"); category.categoryIconData = Resources::GetImageData(stSettingsCategories[idx].icon); category.categoryIconGlowData = Resources::GetImageData(stSettingsCategories[idx].iconGlow); category.categoryLabel = new GuiText(tr(stSettingsCategories[idx].name), 46, glm::vec4(0.8f, 0.8f, 0.8f, 1.0f)); category.categoryLabel->setPosition(0, -120); category.categoryBgImage = new GuiImage(categoryBgImageData); category.categoryImages = new GuiImage(categoryImageData); category.categoryIcon = new GuiImage(category.categoryIconData); category.categoryIconGlow = new GuiImage(category.categoryIconGlowData); category.categoryButton = new GuiButton(category.categoryImages->getWidth(), category.categoryImages->getHeight()); category.categoryIcon->setPosition(0, 40); category.categoryIconGlow->setPosition(0, 40); category.categoryButton->setLabel(category.categoryLabel); category.categoryButton->setImage(category.categoryImages); category.categoryButton->setPosition(-300, 0); category.categoryButton->setIcon(category.categoryIcon); category.categoryButton->setIconOver(category.categoryIconGlow); category.categoryButton->setTrigger(&touchTrigger); category.categoryButton->setTrigger(&wpadTouchTrigger); category.categoryButton->setSoundClick(buttonClickSound); category.categoryButton->setEffectGrow(); category.categoryButton->clicked.connect(this, &SettingsMenu::OnCategoryClick); categorySelectionFrame.append(category.categoryBgImage); categorySelectionFrame.append(category.categoryButton); category.categoryButton->setParent(category.categoryBgImage); category.categoryBgImage->setPosition(currentPosition + (category.categoryBgImage->getWidth() + 40) * idx, 0); for(u32 n = 0; n < splitDescriptions.size(); n++) { GuiText * descr = new GuiText(tr(splitDescriptions[n].c_str()), 46, glm::vec4(0.8f, 0.8f, 0.8f, 1.0f)); descr->setAlignment(ALIGN_MIDDLE | ALIGN_LEFT); descr->setPosition(category.categoryBgImage->getWidth() * 0.5f - 50.0f, category.categoryBgImage->getHeight() * 0.5f - 100.0f - n * 60.0f); categorySelectionFrame.append(descr); descr->setParent(category.categoryBgImage); category.descriptions.push_back(descr); } GuiImage *smallIconOver = new GuiImage(category.categoryIconGlowData); GuiImage *smallIcon = new GuiImage(category.categoryIconData); GuiButton *smallIconButton = new GuiButton(smallIcon->getWidth() * smallIconScale, smallIcon->getHeight() * smallIconScale); smallIcon->setScale(smallIconScale); smallIconOver->setScale(smallIconScale); smallIconButton->setImage(smallIcon); smallIconButton->setEffectGrow(); smallIconButton->setTrigger(&touchTrigger); smallIconButton->setTrigger(&wpadTouchTrigger); smallIconButton->setSoundClick(buttonClickSound); smallIconButton->clicked.connect(this, &SettingsMenu::OnSmallIconClick); categorySelectionFrame.append(smallIconButton); categorySmallImages.push_back(smallIcon); categorySmallImagesOver.push_back(smallIconOver); categorySmallButtons.push_back(smallIconButton); } leftArrowButton.setImage(&leftArrowImage); leftArrowButton.setEffectGrow(); leftArrowButton.setPosition(40, 0); leftArrowButton.setAlignment(ALIGN_LEFT | ALIGN_MIDDLE); leftArrowButton.setTrigger(&touchTrigger); leftArrowButton.setTrigger(&wpadTouchTrigger); leftArrowButton.setSoundClick(buttonClickSound); leftArrowButton.clicked.connect(this, &SettingsMenu::OnCategoryLeftClick); categorySelectionFrame.append(&leftArrowButton); rightArrowButton.setImage(&rightArrowImage); rightArrowButton.setEffectGrow(); rightArrowButton.setPosition(-40, 0); rightArrowButton.setAlignment(ALIGN_RIGHT | ALIGN_MIDDLE); rightArrowButton.setTrigger(&touchTrigger); rightArrowButton.setTrigger(&wpadTouchTrigger); rightArrowButton.setSoundClick(buttonClickSound); rightArrowButton.clicked.connect(this, &SettingsMenu::OnCategoryRightClick); categorySelectionFrame.append(&rightArrowButton); DPADButtons.setTrigger(&buttonATrigger); DPADButtons.setTrigger(&buttonBTrigger); DPADButtons.setTrigger(&buttonLTrigger); DPADButtons.setTrigger(&buttonRTrigger); DPADButtons.setTrigger(&buttonLeftTrigger); DPADButtons.setTrigger(&buttonRightTrigger); DPADButtons.clicked.connect(this, &SettingsMenu::OnDPADClick); append(&DPADButtons); categorySelectionFrame.append(&DPADButtons); setTargetPosition(0); moving = false; //! the particle BG is always appended in all sub menus append(&particleBgImage); append(&categorySelectionFrame); }
int main(int argc, char *argv[]) { setlocale(LC_ALL, "en.UTF-8"); geckoinit = InitGecko(); if (hbcStubAvailable() || geckoinit) { InitTextVideo(); } // DEBUG_Init(GDBSTUB_DEVICE_USB, 1); //_break(); __exception_setreload(5); //auto reset code dump nobody gives us codedump info anyways. gprintf("\n\n------------------"); gprintf("\nUSB Loader GX rev%s",GetRev()); gprintf("\nmain(%d", argc); for (int i=0;i<argc;i++) gprintf(", %s",argv[i]?argv[i]:"<NULL>"); gprintf(")"); // This part is added, because we need a identify patched ios // printf("\n\tReloading into ios 236"); if (IOS_ReloadIOSsafe(236) < 0) { // printf("\n\tIOS 236 not found, reloading into 36"); IOS_ReloadIOSsafe(36); } printf("\n\tStarting up"); MEM2_init(36); // Initialize 36 MB MEM2_takeBigOnes(true); s32 ret; bool startupproblem = false; bool bootDevice_found=false; if (argc >= 1) { if (!strncasecmp(argv[0], "usb:/", 5)) { strcpy(bootDevice, "USB:"); bootDevice_found = true; } else if (!strncasecmp(argv[0], "sd:/", 4)) bootDevice_found = true; } printf("\n\tInitializing controllers"); /** PAD_Init has to be before InitVideo don't move that **/ PAD_Init(); // initialize PAD/WPAD printf("\n\tInitialize USB (wake up)"); USBDevice_Init(); // seems enough to wake up some HDDs if they are in sleep mode when the loader starts (tested with WD MyPassport Essential 2.5") gprintf("\n\tChecking for stub IOS"); ios222rev = getIOSrev(0x00000001000000dell); ios249rev = getIOSrev(0x00000001000000f9ll); //if we don't like either of the cIOS then scram if (!(ios222rev==4 || ios222rev==5 || (ios249rev>=9 && ios249rev<65280))) { InitTextVideo(); printf("\x1b[2J"); if ((ios222rev < 0 && ios222rev != WII_EINSTALL) && (ios249rev < 0 && ios249rev != WII_EINSTALL)) { printf("\n\n\n\tWARNING!"); printf("\n\tUSB Loader GX needs unstubbed cIOS 222 v4 or 249 v9+"); printf("\n\n\tWe cannot determine the versions on your system,\n\tsince you have no patched ios 36 or 236 installed."); printf("\n\tTherefor, if loading of USB Loader GX fails, you\n\tprobably have installed the 4.2 update,"); printf("\n\tand you should go figure out how to get some cios action going on\n\tin your Wii."); printf("\n\n\tThis message will show every time."); sleep(5); } else { printf("\n\n\n\tERROR!"); printf("\n\tUSB Loader GX needs unstubbed cIOS 222 v4 or 249 v9+"); printf("\n\n\tI found \n\t\t222 = %d%s",ios222rev,ios222rev==65280?" (Stubbed by 4.2 update)":""); printf("\n\t\t249 = %d%s",ios249rev,ios249rev==65280?" (Stubbed by 4.2 update)":""); printf("\n\n\tGo figure out how to get some cIOS action going on\n\tin your Wii and come back and see me."); sleep(15); printf("\n\n\tBye"); USBDevice_deInit(); exit(0); } } printf("\n\tReloading ios 249..."); ret = IOS_ReloadIOSsafe(249); printf("%d", ret); if (ret < 0) { printf("\n\tIOS 249 failed, reloading ios 222..."); ret = IOS_ReloadIOSsafe(222); printf("%d", ret); if (ret < 0) { printf("\n\tIOS 222 failed, reloading ios 250..."); ret = IOS_ReloadIOSsafe(250); printf("%d", ret); if(ret < 0) { printf("\n\tIOS 250 failed, reloading ios 223..."); ret = IOS_ReloadIOSsafe(223); printf("%d", ret); if (ret < 0) { printf("\n\tERROR: cIOS could not be loaded!\n"); sleep(5); SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); } } } printf("\n\tInitialize sd card"); SDCard_Init(); printf("\n\tLoad ehc module"); load_ehc_module(); printf("\n\tdeinit sd card"); SDCard_deInit(); } printf("\n\tInit wbfs..."); ret = WBFS_Init(WBFS_DEVICE_USB); printf("%d", ret); if (ret < 0) { printf("\n\tYou have issues with a slow disc, or a difficult disc\n\tReloading 222..."); ret = IOS_ReloadIOSsafe(222); printf("%d", ret); /*if(ret < 0) { // printf("\n\tSleeping for 4 seconds"); // sleep(4); InitVideo(); // Initialise video Menu_Render(); BootUpProblems(); startupproblem = true; ret = 1; }*/ printf("\n\tInitialize sd card"); SDCard_Init(); printf("\n\tLoad ehc module"); load_ehc_module(); printf("\n\tdeinit sd card"); SDCard_deInit(); printf("\n\tInitialize wbfs..."); USBDevice_deInit(); USBDevice_Init(); ret = WBFS_Init(WBFS_DEVICE_USB); printf("%d", ret); if(ret < 0) { // printf("\n\tSleeping for 4 seconds"); // sleep(4); InitVideo(); // Initialise video Menu_Render(); BootUpProblems(); startupproblem = true; ret = 1; } } printf("\n\tInitialize sd card"); SDCard_Init(); // mount SD for loading cfg's //this should have already been done by now in order to WBFS_Init(). printf("\n\tInitialize usb device"); USBDevice_Init(); // and mount USB:/ if (!bootDevice_found) { printf("\n\tSearch for configuration file"); //try USB //left in all the dol and elf files in this check in case this is the first time running the app and they dont have the config if (checkfile((char*) "USB:/config/GXglobal.cfg") || (checkfile((char*) "USB:/apps/usbloader_gx/boot.elf")) || checkfile((char*) "USB:/apps/usbloadergx/boot.dol") || (checkfile((char*) "USB:/apps/usbloadergx/boot.elf")) || checkfile((char*) "USB:/apps/usbloader_gx/boot.dol")) strcpy(bootDevice, "USB:"); printf("\n\tConfiguration file is on %s", bootDevice); } // Try opening and closing the configuration file here // to prevent a crash dump later on - giantpune char GXGlobal_cfg[26]; sprintf(GXGlobal_cfg, "%s/config/GXGlobal.cfg", bootDevice); FILE *fp = fopen(GXGlobal_cfg, "r"); if (fp) { fclose(fp); } gettextCleanUp(); printf("\n\tLoading configuration..."); CFG_Load(); printf("done"); // gprintf("\n\tbootDevice = %s",bootDevice); /* Load Custom IOS */ if ((Settings.cios == ios222 && IOS_GetVersion() != 222) || (Settings.cios == ios223 && IOS_GetVersion() != 223)) { printf("\n\tReloading IOS to config setting (%d)...", Settings.cios == ios222 ? 222 : 223); SDCard_deInit(); // unmount SD for reloading IOS USBDevice_deInit(); // unmount USB for reloading IOS USBStorage2_Deinit(); ret = IOS_ReloadIOSsafe(Settings.cios == ios222 ? 222 : 223); printf("%d", ret); SDCard_Init(); load_ehc_module(); if (ret < 0) { SDCard_deInit(); Settings.cios = ios249; ret = IOS_ReloadIOSsafe(249); // now mount SD:/ //no need to keep mindlessly mounting and unmounting SD card SDCard_Init(); } USBDevice_Init(); // and mount USB:/ WBFS_Init(WBFS_DEVICE_USB); } else if ((Settings.cios == ios249 && IOS_GetVersion() != 249) || (Settings.cios == ios250 && IOS_GetVersion() != 250)) { printf("\n\tReloading IOS to config setting (%d)...", ios249 ? 249 : 250); SDCard_deInit(); // unmount SD for reloading IOS USBDevice_deInit(); // unmount USB for reloading IOS USBStorage2_Deinit(); ret = IOS_ReloadIOSsafe(ios249 ? 249 : 250); printf("%d", ret); if (ret < 0) { Settings.cios = ios222; ret = IOS_ReloadIOSsafe(222); SDCard_Init(); load_ehc_module(); } else SDCard_Init(); // now mount SD:/ //no need to keep mindlessly mounting and unmounting SD card USBDevice_Init(); // and mount USB:/ WBFS_Init(WBFS_DEVICE_USB); } // Partition_GetList(&partitions); if (ret < 0) { printf("\nERROR: cIOS could not be loaded!"); sleep(5); exit(0); //SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); } //gprintf("\n\tcIOS = %u (Rev %u)",IOS_GetVersion(), IOS_GetRevision());//don't need gprintf if sending console shit to gecko, too printf("\n\tcIOS = %u (Rev %u)",IOS_GetVersion(), IOS_GetRevision()); // printf("Sleeping for 5 seconds\n"); // sleep(5); //if a ID was passed via args copy it and try to boot it after the partition is mounted //its not really a headless mode. more like hairless. if (argc > 1 && argv[1]) { if (strlen(argv[1])==6) strncpy(headlessID, argv[1], sizeof(headlessID)); } //! Init the rest of the System Sys_Init(); Wpad_Init(); if(!startupproblem) InitVideo(); InitAudio(); // Initialize audio WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR); WPAD_SetVRes(WPAD_CHAN_ALL, screenwidth, screenheight); // load main font from file, or default to built-in font fontSystem = new FreeTypeGX(); char *fontPath = NULL; asprintf(&fontPath, "%sfont.ttf", CFG.theme_path); fontSystem->loadFont(fontPath, font_ttf, font_ttf_size, 0); fontSystem->setCompatibilityMode(FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_PASSCLR | FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_NONE); free(fontPath); fontClock = new FreeTypeGX(); fontClock->loadFont(NULL, clock_ttf, clock_ttf_size, 0); fontClock->setCompatibilityMode(FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_PASSCLR | FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_NONE); gprintf("\n\tEnd of Main()"); InitGUIThreads(); MainMenu(MENU_CHECK); return 0; }
/** * Downloads the contents of a URL to memory * This method is not threadsafe (because networking is not threadsafe on the Wii) */ struct block downloadfile(const char *url) { int sslcontext = -1; //Check if the url starts with "http://", if not it is not considered a valid url if (strncmp(url, "http://", strlen("http://")) == 0) http_port = 80; else if(strncmp(url, "https://", strlen("https://")) == 0) { http_port = 443; gprintf("Initializing ssl...\n"); if(ssl_init() < 0) return emptyblock; } else return emptyblock; //Locate the path part of the url by searching for '/' past "http://" char *path = 0; if(http_port == 443) path = strchr(url + strlen("https://"), '/'); else path = strchr(url + strlen("http://"), '/'); //At the very least the url has to end with '/', ending with just a domain is invalid if (path == NULL) { //printf("URL '%s' has no PATH part\n", url); return emptyblock; } //Extract the domain part out of the url int domainlength = path - url - strlen("http://") - (http_port == 443 ? 1 : 0); if (domainlength == 0) { //printf("No domain part in URL '%s'\n", url); return emptyblock; } char domain[domainlength + 1]; strlcpy(domain, url + strlen("http://") + (http_port == 443 ? 1 : 0), domainlength + 1); //Parsing of the URL is done, start making an actual connection u32 ipaddress = getipbynamecached(domain); if (ipaddress == 0) { //printf("\ndomain %s could not be resolved", domain); return emptyblock; } s32 connection = tcp_connect(ipaddress, http_port); if (connection < 0) { //printf("Error establishing connection"); return emptyblock; } if(http_port == 443) { //patched out anyways so just to set something sslcontext = ssl_new((u8*)domain,0); if(sslcontext < 0) { //gprintf("ssl_new\n"); result = HTTPR_ERR_CONNECT; net_close (connection); return emptyblock; } //patched out anyways so just to set something ssl_setbuiltinclientcert(sslcontext,0); if(ssl_connect(sslcontext,connection) < 0) { //gprintf("ssl_connect\n"); result = HTTPR_ERR_CONNECT; ssl_shutdown(sslcontext); net_close (connection); return emptyblock; } int ret = ssl_handshake(sslcontext); if(ret < 0) { //gprintf("ssl_handshake %i\n", ret); result = HTTPR_ERR_STATUS; ssl_shutdown(sslcontext); net_close (connection); return emptyblock; } } // Remove Referer from the request header for incompatible websites (ex. Cloudflare proxy) char referer[domainlength + 12]; snprintf(referer, sizeof(referer), "Referer: %s\r\n", domain); if(strstr(url, "geckocodes")) { strcpy(referer, ""); } //Form a nice request header to send to the webserver char* headerformat = "GET %s HTTP/1.0\r\nHost: %s\r\n%sUser-Agent: USBLoaderGX r%s\r\n\r\n"; char header[strlen(headerformat) + strlen(path) + strlen(domain) + strlen(referer) + 100]; sprintf(header, headerformat, path, domain, referer, GetRev()); //gprintf("\nHTTP Request:\n"); //gprintf("%s\n",header); //Do the request and get the response tcp_write(http_port == 443 ? sslcontext : connection, header); read_header( http_port == 443 ? sslcontext : connection); if (http_status >= 400) // Not found { //gprintf("HTTP ERROR: %d\n", http_status); return emptyblock; } if(!content_length) content_length = 0; // create data buffer to return struct block response; response.data = malloc(content_length); response.size = content_length; if (response.data == NULL) { return emptyblock; } if (http_status == 200) { if(displayProgressWindow) { ProgressCancelEnable(true); StartProgress(tr("Downloading file..."), tr("Please wait"), 0, false, false); } int ret = tcp_readData(http_port == 443 ? sslcontext : connection, &response.data, content_length); if(!ret) { free(response.data); result = HTTPR_ERR_RECEIVE; if(http_port == 443) ssl_shutdown(sslcontext); net_close (connection); return emptyblock; } } else if (http_status == 302) // 302 FOUND (redirected link) { // close current connection if(http_port == 443) ssl_shutdown(sslcontext); net_close (connection); // prevent infinite loops retryloop++; if(retryloop > 3) { retryloop = 0; return emptyblock; } struct block redirected = downloadfile(content_location); if(redirected.size == 0) return emptyblock; // copy the newURL data into the original data u8 * tmp = realloc(response.data, redirected.size); if (tmp == NULL) { gprintf("Could not allocate enough memory for new URL. Download canceled.\n"); free(response.data); response.size = 0; free(redirected.data); result = HTTPR_ERR_RECEIVE; if(http_port == 443) ssl_shutdown(sslcontext); net_close (connection); return emptyblock; } response.data = tmp; memcpy(response.data, redirected.data, redirected.size); free(redirected.data); response.size = redirected.size; } retryloop = 0; // reset progress window if used if(displayProgressWindow) { ProgressStop(); ProgressCancelEnable(false); displayProgressWindow = false; } return response; }