diff --git a/Wabbajack.Common/Extensions/EnumExt.cs b/Wabbajack.Common/Extensions/EnumExt.cs new file mode 100644 index 00000000..8f289ba2 --- /dev/null +++ b/Wabbajack.Common/Extensions/EnumExt.cs @@ -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 GetValues() + where T : struct, Enum + { + return Enum.GetValues(typeof(T)).Cast(); + } + + public static string ToDescriptionString(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; + } + } +} diff --git a/Wabbajack.Common/GameMetaData.cs b/Wabbajack.Common/GameMetaData.cs index 5440e722..c1b6aee1 100644 --- a/Wabbajack.Common/GameMetaData.cs +++ b/Wabbajack.Common/GameMetaData.cs @@ -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 } diff --git a/Wabbajack.Common/Wabbajack.Common.csproj b/Wabbajack.Common/Wabbajack.Common.csproj index 4469b164..8ecec865 100644 --- a/Wabbajack.Common/Wabbajack.Common.csproj +++ b/Wabbajack.Common/Wabbajack.Common.csproj @@ -95,6 +95,7 @@ + diff --git a/Wabbajack/Resources/Icons/gog.png b/Wabbajack/Resources/Icons/gog.png new file mode 100644 index 00000000..f0672a74 Binary files /dev/null and b/Wabbajack/Resources/Icons/gog.png differ diff --git a/Wabbajack/Resources/Icons/steam.png b/Wabbajack/Resources/Icons/steam.png new file mode 100644 index 00000000..428d3189 Binary files /dev/null and b/Wabbajack/Resources/Icons/steam.png differ diff --git a/Wabbajack/View Models/Compilers/VortexCompilerVM.cs b/Wabbajack/View Models/Compilers/VortexCompilerVM.cs index d23d0150..4ef996c4 100644 --- a/Wabbajack/View Models/Compilers/VortexCompilerVM.cs +++ b/Wabbajack/View Models/Compilers/VortexCompilerVM.cs @@ -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 _ModlistSettings; public ModlistSettingsEditorVM ModlistSettings => _ModlistSettings.Value; + private static ObservableCollectionExtended gameOptions = new ObservableCollectionExtended( + EnumExt.GetValues() + .Select(g => new GameVM(g)) + .OrderBy(g => g.DisplayName)); + + public ObservableCollectionExtended 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(); } } diff --git a/Wabbajack/View Models/GameVM.cs b/Wabbajack/View Models/GameVM.cs new file mode 100644 index 00000000..1cd3d1dc --- /dev/null +++ b/Wabbajack/View Models/GameVM.cs @@ -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(); + } + } + } +} diff --git a/Wabbajack/Views/Compilers/VortexCompilerConfigView.xaml b/Wabbajack/Views/Compilers/VortexCompilerConfigView.xaml index 3a6d9b14..bc1f3d34 100644 --- a/Wabbajack/Views/Compilers/VortexCompilerConfigView.xaml +++ b/Wabbajack/Views/Compilers/VortexCompilerConfigView.xaml @@ -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 @@ + - + + VerticalContentAlignment="Center" + FontSize="14" + ItemsSource="{Binding GameOptions}" + SelectedValue="{Binding SelectedGame}" + ToolTip="The game you wish to target"> + + + + + + + + + + + + + + + Designer + MO2CompilerConfigView.xaml @@ -472,5 +473,9 @@ + + + + \ No newline at end of file