VortexCompiler will now export MD and HTML files

This commit is contained in:
erri120 2019-11-17 15:54:04 +01:00
parent 24378ac553
commit b21fdfbd8c
No known key found for this signature in database
GPG Key ID: A8C0A18D8D4D3135
2 changed files with 33 additions and 9 deletions

View File

@ -44,18 +44,26 @@ namespace Wabbajack.Lib
wtr.WriteLine(txt); wtr.WriteLine(txt);
} }
public void Build(Compiler c, ModList lst) public void Build(ACompiler c, ModList lst)
{ {
Compiler compiler = null;
if (lst.ModManager == ModManager.MO2)
compiler = (Compiler) c;
Text($"### {lst.Name} by {lst.Author} - Installation Summary"); Text($"### {lst.Name} by {lst.Author} - Installation Summary");
Text($"Build with Wabbajack Version {lst.WabbajackVersion}"); Text($"Build with Wabbajack Version {lst.WabbajackVersion}");
Text(lst.Description); Text(lst.Description);
Text($"#### Website:"); Text("#### Website:");
NoWrapText($"[{lst.Website}]({lst.Website})"); NoWrapText($"[{lst.Website}]({lst.Website})");
Text($"Mod Manager: {lst.ModManager.ToString()}");
var readme_file = Path.Combine(c.MO2ProfileDir, "readme.md"); if (lst.ModManager == ModManager.MO2)
{
var readme_file = Path.Combine(compiler?.MO2ProfileDir, "readme.md");
if (File.Exists(readme_file)) if (File.Exists(readme_file))
File.ReadAllLines(readme_file) File.ReadAllLines(readme_file)
.Do(NoWrapText); .Do(NoWrapText);
}
Text( Text(
$"#### Download Summary ({lst.Archives.Count} archives - {lst.Archives.Sum(a => a.Size).ToFileSizeString()})"); $"#### Download Summary ({lst.Archives.Count} archives - {lst.Archives.Sum(a => a.Size).ToFileSizeString()})");

View File

@ -1,10 +1,12 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.IO; using System.IO;
using System.IO.Compression; using System.IO.Compression;
using System.Linq; using System.Linq;
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Text; using System.Text;
using CommonMark;
using Microsoft.WindowsAPICodePack.Shell; using Microsoft.WindowsAPICodePack.Shell;
using Wabbajack.Common; using Wabbajack.Common;
using Wabbajack.Lib.CompilationSteps; using Wabbajack.Lib.CompilationSteps;
@ -81,6 +83,8 @@ namespace Wabbajack.Lib
public override bool Compile() public override bool Compile()
{ {
if (string.IsNullOrEmpty(ModListName))
ModListName = $"Vortex ModList for {Game.ToString()}";
ModListOutputFile = $"{ModListName}{ExtensionManager.Extension}"; ModListOutputFile = $"{ModListName}{ExtensionManager.Extension}";
Info($"Starting Vortex compilation for {GameName} at {GamePath} with staging folder at {StagingFolder} and downloads folder at {DownloadsFolder}."); Info($"Starting Vortex compilation for {GameName} at {GamePath} with staging folder at {StagingFolder} and downloads folder at {DownloadsFolder}.");
@ -196,7 +200,7 @@ namespace Wabbajack.Lib
ModList = new ModList ModList = new ModList
{ {
Name = ModListName ?? $"Vortex ModList for {Game.ToString()}", Name = ModListName ?? "",
Author = ModListAuthor ?? "", Author = ModListAuthor ?? "",
Description = ModListDescription ?? "", Description = ModListDescription ?? "",
Readme = ModListReadme ?? "", Readme = ModListReadme ?? "",
@ -208,9 +212,12 @@ namespace Wabbajack.Lib
GameType = Game GameType = Game
}; };
GenerateReport();
ExportModList(); ExportModList();
Info("Done Building ModList"); Info("Done Building ModList");
ShowReport();
return true; return true;
} }
@ -275,7 +282,7 @@ namespace Wabbajack.Lib
Directory.Delete(ModListOutputFolder, true); Directory.Delete(ModListOutputFolder, true);
} }
/*private void GenerateReport() private void GenerateReport()
{ {
string css; string css;
using (var cssStream = Utils.GetResourceStream("Wabbajack.Lib.css-min.css")) using (var cssStream = Utils.GetResourceStream("Wabbajack.Lib.css-min.css"))
@ -292,7 +299,16 @@ namespace Wabbajack.Lib
reporter.Build(this, ModList); reporter.Build(this, ModList);
} }
} }
}*/
ModList.ReportHTML = "<style>" + css + "</style>" + CommonMarkConverter.Convert(File.ReadAllText($"{ModList.Name}.md"));
}
private void ShowReport()
{
var file = Alphaleonis.Win32.Filesystem.Path.GetTempFileName() + ".html";
File.WriteAllText(file, ModList.ReportHTML);
Process.Start(file);
}
private void CreateMetaFiles() private void CreateMetaFiles()
{ {