Skip to content

Commit

Permalink
[UI/UX] Add sort by caught/hatched count to starter select (#5161)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fontbane authored Jan 20, 2025
1 parent d85aedb commit 39283e3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/ui/dropdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ export enum SortCriteria {
COST = 1,
CANDY = 2,
IV = 3,
NAME = 4
NAME = 4,
CAUGHT = 5,
HATCHED = 6
}

export class DropDownLabel {
Expand Down
8 changes: 7 additions & 1 deletion src/ui/starter-select-ui-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,9 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
new DropDownOption(SortCriteria.COST, new DropDownLabel(i18next.t("filterBar:sortByCost"))),
new DropDownOption(SortCriteria.CANDY, new DropDownLabel(i18next.t("filterBar:sortByCandies"))),
new DropDownOption(SortCriteria.IV, new DropDownLabel(i18next.t("filterBar:sortByIVs"))),
new DropDownOption(SortCriteria.NAME, new DropDownLabel(i18next.t("filterBar:sortByName")))
new DropDownOption(SortCriteria.NAME, new DropDownLabel(i18next.t("filterBar:sortByName"))),
new DropDownOption(SortCriteria.CAUGHT, new DropDownLabel(i18next.t("filterBar:sortByNumCaught"))),
new DropDownOption(SortCriteria.HATCHED, new DropDownLabel(i18next.t("filterBar:sortByNumHatched")))
];
this.filterBar.addFilter(DropDownColumn.SORT, i18next.t("filterBar:sortFilter"), new DropDown(0, 0, sortOptions, this.updateStarters, DropDownType.SINGLE));
this.filterBarContainer.add(this.filterBar);
Expand Down Expand Up @@ -2698,6 +2700,10 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
return (avgIVsA - avgIVsB) * -sort.dir;
case SortCriteria.NAME:
return a.species.name.localeCompare(b.species.name) * -sort.dir;
case SortCriteria.CAUGHT:
return (globalScene.gameData.dexData[a.species.speciesId].caughtCount - globalScene.gameData.dexData[b.species.speciesId].caughtCount) * -sort.dir;
case SortCriteria.HATCHED:
return (globalScene.gameData.dexData[a.species.speciesId].hatchedCount - globalScene.gameData.dexData[b.species.speciesId].hatchedCount) * -sort.dir;
}
return 0;
});
Expand Down

0 comments on commit 39283e3

Please sign in to comment.