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.

85 lines
3.2 KiB

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