From 7457077ba3edfe205f5fbab073dff18ed3e91c60 Mon Sep 17 00:00:00 2001 From: Anairkoen Schno Date: Wed, 26 Sep 2018 20:55:59 -0500 Subject: [PATCH] Added support for modsaber conflicts Updated URI base to new address --- IPA.Injector/Properties/AssemblyInfo.cs | 4 ++-- IPA.Loader/Updating/ModsaberML/ApiEndpoint.cs | 5 ++++- IPA.Loader/Updating/ModsaberML/Updater.cs | 22 ++++++++++++++----- IPA.Loader/Updating/SelfPlugin.cs | 2 +- IPA/Properties/AssemblyInfo.cs | 4 ++-- 5 files changed, 26 insertions(+), 11 deletions(-) diff --git a/IPA.Injector/Properties/AssemblyInfo.cs b/IPA.Injector/Properties/AssemblyInfo.cs index 7edbc69b..e361ac53 100644 --- a/IPA.Injector/Properties/AssemblyInfo.cs +++ b/IPA.Injector/Properties/AssemblyInfo.cs @@ -35,5 +35,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("3.10.5")] -[assembly: AssemblyFileVersion("3.10.5")] +[assembly: AssemblyVersion("3.10.6")] +[assembly: AssemblyFileVersion("3.10.6")] diff --git a/IPA.Loader/Updating/ModsaberML/ApiEndpoint.cs b/IPA.Loader/Updating/ModsaberML/ApiEndpoint.cs index 34116cb5..d723801f 100644 --- a/IPA.Loader/Updating/ModsaberML/ApiEndpoint.cs +++ b/IPA.Loader/Updating/ModsaberML/ApiEndpoint.cs @@ -16,7 +16,7 @@ namespace IPA.Updating.ModsaberML { class ApiEndpoint { - public const string ApiBase = "https://www.modsaber.ml/"; + public const string ApiBase = "https://www.modsaber.org/"; public const string GetModInfoEndpoint = "registry/{0}/{1}"; public const string GetModsWithSemver = "api/v1.0/mods/semver/{0}/{1}"; @@ -130,6 +130,9 @@ namespace IPA.Updating.ModsaberML [JsonProperty("dependsOn", ItemConverterType = typeof(ModsaberDependencyConverter))] public Dependency[] Dependencies = new Dependency[0]; + [JsonProperty("conflictsWith", ItemConverterType = typeof(ModsaberDependencyConverter))] + public Dependency[] Conflicts = new Dependency[0]; + [JsonProperty("oldVersions", ItemConverterType = typeof(SemverVersionConverter))] public Version[] OldVersions = new Version[0]; diff --git a/IPA.Loader/Updating/ModsaberML/Updater.cs b/IPA.Loader/Updating/ModsaberML/Updater.cs index 8d2fa796..4b5f4e30 100644 --- a/IPA.Loader/Updating/ModsaberML/Updater.cs +++ b/IPA.Loader/Updating/ModsaberML/Updater.cs @@ -58,6 +58,7 @@ namespace IPA.Updating.ModsaberML public Version Version { get; set; } = null; public Version ResolvedVersion { get; set; } = null; public Range Requirement { get; set; } = null; + public Range Conflicts { get; set; } = null; public bool Resolved { get; set; } = false; public bool Has { get; set; } = false; public HashSet Consumers { get; set; } = new HashSet(); @@ -68,7 +69,7 @@ namespace IPA.Updating.ModsaberML public override string ToString() { - return $"{Name}@{Version}{(Resolved ? $" -> {ResolvedVersion}" : "")} - ({Requirement}) {(Has ? $" Already have" : "")}"; + return $"{Name}@{Version}{(Resolved ? $" -> {ResolvedVersion}" : "")} - ({Requirement} ! {Conflicts}) {(Has ? $" Already have" : "")}"; } } @@ -226,6 +227,7 @@ namespace IPA.Updating.ModsaberML } list.Value.AddRange(mod.Value.Dependencies.Select(d => new DependencyObject { Name = d.Name, Requirement = d.VersionRange, Consumers = new HashSet() { dep.Name } })); + list.Value.AddRange(mod.Value.Conflicts.Select(d => new DependencyObject { Name = d.Name, Conflicts = d.VersionRange, Consumers = new HashSet() { dep.Name } })); } var depNames = new HashSet(); @@ -242,9 +244,19 @@ namespace IPA.Updating.ModsaberML { var toMod = final.Where(d => d.Name == dep.Name).First(); - toMod.Requirement = toMod.Requirement.Intersect(dep.Requirement); - foreach (var consume in dep.Consumers) - toMod.Consumers.Add(consume); + if (dep.Requirement != null) + { + toMod.Requirement = toMod.Requirement.Intersect(dep.Requirement); + foreach (var consume in dep.Consumers) + toMod.Consumers.Add(consume); + } + else if (dep.Conflicts != null) + { + if (toMod.Conflicts == null) + toMod.Conflicts = dep.Conflicts; + else + toMod.Conflicts = new Range($"{toMod.Conflicts} || {dep.Conflicts}"); // there should be a better way to do this + } } } @@ -274,7 +286,7 @@ namespace IPA.Updating.ModsaberML continue; } - var ver = modsMatching.Value.Where(val => val.GameVersion == BeatSaber.GameVersion && val.Approved).Select(mod => mod.Version).Max(); // (2.1) + var ver = modsMatching.Value.Where(val => val.GameVersion == BeatSaber.GameVersion && val.Approved && !dep.Conflicts.IsSatisfied(val.Version)).Select(mod => mod.Version).Max(); // (2.1) if (dep.Resolved = ver != null) dep.ResolvedVersion = ver; // (2.2) dep.Has = dep.Version == dep.ResolvedVersion && dep.Resolved; // dep.Version is only not null if its already installed } diff --git a/IPA.Loader/Updating/SelfPlugin.cs b/IPA.Loader/Updating/SelfPlugin.cs index b6f0344a..f80e86b5 100644 --- a/IPA.Loader/Updating/SelfPlugin.cs +++ b/IPA.Loader/Updating/SelfPlugin.cs @@ -11,7 +11,7 @@ namespace IPA.Updating internal class SelfPlugin : IBeatSaberPlugin { internal const string IPA_Name = "Beat Saber IPA"; - internal const string IPA_Version = "3.10.5"; + internal const string IPA_Version = "3.10.6"; public static SelfPlugin Instance { get; set; } = new SelfPlugin(); diff --git a/IPA/Properties/AssemblyInfo.cs b/IPA/Properties/AssemblyInfo.cs index 17001ece..a0b37198 100644 --- a/IPA/Properties/AssemblyInfo.cs +++ b/IPA/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("3.10.5")] -[assembly: AssemblyFileVersion("3.10.5")] +[assembly: AssemblyVersion("3.10.6")] +[assembly: AssemblyFileVersion("3.10.6")]