usbloadergx/source/settings/menus/GameLoadSM.cpp
dimok789 070b77548a OK since the Wii System Menu Player is released now as I already mentioned the source for the loader will also be put on SVN again. Now that i am done with merging here is the MOD17 source.
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.
2012-05-06 10:59:58 +00:00

595 lines
16 KiB
C++

/****************************************************************************
* Copyright (C) 2010
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
***************************************************************************/
#include <unistd.h>
#include <gccore.h>
#include "settings/CSettings.h"
#include "settings/CGameStatistics.h"
#include "themes/CTheme.h"
#include "prompts/PromptWindows.h"
#include "prompts/DiscBrowser.h"
#include "prompts/filebrowser.h"
#include "usbloader/AlternateDOLOffsets.h"
#include "language/gettext.h"
#include "wad/nandtitle.h"
#include "system/IosLoader.h"
#include "GameLoadSM.hpp"
static const char * OnOffText[] =
{
trNOOP( "OFF" ),
trNOOP( "ON" ),
trNOOP( "Auto" )
};
static const char * VideoModeText[] =
{
trNOOP( "System Default" ),
trNOOP( "Disc Default" ),
trNOOP( "Force PAL50" ),
trNOOP( "Force PAL60" ),
trNOOP( "Force NTSC" ),
trNOOP( "Region Patch" ),
trNOOP( "Force PAL480p" ),
trNOOP( "Force NTSC480p" ),
};
static const char * AspectText[] =
{
trNOOP( "Force 4:3" ),
trNOOP( "Force 16:9" ),
trNOOP( "System Default" )
};
static const char * LanguageText[] =
{
trNOOP( "Japanese" ),
trNOOP( "English" ),
trNOOP( "German" ),
trNOOP( "French" ),
trNOOP( "Spanish" ),
trNOOP( "Italian" ),
trNOOP( "Dutch" ),
trNOOP( "SChinese" ),
trNOOP( "TChinese" ),
trNOOP( "Korean" ),
trNOOP( "Console Default" ),
};
static const char * Error002Text[] =
{
trNOOP( "No" ),
trNOOP( "Yes" ),
trNOOP( "Anti" )
};
static const char * ParentalText[] =
{
trNOOP( "0 (Everyone)" ),
trNOOP( "1 (Child 7+)" ),
trNOOP( "2 (Teen 12+)" ),
trNOOP( "3 (Mature 16+)" ),
trNOOP( "4 (Adults Only 18+)" )
};
static const char * AlternateDOLText[] =
{
trNOOP( "OFF" ),
trNOOP( "Select a DOL from Game" ),
trNOOP( "Load From SD/USB" ),
trNOOP( "List on Gamelaunch" ),
trNOOP( "Default" ),
};
static const char * NandEmuText[] =
{
trNOOP( "OFF" ),
trNOOP( "Partial" ),
trNOOP( "Full" )
};
static const char * HooktypeText[] =
{
trNOOP( "None" ),
trNOOP( "VBI (Default)" ),
trNOOP( "KPAD Read" ),
trNOOP( "Joypad" ),
trNOOP( "GXDraw" ),
trNOOP( "GXFlush" ),
trNOOP( "OSSleepThread" ),
trNOOP( "AXNextFrame" ),
};
GameLoadSM::GameLoadSM(struct discHdr *hdr)
: SettingsMenu(tr("Game Load"), &GuiOptions, MENU_NONE),
Header(hdr)
{
GameConfig = *GameSettings.GetGameCFG((const char *) Header->id);
if(!btnOutline)
btnOutline = Resources::GetImageData("button_dialogue_box.png");
if(!trigA)
trigA = new GuiTrigger();
trigA->SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
saveBtnTxt = new GuiText(tr( "Save" ), 22, thColor("r=0 g=0 b=0 a=255 - prompt windows button text color"));
saveBtnTxt->SetMaxWidth(btnOutline->GetWidth() - 30);
saveBtnImg = new GuiImage (btnOutline);
if (Settings.wsprompt == ON)
{
saveBtnTxt->SetWidescreen(Settings.widescreen);
saveBtnImg->SetWidescreen(Settings.widescreen);
}
saveBtn = new GuiButton(saveBtnImg, saveBtnImg, 2, 3, 180, 400, trigA, btnSoundOver, btnSoundClick2, 1);
saveBtn->SetLabel(saveBtnTxt);
Append(saveBtn);
SetOptionNames();
SetOptionValues();
}
GameLoadSM::~GameLoadSM()
{
HaltGui();
//! The rest is destroyed in SettingsMenu.cpp
Remove(saveBtn);
delete saveBtnTxt;
delete saveBtnImg;
delete saveBtn;
ResumeGui();
}
void GameLoadSM::SetDefaultConfig()
{
char id[7];
snprintf(id, sizeof(id), GameConfig.id);
GameSettings.SetDefault(GameConfig);
snprintf(GameConfig.id, sizeof(GameConfig.id), id);
}
void GameLoadSM::SetOptionNames()
{
int Idx = 0;
Options->SetName(Idx++, "%s", tr( "Game Lock" ));
Options->SetName(Idx++, "%s", tr( "Favorite Level" ));
Options->SetName(Idx++, "%s", tr( "Video Mode" ));
Options->SetName(Idx++, "%s", tr( "VIDTV Patch" ));
Options->SetName(Idx++, "%s", tr( "Sneek Video Patch" ));
Options->SetName(Idx++, "%s", tr( "Aspect Ratio" ));
Options->SetName(Idx++, "%s", tr( "Patch Country Strings" ));
Options->SetName(Idx++, "%s", tr( "Game Language" ));
Options->SetName(Idx++, "%s", tr( "Ocarina" ));
Options->SetName(Idx++, "%s", tr( "Parental Control" ));
Options->SetName(Idx++, "%s", tr( "Hooktype" ));
Options->SetName(Idx++, "%s", tr( "Wiird Debugger" ));
Options->SetName(Idx++, "%s", tr( "Game IOS" ));
Options->SetName(Idx++, "%s", tr( "Error 002 fix" ));
Options->SetName(Idx++, "%s", tr( "Return To" ));
Options->SetName(Idx++, "%s", tr( "Block IOS Reload" ));
//! Only wii games and emu nand channels
if( Header->type == TYPE_GAME_WII_IMG
|| Header->type == TYPE_GAME_WII_DISC
|| Header->type == TYPE_GAME_EMUNANDCHAN)
{
Options->SetName(Idx++, "%s", tr( "Nand Emulation" ));
Options->SetName(Idx++, "%s", tr( "Nand Emu Path" ));
}
//! Only on Wii games
if(Header->type == TYPE_GAME_WII_IMG || Header->type == TYPE_GAME_WII_DISC)
{
Options->SetName(Idx++, "%s", tr( "Alternate DOL" ));
Options->SetName(Idx++, "%s", tr( "Select DOL Offset" ));
}
}
void GameLoadSM::SetOptionValues()
{
int Idx = 0;
//! Settings: Game Lock
Options->SetValue(Idx++, "%s", tr( OnOffText[GameConfig.Locked] ));
//! Settings: Favorite Level
Options->SetValue(Idx++, "%i", GameStatistics.GetFavoriteRank(Header->id));
//! Settings: Video Mode
if(GameConfig.video == INHERIT)
Options->SetValue(Idx++, tr("Use global"));
else
Options->SetValue(Idx++, "%s", tr(VideoModeText[GameConfig.video]));
//! Settings: VIDTV Patch
if(GameConfig.vipatch == INHERIT)
Options->SetValue(Idx++, tr("Use global"));
else
Options->SetValue(Idx++, "%s", tr(OnOffText[GameConfig.vipatch]));
//! Settings: Sneek Video Patch
if(GameConfig.sneekVideoPatch == INHERIT)
Options->SetValue(Idx++, tr("Use global"));
else
Options->SetValue(Idx++, "%s", tr(OnOffText[GameConfig.sneekVideoPatch]));
//! Settings: Aspect Ratio
if(GameConfig.aspectratio == INHERIT)
Options->SetValue(Idx++, tr("Use global"));
else
Options->SetValue(Idx++, "%s", tr(AspectText[GameConfig.aspectratio]));
//! Settings: Patch Country Strings
if(GameConfig.patchcountrystrings == INHERIT)
Options->SetValue(Idx++, tr("Use global"));
else
Options->SetValue(Idx++, "%s", tr(OnOffText[GameConfig.patchcountrystrings]));
//! Settings: Game Language
if(GameConfig.language == INHERIT)
Options->SetValue(Idx++, tr("Use global"));
else
Options->SetValue(Idx++, "%s", tr(LanguageText[GameConfig.language]));
//! Settings: Ocarina
if(GameConfig.ocarina == INHERIT)
Options->SetValue(Idx++, tr("Use global"));
else
Options->SetValue(Idx++, "%s", tr(OnOffText[GameConfig.ocarina]));
//! Settings: Parental Control
Options->SetValue(Idx++, "%s", tr(ParentalText[GameConfig.parentalcontrol]));
//! Settings: Hooktype
if(GameConfig.Hooktype == INHERIT)
Options->SetValue(Idx++, tr("Use global"));
else
Options->SetValue(Idx++, "%s", tr( HooktypeText[GameConfig.Hooktype] ));
//! Settings: Wiird Debugger
if(GameConfig.WiirdDebugger == INHERIT)
Options->SetValue(Idx++, tr("Use global"));
else
Options->SetValue(Idx++, "%s", tr( OnOffText[GameConfig.WiirdDebugger] ));
//! Settings: Game IOS
if(GameConfig.ios == INHERIT)
Options->SetValue(Idx++, tr("Use global"));
else
Options->SetValue(Idx++, "%i", GameConfig.ios);
//! Settings: Error 002 fix
if(GameConfig.errorfix002 == INHERIT)
Options->SetValue(Idx++, tr("Use global"));
else
Options->SetValue(Idx++, "%s", tr(Error002Text[GameConfig.errorfix002]));
//! Settings: Return To
if(GameConfig.returnTo)
{
const char* TitleName = NULL;
u64 tid = NandTitles.FindU32(Settings.returnTo);
if (tid > 0)
TitleName = NandTitles.NameOf(tid);
Options->SetValue(Idx++, "%s", TitleName ? TitleName : strlen(Settings.returnTo) > 0 ?
Settings.returnTo : tr( OnOffText[0] ));
}
else
{
Options->SetValue(Idx++, "%s", tr( OnOffText[0] ));
}
//! Settings: Block IOS Reload
if(GameConfig.iosreloadblock == INHERIT)
Options->SetValue(Idx++, tr("Use global"));
else
Options->SetValue(Idx++, "%s", tr( OnOffText[GameConfig.iosreloadblock]) );
//! Only wii games and emu nand channels
if( Header->type == TYPE_GAME_WII_IMG
|| Header->type == TYPE_GAME_WII_DISC
|| Header->type == TYPE_GAME_EMUNANDCHAN)
{
//! Settings: Nand Emulation
if(GameConfig.NandEmuMode == INHERIT)
Options->SetValue(Idx++, tr("Use global"));
else
Options->SetValue(Idx++, "%s", tr( NandEmuText[GameConfig.NandEmuMode] ));
//! Settings: Nand Emu Path
if(GameConfig.NandEmuPath.size() == 0)
Options->SetValue(Idx++, tr("Use global"));
else
Options->SetValue(Idx++, "%s", GameConfig.NandEmuPath.c_str());
}
//! Only on Wii games
if(Header->type == TYPE_GAME_WII_IMG || Header->type == TYPE_GAME_WII_DISC)
{
//! Settings: Alternate DOL
Options->SetValue(Idx++, "%s", tr( AlternateDOLText[GameConfig.loadalternatedol] ));
//! Settings: Select DOL Offset
if(GameConfig.loadalternatedol != 1)
Options->SetValue(Idx++, tr("Not required"));
else
{
if(GameConfig.alternatedolname.size() != 0)
Options->SetValue(Idx++, "%i <%s>", GameConfig.alternatedolstart, GameConfig.alternatedolname.c_str());
else
Options->SetValue(Idx++, "%i", GameConfig.alternatedolstart);
}
}
}
int GameLoadSM::GetMenuInternal()
{
if (saveBtn->GetState() == STATE_CLICKED)
{
if (GameSettings.AddGame(GameConfig) && GameSettings.Save())
{
WindowPrompt(tr( "Successfully Saved" ), 0, tr( "OK" ));
}
else
WindowPrompt(tr( "Save Failed. No device inserted?" ), 0, tr( "OK" ));
saveBtn->ResetState();
}
int ret = optionBrowser->GetClickedOption();
if (ret < 0)
return MENU_NONE;
int Idx = -1;
//! Settings: Game Lock
if (ret == ++Idx)
{
if (++GameConfig.Locked >= MAX_ON_OFF) GameConfig.Locked = 0;
}
//! Settings: Favorite Level
else if (ret == ++Idx)
{
int Level = GameStatistics.GetFavoriteRank(Header->id);
if (++Level > 5) Level = 0;
GameStatistics.SetFavoriteRank(Header->id, Level);
GameStatistics.Save();
}
//! Settings: Video Mode
else if (ret == ++Idx)
{
if (++GameConfig.video >= VIDEO_MODE_MAX) GameConfig.video = INHERIT;
}
//! Settings: VIDTV Patch
if (ret == ++Idx)
{
if (++GameConfig.vipatch >= MAX_ON_OFF) GameConfig.vipatch = INHERIT;
}
//! Settings: Sneek Video Patch
else if (ret == ++Idx)
{
if (++GameConfig.sneekVideoPatch >= MAX_ON_OFF) GameConfig.sneekVideoPatch = INHERIT;
}
//! Settings: Aspect Ratio
else if (ret == ++Idx)
{
if (++GameConfig.aspectratio >= ASPECT_MAX) GameConfig.aspectratio = INHERIT;
}
//! Settings: Patch Country Strings
if (ret == ++Idx)
{
if (++GameConfig.patchcountrystrings >= MAX_ON_OFF) GameConfig.patchcountrystrings = INHERIT;
}
//! Settings: Game Language
if (ret == ++Idx)
{
if (++GameConfig.language >= MAX_LANGUAGE) GameConfig.language = INHERIT;
}
//! Settings: Ocarina
else if (ret == ++Idx)
{
if (++GameConfig.ocarina >= MAX_ON_OFF) GameConfig.ocarina = INHERIT;
}
//! Settings: Parental Control
else if (ret == ++Idx)
{
if (++GameConfig.parentalcontrol >= 5) GameConfig.parentalcontrol = 0;
}
//! Settings: Hooktype
if (ret == ++Idx)
{
if (++GameConfig.Hooktype >= 8) GameConfig.Hooktype = INHERIT;
}
//! Settings: Wiird Debugger
else if (ret == ++Idx)
{
if (++GameConfig.WiirdDebugger >= MAX_ON_OFF) GameConfig.WiirdDebugger = INHERIT;
}
//! Settings: Game IOS
else if (ret == ++Idx)
{
char entered[4];
snprintf(entered, sizeof(entered), "%i", GameConfig.ios);
if(OnScreenNumpad(entered, sizeof(entered)))
{
int newIOS = atoi(entered);
if(newIOS != INHERIT && (newIOS < 200 || newIOS > 255)) {
WindowPrompt(tr("Error:"), tr("Invalid IOS number entered. Number must be -1 for inherit or 200 - 255."), tr("OK"));
}
else
{
GameConfig.ios = newIOS;
if(GameConfig.ios != INHERIT && NandTitles.IndexOf(TITLE_ID(1, GameConfig.ios)) < 0)
{
WindowPrompt(tr("Warning:"), tr("This IOS was not found on the titles list. If you are sure you have it installed than ignore this warning."), tr("OK"));
}
else if(GameConfig.ios == 254)
{
WindowPrompt(tr("Warning:"), tr("This IOS is the BootMii ios. If you are sure it is not BootMii and you have something else installed there than ignore this warning."), tr("OK"));
}
}
}
}
//! Settings: Error 002 fix
else if (ret == ++Idx)
{
if (++GameConfig.errorfix002 >= 3) GameConfig.errorfix002 = INHERIT;
}
//! Settings: Return To
else if (ret == ++Idx)
{
if (++GameConfig.returnTo >= MAX_ON_OFF) GameConfig.returnTo = 0;
}
//! Settings: Block IOS Reload
if (ret == ++Idx)
{
if(++GameConfig.iosreloadblock >= 3) GameConfig.iosreloadblock = INHERIT;
}
//! Only wii games and emu nand channels
if( Header->type == TYPE_GAME_WII_IMG
|| Header->type == TYPE_GAME_WII_DISC
|| Header->type == TYPE_GAME_EMUNANDCHAN)
{
//! Settings: Nand Emulation
if (ret == ++Idx)
{
if(!IosLoader::IsD2X())
WindowPrompt(tr("Error:"), tr("Nand Emulation is only available on D2X cIOS!"), tr("OK"));
else if (++GameConfig.NandEmuMode >= 3) GameConfig.NandEmuMode = INHERIT;
//! On titles from emulated nand path disabling the nand emu mode is not allowed
if(Header->type == TYPE_GAME_EMUNANDCHAN && GameConfig.NandEmuMode == OFF)
GameConfig.NandEmuMode = 1;
}
//! Settings: Nand Emu Path
else if (ret == ++Idx)
{
if(!IosLoader::IsD2X())
WindowPrompt(tr("Error:"), tr("Nand Emulation is only available on D2X cIOS!"), tr("OK"));
else
{
char entered[300];
snprintf(entered, sizeof(entered), GameConfig.NandEmuPath.c_str());
HaltGui();
GuiWindow * parent = (GuiWindow *) parentElement;
if(parent) parent->SetState(STATE_DISABLED);
this->SetState(STATE_DEFAULT);
this->Remove(optionBrowser);
ResumeGui();
int result = BrowseDevice(entered, sizeof(entered), FB_DEFAULT, noFILES);
if(parent) parent->SetState(STATE_DEFAULT);
this->Append(optionBrowser);
if (result == 1)
{
if (entered[strlen(entered)-1] != '/')
strcat(entered, "/");
GameConfig.NandEmuPath = entered;
WindowPrompt(tr( "Path Changed" ), 0, tr( "OK" ));
}
}
}
}
//! Only on Wii games
if(Header->type == TYPE_GAME_WII_IMG || Header->type == TYPE_GAME_WII_DISC)
{
//! Settings: Alternate DOL
if (ret == ++Idx)
{
if (++GameConfig.loadalternatedol >= ALT_DOL_MAX_CHOICE)
GameConfig.loadalternatedol = 0;
}
//! Settings: Select DOL Offset from Game
else if ( (ret == ++Idx)
&& (GameConfig.loadalternatedol == 1))
{
GuiWindow * parentWindow = (GuiWindow *) parentElement;
if(parentWindow) parentWindow->SetState(STATE_DISABLED);
//alt dol menu for games that require more than a single alt dol
int autodol = autoSelectDolPrompt((char *) GameConfig.id);
if(autodol == 0)
{
if(parentWindow) parentWindow->SetState(STATE_DEFAULT);
return MENU_NONE; //Cancel Button pressed
}
char tmp[170];
if (autodol > 0)
{
GameConfig.alternatedolstart = autodol;
snprintf(tmp, sizeof(tmp), "%s <%i>", tr( "AUTO" ), autodol);
GameConfig.alternatedolname = tmp;
SetOptionValues();
if(parentWindow) parentWindow->SetState(STATE_DEFAULT);
return MENU_NONE;
}
int res = DiscBrowse(GameConfig.id, tmp, sizeof(tmp));
if (res >= 0)
{
GameConfig.alternatedolname = tmp;
GameConfig.alternatedolstart = res;
snprintf(tmp, sizeof(tmp), "%s %.6s - %i", tr( "It seems that you have some information that will be helpful to us. Please pass this information along to the DEV team." ), (char *) GameConfig.id, GameConfig.alternatedolstart);
WindowPrompt(0, tmp, tr( "OK" ));
}
if(GameConfig.alternatedolstart == 0)
GameConfig.loadalternatedol = 0;
if(parentWindow) parentWindow->SetState(STATE_DEFAULT);
}
}
SetOptionValues();
return MENU_NONE;
}