mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
handle several more unmatching files
This commit is contained in:
parent
2d061bc1e4
commit
8b7b64ddd4
@ -29,6 +29,16 @@ namespace Wabbajack
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string MO2Profile;
|
||||||
|
|
||||||
|
public string MO2ProfileDir
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return Path.Combine(MO2Folder, MO2Profile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Action<string> Log_Fn { get; }
|
public Action<string> Log_Fn { get; }
|
||||||
public Action<string, long, long> Progress_Function { get; }
|
public Action<string, long, long> Progress_Function { get; }
|
||||||
|
|
||||||
@ -50,6 +60,8 @@ namespace Wabbajack
|
|||||||
GamePath = ((string)MO2Ini.General.gamePath).Replace("\\\\", "\\");
|
GamePath = ((string)MO2Ini.General.gamePath).Replace("\\\\", "\\");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void LoadArchives()
|
public void LoadArchives()
|
||||||
{
|
{
|
||||||
IndexedArchives = Directory.EnumerateFiles(MO2DownloadsFolder)
|
IndexedArchives = Directory.EnumerateFiles(MO2DownloadsFolder)
|
||||||
@ -155,15 +167,96 @@ namespace Wabbajack
|
|||||||
IgnoreStartsWith("logs\\"),
|
IgnoreStartsWith("logs\\"),
|
||||||
IgnoreStartsWith("downloads\\"),
|
IgnoreStartsWith("downloads\\"),
|
||||||
IgnoreStartsWith("webcache\\"),
|
IgnoreStartsWith("webcache\\"),
|
||||||
|
IgnoreStartsWith("nxmhandler."),
|
||||||
IgnoreEndsWith(".pyc"),
|
IgnoreEndsWith(".pyc"),
|
||||||
|
IgnoreOtherProfiles(),
|
||||||
|
IncludeThisProfile(),
|
||||||
// Ignore the ModOrganizer.ini file it contains info created by MO2 on startup
|
// Ignore the ModOrganizer.ini file it contains info created by MO2 on startup
|
||||||
IgnoreStartsWith("ModOrganizer.ini"),
|
IgnoreStartsWith("ModOrganizer.ini"),
|
||||||
IgnoreRegex(Consts.GameFolderFilesDir + "\\\\.*\\.bsa"),
|
IgnoreRegex(Consts.GameFolderFilesDir + "\\\\.*\\.bsa"),
|
||||||
|
IncludeModIniData(),
|
||||||
DirectMatch(),
|
DirectMatch(),
|
||||||
|
|
||||||
|
// If we have no match at this point for a game folder file, skip them, we can't do anything about them
|
||||||
|
IgnoreGameFiles(),
|
||||||
DropAll()
|
DropAll()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Func<RawSourceFile, Directive> IncludeModIniData()
|
||||||
|
{
|
||||||
|
return source =>
|
||||||
|
{
|
||||||
|
if (source.Path.StartsWith("mods\\") && source.Path.EndsWith("\\meta.ini"))
|
||||||
|
{
|
||||||
|
var e = source.EvolveTo<InlineFile>();
|
||||||
|
e.SourceData = File.ReadAllBytes(source.AbsolutePath).ToBase64();
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private Func<RawSourceFile, Directive> IgnoreGameFiles()
|
||||||
|
{
|
||||||
|
var start_dir = Consts.GameFolderFilesDir + "\\";
|
||||||
|
return source =>
|
||||||
|
{
|
||||||
|
if (source.Path.StartsWith(start_dir))
|
||||||
|
{
|
||||||
|
var i = source.EvolveTo<IgnoredDirectly>();
|
||||||
|
i.Reason = "Default game file";
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private Func<RawSourceFile, Directive> IncludeThisProfile()
|
||||||
|
{
|
||||||
|
var correct_profile = Path.Combine("profiles", MO2Profile) + "\\";
|
||||||
|
return source =>
|
||||||
|
{
|
||||||
|
if (source.Path.StartsWith(correct_profile))
|
||||||
|
{
|
||||||
|
byte[] data;
|
||||||
|
if (source.Path.EndsWith("\\modlist.txt"))
|
||||||
|
data = ReadAndCleanModlist(source.AbsolutePath);
|
||||||
|
else
|
||||||
|
data = File.ReadAllBytes(source.AbsolutePath);
|
||||||
|
|
||||||
|
var e = source.EvolveTo<InlineFile>();
|
||||||
|
e.SourceData = data.ToBase64();
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private byte[] ReadAndCleanModlist(string absolutePath)
|
||||||
|
{
|
||||||
|
var lines = File.ReadAllLines(absolutePath);
|
||||||
|
lines = (from line in lines
|
||||||
|
where !(line.StartsWith("-") && !line.EndsWith("_separator"))
|
||||||
|
select line).ToArray();
|
||||||
|
return Encoding.UTF8.GetBytes(String.Join("\r\n", lines));
|
||||||
|
}
|
||||||
|
|
||||||
|
private Func<RawSourceFile, Directive> IgnoreOtherProfiles()
|
||||||
|
{
|
||||||
|
var correct_profile = Path.Combine("profiles", MO2Profile) + "\\";
|
||||||
|
return source =>
|
||||||
|
{
|
||||||
|
if (source.Path.StartsWith("profiles\\") && !source.Path.StartsWith(correct_profile))
|
||||||
|
{
|
||||||
|
var c = source.EvolveTo<IgnoredDirectly>();
|
||||||
|
c.Reason = "File not for this profile";
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
private Func<RawSourceFile, Directive> IgnoreEndsWith(string v)
|
private Func<RawSourceFile, Directive> IgnoreEndsWith(string v)
|
||||||
{
|
{
|
||||||
var reason = String.Format("Ignored because path ends with {0}", v);
|
var reason = String.Format("Ignored because path ends with {0}", v);
|
||||||
|
@ -13,6 +13,7 @@ namespace Wabbajack
|
|||||||
{
|
{
|
||||||
var compiler = new Compiler("c:\\Mod Organizer 2", msg => Console.WriteLine(msg), (msg, id, prog) => Console.WriteLine(msg));
|
var compiler = new Compiler("c:\\Mod Organizer 2", msg => Console.WriteLine(msg), (msg, id, prog) => Console.WriteLine(msg));
|
||||||
compiler.LoadArchives();
|
compiler.LoadArchives();
|
||||||
|
compiler.MO2Profile = "Lexy's Legacy of The Dragonborn Special Edition";
|
||||||
compiler.Compile();
|
compiler.Compile();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user