mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
ConfirmUpdateOfExistingInstallView /w remember setting
This commit is contained in:
parent
7f695a4a9e
commit
f139ed2335
32
Wabbajack/Converters/IsTypeVisibilityConverter.cs
Normal file
32
Wabbajack/Converters/IsTypeVisibilityConverter.cs
Normal file
@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Wabbajack
|
||||
{
|
||||
public class IsTypeVisibilityConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (targetType != typeof(Visibility))
|
||||
throw new InvalidOperationException($"The target must be of type {nameof(Visibility)}");
|
||||
|
||||
if (!(parameter is Type paramType))
|
||||
{
|
||||
throw new ArgumentException();
|
||||
}
|
||||
if (value == null) return Visibility.Collapsed;
|
||||
return paramType.Equals(value.GetType()) ? Visibility.Visible : Visibility.Collapsed;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
@ -58,6 +58,7 @@ namespace Wabbajack
|
||||
{
|
||||
public string InstallationLocation { get; set; }
|
||||
public string DownloadLocation { get; set; }
|
||||
public bool AutomaticallyOverrideExistingInstall { get; set; }
|
||||
}
|
||||
|
||||
public class CompilerSettings
|
||||
|
@ -15,6 +15,7 @@
|
||||
<local:InverseBooleanConverter x:Key="InverseBooleanConverter" />
|
||||
<local:IsNotNullVisibilityConverter x:Key="IsNotNullVisibilityConverter" />
|
||||
<local:EqualsToBoolConverter x:Key="EqualsToBoolConverter" />
|
||||
<local:IsTypeVisibilityConverter x:Key="IsTypeVisibilityConverter" />
|
||||
|
||||
<!-- Colors -->
|
||||
<Color x:Key="WindowBackgroundColor">#121212</Color>
|
||||
|
@ -29,6 +29,9 @@ namespace Wabbajack
|
||||
|
||||
public FilePickerVM DownloadLocation { get; }
|
||||
|
||||
[Reactive]
|
||||
public bool AutomaticallyOverwrite { get; set; }
|
||||
|
||||
public MO2InstallerVM(InstallerVM installerVM)
|
||||
{
|
||||
_installerVM = installerVM;
|
||||
@ -131,11 +134,31 @@ namespace Wabbajack
|
||||
if (settingsPair.Current == null) return;
|
||||
Location.TargetPath = settingsPair.Current.InstallationLocation;
|
||||
DownloadLocation.TargetPath = settingsPair.Current.DownloadLocation;
|
||||
AutomaticallyOverwrite = settingsPair.Current.AutomaticallyOverrideExistingInstall;
|
||||
})
|
||||
.DisposeWith(CompositeDisposable);
|
||||
installerVM.MWVM.Settings.SaveSignal
|
||||
.Subscribe(_ => SaveSettings(CurrentSettings))
|
||||
.DisposeWith(CompositeDisposable);
|
||||
|
||||
// Hook onto user interventions, and intercept MO2 specific ones for customization
|
||||
this.WhenAny(x => x.ActiveInstallation.LogMessages)
|
||||
.Switch()
|
||||
.Subscribe(x =>
|
||||
{
|
||||
switch (x)
|
||||
{
|
||||
case ConfirmUpdateOfExistingInstall c:
|
||||
if (AutomaticallyOverwrite)
|
||||
{
|
||||
c.Confirm();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
})
|
||||
.DisposeWith(CompositeDisposable);
|
||||
}
|
||||
|
||||
public void Unload()
|
||||
@ -149,6 +172,7 @@ namespace Wabbajack
|
||||
if (settings == null) return;
|
||||
settings.InstallationLocation = Location.TargetPath;
|
||||
settings.DownloadLocation = DownloadLocation.TargetPath;
|
||||
settings.AutomaticallyOverrideExistingInstall = AutomaticallyOverwrite;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -391,13 +391,10 @@
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Border.Style>
|
||||
<ContentPresenter Content="{Binding ActiveGlobalUserIntervention}">
|
||||
<ContentPresenter.Resources>
|
||||
<DataTemplate DataType="{x:Type common:ConfirmationIntervention}">
|
||||
<local:ConfirmationInterventionView />
|
||||
</DataTemplate>
|
||||
</ContentPresenter.Resources>
|
||||
</ContentPresenter>
|
||||
<Grid>
|
||||
<!--<local:ConfirmationInterventionView DataContext="{Binding ActiveGlobalUserIntervention}" Visibility="{Binding ActiveGlobalUserIntervention, Converter={StaticResource IsTypeVisibilityConverter}, ConverterParameter={x:Type common:ConfirmationIntervention}}" />-->
|
||||
<local:ConfirmUpdateOfExistingInstallView Visibility="{Binding ActiveGlobalUserIntervention, Converter={StaticResource IsTypeVisibilityConverter}, ConverterParameter={x:Type lib:ConfirmUpdateOfExistingInstall}}" />
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
@ -0,0 +1,58 @@
|
||||
<UserControl
|
||||
x:Class="Wabbajack.ConfirmUpdateOfExistingInstallView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Wabbajack"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
mc:Ignorable="d">
|
||||
<Grid Margin="10">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="10" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="5*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="2*" />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock
|
||||
Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="3"
|
||||
Margin="0,0,0,5"
|
||||
FontFamily="Lucida Sans"
|
||||
FontSize="14"
|
||||
FontWeight="Bold"
|
||||
Text="{Binding ActiveGlobalUserIntervention.ShortDescription}"
|
||||
TextWrapping="WrapWithOverflow" />
|
||||
<TextBlock
|
||||
Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="3"
|
||||
Text="{Binding ActiveGlobalUserIntervention.ExtendedDescription}"
|
||||
TextWrapping="WrapWithOverflow" />
|
||||
<CheckBox
|
||||
Grid.Row="2"
|
||||
Grid.Column="2"
|
||||
Margin="4"
|
||||
HorizontalAlignment="Right"
|
||||
Content="Remember"
|
||||
IsChecked="{Binding Installer.AutomaticallyOverwrite}"
|
||||
ToolTip="If installing over an existing installation next time, automatically replace it without asking permission." />
|
||||
<Button
|
||||
Grid.Row="3"
|
||||
Grid.Column="0"
|
||||
Command="{Binding ActiveGlobalUserIntervention.CancelCommand}"
|
||||
Content="Cancel" />
|
||||
<Button
|
||||
Grid.Row="3"
|
||||
Grid.Column="2"
|
||||
Command="{Binding ActiveGlobalUserIntervention.ConfirmCommand}"
|
||||
Content="Confirm" />
|
||||
</Grid>
|
||||
</UserControl>
|
@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Wabbajack
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for ConfirmUpdateOfExistingInstallView.xaml
|
||||
/// </summary>
|
||||
public partial class ConfirmUpdateOfExistingInstallView : UserControl
|
||||
{
|
||||
public ConfirmUpdateOfExistingInstallView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?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>
|
||||
@ -172,6 +172,7 @@
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Compile Include="Converters\IsTypeVisibilityConverter.cs" />
|
||||
<Compile Include="Views\Interventions\ConfirmationInterventionView.xaml.cs">
|
||||
<DependentUpon>ConfirmationInterventionView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@ -195,6 +196,9 @@
|
||||
<Compile Include="Views\Common\HeatedBackgroundView.xaml.cs">
|
||||
<DependentUpon>HeatedBackgroundView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\Interventions\ConfirmUpdateOfExistingInstallView.xaml.cs">
|
||||
<DependentUpon>ConfirmUpdateOfExistingInstallView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\LinksView.xaml.cs">
|
||||
<DependentUpon>LinksView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@ -282,6 +286,10 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Views\Interventions\ConfirmUpdateOfExistingInstallView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Views\LinksView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
@ -536,8 +544,6 @@
|
||||
<ItemGroup>
|
||||
<Resource Include="Resources\Wabba_Ded.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="View Models\Installers\User Interventions\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
Loading…
Reference in New Issue
Block a user