fixes #19 - Add installation summary

This commit is contained in:
Timothy Baldridge 2019-08-30 17:57:56 -06:00
parent 161d811416
commit ab3c87975c
10 changed files with 123 additions and 8 deletions

View File

@ -3,6 +3,9 @@
#### Version 0.9 - ???? #### Version 0.9 - ????
* Added log information for when modlists start parsing during installation * Added log information for when modlists start parsing during installation
* Check all links during mod list creation * Check all links during mod list creation
* Generate a installation report during compilation
* Show the report after compiling
* Added a button to view the report before installing
#### Version 0.8.1 - 8/29/2019 #### Version 0.8.1 - 8/29/2019
* Fixed a bug that was causing VFS temp folders not to be cleaned * Fixed a bug that was causing VFS temp folders not to be cleaned

View File

@ -85,6 +85,7 @@
<Compile Include="Consts.cs" /> <Compile Include="Consts.cs" />
<Compile Include="DynamicIniData.cs" /> <Compile Include="DynamicIniData.cs" />
<Compile Include="FileExtractor.cs" /> <Compile Include="FileExtractor.cs" />
<Compile Include="MarkdownBuilder.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SplittingStream.cs" /> <Compile Include="SplittingStream.cs" />
<Compile Include="Utils.cs" /> <Compile Include="Utils.cs" />

View File

@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
using System.Threading; using System.Threading;
@ -106,6 +107,20 @@ namespace Wabbajack
} }
} }
private string _htmlReport;
public Visibility ShowReportButton => _htmlReport == null ? Visibility.Collapsed : Visibility.Visible;
public string HTMLReport
{
get { return _htmlReport; }
set
{
_htmlReport = value;
OnPropertyChanged("HTMLReport");
OnPropertyChanged("ShowReportButton");
}
}
private int _queueProgress; private int _queueProgress;
public int QueueProgress public int QueueProgress
{ {
@ -179,6 +194,7 @@ namespace Wabbajack
_modList = modlist.FromJSONString<ModList>(); _modList = modlist.FromJSONString<ModList>();
Mode = "Installing"; Mode = "Installing";
ModListName = _modList.Name; ModListName = _modList.Name;
HTMLReport = _modList.ReportHTML;
Location = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); Location = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
} }
@ -280,6 +296,27 @@ namespace Wabbajack
} }
} }
private ICommand _showReportCommand;
public ICommand ShowReportCommand
{
get
{
if (_showReportCommand == null)
{
_showReportCommand = new LambdaCommand(() => true, () => this.ShowReport());
}
return _showReportCommand;
}
}
private void ShowReport()
{
var file = Path.GetTempFileName() + ".html";
File.WriteAllText(file, HTMLReport);
Process.Start(file);
}
private void ExecuteBegin() private void ExecuteBegin()
{ {
if (Mode == "Installing") if (Mode == "Installing")
@ -313,6 +350,10 @@ namespace Wabbajack
try try
{ {
compiler.Compile(); compiler.Compile();
if (compiler.ModList != null && compiler.ModList.ReportHTML != null)
{
HTMLReport = compiler.ModList.ReportHTML;
}
} }
catch (Exception ex) catch (Exception ex)
{ {

View File

@ -3,13 +3,16 @@ using Newtonsoft.Json;
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Net;
using System.Reflection; using System.Reflection;
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Web; using System.Web;
using CommonMark;
using Wabbajack.Common; using Wabbajack.Common;
using static Wabbajack.NexusAPI; using static Wabbajack.NexusAPI;
using VFS; using VFS;
@ -252,12 +255,32 @@ namespace Wabbajack
Name = MO2Profile Name = MO2Profile
}; };
GenerateReport();
PatchExecutable(); PatchExecutable();
ResetMembers(); ResetMembers();
ShowReport();
Info("Done Building Modpack"); Info("Done Building Modpack");
} }
private void ShowReport()
{
var file = Path.GetTempFileName() + ".html";
File.WriteAllText(file, ModList.ReportHTML);
Process.Start(file);
}
private void GenerateReport()
{
using (var fs = File.OpenWrite($"{ModList.Name}.md"))
{
fs.SetLength(0);
using (var reporter = new ReportBuilder(fs))
reporter.Build(ModList);
}
ModList.ReportHTML = CommonMarkConverter.Convert(File.ReadAllText($"{ModList.Name}.md"));
}
/// <summary> /// <summary>
/// Clear references to lists that hold a lot of data. /// Clear references to lists that hold a lot of data.
@ -436,13 +459,18 @@ namespace Wabbajack
} }
else if (general.modID != null && general.fileID != null && general.gameName != null) else if (general.modID != null && general.fileID != null && general.gameName != null)
{ {
result = new NexusMod() var nm = new NexusMod()
{ {
GameName = general.gameName, GameName = general.gameName,
FileID = general.fileID, FileID = general.fileID,
ModID = general.modID, ModID = general.modID,
Version = general.version ?? "0.0.0.0" Version = general.version ?? "0.0.0.0"
}; };
var info = NexusAPI.GetModInfo(nm, NexusKey);
nm.Author = info.author;
nm.UploadedBy = info.uploaded_by;
nm.UploaderProfile = info.uploaded_users_profile_url;
result = nm;
} }
else else
{ {
@ -552,7 +580,7 @@ namespace Wabbajack
Status($"Generating patch of {filename}"); Status($"Generating patch of {filename}");
using (var ms = new MemoryStream()) { using (var ms = new MemoryStream()) {
BSDiff.Create(File.ReadAllBytes(game_file), File.ReadAllBytes(source.AbsolutePath), ms); //BSDiff.Create(File.ReadAllBytes(game_file), File.ReadAllBytes(source.AbsolutePath), ms);
result.SourceData = ms.ToArray().ToBase64(); result.SourceData = ms.ToArray().ToBase64();
} }
Info($"Generated a {result.SourceData.Length} byte patch for {filename}"); Info($"Generated a {result.SourceData.Length} byte patch for {filename}");

View File

@ -68,6 +68,11 @@ namespace Wabbajack
/// Archives required by this modlist /// Archives required by this modlist
/// </summary> /// </summary>
public List<Archive> Archives; public List<Archive> Archives;
/// <summary>
/// Content Report in HTML form
/// </summary>
public string ReportHTML;
} }
public class Directive public class Directive
@ -175,6 +180,9 @@ namespace Wabbajack
public string ModID; public string ModID;
public string FileID; public string FileID;
public string Version; public string Version;
public string UploaderProfile;
public string UploadedBy;
public string Author;
} }
public class GoogleDriveMod : Archive public class GoogleDriveMod : Archive

View File

@ -17,6 +17,7 @@
<RowDefinition></RowDefinition> <RowDefinition></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition> <RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition> <RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal" Margin="0, 16, 0, 16"> <StackPanel Grid.Row="0" Orientation="Horizontal" Margin="0, 16, 0, 16">
<TextBlock Text="{Binding Mode}" FontSize="16" FontWeight="Bold"></TextBlock> <TextBlock Text="{Binding Mode}" FontSize="16" FontWeight="Bold"></TextBlock>
@ -68,7 +69,8 @@
<TextBlock Text="Log:" Grid.Row="4" FontSize="14" Margin="0, 16, 0, 8"></TextBlock> <TextBlock Text="Log:" Grid.Row="4" FontSize="14" Margin="0, 16, 0, 8"></TextBlock>
<ListBox local:AutoScrollBehavior.ScrollOnNewItem="True" Grid.Row ="5" ItemsSource="{Binding Log}"> <ListBox local:AutoScrollBehavior.ScrollOnNewItem="True" Grid.Row ="5" ItemsSource="{Binding Log}">
</ListBox> </ListBox>
<Button Content="Begin" Grid.Row="6" Height="30" Command="{Binding Begin}"></Button> <Button Content="View Modlist Contents" Grid.Row="6" Height="30" Visibility="{Binding ShowReportButton}" Command="{Binding ShowReportCommand}"></Button>
<CheckBox Content="Ignore Missing Files" Grid.Row="7" Height="20" IsChecked="{Binding IgnoreMissingFiles}"></CheckBox> <Button Content="Begin" Grid.Row="7" Height="30" Command="{Binding Begin}"></Button>
<CheckBox Content="Ignore Missing Files" Grid.Row="8" Height="20" IsChecked="{Binding IgnoreMissingFiles}"></CheckBox>
</Grid> </Grid>
</Window> </Window>

View File

@ -79,10 +79,12 @@ namespace Wabbajack
var modlist = Installer.CheckForModPack(); var modlist = Installer.CheckForModPack();
if (modlist == null) if (modlist == null)
{ {
Utils.Log("No Modlist found, running in Compiler mode.");
} }
else else
{ {
context.ConfigureForInstall(modlist); context.ConfigureForInstall(modlist);
} }
}).Start(); }).Start();

View File

@ -99,12 +99,11 @@ namespace Wabbajack
return true; return true;
} }
private static string ConvertGameName(string gameName) public static string ConvertGameName(string gameName)
{ {
if (gameName == "SkyrimSE") return "skyrimspecialedition"; if (gameName == "SkyrimSE") return "skyrimspecialedition";
if (gameName == "FalloutNV") return "newvegas"; if (gameName == "FalloutNV") return "newvegas";
return gameName; return gameName.ToLower();
} }
@ -162,6 +161,32 @@ namespace Wabbajack
} }
} }
public class ModInfo
{
public string author;
public string uploaded_by;
public string uploaded_users_profile_url;
}
public static ModInfo GetModInfo(NexusMod archive, string apikey)
{
string path = Path.Combine(Consts.NexusCacheDirectory, $"mod-info-{archive.GameName}-{archive.ModID}.json");
if (File.Exists(path))
return path.FromJSON<ModInfo>();
var url = $"https://api.nexusmods.com/v1/games/{ConvertGameName(archive.GameName)}/mods/{archive.ModID}.json";
var client = BaseNexusClient(apikey);
using (var s = client.GetStreamSync(url))
{
var result = s.FromJSON<ModInfo>();
result.ToJSON(path);
return result;
}
}
public static EndorsementResponse EndorseMod(NexusMod mod, string apikey) public static EndorsementResponse EndorseMod(NexusMod mod, string apikey)
{ {
Utils.Status($"Endorsing ${mod.GameName} - ${mod.ModID}"); Utils.Status($"Endorsing ${mod.GameName} - ${mod.ModID}");

View File

@ -96,6 +96,9 @@
<Prefer32Bit>true</Prefer32Bit> <Prefer32Bit>true</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="CommonMark, Version=0.1.0.0, Culture=neutral, PublicKeyToken=001ef8810438905d, processorArchitecture=MSIL">
<HintPath>..\packages\CommonMark.NET.0.15.1\lib\net45\CommonMark.dll</HintPath>
</Reference>
<Reference Include="Costura, Version=4.0.0.0, Culture=neutral, PublicKeyToken=9919ef960d84173d, processorArchitecture=MSIL"> <Reference Include="Costura, Version=4.0.0.0, Culture=neutral, PublicKeyToken=9919ef960d84173d, processorArchitecture=MSIL">
<HintPath>..\packages\Costura.Fody.4.0.0\lib\net40\Costura.dll</HintPath> <HintPath>..\packages\Costura.Fody.4.0.0\lib\net40\Costura.dll</HintPath>
</Reference> </Reference>
@ -141,6 +144,7 @@
</ApplicationDefinition> </ApplicationDefinition>
<Compile Include="Data.cs" /> <Compile Include="Data.cs" />
<Compile Include="LambdaCommand.cs" /> <Compile Include="LambdaCommand.cs" />
<Compile Include="ReportBuilder.cs" />
<Compile Include="Themes\LeftMarginMultiplierConverter.cs" /> <Compile Include="Themes\LeftMarginMultiplierConverter.cs" />
<Compile Include="Themes\TreeViewItemExtensions.cs" /> <Compile Include="Themes\TreeViewItemExtensions.cs" />
<Page Include="MainWindow.xaml"> <Page Include="MainWindow.xaml">

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="CommonMark.NET" version="0.15.1" targetFramework="net472" />
<package id="Costura.Fody" version="4.0.0" targetFramework="net472" /> <package id="Costura.Fody" version="4.0.0" targetFramework="net472" />
<package id="Fody" version="5.1.1" targetFramework="net472" developmentDependency="true" /> <package id="Fody" version="5.1.1" targetFramework="net472" developmentDependency="true" />
<package id="GitInfo" version="2.0.20" targetFramework="net472" developmentDependency="true" /> <package id="GitInfo" version="2.0.20" targetFramework="net472" developmentDependency="true" />