From 62163b65122f26d62df27477f833cedf7cc58eca Mon Sep 17 00:00:00 2001 From: "e.bovendeur" Date: Tue, 13 Oct 2009 10:47:56 +0000 Subject: [PATCH] * Changed the favorite icon to 5 stars, which can be used as a ranking system. The more stars are selected, the higher the game will show up in the favorites list. Games without stars are not shown in the favorite list. * Changed credit screen. --- gui.pnproj | 2 +- gui.pnps | 2 +- source/filelist.h | 3 + source/images/rankIcon.png | Bin 0 -> 1548 bytes source/menu.cpp | 10 +- source/prompts/PromptWindows.cpp | 153 +++++++++++++++++++++++-------- source/usbloader/getentries.cpp | 26 ++++++ 7 files changed, 154 insertions(+), 42 deletions(-) create mode 100644 source/images/rankIcon.png diff --git a/gui.pnproj b/gui.pnproj index 0f61edd0..c79b05df 100644 --- a/gui.pnproj +++ b/gui.pnproj @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/gui.pnps b/gui.pnps index bef7a483..270f2823 100644 --- a/gui.pnps +++ b/gui.pnps @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/source/filelist.h b/source/filelist.h index 4f20712f..76716fb3 100644 --- a/source/filelist.h +++ b/source/filelist.h @@ -344,6 +344,9 @@ extern const u32 searchIcon_png_size; extern const u8 abcIcon_png[]; extern const u32 abcIcon_png_size; +extern const u8 rankIcon_png[]; +extern const u32 rankIcon_png_size; + extern const u8 playCountIcon_png[]; extern const u32 playCountIcon_png_size; diff --git a/source/images/rankIcon.png b/source/images/rankIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..6861a7bf3d8d7867d1fed87e7ab4ae099f66f185 GIT binary patch literal 1548 zcmV+n2J`ueP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D02g#cSaefwW^{L9 za%BKeVQFr3E>1;MAa*k@HN8cn$p8Qaen~_@R9HvNnAvX=R}{wQzw0~O3p}9mP!JUo z2n0$CL?H{IBn^w>VqrV06Ypa?-pBhAOiB{l*`3u1PJpzas_WC&`(4SrW(+U3^m#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1}Db`pHA+dTb9{$mi(gM;h76^39;c&=iX+H8; zqgJa`uC@vH_}MVRVin#>3^I{T85M7lm0gtH{n@e#^<#Ka1sKg%{5j9oy$B+`vy%Gkr5`#=+Q^vGBVrzSt`|#Hni=b+*gi*H-M#~6>%_Eo$iTQG2 z<%`E86WJ77Y8Hw0ea!#%&sXWq@!u#lK8hbjM=0zbf%{)GCYi`40ER#Z*2Y&6OM0000SetPosition(70,y); i++; - txt[i] = new GuiText("dimok / nIxx"); + txt[i] = new GuiText("nIxx / giantpune"); txt[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP); txt[i]->SetPosition(220,y); i++; - y+=24; + y+=22; - txt[i] = new GuiText("giantpune / ardi"); + txt[i] = new GuiText("ardi / lustar"); txt[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP); txt[i]->SetPosition(220,y); i++; - y+=24; + y+=22; + + txt[i] = new GuiText("r-win"); + txt[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP); + txt[i]->SetPosition(220,y); + i++; + y+=22; char text[100]; - sprintf(text, "hungyip84 / DrayX7 %s", tr("(both retired)")); + sprintf(text, "hungyip84 / DrayX7 %s", tr("(retired)")); txt[i] = new GuiText(text); txt[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP); txt[i]->SetPosition(220,y); i++; - y+=24; + y+=22; - txt[i] = new GuiText("lustar"); + sprintf(text, "dimok %s", tr("(retired)")); + txt[i] = new GuiText(text); txt[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP); txt[i]->SetPosition(220,y); i++; @@ -276,20 +283,20 @@ void WindowCredits() { txt[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP); txt[i]->SetPosition(220,y); i++; - y+=24; + y+=22; sprintf(text, "CorneliousJD %s", tr("for hosting the update files")); txt[i] = new GuiText(text); txt[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP); txt[i]->SetPosition(220,y); i++; - y+=30; + y+=22; txt[i] = new GuiText(tr("Special thanks to:")); txt[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP); txt[i]->SetPosition(70,y); i++; - y+=24; + y+=22; sprintf(text, "Waninkoko, Kwiirk & Hermes %s", tr("for the USB Loader source")); txt[i] = new GuiText(text); @@ -980,6 +987,41 @@ WindowExitPrompt(const char *title, const char *msg, const char *btn1Label, return choice; } +void SetupFavoriteButton(GuiButton *btnFavorite, int xPos, GuiImage *img, GuiSound *sndOver, GuiSound *sndClick, GuiTrigger *trig) +{ + btnFavorite->SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); + btnFavorite->SetPosition(xPos, -60); + btnFavorite->SetImage(img); + btnFavorite->SetSoundOver(sndOver); + btnFavorite->SetSoundClick(sndClick); + btnFavorite->SetTrigger(trig); + btnFavorite->SetEffectGrow(); +} + +u8 SetFavorite(GuiButton *fav1, GuiButton *fav2, GuiButton *fav3, GuiButton *fav4, GuiButton *fav5, u8* gameId, u8 favorite) +{ + struct Game_NUM * game_num = CFG_get_game_num(gameId); + if (game_num) { + favoritevar = game_num->favorite; + playcount = game_num->count; + } else { + favoritevar = 0; + playcount = 0; + } + favoritevar = (favorite == favoritevar) ? 0 : favorite; // Press the current rank to reset the rank + CFG_save_game_num(gameId); + return favoritevar; +} + +void SetFavoriteImages(GuiImage *b1, GuiImage *b2, GuiImage *b3, GuiImage *b4, GuiImage *b5, GuiImageData *on, GuiImageData *off) +{ + b1->SetImage(favoritevar >= 1 ? on : off); + b2->SetImage(favoritevar >= 2 ? on : off); + b3->SetImage(favoritevar >= 3 ? on : off); + b4->SetImage(favoritevar >= 4 ? on : off); + b5->SetImage(favoritevar >= 5 ? on : off); +} + /**************************************************************************** * GameWindowPrompt * @@ -1111,17 +1153,29 @@ int GameWindowPrompt() { GuiButton btn3(&btn3Img,&btn3Img, 0, 4, 50, -40, &trigA, &btnSoundOver, &btnClick,1); btn3.SetLabel(&btn3Txt); - GuiImage btnFavoriteImg; - btnFavoriteImg.SetWidescreen(CFG.widescreen); + GuiImage btnFavoriteImg1; + btnFavoriteImg1.SetWidescreen(CFG.widescreen); + GuiImage btnFavoriteImg2; + btnFavoriteImg2.SetWidescreen(CFG.widescreen); + GuiImage btnFavoriteImg3; + btnFavoriteImg3.SetWidescreen(CFG.widescreen); + GuiImage btnFavoriteImg4; + btnFavoriteImg4.SetWidescreen(CFG.widescreen); + GuiImage btnFavoriteImg5; + btnFavoriteImg5.SetWidescreen(CFG.widescreen); + //GuiButton btnFavorite(&btnFavoriteImg,&btnFavoriteImg, 2, 5, -125, -60, &trigA, &btnSoundOver, &btnClick,1); - 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(); + GuiButton btnFavorite1(imgFavorite.GetWidth(), imgFavorite.GetHeight()); + GuiButton btnFavorite2(imgFavorite.GetWidth(), imgFavorite.GetHeight()); + GuiButton btnFavorite3(imgFavorite.GetWidth(), imgFavorite.GetHeight()); + GuiButton btnFavorite4(imgFavorite.GetWidth(), imgFavorite.GetHeight()); + GuiButton btnFavorite5(imgFavorite.GetWidth(), imgFavorite.GetHeight()); + + SetupFavoriteButton(&btnFavorite1, -198, &btnFavoriteImg1, &btnSoundOver, &btnClick, &trigA); + SetupFavoriteButton(&btnFavorite2, -171, &btnFavoriteImg2, &btnSoundOver, &btnClick, &trigA); + SetupFavoriteButton(&btnFavorite3, -144, &btnFavoriteImg3, &btnSoundOver, &btnClick, &trigA); + SetupFavoriteButton(&btnFavorite4, -117, &btnFavoriteImg4, &btnSoundOver, &btnClick, &trigA); + SetupFavoriteButton(&btnFavorite5, -90, &btnFavoriteImg5, &btnSoundOver, &btnClick, &trigA); GuiImage btnLeftImg(&imgLeft); if (Settings.wsprompt == yes) { @@ -1148,7 +1202,11 @@ int GameWindowPrompt() { promptWindow.Append(&sizeTxt); promptWindow.Append(&btnLeft); promptWindow.Append(&btnRight); - promptWindow.Append(&btnFavorite); + promptWindow.Append(&btnFavorite1); + promptWindow.Append(&btnFavorite2); + promptWindow.Append(&btnFavorite3); + promptWindow.Append(&btnFavorite4); + promptWindow.Append(&btnFavorite5); } //check if unlocked @@ -1277,7 +1335,7 @@ int GameWindowPrompt() { favoritevar = 0; } playcntTxt.SetTextf("%s: %i",tr("Play Count"), playcount); - btnFavoriteImg.SetImage(favoritevar ? &imgFavorite : &imgNotFavorite); + SetFavoriteImages(&btnFavoriteImg1, &btnFavoriteImg2, &btnFavoriteImg3, &btnFavoriteImg4, &btnFavoriteImg5, &imgFavorite, &imgNotFavorite); nameTxt.SetPosition(0, 1); @@ -1340,25 +1398,46 @@ int GameWindowPrompt() { choice = 3; promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); } - - else if (btnFavorite.GetState() == STATE_CLICKED) {//switch favorite + else if (btnFavorite1.GetState() == STATE_CLICKED) {//switch favorite //if(isSdInserted()) { if (isInserted(bootDevice)) { - struct Game_NUM * game_num = CFG_get_game_num(header->id); - if (game_num) { - playcount = game_num->count; - favoritevar = game_num->favorite; - } else { - playcount = 0; - favoritevar = 0; - } - favoritevar = (favoritevar + 1) % 2; - CFG_save_game_num(header->id); - btnFavoriteImg.SetImage(favoritevar ? &imgFavorite : &imgNotFavorite); + SetFavorite(&btnFavorite1, &btnFavorite2, &btnFavorite3, &btnFavorite4, &btnFavorite5, header->id, 1); + SetFavoriteImages(&btnFavoriteImg1, &btnFavoriteImg2, &btnFavoriteImg3, &btnFavoriteImg4, &btnFavoriteImg5, &imgFavorite, &imgNotFavorite); } - btnFavorite.ResetState(); + btnFavorite1.ResetState(); + } + else if (btnFavorite2.GetState() == STATE_CLICKED) {//switch favorite + //if(isSdInserted()) { + if (isInserted(bootDevice)) { + SetFavorite(&btnFavorite1, &btnFavorite2, &btnFavorite3, &btnFavorite4, &btnFavorite5, header->id, 2); + SetFavoriteImages(&btnFavoriteImg1, &btnFavoriteImg2, &btnFavoriteImg3, &btnFavoriteImg4, &btnFavoriteImg5, &imgFavorite, &imgNotFavorite); + } + btnFavorite2.ResetState(); + } + else if (btnFavorite3.GetState() == STATE_CLICKED) {//switch favorite + //if(isSdInserted()) { + if (isInserted(bootDevice)) { + SetFavorite(&btnFavorite1, &btnFavorite2, &btnFavorite3, &btnFavorite4, &btnFavorite5, header->id, 3); + SetFavoriteImages(&btnFavoriteImg1, &btnFavoriteImg2, &btnFavoriteImg3, &btnFavoriteImg4, &btnFavoriteImg5, &imgFavorite, &imgNotFavorite); + } + btnFavorite3.ResetState(); + } + else if (btnFavorite4.GetState() == STATE_CLICKED) {//switch favorite + //if(isSdInserted()) { + if (isInserted(bootDevice)) { + SetFavorite(&btnFavorite1, &btnFavorite2, &btnFavorite3, &btnFavorite4, &btnFavorite5, header->id, 4); + SetFavoriteImages(&btnFavoriteImg1, &btnFavoriteImg2, &btnFavoriteImg3, &btnFavoriteImg4, &btnFavoriteImg5, &imgFavorite, &imgNotFavorite); + } + btnFavorite4.ResetState(); + } + else if (btnFavorite5.GetState() == STATE_CLICKED) {//switch favorite + //if(isSdInserted()) { + if (isInserted(bootDevice)) { + SetFavorite(&btnFavorite1, &btnFavorite2, &btnFavorite3, &btnFavorite4, &btnFavorite5, header->id, 5); + SetFavoriteImages(&btnFavoriteImg1, &btnFavoriteImg2, &btnFavoriteImg3, &btnFavoriteImg4, &btnFavoriteImg5, &imgFavorite, &imgNotFavorite); + } + btnFavorite5.ResetState(); } - // 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 promptWindow.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 50); diff --git a/source/usbloader/getentries.cpp b/source/usbloader/getentries.cpp index 09972e58..5f818b84 100644 --- a/source/usbloader/getentries.cpp +++ b/source/usbloader/getentries.cpp @@ -96,6 +96,28 @@ s32 __Menu_EntryCmpCount(const void *a, const void *b) { return ret; } + +s32 __Menu_EntryCmpFavorite(const void *a, const void *b) { + s32 ret; + + struct discHdr *hdr1 = (struct discHdr *)a; + + struct discHdr *hdr2 = (struct discHdr *)b; + + /* Compare Favorite (rank) */ + u16 fav1 = 0; + u16 fav2 = 0; + struct Game_NUM* game_num1 = CFG_get_game_num(hdr1->id); + struct Game_NUM* game_num2 = CFG_get_game_num(hdr2->id); + + if (game_num1) fav1 = game_num1->favorite; + if (game_num2) fav2 = game_num2->favorite; + + ret = (s32) (fav2-fav1); + if (ret == 0) return stricmp(get_title(hdr1), get_title(hdr2)); + + return ret; +} /**************************************************************************** * Get PrevFilter ***************************************************************************/ @@ -396,6 +418,8 @@ int buildTitleList(int t, wchar_t* gameFilter, discHdr ** PgameList, u32 *PgameC if (Settings.sort==pcount) { qsort(buffer, cnt, sizeof(struct discHdr), __Menu_EntryCmpCount); + } else if (Settings.fave) { + qsort(buffer, cnt, sizeof(struct discHdr), __Menu_EntryCmpFavorite); } else { qsort(buffer, cnt, sizeof(struct discHdr), __Menu_EntryCmp); } @@ -481,6 +505,8 @@ int __Menu_GetGameList(int t, wchar_t* gameFilter, discHdr ** PgameList, u32 *Pg if (Settings.sort==pcount) { qsort(buffer, cnt, sizeof(struct discHdr), __Menu_EntryCmpCount); + } else if (Settings.fave) { + qsort(buffer, cnt, sizeof(struct discHdr), __Menu_EntryCmpFavorite); } else { qsort(buffer, cnt, sizeof(struct discHdr), __Menu_EntryCmp); }