mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
VortexCompiler game selection combobox work
This commit is contained in:
parent
40d95cb034
commit
228bb3d070
30
Wabbajack.Common/Extensions/EnumExt.cs
Normal file
30
Wabbajack.Common/Extensions/EnumExt.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Wabbajack.Common
|
||||
{
|
||||
public static class EnumExt
|
||||
{
|
||||
public static IEnumerable<T> GetValues<T>()
|
||||
where T : struct, Enum
|
||||
{
|
||||
return Enum.GetValues(typeof(T)).Cast<T>();
|
||||
}
|
||||
|
||||
public static string ToDescriptionString<TEnum>(this TEnum val)
|
||||
where TEnum : struct, IConvertible
|
||||
{
|
||||
if (!typeof(TEnum).IsEnum)
|
||||
{
|
||||
throw new ArgumentException("T must be an Enum");
|
||||
}
|
||||
|
||||
DescriptionAttribute[] attributes = (DescriptionAttribute[])val.GetType().GetField(val.ToString()).GetCustomAttributes(typeof(DescriptionAttribute), false);
|
||||
return attributes.Length > 0 ? attributes[0].Description : string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,29 +1,43 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using Alphaleonis.Win32.Filesystem;
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace Wabbajack.Common
|
||||
{
|
||||
public enum Game {
|
||||
public enum Game
|
||||
{
|
||||
//MO2 GAMES
|
||||
Morrowind,
|
||||
Oblivion,
|
||||
[Description("Fallout 3")]
|
||||
Fallout3,
|
||||
[Description("Fallout New Vegas")]
|
||||
FalloutNewVegas,
|
||||
Skyrim,
|
||||
[Description("Skyrim Special Edition")]
|
||||
SkyrimSpecialEdition,
|
||||
[Description("Fallout 4")]
|
||||
Fallout4,
|
||||
[Description("Skyrim VR")]
|
||||
SkyrimVR,
|
||||
//VORTEX GAMES
|
||||
[Description("Darkest Dungeon")]
|
||||
DarkestDungeon,
|
||||
[Description("Divinity Original Sin 2")]
|
||||
DivinityOriginalSin2,
|
||||
[Description("Divinity Original Sin 2 Definitive Edition")]
|
||||
DivinityOriginalSin2DE, //definitive edition has its own nexus page but same Steam/GOG ids
|
||||
Starbound,
|
||||
[Description("Star Wars: Knights of the Old Republic")]
|
||||
SWKOTOR,
|
||||
[Description("Star Wars: Knights of the Old Republic 2")]
|
||||
SWKOTOR2,
|
||||
Witcher,
|
||||
[Description("Witcher 2")]
|
||||
Witcher2,
|
||||
[Description("Witcher 3")]
|
||||
Witcher3
|
||||
}
|
||||
|
||||
|
@ -95,6 +95,7 @@
|
||||
<Compile Include="Enums\RunMode.cs" />
|
||||
<Compile Include="ExtensionManager.cs" />
|
||||
<Compile Include="Extensions\DictionaryExt.cs" />
|
||||
<Compile Include="Extensions\EnumExt.cs" />
|
||||
<Compile Include="Extensions\HashHelper.cs" />
|
||||
<Compile Include="Extensions\RxExt.cs" />
|
||||
<Compile Include="Extensions\TaskExt.cs" />
|
||||
|
BIN
Wabbajack/Resources/Icons/gog.png
Normal file
BIN
Wabbajack/Resources/Icons/gog.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 118 KiB |
BIN
Wabbajack/Resources/Icons/steam.png
Normal file
BIN
Wabbajack/Resources/Icons/steam.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
@ -5,6 +5,8 @@ using System.Reactive.Disposables;
|
||||
using System.Reactive.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
using DynamicData.Binding;
|
||||
using ReactiveUI;
|
||||
using ReactiveUI.Fody.Helpers;
|
||||
using Wabbajack.Common;
|
||||
@ -24,8 +26,15 @@ namespace Wabbajack
|
||||
private readonly ObservableAsPropertyHelper<ModlistSettingsEditorVM> _ModlistSettings;
|
||||
public ModlistSettingsEditorVM ModlistSettings => _ModlistSettings.Value;
|
||||
|
||||
private static ObservableCollectionExtended<GameVM> gameOptions = new ObservableCollectionExtended<GameVM>(
|
||||
EnumExt.GetValues<Game>()
|
||||
.Select(g => new GameVM(g))
|
||||
.OrderBy(g => g.DisplayName));
|
||||
|
||||
public ObservableCollectionExtended<GameVM> GameOptions => gameOptions;
|
||||
|
||||
[Reactive]
|
||||
public Game SelectedGame { get; set; }
|
||||
public GameVM SelectedGame { get; set; } = gameOptions.First(x => x.Game == Game.SkyrimSpecialEdition);
|
||||
|
||||
[Reactive]
|
||||
public FilePickerVM GameLocation { get; set; }
|
||||
@ -71,7 +80,7 @@ namespace Wabbajack
|
||||
try
|
||||
{
|
||||
compiler = new VortexCompiler(
|
||||
game: this.SelectedGame,
|
||||
game: this.SelectedGame.Game,
|
||||
gamePath: this.GameLocation.TargetPath,
|
||||
vortexFolder: VortexCompiler.TypicalVortexFolder(),
|
||||
downloadsFolder: this.DownloadsLocation.TargetPath,
|
||||
@ -101,7 +110,7 @@ namespace Wabbajack
|
||||
|
||||
// Load settings
|
||||
this.settings = parent.MWVM.Settings.Compiler.VortexCompilation;
|
||||
this.SelectedGame = settings.LastCompiledGame;
|
||||
this.SelectedGame = gameOptions.First(x => x.Game == settings.LastCompiledGame);
|
||||
if (!string.IsNullOrWhiteSpace(settings.DownloadLocation))
|
||||
{
|
||||
this.DownloadsLocation.TargetPath = settings.DownloadLocation;
|
||||
@ -116,7 +125,7 @@ namespace Wabbajack
|
||||
|
||||
// Load custom game settings when game type changes
|
||||
this.WhenAny(x => x.SelectedGame)
|
||||
.Select(game => settings.ModlistSettings.TryCreate(game))
|
||||
.Select(game => settings.ModlistSettings.TryCreate(game.Game))
|
||||
.Pairwise()
|
||||
.Subscribe(pair =>
|
||||
{
|
||||
@ -132,7 +141,7 @@ namespace Wabbajack
|
||||
this._ModlistSettings = this.WhenAny(x => x.SelectedGame)
|
||||
.Select(game =>
|
||||
{
|
||||
var gameSettings = settings.ModlistSettings.TryCreate(game);
|
||||
var gameSettings = settings.ModlistSettings.TryCreate(game.Game);
|
||||
return new ModlistSettingsEditorVM(gameSettings.ModlistSettings);
|
||||
})
|
||||
// Interject and save old while loading new
|
||||
@ -152,7 +161,7 @@ namespace Wabbajack
|
||||
{
|
||||
settings.DownloadLocation = this.DownloadsLocation.TargetPath;
|
||||
settings.StagingLocation = this.StagingLocation.TargetPath;
|
||||
settings.LastCompiledGame = this.SelectedGame;
|
||||
settings.LastCompiledGame = this.SelectedGame.Game;
|
||||
this.ModlistSettings?.Save();
|
||||
}
|
||||
}
|
||||
|
25
Wabbajack/View Models/GameVM.cs
Normal file
25
Wabbajack/View Models/GameVM.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Wabbajack.Common;
|
||||
|
||||
namespace Wabbajack
|
||||
{
|
||||
public class GameVM
|
||||
{
|
||||
public Game Game { get; }
|
||||
public string DisplayName { get; }
|
||||
|
||||
public GameVM(Game game)
|
||||
{
|
||||
this.Game = game;
|
||||
this.DisplayName = game.ToDescriptionString();
|
||||
if (string.IsNullOrWhiteSpace(this.DisplayName))
|
||||
{
|
||||
this.DisplayName = game.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -5,6 +5,7 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Wabbajack"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
d:DataContext="{d:DesignInstance local:VortexCompilerVM}"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
mc:Ignorable="d">
|
||||
@ -19,12 +20,13 @@
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="28" />
|
||||
<RowDefinition Height="40" />
|
||||
<RowDefinition Height="40" />
|
||||
<RowDefinition Height="40" />
|
||||
<RowDefinition Height="28" />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock
|
||||
Grid.Row="0"
|
||||
Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Center"
|
||||
@ -33,13 +35,23 @@
|
||||
TextAlignment="Center"
|
||||
ToolTip="The game you wish to target" />
|
||||
<ComboBox
|
||||
Grid.Row="0"
|
||||
Grid.Row="1"
|
||||
Grid.Column="2"
|
||||
Height="30"
|
||||
VerticalAlignment="Center"
|
||||
ToolTip="The game you wish to target" />
|
||||
VerticalContentAlignment="Center"
|
||||
FontSize="14"
|
||||
ItemsSource="{Binding GameOptions}"
|
||||
SelectedValue="{Binding SelectedGame}"
|
||||
ToolTip="The game you wish to target">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding DisplayName}" />
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
<TextBlock
|
||||
Grid.Row="1"
|
||||
Grid.Row="2"
|
||||
Grid.Column="0"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Center"
|
||||
@ -48,15 +60,42 @@
|
||||
TextAlignment="Center"
|
||||
ToolTip="The install folder for the game" />
|
||||
<local:FilePicker
|
||||
Grid.Row="1"
|
||||
Grid.Row="2"
|
||||
Grid.Column="2"
|
||||
Height="30"
|
||||
VerticalAlignment="Center"
|
||||
DataContext="{Binding GameLocation}"
|
||||
FontSize="14"
|
||||
ToolTip="The install folder for the game" />
|
||||
<Grid
|
||||
Grid.Row="3"
|
||||
Grid.Column="2"
|
||||
Height="28"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Top">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button
|
||||
Grid.Column="0"
|
||||
Margin="0,0,5,0"
|
||||
Background="Transparent"
|
||||
Style="{StaticResource CircleButtonStyle}"
|
||||
ToolTip="Attempt to locate the game in Steam">
|
||||
<Image Margin="1" Source="../../Resources/Icons/steam.png" />
|
||||
</Button>
|
||||
<Button
|
||||
Grid.Column="1"
|
||||
Background="Transparent"
|
||||
Style="{StaticResource CircleButtonStyle}"
|
||||
ToolTip="Attempt to locate game in GoG">
|
||||
<Image Margin="1" Source="../../Resources/Icons/gog.png" />
|
||||
</Button>
|
||||
</Grid>
|
||||
|
||||
<TextBlock
|
||||
Grid.Row="0"
|
||||
Grid.Row="1"
|
||||
Grid.Column="4"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Center"
|
||||
@ -65,7 +104,7 @@
|
||||
TextAlignment="Center"
|
||||
ToolTip="The folder to downloads your mods" />
|
||||
<local:FilePicker
|
||||
Grid.Row="0"
|
||||
Grid.Row="1"
|
||||
Grid.Column="6"
|
||||
Height="30"
|
||||
VerticalAlignment="Center"
|
||||
@ -73,7 +112,7 @@
|
||||
FontSize="14"
|
||||
ToolTip="The folder to downloads your mods" />
|
||||
<TextBlock
|
||||
Grid.Row="1"
|
||||
Grid.Row="2"
|
||||
Grid.Column="4"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Center"
|
||||
@ -81,7 +120,7 @@
|
||||
Text="Staging Location"
|
||||
TextAlignment="Center" />
|
||||
<local:FilePicker
|
||||
Grid.Row="1"
|
||||
Grid.Row="2"
|
||||
Grid.Column="6"
|
||||
Height="30"
|
||||
VerticalAlignment="Center"
|
||||
|
@ -162,6 +162,7 @@
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Compile Include="Converters\EqualsToBoolConverter.cs" />
|
||||
<Compile Include="View Models\GameVM.cs" />
|
||||
<Compile Include="Views\Compilers\MO2CompilerConfigView.xaml.cs">
|
||||
<DependentUpon>MO2CompilerConfigView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@ -472,5 +473,9 @@
|
||||
<Resource Include="Resources\MO2Button.png" />
|
||||
<Resource Include="Resources\VortexButton.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="Resources\Icons\gog.png" />
|
||||
<Resource Include="Resources\Icons\steam.png" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
Loading…
Reference in New Issue
Block a user