Browse Source

Added support for modsaber conflicts

Updated URI base to new address
piracy-check
Anairkoen Schno 6 years ago
parent
commit
261fc2604c
5 changed files with 26 additions and 11 deletions
  1. +2
    -2
      IPA.Injector/Properties/AssemblyInfo.cs
  2. +4
    -1
      IPA.Loader/Updating/ModsaberML/ApiEndpoint.cs
  3. +17
    -5
      IPA.Loader/Updating/ModsaberML/Updater.cs
  4. +1
    -1
      IPA.Loader/Updating/SelfPlugin.cs
  5. +2
    -2
      IPA/Properties/AssemblyInfo.cs

+ 2
- 2
IPA.Injector/Properties/AssemblyInfo.cs View File

@ -35,5 +35,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.10.5")]
[assembly: AssemblyFileVersion("3.10.5")]
[assembly: AssemblyVersion("3.10.6")]
[assembly: AssemblyFileVersion("3.10.6")]

+ 4
- 1
IPA.Loader/Updating/ModsaberML/ApiEndpoint.cs View File

@ -16,7 +16,7 @@ namespace IPA.Updating.ModsaberML
{ {
class ApiEndpoint 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 GetModInfoEndpoint = "registry/{0}/{1}";
public const string GetModsWithSemver = "api/v1.0/mods/semver/{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))] [JsonProperty("dependsOn", ItemConverterType = typeof(ModsaberDependencyConverter))]
public Dependency[] Dependencies = new Dependency[0]; public Dependency[] Dependencies = new Dependency[0];
[JsonProperty("conflictsWith", ItemConverterType = typeof(ModsaberDependencyConverter))]
public Dependency[] Conflicts = new Dependency[0];
[JsonProperty("oldVersions", ItemConverterType = typeof(SemverVersionConverter))] [JsonProperty("oldVersions", ItemConverterType = typeof(SemverVersionConverter))]
public Version[] OldVersions = new Version[0]; public Version[] OldVersions = new Version[0];


+ 17
- 5
IPA.Loader/Updating/ModsaberML/Updater.cs View File

@ -58,6 +58,7 @@ namespace IPA.Updating.ModsaberML
public Version Version { get; set; } = null; public Version Version { get; set; } = null;
public Version ResolvedVersion { get; set; } = null; public Version ResolvedVersion { get; set; } = null;
public Range Requirement { get; set; } = null; public Range Requirement { get; set; } = null;
public Range Conflicts { get; set; } = null;
public bool Resolved { get; set; } = false; public bool Resolved { get; set; } = false;
public bool Has { get; set; } = false; public bool Has { get; set; } = false;
public HashSet<string> Consumers { get; set; } = new HashSet<string>(); public HashSet<string> Consumers { get; set; } = new HashSet<string>();
@ -68,7 +69,7 @@ namespace IPA.Updating.ModsaberML
public override string ToString() 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<string>() { dep.Name } })); list.Value.AddRange(mod.Value.Dependencies.Select(d => new DependencyObject { Name = d.Name, Requirement = d.VersionRange, Consumers = new HashSet<string>() { dep.Name } }));
list.Value.AddRange(mod.Value.Conflicts.Select(d => new DependencyObject { Name = d.Name, Conflicts = d.VersionRange, Consumers = new HashSet<string>() { dep.Name } }));
} }
var depNames = new HashSet<string>(); var depNames = new HashSet<string>();
@ -242,9 +244,19 @@ namespace IPA.Updating.ModsaberML
{ {
var toMod = final.Where(d => d.Name == dep.Name).First(); 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; 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) 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 dep.Has = dep.Version == dep.ResolvedVersion && dep.Resolved; // dep.Version is only not null if its already installed
} }


+ 1
- 1
IPA.Loader/Updating/SelfPlugin.cs View File

@ -11,7 +11,7 @@ namespace IPA.Updating
internal class SelfPlugin : IBeatSaberPlugin internal class SelfPlugin : IBeatSaberPlugin
{ {
internal const string IPA_Name = "Beat Saber IPA"; 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(); public static SelfPlugin Instance { get; set; } = new SelfPlugin();


+ 2
- 2
IPA/Properties/AssemblyInfo.cs View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.10.5")]
[assembly: AssemblyFileVersion("3.10.5")]
[assembly: AssemblyVersion("3.10.6")]
[assembly: AssemblyFileVersion("3.10.6")]

Loading…
Cancel
Save