mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
MO2 remaps game folder to Game Folder Files if the game executable exists in that folder
This commit is contained in:
parent
059f2ec96f
commit
3c671272b6
@ -29,9 +29,11 @@ namespace Wabbajack.Lib
|
||||
public ModList ModList { get; private set; }
|
||||
public Dictionary<Hash, AbsolutePath> HashedArchives { get; } = new Dictionary<Hash, AbsolutePath>();
|
||||
|
||||
public GameMetaData Game { get; }
|
||||
|
||||
public SystemParameters? SystemParameters { get; set; }
|
||||
|
||||
public AInstaller(AbsolutePath archive, ModList modList, AbsolutePath outputFolder, AbsolutePath downloadFolder, SystemParameters? parameters, int steps)
|
||||
public AInstaller(AbsolutePath archive, ModList modList, AbsolutePath outputFolder, AbsolutePath downloadFolder, SystemParameters? parameters, int steps, Game game)
|
||||
: base(steps)
|
||||
{
|
||||
ModList = modList;
|
||||
@ -39,6 +41,7 @@ namespace Wabbajack.Lib
|
||||
OutputFolder = outputFolder;
|
||||
DownloadFolder = downloadFolder;
|
||||
SystemParameters = parameters;
|
||||
Game = game.MetaData();
|
||||
}
|
||||
|
||||
public void Info(string msg)
|
||||
@ -280,7 +283,9 @@ namespace Wabbajack.Lib
|
||||
|
||||
public async Task HashArchives()
|
||||
{
|
||||
var hashResults = await DownloadFolder.EnumerateFiles()
|
||||
var hashResults = await
|
||||
DownloadFolder.EnumerateFiles()
|
||||
.Concat(Game.GameLocation().EnumerateFiles())
|
||||
.Where(e => e.Extension != Consts.HashFileExtension)
|
||||
.PMap(Queue, async e => (await e.FileHashCachedAsync(), e));
|
||||
HashedArchives.SetTo(hashResults
|
||||
|
@ -17,17 +17,14 @@ namespace Wabbajack.Lib.CompilationSteps
|
||||
|
||||
public override async ValueTask<Directive?> Run(RawSourceFile source)
|
||||
{
|
||||
if (_gameFolderFilesExists)
|
||||
{
|
||||
if (source.AbsolutePath.InFolder(_gameFolder))
|
||||
{
|
||||
var result = source.EvolveTo<IgnoredDirectly>();
|
||||
result.Reason = $"Ignoring game files because {Consts.GameFolderFilesDir} exists";
|
||||
return result;
|
||||
}
|
||||
}
|
||||
if (!_gameFolderFilesExists) return null;
|
||||
|
||||
if (!source.AbsolutePath.InFolder(_gameFolder)) return null;
|
||||
|
||||
var result = source.EvolveTo<IgnoredDirectly>();
|
||||
result.Reason = $"Ignoring game files because {Consts.GameFolderFilesDir} exists";
|
||||
return result;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public override IState GetState()
|
||||
|
@ -547,9 +547,6 @@ namespace Wabbajack.Lib
|
||||
// Ignore the ModOrganizer.ini file it contains info created by MO2 on startup
|
||||
new IncludeStubbedConfigFiles(this),
|
||||
new IncludeLootFiles(this),
|
||||
new IgnoreStartsWith(this, Path.Combine((string)Consts.GameFolderFilesDir, "Data")),
|
||||
new IgnoreStartsWith(this, Path.Combine((string)Consts.GameFolderFilesDir, "Papyrus Compiler")),
|
||||
new IgnoreStartsWith(this, Path.Combine((string)Consts.GameFolderFilesDir, "Skyrim")),
|
||||
new IgnoreRegex(this, Consts.GameFolderFilesDir + "\\\\.*\\.bsa"),
|
||||
new IncludeRegex(this, "^[^\\\\]*\\.bat$"),
|
||||
new IncludeModIniData(this),
|
||||
|
@ -32,8 +32,6 @@ namespace Wabbajack.Lib
|
||||
|
||||
public AbsolutePath? GameFolder { get; set; }
|
||||
|
||||
public GameMetaData Game { get; }
|
||||
|
||||
public MO2Installer(AbsolutePath archive, ModList modList, AbsolutePath outputFolder, AbsolutePath downloadFolder, SystemParameters parameters)
|
||||
: base(
|
||||
archive: archive,
|
||||
@ -41,11 +39,15 @@ namespace Wabbajack.Lib
|
||||
outputFolder: outputFolder,
|
||||
downloadFolder: downloadFolder,
|
||||
parameters: parameters,
|
||||
steps: 20)
|
||||
steps: 20,
|
||||
game: modList.GameType)
|
||||
{
|
||||
Game = ModList.GameType.MetaData();
|
||||
var gameExe = Consts.GameFolderFilesDir.Combine(modList.GameType.MetaData().MainExecutable!);
|
||||
RedirectGamePath = modList.Directives.Any(d => d.To == gameExe);
|
||||
}
|
||||
|
||||
public bool RedirectGamePath { get; }
|
||||
|
||||
protected override async Task<bool> _Begin(CancellationToken cancel)
|
||||
{
|
||||
if (cancel.IsCancellationRequested) return false;
|
||||
@ -379,9 +381,12 @@ namespace Wabbajack.Lib
|
||||
{
|
||||
var data = Encoding.UTF8.GetString(await LoadBytesFromPath(directive.SourceDataID));
|
||||
|
||||
data = data.Replace(Consts.GAME_PATH_MAGIC_BACK, (string)GameFolder!);
|
||||
data = data.Replace(Consts.GAME_PATH_MAGIC_DOUBLE_BACK, ((string)GameFolder!).Replace("\\", "\\\\"));
|
||||
data = data.Replace(Consts.GAME_PATH_MAGIC_FORWARD, ((string)GameFolder).Replace("\\", "/"));
|
||||
var gameFolder = (string)(RedirectGamePath ? Consts.GameFolderFilesDir.RelativeTo(OutputFolder) : GameFolder!);
|
||||
|
||||
|
||||
data = data.Replace(Consts.GAME_PATH_MAGIC_BACK, gameFolder);
|
||||
data = data.Replace(Consts.GAME_PATH_MAGIC_DOUBLE_BACK, gameFolder.Replace("\\", "\\\\"));
|
||||
data = data.Replace(Consts.GAME_PATH_MAGIC_FORWARD, gameFolder.Replace("\\", "/"));
|
||||
|
||||
data = data.Replace(Consts.MO2_PATH_MAGIC_BACK, (string)OutputFolder);
|
||||
data = data.Replace(Consts.MO2_PATH_MAGIC_DOUBLE_BACK, ((string)OutputFolder).Replace("\\", "\\\\"));
|
||||
|
@ -551,7 +551,7 @@ namespace Wabbajack.Test
|
||||
class TestInstaller : AInstaller
|
||||
{
|
||||
public TestInstaller(AbsolutePath archive, ModList modList, AbsolutePath outputFolder, AbsolutePath downloadFolder, SystemParameters parameters)
|
||||
: base(archive, modList, outputFolder, downloadFolder, parameters, steps: 1)
|
||||
: base(archive, modList, outputFolder, downloadFolder, parameters, steps: 1, modList.GameType)
|
||||
{
|
||||
Queue.SetActiveThreadsObservable(Observable.Return(1));
|
||||
}
|
||||
|
@ -61,7 +61,6 @@ namespace Wabbajack.Test
|
||||
DownloadAndInstall(Game.SkyrimSpecialEdition, 12604, "SkyUI"),
|
||||
DownloadAndInstall(Game.Fallout4, 11925, "Anti-Tank Rifle"),
|
||||
DownloadAndInstall(Game.SkyrimSpecialEdition, 4783, "Frost Armor UNP"),
|
||||
DownloadAndInstall(Game.Fallout4, 43474, "EM 2 Rifle No.9 Mk1"),
|
||||
DownloadAndInstall(Game.SkyrimSpecialEdition, 32359, "Frost Armor HDT"));
|
||||
|
||||
// We're going to fully patch this mod from another source.
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@ -431,7 +432,12 @@ namespace Wabbajack.Test
|
||||
var mod = utils.AddMod();
|
||||
var skyrimExe = utils.AddModFile(mod, @"Data\test.exe", 10);
|
||||
|
||||
await Game.SkyrimSpecialEdition.MetaData().GameLocation().Combine("SkyrimSE.exe").CopyToAsync(skyrimExe);
|
||||
var gameFolder = Consts.GameFolderFilesDir.RelativeTo(utils.MO2Folder);
|
||||
gameFolder.CreateDirectory();
|
||||
|
||||
var gameMeta = Game.SkyrimSpecialEdition.MetaData();
|
||||
await gameMeta.GameLocation().Combine(gameMeta.MainExecutable!).CopyToAsync(skyrimExe);
|
||||
await gameMeta.GameLocation().Combine(gameMeta.MainExecutable!).CopyToAsync(gameFolder.Combine(gameMeta.MainExecutable!));
|
||||
|
||||
await utils.Configure();
|
||||
|
||||
@ -439,8 +445,16 @@ namespace Wabbajack.Test
|
||||
|
||||
utils.VerifyInstalledFile(mod, @"Data\test.exe");
|
||||
|
||||
Consts.TestMode = true;
|
||||
Assert.False("SkyrimSE.exe".RelativeTo(utils.DownloadsFolder).Exists, "File should not appear in the download folder because it should be copied from the game folder");
|
||||
|
||||
var file = "ModOrganizer.ini".RelativeTo(utils.InstallFolder);
|
||||
Assert.True(file.Exists);
|
||||
|
||||
var ini = file.LoadIniFile();
|
||||
Assert.Equal(((AbsolutePath)(string)ini?.General?.gamePath).Combine(gameMeta.MainExecutable),
|
||||
Consts.GameFolderFilesDir.Combine(gameMeta.MainExecutable).RelativeTo(utils.InstallFolder));
|
||||
|
||||
Consts.TestMode = true;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
Loading…
Reference in New Issue
Block a user