mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
commit
1b428cd03b
@ -1,13 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Reactive.Subjects;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading;
|
||||
using CommonMark;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Lib.CompilationSteps;
|
||||
using Wabbajack.Lib.Downloaders;
|
||||
@ -159,28 +156,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()
|
||||
|
@ -95,11 +95,6 @@ namespace Wabbajack.Lib
|
||||
/// </summary>
|
||||
public string Readme;
|
||||
|
||||
/// <summary>
|
||||
/// Content Report in HTML form
|
||||
/// </summary>
|
||||
public string ReportHTML;
|
||||
|
||||
/// <summary>
|
||||
/// The size of all the archives once they're downloaded
|
||||
/// </summary>
|
||||
|
@ -82,7 +82,7 @@ namespace Wabbajack.Lib.Downloaders
|
||||
|
||||
public abstract IDownloader GetDownloader();
|
||||
|
||||
public abstract string GetReportEntry(Archive a);
|
||||
public abstract string GetManifestURL(Archive a);
|
||||
public abstract string[] GetMetaIni();
|
||||
}
|
||||
}
|
||||
|
@ -154,9 +154,9 @@ namespace Wabbajack.Lib.Downloaders
|
||||
return DownloadDispatcher.GetInstance<TDownloader>();
|
||||
}
|
||||
|
||||
public override string GetReportEntry(Archive a)
|
||||
public override string GetManifestURL(Archive a)
|
||||
{
|
||||
return $"* {((INeedsLogin)GetDownloader()).SiteName} - [{a.Name}]({Site}/files/file/{FileName}/?do=download&r={FileID})";
|
||||
return $"{Site}/files/file/{FileName}/?do=download&r={FileID}";
|
||||
}
|
||||
|
||||
public override string[] GetMetaIni()
|
||||
|
@ -255,7 +255,7 @@ namespace Wabbajack.Lib.Downloaders
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override string GetReportEntry(Archive a)
|
||||
public override string GetManifestURL(Archive a)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
@ -83,9 +83,9 @@ namespace Wabbajack.Lib.Downloaders
|
||||
return DownloadDispatcher.GetInstance<GameFileSourceDownloader>();
|
||||
}
|
||||
|
||||
public override string GetReportEntry(Archive a)
|
||||
public override string GetManifestURL(Archive a)
|
||||
{
|
||||
return $"* Game File {Game} - {GameFile}";
|
||||
return null;
|
||||
}
|
||||
|
||||
public override string[] GetMetaIni()
|
||||
|
@ -75,9 +75,9 @@ namespace Wabbajack.Lib.Downloaders
|
||||
return DownloadDispatcher.GetInstance<GoogleDriveDownloader>();
|
||||
}
|
||||
|
||||
public override string GetReportEntry(Archive a)
|
||||
public override string GetManifestURL(Archive a)
|
||||
{
|
||||
return $"* GoogleDrive - [{a.Name}](https://drive.google.com/uc?id={Id}&export=download)";
|
||||
return $"https://drive.google.com/uc?id={Id}&export=download";
|
||||
}
|
||||
|
||||
public override string[] GetMetaIni()
|
||||
|
@ -200,9 +200,9 @@ TOP:
|
||||
return DownloadDispatcher.GetInstance<HTTPDownloader>();
|
||||
}
|
||||
|
||||
public override string GetReportEntry(Archive a)
|
||||
public override string GetManifestURL(Archive a)
|
||||
{
|
||||
return $"* [{a.Name} - {Url}]({Url})";
|
||||
return Url;
|
||||
}
|
||||
|
||||
public override string[] GetMetaIni()
|
||||
|
@ -122,9 +122,9 @@ namespace Wabbajack.Lib.Downloaders
|
||||
return DownloadDispatcher.GetInstance<ManualDownloader>();
|
||||
}
|
||||
|
||||
public override string GetReportEntry(Archive a)
|
||||
public override string GetManifestURL(Archive a)
|
||||
{
|
||||
return $"* Manual Download - [{a.Name} - {Url}]({Url})";
|
||||
return Url;
|
||||
}
|
||||
|
||||
public override string[] GetMetaIni()
|
||||
|
@ -64,9 +64,9 @@ namespace Wabbajack.Lib.Downloaders
|
||||
return DownloadDispatcher.GetInstance<MediaFireDownloader>();
|
||||
}
|
||||
|
||||
public override string GetReportEntry(Archive a)
|
||||
public override string GetManifestURL(Archive a)
|
||||
{
|
||||
return $"* [{a.Name} - {Url}]({Url})";
|
||||
return Url;
|
||||
}
|
||||
|
||||
public override string[] GetMetaIni()
|
||||
|
@ -105,9 +105,9 @@ namespace Wabbajack.Lib.Downloaders
|
||||
return DownloadDispatcher.GetInstance<ModDBDownloader>();
|
||||
}
|
||||
|
||||
public override string GetReportEntry(Archive a)
|
||||
public override string GetManifestURL(Archive a)
|
||||
{
|
||||
return $"* ModDB - [{a.Name}]({Url})";
|
||||
return Url;
|
||||
}
|
||||
|
||||
public override string[] GetMetaIni()
|
||||
|
@ -193,15 +193,9 @@ namespace Wabbajack.Lib.Downloaders
|
||||
return DownloadDispatcher.GetInstance<NexusDownloader>();
|
||||
}
|
||||
|
||||
public override string GetReportEntry(Archive a)
|
||||
public override string GetManifestURL(Archive a)
|
||||
{
|
||||
var profile = UploaderProfile.Replace("/games/",
|
||||
"/" + NexusApiUtils.ConvertGameName(GameName).ToLower() + "/");
|
||||
|
||||
return string.Join("\n",
|
||||
$"* [{a.Name}](http://nexusmods.com/{NexusApiUtils.ConvertGameName(GameName)}/mods/{ModID})",
|
||||
$" * Author : [{UploadedBy}]({profile})",
|
||||
$" * Version : {Version}");
|
||||
return $"http://nexusmods.com/{NexusApiUtils.ConvertGameName(GameName)}/mods/{ModID}";
|
||||
}
|
||||
|
||||
public override string[] GetMetaIni()
|
||||
|
@ -92,9 +92,9 @@ namespace Wabbajack.Lib.Downloaders
|
||||
return DownloadDispatcher.GetInstance<SteamWorkshopDownloader>();
|
||||
}
|
||||
|
||||
public override string GetReportEntry(Archive a)
|
||||
public override string GetManifestURL(Archive a)
|
||||
{
|
||||
return $"* Steam - [{Item.ItemID}]";
|
||||
return $"https://steamcommunity.com/sharedfiles/filedetails/?id={Item.ItemID}";
|
||||
}
|
||||
|
||||
public override string[] GetMetaIni()
|
||||
|
@ -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
51
Wabbajack.Lib/Manifest.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,152 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Wabbajack.Common;
|
||||
using File = Alphaleonis.Win32.Filesystem.File;
|
||||
using Path = Alphaleonis.Win32.Filesystem.Path;
|
||||
|
||||
namespace Wabbajack.Lib
|
||||
{
|
||||
public class ReportBuilder : IDisposable
|
||||
{
|
||||
private const int WRAP_SIZE = 80;
|
||||
private readonly StreamWriter _wtr;
|
||||
private string _outputFolder;
|
||||
|
||||
public ReportBuilder(Stream str, string outputFolder)
|
||||
{
|
||||
_outputFolder = outputFolder;
|
||||
_wtr = new StreamWriter(str);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_wtr.Flush();
|
||||
_wtr?.Dispose();
|
||||
}
|
||||
|
||||
public void Text(string txt)
|
||||
{
|
||||
var offset = 0;
|
||||
while (offset + WRAP_SIZE < txt.Length)
|
||||
{
|
||||
_wtr.WriteLine(txt.Substring(offset, WRAP_SIZE));
|
||||
offset += WRAP_SIZE;
|
||||
}
|
||||
|
||||
if (offset < txt.Length) _wtr.WriteLine(txt.Substring(offset, txt.Length - offset));
|
||||
}
|
||||
|
||||
public void NoWrapText(string txt)
|
||||
{
|
||||
_wtr.WriteLine(txt);
|
||||
}
|
||||
|
||||
public void Build(ACompiler c, ModList lst)
|
||||
{
|
||||
MO2Compiler compiler = null;
|
||||
if (lst.ModManager == ModManager.MO2)
|
||||
compiler = (MO2Compiler) c;
|
||||
|
||||
Text($"### {lst.Name} by {lst.Author} - Installation Summary");
|
||||
Text($"Build with Wabbajack Version {lst.WabbajackVersion}");
|
||||
Text(lst.Description);
|
||||
Text("#### Website:");
|
||||
NoWrapText($"[{lst.Website}]({lst.Website})");
|
||||
Text($"Mod Manager: {lst.ModManager.ToString()}");
|
||||
|
||||
if (lst.ModManager == ModManager.MO2)
|
||||
{
|
||||
var readmeFile = Path.Combine(compiler?.MO2ProfileDir, "readme.md");
|
||||
if (File.Exists(readmeFile))
|
||||
File.ReadAllLines(readmeFile)
|
||||
.Do(NoWrapText);
|
||||
}
|
||||
|
||||
var archiveCount = lst.Archives.Count + lst.Directives.Count(d => d is SteamMeta);
|
||||
var totalSize = lst.Archives.Sum(a => a.Size);
|
||||
totalSize += lst.Directives.Where(d => d is SteamMeta).Cast<SteamMeta>().Sum(s => s.Size);
|
||||
|
||||
Text(
|
||||
$"#### Download Summary ({archiveCount} archives - {totalSize.ToFileSizeString()})");
|
||||
foreach (var archive in SortArchives(lst.Archives))
|
||||
{
|
||||
var hash = archive.Hash.FromBase64().ToHex();
|
||||
NoWrapText(archive.State.GetReportEntry(archive));
|
||||
NoWrapText($" * Size : {archive.Size.ToFileSizeString()}");
|
||||
NoWrapText($" * SHA256 : [{hash}](https://www.virustotal.com/gui/file/{hash})");
|
||||
}
|
||||
lst.Directives.Where(d => d is SteamMeta).Do(f =>
|
||||
{
|
||||
if (!(f is SteamMeta s))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var link = $"https://steamcommunity.com/sharedfiles/filedetails/?id={s.ItemID}";
|
||||
var size = ((long)s.Size).ToFileSizeString();
|
||||
NoWrapText($"* Steam Workshop Item: [{s.ItemID}]({link}) | Size: {size}");
|
||||
});
|
||||
|
||||
Text("\n\n");
|
||||
var patched = lst.Directives.OfType<PatchedFromArchive>().OrderBy(p => p.To).ToList();
|
||||
Text($"#### Summary of ({patched.Count}) patches");
|
||||
foreach (var directive in patched)
|
||||
NoWrapText(
|
||||
$"* Applying {SizeForID(directive.PatchID)} byte patch `{directive.FullPath}` to create `{directive.To}`");
|
||||
|
||||
|
||||
var files = lst.Directives.OrderBy(d => d.To).ToList();
|
||||
Text($"\n\n### Install Plan of ({files.Count}) files");
|
||||
Text("(ignoring files that are directly copied from archives or listed in the patches section above)");
|
||||
foreach (var directive in files.OrderBy(f => f.GetType().Name).ThenByDescending(f => f.To))
|
||||
switch (directive)
|
||||
{
|
||||
case PropertyFile i:
|
||||
NoWrapText($"* `{i.SourceDataID}` as a `{Enum.GetName(typeof(PropertyType),i.Type)}`");
|
||||
break;
|
||||
case FromArchive f:
|
||||
//NoWrapText($"* `{f.To}` from `{f.FullPath}`");
|
||||
break;
|
||||
case CleanedESM i:
|
||||
NoWrapText($"* `{i.To}` by applying a patch to a game ESM ({i.SourceESMHash})");
|
||||
break;
|
||||
case RemappedInlineFile i:
|
||||
NoWrapText($"* `{i.To}` by remapping the contents of an inline file");
|
||||
break;
|
||||
case InlineFile i:
|
||||
NoWrapText($"* `{i.To}` from `{SizeForID(i.SourceDataID).ToFileSizeString()}` file included in modlist");
|
||||
break;
|
||||
case CreateBSA i:
|
||||
NoWrapText(
|
||||
$"* `{i.To}` by creating a BSA of files found in `{Consts.BSACreationDir}\\{i.TempID}`");
|
||||
break;
|
||||
}
|
||||
|
||||
var inlined = lst.Directives.OfType<InlineFile>()
|
||||
.Select(f => (f.To, "inlined", SizeForID(f.SourceDataID)))
|
||||
.Concat(lst.Directives
|
||||
.OfType<PatchedFromArchive>()
|
||||
.Select(f => (f.To, "patched", SizeForID(f.PatchID))))
|
||||
.Distinct()
|
||||
.OrderByDescending(f => f.Item3);
|
||||
|
||||
NoWrapText("\n\n### Summary of inlined files in this installer");
|
||||
foreach (var inline in inlined)
|
||||
{
|
||||
NoWrapText($"* {inline.Item3.ToFileSizeString()} for {inline.Item2} file {inline.To}");
|
||||
}
|
||||
}
|
||||
|
||||
private long SizeForID(string id)
|
||||
{
|
||||
return File.GetSize(Path.Combine(_outputFolder, id));
|
||||
}
|
||||
|
||||
private IEnumerable<Archive> SortArchives(List<Archive> lstArchives)
|
||||
{
|
||||
return lstArchives.OrderByDescending(a => a.Size);
|
||||
}
|
||||
}
|
||||
}
|
@ -248,7 +248,7 @@ namespace Wabbajack.Lib
|
||||
await ValidateModlist.RunValidation(Queue, ModList);
|
||||
|
||||
UpdateTracker.NextStep("Generating Report");
|
||||
GenerateReport();
|
||||
GenerateManifest();
|
||||
|
||||
UpdateTracker.NextStep("Exporting ModList");
|
||||
ExportModList();
|
||||
|
@ -15,9 +15,6 @@
|
||||
<PackageReference Include="Ceras">
|
||||
<Version>4.1.7</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="CommonMark.NET">
|
||||
<Version>0.15.1</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Fody">
|
||||
<Version>6.1.0</Version>
|
||||
</PackageReference>
|
||||
@ -80,8 +77,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>
|
||||
|
1
Wabbajack.Lib/css-min.css
vendored
1
Wabbajack.Lib/css-min.css
vendored
@ -1 +0,0 @@
|
||||
*{margin:0;padding:0;border:0;font-size:100%;font-family:'Segoe UI',Tahoma,Geneva,Verdana,sans-serif;vertical-align:baseline;-webkit-text-size-adjust:none;padding-left:10px;padding-right:10px}ul{list-style:none}q{quotes:none}q:after,q:before{content:'';content:none}h1,h2,h3,h4,h5,h6{color:#555;font-weight:400;line-height:1.5;margin:0}h3{margin:1em 0 1em .5em;text-align:left;text-decoration:underline}h1 a,h2 a,h3 a,h4 a,h5 a,h6 a{color:inherit;text-decoration:none}h2{font-size:1.85em;font-weight:300}h3{font-size:1.75em}h4{font-size:1.5em}h5{font-size:.9em}h6{font-size:.7em}a{color:#6cc091;text-decoration:underline}a:hover{text-decoration:none}code{background:rgba(144,144,144,.075);border-radius:0;border:solid 1px #dbdbdb;font-family:"Courier New",monospace;font-size:.9em}
|
@ -1,67 +0,0 @@
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
font-size: 100%;
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
vertical-align: baseline;
|
||||
-webkit-text-size-adjust: none;
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
|
||||
}
|
||||
ul {
|
||||
list-style: none;
|
||||
}
|
||||
q {
|
||||
quotes: none;
|
||||
}
|
||||
q:before , q:after {
|
||||
content: '';
|
||||
content: none;
|
||||
}
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
color: #555;
|
||||
font-weight: 400;
|
||||
line-height: 1.5;
|
||||
margin: 0 0 0 0;
|
||||
}
|
||||
h3 {
|
||||
margin: 1em 0 1em 0.5em;
|
||||
text-align: left;
|
||||
text-decoration: underline;
|
||||
}
|
||||
h1 a, h2 a, h3 a, h4 a, h5 a, h6 a {
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
}
|
||||
h2 {
|
||||
font-size: 1.85em;
|
||||
font-weight: 300;
|
||||
}
|
||||
h3 {
|
||||
font-size: 1.75em;
|
||||
}
|
||||
h4 {
|
||||
font-size: 1.5em;
|
||||
}
|
||||
h5 {
|
||||
font-size: 0.9em;
|
||||
}
|
||||
h6 {
|
||||
font-size: 0.7em;
|
||||
}
|
||||
a {
|
||||
color: #6cc091;
|
||||
text-decoration: underline;
|
||||
}
|
||||
a:hover {
|
||||
text-decoration: none;
|
||||
}
|
||||
code {
|
||||
background: rgba(144, 144, 144, 0.075);
|
||||
border-radius: 0;
|
||||
border: solid 1px #dbdbdb;
|
||||
font-family: "Courier New", monospace;
|
||||
font-size: 0.9em;
|
||||
}
|
@ -186,14 +186,6 @@ namespace Wabbajack
|
||||
{
|
||||
var modList = await this.Compiler.Compile();
|
||||
Completed = ErrorResponse.Create(modList.Succeeded);
|
||||
try
|
||||
{
|
||||
ShowReport(modList.Value);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Utils.Error(ex, $"Error opening manifest report");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -275,12 +267,5 @@ namespace Wabbajack
|
||||
.Switch()
|
||||
.ToGuiProperty(this, nameof(CurrentCpuCount));
|
||||
}
|
||||
|
||||
public void ShowReport(ModList modList)
|
||||
{
|
||||
var file = Path.GetTempFileName() + ".html";
|
||||
File.WriteAllText(file, modList.ReportHTML);
|
||||
Utils.StartProcessFromFile(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,9 +41,6 @@ namespace Wabbajack
|
||||
private readonly ObservableAsPropertyHelper<ISubInstallerVM> _installer;
|
||||
public ISubInstallerVM Installer => _installer.Value;
|
||||
|
||||
private readonly ObservableAsPropertyHelper<string> _htmlReport;
|
||||
public string HTMLReport => _htmlReport.Value;
|
||||
|
||||
private readonly ObservableAsPropertyHelper<bool> _installing;
|
||||
public bool Installing => _installing.Value;
|
||||
|
||||
@ -203,9 +200,6 @@ namespace Wabbajack
|
||||
this.WhenAny(x => x.ModList)
|
||||
.Select(_ => false))
|
||||
.ToGuiProperty(this, nameof(LoadingModlist));
|
||||
_htmlReport = this.WhenAny(x => x.ModList)
|
||||
.Select(modList => modList?.ReportHTML)
|
||||
.ToGuiProperty(this, nameof(HTMLReport));
|
||||
_installing = this.WhenAny(x => x.Installer.ActiveInstallation)
|
||||
.Select(i => i != null)
|
||||
.ToGuiProperty(this, nameof(Installing));
|
||||
@ -314,7 +308,10 @@ namespace Wabbajack
|
||||
.ToGuiProperty(this, nameof(ModListName));
|
||||
|
||||
// Define commands
|
||||
ShowManifestCommand = ReactiveCommand.Create(ShowReport);
|
||||
ShowManifestCommand = ReactiveCommand.Create(() =>
|
||||
{
|
||||
new ManifestWindow(ModList.SourceModList).Show();
|
||||
});
|
||||
OpenReadmeCommand = ReactiveCommand.Create(
|
||||
execute: () => this.ModList?.OpenReadmeWindow(),
|
||||
canExecute: this.WhenAny(x => x.ModList)
|
||||
@ -438,12 +435,5 @@ namespace Wabbajack
|
||||
.Switch()
|
||||
.ToGuiProperty(this, nameof(CurrentCpuCount));
|
||||
}
|
||||
|
||||
private void ShowReport()
|
||||
{
|
||||
var file = Path.GetTempFileName() + ".html";
|
||||
File.WriteAllText(file, HTMLReport);
|
||||
Utils.StartProcessFromFile(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
24
Wabbajack/View Models/ManifestVM.cs
Normal file
24
Wabbajack/View Models/ManifestVM.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using System.Collections.Generic;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Lib;
|
||||
|
||||
namespace Wabbajack
|
||||
{
|
||||
public class ManifestVM : ViewModel
|
||||
{
|
||||
public Manifest Manifest { get; set; }
|
||||
|
||||
public string Name => !string.IsNullOrWhiteSpace(Manifest.Name) ? Manifest.Name : "Wabbajack Modlist";
|
||||
public string Author => !string.IsNullOrWhiteSpace(Manifest.Author) ? $"Created by {Manifest.Author}" : "Created by Jyggalag";
|
||||
public string Description => !string.IsNullOrWhiteSpace(Manifest.Description) ? Manifest.Description : "";
|
||||
public string InstallSize => $"Install Size: {Manifest.InstallSize.ToFileSizeString()}";
|
||||
public string DownloadSize => $"Download Size: {Manifest.DownloadSize.ToFileSizeString()}";
|
||||
|
||||
public IEnumerable<Archive> Archives => Manifest.Archives;
|
||||
|
||||
public ManifestVM(Manifest manifest)
|
||||
{
|
||||
Manifest = manifest;
|
||||
}
|
||||
}
|
||||
}
|
@ -17,7 +17,6 @@ namespace Wabbajack
|
||||
public Exception Error { get; }
|
||||
public string ModListPath { get; }
|
||||
public string Name => SourceModList?.Name;
|
||||
public string ReportHTML => SourceModList?.ReportHTML;
|
||||
public string Readme => SourceModList?.Readme;
|
||||
public string Author => SourceModList?.Author;
|
||||
public string Description => SourceModList?.Description;
|
||||
|
60
Wabbajack/Views/ManifestView.xaml
Normal file
60
Wabbajack/Views/ManifestView.xaml
Normal file
@ -0,0 +1,60 @@
|
||||
<reactiveUi:ReactiveUserControl x:TypeArguments="local:ManifestVM" x:Class="Wabbajack.ManifestView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Wabbajack"
|
||||
xmlns:reactiveUi="http://reactiveui.net"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<ScrollViewer>
|
||||
<ScrollViewer.Resources>
|
||||
<Style x:Key="HeaderStyle" TargetType="{x:Type TextBlock}">
|
||||
<Setter Property="Foreground" Value="#03DAC6"/>
|
||||
</Style>
|
||||
<Style x:Key="HyperlinkStyle" TargetType="{x:Type Hyperlink}">
|
||||
<Setter Property="Foreground" Value="#BB76FC"/>
|
||||
</Style>
|
||||
<Style x:Key="ModTitleStyle" TargetType="{x:Type TextBlock}">
|
||||
<Setter Property="Foreground" Value="#C7FC86"/>
|
||||
</Style>
|
||||
</ScrollViewer.Resources>
|
||||
<StackPanel Margin="8">
|
||||
<TextBlock x:Name="Name" FontSize="32" HorizontalAlignment="Center" Style="{StaticResource HeaderStyle}"/>
|
||||
<TextBlock x:Name="Author" FontSize="14" Padding="0 3 0 3"/>
|
||||
<TextBlock x:Name="Description" FontSize="14" TextWrapping="Wrap"/>
|
||||
|
||||
<TextBlock FontSize="26" Padding="0 6 0 0" Text="Mods"/>
|
||||
<TextBlock x:Name="InstallSize" FontSize="20"/>
|
||||
<TextBlock x:Name="DownloadSize" FontSize="20" Padding="0 0 0 3"/>
|
||||
|
||||
<ItemsControl Padding="0 3 0 6" x:Name="ModsList">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<StackPanel/>
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid Margin="0 3 0 3">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Padding="6 0 0 0" Grid.Column="0" Grid.Row="0" FontSize="16" Text="{Binding Path=Name}" Style="{StaticResource ModTitleStyle}"/>
|
||||
<TextBlock Padding="3 0 0 0" Grid.Column="1" Grid.Row="0" FontSize="16">
|
||||
<Hyperlink NavigateUri="{Binding Path=Name}" Style="{StaticResource HyperlinkStyle}" RequestNavigate="Hyperlink_OnRequestNavigate">Link</Hyperlink>
|
||||
</TextBlock>
|
||||
<TextBlock Padding="6 0 0 0" Grid.Column="0" Grid.Row="1" FontSize="12" Text="{Binding Path=Hash}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</reactiveUi:ReactiveUserControl>
|
59
Wabbajack/Views/ManifestView.xaml.cs
Normal file
59
Wabbajack/Views/ManifestView.xaml.cs
Normal file
@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Reactive.Disposables;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Navigation;
|
||||
using ReactiveUI;
|
||||
using Wabbajack.Lib;
|
||||
|
||||
namespace Wabbajack
|
||||
{
|
||||
public partial class ManifestView
|
||||
{
|
||||
public ModList Modlist { get; set; }
|
||||
|
||||
public ManifestView(ModList modlist)
|
||||
{
|
||||
Modlist = modlist;
|
||||
|
||||
var manifest = new Manifest(modlist);
|
||||
if(ViewModel == null)
|
||||
ViewModel = new ManifestVM(manifest);
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
this.WhenActivated(disposable =>
|
||||
{
|
||||
this.OneWayBind(ViewModel, x => x.Name, x => x.Name.Text)
|
||||
.DisposeWith(disposable);
|
||||
this.OneWayBind(ViewModel, x => x.Author, x => x.Author.Text)
|
||||
.DisposeWith(disposable);
|
||||
this.OneWayBind(ViewModel, x => x.Description, x => x.Description.Text)
|
||||
.DisposeWith(disposable);
|
||||
this.OneWayBind(ViewModel, x => x.Archives, x => x.ModsList.ItemsSource)
|
||||
.DisposeWith(disposable);
|
||||
this.OneWayBind(ViewModel, x => x.InstallSize, x => x.InstallSize.Text)
|
||||
.DisposeWith(disposable);
|
||||
this.OneWayBind(ViewModel, x => x.DownloadSize, x => x.DownloadSize.Text)
|
||||
.DisposeWith(disposable);
|
||||
});
|
||||
}
|
||||
|
||||
private void Hyperlink_OnRequestNavigate(object sender, RequestNavigateEventArgs e)
|
||||
{
|
||||
if (!(sender is Hyperlink hyperlink)) return;
|
||||
if (!(hyperlink.DataContext is Archive archive)) return;
|
||||
|
||||
var url = archive.State.GetManifestURL(archive);
|
||||
if (string.IsNullOrWhiteSpace(url)) return;
|
||||
|
||||
if (url.StartsWith("https://github.com/"))
|
||||
url = url.Substring(0, url.IndexOf("release", StringComparison.Ordinal));
|
||||
|
||||
//url = url.Replace("&", "^&");
|
||||
Process.Start(new ProcessStartInfo("cmd", $"/c start {url}") {CreateNoWindow = true});
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
22
Wabbajack/Views/ManifestWindow.xaml
Normal file
22
Wabbajack/Views/ManifestWindow.xaml
Normal file
@ -0,0 +1,22 @@
|
||||
<mah:MetroWindow x:Class="Wabbajack.ManifestWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:Wabbajack"
|
||||
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
|
||||
mc:Ignorable="d"
|
||||
Title="Manifest"
|
||||
Width="1280"
|
||||
Height="960"
|
||||
MinWidth="850"
|
||||
MinHeight="650"
|
||||
ResizeMode="CanResize"
|
||||
TitleBarHeight="25"
|
||||
UseLayoutRounding="True"
|
||||
WindowTitleBrush="{StaticResource MahApps.Brushes.Accent}"
|
||||
Style="{StaticResource {x:Type Window}}"
|
||||
d:DataContext="{d:DesignInstance local:ManifestWindow }">
|
||||
<Grid x:Name="Grid">
|
||||
</Grid>
|
||||
</mah:MetroWindow>
|
22
Wabbajack/Views/ManifestWindow.xaml.cs
Normal file
22
Wabbajack/Views/ManifestWindow.xaml.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using Wabbajack.Lib;
|
||||
|
||||
namespace Wabbajack
|
||||
{
|
||||
public partial class ManifestWindow
|
||||
{
|
||||
public ModList Modlist { get; set; }
|
||||
|
||||
public ManifestWindow(ModList modlist)
|
||||
{
|
||||
Modlist = modlist;
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
var manifestView = new ManifestView(Modlist);
|
||||
|
||||
Grid.Children.Add(manifestView);
|
||||
|
||||
Title = $"{Modlist.Name} by {Modlist.Author}";
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user