* Added a button to game prompts to make a game a favorite.

* Game prompt now displays how many times a game has been played. (cap of 255 will be fixed)
* Added buton on main window to view only favorited games. (Known Bug: If this button is pressed with no favorite games, the loader will crash)
This commit is contained in:
DRayX7 2009-05-21 08:56:23 +00:00
parent 2062ef871d
commit e6daf212bd
6 changed files with 140 additions and 42 deletions

View File

@ -248,4 +248,10 @@ extern const u32 exit_button_png_size;
extern const u8 mp3_stop_png[]; extern const u8 mp3_stop_png[];
extern const u32 mp3_stop_png_size; extern const u32 mp3_stop_png_size;
extern const u8 favorite_png[];
extern const u32 favorite_png_size;
extern const u8 not_favorite_png[];
extern const u32 not_favorite_png_size;
#endif #endif

View File

@ -154,6 +154,7 @@ snprintf(LANGUAGE.Password, sizeof(LANGUAGE.Password), "Password");
snprintf(LANGUAGE.PasswordChanged, sizeof(LANGUAGE.PasswordChanged), "Password Changed"); snprintf(LANGUAGE.PasswordChanged, sizeof(LANGUAGE.PasswordChanged), "Password Changed");
snprintf(LANGUAGE.Passwordhasbeenchanged, sizeof(LANGUAGE.Passwordhasbeenchanged), "Password has been changed"); snprintf(LANGUAGE.Passwordhasbeenchanged, sizeof(LANGUAGE.Passwordhasbeenchanged), "Password has been changed");
snprintf(LANGUAGE.Passwordchange, sizeof(LANGUAGE.Passwordchange), "Password change"); snprintf(LANGUAGE.Passwordchange, sizeof(LANGUAGE.Passwordchange), "Password change");
snprintf(LANGUAGE.Plays, sizeof(LANGUAGE.Plays), "Play Count");
snprintf(LANGUAGE.PowerofftheWii, sizeof(LANGUAGE.PowerofftheWii), "Power off the Wii"); snprintf(LANGUAGE.PowerofftheWii, sizeof(LANGUAGE.PowerofftheWii), "Power off the Wii");
snprintf(LANGUAGE.Prev, sizeof(LANGUAGE.Prev), "Prev"); snprintf(LANGUAGE.Prev, sizeof(LANGUAGE.Prev), "Prev");
snprintf(LANGUAGE.PromptsButtons, sizeof(LANGUAGE.PromptsButtons), "Prompts Buttons"); snprintf(LANGUAGE.PromptsButtons, sizeof(LANGUAGE.PromptsButtons), "Prompts Buttons");
@ -745,6 +746,10 @@ void language_set(char *name, char *val)
strcopy(LANGUAGE.Passwordchange, val, sizeof(LANGUAGE.Passwordchange)); strcopy(LANGUAGE.Passwordchange, val, sizeof(LANGUAGE.Passwordchange));
return; return;
} }
if (strcmp(name, "Plays") == 0) {
strcopy(LANGUAGE.Plays, val, sizeof(LANGUAGE.Plays));
return;
}
if (strcmp(name, "PowerofftheWii") == 0) { if (strcmp(name, "PowerofftheWii") == 0) {
strcopy(LANGUAGE.PowerofftheWii, val, sizeof(LANGUAGE.PowerofftheWii)); strcopy(LANGUAGE.PowerofftheWii, val, sizeof(LANGUAGE.PowerofftheWii));
return; return;

View File

@ -140,6 +140,7 @@ struct LANGUAGE
char Passwordhasbeenchanged[80]; char Passwordhasbeenchanged[80];
char Passwordchange[50]; char Passwordchange[50];
char PowerofftheWii[50]; char PowerofftheWii[50];
char Plays[20];
char Prev[50]; char Prev[50];
char PromptsButtons[50]; char PromptsButtons[50];
char ReloadSD[50]; char ReloadSD[50];

View File

@ -636,3 +636,18 @@ void GuiGameBrowser::Update(GuiTrigger * t)
if(updateCB) if(updateCB)
updateCB(this); updateCB(this);
} }
void GuiGameBrowser::Reload(struct discHdr * l, int count)
{
LOCK(this);
gameList = l;
gameCnt = count;
if (gameCnt == 0) gameCnt = 1;
scrollbaron = (gameCnt > THEME.pagesize) ? 1 : 0;
pagesize = (gameCnt > THEME.pagesize) ? THEME.pagesize : gameCnt;
selectedItem = 0;
listOffset = 0;
for(int i=0; i<pagesize; i++)
game[i]->ResetState();
}

View File

@ -42,6 +42,7 @@ class GuiGameBrowser : public GuiElement
void Draw(); void Draw();
void Update(GuiTrigger * t); void Update(GuiTrigger * t);
int GetOffset(); int GetOffset();
void Reload(struct discHdr * l, int count);
//GuiText * optionVal[PAGESIZE]; //GuiText * optionVal[PAGESIZE];
protected: protected:
int selectedItem; int selectedItem;

View File

@ -83,6 +83,7 @@ static int datag = 0;
int datagB =0; int datagB =0;
int dataed = -1; int dataed = -1;
int cosa=0,sina=0,offa=0; int cosa=0,sina=0,offa=0;
u8 dispFave=0;
//downloadvariables //downloadvariables
static char missingFiles[500][12]; //fixed static char missingFiles[500][12]; //fixed
@ -991,6 +992,8 @@ int GameWindowPrompt()
char ID[4]; char ID[4];
char IDFull[7]; char IDFull[7];
char gameName[CFG.maxcharacters + 4]; char gameName[CFG.maxcharacters + 4];
u8 faveChoice = 0;
u8 playCount = 0;
GuiWindow promptWindow(472,320); GuiWindow promptWindow(472,320);
promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
@ -1002,6 +1005,11 @@ int GameWindowPrompt()
snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path); snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path);
GuiImageData btnOutline(imgPath, button_dialogue_box_png); GuiImageData btnOutline(imgPath, button_dialogue_box_png);
snprintf(imgPath, sizeof(imgPath), "%sfavorite.png", CFG.theme_path);
GuiImageData imgFavorite(imgPath, favorite_png);
snprintf(imgPath, sizeof(imgPath), "%snot_favorite.png", CFG.theme_path);
GuiImageData imgNotFavorite(imgPath, not_favorite_png);
snprintf(imgPath, sizeof(imgPath), "%sstartgame_arrow_left.png", CFG.theme_path); snprintf(imgPath, sizeof(imgPath), "%sstartgame_arrow_left.png", CFG.theme_path);
GuiImageData imgLeft(imgPath, startgame_arrow_left_png); GuiImageData imgLeft(imgPath, startgame_arrow_left_png);
snprintf(imgPath, sizeof(imgPath), "%sstartgame_arrow_right.png", CFG.theme_path); snprintf(imgPath, sizeof(imgPath), "%sstartgame_arrow_right.png", CFG.theme_path);
@ -1064,6 +1072,11 @@ int GameWindowPrompt()
diskImg2.SetAngle(angle); diskImg2.SetAngle(angle);
diskImg2.SetBeta(180); diskImg2.SetBeta(180);
char PlayCnt[25] = "";
GuiText playcntTxt(PlayCnt, 18, (GXColor){THEME.info_r, THEME.info_g, THEME.info_b, 255});
playcntTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
playcntTxt.SetPosition(-115,45);
GuiButton btn1(160, 160); GuiButton btn1(160, 160);
btn1.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); btn1.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
btn1.SetPosition(0, -20); btn1.SetPosition(0, -20);
@ -1116,6 +1129,17 @@ int GameWindowPrompt()
btn3.SetTrigger(&trigA); btn3.SetTrigger(&trigA);
btn3.SetEffectGrow(); btn3.SetEffectGrow();
GuiImage btnFavoriteImg;
btnFavoriteImg.SetWidescreen(CFG.widescreen);
GuiButton btnFavorite(imgFavorite.GetWidth(), imgFavorite.GetHeight());
btnFavorite.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
btnFavorite.SetPosition(-125, -60);
btnFavorite.SetImage(&btnFavoriteImg);
btnFavorite.SetSoundOver(&btnSoundOver);
btnFavorite.SetSoundClick(&btnClick);
btnFavorite.SetTrigger(&trigA);
btnFavorite.SetEffectGrow();
GuiImage btnLeftImg(&imgLeft); GuiImage btnLeftImg(&imgLeft);
GuiButton btnLeft(imgLeft.GetWidth(), imgLeft.GetHeight()); GuiButton btnLeft(imgLeft.GetWidth(), imgLeft.GetHeight());
btnLeft.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); btnLeft.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
@ -1141,10 +1165,12 @@ int GameWindowPrompt()
promptWindow.Append(&dialogBoxImg); promptWindow.Append(&dialogBoxImg);
promptWindow.Append(&nameBtn); promptWindow.Append(&nameBtn);
promptWindow.Append(&sizeTxt); promptWindow.Append(&sizeTxt);
promptWindow.Append(&playcntTxt);
// promptWindow.Append(&btn1); // move down at last apended // promptWindow.Append(&btn1); // move down at last apended
promptWindow.Append(&btn2); promptWindow.Append(&btn2);
promptWindow.Append(&btnLeft); promptWindow.Append(&btnLeft);
promptWindow.Append(&btnRight); promptWindow.Append(&btnRight);
promptWindow.Append(&btnFavorite);
//check if unlocked //check if unlocked
if (CFG.godmode == 1) if (CFG.godmode == 1)
@ -1269,6 +1295,19 @@ int GameWindowPrompt()
diskImg.SetImage(diskCover); diskImg.SetImage(diskCover);
sizeTxt.SetText(sizeText); sizeTxt.SetText(sizeText);
nameTxt.SetText(gameName); nameTxt.SetText(gameName);
struct Game_NUM* game_num = CFG_get_game_num(header->id);
if (game_num) {
playCount = game_num->count;
faveChoice = game_num->favorite;
} else {
playCount = 0;
faveChoice = 0;
}
sprintf(PlayCnt,"%s: %i",LANGUAGE.Plays, playCount);
playcntTxt.SetText(PlayCnt);
btnFavoriteImg.SetImage(faveChoice ? &imgFavorite : &imgNotFavorite);
char* pch; char* pch;
pch=strrchr((gameName),'_'); pch=strrchr((gameName),'_');
@ -1340,6 +1379,22 @@ int GameWindowPrompt()
choice = 3; choice = 3;
promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50);
} }
else if(btnFavorite.GetState() == STATE_CLICKED){//switch favorite
if(isSdInserted() == 1) {
faveChoice = !faveChoice;
btnFavoriteImg.SetImage(faveChoice ? &imgFavorite : &imgNotFavorite);
extern u8 favorite;
struct Game_NUM* game_num = CFG_get_game_num(header->id);
if (game_num) {
favorite = game_num->favorite;
}
favorite = faveChoice;
CFG_save_game_num(header->id);
}
btnFavorite.ResetState();
}
// this next part is long because nobody could agree on what the left/right buttons should do // this next part is long because nobody could agree on what the left/right buttons should do
else if((btnRight.GetState() == STATE_CLICKED) && (Settings.xflip == no)){//next game else if((btnRight.GetState() == STATE_CLICKED) && (Settings.xflip == no)){//next game
promptWindow.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 50); promptWindow.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 50);
@ -2324,26 +2379,24 @@ s32 __Menu_GetEntries(void)
/* Get header list */ /* Get header list */
ret = WBFS_GetHeaders(buffer, cnt, sizeof(struct discHdr)); ret = WBFS_GetHeaders(buffer, cnt, sizeof(struct discHdr));
if (ret < 0) if (ret < 0) {
goto err; if(buffer) free(buffer);
return ret;
}
/////////////show favorites only/////////////////////// /* Filters */
if (Settings.sort==fave){ if (Settings.sort==fave || dispFave) {
u32 cnt2 = 0; u32 cnt2 = 0;
for (u32 i = 0; i < cnt; i++) for (u32 i = 0; i < cnt; i++)
{ {
header = &buffer[i]; header = &buffer[i];
u8 favorite = 0; u8 favorite = 0;
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) {
{ favorite = game_num->favorite;
favorite = game_num->favorite;} }
if (favorite==1) if (favorite==1) {
//if (get_block(header) < CFG.parentalcontrol)
{
buffer2 = (discHdr *) realloc(buffer2, (cnt2+1) * sizeof(struct discHdr)); buffer2 = (discHdr *) realloc(buffer2, (cnt2+1) * sizeof(struct discHdr));
if (!buffer2) if (!buffer2)
{ {
@ -2359,12 +2412,8 @@ s32 __Menu_GetEntries(void)
buffer = buffer2; buffer = buffer2;
buffer2 = NULL; buffer2 = NULL;
cnt = cnt2; cnt = cnt2;
//if (cnt==0){Settings.sort=all;__Menu_GetEntries();}
qsort(buffer, cnt, sizeof(struct discHdr), __Menu_EntryCmp);
} }
else {
if (CFG.parentalcontrol && !CFG.godmode) if (CFG.parentalcontrol && !CFG.godmode)
{ {
u32 cnt2 = 0; u32 cnt2 = 0;
@ -2388,14 +2437,14 @@ s32 __Menu_GetEntries(void)
buffer = buffer2; buffer = buffer2;
buffer2 = NULL; buffer2 = NULL;
cnt = cnt2; cnt = cnt2;
}if (Settings.sort==all){qsort(buffer, cnt, sizeof(struct discHdr), __Menu_EntryCmp);}
else //if (Settings.sort==pcount)
{qsort(buffer, cnt, sizeof(struct discHdr), __Menu_EntryCmpCount);}
} }
if (Settings.sort==pcount) {
/* Sort entries */ qsort(buffer, cnt, sizeof(struct discHdr), __Menu_EntryCmpCount);
//qsort(buffer, cnt, sizeof(struct discHdr), __Menu_EntryCmp); }
else {
qsort(buffer, cnt, sizeof(struct discHdr), __Menu_EntryCmp);
}
/* Free memory */ /* Free memory */
if (gameList) if (gameList)
@ -2403,19 +2452,13 @@ s32 __Menu_GetEntries(void)
/* Set values */ /* Set values */
gameList = buffer; gameList = buffer;
buffer = NULL;
gameCnt = cnt; gameCnt = cnt;
/* Reset variables */ /* Reset variables */
gameSelected = gameStart = 0; gameSelected = gameStart = 0;
return 0; return 0;
err:
/* Free memory */
if (buffer)
free(buffer);
return ret;
} }
/**************************************************************************** /****************************************************************************
@ -2827,6 +2870,11 @@ static int MenuDiscList()
snprintf(imgPath, sizeof(imgPath), "%sbattery_bar.png", CFG.theme_path); snprintf(imgPath, sizeof(imgPath), "%sbattery_bar.png", CFG.theme_path);
GuiImageData batteryBar(imgPath, battery_bar_png); GuiImageData batteryBar(imgPath, battery_bar_png);
snprintf(imgPath, sizeof(imgPath), "%sfavorite.png", CFG.theme_path);
GuiImageData imgFavoriteOn(imgPath, favorite_png);
snprintf(imgPath, sizeof(imgPath), "%snot_favorite.png", CFG.theme_path);
GuiImageData imgFavoriteOff(imgPath, not_favorite_png);
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);
GuiTrigger trigHome; GuiTrigger trigHome;
@ -2946,6 +2994,17 @@ static int MenuDiscList()
wiiBtn.SetSoundClick(&btnClick); wiiBtn.SetSoundClick(&btnClick);
wiiBtn.SetTrigger(&trigA); wiiBtn.SetTrigger(&trigA);
GuiImage favoriteBtnImg(dispFave ? &imgFavoriteOn : &imgFavoriteOff);;
favoriteBtnImg.SetWidescreen(CFG.widescreen);
GuiButton favoriteBtn(imgFavoriteOn.GetWidth(), imgFavoriteOn.GetHeight());
favoriteBtn.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
favoriteBtn.SetPosition(-90, 105);
favoriteBtn.SetImage(&favoriteBtnImg);
favoriteBtn.SetSoundOver(&btnSoundOver);
favoriteBtn.SetSoundClick(&btnClick);
favoriteBtn.SetTrigger(&trigA);
favoriteBtn.SetEffectGrow();
//Downloading Covers //Downloading Covers
GuiTooltip DownloadBtnTT(LANGUAGE.ClicktoDownloadCovers); GuiTooltip DownloadBtnTT(LANGUAGE.ClicktoDownloadCovers);
if (Settings.wsprompt == yes) if (Settings.wsprompt == yes)
@ -2997,6 +3056,7 @@ static int MenuDiscList()
w.Append(&homeBtn); w.Append(&homeBtn);
w.Append(&settingsBtn); w.Append(&settingsBtn);
w.Append(&DownloadBtn); w.Append(&DownloadBtn);
w.Append(&favoriteBtn);
if((Settings.hddinfo == hr12)||(Settings.hddinfo == hr24)) if((Settings.hddinfo == hr12)||(Settings.hddinfo == hr24))
{ {
@ -3200,6 +3260,16 @@ static int MenuDiscList()
} }
else if(favoriteBtn.GetState() == STATE_CLICKED)
{
dispFave = !dispFave;
__Menu_GetEntries();
gameBrowser.Reload(gameList, gameCnt);
sprintf(GamesCnt,"%s: %i",LANGUAGE.Games, gameCnt);
gamecntTxt.SetText(GamesCnt);
favoriteBtnImg.SetImage(dispFave ? &imgFavoriteOn : &imgFavoriteOff);
favoriteBtn.ResetState();
}
//Get selected game under cursor //Get selected game under cursor
int selectimg;//, promptnumber; int selectimg;//, promptnumber;