// Token: 0x060015DF RID: 5599 RVA: 0x000CA0F4 File Offset: 0x000C82F4 protected override bool ApplyWorker(XmlDocument xml) { bool flag = false; for (int i = 0; i < this.mods.Count; i++) { if (ModLister.GetModWithIdentifier(this.mods[i], true) != null) { flag = true; break; } } if (flag) { if (this.match != null) { return(this.match.Apply(xml)); } } else if (this.nomatch != null) { return(this.nomatch.Apply(xml)); } return(true); }
public bool MoveNext() { uint num = (uint)this.$PC; this.$PC = -1; switch (num) { case 0u: ModLister.EnsureInit(); i = 0; break; case 1u: i++; break; default: return(false); } if (i < ModsConfig.data.activeMods.Count) { this.$current = ModLister.GetModWithIdentifier(ModsConfig.data.activeMods[i]); if (!this.$disposing) { this.$PC = 1; } return(true); } this.$PC = -1; return(false); }
protected override bool ApplyWorker(XmlDocument xml) { bool flag = false; int num = 0; while (num < this.mods.Count) { if (ModLister.GetModWithIdentifier(this.mods[num]) == null) { num++; continue; } flag = true; break; } if (flag) { if (this.match != null) { return(this.match.Apply(xml)); } } else if (this.nomatch != null) { return(this.nomatch.Apply(xml)); } return(false); }
public static bool TryCreateDialogsForVersionMismatchWarnings(Action confirmedAction) { string text = null; string text2 = null; if (!BackCompatibility.IsSaveCompatibleWith(ScribeMetaHeaderUtility.loadedGameVersion) && !ScribeMetaHeaderUtility.VersionsMatch()) { text2 = "VersionMismatch".Translate(); string text3 = (!ScribeMetaHeaderUtility.loadedGameVersion.NullOrEmpty()) ? ScribeMetaHeaderUtility.loadedGameVersion : ("(" + "UnknownLower".Translate() + ")"); text = ((ScribeMetaHeaderUtility.lastMode != ScribeHeaderMode.Map) ? ((ScribeMetaHeaderUtility.lastMode != ScribeHeaderMode.World) ? "FileIncompatibleWarning".Translate(text3, VersionControl.CurrentVersionString) : "WorldFileVersionMismatch".Translate(text3, VersionControl.CurrentVersionString)) : "SaveGameIncompatibleWarningText".Translate(text3, VersionControl.CurrentVersionString)); } bool flag = false; string text4 = default(string); string text5 = default(string); if (!ScribeMetaHeaderUtility.LoadedModsMatchesActiveMods(out text4, out text5)) { flag = true; string text6 = "ModsMismatchWarningText".Translate(text4, text5); text = ((text != null) ? (text + "\n\n" + text6) : text6); if (text2 == null) { text2 = "ModsMismatchWarningTitle".Translate(); } } if (text != null) { string text7 = text; string title = text2; Dialog_MessageBox dialog = Dialog_MessageBox.CreateConfirmation(text7, confirmedAction, false, title); dialog.buttonAText = "LoadAnyway".Translate(); if (flag) { dialog.buttonCText = "ChangeLoadedMods".Translate(); dialog.buttonCAction = delegate { int num = ModLister.InstalledModsListHash(false); ModsConfig.SetActiveToList(ScribeMetaHeaderUtility.loadedModIdsList); ModsConfig.Save(); if (num == ModLister.InstalledModsListHash(false)) { IEnumerable <string> items = from id in Enumerable.Range(0, ScribeMetaHeaderUtility.loadedModIdsList.Count) where ModLister.GetModWithIdentifier(ScribeMetaHeaderUtility.loadedModIdsList[id]) == null select ScribeMetaHeaderUtility.loadedModNamesList[id]; Messages.Message(string.Format("{0}: {1}", "MissingMods".Translate(), GenText.ToCommaList(items, true)), MessageTypeDefOf.RejectInput); dialog.buttonCClose = false; } else { ModsConfig.RestartFromChangedMods(); } }; } Find.WindowStack.Add(dialog); return(true); } return(false); }
public override void OnClicked(Page_ModsConfig window) { ModMetaData modWithIdentifier = ModLister.GetModWithIdentifier(packageId, ignorePostfix: true); if (modWithIdentifier != null && modWithIdentifier.Active) { window.SelectMod(modWithIdentifier); } }
public static bool TryCreateDialogsForVersionMismatchWarnings(Action confirmedAction) { string text = null; string text2 = null; if (!BackCompatibility.IsSaveCompatibleWith(loadedGameVersion) && !VersionsMatch()) { text2 = "VersionMismatch".Translate(); string value = loadedGameVersion.NullOrEmpty() ? ("(" + "UnknownLower".TranslateSimple() + ")") : loadedGameVersion; text = ((lastMode == ScribeHeaderMode.Map) ? ((string)"SaveGameIncompatibleWarningText".Translate(value, VersionControl.CurrentVersionString)) : ((lastMode != ScribeHeaderMode.World) ? ((string)"FileIncompatibleWarning".Translate(value, VersionControl.CurrentVersionString)) : ((string)"WorldFileVersionMismatch".Translate(value, VersionControl.CurrentVersionString)))); } bool flag = false; if (!LoadedModsMatchesActiveMods(out string loadedModsSummary, out string runningModsSummary)) { flag = true; string text3 = "ModsMismatchWarningText".Translate(loadedModsSummary, runningModsSummary); text = ((text != null) ? (text + "\n\n" + text3) : text3); if (text2 == null) { text2 = "ModsMismatchWarningTitle".Translate(); } } if (text != null) { Dialog_MessageBox dialog = Dialog_MessageBox.CreateConfirmation(text, confirmedAction, destructive: false, text2); dialog.buttonAText = "LoadAnyway".Translate(); if (flag) { dialog.buttonCText = "ChangeLoadedMods".Translate(); dialog.buttonCAction = delegate { if (Current.ProgramState == ProgramState.Entry) { ModsConfig.SetActiveToList(loadedModIdsList); } ModsConfig.SaveFromList(loadedModIdsList); IEnumerable <string> enumerable = from id in Enumerable.Range(0, loadedModIdsList.Count) where ModLister.GetModWithIdentifier(loadedModIdsList[id]) == null select loadedModNamesList[id]; if (enumerable.Any()) { Messages.Message(string.Format("{0}: {1}", "MissingMods".Translate(), enumerable.ToCommaList()), MessageTypeDefOf.RejectInput, historical: false); dialog.buttonCClose = false; } ModsConfig.RestartFromChangedMods(); }; } Find.WindowStack.Add(dialog); return(true); } return(false); }
private static void LoadedFilesForMod() { List <DebugMenuOption> list = new List <DebugMenuOption>(); foreach (ModContentPack item in LoadedModManager.RunningModsListForReading) { ModContentPack mod = item; list.Add(new DebugMenuOption(mod.Name, DebugMenuOptionMode.Action, delegate { ModMetaData metaData = ModLister.GetModWithIdentifier(mod.PackageId); if (metaData.loadFolders != null && metaData.loadFolders.DefinedVersions().Count != 0) { Find.WindowStack.Add(new Dialog_DebugOptionListLister(from ver in metaData.loadFolders.DefinedVersions() select new DebugMenuOption(ver, DebugMenuOptionMode.Action, delegate { ShowTable((from f in metaData.loadFolders.FoldersForVersion(ver) select Path.Combine(mod.RootDir, f.folderName)).Reverse().ToList()); }))); } else { ShowTable(null); } })); void ShowTable(List <string> loadFolders) { List <Pair <string, string> > list2 = new List <Pair <string, string> >(); list2.AddRange(from f in DirectXmlLoader.XmlAssetsInModFolder(mod, "Defs/", loadFolders) select new Pair <string, string>(f.FullFilePath, "-")); list2.AddRange(from f in DirectXmlLoader.XmlAssetsInModFolder(mod, "Patches/", loadFolders) select new Pair <string, string>(f.FullFilePath, "-")); list2.AddRange(from f in ModContentPack.GetAllFilesForMod(mod, GenFilePaths.ContentPath <Texture2D>(), ModContentLoader <Texture2D> .IsAcceptableExtension, loadFolders) select new Pair <string, string>(f.Value.FullName, f.Key)); list2.AddRange(from f in ModContentPack.GetAllFilesForMod(mod, GenFilePaths.ContentPath <AudioClip>(), ModContentLoader <AudioClip> .IsAcceptableExtension, loadFolders) select new Pair <string, string>(f.Value.FullName, f.Key)); list2.AddRange(from f in ModContentPack.GetAllFilesForMod(mod, GenFilePaths.ContentPath <string>(), ModContentLoader <string> .IsAcceptableExtension, loadFolders) select new Pair <string, string>(f.Value.FullName, f.Key)); list2.AddRange(from f in ModContentPack.GetAllFilesForModPreserveOrder(mod, "Assemblies/", (string e) => e.ToLower() == ".dll", loadFolders) select new Pair <string, string>(f.Item2.FullName, f.Item1)); DebugTables.MakeTablesDialog(list2, new List <TableDataGetter <Pair <string, string> > > { new TableDataGetter <Pair <string, string> >("full path", (Pair <string, string> f) => f.First), new TableDataGetter <Pair <string, string> >("internal path", (Pair <string, string> f) => f.Second) }.ToArray()); } } Find.WindowStack.Add(new Dialog_DebugOptionListLister(list)); }
public override void OnClicked(Page_ModsConfig window) { ModMetaData modWithIdentifier = ModLister.GetModWithIdentifier(packageId, ignorePostfix: true); if (modWithIdentifier == null) { if (!Url.NullOrEmpty()) { SteamUtility.OpenUrl(Url); } } else if (!modWithIdentifier.Active) { window.SelectMod(modWithIdentifier); } }
public static void DeactivateNotInstalledMods(Action <string> logCallback = null) { for (int num = data.activeMods.Count - 1; num >= 0; num--) { ModMetaData modWithIdentifier = ModLister.GetModWithIdentifier(data.activeMods[num]); if (modWithIdentifier == null && TryGetPackageIdWithoutExtraSteamPostfix(data.activeMods[num], out var nonSteamPackageId)) { modWithIdentifier = ModLister.GetModWithIdentifier(nonSteamPackageId); } if (modWithIdentifier == null) { logCallback?.Invoke("Deactivating " + data.activeMods[num]); data.activeMods.RemoveAt(num); } } RecacheActiveMods(); }
public IEnumerable <ModRequirement> GetRequirements() { for (int j = 0; j < Dependencies.Count; j++) { yield return(Dependencies[j]); } for (int j = 0; j < meta.incompatibleWith.Count; j++) { ModMetaData modWithIdentifier = ModLister.GetModWithIdentifier(meta.incompatibleWith[j]); if (modWithIdentifier != null) { yield return(new ModIncompatibility { packageId = modWithIdentifier.PackageIdPlayerFacing, displayName = modWithIdentifier.Name }); } } }
private static bool ReorderConflict(int modIndex, int newIndex) { ModMetaData modWithIdentifier = ModLister.GetModWithIdentifier(data.activeMods[modIndex]); for (int i = 0; i < data.activeMods.Count; i++) { if (i != modIndex) { ModMetaData modWithIdentifier2 = ModLister.GetModWithIdentifier(data.activeMods[i]); if (modWithIdentifier.IsCoreMod && modWithIdentifier2.Source == ContentSource.OfficialModsFolder && i < newIndex) { return(true); } if (modWithIdentifier.Source == ContentSource.OfficialModsFolder && modWithIdentifier2.IsCoreMod) { return(i >= newIndex); } } } return(false); }
public static bool LoadedModsMatchesActiveMods(out string loadedModsSummary, out string runningModsSummary) { loadedModsSummary = null; runningModsSummary = null; List <string> list = LoadedModManager.RunningMods.Select((ModContentPack mod) => mod.PackageId).ToList(); List <string> b = LoadedModManager.RunningMods.Select((ModContentPack mod) => mod.FolderName).ToList(); if (ModListsMatch(loadedModIdsList, list) || ModListsMatch(loadedModIdsList, b)) { return(true); } if (loadedModNamesList == null) { loadedModsSummary = "None".Translate(); } else { loadedModsSummary = loadedModNamesList.ToCommaList(); } runningModsSummary = list.Select((string id) => ModLister.GetModWithIdentifier(id).Name).ToCommaList(); return(false); }
public static bool LoadedModsMatchesActiveMods(out string loadedModsSummary, out string runningModsSummary) { loadedModsSummary = null; runningModsSummary = null; List <string> list = (from mod in LoadedModManager.RunningMods select mod.Identifier).ToList(); if (ModListsMatch(loadedModIdsList, list)) { return(true); } if (loadedModNamesList == null) { loadedModsSummary = "None".Translate(); } else { loadedModsSummary = loadedModNamesList.ToCommaList(); } runningModsSummary = (from id in list select ModLister.GetModWithIdentifier(id).Name).ToCommaList(); return(false); }
private void InitLoadFolders() { foldersToLoadDescendingOrder = new List <string>(); ModMetaData modWithIdentifier = ModLister.GetModWithIdentifier(PackageId); if (modWithIdentifier?.loadFolders != null && modWithIdentifier.loadFolders.DefinedVersions().Count > 0) { List <LoadFolder> list = modWithIdentifier.LoadFoldersForVersion(VersionControl.CurrentVersionStringWithoutBuild); if (list != null && list.Count > 0) { AddFolders(list); return; } int num = VersionControl.CurrentVersion.Major; int num2 = VersionControl.CurrentVersion.Minor; while (true) { if (num2 == 0) { num--; num2 = 9; } else { num2--; } if (num < 1) { break; } List <LoadFolder> list2 = modWithIdentifier.LoadFoldersForVersion(num + "." + num2); if (list2 != null) { AddFolders(list2); return; } } List <LoadFolder> list3 = modWithIdentifier.LoadFoldersForVersion("default"); if (list3 != null) { AddFolders(list3); return; } } if (foldersToLoadDescendingOrder.Count != 0) { return; } string text = Path.Combine(RootDir, VersionControl.CurrentVersionStringWithoutBuild); if (Directory.Exists(text)) { foldersToLoadDescendingOrder.Add(text); } else { Version version = new Version(0, 0); DirectoryInfo[] directories = rootDirInt.GetDirectories(); for (int i = 0; i < directories.Length; i++) { if (VersionControl.TryParseVersionString(directories[i].Name, out var version2) && version2 > version) { version = version2; } } if (version.Major > 0) { foldersToLoadDescendingOrder.Add(Path.Combine(RootDir, version.ToString())); } } string text2 = Path.Combine(RootDir, CommonFolderName); if (Directory.Exists(text2)) { foldersToLoadDescendingOrder.Add(text2); } foldersToLoadDescendingOrder.Add(RootDir); void AddFolders(List <LoadFolder> folders) { for (int num3 = folders.Count - 1; num3 >= 0; num3--) { if (folders[num3].ShouldLoad) { foldersToLoadDescendingOrder.Add(Path.Combine(RootDir, folders[num3].folderName)); } } } }
private static bool <SetActiveToList> m__0(string mod) { return(ModLister.GetModWithIdentifier(mod) != null); }
public static void SetActiveToList(List <string> mods) { ModsConfig.data.activeMods = (from mod in mods where ModLister.GetModWithIdentifier(mod) != null select mod).ToList <string>(); }
static ModsConfig() { activeModsHashSet = new HashSet <string>(); activeModsInLoadOrderCached = new List <ModMetaData>(); bool flag = false; bool flag2 = false; data = DirectXmlLoader.ItemFromXmlFile <ModsConfigData>(GenFilePaths.ModsConfigFilePath); if (data.version != null) { bool flag3 = false; int result; if (data.version.Contains(".")) { int num = VersionControl.MinorFromVersionString(data.version); if (VersionControl.MajorFromVersionString(data.version) != VersionControl.CurrentMajor || num != VersionControl.CurrentMinor) { flag3 = true; } } else if (data.version.Length > 0 && data.version.All((char x) => char.IsNumber(x)) && int.TryParse(data.version, out result) && result <= 2009) { flag3 = true; } if (flag3) { Log.Message("Mods config data is from version " + data.version + " while we are running " + VersionControl.CurrentVersionStringWithRev + ". Resetting."); data = new ModsConfigData(); flag = true; } } for (int i = 0; i < data.activeMods.Count; i++) { string packageId = data.activeMods[i]; if (ModLister.GetModWithIdentifier(packageId) == null) { ModMetaData modMetaData = ModLister.AllInstalledMods.FirstOrDefault((ModMetaData m) => m.FolderName == packageId); if (modMetaData != null) { data.activeMods[i] = modMetaData.PackageId; flag2 = true; } if (TryGetPackageIdWithoutExtraSteamPostfix(packageId, out var nonSteamPackageId) && ModLister.GetModWithIdentifier(nonSteamPackageId) != null) { data.activeMods[i] = nonSteamPackageId; } } } HashSet <string> hashSet = new HashSet <string>(); foreach (ModMetaData allInstalledMod in ModLister.AllInstalledMods) { if (allInstalledMod.Active) { if (hashSet.Contains(allInstalledMod.PackageIdNonUnique)) { allInstalledMod.Active = false; Log.Warning("There was more than one enabled instance of mod with PackageID: " + allInstalledMod.PackageIdNonUnique + ". Disabling the duplicates."); continue; } hashSet.Add(allInstalledMod.PackageIdNonUnique); } if (!allInstalledMod.IsCoreMod && allInstalledMod.Official && IsExpansionNew(allInstalledMod.PackageId)) { SetActive(allInstalledMod.PackageId, active: true); AddKnownExpansion(allInstalledMod.PackageId); flag2 = true; } } if (!File.Exists(GenFilePaths.ModsConfigFilePath) || flag) { Reset(); } else if (flag2) { Save(); } RecacheActiveMods(); }
public static void SetActiveToList(List <string> mods) { data.activeMods = mods.Where((string mod) => ModLister.GetModWithIdentifier(mod) != null).ToList(); RecacheActiveMods(); }