From c6118e7ca2abfd4d2cdc2956f4fd7cdebf675c5a Mon Sep 17 00:00:00 2001 From: icedream Date: Wed, 22 Oct 2014 19:42:45 +0200 Subject: [PATCH] Properly exporting information from addon.json. --- src/addoncreator/Addon.cs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/addoncreator/Addon.cs b/src/addoncreator/Addon.cs index f3e39f9..56a1e35 100644 --- a/src/addoncreator/Addon.cs +++ b/src/addoncreator/Addon.cs @@ -182,10 +182,22 @@ namespace GarrysMod.AddonCreator addonJson.CheckForErrors(); addonJson.RemoveIgnoredFiles(ref files); - // TODO: Extract data from addon.json + // Extract data from addon.json + Title = addonJson.Title; + Description = string.IsNullOrEmpty(addonJson.Description) ? string.Empty : addonJson.Description; + Version = addonJson.Version; + + // Create a stripped down version of addon.json for the output gma, it will replace the Description field + var newDescription = JsonConvert.SerializeObject(new AddonJson + { + Description = Description, + Tags = addonJson.Tags, + Type = addonJson.Type + }); // Sort files var resultingFiles = new SortedDictionary(files); + resultingFiles.Remove("addon.json"); // General whitelist var blacklistedFiles = AddonWhitelist @@ -219,14 +231,14 @@ namespace GarrysMod.AddonCreator throw new IndexOutOfRangeException("Required content count must not exceed " + byte.MaxValue + " entries."); } sw.Write((byte)RequiredContent.Count); - foreach (string content in RequiredContent) + foreach (var content in RequiredContent) { sw.Write(content, true); } // Metadata sw.Write(Title, true); - sw.Write(Description, true); + sw.Write(newDescription, true); // "Description" field which is actually a trimmed down addon.json sw.Write(Author, true); sw.Write(Version);