mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Merge pull request #1369 from EzioTheDeadPoet/include_saves_option
adds option to include save files if wanted.
This commit is contained in:
commit
4476a41193
@ -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.
|
||||
|
||||
|
@ -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||--}";
|
||||
|
@ -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<Directive?> 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<InlineFile>();
|
||||
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<IgnoredDirectly>();
|
||||
result.Reason = "Ignore Save files";
|
||||
return result;
|
||||
}
|
||||
return null;
|
||||
|
||||
var result = source.EvolveTo<IgnoredDirectly>();
|
||||
result.Reason = "Ignore Save files";
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user