You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
3.1 KiB

  1. #nullable enable
  2. using IPA.JsonConverters;
  3. using IPA.Utilities;
  4. using Newtonsoft.Json;
  5. using Newtonsoft.Json.Linq;
  6. using SemVer;
  7. using System;
  8. using System.Collections.Generic;
  9. using AlmostVersionConverter = IPA.JsonConverters.AlmostVersionConverter;
  10. using Version = SemVer.Version;
  11. #if NET3
  12. using Net3_Proxy;
  13. using Array = Net3_Proxy.Array;
  14. #endif
  15. namespace IPA.Loader
  16. {
  17. internal class PluginManifest
  18. {
  19. [JsonProperty("name", Required = Required.Always)]
  20. public string Name = null!;
  21. [JsonProperty("id", Required = Required.AllowNull)] // TODO: on major version bump, make this always
  22. public string? Id;
  23. [JsonProperty("description", Required = Required.Always), JsonConverter(typeof(MultilineStringConverter))]
  24. public string Description = null!;
  25. [JsonProperty("version", Required = Required.Always), JsonConverter(typeof(SemverVersionConverter))]
  26. public Version Version = null!;
  27. [JsonProperty("gameVersion", Required = Required.Always), JsonConverter(typeof(AlmostVersionConverter))]
  28. public AlmostVersion GameVersion = null!;
  29. [JsonProperty("author", Required = Required.Always)]
  30. public string Author = null!;
  31. [JsonProperty("dependsOn", Required = Required.DisallowNull, ItemConverterType = typeof(SemverRangeConverter))]
  32. public Dictionary<string, Range> Dependencies = new();
  33. [JsonProperty("conflictsWith", Required = Required.DisallowNull, ItemConverterType = typeof(SemverRangeConverter))]
  34. public Dictionary<string, Range> Conflicts = new();
  35. [JsonProperty("features", Required = Required.DisallowNull), JsonConverter(typeof(FeaturesFieldConverter))]
  36. public Dictionary<string, JObject> Features = new();
  37. [JsonProperty("loadBefore", Required = Required.DisallowNull)]
  38. public string[] LoadBefore = Array.Empty<string>();
  39. [JsonProperty("loadAfter", Required = Required.DisallowNull)]
  40. public string[] LoadAfter = Array.Empty<string>();
  41. [JsonProperty("icon", Required = Required.DisallowNull)]
  42. public string? IconPath = null;
  43. [JsonProperty("files", Required = Required.DisallowNull)]
  44. public string[] Files = Array.Empty<string>();
  45. [Serializable]
  46. public class LinksObject
  47. {
  48. [JsonProperty("project-home", Required = Required.DisallowNull)]
  49. public Uri? ProjectHome = null;
  50. [JsonProperty("project-source", Required = Required.DisallowNull)]
  51. public Uri? ProjectSource = null;
  52. [JsonProperty("donate", Required = Required.DisallowNull)]
  53. public Uri? Donate = null;
  54. }
  55. [JsonProperty("links", Required = Required.DisallowNull)]
  56. public LinksObject? Links = null;
  57. [Serializable]
  58. public class MiscObject
  59. {
  60. [JsonProperty("plugin-hint", Required = Required.DisallowNull)]
  61. public string? PluginMainHint = null;
  62. }
  63. [JsonProperty("misc", Required = Required.DisallowNull)]
  64. public MiscObject? Misc = null;
  65. }
  66. }