usbloadergx/source/language/UpdateLanguage.cpp

167 lines
4.2 KiB
C++
Raw Permalink Normal View History

/****************************************************************************
* languagefile updater
* for USB Loader GX *giantpune*
* 2015 Cyan
***************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/dir.h>
#include "UpdateLanguage.h"
#include "gettext.h"
#include "FileOperations/fileops.h"
#include "FileOperations/DirList.h"
#include "menu.h"
#include "network/networkops.h"
#include "network/http.h"
#include "network/URL_List.h"
#include "prompts/PromptWindows.h"
#include "prompts/ProgressWindow.h"
#include "utils/ShowError.h"
#include "gecko.h"
#include "svnrev.h"
static const char * LanguageFilesURL = "http://svn.code.sf.net/p/usbloadergx/code/trunk/Languages/";
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;
gprintf("%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;
}
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();
USB Loader GX v3.0: Released on 2012 05 12 ATTENTION: USB Loader GX Version 3.0 introduces a new auto-update mechanism which is not compatible with old versions. (The old host is offline) If you are still using an old version of USB Loader GX, you need to update manually. Download the latest version or use our easy installer for Windows available on our website. http://code.google.com/p/usbloader-gui/downloads/list You can also check how to install or update manually here: http://code.google.com/p/usbloader-gui/wiki/Installation We are sorry for the inconvenience. New: - Added a new Layout: Channel grid mode! Channel grid displays games as channels and plays banner animations like the real Wii System Menu. Channel grid mode and banner animation requires AHBPROT flags to load resource files directly from your Wii. If you use an old HBC you should use our latest forwarder or update the HBC otherwise you wont have that support. - Added Channel launching from Emulated NAND. (big thanks to TriiForce guys and Miigotu) - Added GameCube games launching from SD Card through Dios Mios Lite (DML). (thanks to G0dLiKe, crediar, all DML devs and FIX94) Check DML website here http://code.google.com/p/dios-mios-lite-source-project/ - Added direct install/uninstall of WAD files to the Emulated NAND Channel path in the features settings menu. - Added a new icon in the toolbar to select the origin of the titles: Wii games, Channels from Wii, Channels from EmuNand, GameCube games. - Added the possibility to boot USB Loader GX without an HDD connected (It will fall back to "Channel from Wii" title's origin). - Added an option to choose which Game Window mode to use between the old "Rotating Disc" or the new "Banner Animation". - Added the favorite level setting to the game settings since it is no longer displayed when using "Banner Animation" game window mode. - Added an option to adjust the screen size for overscan TVs (Use negative values to shrink the display). - Added display of game's size from Wii disc games on the game window prompt (Rotating disc mode only). - Added a button in the search window to switch between "Beginning" and "Content" search methods. - Added auto-complete function to the search window. - Added a new GUI numpad for entering numbers. - Added setting for tooltip delay time. - Added resize of widescreen screenshots to 768px width. - Added cover download for the currently inserted disc. - Added delete of full cover on art work uninstall and game uninstall. - Added a parental control option to block priiloader override on return to system menu. - Added a prompt asking for downloading new language files when trying to update and no language files exist yet. - Added translation parsing for rating descriptors and for genres from wiitdb.xml. Requires a one time update of wiitdb.xml for cache rebuild. - Added a new option to force reading the game's titles from disc header. - Added renaming of internal TitleID of all HBC versions to JODI for GameTDB to find it. - Added a cheat update button to re-download the cheat text file. - Added a cancel button to several progress bar windows: Game installation, NAND extraction, etc. - Added separate path and setting for Emulated NAND Saves and Emulated NAND Channels. - Added per game NAND emulation path setting. - Added Mii extractor and SYSCONF file extractor to Emulated NAND. It always overwrites old files. - Added automatic Mii extraction on save game extract if the Mii file does not exist yet on Emulated NAND. - Added keep of AHBPROT flag on IOS Reload. Homebrews booted now have AHBPROT. (thanks to davebaol) - Added a new feature to force aspect ratio on games/channels. (thanks to giantpune for help with disassembler) - Added Zelda Skyward Sword Alternative dol offset (PAL and NTSC-U) for automatic dol selection. - Added detection of enabled cheat codes from an already created .gct file. - Added support for 2 USB drives for d2x cIOS (Requires d2x v9+). Changes: - Removed buggy focus system completely and added support to control screen pointer with analog sticks from respective controllers if the wiimote is not pointing to the screen. Compatible with Nunchuk, Classic Controller and GameCube controller. A speed factor is available in the GUI settings. - Restructured game's settings for different types of games (Wii/GC/Channels). - Added auto position of progress window messages in vertical direction depending of how many are used at the same time. - If "Titles from GameTDB" is not enabled the title will be read from the folder name if possible or from the game disc header. Title caching can still be used and is recommended in that case. - Settings title, keyboard text and key color can be changed by themes now. - Added optional background image for list/carousel/grid layouts (unused by default theme). - Use of old built-in font for credits window because it doesn't look good with the system menu one. - Removed the need of a cIOS to launch the loader (if anyone uses it with IOS58 for whatever reason). - Improved detection of game partition when starting the loader without configs (fresh start). - Isfs is now initiated once and deinitiated when cleaning up only, instead of the whole init/deinit every single access. - Updated file system libraries. - Removed pngu which is not needed, changed screenshot function to use libgd instead - added init of network into background thread so it is cancelable and has a timeout - changed wifi gecko to UDP socket - Converted all ogg sounds from 44.1 khz to 48 khz. - Optimized use of memory: Sizes over 30kb go to mem2 now first till it runs out ; Avoid use of mem2 area used on IOS_Reload (first 2 mb) ; Change font character texture to I4 which uses half as much memory (less cache memory). - Changed update function to get the files from googlecode website, since old update host website isn't accessible anymore. Fixes: - Fixed small scrollbar bug when having only 1 item. - Fixed reloading of cover image on game list when only 1 item is left after a change (e.g. filtering). - Improved calculation of progress speed. Now it is always the last 15 secs average instead of overall progress speed. - Fixed "new" game showing even with a parental control setting. - Fixed removing of unused cached titles on wiitdb load. - Fixed ocarina codes when using more than 255 codes (brawl+) (untested). - Fixed bug where entering "-1" (Use global) for cIOS was not possible in game settings. - Fixed playback of some BNS banner sounds. - Fixed reloading into another IOS before launch of game. - Removed buggy lz77 implementation and use the one known working. - Fixed launching of dollz compressed dol files. (thanks FIX94) - Fixed reading game's titles from disc header on fat32/ntfs/ext. - Fixed crash on missing <app> tag on meta.xml files. - Forwarder: Fixed crash on drives with physical sector size > 512 bytes. - Forwarder: Fixed endless waiting for slow HDD. (thanks to FIX94) - Forwarder: Added missing ext2 unmount. (thanks to FIX94) - Supports new WiiMotion+ controllers by using latest libraries. - Lots of string handling improvements (thanks to gerbilsoft for his patch) New Channel Grid Mode specific features: - New settings section for all banner's settings. - Use of BNR (banner animation) cache setting to load banners and icon's animation faster. (Enabled by default. Takes ~35MB/100 Banners) Wii games/Channels also accept ID3.bnr for custom-made multi-region banners. - BNR cache path setting. - Pulsing "new" icon on banner grid layout for new games. - Centering and size setting for banner's animation resources. - Channel's zooming speed setting. - Page's scrolling speed setting. New GameCube specific features: - Supports Dios Mios Lite (DML) v1.2+ - Uses of a custom banner for GameCube games which loads the game's internal opening.bnr informations (big thanks to diddy from the wiithemeteam for creating the brlyt/brlan for the banner). - DML settings editable from the loader (global and per game settings). - Supported formats for gamecubes are ISO/GCM and GCRegEx. - Custom game paths. The following paths are accepted: 1. configpath/ID6/ 2. configpath/ID6_Title/ 3. configpath/Title [ID6]/ 4. configpath/gamepath/ (slow loading speed) Accepted game's filenames: title.iso, title.gcm, GAMEID6.iso, GAMEID6.gcm - DML cheats now work the same way as for other Wii games, gct goes to "GCT Cheatcode Path" as GAMEID.gct - GameCube games copy from USB to SD on demand with choice menu to delete SD games to make space, If you want to use this feature then set the "Main GC path" to USB and the "SD GameCube path" to SD card. If duplicated games are detected on SD and USB, the games on SD will be prioritized. - Added GameCube disc dump functionality with multi-disc menu game selection, compress and align support (thanks to FIX94 and Overjoy for their disc dump sources on which this is based). - Use of the BNR cache path to load ID6.bnr or ID3.bnr if available for custom-made banners. (Loading only) - Video mode option to force interlace mode on GameCube. - Fixed force prog mode on DML 1.4
2012-05-12 11:10:37 +02:00
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;
}