Skip to content

Commit

Permalink
Improve and localize time played in game list
Browse files Browse the repository at this point in the history
  • Loading branch information
Fs00 committed Sep 12, 2023
1 parent 3ef0a42 commit deadcef
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/generate_pot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ jobs:
- name: "Generate POT file using xgettext"
run: >
find src -name *.cpp -o -name *.hpp -o -name *.h |
xargs xgettext --from-code=utf-8
-k_ -kwxTRANSLATE -w 100
xargs xgettext --from-code=utf-8 -w 100
--keyword="_" --keyword="wxTRANSLATE" --keyword="wxPLURAL:1,2"
--check=space-ellipsis --omit-header
-o cemu.pot
Expand Down
19 changes: 12 additions & 7 deletions src/gui/components/wxGameList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1009,15 +1009,20 @@ void wxGameList::OnGameEntryUpdatedByTitleId(wxTitleIdEvent& event)
if (iosu::pdm::GetStatForGamelist(baseTitleId, playTimeStat))
{
// time played
uint32 timePlayed = playTimeStat.numMinutesPlayed * 60;
if (timePlayed == 0)
uint32 minutesPlayed = playTimeStat.numMinutesPlayed;
if (minutesPlayed == 0)
SetItem(index, ColumnGameTime, wxEmptyString);
else if (timePlayed < 60)
SetItem(index, ColumnGameTime, fmt::format("{} seconds", timePlayed));
else if (timePlayed < 60 * 60)
SetItem(index, ColumnGameTime, fmt::format("{} minutes", timePlayed / 60));
else if (minutesPlayed < 60)
SetItem(index, ColumnGameTime, formatWxString(wxPLURAL("{} minute", "{} minutes", minutesPlayed), minutesPlayed));
else
SetItem(index, ColumnGameTime, fmt::format("{} hours {} minutes", timePlayed / 3600, (timePlayed / 60) % 60));
{
uint32 hours = minutesPlayed / 60;
uint32 minutes = minutesPlayed % 60;
wxString hoursText = formatWxString(wxPLURAL("{} hour", "{} hours", hours), hours);
wxString minutesText = formatWxString(wxPLURAL("{} minute", "{} minutes", minutes), minutes);
SetItem(index, ColumnGameTime, hoursText + " " + minutesText);
}

// last played
if (playTimeStat.last_played.year != 0)
{
Expand Down

0 comments on commit deadcef

Please sign in to comment.