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 - ????
* Added log information for when modlists start parsing during installation
* 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
* 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="DynamicIniData.cs" />
<Compile Include="FileExtractor.cs" />
<Compile Include="MarkdownBuilder.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SplittingStream.cs" />
<Compile Include="Utils.cs" />

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Reflection;
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;
public int QueueProgress
{
@ -179,6 +194,7 @@ namespace Wabbajack
_modList = modlist.FromJSONString<ModList>();
Mode = "Installing";
ModListName = _modList.Name;
HTMLReport = _modList.ReportHTML;
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()
{
if (Mode == "Installing")
@ -313,6 +350,10 @@ namespace Wabbajack
try
{
compiler.Compile();
if (compiler.ModList != null && compiler.ModList.ReportHTML != null)
{
HTMLReport = compiler.ModList.ReportHTML;
}
}
catch (Exception ex)
{

View File

@ -3,13 +3,16 @@ using Newtonsoft.Json;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using CommonMark;
using Wabbajack.Common;
using static Wabbajack.NexusAPI;
using VFS;
@ -252,12 +255,32 @@ namespace Wabbajack
Name = MO2Profile
};
GenerateReport();
PatchExecutable();
ResetMembers();
ShowReport();
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>
/// 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)
{
result = new NexusMod()
var nm = new NexusMod()
{
GameName = general.gameName,
FileID = general.fileID,
ModID = general.modID,
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
{
@ -552,7 +580,7 @@ namespace Wabbajack
Status($"Generating patch of {filename}");
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();
}
Info($"Generated a {result.SourceData.Length} byte patch for {filename}");

View File

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

View File

@ -17,6 +17,7 @@
<RowDefinition></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal" Margin="0, 16, 0, 16">
<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>
<ListBox local:AutoScrollBehavior.ScrollOnNewItem="True" Grid.Row ="5" ItemsSource="{Binding Log}">
</ListBox>
<Button Content="Begin" Grid.Row="6" Height="30" Command="{Binding Begin}"></Button>
<CheckBox Content="Ignore Missing Files" Grid.Row="7" Height="20" IsChecked="{Binding IgnoreMissingFiles}"></CheckBox>
<Button Content="View Modlist Contents" Grid.Row="6" Height="30" Visibility="{Binding ShowReportButton}" Command="{Binding ShowReportCommand}"></Button>
<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>
</Window>

View File

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

View File

@ -99,12 +99,11 @@ namespace Wabbajack
return true;
}
private static string ConvertGameName(string gameName)
public static string ConvertGameName(string gameName)
{
if (gameName == "SkyrimSE") return "skyrimspecialedition";
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)
{
Utils.Status($"Endorsing ${mod.GameName} - ${mod.ModID}");

View File

@ -96,6 +96,9 @@
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<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">
<HintPath>..\packages\Costura.Fody.4.0.0\lib\net40\Costura.dll</HintPath>
</Reference>
@ -141,6 +144,7 @@
</ApplicationDefinition>
<Compile Include="Data.cs" />
<Compile Include="LambdaCommand.cs" />
<Compile Include="ReportBuilder.cs" />
<Compile Include="Themes\LeftMarginMultiplierConverter.cs" />
<Compile Include="Themes\TreeViewItemExtensions.cs" />
<Page Include="MainWindow.xaml">

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CommonMark.NET" version="0.15.1" 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="GitInfo" version="2.0.20" targetFramework="net472" developmentDependency="true" />