From c6e523a5444ba1f58d2118a7764b9191c5accda3 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Sat, 17 Jun 2023 01:01:28 -0700 Subject: [PATCH 01/33] First successful build and launch. --- lib/FFXIVQuickLauncher | 2 +- .../Components/MainPage/MainPage.cs | 5 +- .../Components/SettingsPage/SettingsPage.cs | 1 + .../Components/SettingsPage/SettingsTab.cs | 5 +- .../SettingsPage/Tabs/SettingsTabDxvk.cs | 90 ++++++++ .../SettingsPage/Tabs/SettingsTabWine.cs | 19 +- .../Configuration/ILauncherConfig.cs | 17 +- src/XIVLauncher.Core/Program.cs | 27 ++- src/XIVLauncher.Core/Runners/Dxvk.cs | 194 ++++++++++++++++++ src/XIVLauncher.Core/Runners/Wine.cs | 87 ++++++++ 10 files changed, 430 insertions(+), 17 deletions(-) create mode 100644 src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDxvk.cs create mode 100644 src/XIVLauncher.Core/Runners/Dxvk.cs create mode 100644 src/XIVLauncher.Core/Runners/Wine.cs diff --git a/lib/FFXIVQuickLauncher b/lib/FFXIVQuickLauncher index 77115d3f..62fee287 160000 --- a/lib/FFXIVQuickLauncher +++ b/lib/FFXIVQuickLauncher @@ -1 +1 @@ -Subproject commit 77115d3f7d920179ce83f0708ec97ba2450ce795 +Subproject commit 62fee287329fe27cdf17106f562b2bf1ea3809c0 diff --git a/src/XIVLauncher.Core/Components/MainPage/MainPage.cs b/src/XIVLauncher.Core/Components/MainPage/MainPage.cs index cbb3fb42..49fb4a4d 100644 --- a/src/XIVLauncher.Core/Components/MainPage/MainPage.cs +++ b/src/XIVLauncher.Core/Components/MainPage/MainPage.cs @@ -19,6 +19,7 @@ using XIVLauncher.Core.Accounts; using XIVLauncher.Common.Game.Exceptions; using XIVLauncher.Core.Support; +using XIVLauncher.Core.Runners; namespace XIVLauncher.Core.Components.MainPage; @@ -691,7 +692,7 @@ public async Task StartGameAndAddon(Launcher.LoginResult loginResult, b } else if (Environment.OSVersion.Platform == PlatformID.Unix) { - if (App.Settings.WineStartupType == WineStartupType.Custom) + if (App.Settings.WineType == WineType.Custom) { if (App.Settings.WineBinaryPath == null) throw new Exception("Custom wine binary path wasn't set."); @@ -712,7 +713,7 @@ public async Task StartGameAndAddon(Launcher.LoginResult loginResult, b await Program.CompatibilityTools.EnsureTool(tempPath).ConfigureAwait(false); - var gameFixApply = new GameFixApply(App.Settings.GamePath, App.Settings.GameConfigPath, Program.CompatibilityTools.Settings.Prefix, tempPath); + var gameFixApply = new GameFixApply(App.Settings.GamePath, App.Settings.GameConfigPath, Program.CompatibilityTools.Prefix, tempPath); gameFixApply.UpdateProgress += (text, hasProgress, progress) => { App.LoadingPage.Line1 = "Applying game-specific fixes..."; diff --git a/src/XIVLauncher.Core/Components/SettingsPage/SettingsPage.cs b/src/XIVLauncher.Core/Components/SettingsPage/SettingsPage.cs index 689ed724..248e8e15 100644 --- a/src/XIVLauncher.Core/Components/SettingsPage/SettingsPage.cs +++ b/src/XIVLauncher.Core/Components/SettingsPage/SettingsPage.cs @@ -11,6 +11,7 @@ public class SettingsPage : Page new SettingsTabGame(), new SettingsTabPatching(), new SettingsTabWine(), + new SettingsTabDxvk(), new SettingsTabDalamud(), new SettingsTabAutoStart(), new SettingsTabAbout(), diff --git a/src/XIVLauncher.Core/Components/SettingsPage/SettingsTab.cs b/src/XIVLauncher.Core/Components/SettingsPage/SettingsTab.cs index e50ebeda..5e86faab 100644 --- a/src/XIVLauncher.Core/Components/SettingsPage/SettingsTab.cs +++ b/src/XIVLauncher.Core/Components/SettingsPage/SettingsTab.cs @@ -16,9 +16,10 @@ public override void Draw() foreach (SettingsEntry settingsEntry in Entries) { if (settingsEntry.IsVisible) + { settingsEntry.Draw(); - - ImGui.Dummy(new Vector2(10) * ImGuiHelpers.GlobalScale); + ImGui.Dummy(new Vector2(10) * ImGuiHelpers.GlobalScale); + } } base.Draw(); diff --git a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDxvk.cs b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDxvk.cs new file mode 100644 index 00000000..383956cb --- /dev/null +++ b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDxvk.cs @@ -0,0 +1,90 @@ +using System.IO; +using System.Numerics; +using System.Runtime.InteropServices; +using ImGuiNET; +using XIVLauncher.Common.Unix.Compatibility; +using XIVLauncher.Common.Util; +using XIVLauncher.Core.Runners; + +namespace XIVLauncher.Core.Components.SettingsPage.Tabs; + +public class SettingsTabDxvk : SettingsTab +{ + private SettingsEntry dxvkVersionSetting; + private SettingsEntry dxvkHudSetting; + + public SettingsTabDxvk() + { + Entries = new SettingsEntry[] + { + dxvkVersionSetting = new SettingsEntry("DXVK Version", "Choose which version of DXVK to use.", () => Program.Config.DxvkVersion ?? DxvkVersion.v1_10_3, type => Program.Config.DxvkVersion = type) + { + CheckWarning = type => + { + if (new [] {DxvkVersion.v2_1, DxvkVersion.v2_2}.Contains(type)) + return "May not work with pre-8.0 or non-proton wine builds. AMD users may need to use env variable RADV_PERFTEST=gpl"; + return null; + }, + }, + new SettingsEntry("Enable DXVK ASYNC", "Enable DXVK ASYNC patch.", () => Program.Config.DxvkAsyncEnabled ?? true, b => Program.Config.DxvkAsyncEnabled = b) + { + CheckVisibility = () => (new [] {DxvkVersion.v1_10_3, DxvkVersion.v2_0}.Contains(dxvkVersionSetting.Value)), + CheckWarning = b => + { + if (!b && dxvkVersionSetting.Value == DxvkVersion.v2_0) + return "AMD users may need to use env variable RADV_PERFTEST=gpl"; + return null; + }, + }, + dxvkHudSetting = new SettingsEntry("DXVK Overlay", "DXVK Hud is included. MangoHud must be installed separately.\nFlatpak XIVLauncher needs flatpak MangoHud.", () => Program.Config.DxvkHudType, type => Program.Config.DxvkHudType = type) + { + CheckVisibility = () => dxvkVersionSetting.Value != DxvkVersion.Disabled, + CheckValidity = type => + { + if ((type == DxvkHudType.MangoHud || type == DxvkHudType.MangoHudCustom || type == DxvkHudType.MangoHudFull) + && (!File.Exists("/usr/lib/mangohud/libMangoHud.so") && !File.Exists("/usr/lib64/mangohud/libMangoHud.so") && !File.Exists("/usr/lib/extensions/vulkan/MangoHud/lib/x86_64-linux-gnu/libMangoHud.so"))) + return "MangoHud not detected."; + + return null; + } + }, + new SettingsEntry("DXVK Hud Custom String", "Set a custom string for the built in DXVK Hud. Warning: If it's invalid, the game may hang.", () => Program.Config.DxvkHudCustom, s => Program.Config.DxvkHudCustom = s) + { + CheckVisibility = () => dxvkHudSetting.Value == DxvkHudType.Custom && dxvkVersionSetting.Value != DxvkVersion.Disabled, + CheckWarning = s => + { + if(!Dxvk.CheckDxvkHudString(s)) + return "That's not a valid hud string"; + return null; + }, + }, + new SettingsEntry("MangoHud Custom Path", "Set a custom path for MangoHud config file.", () => Program.Config.DxvkMangoCustom, s => Program.Config.DxvkMangoCustom = s) + { + CheckVisibility = () => dxvkHudSetting.Value == DxvkHudType.MangoHudCustom && dxvkVersionSetting.Value != DxvkVersion.Disabled, + CheckWarning = s => + { + if(!File.Exists(s)) + return "That's not a valid file."; + return null; + }, + }, + new NumericSettingsEntry("Frame Rate Limit", "Set a frame rate limit, and DXVK will try not exceed it. Use 0 for unlimited.", () => Program.Config.DxvkFrameRate ?? 0, i => Program.Config.DxvkFrameRate = i, 0, 1000) + { + CheckVisibility = () => dxvkVersionSetting.Value != DxvkVersion.Disabled, + }, + }; + } + + public override SettingsEntry[] Entries { get; } + + public override bool IsUnixExclusive => true; + + public override string Title => "DXVK"; + + public override void Save() + { + base.Save(); + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + Program.CreateCompatToolsInstance(); + } +} diff --git a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabWine.cs b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabWine.cs index dc4fbcfa..c0f825af 100644 --- a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabWine.cs +++ b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabWine.cs @@ -3,25 +3,31 @@ using ImGuiNET; using XIVLauncher.Common.Unix.Compatibility; using XIVLauncher.Common.Util; +using XIVLauncher.Core.Runners; namespace XIVLauncher.Core.Components.SettingsPage.Tabs; public class SettingsTabWine : SettingsTab { - private SettingsEntry startupTypeSetting; + private SettingsEntry startupTypeSetting; public SettingsTabWine() { Entries = new SettingsEntry[] { - startupTypeSetting = new SettingsEntry("Installation Type", "Choose how XIVLauncher will start and manage your game installation.", - () => Program.Config.WineStartupType ?? WineStartupType.Managed, x => Program.Config.WineStartupType = x), + startupTypeSetting = new SettingsEntry("Installation Type", "Choose how XIVLauncher will start and manage your game installation.", + () => Program.Config.WineType ?? WineType.Managed, x => Program.Config.WineType = x), + new SettingsEntry("Wine Version", "Choose a patched wine version.", () => Program.Config.WineVersion ?? WineVersion.Wine8_5, x => Program.Config.WineVersion = x) + { + CheckVisibility = () => startupTypeSetting.Value == WineType.Other + }, + new SettingsEntry("Wine Binary Path", "Set the path XIVLauncher will use to run applications via wine.\nIt should be an absolute path to a folder containing wine64 and wineserver binaries.", () => Program.Config.WineBinaryPath, s => Program.Config.WineBinaryPath = s) { - CheckVisibility = () => startupTypeSetting.Value == WineStartupType.Custom + CheckVisibility = () => startupTypeSetting.Value == WineType.Custom }, new SettingsEntry("Enable Feral's GameMode", "Enable launching with Feral Interactive's GameMode CPU optimizations.", () => Program.Config.GameModeEnabled ?? true, b => Program.Config.GameModeEnabled = b) @@ -49,8 +55,7 @@ public SettingsTabWine() return null; } }, - - new SettingsEntry("DXVK Overlay", "Configure how much of the DXVK overlay is to be shown.", () => Program.Config.DxvkHudType, type => Program.Config.DxvkHudType = type), + new SettingsEntry("Enable ReShade Fix", "Passes d3dcompiler_47=n as instructed by the linux ReShade installer.", () => Program.Config.ReShadeFix ?? false, b => Program.Config.ReShadeFix = b), new SettingsEntry("WINEDEBUG Variables", "Configure debug logging for wine. Useful for troubleshooting.", () => Program.Config.WineDebugVars ?? string.Empty, s => Program.Config.WineDebugVars = s) }; } @@ -75,7 +80,7 @@ public override void Draw() if (ImGui.Button("Open prefix")) { - PlatformHelpers.OpenBrowser(Program.CompatibilityTools.Settings.Prefix.FullName); + PlatformHelpers.OpenBrowser(Program.CompatibilityTools.Prefix.FullName); } ImGui.SameLine(); diff --git a/src/XIVLauncher.Core/Configuration/ILauncherConfig.cs b/src/XIVLauncher.Core/Configuration/ILauncherConfig.cs index 026666d8..281eed80 100644 --- a/src/XIVLauncher.Core/Configuration/ILauncherConfig.cs +++ b/src/XIVLauncher.Core/Configuration/ILauncherConfig.cs @@ -3,6 +3,7 @@ using XIVLauncher.Common.Dalamud; using XIVLauncher.Common.Game.Patch.Acquisition; using XIVLauncher.Common.Unix.Compatibility; +using XIVLauncher.Core.Runners; namespace XIVLauncher.Core.Configuration; @@ -62,7 +63,11 @@ public interface ILauncherConfig #region Linux - public WineStartupType? WineStartupType { get; set; } + public WineType? WineType { get; set; } + + public WineVersion? WineVersion { get; set; } + + public DxvkVersion? DxvkVersion { get; set; } public string? WineBinaryPath { get; set; } @@ -74,7 +79,15 @@ public interface ILauncherConfig public bool? FSyncEnabled { get; set; } - public Dxvk.DxvkHudType DxvkHudType { get; set; } + public DxvkHudType DxvkHudType { get; set; } + + public string? DxvkHudCustom { get; set; } + + public string? DxvkMangoCustom { get; set; } + + public int? DxvkFrameRate { get; set; } + + public bool? ReShadeFix { get; set; } public string? WineDebugVars { get; set; } diff --git a/src/XIVLauncher.Core/Program.cs b/src/XIVLauncher.Core/Program.cs index fb43c617..6cfb3687 100644 --- a/src/XIVLauncher.Core/Program.cs +++ b/src/XIVLauncher.Core/Program.cs @@ -21,6 +21,7 @@ using XIVLauncher.Core.Components.LoadingPage; using XIVLauncher.Core.Configuration; using XIVLauncher.Core.Configuration.Parsers; +using XIVLauncher.Core.Runners; namespace XIVLauncher.Core; @@ -108,11 +109,16 @@ private static void LoadConfig(Storage storage) Config.GlobalScale ??= 1.0f; Config.GameModeEnabled ??= false; + Config.ReShadeFix ??= false; + Config.DxvkVersion ??= DxvkVersion.v1_10_3; Config.DxvkAsyncEnabled ??= true; + Config.DxvkFrameRate ??= 0; Config.ESyncEnabled ??= true; Config.FSyncEnabled ??= false; + Config.DxvkHudCustom ??= "fps,frametimes,gpuload,version"; + Config.DxvkMangoCustom ??= Path.Combine(Environment.GetEnvironmentVariable("HOME"), ".config", "MangoHud", "MangoHud.conf"); - Config.WineStartupType ??= WineStartupType.Managed; + Config.WineType ??= WineType.Managed; Config.WineBinaryPath ??= "/usr/bin"; Config.WineDebugVars ??= "-all"; } @@ -291,9 +297,24 @@ public static void CreateCompatToolsInstance() { var wineLogFile = new FileInfo(Path.Combine(storage.GetFolder("logs").FullName, "wine.log")); var winePrefix = storage.GetFolder("wineprefix"); - var wineSettings = new WineSettings(Config.WineStartupType, Config.WineBinaryPath, Config.WineDebugVars, wineLogFile, winePrefix, Config.ESyncEnabled, Config.FSyncEnabled); var toolsFolder = storage.GetFolder("compatibilitytool"); - CompatibilityTools = new CompatibilityTools(wineSettings, Config.DxvkHudType, Config.GameModeEnabled, Config.DxvkAsyncEnabled, toolsFolder); + Wine.Initialize(); + Dxvk.Initialize(); + var wineoverride = "msquic=,mscoree=n,b;"; + var wineenv = new Dictionary(); + if (Dxvk.Settings is null) + { + wineoverride += "d3d9,d3d11,d3d10core,dxgi=b"; + wineenv.Add("PROTON_USE_WINED3D", "1"); // needed for proton-based wine to work with WineD3D. + } + else + { + wineoverride = "d3d9,d3d11,d3d10core,dxgi=n,b"; + } + if (Config.ReShadeFix.Value) + wineoverride += ";d3dcompiler_47=n"; + var winepath = (Config.WineType == WineType.Custom) ? Config.WineBinaryPath : ""; + CompatibilityTools = new CompatibilityTools(winepath, Wine.Settings, Dxvk.Settings, wineenv, wineoverride, winePrefix, toolsFolder, wineLogFile); } public static void ShowWindow() diff --git a/src/XIVLauncher.Core/Runners/Dxvk.cs b/src/XIVLauncher.Core/Runners/Dxvk.cs new file mode 100644 index 00000000..a12eb784 --- /dev/null +++ b/src/XIVLauncher.Core/Runners/Dxvk.cs @@ -0,0 +1,194 @@ +using System; +using System.Collections.Generic; +using System.Collections.Specialized; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Text.RegularExpressions; +using Serilog; +using XIVLauncher.Common; +using XIVLauncher.Common.Unix.Compatibility; + +namespace XIVLauncher.Core.Runners; + +public enum DxvkVersion +{ + [SettingsDescription("1.10.3 (default)", "Current version of 1.10 branch of DXVK.")] + v1_10_3, + + [SettingsDescription("2.0", "Newer version of DXVK. Last version with Async patch")] + v2_0, + + [SettingsDescription("2.1 (No Async)", "Newer version of DXVK, using graphics pipeline library. No Async patch.")] + v2_1, + + [SettingsDescription("2.2 (No Async)", "Newest version of DXVK, using graphics pipeline library. No Async patch.")] + v2_2, + + [SettingsDescription("Disabled", "Disable Dxvk, use WineD3D / OpenGL instead.")] + Disabled, +} + +public enum DxvkHudType +{ + [SettingsDescription("None", "Show nothing")] + None, + + [SettingsDescription("FPS", "Only show FPS")] + Fps, + + [SettingsDescription("DXVK Hud Custom", "Use a custom DXVK_HUD string")] + Custom, + + [SettingsDescription("Full", "Show everything")] + Full, + + [SettingsDescription("MangoHud Default", "Uses no config file.")] + MangoHud, + + [SettingsDescription("MangoHud Custom", "Specify a custom config file")] + MangoHudCustom, + + [SettingsDescription("MangoHud Full", "Show (almost) everything")] + MangoHudFull, +} + +public static class Dxvk +{ + public static Runner Settings { get; private set; } + + private const string ALLOWED_CHARS = "^[0-9a-zA-Z,=.]+$"; + + private const string ALLOWED_WORDS = "^(?:devinfo|fps|frametimes|submissions|drawcalls|pipelines|descriptors|memory|gpuload|version|api|cs|compiler|samplers|scale=(?:[0-9])*(?:.(?:[0-9])+)?)$"; + + + public static void Initialize() + { + if (Program.Config.DxvkVersion == DxvkVersion.Disabled) + { + Settings = null; + return; + } + + var folder = ""; + var url = ""; + var rootfolder = Program.storage.Root.FullName; + var dxvkfolder = Path.Combine(rootfolder, "compatibilitytool", "dxvk"); + var async = (Program.Config.DxvkAsyncEnabled ?? true) ? "1" : "0"; + var framerate = Program.Config.DxvkFrameRate ?? 0; + var env = new Dictionary + { + { "DXVK_LOG_PATH", Path.Combine(rootfolder, "logs") }, + { "DXVK_CONFIG_FILE", Path.Combine(dxvkfolder, "dxvk.conf") }, + }; + if (framerate != 0) + env.Add("DXVK_FRAME_RATE", framerate.ToString()); + switch (Program.Config.DxvkVersion) + { + case DxvkVersion.v1_10_3: + folder = "dxvk-async-1.10.3"; + url = "https://github.com/Sporif/dxvk-async/releases/download/1.10.3/dxvk-async-1.10.3.tar.gz"; + env.Add("DXVK_ASYNC", async); + break; + + case DxvkVersion.v2_0: + folder = "dxvk-async-2.0"; + url = "https://github.com/Sporif/dxvk-async/releases/download/2.0/dxvk-async-2.0.tar.gz"; + env.Add("DXVK_ASYNC", async); + break; + + case DxvkVersion.v2_1: + folder = "dxvk-2.1"; + url = "https://github.com/doitsujin/dxvk/releases/download/v2.1/dxvk-2.1.tar.gz"; + break; + + case DxvkVersion.v2_2: + folder = "dxvk-2.2"; + url = "https://github.com/doitsujin/dxvk/releases/download/v2.2/dxvk-2.2.tar.gz"; + break; + + default: + throw new ArgumentOutOfRangeException("Bad Value for DxvkVersion"); + } + + var dxvkCachePath = new DirectoryInfo(Path.Combine(dxvkfolder, "cache")); + if (!dxvkCachePath.Exists) dxvkCachePath.Create(); + env.Add("DXVK_STATE_CACHE_PATH", Path.Combine(dxvkCachePath.FullName, folder)); + + var dxvkHudCustom = Program.Config.DxvkHudCustom ?? "fps,frametimes,gpuload,version"; + var mangoHudConfig = string.IsNullOrEmpty(Program.Config.DxvkMangoCustom) ? null : new FileInfo(Program.Config.DxvkMangoCustom); + switch (Program.Config.DxvkHudType) + { + case DxvkHudType.Fps: + env.Add("DXVK_HUD","fps"); + env.Add("MANGOHUD","0"); + break; + + case DxvkHudType.Custom: + if (!CheckDxvkHudString(Program.Config.DxvkHudCustom)) + dxvkHudCustom = "fps,frametimes,gpuload,version"; + env.Add("DXVK_HUD", Program.Config.DxvkHudCustom); + env.Add("MANGOHUD","0"); + break; + + case DxvkHudType.Full: + env.Add("DXVK_HUD","full"); + env.Add("MANGOHUD","0"); + break; + + case DxvkHudType.MangoHud: + env.Add("DXVK_HUD","0"); + env.Add("MANGOHUD","1"); + env.Add("MANGOHUD_CONFIG", ""); + break; + + case DxvkHudType.MangoHudCustom: + env.Add("DXVK_HUD","0"); + env.Add("MANGOHUD","1"); + + if (mangoHudConfig is null) + { + var home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); + var conf1 = Path.Combine(rootfolder, "MangoHud.conf"); + var conf2 = Path.Combine(home, ".config", "MangoHud", "wine-ffxiv_dx11.conf"); + var conf3 = Path.Combine(home, ".config", "MangoHud", "MangoHud.conf"); + if (File.Exists(conf1)) + mangoHudConfig = new FileInfo(conf1); + else if (File.Exists(conf2)) + mangoHudConfig = new FileInfo(conf2); + else if (File.Exists(conf3)) + mangoHudConfig = new FileInfo(conf3); + } + + if (mangoHudConfig is not null && mangoHudConfig.Exists) + env.Add("MANGOHUD_CONFIGFILE", mangoHudConfig.FullName); + else + env.Add("MANGOHUD_CONFIG", ""); + break; + + case DxvkHudType.MangoHudFull: + env.Add("DXVK_HUD","0"); + env.Add("MANGOHUD","1"); + env.Add("MANGOHUD_CONFIG","full"); + break; + + case DxvkHudType.None: + break; + + default: + throw new ArgumentOutOfRangeException(); + } + } + + public static bool CheckDxvkHudString(string? customHud) + { + if (string.IsNullOrWhiteSpace(customHud)) return false; + if (customHud == "1") return true; + if (!Regex.IsMatch(customHud,ALLOWED_CHARS)) return false; + + string[] hudvars = customHud.Split(","); + + return hudvars.All(hudvar => Regex.IsMatch(hudvar, ALLOWED_WORDS)); + } +} + diff --git a/src/XIVLauncher.Core/Runners/Wine.cs b/src/XIVLauncher.Core/Runners/Wine.cs new file mode 100644 index 00000000..84d58376 --- /dev/null +++ b/src/XIVLauncher.Core/Runners/Wine.cs @@ -0,0 +1,87 @@ +using System; +using System.Collections.Generic; +using System.Collections.Specialized; +using System.Diagnostics; +using System.IO; +using System.Linq; +using Serilog; +using XIVLauncher.Common; +using XIVLauncher.Common.Unix.Compatibility; + +namespace XIVLauncher.Core.Runners; + +public enum WineType +{ + [SettingsDescription("Managed by XIVLauncher", "The game installation and wine setup is managed by XIVLauncher - you can leave it up to us.")] + Managed, + + [SettingsDescription("User Managed", "Select from a list of patched wine versions. We'll download them for you.")] + Other, + + [SettingsDescription("Custom", "Point XIVLauncher to a custom location containing wine binaries to run the game with.")] + Custom, +} + +public enum WineVersion +{ + [SettingsDescription("Wine-xiv 8.5", "A patched version of Wine-staging 8.5. The current default.")] + Wine8_5, + + [SettingsDescription("Wine-xiv 7.10", "A legacy patched version of Wine, based on 7.10. A previous default")] + Wine7_10, +} + +public static class Wine +{ +#if WINE_XIV_ARCH_LINUX + private const string DISTRO = "arch"; +#elif WINE_XIV_FEDORA_LINUX + private const string DISTRO = "fedora"; +#else + private const string DISTRO = "ubuntu"; +#endif + + public static Runner Settings { get; private set; } + + public static void Initialize() + { + var version = (Program.Config.WineType == WineType.Managed) ? WineVersion.Wine8_5 : Program.Config.WineVersion; + var folder = ""; + var url = ""; + + switch (version) + { + case WineVersion.Wine8_5: + folder = "wine-xiv-staging-fsync-git-8.5.r4.g4211bac7"; + url = $"https://github.com/goatcorp/wine-xiv-git/releases/download/8.5.r4.g4211bac7/wine-xiv-staging-fsync-git-{DISTRO}-8.5.r4.g4211bac7.tar.xz"; + break; + + case WineVersion.Wine7_10: + folder = "wine-xiv-staging-fsync-git-7.10.r3.g560db77d"; + url = $"https://github.com/goatcorp/wine-xiv-git/releases/download/7.10.r3.g560db77d/wine-xiv-staging-fsync-git-{DISTRO}-7.10.r3.g560db77d.tar.xz"; + break; + + default: + throw new ArgumentOutOfRangeException("Bad value for WineVersion"); + } + + var env = new Dictionary(); + if (Program.Config.GameModeEnabled ?? false) + { + var ldPreload = Environment.GetEnvironmentVariable("LD_PRELOAD") ?? ""; + if (!ldPreload.Contains("libgamemodeauto.so.0")) + ldPreload = (ldPreload.Equals("")) ? "libgamemodeaudo.so" : ldPreload + ":libgamemodeauto.so.0"; + env.Add("LD_PRELOAD", ldPreload); + } + if (!string.IsNullOrEmpty(Program.Config.WineDebugVars)) + env.Add("WINEDEBUG", Program.Config.WineDebugVars); + if (Program.Config.ESyncEnabled ?? true) env.Add("WINEESYNC", "1"); + if (Program.Config.FSyncEnabled ?? false) env.Add("WINEFSYNC", "1"); + + Settings = new Runner(folder, url, env); + } +} + + + + From 903ee25bf008f2aaffec965b003bc5dcd2f0d0bd Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Sat, 17 Jun 2023 01:05:21 -0700 Subject: [PATCH 02/33] Reposition submodule --- lib/FFXIVQuickLauncher | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/FFXIVQuickLauncher b/lib/FFXIVQuickLauncher index 62fee287..77115d3f 160000 --- a/lib/FFXIVQuickLauncher +++ b/lib/FFXIVQuickLauncher @@ -1 +1 @@ -Subproject commit 62fee287329fe27cdf17106f562b2bf1ea3809c0 +Subproject commit 77115d3f7d920179ce83f0708ec97ba2450ce795 From 9b0587947fa0f0edfb7807385fd3710130da2649 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Sat, 17 Jun 2023 01:47:16 -0700 Subject: [PATCH 03/33] Minor fixes --- src/XIVLauncher.Core/Runners/Dxvk.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/XIVLauncher.Core/Runners/Dxvk.cs b/src/XIVLauncher.Core/Runners/Dxvk.cs index a12eb784..ab56ca4e 100644 --- a/src/XIVLauncher.Core/Runners/Dxvk.cs +++ b/src/XIVLauncher.Core/Runners/Dxvk.cs @@ -178,6 +178,8 @@ public static void Initialize() default: throw new ArgumentOutOfRangeException(); } + + Settings = new Runner(folder, url, env); } public static bool CheckDxvkHudString(string? customHud) From e687d0346883e306b7f84a5828ed6767da10ee00 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Sat, 17 Jun 2023 01:51:08 -0700 Subject: [PATCH 04/33] Update submodule --- lib/FFXIVQuickLauncher | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/FFXIVQuickLauncher b/lib/FFXIVQuickLauncher index 77115d3f..6e29c1d9 160000 --- a/lib/FFXIVQuickLauncher +++ b/lib/FFXIVQuickLauncher @@ -1 +1 @@ -Subproject commit 77115d3f7d920179ce83f0708ec97ba2450ce795 +Subproject commit 6e29c1d90199b9eb36989a4f5e0259195b707794 From 3de5ce9a18d0fc9fa5a118446034d14e039c0d8a Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Sun, 18 Jun 2023 16:50:11 -0700 Subject: [PATCH 05/33] Move more login into runners --- .../Components/MainPage/MainPage.cs | 7 +- src/XIVLauncher.Core/Program.cs | 3 +- src/XIVLauncher.Core/Runners/Dxvk.cs | 5 +- src/XIVLauncher.Core/Runners/DxvkRunner.cs | 52 ++++++++++++ src/XIVLauncher.Core/Runners/Wine.cs | 24 +++++- src/XIVLauncher.Core/Runners/WineRunner.cs | 84 +++++++++++++++++++ 6 files changed, 164 insertions(+), 11 deletions(-) create mode 100644 src/XIVLauncher.Core/Runners/DxvkRunner.cs create mode 100644 src/XIVLauncher.Core/Runners/WineRunner.cs diff --git a/src/XIVLauncher.Core/Components/MainPage/MainPage.cs b/src/XIVLauncher.Core/Components/MainPage/MainPage.cs index 310d5d47..745b2f08 100644 --- a/src/XIVLauncher.Core/Components/MainPage/MainPage.cs +++ b/src/XIVLauncher.Core/Components/MainPage/MainPage.cs @@ -732,10 +732,6 @@ public async Task StartGameAndAddon(Launcher.LoginResult loginResult, b } } - var winver = (App.Settings.SetWin7 ?? true) ? "win7" : "win10"; - - Program.CompatibilityTools.RunInPrefix($"winecfg /v {winver}"); - if (Environment.OSVersion.Platform == PlatformID.Win32NT) { runner = new WindowsGameRunner(dalamudLauncher, dalamudOk, Program.DalamudUpdater.Runtime); @@ -760,9 +756,12 @@ public async Task StartGameAndAddon(Launcher.LoginResult loginResult, b var _ = Task.Run(async () => { var tempPath = App.Storage.GetFolder("temp"); + var winver = (App.Settings.SetWin7 ?? true) ? "win7" : "win10"; await Program.CompatibilityTools.EnsureTool(tempPath).ConfigureAwait(false); + Program.CompatibilityTools.RunInPrefix($"winecfg /v {winver}"); + var gameFixApply = new GameFixApply(App.Settings.GamePath, App.Settings.GameConfigPath, Program.CompatibilityTools.Prefix, tempPath); gameFixApply.UpdateProgress += (text, hasProgress, progress) => { diff --git a/src/XIVLauncher.Core/Program.cs b/src/XIVLauncher.Core/Program.cs index 2dfa2042..ae6ad1be 100644 --- a/src/XIVLauncher.Core/Program.cs +++ b/src/XIVLauncher.Core/Program.cs @@ -341,8 +341,7 @@ public static void CreateCompatToolsInstance() } if (Config.ReShadeFix.Value) wineoverride += ";d3dcompiler_47=n"; - var winepath = (Config.WineType == WineType.Custom) ? Config.WineBinaryPath : ""; - CompatibilityTools = new CompatibilityTools(winepath, Wine.Settings, Dxvk.Settings, wineenv, wineoverride, winePrefix, toolsFolder, wineLogFile); + CompatibilityTools = new CompatibilityTools(Wine.Settings, Dxvk.Settings, wineenv, wineoverride, winePrefix, toolsFolder, wineLogFile); } public static void ShowWindow() diff --git a/src/XIVLauncher.Core/Runners/Dxvk.cs b/src/XIVLauncher.Core/Runners/Dxvk.cs index ab56ca4e..5b495fa7 100644 --- a/src/XIVLauncher.Core/Runners/Dxvk.cs +++ b/src/XIVLauncher.Core/Runners/Dxvk.cs @@ -55,7 +55,7 @@ public enum DxvkHudType public static class Dxvk { - public static Runner Settings { get; private set; } + public static DxvkRunner Settings { get; private set; } private const string ALLOWED_CHARS = "^[0-9a-zA-Z,=.]+$"; @@ -179,7 +179,8 @@ public static void Initialize() throw new ArgumentOutOfRangeException(); } - Settings = new Runner(folder, url, env); + var prefix = new DirectoryInfo(Path.Combine(Program.storage.Root.FullName, "wineprefix")); + Settings = new DxvkRunner(folder, url, prefix, env); } public static bool CheckDxvkHudString(string? customHud) diff --git a/src/XIVLauncher.Core/Runners/DxvkRunner.cs b/src/XIVLauncher.Core/Runners/DxvkRunner.cs new file mode 100644 index 00000000..e8df6b54 --- /dev/null +++ b/src/XIVLauncher.Core/Runners/DxvkRunner.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.Collections.Specialized; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Net.Http; +using System.Threading.Tasks; +using Serilog; +using XIVLauncher.Common.Util; +using XIVLauncher.Common.Unix.Compatibility; + +namespace XIVLauncher.Core.Runners; + +public class DxvkRunner : Runner +{ + public override string RunnerType => "Dxvk"; + + private DirectoryInfo ToolFolder => new DirectoryInfo(Path.Combine(Program.storage.Root.FullName, "compatibilitytool", "dxvk")); + + public DxvkRunner(string folder, string url, DirectoryInfo prefix, Dictionary env = null) + : base(folder, url, prefix, env) + { } + + public override async Task Install() + { + if (IsDirectoryEmpty(Path.Combine(ToolFolder.FullName, Folder))) + { + if (string.IsNullOrEmpty(DownloadUrl)) + { + Log.Error($"Attempted to download runner {RunnerType} without a download Url."); + throw new InvalidOperationException($"{RunnerType} runner does not exist, and no download URL was provided for it."); + } + Log.Information($"{Folder} does not exist. Downloading..."); + using var client = new HttpClient(); + var tempPath = Path.GetTempFileName(); + + File.WriteAllBytes(tempPath, await client.GetByteArrayAsync(DownloadUrl)); + PlatformHelpers.Untar(tempPath, ToolFolder.FullName); + + File.Delete(tempPath); + } + + var prefixinstall = new DirectoryInfo(Path.Combine(Prefix.FullName, "drive_c", "windows", "system32")); + var files = new DirectoryInfo(Path.Combine(ToolFolder.FullName, Folder, "x64")).GetFiles(); + + foreach (FileInfo fileName in files) + { + fileName.CopyTo(Path.Combine(prefixinstall.FullName, fileName.Name), true); + } + } +} \ No newline at end of file diff --git a/src/XIVLauncher.Core/Runners/Wine.cs b/src/XIVLauncher.Core/Runners/Wine.cs index 84d58376..a7515b6d 100644 --- a/src/XIVLauncher.Core/Runners/Wine.cs +++ b/src/XIVLauncher.Core/Runners/Wine.cs @@ -41,13 +41,31 @@ public static class Wine private const string DISTRO = "ubuntu"; #endif - public static Runner Settings { get; private set; } + public static WineRunner Settings { get; private set; } public static void Initialize() { - var version = (Program.Config.WineType == WineType.Managed) ? WineVersion.Wine8_5 : Program.Config.WineVersion; + var winepath = ""; var folder = ""; var url = ""; + var prefix = new DirectoryInfo(Path.Combine(Program.storage.Root.FullName, "wineprefix")); + var version = WineVersion.Wine8_5; + switch (Program.Config.WineType ?? WineType.Managed) + { + case WineType.Custom: + winepath = Program.Config.WineBinaryPath ?? "/usr/bin"; + break; + + case WineType.Managed: + break; + + case WineType.Other: + version = Program.Config.WineVersion ?? WineVersion.Wine8_5; + break; + + default: + throw new ArgumentOutOfRangeException("Bad value for WineVersion"); + } switch (version) { @@ -78,7 +96,7 @@ public static void Initialize() if (Program.Config.ESyncEnabled ?? true) env.Add("WINEESYNC", "1"); if (Program.Config.FSyncEnabled ?? false) env.Add("WINEFSYNC", "1"); - Settings = new Runner(folder, url, env); + Settings = new WineRunner(winepath, folder, url, Program.storage.Root, env); } } diff --git a/src/XIVLauncher.Core/Runners/WineRunner.cs b/src/XIVLauncher.Core/Runners/WineRunner.cs new file mode 100644 index 00000000..e950f0b7 --- /dev/null +++ b/src/XIVLauncher.Core/Runners/WineRunner.cs @@ -0,0 +1,84 @@ +using System; +using System.Collections.Generic; +using System.Collections.Specialized; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Net.Http; +using System.Threading.Tasks; +using Serilog; +using XIVLauncher.Common.Util; +using XIVLauncher.Common.Unix.Compatibility; + +namespace XIVLauncher.Core.Runners; + +public class WineRunner : Runner +{ + public override string RunnerType => "Wine"; + + private string WinePath; + + private string WineServerPath; + + private DirectoryInfo ToolFolder => new DirectoryInfo(Path.Combine(Program.storage.Root.FullName, "compatibilitytool", "wine")); + + private string WineServer => Path.Combine(ToolFolder.FullName, "wine", Folder, "bin", "wineserver"); + + public WineRunner(string winepath, string folder, string url, DirectoryInfo prefix, Dictionary env = null) + : base(folder, url, prefix, env) + { + if (string.IsNullOrEmpty(winepath)) + { + WinePath = Path.Combine(ToolFolder.FullName, Folder, "bin", "wine64"); + WineServerPath = Path.Combine(ToolFolder.FullName, Folder, "bin", "wineserver"); + } + else + { + WinePath = Path.Combine(winepath, "wine64"); + WineServerPath = Path.Combine(winepath, "wineserver"); + } + } + + public override async Task Install() + { + if (IsDirectoryEmpty(Path.Combine(ToolFolder.FullName, Folder))) + { + Log.Information($"Downloading Tool to {ToolFolder.FullName}"); + if (string.IsNullOrEmpty(DownloadUrl)) + { + Log.Error($"Attempted to download runner {RunnerType} without a download Url."); + throw new InvalidOperationException($"{RunnerType} runner does not exist, and no download URL was provided for it."); + } + Log.Information($"{Folder} does not exist. Downloading..."); + using var client = new HttpClient(); + var tempPath = Path.GetTempFileName(); + + File.WriteAllBytes(tempPath, await client.GetByteArrayAsync(DownloadUrl)); + PlatformHelpers.Untar(tempPath, ToolFolder.FullName); + + File.Delete(tempPath); + } + else + Log.Information("Did not try to download Wine."); + } + + public override string GetCommand() + { + return WinePath; + } + + public override string GetServer() + { + return WineServer; + } + + public override string GetPathCommand() + { + return GetCommand(); + } + + public override string GetPathParameters(string unixPath) + { + return $"winepath --windows {unixPath}"; + } +} \ No newline at end of file From 3a7aca88c73c8b94e21482323645791d915d4c97 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Wed, 21 Jun 2023 21:23:57 -0700 Subject: [PATCH 06/33] More work done --- lib/FFXIVQuickLauncher | 2 +- .../Components/MainPage/MainPage.cs | 8 ++++ .../SettingsPage/Tabs/SettingsTabDxvk.cs | 19 +++++++-- .../Tabs/SettingsTabTroubleshooting.cs | 12 +++--- .../SettingsPage/Tabs/SettingsTabWine.cs | 5 +-- .../Configuration/ILauncherConfig.cs | 4 +- src/XIVLauncher.Core/Program.cs | 17 ++++---- .../Runners/{Dxvk.cs => DxvkManager.cs} | 41 +++++++++++-------- src/XIVLauncher.Core/Runners/DxvkRunner.cs | 2 +- .../Runners/{Wine.cs => WineManager.cs} | 9 ++-- src/XIVLauncher.Core/Runners/WineRunner.cs | 39 ++++++------------ 11 files changed, 82 insertions(+), 76 deletions(-) rename src/XIVLauncher.Core/Runners/{Dxvk.cs => DxvkManager.cs} (86%) rename src/XIVLauncher.Core/Runners/{Wine.cs => WineManager.cs} (94%) diff --git a/lib/FFXIVQuickLauncher b/lib/FFXIVQuickLauncher index 6e29c1d9..99f8d750 160000 --- a/lib/FFXIVQuickLauncher +++ b/lib/FFXIVQuickLauncher @@ -1 +1 @@ -Subproject commit 6e29c1d90199b9eb36989a4f5e0259195b707794 +Subproject commit 99f8d750208da000603ec6d5799c66e585f77b9f diff --git a/src/XIVLauncher.Core/Components/MainPage/MainPage.cs b/src/XIVLauncher.Core/Components/MainPage/MainPage.cs index 745b2f08..539b19d2 100644 --- a/src/XIVLauncher.Core/Components/MainPage/MainPage.cs +++ b/src/XIVLauncher.Core/Components/MainPage/MainPage.cs @@ -760,6 +760,14 @@ public async Task StartGameAndAddon(Launcher.LoginResult loginResult, b await Program.CompatibilityTools.EnsureTool(tempPath).ConfigureAwait(false); + if (Program.Config.DxvkVersion == DxvkVersion.Disabled) + { + if (Program.Config.WineD3DUseVK ?? false) + Program.CompatibilityTools.AddRegistryKey("HKEY_CURRENT_USER\\Software\\Wine\\Direct3D", "renderer", "vulkan"); + else + Program.CompatibilityTools.AddRegistryKey("HKEY_CURRENT_USER\\Software\\Wine\\Direct3D", "renderer", "gl"); + } + Program.CompatibilityTools.RunInPrefix($"winecfg /v {winver}"); var gameFixApply = new GameFixApply(App.Settings.GamePath, App.Settings.GameConfigPath, Program.CompatibilityTools.Prefix, tempPath); diff --git a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDxvk.cs b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDxvk.cs index 383956cb..58cd3259 100644 --- a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDxvk.cs +++ b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDxvk.cs @@ -11,6 +11,7 @@ namespace XIVLauncher.Core.Components.SettingsPage.Tabs; public class SettingsTabDxvk : SettingsTab { private SettingsEntry dxvkVersionSetting; + private SettingsEntry wineD3DUseVk; private SettingsEntry dxvkHudSetting; public SettingsTabDxvk() @@ -26,6 +27,16 @@ public SettingsTabDxvk() return null; }, }, + wineD3DUseVk = new SettingsEntry("Use WineD3D Vulkan renderer", "Use Vulkan instead of OpenGL for WineD3D. Unstable. May cause system to lock up.", () => Program.Config.WineD3DUseVK ?? false, b => Program.Config.WineD3DUseVK = b) + { + CheckVisibility = () => dxvkVersionSetting.Value == DxvkVersion.Disabled, + CheckWarning = b => + { + if (b) + return "WARNING! This is very experimental, and may cause your system to crash or hang. If you still want to use it, disable Dalamud."; + return null; + }, + }, new SettingsEntry("Enable DXVK ASYNC", "Enable DXVK ASYNC patch.", () => Program.Config.DxvkAsyncEnabled ?? true, b => Program.Config.DxvkAsyncEnabled = b) { CheckVisibility = () => (new [] {DxvkVersion.v1_10_3, DxvkVersion.v2_0}.Contains(dxvkVersionSetting.Value)), @@ -36,9 +47,9 @@ public SettingsTabDxvk() return null; }, }, - dxvkHudSetting = new SettingsEntry("DXVK Overlay", "DXVK Hud is included. MangoHud must be installed separately.\nFlatpak XIVLauncher needs flatpak MangoHud.", () => Program.Config.DxvkHudType, type => Program.Config.DxvkHudType = type) + dxvkHudSetting = new SettingsEntry("DXVK Overlay", "DXVK Hud is included with Dxvk. It doesn't work if Dxvk is disabled.\nMangoHud must be installed separately. Flatpak XIVLauncher needs flatpak MangoHud.", () => Program.Config.DxvkHudType, type => Program.Config.DxvkHudType = type) { - CheckVisibility = () => dxvkVersionSetting.Value != DxvkVersion.Disabled, + CheckVisibility = () => dxvkVersionSetting.Value != DxvkVersion.Disabled || wineD3DUseVk.Value, CheckValidity = type => { if ((type == DxvkHudType.MangoHud || type == DxvkHudType.MangoHudCustom || type == DxvkHudType.MangoHudFull) @@ -53,14 +64,14 @@ public SettingsTabDxvk() CheckVisibility = () => dxvkHudSetting.Value == DxvkHudType.Custom && dxvkVersionSetting.Value != DxvkVersion.Disabled, CheckWarning = s => { - if(!Dxvk.CheckDxvkHudString(s)) + if(!DxvkManager.CheckDxvkHudString(s)) return "That's not a valid hud string"; return null; }, }, new SettingsEntry("MangoHud Custom Path", "Set a custom path for MangoHud config file.", () => Program.Config.DxvkMangoCustom, s => Program.Config.DxvkMangoCustom = s) { - CheckVisibility = () => dxvkHudSetting.Value == DxvkHudType.MangoHudCustom && dxvkVersionSetting.Value != DxvkVersion.Disabled, + CheckVisibility = () => dxvkHudSetting.Value == DxvkHudType.MangoHudCustom && dxvkVersionSetting.Value != DxvkVersion.Disabled, CheckWarning = s => { if(!File.Exists(s)) diff --git a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabTroubleshooting.cs b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabTroubleshooting.cs index c3f4f153..db8ad99c 100644 --- a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabTroubleshooting.cs +++ b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabTroubleshooting.cs @@ -25,12 +25,6 @@ public override void Draw() ImGui.Separator(); - ImGui.Text("\nReset settings to default."); - if (ImGui.Button("Clear Settings")) - { - Program.ClearSettings(true); - } - ImGui.Text("\nClear the Wine Prefix - delete the ~/.xlcore/wineprefix folder"); if (ImGui.Button("Clear Prefix")) { @@ -55,6 +49,12 @@ public override void Draw() Program.ClearLogs(true); } + ImGui.Text("\nReset settings to default."); + if (ImGui.Button("Clear Settings")) + { + Program.ClearSettings(true); + } + ImGui.Text("\nDo all of the above."); if (ImGui.Button("Clear Everything")) { diff --git a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabWine.cs b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabWine.cs index eadde8ec..4e0f027d 100644 --- a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabWine.cs +++ b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabWine.cs @@ -55,10 +55,7 @@ public SettingsTabWine() return null; } }, - new SettingsEntry("Enable ReShade Fix", "Passes d3dcompiler_47=n as instructed by the linux ReShade installer.", () => Program.Config.ReShadeFix ?? false, b => Program.Config.ReShadeFix = b), - - new SettingsEntry("Set Windows version to 7", "Default for Wine 8.1+ is Windows 10, but this causes issues with some Dalamud plugins. Windows 7 is recommended for now.", () => Program.Config.SetWin7 ?? true, b => Program.Config.SetWin7 = b), - + new SettingsEntry("Set Windows version to 7", "Default for Wine 8.1+ is Windows 10, but this can cause issues with some Dalamud plugins. Windows 7 is recommended for now.", () => Program.Config.SetWin7 ?? true, b => Program.Config.SetWin7 = b), new SettingsEntry("WINEDEBUG Variables", "Configure debug logging for wine. Useful for troubleshooting.", () => Program.Config.WineDebugVars ?? string.Empty, s => Program.Config.WineDebugVars = s) }; } diff --git a/src/XIVLauncher.Core/Configuration/ILauncherConfig.cs b/src/XIVLauncher.Core/Configuration/ILauncherConfig.cs index 35b027ce..7c0c254c 100644 --- a/src/XIVLauncher.Core/Configuration/ILauncherConfig.cs +++ b/src/XIVLauncher.Core/Configuration/ILauncherConfig.cs @@ -69,6 +69,8 @@ public interface ILauncherConfig public DxvkVersion? DxvkVersion { get; set; } + public bool? WineD3DUseVK { get; set; } + public string? WineBinaryPath { get; set; } public bool? GameModeEnabled { get; set; } @@ -87,8 +89,6 @@ public interface ILauncherConfig public int? DxvkFrameRate { get; set; } - public bool? ReShadeFix { get; set; } - public string? WineDebugVars { get; set; } public bool? FixLDP { get; set; } diff --git a/src/XIVLauncher.Core/Program.cs b/src/XIVLauncher.Core/Program.cs index ae6ad1be..c2f52fe4 100644 --- a/src/XIVLauncher.Core/Program.cs +++ b/src/XIVLauncher.Core/Program.cs @@ -116,8 +116,8 @@ private static void LoadConfig(Storage storage) Config.GlobalScale ??= 1.0f; Config.GameModeEnabled ??= false; - Config.ReShadeFix ??= false; Config.DxvkVersion ??= DxvkVersion.v1_10_3; + Config.WineD3DUseVK ??= false; Config.DxvkAsyncEnabled ??= true; Config.DxvkFrameRate ??= 0; Config.ESyncEnabled ??= true; @@ -326,22 +326,19 @@ public static void CreateCompatToolsInstance() var wineLogFile = new FileInfo(Path.Combine(storage.GetFolder("logs").FullName, "wine.log")); var winePrefix = storage.GetFolder("wineprefix"); var toolsFolder = storage.GetFolder("compatibilitytool"); - Wine.Initialize(); - Dxvk.Initialize(); - var wineoverride = "msquic=,mscoree=n,b;"; + var wine = WineManager.Initialize(); + var dxvk = DxvkManager.Initialize(); + var wineoverride = "msquic,mscoree=n,b;"; var wineenv = new Dictionary(); - if (Dxvk.Settings is null) + if (dxvk.RunnerType == "WineD3D") { wineoverride += "d3d9,d3d11,d3d10core,dxgi=b"; - wineenv.Add("PROTON_USE_WINED3D", "1"); // needed for proton-based wine to work with WineD3D. } else { wineoverride = "d3d9,d3d11,d3d10core,dxgi=n,b"; } - if (Config.ReShadeFix.Value) - wineoverride += ";d3dcompiler_47=n"; - CompatibilityTools = new CompatibilityTools(Wine.Settings, Dxvk.Settings, wineenv, wineoverride, winePrefix, toolsFolder, wineLogFile); + CompatibilityTools = new CompatibilityTools(wine, dxvk, wineenv, wineoverride, winePrefix, toolsFolder, wineLogFile); } public static void ShowWindow() @@ -429,7 +426,7 @@ public static void ClearPlugins(bool tsbutton = false) public static void ClearTools(bool tsbutton = false) { storage.GetFolder("compatibilitytool").Delete(true); - storage.GetFolder("compatibilitytool/beta"); + storage.GetFolder("compatibilitytool/wine"); storage.GetFolder("compatibilitytool/dxvk"); if (tsbutton) CreateCompatToolsInstance(); } diff --git a/src/XIVLauncher.Core/Runners/Dxvk.cs b/src/XIVLauncher.Core/Runners/DxvkManager.cs similarity index 86% rename from src/XIVLauncher.Core/Runners/Dxvk.cs rename to src/XIVLauncher.Core/Runners/DxvkManager.cs index 5b495fa7..5bb98b68 100644 --- a/src/XIVLauncher.Core/Runners/Dxvk.cs +++ b/src/XIVLauncher.Core/Runners/DxvkManager.cs @@ -53,23 +53,16 @@ public enum DxvkHudType MangoHudFull, } -public static class Dxvk +public static class DxvkManager { - public static DxvkRunner Settings { get; private set; } - private const string ALLOWED_CHARS = "^[0-9a-zA-Z,=.]+$"; private const string ALLOWED_WORDS = "^(?:devinfo|fps|frametimes|submissions|drawcalls|pipelines|descriptors|memory|gpuload|version|api|cs|compiler|samplers|scale=(?:[0-9])*(?:.(?:[0-9])+)?)$"; - public static void Initialize() + public static DxvkRunner Initialize() { - if (Program.Config.DxvkVersion == DxvkVersion.Disabled) - { - Settings = null; - return; - } - + var runnerType = "Dxvk"; var folder = ""; var url = ""; var rootfolder = Program.storage.Root.FullName; @@ -108,16 +101,30 @@ public static void Initialize() break; default: - throw new ArgumentOutOfRangeException("Bad Value for DxvkVersion"); + env.Add("PROTON_USE_WINED3D", "1"); + runnerType = "WineD3D"; + env.Add("MANGHUD_DLSYM", "1"); + break; } - var dxvkCachePath = new DirectoryInfo(Path.Combine(dxvkfolder, "cache")); - if (!dxvkCachePath.Exists) dxvkCachePath.Create(); - env.Add("DXVK_STATE_CACHE_PATH", Path.Combine(dxvkCachePath.FullName, folder)); + if (runnerType == "Dxvk") + { + var dxvkCachePath = new DirectoryInfo(Path.Combine(dxvkfolder, "cache")); + if (!dxvkCachePath.Exists) dxvkCachePath.Create(); + env.Add("DXVK_STATE_CACHE_PATH", Path.Combine(dxvkCachePath.FullName, folder)); + } + var hudType = Program.Config.DxvkHudType; + if (Program.Config.DxvkVersion == DxvkVersion.Disabled) + { + if (!Program.Config.WineD3DUseVK.Value) + hudType = DxvkHudType.None; + else if (new [] {DxvkHudType.Custom, DxvkHudType.Fps, DxvkHudType.Full}.Contains(Program.Config.DxvkHudType)) + hudType = DxvkHudType.None; + } var dxvkHudCustom = Program.Config.DxvkHudCustom ?? "fps,frametimes,gpuload,version"; var mangoHudConfig = string.IsNullOrEmpty(Program.Config.DxvkMangoCustom) ? null : new FileInfo(Program.Config.DxvkMangoCustom); - switch (Program.Config.DxvkHudType) + switch (hudType) { case DxvkHudType.Fps: env.Add("DXVK_HUD","fps"); @@ -180,7 +187,9 @@ public static void Initialize() } var prefix = new DirectoryInfo(Path.Combine(Program.storage.Root.FullName, "wineprefix")); - Settings = new DxvkRunner(folder, url, prefix, env); + var settings = new DxvkRunner(folder, url, prefix, env); + settings.RunnerType = runnerType; + return settings; } public static bool CheckDxvkHudString(string? customHud) diff --git a/src/XIVLauncher.Core/Runners/DxvkRunner.cs b/src/XIVLauncher.Core/Runners/DxvkRunner.cs index e8df6b54..600681a8 100644 --- a/src/XIVLauncher.Core/Runners/DxvkRunner.cs +++ b/src/XIVLauncher.Core/Runners/DxvkRunner.cs @@ -14,7 +14,7 @@ namespace XIVLauncher.Core.Runners; public class DxvkRunner : Runner { - public override string RunnerType => "Dxvk"; + public override string RunnerType { get; set; } private DirectoryInfo ToolFolder => new DirectoryInfo(Path.Combine(Program.storage.Root.FullName, "compatibilitytool", "dxvk")); diff --git a/src/XIVLauncher.Core/Runners/Wine.cs b/src/XIVLauncher.Core/Runners/WineManager.cs similarity index 94% rename from src/XIVLauncher.Core/Runners/Wine.cs rename to src/XIVLauncher.Core/Runners/WineManager.cs index a7515b6d..b268a263 100644 --- a/src/XIVLauncher.Core/Runners/Wine.cs +++ b/src/XIVLauncher.Core/Runners/WineManager.cs @@ -31,7 +31,7 @@ public enum WineVersion Wine7_10, } -public static class Wine +public static class WineManager { #if WINE_XIV_ARCH_LINUX private const string DISTRO = "arch"; @@ -41,11 +41,10 @@ public static class Wine private const string DISTRO = "ubuntu"; #endif - public static WineRunner Settings { get; private set; } - - public static void Initialize() + public static WineRunner Initialize() { var winepath = ""; + var wineargs = ""; var folder = ""; var url = ""; var prefix = new DirectoryInfo(Path.Combine(Program.storage.Root.FullName, "wineprefix")); @@ -96,7 +95,7 @@ public static void Initialize() if (Program.Config.ESyncEnabled ?? true) env.Add("WINEESYNC", "1"); if (Program.Config.FSyncEnabled ?? false) env.Add("WINEFSYNC", "1"); - Settings = new WineRunner(winepath, folder, url, Program.storage.Root, env); + return new WineRunner(winepath, wineargs, folder, url, Program.storage.Root, env); } } diff --git a/src/XIVLauncher.Core/Runners/WineRunner.cs b/src/XIVLauncher.Core/Runners/WineRunner.cs index e950f0b7..0857ef12 100644 --- a/src/XIVLauncher.Core/Runners/WineRunner.cs +++ b/src/XIVLauncher.Core/Runners/WineRunner.cs @@ -16,27 +16,32 @@ public class WineRunner : Runner { public override string RunnerType => "Wine"; - private string WinePath; + public override string RunCommand { get; } - private string WineServerPath; + public override string RunArguments { get; } + + public override string Server { get; } + + public override string PathArguments => "winepath --windows"; private DirectoryInfo ToolFolder => new DirectoryInfo(Path.Combine(Program.storage.Root.FullName, "compatibilitytool", "wine")); private string WineServer => Path.Combine(ToolFolder.FullName, "wine", Folder, "bin", "wineserver"); - public WineRunner(string winepath, string folder, string url, DirectoryInfo prefix, Dictionary env = null) + public WineRunner(string winepath, string wineargs, string folder, string url, DirectoryInfo prefix, Dictionary env = null) : base(folder, url, prefix, env) { if (string.IsNullOrEmpty(winepath)) { - WinePath = Path.Combine(ToolFolder.FullName, Folder, "bin", "wine64"); - WineServerPath = Path.Combine(ToolFolder.FullName, Folder, "bin", "wineserver"); + RunCommand = Path.Combine(ToolFolder.FullName, Folder, "bin", "wine64"); + Server = Path.Combine(ToolFolder.FullName, Folder, "bin", "wineserver"); } else { - WinePath = Path.Combine(winepath, "wine64"); - WineServerPath = Path.Combine(winepath, "wineserver"); + RunCommand = Path.Combine(winepath, "wine64"); + Server = Path.Combine(winepath, "wineserver"); } + RunArguments = wineargs; } public override async Task Install() @@ -61,24 +66,4 @@ public override async Task Install() else Log.Information("Did not try to download Wine."); } - - public override string GetCommand() - { - return WinePath; - } - - public override string GetServer() - { - return WineServer; - } - - public override string GetPathCommand() - { - return GetCommand(); - } - - public override string GetPathParameters(string unixPath) - { - return $"winepath --windows {unixPath}"; - } } \ No newline at end of file From c522e0f0e0f8418422f692214e5942985e94ccd2 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Fri, 23 Jun 2023 18:01:37 -0700 Subject: [PATCH 07/33] Move WineRunner, DxvkRunner to FFQL repo --- lib/FFXIVQuickLauncher | 2 +- .../Components/MainPage/MainPage.cs | 5 +- .../SettingsPage/Tabs/SettingsTabDxvk.cs | 3 +- .../SettingsPage/Tabs/SettingsTabWine.cs | 3 +- .../Configuration/ILauncherConfig.cs | 1 - .../{Runners => }/DxvkManager.cs | 20 +++--- src/XIVLauncher.Core/Program.cs | 9 ++- src/XIVLauncher.Core/Runners/DxvkRunner.cs | 52 -------------- src/XIVLauncher.Core/Runners/WineRunner.cs | 69 ------------------- .../{Runners => }/WineManager.cs | 19 ++--- 10 files changed, 26 insertions(+), 157 deletions(-) rename src/XIVLauncher.Core/{Runners => }/DxvkManager.cs (94%) delete mode 100644 src/XIVLauncher.Core/Runners/DxvkRunner.cs delete mode 100644 src/XIVLauncher.Core/Runners/WineRunner.cs rename src/XIVLauncher.Core/{Runners => }/WineManager.cs (82%) diff --git a/lib/FFXIVQuickLauncher b/lib/FFXIVQuickLauncher index 99f8d750..06344824 160000 --- a/lib/FFXIVQuickLauncher +++ b/lib/FFXIVQuickLauncher @@ -1 +1 @@ -Subproject commit 99f8d750208da000603ec6d5799c66e585f77b9f +Subproject commit 06344824f733a083fdbca96092a8513b772bfdc0 diff --git a/src/XIVLauncher.Core/Components/MainPage/MainPage.cs b/src/XIVLauncher.Core/Components/MainPage/MainPage.cs index 539b19d2..72218abf 100644 --- a/src/XIVLauncher.Core/Components/MainPage/MainPage.cs +++ b/src/XIVLauncher.Core/Components/MainPage/MainPage.cs @@ -19,7 +19,6 @@ using XIVLauncher.Core.Accounts; using XIVLauncher.Common.Game.Exceptions; using XIVLauncher.Core.Support; -using XIVLauncher.Core.Runners; namespace XIVLauncher.Core.Components.MainPage; @@ -745,8 +744,8 @@ public async Task StartGameAndAddon(Launcher.LoginResult loginResult, b else if (!Directory.Exists(App.Settings.WineBinaryPath)) throw new Exception("Custom wine binary path is invalid: no such directory.\n" + "Check path carefully for typos: " + App.Settings.WineBinaryPath); - else if (!File.Exists(Path.Combine(App.Settings.WineBinaryPath,"wine64"))) - throw new Exception("Custom wine binary path is invalid: no wine64 found at that location.\n" + + else if (!File.Exists(Path.Combine(App.Settings.WineBinaryPath, "wine64")) && !File.Exists(Path.Combine(App.Settings.WineBinaryPath, "wine"))) + throw new Exception("Custom wine binary path is invalid: no wine or wine64 found at that location.\n" + "Check path carefully for typos: " + App.Settings.WineBinaryPath); } diff --git a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDxvk.cs b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDxvk.cs index 58cd3259..c811942d 100644 --- a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDxvk.cs +++ b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDxvk.cs @@ -4,7 +4,6 @@ using ImGuiNET; using XIVLauncher.Common.Unix.Compatibility; using XIVLauncher.Common.Util; -using XIVLauncher.Core.Runners; namespace XIVLauncher.Core.Components.SettingsPage.Tabs; @@ -71,7 +70,7 @@ public SettingsTabDxvk() }, new SettingsEntry("MangoHud Custom Path", "Set a custom path for MangoHud config file.", () => Program.Config.DxvkMangoCustom, s => Program.Config.DxvkMangoCustom = s) { - CheckVisibility = () => dxvkHudSetting.Value == DxvkHudType.MangoHudCustom && dxvkVersionSetting.Value != DxvkVersion.Disabled, + CheckVisibility = () => dxvkHudSetting.Value == DxvkHudType.MangoHudCustom && !(dxvkVersionSetting.Value == DxvkVersion.Disabled && !wineD3DUseVk.Value), CheckWarning = s => { if(!File.Exists(s)) diff --git a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabWine.cs b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabWine.cs index 4e0f027d..a8125c63 100644 --- a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabWine.cs +++ b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabWine.cs @@ -3,7 +3,6 @@ using ImGuiNET; using XIVLauncher.Common.Unix.Compatibility; using XIVLauncher.Common.Util; -using XIVLauncher.Core.Runners; namespace XIVLauncher.Core.Components.SettingsPage.Tabs; @@ -20,7 +19,7 @@ public SettingsTabWine() new SettingsEntry("Wine Version", "Choose a patched wine version.", () => Program.Config.WineVersion ?? WineVersion.Wine8_5, x => Program.Config.WineVersion = x) { - CheckVisibility = () => startupTypeSetting.Value == WineType.Other + CheckVisibility = () => startupTypeSetting.Value == WineType.Managed }, new SettingsEntry("Wine Binary Path", diff --git a/src/XIVLauncher.Core/Configuration/ILauncherConfig.cs b/src/XIVLauncher.Core/Configuration/ILauncherConfig.cs index 7c0c254c..48afb0c1 100644 --- a/src/XIVLauncher.Core/Configuration/ILauncherConfig.cs +++ b/src/XIVLauncher.Core/Configuration/ILauncherConfig.cs @@ -3,7 +3,6 @@ using XIVLauncher.Common.Dalamud; using XIVLauncher.Common.Game.Patch.Acquisition; using XIVLauncher.Common.Unix.Compatibility; -using XIVLauncher.Core.Runners; namespace XIVLauncher.Core.Configuration; diff --git a/src/XIVLauncher.Core/Runners/DxvkManager.cs b/src/XIVLauncher.Core/DxvkManager.cs similarity index 94% rename from src/XIVLauncher.Core/Runners/DxvkManager.cs rename to src/XIVLauncher.Core/DxvkManager.cs index 5bb98b68..36c4d196 100644 --- a/src/XIVLauncher.Core/Runners/DxvkManager.cs +++ b/src/XIVLauncher.Core/DxvkManager.cs @@ -9,7 +9,7 @@ using XIVLauncher.Common; using XIVLauncher.Common.Unix.Compatibility; -namespace XIVLauncher.Core.Runners; +namespace XIVLauncher.Core; public enum DxvkVersion { @@ -62,7 +62,7 @@ public static class DxvkManager public static DxvkRunner Initialize() { - var runnerType = "Dxvk"; + var isDxvk = true; var folder = ""; var url = ""; var rootfolder = Program.storage.Root.FullName; @@ -100,14 +100,18 @@ public static DxvkRunner Initialize() url = "https://github.com/doitsujin/dxvk/releases/download/v2.2/dxvk-2.2.tar.gz"; break; - default: + + case DxvkVersion.Disabled: env.Add("PROTON_USE_WINED3D", "1"); - runnerType = "WineD3D"; env.Add("MANGHUD_DLSYM", "1"); + isDxvk = false; break; + + default: + throw new ArgumentOutOfRangeException("Bad value for DxvkVersion"); } - if (runnerType == "Dxvk") + if (isDxvk) { var dxvkCachePath = new DirectoryInfo(Path.Combine(dxvkfolder, "cache")); if (!dxvkCachePath.Exists) dxvkCachePath.Create(); @@ -115,7 +119,7 @@ public static DxvkRunner Initialize() } var hudType = Program.Config.DxvkHudType; - if (Program.Config.DxvkVersion == DxvkVersion.Disabled) + if (!isDxvk) { if (!Program.Config.WineD3DUseVK.Value) hudType = DxvkHudType.None; @@ -186,9 +190,7 @@ public static DxvkRunner Initialize() throw new ArgumentOutOfRangeException(); } - var prefix = new DirectoryInfo(Path.Combine(Program.storage.Root.FullName, "wineprefix")); - var settings = new DxvkRunner(folder, url, prefix, env); - settings.RunnerType = runnerType; + var settings = new DxvkRunner(folder, url, Program.storage.Root.FullName, env, isDxvk); return settings; } diff --git a/src/XIVLauncher.Core/Program.cs b/src/XIVLauncher.Core/Program.cs index c2f52fe4..834de01c 100644 --- a/src/XIVLauncher.Core/Program.cs +++ b/src/XIVLauncher.Core/Program.cs @@ -22,7 +22,6 @@ using XIVLauncher.Core.Components.LoadingPage; using XIVLauncher.Core.Configuration; using XIVLauncher.Core.Configuration.Parsers; -using XIVLauncher.Core.Runners; namespace XIVLauncher.Core; @@ -330,13 +329,13 @@ public static void CreateCompatToolsInstance() var dxvk = DxvkManager.Initialize(); var wineoverride = "msquic,mscoree=n,b;"; var wineenv = new Dictionary(); - if (dxvk.RunnerType == "WineD3D") + if (dxvk.IsDxvk) { - wineoverride += "d3d9,d3d11,d3d10core,dxgi=b"; + wineoverride += "d3d9,d3d11,d3d10core,dxgi=n,b"; } else { - wineoverride = "d3d9,d3d11,d3d10core,dxgi=n,b"; + wineoverride += "d3d9,d3d11,d3d10core,dxgi=b"; } CompatibilityTools = new CompatibilityTools(wine, dxvk, wineenv, wineoverride, winePrefix, toolsFolder, wineLogFile); } @@ -426,7 +425,7 @@ public static void ClearPlugins(bool tsbutton = false) public static void ClearTools(bool tsbutton = false) { storage.GetFolder("compatibilitytool").Delete(true); - storage.GetFolder("compatibilitytool/wine"); + storage.GetFolder("compatibilitytool/beta"); storage.GetFolder("compatibilitytool/dxvk"); if (tsbutton) CreateCompatToolsInstance(); } diff --git a/src/XIVLauncher.Core/Runners/DxvkRunner.cs b/src/XIVLauncher.Core/Runners/DxvkRunner.cs deleted file mode 100644 index 600681a8..00000000 --- a/src/XIVLauncher.Core/Runners/DxvkRunner.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.Specialized; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Net.Http; -using System.Threading.Tasks; -using Serilog; -using XIVLauncher.Common.Util; -using XIVLauncher.Common.Unix.Compatibility; - -namespace XIVLauncher.Core.Runners; - -public class DxvkRunner : Runner -{ - public override string RunnerType { get; set; } - - private DirectoryInfo ToolFolder => new DirectoryInfo(Path.Combine(Program.storage.Root.FullName, "compatibilitytool", "dxvk")); - - public DxvkRunner(string folder, string url, DirectoryInfo prefix, Dictionary env = null) - : base(folder, url, prefix, env) - { } - - public override async Task Install() - { - if (IsDirectoryEmpty(Path.Combine(ToolFolder.FullName, Folder))) - { - if (string.IsNullOrEmpty(DownloadUrl)) - { - Log.Error($"Attempted to download runner {RunnerType} without a download Url."); - throw new InvalidOperationException($"{RunnerType} runner does not exist, and no download URL was provided for it."); - } - Log.Information($"{Folder} does not exist. Downloading..."); - using var client = new HttpClient(); - var tempPath = Path.GetTempFileName(); - - File.WriteAllBytes(tempPath, await client.GetByteArrayAsync(DownloadUrl)); - PlatformHelpers.Untar(tempPath, ToolFolder.FullName); - - File.Delete(tempPath); - } - - var prefixinstall = new DirectoryInfo(Path.Combine(Prefix.FullName, "drive_c", "windows", "system32")); - var files = new DirectoryInfo(Path.Combine(ToolFolder.FullName, Folder, "x64")).GetFiles(); - - foreach (FileInfo fileName in files) - { - fileName.CopyTo(Path.Combine(prefixinstall.FullName, fileName.Name), true); - } - } -} \ No newline at end of file diff --git a/src/XIVLauncher.Core/Runners/WineRunner.cs b/src/XIVLauncher.Core/Runners/WineRunner.cs deleted file mode 100644 index 0857ef12..00000000 --- a/src/XIVLauncher.Core/Runners/WineRunner.cs +++ /dev/null @@ -1,69 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.Specialized; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Net.Http; -using System.Threading.Tasks; -using Serilog; -using XIVLauncher.Common.Util; -using XIVLauncher.Common.Unix.Compatibility; - -namespace XIVLauncher.Core.Runners; - -public class WineRunner : Runner -{ - public override string RunnerType => "Wine"; - - public override string RunCommand { get; } - - public override string RunArguments { get; } - - public override string Server { get; } - - public override string PathArguments => "winepath --windows"; - - private DirectoryInfo ToolFolder => new DirectoryInfo(Path.Combine(Program.storage.Root.FullName, "compatibilitytool", "wine")); - - private string WineServer => Path.Combine(ToolFolder.FullName, "wine", Folder, "bin", "wineserver"); - - public WineRunner(string winepath, string wineargs, string folder, string url, DirectoryInfo prefix, Dictionary env = null) - : base(folder, url, prefix, env) - { - if (string.IsNullOrEmpty(winepath)) - { - RunCommand = Path.Combine(ToolFolder.FullName, Folder, "bin", "wine64"); - Server = Path.Combine(ToolFolder.FullName, Folder, "bin", "wineserver"); - } - else - { - RunCommand = Path.Combine(winepath, "wine64"); - Server = Path.Combine(winepath, "wineserver"); - } - RunArguments = wineargs; - } - - public override async Task Install() - { - if (IsDirectoryEmpty(Path.Combine(ToolFolder.FullName, Folder))) - { - Log.Information($"Downloading Tool to {ToolFolder.FullName}"); - if (string.IsNullOrEmpty(DownloadUrl)) - { - Log.Error($"Attempted to download runner {RunnerType} without a download Url."); - throw new InvalidOperationException($"{RunnerType} runner does not exist, and no download URL was provided for it."); - } - Log.Information($"{Folder} does not exist. Downloading..."); - using var client = new HttpClient(); - var tempPath = Path.GetTempFileName(); - - File.WriteAllBytes(tempPath, await client.GetByteArrayAsync(DownloadUrl)); - PlatformHelpers.Untar(tempPath, ToolFolder.FullName); - - File.Delete(tempPath); - } - else - Log.Information("Did not try to download Wine."); - } -} \ No newline at end of file diff --git a/src/XIVLauncher.Core/Runners/WineManager.cs b/src/XIVLauncher.Core/WineManager.cs similarity index 82% rename from src/XIVLauncher.Core/Runners/WineManager.cs rename to src/XIVLauncher.Core/WineManager.cs index b268a263..b6e2fd18 100644 --- a/src/XIVLauncher.Core/Runners/WineManager.cs +++ b/src/XIVLauncher.Core/WineManager.cs @@ -8,16 +8,13 @@ using XIVLauncher.Common; using XIVLauncher.Common.Unix.Compatibility; -namespace XIVLauncher.Core.Runners; +namespace XIVLauncher.Core; public enum WineType { - [SettingsDescription("Managed by XIVLauncher", "The game installation and wine setup is managed by XIVLauncher - you can leave it up to us.")] + [SettingsDescription("Managed by XIVLauncher", "Choose a patched version of wine made specifically for XIVLauncher")] Managed, - [SettingsDescription("User Managed", "Select from a list of patched wine versions. We'll download them for you.")] - Other, - [SettingsDescription("Custom", "Point XIVLauncher to a custom location containing wine binaries to run the game with.")] Custom, } @@ -47,8 +44,7 @@ public static WineRunner Initialize() var wineargs = ""; var folder = ""; var url = ""; - var prefix = new DirectoryInfo(Path.Combine(Program.storage.Root.FullName, "wineprefix")); - var version = WineVersion.Wine8_5; + var version = Program.Config.WineVersion ?? WineVersion.Wine8_5; switch (Program.Config.WineType ?? WineType.Managed) { case WineType.Custom: @@ -58,12 +54,8 @@ public static WineRunner Initialize() case WineType.Managed: break; - case WineType.Other: - version = Program.Config.WineVersion ?? WineVersion.Wine8_5; - break; - default: - throw new ArgumentOutOfRangeException("Bad value for WineVersion"); + throw new ArgumentOutOfRangeException("Bad value for WineType"); } switch (version) @@ -94,8 +86,9 @@ public static WineRunner Initialize() env.Add("WINEDEBUG", Program.Config.WineDebugVars); if (Program.Config.ESyncEnabled ?? true) env.Add("WINEESYNC", "1"); if (Program.Config.FSyncEnabled ?? false) env.Add("WINEFSYNC", "1"); + env.Add("WINEPREFIX", Path.Combine(Program.storage.Root.FullName, "wineprefix")); - return new WineRunner(winepath, wineargs, folder, url, Program.storage.Root, env); + return new WineRunner(winepath, wineargs, folder, url, Program.storage.Root.FullName, env); } } From 272f4d184337d3bd3c04b9f70810d659e1afdf85 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Sat, 24 Jun 2023 15:17:37 -0700 Subject: [PATCH 08/33] Fix gamemode, update submodule --- lib/FFXIVQuickLauncher | 2 +- .../Components/SettingsPage/Tabs/SettingsTabDxvk.cs | 2 +- src/XIVLauncher.Core/WineManager.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/FFXIVQuickLauncher b/lib/FFXIVQuickLauncher index 06344824..b0a8bd32 160000 --- a/lib/FFXIVQuickLauncher +++ b/lib/FFXIVQuickLauncher @@ -1 +1 @@ -Subproject commit 06344824f733a083fdbca96092a8513b772bfdc0 +Subproject commit b0a8bd322defd822dff38f5c78dc5f89c143cc22 diff --git a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDxvk.cs b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDxvk.cs index c811942d..9d7d7141 100644 --- a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDxvk.cs +++ b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDxvk.cs @@ -22,7 +22,7 @@ public SettingsTabDxvk() CheckWarning = type => { if (new [] {DxvkVersion.v2_1, DxvkVersion.v2_2}.Contains(type)) - return "May not work with pre-8.0 or non-proton wine builds. AMD users may need to use env variable RADV_PERFTEST=gpl"; + return "May not work with older graphics cards. AMD users may need to use env variable RADV_PERFTEST=gpl"; return null; }, }, diff --git a/src/XIVLauncher.Core/WineManager.cs b/src/XIVLauncher.Core/WineManager.cs index b6e2fd18..57062eb3 100644 --- a/src/XIVLauncher.Core/WineManager.cs +++ b/src/XIVLauncher.Core/WineManager.cs @@ -79,7 +79,7 @@ public static WineRunner Initialize() { var ldPreload = Environment.GetEnvironmentVariable("LD_PRELOAD") ?? ""; if (!ldPreload.Contains("libgamemodeauto.so.0")) - ldPreload = (ldPreload.Equals("")) ? "libgamemodeaudo.so" : ldPreload + ":libgamemodeauto.so.0"; + ldPreload = (ldPreload.Equals("")) ? "libgamemodeauto.so.0" : ldPreload + ":libgamemodeauto.so.0"; env.Add("LD_PRELOAD", ldPreload); } if (!string.IsNullOrEmpty(Program.Config.WineDebugVars)) From 8fd716db41069f59575d25a0199c0c0db0a4267b Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Sat, 24 Jun 2023 15:39:31 -0700 Subject: [PATCH 09/33] Move MacVideoFix to xlcore --- lib/FFXIVQuickLauncher | 2 +- .../Components/MainPage/MainPage.cs | 5 +- src/XIVLauncher.Core/GameFixes/MacVideoFix.cs | 59 +++++++++++++++++++ 3 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 src/XIVLauncher.Core/GameFixes/MacVideoFix.cs diff --git a/lib/FFXIVQuickLauncher b/lib/FFXIVQuickLauncher index b0a8bd32..c37927cb 160000 --- a/lib/FFXIVQuickLauncher +++ b/lib/FFXIVQuickLauncher @@ -1 +1 @@ -Subproject commit b0a8bd322defd822dff38f5c78dc5f89c143cc22 +Subproject commit c37927cba52ac66e936e72f3ef63d31ce01b52fd diff --git a/src/XIVLauncher.Core/Components/MainPage/MainPage.cs b/src/XIVLauncher.Core/Components/MainPage/MainPage.cs index 72218abf..84decebe 100644 --- a/src/XIVLauncher.Core/Components/MainPage/MainPage.cs +++ b/src/XIVLauncher.Core/Components/MainPage/MainPage.cs @@ -19,6 +19,7 @@ using XIVLauncher.Core.Accounts; using XIVLauncher.Common.Game.Exceptions; using XIVLauncher.Core.Support; +using XIVLauncher.Core.GameFixes; namespace XIVLauncher.Core.Components.MainPage; @@ -769,7 +770,9 @@ public async Task StartGameAndAddon(Launcher.LoginResult loginResult, b Program.CompatibilityTools.RunInPrefix($"winecfg /v {winver}"); - var gameFixApply = new GameFixApply(App.Settings.GamePath, App.Settings.GameConfigPath, Program.CompatibilityTools.Prefix, tempPath); + var fixes = new GameFix[] { new MacVideoFix(App.Settings.GamePath, App.Settings.GameConfigPath, Program.CompatibilityTools.Prefix, tempPath), }; + + var gameFixApply = new GameFixApply(fixes); gameFixApply.UpdateProgress += (text, hasProgress, progress) => { App.LoadingPage.Line1 = "Applying game-specific fixes..."; diff --git a/src/XIVLauncher.Core/GameFixes/MacVideoFix.cs b/src/XIVLauncher.Core/GameFixes/MacVideoFix.cs new file mode 100644 index 00000000..a8b244fe --- /dev/null +++ b/src/XIVLauncher.Core/GameFixes/MacVideoFix.cs @@ -0,0 +1,59 @@ +using System; +using System.IO; +using System.IO.Compression; +using System.Linq; +using XIVLauncher.Common.Util; +using XIVLauncher.Common.Unix.Compatibility.GameFixes; + +namespace XIVLauncher.Core.GameFixes; + +public class MacVideoFix : GameFix +{ + private const string MAC_ZIP_URL = "https://mac-dl.ffxiv.com/cw/finalfantasyxiv-1.1.2.zip"; + + public MacVideoFix(DirectoryInfo gameDirectory, DirectoryInfo configDirectory, DirectoryInfo winePrefixDirectory, DirectoryInfo tempDirectory) + : base(gameDirectory, configDirectory, winePrefixDirectory, tempDirectory) + { + } + + public override string LoadingTitle => "Preparing FMV cutscenes..."; + + public override void Apply() + { + var outputDirectory = new DirectoryInfo(Path.Combine(GameDir.FullName, "game", "movie", "ffxiv")); + var movieFileNames = new [] { "00000.bk2", "00001.bk2", "00002.bk2", "00003.bk2" }; + var movieFiles = movieFileNames.Select(movie => new FileInfo(Path.Combine(outputDirectory.FullName, movie))); + + if (movieFiles.All((movieFile) => movieFile.Exists)) + return; + + var zipFilePath = Path.Combine(TempDir.FullName, $"{Guid.NewGuid()}.zip"); + using var client = new HttpClientDownloadWithProgress(MAC_ZIP_URL, zipFilePath); + client.ProgressChanged += (size, downloaded, percentage) => + { + if (percentage != null && size != null) + { + this.UpdateProgress?.Invoke($"{LoadingTitle} ({ApiHelpers.BytesToString(downloaded)}/{ApiHelpers.BytesToString(size.Value)})", true, (float)(percentage.Value / 100f)); + } + }; + + client.Download().GetAwaiter().GetResult(); + + var zipMovieFileNames = movieFileNames.Select(movie => Path.Combine("game", "movie", "ffxiv", movie)); + + using (ZipArchive archive = ZipFile.OpenRead(zipFilePath)) + { + foreach (ZipArchiveEntry entry in archive.Entries) + { + if (zipMovieFileNames.Any((fileName) => entry.FullName.EndsWith(fileName, StringComparison.OrdinalIgnoreCase))) + { + string destinationPath = Path.Combine(outputDirectory.FullName, entry.Name); + if (!File.Exists(destinationPath)) + entry.ExtractToFile(destinationPath); + } + } + } + + File.Delete(zipFilePath); + } +} \ No newline at end of file From 380e62a575fa49598eda6c706ca88d76102854f4 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Sat, 24 Jun 2023 19:03:01 -0700 Subject: [PATCH 10/33] Replace directives with GetDistro function --- lib/FFXIVQuickLauncher | 2 +- src/XIVLauncher.Core/WineManager.cs | 19 +++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/lib/FFXIVQuickLauncher b/lib/FFXIVQuickLauncher index c37927cb..d8e66cef 160000 --- a/lib/FFXIVQuickLauncher +++ b/lib/FFXIVQuickLauncher @@ -1 +1 @@ -Subproject commit c37927cba52ac66e936e72f3ef63d31ce01b52fd +Subproject commit d8e66ceff0797c5d4c226cbaccb2ffb38d0b57d0 diff --git a/src/XIVLauncher.Core/WineManager.cs b/src/XIVLauncher.Core/WineManager.cs index 57062eb3..10452062 100644 --- a/src/XIVLauncher.Core/WineManager.cs +++ b/src/XIVLauncher.Core/WineManager.cs @@ -30,14 +30,6 @@ public enum WineVersion public static class WineManager { -#if WINE_XIV_ARCH_LINUX - private const string DISTRO = "arch"; -#elif WINE_XIV_FEDORA_LINUX - private const string DISTRO = "fedora"; -#else - private const string DISTRO = "ubuntu"; -#endif - public static WineRunner Initialize() { var winepath = ""; @@ -62,12 +54,12 @@ public static WineRunner Initialize() { case WineVersion.Wine8_5: folder = "wine-xiv-staging-fsync-git-8.5.r4.g4211bac7"; - url = $"https://github.com/goatcorp/wine-xiv-git/releases/download/8.5.r4.g4211bac7/wine-xiv-staging-fsync-git-{DISTRO}-8.5.r4.g4211bac7.tar.xz"; + url = $"https://github.com/goatcorp/wine-xiv-git/releases/download/8.5.r4.g4211bac7/wine-xiv-staging-fsync-git-{GetDistro()}-8.5.r4.g4211bac7.tar.xz"; break; case WineVersion.Wine7_10: folder = "wine-xiv-staging-fsync-git-7.10.r3.g560db77d"; - url = $"https://github.com/goatcorp/wine-xiv-git/releases/download/7.10.r3.g560db77d/wine-xiv-staging-fsync-git-{DISTRO}-7.10.r3.g560db77d.tar.xz"; + url = $"https://github.com/goatcorp/wine-xiv-git/releases/download/7.10.r3.g560db77d/wine-xiv-staging-fsync-git-{GetDistro()}-7.10.r3.g560db77d.tar.xz"; break; default: @@ -90,6 +82,13 @@ public static WineRunner Initialize() return new WineRunner(winepath, wineargs, folder, url, Program.storage.Root.FullName, env); } + + private static string GetDistro() + { + if (File.Exists("/etc/arch-release")) return "arch"; + if (File.Exists("/etc/fedora-release")) return "fedora"; + return "ubuntu"; + } } From 83141405c381a046e95adb454c01cd68eaababb7 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Sat, 24 Jun 2023 22:07:34 -0700 Subject: [PATCH 11/33] Move distro function to Program.cs, add flatpak detection --- .../SettingsPage/Tabs/SettingsTabDebug.cs | 3 +- src/XIVLauncher.Core/Program.cs | 69 +++++++++++++++++-- src/XIVLauncher.Core/WineManager.cs | 4 +- 3 files changed, 66 insertions(+), 10 deletions(-) diff --git a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDebug.cs b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDebug.cs index 53225022..1362cb09 100644 --- a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDebug.cs +++ b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDebug.cs @@ -21,9 +21,8 @@ public override void Draw() if (Program.IsSteamDeckGamingMode) ImGui.Text("Steam Deck Gaming Mode Detected"); -#if FLATPAK + if (Program.IsFlatpak) ImGui.Text("Running as a Flatpak"); -#endif ImGui.Spacing(); diff --git a/src/XIVLauncher.Core/Program.cs b/src/XIVLauncher.Core/Program.cs index 834de01c..cca4fd7e 100644 --- a/src/XIVLauncher.Core/Program.cs +++ b/src/XIVLauncher.Core/Program.cs @@ -44,7 +44,9 @@ class Program private static readonly Vector3 clearColor = new(0.1f, 0.1f, 0.1f); private static bool showImGuiDemoWindow = true; - + public static string Distro { get; private set; } + private static string DistroLong; + public static bool IsFlatpak { get; private set; } private static LauncherApp launcherApp; public static Storage storage; public static DirectoryInfo DotnetRuntime => storage.GetFolder("runtime"); @@ -75,6 +77,7 @@ private static void SetupLogging(string[] args) Log.Information("========================================================"); Log.Information("Starting a session(v{Version} - {Hash})", AppUtil.GetAssemblyVersion(), AppUtil.GetGitHash()); + Log.Information("Running on {DistroName}, wine distro set to {Distro}", DistroLong, Distro); } private static void LoadConfig(Storage storage) @@ -154,6 +157,7 @@ private static void Main(string[] args) if (CoreEnvironmentSettings.ClearLogs) ClearLogs(); } + GetDistro(); SetupLogging(mainargs); LoadConfig(storage); @@ -251,16 +255,14 @@ private static void Main(string[] args) var needUpdate = false; -#if FLATPAK - if (Config.DoVersionCheck ?? false) + if (Config.DoVersionCheck ?? false && IsFlatpak) { var versionCheckResult = UpdateCheck.CheckForUpdate().GetAwaiter().GetResult(); if (versionCheckResult.Success) needUpdate = versionCheckResult.NeedUpdate; - } -#endif - + } + needUpdate = CoreEnvironmentSettings.IsUpgrade ? true : needUpdate; launcherApp = new LauncherApp(storage, needUpdate); @@ -383,6 +385,61 @@ private static ISecretProvider GetSecretProvider(Storage storage) } } + private static void GetDistro() + { + try + { + if (!File.Exists("/etc/os-release")) + { + Distro = "ubuntu"; + DistroLong = "Unknown distribution"; + IsFlatpak = false; + return; + } + var osRelease = File.ReadAllLines("/etc/os-release"); + var name = ""; + var pretty = ""; + var distro = ""; + var flatpak = false; + foreach (var line in osRelease) + { + var keyValue = line.Split("=", 2); + if (keyValue.Length == 1) continue; + if (keyValue[0] == "NAME") + name = keyValue[1]; + if (keyValue[0] == "PRETTY_NAME") + pretty = keyValue[1]; + if (keyValue[0] == "ID_LIKE") + { + if (keyValue[1].Contains("arch")) + distro = "arch"; + if (keyValue[1].Contains("fedora")) + distro = "fedora"; + if (keyValue[1].Contains("ubuntu")) + distro = "ubuntu"; + if (keyValue[1].Contains("debian")) + distro = "ubuntu"; + } + if (keyValue[0] == "ID") + { + if (keyValue[1].Contains("tumbleweed")) + distro = "fedora"; + if (keyValue[1] == "org.freedesktop.platform") + flatpak = true; + } + } + Distro = (distro == "") ? "ubuntu" : distro; + DistroLong = pretty == "" ? (name == "" ? "Unknown distribution" : name) : pretty; + IsFlatpak = flatpak; + } + catch + { + // If there's any kind of error opening the file or even finding it, just go with default. + Distro = "ubuntu"; + DistroLong = "Unknown distribution"; + } + } + public static void ClearSettings(bool tsbutton = false) { if (storage.GetFile("launcher.ini").Exists) storage.GetFile("launcher.ini").Delete(); diff --git a/src/XIVLauncher.Core/WineManager.cs b/src/XIVLauncher.Core/WineManager.cs index 10452062..3182312a 100644 --- a/src/XIVLauncher.Core/WineManager.cs +++ b/src/XIVLauncher.Core/WineManager.cs @@ -54,12 +54,12 @@ public static WineRunner Initialize() { case WineVersion.Wine8_5: folder = "wine-xiv-staging-fsync-git-8.5.r4.g4211bac7"; - url = $"https://github.com/goatcorp/wine-xiv-git/releases/download/8.5.r4.g4211bac7/wine-xiv-staging-fsync-git-{GetDistro()}-8.5.r4.g4211bac7.tar.xz"; + url = $"https://github.com/goatcorp/wine-xiv-git/releases/download/8.5.r4.g4211bac7/wine-xiv-staging-fsync-git-{Program.Distro}-8.5.r4.g4211bac7.tar.xz"; break; case WineVersion.Wine7_10: folder = "wine-xiv-staging-fsync-git-7.10.r3.g560db77d"; - url = $"https://github.com/goatcorp/wine-xiv-git/releases/download/7.10.r3.g560db77d/wine-xiv-staging-fsync-git-{GetDistro()}-7.10.r3.g560db77d.tar.xz"; + url = $"https://github.com/goatcorp/wine-xiv-git/releases/download/7.10.r3.g560db77d/wine-xiv-staging-fsync-git-{Program.Distro}-7.10.r3.g560db77d.tar.xz"; break; default: From 2142c7dcfe6301ded295ddd8b90fb43fbfc0fe21 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Sat, 24 Jun 2023 22:32:21 -0700 Subject: [PATCH 12/33] Use Dictionary instead of iterating array --- .../SettingsPage/Tabs/SettingsTabDebug.cs | 2 +- src/XIVLauncher.Core/Program.cs | 51 ++++++++++--------- 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDebug.cs b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDebug.cs index 1362cb09..b97854be 100644 --- a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDebug.cs +++ b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDebug.cs @@ -12,7 +12,7 @@ public override void Draw() { ImGui.TextUnformatted("Generic Information"); ImGui.Separator(); - ImGui.TextUnformatted($"Operating System: {Environment.OSVersion}"); + ImGui.TextUnformatted($"Operating System: {Program.DistroLong} - {Environment.OSVersion}"); ImGui.TextUnformatted($"Runtime Version: {Environment.Version}"); if (Program.IsSteamDeckHardware) diff --git a/src/XIVLauncher.Core/Program.cs b/src/XIVLauncher.Core/Program.cs index cca4fd7e..2a9bdbdf 100644 --- a/src/XIVLauncher.Core/Program.cs +++ b/src/XIVLauncher.Core/Program.cs @@ -45,7 +45,7 @@ class Program private static readonly Vector3 clearColor = new(0.1f, 0.1f, 0.1f); private static bool showImGuiDemoWindow = true; public static string Distro { get; private set; } - private static string DistroLong; + public static string DistroLong { get; private set; } public static bool IsFlatpak { get; private set; } private static LauncherApp launcherApp; public static Storage storage; @@ -262,7 +262,7 @@ private static void Main(string[] args) if (versionCheckResult.Success) needUpdate = versionCheckResult.NeedUpdate; } - + needUpdate = CoreEnvironmentSettings.IsUpgrade ? true : needUpdate; launcherApp = new LauncherApp(storage, needUpdate); @@ -401,33 +401,33 @@ private static void GetDistro() var pretty = ""; var distro = ""; var flatpak = false; + var OSInfo = new Dictionary(); foreach (var line in osRelease) { var keyValue = line.Split("=", 2); - if (keyValue.Length == 1) continue; - if (keyValue[0] == "NAME") - name = keyValue[1]; - if (keyValue[0] == "PRETTY_NAME") - pretty = keyValue[1]; - if (keyValue[0] == "ID_LIKE") - { - if (keyValue[1].Contains("arch")) - distro = "arch"; - if (keyValue[1].Contains("fedora")) - distro = "fedora"; - if (keyValue[1].Contains("ubuntu")) - distro = "ubuntu"; - if (keyValue[1].Contains("debian")) - distro = "ubuntu"; - } - if (keyValue[0] == "ID") - { - if (keyValue[1].Contains("tumbleweed")) - distro = "fedora"; - if (keyValue[1] == "org.freedesktop.platform") - flatpak = true; - } + if (keyValue.Length == 1) + OSInfo.Add(keyValue[0], ""); + else + OSInfo.Add(keyValue[0], keyValue[1]); } + + name = (OSInfo["NAME"] ?? "").Trim('"'); + pretty = (OSInfo["PRETTY_NAME"] ?? "").Trim('"'); + + var idLike = OSInfo["ID_LIKE"] ?? ""; + if (idLike.Contains("arch")) + distro = "arch"; + else if (idLike.Contains("fedora")) + distro = "fedora"; + else + distro = "ubuntu"; + + var id = OSInfo["ID"] ?? ""; + if (id.Contains("tumbleweed")) + distro = "fedora"; + if (id == "org.freedesktop.platform") + flatpak = true; + Distro = (distro == "") ? "ubuntu" : distro; DistroLong = pretty == "" ? (name == "" ? "Unknown distribution" : name) : pretty; IsFlatpak = flatpak; @@ -437,6 +437,7 @@ private static void GetDistro() // If there's any kind of error opening the file or even finding it, just go with default. Distro = "ubuntu"; DistroLong = "Unknown distribution"; + IsFlatpak = false; } } From 0637558074c5b6139102631a096d3b62bd54dfcb Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Sat, 24 Jun 2023 23:18:37 -0700 Subject: [PATCH 13/33] Fix error by switching to .ContainsKey() --- src/XIVLauncher.Core/Program.cs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/XIVLauncher.Core/Program.cs b/src/XIVLauncher.Core/Program.cs index 2a9bdbdf..cec3c837 100644 --- a/src/XIVLauncher.Core/Program.cs +++ b/src/XIVLauncher.Core/Program.cs @@ -397,24 +397,21 @@ private static void GetDistro() return; } var osRelease = File.ReadAllLines("/etc/os-release"); - var name = ""; - var pretty = ""; var distro = ""; var flatpak = false; var OSInfo = new Dictionary(); foreach (var line in osRelease) { - var keyValue = line.Split("=", 2); + var keyValue = line.Split('=', 2); if (keyValue.Length == 1) OSInfo.Add(keyValue[0], ""); else OSInfo.Add(keyValue[0], keyValue[1]); } - name = (OSInfo["NAME"] ?? "").Trim('"'); - pretty = (OSInfo["PRETTY_NAME"] ?? "").Trim('"'); - - var idLike = OSInfo["ID_LIKE"] ?? ""; + var name = (OSInfo.ContainsKey("NAME") ? OSInfo["NAME"] : "").Trim('"'); + var pretty = (OSInfo.ContainsKey("PRETTY_NAME") ? OSInfo["PRETTY_NAME"] : "").Trim('"'); + var idLike = OSInfo.ContainsKey("ID_LIKE") ? OSInfo["ID_LIKE"] : ""; if (idLike.Contains("arch")) distro = "arch"; else if (idLike.Contains("fedora")) @@ -422,7 +419,7 @@ private static void GetDistro() else distro = "ubuntu"; - var id = OSInfo["ID"] ?? ""; + var id = OSInfo.ContainsKey("ID") ? OSInfo["ID"] : ""; if (id.Contains("tumbleweed")) distro = "fedora"; if (id == "org.freedesktop.platform") From 74b491281370cfce8c44ab484ef778107c5f72fc Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Sun, 25 Jun 2023 12:46:21 -0700 Subject: [PATCH 14/33] Move distro detection to own class, use enum --- .../SettingsPage/Tabs/SettingsTabDebug.cs | 6 +- src/XIVLauncher.Core/Distro.cs | 76 +++++++++++++++++++ src/XIVLauncher.Core/Program.cs | 63 +-------------- src/XIVLauncher.Core/WineManager.cs | 4 +- 4 files changed, 86 insertions(+), 63 deletions(-) create mode 100644 src/XIVLauncher.Core/Distro.cs diff --git a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDebug.cs b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDebug.cs index b97854be..e042574a 100644 --- a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDebug.cs +++ b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDebug.cs @@ -12,7 +12,7 @@ public override void Draw() { ImGui.TextUnformatted("Generic Information"); ImGui.Separator(); - ImGui.TextUnformatted($"Operating System: {Program.DistroLong} - {Environment.OSVersion}"); + ImGui.TextUnformatted($"Operating System: {Distro.Name} - {Environment.OSVersion}"); ImGui.TextUnformatted($"Runtime Version: {Environment.Version}"); if (Program.IsSteamDeckHardware) @@ -21,8 +21,10 @@ public override void Draw() if (Program.IsSteamDeckGamingMode) ImGui.Text("Steam Deck Gaming Mode Detected"); - if (Program.IsFlatpak) + if (Distro.IsFlatpak) ImGui.Text("Running as a Flatpak"); + else + ImGui.Text("Running a native build"); ImGui.Spacing(); diff --git a/src/XIVLauncher.Core/Distro.cs b/src/XIVLauncher.Core/Distro.cs new file mode 100644 index 00000000..6df5fe7f --- /dev/null +++ b/src/XIVLauncher.Core/Distro.cs @@ -0,0 +1,76 @@ +using System.Numerics; +using System.IO; +using System.Collections.Generic; + +namespace XIVLauncher.Core; + +public enum WinePackage +{ + ubuntu, + + fedora, + + arch, +} + +public static class Distro +{ + public static WinePackage Package { get; private set; } + + public static string Name { get; private set; } + + public static bool IsFlatpak { get; private set; } + + public static void GetDistro() + { + try + { + if (!File.Exists("/etc/os-release")) + { + Package = WinePackage.ubuntu; + Name = "Unknown distribution"; + IsFlatpak = false; + return; + } + var osRelease = File.ReadAllLines("/etc/os-release"); + var distro = WinePackage.ubuntu; + var flatpak = false; + var OSInfo = new Dictionary(); + foreach (var line in osRelease) + { + var keyValue = line.Split('=', 2); + if (keyValue.Length == 1) + OSInfo.Add(keyValue[0], ""); + else + OSInfo.Add(keyValue[0], keyValue[1]); + } + + var name = (OSInfo.ContainsKey("NAME") ? OSInfo["NAME"] : "").Trim('"'); + var pretty = (OSInfo.ContainsKey("PRETTY_NAME") ? OSInfo["PRETTY_NAME"] : "").Trim('"'); + var idLike = OSInfo.ContainsKey("ID_LIKE") ? OSInfo["ID_LIKE"] : ""; + if (idLike.Contains("arch")) + distro = WinePackage.arch; + else if (idLike.Contains("fedora")) + distro = WinePackage.fedora; + else + distro = WinePackage.ubuntu; + + var id = OSInfo.ContainsKey("ID") ? OSInfo["ID"] : ""; + if (id.Contains("tumbleweed") || id.Contains("fedora")) + distro = WinePackage.fedora; + if (id == "org.freedesktop.platform") + flatpak = true; + + Package = distro; + Name = pretty == "" ? (name == "" ? "Unknown distribution" : name) : pretty; + IsFlatpak = flatpak; + } + catch + { + // If there's any kind of error opening the file or even finding it, just go with default. + Package = WinePackage.ubuntu; + Name = "Unknown distribution"; + IsFlatpak = false; + } + } +} \ No newline at end of file diff --git a/src/XIVLauncher.Core/Program.cs b/src/XIVLauncher.Core/Program.cs index cec3c837..cf94f91c 100644 --- a/src/XIVLauncher.Core/Program.cs +++ b/src/XIVLauncher.Core/Program.cs @@ -44,9 +44,7 @@ class Program private static readonly Vector3 clearColor = new(0.1f, 0.1f, 0.1f); private static bool showImGuiDemoWindow = true; - public static string Distro { get; private set; } - public static string DistroLong { get; private set; } - public static bool IsFlatpak { get; private set; } + private static LauncherApp launcherApp; public static Storage storage; public static DirectoryInfo DotnetRuntime => storage.GetFolder("runtime"); @@ -77,7 +75,7 @@ private static void SetupLogging(string[] args) Log.Information("========================================================"); Log.Information("Starting a session(v{Version} - {Hash})", AppUtil.GetAssemblyVersion(), AppUtil.GetGitHash()); - Log.Information("Running on {DistroName}, wine distro set to {Distro}", DistroLong, Distro); + Log.Information("Running on {DistroName}, wine package set to {DistroPackage}", Distro.Name, Distro.Package.ToString()); } private static void LoadConfig(Storage storage) @@ -157,7 +155,7 @@ private static void Main(string[] args) if (CoreEnvironmentSettings.ClearLogs) ClearLogs(); } - GetDistro(); + Distro.GetDistro(); SetupLogging(mainargs); LoadConfig(storage); @@ -255,7 +253,7 @@ private static void Main(string[] args) var needUpdate = false; - if (Config.DoVersionCheck ?? false && IsFlatpak) + if (Config.DoVersionCheck ?? false && Distro.IsFlatpak) { var versionCheckResult = UpdateCheck.CheckForUpdate().GetAwaiter().GetResult(); @@ -385,59 +383,6 @@ private static ISecretProvider GetSecretProvider(Storage storage) } } - private static void GetDistro() - { - try - { - if (!File.Exists("/etc/os-release")) - { - Distro = "ubuntu"; - DistroLong = "Unknown distribution"; - IsFlatpak = false; - return; - } - var osRelease = File.ReadAllLines("/etc/os-release"); - var distro = ""; - var flatpak = false; - var OSInfo = new Dictionary(); - foreach (var line in osRelease) - { - var keyValue = line.Split('=', 2); - if (keyValue.Length == 1) - OSInfo.Add(keyValue[0], ""); - else - OSInfo.Add(keyValue[0], keyValue[1]); - } - - var name = (OSInfo.ContainsKey("NAME") ? OSInfo["NAME"] : "").Trim('"'); - var pretty = (OSInfo.ContainsKey("PRETTY_NAME") ? OSInfo["PRETTY_NAME"] : "").Trim('"'); - var idLike = OSInfo.ContainsKey("ID_LIKE") ? OSInfo["ID_LIKE"] : ""; - if (idLike.Contains("arch")) - distro = "arch"; - else if (idLike.Contains("fedora")) - distro = "fedora"; - else - distro = "ubuntu"; - - var id = OSInfo.ContainsKey("ID") ? OSInfo["ID"] : ""; - if (id.Contains("tumbleweed")) - distro = "fedora"; - if (id == "org.freedesktop.platform") - flatpak = true; - - Distro = (distro == "") ? "ubuntu" : distro; - DistroLong = pretty == "" ? (name == "" ? "Unknown distribution" : name) : pretty; - IsFlatpak = flatpak; - } - catch - { - // If there's any kind of error opening the file or even finding it, just go with default. - Distro = "ubuntu"; - DistroLong = "Unknown distribution"; - IsFlatpak = false; - } - } - public static void ClearSettings(bool tsbutton = false) { if (storage.GetFile("launcher.ini").Exists) storage.GetFile("launcher.ini").Delete(); diff --git a/src/XIVLauncher.Core/WineManager.cs b/src/XIVLauncher.Core/WineManager.cs index 3182312a..daf75f49 100644 --- a/src/XIVLauncher.Core/WineManager.cs +++ b/src/XIVLauncher.Core/WineManager.cs @@ -54,12 +54,12 @@ public static WineRunner Initialize() { case WineVersion.Wine8_5: folder = "wine-xiv-staging-fsync-git-8.5.r4.g4211bac7"; - url = $"https://github.com/goatcorp/wine-xiv-git/releases/download/8.5.r4.g4211bac7/wine-xiv-staging-fsync-git-{Program.Distro}-8.5.r4.g4211bac7.tar.xz"; + url = $"https://github.com/goatcorp/wine-xiv-git/releases/download/8.5.r4.g4211bac7/wine-xiv-staging-fsync-git-{Distro.Package.ToString()}-8.5.r4.g4211bac7.tar.xz"; break; case WineVersion.Wine7_10: folder = "wine-xiv-staging-fsync-git-7.10.r3.g560db77d"; - url = $"https://github.com/goatcorp/wine-xiv-git/releases/download/7.10.r3.g560db77d/wine-xiv-staging-fsync-git-{Program.Distro}-7.10.r3.g560db77d.tar.xz"; + url = $"https://github.com/goatcorp/wine-xiv-git/releases/download/7.10.r3.g560db77d/wine-xiv-staging-fsync-git-{Distro.Package.ToString()}-7.10.r3.g560db77d.tar.xz"; break; default: From 5d753452628ecc3af7c9e6a4eaee8f5f1a1e73e5 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Sun, 25 Jun 2023 12:46:50 -0700 Subject: [PATCH 15/33] Forgot to save a couple files --- src/XIVLauncher.Core/Distro.cs | 2 +- src/XIVLauncher.Core/Program.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/XIVLauncher.Core/Distro.cs b/src/XIVLauncher.Core/Distro.cs index 6df5fe7f..0eb6dc43 100644 --- a/src/XIVLauncher.Core/Distro.cs +++ b/src/XIVLauncher.Core/Distro.cs @@ -21,7 +21,7 @@ public static class Distro public static bool IsFlatpak { get; private set; } - public static void GetDistro() + public static void GetInfo() { try { diff --git a/src/XIVLauncher.Core/Program.cs b/src/XIVLauncher.Core/Program.cs index cf94f91c..4c118050 100644 --- a/src/XIVLauncher.Core/Program.cs +++ b/src/XIVLauncher.Core/Program.cs @@ -155,7 +155,7 @@ private static void Main(string[] args) if (CoreEnvironmentSettings.ClearLogs) ClearLogs(); } - Distro.GetDistro(); + Distro.GetInfo(); SetupLogging(mainargs); LoadConfig(storage); From 94f34c486927665a0d0b98535a959dc35345231b Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Sun, 25 Jun 2023 12:52:46 -0700 Subject: [PATCH 16/33] Revert "Move MacVideoFix to xlcore" This reverts commit 8fd716db41069f59575d25a0199c0c0db0a4267b. --- lib/FFXIVQuickLauncher | 2 +- .../Components/MainPage/MainPage.cs | 5 +- src/XIVLauncher.Core/GameFixes/MacVideoFix.cs | 59 ------------------- 3 files changed, 2 insertions(+), 64 deletions(-) delete mode 100644 src/XIVLauncher.Core/GameFixes/MacVideoFix.cs diff --git a/lib/FFXIVQuickLauncher b/lib/FFXIVQuickLauncher index d8e66cef..78e02be5 160000 --- a/lib/FFXIVQuickLauncher +++ b/lib/FFXIVQuickLauncher @@ -1 +1 @@ -Subproject commit d8e66ceff0797c5d4c226cbaccb2ffb38d0b57d0 +Subproject commit 78e02be58eed5905ff4178079fc607e6e8e8b6a2 diff --git a/src/XIVLauncher.Core/Components/MainPage/MainPage.cs b/src/XIVLauncher.Core/Components/MainPage/MainPage.cs index 84decebe..72218abf 100644 --- a/src/XIVLauncher.Core/Components/MainPage/MainPage.cs +++ b/src/XIVLauncher.Core/Components/MainPage/MainPage.cs @@ -19,7 +19,6 @@ using XIVLauncher.Core.Accounts; using XIVLauncher.Common.Game.Exceptions; using XIVLauncher.Core.Support; -using XIVLauncher.Core.GameFixes; namespace XIVLauncher.Core.Components.MainPage; @@ -770,9 +769,7 @@ public async Task StartGameAndAddon(Launcher.LoginResult loginResult, b Program.CompatibilityTools.RunInPrefix($"winecfg /v {winver}"); - var fixes = new GameFix[] { new MacVideoFix(App.Settings.GamePath, App.Settings.GameConfigPath, Program.CompatibilityTools.Prefix, tempPath), }; - - var gameFixApply = new GameFixApply(fixes); + var gameFixApply = new GameFixApply(App.Settings.GamePath, App.Settings.GameConfigPath, Program.CompatibilityTools.Prefix, tempPath); gameFixApply.UpdateProgress += (text, hasProgress, progress) => { App.LoadingPage.Line1 = "Applying game-specific fixes..."; diff --git a/src/XIVLauncher.Core/GameFixes/MacVideoFix.cs b/src/XIVLauncher.Core/GameFixes/MacVideoFix.cs deleted file mode 100644 index a8b244fe..00000000 --- a/src/XIVLauncher.Core/GameFixes/MacVideoFix.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System; -using System.IO; -using System.IO.Compression; -using System.Linq; -using XIVLauncher.Common.Util; -using XIVLauncher.Common.Unix.Compatibility.GameFixes; - -namespace XIVLauncher.Core.GameFixes; - -public class MacVideoFix : GameFix -{ - private const string MAC_ZIP_URL = "https://mac-dl.ffxiv.com/cw/finalfantasyxiv-1.1.2.zip"; - - public MacVideoFix(DirectoryInfo gameDirectory, DirectoryInfo configDirectory, DirectoryInfo winePrefixDirectory, DirectoryInfo tempDirectory) - : base(gameDirectory, configDirectory, winePrefixDirectory, tempDirectory) - { - } - - public override string LoadingTitle => "Preparing FMV cutscenes..."; - - public override void Apply() - { - var outputDirectory = new DirectoryInfo(Path.Combine(GameDir.FullName, "game", "movie", "ffxiv")); - var movieFileNames = new [] { "00000.bk2", "00001.bk2", "00002.bk2", "00003.bk2" }; - var movieFiles = movieFileNames.Select(movie => new FileInfo(Path.Combine(outputDirectory.FullName, movie))); - - if (movieFiles.All((movieFile) => movieFile.Exists)) - return; - - var zipFilePath = Path.Combine(TempDir.FullName, $"{Guid.NewGuid()}.zip"); - using var client = new HttpClientDownloadWithProgress(MAC_ZIP_URL, zipFilePath); - client.ProgressChanged += (size, downloaded, percentage) => - { - if (percentage != null && size != null) - { - this.UpdateProgress?.Invoke($"{LoadingTitle} ({ApiHelpers.BytesToString(downloaded)}/{ApiHelpers.BytesToString(size.Value)})", true, (float)(percentage.Value / 100f)); - } - }; - - client.Download().GetAwaiter().GetResult(); - - var zipMovieFileNames = movieFileNames.Select(movie => Path.Combine("game", "movie", "ffxiv", movie)); - - using (ZipArchive archive = ZipFile.OpenRead(zipFilePath)) - { - foreach (ZipArchiveEntry entry in archive.Entries) - { - if (zipMovieFileNames.Any((fileName) => entry.FullName.EndsWith(fileName, StringComparison.OrdinalIgnoreCase))) - { - string destinationPath = Path.Combine(outputDirectory.FullName, entry.Name); - if (!File.Exists(destinationPath)) - entry.ExtractToFile(destinationPath); - } - } - } - - File.Delete(zipFilePath); - } -} \ No newline at end of file From ad5109597f2a9582c8f87a3878d6461cf95dbaff Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Sun, 25 Jun 2023 15:50:31 -0700 Subject: [PATCH 17/33] Update submodule so it will build --- lib/FFXIVQuickLauncher | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/FFXIVQuickLauncher b/lib/FFXIVQuickLauncher index 2844c3df..5c023527 160000 --- a/lib/FFXIVQuickLauncher +++ b/lib/FFXIVQuickLauncher @@ -1 +1 @@ -Subproject commit 2844c3df359080755bf4475aff30066c2e5cc29a +Subproject commit 5c02352727695b67a442209d962afeb02a34f582 From 009837117e27ab7fc0eb7f6344e56e8a202ae421 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Mon, 26 Jun 2023 15:02:41 -0700 Subject: [PATCH 18/33] Fix slightly wrong WINEDLLOVERRIDE. --- src/XIVLauncher.Core/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/XIVLauncher.Core/Program.cs b/src/XIVLauncher.Core/Program.cs index 4c118050..913b38f0 100644 --- a/src/XIVLauncher.Core/Program.cs +++ b/src/XIVLauncher.Core/Program.cs @@ -327,7 +327,7 @@ public static void CreateCompatToolsInstance() var toolsFolder = storage.GetFolder("compatibilitytool"); var wine = WineManager.Initialize(); var dxvk = DxvkManager.Initialize(); - var wineoverride = "msquic,mscoree=n,b;"; + var wineoverride = "msquic=,mscoree=n,b;"; var wineenv = new Dictionary(); if (dxvk.IsDxvk) { From 6fe1b6baba57d36a1f3e7775848206e18866623e Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Tue, 27 Jun 2023 21:43:26 -0700 Subject: [PATCH 19/33] Changes to match with main XL repo. More to come. * Changed names of classes to WineSettings and DxvkSettings * Removed a bunch of unused variables * Moved WINEDLLOVERRIDES * Update submodule --- lib/FFXIVQuickLauncher | 2 +- src/XIVLauncher.Core/DxvkManager.cs | 4 ++-- src/XIVLauncher.Core/Program.cs | 14 ++------------ src/XIVLauncher.Core/WineManager.cs | 12 ++---------- 4 files changed, 7 insertions(+), 25 deletions(-) diff --git a/lib/FFXIVQuickLauncher b/lib/FFXIVQuickLauncher index 5c023527..c6353d5a 160000 --- a/lib/FFXIVQuickLauncher +++ b/lib/FFXIVQuickLauncher @@ -1 +1 @@ -Subproject commit 5c02352727695b67a442209d962afeb02a34f582 +Subproject commit c6353d5a2c1b52415556994cfdca00d349981202 diff --git a/src/XIVLauncher.Core/DxvkManager.cs b/src/XIVLauncher.Core/DxvkManager.cs index 36c4d196..f030c830 100644 --- a/src/XIVLauncher.Core/DxvkManager.cs +++ b/src/XIVLauncher.Core/DxvkManager.cs @@ -60,7 +60,7 @@ public static class DxvkManager private const string ALLOWED_WORDS = "^(?:devinfo|fps|frametimes|submissions|drawcalls|pipelines|descriptors|memory|gpuload|version|api|cs|compiler|samplers|scale=(?:[0-9])*(?:.(?:[0-9])+)?)$"; - public static DxvkRunner Initialize() + public static DxvkSettings Initialize() { var isDxvk = true; var folder = ""; @@ -190,7 +190,7 @@ public static DxvkRunner Initialize() throw new ArgumentOutOfRangeException(); } - var settings = new DxvkRunner(folder, url, Program.storage.Root.FullName, env, isDxvk); + var settings = new DxvkSettings(folder, url, Program.storage.Root.FullName, env, isDxvk); return settings; } diff --git a/src/XIVLauncher.Core/Program.cs b/src/XIVLauncher.Core/Program.cs index 913b38f0..3c96d139 100644 --- a/src/XIVLauncher.Core/Program.cs +++ b/src/XIVLauncher.Core/Program.cs @@ -327,17 +327,7 @@ public static void CreateCompatToolsInstance() var toolsFolder = storage.GetFolder("compatibilitytool"); var wine = WineManager.Initialize(); var dxvk = DxvkManager.Initialize(); - var wineoverride = "msquic=,mscoree=n,b;"; - var wineenv = new Dictionary(); - if (dxvk.IsDxvk) - { - wineoverride += "d3d9,d3d11,d3d10core,dxgi=n,b"; - } - else - { - wineoverride += "d3d9,d3d11,d3d10core,dxgi=b"; - } - CompatibilityTools = new CompatibilityTools(wine, dxvk, wineenv, wineoverride, winePrefix, toolsFolder, wineLogFile); + CompatibilityTools = new CompatibilityTools(wine, dxvk, winePrefix, toolsFolder, wineLogFile, Distro.IsFlatpak); } public static void ShowWindow() @@ -425,7 +415,7 @@ public static void ClearPlugins(bool tsbutton = false) public static void ClearTools(bool tsbutton = false) { storage.GetFolder("compatibilitytool").Delete(true); - storage.GetFolder("compatibilitytool/beta"); + storage.GetFolder("compatibilitytool/wine"); storage.GetFolder("compatibilitytool/dxvk"); if (tsbutton) CreateCompatToolsInstance(); } diff --git a/src/XIVLauncher.Core/WineManager.cs b/src/XIVLauncher.Core/WineManager.cs index daf75f49..b30e106b 100644 --- a/src/XIVLauncher.Core/WineManager.cs +++ b/src/XIVLauncher.Core/WineManager.cs @@ -30,10 +30,9 @@ public enum WineVersion public static class WineManager { - public static WineRunner Initialize() + public static WineSettings Initialize() { var winepath = ""; - var wineargs = ""; var folder = ""; var url = ""; var version = Program.Config.WineVersion ?? WineVersion.Wine8_5; @@ -80,14 +79,7 @@ public static WineRunner Initialize() if (Program.Config.FSyncEnabled ?? false) env.Add("WINEFSYNC", "1"); env.Add("WINEPREFIX", Path.Combine(Program.storage.Root.FullName, "wineprefix")); - return new WineRunner(winepath, wineargs, folder, url, Program.storage.Root.FullName, env); - } - - private static string GetDistro() - { - if (File.Exists("/etc/arch-release")) return "arch"; - if (File.Exists("/etc/fedora-release")) return "fedora"; - return "ubuntu"; + return new WineSettings(winepath, folder, url, Program.storage.Root.FullName, env); } } From 7afb7a25da7a61ec63eb4dd87c219b4d1b5a09f0 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Wed, 28 Jun 2023 16:38:10 -0700 Subject: [PATCH 20/33] Remove WineD3D Vulkan --- src/XIVLauncher.Core/Components/MainPage/MainPage.cs | 10 ---------- .../Components/SettingsPage/Tabs/SettingsTabDxvk.cs | 12 +----------- .../Configuration/ILauncherConfig.cs | 2 -- src/XIVLauncher.Core/DxvkManager.cs | 9 +-------- src/XIVLauncher.Core/Program.cs | 1 - 5 files changed, 2 insertions(+), 32 deletions(-) diff --git a/src/XIVLauncher.Core/Components/MainPage/MainPage.cs b/src/XIVLauncher.Core/Components/MainPage/MainPage.cs index ffef2693..d529bbc0 100644 --- a/src/XIVLauncher.Core/Components/MainPage/MainPage.cs +++ b/src/XIVLauncher.Core/Components/MainPage/MainPage.cs @@ -761,16 +761,6 @@ public async Task StartGameAndAddon(Launcher.LoginResult loginResult, b await Program.CompatibilityTools.EnsureTool(tempPath).ConfigureAwait(false); Program.CompatibilityTools.RunInPrefix($"winecfg /v {winver}"); - if (Program.Config.DxvkVersion == DxvkVersion.Disabled) - { - if (Program.Config.WineD3DUseVK ?? false) - Program.CompatibilityTools.AddRegistryKey("HKEY_CURRENT_USER\\Software\\Wine\\Direct3D", "renderer", "vulkan"); - else - Program.CompatibilityTools.AddRegistryKey("HKEY_CURRENT_USER\\Software\\Wine\\Direct3D", "renderer", "gl"); - } - - Program.CompatibilityTools.RunInPrefix($"winecfg /v {winver}"); - var gameFixApply = new GameFixApply(App.Settings.GamePath, App.Settings.GameConfigPath, Program.CompatibilityTools.Prefix, tempPath); gameFixApply.UpdateProgress += (text, hasProgress, progress) => { diff --git a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDxvk.cs b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDxvk.cs index 9d7d7141..0d086910 100644 --- a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDxvk.cs +++ b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDxvk.cs @@ -26,16 +26,6 @@ public SettingsTabDxvk() return null; }, }, - wineD3DUseVk = new SettingsEntry("Use WineD3D Vulkan renderer", "Use Vulkan instead of OpenGL for WineD3D. Unstable. May cause system to lock up.", () => Program.Config.WineD3DUseVK ?? false, b => Program.Config.WineD3DUseVK = b) - { - CheckVisibility = () => dxvkVersionSetting.Value == DxvkVersion.Disabled, - CheckWarning = b => - { - if (b) - return "WARNING! This is very experimental, and may cause your system to crash or hang. If you still want to use it, disable Dalamud."; - return null; - }, - }, new SettingsEntry("Enable DXVK ASYNC", "Enable DXVK ASYNC patch.", () => Program.Config.DxvkAsyncEnabled ?? true, b => Program.Config.DxvkAsyncEnabled = b) { CheckVisibility = () => (new [] {DxvkVersion.v1_10_3, DxvkVersion.v2_0}.Contains(dxvkVersionSetting.Value)), @@ -48,7 +38,7 @@ public SettingsTabDxvk() }, dxvkHudSetting = new SettingsEntry("DXVK Overlay", "DXVK Hud is included with Dxvk. It doesn't work if Dxvk is disabled.\nMangoHud must be installed separately. Flatpak XIVLauncher needs flatpak MangoHud.", () => Program.Config.DxvkHudType, type => Program.Config.DxvkHudType = type) { - CheckVisibility = () => dxvkVersionSetting.Value != DxvkVersion.Disabled || wineD3DUseVk.Value, + CheckVisibility = () => dxvkVersionSetting.Value != DxvkVersion.Disabled, CheckValidity = type => { if ((type == DxvkHudType.MangoHud || type == DxvkHudType.MangoHudCustom || type == DxvkHudType.MangoHudFull) diff --git a/src/XIVLauncher.Core/Configuration/ILauncherConfig.cs b/src/XIVLauncher.Core/Configuration/ILauncherConfig.cs index 48afb0c1..3c10bdbf 100644 --- a/src/XIVLauncher.Core/Configuration/ILauncherConfig.cs +++ b/src/XIVLauncher.Core/Configuration/ILauncherConfig.cs @@ -68,8 +68,6 @@ public interface ILauncherConfig public DxvkVersion? DxvkVersion { get; set; } - public bool? WineD3DUseVK { get; set; } - public string? WineBinaryPath { get; set; } public bool? GameModeEnabled { get; set; } diff --git a/src/XIVLauncher.Core/DxvkManager.cs b/src/XIVLauncher.Core/DxvkManager.cs index f030c830..8acff5a1 100644 --- a/src/XIVLauncher.Core/DxvkManager.cs +++ b/src/XIVLauncher.Core/DxvkManager.cs @@ -25,7 +25,7 @@ public enum DxvkVersion [SettingsDescription("2.2 (No Async)", "Newest version of DXVK, using graphics pipeline library. No Async patch.")] v2_2, - [SettingsDescription("Disabled", "Disable Dxvk, use WineD3D / OpenGL instead.")] + [SettingsDescription("Disabled", "Disable Dxvk, use WineD3D with OpenGL instead.")] Disabled, } @@ -119,13 +119,6 @@ public static DxvkSettings Initialize() } var hudType = Program.Config.DxvkHudType; - if (!isDxvk) - { - if (!Program.Config.WineD3DUseVK.Value) - hudType = DxvkHudType.None; - else if (new [] {DxvkHudType.Custom, DxvkHudType.Fps, DxvkHudType.Full}.Contains(Program.Config.DxvkHudType)) - hudType = DxvkHudType.None; - } var dxvkHudCustom = Program.Config.DxvkHudCustom ?? "fps,frametimes,gpuload,version"; var mangoHudConfig = string.IsNullOrEmpty(Program.Config.DxvkMangoCustom) ? null : new FileInfo(Program.Config.DxvkMangoCustom); switch (hudType) diff --git a/src/XIVLauncher.Core/Program.cs b/src/XIVLauncher.Core/Program.cs index 3c96d139..3fe265c7 100644 --- a/src/XIVLauncher.Core/Program.cs +++ b/src/XIVLauncher.Core/Program.cs @@ -117,7 +117,6 @@ private static void LoadConfig(Storage storage) Config.GameModeEnabled ??= false; Config.DxvkVersion ??= DxvkVersion.v1_10_3; - Config.WineD3DUseVK ??= false; Config.DxvkAsyncEnabled ??= true; Config.DxvkFrameRate ??= 0; Config.ESyncEnabled ??= true; From f7162a461c9a86634c30be123d38fc35cc625d67 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Wed, 28 Jun 2023 18:22:29 -0700 Subject: [PATCH 21/33] Move Wine, Dxvk, Distro to UnixCompatibility * Also split out Hud settings from Dxvk * Renamed some vars and funcs for better clarity * Removed some duplicate functions * Hopefully made a bit more platform independant. --- .../Components/MainPage/MainPage.cs | 1 + .../SettingsPage/Tabs/SettingsTabDebug.cs | 3 +- .../SettingsPage/Tabs/SettingsTabDxvk.cs | 18 +-- .../SettingsPage/Tabs/SettingsTabWine.cs | 1 + .../Configuration/ILauncherConfig.cs | 5 +- src/XIVLauncher.Core/Distro.cs | 33 +++-- src/XIVLauncher.Core/Program.cs | 12 +- .../UnixCompatibility/DxvkManager.cs | 105 ++++++++++++++++ .../HudManager.cs} | 119 +++++------------- .../{ => UnixCompatibility}/WineManager.cs | 9 +- 10 files changed, 186 insertions(+), 120 deletions(-) create mode 100644 src/XIVLauncher.Core/UnixCompatibility/DxvkManager.cs rename src/XIVLauncher.Core/{DxvkManager.cs => UnixCompatibility/HudManager.cs} (52%) rename src/XIVLauncher.Core/{ => UnixCompatibility}/WineManager.cs (93%) diff --git a/src/XIVLauncher.Core/Components/MainPage/MainPage.cs b/src/XIVLauncher.Core/Components/MainPage/MainPage.cs index d529bbc0..df615f48 100644 --- a/src/XIVLauncher.Core/Components/MainPage/MainPage.cs +++ b/src/XIVLauncher.Core/Components/MainPage/MainPage.cs @@ -19,6 +19,7 @@ using XIVLauncher.Core.Accounts; using XIVLauncher.Common.Game.Exceptions; using XIVLauncher.Core.Support; +using XIVLauncher.Core.UnixCompatibility; namespace XIVLauncher.Core.Components.MainPage; diff --git a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDebug.cs b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDebug.cs index e042574a..2abacd9f 100644 --- a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDebug.cs +++ b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDebug.cs @@ -1,5 +1,6 @@ using System.Collections; using ImGuiNET; +using XIVLauncher.Core.UnixCompatibility; namespace XIVLauncher.Core.Components.SettingsPage.Tabs; @@ -23,8 +24,6 @@ public override void Draw() if (Distro.IsFlatpak) ImGui.Text("Running as a Flatpak"); - else - ImGui.Text("Running a native build"); ImGui.Spacing(); diff --git a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDxvk.cs b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDxvk.cs index 0d086910..99bebd02 100644 --- a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDxvk.cs +++ b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDxvk.cs @@ -4,6 +4,7 @@ using ImGuiNET; using XIVLauncher.Common.Unix.Compatibility; using XIVLauncher.Common.Util; +using XIVLauncher.Core.UnixCompatibility; namespace XIVLauncher.Core.Components.SettingsPage.Tabs; @@ -11,7 +12,7 @@ public class SettingsTabDxvk : SettingsTab { private SettingsEntry dxvkVersionSetting; private SettingsEntry wineD3DUseVk; - private SettingsEntry dxvkHudSetting; + private SettingsEntry hudSetting; public SettingsTabDxvk() { @@ -36,13 +37,14 @@ public SettingsTabDxvk() return null; }, }, - dxvkHudSetting = new SettingsEntry("DXVK Overlay", "DXVK Hud is included with Dxvk. It doesn't work if Dxvk is disabled.\nMangoHud must be installed separately. Flatpak XIVLauncher needs flatpak MangoHud.", () => Program.Config.DxvkHudType, type => Program.Config.DxvkHudType = type) + hudSetting = new SettingsEntry("DXVK Overlay", "DXVK Hud is included with Dxvk. It doesn't work if Dxvk is disabled.\nMangoHud must be installed separately. Flatpak XIVLauncher needs flatpak MangoHud.", () => Program.Config.HudType, type => Program.Config.HudType = type) { CheckVisibility = () => dxvkVersionSetting.Value != DxvkVersion.Disabled, CheckValidity = type => { - if ((type == DxvkHudType.MangoHud || type == DxvkHudType.MangoHudCustom || type == DxvkHudType.MangoHudFull) - && (!File.Exists("/usr/lib/mangohud/libMangoHud.so") && !File.Exists("/usr/lib64/mangohud/libMangoHud.so") && !File.Exists("/usr/lib/extensions/vulkan/MangoHud/lib/x86_64-linux-gnu/libMangoHud.so"))) + if ((type == HudType.MangoHud || type == HudType.MangoHudCustom || type == HudType.MangoHudFull) + && (HudManager.FindMangoHud() is null)) + // (!File.Exists("/usr/lib/mangohud/libMangoHud.so") && !File.Exists("/usr/lib64/mangohud/libMangoHud.so") && !File.Exists("/usr/lib/extensions/vulkan/MangoHud/lib/x86_64-linux-gnu/libMangoHud.so"))) return "MangoHud not detected."; return null; @@ -50,17 +52,17 @@ public SettingsTabDxvk() }, new SettingsEntry("DXVK Hud Custom String", "Set a custom string for the built in DXVK Hud. Warning: If it's invalid, the game may hang.", () => Program.Config.DxvkHudCustom, s => Program.Config.DxvkHudCustom = s) { - CheckVisibility = () => dxvkHudSetting.Value == DxvkHudType.Custom && dxvkVersionSetting.Value != DxvkVersion.Disabled, + CheckVisibility = () => hudSetting.Value == HudType.Custom && dxvkVersionSetting.Value != DxvkVersion.Disabled, CheckWarning = s => { - if(!DxvkManager.CheckDxvkHudString(s)) + if(!HudManager.CheckDxvkHudString(s)) return "That's not a valid hud string"; return null; }, }, - new SettingsEntry("MangoHud Custom Path", "Set a custom path for MangoHud config file.", () => Program.Config.DxvkMangoCustom, s => Program.Config.DxvkMangoCustom = s) + new SettingsEntry("MangoHud Custom Path", "Set a custom path for MangoHud config file.", () => Program.Config.MangoHudCustom, s => Program.Config.MangoHudCustom = s) { - CheckVisibility = () => dxvkHudSetting.Value == DxvkHudType.MangoHudCustom && !(dxvkVersionSetting.Value == DxvkVersion.Disabled && !wineD3DUseVk.Value), + CheckVisibility = () => hudSetting.Value == HudType.MangoHudCustom && !(dxvkVersionSetting.Value == DxvkVersion.Disabled && !wineD3DUseVk.Value), CheckWarning = s => { if(!File.Exists(s)) diff --git a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabWine.cs b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabWine.cs index a8125c63..2acc1662 100644 --- a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabWine.cs +++ b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabWine.cs @@ -3,6 +3,7 @@ using ImGuiNET; using XIVLauncher.Common.Unix.Compatibility; using XIVLauncher.Common.Util; +using XIVLauncher.Core.UnixCompatibility; namespace XIVLauncher.Core.Components.SettingsPage.Tabs; diff --git a/src/XIVLauncher.Core/Configuration/ILauncherConfig.cs b/src/XIVLauncher.Core/Configuration/ILauncherConfig.cs index 3c10bdbf..2ed63a51 100644 --- a/src/XIVLauncher.Core/Configuration/ILauncherConfig.cs +++ b/src/XIVLauncher.Core/Configuration/ILauncherConfig.cs @@ -3,6 +3,7 @@ using XIVLauncher.Common.Dalamud; using XIVLauncher.Common.Game.Patch.Acquisition; using XIVLauncher.Common.Unix.Compatibility; +using XIVLauncher.Core.UnixCompatibility; namespace XIVLauncher.Core.Configuration; @@ -78,11 +79,11 @@ public interface ILauncherConfig public bool? FSyncEnabled { get; set; } - public DxvkHudType DxvkHudType { get; set; } + public HudType HudType { get; set; } public string? DxvkHudCustom { get; set; } - public string? DxvkMangoCustom { get; set; } + public string? MangoHudCustom { get; set; } public int? DxvkFrameRate { get; set; } diff --git a/src/XIVLauncher.Core/Distro.cs b/src/XIVLauncher.Core/Distro.cs index 0eb6dc43..89538fa2 100644 --- a/src/XIVLauncher.Core/Distro.cs +++ b/src/XIVLauncher.Core/Distro.cs @@ -2,38 +2,49 @@ using System.IO; using System.Collections.Generic; -namespace XIVLauncher.Core; +namespace XIVLauncher.Core.UnixCompatibility; -public enum WinePackage +public enum DistroPackage { ubuntu, fedora, arch, + + none, } public static class Distro { - public static WinePackage Package { get; private set; } + public static DistroPackage Package { get; private set; } public static string Name { get; private set; } public static bool IsFlatpak { get; private set; } - public static void GetInfo() + public static void UseWindows() + { + Package = DistroPackage.none; + OperatingSystem os = System.Environment.OSVersion; + Name = os.VersionString; + IsFlatpak = false; + + } + + public static void UseUnix() { try { if (!File.Exists("/etc/os-release")) { - Package = WinePackage.ubuntu; + Package = DistroPackage.ubuntu; Name = "Unknown distribution"; IsFlatpak = false; return; } var osRelease = File.ReadAllLines("/etc/os-release"); - var distro = WinePackage.ubuntu; + var distro = DistroPackage.ubuntu; var flatpak = false; var OSInfo = new Dictionary(); foreach (var line in osRelease) @@ -49,15 +60,15 @@ public static void GetInfo() var pretty = (OSInfo.ContainsKey("PRETTY_NAME") ? OSInfo["PRETTY_NAME"] : "").Trim('"'); var idLike = OSInfo.ContainsKey("ID_LIKE") ? OSInfo["ID_LIKE"] : ""; if (idLike.Contains("arch")) - distro = WinePackage.arch; + distro = DistroPackage.arch; else if (idLike.Contains("fedora")) - distro = WinePackage.fedora; + distro = DistroPackage.fedora; else - distro = WinePackage.ubuntu; + distro = DistroPackage.ubuntu; var id = OSInfo.ContainsKey("ID") ? OSInfo["ID"] : ""; if (id.Contains("tumbleweed") || id.Contains("fedora")) - distro = WinePackage.fedora; + distro = DistroPackage.fedora; if (id == "org.freedesktop.platform") flatpak = true; @@ -68,7 +79,7 @@ public static void GetInfo() catch { // If there's any kind of error opening the file or even finding it, just go with default. - Package = WinePackage.ubuntu; + Package = DistroPackage.ubuntu; Name = "Unknown distribution"; IsFlatpak = false; } diff --git a/src/XIVLauncher.Core/Program.cs b/src/XIVLauncher.Core/Program.cs index 3fe265c7..facc164e 100644 --- a/src/XIVLauncher.Core/Program.cs +++ b/src/XIVLauncher.Core/Program.cs @@ -22,6 +22,7 @@ using XIVLauncher.Core.Components.LoadingPage; using XIVLauncher.Core.Configuration; using XIVLauncher.Core.Configuration.Parsers; +using XIVLauncher.Core.UnixCompatibility; namespace XIVLauncher.Core; @@ -75,7 +76,6 @@ private static void SetupLogging(string[] args) Log.Information("========================================================"); Log.Information("Starting a session(v{Version} - {Hash})", AppUtil.GetAssemblyVersion(), AppUtil.GetGitHash()); - Log.Information("Running on {DistroName}, wine package set to {DistroPackage}", Distro.Name, Distro.Package.ToString()); } private static void LoadConfig(Storage storage) @@ -122,7 +122,7 @@ private static void LoadConfig(Storage storage) Config.ESyncEnabled ??= true; Config.FSyncEnabled ??= false; Config.DxvkHudCustom ??= "fps,frametimes,gpuload,version"; - Config.DxvkMangoCustom ??= Path.Combine(Environment.GetEnvironmentVariable("HOME"), ".config", "MangoHud", "MangoHud.conf"); + Config.MangoHudCustom ??= Path.Combine(Environment.GetEnvironmentVariable("HOME"), ".config", "MangoHud", "MangoHud.conf"); Config.SetWin7 ??= true; Config.WineType ??= WineType.Managed; @@ -154,7 +154,6 @@ private static void Main(string[] args) if (CoreEnvironmentSettings.ClearLogs) ClearLogs(); } - Distro.GetInfo(); SetupLogging(mainargs); LoadConfig(storage); @@ -184,15 +183,18 @@ private static void Main(string[] args) { case PlatformID.Win32NT: Steam = new WindowsSteam(); + Distro.UseWindows(); break; case PlatformID.Unix: Steam = new UnixSteam(); + Distro.UseUnix(); break; default: throw new PlatformNotSupportedException(); } + Log.Information("Running on {DistroName}. {wineInfo}", Distro.Name, (Distro.Package == DistroPackage.none) ? string.Empty : $"Using {Distro.Package} for managed wine downloads."); if (!Config.IsIgnoringSteam ?? true) { try @@ -324,8 +326,8 @@ public static void CreateCompatToolsInstance() var wineLogFile = new FileInfo(Path.Combine(storage.GetFolder("logs").FullName, "wine.log")); var winePrefix = storage.GetFolder("wineprefix"); var toolsFolder = storage.GetFolder("compatibilitytool"); - var wine = WineManager.Initialize(); - var dxvk = DxvkManager.Initialize(); + var wine = WineManager.GetSettings(); + var dxvk = DxvkManager.GetSettings(); CompatibilityTools = new CompatibilityTools(wine, dxvk, winePrefix, toolsFolder, wineLogFile, Distro.IsFlatpak); } diff --git a/src/XIVLauncher.Core/UnixCompatibility/DxvkManager.cs b/src/XIVLauncher.Core/UnixCompatibility/DxvkManager.cs new file mode 100644 index 00000000..7620c43f --- /dev/null +++ b/src/XIVLauncher.Core/UnixCompatibility/DxvkManager.cs @@ -0,0 +1,105 @@ +using System; +using System.Collections.Generic; +using System.Collections.Specialized; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Text.RegularExpressions; +using Serilog; +using XIVLauncher.Common; +using XIVLauncher.Common.Unix.Compatibility; + +namespace XIVLauncher.Core.UnixCompatibility; + +public enum DxvkVersion +{ + [SettingsDescription("1.10.3 (default)", "Current version of 1.10 branch of DXVK.")] + v1_10_3, + + [SettingsDescription("2.0", "Newer version of DXVK. Last version with Async patch")] + v2_0, + + [SettingsDescription("2.1 (No Async)", "Newer version of DXVK, using graphics pipeline library. No Async patch.")] + v2_1, + + [SettingsDescription("2.2 (No Async)", "Newest version of DXVK, using graphics pipeline library. No Async patch.")] + v2_2, + + [SettingsDescription("Disabled", "Disable Dxvk, use WineD3D with OpenGL instead.")] + Disabled, +} + +public static class DxvkManager +{ + public static DxvkSettings GetSettings() + { + var isDxvk = true; + var folder = ""; + var url = ""; + var rootfolder = Program.storage.Root.FullName; + var dxvkfolder = Path.Combine(rootfolder, "compatibilitytool", "dxvk"); + var async = (Program.Config.DxvkAsyncEnabled ?? true) ? "1" : "0"; + var framerate = Program.Config.DxvkFrameRate ?? 0; + var env = new Dictionary + { + { "DXVK_LOG_PATH", Path.Combine(rootfolder, "logs") }, + { "DXVK_CONFIG_FILE", Path.Combine(dxvkfolder, "dxvk.conf") }, + }; + if (framerate != 0) + env.Add("DXVK_FRAME_RATE", framerate.ToString()); + switch (Program.Config.DxvkVersion) + { + case DxvkVersion.v1_10_3: + folder = "dxvk-async-1.10.3"; + url = "https://github.com/Sporif/dxvk-async/releases/download/1.10.3/dxvk-async-1.10.3.tar.gz"; + env.Add("DXVK_ASYNC", async); + break; + + case DxvkVersion.v2_0: + folder = "dxvk-async-2.0"; + url = "https://github.com/Sporif/dxvk-async/releases/download/2.0/dxvk-async-2.0.tar.gz"; + env.Add("DXVK_ASYNC", async); + break; + + case DxvkVersion.v2_1: + folder = "dxvk-2.1"; + url = "https://github.com/doitsujin/dxvk/releases/download/v2.1/dxvk-2.1.tar.gz"; + break; + + case DxvkVersion.v2_2: + folder = "dxvk-2.2"; + url = "https://github.com/doitsujin/dxvk/releases/download/v2.2/dxvk-2.2.tar.gz"; + break; + + + case DxvkVersion.Disabled: + env.Add("PROTON_USE_WINED3D", "1"); + env.Add("MANGHUD_DLSYM", "1"); + isDxvk = false; + break; + + default: + throw new ArgumentOutOfRangeException("Bad value for DxvkVersion"); + } + + if (isDxvk) + { + var dxvkCachePath = new DirectoryInfo(Path.Combine(dxvkfolder, "cache")); + if (!dxvkCachePath.Exists) dxvkCachePath.Create(); + env.Add("DXVK_STATE_CACHE_PATH", Path.Combine(dxvkCachePath.FullName, folder)); + } + + var hud = HudManager.GetSettings(); + foreach (var kvp in hud) + { + if (env.ContainsKey(kvp.Key)) + env[kvp.Key] = kvp.Value; + else + env.Add(kvp.Key, kvp.Value); + } + + var settings = new DxvkSettings(folder, url, Program.storage.Root.FullName, env, isDxvk); + return settings; + } +} + diff --git a/src/XIVLauncher.Core/DxvkManager.cs b/src/XIVLauncher.Core/UnixCompatibility/HudManager.cs similarity index 52% rename from src/XIVLauncher.Core/DxvkManager.cs rename to src/XIVLauncher.Core/UnixCompatibility/HudManager.cs index 8acff5a1..be372878 100644 --- a/src/XIVLauncher.Core/DxvkManager.cs +++ b/src/XIVLauncher.Core/UnixCompatibility/HudManager.cs @@ -9,27 +9,9 @@ using XIVLauncher.Common; using XIVLauncher.Common.Unix.Compatibility; -namespace XIVLauncher.Core; +namespace XIVLauncher.Core.UnixCompatibility; -public enum DxvkVersion -{ - [SettingsDescription("1.10.3 (default)", "Current version of 1.10 branch of DXVK.")] - v1_10_3, - - [SettingsDescription("2.0", "Newer version of DXVK. Last version with Async patch")] - v2_0, - - [SettingsDescription("2.1 (No Async)", "Newer version of DXVK, using graphics pipeline library. No Async patch.")] - v2_1, - - [SettingsDescription("2.2 (No Async)", "Newest version of DXVK, using graphics pipeline library. No Async patch.")] - v2_2, - - [SettingsDescription("Disabled", "Disable Dxvk, use WineD3D with OpenGL instead.")] - Disabled, -} - -public enum DxvkHudType +public enum HudType { [SettingsDescription("None", "Show nothing")] None, @@ -53,100 +35,50 @@ public enum DxvkHudType MangoHudFull, } -public static class DxvkManager +public static class HudManager { private const string ALLOWED_CHARS = "^[0-9a-zA-Z,=.]+$"; private const string ALLOWED_WORDS = "^(?:devinfo|fps|frametimes|submissions|drawcalls|pipelines|descriptors|memory|gpuload|version|api|cs|compiler|samplers|scale=(?:[0-9])*(?:.(?:[0-9])+)?)$"; - - public static DxvkSettings Initialize() + public static Dictionary GetSettings() { - var isDxvk = true; - var folder = ""; - var url = ""; var rootfolder = Program.storage.Root.FullName; - var dxvkfolder = Path.Combine(rootfolder, "compatibilitytool", "dxvk"); - var async = (Program.Config.DxvkAsyncEnabled ?? true) ? "1" : "0"; - var framerate = Program.Config.DxvkFrameRate ?? 0; - var env = new Dictionary - { - { "DXVK_LOG_PATH", Path.Combine(rootfolder, "logs") }, - { "DXVK_CONFIG_FILE", Path.Combine(dxvkfolder, "dxvk.conf") }, - }; - if (framerate != 0) - env.Add("DXVK_FRAME_RATE", framerate.ToString()); - switch (Program.Config.DxvkVersion) - { - case DxvkVersion.v1_10_3: - folder = "dxvk-async-1.10.3"; - url = "https://github.com/Sporif/dxvk-async/releases/download/1.10.3/dxvk-async-1.10.3.tar.gz"; - env.Add("DXVK_ASYNC", async); - break; - - case DxvkVersion.v2_0: - folder = "dxvk-async-2.0"; - url = "https://github.com/Sporif/dxvk-async/releases/download/2.0/dxvk-async-2.0.tar.gz"; - env.Add("DXVK_ASYNC", async); - break; - - case DxvkVersion.v2_1: - folder = "dxvk-2.1"; - url = "https://github.com/doitsujin/dxvk/releases/download/v2.1/dxvk-2.1.tar.gz"; - break; - - case DxvkVersion.v2_2: - folder = "dxvk-2.2"; - url = "https://github.com/doitsujin/dxvk/releases/download/v2.2/dxvk-2.2.tar.gz"; - break; - - - case DxvkVersion.Disabled: - env.Add("PROTON_USE_WINED3D", "1"); - env.Add("MANGHUD_DLSYM", "1"); - isDxvk = false; - break; - - default: - throw new ArgumentOutOfRangeException("Bad value for DxvkVersion"); - } - - if (isDxvk) + var env = new Dictionary(); + var hudType = Program.Config.HudType; + if (FindMangoHud() is null && new [] {HudType.MangoHud, HudType.MangoHudCustom, HudType.MangoHudFull}.Contains(hudType)) { - var dxvkCachePath = new DirectoryInfo(Path.Combine(dxvkfolder, "cache")); - if (!dxvkCachePath.Exists) dxvkCachePath.Create(); - env.Add("DXVK_STATE_CACHE_PATH", Path.Combine(dxvkCachePath.FullName, folder)); + hudType = HudType.None; + Program.Config.HudType = HudType.None; } - - var hudType = Program.Config.DxvkHudType; var dxvkHudCustom = Program.Config.DxvkHudCustom ?? "fps,frametimes,gpuload,version"; - var mangoHudConfig = string.IsNullOrEmpty(Program.Config.DxvkMangoCustom) ? null : new FileInfo(Program.Config.DxvkMangoCustom); + var mangoHudConfig = string.IsNullOrEmpty(Program.Config.MangoHudCustom) ? null : new FileInfo(Program.Config.MangoHudCustom); switch (hudType) { - case DxvkHudType.Fps: + case HudType.Fps: env.Add("DXVK_HUD","fps"); env.Add("MANGOHUD","0"); break; - case DxvkHudType.Custom: + case HudType.Custom: if (!CheckDxvkHudString(Program.Config.DxvkHudCustom)) dxvkHudCustom = "fps,frametimes,gpuload,version"; env.Add("DXVK_HUD", Program.Config.DxvkHudCustom); env.Add("MANGOHUD","0"); break; - case DxvkHudType.Full: + case HudType.Full: env.Add("DXVK_HUD","full"); env.Add("MANGOHUD","0"); break; - case DxvkHudType.MangoHud: + case HudType.MangoHud: env.Add("DXVK_HUD","0"); env.Add("MANGOHUD","1"); env.Add("MANGOHUD_CONFIG", ""); break; - case DxvkHudType.MangoHudCustom: + case HudType.MangoHudCustom: env.Add("DXVK_HUD","0"); env.Add("MANGOHUD","1"); @@ -170,21 +102,20 @@ public static DxvkSettings Initialize() env.Add("MANGOHUD_CONFIG", ""); break; - case DxvkHudType.MangoHudFull: + case HudType.MangoHudFull: env.Add("DXVK_HUD","0"); env.Add("MANGOHUD","1"); env.Add("MANGOHUD_CONFIG","full"); break; - case DxvkHudType.None: + case HudType.None: break; default: throw new ArgumentOutOfRangeException(); } - var settings = new DxvkSettings(folder, url, Program.storage.Root.FullName, env, isDxvk); - return settings; + return env; } public static bool CheckDxvkHudString(string? customHud) @@ -197,5 +128,17 @@ public static bool CheckDxvkHudString(string? customHud) return hudvars.All(hudvar => Regex.IsMatch(hudvar, ALLOWED_WORDS)); } -} + public static string? FindMangoHud() + { + var usrLib = Path.Combine("/usr", "lib", "mangohud", "libMangoHud.so"); // fedora uses this + var usrLib64 = Path.Combine("/usr", "lib64", "mangohud", "libMangoHud.so"); // arch and openSUSE use this + var flatpak = Path.Combine(new string[] { "/usr", "lib", "extensions", "vulkan", "lib", "x86_64-linux-gnu", "libMangoHud.so"}); + var debuntu = Path.Combine(new string[] { "/usr", "lib", "x86_64-linux-gnu", "mangohud", "libMangoHud.so"}); + if (File.Exists(usrLib64)) return usrLib64; + if (File.Exists(usrLib)) return usrLib; + if (File.Exists(flatpak)) return flatpak; + if (File.Exists(debuntu)) return debuntu; + return null; + } +} \ No newline at end of file diff --git a/src/XIVLauncher.Core/WineManager.cs b/src/XIVLauncher.Core/UnixCompatibility/WineManager.cs similarity index 93% rename from src/XIVLauncher.Core/WineManager.cs rename to src/XIVLauncher.Core/UnixCompatibility/WineManager.cs index b30e106b..77ea1143 100644 --- a/src/XIVLauncher.Core/WineManager.cs +++ b/src/XIVLauncher.Core/UnixCompatibility/WineManager.cs @@ -8,7 +8,7 @@ using XIVLauncher.Common; using XIVLauncher.Common.Unix.Compatibility; -namespace XIVLauncher.Core; +namespace XIVLauncher.Core.UnixCompatibility; public enum WineType { @@ -30,12 +30,13 @@ public enum WineVersion public static class WineManager { - public static WineSettings Initialize() + public static WineSettings GetSettings() { var winepath = ""; var folder = ""; var url = ""; var version = Program.Config.WineVersion ?? WineVersion.Wine8_5; + var package = Distro.Package.ToString(); switch (Program.Config.WineType ?? WineType.Managed) { case WineType.Custom: @@ -53,12 +54,12 @@ public static WineSettings Initialize() { case WineVersion.Wine8_5: folder = "wine-xiv-staging-fsync-git-8.5.r4.g4211bac7"; - url = $"https://github.com/goatcorp/wine-xiv-git/releases/download/8.5.r4.g4211bac7/wine-xiv-staging-fsync-git-{Distro.Package.ToString()}-8.5.r4.g4211bac7.tar.xz"; + url = $"https://github.com/goatcorp/wine-xiv-git/releases/download/8.5.r4.g4211bac7/wine-xiv-staging-fsync-git-{package}-8.5.r4.g4211bac7.tar.xz"; break; case WineVersion.Wine7_10: folder = "wine-xiv-staging-fsync-git-7.10.r3.g560db77d"; - url = $"https://github.com/goatcorp/wine-xiv-git/releases/download/7.10.r3.g560db77d/wine-xiv-staging-fsync-git-{Distro.Package.ToString()}-7.10.r3.g560db77d.tar.xz"; + url = $"https://github.com/goatcorp/wine-xiv-git/releases/download/7.10.r3.g560db77d/wine-xiv-staging-fsync-git-{package}-7.10.r3.g560db77d.tar.xz"; break; default: From 64a3a6274718542d9cfdf384f4061e51d945eac0 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Wed, 28 Jun 2023 18:23:07 -0700 Subject: [PATCH 22/33] Cleaned up some Distro-related stuff. --- .../Components/SettingsPage/Tabs/SettingsTabDebug.cs | 5 ++++- src/XIVLauncher.Core/Distro.cs | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDebug.cs b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDebug.cs index 2abacd9f..76739fe9 100644 --- a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDebug.cs +++ b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDebug.cs @@ -13,7 +13,10 @@ public override void Draw() { ImGui.TextUnformatted("Generic Information"); ImGui.Separator(); - ImGui.TextUnformatted($"Operating System: {Distro.Name} - {Environment.OSVersion}"); + if (Distro.IsLinux) + ImGui.TextUnformatted($"Operating System: {Distro.Name} - {Environment.OSVersion}"); + else + ImGui.TextUnformatted($"Operating System: {Environment.OSVersion}"); ImGui.TextUnformatted($"Runtime Version: {Environment.Version}"); if (Program.IsSteamDeckHardware) diff --git a/src/XIVLauncher.Core/Distro.cs b/src/XIVLauncher.Core/Distro.cs index 89538fa2..597b265c 100644 --- a/src/XIVLauncher.Core/Distro.cs +++ b/src/XIVLauncher.Core/Distro.cs @@ -23,17 +23,21 @@ public static class Distro public static bool IsFlatpak { get; private set; } + public static bool IsLinux { get; private set; } + public static void UseWindows() { Package = DistroPackage.none; OperatingSystem os = System.Environment.OSVersion; Name = os.VersionString; IsFlatpak = false; + IsLinux = false; } public static void UseUnix() { + IsLinux = true; try { if (!File.Exists("/etc/os-release")) From ea617f28cd40494f1c1c0650d042f2e252720e84 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Wed, 28 Jun 2023 18:24:35 -0700 Subject: [PATCH 23/33] Update submodule --- lib/FFXIVQuickLauncher | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/FFXIVQuickLauncher b/lib/FFXIVQuickLauncher index c6353d5a..9284ecb2 160000 --- a/lib/FFXIVQuickLauncher +++ b/lib/FFXIVQuickLauncher @@ -1 +1 @@ -Subproject commit c6353d5a2c1b52415556994cfdca00d349981202 +Subproject commit 9284ecb2b76c5f2670ece85f8750b30dbb919d5f From c80b205e535d54c0c9c916c21d35d927bdd9bda4 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Wed, 28 Jun 2023 19:23:19 -0700 Subject: [PATCH 24/33] Touched up the Wine Tab * Added button for explorer with WineD3D * Changed SetWin7 to two buttons to set windows type quickly --- .../Components/MainPage/MainPage.cs | 2 -- .../SettingsPage/Tabs/SettingsTabWine.cs | 30 ++++++++++++++++++- .../Configuration/ILauncherConfig.cs | 2 -- src/XIVLauncher.Core/Program.cs | 1 - 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/XIVLauncher.Core/Components/MainPage/MainPage.cs b/src/XIVLauncher.Core/Components/MainPage/MainPage.cs index df615f48..f508f07f 100644 --- a/src/XIVLauncher.Core/Components/MainPage/MainPage.cs +++ b/src/XIVLauncher.Core/Components/MainPage/MainPage.cs @@ -757,10 +757,8 @@ public async Task StartGameAndAddon(Launcher.LoginResult loginResult, b var _ = Task.Run(async () => { var tempPath = App.Storage.GetFolder("temp"); - var winver = (App.Settings.SetWin7 ?? true) ? "win7" : "win10"; await Program.CompatibilityTools.EnsureTool(tempPath).ConfigureAwait(false); - Program.CompatibilityTools.RunInPrefix($"winecfg /v {winver}"); var gameFixApply = new GameFixApply(App.Settings.GamePath, App.Settings.GameConfigPath, Program.CompatibilityTools.Prefix, tempPath); gameFixApply.UpdateProgress += (text, hasProgress, progress) => diff --git a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabWine.cs b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabWine.cs index 2acc1662..a48a22ad 100644 --- a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabWine.cs +++ b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabWine.cs @@ -55,7 +55,6 @@ public SettingsTabWine() return null; } }, - new SettingsEntry("Set Windows version to 7", "Default for Wine 8.1+ is Windows 10, but this can cause issues with some Dalamud plugins. Windows 7 is recommended for now.", () => Program.Config.SetWin7 ?? true, b => Program.Config.SetWin7 = b), new SettingsEntry("WINEDEBUG Variables", "Configure debug logging for wine. Useful for troubleshooting.", () => Program.Config.WineDebugVars ?? string.Empty, s => Program.Config.WineDebugVars = s) }; } @@ -70,6 +69,10 @@ public override void Draw() { base.Draw(); + ImGui.Separator(); + + ImGui.Dummy(new Vector2(10) * ImGuiHelpers.GlobalScale); + if (!Program.CompatibilityTools.IsToolDownloaded) { ImGui.BeginDisabled(); @@ -97,6 +100,31 @@ public override void Draw() Program.CompatibilityTools.RunInPrefix("explorer"); } + ImGui.SameLine(); + + if (ImGui.Button("Open Wine explorer (use WineD3D")) + { + Program.CompatibilityTools.RunInPrefix("explorer", wineD3D: true); + + } + + ImGui.Dummy(new Vector2(10) * ImGuiHelpers.GlobalScale); + + + if (ImGui.Button("Set Wine to Windows 7")) + { + Program.CompatibilityTools.RunInPrefix($"winecfg /v win7", redirectOutput: true, writeLog: true); + } + + ImGui.SameLine(); + + if (ImGui.Button("Set Wine to Windows 10")) + { + Program.CompatibilityTools.RunInPrefix($"winecfg /v win10", redirectOutput: true, writeLog: true); + } + + ImGui.Dummy(new Vector2(10) * ImGuiHelpers.GlobalScale); + if (ImGui.Button("Kill all wine processes")) { Program.CompatibilityTools.Kill(); diff --git a/src/XIVLauncher.Core/Configuration/ILauncherConfig.cs b/src/XIVLauncher.Core/Configuration/ILauncherConfig.cs index 2ed63a51..53edaf9f 100644 --- a/src/XIVLauncher.Core/Configuration/ILauncherConfig.cs +++ b/src/XIVLauncher.Core/Configuration/ILauncherConfig.cs @@ -93,8 +93,6 @@ public interface ILauncherConfig public bool? FixIM { get; set; } - public bool? SetWin7 { get; set; } - #endregion #region Dalamud diff --git a/src/XIVLauncher.Core/Program.cs b/src/XIVLauncher.Core/Program.cs index facc164e..a4b4eec8 100644 --- a/src/XIVLauncher.Core/Program.cs +++ b/src/XIVLauncher.Core/Program.cs @@ -123,7 +123,6 @@ private static void LoadConfig(Storage storage) Config.FSyncEnabled ??= false; Config.DxvkHudCustom ??= "fps,frametimes,gpuload,version"; Config.MangoHudCustom ??= Path.Combine(Environment.GetEnvironmentVariable("HOME"), ".config", "MangoHud", "MangoHud.conf"); - Config.SetWin7 ??= true; Config.WineType ??= WineType.Managed; Config.WineBinaryPath ??= "/usr/bin"; From c5331d0e06689e0636a166d62301b319f2932659 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Wed, 28 Jun 2023 19:36:54 -0700 Subject: [PATCH 25/33] Switch to using XIVLauncher.Common.Platform enum --- .../Components/SettingsPage/Tabs/SettingsTabDebug.cs | 3 ++- src/XIVLauncher.Core/Distro.cs | 9 +++++---- src/XIVLauncher.Core/Program.cs | 4 ++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDebug.cs b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDebug.cs index 76739fe9..dd12f0c6 100644 --- a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDebug.cs +++ b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDebug.cs @@ -1,5 +1,6 @@ using System.Collections; using ImGuiNET; +using XIVLauncher.Common; using XIVLauncher.Core.UnixCompatibility; namespace XIVLauncher.Core.Components.SettingsPage.Tabs; @@ -13,7 +14,7 @@ public override void Draw() { ImGui.TextUnformatted("Generic Information"); ImGui.Separator(); - if (Distro.IsLinux) + if (Distro.Platform == Platform.Linux) ImGui.TextUnformatted($"Operating System: {Distro.Name} - {Environment.OSVersion}"); else ImGui.TextUnformatted($"Operating System: {Environment.OSVersion}"); diff --git a/src/XIVLauncher.Core/Distro.cs b/src/XIVLauncher.Core/Distro.cs index 597b265c..1976d4c6 100644 --- a/src/XIVLauncher.Core/Distro.cs +++ b/src/XIVLauncher.Core/Distro.cs @@ -1,6 +1,7 @@ using System.Numerics; using System.IO; using System.Collections.Generic; +using XIVLauncher.Common; namespace XIVLauncher.Core.UnixCompatibility; @@ -23,7 +24,7 @@ public static class Distro public static bool IsFlatpak { get; private set; } - public static bool IsLinux { get; private set; } + public static Platform Platform { get; private set; } public static void UseWindows() { @@ -31,13 +32,13 @@ public static void UseWindows() OperatingSystem os = System.Environment.OSVersion; Name = os.VersionString; IsFlatpak = false; - IsLinux = false; + Platform = Platform.Win32; } - public static void UseUnix() + public static void UseLinux() { - IsLinux = true; + Platform = Platform.Linux; try { if (!File.Exists("/etc/os-release")) diff --git a/src/XIVLauncher.Core/Program.cs b/src/XIVLauncher.Core/Program.cs index a4b4eec8..fccdf5a6 100644 --- a/src/XIVLauncher.Core/Program.cs +++ b/src/XIVLauncher.Core/Program.cs @@ -187,13 +187,13 @@ private static void Main(string[] args) case PlatformID.Unix: Steam = new UnixSteam(); - Distro.UseUnix(); + Distro.UseLinux(); break; default: throw new PlatformNotSupportedException(); } - Log.Information("Running on {DistroName}. {wineInfo}", Distro.Name, (Distro.Package == DistroPackage.none) ? string.Empty : $"Using {Distro.Package} for managed wine downloads."); + Log.Information("Running on {DistroName}. {wineInfo}", Distro.Name, (Distro.Platform == Platform.Linux) ? $"Using {Distro.Package} for managed wine downloads." : string.Empty); if (!Config.IsIgnoringSteam ?? true) { try From f8a236b91eb7fe1012aca0ae051fe933bf0318fc Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Wed, 28 Jun 2023 20:21:53 -0700 Subject: [PATCH 26/33] Added some code in Distro for MacOS & FreeBSD. --- src/XIVLauncher.Core/Distro.cs | 39 +++++++++++++++++++++++++-------- src/XIVLauncher.Core/Program.cs | 3 +-- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/src/XIVLauncher.Core/Distro.cs b/src/XIVLauncher.Core/Distro.cs index 1976d4c6..bc975214 100644 --- a/src/XIVLauncher.Core/Distro.cs +++ b/src/XIVLauncher.Core/Distro.cs @@ -2,6 +2,7 @@ using System.IO; using System.Collections.Generic; using XIVLauncher.Common; +using System.Runtime.InteropServices; namespace XIVLauncher.Core.UnixCompatibility; @@ -26,18 +27,38 @@ public static class Distro public static Platform Platform { get; private set; } - public static void UseWindows() + public static void Initialize() { - Package = DistroPackage.none; - OperatingSystem os = System.Environment.OSVersion; - Name = os.VersionString; - IsFlatpak = false; - Platform = Platform.Win32; + var os = System.Environment.OSVersion; + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + Package = DistroPackage.none; + Name = os.VersionString; + IsFlatpak = false; + Platform = Platform.Win32; + return; + } - } + // There's no wine releases for MacOS or FreeBSD, and I'm not sure this will even compile on either + // platform, but here's some code just in case. Can modify this as needed if it's useful in the future. + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + Platform = Platform.Mac; + Name = os.VersionString; + IsFlatpak = false; + Package = DistroPackage.none; + return; + } + + if (RuntimeInformation.IsOSPlatform(OSPlatform.FreeBSD)) + { + Platform = Platform.Linux; // Don't have an option for this atm. + Name = os.VersionString; + IsFlatpak = false; + Package = DistroPackage.none; + return; + } - public static void UseLinux() - { Platform = Platform.Linux; try { diff --git a/src/XIVLauncher.Core/Program.cs b/src/XIVLauncher.Core/Program.cs index fccdf5a6..247ba7ed 100644 --- a/src/XIVLauncher.Core/Program.cs +++ b/src/XIVLauncher.Core/Program.cs @@ -182,17 +182,16 @@ private static void Main(string[] args) { case PlatformID.Win32NT: Steam = new WindowsSteam(); - Distro.UseWindows(); break; case PlatformID.Unix: Steam = new UnixSteam(); - Distro.UseLinux(); break; default: throw new PlatformNotSupportedException(); } + Distro.Initialize(); Log.Information("Running on {DistroName}. {wineInfo}", Distro.Name, (Distro.Platform == Platform.Linux) ? $"Using {Distro.Package} for managed wine downloads." : string.Empty); if (!Config.IsIgnoringSteam ?? true) { From 2334b28327cc7ec92b4901722b627e8c493242ea Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Fri, 30 Jun 2023 21:44:37 -0700 Subject: [PATCH 27/33] Minor cleanup of code and rewording some options. * Make Hud options a bit more clear * Add warning for MangoHud+ReShade+Dalamud --- .../SettingsPage/Tabs/SettingsTabDxvk.cs | 17 +++-- src/XIVLauncher.Core/Distro.cs | 69 ++++++++++++------- src/XIVLauncher.Core/Program.cs | 6 +- .../UnixCompatibility/HudManager.cs | 4 +- 4 files changed, 61 insertions(+), 35 deletions(-) diff --git a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDxvk.cs b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDxvk.cs index 99bebd02..77773fe7 100644 --- a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDxvk.cs +++ b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDxvk.cs @@ -37,18 +37,25 @@ public SettingsTabDxvk() return null; }, }, - hudSetting = new SettingsEntry("DXVK Overlay", "DXVK Hud is included with Dxvk. It doesn't work if Dxvk is disabled.\nMangoHud must be installed separately. Flatpak XIVLauncher needs flatpak MangoHud.", () => Program.Config.HudType, type => Program.Config.HudType = type) + hudSetting = new SettingsEntry("DXVK Overlay", "DXVK Hud is included with Dxvk. It doesn't work if Dxvk is disabled.\nMangoHud must be installed separately. Flatpak XIVLauncher needs flatpak MangoHud.", () => Program.Config.HudType, x => Program.Config.HudType = x) { CheckVisibility = () => dxvkVersionSetting.Value != DxvkVersion.Disabled, - CheckValidity = type => + CheckValidity = x => { - if ((type == HudType.MangoHud || type == HudType.MangoHudCustom || type == HudType.MangoHudFull) + if ((x == HudType.MangoHud || x == HudType.MangoHudCustom || x == HudType.MangoHudFull) && (HudManager.FindMangoHud() is null)) - // (!File.Exists("/usr/lib/mangohud/libMangoHud.so") && !File.Exists("/usr/lib64/mangohud/libMangoHud.so") && !File.Exists("/usr/lib/extensions/vulkan/MangoHud/lib/x86_64-linux-gnu/libMangoHud.so"))) return "MangoHud not detected."; return null; - } + }, + CheckWarning = x => + { + if ((x == HudType.MangoHud || x == HudType.MangoHudCustom || x == HudType.MangoHudFull) + && (HudManager.FindMangoHud() is not null)) + return "WARNING! Using MangoHud, Dalamud AND ReShade all at the same time may result in crashes. Using any two should be safe."; + + return null; + } }, new SettingsEntry("DXVK Hud Custom String", "Set a custom string for the built in DXVK Hud. Warning: If it's invalid, the game may hang.", () => Program.Config.DxvkHudCustom, s => Program.Config.DxvkHudCustom = s) { diff --git a/src/XIVLauncher.Core/Distro.cs b/src/XIVLauncher.Core/Distro.cs index bc975214..38722153 100644 --- a/src/XIVLauncher.Core/Distro.cs +++ b/src/XIVLauncher.Core/Distro.cs @@ -52,7 +52,7 @@ public static void Initialize() if (RuntimeInformation.IsOSPlatform(OSPlatform.FreeBSD)) { - Platform = Platform.Linux; // Don't have an option for this atm. + Platform = Platform.Mac; // Don't have an option for this atm. Name = os.VersionString; IsFlatpak = false; Package = DistroPackage.none; @@ -70,37 +70,30 @@ public static void Initialize() return; } var osRelease = File.ReadAllLines("/etc/os-release"); - var distro = DistroPackage.ubuntu; - var flatpak = false; - var OSInfo = new Dictionary(); + var osInfo = new Dictionary(); foreach (var line in osRelease) { var keyValue = line.Split('=', 2); if (keyValue.Length == 1) - OSInfo.Add(keyValue[0], ""); + osInfo.Add(keyValue[0], ""); else - OSInfo.Add(keyValue[0], keyValue[1]); + osInfo.Add(keyValue[0], keyValue[1]); } - var name = (OSInfo.ContainsKey("NAME") ? OSInfo["NAME"] : "").Trim('"'); - var pretty = (OSInfo.ContainsKey("PRETTY_NAME") ? OSInfo["PRETTY_NAME"] : "").Trim('"'); - var idLike = OSInfo.ContainsKey("ID_LIKE") ? OSInfo["ID_LIKE"] : ""; - if (idLike.Contains("arch")) - distro = DistroPackage.arch; - else if (idLike.Contains("fedora")) - distro = DistroPackage.fedora; - else - distro = DistroPackage.ubuntu; - - var id = OSInfo.ContainsKey("ID") ? OSInfo["ID"] : ""; - if (id.Contains("tumbleweed") || id.Contains("fedora")) - distro = DistroPackage.fedora; - if (id == "org.freedesktop.platform") - flatpak = true; - - Package = distro; + var name = (osInfo.ContainsKey("NAME") ? osInfo["NAME"] : "").Trim('"'); + var pretty = (osInfo.ContainsKey("PRETTY_NAME") ? osInfo["PRETTY_NAME"] : "").Trim('"'); Name = pretty == "" ? (name == "" ? "Unknown distribution" : name) : pretty; - IsFlatpak = flatpak; + + if (CheckFlatpak(osInfo)) + { + IsFlatpak = true; + Package = DistroPackage.ubuntu; + return; + } + + Package = CheckDistro(osInfo); + IsFlatpak = false; + return; } catch { @@ -109,5 +102,31 @@ public static void Initialize() Name = "Unknown distribution"; IsFlatpak = false; } - } + } + + private static bool CheckFlatpak(Dictionary osInfo) + { + if (osInfo.ContainsKey("ID")) + if (osInfo["ID"] == "org.freedesktop.platform") + return true; + return false; + } + + private static DistroPackage CheckDistro(Dictionary osInfo) + { + foreach (var kvp in osInfo) + { + if (kvp.Value.ToLower().Contains("fedora")) + return DistroPackage.fedora; + if (kvp.Value.ToLower().Contains("tumbleweed")) + return DistroPackage.fedora; + if (kvp.Value.ToLower().Contains("ubuntu")) + return DistroPackage.ubuntu; + if (kvp.Value.ToLower().Contains("debian")) + return DistroPackage.ubuntu; + if (kvp.Value.ToLower().Contains("arch")) + return DistroPackage.arch; + } + return DistroPackage.ubuntu; + } } \ No newline at end of file diff --git a/src/XIVLauncher.Core/Program.cs b/src/XIVLauncher.Core/Program.cs index 247ba7ed..ec63fcc4 100644 --- a/src/XIVLauncher.Core/Program.cs +++ b/src/XIVLauncher.Core/Program.cs @@ -192,7 +192,7 @@ private static void Main(string[] args) throw new PlatformNotSupportedException(); } Distro.Initialize(); - Log.Information("Running on {DistroName}. {wineInfo}", Distro.Name, (Distro.Platform == Platform.Linux) ? $"Using {Distro.Package} for managed wine downloads." : string.Empty); + Log.Information("Running on {DistroName}. {wineInfo}", Distro.Name, (Distro.Platform == Platform.Linux) ? $"Using {Distro.Package} package for managed wine downloads." : string.Empty); if (!Config.IsIgnoringSteam ?? true) { try @@ -414,8 +414,8 @@ public static void ClearPlugins(bool tsbutton = false) public static void ClearTools(bool tsbutton = false) { storage.GetFolder("compatibilitytool").Delete(true); - storage.GetFolder("compatibilitytool/wine"); - storage.GetFolder("compatibilitytool/dxvk"); + storage.GetFolder(Path.Combine("compatibilitytool", "wine")); + storage.GetFolder(Path.Combine("compatibilitytool", "dxvk")); if (tsbutton) CreateCompatToolsInstance(); } diff --git a/src/XIVLauncher.Core/UnixCompatibility/HudManager.cs b/src/XIVLauncher.Core/UnixCompatibility/HudManager.cs index be372878..5db3c385 100644 --- a/src/XIVLauncher.Core/UnixCompatibility/HudManager.cs +++ b/src/XIVLauncher.Core/UnixCompatibility/HudManager.cs @@ -16,13 +16,13 @@ public enum HudType [SettingsDescription("None", "Show nothing")] None, - [SettingsDescription("FPS", "Only show FPS")] + [SettingsDescription("DXVK Hud FPS", "Only show FPS")] Fps, [SettingsDescription("DXVK Hud Custom", "Use a custom DXVK_HUD string")] Custom, - [SettingsDescription("Full", "Show everything")] + [SettingsDescription("DXVK Hud Full", "Show everything")] Full, [SettingsDescription("MangoHud Default", "Uses no config file.")] From ccf30a719336043847d4115890355879044f27f2 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Fri, 30 Jun 2023 21:45:45 -0700 Subject: [PATCH 28/33] Update submodule --- lib/FFXIVQuickLauncher | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/FFXIVQuickLauncher b/lib/FFXIVQuickLauncher index 9284ecb2..22b5b080 160000 --- a/lib/FFXIVQuickLauncher +++ b/lib/FFXIVQuickLauncher @@ -1 +1 @@ -Subproject commit 9284ecb2b76c5f2670ece85f8750b30dbb919d5f +Subproject commit 22b5b08082eb725c4cd81e96a337f55b8c2c4c22 From 3b0747465ebae99c39b707989401e16a0beb17e1 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Fri, 30 Jun 2023 22:51:49 -0700 Subject: [PATCH 29/33] Fixed flatpak path for mangohud --- src/XIVLauncher.Core/UnixCompatibility/HudManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/XIVLauncher.Core/UnixCompatibility/HudManager.cs b/src/XIVLauncher.Core/UnixCompatibility/HudManager.cs index 5db3c385..9637b114 100644 --- a/src/XIVLauncher.Core/UnixCompatibility/HudManager.cs +++ b/src/XIVLauncher.Core/UnixCompatibility/HudManager.cs @@ -133,7 +133,7 @@ public static bool CheckDxvkHudString(string? customHud) { var usrLib = Path.Combine("/usr", "lib", "mangohud", "libMangoHud.so"); // fedora uses this var usrLib64 = Path.Combine("/usr", "lib64", "mangohud", "libMangoHud.so"); // arch and openSUSE use this - var flatpak = Path.Combine(new string[] { "/usr", "lib", "extensions", "vulkan", "lib", "x86_64-linux-gnu", "libMangoHud.so"}); + var flatpak = Path.Combine(new string[] { "/usr", "lib", "extensions", "vulkan", "MangoHud", "lib", "x86_64-linux-gnu", "libMangoHud.so"}); var debuntu = Path.Combine(new string[] { "/usr", "lib", "x86_64-linux-gnu", "mangohud", "libMangoHud.so"}); if (File.Exists(usrLib64)) return usrLib64; if (File.Exists(usrLib)) return usrLib; From 92a7cff0dd94e9920b987fd2669a842bae1bd6f2 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Fri, 7 Jul 2023 17:45:54 -0700 Subject: [PATCH 30/33] Changed default wine to 7.10 --- .../Components/SettingsPage/Tabs/SettingsTabWine.cs | 2 +- src/XIVLauncher.Core/Program.cs | 1 + src/XIVLauncher.Core/UnixCompatibility/WineManager.cs | 9 ++------- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabWine.cs b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabWine.cs index a48a22ad..ff3e81d6 100644 --- a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabWine.cs +++ b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabWine.cs @@ -18,7 +18,7 @@ public SettingsTabWine() startupTypeSetting = new SettingsEntry("Installation Type", "Choose how XIVLauncher will start and manage your game installation.", () => Program.Config.WineType ?? WineType.Managed, x => Program.Config.WineType = x), - new SettingsEntry("Wine Version", "Choose a patched wine version.", () => Program.Config.WineVersion ?? WineVersion.Wine8_5, x => Program.Config.WineVersion = x) + new SettingsEntry("Wine Version", "Choose a patched wine version.", () => Program.Config.WineVersion ?? WineVersion.Wine7_10, x => Program.Config.WineVersion = x) { CheckVisibility = () => startupTypeSetting.Value == WineType.Managed }, diff --git a/src/XIVLauncher.Core/Program.cs b/src/XIVLauncher.Core/Program.cs index ec63fcc4..d8051247 100644 --- a/src/XIVLauncher.Core/Program.cs +++ b/src/XIVLauncher.Core/Program.cs @@ -125,6 +125,7 @@ private static void LoadConfig(Storage storage) Config.MangoHudCustom ??= Path.Combine(Environment.GetEnvironmentVariable("HOME"), ".config", "MangoHud", "MangoHud.conf"); Config.WineType ??= WineType.Managed; + Config.WineVersion ??= WineVersion.Wine7_10; Config.WineBinaryPath ??= "/usr/bin"; Config.WineDebugVars ??= "-all"; diff --git a/src/XIVLauncher.Core/UnixCompatibility/WineManager.cs b/src/XIVLauncher.Core/UnixCompatibility/WineManager.cs index 77ea1143..d287b3e4 100644 --- a/src/XIVLauncher.Core/UnixCompatibility/WineManager.cs +++ b/src/XIVLauncher.Core/UnixCompatibility/WineManager.cs @@ -35,7 +35,7 @@ public static WineSettings GetSettings() var winepath = ""; var folder = ""; var url = ""; - var version = Program.Config.WineVersion ?? WineVersion.Wine8_5; + var version = Program.Config.WineVersion ?? WineVersion.Wine7_10; var package = Distro.Package.ToString(); switch (Program.Config.WineType ?? WineType.Managed) { @@ -68,12 +68,7 @@ public static WineSettings GetSettings() var env = new Dictionary(); if (Program.Config.GameModeEnabled ?? false) - { - var ldPreload = Environment.GetEnvironmentVariable("LD_PRELOAD") ?? ""; - if (!ldPreload.Contains("libgamemodeauto.so.0")) - ldPreload = (ldPreload.Equals("")) ? "libgamemodeauto.so.0" : ldPreload + ":libgamemodeauto.so.0"; - env.Add("LD_PRELOAD", ldPreload); - } + env.Add("LD_PRELOAD", "libgamemodeauto.so.0"); if (!string.IsNullOrEmpty(Program.Config.WineDebugVars)) env.Add("WINEDEBUG", Program.Config.WineDebugVars); if (Program.Config.ESyncEnabled ?? true) env.Add("WINEESYNC", "1"); From 7ab0524b4819c41921ab6497e52cd9d946eaa930 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Fri, 7 Jul 2023 17:57:47 -0700 Subject: [PATCH 31/33] Update WineVersion descriptions --- src/XIVLauncher.Core/UnixCompatibility/WineManager.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/XIVLauncher.Core/UnixCompatibility/WineManager.cs b/src/XIVLauncher.Core/UnixCompatibility/WineManager.cs index d287b3e4..553656ac 100644 --- a/src/XIVLauncher.Core/UnixCompatibility/WineManager.cs +++ b/src/XIVLauncher.Core/UnixCompatibility/WineManager.cs @@ -21,11 +21,11 @@ public enum WineType public enum WineVersion { - [SettingsDescription("Wine-xiv 8.5", "A patched version of Wine-staging 8.5. The current default.")] - Wine8_5, - - [SettingsDescription("Wine-xiv 7.10", "A legacy patched version of Wine, based on 7.10. A previous default")] + [SettingsDescription("Wine-xiv 7.10 (Default)", "A patched version of Wine, based on 7.10. The current default.")] Wine7_10, + + [SettingsDescription("Wine-xiv 8.5", "A newer patched version of Wine-staging 8.5. May be faster, but less stable.")] + Wine8_5, } public static class WineManager From 22bfcbb0c0fee7d5ee8d5e6c995f6b0d2a450846 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Fri, 7 Jul 2023 22:32:40 -0700 Subject: [PATCH 32/33] Update submodule --- lib/FFXIVQuickLauncher | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/FFXIVQuickLauncher b/lib/FFXIVQuickLauncher index 22b5b080..ffef16dd 160000 --- a/lib/FFXIVQuickLauncher +++ b/lib/FFXIVQuickLauncher @@ -1 +1 @@ -Subproject commit 22b5b08082eb725c4cd81e96a337f55b8c2c4c22 +Subproject commit ffef16ddf067641cd400740204dd06e5bc55bff8 From 387d17d65ca0061acbab919f86aaa7075c063b91 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Mon, 10 Jul 2023 20:25:03 -0700 Subject: [PATCH 33/33] Update Distro.cs to correct namespace. --- src/XIVLauncher.Core/Distro.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/XIVLauncher.Core/Distro.cs b/src/XIVLauncher.Core/Distro.cs index 38722153..7f929491 100644 --- a/src/XIVLauncher.Core/Distro.cs +++ b/src/XIVLauncher.Core/Distro.cs @@ -4,7 +4,7 @@ using XIVLauncher.Common; using System.Runtime.InteropServices; -namespace XIVLauncher.Core.UnixCompatibility; +namespace XIVLauncher.Core; public enum DistroPackage {