Percent implicit conversion operator changed to explicit

This commit is contained in:
Justin Swanson 2020-02-10 17:45:17 -06:00
parent 43883d351a
commit bdfe00c32d
6 changed files with 35 additions and 6 deletions

View File

@ -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)

View File

@ -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;
}

View File

@ -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));
}
/// <summary>

View File

@ -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)

View File

@ -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)

View File

@ -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<ModListTileView, ModListMetadataVM, double>(this.ViewModel, x => x.ProgressPercent);
this.MarkAsNeeded<ModListTileView, ModListMetadataVM, Percent>(this.ViewModel, x => x.ProgressPercent);
this.MarkAsNeeded<ModListTileView, ModListMetadataVM, bool>(this.ViewModel, x => x.IsBroken);
this.MarkAsNeeded<ModListTileView, ModListMetadataVM, bool>(this.ViewModel, x => x.Exists);
this.MarkAsNeeded<ModListTileView, ModListMetadataVM, string>(this.ViewModel, x => x.Metadata.Links.ImageUri);