コード例 #1
0
        public void VersionSpan_FiniteRange_CorrectString()
        {
            // Arrange
            IGame       game = new KerbalSpaceProgram();
            GameVersion min  = new GameVersion(1, 0, 0);
            GameVersion max  = new GameVersion(1, 1, 1);
            // Act
            string s = GameVersionRange.VersionSpan(game, min, max);

            // Assert
            Assert.AreEqual("KSP 1.0.0–1.1.1", s);
        }
コード例 #2
0
ファイル: IRegistryQuerier.cs プロジェクト: mioackerman/CKAN
        /// <summary>
        /// Generate a string describing the range of game versions
        /// compatible with the given module.
        /// </summary>
        /// <param name="identifier">Mod name to findDependencyShallow</param>
        /// <returns>
        /// String describing range of compatible game versions.
        /// </returns>
        public static string CompatibleGameVersions(this IRegistryQuerier querier, IGame game, CkanModule module)
        {
            ModuleVersion minMod = null, maxMod = null;
            GameVersion   minKsp = null, maxKsp = null;

            Registry.GetMinMaxVersions(
                new CkanModule[] { module },
                out minMod, out maxMod,
                out minKsp, out maxKsp
                );
            return(GameVersionRange.VersionSpan(game, minKsp, maxKsp));
        }
コード例 #3
0
        public void VersionSpan_MaxOnly_CorrectString()
        {
            // Arrange
            IGame       game = new KerbalSpaceProgram();
            GameVersion min  = GameVersion.Any;
            GameVersion max  = new GameVersion(1, 0, 0);
            // Act
            string s = GameVersionRange.VersionSpan(game, min, max);

            // Assert
            Assert.AreEqual("KSP 1.0.0 and earlier", s);
        }
コード例 #4
0
        public void VersionSpan_AllVersions_CorrectString()
        {
            // Arrange
            IGame       game = new KerbalSpaceProgram();
            GameVersion min  = GameVersion.Any;
            GameVersion max  = GameVersion.Any;
            // Act
            string s = GameVersionRange.VersionSpan(game, min, max);

            // Assert
            Assert.AreEqual("KSP all versions", s);
        }
コード例 #5
0
ファイル: IRegistryQuerier.cs プロジェクト: mioackerman/CKAN
        /// <summary>
        /// Generate a string describing the range of game versions
        /// compatible with the given module.
        /// </summary>
        /// <param name="identifier">Mod name to findDependencyShallow</param>
        /// <returns>
        /// String describing range of compatible game versions.
        /// </returns>
        public static string CompatibleGameVersions(this IRegistryQuerier querier, IGame game, string identifier)
        {
            List <CkanModule> releases = querier.AvailableByIdentifier(identifier).ToList();

            if (releases != null && releases.Count > 0)
            {
                ModuleVersion minMod = null, maxMod = null;
                GameVersion   minKsp = null, maxKsp = null;
                Registry.GetMinMaxVersions(releases, out minMod, out maxMod, out minKsp, out maxKsp);
                return(GameVersionRange.VersionSpan(game, minKsp, maxKsp));
            }
            return("");
        }
コード例 #6
0
        private void ShowVersionTable(CKAN.GameInstance inst, List <CkanModule> modules)
        {
            var versions     = modules.Select(m => m.version.ToString()).ToList();
            var gameVersions = modules.Select(m =>
            {
                GameVersion minKsp = null, maxKsp = null;
                Registry.GetMinMaxVersions(new List <CkanModule>()
                {
                    m
                }, out _, out _, out minKsp, out maxKsp);
                return(GameVersionRange.VersionSpan(inst.game, minKsp, maxKsp));
            }).ToList();

            string[] headers           = new string[] { "Version", "Game Versions" };
            int      versionLength     = Math.Max(headers[0].Length, versions.Max(v => v.Length));
            int      gameVersionLength = Math.Max(headers[1].Length, gameVersions.Max(v => v.Length));

            user.RaiseMessage("");
            user.RaiseMessage(
                "{0}  {1}",
                headers[0].PadRight(versionLength),
                headers[1].PadRight(gameVersionLength)
                );
            user.RaiseMessage(
                "{0}  {1}",
                new string('-', versionLength),
                new string('-', gameVersionLength)
                );
            for (int row = 0; row < versions.Count; ++row)
            {
                user.RaiseMessage(
                    "{0}  {1}",
                    versions[row].PadRight(versionLength),
                    gameVersions[row].PadRight(gameVersionLength)
                    );
            }
        }
コード例 #7
0
        private void addVersionBox(int l, int t, int r, int b, Func <string> title, Func <ConsoleTheme, ConsoleColor> color, bool doubleLine, List <CkanModule> releases)
        {
            AddObject(new ConsoleFrame(
                          l, t, r, b,
                          title,
                          color,
                          doubleLine
                          ));

            if (releases != null && releases.Count > 0)
            {
                ModuleVersion minMod = null, maxMod = null;
                GameVersion   minKsp = null, maxKsp = null;
                Registry.GetMinMaxVersions(releases, out minMod, out maxMod, out minKsp, out maxKsp);
                AddObject(new ConsoleLabel(
                              l + 2, t + 1, r - 2,
                              () => minMod == maxMod
                        ? $"{ModuleInstaller.WithAndWithoutEpoch(minMod?.ToString() ?? "???")}"
                        : $"{ModuleInstaller.WithAndWithoutEpoch(minMod?.ToString() ?? "???")} - {ModuleInstaller.WithAndWithoutEpoch(maxMod?.ToString() ?? "???")}",
                              null,
                              color
                              ));
                AddObject(new ConsoleLabel(
                              l + 2, t + 2, r - 2,
                              () => "Compatible with:",
                              null,
                              th => th.DimLabelFg
                              ));
                AddObject(new ConsoleLabel(
                              l + 4, t + 3, r - 2,
                              () => GameVersionRange.VersionSpan(manager.CurrentInstance.game, minKsp, maxKsp),
                              null,
                              color
                              ));
            }
        }
コード例 #8
0
        private bool VersionsNeedManualReview(Metadata metadata, out string reason)
        {
            JObject json   = metadata.Json();
            var     minStr = json["ksp_version_min"] ?? json["ksp_version"];
            var     maxStr = json["ksp_version_max"] ?? json["ksp_version"];
            var     minVer = minStr == null ? GameVersion.Any : GameVersion.Parse((string)minStr);
            var     maxVer = maxStr == null ? GameVersion.Any : GameVersion.Parse((string)maxStr);

            if (currentRelease.IntersectWith(new GameVersionRange(minVer, maxVer)) == null)
            {
                var game = new KerbalSpaceProgram();
                reason = $"Hard-coded game versions not compatible with current release: {GameVersionRange.VersionSpan(game, minVer, maxVer)}\r\nPlease check that they match the forum thread.";
                return(true);
            }
            else
            {
                // Compatible with latest release, no manual review needed
                reason = "";
                return(false);
            }
        }
コード例 #9
0
        public void Validate(Metadata metadata)
        {
            var mod = CkanModule.FromJson(metadata.Json().ToString());

            if (!mod.IsCompatibleKSP(new GameVersionCriteria(null, knownVersions)))
            {
                GameVersion minKsp = null, maxKsp = null;
                Registry.GetMinMaxVersions(new List <CkanModule>()
                {
                    mod
                }, out _, out _, out minKsp, out maxKsp);
                var game = new KerbalSpaceProgram();
                throw new Kraken($"{metadata.Identifier} doesn't match any valid game version: {GameVersionRange.VersionSpan(game, minKsp, maxKsp)}");
            }
        }