mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-11-05 11:05:06 +01:00
070b77548a
Changelog since last revision: - add banner/icon animation support for wii games / channels / gamecube - add custom banner for gamecube which loads the gamecube internal opening.bnr information (it is much better than the generic one of the system menu) (big thanks to diddy from the wiithemeteam for creating the brlyt/brlan for the banner) - add gamecube banner of system menu (not used right now since it sucks) - add banner grid of the system menu (resources loaded from nand) (with button highliter) - add big banner frame window of the system menu (resources loaded from nand). the banner window has buttons "Settings" and "Start" by default. if parental control is enabled the "Settings" button is replaced by "Back" - add play count text to the banner frame window (can be disabled as up until now in the gui settings) - add zoom in/out/scroll animations to banner grid and change into big frame window - add loading gc banners from ISO and DVD - add loading wii banners from DVD discs even if the game is not installed - add favorite level setting to the game settings since it is no longer on the banner frame window - add new settings section for banner settings - add option to choose between disc window and banner window - added back ehci module to support 2 usb drives and re-enabled the option - add option for 2 usb drives for d2x cIOS as well (will be supported in the future, not yet) - exchanged "GC Games" and "EmuNand Channels" on the game selection screen (more space for translators) - add and fixed gui numpad for entering numbers of any kind - add setting for tooltip delay time - fix reload of cover image on game list when only 1 item is left after a change (e.g. sort) - add use of old build in font for credits window because it doesnt look good with the system menu one - fixed effect bug when scrolling buttons in the settings and the wiimote is over button 1 - fixed bug where entering -1 (Use global) for cIOS was not possible in game settings - many source cleanups - add bnr chace setting - add DML configuration from the loader - removed creation of temporary "boot.bin" file - DML custom game paths. Additionally i added support for following forms of paths: 1. configpath/gamepath/game.iso 2. configpath/gamepath/game.gcm 3. configpath/gamepath/GAMEID6.iso 4. configpath/gamepath/GAMEID6.gcm Where gamepath can be anything you want inside the configure path in the custom path settings. I don't know if GCM files are allowed by DML but i just added support for it just in case. Changing path to USB is not blocked currently but games won't run from USB just keep that in mind. The "copy to SD before start" feature is not added yet. Listing the games should work though - DML cheats now work the same way as for wii, gct goes to "Cheatcode Path" as GAMEID.gct (same as on wii) - several DML internal configs are added as per game/global settings - added load of last cheat configuration from GCT files - added init of network into background thread so it is cancelable and has a timeout - added gc games copy from USB to SD on demand with choice menu to delete SD games to make space, SD games path can be chosen seperately from main gc path. all dupicate sd games are prefered then the main path to allow direct boot of games that are already on sd. main path can be on USB or anywhere else. - added gc disc dump functionality with multidisc, compress and align support (thanks to FIX94 and Overjoy for their disc dump source on which this is based) - added selection menu for gc multidisc which game to install - fixed loading game ID when it can't be read from path for GC games and with that loading the titles from GameTDB for them - lots of string handling improvements (thanks to gerbilsoft for his patch) - added gamecube banner cache loading (only loading) if available with GAMEID6.bnr or ID3.bnr in the banner cache path. wii games/channels also accept now ID3.bnr. - added several progress bar cancel buttons on some missing progress windows - improved calculation of progress speed. now it is always the last 15 secs average instead of overall progress speed. - added pulsing new icon on banner grid layout for new games - added resize of widescreen screenshots to 768 width - added mii extract on save game extract if the file does not yet exists - added mii extractor and SYSCONF extractor that always extracts and overwrites old files - changed wifi gecko to UDP socket - support for DML v1.2+ NOTE: Banner animation support requires AHBPROT flag to be enabled. If you use old HBC you should use our forwarder or update the HBC otherwise you wont have that support. I am hoping that now the themers and the translators can catch up with their stuff for the next upcomming official release.
266 lines
7.2 KiB
C++
266 lines
7.2 KiB
C++
#include <unistd.h>
|
|
#include "menus.h"
|
|
#include "GameCube/GCGames.h"
|
|
#include "GameCube/GCDumper.hpp"
|
|
#include "usbloader/usbstorage2.h"
|
|
#include "usbloader/wbfs.h"
|
|
#include "usbloader/disc.h"
|
|
#include "usbloader/GameList.h"
|
|
#include "prompts/ProgressWindow.h"
|
|
#include "prompts/GCMultiDiscMenu.h"
|
|
#include "themes/CTheme.h"
|
|
#include "utils/tools.h"
|
|
|
|
#define WII_MAGIC 0x5D1C9EA3
|
|
|
|
extern int install_abort_signal;
|
|
float gamesize = 0.0f;
|
|
|
|
/****************************************************************************
|
|
* MenuGCInstall
|
|
***************************************************************************/
|
|
int MenuGCInstall()
|
|
{
|
|
GCDumper gcDumper;
|
|
if(gcDumper.ReadDiscHeader() < 0)
|
|
{
|
|
WindowPrompt(tr("Error"), tr("Error reading disc"), tr("OK"));
|
|
return MENU_DISCLIST;
|
|
}
|
|
|
|
std::vector<u32> installGames;
|
|
|
|
if(gcDumper.GetDiscHeaders().size() == 0)
|
|
{
|
|
WindowPrompt(tr("Error"), tr("No games found on the disc"), tr("OK"));
|
|
return MENU_DISCLIST;
|
|
}
|
|
else if(gcDumper.GetDiscHeaders().size() > 1)
|
|
{
|
|
//! Multi game disc, lets ask the user which games to install
|
|
GCMultiDiscMenu gcMenu(gcDumper.GetDiscHeaders());
|
|
gcMenu.SetAlignment(ALIGN_CENTER, ALIGN_MIDDLE);
|
|
gcMenu.SetEffect(EFFECT_FADE, 20);
|
|
mainWindow->SetState(STATE_DISABLED);
|
|
mainWindow->Append(&gcMenu);
|
|
|
|
int choice = gcMenu.ShowSelection();
|
|
|
|
gcMenu.SetEffect(EFFECT_FADE, -20);
|
|
while(gcMenu.GetEffect() > 0) usleep(1000);
|
|
|
|
mainWindow->Remove(&gcMenu);
|
|
mainWindow->SetState(STATE_DEFAULT);
|
|
|
|
installGames = gcMenu.GetSelectedGames();
|
|
|
|
if(choice == 0 || installGames.size() == 0)
|
|
return MENU_DISCLIST;
|
|
}
|
|
else
|
|
{
|
|
if(!WindowPrompt(tr( "Continue to install game?" ), gcDumper.GetDiscHeaders().at(0).title, tr("Yes"), tr( "Cancel" )))
|
|
return MENU_DISCLIST;
|
|
|
|
installGames.push_back(0);
|
|
}
|
|
|
|
//! setup dumper settings
|
|
gcDumper.SetCompressed(Settings.GCInstallCompressed);
|
|
gcDumper.SetCompressed(Settings.GCInstallAligned);
|
|
|
|
//! If a different main path then the SD path is selected ask where to install
|
|
int destination = 1;
|
|
if(strcmp(Settings.GameCubePath, Settings.GameCubeSDPath) != 0)
|
|
destination = WindowPrompt(tr("Where should the game be installed to?"), 0, tr("Main Path"), tr("SD Path"), tr("Cancel"));
|
|
if(!destination)
|
|
return MENU_DISCLIST;
|
|
|
|
const char *InstallPath = destination == 1 ? Settings.GameCubePath : Settings.GameCubeSDPath;
|
|
|
|
//! Start of install process, enable wii slot light
|
|
wiilight(1);
|
|
|
|
int result = 0;
|
|
int installed_games = 0;
|
|
|
|
for(u32 i = 0; i < installGames.size(); ++i)
|
|
{
|
|
//! check if the game is already installed on SD/USB
|
|
if(GCGames::Instance()->IsInstalled((char *)gcDumper.GetDiscHeaders().at(installGames[i]).id))
|
|
{
|
|
WindowPrompt(tr("Game is already installed:"), gcDumper.GetDiscHeaders().at(installGames[i]).title, tr("OK"));
|
|
if(i+1 < installGames.size()) {
|
|
continue;
|
|
}
|
|
else if(i == 0)
|
|
{
|
|
result = MENU_DISCLIST;
|
|
break;
|
|
}
|
|
}
|
|
|
|
// game is not yet installed so let's install it
|
|
int ret = gcDumper.InstallGame(InstallPath, installGames[i]);
|
|
if(ret >= 0) {
|
|
//! success
|
|
installed_games++;
|
|
}
|
|
else if(ret == PROGRESS_CANCELED)
|
|
{
|
|
result = MENU_DISCLIST;
|
|
break;
|
|
}
|
|
else if(ret < 0)
|
|
{
|
|
//! Error occured, ask the user what to do if there are more games to install
|
|
if(i+1 < installGames.size())
|
|
{
|
|
if(!WindowPrompt(tr( "Install Error!" ), tr("Do you want to continue with next game?"), tr("Yes"), tr( "Cancel" )))
|
|
{
|
|
result = MENU_DISCLIST;
|
|
break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
WindowPrompt(tr( "Install Error!" ), 0, tr( "Back" ));
|
|
result = MENU_DISCLIST;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
wiilight(0);
|
|
GCGames::Instance()->LoadAllGames();
|
|
|
|
//! no game was installed so don't show successfully installed prompt
|
|
if(installed_games == 0)
|
|
return result;
|
|
|
|
bgMusic->Pause();
|
|
GuiSound instsuccess(Resources::GetFile("success.ogg"), Resources::GetFileSize("success.ogg"), Settings.sfxvolume);
|
|
instsuccess.SetVolume(Settings.sfxvolume);
|
|
instsuccess.SetLoop(0);
|
|
instsuccess.Play();
|
|
char gamesTxt[20];
|
|
snprintf(gamesTxt, sizeof(gamesTxt), "%i %s", installed_games, tr("Games"));
|
|
WindowPrompt(tr("Successfully installed:"), installGames.size() > 1 ? gamesTxt : gcDumper.GetDiscHeaders().at(installGames[0]).title, tr( "OK" ));
|
|
instsuccess.Stop();
|
|
bgMusic->Resume();
|
|
|
|
return MENU_DISCLIST;
|
|
}
|
|
|
|
/****************************************************************************
|
|
* MenuInstall
|
|
***************************************************************************/
|
|
int MenuInstall()
|
|
{
|
|
gprintf("\nMenuInstall()\n");
|
|
|
|
static struct discHdr headerdisc ATTRIBUTE_ALIGN( 32 );
|
|
|
|
Disc_SetUSB(NULL);
|
|
|
|
int ret, choice = 0;
|
|
|
|
ret = DiscWait(tr( "Insert Disk" ), tr( "Waiting..." ), tr( "Cancel" ), 0, 0);
|
|
if (ret < 0)
|
|
{
|
|
WindowPrompt(tr( "Error reading Disc" ), 0, tr( "Back" ));
|
|
return MENU_DISCLIST;
|
|
}
|
|
ret = Disc_Open();
|
|
if (ret < 0)
|
|
{
|
|
WindowPrompt(tr( "Could not open Disc" ), 0, tr( "Back" ));
|
|
return MENU_DISCLIST;
|
|
}
|
|
|
|
memset(&headerdisc, 0, sizeof(struct discHdr));
|
|
|
|
Disc_ReadHeader(&headerdisc);
|
|
|
|
if ((headerdisc.magic != WII_MAGIC) && (headerdisc.gc_magic != GCGames::MAGIC))
|
|
{
|
|
choice = WindowPrompt(tr( "Not a Wii or a Game Cube Disc" ), tr( "Insert a Wii or a Game Cube Disc!" ), tr( "OK" ), tr( "Back" ));
|
|
if (choice == 1)
|
|
return MenuInstall();
|
|
else
|
|
return MENU_DISCLIST;
|
|
}
|
|
|
|
if(headerdisc.gc_magic == GCGames::MAGIC)
|
|
{
|
|
return MenuGCInstall();
|
|
}
|
|
|
|
ret = WBFS_CheckGame(headerdisc.id);
|
|
if (ret)
|
|
{
|
|
WindowPrompt(tr( "Game is already installed:" ), headerdisc.title, tr( "Back" ));
|
|
return MENU_DISCLIST;
|
|
}
|
|
|
|
f32 freespace, used;
|
|
|
|
WBFS_DiskSpace(&used, &freespace);
|
|
gamesize = (float) WBFS_EstimeGameSize();
|
|
|
|
char gametxt[strlen(headerdisc.title) + 16];
|
|
snprintf(gametxt, sizeof(gametxt), "%s : %.2fGB", headerdisc.title, gamesize/GB_SIZE);
|
|
|
|
wiilight(1);
|
|
choice = WindowPrompt(tr( "Continue to install game?" ), gametxt, tr( "OK" ), tr( "Cancel" ));
|
|
|
|
if (choice == 1)
|
|
{
|
|
sprintf(gametxt, "%s", tr( "Installing game:" ));
|
|
|
|
if (gamesize/GB_SIZE > freespace)
|
|
{
|
|
char errortxt[50];
|
|
sprintf(errortxt, "%s: %.2fGB, %s: %.2fGB", tr( "Game Size" ), gamesize/GB_SIZE, tr( "Free Space" ), freespace);
|
|
WindowPrompt(tr( "Not enough free space!" ), errortxt, tr( "OK" ));
|
|
}
|
|
else
|
|
{
|
|
StartProgress(gametxt, headerdisc.title, 0, true, true);
|
|
ProgressCancelEnable(true);
|
|
ret = WBFS_AddGame();
|
|
ProgressCancelEnable(false);
|
|
ProgressStop();
|
|
wiilight(0);
|
|
if (install_abort_signal)
|
|
{
|
|
WindowPrompt(tr( "Install Canceled" ), 0, tr( "OK" ));
|
|
}
|
|
else if (ret != 0)
|
|
{
|
|
WindowPrompt(tr( "Install Error!" ), 0, tr( "Back" ));
|
|
}
|
|
else
|
|
{
|
|
ShowProgress(tr("Install finished"), headerdisc.title, tr("Reloading game list now, please wait..."), gamesize, gamesize, true, true);
|
|
gameList.ReadGameList(); //get the entries again
|
|
gameList.FilterList();
|
|
bgMusic->Pause();
|
|
GuiSound instsuccess(Resources::GetFile("success.ogg"), Resources::GetFileSize("success.ogg"), Settings.sfxvolume);
|
|
instsuccess.SetVolume(Settings.sfxvolume);
|
|
instsuccess.SetLoop(0);
|
|
instsuccess.Play();
|
|
WindowPrompt(tr( "Successfully installed:" ), headerdisc.title, tr( "OK" ));
|
|
instsuccess.Stop();
|
|
bgMusic->Resume();
|
|
}
|
|
}
|
|
}
|
|
|
|
//Turn off the WiiLight
|
|
wiilight(0);
|
|
gamesize = 0.0f;
|
|
|
|
return MENU_DISCLIST;
|
|
}
|