private void btnCompare_Click(object sender, EventArgs e) { ClearLog(); string oldPath = dlgOldMod.FileName; string newPath = dlgNewMod.FileName; //dont backup if the file is being modded. BackupTheFile(newPath); ModPackInformation oldVersionInformation = GetModPackData(oldPath); ModPackInformation newVersionInformation = GetModPackData(newPath); txtResult.Text = ComparePacks(oldVersionInformation, newVersionInformation); txtNewPack.Text = newVersionInformation.ModListHtml; if (cbRemoveCommonOverrides.Checked) { RemoveCommonAutoLoadedMods(newPath); } if (cbAddChangeLogToNew.Checked) { AddTextFileToZip(newPath, "changelog.html", txtResult.Text); } }
private string ComparePacks(ModPackInformation oldVersionInformation, ModPackInformation newVersionInformation) { StringBuilder result = new StringBuilder(); result.AppendLine($"<p>Modpack version <a href='{Resources.CurseProjectUrl}{newVersionInformation.ProjectId}'>{newVersionInformation.ModPackVersion}</a><br/>"); result.AppendLine($"Modpack Author {newVersionInformation.ModPackAuthor}</br>"); if (!((string)oldVersionInformation.MinecraftVersion) .Equals((string)newVersionInformation.MinecraftVersion, StringComparison.InvariantCultureIgnoreCase)) { result.AppendLine($"Minecraft version updated to {newVersionInformation.MinecraftVersion}<br/>"); } if (!((string)oldVersionInformation.Loader) .Equals((string)newVersionInformation.Loader, StringComparison.InvariantCultureIgnoreCase)) { result.AppendLine($"Loader updated to {newVersionInformation.Loader}<br/>"); } result.AppendLine($"</p>"); IList <ModVersion> removedMods = GetRemovedMods(oldVersionInformation.Mods, newVersionInformation.Mods); BuildList("Removed", removedMods, result); IList <ModVersion> addedMods = GetAddedMods(oldVersionInformation.Mods, newVersionInformation.Mods); BuildList("Added", addedMods, result); IList <ModVersion> updatedMods = GetUpdatedMods(oldVersionInformation.Mods, newVersionInformation.Mods); BuildList("Updated", updatedMods, result); result.AppendLine($"<p>Change log generated the Curse Mod List Change Log Creator by {Resources.Authors}<br/><a href=\"{Resources.GitHubUrlForTheProject}\">Get it from Github!</a></p>"); return(result.ToString()); }
private ModVersion GetMod(ModPackInformation info, string modId) { ModVersion result = info.Mods.FirstOrDefault(m => m.ModProjectId.Equals(modId, StringComparison.InvariantCultureIgnoreCase)); if (result == null) { result = new ModVersion { ModProjectId = modId }; info.Mods.Add(result); } return(result); }
private void HandleManifest(Stream contents, ModPackInformation info) { ModPackInformation result = new ModPackInformation(); using (StreamReader sr = new StreamReader(contents)) using (JsonReader reader = new JsonTextReader(sr)) { JsonSerializer serializer = new JsonSerializer(); dynamic manifest = serializer.Deserialize(reader); info.MinecraftVersion = manifest.minecraft.version; info.Loader = manifest.minecraft.modLoaders[0].id; info.ModPackAuthor = manifest.author; info.ModPackVersion = manifest.version; info.ProjectId = manifest.projectID; foreach (dynamic file in manifest.files) { ModVersion mod = GetMod(info, ((string)file.projectID)); mod.ModFileId = file.fileID; } } }
private void HandleModList(Stream modList, ModPackInformation info) { var doc = new HtmlAgilityPack.HtmlDocument(); doc.Load(modList); HtmlNode root = doc.DocumentNode.FirstChild;//gets the ul element info.ModListHtml = doc.Text; foreach (var item in root.Elements("li")) { //this should be an li HtmlNode node = item.ChildNodes.FirstOrDefault(); string name = node.InnerHtml; string url = node.GetAttributeValue("href", string.Empty); string projectid = url; if (url.StartsWith(Resources.CurseProjectUrl)) { projectid = url.Remove(0, Resources.CurseProjectUrl.Length); } ModVersion mod = GetMod(info, projectid); mod.Name = name; mod.Url = url; } }