Annotated code to make it easier to read. No functional changes.

This commit is contained in:
giantpune 2009-05-04 03:45:45 +00:00
parent 97d59a61aa
commit f69bfb6421
3 changed files with 42 additions and 36 deletions

View File

@ -29,6 +29,8 @@ char current_path[100];
//int COVER_XCOORD = 28; //int COVER_XCOORD = 28;
//int COVER_YCOORD = 105; //int COVER_YCOORD = 105;
//define variables
struct CFG CFG; struct CFG CFG;
struct THEME THEME; struct THEME THEME;
u8 ocarinaChoice = 0; u8 ocarinaChoice = 0;
@ -199,9 +201,9 @@ void CFG_Default()
CFG.godmode = 0; CFG.godmode = 0;
// CFG.installdownload = 0; // CFG.installdownload = 0;
// CFG.hidesettingmenu = 0; // CFG.hidesettingmenu = 0;
snprintf(CFG.covers_path, sizeof(CFG.covers_path), "SD:/images/"); snprintf(CFG.covers_path, sizeof(CFG.covers_path), "SD:/images/"); //default image path
snprintf(CFG.disc_path, sizeof(CFG.disc_path), "SD:/images/disc/"); snprintf(CFG.disc_path, sizeof(CFG.disc_path), "SD:/images/disc/");//default path for disc images
snprintf(CFG.unlockCode, sizeof(CFG.unlockCode), "ab121b"); snprintf(CFG.unlockCode, sizeof(CFG.unlockCode), "ab121b"); // default passwore
//all alignments are left top here //all alignments are left top here
THEME.selection_x = 200; THEME.selection_x = 200;
@ -406,12 +408,15 @@ void cfg_set(char *name, char *val)
cfg_map("home", "reboot", &CFG.home, CFG_HOME_REBOOT); cfg_map("home", "reboot", &CFG.home, CFG_HOME_REBOOT);
cfg_int("simple", &CFG.simple, 3); cfg_int("simple", &CFG.simple, 3);
*/ */
if (!CFG.widescreen &&(strcmp(name, "theme_path") == 0)) {
// if these are defined in txt file, use them. otherwise use defaults
if (!CFG.widescreen &&(strcmp(name, "theme_path") == 0)) {// if in 4:3
strcopy(CFG.theme_path, val, sizeof(CFG.theme_path)); strcopy(CFG.theme_path, val, sizeof(CFG.theme_path));
return; return;
} }
if (CFG.widescreen && strcmp(name, "wtheme_path") == 0) { if (CFG.widescreen && strcmp(name, "wtheme_path") == 0) { // if in 16:9
strcopy(CFG.theme_path, val, sizeof(CFG.theme_path)); strcopy(CFG.theme_path, val, sizeof(CFG.theme_path));
return; return;
} }
@ -831,7 +836,7 @@ void cfg_set_game_opt(struct Game_CFG *game, u8 *id)
game->parentalcontrol = parentalcontrolChoice; game->parentalcontrol = parentalcontrolChoice;
} }
bool cfg_save_global() bool cfg_save_global()// save global settings
{ {
struct stat st; struct stat st;
if(stat("SD:/config/", &st) != 0) { if(stat("SD:/config/", &st) != 0) {
@ -930,7 +935,7 @@ bool cfg_load_games()
return cfg_parsefile("SD:/config/settings.cfg", &game_set); return cfg_parsefile("SD:/config/settings.cfg", &game_set);
} }
bool cfg_save_games() bool cfg_save_games()// save per game setings
{ {
FILE *f; FILE *f;
int i; int i;

View File

@ -452,7 +452,7 @@ void GuiGameBrowser::Update(GuiTrigger * t)
} }
WPAD_ScanPads(); WPAD_ScanPads();
u8 cnt, buttons = NULL; u8 cnt, buttons = NULL;/////////////////////////////////////////////////////scroll by holding B and tilt wiimote
int position1 = 0; int position1 = 0;
@ -520,7 +520,7 @@ void GuiGameBrowser::Update(GuiTrigger * t)
position2 = 0; position2 = 0;
} }
if(scrollbarBoxBtn->GetState() == STATE_HELD && if(scrollbarBoxBtn->GetState() == STATE_HELD &&/////////////////////allow dragging of scrollbar box
scrollbarBoxBtn->GetStateChan() == t->chan && scrollbarBoxBtn->GetStateChan() == t->chan &&
t->wpad.ir.valid && gameCnt > pagesize) t->wpad.ir.valid && gameCnt > pagesize)
{ {
@ -548,7 +548,7 @@ void GuiGameBrowser::Update(GuiTrigger * t)
scrollbarBoxBtn->SetPosition(width/2-18+7, positionbar+8); scrollbarBoxBtn->SetPosition(width/2-18+7, positionbar+8);
if(t->Right()) if(t->Right())/////////////////////////////////////////////////////skip pagesize # of games if right is pressed
{ {
if(listOffset < gameCnt && gameCnt > pagesize) if(listOffset < gameCnt && gameCnt > pagesize)
{ {
@ -570,7 +570,7 @@ void GuiGameBrowser::Update(GuiTrigger * t)
} else { } else {
if(t->Down()) if(t->Down())/////////////////////////////////////////////////////if there isn't a scrollbar and down is pressed
{ {
next = this->FindMenuItem(gameIndex[selectedItem], 1); next = this->FindMenuItem(gameIndex[selectedItem], 1);
@ -589,7 +589,7 @@ void GuiGameBrowser::Update(GuiTrigger * t)
} }
} }
} }
else if(t->Up()) else if(t->Up())///////////////////////////////////////////////////up
{ {
prev = this->FindMenuItem(gameIndex[selectedItem], -1); prev = this->FindMenuItem(gameIndex[selectedItem], -1);

View File

@ -711,6 +711,7 @@ DeviceWait(const char *title, const char *msg, const char *btn1Label, const char
GuiTrigger trigA; GuiTrigger trigA;
trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
GuiImageData dialogBox(dialogue_box_png); GuiImageData dialogBox(dialogue_box_png);
GuiImage dialogBoxImg(&dialogBox); GuiImage dialogBoxImg(&dialogBox);
@ -739,6 +740,8 @@ DeviceWait(const char *title, const char *msg, const char *btn1Label, const char
mainWindow->ChangeFocus(&promptWindow); mainWindow->ChangeFocus(&promptWindow);
ResumeGui(); ResumeGui();
s32 ret2; s32 ret2;
while(i >= 0) while(i >= 0)
{ {
@ -937,7 +940,7 @@ int GameWindowPrompt()
} }
changed = 0; changed = 0;
//load disc image based or what game is seleted
struct discHdr * header = &gameList[gameSelected]; struct discHdr * header = &gameList[gameSelected];
WBFS_GameSize(header->id, &size); WBFS_GameSize(header->id, &size);
@ -1039,7 +1042,7 @@ int GameWindowPrompt()
promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50);
} }
else if(btnRight.GetState() == STATE_CLICKED) { else if(btnRight.GetState() == STATE_CLICKED) {//next game
promptWindow.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 50); promptWindow.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 50);
changed = 1; changed = 1;
gameSelected = (gameSelected + 1) % gameCnt; gameSelected = (gameSelected + 1) % gameCnt;
@ -1047,7 +1050,7 @@ int GameWindowPrompt()
break; break;
} }
else if(btnLeft.GetState() == STATE_CLICKED) { else if(btnLeft.GetState() == STATE_CLICKED) {//previous game
promptWindow.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 50); promptWindow.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 50);
changed = 2; changed = 2;
gameSelected = (gameSelected - 1 + gameCnt) % gameCnt; gameSelected = (gameSelected - 1 + gameCnt) % gameCnt;
@ -1289,7 +1292,7 @@ char * NetworkInitPromp(int choice2)
u32 i = 0; u32 i = 0;
char filename[11]; char filename[11];
// char filenameshort[10]; // char filenameshort[10];
bool found1 = false; bool found1 = false;/////add Ids of games that are missing covers to cntMissFiles
bool found2 = false; bool found2 = false;
for (i = 0; i < gameCnt && cntMissFiles < 500; i++) for (i = 0; i < gameCnt && cntMissFiles < 500; i++)
{ {
@ -1607,7 +1610,7 @@ ProgressDownloadWindow(int choice2)
sprintf(imgPath,"%s%s", CFG.covers_path, missingFiles[i]); sprintf(imgPath,"%s%s", CFG.covers_path, missingFiles[i]);
} }
struct block file = downloadfile(URLFile); struct block file = downloadfile(URLFile);//reject known bad images
if (file.size == 36864 || file.size <= 1024 || file.size == 7386 || file.data == NULL) { if (file.size == 36864 || file.size <= 1024 || file.size == 7386 || file.data == NULL) {
cntNotFound++; cntNotFound++;
@ -2147,7 +2150,7 @@ static int MenuDiscList()
WBFS_DiskSpace(&used, &freespace); WBFS_DiskSpace(&used, &freespace);
if (!gameCnt) { if (!gameCnt) { //if there is no list of games to display
nolist = 1; nolist = 1;
} }
@ -2301,7 +2304,7 @@ static int MenuDiscList()
DownloadBtn.SetAlignment(ALIGN_LEFT, ALIGN_TOP); DownloadBtn.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
DownloadBtn.SetPosition(THEME.cover_x,THEME.cover_y);//(20, 300); DownloadBtn.SetPosition(THEME.cover_x,THEME.cover_y);//(20, 300);
DownloadBtn.SetSoundOver(&btnSoundOver); DownloadBtn.SetSoundOver(&btnSoundOver);
if (CFG.godmode == 1){ if (CFG.godmode == 1){//only make the button have trigger & tooltip if in godmode
if (Settings.tooltips == TooltipsOn && THEME.showToolTip != 0){ if (Settings.tooltips == TooltipsOn && THEME.showToolTip != 0){
DownloadBtn.SetToolTip(&ttDownloadImg,&ttDownloadTxt,205,-30); DownloadBtn.SetToolTip(&ttDownloadImg,&ttDownloadTxt,205,-30);
DownloadBtn.SetTrigger(&trigA); DownloadBtn.SetTrigger(&trigA);
@ -2403,8 +2406,8 @@ static int MenuDiscList()
VIDEO_WaitVSync (); VIDEO_WaitVSync ();
//CLOCK //CLOCK
if ((Settings.hddinfo == Clock)&&(counter % 2000 == 0)) { if ((Settings.hddinfo == Clock)&&(counter % 2000 == 0)) {//only update the clock every 2000 loops
time_t rawtime = time(0); time_t rawtime = time(0); //this fixes code dump caused by the clock
timeinfo = localtime (&rawtime); timeinfo = localtime (&rawtime);
strftime(theTime, sizeof(theTime), "%H:%M", timeinfo); strftime(theTime, sizeof(theTime), "%H:%M", timeinfo);
clockTime.SetText(theTime); clockTime.SetText(theTime);
@ -2435,7 +2438,7 @@ static int MenuDiscList()
} }
} }
#endif #endif
// respond to button presses
if(shutdown == 1) if(shutdown == 1)
{ {
Sys_Shutdown(); Sys_Shutdown();
@ -2563,8 +2566,8 @@ static int MenuDiscList()
//Get selected game under cursor //Get selected game under cursor
int selectimg, promptnumber; int selectimg;//, promptnumber;
promptnumber = 0; //promptnumber = 0;
char ID[4]; char ID[4];
char IDfull[7]; char IDfull[7];
selectimg = gameBrowser.GetSelectedOption(); selectimg = gameBrowser.GetSelectedOption();
@ -2579,7 +2582,7 @@ static int MenuDiscList()
{ {
if (selectimg != selectedold) if (selectimg != selectedold)
{ {
selectedold = selectimg; selectedold = selectimg;//update displayed cover, game ID, and region if the selected game changes
struct discHdr *header = &gameList[selectimg]; struct discHdr *header = &gameList[selectimg];
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]);
@ -2649,7 +2652,7 @@ static int MenuDiscList()
coverImg = new GuiImage(cover); coverImg = new GuiImage(cover);
coverImg->SetWidescreen(CFG.widescreen); coverImg->SetWidescreen(CFG.widescreen);
DownloadBtn.SetImage(coverImg); DownloadBtn.SetImage(coverImg);// put the new image on the download button
w.Append(&DownloadBtn); w.Append(&DownloadBtn);
if ((Settings.sinfo == GameID) || (Settings.sinfo == Both)){ if ((Settings.sinfo == GameID) || (Settings.sinfo == Both)){
@ -2712,7 +2715,7 @@ static int MenuDiscList()
ios2 = 0; ios2 = 0;
break; break;
} }
// if we have used the network or cios222 we need to reload the disklist
if(networkisinitialized == 1 || ios2 == 1 || Settings.cios == ios222) { if(networkisinitialized == 1 || ios2 == 1 || Settings.cios == ios222) {
WPAD_Flush(0); WPAD_Flush(0);
@ -2776,7 +2779,7 @@ static int MenuDiscList()
returnHere = true; returnHere = true;
} }
else if (choice == 3) //&& (CFG.godmode == 1)) else if (choice == 3) //WBFS renaming
{ {
wiilight(0); wiilight(0);
//enter new game title //enter new game title
@ -2853,8 +2856,6 @@ static int MenuFormat()
GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, vol); GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, vol);
GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, vol); GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, vol);
//btnClick.SetVolume(vol);
//btnSoundOver.SetVolume(vol);
snprintf(imgPath, sizeof(imgPath), "%swiimote_poweroff.png", CFG.theme_path); snprintf(imgPath, sizeof(imgPath), "%swiimote_poweroff.png", CFG.theme_path);
GuiImageData btnpwroff(imgPath, wiimote_poweroff_png); GuiImageData btnpwroff(imgPath, wiimote_poweroff_png);
snprintf(imgPath, sizeof(imgPath), "%swiimote_poweroff_over.png", CFG.theme_path); snprintf(imgPath, sizeof(imgPath), "%swiimote_poweroff_over.png", CFG.theme_path);
@ -3591,7 +3592,7 @@ int GameSettings(struct discHdr * header)
struct Game_CFG* game_cfg = CFG_get_game_opt(header->id); struct Game_CFG* game_cfg = CFG_get_game_opt(header->id);
if (game_cfg) if (game_cfg)//if there are saved settings for this game use them
{ {
videoChoice = game_cfg->video; videoChoice = game_cfg->video;
languageChoice = game_cfg->language; languageChoice = game_cfg->language;
@ -3599,7 +3600,7 @@ int GameSettings(struct discHdr * header)
viChoice = game_cfg->vipatch; viChoice = game_cfg->vipatch;
iosChoice = game_cfg->ios; iosChoice = game_cfg->ios;
} }
else else// otherwise use the global settings
{ {
videoChoice = Settings.video; videoChoice = Settings.video;
languageChoice = Settings.language; languageChoice = Settings.language;