diff --git a/README.md b/README.md index 2d3dff6e..b37a3888 100644 --- a/README.md +++ b/README.md @@ -127,7 +127,7 @@ There are some special cases where you want to change the default Wabbajack beha | `WABBAJACK_ALWAYS_ENABLE` | The mod will not be ignored by Wabbajack even if it's disabled | Wabbajack will normally ignore all mods you disabled in MO2 but there are some cases where you might want to give some choice to the end user and want to have the mod included | | `WABBAJACK_ALWAYS_DISABLE` | The mod will always be ignored by Wabbajack | Useful if you don't want some mods included in the Modlist but still want to keep it active in your own setup | -#### Folder Tags +#### Tagfile Tags You can create an empty `tagfile` with no extention in any folder you want to apply this tags to. This is meant to be used with folders that aren't mods. @@ -136,6 +136,7 @@ You can create an empty `tagfile` with no extention in any folder you want to ap | `WABBAJACK_INCLUDE` | All files in this folder will be inlined into the `.wabbajack` file | | | `WABBAJACK_NOMATCH_INCLUDE` | All files in this folder will be inlined into the `.wabbajack` file even if Wabbajack did not found a match for them. | Useful for generated files.| | `WABBAJACK_IGNORE` | All files in this folder will be ignored by Wabbajack and therefore not be put into into the `.wabbajack` file. | Useful for tools or other things outside a mod you don't want/need reproduced on a users machine. Handle with care since excluded stuff can potentially break a setup.\* | +| `WABBAJACK_INCLUDE_SAVES` | When this file exists Wabbajack will include your save files in the `.wabbajack` file.|| \*It will finish the installation of a modlist, but the installed list might not run if you excluded a crutial part of it. diff --git a/Wabbajack.Common/Consts.cs b/Wabbajack.Common/Consts.cs index bda50e65..77cc604d 100644 --- a/Wabbajack.Common/Consts.cs +++ b/Wabbajack.Common/Consts.cs @@ -47,6 +47,7 @@ namespace Wabbajack.Common public static string WABBAJACK_ALWAYS_DISABLE = "WABBAJACK_ALWAYS_DISABLE"; public static string WABBAJACK_NOMATCH_INCLUDE = "WABBAJACK_NOMATCH_INCLUDE"; public static string WABBAJACK_IGNORE = "WABBAJACK_IGNORE"; + public static string WABBAJACK_INCLUDE_SAVES = "WABBAJACK_INCLUDE_SAVES"; public static string GAME_PATH_MAGIC_BACK = "{--||GAME_PATH_MAGIC_BACK||--}"; public static string GAME_PATH_MAGIC_DOUBLE_BACK = "{--||GAME_PATH_MAGIC_DOUBLE_BACK||--}"; diff --git a/Wabbajack.Lib/CompilationSteps/IgnoreSaveFiles.cs b/Wabbajack.Lib/CompilationSteps/IgnoreSaveFiles.cs index b5ac1fd5..43271593 100644 --- a/Wabbajack.Lib/CompilationSteps/IgnoreSaveFiles.cs +++ b/Wabbajack.Lib/CompilationSteps/IgnoreSaveFiles.cs @@ -1,4 +1,6 @@ -using System.Linq; +using System; +using System.IO; +using System.Linq; using System.Threading.Tasks; using Wabbajack.Common; @@ -7,21 +9,53 @@ namespace Wabbajack.Lib.CompilationSteps public class IgnoreSaveFiles : MO2CompilationStep { private AbsolutePath[] _profilePaths; + private readonly bool _includeSaves; + private readonly string _tag; + private readonly AbsolutePath _sourcePath; public IgnoreSaveFiles(ACompiler compiler) : base(compiler) { + _tag = Consts.WABBAJACK_INCLUDE_SAVES; + _sourcePath = compiler.SourcePath; + string rootDirectory = (string)_sourcePath; + + try + { + _includeSaves = File.Exists(((String)Directory.EnumerateFiles(rootDirectory, _tag).ToList().First())) ? true : false; + } + catch // Cant get a .First() if the list is empty, which it is when the files doesn't exist. + { + _includeSaves = false; + } + + _profilePaths = MO2Compiler.SelectedProfiles.Select(p => MO2Compiler.SourcePath.Combine("profiles", p, "saves")).ToArray(); } public override async ValueTask Run(RawSourceFile source) { - if (!_profilePaths.Any(p => source.File.AbsoluteName.InFolder(p))) - return null; + if (_includeSaves) + { + foreach (var folderpath in _profilePaths) + { + if (!source.AbsolutePath.InFolder(folderpath)) continue; + var result = source.EvolveTo(); + result.SourceDataID = await _compiler.IncludeFile(source.AbsolutePath); + return result; + } + } + else + { + if (!_profilePaths.Any(p => source.File.AbsoluteName.InFolder(p))) + return null; + + var result = source.EvolveTo(); + result.Reason = "Ignore Save files"; + return result; + } + return null; - var result = source.EvolveTo(); - result.Reason = "Ignore Save files"; - return result; } } }