From 53fb9edb4231d27436efdbdcee5ee9a8af720c14 Mon Sep 17 00:00:00 2001 From: Paul Hebble Date: Wed, 6 Jan 2021 15:37:37 -0600 Subject: [PATCH] Store remote version file URL in metadata resources --- CKAN.schema | 5 +++++ Core/Types/ResourcesDescriptor.cs | 8 ++++++-- GUI/Controls/ModInfo.cs | 1 + GUI/Properties/Resources.Designer.cs | 3 +++ GUI/Properties/Resources.resx | 1 + Netkan/Transformers/AvcTransformer.cs | 5 +++++ Spec.md | 1 + 7 files changed, 22 insertions(+), 2 deletions(-) diff --git a/CKAN.schema b/CKAN.schema index 58ac3a7fa0..26045fba09 100644 --- a/CKAN.schema +++ b/CKAN.schema @@ -220,6 +220,11 @@ "type" : "string", "format" : "uri" }, + "remote-avc" : { + "description" : "Mod's remote hosted version file", + "type" : "string", + "format" : "uri" + }, "store": { "description" : "Purchase DLC here", "type" : "string", diff --git a/Core/Types/ResourcesDescriptor.cs b/Core/Types/ResourcesDescriptor.cs index de93fdf2fd..4e933b8c40 100644 --- a/Core/Types/ResourcesDescriptor.cs +++ b/Core/Types/ResourcesDescriptor.cs @@ -41,11 +41,15 @@ public class ResourcesDescriptor [JsonConverter(typeof(JsonOldResourceUrlConverter))] public Uri metanetkan; - [JsonProperty("store", Order = 10, NullValueHandling = NullValueHandling.Ignore)] + [JsonProperty("remote-avc", Order = 10, NullValueHandling = NullValueHandling.Ignore)] + [JsonConverter(typeof(JsonOldResourceUrlConverter))] + public Uri remoteAvc; + + [JsonProperty("store", Order = 11, NullValueHandling = NullValueHandling.Ignore)] [JsonConverter(typeof(JsonOldResourceUrlConverter))] public Uri store; - [JsonProperty("steamstore", Order = 11, NullValueHandling = NullValueHandling.Ignore)] + [JsonProperty("steamstore", Order = 12, NullValueHandling = NullValueHandling.Ignore)] [JsonConverter(typeof(JsonOldResourceUrlConverter))] public Uri steamstore; } diff --git a/GUI/Controls/ModInfo.cs b/GUI/Controls/ModInfo.cs index 55a3f15bb6..4d0caa5133 100644 --- a/GUI/Controls/ModInfo.cs +++ b/GUI/Controls/ModInfo.cs @@ -157,6 +157,7 @@ private void UpdateModInfo(GUIMod gui_module) AddResourceLink(Properties.Resources.ModInfoLicenseLabel, res.license); AddResourceLink(Properties.Resources.ModInfoManualLabel, res.manual); AddResourceLink(Properties.Resources.ModInfoMetanetkanLabel, res.metanetkan); + AddResourceLink(Properties.Resources.ModInfoRemoteAvcLabel, res.remoteAvc); AddResourceLink(Properties.Resources.ModInfoStoreLabel, res.store); AddResourceLink(Properties.Resources.ModInfoSteamStoreLabel, res.steamstore); } diff --git a/GUI/Properties/Resources.Designer.cs b/GUI/Properties/Resources.Designer.cs index 96fd9db134..f25b7be4c9 100644 --- a/GUI/Properties/Resources.Designer.cs +++ b/GUI/Properties/Resources.Designer.cs @@ -585,6 +585,9 @@ internal class Resources { internal static string ModInfoMetanetkanLabel { get { return (string)(ResourceManager.GetObject("ModInfoMetanetkanLabel", resourceCulture)); } } + internal static string ModInfoRemoteAvcLabel { + get { return (string)(ResourceManager.GetObject("ModInfoRemoteAvcLabel", resourceCulture)); } + } internal static string ModInfoStoreLabel { get { return (string)(ResourceManager.GetObject("ModInfoStoreLabel", resourceCulture)); } } diff --git a/GUI/Properties/Resources.resx b/GUI/Properties/Resources.resx index efdb9d77fb..23cdafe983 100644 --- a/GUI/Properties/Resources.resx +++ b/GUI/Properties/Resources.resx @@ -285,6 +285,7 @@ If you suspect a bug in the client: https://github.com/KSP-CKAN/CKAN/issues/new/ Licence: Manual: Metanetkan: + Remote version file: Store: Steam store: Loading modules diff --git a/Netkan/Transformers/AvcTransformer.cs b/Netkan/Transformers/AvcTransformer.cs index 7d0c575ed4..37cbc36571 100644 --- a/Netkan/Transformers/AvcTransformer.cs +++ b/Netkan/Transformers/AvcTransformer.cs @@ -73,6 +73,11 @@ public IEnumerable Transform(Metadata metadata, TransformOptions opts) if (remoteUri != null) { + if (json["resources"] == null) + json["resources"] = new JObject(); + var resourcesJson = (JObject)json["resources"]; + resourcesJson.SafeAdd("remote-avc", remoteUri.OriginalString); + try { var remoteJson = _github?.DownloadText(remoteUri) diff --git a/Spec.md b/Spec.md index 6f3b9fbbf5..7b6218eb61 100644 --- a/Spec.md +++ b/Spec.md @@ -603,6 +603,7 @@ are described. Unless specified otherwise, these are URLs: - `curse` : (**v1.20**) The mod on Curse. - `manual` : The mod's manual, if it exists. - `metanetkan` : (**v1.27**) URL of the module's remote hosted netkan +- `remote-avc` : URL of remote version file - `store`: (**v1.28**) URL where you can purchase a DLC - `steamstore`: (**v1.28**) URL where you can purchase a DLC on Steam