diff options
| author | SamusAranX <hallo@emmalyx.site> | 2023-05-12 01:56:37 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-12 01:56:37 +0200 |
| commit | 531da8a1c0760c8ebf121ac83ba4c840ead9e443 (patch) | |
| tree | 1cc849b054d33f0981444e9ba7323c0a15235f92 /src/Ryujinx.Ui.Common/App/ApplicationData.cs | |
| parent | 5cbdfbc7a4b7413a4f633c77190a79bfc6520e98 (diff) | |
Changed LastPlayed field from string to nullable DateTime (#4861)
* Changed LastPlayed field from string to nullable DateTime
Added ApplicationData.LastPlayedString property
Added NullableDateTimeConverter for the DateTime->string conversion in Avalonia
* Added migration from string-based last_played to DateTime-based last_played_utc
* Updated comment style
* Added MarkupExtension to NullableDateTimeConverter and changed its usage
Cleaned up leftover usings
* Missed one comment
Diffstat (limited to 'src/Ryujinx.Ui.Common/App/ApplicationData.cs')
| -rw-r--r-- | src/Ryujinx.Ui.Common/App/ApplicationData.cs | 45 |
1 files changed, 31 insertions, 14 deletions
diff --git a/src/Ryujinx.Ui.Common/App/ApplicationData.cs b/src/Ryujinx.Ui.Common/App/ApplicationData.cs index d9d3cf68..f0aa40be 100644 --- a/src/Ryujinx.Ui.Common/App/ApplicationData.cs +++ b/src/Ryujinx.Ui.Common/App/ApplicationData.cs @@ -10,27 +10,44 @@ using LibHac.Tools.FsSystem.NcaUtils; using Ryujinx.Common.Logging; using Ryujinx.HLE.FileSystem; using System; +using System.Globalization; using System.IO; +using System.Text.Json.Serialization; namespace Ryujinx.Ui.App.Common { public class ApplicationData { - public bool Favorite { get; set; } - public byte[] Icon { get; set; } - public string TitleName { get; set; } - public string TitleId { get; set; } - public string Developer { get; set; } - public string Version { get; set; } - public string TimePlayed { get; set; } - public double TimePlayedNum { get; set; } - public string LastPlayed { get; set; } - public string FileExtension { get; set; } - public string FileSize { get; set; } - public double FileSizeBytes { get; set; } - public string Path { get; set; } + public bool Favorite { get; set; } + public byte[] Icon { get; set; } + public string TitleName { get; set; } + public string TitleId { get; set; } + public string Developer { get; set; } + public string Version { get; set; } + public string TimePlayed { get; set; } + public double TimePlayedNum { get; set; } + public DateTime? LastPlayed { get; set; } + public string FileExtension { get; set; } + public string FileSize { get; set; } + public double FileSizeBytes { get; set; } + public string Path { get; set; } public BlitStruct<ApplicationControlProperty> ControlHolder { get; set; } - + + [JsonIgnore] + public string LastPlayedString + { + get + { + if (!LastPlayed.HasValue) + { + // TODO: maybe put localized string here instead of just "Never" + return "Never"; + } + + return LastPlayed.Value.ToLocalTime().ToString(CultureInfo.CurrentCulture); + } + } + public static string GetApplicationBuildId(VirtualFileSystem virtualFileSystem, string titleFilePath) { using FileStream file = new(titleFilePath, FileMode.Open, FileAccess.Read); |
