mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-07-02 13:01:18 +12:00
move date comparison code to date class declaration
This commit is contained in:
parent
15f8f87f52
commit
b605b359f4
3 changed files with 35 additions and 42 deletions
|
@ -464,5 +464,34 @@ namespace iosu
|
|||
return static_cast<IOSUModule*>(&sIOSUModuleNNPDM);
|
||||
}
|
||||
|
||||
|
||||
bool GameListStat::LastPlayDate::operator<(const LastPlayDate& b) const
|
||||
{
|
||||
const auto& a = *this;
|
||||
|
||||
if(a.year < b.year)
|
||||
return true;
|
||||
if(a.year > b.year)
|
||||
return false;
|
||||
|
||||
// same year
|
||||
if(a.month < b.month)
|
||||
return true;
|
||||
if(a.month > b.month)
|
||||
return false;
|
||||
|
||||
// same year and month
|
||||
return a.day < b.day;
|
||||
}
|
||||
|
||||
bool GameListStat::LastPlayDate::operator==(const LastPlayDate& b) const
|
||||
{
|
||||
const auto& a = *this;
|
||||
return a.year == b.year &&
|
||||
a.month == b.month &&
|
||||
a.day == b.day;
|
||||
}
|
||||
std::weak_ordering GameListStat::LastPlayDate::operator<=>(const LastPlayDate& b) const = default;
|
||||
|
||||
};
|
||||
};
|
||||
|
|
|
@ -21,11 +21,15 @@ namespace iosu
|
|||
/* Helper for UI game list */
|
||||
struct GameListStat
|
||||
{
|
||||
struct
|
||||
struct LastPlayDate
|
||||
{
|
||||
uint32 year; // if 0 -> never played
|
||||
uint32 month;
|
||||
uint32 day;
|
||||
|
||||
bool operator<(const LastPlayDate& b) const;
|
||||
bool operator==(const LastPlayDate& b) const;
|
||||
std::weak_ordering operator<=>(const LastPlayDate& b) const;
|
||||
}last_played;
|
||||
uint32 numMinutesPlayed;
|
||||
};
|
||||
|
|
|
@ -434,46 +434,6 @@ static inline int order_to_int(const std::weak_ordering &wo)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static bool operator<(const iosu::pdm::GameListStat& a, const iosu::pdm::GameListStat& b)
|
||||
{
|
||||
const auto& lastA = a.last_played;
|
||||
const auto& lastB = b.last_played;
|
||||
|
||||
if(lastA.year < lastB.year)
|
||||
return true;
|
||||
if(lastA.year > lastB.year)
|
||||
return false;
|
||||
|
||||
// same year
|
||||
if(lastA.month < lastB.month)
|
||||
return true;
|
||||
if(lastA.month > lastB.month)
|
||||
return false;
|
||||
|
||||
// same year and month
|
||||
return lastA.day < lastB.day;
|
||||
}
|
||||
|
||||
static bool operator==(const iosu::pdm::GameListStat& a, const iosu::pdm::GameListStat& b)
|
||||
{
|
||||
const auto& lastA = a.last_played;
|
||||
const auto& lastB = b.last_played;
|
||||
|
||||
return lastA.year == lastB.year &&
|
||||
lastA.month == lastB.month &&
|
||||
lastA.day == lastB.day;
|
||||
}
|
||||
|
||||
static std::weak_ordering operator<=>(const iosu::pdm::GameListStat& a, const iosu::pdm::GameListStat& b)
|
||||
{
|
||||
if (a == b)
|
||||
return std::weak_ordering::equivalent;
|
||||
if (a < b)
|
||||
return std::weak_ordering::less;
|
||||
else
|
||||
return std::weak_ordering::greater;
|
||||
}
|
||||
|
||||
std::weak_ordering wxGameList::SortComparator(uint64 titleId1, uint64 titleId2, SortData* sortData)
|
||||
{
|
||||
auto titleLastPlayed = [](uint64_t id)
|
||||
|
@ -508,7 +468,7 @@ std::weak_ordering wxGameList::SortComparator(uint64 titleId1, uint64 titleId2,
|
|||
return std::tie(isFavoriteB, nameA) <=> std::tie(isFavoriteA, nameB);
|
||||
}
|
||||
case ColumnGameStarted:
|
||||
return titleLastPlayed(titleId1) <=> titleLastPlayed(titleId2);
|
||||
return titleLastPlayed(titleId1).last_played <=> titleLastPlayed(titleId2).last_played;
|
||||
case ColumnGameTime:
|
||||
return titlePlayMinutes(titleId1) <=> titlePlayMinutes(titleId2);
|
||||
case ColumnRegion:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue