public DeconstructBSAs(ACompiler compiler) : base(compiler) { _mo2Compiler = (MO2Compiler)compiler; _includeDirectly = _mo2Compiler.ModInis.Where(kv => { var general = kv.Value.General; if (general.notes != null && (general.notes.Contains(Consts.WABBAJACK_INCLUDE) || general.notes.Contains(Consts.WABBAJACK_NOMATCH_INCLUDE))) { return(true); } if (general.comments != null && (general.comments.Contains(Consts.WABBAJACK_INCLUDE) || general.comments.Contains(Consts.WABBAJACK_NOMATCH_INCLUDE))) { return(true); } return(false); }) .Select(kv => kv.Key.RelativeTo(_mo2Compiler.SourcePath)) .ToList(); _microstack = bsa => new List <ICompilationStep> { new DirectMatch(_mo2Compiler), new IncludePatches(_mo2Compiler, bsa), new DropAll(_mo2Compiler) }; _microstackWithInclude = bsa => new List <ICompilationStep> { new DirectMatch(_mo2Compiler), new IncludePatches(_mo2Compiler, bsa), new IncludeAll(_mo2Compiler) }; }
public IgnoreOtherProfiles(ACompiler compiler) : base(compiler) { _mo2Compiler = (MO2Compiler)compiler; _profiles = _mo2Compiler.SelectedProfiles .Select(p => Path.Combine("profiles", p) + "\\") .ToList(); }
public IgnoreOtherProfiles(ACompiler compiler) : base(compiler) { _mo2Compiler = (MO2Compiler)compiler; _modProfilesFolder = _mo2Compiler.MO2Folder.Combine("profiles"); _profiles = _mo2Compiler.SelectedProfiles .Select(p => _modProfilesFolder.Combine(p)) .ToList(); }
protected async Task <MO2Compiler> ConfigureAndRunCompiler(string profile) { var compiler = new MO2Compiler( mo2Folder: utils.MO2Folder, mo2Profile: profile, outputFile: OutputFile(profile)); Assert.True(await compiler.Begin()); return(compiler); }
private async Task <MO2Compiler> ConfigureAndRunCompiler(string profile) { var compiler = new MO2Compiler( mo2Folder: utils.MO2Folder, mo2Profile: profile, outputFile: profile + Consts.ModListExtension); Assert.IsTrue(await compiler.Begin()); return(compiler); }
protected async Task <MO2Compiler> ConfigureAndRunCompiler(string profile) { var compiler = new MO2Compiler( mo2Folder: utils.MO2Folder, mo2Profile: profile, outputFile: profile + ExtensionManager.Extension); compiler.ShowReportWhenFinished = false; Assert.IsTrue(await compiler.Begin()); return(compiler); }
public async Task CreateModlist() { var profile = utils.AddProfile("Default"); var mod = utils.AddMod(); await DownloadAndInstall( "https://github.com/ModOrganizer2/modorganizer/releases/download/v2.2.1/Mod.Organizer.2.2.1.7z", "Mod.Organizer.2.2.1.7z", utils.MO2Folder); File.WriteAllLines(Path.Combine(utils.DownloadsFolder, "Mod.Organizer.2.2.1.7z.meta"), new List <string> { "[General]", "directURL=https://github.com/ModOrganizer2/modorganizer/releases/download/v2.2.1/Mod.Organizer.2.2.1.7z" }); var modfiles = await Task.WhenAll( DownloadAndInstall(Game.SkyrimSpecialEdition, 12604, "SkyUI"), DownloadAndInstall(Game.Fallout4, 11925, "Anti-Tank Rifle"), DownloadAndInstall(Game.SkyrimSpecialEdition, 4783, "Frost Armor UNP"), DownloadAndInstall(Game.SkyrimSpecialEdition, 32359, "Frost Armor HDT")); // We're going to fully patch this mod from another source. File.Delete(modfiles[3].Download); utils.Configure(); File.WriteAllLines(Path.Combine(modfiles[3].ModFolder, "meta.ini"), new [] { "[General]", $"matchAll= {Path.GetFileName(modfiles[2].Download)}" }); var modlist = await CompileAndInstall(profile); utils.VerifyAllFiles(); var loot_folder = Path.Combine(utils.InstallFolder, "LOOT Config Files"); if (Directory.Exists(loot_folder)) { Utils.DeleteDirectory(loot_folder); } var compiler = new MO2Compiler( mo2Folder: utils.InstallFolder, mo2Profile: profile, outputFile: profile + Consts.ModListExtension); compiler.MO2DownloadsFolder = Path.Combine(utils.DownloadsFolder); Assert.IsTrue(await compiler.Begin()); }
public static int GetFilePriority(MO2Compiler compiler, VirtualFile file) { var archive = file.TopParent; var adata = compiler.ArchivesByFullPath[archive.AbsoluteName]; if (adata.State is GameFileSourceDownloader.State gs) { return(gs.Game == compiler.CompilingGame.Game ? 2 : 3); } return(1); }
public IgnoreDisabledMods(ACompiler compiler) : base(compiler) { _mo2Compiler = (MO2Compiler)compiler; var alwaysEnabled = _mo2Compiler.ModInis.Where(f => IsAlwaysEnabled(f.Value)).Select(f => f.Key).Distinct(); _allEnabledMods = _mo2Compiler.SelectedProfiles .SelectMany(p => _mo2Compiler.MO2Folder.Combine("profiles", p, "modlist.txt").ReadAllLines()) .Where(line => line.StartsWith("+") || line.EndsWith("_separator")) .Select(line => line.Substring(1).RelativeTo(_mo2Compiler.MO2ModsFolder)) .Concat(alwaysEnabled) .ToList(); }
private async Task Install(MO2Compiler compiler) { var modlist = AInstaller.LoadFromFile(compiler.ModListOutputFile); var installer = new MO2Installer( archive: compiler.ModListOutputFile, modList: modlist, outputFolder: utils.InstallFolder, downloadFolder: utils.DownloadsFolder); installer.GameFolder = utils.GameFolder; await installer.Begin(); }
protected async Task <MO2Compiler> ConfigureAndRunCompiler(string profile, bool useGameFiles = false) { var compiler = new MO2Compiler( sourcePath: utils.SourcePath, downloadsPath: utils.DownloadsPath, mo2Profile: profile, outputFile: OutputFile(profile)); compiler.UseGamePaths = useGameFiles; Assert.True(await compiler.Begin()); return(compiler); }
public IncludePatches(ACompiler compiler, VirtualFile?constructingFromBSA = null) : base(compiler) { _bsa = constructingFromBSA; _mo2Compiler = (MO2Compiler)compiler; _indexed = _compiler.IndexedFiles.Values .SelectMany(f => f) .GroupBy(f => f.Name.FileName) .ToDictionary(f => f.Key); _indexedByName = _indexed.Values .SelectMany(s => s) .Where(f => f.IsNative) .ToDictionary(f => f.FullPath.FileName); }
protected void Install(MO2Compiler compiler) { var modlist = AInstaller.LoadFromFile(compiler.ModListOutputFile); var installer = new MO2Installer( archive: compiler.ModListOutputFile, modList: modlist, outputFolder: utils.InstallFolder, downloadFolder: utils.DownloadsFolder); installer.WarnOnOverwrite = false; installer.GameFolder = utils.GameFolder; installer.Begin().Wait(); }
public async Task CreateModlist() { var profile = utils.AddProfile("Default"); var mod = await utils.AddMod(); await DownloadAndInstall( "https://github.com/ModOrganizer2/modorganizer/releases/download/v2.2.1/Mod.Organizer.2.2.1.7z", "Mod.Organizer.2.2.1.7z"); await utils.DownloadsPath.Combine("Mod.Organizer.2.2.1.7z.meta").WriteAllLinesAsync( "[General]", "directURL=https://github.com/ModOrganizer2/modorganizer/releases/download/v2.2.1/Mod.Organizer.2.2.1.7z" ); var modfiles = await Task.WhenAll( DownloadAndInstall(Game.SkyrimSpecialEdition, 12604, "SkyUI"), DownloadAndInstall(Game.Fallout4, 11925, "Anti-Tank Rifle"), DownloadAndInstall(Game.SkyrimSpecialEdition, 4783, "Frost Armor UNP"), DownloadAndInstall(Game.SkyrimSpecialEdition, 32359, "Frost Armor HDT"), DownloadAndInstall("https://github.com/ShikyoKira/Project-New-Reign---Nemesis-Main/releases/download/v0.84-beta/Nemesis.Unlimited.Behavior.Engine.v0.84-beta.rar", "Nemesis.Unlimited.Behavior.Engine.v0.84-beta.rar", "Nemesis"), DownloadAndInstall(Game.Fallout4, 40136, "RAR test File")); // ShouldPullFrom Mirror // We're going to fully patch this mod from another source. await modfiles[3].Download.DeleteAsync(); await utils.Configure(); await modfiles[3].ModFolder.Combine("meta.ini").WriteAllLinesAsync( "[General]", $"matchAll= {modfiles[2].Download.FileName}" ); await utils.SourcePath.Combine("startup.bat").WriteAllLinesAsync( "ModOrganizer2.exe SKSE" ); await CompileAndInstall(profile); await utils.VerifyAllFiles(); await utils.InstallPath.Combine(Consts.LOOTFolderFilesDir).DeleteDirectory(); var compiler = new MO2Compiler( sourcePath: utils.InstallPath, downloadsPath: utils.DownloadsPath, mo2Profile: profile, outputFile: profile.RelativeTo(AbsolutePath.EntryPoint).WithExtension(Consts.ModListExtension)); Assert.True(await compiler.Begin()); }
public IncludeTaggedMods(ACompiler compiler, string tag) : base(compiler) { _mo2Compiler = (MO2Compiler)compiler; _tag = tag; _includeDirectly = _mo2Compiler.ModInis.Where(kv => { var general = kv.Value.General; if (general.notes != null && general.notes.Contains(_tag)) { return(true); } return(general.comments != null && general.comments.Contains(_tag)); }).Select(kv => $"mods\\{kv.Key}\\"); }
protected async Task Install(MO2Compiler compiler) { var modlist = AInstaller.LoadFromFile(compiler.ModListOutputFile); var installer = new MO2Installer( archive: compiler.ModListOutputFile, modList: modlist, outputFolder: utils.InstallFolder, downloadFolder: utils.DownloadsFolder, parameters: SystemParametersConstructor.Create()); installer.WarnOnOverwrite = false; installer.GameFolder = utils.GameFolder; await installer.Begin(); }
public async Task CreateModlist() { var profile = utils.AddProfile("Default"); var mod = utils.AddMod(); await DownloadAndInstall( "https://github.com/ModOrganizer2/modorganizer/releases/download/v2.2.1/Mod.Organizer.2.2.1.7z", "Mod.Organizer.2.2.1.7z"); await utils.DownloadsFolder.Combine("Mod.Organizer.2.2.1.7z.meta").WriteAllLinesAsync( "[General]", "directURL=https://github.com/ModOrganizer2/modorganizer/releases/download/v2.2.1/Mod.Organizer.2.2.1.7z" ); var modfiles = await Task.WhenAll( DownloadAndInstall(Game.SkyrimSpecialEdition, 12604, "SkyUI"), DownloadAndInstall(Game.Fallout4, 11925, "Anti-Tank Rifle"), DownloadAndInstall(Game.SkyrimSpecialEdition, 4783, "Frost Armor UNP"), DownloadAndInstall(Game.SkyrimSpecialEdition, 32359, "Frost Armor HDT")); // We're going to fully patch this mod from another source. modfiles[3].Download.Delete(); await utils.Configure(); await modfiles[3].ModFolder.Combine("meta.ini").WriteAllLinesAsync( "[General]", $"matchAll= {modfiles[2].Download.FileName}" ); await utils.MO2Folder.Combine("startup.bat").WriteAllLinesAsync( "ModOrganizer2.exe SKSE" ); await CompileAndInstall(profile); utils.VerifyAllFiles(); await utils.InstallFolder.Combine(Consts.LOOTFolderFilesDir).DeleteDirectory(); var compiler = new MO2Compiler( mo2Folder: utils.InstallFolder, mo2Profile: profile, outputFile: profile.RelativeTo(AbsolutePath.EntryPoint).WithExtension(Consts.ModListExtension)); compiler.MO2DownloadsFolder = utils.DownloadsFolder; Assert.True(await compiler.Begin()); }
public IgnoreDisabledMods(ACompiler compiler) : base(compiler) { _mo2Compiler = (MO2Compiler)compiler; var alwaysEnabled = _mo2Compiler.ModInis.Where(f => HasFlagInNotes(f.Value, Consts.WABBAJACK_ALWAYS_ENABLE)).Select(f => f.Key).Distinct(); var alwaysDisabled = _mo2Compiler.ModInis .Where(f => HasFlagInNotes(f.Value, Consts.WABBAJACK_ALWAYS_DISABLE)).Select(f => f.Key).Distinct(); _allEnabledMods = _mo2Compiler.SelectedProfiles .SelectMany(p => _mo2Compiler.SourcePath.Combine("profiles", p, "modlist.txt").ReadAllLines()) .Where(line => line.StartsWith("+") || line.EndsWith("_separator")) .Select(line => line.Substring(1).RelativeTo(_mo2Compiler.MO2ModsFolder)) .Concat(alwaysEnabled) .Except(alwaysDisabled) .ToList(); }
public IncludePatches(ACompiler compiler, VirtualFile?constructingFromBSA = null) : base(compiler) { _bsa = constructingFromBSA; _mo2Compiler = (MO2Compiler)compiler; _indexed = _compiler.IndexedFiles.Values .SelectMany(f => f) .GroupBy(f => f.Name.FileName) .ToDictionary(f => f.Key); _indexedByName = _indexed.Values .SelectMany(s => s) .Where(f => f.IsNative) .GroupBy(f => f.Name.FileName) .ToDictionary(f => f.Key, f => (IEnumerable <VirtualFile>)f); _isGenericGame = _mo2Compiler.CompilingGame.IsGenericMO2Plugin; }
protected async Task Install(MO2Compiler compiler) { Utils.Log("Loading Modlist"); var modlist = AInstaller.LoadFromFile(compiler.ModListOutputFile); Utils.Log("Constructing Installer"); var installer = new MO2Installer( archive: compiler.ModListOutputFile, modList: modlist, outputFolder: utils.InstallFolder, downloadFolder: utils.DownloadsFolder, parameters: CreateDummySystemParameters()); installer.WarnOnOverwrite = false; installer.GameFolder = utils.GameFolder; Utils.Log("Starting Install"); await installer.Begin(); }
public async Task <GetResponse <ModList> > Compile() { string outputFile; if (string.IsNullOrWhiteSpace(Parent.OutputLocation.TargetPath)) { outputFile = MOProfile + Consts.ModListExtension; } else { outputFile = Path.Combine(Parent.OutputLocation.TargetPath, MOProfile + Consts.ModListExtension); } try { using (ActiveCompilation = new MO2Compiler( mo2Folder: Mo2Folder, mo2Profile: MOProfile, outputFile: outputFile) { ModListName = ModlistSettings.ModListName, ModListAuthor = ModlistSettings.AuthorText, ModListDescription = ModlistSettings.Description, ModListImage = ModlistSettings.ImagePath.TargetPath, ModListWebsite = ModlistSettings.Website, ModListReadme = ModlistSettings.ReadmeIsWebsite ? ModlistSettings.ReadmeWebsite : ModlistSettings.ReadmeFilePath.TargetPath, ReadmeIsWebsite = ModlistSettings.ReadmeIsWebsite, MO2DownloadsFolder = DownloadLocation.TargetPath, }) { Parent.MWVM.Settings.Performance.AttachToBatchProcessor(ActiveCompilation); var success = await ActiveCompilation.Begin(); return(GetResponse <ModList> .Create(success, ActiveCompilation.ModList)); } } finally { StatusTracker = null; ActiveCompilation = null; } }
public async Task CreateModlist() { var profile = utils.AddProfile("Default"); var mod = utils.AddMod(); await DownloadAndInstall( "https://github.com/ModOrganizer2/modorganizer/releases/download/v2.2.1/Mod.Organizer.2.2.1.7z", "Mod.Organizer.2.2.1.7z", utils.MO2Folder); File.WriteAllLines(Path.Combine(utils.DownloadsFolder, "Mod.Organizer.2.2.1.7z.meta"), new List <string> { "[General]", "directURL=https://github.com/ModOrganizer2/modorganizer/releases/download/v2.2.1/Mod.Organizer.2.2.1.7z" }); await DownloadAndInstall(Game.SkyrimSpecialEdition, 12604, "SkyUI"); utils.Configure(); var modlist = await CompileAndInstall(profile); utils.VerifyAllFiles(); var loot_folder = Path.Combine(utils.InstallFolder, "LOOT Config Files"); if (Directory.Exists(loot_folder)) { Utils.DeleteDirectory(loot_folder); } var compiler = new MO2Compiler( mo2Folder: utils.InstallFolder, mo2Profile: profile, outputFile: profile + ExtensionManager.Extension); compiler.MO2DownloadsFolder = Path.Combine(utils.DownloadsFolder); compiler.ShowReportWhenFinished = false; Assert.IsTrue(await compiler.Begin()); }
public async Task Compile() { string outputFile; if (string.IsNullOrWhiteSpace(Parent.OutputLocation.TargetPath)) { outputFile = MOProfile + ExtensionManager.Extension; } else { outputFile = Path.Combine(Parent.OutputLocation.TargetPath, MOProfile + ExtensionManager.Extension); } try { ActiveCompilation = new MO2Compiler( mo2Folder: Mo2Folder, mo2Profile: MOProfile, outputFile: outputFile) { ModListName = ModlistSettings.ModListName, ModListAuthor = ModlistSettings.AuthorText, ModListDescription = ModlistSettings.Description, ModListImage = ModlistSettings.ImagePath.TargetPath, ModListWebsite = ModlistSettings.Website, ModListReadme = ModlistSettings.ReadmeIsWebsite ? ModlistSettings.ReadmeWebsite : ModlistSettings.ReadmeFilePath.TargetPath, ReadmeIsWebsite = ModlistSettings.ReadmeIsWebsite, }; await ActiveCompilation.Begin(); } finally { StatusTracker = null; ActiveCompilation.Dispose(); ActiveCompilation = null; } }
public IncludeThisProfile(ACompiler compiler) : base(compiler) { _mo2Compiler = (MO2Compiler)compiler; _correctProfiles = _mo2Compiler.SelectedProfiles.Select(p => _mo2Compiler.MO2ProfileDir.Parent.Combine(p)).ToList(); }
public MO2CompilerVM(CompilerVM parent) { Parent = parent; ModListLocation = new FilePickerVM() { ExistCheckOption = FilePickerVM.CheckOptions.On, PathType = FilePickerVM.PathTypeOptions.File, PromptTitle = "Select a ModList" }; DownloadLocation = new FilePickerVM() { ExistCheckOption = FilePickerVM.CheckOptions.On, PathType = FilePickerVM.PathTypeOptions.Folder, PromptTitle = "Select a downloads location", }; _mo2Folder = this.WhenAny(x => x.ModListLocation.TargetPath) .Select(loc => { try { var profileFolder = Path.GetDirectoryName(loc); return(Path.GetDirectoryName(Path.GetDirectoryName(profileFolder))); } catch (Exception) { return(null); } }) .ToGuiProperty(this, nameof(Mo2Folder)); _moProfile = this.WhenAny(x => x.ModListLocation.TargetPath) .Select(loc => { try { var profileFolder = Path.GetDirectoryName(loc); return(Path.GetFileName(profileFolder)); } catch (Exception) { return(null); } }) .ToGuiProperty(this, nameof(MOProfile)); // Wire missing Mo2Folder to signal error state for ModList Location ModListLocation.AdditionalError = this.WhenAny(x => x.Mo2Folder) .Select <string, IErrorResponse>(moFolder => { if (Directory.Exists(moFolder)) { return(ErrorResponse.Success); } return(ErrorResponse.Fail($"MO2 folder could not be located from the given ModList location.{Environment.NewLine}Make sure your ModList is inside a valid MO2 distribution.")); }); // Load custom ModList settings per MO2 profile _modlistSettings = Observable.CombineLatest( (this).WhenAny(x => x.ModListLocation.ErrorState), (this).WhenAny(x => x.ModListLocation.TargetPath), resultSelector: (state, path) => (State: state, Path: path)) // A short throttle is a quick hack to make the above changes "atomic" .Throttle(TimeSpan.FromMilliseconds(25), RxApp.MainThreadScheduler) .Select(u => { if (u.State.Failed) { return(null); } var modlistSettings = _settings.ModlistSettings.TryCreate(u.Path); return(new ModlistSettingsEditorVM(modlistSettings) { ModListName = MOProfile }); }) // Interject and save old while loading new .Pairwise() .Do(pair => { pair.Previous?.Save(); pair.Current?.Init(); }) .Select(x => x.Current) .ToGuiProperty(this, nameof(ModlistSettings)); CanCompile = Observable.CombineLatest( this.WhenAny(x => x.ModListLocation.InError), this.WhenAny(x => x.DownloadLocation.InError), parent.WhenAny(x => x.OutputLocation.InError), this.WhenAny(x => x.ModlistSettings) .Select(x => x?.InError ?? Observable.Return(false)) .Switch(), resultSelector: (ml, down, output, modlistSettings) => !ml && !down && !output && !modlistSettings) .Publish() .RefCount(); // Load settings _settings = parent.MWVM.Settings.Compiler.MO2Compilation; ModListLocation.TargetPath = _settings.LastCompiledProfileLocation; if (!string.IsNullOrWhiteSpace(_settings.DownloadLocation)) { DownloadLocation.TargetPath = _settings.DownloadLocation; } parent.MWVM.Settings.SaveSignal .Subscribe(_ => Unload()) .DisposeWith(CompositeDisposable); // If Mo2 folder changes and download location is empty, set it for convenience this.WhenAny(x => x.Mo2Folder) .DelayInitial(TimeSpan.FromMilliseconds(100), RxApp.MainThreadScheduler) .Where(x => Directory.Exists(x)) .FlowSwitch( (this).WhenAny(x => x.DownloadLocation.Exists) .Invert()) // A skip is needed to ignore the initial signal when the FilterSwitch turns on .Skip(1) .Subscribe(_ => { DownloadLocation.TargetPath = MO2Compiler.GetTypicalDownloadsFolder(Mo2Folder); }) .DisposeWith(CompositeDisposable); }
public IncludeStubbedConfigFiles(ACompiler compiler) : base(compiler) { _mo2Compiler = (MO2Compiler)compiler; }
public IncludeThisProfile(ACompiler compiler) : base(compiler) { _mo2Compiler = (MO2Compiler)compiler; _correctProfiles = _mo2Compiler.SelectedProfiles.Select(p => Path.Combine("profiles", p) + "\\").ToList(); }
public PatchStockESMs(ACompiler compiler) : base(compiler) { _mo2Compiler = (MO2Compiler)compiler; }
public static (bool, byte[], VirtualFile) PickPatch(MO2Compiler mo2Compiler, IEnumerable <(bool foundHash, byte[]? data, VirtualFile file)> patches)