mirror of
https://github.com/4sval/FModel.git
synced 2026-09-13 12:06:39 -05:00
sleeping makes you clever
This commit is contained in:
@@ -39,7 +39,7 @@ namespace FModel.Settings
|
||||
if (File.Exists(FilePath)) File.Delete(FilePath);
|
||||
}
|
||||
|
||||
public static bool TryGetGameCustomEndpoint(FGame game, EEndpointType type, out FEndpoint endpoint)
|
||||
public static bool IsEndpointEnabled(FGame game, EEndpointType type, out FEndpoint endpoint)
|
||||
{
|
||||
endpoint = null;
|
||||
if (!Default.CustomEndpoints.TryGetValue(game, out var endpoints))
|
||||
|
||||
@@ -295,7 +295,7 @@ public class CUE4ParseViewModel : ViewModel
|
||||
{
|
||||
// game directory dependent, we don't have the provider game name yet since we don't have aes keys
|
||||
// except when this comes from the AES Manager
|
||||
if (!UserSettings.TryGetGameCustomEndpoint(Game, EEndpointType.Aes, out var endpoint))
|
||||
if (!UserSettings.IsEndpointEnabled(Game, EEndpointType.Aes, out var endpoint))
|
||||
return;
|
||||
|
||||
await _threadWorkerView.Begin(cancellationToken =>
|
||||
@@ -323,7 +323,7 @@ public class CUE4ParseViewModel : ViewModel
|
||||
|
||||
public async Task InitBenMappings()
|
||||
{
|
||||
if (!UserSettings.TryGetGameCustomEndpoint(Game, EEndpointType.Mapping, out var endpoint))
|
||||
if (!UserSettings.IsEndpointEnabled(Game, EEndpointType.Mapping, out var endpoint))
|
||||
return;
|
||||
|
||||
await _threadWorkerView.Begin(cancellationToken =>
|
||||
|
||||
@@ -68,6 +68,20 @@ public class SettingsViewModel : ViewModel
|
||||
set => SetProperty(ref _selectedOptions, value);
|
||||
}
|
||||
|
||||
private FEndpoint _aesEndpoint;
|
||||
public FEndpoint AesEndpoint
|
||||
{
|
||||
get => _aesEndpoint;
|
||||
set => SetProperty(ref _aesEndpoint, value);
|
||||
}
|
||||
|
||||
private FEndpoint _mappingEndpoint;
|
||||
public FEndpoint MappingEndpoint
|
||||
{
|
||||
get => _mappingEndpoint;
|
||||
set => SetProperty(ref _mappingEndpoint, value);
|
||||
}
|
||||
|
||||
private ELanguage _selectedAssetLanguage;
|
||||
public ELanguage SelectedAssetLanguage
|
||||
{
|
||||
@@ -96,13 +110,6 @@ public class SettingsViewModel : ViewModel
|
||||
set => SetProperty(ref _selectedCompressedAudio, value);
|
||||
}
|
||||
|
||||
private string _currentMappingFile;
|
||||
public string CurrentMappingFile // only used so that it updates the UI
|
||||
{
|
||||
get => _currentMappingFile;
|
||||
set => SetProperty(ref _currentMappingFile, value);
|
||||
}
|
||||
|
||||
private EIconStyle _selectedCosmeticStyle;
|
||||
public EIconStyle SelectedCosmeticStyle
|
||||
{
|
||||
@@ -198,8 +205,11 @@ public class SettingsViewModel : ViewModel
|
||||
_optionsSnapshot = UserSettings.Default.OverridedOptions[_game];
|
||||
}
|
||||
|
||||
if (UserSettings.TryGetGameCustomEndpoint(_game, EEndpointType.Mapping, out var endpoint))
|
||||
CurrentMappingFile = endpoint.Path;
|
||||
if (UserSettings.Default.CustomEndpoints.TryGetValue(_game, out var endpoints))
|
||||
{
|
||||
AesEndpoint = endpoints[0];
|
||||
MappingEndpoint = endpoints[1];
|
||||
}
|
||||
|
||||
_assetLanguageSnapshot = UserSettings.Default.AssetLanguage;
|
||||
_compressedAudioSnapshot = UserSettings.Default.CompressedAudioMode;
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
using FModel.Framework;
|
||||
using FModel.Settings;
|
||||
using FModel.ViewModels;
|
||||
|
||||
namespace FModel.Views.Resources.Converters;
|
||||
|
||||
public class EndpointOverwriteToBoolConverter : IMultiValueConverter
|
||||
{
|
||||
public static readonly EndpointOverwriteToBoolConverter Instance = new();
|
||||
|
||||
private ApplicationViewModel _vm;
|
||||
private EEndpointType _type;
|
||||
private FEndpoint _endpoint;
|
||||
|
||||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
_vm = values[0] as ApplicationViewModel;
|
||||
_type = values[1] as EEndpointType? ?? EEndpointType.Mapping;
|
||||
if (_vm == null || !UserSettings.TryGetGameCustomEndpoint(_vm.CUE4Parse.Game, _type, out _endpoint))
|
||||
return default;
|
||||
|
||||
return targetType switch
|
||||
{
|
||||
not null when targetType == typeof(bool?) => _endpoint.Overwrite, // IsChecked
|
||||
not null when targetType == typeof(string) => _endpoint.Path,
|
||||
not null when targetType == typeof(Visibility) => _endpoint.Overwrite ? Visibility.Visible : Visibility.Collapsed,
|
||||
_ => throw new NotImplementedException()
|
||||
};
|
||||
}
|
||||
|
||||
public object[] ConvertBack(object value, Type[] targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
var t = value.GetType();
|
||||
switch (t)
|
||||
{
|
||||
case not null when t == typeof(bool):
|
||||
_endpoint.Overwrite = (bool)value;
|
||||
break;
|
||||
case not null when t == typeof(string):
|
||||
_endpoint.Path = (string)value;
|
||||
break;
|
||||
default:
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
return new object[] { _vm, _type };
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ public class EndpointToTypeConverter : IMultiValueConverter
|
||||
values[1] is not EEndpointType type)
|
||||
return false;
|
||||
|
||||
var isEnabled = UserSettings.TryGetGameCustomEndpoint(viewModel.CUE4Parse.Game, type, out _);
|
||||
var isEnabled = UserSettings.IsEndpointEnabled(viewModel.CUE4Parse.Game, type, out _);
|
||||
return targetType switch
|
||||
{
|
||||
not null when targetType == typeof(Visibility) => isEnabled ? Visibility.Visible : Visibility.Collapsed,
|
||||
|
||||
@@ -199,23 +199,13 @@
|
||||
</Button>
|
||||
</Grid>
|
||||
|
||||
<TextBlock Grid.Row="13" Grid.Column="0" Text="AES Reload at Launch" VerticalAlignment="Center" Margin="0 0 0 5">
|
||||
<TextBlock.Visibility>
|
||||
<MultiBinding Converter="{x:Static converters:EndpointToTypeConverter.Instance}">
|
||||
<Binding RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type local:Views.SettingsView}}" Path="DataContext" />
|
||||
<Binding Source="{x:Static local:EEndpointType.Aes}" />
|
||||
</MultiBinding>
|
||||
</TextBlock.Visibility>
|
||||
</TextBlock>
|
||||
<TextBlock Grid.Row="13" Grid.Column="0" Text="AES Reload at Launch" VerticalAlignment="Center" Margin="0 0 0 5"
|
||||
DataContext="{Binding DataContext, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:Views.SettingsView}}}"
|
||||
Visibility="{Binding SettingsView.AesEndpoint.IsEnabled, Converter={StaticResource BoolToVisibilityConverter}}" />
|
||||
<ComboBox Grid.Row="13" Grid.Column="2" Grid.ColumnSpan="5" Margin="0 0 0 5"
|
||||
DataContext="{Binding DataContext, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:Views.SettingsView}}}"
|
||||
ItemsSource="{Binding SettingsView.AesReloads}" SelectedItem="{Binding SettingsView.SelectedAesReload, Mode=TwoWay}">
|
||||
<ComboBox.Visibility>
|
||||
<MultiBinding Converter="{x:Static converters:EndpointToTypeConverter.Instance}">
|
||||
<Binding RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type local:Views.SettingsView}}" Path="DataContext" />
|
||||
<Binding Source="{x:Static local:EEndpointType.Aes}" />
|
||||
</MultiBinding>
|
||||
</ComboBox.Visibility>
|
||||
ItemsSource="{Binding SettingsView.AesReloads}" SelectedItem="{Binding SettingsView.SelectedAesReload, Mode=TwoWay}"
|
||||
Visibility="{Binding SettingsView.AesEndpoint.IsEnabled, Converter={StaticResource BoolToVisibilityConverter}}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Converter={x:Static converters:EnumToStringConverter.Instance}}" />
|
||||
@@ -227,42 +217,25 @@
|
||||
<CheckBox Grid.Row="14" Grid.Column="2" Content="{Binding IsChecked, RelativeSource={RelativeSource Self}, Converter={x:Static converters:BoolToToggleConverter.Instance}}"
|
||||
IsChecked="{Binding KeepDirectoryStructure, Source={x:Static local:Settings.UserSettings.Default}, Mode=TwoWay}" Margin="0 5 0 10"/>
|
||||
|
||||
<TextBlock Grid.Row="15" Grid.Column="0" Text="Overwrite Mapping File" VerticalAlignment="Center" Margin="0 0 0 5">
|
||||
<TextBlock.Visibility>
|
||||
<!-- if mapping custom endpoint is enabled, make this visible -->
|
||||
<MultiBinding Converter="{x:Static converters:EndpointToTypeConverter.Instance}">
|
||||
<Binding RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type local:Views.SettingsView}}" Path="DataContext" />
|
||||
<Binding Source="{x:Static local:EEndpointType.Mapping}" />
|
||||
</MultiBinding>
|
||||
</TextBlock.Visibility>
|
||||
</TextBlock>
|
||||
<CheckBox x:Name="OverwriteCkBox" Grid.Row="15" Grid.Column="2" Margin="0 5 0 10"
|
||||
Content="{Binding IsChecked, RelativeSource={RelativeSource Self}, Converter={x:Static converters:BoolToToggleConverter.Instance}}">
|
||||
<CheckBox.Visibility>
|
||||
<!-- if mapping custom endpoint is enabled, make this visible -->
|
||||
<MultiBinding Converter="{x:Static converters:EndpointToTypeConverter.Instance}">
|
||||
<Binding RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type local:Views.SettingsView}}" Path="DataContext" />
|
||||
<Binding Source="{x:Static local:EEndpointType.Mapping}" />
|
||||
</MultiBinding>
|
||||
</CheckBox.Visibility>
|
||||
<CheckBox.IsChecked>
|
||||
<!-- if mapping custom endpoint is enabled, this gets/sets the value of Overwrite -->
|
||||
<MultiBinding Converter="{x:Static converters:EndpointOverwriteToBoolConverter.Instance}">
|
||||
<Binding RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type local:Views.SettingsView}}" Path="DataContext" />
|
||||
<Binding Path="." Source="{x:Static local:EEndpointType.Mapping}" /> <!-- TwoWay binding needs a Path -->
|
||||
</MultiBinding>
|
||||
</CheckBox.IsChecked>
|
||||
</CheckBox>
|
||||
<TextBlock Grid.Row="15" Grid.Column="0" Text="Overwrite Mapping File" VerticalAlignment="Center" Margin="0 0 0 5"
|
||||
DataContext="{Binding DataContext, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:Views.SettingsView}}}"
|
||||
Visibility="{Binding SettingsView.MappingEndpoint.IsEnabled, Converter={StaticResource BoolToVisibilityConverter}}" />
|
||||
<CheckBox Grid.Row="15" Grid.Column="2" Margin="0 5 0 10"
|
||||
DataContext="{Binding DataContext, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:Views.SettingsView}}}"
|
||||
Content="{Binding IsChecked, RelativeSource={RelativeSource Self}, Converter={x:Static converters:BoolToToggleConverter.Instance}}"
|
||||
Visibility="{Binding SettingsView.MappingEndpoint.IsEnabled, Converter={StaticResource BoolToVisibilityConverter}}"
|
||||
IsChecked="{Binding SettingsView.MappingEndpoint.Overwrite, Mode=TwoWay}" />
|
||||
|
||||
<TextBlock Grid.Row="16" Grid.Column="0" Text="Mapping File Path" VerticalAlignment="Center" Margin="0 0 0 5"
|
||||
Visibility="{Binding IsChecked, ElementName=OverwriteCkBox, Converter={StaticResource BoolToVisibilityConverter}}">
|
||||
DataContext="{Binding DataContext, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:Views.SettingsView}}}"
|
||||
Visibility="{Binding SettingsView.MappingEndpoint.Overwrite, Converter={StaticResource BoolToVisibilityConverter}}">
|
||||
</TextBlock>
|
||||
<TextBox Grid.Row="16" Grid.Column="2" Grid.ColumnSpan="3" Margin="0 0 0 5"
|
||||
IsReadOnly="True" Text="{Binding SettingsView.CurrentMappingFile, Mode=TwoWay}"
|
||||
Visibility="{Binding IsChecked, ElementName=OverwriteCkBox, Converter={StaticResource BoolToVisibilityConverter}}"
|
||||
DataContext="{Binding DataContext, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:Views.SettingsView}}}" />
|
||||
<TextBox Grid.Row="16" Grid.Column="2" Grid.ColumnSpan="3" Margin="0 0 0 5" Text="{Binding SettingsView.MappingEndpoint.Path, Mode=TwoWay}"
|
||||
DataContext="{Binding DataContext, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:Views.SettingsView}}}"
|
||||
Visibility="{Binding SettingsView.MappingEndpoint.Overwrite, Converter={StaticResource BoolToVisibilityConverter}}" />
|
||||
<Button Grid.Row="16" Grid.Column="6" Content="..." HorizontalAlignment="Right" Click="OnBrowseMappings" Margin="0 0 0 5"
|
||||
Visibility="{Binding IsChecked, ElementName=OverwriteCkBox, Converter={StaticResource BoolToVisibilityConverter}}" />
|
||||
DataContext="{Binding DataContext, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:Views.SettingsView}}}"
|
||||
Visibility="{Binding SettingsView.MappingEndpoint.Overwrite, Converter={StaticResource BoolToVisibilityConverter}}" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
<DataTemplate x:Key="CreatorTemplate">
|
||||
|
||||
@@ -99,11 +99,10 @@ public partial class SettingsView
|
||||
Filter = "USMAP Files (*.usmap)|*.usmap|All Files (*.*)|*.*"
|
||||
};
|
||||
|
||||
if (!openFileDialog.ShowDialog().GetValueOrDefault() ||
|
||||
!UserSettings.TryGetGameCustomEndpoint(_applicationView.CUE4Parse.Game, EEndpointType.Mapping, out var endpoint))
|
||||
if (!openFileDialog.ShowDialog().GetValueOrDefault())
|
||||
return;
|
||||
|
||||
endpoint.Path = _applicationView.SettingsView.CurrentMappingFile = openFileDialog.FileName;
|
||||
_applicationView.SettingsView.MappingEndpoint.Path = openFileDialog.FileName;
|
||||
await _applicationView.CUE4Parse.InitBenMappings();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user