From 43883d351a8f609e9c6b1ae1d71a4972b7a07a97 Mon Sep 17 00:00:00 2001 From: Justin Swanson Date: Mon, 10 Feb 2020 17:41:14 -0600 Subject: [PATCH 1/2] Percent hotfix for binding crash --- Wabbajack/Views/Settings/PerformanceSettingsView.xaml.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Wabbajack/Views/Settings/PerformanceSettingsView.xaml.cs b/Wabbajack/Views/Settings/PerformanceSettingsView.xaml.cs index 4e208c15..4356d024 100644 --- a/Wabbajack/Views/Settings/PerformanceSettingsView.xaml.cs +++ b/Wabbajack/Views/Settings/PerformanceSettingsView.xaml.cs @@ -64,7 +64,7 @@ namespace Wabbajack vmToViewConverter: x => x, viewToVmConverter: x => (byte)(x ?? 0)) .DisposeWith(disposable); - this.BindStrict(this.ViewModel, x => x.TargetUsage, x => x.TargetUsageSpinner.Value) + this.Bind(this.ViewModel, x => x.TargetUsage, x => x.TargetUsageSpinner.Value) .DisposeWith(disposable); this.Bind(this.ViewModel, x => x.TargetUsage, x => x.TargetUsageSlider.Value) .DisposeWith(disposable); From bdfe00c32df4407cea2902670e839ae9e3b0cf32 Mon Sep 17 00:00:00 2001 From: Justin Swanson Date: Mon, 10 Feb 2020 17:45:17 -0600 Subject: [PATCH 2/2] Percent implicit conversion operator changed to explicit --- Wabbajack.Common/StatusUpdate.cs | 2 +- Wabbajack.Common/Util/Percent.cs | 32 ++++++++++++++++++- Wabbajack.Lib/ABatchProcessor.cs | 2 +- .../Views/Compilers/CompilerView.xaml.cs | 1 - .../Views/Installers/InstallationView.xaml.cs | 1 - Wabbajack/Views/ModListTileView.xaml.cs | 3 +- 6 files changed, 35 insertions(+), 6 deletions(-) diff --git a/Wabbajack.Common/StatusUpdate.cs b/Wabbajack.Common/StatusUpdate.cs index 943b4008..b4c9b31b 100644 --- a/Wabbajack.Common/StatusUpdate.cs +++ b/Wabbajack.Common/StatusUpdate.cs @@ -44,7 +44,7 @@ namespace Wabbajack.Common { var per_step = 1.0f / _internalMaxStep; var macro = _internalCurrentStep * per_step; - return Percent.FactoryPutInRange(macro + (per_step * sub_status)); + return Percent.FactoryPutInRange(macro + (per_step * sub_status.Value)); } public void MakeUpdate(Percent progress) diff --git a/Wabbajack.Common/Util/Percent.cs b/Wabbajack.Common/Util/Percent.cs index 4326d3ef..e9adde5d 100644 --- a/Wabbajack.Common/Util/Percent.cs +++ b/Wabbajack.Common/Util/Percent.cs @@ -70,7 +70,37 @@ namespace Wabbajack.Common return new Percent(c1.Value / c2.Value); } - public static implicit operator double(Percent c1) + public static bool operator ==(Percent c1, Percent c2) + { + return c1.Value == c2.Value; + } + + public static bool operator !=(Percent c1, Percent c2) + { + return c1.Value != c2.Value; + } + + public static bool operator >(Percent c1, Percent c2) + { + return c1.Value > c2.Value; + } + + public static bool operator <(Percent c1, Percent c2) + { + return c1.Value < c2.Value; + } + + public static bool operator >=(Percent c1, Percent c2) + { + return c1.Value >= c2.Value; + } + + public static bool operator <=(Percent c1, Percent c2) + { + return c1.Value <= c2.Value; + } + + public static explicit operator double(Percent c1) { return c1.Value; } diff --git a/Wabbajack.Lib/ABatchProcessor.cs b/Wabbajack.Lib/ABatchProcessor.cs index 8e808af8..ab87e1d4 100644 --- a/Wabbajack.Lib/ABatchProcessor.cs +++ b/Wabbajack.Lib/ABatchProcessor.cs @@ -128,7 +128,7 @@ namespace Wabbajack.Lib ManualCoreLimit, MaxCores, TargetUsagePercent, - (manual, max, target) => CalculateThreadsToUse(recommendedCount, manual, max, target)); + (manual, max, target) => CalculateThreadsToUse(recommendedCount, manual, max, target.Value)); } /// diff --git a/Wabbajack/Views/Compilers/CompilerView.xaml.cs b/Wabbajack/Views/Compilers/CompilerView.xaml.cs index cddb0db0..57b5e6f9 100644 --- a/Wabbajack/Views/Compilers/CompilerView.xaml.cs +++ b/Wabbajack/Views/Compilers/CompilerView.xaml.cs @@ -122,7 +122,6 @@ namespace Wabbajack .BindToStrict(this, x => x.LogView.ProgressPercent) .DisposeWith(dispose); this.WhenAny(x => x.ViewModel.PercentCompleted) - .Select(f => (double)f) .BindToStrict(this, x => x.CpuView.ProgressPercent) .DisposeWith(dispose); this.WhenAny(x => x.ViewModel.MWVM.Settings) diff --git a/Wabbajack/Views/Installers/InstallationView.xaml.cs b/Wabbajack/Views/Installers/InstallationView.xaml.cs index 971180b6..240e08f5 100644 --- a/Wabbajack/Views/Installers/InstallationView.xaml.cs +++ b/Wabbajack/Views/Installers/InstallationView.xaml.cs @@ -134,7 +134,6 @@ namespace Wabbajack .BindToStrict(this, x => x.LogView.ProgressPercent) .DisposeWith(dispose); this.WhenAny(x => x.ViewModel.PercentCompleted) - .Select(f => (double)f) .BindToStrict(this, x => x.CpuView.ProgressPercent) .DisposeWith(dispose); this.WhenAny(x => x.ViewModel.MWVM.Settings) diff --git a/Wabbajack/Views/ModListTileView.xaml.cs b/Wabbajack/Views/ModListTileView.xaml.cs index 73d6b080..f738b6c6 100644 --- a/Wabbajack/Views/ModListTileView.xaml.cs +++ b/Wabbajack/Views/ModListTileView.xaml.cs @@ -15,6 +15,7 @@ using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using ReactiveUI; +using Wabbajack.Common; namespace Wabbajack { @@ -28,7 +29,7 @@ namespace Wabbajack InitializeComponent(); this.WhenActivated(dispose => { - this.MarkAsNeeded(this.ViewModel, x => x.ProgressPercent); + this.MarkAsNeeded(this.ViewModel, x => x.ProgressPercent); this.MarkAsNeeded(this.ViewModel, x => x.IsBroken); this.MarkAsNeeded(this.ViewModel, x => x.Exists); this.MarkAsNeeded(this.ViewModel, x => x.Metadata.Links.ImageUri);