fix a little bug

add function to create gameList based on installed channels.  not used yet.
This commit is contained in:
giantpune 2009-10-01 09:17:55 +00:00
parent c797c3fa13
commit aa936a5c43
10 changed files with 462 additions and 94 deletions

View File

@ -23,7 +23,7 @@
#include "sys.h" #include "sys.h"
#include "network/http.h" #include "network/http.h"
#include <zlib.h> #include <zlib.h>
#include "Settings/cfg.h" #include "settings/cfg.h"
#include "unzip/unzip.h" #include "unzip/unzip.h"
#include "unzip/miniunz.h" #include "unzip/miniunz.h"

View File

@ -64,7 +64,7 @@ float gamesize;
int currentMenu; int currentMenu;
int idiotFlag=-1; int idiotFlag=-1;
char idiotChar[50]; char idiotChar[50];
u8 dvdMounted=0; u8 mountMethod=0;
struct discHdr *dvdheader = NULL; struct discHdr *dvdheader = NULL;
@ -222,7 +222,7 @@ void rockout(int f = 0) {
if ((!(strcasestr(get_title(&gameList[num]),"guitar")|| if ((!(strcasestr(get_title(&gameList[num]),"guitar")||
strcasestr(get_title(&gameList[num]),"band")|| strcasestr(get_title(&gameList[num]),"band")||
strcasestr(get_title(&gameList[num]),"rock")|| strcasestr(get_title(&gameList[num]),"rock")||
f==1))||dvdMounted) { f==1))||mountMethod) {
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
delete pointer[i]; delete pointer[i];
snprintf(imgPath, sizeof(imgPath), "%splayer1_point.png", CFG.theme_path); snprintf(imgPath, sizeof(imgPath), "%splayer1_point.png", CFG.theme_path);
@ -336,6 +336,13 @@ int MenuDiscList() {
char dvdID[8]; char dvdID[8];
if (!dvdheader) if (!dvdheader)
dvdheader = new struct discHdr; dvdheader = new struct discHdr;
u8 mountMethodOLD =0;
///WII_Initialize();
///WII_LaunchTitle(TITLE_ID(0x00010001,0xJODI));
@ -362,6 +369,7 @@ int MenuDiscList() {
char theTime[80]=""; char theTime[80]="";
time_t lastrawtime=0; time_t lastrawtime=0;
if (mountMethod!=3)
WBFS_DiskSpace(&used, &freespace); WBFS_DiskSpace(&used, &freespace);
if (!gameCnt) { //if there is no list of games to display if (!gameCnt) { //if there is no list of games to display
@ -454,13 +462,13 @@ int MenuDiscList() {
char spaceinfo[30]; char spaceinfo[30];
sprintf(spaceinfo,"%.2fGB %s %.2fGB %s",freespace,tr("of"),(freespace+used),tr("free")); sprintf(spaceinfo,(mountMethod!=3?"%.2fGB %s %.2fGB %s":" "),freespace,tr("of"),(freespace+used),tr("free"));
GuiText usedSpaceTxt(spaceinfo, 18, THEME.info); GuiText usedSpaceTxt(spaceinfo, 18, THEME.info);
usedSpaceTxt.SetAlignment(THEME.hddinfo_align, ALIGN_TOP); usedSpaceTxt.SetAlignment(THEME.hddinfo_align, ALIGN_TOP);
usedSpaceTxt.SetPosition(THEME.hddinfo_x, THEME.hddinfo_y); usedSpaceTxt.SetPosition(THEME.hddinfo_x, THEME.hddinfo_y);
char GamesCnt[15]; char GamesCnt[15];
sprintf(GamesCnt,"%s: %i",tr("Games"), gameCnt); sprintf(GamesCnt,"%s: %i",(mountMethod!=3?tr("Games"):tr("Channels")), gameCnt);
GuiText gamecntTxt(GamesCnt, 18, THEME.info); GuiText gamecntTxt(GamesCnt, 18, THEME.info);
GuiButton gamecntBtn(100,18); GuiButton gamecntBtn(100,18);
@ -729,15 +737,16 @@ int MenuDiscList() {
if (Settings.godmode == 1) {//only make the button have trigger & tooltip if in godmode if (Settings.godmode == 1 && mountMethod!=3) {//only make the button have trigger & tooltip if in godmode
DownloadBtn.SetSoundOver(&btnSoundOver); DownloadBtn.SetSoundOver(&btnSoundOver);
DownloadBtn.SetTrigger(&trigA); DownloadBtn.SetTrigger(&trigA);
DownloadBtn.SetTrigger(&trig1); DownloadBtn.SetTrigger(&trig1);
DownloadBtn.SetToolTip(&DownloadBtnTT,205,-30); DownloadBtn.SetToolTip(&DownloadBtnTT,205,-30);
idBtn.SetSoundOver(&btnSoundOver); idBtn.SetSoundOver(&btnSoundOver);
idBtn.SetTrigger(&trigA); idBtn.SetTrigger(&trigA);
idBtn.SetToolTip(&IDBtnTT,205,-30); idBtn.SetToolTip(&IDBtnTT,205,-30);
} else } else
{ {
DownloadBtn.SetRumble(false); DownloadBtn.SetRumble(false);
@ -810,6 +819,8 @@ int MenuDiscList() {
w.SetUpdateCallback(DiscListWinUpdateCallback); w.SetUpdateCallback(DiscListWinUpdateCallback);
// End Toolbar // End Toolbar
if (Settings.godmode == 1) if (Settings.godmode == 1)
w.Append(&homebrewBtn); w.Append(&homebrewBtn);
@ -835,8 +846,9 @@ int MenuDiscList() {
if(searchBar) if(searchBar)
mainWindow->Append(searchBar); mainWindow->Append(searchBar);
} }
ResumeGui(); ResumeGui();
while (menu == MENU_NONE) { while (menu == MENU_NONE) {
@ -936,7 +948,7 @@ int MenuDiscList() {
} }
} }
} else if (gamecntBtn.GetState() == STATE_CLICKED) { } else if (gamecntBtn.GetState() == STATE_CLICKED && mountMethod!=3) {
char linebuf[150]; char linebuf[150];
snprintf(linebuf, sizeof(linebuf), "%s %sGameList ?",tr("Save Game List to"), Settings.update_path); snprintf(linebuf, sizeof(linebuf), "%s %sGameList ?",tr("Save Game List to"), Settings.update_path);
@ -945,16 +957,7 @@ int MenuDiscList() {
if (choice==1) if (choice==1)
{ {
if (save_gamelist(0)) if (save_gamelist(choice-1))
WindowPrompt(0,tr("Saved"), tr("OK"));
else
WindowPrompt(tr("Error"),tr("Could not save."), tr("OK"));
menu = MENU_DISCLIST;
break;
}
else if (choice==2)
{
if (save_gamelist(1))
WindowPrompt(0,tr("Saved"), tr("OK")); WindowPrompt(0,tr("Saved"), tr("OK"));
else else
WindowPrompt(tr("Error"),tr("Could not save."), tr("OK")); WindowPrompt(tr("Error"),tr("Could not save."), tr("OK"));
@ -962,6 +965,7 @@ int MenuDiscList() {
break; break;
} }
gamecntBtn.ResetState(); gamecntBtn.ResetState();
} else if (homeBtn.GetState() == STATE_CLICKED) { } else if (homeBtn.GetState() == STATE_CLICKED) {
@ -1112,7 +1116,7 @@ int MenuDiscList() {
} }
else if (searchBtn.GetState() == STATE_CLICKED) { else if (searchBtn.GetState() == STATE_CLICKED && mountMethod!=3) {
show_searchwindow=!show_searchwindow; show_searchwindow=!show_searchwindow;
HaltGui(); HaltGui();
@ -1270,7 +1274,7 @@ int MenuDiscList() {
} else if (homebrewBtn.GetState() == STATE_CLICKED) { } else if (homebrewBtn.GetState() == STATE_CLICKED) {
menu = MENU_HOMEBREWBROWSE; menu = MENU_HOMEBREWBROWSE;
break; break;
} else if (gameInfo.GetState() == STATE_CLICKED) { } else if (gameInfo.GetState() == STATE_CLICKED && mountMethod!=3) {
gameInfo.ResetState(); gameInfo.ResetState();
gameSelected = selectImg1; gameSelected = selectImg1;
rockout(); rockout();
@ -1286,7 +1290,9 @@ int MenuDiscList() {
} }
} }
else if (dvdBtn.GetState() == STATE_CLICKED) { else if (dvdBtn.GetState() == STATE_CLICKED) {
dvdMounted=DiscMount(dvdID); mountMethodOLD = (mountMethod==0||mountMethod==3?mountMethod:0);
mountMethod=DiscMount(dvdID);
dvdheader->id[0]=dvdID[0]; dvdheader->id[0]=dvdID[0];
dvdheader->id[1]=dvdID[1]; dvdheader->id[1]=dvdID[1];
dvdheader->id[2]=dvdID[2]; dvdheader->id[2]=dvdID[2];
@ -1344,7 +1350,7 @@ int MenuDiscList() {
delete GameRegionTxt; delete GameRegionTxt;
GameRegionTxt = NULL; GameRegionTxt = NULL;
} }
switch (header->id[3]) { switch (header->id[3]) {
case 'E': case 'E':
sprintf(gameregion,"NTSC U"); sprintf(gameregion,"NTSC U");
@ -1398,8 +1404,8 @@ int MenuDiscList() {
idBtn.SetLabel(GameIDTxt); idBtn.SetLabel(GameIDTxt);
w.Append(&idBtn); w.Append(&idBtn);
} }
//don't try to show region for channels because all the custom channels wont follow the rules
if ((Settings.sinfo == GameRegion) || (Settings.sinfo == Both)) { if (((Settings.sinfo == GameRegion) || (Settings.sinfo == Both))&&mountMethod!=3) {
GameRegionTxt = new GuiText(gameregion, 22, THEME.info); GameRegionTxt = new GuiText(gameregion, 22, THEME.info);
GameRegionTxt->SetAlignment(ALIGN_LEFT, ALIGN_TOP); GameRegionTxt->SetAlignment(ALIGN_LEFT, ALIGN_TOP);
GameRegionTxt->SetPosition(THEME.region_x, THEME.region_y); GameRegionTxt->SetPosition(THEME.region_x, THEME.region_y);
@ -1409,7 +1415,7 @@ int MenuDiscList() {
} }
} }
if (idBtn.GetState() == STATE_CLICKED) { if (idBtn.GetState() == STATE_CLICKED && mountMethod!=3) {
struct discHdr * header = &gameList[gameBrowser->GetSelectedOption()]; struct discHdr * header = &gameList[gameBrowser->GetSelectedOption()];
//enter new game ID //enter new game ID
char entered[10]; char entered[10];
@ -1426,7 +1432,7 @@ int MenuDiscList() {
} }
} }
if (((gameSelected >= 0) && (gameSelected < (s32)gameCnt)) || dvdMounted) { if (((gameSelected >= 0) && (gameSelected < (s32)gameCnt)) || mountMethod==1 || mountMethod==2) {
if(searchBar) if(searchBar)
{ {
HaltGui(); HaltGui();
@ -1434,9 +1440,9 @@ int MenuDiscList() {
ResumeGui(); ResumeGui();
} }
rockout(); rockout();
struct discHdr *header = (dvdMounted?dvdheader:&gameList[gameSelected]); struct discHdr *header = (mountMethod==1||mountMethod==2?dvdheader:&gameList[gameSelected]);
// struct discHdr *header = dvdheader:&gameList[gameSelected]); // struct discHdr *header = dvdheader:&gameList[gameSelected]);
if (!dvdMounted)//only get this stuff it we are booting a game from USB if (!mountMethod)//only get this stuff it we are booting a game from USB
{ {
WBFS_GameSize(header->id, &size); WBFS_GameSize(header->id, &size);
if (strlen(get_title(header)) < (MAX_CHARACTERS + 3)) { if (strlen(get_title(header)) < (MAX_CHARACTERS + 3)) {
@ -1451,7 +1457,7 @@ int MenuDiscList() {
//check if alt Dol and gct file is present //check if alt Dol and gct file is present
FILE *exeFile = NULL; FILE *exeFile = NULL;
char nipple[100]; char nipple[100];
header = (dvdMounted?dvdheader:&gameList[gameSelected]); //reset header header = (mountMethod==1||mountMethod==2?dvdheader:&gameList[gameSelected]); //reset header
snprintf (IDfull,sizeof(IDfull),"%c%c%c%c%c%c", header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]); snprintf (IDfull,sizeof(IDfull),"%c%c%c%c%c%c", header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]);
struct Game_CFG* game_cfg = CFG_get_game_opt(header->id); struct Game_CFG* game_cfg = CFG_get_game_opt(header->id);
@ -1523,7 +1529,7 @@ int MenuDiscList() {
while (returnHere) { while (returnHere) {
returnHere = false; returnHere = false;
if (Settings.wiilight != 2) wiilight(1); if (Settings.wiilight != 2) wiilight(1);
choice = GameWindowPrompt(); choice = GameWindowPrompt();
// header = &gameList[gameSelected]; //reset header // header = &gameList[gameSelected]; //reset header
if (choice == 1) { if (choice == 1) {
@ -1574,7 +1580,7 @@ int MenuDiscList() {
ResumeGui(); ResumeGui();
//re-evaluate header now in case they changed games while on the game prompt //re-evaluate header now in case they changed games while on the game prompt
header = (dvdMounted?dvdheader:&gameList[gameSelected]); header = (mountMethod==1||mountMethod==2?dvdheader:&gameList[gameSelected]);
int settret = GameSettings(header); int settret = GameSettings(header);
/* unneeded for now, kept in case database gets a separate language setting /* unneeded for now, kept in case database gets a separate language setting
//menu = MENU_DISCLIST; // refresh titles (needed if the language setting has changed) //menu = MENU_DISCLIST; // refresh titles (needed if the language setting has changed)
@ -1593,7 +1599,7 @@ int MenuDiscList() {
rockout(2); rockout(2);
} }
else if (choice == 3 && !dvdMounted) { //WBFS renaming else if (choice == 3 && !mountMethod) { //WBFS renaming
wiilight(0); wiilight(0);
//re-evaluate header now in case they changed games while on the game prompt //re-evaluate header now in case they changed games while on the game prompt
header = &gameList[gameSelected]; header = &gameList[gameSelected];
@ -1610,7 +1616,7 @@ int MenuDiscList() {
} }
} else if (choice == 0) { } else if (choice == 0) {
rockout(2); rockout(2);
dvdMounted =0; if (mountMethod==1||mountMethod==2)mountMethod = mountMethodOLD;
if (Settings.gameDisplay==list) { if (Settings.gameDisplay==list) {
gameBrowser->SetFocus(1); gameBrowser->SetFocus(1);
} else if (Settings.gameDisplay==grid) { } else if (Settings.gameDisplay==grid) {
@ -1648,7 +1654,7 @@ int MenuDiscList() {
// set alt dol default // set alt dol default
if (menu == MENU_EXIT && altdoldefault) { if (menu == MENU_EXIT && altdoldefault) {
struct discHdr *header = (dvdMounted?dvdheader:&gameList[gameSelected]); struct discHdr *header = (mountMethod==1||mountMethod==2?dvdheader:&gameList[gameSelected]);
struct Game_CFG* game_cfg = CFG_get_game_opt(header->id); struct Game_CFG* game_cfg = CFG_get_game_opt(header->id);
// use default only if no alt dol was selected manually // use default only if no alt dol was selected manually
if (game_cfg) { if (game_cfg) {
@ -1688,8 +1694,6 @@ int MenuDiscList() {
gameGrid = NULL; gameGrid = NULL;
delete gameCarousel; delete gameCarousel;
gameCarousel = NULL; gameCarousel = NULL;
//delete dvdheader;
//dvdheader = NULL;
ResumeGui(); ResumeGui();
return menu; return menu;
} }
@ -2163,12 +2167,14 @@ int MainMenu(int menu) {
} }
//MemInfoPrompt(); //MemInfoPrompt();
if (dvdMounted) //for testing
/*if (mountMethod)
{ {
char tmp[30]; char tmp[30];
sprintf(tmp,"boot method --> %i",dvdMounted); sprintf(tmp,"boot method --> %i",mountMethod);
WindowPrompt(0,tmp,0,0,0,0,100); WindowPrompt(0,tmp,0,0,0,0,100);
} }
*/
CloseXMLDatabase(); CloseXMLDatabase();
ExitGUIThreads(); ExitGUIThreads();
bgMusic->Stop(); bgMusic->Stop();
@ -2186,7 +2192,17 @@ int MainMenu(int menu) {
delete fontSystem; delete fontSystem;
ShutdownAudio(); ShutdownAudio();
StopGX(); StopGX();
if (dvdMounted==2) if (mountMethod==3)
{
struct discHdr *header = &gameList[gameSelected];
char tmp[20];
u32 tid;
sprintf(tmp,"%c%c%c%c",header->id[0],header->id[1],header->id[2],header->id[3]);
memcpy(&tid, tmp, 4);
WII_Initialize();
WII_LaunchTitle(TITLE_ID((header->id[5]=='1'?0x00010001:0x00010002),tid));
}
if (mountMethod==2)
{ {
WII_Initialize(); WII_Initialize();
WII_LaunchTitle(0x0000000100000100ULL); WII_LaunchTitle(0x0000000100000100ULL);
@ -2199,7 +2215,7 @@ int MainMenu(int menu) {
} else { } else {
int ret = 0; int ret = 0;
struct discHdr *header = (dvdMounted?dvdheader:&gameList[gameSelected]); struct discHdr *header = (mountMethod?dvdheader:&gameList[gameSelected]);
struct Game_CFG* game_cfg = CFG_get_game_opt(header->id); struct Game_CFG* game_cfg = CFG_get_game_opt(header->id);
@ -2234,6 +2250,7 @@ int MainMenu(int menu) {
} }
reloadblock = off; reloadblock = off;
} }
int ios2; int ios2;
switch (iosChoice) { switch (iosChoice) {
case i249: case i249:
@ -2260,7 +2277,7 @@ int MainMenu(int menu) {
Sys_IosReload(249); Sys_IosReload(249);
} }
} }
if (!dvdMounted) if (!mountMethod)
{ {
ret = Disc_SetUSB(header->id); ret = Disc_SetUSB(header->id);
if (ret < 0) Sys_BackToLoader(); if (ret < 0) Sys_BackToLoader();

View File

@ -30,7 +30,7 @@ extern void HaltGui();
extern GuiWindow * mainWindow; extern GuiWindow * mainWindow;
extern u8 shutdown; extern u8 shutdown;
extern u8 reset; extern u8 reset;
extern u8 dvdMounted; extern u8 mountMethod;
/******************************************************************************** /********************************************************************************
*Disk Browser *Disk Browser
@ -41,7 +41,7 @@ int DiscBrowse(struct discHdr * header) {
u64 offset; u64 offset;
HaltGui(); HaltGui();
if (!dvdMounted) if (!mountMethod)
{ {
ret = Disc_SetUSB(header->id); ret = Disc_SetUSB(header->id);
if (ret < 0) { if (ret < 0) {

View File

@ -51,7 +51,7 @@ extern float gamesize;
extern struct discHdr * gameList; extern struct discHdr * gameList;
extern u8 shutdown; extern u8 shutdown;
extern u8 reset; extern u8 reset;
extern u8 dvdMounted; extern u8 mountMethod;
extern struct discHdr *dvdheader; extern struct discHdr *dvdheader;
/*** Extern functions ***/ /*** Extern functions ***/
@ -1034,7 +1034,7 @@ int GameWindowPrompt() {
GuiImage dialogBoxImg(&dialogBox); GuiImage dialogBoxImg(&dialogBox);
GuiTooltip nameBtnTT(tr("Rename Game on WBFS")); GuiTooltip nameBtnTT(tr("Rename Game on WBFS"));
if (Settings.wsprompt == yes && !dvdMounted) if (Settings.wsprompt == yes)
nameBtnTT.SetWidescreen(CFG.widescreen); nameBtnTT.SetWidescreen(CFG.widescreen);
GuiText nameTxt("", 22, THEME.prompttext); GuiText nameTxt("", 22, THEME.prompttext);
if (Settings.wsprompt == yes) if (Settings.wsprompt == yes)
@ -1047,9 +1047,9 @@ int GameWindowPrompt() {
nameBtn.SetPosition(0,-122); nameBtn.SetPosition(0,-122);
nameBtn.SetSoundOver(&btnSoundOver); nameBtn.SetSoundOver(&btnSoundOver);
nameBtn.SetSoundClick(&btnClick); nameBtn.SetSoundClick(&btnClick);
nameBtn.SetToolTip(&nameBtnTT,24,-30, ALIGN_LEFT); if (!mountMethod) nameBtn.SetToolTip(&nameBtnTT,24,-30, ALIGN_LEFT);
if (Settings.godmode == 1 && !dvdMounted) { if (Settings.godmode == 1 && !mountMethod) {
nameBtn.SetTrigger(&trigA); nameBtn.SetTrigger(&trigA);
nameBtn.SetEffectGrow(); nameBtn.SetEffectGrow();
} }
@ -1091,7 +1091,7 @@ int GameWindowPrompt() {
btn2Img.SetWidescreen(CFG.widescreen); btn2Img.SetWidescreen(CFG.widescreen);
} }
GuiButton btn2(&btn2Img,&btn2Img, 1, 5, 0, 0, &trigA, &btnSoundOver, &btnClick,1); GuiButton btn2(&btn2Img,&btn2Img, 1, 5, 0, 0, &trigA, &btnSoundOver, &btnClick,1);
if (Settings.godmode == 1 && dvdMounted!=2) { if (Settings.godmode == 1 && mountMethod!=2 && mountMethod!=3) {
btn2.SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM); btn2.SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM);
btn2.SetPosition(-50, -40); btn2.SetPosition(-50, -40);
} else { } else {
@ -1143,7 +1143,7 @@ int GameWindowPrompt() {
promptWindow.Append(&nameBtn); promptWindow.Append(&nameBtn);
promptWindow.Append(&playcntTxt); promptWindow.Append(&playcntTxt);
promptWindow.Append(&btn2); promptWindow.Append(&btn2);
if (!dvdMounted)//stuff we don't show if it is a DVD mounted if (!mountMethod)//stuff we don't show if it is a DVD mounted
{ {
promptWindow.Append(&sizeTxt); promptWindow.Append(&sizeTxt);
promptWindow.Append(&btnLeft); promptWindow.Append(&btnLeft);
@ -1152,7 +1152,7 @@ int GameWindowPrompt() {
} }
//check if unlocked //check if unlocked
if (Settings.godmode == 1 && dvdMounted!=2) { if (Settings.godmode == 1 && mountMethod!=2 && mountMethod!=3) {
promptWindow.Append(&btn3); promptWindow.Append(&btn3);
} }
@ -1180,7 +1180,7 @@ int GameWindowPrompt() {
} }
//load disc image based or what game is seleted //load disc image based or what game is seleted
struct discHdr * header = (dvdMounted?dvdheader:&gameList[gameSelected]); struct discHdr * header = (mountMethod==1||mountMethod==2?dvdheader:&gameList[gameSelected]);
snprintf (ID,sizeof(ID),"%c%c%c", header->id[0], header->id[1], header->id[2]); snprintf (ID,sizeof(ID),"%c%c%c", header->id[0], header->id[1], header->id[2]);
snprintf (IDFull,sizeof(IDFull),"%c%c%c%c%c%c", header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]); snprintf (IDFull,sizeof(IDFull),"%c%c%c%c%c%c", header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]);
@ -1260,13 +1260,13 @@ int GameWindowPrompt() {
} else } else
diskImg.SetImage(diskCover); diskImg.SetImage(diskCover);
if (!dvdMounted) if (!mountMethod)
{ {
WBFS_GameSize(header->id, &size); WBFS_GameSize(header->id, &size);
sizeTxt.SetTextf("%.2fGB", size); //set size text; sizeTxt.SetTextf("%.2fGB", size); //set size text;
} }
nameTxt.SetText(!dvdMounted?get_title(header):IDFull); nameTxt.SetText(mountMethod!=1&&mountMethod!=2?get_title(header):IDFull);
struct Game_NUM* game_num = CFG_get_game_num(header->id); struct Game_NUM* game_num = CFG_get_game_num(header->id);
if (game_num) { if (game_num) {

View File

@ -24,7 +24,16 @@
#include "wad/wad.h" #include "wad/wad.h"
#include "xml/xml.h" #include "xml/xml.h"
#include "../wad/title.h" #include "../wad/title.h"
#include "unzip/inflate.h" #include "../usbloader/getentries.h"
#define typei 0x00010001
struct discHdr * titleList=NULL;
//discHdr ** titleList;
u32 titleCnt;
extern struct discHdr * gameList;
extern u32 gameCnt;
/*** Extern functions ***/ /*** Extern functions ***/
extern void ResumeGui(); extern void ResumeGui();
@ -35,8 +44,188 @@ extern GuiWindow * mainWindow;
extern u8 shutdown; extern u8 shutdown;
extern u8 reset; extern u8 reset;
extern u32 infilesize; extern u32 infilesize;
extern u32 uncfilesize; extern wchar_t *gameFilter;
extern char wiiloadVersion[2];
inline int wcsnicmp(const wchar_t *s1, const wchar_t *s2, int len)
{
if (len <= 0)
return (0);
do
{
int r = towupper(*s1) - towupper(*s2++);
if (r) return r;
if (*s1++ == 0)
break;
} while (--len != 0);
return (0);
}
/********************************************************************************
* put istalled titles into a struct so it can be handled by all the other
* shitloads of functions we have easily
*
*********************************************************************************/
int buildTitleList1(int t, wchar_t* gameFilter, discHdr ** PgameList, u32 *PgameCnt){
struct discHdr *buffer = NULL;
u32 i = 0;
u32 cnt, cnt2=0, len;
u32 num_titles;
u32 titles[100] ATTRIBUTE_ALIGN(32);
u32 num_sys_titles;
u32 sys_titles[10] ATTRIBUTE_ALIGN(32);
s32 ret = -1;
FILE *f;
char path[100];
ISFS_Initialize();
sprintf(path,"%s/config/database.txt",bootDevice);
f = fopen(path, "r");
ret = getTitles_TypeCount(typei, &num_titles);
if (ret < 0) {
return -1;
}
ret = getTitles_Type(typei, titles, num_titles);
if (ret < 0) {
return -2;
}
ret = getTitles_TypeCount(0x00010002, &num_sys_titles);
if (ret < 0) {
return -3;
}
ret = getTitles_Type(0x00010002, sys_titles, num_sys_titles);
if (ret < 0) {
return -4;
}
cnt = (num_titles+num_sys_titles);
len = sizeof(struct discHdr) * cnt;
buffer = (struct discHdr *)memalign(32, len);
if (!buffer)
return -1;
memset(buffer, 0, len);
char name[64];
while (i < (num_titles+num_sys_titles)) {
//start from the beginning of the file each loop
if (f)rewind(f);
char text[15];
strcpy(name,"");//make sure name is empty
u8 found=0;
sprintf(text, "%s", titleText(i<num_titles?typei:0x00010002, i<num_titles?titles[i]:sys_titles[i-num_titles]));
char line[200];
char tmp[50];
snprintf(tmp,50," ");
//check if the content.bin is on the SD card for that game
//if there is content.bin,then the game is on the SDmenu and not the wii
sprintf(line,"SD:/private/wii/title/%s/content.bin",text);
if (!checkfile(line))
{
struct discHdr *header = &buffer[i];
if (f) {
while (fgets(line, sizeof(line), f)) {
if (line[0]== text[0]&&
line[1]== text[1]&&
line[2]== text[2]) {
int j=0;
found=1;
for (j=0;(line[j+4]!='\0' || j<51);j++)
tmp[j]=line[j+4];
snprintf(header->title,sizeof(header->title),"%s",tmp);
//break;
}
}
}
if (!found) {
if (getName00(header->title, TITLE_ID(i<num_titles?typei:0x00010002, i<num_titles?titles[i]:sys_titles[i-num_titles]),CONF_GetLanguage()*2)>=0)
found=2;
if (!found) {
if (getNameBN(header->title, TITLE_ID(i<num_titles?typei:0x00010002, i<num_titles?titles[i]:sys_titles[i-num_titles]))>=0)
found=3;
if (!found)
snprintf(header->title,sizeof(header->title),"%s (%08x)",text,i<num_titles?titles[i]:sys_titles[i-num_titles]);
}
}
header->id[0]=text[0];
header->id[1]=text[1];
header->id[2]=text[2];
header->id[3]=text[3];
header->id[4]='G';
header->id[5]='P';
//not using these filters right now, but i left them in just in case
// Filters
/*if (Settings.fave) {
struct Game_NUM* game_num = CFG_get_game_num(header->id);
if (!game_num || game_num->favorite==0)
continue;
}
if (Settings.parentalcontrol && !Settings.godmode ) {
if (get_block(header) >= Settings.parentalcontrol)
continue;
}*/
if(gameFilter && *gameFilter) {
u32 filter_len = wcslen(gameFilter);
wchar_t *gameName = FreeTypeGX::charToWideChar(get_title(header));
if (!gameName || wcsnicmp(gameName, gameFilter, filter_len)) {
delete [] gameName;
continue;
}
}
if(i != cnt2)
buffer[cnt2] = buffer[i];
cnt2++;
}
i++;
}
fclose(f);
Uninstall_FromTitle(TITLE_ID(1, 0));
ISFS_Deinitialize();
if(cnt > cnt2)
{
cnt = cnt2;
buffer = (struct discHdr *)realloc(buffer, sizeof(struct discHdr) * cnt);
}
if (!buffer)
return -1;
if (Settings.sort==pcount) {
qsort(buffer, cnt, sizeof(struct discHdr), __Menu_EntryCmpCount);
} else {
qsort(buffer, cnt, sizeof(struct discHdr), __Menu_EntryCmp);
}
/*PgameList = buffer;
buffer = NULL;
PgameCnt = cnt;*/
if(PgameList) *PgameList = buffer; else free(buffer);
if(PgameCnt) *PgameCnt = cnt;
return 0;
return cnt;
}
/******************************************************************************** /********************************************************************************
* TitleBrowser- opens a browser with a list of installed Titles * TitleBrowser- opens a browser with a list of installed Titles
@ -419,12 +608,7 @@ int TitleBrowser(u32 type) {
int choice = WindowPrompt(filesizetxt, temp, tr("OK"), tr("Cancel")); int choice = WindowPrompt(filesizetxt, temp, tr("OK"), tr("Cancel"));
if(choice == 1) { if(choice == 1) {
bool compressed = (wiiloadVersion[0] > 1 || wiiloadVersion[1] > 4) && uncfilesize != 0; FILE *file = fopen(filepath, "wb");
char currentPath[100];
sprintf(currentPath, compressed ? "%s.z" : "%s", filepath);
FILE *file = fopen(currentPath, "wb");
int len = NETWORKBLOCKSIZE; int len = NETWORKBLOCKSIZE;
u8 *buffer = (u8*) malloc(NETWORKBLOCKSIZE); u8 *buffer = (u8*) malloc(NETWORKBLOCKSIZE);
@ -456,24 +640,6 @@ int TitleBrowser(u32 type) {
} }
free(buffer); free(buffer);
fclose(file); fclose(file);
if (compressed) {
FILE *cfile = fopen(currentPath, "rb");
FILE *ufile = fopen(filepath, "wb");
int r;
if (( r = inflateFile(cfile, ufile)) != Z_OK) {
char buf[100];
sprintf((char *) &buf, "Inflate failed: %d", r);
WindowPrompt(tr("Compressed:"), (char *) &buf, tr("OK"));
}
fclose(cfile);
fclose(ufile);
remove(currentPath);
}
ProgressStop(); ProgressStop();
if (read != infilesize) { if (read != infilesize) {
@ -481,10 +647,6 @@ int TitleBrowser(u32 type) {
remove(filepath); remove(filepath);
} else { } else {
if (compressed) {
infilesize = uncfilesize;
}
//determine what type of file we just got //determine what type of file we just got
char filename[101]; char filename[101];
char tmptxt[200]; char tmptxt[200];
@ -569,3 +731,4 @@ int TitleBrowser(u32 type) {
} }

View File

@ -12,4 +12,6 @@
//! type is the type of chnnel to put in the list //! type is the type of chnnel to put in the list
int TitleBrowser(u32 type); int TitleBrowser(u32 type);
//int buildTitleList(int t=0, const wchar_t* Filter=NULL);
#endif #endif

View File

@ -35,7 +35,7 @@ extern GuiImageData * pointer[4];
extern GuiImageData * background; extern GuiImageData * background;
extern u8 shutdown; extern u8 shutdown;
extern u8 reset; extern u8 reset;
extern u8 dvdMounted; extern u8 mountMethod;
extern struct discHdr *dvdheader; extern struct discHdr *dvdheader;
/**************************************************************************** /****************************************************************************
@ -1788,7 +1788,7 @@ int GameSettings(struct discHdr * header) {
trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B); trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B);
char gameName[31]; char gameName[31];
if (!dvdMounted) if (!mountMethod)
{ {
if (strlen(get_title(header)) < (27 + 3)) { if (strlen(get_title(header)) < (27 + 3)) {
sprintf(gameName, "%s", get_title(header)); sprintf(gameName, "%s", get_title(header));
@ -1800,7 +1800,7 @@ int GameSettings(struct discHdr * header) {
} }
else sprintf(gameName, "%c%c%c%c%c%c", header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]); else sprintf(gameName, "%c%c%c%c%c%c", header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]);
GuiText titleTxt(!dvdMounted?get_title(header):gameName, 28, (GXColor) {0, 0, 0, 255}); GuiText titleTxt(!mountMethod?get_title(header):gameName, 28, (GXColor) {0, 0, 0, 255});
titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
titleTxt.SetPosition(12,40); titleTxt.SetPosition(12,40);
titleTxt.SetMaxWidth(356, GuiText::SCROLL); titleTxt.SetMaxWidth(356, GuiText::SCROLL);
@ -2367,7 +2367,7 @@ int GameSettings(struct discHdr * header) {
switch (ret) { switch (ret) {
case 0: case 0:
choice1 = WindowPrompt(tr("Do you really want to delete:"),gameName,tr("Yes"),tr("Cancel")); choice1 = WindowPrompt(tr("Do you really want to delete:"),gameName,tr("Yes"),tr("Cancel"));
if (choice1 == 1 && !dvdMounted) { if (choice1 == 1 && !mountMethod) {
CFG_forget_game_opt(header->id); CFG_forget_game_opt(header->id);
CFG_forget_game_num(header->id); CFG_forget_game_num(header->id);
ret = WBFS_RemoveGame(header->id); ret = WBFS_RemoveGame(header->id);

View File

@ -10,7 +10,7 @@
#include "fstfile.h" #include "fstfile.h"
#include "../patches/dvd_broadway.h" #include "../patches/dvd_broadway.h"
extern u8 dvdMounted; extern u8 mountMethod;
/** Alternate dolloader made by WiiPower modified by dimok **/ /** Alternate dolloader made by WiiPower modified by dimok **/
bool Load_Dol(void **buffer, int* dollen, char * filepath) { bool Load_Dol(void **buffer, int* dollen, char * filepath) {
@ -198,7 +198,7 @@ u32 Load_Dol_from_disc(u32 doloffset, u8 videoSelected, u8 patchcountrystring, u
return -1; return -1;
} }
if (!dvdMounted)ret = WDVD_Read(dol_header, sizeof(dolheader), (doloffset<<2)); if (!mountMethod)ret = WDVD_Read(dol_header, sizeof(dolheader), (doloffset<<2));
else{ else{
dvddone = 0; dvddone = 0;

View File

@ -5,10 +5,20 @@
#include "main.h" #include "main.h"
#include <wctype.h> #include <wctype.h>
#include "getentries.h" #include "getentries.h"
#include "../prompts/TitleBrowser.h"
#include "wad/wad.h"
#include "xml/xml.h"
#include "../wad/title.h"
#include <algorithm> #include <algorithm>
#include <vector> #include <vector>
#include "listfiles.h"
#define typei 0x00010001
struct discHdr * gameList=NULL; struct discHdr * gameList=NULL;
s32 gameSelected=0, gameStart=0; s32 gameSelected=0, gameStart=0;
u32 gameCnt=0; u32 gameCnt=0;
@ -16,6 +26,8 @@ wchar_t *gameFilter=NULL;
wchar_t *gameFilterNextList=NULL; wchar_t *gameFilterNextList=NULL;
wchar_t *gameFilterPrev=NULL; wchar_t *gameFilterPrev=NULL;
extern u8 mountMethod;
/**************************************************************************** /****************************************************************************
* wcsdup based on new wchar_t [...] * wcsdup based on new wchar_t [...]
***************************************************************************/ ***************************************************************************/
@ -236,6 +248,171 @@ error:
return -1; return -1;
} }
int buildTitleList(int t, wchar_t* gameFilter, discHdr ** PgameList, u32 *PgameCnt){
struct discHdr *buffer = NULL;
u32 i = 0;
u32 cnt, cnt2=0, len;
u32 num_titles;
u32 titles[100] ATTRIBUTE_ALIGN(32);
u32 num_sys_titles;
u32 sys_titles[10] ATTRIBUTE_ALIGN(32);
s32 ret = -1;
FILE *f;
char path[100];
ISFS_Initialize();
sprintf(path,"%s/config/database.txt",bootDevice);
f = fopen(path, "r");
ret = getTitles_TypeCount(typei, &num_titles);
if (ret < 0) {
return -1;
}
ret = getTitles_Type(typei, titles, num_titles);
if (ret < 0) {
return -2;
}
ret = getTitles_TypeCount(0x00010002, &num_sys_titles);
if (ret < 0) {
return -3;
}
ret = getTitles_Type(0x00010002, sys_titles, num_sys_titles);
if (ret < 0) {
return -4;
}
cnt = (num_titles+num_sys_titles);
len = sizeof(struct discHdr) * cnt;
buffer = (struct discHdr *)memalign(32, len);
if (!buffer)
return -1;
memset(buffer, 0, len);
char name[64];
while (i < (num_titles+num_sys_titles)) {
//start from the beginning of the file each loop
if (f)rewind(f);
char text[15];
strcpy(name,"");//make sure name is empty
u8 found=0;
sprintf(text, "%s", titleText(i<num_titles?typei:0x00010002, i<num_titles?titles[i]:sys_titles[i-num_titles]));
char line[200];
char tmp[50];
snprintf(tmp,50," ");
//check if the content.bin is on the SD card for that game
//if there is content.bin,then the game is on the SDmenu and not the wii
sprintf(line,"SD:/private/wii/title/%s/content.bin",text);
if (!checkfile(line))
{
struct discHdr *header = &buffer[i];
if (f) {
while (fgets(line, sizeof(line), f)) {
if (line[0]== text[0]&&
line[1]== text[1]&&
line[2]== text[2]) {
int j=0;
found=1;
for (j=0;(line[j+4]!='\0' || j<51);j++)
tmp[j]=line[j+4];
snprintf(header->title,sizeof(header->title),"%s",tmp);
//break;
}
}
}
if (!found) {
if (getName00(header->title, TITLE_ID(i<num_titles?typei:0x00010002, i<num_titles?titles[i]:sys_titles[i-num_titles]),CONF_GetLanguage()*2)>=0)
found=2;
if (!found) {
if (getNameBN(header->title, TITLE_ID(i<num_titles?typei:0x00010002, i<num_titles?titles[i]:sys_titles[i-num_titles]))>=0)
found=3;
if (!found)
snprintf(header->title,sizeof(header->title),"%s (%08x)",text,i<num_titles?titles[i]:sys_titles[i-num_titles]);
}
}
//put the 4th and 8th digit of the title type as the last 2 characters here
//no reason other than it will let us know how we should boot the title later
header->id[0]=text[0];
header->id[1]=text[1];
header->id[2]=text[2];
header->id[3]=text[3];
header->id[4]='1';
header->id[5]=(i<num_titles?'1':'2');
//header->
//not using these filters right now, but i left them in just in case
// Filters
/*if (Settings.fave) {
struct Game_NUM* game_num = CFG_get_game_num(header->id);
if (!game_num || game_num->favorite==0)
continue;
}
if (Settings.parentalcontrol && !Settings.godmode ) {
if (get_block(header) >= Settings.parentalcontrol)
continue;
}*/
if(gameFilter && *gameFilter) {
u32 filter_len = wcslen(gameFilter);
wchar_t *gameName = FreeTypeGX::charToWideChar(get_title(header));
if (!gameName || wcsnicmp(gameName, gameFilter, filter_len)) {
delete [] gameName;
continue;
}
}
if(i != cnt2)
buffer[cnt2] = buffer[i];
cnt2++;
}
i++;
}
fclose(f);
Uninstall_FromTitle(TITLE_ID(1, 0));
ISFS_Deinitialize();
if(cnt > cnt2)
{
cnt = cnt2;
buffer = (struct discHdr *)realloc(buffer, sizeof(struct discHdr) * cnt);
}
if (!buffer)
return -1;
if (Settings.sort==pcount) {
qsort(buffer, cnt, sizeof(struct discHdr), __Menu_EntryCmpCount);
} else {
qsort(buffer, cnt, sizeof(struct discHdr), __Menu_EntryCmp);
}
/*PgameList = buffer;
buffer = NULL;
PgameCnt = cnt;*/
if(PgameList) *PgameList = buffer; else free(buffer);
if(PgameCnt) *PgameCnt = cnt;
return 0;
return cnt;
}
/**************************************************************************** /****************************************************************************
* Get Gamelist * Get Gamelist
***************************************************************************/ ***************************************************************************/
@ -317,6 +494,12 @@ int __Menu_GetGameList(int t, wchar_t* gameFilter, discHdr ** PgameList, u32 *Pg
int __Menu_GetEntries(int t, const wchar_t* Filter) { int __Menu_GetEntries(int t, const wchar_t* Filter) {
/*if (mountMethod==3)
{
return buildTitleList();
}*/
u32 new_gameCnt = 0; u32 new_gameCnt = 0;
struct discHdr *new_gameList = NULL; struct discHdr *new_gameList = NULL;
wchar_t *new_gameFilter = NULL; wchar_t *new_gameFilter = NULL;
@ -327,7 +510,8 @@ int __Menu_GetEntries(int t, const wchar_t* Filter) {
if(new_gameFilter == NULL) return -1; if(new_gameFilter == NULL) return -1;
for(;;) for(;;)
{ {
if(__Menu_GetGameList(t, new_gameFilter, &new_gameList, &new_gameCnt) < 0) if(buildTitleList(t, new_gameFilter, &new_gameList, &new_gameCnt) < 0)
//if(__Menu_GetGameList(t, new_gameFilter, &new_gameList, &new_gameCnt) < 0)
return -1; return -1;
if(new_gameCnt > 0 || new_gameFilter[0] == 0) if(new_gameCnt > 0 || new_gameFilter[0] == 0)
break; break;

View File

@ -27,5 +27,7 @@ extern wchar_t *gameFilterPrev;
//! if this Parameter="" then no filter is activ //! if this Parameter="" then no filter is activ
//! //!
int __Menu_GetEntries(int t=0, const wchar_t* Filter=NULL); int __Menu_GetEntries(int t=0, const wchar_t* Filter=NULL);
s32 __Menu_EntryCmpCount(const void *a, const void *b);
s32 __Menu_EntryCmp(const void *a, const void *b);
#endif #endif