UI: Show Total Time Played at the bottom of the UI in the status bar next to game total.

Does not show up in-game, and is recalculated every time the game list is reloaded.
This commit is contained in:
GreemDev 2025-05-20 04:19:54 -05:00
parent df3b5b4bd8
commit 92440afcd7
5 changed files with 95 additions and 2 deletions

View file

@ -25,6 +25,7 @@ using Ryujinx.Ava.UI.Renderer;
using Ryujinx.Ava.UI.Windows;
using Ryujinx.Ava.Systems.AppLibrary;
using Ryujinx.Ava.Systems.Configuration;
using Ryujinx.Ava.Utilities;
using Ryujinx.Common;
using Ryujinx.Common.Configuration;
using Ryujinx.Common.Helper;
@ -112,6 +113,7 @@ namespace Ryujinx.Ava.UI.ViewModels
await Updater.BeginUpdateAsync(true);
});
private bool _showTotalTimePlayed;
private bool _showLoadProgress;
private bool _isGameRunning;
private bool _isAmiiboRequested;
@ -197,6 +199,8 @@ namespace Ryujinx.Ava.UI.ViewModels
#if DEBUG
topLevel.AttachDevTools(new KeyGesture(Avalonia.Input.Key.F12, KeyModifiers.Control));
#endif
Window.ApplicationLibrary.TotalTimePlayedRecalculated += TotalTimePlayed_Recalculated;
}
#region Properties
@ -299,6 +303,24 @@ namespace Ryujinx.Ava.UI.ViewModels
OnPropertyChanged(nameof(ShowFirmwareStatus));
}
}
private void TotalTimePlayed_Recalculated(Optional<TimeSpan> ts)
{
ShowTotalTimePlayed = ts.HasValue;
if (ts.HasValue)
LocaleManager.Instance.SetDynamicValues(LocaleKeys.GameListLabelTotalTimePlayed, ValueFormatUtils.FormatTimeSpan(ts.Value));
}
public bool ShowTotalTimePlayed
{
get => _showTotalTimePlayed && EnableNonGameRunningControls;
set
{
_showTotalTimePlayed = value;
OnPropertyChanged();
}
}
public ApplicationData ListSelectedApplication
{

View file

@ -29,7 +29,7 @@
Margin="5"
VerticalAlignment="Center"
IsVisible="{Binding EnableNonGameRunningControls}">
<Grid Margin="0" ColumnDefinitions="Auto,Auto,Auto,*">
<Grid Margin="0" ColumnDefinitions="Auto,Auto,Auto,*,Auto,Auto,*">
<Button
Width="25"
Height="25"
@ -68,6 +68,14 @@
IsVisible="{Binding StatusBarVisible}"
Maximum="{Binding StatusBarProgressMaximum}"
Value="{Binding StatusBarProgressValue}" />
<controls:MiniVerticalSeparator Grid.Column="4" IsVisible="{Binding ShowTotalTimePlayed}" />
<TextBlock
Grid.Column="5"
Margin="5,0,5,0"
VerticalAlignment="Center"
IsVisible="{Binding ShowTotalTimePlayed}"
Text="{ext:Locale GameListLabelTotalTimePlayed}">
</TextBlock>
</Grid>
</StackPanel>
<StackPanel

View file

@ -717,6 +717,8 @@ namespace Ryujinx.Ava.UI.Windows
ShowNewContentAddedDialog(dlcLoaded, dlcRemoved, updatesLoaded, updatesRemoved);
}
Executor.ExecuteBackgroundAsync(ApplicationLibrary.RefreshTotalTimePlayedAsync);
_isLoading = false;
})