From fe3da01687617546b62c1fddb97c374c9aef4402 Mon Sep 17 00:00:00 2001 From: Luca Date: Sun, 14 Mar 2021 14:15:33 +0100 Subject: [PATCH] include mo2 splash screen if present --- .../CompilationSteps/IncludeSplashScreen.cs | 47 +++++++++++++++++++ Wabbajack.Lib/MO2Compiler.cs | 1 + 2 files changed, 48 insertions(+) create mode 100644 Wabbajack.Lib/CompilationSteps/IncludeSplashScreen.cs diff --git a/Wabbajack.Lib/CompilationSteps/IncludeSplashScreen.cs b/Wabbajack.Lib/CompilationSteps/IncludeSplashScreen.cs new file mode 100644 index 00000000..fea04988 --- /dev/null +++ b/Wabbajack.Lib/CompilationSteps/IncludeSplashScreen.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Wabbajack.Common; + +namespace Wabbajack.Lib.CompilationSteps +{ + public class IncludeSplashScreen : MO2CompilationStep + { + private readonly string _splash; + + private readonly AbsolutePath _sourcePath; + private List _splashPath; + private readonly bool _splashExists; + + public IncludeSplashScreen(ACompiler compiler) : base(compiler) + { + _splash = "splash.png"; + _sourcePath = compiler.SourcePath; + string rootDirectory = (string)_sourcePath; + _splashExists = File.Exists(((String)Directory.EnumerateFiles(rootDirectory, _splash).ToList().First())) ? true : false; + + _splashPath = Directory.EnumerateFiles(rootDirectory, _splash).Select(str => (AbsolutePath)str) + .ToList(); + } + + + public override async ValueTask Run(RawSourceFile source) + { + if (_splashExists) + { + foreach (var folderpath in _splashPath) + { + if (!source.AbsolutePath.InFolder(folderpath)) continue; + var result = source.EvolveTo(); + result.SourceDataID = await _compiler.IncludeFile(source.AbsolutePath); + return result; + } + } + return null; + } + } + +} diff --git a/Wabbajack.Lib/MO2Compiler.cs b/Wabbajack.Lib/MO2Compiler.cs index ef61ff60..ed2af8df 100644 --- a/Wabbajack.Lib/MO2Compiler.cs +++ b/Wabbajack.Lib/MO2Compiler.cs @@ -451,6 +451,7 @@ namespace Wabbajack.Lib new DirectMatch(this), new IncludeTaggedMods(this, Consts.WABBAJACK_INCLUDE), new IncludeTaggedFolders(this, Consts.WABBAJACK_INCLUDE), + new IncludeSplashScreen(this), new IgnoreEndsWith(this, ".pyc"), new IgnoreEndsWith(this, ".log"), new DeconstructBSAs(