public void RegisterDlc(string identifier, UnmanagedModuleVersion version) { CkanModule dlcModule = null; if (available_modules.TryGetValue(identifier, out AvailableModule avail)) { dlcModule = avail.ByVersion(version); } if (dlcModule == null) { // Don't have the real thing, make a fake one dlcModule = new CkanModule() { spec_version = new ModuleVersion("v1.28"), identifier = identifier, name = identifier, @abstract = "An official expansion pack for KSP", author = new List <string>() { "SQUAD" }, version = version, kind = "dlc", license = new List <License>() { new License("restricted") }, }; } installed_modules.Add( identifier, new InstalledModule(null, dlcModule, new string[] { }, false) ); }
private Dictionary<string, UnmanagedModuleVersion> TestDlcScan() { var dlc = new Dictionary<string, UnmanagedModuleVersion>(); var dlcDirectory = Path.Combine(ksp.CkanDir(), "dlc"); if (Directory.Exists(dlcDirectory)) { foreach (var f in Directory.EnumerateFiles(dlcDirectory, "*.dlc", SearchOption.TopDirectoryOnly)) { var id = $"{Path.GetFileNameWithoutExtension(f)}-DLC"; var ver = File.ReadAllText(f).Trim(); dlc[id] = new UnmanagedModuleVersion(ver); } } return dlc; }
public virtual bool IsInstalled(GameInstance ksp, out string identifier, out UnmanagedModuleVersion version) { identifier = $"{IdentifierBaseName}-DLC"; version = null; var directoryPath = Path.Combine(game.PrimaryModDirectory(ksp), "SquadExpansion", DirectoryBaseName); if (Directory.Exists(directoryPath)) { var readmeFilePath = Path.Combine(directoryPath, "readme.txt"); if (File.Exists(readmeFilePath)) { foreach (var line in File.ReadAllLines(readmeFilePath)) { var match = VersionPattern.Match(line); if (match.Success) { var versionStr = match.Groups["version"].Value; if (CanonicalVersions.ContainsKey(versionStr)) { versionStr = CanonicalVersions[versionStr]; } version = new UnmanagedModuleVersion(versionStr); break; } } } return(true); } else { return(false); } }
public bool IsInstalled(KSP ksp, out string identifier, out UnmanagedModuleVersion version) { identifier = Identifier; version = null; var directoryPath = Path.Combine(ksp.GameData(), "SquadExpansion", "MakingHistory"); if (Directory.Exists(directoryPath)) { var readmeFilePath = Path.Combine(directoryPath, "readme.txt"); if (File.Exists(readmeFilePath)) { foreach (var line in File.ReadAllLines(readmeFilePath)) { var match = VersionPattern.Match(line); if (match.Success) { var versionStr = match.Groups["version"].Value; if (CanonicalVersions.ContainsKey(versionStr)) { versionStr = CanonicalVersions[versionStr]; } version = new UnmanagedModuleVersion(versionStr); break; } } } return(true); } else { return(false); } }
public void RegisterDlc(string identifier, UnmanagedModuleVersion version) { _installedDlcModules[identifier] = version; }
public void DllVersion() { var v1 = new UnmanagedModuleVersion("0"); Assert.That(v1.ToString().Contains("unmanaged")); }