From 5e16d98830c8e7b2145db96fd7137adffb43d324 Mon Sep 17 00:00:00 2001 From: FaithBeam Date: Sun, 19 Mar 2023 11:59:16 -0400 Subject: [PATCH] Os specific wrappers --- .../ViewModels/MainWindowViewModel.cs | 4 ++-- .../WrapperUtility.cs | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Sims1WidescreenPatcher.Core/ViewModels/MainWindowViewModel.cs b/Sims1WidescreenPatcher.Core/ViewModels/MainWindowViewModel.cs index 9e2d58a..767f6fe 100644 --- a/Sims1WidescreenPatcher.Core/ViewModels/MainWindowViewModel.cs +++ b/Sims1WidescreenPatcher.Core/ViewModels/MainWindowViewModel.cs @@ -1,5 +1,6 @@ using System.Reactive; using System.Reactive.Linq; +using System.Runtime.InteropServices; using System.Windows.Input; using Avalonia.Collections; using ReactiveUI; @@ -118,8 +119,7 @@ private bool IsBusy } } - public AvaloniaList Wrappers { get; } = - new(WrapperUtility.Wrapper.DDrawCompat, WrapperUtility.Wrapper.DgVoodoo2, WrapperUtility.Wrapper.None); + public AvaloniaList Wrappers => new(WrapperUtility.GetWrappers()); public WrapperUtility.Wrapper SelectedWrapper { diff --git a/Sims1WidescreenPatcher.Utilities/WrapperUtility.cs b/Sims1WidescreenPatcher.Utilities/WrapperUtility.cs index 4469ec9..2bd5294 100644 --- a/Sims1WidescreenPatcher.Utilities/WrapperUtility.cs +++ b/Sims1WidescreenPatcher.Utilities/WrapperUtility.cs @@ -1,4 +1,5 @@ using System.Reflection; +using System.Runtime.InteropServices; using Serilog; namespace Sims1WidescreenPatcher.Utilities; @@ -12,11 +13,27 @@ public enum Wrapper DgVoodoo2 } - private static string[] _ddrawCompatResources = {"ddraw.dll"}; + private static string[] _ddrawCompatResources = { "ddraw.dll" }; private static string[] _dgvoodooResources = {"D3D8.dll", "D3DImm.dll", "DDraw.dll", "dgVoodoo.conf", "dgVoodooCpl.exe"}; + public static List GetWrappers() + { + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + return new List { Wrapper.DDrawCompat, Wrapper.DgVoodoo2, Wrapper.None }; + } + else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + { + return new List { Wrapper.None, Wrapper.DgVoodoo2 }; + } + else + { + return new List { Wrapper.None }; + } + } + public static async Task ExtractWrapper(Wrapper wrapper, string path) { Log.Information("Begin extract wrapper");