using System; using System.Text.Json.Serialization; namespace Ryujinx.Ava.Systems.AppLibrary { public class ApplicationMetadata { public string Title { get; set; } public bool Favorite { get; set; } [JsonPropertyName("timespan_played")] public TimeSpan TimePlayed { get; set; } = TimeSpan.Zero; [JsonPropertyName("last_played_utc")] public DateTime? LastPlayed { get; set; } = null; [JsonPropertyName("time_played")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] public double TimePlayedOld { get; set; } [JsonPropertyName("last_played")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] public string LastPlayedOld { get; set; } /// /// Updates . Call this before launching a game. /// public void UpdatePreGame() { LastPlayed = DateTime.UtcNow; } /// /// Updates and . Call this after a game ends. /// /// The active gameplay time this past session. public void UpdatePostGame(TimeSpan playTime) { UpdatePreGame(); TimePlayed += playTime; } } }