Created new Manifest class

This commit is contained in:
erri120 2020-02-01 13:13:12 +01:00
parent ff7964b797
commit 366ccbc1e1
No known key found for this signature in database
GPG Key ID: A8C0A18D8D4D3135
5 changed files with 56 additions and 25 deletions

View File

@ -159,28 +159,10 @@ namespace Wabbajack.Lib
Utils.DeleteDirectory(ModListOutputFolder);
}
public void GenerateReport()
public void GenerateManifest()
{
string css;
using (var cssStream = Utils.GetEmbeddedResourceStream("Wabbajack.Lib.css-min.css"))
{
using (var reader = new StreamReader(cssStream))
{
css = reader.ReadToEnd();
}
}
using (var fs = File.Open($"{ModList.Name}.md", System.IO.FileMode.Create))
{
fs.SetLength(0);
using (var reporter = new ReportBuilder(fs, ModListOutputFolder))
{
reporter.Build(this, ModList);
}
}
ModList.ReportHTML = "<style>" + css + "</style>"
+ CommonMarkConverter.Convert(File.ReadAllText($"{ModList.Name}.md"));
var manifest = new Manifest(ModList);
manifest.ToJSON(ModListOutputFile + ".manifest.json");
}
public async Task GatherArchives()

View File

@ -290,7 +290,7 @@ namespace Wabbajack.Lib
await ValidateModlist.RunValidation(Queue, ModList);
UpdateTracker.NextStep("Generating Report");
GenerateReport();
GenerateManifest();
UpdateTracker.NextStep("Exporting Modlist");
ExportModList();

51
Wabbajack.Lib/Manifest.cs Normal file
View File

@ -0,0 +1,51 @@
using System.Collections.Generic;
using System.Linq;
using Wabbajack.Common;
namespace Wabbajack.Lib
{
public class Manifest
{
public string Name;
public string Author;
public string Description;
public Game GameType;
// Enum toString for better parsing in other software
public string GameName;
public ModManager ModManager;
// Enum toString for better parsing in other software
public string ModManagerName;
public long DownloadSize;
public long InstallSize;
public List<Archive> Archives;
public Manifest(ModList modlist)
{
Name = modlist.Name;
Author = modlist.Author;
Description = modlist.Description;
GameType = modlist.GameType;
GameName = GameType.ToString();
ModManager = modlist.ModManager;
ModManagerName = ModManager.ToString();
DownloadSize = modlist.DownloadSize;
InstallSize = modlist.InstallSize;
// meta is being omitted due to it being useless and not very space friendly
Archives = modlist.Archives.Select(a => new Archive
{
Hash = a.Hash,
Name = a.Name,
Size = a.Size,
State = a.State
}).ToList();
}
}
}

View File

@ -248,7 +248,7 @@ namespace Wabbajack.Lib
await ValidateModlist.RunValidation(Queue, ModList);
UpdateTracker.NextStep("Generating Report");
GenerateReport();
GenerateManifest();
UpdateTracker.NextStep("Exporting ModList");
ExportModList();

View File

@ -80,8 +80,6 @@
</ItemGroup>
<ItemGroup>
<None Remove="LibCefHelpers\cefsharp.7z" />
<None Remove="css-min.css" />
<EmbeddedResource Include="css-min.css" />
<None Update="Downloaders\BethesdaNet\bethnetlogin.exe">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>