#nullable enable using System; using System.Collections.Generic; using System.Linq; using System.Numerics; using Newtonsoft.Json; namespace VRCX { public class ScreenshotMetadata { /// /// Name of the application writing to the screenshot. Should be VRCX. /// public string Application { get; set; } /// /// The version of this schema. If the format changes, this number should change. /// public int Version { get; set; } /// /// The details of the user that took the picture. /// public AuthorDetail Author { get; set; } /// /// Information about the world the picture was taken in. /// public WorldDetail World { get; set; } /// /// A list of players in the world at the time the picture was taken. /// public List Players { get; set; } /// /// If this class was serialized from a file, this should be the path to the file. /// [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] internal string SourceFile; /// /// The position of the player that took the picture when the shot was taken. Not written by VRCX, this is legacy support for reading LFS files. /// [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] public Vector3? Pos { get; set; } [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] public DateTime? Timestamp { get; set; } [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] public string? Note { get; set; } /// /// Any error that occurred while parsing the file. This being true implies nothing else is set. /// [JsonIgnore] internal string? Error; [JsonIgnore] internal string JSON; public ScreenshotMetadata() { Application = "VRCX"; Version = 1; Author = new AuthorDetail(); World = new WorldDetail(); Players = new List(); } public static ScreenshotMetadata JustError(string sourceFile, string error) { return new ScreenshotMetadata { Error = error, SourceFile = sourceFile }; } public bool ContainsPlayerID(string id) { return Players.Any(p => p.Id == id); } public bool ContainsPlayerName(string playerName, bool partial, bool ignoreCase) { var comparisonType = ignoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal; if (partial) { return Players.Any(p => p.DisplayName.IndexOf(playerName, comparisonType) != -1); } return Players.Any(p => p.DisplayName.Equals(playerName, comparisonType)); } public class AuthorDetail { /// /// The ID of the user. /// public string Id { get; set; } /// /// The display name of the user. /// public string? DisplayName { get; set; } } public class WorldDetail { /// /// The ID of the world. /// public string Id { get; set; } /// /// The name of the world. /// public string? Name { get; set; } /// /// The full ID of the game instance. /// public string InstanceId { get; set; } } public class PlayerDetail { /// /// The ID of the player in the world. /// public string Id { get; set; } /// /// The display name of the player in the world. /// public string DisplayName { get; set; } /// /// The position of the player in the world. Not written by VRCX, this is legacy support for reading LFS files. /// [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] public Vector3? Pos { get; set; } = null; } } }