From 94cac74a3ade1723752e657dd99a25200948765e Mon Sep 17 00:00:00 2001 From: DRayX7 Date: Fri, 22 May 2009 17:51:28 +0000 Subject: [PATCH] **Changes: *Seperated the functionality of show favorites and sorting (so you can show only favorites and sort however you want). *Fixed some bugs with sorting. **Known Bugs: *If the loader is started with show favorites on, and it is then turned off, it code dumps (if you have less than 10 games favorited). *If you change the favorite status of a game it resets the play count. Please do not create issues about these, they will be fixed soon. **Note: *There is a new libogc package in the downloads section, you don't have to update, but it is recommended. --- source/cfg.c | 14 +++++++-- source/cfg.h | 36 +++++++++++------------ source/menu.cpp | 77 ++++++++++++++++++++++--------------------------- 3 files changed, 63 insertions(+), 64 deletions(-) diff --git a/source/cfg.c b/source/cfg.c index 79fce5b0..eb92f303 100644 --- a/source/cfg.c +++ b/source/cfg.c @@ -50,7 +50,8 @@ u8 viChoice = 0; u8 iosChoice = 0; u8 parentalcontrolChoice = 0; u8 xflip = 0; -u8 sort = 0; +u8 sort = 0; +u8 fave = 0; u8 qboot = 0; u8 wsprompt = 0; u8 keyset = 0; @@ -765,7 +766,13 @@ void global_cfg_set(char *name, char *val) } return; } - + else if (strcmp(name, "fave") == 0) { + int i; + if (sscanf(val, "%d", &i) == 1) { + Settings.fave = i; + } + return; + } else if (strcmp(name, "keyset") == 0) { int i; if (sscanf(val, "%d", &i) == 1) { @@ -1038,7 +1045,8 @@ bool cfg_save_global()// save global settings fprintf(f, "volume = %d\n ", Settings.volume); fprintf(f, "tooltips = %d\n ", Settings.tooltips); fprintf(f, "password = %s\n ", Settings.unlockCode); - fprintf(f, "sort = %d\n ", Settings.sort); + fprintf(f, "sort = %d\n ", Settings.sort); + fprintf(f, "fave = %d\n ", Settings.fave); fprintf(f, "cios = %d\n ", Settings.cios); fprintf(f, "keyset = %d\n ", Settings.keyset); fprintf(f, "xflip = %d\n ", Settings.xflip); diff --git a/source/cfg.h b/source/cfg.h index 03acf738..c7c9d72f 100644 --- a/source/cfg.h +++ b/source/cfg.h @@ -144,7 +144,6 @@ struct THEME extern struct CFG CFG; extern struct THEME THEME; extern u8 ocarinaChoice; -extern u8 sort; extern u16 playcnt; extern u8 videoChoice; extern u8 languageChoice; @@ -154,7 +153,8 @@ extern u8 faveChoice; extern u8 parentalcontrolChoice; extern u8 xflip; extern u8 qboot; -extern u8 sort; +extern u8 sort; +extern u8 fave; extern u8 wsprompt; extern u8 keyset; @@ -239,7 +239,6 @@ enum { }; enum { all, - fave, pcount, }; @@ -288,25 +287,26 @@ enum { };*/ struct SSettings { - int video; - int language; - int ocarina; - int vpatch; - int ios; - int sinfo; - int hddinfo; - int rumble; - int xflip; - int volume; + int video; + int language; + int ocarina; + int vpatch; + int ios; + int sinfo; + int hddinfo; + int rumble; + int xflip; + int volume; int tooltips; char unlockCode[20]; - int parentalcontrol; + int parentalcontrol; int cios; - int qboot; - int wsprompt; - int keyset; + int qboot; + int wsprompt; + int keyset; int unicodefix; - int sort; + int sort; + int fave; }; void CFG_LoadGlobal(void); diff --git a/source/menu.cpp b/source/menu.cpp index f18d1d50..9838b5ac 100644 --- a/source/menu.cpp +++ b/source/menu.cpp @@ -1366,10 +1366,12 @@ int GameWindowPrompt() if(isSdInserted() == 1) { faveChoice = !faveChoice; btnFavoriteImg.SetImage(faveChoice ? &imgFavorite : &imgNotFavorite); - extern u8 favorite; + extern u8 favorite; + extern u8 count; struct Game_NUM* game_num = CFG_get_game_num(header->id); if (game_num) { - favorite = game_num->favorite; + favorite = game_num->favorite; + count = game_num->count; } favorite = faveChoice; CFG_save_game_num(header->id); @@ -2367,7 +2369,7 @@ s32 __Menu_GetEntries(void) } /* Filters */ - if (Settings.sort==fave || dispFave) { + if (Settings.fave) { u32 cnt2 = 0; for (u32 i = 0; i < cnt; i++) @@ -2908,8 +2910,7 @@ static int MenuDiscList() wiiBtn.SetSoundOver(&btnSoundOver); wiiBtn.SetSoundClick(&btnClick); wiiBtn.SetTrigger(&trigA); - - //GuiImage favoriteBtnImg((Settings.sort==fave) ? &imgFavoriteOn : &imgFavoriteOff);; + GuiImage favoriteBtnImg(&imgfavIcon); favoriteBtnImg.SetWidescreen(CFG.widescreen); GuiButton favoriteBtn(imgfavIcon.GetWidth(), imgfavIcon.GetHeight()); @@ -2926,7 +2927,7 @@ static int MenuDiscList() abcBtnImg.SetWidescreen(CFG.widescreen); GuiButton abcBtn(abcBtnImg.GetWidth(), abcBtnImg.GetHeight()); abcBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);//(ALIGN_CENTRE, ALIGN_MIDDLE); - abcBtn.SetPosition(-40, 15); + abcBtn.SetPosition(-30, 15); abcBtn.SetImage(&abcBtnImg); abcBtn.SetSoundOver(&btnSoundOver); abcBtn.SetSoundClick(&btnClick); @@ -2939,16 +2940,16 @@ static int MenuDiscList() countBtnImg.SetWidescreen(CFG.widescreen); GuiButton countBtn(countBtnImg.GetWidth(), countBtnImg.GetHeight()); countBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);//(ALIGN_CENTRE, ALIGN_MIDDLE); - countBtn.SetPosition(0, 15); + countBtn.SetPosition(10, 15); countBtn.SetImage(&countBtnImg); countBtn.SetSoundOver(&btnSoundOver); countBtn.SetSoundClick(&btnClick); countBtn.SetTrigger(&trigA); countBtn.SetEffectGrow(); countBtn.SetAlpha(70); - - if (Settings.sort==fave)favoriteBtn.SetAlpha(255); - else if (Settings.sort==all)abcBtn.SetAlpha(255); + + if (Settings.fave)favoriteBtn.SetAlpha(255); + if (Settings.sort==all)abcBtn.SetAlpha(255); else if (Settings.sort==pcount)countBtn.SetAlpha(255); //Downloading Covers @@ -3212,59 +3213,49 @@ static int MenuDiscList() else if(favoriteBtn.GetState() == STATE_CLICKED) { - //dispFave = !dispFave; - Settings.sort=fave; + Settings.fave=!Settings.fave; if(isSdInserted() == 1) { cfg_save_global(); - } + } __Menu_GetEntries(); gameBrowser.Reload(gameList, gameCnt); sprintf(GamesCnt,"%s: %i",LANGUAGE.Games, gameCnt); gamecntTxt.SetText(GamesCnt); selectedold = 1; - //favoriteBtnImg.SetImage((Settings.sort==fave) ? &imgFavoriteOn : &imgFavoriteOff); favoriteBtn.ResetState(); - favoriteBtn.SetAlpha(255); - abcBtn.SetAlpha(70); - countBtn.SetAlpha(70); + favoriteBtn.SetAlpha(Settings.fave ? 255 : 70); } else if(abcBtn.GetState() == STATE_CLICKED) { - //dispFave = !dispFave; - Settings.sort=all; - if(isSdInserted() == 1) { - cfg_save_global(); + if(Settings.sort != all) { + Settings.sort=all; + if(isSdInserted() == 1) { + cfg_save_global(); } - __Menu_GetEntries(); - gameBrowser.Reload(gameList, gameCnt); - sprintf(GamesCnt,"%s: %i",LANGUAGE.Games, gameCnt); - gamecntTxt.SetText(GamesCnt); - selectedold = 1; - //favoriteBtnImg.SetImage((Settings.sort==fave) ? &imgFavoriteOn : &imgFavoriteOff); + __Menu_GetEntries(); + gameBrowser.Reload(gameList, gameCnt); + selectedold = 1; + abcBtn.SetAlpha(255); + countBtn.SetAlpha(70); + } abcBtn.ResetState(); - favoriteBtn.SetAlpha(70); - abcBtn.SetAlpha(255); - countBtn.SetAlpha(70); } else if(countBtn.GetState() == STATE_CLICKED) { - //dispFave = !dispFave; - if(isSdInserted() == 1) { - cfg_save_global(); + if(Settings.sort != pcount) { + Settings.sort=pcount; + if(isSdInserted() == 1) { + cfg_save_global(); } - Settings.sort=pcount; - __Menu_GetEntries(); - gameBrowser.Reload(gameList, gameCnt); - sprintf(GamesCnt,"%s: %i",LANGUAGE.Games, gameCnt); - gamecntTxt.SetText(GamesCnt); - selectedold = 1; - //favoriteBtnImg.SetImage((Settings.sort==fave) ? &imgFavoriteOn : &imgFavoriteOff); + __Menu_GetEntries(); + gameBrowser.Reload(gameList, gameCnt); + selectedold = 1; + abcBtn.SetAlpha(70); + countBtn.SetAlpha(255); + } countBtn.ResetState(); - favoriteBtn.SetAlpha(70); - abcBtn.SetAlpha(70); - countBtn.SetAlpha(255); } //Get selected game under cursor