public void SetupInitialSelection(GameTarget target) { IsSelected = CheckedByDefault; //Reset if (Condition == AltFileCondition.COND_MANUAL) { IsSelected = CheckedByDefault; return; } if (Condition == AltFileCondition.COND_MANUAL) { return; } var installedDLC = MEDirectories.GetInstalledDLC(target); switch (Condition) { case AltFileCondition.COND_DLC_NOT_PRESENT: IsSelected = !ConditionalDLC.All(i => installedDLC.Contains(i, StringComparer.CurrentCultureIgnoreCase)); break; case AltFileCondition.COND_DLC_PRESENT: IsSelected = ConditionalDLC.Any(i => installedDLC.Contains(i, StringComparer.CurrentCultureIgnoreCase)); break; //The following conditions don't exist right now //case AltFileCondition.COND_ALL_DLC_NOT_PRESENT: // IsSelected = !ConditionalDLC.Any(i => installedDLC.Contains(i, StringComparer.CurrentCultureIgnoreCase)); // break; //case AltFileCondition.COND_ALL_DLC_PRESENT: // IsSelected = ConditionalDLC.All(i => installedDLC.Contains(i, StringComparer.CurrentCultureIgnoreCase)); // break; } }
public void SetupInitialSelection(GameTarget target) { IsSelected = false; //Reset if (Condition == AltDLCCondition.COND_MANUAL) { IsSelected = CheckedByDefault; return; } var installedDLC = MEDirectories.GetInstalledDLC(target); switch (Condition) { case AltDLCCondition.COND_DLC_NOT_PRESENT: case AltDLCCondition.COND_ANY_DLC_NOT_PRESENT: IsSelected = !ConditionalDLC.All(i => installedDLC.Contains(i, StringComparer.CurrentCultureIgnoreCase)); break; case AltDLCCondition.COND_DLC_PRESENT: case AltDLCCondition.COND_ANY_DLC_PRESENT: IsSelected = ConditionalDLC.Any(i => installedDLC.Contains(i, StringComparer.CurrentCultureIgnoreCase)); break; case AltDLCCondition.COND_ALL_DLC_NOT_PRESENT: IsSelected = !ConditionalDLC.Any(i => installedDLC.Contains(i, StringComparer.CurrentCultureIgnoreCase)); break; case AltDLCCondition.COND_ALL_DLC_PRESENT: IsSelected = ConditionalDLC.All(i => installedDLC.Contains(i, StringComparer.CurrentCultureIgnoreCase)); break; } }
public SFARObject(string file, GameTarget target, Func <string, bool> restoreSFARCallback, Action startingRestoreCallback, Action <object> notifyNoLongerModifiedCallback) { RestoreConfirmationCallback = restoreSFARCallback; IsModified = true; this.startingRestoreCallback = startingRestoreCallback; this.notifyNoLongerModified = notifyNoLongerModifiedCallback; this.target = target; Unpacked = new FileInfo(file).Length == 32; DLCDirectory = Directory.GetParent(Directory.GetParent(file).FullName).FullName; FilePath = file.Substring(target.TargetPath.Length + 1); if (Path.GetFileName(file) == @"Patch_001.sfar") { UIString = @"TestPatch"; } else { ME3Directory.OfficialDLCNames.TryGetValue(Path.GetFileName(Directory.GetParent(Directory.GetParent(file).FullName).FullName), out var name); UIString = name; if (Unpacked) { UIString += @" - " + M3L.GetString(M3L.string_unpacked); } var unpackedFiles = Directory.GetFiles(DLCDirectory, @"*", SearchOption.AllDirectories); if (unpackedFiles.Any(x => Path.GetExtension(x) == @".bin") && !Unpacked) { Inconsistent = true; } } RestoreCommand = new GenericCommand(RestoreSFARWrapper, CanRestoreSFAR); }
public ModifiedFileObject(string filePath, GameTarget target, Func <string, bool> restoreBasegamefileConfirmationCallback, Action notifyRestoringFileCallback, Action <object> notifyRestoredCallback) { this.FilePath = filePath; this.target = target; this.notifyRestoredCallback = notifyRestoredCallback; this.restoreBasegamefileConfirmationCallback = restoreBasegamefileConfirmationCallback; this.notifyRestoringCallback = notifyRestoringFileCallback; RestoreCommand = new GenericCommand(RestoreFileWrapper, CanRestoreFile); }
public SFARObject(string file, GameTarget target, Func <string, bool> restoreSFARCallback, Action startingRestoreCallback, Action <object> notifyNoLongerModifiedCallback) { RestoreConfirmationCallback = restoreSFARCallback; IsModified = true; this.startingRestoreCallback = startingRestoreCallback; this.notifyNoLongerModified = notifyNoLongerModifiedCallback; this.target = target; Unpacked = new FileInfo(file).Length == 32; DLCDirectory = Directory.GetParent(Directory.GetParent(file).FullName).FullName; FilePath = file.Substring(target.TargetPath.Length + 1); if (Path.GetFileName(file) == @"Patch_001.sfar") { UIString = @"TestPatch"; IsMPSFAR = true; IsSPSFAR = true; } else { var dlcFoldername = Directory.GetParent(Directory.GetParent(file).FullName).FullName; if (dlcFoldername.Contains(@"DLC_UPD") || dlcFoldername.Contains(@"DLC_CON_MP")) { IsMPSFAR = true; } else { IsSPSFAR = true; } ME3Directory.OfficialDLCNames.TryGetValue(Path.GetFileName(dlcFoldername), out var name); UIString = name; if (Unpacked) { UIString += @" - " + M3L.GetString(M3L.string_unpacked); } if (!Unpacked) { var filesInSfarDir = Directory.EnumerateFiles(DLCDirectory, "*.*", SearchOption.AllDirectories).ToList(); if (filesInSfarDir.Any(d => !Path.GetFileName(d).Equals("PCConsoleTOC.bin", StringComparison.InvariantCultureIgnoreCase) && //pcconsoletoc will be produced for all folders even with autotoc asi even if its not needed VanillaDatabaseService.UnpackedFileExtensions.Contains(Path.GetExtension(d.ToLower())))) { Inconsistent = true; } } } RestoreCommand = new GenericCommand(RestoreSFARWrapper, CanRestoreSFAR); }
public void SetupInitialSelection(GameTarget target, Mod mod) { UIIsSelectable = false; //Reset IsSelected = false; //Reset if (Condition == AltDLCCondition.COND_MANUAL) { IsSelected = CheckedByDefault; if (DLCRequirementsForManual != null) { var dlc = M3Directories.GetInstalledDLC(target); if (mod.ModDescTargetVersion >= 6.3) { var requiredDLC = DLCRequirementsForManual.Where(x => !x.StartsWith(@"-") || x.StartsWith(@"+")).Select(x => x.TrimStart('+')); // none or + means 'must exist' var notPresentDLCRequired = DLCRequirementsForManual.Where(x => x.StartsWith(@"-")).Select(x => x.TrimStart('-')); UIIsSelectable = dlc.ContainsAll(requiredDLC, StringComparer.InvariantCultureIgnoreCase) && dlc.ContainsNone(notPresentDLCRequired, StringComparer.InvariantCultureIgnoreCase); } else { // Previous logic. Left here to ensure nothing changes. UIIsSelectable = dlc.ContainsAll(DLCRequirementsForManual, StringComparer.InvariantCultureIgnoreCase); } if (!UIIsSelectable && mod.ModDescTargetVersion >= 6.2) { // Mod Manager 6.2: If requirements are not met this option is forcibly not checked. // Mods targeting Moddesc 6 or 6.1 will possibly be bugged if they used this feature IsSelected = false; } CLog.Information($@" > AlternateDLC SetupInitialSelection() {FriendlyName}: UISelectable: {UIIsSelectable}, conducted DLCRequirements check.", Settings.LogModInstallation); } else { UIIsSelectable = true; } return; } var installedDLC = M3Directories.GetInstalledDLC(target); switch (Condition) { case AltDLCCondition.COND_DLC_NOT_PRESENT: case AltDLCCondition.COND_ANY_DLC_NOT_PRESENT: IsSelected = !ConditionalDLC.All(i => installedDLC.Contains(i, StringComparer.CurrentCultureIgnoreCase)); break; case AltDLCCondition.COND_DLC_PRESENT: case AltDLCCondition.COND_ANY_DLC_PRESENT: IsSelected = ConditionalDLC.Any(i => installedDLC.Contains(i, StringComparer.CurrentCultureIgnoreCase)); break; case AltDLCCondition.COND_ALL_DLC_NOT_PRESENT: IsSelected = !ConditionalDLC.Any(i => installedDLC.Contains(i, StringComparer.CurrentCultureIgnoreCase)); break; case AltDLCCondition.COND_ALL_DLC_PRESENT: IsSelected = ConditionalDLC.All(i => installedDLC.Contains(i, StringComparer.CurrentCultureIgnoreCase)); break; case AltDLCCondition.COND_SPECIFIC_SIZED_FILES: { var selected = true; foreach (var reqPair in RequiredSpecificFiles) { if (selected) { var targetFile = Path.Combine(target.TargetPath, reqPair.Key); selected &= File.Exists(targetFile) && new FileInfo(targetFile).Length == reqPair.Value; } } IsSelected = selected; } break; case AltDLCCondition.COND_SPECIFIC_DLC_SETUP: { var selected = true; foreach (var condDlc in ConditionalDLC) { if (selected) { bool existenceRule = condDlc.Substring(0, 1) == @"+"; var dlcfoldername = condDlc.Substring(1); if (existenceRule) { selected &= installedDLC.Contains(dlcfoldername, StringComparer.CurrentCultureIgnoreCase); } else { selected &= !installedDLC.Contains(dlcfoldername, StringComparer.CurrentCultureIgnoreCase); } } } IsSelected = selected; } break; } UIIsSelectable = false; //autos //IsSelected; //autos }
public void SetupInitialSelection(GameTarget target) { UIIsSelectable = false; //Reset IsSelected = false; //Reset if (Condition == AltDLCCondition.COND_MANUAL) { IsSelected = CheckedByDefault; if (DLCRequirementsForManual != null) { var dlc = MEDirectories.GetInstalledDLC(target); UIIsSelectable = dlc.ContainsAll(DLCRequirementsForManual, StringComparer.InvariantCultureIgnoreCase); CLog.Information($@" > AlternateDLC SetupInitialSelection() {FriendlyName}: UISelectable: {UIIsSelectable}, conducted DLCRequirements check.", Settings.LogModInstallation); } else //TODO: FILE LEVEL CHECKS FOR ALOV { UIIsSelectable = true; } return; } var installedDLC = MEDirectories.GetInstalledDLC(target); switch (Condition) { case AltDLCCondition.COND_DLC_NOT_PRESENT: case AltDLCCondition.COND_ANY_DLC_NOT_PRESENT: IsSelected = !ConditionalDLC.All(i => installedDLC.Contains(i, StringComparer.CurrentCultureIgnoreCase)); break; case AltDLCCondition.COND_DLC_PRESENT: case AltDLCCondition.COND_ANY_DLC_PRESENT: IsSelected = ConditionalDLC.Any(i => installedDLC.Contains(i, StringComparer.CurrentCultureIgnoreCase)); break; case AltDLCCondition.COND_ALL_DLC_NOT_PRESENT: IsSelected = !ConditionalDLC.Any(i => installedDLC.Contains(i, StringComparer.CurrentCultureIgnoreCase)); break; case AltDLCCondition.COND_ALL_DLC_PRESENT: IsSelected = ConditionalDLC.All(i => installedDLC.Contains(i, StringComparer.CurrentCultureIgnoreCase)); break; case AltDLCCondition.COND_SPECIFIC_SIZED_FILES: { var selected = true; foreach (var reqPair in RequiredSpecificFiles) { if (selected) { var targetFile = Path.Combine(target.TargetPath, reqPair.Key); selected &= File.Exists(targetFile) && new FileInfo(targetFile).Length == reqPair.Value; } } IsSelected = selected; } break; case AltDLCCondition.COND_SPECIFIC_DLC_SETUP: { var selected = true; foreach (var condDlc in ConditionalDLC) { if (selected) { bool existenceRule = condDlc.Substring(0, 1) == @"+"; var dlcfoldername = condDlc.Substring(1); if (existenceRule) { selected &= installedDLC.Contains(dlcfoldername, StringComparer.CurrentCultureIgnoreCase); } else { selected &= !installedDLC.Contains(dlcfoldername, StringComparer.CurrentCultureIgnoreCase); } } } IsSelected = selected; } break; } UIIsSelectable = false; //autos //IsSelected; //autos }