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 00000000..6861a7bf Binary files /dev/null and b/source/images/rankIcon.png differ diff --git a/source/menu.cpp b/source/menu.cpp index c294b222..8ee5fdf8 100644 --- a/source/menu.cpp +++ b/source/menu.cpp @@ -417,6 +417,10 @@ int MenuDiscList() { GuiImageData imgabcIcon(imgPath, abcIcon_png); snprintf(imgPath, sizeof(imgPath), "%sabcIcon_gray.png", CFG.theme_path); GuiImageData imgabcIcon_gray(imgPath, NULL); + snprintf(imgPath, sizeof(imgPath), "%srankIcon.png", CFG.theme_path); + GuiImageData imgrankIcon(imgPath, rankIcon_png); + snprintf(imgPath, sizeof(imgPath), "%srankIcon_gray.png", CFG.theme_path); + GuiImageData imgrankIcon_gray(imgPath, NULL); snprintf(imgPath, sizeof(imgPath), "%splayCountIcon.png", CFG.theme_path); GuiImageData imgplayCountIcon(imgPath, playCountIcon_png); snprintf(imgPath, sizeof(imgPath), "%splayCountIcon_gray.png", CFG.theme_path); @@ -568,14 +572,14 @@ int MenuDiscList() { GuiButton searchBtn(&searchBtnImg_g,&searchBtnImg_g, ALIGN_LEFT, ALIGN_TOP, THEME.gamelist_search_x, THEME.gamelist_search_y, &trigA, &btnSoundOver, &btnClick,1, &searchBtnTT, -15, 52, 0, 3); searchBtn.SetAlpha(180); - GuiTooltip abcBtnTT(tr("Sort alphabetically")); + GuiTooltip abcBtnTT(Settings.fave ? tr("Sort by rank") : tr("Sort alphabetically")); if (Settings.wsprompt == yes) abcBtnTT.SetWidescreen(CFG.widescreen); abcBtnTT.SetAlpha(THEME.tooltipAlpha); - GuiImage abcBtnImg(&imgabcIcon); + GuiImage abcBtnImg(Settings.fave ? &imgrankIcon : &imgabcIcon); abcBtnImg.SetWidescreen(CFG.widescreen); // GuiImage abcBtnImg_g(abcBtnImg); abcBtnImg_g.SetGrayscale(); - GuiImage abcBtnImg_g(&imgabcIcon_gray); + GuiImage abcBtnImg_g(Settings.fave ? &imgrankIcon_gray : &imgabcIcon_gray); if(abcBtnImg_g.GetImage() == NULL) { abcBtnImg_g = abcBtnImg; abcBtnImg_g.SetGrayscale();} abcBtnImg_g.SetWidescreen(CFG.widescreen); GuiButton abcBtn(&abcBtnImg_g,&abcBtnImg_g, ALIGN_LEFT, ALIGN_TOP, THEME.gamelist_abc_x, THEME.gamelist_abc_y, &trigA, &btnSoundOver, &btnClick,1,&abcBtnTT, -15, 52, 0, 3); diff --git a/source/prompts/PromptWindows.cpp b/source/prompts/PromptWindows.cpp index 436244d7..63d4220f 100644 --- a/source/prompts/PromptWindows.cpp +++ b/source/prompts/PromptWindows.cpp @@ -222,28 +222,35 @@ void WindowCredits() { txt[i]->SetPosition(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); }