diff --git a/Wabbajack.Lib/ACompiler.cs b/Wabbajack.Lib/ACompiler.cs index c69cce78..b893adf6 100644 --- a/Wabbajack.Lib/ACompiler.cs +++ b/Wabbajack.Lib/ACompiler.cs @@ -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 = "" - + CommonMarkConverter.Convert(File.ReadAllText($"{ModList.Name}.md")); + var manifest = new Manifest(ModList); + manifest.ToJSON(ModListOutputFile + ".manifest.json"); } public async Task GatherArchives() diff --git a/Wabbajack.Lib/Data.cs b/Wabbajack.Lib/Data.cs index 495fff61..a7f6bdda 100644 --- a/Wabbajack.Lib/Data.cs +++ b/Wabbajack.Lib/Data.cs @@ -95,11 +95,6 @@ namespace Wabbajack.Lib /// public string Readme; - /// - /// Content Report in HTML form - /// - public string ReportHTML; - /// /// The size of all the archives once they're downloaded /// diff --git a/Wabbajack.Lib/Downloaders/AbstractDownloadState.cs b/Wabbajack.Lib/Downloaders/AbstractDownloadState.cs index 3e9d9187..8b2d0003 100644 --- a/Wabbajack.Lib/Downloaders/AbstractDownloadState.cs +++ b/Wabbajack.Lib/Downloaders/AbstractDownloadState.cs @@ -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(); } } diff --git a/Wabbajack.Lib/Downloaders/AbstractIPS4Downloader.cs b/Wabbajack.Lib/Downloaders/AbstractIPS4Downloader.cs index 7993dd66..60ff4239 100644 --- a/Wabbajack.Lib/Downloaders/AbstractIPS4Downloader.cs +++ b/Wabbajack.Lib/Downloaders/AbstractIPS4Downloader.cs @@ -154,9 +154,9 @@ namespace Wabbajack.Lib.Downloaders return DownloadDispatcher.GetInstance(); } - 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() diff --git a/Wabbajack.Lib/Downloaders/BethesdaNetDownloader.cs b/Wabbajack.Lib/Downloaders/BethesdaNetDownloader.cs index 4bf7a75d..b1425e8f 100644 --- a/Wabbajack.Lib/Downloaders/BethesdaNetDownloader.cs +++ b/Wabbajack.Lib/Downloaders/BethesdaNetDownloader.cs @@ -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(); } diff --git a/Wabbajack.Lib/Downloaders/GameFileSourceDownloader.cs b/Wabbajack.Lib/Downloaders/GameFileSourceDownloader.cs index d9056275..00da800e 100644 --- a/Wabbajack.Lib/Downloaders/GameFileSourceDownloader.cs +++ b/Wabbajack.Lib/Downloaders/GameFileSourceDownloader.cs @@ -83,9 +83,9 @@ namespace Wabbajack.Lib.Downloaders return DownloadDispatcher.GetInstance(); } - public override string GetReportEntry(Archive a) + public override string GetManifestURL(Archive a) { - return $"* Game File {Game} - {GameFile}"; + return null; } public override string[] GetMetaIni() diff --git a/Wabbajack.Lib/Downloaders/GoogleDriveDownloader.cs b/Wabbajack.Lib/Downloaders/GoogleDriveDownloader.cs index 4b4dc382..06afd874 100644 --- a/Wabbajack.Lib/Downloaders/GoogleDriveDownloader.cs +++ b/Wabbajack.Lib/Downloaders/GoogleDriveDownloader.cs @@ -75,9 +75,9 @@ namespace Wabbajack.Lib.Downloaders return DownloadDispatcher.GetInstance(); } - 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() diff --git a/Wabbajack.Lib/Downloaders/HTTPDownloader.cs b/Wabbajack.Lib/Downloaders/HTTPDownloader.cs index 5a479137..f0538e99 100644 --- a/Wabbajack.Lib/Downloaders/HTTPDownloader.cs +++ b/Wabbajack.Lib/Downloaders/HTTPDownloader.cs @@ -200,9 +200,9 @@ TOP: return DownloadDispatcher.GetInstance(); } - public override string GetReportEntry(Archive a) + public override string GetManifestURL(Archive a) { - return $"* [{a.Name} - {Url}]({Url})"; + return Url; } public override string[] GetMetaIni() diff --git a/Wabbajack.Lib/Downloaders/ManualDownloader.cs b/Wabbajack.Lib/Downloaders/ManualDownloader.cs index a2e80bc3..de298fba 100644 --- a/Wabbajack.Lib/Downloaders/ManualDownloader.cs +++ b/Wabbajack.Lib/Downloaders/ManualDownloader.cs @@ -122,9 +122,9 @@ namespace Wabbajack.Lib.Downloaders return DownloadDispatcher.GetInstance(); } - 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() diff --git a/Wabbajack.Lib/Downloaders/MediaFireDownloader.cs b/Wabbajack.Lib/Downloaders/MediaFireDownloader.cs index 9ae7afe4..65b341d8 100644 --- a/Wabbajack.Lib/Downloaders/MediaFireDownloader.cs +++ b/Wabbajack.Lib/Downloaders/MediaFireDownloader.cs @@ -64,9 +64,9 @@ namespace Wabbajack.Lib.Downloaders return DownloadDispatcher.GetInstance(); } - public override string GetReportEntry(Archive a) + public override string GetManifestURL(Archive a) { - return $"* [{a.Name} - {Url}]({Url})"; + return Url; } public override string[] GetMetaIni() diff --git a/Wabbajack.Lib/Downloaders/ModDBDownloader.cs b/Wabbajack.Lib/Downloaders/ModDBDownloader.cs index b0240652..65fdf4f3 100644 --- a/Wabbajack.Lib/Downloaders/ModDBDownloader.cs +++ b/Wabbajack.Lib/Downloaders/ModDBDownloader.cs @@ -105,9 +105,9 @@ namespace Wabbajack.Lib.Downloaders return DownloadDispatcher.GetInstance(); } - public override string GetReportEntry(Archive a) + public override string GetManifestURL(Archive a) { - return $"* ModDB - [{a.Name}]({Url})"; + return Url; } public override string[] GetMetaIni() diff --git a/Wabbajack.Lib/Downloaders/NexusDownloader.cs b/Wabbajack.Lib/Downloaders/NexusDownloader.cs index 9870811f..a8f62d55 100644 --- a/Wabbajack.Lib/Downloaders/NexusDownloader.cs +++ b/Wabbajack.Lib/Downloaders/NexusDownloader.cs @@ -193,15 +193,9 @@ namespace Wabbajack.Lib.Downloaders return DownloadDispatcher.GetInstance(); } - 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() diff --git a/Wabbajack.Lib/Downloaders/SteamWorkshopDownloader.cs b/Wabbajack.Lib/Downloaders/SteamWorkshopDownloader.cs index 61723181..b4d188d5 100644 --- a/Wabbajack.Lib/Downloaders/SteamWorkshopDownloader.cs +++ b/Wabbajack.Lib/Downloaders/SteamWorkshopDownloader.cs @@ -92,9 +92,9 @@ namespace Wabbajack.Lib.Downloaders return DownloadDispatcher.GetInstance(); } - 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() diff --git a/Wabbajack.Lib/MO2Compiler.cs b/Wabbajack.Lib/MO2Compiler.cs index 72029913..0f5fa831 100644 --- a/Wabbajack.Lib/MO2Compiler.cs +++ b/Wabbajack.Lib/MO2Compiler.cs @@ -290,7 +290,7 @@ namespace Wabbajack.Lib await ValidateModlist.RunValidation(Queue, ModList); UpdateTracker.NextStep("Generating Report"); - GenerateReport(); + GenerateManifest(); UpdateTracker.NextStep("Exporting Modlist"); ExportModList(); diff --git a/Wabbajack.Lib/Manifest.cs b/Wabbajack.Lib/Manifest.cs new file mode 100644 index 00000000..df85609b --- /dev/null +++ b/Wabbajack.Lib/Manifest.cs @@ -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 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(); + } + } +} diff --git a/Wabbajack.Lib/ReportBuilder.cs b/Wabbajack.Lib/ReportBuilder.cs deleted file mode 100644 index 8c64570d..00000000 --- a/Wabbajack.Lib/ReportBuilder.cs +++ /dev/null @@ -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().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().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() - .Select(f => (f.To, "inlined", SizeForID(f.SourceDataID))) - .Concat(lst.Directives - .OfType() - .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 SortArchives(List lstArchives) - { - return lstArchives.OrderByDescending(a => a.Size); - } - } -} diff --git a/Wabbajack.Lib/VortexCompiler.cs b/Wabbajack.Lib/VortexCompiler.cs index cd3cb7ab..af5b29f8 100644 --- a/Wabbajack.Lib/VortexCompiler.cs +++ b/Wabbajack.Lib/VortexCompiler.cs @@ -248,7 +248,7 @@ namespace Wabbajack.Lib await ValidateModlist.RunValidation(Queue, ModList); UpdateTracker.NextStep("Generating Report"); - GenerateReport(); + GenerateManifest(); UpdateTracker.NextStep("Exporting ModList"); ExportModList(); diff --git a/Wabbajack.Lib/Wabbajack.Lib.csproj b/Wabbajack.Lib/Wabbajack.Lib.csproj index 23042f95..06e5a53a 100644 --- a/Wabbajack.Lib/Wabbajack.Lib.csproj +++ b/Wabbajack.Lib/Wabbajack.Lib.csproj @@ -15,9 +15,6 @@ 4.1.7 - - 0.15.1 - 6.1.0 @@ -80,8 +77,6 @@ - - Always diff --git a/Wabbajack.Lib/css-min.css b/Wabbajack.Lib/css-min.css deleted file mode 100644 index e33c9bfc..00000000 --- a/Wabbajack.Lib/css-min.css +++ /dev/null @@ -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} \ No newline at end of file diff --git a/Wabbajack.Lib/css.css b/Wabbajack.Lib/css.css deleted file mode 100644 index 8aaed153..00000000 --- a/Wabbajack.Lib/css.css +++ /dev/null @@ -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; -} \ No newline at end of file diff --git a/Wabbajack/View Models/Compilers/CompilerVM.cs b/Wabbajack/View Models/Compilers/CompilerVM.cs index fd044cdc..3e91b6a3 100644 --- a/Wabbajack/View Models/Compilers/CompilerVM.cs +++ b/Wabbajack/View Models/Compilers/CompilerVM.cs @@ -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); - } } } diff --git a/Wabbajack/View Models/Installers/InstallerVM.cs b/Wabbajack/View Models/Installers/InstallerVM.cs index 83c32d88..d697421b 100644 --- a/Wabbajack/View Models/Installers/InstallerVM.cs +++ b/Wabbajack/View Models/Installers/InstallerVM.cs @@ -41,9 +41,6 @@ namespace Wabbajack private readonly ObservableAsPropertyHelper _installer; public ISubInstallerVM Installer => _installer.Value; - private readonly ObservableAsPropertyHelper _htmlReport; - public string HTMLReport => _htmlReport.Value; - private readonly ObservableAsPropertyHelper _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); - } } } diff --git a/Wabbajack/View Models/ManifestVM.cs b/Wabbajack/View Models/ManifestVM.cs new file mode 100644 index 00000000..80935f71 --- /dev/null +++ b/Wabbajack/View Models/ManifestVM.cs @@ -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 Archives => Manifest.Archives; + + public ManifestVM(Manifest manifest) + { + Manifest = manifest; + } + } +} diff --git a/Wabbajack/View Models/ModListVM.cs b/Wabbajack/View Models/ModListVM.cs index 7c3f92a6..783b42c0 100644 --- a/Wabbajack/View Models/ModListVM.cs +++ b/Wabbajack/View Models/ModListVM.cs @@ -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; diff --git a/Wabbajack/Views/ManifestView.xaml b/Wabbajack/Views/ManifestView.xaml new file mode 100644 index 00000000..e2c9860d --- /dev/null +++ b/Wabbajack/Views/ManifestView.xaml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Link + + + + + + + + + diff --git a/Wabbajack/Views/ManifestView.xaml.cs b/Wabbajack/Views/ManifestView.xaml.cs new file mode 100644 index 00000000..22ac66ac --- /dev/null +++ b/Wabbajack/Views/ManifestView.xaml.cs @@ -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; + } + } +} diff --git a/Wabbajack/Views/ManifestWindow.xaml b/Wabbajack/Views/ManifestWindow.xaml new file mode 100644 index 00000000..1e2f42e7 --- /dev/null +++ b/Wabbajack/Views/ManifestWindow.xaml @@ -0,0 +1,22 @@ + + + + diff --git a/Wabbajack/Views/ManifestWindow.xaml.cs b/Wabbajack/Views/ManifestWindow.xaml.cs new file mode 100644 index 00000000..532754c6 --- /dev/null +++ b/Wabbajack/Views/ManifestWindow.xaml.cs @@ -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}"; + } + } +}