forgot this

This commit is contained in:
Asval 2024-05-19 21:17:41 +02:00
parent e94f558d6f
commit 608e6fd42d
3 changed files with 36 additions and 6 deletions

View File

@ -33,16 +33,28 @@ public class GameSelectorViewModel : ViewModel
public IList<CustomDirectory> CustomDirectories { get; set; }
}
private bool _useCustomEGames;
public bool UseCustomEGames
{
get => _useCustomEGames;
set => SetProperty(ref _useCustomEGames, value);
}
private DirectorySettings _selectedDirectory;
public DirectorySettings SelectedDirectory
{
get => _selectedDirectory;
set => SetProperty(ref _selectedDirectory, value);
set
{
SetProperty(ref _selectedDirectory, value);
UseCustomEGames = EnumerateUeGames().ElementAt(1).Contains(_selectedDirectory.UeVersion);
}
}
private readonly ObservableCollection<DirectorySettings> _detectedDirectories;
public ReadOnlyObservableCollection<DirectorySettings> DetectedDirectories { get; }
public ReadOnlyObservableCollection<EGame> UeVersions { get; }
public ReadOnlyObservableCollection<EGame> UeGames { get; }
public ReadOnlyObservableCollection<EGame> CustomUeGames { get; }
public GameSelectorViewModel(string gameDirectory)
{
@ -61,7 +73,9 @@ public class GameSelectorViewModel : ViewModel
else
SelectedDirectory = DetectedDirectories.FirstOrDefault();
UeVersions = new ReadOnlyObservableCollection<EGame>(new ObservableCollection<EGame>(EnumerateUeGames()));
var ueGames = EnumerateUeGames().ToArray();
UeGames = new ReadOnlyObservableCollection<EGame>(new ObservableCollection<EGame>(ueGames[0]));
CustomUeGames = new ReadOnlyObservableCollection<EGame>(new ObservableCollection<EGame>(ueGames[1]));
}
public void AddUndetectedDir(string gameDirectory) => AddUndetectedDir(gameDirectory.SubstringAfterLast('\\'), gameDirectory);
@ -80,11 +94,11 @@ public class GameSelectorViewModel : ViewModel
SelectedDirectory = DetectedDirectories.Last();
}
private IEnumerable<EGame> EnumerateUeGames()
private IEnumerable<IGrouping<bool, EGame>> EnumerateUeGames()
=> Enum.GetValues<EGame>()
.GroupBy(value => (int)value)
.Select(group => group.First())
.OrderBy(value => (int)value == ((int)value & ~0xF));
.GroupBy(value => (int)value == ((int)value & ~0xF));
private IEnumerable<DirectorySettings> EnumerateDetectedGames()
{
yield return GetUnrealEngineGame("Fortnite", "\\FortniteGame\\Content\\Paks", EGame.GAME_UE5_4);

View File

@ -61,14 +61,26 @@
</ComboBox>
<TextBlock Grid.Row="1" Grid.Column="0" Text="UE Versions" VerticalAlignment="Center" Margin="0 0 0 5" />
<ComboBox Grid.Row="1" Grid.Column="2" Grid.ColumnSpan="3" ItemsSource="{Binding UeVersions}" Margin="0 0 0 5"
<ComboBox Grid.Row="1" Grid.Column="2" Margin="0 0 0 5"
VerticalAlignment="Center" SelectedItem="{Binding SelectedDirectory.UeVersion, Mode=TwoWay}">
<ComboBox.Style>
<Style TargetType="ComboBox" BasedOn="{StaticResource {x:Type ComboBox}}">
<Setter Property="ItemsSource" Value="{Binding UeGames}" />
<Style.Triggers>
<DataTrigger Binding="{Binding UseCustomEGames}" Value="True">
<Setter Property="ItemsSource" Value="{Binding CustomUeGames}" />
</DataTrigger>
</Style.Triggers>
</Style>
</ComboBox.Style>
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Converter={x:Static converters:EnumToStringConverter.Instance}}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<CheckBox Grid.Row="1" Grid.Column="4" Margin="5 0 0 5" ToolTip="Enable custom UE versions"
IsChecked="{Binding UseCustomEGames, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
<TextBlock Grid.Row="2" Grid.Column="0" Text="Directory" VerticalAlignment="Center" />
<TextBox Grid.Row="2" Grid.Column="2" Text="{Binding SelectedDirectory.GameDirectory, Mode=TwoWay}" />
@ -83,7 +95,9 @@
</Viewbox>
</Button>
</Grid>
<Separator Style="{StaticResource CustomSeparator}" Tag="ADD UNDETECTED GAME" />
<Expander ExpandDirection="Down" IsExpanded="False">
<Grid MaxWidth="{Binding ActualWidth, ElementName=Hello}">
<Grid.RowDefinitions>

View File

@ -1,6 +1,7 @@
using FModel.ViewModels;
using Ookii.Dialogs.Wpf;
using System.Windows;
using CUE4Parse.Utils;
namespace FModel.Views;
@ -38,6 +39,7 @@ public partial class DirectorySelector
var folderBrowser = new VistaFolderBrowserDialog {ShowNewFolderButton = false};
if (folderBrowser.ShowDialog() == true)
{
HelloMyNameIsGame.Text = folderBrowser.SelectedPath.SubstringAfterLast('\\');
HelloGameMyNameIsDirectory.Text = folderBrowser.SelectedPath;
}
}