Merge branch 'master' into settings-pane

This commit is contained in:
Justin Swanson 2020-01-11 00:42:51 -06:00
commit 75c48e5fe2
27 changed files with 838 additions and 1063 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 308 KiB

View File

@ -159,7 +159,7 @@
<Version>12.0.3</Version>
</PackageReference>
<PackageReference Include="ReactiveUI">
<Version>11.1.1</Version>
<Version>11.1.6</Version>
</PackageReference>
<PackageReference Include="System.Reactive">
<Version>4.3.2</Version>

View File

@ -143,6 +143,7 @@ namespace Wabbajack.Common
MO2ArchiveName = "oblivion",
GameLocationRegistryKey = @"HKEY_LOCAL_MACHINE\SOFTWARE\Bethesda Softworks\Oblivion",
SteamIDs = new List<int> {22330},
GOGIDs = new List<int>{1458058109},
RequiredFiles = new List<string>
{
"oblivion.exe"
@ -179,6 +180,7 @@ namespace Wabbajack.Common
MO2ArchiveName = "falloutnv",
GameLocationRegistryKey = @"HKEY_LOCAL_MACHINE\SOFTWARE\Bethesda Softworks\falloutnv",
SteamIDs = new List<int> {22380, 22490}, // normal and RU version
GOGIDs = new List<int>{1454587428},
RequiredFiles = new List<string>
{
"FalloutNV.exe"

View File

@ -104,11 +104,7 @@ namespace Wabbajack.Common.StoreHandlers
Path = path
};
var gameMeta = GameRegistry.Games.Values.FirstOrDefault(g =>
{
return (g.GOGIDs?.Contains(gameID) ?? false)
&& (g.RequiredFiles?.TrueForAll(file => File.Exists(Path.Combine(game.Path, file))) ?? true);
});
var gameMeta = GameRegistry.Games.Values.FirstOrDefault(g => (g.GOGIDs?.Contains(gameID) ?? false));
if (gameMeta == null)
{

View File

@ -24,7 +24,7 @@
<PackageReference Include="ini-parser-netstandard" Version="2.5.2" />
<PackageReference Include="Microsoft.Win32.Registry" Version="4.7.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="ReactiveUI" Version="11.1.1" />
<PackageReference Include="ReactiveUI" Version="11.1.6" />
<PackageReference Include="SharpZipLib" Version="1.2.0" />
<PackageReference Include="System.Data.HashFunction.xxHash" Version="2.0.0" />
<PackageReference Include="System.Security.Cryptography.ProtectedData" Version="4.7.0" />

View File

@ -43,10 +43,10 @@ namespace Wabbajack.Lib.Downloaders
TriggerLogin = ReactiveCommand.CreateFromTask(
execute: () => Utils.CatchAndLog(async () => await Utils.Log(new RequestSiteLogin(this)).Task),
canExecute: IsLoggedIn.Select(b => !b).ObserveOn(RxApp.MainThreadScheduler));
canExecute: IsLoggedIn.Select(b => !b).ObserveOnGuiThread());
ClearLogin = ReactiveCommand.Create(
execute: () => Utils.CatchAndLog(() => Utils.DeleteEncryptedJson(_encryptedKeyName)),
canExecute: IsLoggedIn.ObserveOn(RxApp.MainThreadScheduler));
canExecute: IsLoggedIn.ObserveOnGuiThread());
}
public ReactiveCommand<Unit, Unit> TriggerLogin { get; }

View File

@ -43,10 +43,10 @@ namespace Wabbajack.Lib.Downloaders
TriggerLogin = ReactiveCommand.CreateFromTask(
execute: () => Utils.CatchAndLog(NexusApiClient.RequestAndCacheAPIKey),
canExecute: IsLoggedIn.Select(b => !b).ObserveOn(RxApp.MainThreadScheduler));
canExecute: IsLoggedIn.Select(b => !b).ObserveOnGuiThread());
ClearLogin = ReactiveCommand.Create(
execute: () => Utils.CatchAndLog(() => Utils.DeleteEncryptedJson("nexusapikey")),
canExecute: IsLoggedIn.ObserveOn(RxApp.MainThreadScheduler));
canExecute: IsLoggedIn.ObserveOnGuiThread());
}
public async Task<AbstractDownloadState> GetDownloaderState(dynamic archiveINI)

View File

@ -484,6 +484,7 @@ namespace Wabbajack.Lib
new IgnoreGameFiles(this),
new DirectMatch(this),
new IncludeTaggedMods(this, Consts.WABBAJACK_INCLUDE),
new IgnoreGameFiles(this),

View File

@ -186,7 +186,7 @@
<Version>12.0.3</Version>
</PackageReference>
<PackageReference Include="ReactiveUI">
<Version>11.1.1</Version>
<Version>11.1.6</Version>
</PackageReference>
<PackageReference Include="System.Reactive">
<Version>4.3.2</Version>

View File

@ -1,35 +0,0 @@
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Wabbajack.VirtualFileSystem")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Wabbajack.VirtualFileSystem")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("5d6a2eaf-6604-4c51-8ae2-a746b4bc5e3e")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -1,99 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{5D6A2EAF-6604-4C51-8AE2-A746B4BC5E3E}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Wabbajack.VirtualFileSystem</RootNamespace>
<AssemblyName>Wabbajack.VirtualFileSystem</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<NoWarn>CS1998</NoWarn>
<WarningsAsErrors>CS4014</WarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<NoWarn>CS1998</NoWarn>
<WarningsAsErrors>CS4014</WarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Numerics" />
<Reference Include="System.Transactions" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Context.cs" />
<Compile Include="Extensions.cs" />
<Compile Include="PortableFile.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="VirtualFile.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="$(SolutionDir)\Wabbajack.Common.CSP\Wabbajack.Common.CSP.csproj">
<Project>{9e69bc98-1512-4977-b683-6e7e5292c0b8}</Project>
<Name>Wabbajack.Common.CSP</Name>
</ProjectReference>
<ProjectReference Include="$(SolutionDir)\Wabbajack.Common\Wabbajack.Common.csproj">
<Project>{b3f3fb6e-b9eb-4f49-9875-d78578bc7ae5}</Project>
<Name>Wabbajack.Common</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="AlphaFS">
<Version>2.2.6</Version>
</PackageReference>
<PackageReference Include="K4os.Hash.Crc">
<Version>1.1.4</Version>
</PackageReference>
<PackageReference Include="System.Collections.Immutable">
<Version>1.7.0</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Wabbajack.Common\Wabbajack.Common.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Genbox.AlphaFS" Version="2.2.2.1" />
<PackageReference Include="K4os.Hash.Crc" Version="1.1.4" />
<PackageReference Include="System.Collections.Immutable" Version="1.7.0" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,56 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive.Linq;
using System.Text;
using System.Threading.Tasks;
using DynamicData;
namespace Wabbajack
{
public static class DynamicDataExt
{
public static IObservable<IChangeSet<TCache, TKey>> TransformAndCache<TObject, TKey, TCache>(
this IObservable<IChangeSet<TObject, TKey>> obs,
Func<TKey, TObject, TCache> onAdded,
Action<Change<TObject, TKey>, TCache> onUpdated)
{
var cache = new ChangeAwareCache<TCache, TKey>();
return obs
.Select(changeSet =>
{
foreach (var change in changeSet)
{
switch (change.Reason)
{
case ChangeReason.Add:
case ChangeReason.Update:
case ChangeReason.Refresh:
var lookup = cache.Lookup(change.Key);
TCache val;
if (lookup.HasValue)
{
val = lookup.Value;
}
else
{
val = onAdded(change.Key, change.Current);
cache.Add(val, change.Key);
}
onUpdated(change, val);
break;
case ChangeReason.Remove:
cache.Remove(change.Key);
break;
case ChangeReason.Moved:
break;
default:
throw new NotImplementedException();
}
}
return cache.CaptureChanges();
})
.Where(cs => cs.Count > 0);
}
}
}

View File

@ -1,6 +1,10 @@
using Microsoft.WindowsAPICodePack.Dialogs;
using DynamicData;
using DynamicData.Binding;
using Microsoft.WindowsAPICodePack.Dialogs;
using ReactiveUI;
using System;
using System.IO;
using System.Reactive.Linq;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
@ -53,5 +57,23 @@ namespace Wabbajack.UI
return ofd.FileName;
return null;
}
public static IDisposable BindCpuStatus(IObservable<CPUStatus> status, ObservableCollectionExtended<CPUDisplayVM> list)
{
return status.ObserveOn(RxApp.TaskpoolScheduler)
.ToObservableChangeSet(x => x.ID)
.Batch(TimeSpan.FromMilliseconds(50), RxApp.TaskpoolScheduler)
.EnsureUniqueChanges()
.TransformAndCache(
onAdded: (key, cpu) => new CPUDisplayVM(cpu),
onUpdated: (change, vm) => vm.AbsorbStatus(change.Current))
.AutoRefresh(x => x.IsWorking)
.AutoRefresh(x => x.StartTime)
.Filter(i => i.IsWorking && i.ID != WorkQueue.UnassignedCpuId)
.Sort(SortExpressionComparer<CPUDisplayVM>.Ascending(s => s.StartTime))
.ObserveOnGuiThread()
.Bind(list)
.Subscribe();
}
}
}

View File

@ -3,23 +3,46 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ReactiveUI.Fody.Helpers;
using Wabbajack.Common;
using Wabbajack.Lib;
namespace Wabbajack
{
public class CPUDisplayVM
public class CPUDisplayVM : ViewModel
{
public CPUStatus Status { get; set; }
[Reactive]
public int ID { get; set; }
[Reactive]
public DateTime StartTime { get; set; }
[Reactive]
public bool IsWorking { get; set; }
[Reactive]
public string Msg { get; set; }
[Reactive]
public float ProgressPercent { get; set; }
public CPUDisplayVM()
{
}
public CPUDisplayVM(CPUStatus cpu)
{
AbsorbStatus(cpu);
}
public void AbsorbStatus(CPUStatus cpu)
{
bool starting = cpu.IsWorking && ((!Status?.IsWorking) ?? true);
Status = cpu;
bool starting = cpu.IsWorking && !IsWorking;
if (starting)
{
StartTime = DateTime.Now;
}
ID = cpu.ID;
Msg = cpu.Msg;
ProgressPercent = cpu.ProgressPercent;
IsWorking = cpu.IsWorking;
}
}
}

View File

@ -123,7 +123,7 @@ namespace Wabbajack
// Throttle so that it only loads image after any sets of swaps have completed
.Throttle(TimeSpan.FromMilliseconds(50), RxApp.TaskpoolScheduler)
.DistinctUntilChanged()
.ObserveOn(RxApp.MainThreadScheduler)
.ObserveOnGuiThread()
.Select(path =>
{
if (string.IsNullOrWhiteSpace(path)) return UIUtils.BitmapImageFromResource("Resources/Wabba_Mouth_No_Text.png");
@ -154,28 +154,10 @@ namespace Wabbajack
resultSelector: (i, b) => i && b)
.ObserveOnGuiThread());
// Compile progress updates and populate ObservableCollection
Dictionary<int, CPUDisplayVM> cpuDisplays = new Dictionary<int, CPUDisplayVM>();
this.WhenAny(x => x.Compiler.ActiveCompilation)
.SelectMany(c => c?.QueueStatus ?? Observable.Empty<CPUStatus>())
.ObserveOn(RxApp.TaskpoolScheduler)
// Attach start times to incoming CPU items
.Scan(
new CPUDisplayVM(),
(_, cpu) =>
{
var ret = cpuDisplays.TryCreate(cpu.ID);
ret.AbsorbStatus(cpu);
return ret;
})
.ToObservableChangeSet(x => x.Status.ID)
.Batch(TimeSpan.FromMilliseconds(50), RxApp.TaskpoolScheduler)
.EnsureUniqueChanges()
.Filter(i => i.Status.IsWorking && i.Status.ID != WorkQueue.UnassignedCpuId)
.ObserveOn(RxApp.MainThreadScheduler)
.Sort(SortExpressionComparer<CPUDisplayVM>.Ascending(s => s.StartTime))
.Bind(StatusList)
.Subscribe()
UIUtils.BindCpuStatus(
this.WhenAny(x => x.Compiler.ActiveCompilation)
.SelectMany(c => c?.QueueStatus ?? Observable.Empty<CPUStatus>()),
StatusList)
.DisposeWith(CompositeDisposable);
_percentCompleted = this.WhenAny(x => x.Compiler.ActiveCompilation)

View File

@ -299,28 +299,10 @@ namespace Wabbajack
})
.ToProperty(this, nameof(ProgressTitle));
Dictionary<int, CPUDisplayVM> cpuDisplays = new Dictionary<int, CPUDisplayVM>();
// Compile progress updates and populate ObservableCollection
this.WhenAny(x => x.Installer.ActiveInstallation)
.SelectMany(c => c?.QueueStatus ?? Observable.Empty<CPUStatus>())
.ObserveOn(RxApp.TaskpoolScheduler)
// Attach start times to incoming CPU items
.Scan(
new CPUDisplayVM(),
(_, cpu) =>
{
var ret = cpuDisplays.TryCreate(cpu.ID);
ret.AbsorbStatus(cpu);
return ret;
})
.ToObservableChangeSet(x => x.Status.ID)
.Batch(TimeSpan.FromMilliseconds(50), RxApp.TaskpoolScheduler)
.EnsureUniqueChanges()
.Filter(i => i.Status.IsWorking && i.Status.ID != WorkQueue.UnassignedCpuId)
.ObserveOn(RxApp.MainThreadScheduler)
.Sort(SortExpressionComparer<CPUDisplayVM>.Ascending(s => s.StartTime))
.Bind(StatusList)
.Subscribe()
UIUtils.BindCpuStatus(
this.WhenAny(x => x.Installer.ActiveInstallation)
.SelectMany(c => c?.QueueStatus ?? Observable.Empty<CPUStatus>()),
StatusList)
.DisposeWith(CompositeDisposable);
BeginCommand = ReactiveCommand.CreateFromTask(

View File

@ -64,8 +64,8 @@ namespace Wabbajack
.ToObservableChangeSet()
.Buffer(TimeSpan.FromMilliseconds(250), RxApp.TaskpoolScheduler)
.Where(l => l.Count > 0)
.ObserveOn(RxApp.MainThreadScheduler)
.FlattenBufferResult()
.ObserveOnGuiThread()
.Bind(Log)
.Subscribe()
.DisposeWith(CompositeDisposable);

View File

@ -67,7 +67,7 @@ namespace Wabbajack
return default(MemoryStream);
}
})
.ObserveOn(RxApp.MainThreadScheduler)
.ObserveOnGuiThread()
.Select(memStream =>
{
if (memStream == null) return default(BitmapImage);

View File

@ -64,7 +64,7 @@ namespace Wabbajack
return default;
}
})
.ObserveOn(RxApp.MainThreadScheduler)
.ObserveOnGuiThread()
.Select(memStream =>
{
if (memStream == null) return default;

View File

@ -1,6 +1,6 @@
using Alphaleonis.Win32.Filesystem;
using ReactiveUI;
using ReactiveUI;
using ReactiveUI.Fody.Helpers;
using System.IO;
using System.Linq;
using System.Reactive.Linq;
using System.Windows.Input;

View File

@ -108,7 +108,7 @@ namespace Wabbajack
return query.Items.ElementAtOrDefault(index);
})
.StartWith(default(ModVM))
.ObserveOn(RxApp.MainThreadScheduler)
.ObserveOnGuiThread()
.ToProperty(this, nameof(TargetMod));
// Mark interest and materialize image of target mod

View File

@ -1,4 +1,4 @@
<UserControl
<UserControl
x:Class="Wabbajack.CpuView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
@ -25,22 +25,22 @@
BorderThickness="0"
Foreground="{StaticResource DarkPrimaryVariantBrush}"
Maximum="1"
Opacity="{Binding Status.ProgressPercent, Mode=OneWay}"
Value="{Binding Status.ProgressPercent, Mode=OneWay}" />
Opacity="{Binding ProgressPercent, Mode=OneWay}"
Value="{Binding ProgressPercent, Mode=OneWay}" />
<Grid Height="1" VerticalAlignment="Bottom">
<mahapps:MetroProgressBar
Background="Transparent"
BorderThickness="0"
Foreground="{StaticResource DarkSecondaryBrush}"
Maximum="1"
Value="{Binding Status.ProgressPercent, Mode=OneWay}" />
Value="{Binding ProgressPercent, Mode=OneWay}" />
</Grid>
<TextBlock
Margin="0,0,0,2"
Text="{Binding Status.Msg}"
Text="{Binding Msg, Mode=OneWay}"
TextTrimming="CharacterEllipsis"
TextWrapping="NoWrap"
ToolTip="{Binding Status.Msg}" />
ToolTip="{Binding Msg, Mode=OneWay}" />
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>

View File

@ -172,6 +172,7 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="Extensions\DynamicDataExt.cs" />
<Compile Include="UI\FilePickerVM.cs" />
<Compile Include="UI\UIUtils.cs" />
<Compile Include="Util\SystemParametersConstructor.cs" />
@ -537,7 +538,7 @@
<Version>1.6.5</Version>
</PackageReference>
<PackageReference Include="MahApps.Metro.IconPacks">
<Version>3.0.1</Version>
<Version>3.1.0</Version>
</PackageReference>
<PackageReference Include="MegaApiClient">
<Version>1.7.1</Version>
@ -555,13 +556,13 @@
<Version>2.4.4</Version>
</PackageReference>
<PackageReference Include="ReactiveUI.Events.WPF">
<Version>11.1.1</Version>
<Version>11.1.6</Version>
</PackageReference>
<PackageReference Include="ReactiveUI.Fody">
<Version>11.1.6</Version>
</PackageReference>
<PackageReference Include="ReactiveUI.WPF">
<Version>11.1.1</Version>
<Version>11.1.6</Version>
</PackageReference>
<PackageReference Include="SharpCompress">
<Version>0.24.0</Version>
@ -605,8 +606,6 @@
<ItemGroup>
<SplashScreen Include="Resources\Wabba_Mouth_Small.png" />
</ItemGroup>
<ItemGroup>
<Folder Include="UserInterventions\" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>