public VersionStatus(ModMetaData mod) { version = mod.TargetVersion; if (!VersionControl.IsWellFormattedVersionString(mod.TargetVersion)) { match = VersionMatch.InvalidVersion; tip = I18n.InvalidVersion(version); return; } var _version = VersionControl.VersionFromString(version); if (_version.Major != VersionControl.CurrentMajor || _version.Minor != VersionControl.CurrentMinor) { match = VersionMatch.DifferentVersion; tip = I18n.DifferentVersion(mod); return; } if (_version.Build != VersionControl.CurrentBuild) { match = VersionMatch.DifferentBuild; tip = I18n.DifferentBuild(mod); return; } match = VersionMatch.CurrentVersion; tip = I18n.CurrentVersion; }
public static Color Color(VersionMatch match, Color?okColor = null) { switch (match) { case VersionMatch.InvalidVersion: return(UnityEngine.Color.magenta); case VersionMatch.DifferentVersion: return(UnityEngine.Color.red); case VersionMatch.DifferentBuild: return(new Color(.9f, .9f, .9f)); default: return(okColor ?? UnityEngine.Color.white); } }
public static string Tip(ModMetaData mod, VersionMatch match, string version) { switch (match) { case VersionMatch.CurrentVersion: return(I18n.CurrentVersion); case VersionMatch.DifferentBuild: return(I18n.DifferentBuild(mod, version)); case VersionMatch.DifferentVersion: return(I18n.DifferentVersion(mod, version)); case VersionMatch.InvalidVersion: default: return(I18n.InvalidVersion(version)); } }
internal static bool MatchesVersion(this BeatModsEntry m, VersionMatch version) { return(((Range)version).IsSatisfied(m.Version)); }
public static VersionStatus For(ModMetaData mod, VersionMatch match, Version version) { return(For(mod, match, version.ToString())); }
public static VersionStatus For(ModMetaData mod, VersionMatch match, string version) { return(new VersionStatus(match, version, Tip(mod, match, version))); }
public VersionStatus(VersionMatch match, string version, string tip) { this.match = match; this.version = version; this.tip = tip; }
public async Task <IEnumerable <ILookupResult> > GetByLogicalName(string logicalName, VersionMatch versionMatch) { var mods = await _client.GetModsByName(logicalName); var matches = mods.Where(m => ((Range)versionMatch).IsSatisfied(m.Version)); _logger.LogDebug($"Matched {matches.Count()}/{mods.Count()} mods from '{logicalName}'/'{versionMatch.ToString()}'"); if (matches.Any()) { return(matches.OrderByDescending(m => new Version(m.Version)).Select(m => new BeatModsLookupResult(m))); } else { return(new List <ILookupResult>()); } }
public async Task <IEnumerable <ILookupResult> > GetByExpression(string fileExpression, VersionMatch versionMatch) { var mods = await _client.GetModsByPattern(fileExpression); var matches = mods.Where(m => m.MatchesVersion(versionMatch)); return(SortMatches(matches)); }
public async Task <IEnumerable <ILookupResult> > GetByLogicalName(string logicalName, VersionMatch versionMatch) { var map = await _client.Key(logicalName); return(new List <ILookupResult> { new BeatSaverLookupResult(map) }); }
public async Task <IEnumerable <ILookupResult> > GetByExpression(string fileExpression, VersionMatch versionMatch) { if (string.IsNullOrWhiteSpace(fileExpression)) { throw new System.ArgumentNullException(nameof(fileExpression)); } var fileName = System.IO.Path.GetFileNameWithoutExtension(fileExpression); if (fileName.Length == 40) { var map = await _client.Hash(fileName); return(new List <ILookupResult> { new BeatSaverLookupResult(map) }); } throw new System.NotImplementedException(); }