From da6333bcbd1b6157760e3d8803448ef6b330ba9b Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Fri, 24 Nov 2023 15:55:51 -0800 Subject: [PATCH 01/23] feature: Allow install as Steam compatibility tool --- .../Components/SettingsPage/SettingsPage.cs | 1 + .../SettingsPage/Tabs/SettingsTabSteamTool.cs | 100 ++++++++++++++++ .../Configuration/ILauncherConfig.cs | 4 + .../CoreEnvironmentSettings.cs | 15 ++- src/XIVLauncher.Core/Program.cs | 3 + .../Resources/compatibilitytool.vdf | 14 +++ .../Resources/openssl_fix.cnf | 17 +++ .../Resources/toolmanifest.vdf | 5 + src/XIVLauncher.Core/Resources/xlcore | 35 ++++++ .../SteamCompatibilityTool.cs | 107 ++++++++++++++++++ src/XIVLauncher.Core/XIVLauncher.Core.csproj | 4 + 11 files changed, 303 insertions(+), 2 deletions(-) create mode 100644 src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabSteamTool.cs create mode 100644 src/XIVLauncher.Core/Resources/compatibilitytool.vdf create mode 100644 src/XIVLauncher.Core/Resources/openssl_fix.cnf create mode 100644 src/XIVLauncher.Core/Resources/toolmanifest.vdf create mode 100755 src/XIVLauncher.Core/Resources/xlcore create mode 100644 src/XIVLauncher.Core/SteamCompatibilityTool.cs diff --git a/src/XIVLauncher.Core/Components/SettingsPage/SettingsPage.cs b/src/XIVLauncher.Core/Components/SettingsPage/SettingsPage.cs index cbf9a074..3826d516 100644 --- a/src/XIVLauncher.Core/Components/SettingsPage/SettingsPage.cs +++ b/src/XIVLauncher.Core/Components/SettingsPage/SettingsPage.cs @@ -12,6 +12,7 @@ public class SettingsPage : Page new SettingsTabPatching(), new SettingsTabWine(), new SettingsTabDalamud(), + new SettingsTabSteamTool(), new SettingsTabAutoStart(), new SettingsTabAbout(), new SettingsTabDebug(), diff --git a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabSteamTool.cs b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabSteamTool.cs new file mode 100644 index 00000000..bdb2d503 --- /dev/null +++ b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabSteamTool.cs @@ -0,0 +1,100 @@ +using System.Numerics; +using System.Runtime.InteropServices; +using System.IO; +using ImGuiNET; +using XIVLauncher.Common.Unix.Compatibility; +using XIVLauncher.Common.Util; +using XIVLauncher.Core; + +namespace XIVLauncher.Core.Components.SettingsPage.Tabs; + +public class SettingsTabSteamTool : SettingsTab +{ + private SettingsEntry steamPath; + + private SettingsEntry steamFlatpakPath; + + private bool steamToolExists => File.Exists(Path.Combine(Program.Config.SteamPath ?? Path.Combine(CoreEnvironmentSettings.XDG_DATA_HOME, "Steam"), "compatibilitytools.d", "xlcore", "xlcore")); + + private bool steamFlatpakToolExists => File.Exists(Path.Combine(Program.Config.SteamFlatpakPath ?? Path.Combine(CoreEnvironmentSettings.HOME, ".var", "app", "com.valvesoftware.Steam", "data", "Steam" ), "compatibilitytools.d", "xlcore", "xlcore")); + + public SettingsTabSteamTool() + { + Entries = new SettingsEntry[] + { + steamPath = new SettingsEntry("Steam Path (native install)", "Path to the native steam config files. Only change this if you have your steam config stored somewhere else.", + () => Program.Config.SteamPath ?? Path.Combine(CoreEnvironmentSettings.XDG_DATA_HOME, "Steam"), s => Program.Config.SteamPath = s), + + steamFlatpakPath = new SettingsEntry("Steam Path (flatpak install)", "Path to the flatpak steam config files. Only change this if you have your steam config stored somewhere else.", + () => Program.Config.SteamFlatpakPath ?? Path.Combine(CoreEnvironmentSettings.HOME, ".var", "app", "com.valvesoftware.Steam", "data", "Steam" ), s => Program.Config.SteamFlatpakPath = s), + }; + } + + public override SettingsEntry[] Entries { get; } + + public override bool IsUnixExclusive => true; + + public override string Title => "Steam Tool"; + + public override void Draw() + { + if (CoreEnvironmentSettings.IsSteamCompatTool) + { + ImGui.Dummy(new Vector2(10)); + ImGui.Text("You are currently running XIVLauncher.Core as a Steam compatibility tool."); + ImGui.Dummy(new Vector2(10)); + ImGui.Text("If you are trying to upgrade, you must first update your local install of XIVLauncher.Core. Then launch the local version," + + "\nnavigate back to this tab, and re-install as a Steam compatibility tool."); + return; + } + ImGui.Dummy(new Vector2(10)); + ImGui.Text("Use this tab to install XIVLauncher.Core as a Steam compatibility tool."); + ImGui.Dummy(new Vector2(10)); + ImGui.Text("After you have installed XIVLauncher.Core as a Steam tool, close this program, and launch Steam. Select Final Fantasy XIV from the library,"); + ImGui.Text("and go to Compatibility. Force the use of a specific Steam Play compatibility tool, and choose XIVLauncher.Core as Compatibility Tool."); + ImGui.Text("XIVLauncher.Core will now be used to launch Final Fantasy XIV. This feature can be used with Flatpak steam."); + + + ImGui.Dummy(new Vector2(10)); + ImGui.Separator(); + ImGui.Dummy(new Vector2(10)); + + ImGui.Text($"Native Steam Tool status: {(steamToolExists ? "INSTALLED" : "Not Installed")}"); + ImGui.Dummy(new Vector2(10)); + if (ImGui.Button($"{(steamToolExists ? "Re-i" : "I")}nstall to native Steam")) + { + this.Save(); + SteamCompatibilityTool.CreateTool(Program.Config.SteamPath); + } + + ImGui.Dummy(new Vector2(10)); + ImGui.Separator(); + ImGui.Dummy(new Vector2(10)); + + ImGui.Text($"Flatpak Steam Tool status: {(steamFlatpakToolExists ? "INSTALLED" : "Not Installed")}"); +#if !FLATPAK + ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudRed); + ImGui.Text("You are NOT running flatpak XIVLauncher.Core. You probably shouldn't install to Flatpak Steam. It may cause issues."); + ImGui.PopStyleColor(); +#endif + ImGui.Dummy(new Vector2(10)); + if (ImGui.Button($"{(steamFlatpakToolExists ? "Re-i" : "I")}nstall to flatpak Steam")) + { + this.Save(); + SteamCompatibilityTool.CreateTool(Program.Config.SteamFlatpakPath); + } + + ImGui.Dummy(new Vector2(10)); + ImGui.Separator(); + ImGui.Dummy(new Vector2(10)); + + base.Draw(); + } + + public override void Save() + { + base.Save(); + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + Program.CreateCompatToolsInstance(); + } +} diff --git a/src/XIVLauncher.Core/Configuration/ILauncherConfig.cs b/src/XIVLauncher.Core/Configuration/ILauncherConfig.cs index c7e72e02..161e188a 100644 --- a/src/XIVLauncher.Core/Configuration/ILauncherConfig.cs +++ b/src/XIVLauncher.Core/Configuration/ILauncherConfig.cs @@ -84,6 +84,10 @@ public interface ILauncherConfig public bool? SetWin7 { get; set; } + public string? SteamPath { get; set; } + + public string? SteamFlatpakPath { get; set; } + #endregion #region Dalamud diff --git a/src/XIVLauncher.Core/CoreEnvironmentSettings.cs b/src/XIVLauncher.Core/CoreEnvironmentSettings.cs index 2a78b2b3..e0c55878 100644 --- a/src/XIVLauncher.Core/CoreEnvironmentSettings.cs +++ b/src/XIVLauncher.Core/CoreEnvironmentSettings.cs @@ -15,17 +15,20 @@ public static class CoreEnvironmentSettings public static bool ClearLogs => CheckEnvBool("XL_CLEAR_LOGS"); public static bool ClearAll => CheckEnvBool("XL_CLEAR_ALL"); public static bool? UseSteam => CheckEnvBoolOrNull("XL_USE_STEAM"); // Fix for Steam Deck users who lock themselves out + public static bool IsSteamCompatTool => CheckEnvBool("XL_SCT"); + public static string HOME => System.Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); + public static string XDG_DATA_HOME => string.IsNullOrEmpty(System.Environment.GetEnvironmentVariable("XDG_DATA_HOME")) ? Path.Combine(HOME, ".local", "share") : System.Environment.GetEnvironmentVariable("XDG_DATA_HOME"); private static bool CheckEnvBool(string key) { - string val = (System.Environment.GetEnvironmentVariable(key) ?? string.Empty).ToLower(); + string val = (Environment.GetEnvironmentVariable(key) ?? string.Empty).ToLower(); if (val == "1" || val == "true" || val == "yes" || val == "y" || val == "on") return true; return false; } private static bool? CheckEnvBoolOrNull(string key) { - string val = (System.Environment.GetEnvironmentVariable(key) ?? string.Empty).ToLower(); + string val = (Environment.GetEnvironmentVariable(key) ?? string.Empty).ToLower(); if (val == "1" || val == "true" || val == "yes" || val == "y" || val == "on") return true; if (val == "0" || val == "false" || val == "no" || val == "n" || val == "off") return false; return null; @@ -37,4 +40,12 @@ public static string GetCleanEnvironmentVariable(string envvar, string badstring if (badstring.Equals("")) return dirty; return string.Join(separator, Array.FindAll(dirty.Split(separator, StringSplitOptions.RemoveEmptyEntries), s => !s.Contains(badstring))); } + + static CoreEnvironmentSettings() + { + var xlpreload = Environment.GetEnvironmentVariable("XL_PRELOAD") ?? ""; + var ldpreload = GetCleanEnvironmentVariable("LD_PRELOAD"); + ldpreload = (string.IsNullOrEmpty(xlpreload) ? "" : xlpreload + ":") + (string.IsNullOrEmpty(ldpreload) ? "" : ldpreload); + Environment.SetEnvironmentVariable("LD_PRELOAD", ldpreload); + } } \ No newline at end of file diff --git a/src/XIVLauncher.Core/Program.cs b/src/XIVLauncher.Core/Program.cs index d6317302..ac08eb50 100644 --- a/src/XIVLauncher.Core/Program.cs +++ b/src/XIVLauncher.Core/Program.cs @@ -128,6 +128,9 @@ private static void LoadConfig(Storage storage) Config.FixLDP ??= false; Config.FixIM ??= false; + + Config.SteamPath ??= Path.Combine(CoreEnvironmentSettings.XDG_DATA_HOME, "Steam"); + Config.SteamFlatpakPath ??= Path.Combine(CoreEnvironmentSettings.HOME, ".var", "app", "com.valvesoftware.Steam", "data", "Steam" ); } public const uint STEAM_APP_ID = 39210; diff --git a/src/XIVLauncher.Core/Resources/compatibilitytool.vdf b/src/XIVLauncher.Core/Resources/compatibilitytool.vdf new file mode 100644 index 00000000..7f85081c --- /dev/null +++ b/src/XIVLauncher.Core/Resources/compatibilitytool.vdf @@ -0,0 +1,14 @@ +"compatibilitytools" +{ + "compat_tools" + { + "XLCore-SCT" // Internal name of this tool + { + "install_path" "." + "display_name" "XIVLauncher.Core as Compatibility Tool" + + "from_oslist" "windows" + "to_oslist" "linux" + } + } +} \ No newline at end of file diff --git a/src/XIVLauncher.Core/Resources/openssl_fix.cnf b/src/XIVLauncher.Core/Resources/openssl_fix.cnf new file mode 100644 index 00000000..4d61c702 --- /dev/null +++ b/src/XIVLauncher.Core/Resources/openssl_fix.cnf @@ -0,0 +1,17 @@ +# Absolute minimum openssl config that works for FFXIV +# Fixes SSL error when logging in +# This is NOT SAFE to use as system default. Do not replace your +# system openssl.cnf with this file. + +openssl_conf = openssl_init + +[openssl_init] +ssl_conf = ssl_module + +[ ssl_module ] +system_default = crypto_policy + +[ crypto_policy ] +MinProtocol = TLSv1.2 +CipherString = DEFAULT:@SECLEVEL=1 + diff --git a/src/XIVLauncher.Core/Resources/toolmanifest.vdf b/src/XIVLauncher.Core/Resources/toolmanifest.vdf new file mode 100644 index 00000000..e53ecf38 --- /dev/null +++ b/src/XIVLauncher.Core/Resources/toolmanifest.vdf @@ -0,0 +1,5 @@ +"manifest" +{ + "commandline" "/xlcore run" + "commandline_waitforexitandrun" "/xlcore waitforexitandrun" +} \ No newline at end of file diff --git a/src/XIVLauncher.Core/Resources/xlcore b/src/XIVLauncher.Core/Resources/xlcore new file mode 100755 index 00000000..685c9511 --- /dev/null +++ b/src/XIVLauncher.Core/Resources/xlcore @@ -0,0 +1,35 @@ +#!/bin/env bash + +# Prevent double launch +if [ $1 == "run" ]; then exit; fi + +xlcoreDir=$HOME/.xlcore +logDir=$xlcoreDir/logs +mkdir -p $xlcoreDir +mkdir -p $logDir + +# Working directory is actually the steam install location, so we need to find the path of this script +tooldir="$(realpath "$(dirname "$0")")" + +# If aria2c isn't found, add our local copy to the $PATH +count=$(find /usr -type f -executable -name "aria2c" 2>/dev/null | wc -l) +if (( $count == 0 )); then + PATH="$PATH:$tooldir/bin" +fi + +# Work around a Steam overlay bug. I put some code into XIVLauncher to add the ldpreload variable +# to the LD_PRELOAD variable before launching proton/wine. This prevents the overlay from corrupting +# the XIVLauncher UI. +# Then set LD_PRELOAD to point to the included libsecret library files. +export XL_PRELOAD="$LD_PRELOAD" +unset LD_PRELOAD + +# If libsecret isn't found, add to $LD_PRELOAD +count=$(ldconfig -p | grep libsecret-1 | wc -l) +if (( $count == 0)); then + export LD_PRELOAD=$tooldir/lib/libsecret-1.so.0:$tooldir/lib/libsecret-1.so.0.0.0:$LD_PRELOAD +fi + +export OPENSSL_CONF="$tooldir/openssl_fix.cnf" +export XL_SCT=1 +"$tooldir/XIVLauncher/XIVLauncher.Core" $@ >> $logDir/steamtool_console.log 2>&1 \ No newline at end of file diff --git a/src/XIVLauncher.Core/SteamCompatibilityTool.cs b/src/XIVLauncher.Core/SteamCompatibilityTool.cs new file mode 100644 index 00000000..38fa4a99 --- /dev/null +++ b/src/XIVLauncher.Core/SteamCompatibilityTool.cs @@ -0,0 +1,107 @@ +using System.Numerics; +using System.IO; +using System.Reflection; +using System.Diagnostics; +using Serilog; + +namespace XIVLauncher.Core; + +static class SteamCompatibilityTool +{ + public static bool CheckTool(string path) + { + return Directory.Exists(Path.Combine(path, "xlcore")); + } + + private static string findXIVLauncherFiles() + { + return System.AppDomain.CurrentDomain.BaseDirectory; + } + + public static void CreateTool(string path) + { + var compatfolder = new DirectoryInfo(Path.Combine(path, "compatibilitytools.d")); + compatfolder.Create(); + var destination = new DirectoryInfo(Path.Combine(compatfolder.FullName, "xlcore")); + if (File.Exists(destination.FullName)) + File.Delete(destination.FullName); + if (destination.Exists) + destination.Delete(true); + + destination.Create(); + destination.CreateSubdirectory("XIVLauncher"); + destination.CreateSubdirectory("bin"); + destination.CreateSubdirectory("lib"); + + var xlcore = new FileInfo(Path.Combine(destination.FullName, "xlcore")); + var compatibilitytool_vdf = new FileInfo(Path.Combine(destination.FullName, "compatibilitytool.vdf")); + var toolmanifest_vdf = new FileInfo(Path.Combine(destination.FullName, "toolmanifest.vdf")); + var openssl_fix = new FileInfo(Path.Combine(destination.FullName, "openssl_fix.cnf")); + + xlcore.Delete(); + compatibilitytool_vdf.Delete(); + toolmanifest_vdf.Delete(); + openssl_fix.Delete(); + + using (var fs = xlcore.Create()) + { + var resource = Assembly.GetExecutingAssembly().GetManifestResourceStream("xlcore"); + resource.CopyTo(fs); + fs.Close(); + } + + // File.SetUnixFileMode() doesn't exist, for some reason, so just run chmod + var psi = new ProcessStartInfo("/bin/chmod"); + psi.ArgumentList.Add("+x"); + psi.ArgumentList.Add(xlcore.FullName); + using (Process proc = new Process()) + { + proc.StartInfo = psi; + proc.Start(); + proc.WaitForExit(); + } + + using (var fs = compatibilitytool_vdf.Create()) + { + var resource = Assembly.GetExecutingAssembly().GetManifestResourceStream("compatibilitytool.vdf"); + resource.CopyTo(fs); + fs.Close(); + } + + using (var fs = toolmanifest_vdf.Create()) + { + var resource = Assembly.GetExecutingAssembly().GetManifestResourceStream("toolmanifest.vdf"); + resource.CopyTo(fs); + fs.Close(); + } + + using (var fs = openssl_fix.Create()) + { + var resource = Assembly.GetExecutingAssembly().GetManifestResourceStream("openssl_fix.cnf"); + resource.CopyTo(fs); + fs.Close(); + } + + // Copy XIVLauncher files + var XIVLauncherFiles = new DirectoryInfo(findXIVLauncherFiles()); + foreach (var file in XIVLauncherFiles.GetFiles()) + { + file.CopyTo(Path.Combine(destination.FullName, "XIVLauncher", file.Name), true); + } + +#if FLATPAK + var aria2c = new FileInfo("/app/bin/aria2c"); + var libsecret = new FileInfo("/app/lib/libsecret-1.so.0.0.0"); + + if (aria2c.Exists) + aria2c.CopyTo(Path.Combine(destination.FullName, "bin", "aria2c")); + + if (libsecret.Exists) + { + var libPath = Path.Combine(destination.FullName, "lib"); + libsecret.CopyTo(Path.Combine(libPath, "libsecret-1.so.0.0.0")); + File.CreateSymbolicLink(Path.Combine(libPath, "libsecret-1.so"), "libsecret-1.so.0.0.0"); + } +#endif + } +} \ No newline at end of file diff --git a/src/XIVLauncher.Core/XIVLauncher.Core.csproj b/src/XIVLauncher.Core/XIVLauncher.Core.csproj index 69fc52df..b3d61fa3 100644 --- a/src/XIVLauncher.Core/XIVLauncher.Core.csproj +++ b/src/XIVLauncher.Core/XIVLauncher.Core.csproj @@ -93,6 +93,10 @@ + + + + From 34c396d7464ae5a7e55341e18702a6f91e0c736b Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Fri, 24 Nov 2023 16:09:59 -0800 Subject: [PATCH 02/23] Tweak Steam Tool tab for clearer instructions --- .../SettingsPage/Tabs/SettingsTabSteamTool.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabSteamTool.cs b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabSteamTool.cs index bdb2d503..d5a14f7a 100644 --- a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabSteamTool.cs +++ b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabSteamTool.cs @@ -47,13 +47,13 @@ public override void Draw() "\nnavigate back to this tab, and re-install as a Steam compatibility tool."); return; } - ImGui.Dummy(new Vector2(10)); - ImGui.Text("Use this tab to install XIVLauncher.Core as a Steam compatibility tool."); - ImGui.Dummy(new Vector2(10)); - ImGui.Text("After you have installed XIVLauncher.Core as a Steam tool, close this program, and launch Steam. Select Final Fantasy XIV from the library,"); + ImGui.Text("\nUse this tab to install XIVLauncher.Core as a Steam compatibility tool."); + ImGui.Text("\nAfter you have installed XIVLauncher as a Steam tool, close this program, and launch Steam. Select Final Fantasy XIV from the library,"); ImGui.Text("and go to Compatibility. Force the use of a specific Steam Play compatibility tool, and choose XIVLauncher.Core as Compatibility Tool."); ImGui.Text("XIVLauncher.Core will now be used to launch Final Fantasy XIV. This feature can be used with Flatpak steam."); - + ImGui.Text("\nIf you wish to install into Flatpak Steam, you must use Flatseal to give XIVLauncher access to Steam's flatpak path. This is probably something like:"); + ImGui.Text($"{CoreEnvironmentSettings.HOME}/.var/app/com.valvesoftware.Steam. If you do not give this permission, installation will fail. You will probably also want to"); + ImGui.Text($"give Steam permission to {CoreEnvironmentSettings.HOME}/.xlcore, so that you can continue to use your current xlcore folder."); ImGui.Dummy(new Vector2(10)); ImGui.Separator(); From 0084586a53494aa4061b0600be50ea50f862e269 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Fri, 24 Nov 2023 18:02:35 -0800 Subject: [PATCH 03/23] Add uninstall buttons --- .../SettingsPage/Tabs/SettingsTabSteamTool.cs | 28 +++++++++++++++++++ .../SteamCompatibilityTool.cs | 10 ++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabSteamTool.cs b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabSteamTool.cs index d5a14f7a..ade5ac52 100644 --- a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabSteamTool.cs +++ b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabSteamTool.cs @@ -66,6 +66,20 @@ public override void Draw() this.Save(); SteamCompatibilityTool.CreateTool(Program.Config.SteamPath); } + ImGui.SameLine(); + if (!steamToolExists) + { + ImGui.BeginDisabled(); + } + if (ImGui.Button("Uninstall from Steam")) + { + this.Save(); + SteamCompatibilityTool.DeleteTool(Program.Config.SteamPath); + } + if (!steamToolExists) + { + ImGui.EndDisabled(); + } ImGui.Dummy(new Vector2(10)); ImGui.Separator(); @@ -83,6 +97,20 @@ public override void Draw() this.Save(); SteamCompatibilityTool.CreateTool(Program.Config.SteamFlatpakPath); } + ImGui.SameLine(); + if (!steamFlatpakToolExists) + { + ImGui.BeginDisabled(); + } + if (ImGui.Button("Uninstall from Flatpak Steam")) + { + this.Save(); + SteamCompatibilityTool.DeleteTool(Program.Config.SteamFlatpakPath); + } + if (!steamFlatpakToolExists) + { + ImGui.EndDisabled(); + } ImGui.Dummy(new Vector2(10)); ImGui.Separator(); diff --git a/src/XIVLauncher.Core/SteamCompatibilityTool.cs b/src/XIVLauncher.Core/SteamCompatibilityTool.cs index 38fa4a99..0042889f 100644 --- a/src/XIVLauncher.Core/SteamCompatibilityTool.cs +++ b/src/XIVLauncher.Core/SteamCompatibilityTool.cs @@ -6,7 +6,7 @@ namespace XIVLauncher.Core; -static class SteamCompatibilityTool +public static class SteamCompatibilityTool { public static bool CheckTool(string path) { @@ -103,5 +103,13 @@ public static void CreateTool(string path) File.CreateSymbolicLink(Path.Combine(libPath, "libsecret-1.so"), "libsecret-1.so.0.0.0"); } #endif + Log.Verbose($"[SCT] XIVLauncher installed as Steam compatibility tool to folder {destination.FullName}"); + } + + public static void DeleteTool(string path) + { + var steamToolFolder = new DirectoryInfo(Path.Combine(path, "compatibilitytools.d", "xlcore")); + steamToolFolder.Delete(true); + Log.Verbose($"[SCT] Deleted Steam compatibility tool at folder {steamToolFolder.FullName}"); } } \ No newline at end of file From 08d2cb3d00253d80c377cca04763b371c72575fc Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Fri, 24 Nov 2023 18:46:47 -0800 Subject: [PATCH 04/23] Fix compatibility tool launch script, clean up instructions. --- .../Components/SettingsPage/Tabs/SettingsTabSteamTool.cs | 8 +++++--- src/XIVLauncher.Core/Resources/xlcore | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabSteamTool.cs b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabSteamTool.cs index ade5ac52..e4ba2b22 100644 --- a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabSteamTool.cs +++ b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabSteamTool.cs @@ -43,8 +43,10 @@ public override void Draw() ImGui.Dummy(new Vector2(10)); ImGui.Text("You are currently running XIVLauncher.Core as a Steam compatibility tool."); ImGui.Dummy(new Vector2(10)); - ImGui.Text("If you are trying to upgrade, you must first update your local install of XIVLauncher.Core. Then launch the local version," + - "\nnavigate back to this tab, and re-install as a Steam compatibility tool."); + ImGui.Text("If you are trying to upgrade, you must first update your local install of XIVLauncher.Core. Then launch the local" + + "\nversion, navigate back to this tab, and re-install as a Steam compatibility tool."); + ImGui.Text("\nIf you are trying to uninstall, you should likewise launch the native version of XIVLauncher, and click the appropriate" + + "\nuninstall button."); return; } ImGui.Text("\nUse this tab to install XIVLauncher.Core as a Steam compatibility tool."); @@ -71,7 +73,7 @@ public override void Draw() { ImGui.BeginDisabled(); } - if (ImGui.Button("Uninstall from Steam")) + if (ImGui.Button("Uninstall from native Steam")) { this.Save(); SteamCompatibilityTool.DeleteTool(Program.Config.SteamPath); diff --git a/src/XIVLauncher.Core/Resources/xlcore b/src/XIVLauncher.Core/Resources/xlcore index 685c9511..1af3bc5c 100755 --- a/src/XIVLauncher.Core/Resources/xlcore +++ b/src/XIVLauncher.Core/Resources/xlcore @@ -1,7 +1,9 @@ #!/bin/env bash # Prevent double launch -if [ $1 == "run" ]; then exit; fi +if [ $1 == "run" ]; then + exit 0 +fi xlcoreDir=$HOME/.xlcore logDir=$xlcoreDir/logs From 98d8cb13e46f9a5a64dc549c971c88a731b499bf Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Fri, 24 Nov 2023 18:58:17 -0800 Subject: [PATCH 05/23] Ignore Steam won't be used with Steam compat tool --- .../Components/SettingsPage/Tabs/SettingsTabGame.cs | 5 ++++- src/XIVLauncher.Core/Program.cs | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabGame.cs b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabGame.cs index ccea203d..951df78b 100644 --- a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabGame.cs +++ b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabGame.cs @@ -38,7 +38,10 @@ public class SettingsTabGame : SettingsTab new SettingsEntry("Game DPI Awareness", "Select the game's DPI Awareness. Change this if the game's scaling looks wrong.", () => Program.Config.DpiAwareness ?? DpiAwareness.Unaware, x => Program.Config.DpiAwareness = x), new SettingsEntry("Free Trial Account", "Check this if you are using a free trial account.", () => Program.Config.IsFt ?? false, x => Program.Config.IsFt = x), new SettingsEntry("Use XIVLauncher authenticator/OTP macros", "Check this if you want to use the XIVLauncher authenticator app or macros.", () => Program.Config.IsOtpServer ?? false, x => Program.Config.IsOtpServer = x), - new SettingsEntry("Ignore Steam", "Check this if you do not want XIVLauncher to communicate with Steam (Requires Restart).", () => Program.Config.IsIgnoringSteam ?? false, x => Program.Config.IsIgnoringSteam = x), + new SettingsEntry("Ignore Steam", "Check this if you do not want XIVLauncher to communicate with Steam (Requires Restart).", () => Program.Config.IsIgnoringSteam ?? false, x => Program.Config.IsIgnoringSteam = x) + { + CheckVisibility = () => !CoreEnvironmentSettings.IsSteamCompatTool, + }, new SettingsEntry("Use Experimental UID Cache", "Tries to save your login token for the next start. Can result in launching with expired sessions.\nDisable if receiving FFXIV error 1012 or 500X.", () => Program.Config.IsUidCacheEnabled ?? false, x => Program.Config.IsUidCacheEnabled = x), }; diff --git a/src/XIVLauncher.Core/Program.cs b/src/XIVLauncher.Core/Program.cs index ac08eb50..3ac857b6 100644 --- a/src/XIVLauncher.Core/Program.cs +++ b/src/XIVLauncher.Core/Program.cs @@ -192,7 +192,7 @@ private static void Main(string[] args) default: throw new PlatformNotSupportedException(); } - if (!Config.IsIgnoringSteam ?? true) + if (CoreEnvironmentSettings.IsSteamCompatTool || (!Config.IsIgnoringSteam ?? true)) { try { From 1e0f80b4e7e4368e80331be2813eabeaa175877f Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Sun, 26 Nov 2023 12:35:44 -0800 Subject: [PATCH 06/23] Add 1s sleep to xlcore script. --- src/XIVLauncher.Core/Resources/xlcore | 1 + 1 file changed, 1 insertion(+) diff --git a/src/XIVLauncher.Core/Resources/xlcore b/src/XIVLauncher.Core/Resources/xlcore index 1af3bc5c..84d57846 100755 --- a/src/XIVLauncher.Core/Resources/xlcore +++ b/src/XIVLauncher.Core/Resources/xlcore @@ -2,6 +2,7 @@ # Prevent double launch if [ $1 == "run" ]; then + sleep 1 exit 0 fi From f373482f79f56b4de22885c198bc8ed9e44dd2b6 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Sun, 26 Nov 2023 13:52:20 -0800 Subject: [PATCH 07/23] Add checks for steam --- .../SettingsPage/Tabs/SettingsTabSteamTool.cs | 27 ++++++++++++++----- .../SteamCompatibilityTool.cs | 12 ++++++++- 2 files changed, 31 insertions(+), 8 deletions(-) rename src/XIVLauncher.Core/{ => UnixCompatibility}/SteamCompatibilityTool.cs (89%) diff --git a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabSteamTool.cs b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabSteamTool.cs index e4ba2b22..b7a8f79e 100644 --- a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabSteamTool.cs +++ b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabSteamTool.cs @@ -4,7 +4,7 @@ using ImGuiNET; using XIVLauncher.Common.Unix.Compatibility; using XIVLauncher.Common.Util; -using XIVLauncher.Core; +using XIVLauncher.Core.UnixCompatibility; namespace XIVLauncher.Core.Components.SettingsPage.Tabs; @@ -24,9 +24,10 @@ public SettingsTabSteamTool() { steamPath = new SettingsEntry("Steam Path (native install)", "Path to the native steam config files. Only change this if you have your steam config stored somewhere else.", () => Program.Config.SteamPath ?? Path.Combine(CoreEnvironmentSettings.XDG_DATA_HOME, "Steam"), s => Program.Config.SteamPath = s), - +#if FLATPAK steamFlatpakPath = new SettingsEntry("Steam Path (flatpak install)", "Path to the flatpak steam config files. Only change this if you have your steam config stored somewhere else.", () => Program.Config.SteamFlatpakPath ?? Path.Combine(CoreEnvironmentSettings.HOME, ".var", "app", "com.valvesoftware.Steam", "data", "Steam" ), s => Program.Config.SteamFlatpakPath = s), +#endif }; } @@ -61,6 +62,13 @@ public override void Draw() ImGui.Separator(); ImGui.Dummy(new Vector2(10)); + if (!SteamCompatibilityTool.IsSteamInstalled) + { + ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudRed); + ImGui.Text("\nWARNING! Steam install not detected. If it is installed, make sure you run it at least once.\n"); + ImGui.PopStyleColor(); + } + ImGui.Text($"Native Steam Tool status: {(steamToolExists ? "INSTALLED" : "Not Installed")}"); ImGui.Dummy(new Vector2(10)); if (ImGui.Button($"{(steamToolExists ? "Re-i" : "I")}nstall to native Steam")) @@ -83,16 +91,20 @@ public override void Draw() ImGui.EndDisabled(); } +#if FLATPAK ImGui.Dummy(new Vector2(10)); ImGui.Separator(); ImGui.Dummy(new Vector2(10)); + if (!SteamCompatibilityTool.IsFlatpakSteamInstalled) + { + ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudRed); + ImGui.Text("\nWARNING! Flatpak Steam install not detected. If it is installed, make sure you run it at least once.\n" + + "This may also appear if you have not given your Flatpak XIVLauncher file permissions to ~/.var/app/com.valvesoftware.Steam\n"); + ImGui.PopStyleColor(); + } + ImGui.Text($"Flatpak Steam Tool status: {(steamFlatpakToolExists ? "INSTALLED" : "Not Installed")}"); -#if !FLATPAK - ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudRed); - ImGui.Text("You are NOT running flatpak XIVLauncher.Core. You probably shouldn't install to Flatpak Steam. It may cause issues."); - ImGui.PopStyleColor(); -#endif ImGui.Dummy(new Vector2(10)); if (ImGui.Button($"{(steamFlatpakToolExists ? "Re-i" : "I")}nstall to flatpak Steam")) { @@ -114,6 +126,7 @@ public override void Draw() ImGui.EndDisabled(); } +#endif ImGui.Dummy(new Vector2(10)); ImGui.Separator(); ImGui.Dummy(new Vector2(10)); diff --git a/src/XIVLauncher.Core/SteamCompatibilityTool.cs b/src/XIVLauncher.Core/UnixCompatibility/SteamCompatibilityTool.cs similarity index 89% rename from src/XIVLauncher.Core/SteamCompatibilityTool.cs rename to src/XIVLauncher.Core/UnixCompatibility/SteamCompatibilityTool.cs index 0042889f..e85df739 100644 --- a/src/XIVLauncher.Core/SteamCompatibilityTool.cs +++ b/src/XIVLauncher.Core/UnixCompatibility/SteamCompatibilityTool.cs @@ -3,11 +3,21 @@ using System.Reflection; using System.Diagnostics; using Serilog; +using XIVLauncher.Core; -namespace XIVLauncher.Core; +namespace XIVLauncher.Core.UnixCompatibility; public static class SteamCompatibilityTool { + public static bool IsSteamInstalled { get; } = false; + + public static bool IsFlatpakSteamInstalled { get; } = false; + + static SteamCompatibilityTool() + { + IsSteamInstalled = Directory.Exists(Path.Combine(CoreEnvironmentSettings.XDG_DATA_HOME, "Steam")); + IsFlatpakSteamInstalled = Directory.Exists(Path.Combine(CoreEnvironmentSettings.HOME, ".var/app/com.valvesoftware.Steam")); + } public static bool CheckTool(string path) { return Directory.Exists(Path.Combine(path, "xlcore")); From 1ca0695f4ecb2dd226a1b931da7efd8f5c219458 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Sun, 26 Nov 2023 21:31:22 -0800 Subject: [PATCH 08/23] Fix non-flatpak Steam detection in flatpak --- src/XIVLauncher.Core/Program.cs | 4 ++++ .../UnixCompatibility/SteamCompatibilityTool.cs | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/XIVLauncher.Core/Program.cs b/src/XIVLauncher.Core/Program.cs index 3ac857b6..1222553e 100644 --- a/src/XIVLauncher.Core/Program.cs +++ b/src/XIVLauncher.Core/Program.cs @@ -129,7 +129,11 @@ private static void LoadConfig(Storage storage) Config.FixLDP ??= false; Config.FixIM ??= false; +#if FLATPAK + Config.SteamPath ??= Path.Combine(CoreEnvironmentSettings.HOME, ".local", "share"); +#else Config.SteamPath ??= Path.Combine(CoreEnvironmentSettings.XDG_DATA_HOME, "Steam"); +#endif Config.SteamFlatpakPath ??= Path.Combine(CoreEnvironmentSettings.HOME, ".var", "app", "com.valvesoftware.Steam", "data", "Steam" ); } diff --git a/src/XIVLauncher.Core/UnixCompatibility/SteamCompatibilityTool.cs b/src/XIVLauncher.Core/UnixCompatibility/SteamCompatibilityTool.cs index e85df739..301ce51c 100644 --- a/src/XIVLauncher.Core/UnixCompatibility/SteamCompatibilityTool.cs +++ b/src/XIVLauncher.Core/UnixCompatibility/SteamCompatibilityTool.cs @@ -15,7 +15,11 @@ public static class SteamCompatibilityTool static SteamCompatibilityTool() { +#if FLATPAK + IsSteamInstalled = Directory.Exists(Path.Combine(CoreEnvironmentSettings.HOME, ".local", "share", "Steam")); +#else IsSteamInstalled = Directory.Exists(Path.Combine(CoreEnvironmentSettings.XDG_DATA_HOME, "Steam")); +#endif IsFlatpakSteamInstalled = Directory.Exists(Path.Combine(CoreEnvironmentSettings.HOME, ".var/app/com.valvesoftware.Steam")); } public static bool CheckTool(string path) From 2e2569ab28c2e53db92590de49a1e77e573d1ae4 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Mon, 27 Nov 2023 19:17:29 -0800 Subject: [PATCH 09/23] Removed #if FLATPAK directives Cleaned up Steam Tool Settings Tab Added command line install options: --deck-install, --deck-remove to install to default paths --install=/path/to/Steam, --remove= to specify path --- .../SettingsPage/Tabs/SettingsTabSteamTool.cs | 68 +++++++++---------- src/XIVLauncher.Core/Program.cs | 47 +++++++++++-- src/XIVLauncher.Core/Resources/xlcore | 6 +- .../SteamCompatibilityTool.cs | 24 ++----- 4 files changed, 85 insertions(+), 60 deletions(-) diff --git a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabSteamTool.cs b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabSteamTool.cs index b7a8f79e..2c9a0899 100644 --- a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabSteamTool.cs +++ b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabSteamTool.cs @@ -14,20 +14,22 @@ public class SettingsTabSteamTool : SettingsTab private SettingsEntry steamFlatpakPath; - private bool steamToolExists => File.Exists(Path.Combine(Program.Config.SteamPath ?? Path.Combine(CoreEnvironmentSettings.XDG_DATA_HOME, "Steam"), "compatibilitytools.d", "xlcore", "xlcore")); + private bool steamInstalled = SteamCompatibilityTool.IsSteamInstalled; - private bool steamFlatpakToolExists => File.Exists(Path.Combine(Program.Config.SteamFlatpakPath ?? Path.Combine(CoreEnvironmentSettings.HOME, ".var", "app", "com.valvesoftware.Steam", "data", "Steam" ), "compatibilitytools.d", "xlcore", "xlcore")); + private bool steamToolInstalled = SteamCompatibilityTool.IsSteamToolInstalled; + + private bool steamFlatpakInstalled = SteamCompatibilityTool.IsSteamFlatpakInstalled; + + private bool steamFlatpakToolInstalled = SteamCompatibilityTool.IsSteamFlatpakToolInstalled; public SettingsTabSteamTool() { Entries = new SettingsEntry[] { steamPath = new SettingsEntry("Steam Path (native install)", "Path to the native steam config files. Only change this if you have your steam config stored somewhere else.", - () => Program.Config.SteamPath ?? Path.Combine(CoreEnvironmentSettings.XDG_DATA_HOME, "Steam"), s => Program.Config.SteamPath = s), -#if FLATPAK + () => Program.Config.SteamPath ?? Path.Combine(CoreEnvironmentSettings.HOME, ".local", "share", "Steam"), s => Program.Config.SteamPath = s), steamFlatpakPath = new SettingsEntry("Steam Path (flatpak install)", "Path to the flatpak steam config files. Only change this if you have your steam config stored somewhere else.", - () => Program.Config.SteamFlatpakPath ?? Path.Combine(CoreEnvironmentSettings.HOME, ".var", "app", "com.valvesoftware.Steam", "data", "Steam" ), s => Program.Config.SteamFlatpakPath = s), -#endif + () => Program.Config.SteamFlatpakPath ?? Path.Combine(CoreEnvironmentSettings.HOME, ".var", "app", "com.valvesoftware.Steam", "data", "Steam" ), s => Program.Config.SteamFlatpakPath = s), }; } @@ -57,62 +59,54 @@ public override void Draw() ImGui.Text("\nIf you wish to install into Flatpak Steam, you must use Flatseal to give XIVLauncher access to Steam's flatpak path. This is probably something like:"); ImGui.Text($"{CoreEnvironmentSettings.HOME}/.var/app/com.valvesoftware.Steam. If you do not give this permission, installation will fail. You will probably also want to"); ImGui.Text($"give Steam permission to {CoreEnvironmentSettings.HOME}/.xlcore, so that you can continue to use your current xlcore folder."); + ImGui.Text("\nIt is NOT recommended to use native XIVLauncher to install to flatpak Steam. Use flatpak XIVLauncher instead."); ImGui.Dummy(new Vector2(10)); ImGui.Separator(); ImGui.Dummy(new Vector2(10)); - if (!SteamCompatibilityTool.IsSteamInstalled) - { - ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudRed); - ImGui.Text("\nWARNING! Steam install not detected. If it is installed, make sure you run it at least once.\n"); - ImGui.PopStyleColor(); - } - - ImGui.Text($"Native Steam Tool status: {(steamToolExists ? "INSTALLED" : "Not Installed")}"); + ImGui.Text($"Steam: {(steamInstalled ? "INSTALLED" : "Not Installed")}. Native Steam Tool: {(steamToolInstalled ? "INSTALLED" : "Not Installed")}."); ImGui.Dummy(new Vector2(10)); - if (ImGui.Button($"{(steamToolExists ? "Re-i" : "I")}nstall to native Steam")) + if (!steamInstalled) ImGui.BeginDisabled(); + if (ImGui.Button($"{(steamToolInstalled ? "Re-i" : "I")}nstall to native Steam")) { this.Save(); SteamCompatibilityTool.CreateTool(Program.Config.SteamPath); + steamToolInstalled = SteamCompatibilityTool.IsSteamToolInstalled; } + if (!steamInstalled) ImGui.EndDisabled(); ImGui.SameLine(); - if (!steamToolExists) - { - ImGui.BeginDisabled(); - } + if (!steamToolInstalled) ImGui.BeginDisabled(); if (ImGui.Button("Uninstall from native Steam")) { this.Save(); SteamCompatibilityTool.DeleteTool(Program.Config.SteamPath); + steamToolInstalled = SteamCompatibilityTool.IsSteamToolInstalled; } - if (!steamToolExists) - { - ImGui.EndDisabled(); - } + if (!steamToolInstalled) ImGui.EndDisabled(); + ImGui.SameLine(); + ImGui.PushFont(FontManager.IconFont); + ImGui.Text(FontAwesomeIcon.LongArrowAltLeft.ToIconString()); + ImGui.PopFont(); + ImGui.SameLine(); + ImGui.Text("STEAM DECK: USE THESE BUTTONS"); -#if FLATPAK ImGui.Dummy(new Vector2(10)); ImGui.Separator(); ImGui.Dummy(new Vector2(10)); - if (!SteamCompatibilityTool.IsFlatpakSteamInstalled) - { - ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudRed); - ImGui.Text("\nWARNING! Flatpak Steam install not detected. If it is installed, make sure you run it at least once.\n" + - "This may also appear if you have not given your Flatpak XIVLauncher file permissions to ~/.var/app/com.valvesoftware.Steam\n"); - ImGui.PopStyleColor(); - } - - ImGui.Text($"Flatpak Steam Tool status: {(steamFlatpakToolExists ? "INSTALLED" : "Not Installed")}"); + ImGui.Text($"Flatpak Steam: {(steamFlatpakInstalled ? "INSTALLED" : "Not Installed")}. Flatpak Steam Tool: {(steamFlatpakToolInstalled ? "INSTALLED" : "Not Installed")}"); ImGui.Dummy(new Vector2(10)); - if (ImGui.Button($"{(steamFlatpakToolExists ? "Re-i" : "I")}nstall to flatpak Steam")) + if (!steamFlatpakInstalled) ImGui.BeginDisabled(); + if (ImGui.Button($"{(steamFlatpakToolInstalled ? "Re-i" : "I")}nstall to flatpak Steam")) { this.Save(); SteamCompatibilityTool.CreateTool(Program.Config.SteamFlatpakPath); + steamFlatpakToolInstalled = SteamCompatibilityTool.IsSteamFlatpakToolInstalled; } + if (!steamFlatpakInstalled) ImGui.EndDisabled(); ImGui.SameLine(); - if (!steamFlatpakToolExists) + if (!steamFlatpakToolInstalled) { ImGui.BeginDisabled(); } @@ -120,13 +114,13 @@ public override void Draw() { this.Save(); SteamCompatibilityTool.DeleteTool(Program.Config.SteamFlatpakPath); + steamFlatpakToolInstalled = SteamCompatibilityTool.IsSteamFlatpakToolInstalled; } - if (!steamFlatpakToolExists) + if (!steamFlatpakToolInstalled) { ImGui.EndDisabled(); } -#endif ImGui.Dummy(new Vector2(10)); ImGui.Separator(); ImGui.Dummy(new Vector2(10)); diff --git a/src/XIVLauncher.Core/Program.cs b/src/XIVLauncher.Core/Program.cs index 1222553e..435239e1 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; @@ -129,11 +130,7 @@ private static void LoadConfig(Storage storage) Config.FixLDP ??= false; Config.FixIM ??= false; -#if FLATPAK Config.SteamPath ??= Path.Combine(CoreEnvironmentSettings.HOME, ".local", "share"); -#else - Config.SteamPath ??= Path.Combine(CoreEnvironmentSettings.XDG_DATA_HOME, "Steam"); -#endif Config.SteamFlatpakPath ??= Path.Combine(CoreEnvironmentSettings.HOME, ".var", "app", "com.valvesoftware.Steam", "data", "Steam" ); } @@ -142,6 +139,48 @@ private static void LoadConfig(Storage storage) private static void Main(string[] args) { + foreach (var arg in args) + { + if (arg == "--deck-install") + { + SteamCompatibilityTool.CreateTool(Path.Combine(CoreEnvironmentSettings.HOME, ".local", "share", "Steam")); + Console.WriteLine($"Installed as Steam compatibility tool to {Path.Combine(CoreEnvironmentSettings.HOME, ".local", "share", "Steam", "compatibilitytools.d", "xlcore")}"); + return; + } + if (arg.StartsWith("--install=")) + { + var path = arg.Split('=', 2)[1]; + if (Directory.Exists(path) && (path.EndsWith("/Steam") || path.EndsWith("/Steam/"))) + { + SteamCompatibilityTool.CreateTool(path); + Console.WriteLine($"Installed as Steam compatibility tool to path {Path.Combine(path, "compatibilitytools.d", "xlcore")}"); + } + else + Console.WriteLine($"Invalid path. Path does not exist or is not a Steam folder: {path}"); + + return; + } + if (arg == "--deck-remove") + { + SteamCompatibilityTool.DeleteTool(Path.Combine(CoreEnvironmentSettings.HOME, ".local", "share", "Steam")); + Console.WriteLine($"Removed XIVLauncher.Core as a Steam compatibility tool from {Path.Combine(CoreEnvironmentSettings.HOME, ".local", "share", "Steam", "compatibilitytools.d")}"); + return; + } + if (arg.StartsWith("--remove=")) + { + var path = arg.Split('=', 2)[1]; + if (Directory.Exists(path) && (path.EndsWith("/Steam") || path.EndsWith("/Steam/"))) + { + SteamCompatibilityTool.DeleteTool(path); + Console.WriteLine($"Removed XIVLauncher.Core as a Steam compatibility tool from {Path.Combine(path, "compatibilitytools.d")}"); + } + else + Console.WriteLine($"Invalid path. Path does not exist or is not a Steam folder: {path}"); + + return; + } + } + mainargs = args; storage = new Storage(APP_NAME); diff --git a/src/XIVLauncher.Core/Resources/xlcore b/src/XIVLauncher.Core/Resources/xlcore index 84d57846..09bfbc9d 100755 --- a/src/XIVLauncher.Core/Resources/xlcore +++ b/src/XIVLauncher.Core/Resources/xlcore @@ -16,7 +16,8 @@ tooldir="$(realpath "$(dirname "$0")")" # If aria2c isn't found, add our local copy to the $PATH count=$(find /usr -type f -executable -name "aria2c" 2>/dev/null | wc -l) -if (( $count == 0 )); then +local=$(find $tooldir -type f -executable -name "aria2c" 2>/dev/null | wc -l) +if (( $count == 0 && $local != 0 )); then PATH="$PATH:$tooldir/bin" fi @@ -29,7 +30,8 @@ unset LD_PRELOAD # If libsecret isn't found, add to $LD_PRELOAD count=$(ldconfig -p | grep libsecret-1 | wc -l) -if (( $count == 0)); then +local=$(find $tooldir -type f -name "libsecret*" 2>/dev/null | wc -l) +if (( $count == 0 && $local !=0 )); then export LD_PRELOAD=$tooldir/lib/libsecret-1.so.0:$tooldir/lib/libsecret-1.so.0.0.0:$LD_PRELOAD fi diff --git a/src/XIVLauncher.Core/UnixCompatibility/SteamCompatibilityTool.cs b/src/XIVLauncher.Core/UnixCompatibility/SteamCompatibilityTool.cs index 301ce51c..f0e6a284 100644 --- a/src/XIVLauncher.Core/UnixCompatibility/SteamCompatibilityTool.cs +++ b/src/XIVLauncher.Core/UnixCompatibility/SteamCompatibilityTool.cs @@ -9,23 +9,13 @@ namespace XIVLauncher.Core.UnixCompatibility; public static class SteamCompatibilityTool { - public static bool IsSteamInstalled { get; } = false; + public static bool IsSteamInstalled => Directory.Exists(Program.Config.SteamPath); - public static bool IsFlatpakSteamInstalled { get; } = false; + public static bool IsSteamFlatpakInstalled => Directory.Exists(Program.Config.SteamFlatpakPath); - static SteamCompatibilityTool() - { -#if FLATPAK - IsSteamInstalled = Directory.Exists(Path.Combine(CoreEnvironmentSettings.HOME, ".local", "share", "Steam")); -#else - IsSteamInstalled = Directory.Exists(Path.Combine(CoreEnvironmentSettings.XDG_DATA_HOME, "Steam")); -#endif - IsFlatpakSteamInstalled = Directory.Exists(Path.Combine(CoreEnvironmentSettings.HOME, ".var/app/com.valvesoftware.Steam")); - } - public static bool CheckTool(string path) - { - return Directory.Exists(Path.Combine(path, "xlcore")); - } + public static bool IsSteamToolInstalled => Directory.Exists(Path.Combine(Program.Config.SteamPath, "compatibilitytools.d", "xlcore")); + + public static bool IsSteamFlatpakToolInstalled => Directory.Exists(Path.Combine(Program.Config.SteamFlatpakPath, "compatibilitytools.d", "xlcore")); private static string findXIVLauncherFiles() { @@ -103,7 +93,6 @@ public static void CreateTool(string path) file.CopyTo(Path.Combine(destination.FullName, "XIVLauncher", file.Name), true); } -#if FLATPAK var aria2c = new FileInfo("/app/bin/aria2c"); var libsecret = new FileInfo("/app/lib/libsecret-1.so.0.0.0"); @@ -116,13 +105,14 @@ public static void CreateTool(string path) libsecret.CopyTo(Path.Combine(libPath, "libsecret-1.so.0.0.0")); File.CreateSymbolicLink(Path.Combine(libPath, "libsecret-1.so"), "libsecret-1.so.0.0.0"); } -#endif + Log.Verbose($"[SCT] XIVLauncher installed as Steam compatibility tool to folder {destination.FullName}"); } public static void DeleteTool(string path) { var steamToolFolder = new DirectoryInfo(Path.Combine(path, "compatibilitytools.d", "xlcore")); + if (!steamToolFolder.Exists) return; steamToolFolder.Delete(true); Log.Verbose($"[SCT] Deleted Steam compatibility tool at folder {steamToolFolder.FullName}"); } From 0ea02dc23ff627f5a4bb8611cba04d4105daff9b Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Mon, 27 Nov 2023 20:00:48 -0800 Subject: [PATCH 10/23] Allow --install to handle ~/path/to/Steam --- src/XIVLauncher.Core/Program.cs | 94 ++++++++++++++++++--------------- 1 file changed, 52 insertions(+), 42 deletions(-) diff --git a/src/XIVLauncher.Core/Program.cs b/src/XIVLauncher.Core/Program.cs index 435239e1..2dc325c0 100644 --- a/src/XIVLauncher.Core/Program.cs +++ b/src/XIVLauncher.Core/Program.cs @@ -139,48 +139,6 @@ private static void LoadConfig(Storage storage) private static void Main(string[] args) { - foreach (var arg in args) - { - if (arg == "--deck-install") - { - SteamCompatibilityTool.CreateTool(Path.Combine(CoreEnvironmentSettings.HOME, ".local", "share", "Steam")); - Console.WriteLine($"Installed as Steam compatibility tool to {Path.Combine(CoreEnvironmentSettings.HOME, ".local", "share", "Steam", "compatibilitytools.d", "xlcore")}"); - return; - } - if (arg.StartsWith("--install=")) - { - var path = arg.Split('=', 2)[1]; - if (Directory.Exists(path) && (path.EndsWith("/Steam") || path.EndsWith("/Steam/"))) - { - SteamCompatibilityTool.CreateTool(path); - Console.WriteLine($"Installed as Steam compatibility tool to path {Path.Combine(path, "compatibilitytools.d", "xlcore")}"); - } - else - Console.WriteLine($"Invalid path. Path does not exist or is not a Steam folder: {path}"); - - return; - } - if (arg == "--deck-remove") - { - SteamCompatibilityTool.DeleteTool(Path.Combine(CoreEnvironmentSettings.HOME, ".local", "share", "Steam")); - Console.WriteLine($"Removed XIVLauncher.Core as a Steam compatibility tool from {Path.Combine(CoreEnvironmentSettings.HOME, ".local", "share", "Steam", "compatibilitytools.d")}"); - return; - } - if (arg.StartsWith("--remove=")) - { - var path = arg.Split('=', 2)[1]; - if (Directory.Exists(path) && (path.EndsWith("/Steam") || path.EndsWith("/Steam/"))) - { - SteamCompatibilityTool.DeleteTool(path); - Console.WriteLine($"Removed XIVLauncher.Core as a Steam compatibility tool from {Path.Combine(path, "compatibilitytools.d")}"); - } - else - Console.WriteLine($"Invalid path. Path does not exist or is not a Steam folder: {path}"); - - return; - } - } - mainargs = args; storage = new Storage(APP_NAME); @@ -229,6 +187,8 @@ private static void Main(string[] args) break; case PlatformID.Unix: + // We should only run the script on Linux (maybe Unix) systems. + if (CommandLineInstaller()) return; Steam = new UnixSteam(); break; @@ -484,4 +444,54 @@ public static void ClearAll(bool tsbutton = false) ClearTools(tsbutton); ClearLogs(true); } + + private static bool CommandLineInstaller() + { + foreach (var arg in mainargs) + { + if (arg == "--deck-install") + { + SteamCompatibilityTool.CreateTool(Path.Combine(CoreEnvironmentSettings.HOME, ".local", "share", "Steam")); + Console.WriteLine($"Installed as Steam compatibility tool to {Path.Combine(CoreEnvironmentSettings.HOME, ".local", "share", "Steam", "compatibilitytools.d", "xlcore")}"); + return true; + } + if (arg.StartsWith("--install=")) + { + var path = arg.Split('=', 2)[1]; + if (path.StartsWith("~/")) + path = CoreEnvironmentSettings.HOME + path.TrimStart('~'); + if (Directory.Exists(path) && (path.EndsWith("/Steam") || path.EndsWith("/Steam/"))) + { + SteamCompatibilityTool.CreateTool(path); + Console.WriteLine($"Installed as Steam compatibility tool to path {Path.Combine(path, "compatibilitytools.d", "xlcore")}"); + } + else + Console.WriteLine($"Invalid path. Path does not exist or is not a Steam folder: {path}"); + + return true; + } + if (arg == "--deck-remove") + { + SteamCompatibilityTool.DeleteTool(Path.Combine(CoreEnvironmentSettings.HOME, ".local", "share", "Steam")); + Console.WriteLine($"Removed XIVLauncher.Core as a Steam compatibility tool from {Path.Combine(CoreEnvironmentSettings.HOME, ".local", "share", "Steam", "compatibilitytools.d")}"); + return true; + } + if (arg.StartsWith("--remove=")) + { + var path = arg.Split('=', 2)[1]; + if (path.StartsWith("~/")) + path = CoreEnvironmentSettings.HOME + path.TrimStart('~'); + if (Directory.Exists(path) && (path.EndsWith("/Steam") || path.EndsWith("/Steam/"))) + { + SteamCompatibilityTool.DeleteTool(path); + Console.WriteLine($"Removed XIVLauncher.Core as a Steam compatibility tool from {Path.Combine(path, "compatibilitytools.d")}"); + } + else + Console.WriteLine($"Invalid path. Path does not exist or is not a Steam folder: {path}"); + + return true; + } + } + return false; + } } \ No newline at end of file From 8d6a0796c4556b4572c1fa16e876a5f0104d9381 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Fri, 15 Dec 2023 21:36:41 -0800 Subject: [PATCH 11/23] Rework XL_PRELOAD --- src/XIVLauncher.Core/Components/MainPage/MainPage.cs | 5 +++++ src/XIVLauncher.Core/CoreEnvironmentSettings.cs | 8 -------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/XIVLauncher.Core/Components/MainPage/MainPage.cs b/src/XIVLauncher.Core/Components/MainPage/MainPage.cs index dcd0f9f8..f0e5f301 100644 --- a/src/XIVLauncher.Core/Components/MainPage/MainPage.cs +++ b/src/XIVLauncher.Core/Components/MainPage/MainPage.cs @@ -685,6 +685,11 @@ public async Task StartGameAndAddon(Launcher.LoginResult loginResult, b IGameRunner runner; + // Set LD_PRELOAD to value of XL_PRELOAD if we're in Steam Compatibility Tool mode. + // We ONLY care about XL_PRELOAD if we're in SCT mode. It's a workaround to prevent a text bug with Steam overlay enabled. + if (CoreEnvironmentSettings.IsSteamCompatTool) + System.Environment.SetEnvironmentVariable("LD_PRELOAD", CoreEnvironmentSettings.GetCleanEnvironmentVariable("XL_PRELOAD")); + // Hack: Strip out gameoverlayrenderer.so entries from LD_PRELOAD if (App.Settings.FixLDP.Value) { diff --git a/src/XIVLauncher.Core/CoreEnvironmentSettings.cs b/src/XIVLauncher.Core/CoreEnvironmentSettings.cs index e0c55878..4ae9454e 100644 --- a/src/XIVLauncher.Core/CoreEnvironmentSettings.cs +++ b/src/XIVLauncher.Core/CoreEnvironmentSettings.cs @@ -40,12 +40,4 @@ public static string GetCleanEnvironmentVariable(string envvar, string badstring if (badstring.Equals("")) return dirty; return string.Join(separator, Array.FindAll(dirty.Split(separator, StringSplitOptions.RemoveEmptyEntries), s => !s.Contains(badstring))); } - - static CoreEnvironmentSettings() - { - var xlpreload = Environment.GetEnvironmentVariable("XL_PRELOAD") ?? ""; - var ldpreload = GetCleanEnvironmentVariable("LD_PRELOAD"); - ldpreload = (string.IsNullOrEmpty(xlpreload) ? "" : xlpreload + ":") + (string.IsNullOrEmpty(ldpreload) ? "" : ldpreload); - Environment.SetEnvironmentVariable("LD_PRELOAD", ldpreload); - } } \ No newline at end of file From 4d8d9b8c72a4a9f67891c7c2bcd2a3464ef268d5 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Sat, 23 Mar 2024 10:56:19 -0700 Subject: [PATCH 12/23] Minor script fix. Seems to help with stuttering. --- src/XIVLauncher.Core/Resources/xlcore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/XIVLauncher.Core/Resources/xlcore b/src/XIVLauncher.Core/Resources/xlcore index 09bfbc9d..33768294 100755 --- a/src/XIVLauncher.Core/Resources/xlcore +++ b/src/XIVLauncher.Core/Resources/xlcore @@ -37,4 +37,4 @@ fi export OPENSSL_CONF="$tooldir/openssl_fix.cnf" export XL_SCT=1 -"$tooldir/XIVLauncher/XIVLauncher.Core" $@ >> $logDir/steamtool_console.log 2>&1 \ No newline at end of file +"$tooldir/XIVLauncher/XIVLauncher.Core" $@ >> $logDir/steamtool_console.log 2>&1 & \ No newline at end of file From cb12b7a889101ccf05e9fabd83bbf803b39a1622 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Sat, 23 Mar 2024 12:32:28 -0700 Subject: [PATCH 13/23] Deck doesn't show flatpak install option --- .../SettingsPage/Tabs/SettingsTabSteamTool.cs | 87 ++++++++++--------- 1 file changed, 45 insertions(+), 42 deletions(-) diff --git a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabSteamTool.cs b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabSteamTool.cs index 2c9a0899..db00ec36 100644 --- a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabSteamTool.cs +++ b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabSteamTool.cs @@ -29,7 +29,10 @@ public SettingsTabSteamTool() steamPath = new SettingsEntry("Steam Path (native install)", "Path to the native steam config files. Only change this if you have your steam config stored somewhere else.", () => Program.Config.SteamPath ?? Path.Combine(CoreEnvironmentSettings.HOME, ".local", "share", "Steam"), s => Program.Config.SteamPath = s), steamFlatpakPath = new SettingsEntry("Steam Path (flatpak install)", "Path to the flatpak steam config files. Only change this if you have your steam config stored somewhere else.", - () => Program.Config.SteamFlatpakPath ?? Path.Combine(CoreEnvironmentSettings.HOME, ".var", "app", "com.valvesoftware.Steam", "data", "Steam" ), s => Program.Config.SteamFlatpakPath = s), + () => Program.Config.SteamFlatpakPath ?? Path.Combine(CoreEnvironmentSettings.HOME, ".var", "app", "com.valvesoftware.Steam", "data", "Steam" ), s => Program.Config.SteamFlatpakPath = s) + { + CheckVisibility = () => CoreEnvironmentSettings.IsDeck != true && SteamCompatibilityTool.IsSteamFlatpakInstalled, + }, }; } @@ -55,23 +58,26 @@ public override void Draw() ImGui.Text("\nUse this tab to install XIVLauncher.Core as a Steam compatibility tool."); ImGui.Text("\nAfter you have installed XIVLauncher as a Steam tool, close this program, and launch Steam. Select Final Fantasy XIV from the library,"); ImGui.Text("and go to Compatibility. Force the use of a specific Steam Play compatibility tool, and choose XIVLauncher.Core as Compatibility Tool."); - ImGui.Text("XIVLauncher.Core will now be used to launch Final Fantasy XIV. This feature can be used with Flatpak steam."); - ImGui.Text("\nIf you wish to install into Flatpak Steam, you must use Flatseal to give XIVLauncher access to Steam's flatpak path. This is probably something like:"); - ImGui.Text($"{CoreEnvironmentSettings.HOME}/.var/app/com.valvesoftware.Steam. If you do not give this permission, installation will fail. You will probably also want to"); - ImGui.Text($"give Steam permission to {CoreEnvironmentSettings.HOME}/.xlcore, so that you can continue to use your current xlcore folder."); - ImGui.Text("\nIt is NOT recommended to use native XIVLauncher to install to flatpak Steam. Use flatpak XIVLauncher instead."); + ImGui.Text("XIVLauncher.Core will now be used to launch Final Fantasy XIV."); + if (CoreEnvironmentSettings.IsDeck != true && steamFlatpakInstalled) + { + ImGui.Text("\nIf you wish to install into Flatpak Steam, you must use Flatseal to give XIVLauncher access to Steam's flatpak path. This is probably something like:"); + ImGui.Text($"{CoreEnvironmentSettings.HOME}/.var/app/com.valvesoftware.Steam. If you do not give this permission, installation will fail. You will probably also want to"); + ImGui.Text($"give Steam permission to {CoreEnvironmentSettings.HOME}/.xlcore, so that you can continue to use your current xlcore folder."); + ImGui.Text("\nIt is NOT recommended to use native XIVLauncher to install to flatpak Steam. Use flatpak XIVLauncher instead."); + } ImGui.Dummy(new Vector2(10)); ImGui.Separator(); ImGui.Dummy(new Vector2(10)); - ImGui.Text($"Steam: {(steamInstalled ? "INSTALLED" : "Not Installed")}. Native Steam Tool: {(steamToolInstalled ? "INSTALLED" : "Not Installed")}."); + ImGui.Text($"Steam settings directory: {(steamInstalled ? "PRESENT" : "Not Present")}. Native Steam Tool: {(steamToolInstalled ? "INSTALLED" : "Not Installed")}."); ImGui.Dummy(new Vector2(10)); if (!steamInstalled) ImGui.BeginDisabled(); if (ImGui.Button($"{(steamToolInstalled ? "Re-i" : "I")}nstall to native Steam")) { this.Save(); - SteamCompatibilityTool.CreateTool(Program.Config.SteamPath); + SteamCompatibilityTool.CreateTool(Program.Config.SteamPath ?? ""); steamToolInstalled = SteamCompatibilityTool.IsSteamToolInstalled; } if (!steamInstalled) ImGui.EndDisabled(); @@ -80,45 +86,42 @@ public override void Draw() if (ImGui.Button("Uninstall from native Steam")) { this.Save(); - SteamCompatibilityTool.DeleteTool(Program.Config.SteamPath); + SteamCompatibilityTool.DeleteTool(Program.Config.SteamPath ?? ""); steamToolInstalled = SteamCompatibilityTool.IsSteamToolInstalled; } if (!steamToolInstalled) ImGui.EndDisabled(); - ImGui.SameLine(); - ImGui.PushFont(FontManager.IconFont); - ImGui.Text(FontAwesomeIcon.LongArrowAltLeft.ToIconString()); - ImGui.PopFont(); - ImGui.SameLine(); - ImGui.Text("STEAM DECK: USE THESE BUTTONS"); - ImGui.Dummy(new Vector2(10)); - ImGui.Separator(); - ImGui.Dummy(new Vector2(10)); - - ImGui.Text($"Flatpak Steam: {(steamFlatpakInstalled ? "INSTALLED" : "Not Installed")}. Flatpak Steam Tool: {(steamFlatpakToolInstalled ? "INSTALLED" : "Not Installed")}"); - ImGui.Dummy(new Vector2(10)); - if (!steamFlatpakInstalled) ImGui.BeginDisabled(); - if (ImGui.Button($"{(steamFlatpakToolInstalled ? "Re-i" : "I")}nstall to flatpak Steam")) - { - this.Save(); - SteamCompatibilityTool.CreateTool(Program.Config.SteamFlatpakPath); - steamFlatpakToolInstalled = SteamCompatibilityTool.IsSteamFlatpakToolInstalled; - } - if (!steamFlatpakInstalled) ImGui.EndDisabled(); - ImGui.SameLine(); - if (!steamFlatpakToolInstalled) - { - ImGui.BeginDisabled(); - } - if (ImGui.Button("Uninstall from Flatpak Steam")) + if (CoreEnvironmentSettings.IsDeck != true && steamFlatpakInstalled) { - this.Save(); - SteamCompatibilityTool.DeleteTool(Program.Config.SteamFlatpakPath); - steamFlatpakToolInstalled = SteamCompatibilityTool.IsSteamFlatpakToolInstalled; - } - if (!steamFlatpakToolInstalled) - { - ImGui.EndDisabled(); + ImGui.Dummy(new Vector2(10)); + ImGui.Separator(); + ImGui.Dummy(new Vector2(10)); + + ImGui.Text($"Flatpak Steam settings directory: PRESENT. Flatpak Steam Tool: {(steamFlatpakToolInstalled ? "INSTALLED" : "Not Installed")}"); + ImGui.Dummy(new Vector2(10)); + if (!steamFlatpakInstalled) ImGui.BeginDisabled(); + if (ImGui.Button($"{(steamFlatpakToolInstalled ? "Re-i" : "I")}nstall to flatpak Steam")) + { + this.Save(); + SteamCompatibilityTool.CreateTool(Program.Config.SteamFlatpakPath ?? ""); + steamFlatpakToolInstalled = SteamCompatibilityTool.IsSteamFlatpakToolInstalled; + } + if (!steamFlatpakInstalled) ImGui.EndDisabled(); + ImGui.SameLine(); + if (!steamFlatpakToolInstalled) + { + ImGui.BeginDisabled(); + } + if (ImGui.Button("Uninstall from Flatpak Steam")) + { + this.Save(); + SteamCompatibilityTool.DeleteTool(Program.Config.SteamFlatpakPath ?? ""); + steamFlatpakToolInstalled = SteamCompatibilityTool.IsSteamFlatpakToolInstalled; + } + if (!steamFlatpakToolInstalled) + { + ImGui.EndDisabled(); + } } ImGui.Dummy(new Vector2(10)); From 9cb5a1a93514251af8f89e7492ddb0de9dd45d84 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Wed, 27 Mar 2024 08:08:53 -0700 Subject: [PATCH 14/23] Change some wording per suggestions --- .../SettingsPage/Tabs/SettingsTabSteamTool.cs | 20 +++++++++---------- .../SteamCompatibilityTool.cs | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabSteamTool.cs b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabSteamTool.cs index db00ec36..dec67ae5 100644 --- a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabSteamTool.cs +++ b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabSteamTool.cs @@ -26,12 +26,12 @@ public SettingsTabSteamTool() { Entries = new SettingsEntry[] { - steamPath = new SettingsEntry("Steam Path (native install)", "Path to the native steam config files. Only change this if you have your steam config stored somewhere else.", + steamPath = new SettingsEntry("Steam Path (native)", "Path to the native steam install. Only change this if you have Steam installed in a non-default location.", () => Program.Config.SteamPath ?? Path.Combine(CoreEnvironmentSettings.HOME, ".local", "share", "Steam"), s => Program.Config.SteamPath = s), - steamFlatpakPath = new SettingsEntry("Steam Path (flatpak install)", "Path to the flatpak steam config files. Only change this if you have your steam config stored somewhere else.", + steamFlatpakPath = new SettingsEntry("Steam Path (flatpak)", "Path to the flatpak Steam installation. Only change this if you have your flatpak Steam installed to a non-default location.", () => Program.Config.SteamFlatpakPath ?? Path.Combine(CoreEnvironmentSettings.HOME, ".var", "app", "com.valvesoftware.Steam", "data", "Steam" ), s => Program.Config.SteamFlatpakPath = s) { - CheckVisibility = () => CoreEnvironmentSettings.IsDeck != true && SteamCompatibilityTool.IsSteamFlatpakInstalled, + CheckVisibility = () => Program.IsSteamDeckHardware != true && SteamCompatibilityTool.IsSteamFlatpakInstalled, }, }; } @@ -56,13 +56,13 @@ public override void Draw() return; } ImGui.Text("\nUse this tab to install XIVLauncher.Core as a Steam compatibility tool."); - ImGui.Text("\nAfter you have installed XIVLauncher as a Steam tool, close this program, and launch Steam. Select Final Fantasy XIV from the library,"); - ImGui.Text("and go to Compatibility. Force the use of a specific Steam Play compatibility tool, and choose XIVLauncher.Core as Compatibility Tool."); - ImGui.Text("XIVLauncher.Core will now be used to launch Final Fantasy XIV."); - if (CoreEnvironmentSettings.IsDeck != true && steamFlatpakInstalled) + ImGui.Text("\nAfter you have installed XIVLauncher as a Steam compatibility tool please close XIVLauncher and launch or restart Steam. Find 'Final Fantasy XIV Online' in your steam library"); + ImGui.Text("and open the 'Properties' menu and navigate to the 'Compatibility' tab. Enable 'Force the use of a specific Steam Play compatibility tool' and from the dropdown menu select 'XIVLauncher.Core'. If this option does not show up then restart Steam and try again."); + ImGui.Text("After finishing these steps, XIVLauncher will now be used when launching FINAL FANTASY XIV from steam."); + if (Program.IsSteamDeckHardware != true && steamFlatpakInstalled) { - ImGui.Text("\nIf you wish to install into Flatpak Steam, you must use Flatseal to give XIVLauncher access to Steam's flatpak path. This is probably something like:"); - ImGui.Text($"{CoreEnvironmentSettings.HOME}/.var/app/com.valvesoftware.Steam. If you do not give this permission, installation will fail. You will probably also want to"); + ImGui.Text("\nIf you wish to install into Flatpak Steam, you must use Flatseal to give XIVLauncher access to Steam's flatpak path. This is commonly found at:"); + ImGui.Text($"{CoreEnvironmentSettings.HOME}/.var/app/com.valvesoftware.Steam. If you do not give this permission, installation will fail. You will also want to"); ImGui.Text($"give Steam permission to {CoreEnvironmentSettings.HOME}/.xlcore, so that you can continue to use your current xlcore folder."); ImGui.Text("\nIt is NOT recommended to use native XIVLauncher to install to flatpak Steam. Use flatpak XIVLauncher instead."); } @@ -91,7 +91,7 @@ public override void Draw() } if (!steamToolInstalled) ImGui.EndDisabled(); - if (CoreEnvironmentSettings.IsDeck != true && steamFlatpakInstalled) + if (!Program.IsSteamDeckHardware && steamFlatpakInstalled) { ImGui.Dummy(new Vector2(10)); ImGui.Separator(); diff --git a/src/XIVLauncher.Core/UnixCompatibility/SteamCompatibilityTool.cs b/src/XIVLauncher.Core/UnixCompatibility/SteamCompatibilityTool.cs index f0e6a284..c65e7f32 100644 --- a/src/XIVLauncher.Core/UnixCompatibility/SteamCompatibilityTool.cs +++ b/src/XIVLauncher.Core/UnixCompatibility/SteamCompatibilityTool.cs @@ -54,7 +54,7 @@ public static void CreateTool(string path) fs.Close(); } - // File.SetUnixFileMode() doesn't exist, for some reason, so just run chmod + // File.SetUnixFileMode() doesn't exist in .NET 6, so just run chmod var psi = new ProcessStartInfo("/bin/chmod"); psi.ArgumentList.Add("+x"); psi.ArgumentList.Add(xlcore.FullName); From d6d4e443538cda9c63b17f2d183e7870457e2d3c Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Wed, 27 Mar 2024 08:20:22 -0700 Subject: [PATCH 15/23] Fix some spacing issues --- .../Components/SettingsPage/Tabs/SettingsTabSteamTool.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabSteamTool.cs b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabSteamTool.cs index dec67ae5..1e6df5b0 100644 --- a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabSteamTool.cs +++ b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabSteamTool.cs @@ -56,15 +56,16 @@ public override void Draw() return; } ImGui.Text("\nUse this tab to install XIVLauncher.Core as a Steam compatibility tool."); - ImGui.Text("\nAfter you have installed XIVLauncher as a Steam compatibility tool please close XIVLauncher and launch or restart Steam. Find 'Final Fantasy XIV Online' in your steam library"); - ImGui.Text("and open the 'Properties' menu and navigate to the 'Compatibility' tab. Enable 'Force the use of a specific Steam Play compatibility tool' and from the dropdown menu select 'XIVLauncher.Core'. If this option does not show up then restart Steam and try again."); - ImGui.Text("After finishing these steps, XIVLauncher will now be used when launching FINAL FANTASY XIV from steam."); + ImGui.Text("\nAfter you have installed XIVLauncher as a Steam compatibility tool please close XIVLauncher and launch or restart Steam. Find 'Final Fantasy XIV Online'"); + ImGui.Text("in your steam library and open the 'Properties' menu and navigate to the 'Compatibility' tab. Enable 'Force the use of a specific Steam Play compatibility tool'"); + ImGui.Text("and from the dropdown menu select 'XIVLauncher.Core'. If this option does not show up then restart Steam and try again. After finishing these steps,"); + ImGui.Text("XIVLauncher will now be used when launching FINAL FANTASY XIV from steam."); if (Program.IsSteamDeckHardware != true && steamFlatpakInstalled) { ImGui.Text("\nIf you wish to install into Flatpak Steam, you must use Flatseal to give XIVLauncher access to Steam's flatpak path. This is commonly found at:"); ImGui.Text($"{CoreEnvironmentSettings.HOME}/.var/app/com.valvesoftware.Steam. If you do not give this permission, installation will fail. You will also want to"); ImGui.Text($"give Steam permission to {CoreEnvironmentSettings.HOME}/.xlcore, so that you can continue to use your current xlcore folder."); - ImGui.Text("\nIt is NOT recommended to use native XIVLauncher to install to flatpak Steam. Use flatpak XIVLauncher instead."); + ImGui.Text("\nDO NOT use native XIVLauncher to install to flatpak Steam. Use flatpak XIVLauncher instead."); } ImGui.Dummy(new Vector2(10)); From b8fee9c13903df71102d92d893f75acf19bdcd94 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Sat, 6 Apr 2024 15:04:58 -0700 Subject: [PATCH 16/23] Convert xlcore script to posix sh --- src/XIVLauncher.Core/Resources/xlcore | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/XIVLauncher.Core/Resources/xlcore b/src/XIVLauncher.Core/Resources/xlcore index 33768294..07cfa897 100755 --- a/src/XIVLauncher.Core/Resources/xlcore +++ b/src/XIVLauncher.Core/Resources/xlcore @@ -1,7 +1,7 @@ -#!/bin/env bash +#!/bin/env sh # Prevent double launch -if [ $1 == "run" ]; then +if [ "$1" = "run" ]; then sleep 1 exit 0 fi @@ -16,8 +16,7 @@ tooldir="$(realpath "$(dirname "$0")")" # If aria2c isn't found, add our local copy to the $PATH count=$(find /usr -type f -executable -name "aria2c" 2>/dev/null | wc -l) -local=$(find $tooldir -type f -executable -name "aria2c" 2>/dev/null | wc -l) -if (( $count == 0 && $local != 0 )); then +if [ $count -eq 0 ] && [ -e "$tooldir/bin/aria2c" ]; then PATH="$PATH:$tooldir/bin" fi @@ -28,13 +27,12 @@ fi export XL_PRELOAD="$LD_PRELOAD" unset LD_PRELOAD -# If libsecret isn't found, add to $LD_PRELOAD +# If libsecret isn't found, add local copy to $LD_PRELOAD count=$(ldconfig -p | grep libsecret-1 | wc -l) -local=$(find $tooldir -type f -name "libsecret*" 2>/dev/null | wc -l) -if (( $count == 0 && $local !=0 )); then +if [ "$count" -eq 0 ] && [ -e "$tooldir/lib/libsecret-1.so.0.0.0" ]; then export LD_PRELOAD=$tooldir/lib/libsecret-1.so.0:$tooldir/lib/libsecret-1.so.0.0.0:$LD_PRELOAD fi export OPENSSL_CONF="$tooldir/openssl_fix.cnf" export XL_SCT=1 -"$tooldir/XIVLauncher/XIVLauncher.Core" $@ >> $logDir/steamtool_console.log 2>&1 & \ No newline at end of file +"$tooldir/XIVLauncher/XIVLauncher.Core" $@ >> $logDir/steamtool_console.log 2>&1 From e6001c2ff125342f1a7ecb2a2dbfe4b9bbc0cef6 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Sun, 7 Apr 2024 08:20:33 -0700 Subject: [PATCH 17/23] Update otp with Common components --- .../Components/Common/Button.cs | 6 +- .../Components/Common/Input.cs | 24 ++++++- .../Components/OtpEntryPage.cs | 72 +++++++++++++++---- 3 files changed, 84 insertions(+), 18 deletions(-) diff --git a/src/XIVLauncher.Core/Components/Common/Button.cs b/src/XIVLauncher.Core/Components/Common/Button.cs index f559d676..819f20a7 100644 --- a/src/XIVLauncher.Core/Components/Common/Button.cs +++ b/src/XIVLauncher.Core/Components/Common/Button.cs @@ -17,6 +17,8 @@ public class Button : Component public int? Width { get; set; } + public int? Height { get; set; } + public Button(string label, bool isEnabled = true, Vector4? color = null, Vector4? hoverColor = null, Vector4? textColor = null) { Label = label; @@ -28,13 +30,13 @@ public Button(string label, bool isEnabled = true, Vector4? color = null, Vector public override void Draw() { - ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, new Vector2(16f, 16f)); + ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, new Vector2(Width is not null ? 0f : 16f, Height is not null ? 0f : 16f)); ImGui.PushStyleVar(ImGuiStyleVar.FrameRounding, 0); ImGui.PushStyleColor(ImGuiCol.Button, Color); ImGui.PushStyleColor(ImGuiCol.ButtonHovered, HoverColor); ImGui.PushStyleColor(ImGuiCol.Text, TextColor); - if (ImGui.Button(Label, new Vector2(Width ?? -1, 0)) || (ImGui.IsItemFocused() && ImGui.IsKeyPressed(ImGuiKey.Enter))) + if (ImGui.Button(Label, new Vector2(Width ?? -1, Height ?? 0)) || (ImGui.IsItemFocused() && (ImGui.IsKeyPressed(ImGuiKey.Enter) || ImGui.IsKeyPressed(ImGuiKey.KeypadEnter)))) { this.Click?.Invoke(); } diff --git a/src/XIVLauncher.Core/Components/Common/Input.cs b/src/XIVLauncher.Core/Components/Common/Input.cs index 9ee1fb05..050c620b 100644 --- a/src/XIVLauncher.Core/Components/Common/Input.cs +++ b/src/XIVLauncher.Core/Components/Common/Input.cs @@ -18,6 +18,8 @@ public class Input : Component public uint MaxLength { get; } + public int Width { get; set; } + public ImGuiInputTextFlags Flags { get; } public bool IsEnabled { get; set; } = true; @@ -43,12 +45,14 @@ public Input( string hint, Vector2? spacing, uint maxLength = 255, + int width = 0, bool isEnabled = true, ImGuiInputTextFlags flags = ImGuiInputTextFlags.None) { Label = label; Hint = hint; MaxLength = maxLength; + Width = width; Flags = flags; IsEnabled = isEnabled; Spacing = spacing ?? Vector2.Zero; @@ -83,19 +87,33 @@ public override void Draw() if (TakeKeyboardFocus && ImGui.IsWindowAppearing()) ImGui.SetKeyboardFocusHere(); - ImGui.Text(Label); + if (!string.IsNullOrEmpty(Label)) + { + if (Width != 0) + ImGuiHelpers.CenteredText(Label); + else + ImGui.Text(Label); + } if (!this.IsEnabled || this.isSteamDeckInputActive) ImGui.BeginDisabled(); var ww = ImGui.GetWindowWidth(); - ImGui.SetNextItemWidth(ww); + if (Width != 0 && Width <= ww) + { + ImGui.SetNextItemWidth(Width); + ImGuiHelpers.CenterCursorFor(Width); + } + else + { + ImGui.SetNextItemWidth(ww); + } ImGui.PopStyleColor(); ImGui.InputTextWithHint($"###{Id}", Hint, ref inputBacking, MaxLength, Flags); - if (ImGui.IsItemFocused() && ImGui.IsKeyPressed(ImGuiKey.Enter)) + if (ImGui.IsItemFocused() && (ImGui.IsKeyPressed(ImGuiKey.Enter) || ImGui.IsKeyPressed(ImGuiKey.KeypadEnter))) { Enter?.Invoke(); } diff --git a/src/XIVLauncher.Core/Components/OtpEntryPage.cs b/src/XIVLauncher.Core/Components/OtpEntryPage.cs index a5590286..007d23fe 100644 --- a/src/XIVLauncher.Core/Components/OtpEntryPage.cs +++ b/src/XIVLauncher.Core/Components/OtpEntryPage.cs @@ -6,6 +6,8 @@ using XIVLauncher.Common.Http; +using XIVLauncher.Core.Components.Common; + namespace XIVLauncher.Core.Components; public class OtpEntryPage : Page @@ -19,10 +21,44 @@ public class OtpEntryPage : Page private OtpListener? otpListener; + private Input otpInput; + + private Button otpOKButton; + + private Button otpCancelButton; + + public string otpValue + { + get => this.otpInput.Value; + set => this.otpInput.Value = value; + } + public OtpEntryPage(LauncherApp app) : base(app) { + void getOtp() + { + TryAcceptOtp(this.otpValue); + } + + void cancelOtp() + { + this.Cancelled = true; + } + if (Program.Steam is not null) Program.Steam.OnGamepadTextInputDismissed += this.SteamOnOnGamepadTextInputDismissed; + + this.otpInput = new Input("", "", new Vector2(12f, 0f), 6, 150, flags: ImGuiInputTextFlags.CharsDecimal) + { + TakeKeyboardFocus = true + }; + this.otpInput.Enter += getOtp; + + this.otpOKButton = new Button("OK"); + this.otpOKButton.Click += getOtp; + + this.otpCancelButton = new Button("Cancel"); + this.otpCancelButton.Click += cancelOtp; } private void SteamOnOnGamepadTextInputDismissed(bool success) @@ -90,14 +126,12 @@ public override void Draw() if (ImGui.BeginChild("###otp", childSize, true, ImGuiWindowFlags.AlwaysAutoResize)) { - ImGui.Dummy(new Vector2(40)); + ImGui.Dummy(new Vector2(30)); // center text in window ImGuiHelpers.CenteredText("Please enter your OTP"); const int INPUT_WIDTH = 150; - ImGui.SetNextItemWidth(INPUT_WIDTH); - ImGuiHelpers.CenterCursorFor(INPUT_WIDTH); if (this.appearing) { @@ -105,22 +139,34 @@ public override void Draw() this.appearing = false; } - var doEnter = ImGui.InputText("###otpInput", ref this.otp, 6, ImGuiInputTextFlags.CharsDecimal | ImGuiInputTextFlags.EnterReturnsTrue); + //var doEnter = ImGui.InputText("###otpInput", ref this.otp, 6, ImGuiInputTextFlags.CharsDecimal | ImGuiInputTextFlags.EnterReturnsTrue); + otpInput.Width = INPUT_WIDTH; + otpInput.Draw(); - var buttonSize = new Vector2(INPUT_WIDTH / 2 - 4, 30); + // var buttonSize = new Vector2(INPUT_WIDTH / 2 - 4, 30); + int buttonW = INPUT_WIDTH / 2 - 4; + int buttonH = 40; ImGuiHelpers.CenterCursorFor(INPUT_WIDTH); - if (ImGui.Button("OK", buttonSize) || doEnter) - { - TryAcceptOtp(this.otp); - } + otpOKButton.Width = buttonW; + otpOKButton.Height = buttonH; + otpOKButton.Draw(); + + // if (ImGui.Button("OK", buttonSize)) // || doEnter) + // { + // TryAcceptOtp(this.otpValue); + // } ImGui.SameLine(); - if (ImGui.Button("Cancel", buttonSize)) - { - this.Cancelled = true; - } + otpCancelButton.Width = buttonW; + otpCancelButton.Height = buttonH; + otpCancelButton.Draw(); + + // if (ImGui.Button("Cancel", buttonSize)) + // { + // this.Cancelled = true; + // } } ImGui.EndChild(); From 62c16da432ae9cf7bf4ac5af8dbfbbdfe2cab8d0 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Sun, 7 Apr 2024 15:02:18 -0700 Subject: [PATCH 18/23] Try without extra Steam Input --- .../Components/Common/Input.cs | 7 +++++ .../Components/OtpEntryPage.cs | 27 ++++++++++--------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/XIVLauncher.Core/Components/Common/Input.cs b/src/XIVLauncher.Core/Components/Common/Input.cs index 050c620b..29fd511e 100644 --- a/src/XIVLauncher.Core/Components/Common/Input.cs +++ b/src/XIVLauncher.Core/Components/Common/Input.cs @@ -34,6 +34,8 @@ public class Input : Component /** Executed on detection of the enter key **/ public event Action? Enter; + public event Action? Escape; + public string Value { get => inputBacking; @@ -118,6 +120,11 @@ public override void Draw() Enter?.Invoke(); } + if (ImGui.IsItemFocused() && ImGui.IsKeyPressed(ImGuiKey.Escape)) + { + Escape?.Invoke(); + } + if (ImGui.IsItemActivated() && HasSteamDeckInput && Program.Steam != null && Program.Steam.IsValid) { this.isSteamDeckInputActive = Program.Steam?.ShowGamepadTextInput(Flags.HasFlag(ImGuiInputTextFlags.Password), false, SteamDeckPrompt, (int)MaxLength, this.inputBacking) ?? false; diff --git a/src/XIVLauncher.Core/Components/OtpEntryPage.cs b/src/XIVLauncher.Core/Components/OtpEntryPage.cs index 007d23fe..05ea1f4b 100644 --- a/src/XIVLauncher.Core/Components/OtpEntryPage.cs +++ b/src/XIVLauncher.Core/Components/OtpEntryPage.cs @@ -46,13 +46,14 @@ void cancelOtp() this.Cancelled = true; } - if (Program.Steam is not null) Program.Steam.OnGamepadTextInputDismissed += this.SteamOnOnGamepadTextInputDismissed; + // if (Program.Steam is not null) Program.Steam.OnGamepadTextInputDismissed += this.SteamOnOnGamepadTextInputDismissed; this.otpInput = new Input("", "", new Vector2(12f, 0f), 6, 150, flags: ImGuiInputTextFlags.CharsDecimal) { TakeKeyboardFocus = true }; this.otpInput.Enter += getOtp; + this.otpInput.Escape += cancelOtp; this.otpOKButton = new Button("OK"); this.otpOKButton.Click += getOtp; @@ -61,13 +62,13 @@ void cancelOtp() this.otpCancelButton.Click += cancelOtp; } - private void SteamOnOnGamepadTextInputDismissed(bool success) - { - if (success) - { - if (Program.Steam is not null) Result = Program.Steam.GetEnteredGamepadText(); - } - } + // private void SteamOnOnGamepadTextInputDismissed(bool success) + // { + // if (success) + // { + // if (Program.Steam is not null) Result = Program.Steam.GetEnteredGamepadText(); + // } + // } public void Reset() { @@ -78,11 +79,11 @@ public void Reset() // TODO(goat): This doesn't work if you call it right after starting the app... Steam probably takes a little while to initialize. Might be annoying for autologin. // BUG: We have to turn this off when using OTP server, because there's no way to dismiss open keyboards - if (Program.Steam != null && Program.Steam.IsValid && Program.IsSteamDeckHardware && App.Settings.IsOtpServer is false) - { - var success = Program.Steam.ShowGamepadTextInput(false, false, "Please enter your OTP", 6, string.Empty); - Log.Verbose("ShowGamepadTextInput: {Success}", success); - } + // if (Program.Steam != null && Program.Steam.IsValid && Program.IsSteamDeckHardware && App.Settings.IsOtpServer is false) + // { + // var success = Program.Steam.ShowGamepadTextInput(false, false, "Please enter your OTP", 6, string.Empty); + // Log.Verbose("ShowGamepadTextInput: {Success}", success); + // } if (App.Settings.IsOtpServer ?? false) { From e03cd9b59f073493d8ef26354e1c8976517c50a2 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Fri, 12 Apr 2024 21:27:47 -0700 Subject: [PATCH 19/23] Update with better steamdeck detection --- src/XIVLauncher.Core/Components/Common/Input.cs | 2 +- src/XIVLauncher.Core/CoreEnvironmentSettings.cs | 2 ++ src/XIVLauncher.Core/Program.cs | 5 +++-- src/XIVLauncher.Core/Resources/xlcore | 6 ++++++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/XIVLauncher.Core/Components/Common/Input.cs b/src/XIVLauncher.Core/Components/Common/Input.cs index 29fd511e..9c70d53b 100644 --- a/src/XIVLauncher.Core/Components/Common/Input.cs +++ b/src/XIVLauncher.Core/Components/Common/Input.cs @@ -64,7 +64,7 @@ public Input( if (Program.Steam != null) { Program.Steam.OnGamepadTextInputDismissed += this.SteamOnOnGamepadTextInputDismissed; - HasSteamDeckInput = Program.IsSteamDeckHardware; + HasSteamDeckInput = Program.IsSteamDeckGamingMode; } } diff --git a/src/XIVLauncher.Core/CoreEnvironmentSettings.cs b/src/XIVLauncher.Core/CoreEnvironmentSettings.cs index 86e6c3b3..6560d186 100644 --- a/src/XIVLauncher.Core/CoreEnvironmentSettings.cs +++ b/src/XIVLauncher.Core/CoreEnvironmentSettings.cs @@ -5,7 +5,9 @@ namespace XIVLauncher.Core; public static class CoreEnvironmentSettings { public static bool? IsDeck => CheckEnvBoolOrNull("XL_DECK"); + public static bool IsSteamDeckVar => CheckEnvBool("SteamDeck"); public static bool? IsDeckGameMode => CheckEnvBoolOrNull("XL_GAMEMODE"); + public static bool IsSteamGamepadUIVar => CheckEnvBool("SteamGamepadUI"); public static bool? IsDeckFirstRun => CheckEnvBoolOrNull("XL_FIRSTRUN"); public static bool IsUpgrade => CheckEnvBool("XL_SHOW_UPGRADE"); public static bool ClearSettings => CheckEnvBool("XL_CLEAR_SETTINGS"); diff --git a/src/XIVLauncher.Core/Program.cs b/src/XIVLauncher.Core/Program.cs index b92f4a47..a9a174e7 100644 --- a/src/XIVLauncher.Core/Program.cs +++ b/src/XIVLauncher.Core/Program.cs @@ -55,12 +55,13 @@ class Program public static DirectoryInfo DotnetRuntime => storage.GetFolder("runtime"); // TODO: We don't have the steamworks api for this yet. + // SteamDeck=1 on Steam Deck by default. SteamGamepadUI=1 in Big Picture / Gaming Mode. public static bool IsSteamDeckHardware => CoreEnvironmentSettings.IsDeck.HasValue ? CoreEnvironmentSettings.IsDeck.Value : - Directory.Exists("/home/deck") || (CoreEnvironmentSettings.IsDeckGameMode ?? false) || (CoreEnvironmentSettings.IsDeckFirstRun ?? false); + CoreEnvironmentSettings.IsSteamDeckVar || (CoreEnvironmentSettings.IsDeckGameMode ?? false) || (CoreEnvironmentSettings.IsDeckFirstRun ?? false); public static bool IsSteamDeckGamingMode => CoreEnvironmentSettings.IsDeckGameMode.HasValue ? CoreEnvironmentSettings.IsDeckGameMode.Value : - Steam != null && Steam.IsValid && Steam.IsRunningOnSteamDeck(); + Steam != null && Steam.IsValid && Steam.IsRunningOnSteamDeck() && CoreEnvironmentSettings.IsSteamGamepadUIVar; private const string APP_NAME = "xlcore"; diff --git a/src/XIVLauncher.Core/Resources/xlcore b/src/XIVLauncher.Core/Resources/xlcore index 07cfa897..0bdfadd2 100755 --- a/src/XIVLauncher.Core/Resources/xlcore +++ b/src/XIVLauncher.Core/Resources/xlcore @@ -33,6 +33,12 @@ if [ "$count" -eq 0 ] && [ -e "$tooldir/lib/libsecret-1.so.0.0.0" ]; then export LD_PRELOAD=$tooldir/lib/libsecret-1.so.0:$tooldir/lib/libsecret-1.so.0.0.0:$LD_PRELOAD fi +# Steam Deck can be detected by checking SteamDeck=1 and SteamGamepadUI=1 (for gaming mode/big picture) +# Unsetting SteamDeck will then disable Steam gamepad input, allowing keyboard to enter info on the launcher +if [ "$SteamDeck" = "1" ] && [ "$SteamGamepadUI" != "1" ]; then + unset SteamDeck +fi + export OPENSSL_CONF="$tooldir/openssl_fix.cnf" export XL_SCT=1 "$tooldir/XIVLauncher/XIVLauncher.Core" $@ >> $logDir/steamtool_console.log 2>&1 From c3098abd5a81ecde3c8e3b79a0b7477ede48e592 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Fri, 19 Apr 2024 16:26:58 -0700 Subject: [PATCH 20/23] Improve CL options --- .../SettingsPage/Tabs/SettingsTabSteamTool.cs | 8 +- .../Configuration/ILauncherConfig.cs | 4 + src/XIVLauncher.Core/Program.cs | 168 +++++++++++++----- src/XIVLauncher.Core/Resources/xlcore | 9 +- .../SteamCompatibilityTool.cs | 126 ++++++++++++- src/XIVLauncher.Core/UpdateCheck.cs | 2 +- 6 files changed, 257 insertions(+), 60 deletions(-) diff --git a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabSteamTool.cs b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabSteamTool.cs index 1e6df5b0..58a84036 100644 --- a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabSteamTool.cs +++ b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabSteamTool.cs @@ -78,7 +78,7 @@ public override void Draw() if (ImGui.Button($"{(steamToolInstalled ? "Re-i" : "I")}nstall to native Steam")) { this.Save(); - SteamCompatibilityTool.CreateTool(Program.Config.SteamPath ?? ""); + SteamCompatibilityTool.CreateTool(isFlatpak: false); steamToolInstalled = SteamCompatibilityTool.IsSteamToolInstalled; } if (!steamInstalled) ImGui.EndDisabled(); @@ -87,7 +87,7 @@ public override void Draw() if (ImGui.Button("Uninstall from native Steam")) { this.Save(); - SteamCompatibilityTool.DeleteTool(Program.Config.SteamPath ?? ""); + SteamCompatibilityTool.DeleteTool(isFlatpak: false); steamToolInstalled = SteamCompatibilityTool.IsSteamToolInstalled; } if (!steamToolInstalled) ImGui.EndDisabled(); @@ -104,7 +104,7 @@ public override void Draw() if (ImGui.Button($"{(steamFlatpakToolInstalled ? "Re-i" : "I")}nstall to flatpak Steam")) { this.Save(); - SteamCompatibilityTool.CreateTool(Program.Config.SteamFlatpakPath ?? ""); + SteamCompatibilityTool.CreateTool(isFlatpak: true); steamFlatpakToolInstalled = SteamCompatibilityTool.IsSteamFlatpakToolInstalled; } if (!steamFlatpakInstalled) ImGui.EndDisabled(); @@ -116,7 +116,7 @@ public override void Draw() if (ImGui.Button("Uninstall from Flatpak Steam")) { this.Save(); - SteamCompatibilityTool.DeleteTool(Program.Config.SteamFlatpakPath ?? ""); + SteamCompatibilityTool.DeleteTool(isFlatpak: true); steamFlatpakToolInstalled = SteamCompatibilityTool.IsSteamFlatpakToolInstalled; } if (!steamFlatpakToolInstalled) diff --git a/src/XIVLauncher.Core/Configuration/ILauncherConfig.cs b/src/XIVLauncher.Core/Configuration/ILauncherConfig.cs index 91120dd1..ac62ee07 100644 --- a/src/XIVLauncher.Core/Configuration/ILauncherConfig.cs +++ b/src/XIVLauncher.Core/Configuration/ILauncherConfig.cs @@ -88,6 +88,10 @@ public interface ILauncherConfig public string? SteamFlatpakPath { get; set; } + public bool? SteamToolInstalled { get; set; } + + public bool? SteamFlatpakToolInstalled { get; set; } + #endregion #region Dalamud diff --git a/src/XIVLauncher.Core/Program.cs b/src/XIVLauncher.Core/Program.cs index a9a174e7..ccfe298c 100644 --- a/src/XIVLauncher.Core/Program.cs +++ b/src/XIVLauncher.Core/Program.cs @@ -73,6 +73,10 @@ class Program public static string CType = CoreEnvironmentSettings.GetCType(); + public static Version CoreVersion = Version.Parse(AppUtil.GetAssemblyVersion()); + + public static string CoreHash = AppUtil.GetGitHash() ?? ""; + public static void Invalidate(uint frames = 100) { invalidationFrames = frames; @@ -138,6 +142,8 @@ private static void LoadConfig(Storage storage) Config.SteamPath ??= Path.Combine(CoreEnvironmentSettings.HOME, ".local", "share"); Config.SteamFlatpakPath ??= Path.Combine(CoreEnvironmentSettings.HOME, ".var", "app", "com.valvesoftware.Steam", "data", "Steam" ); + Config.SteamToolInstalled ??= false; + Config.SteamFlatpakToolInstalled ??= false; } public const uint STEAM_APP_ID = 39210; @@ -200,6 +206,19 @@ private static void Main(string[] args) Loc.SetupWithFallbacks(); + if (System.OperatingSystem.IsLinux()) + { + if (mainArgs.Length > 0) + Log.Information("Command Line option selected: {args}", string.Join(' ', mainArgs)); + var exitValue = LinuxCommandLineOptions(); + if (exitValue) + { + Log.Information("Exiting..."); + return; + } + SteamCompatibilityTool.UpdateSteamTools(); + } + uint appId, altId; string appName, altName; if (Config.IsFt == true) @@ -225,8 +244,6 @@ private static void Main(string[] args) break; case PlatformID.Unix: - // We should only run the script on Linux (maybe Unix) systems. - if (CommandLineInstaller()) return; Steam = new UnixSteam(); break; @@ -261,9 +278,9 @@ private static void Main(string[] args) Log.Debug("Creating Veldrid devices..."); #if DEBUG - var version = AppUtil.GetGitHash(); + var version = CoreHash; #else - var version = $"{AppUtil.GetAssemblyVersion()} ({AppUtil.GetGitHash()})"; + var version = $"{CoreVersion} ({CoreHash})"; #endif // Create window, GraphicsDevice, and all resources necessary for the demo. @@ -478,53 +495,106 @@ public static void ClearAll(bool tsbutton = false) ClearLogs(true); } - private static bool CommandLineInstaller() + private static bool LinuxCommandLineOptions() { - foreach (var arg in mainArgs) + bool exit = false; + + if (mainArgs.Contains("-v")) { - if (arg == "--deck-install") - { - SteamCompatibilityTool.CreateTool(Path.Combine(CoreEnvironmentSettings.HOME, ".local", "share", "Steam")); - Console.WriteLine($"Installed as Steam compatibility tool to {Path.Combine(CoreEnvironmentSettings.HOME, ".local", "share", "Steam", "compatibilitytools.d", "xlcore")}"); - return true; - } - if (arg.StartsWith("--install=")) - { - var path = arg.Split('=', 2)[1]; - if (path.StartsWith("~/")) - path = CoreEnvironmentSettings.HOME + path.TrimStart('~'); - if (Directory.Exists(path) && (path.EndsWith("/Steam") || path.EndsWith("/Steam/"))) - { - SteamCompatibilityTool.CreateTool(path); - Console.WriteLine($"Installed as Steam compatibility tool to path {Path.Combine(path, "compatibilitytools.d", "xlcore")}"); - } - else - Console.WriteLine($"Invalid path. Path does not exist or is not a Steam folder: {path}"); - - return true; - } - if (arg == "--deck-remove") - { - SteamCompatibilityTool.DeleteTool(Path.Combine(CoreEnvironmentSettings.HOME, ".local", "share", "Steam")); - Console.WriteLine($"Removed XIVLauncher.Core as a Steam compatibility tool from {Path.Combine(CoreEnvironmentSettings.HOME, ".local", "share", "Steam", "compatibilitytools.d")}"); - return true; - } - if (arg.StartsWith("--remove=")) - { - var path = arg.Split('=', 2)[1]; - if (path.StartsWith("~/")) - path = CoreEnvironmentSettings.HOME + path.TrimStart('~'); - if (Directory.Exists(path) && (path.EndsWith("/Steam") || path.EndsWith("/Steam/"))) - { - SteamCompatibilityTool.DeleteTool(path); - Console.WriteLine($"Removed XIVLauncher.Core as a Steam compatibility tool from {Path.Combine(path, "compatibilitytools.d")}"); - } - else - Console.WriteLine($"Invalid path. Path does not exist or is not a Steam folder: {path}"); - - return true; - } + Console.WriteLine("Verbose Logging enabled..."); + } + + if (mainArgs.Contains("--update-tools") || mainArgs.Contains("-u")) + { + SteamCompatibilityTool.UpdateSteamTools(true); + exit = true; + } + + if (mainArgs.Contains("--info")) + { + Console.WriteLine($"Steam compatibility tool {(SteamCompatibilityTool.IsSteamToolInstalled ? "is installed: " + SteamCompatibilityTool.CheckVersion(isFlatpak: false).Replace(",", " ") : "is not installed.")}"); + Console.WriteLine($"Steam (flatpak) compatibility tool {(SteamCompatibilityTool.IsSteamFlatpakToolInstalled ? "is installed: " + SteamCompatibilityTool.CheckVersion(isFlatpak: true).Replace(",", " ") : "is not installed.")}"); + exit = true; + } + + if (mainArgs.Contains("--deck-install") && mainArgs.Contains("--deck-remove")) + { + SteamCompatibilityTool.DeleteTool(isFlatpak: false); + Console.WriteLine("Using both --deck-install and --deck-remove. Doing --deck-remove first"); + Console.WriteLine($"Removed XIVLauncher.Core as a Steam compatibility tool from {Program.Config.SteamPath ?? ""}"); + SteamCompatibilityTool.CreateTool(isFlatpak: false); + Console.WriteLine($"Installed as Steam compatibility tool to {Program.Config.SteamPath ?? ""}"); + exit = true; + } + else if (mainArgs.Contains("--deck-install")) + { + SteamCompatibilityTool.CreateTool(isFlatpak: false); + Console.WriteLine($"Installed as Steam compatibility tool to {Program.Config.SteamPath ?? ""}"); + exit = true; + } + else if (mainArgs.Contains("--deck-remove")) + { + SteamCompatibilityTool.DeleteTool(isFlatpak: false); + Console.WriteLine($"Removed XIVLauncher.Core as a Steam compatibility tool from {Program.Config.SteamPath ?? ""}"); + exit = true; + } + + if (mainArgs.Contains("--flatpak-install") && mainArgs.Contains("--flatpak-remove")) + { + Console.WriteLine("Using both --flatpak-install and --flatpak-remove. Doing --deck-remove first"); + SteamCompatibilityTool.DeleteTool(isFlatpak: true); + Console.WriteLine($"Removed XIVLauncher.Core as a Steam compatibility tool from {Program.Config.SteamFlatpakPath ?? ""}"); + SteamCompatibilityTool.CreateTool(isFlatpak: true); + Console.WriteLine($"Installed as Steam compatibility tool to {Program.Config.SteamFlatpakPath ?? ""}"); + exit = true; + } + else if (mainArgs.Contains("--flatpak-install")) + { + SteamCompatibilityTool.CreateTool(isFlatpak: true); + Console.WriteLine($"Installed as Steam compatibility tool to {Program.Config.SteamFlatpakPath ?? ""}"); + exit = true; + } + else if (mainArgs.Contains("--flatpak-remove")) + { + SteamCompatibilityTool.DeleteTool(isFlatpak: true); + Console.WriteLine($"Removed XIVLauncher.Core as a Steam compatibility tool from {Program.Config.SteamFlatpakPath ?? ""}"); + exit = true; + } + + if (mainArgs.Contains("--version")) + { + Console.WriteLine($"XIVLauncher.Core {CoreVersion.ToString()}"); + Console.WriteLine("Copyright (C) 2024 goatcorp.\nLicense GPLv3+: GNU GPL version 3 or later ."); + exit = true; + } + + if (mainArgs.Contains("-V")) + { + Console.WriteLine(CoreVersion.ToString()); + exit = true; + } + + if (mainArgs.Contains("--help") || mainArgs.Contains("-h")) + { + Console.WriteLine($"XIVLaunher.Core {CoreVersion.ToString()}\nA third-party launcher for Final Fantasy XIV.\n\nOptions (use only one):"); + Console.WriteLine(" -v Turn on verbose logging, then run the launcher."); + Console.WriteLine(" -h, --help Display this message."); + Console.WriteLine(" -V Display brief version info."); + Console.WriteLine(" --version Display version and copywrite info."); + Console.WriteLine(" --info Display Steam compatibility tool install status"); + Console.WriteLine(" -u, --update-tools Try to update any installed xlcore steam compatibility tools."); + Console.WriteLine("\nFor Steam Deck and native Steam"); + Console.WriteLine(" --deck-install Install as a compatibility tool in the default location."); + Console.WriteLine($" Path: {Program.Config.SteamPath ?? ""}"); + Console.WriteLine(" --deck-remove Remove compatibility tool install from the defualt location."); + Console.WriteLine("\nFor Flatpak Steam"); + Console.WriteLine(" --flatpak-install Install as a compatibility tool to flatpak Steam."); + Console.WriteLine($" Path: {Program.Config.SteamFlatpakPath ?? ""}"); + Console.WriteLine(" --flatpak-remove Remove compatibility tool from flatpak Steam."); + Console.WriteLine(""); + exit = true; } - return false; + + return exit; } } diff --git a/src/XIVLauncher.Core/Resources/xlcore b/src/XIVLauncher.Core/Resources/xlcore index 0bdfadd2..4bcf06fd 100755 --- a/src/XIVLauncher.Core/Resources/xlcore +++ b/src/XIVLauncher.Core/Resources/xlcore @@ -1,7 +1,13 @@ #!/bin/env sh +# Working directory is actually the steam install location, so we need to find the path of this script +tooldir="$(realpath "$(dirname "$0")")" + # Prevent double launch if [ "$1" = "run" ]; then + if [ ! -f "$tooldir/version" ]; then + "$tooldir/XIVLauncher/XIVLauncher.Core" -V > "$tooldir/version" + fi sleep 1 exit 0 fi @@ -11,9 +17,6 @@ logDir=$xlcoreDir/logs mkdir -p $xlcoreDir mkdir -p $logDir -# Working directory is actually the steam install location, so we need to find the path of this script -tooldir="$(realpath "$(dirname "$0")")" - # If aria2c isn't found, add our local copy to the $PATH count=$(find /usr -type f -executable -name "aria2c" 2>/dev/null | wc -l) if [ $count -eq 0 ] && [ -e "$tooldir/bin/aria2c" ]; then diff --git a/src/XIVLauncher.Core/UnixCompatibility/SteamCompatibilityTool.cs b/src/XIVLauncher.Core/UnixCompatibility/SteamCompatibilityTool.cs index c65e7f32..ac743ebb 100644 --- a/src/XIVLauncher.Core/UnixCompatibility/SteamCompatibilityTool.cs +++ b/src/XIVLauncher.Core/UnixCompatibility/SteamCompatibilityTool.cs @@ -9,6 +9,8 @@ namespace XIVLauncher.Core.UnixCompatibility; public static class SteamCompatibilityTool { + // This is here to prevent auto-updating with different releases of XLCore. So XIVLauncher-RB will not overwrite official, vice versa. + private const string RELEASE = "Official"; public static bool IsSteamInstalled => Directory.Exists(Program.Config.SteamPath); public static bool IsSteamFlatpakInstalled => Directory.Exists(Program.Config.SteamFlatpakPath); @@ -22,8 +24,17 @@ private static string findXIVLauncherFiles() return System.AppDomain.CurrentDomain.BaseDirectory; } - public static void CreateTool(string path) + private static void SetConfigValues(bool isFlatpak) { + if (isFlatpak) + Program.Config.SteamFlatpakToolInstalled = IsSteamFlatpakToolInstalled; + else + Program.Config.SteamToolInstalled = IsSteamToolInstalled; + } + + public static void CreateTool(bool isFlatpak) + { + var path = isFlatpak ? Program.Config.SteamFlatpakPath : Program.Config.SteamPath; var compatfolder = new DirectoryInfo(Path.Combine(path, "compatibilitytools.d")); compatfolder.Create(); var destination = new DirectoryInfo(Path.Combine(compatfolder.FullName, "xlcore")); @@ -41,11 +52,13 @@ public static void CreateTool(string path) var compatibilitytool_vdf = new FileInfo(Path.Combine(destination.FullName, "compatibilitytool.vdf")); var toolmanifest_vdf = new FileInfo(Path.Combine(destination.FullName, "toolmanifest.vdf")); var openssl_fix = new FileInfo(Path.Combine(destination.FullName, "openssl_fix.cnf")); - + var version = new FileInfo(Path.Combine(destination.FullName, "version")); + xlcore.Delete(); compatibilitytool_vdf.Delete(); toolmanifest_vdf.Delete(); openssl_fix.Delete(); + version.Delete(); using (var fs = xlcore.Create()) { @@ -85,6 +98,12 @@ public static void CreateTool(string path) resource.CopyTo(fs); fs.Close(); } + using (var fs = version.Create()) + { + byte[] resource = new System.Text.UTF8Encoding(true).GetBytes(Program.CoreVersion.ToString() + "\n" + RELEASE); + fs.Write(resource, 0, resource.Length); + fs.Close(); + } // Copy XIVLauncher files var XIVLauncherFiles = new DirectoryInfo(findXIVLauncherFiles()); @@ -107,13 +126,114 @@ public static void CreateTool(string path) } Log.Verbose($"[SCT] XIVLauncher installed as Steam compatibility tool to folder {destination.FullName}"); + SetConfigValues(isFlatpak); } - public static void DeleteTool(string path) + public static void DeleteTool(bool isFlatpak) { + var path = isFlatpak ? Program.Config.SteamFlatpakPath : Program.Config.SteamPath; var steamToolFolder = new DirectoryInfo(Path.Combine(path, "compatibilitytools.d", "xlcore")); if (!steamToolFolder.Exists) return; steamToolFolder.Delete(true); Log.Verbose($"[SCT] Deleted Steam compatibility tool at folder {steamToolFolder.FullName}"); + SetConfigValues(isFlatpak); + } + + public static void UpdateSteamTools(bool console = false) + { + if (CoreEnvironmentSettings.IsSteamCompatTool) + return; + + var message = UpdateTool(false); + if (console) + Console.WriteLine(message); + + message = UpdateTool(true); + if (console) + Console.WriteLine(message); + } + + public static string CheckVersion(bool isFlatpak) + { + var path = isFlatpak ? Program.Config.SteamFlatpakPath : Program.Config.SteamPath; + var versionFile = new FileInfo(Path.Combine(path, "compatibilitytools.d", "xlcore", "version")); + + if (!versionFile.Exists) + return ""; + + var version = ""; + try + { + using (var sr = new StreamReader(versionFile.FullName)) + { + var toolVersion = sr.ReadLine() ?? ""; + var release = sr.ReadLine() ?? ""; + sr.Close(); + if (string.IsNullOrEmpty(toolVersion)) + toolVersion = "Unknown"; + if (string.IsNullOrEmpty(release)) + release = "Unknown"; + version = toolVersion + ',' + release; + } + } + catch (Exception e) + { + Log.Error(e, $"Could not get the Steam {(isFlatpak ? "(flatpak) " : "")}compatibility tool version at {path}."); + version = "Unknown,Unknown"; + } + return version; + } + + private static string UpdateTool(bool isFlatpak) + { + var message = string.Empty; + + if ((isFlatpak && !IsSteamFlatpakToolInstalled) || (!isFlatpak && !IsSteamToolInstalled)) + { + message = $"Steam {(isFlatpak ? "(flatpak) " : "")}compatibility tool is not installed. Nothing to update."; + Log.Information(message); + return message; + } + var path = isFlatpak ? Program.Config.SteamFlatpakPath : Program.Config.SteamPath; + var versionFile = new FileInfo(Path.Combine(path, "compatibilitytools.d", "xlcore", "version")); + + if (!versionFile.Exists) + { + CreateTool(isFlatpak); + message = $"Updating Steam {(isFlatpak ? "(flatpak) " : "")}compatibility tool at {path}/compatibilitytools.d/xlcore to version {Program.CoreVersion.ToString()}"; + Log.Information(message); + return message; + } + + var toolInfo = CheckVersion(isFlatpak).Split(',', 2); + var toolVersion = toolInfo[0]; + var release = toolInfo[1]; + + try + { + if (release != RELEASE) + { + message = $"Steam {(isFlatpak ? "(flatpak) " : "")}compatibility Tool mismatch! \"{release}\" release is installed, but this is \"{RELEASE}\" release. Not installing update."; + Log.Warning(message); + return message; + } + if (Version.Parse(toolVersion) < Program.CoreVersion) + { + CreateTool(isFlatpak); + message = $"Updating Steam {(isFlatpak ? "(flatpak) " : "")}compatibility tool at {path}/compatibilitytools.d/xlcore to version {Program.CoreVersion.ToString()}"; + Log.Information(message); + } + else + { + message = $"Steam {(isFlatpak ? "(flatpak) " : "")}compatibility tool version at {path} is {toolVersion} >= {Program.CoreVersion.ToString()}, nothing to do."; + Log.Information(message); + } + } + catch (Exception e) + { + message = $"Could not get the Steam {(isFlatpak ? "(flatpak) " : "")}compatibility tool version at {path}. Not installing update."; + Log.Error(e, message); + } + return message; } } \ No newline at end of file diff --git a/src/XIVLauncher.Core/UpdateCheck.cs b/src/XIVLauncher.Core/UpdateCheck.cs index 1f22bd0f..a92b97da 100644 --- a/src/XIVLauncher.Core/UpdateCheck.cs +++ b/src/XIVLauncher.Core/UpdateCheck.cs @@ -16,7 +16,7 @@ public static async Task CheckForUpdate() var response = await client.GetStringAsync(UPDATE_URL).ConfigureAwait(false); var remoteVersion = Version.Parse(response); - var localVersion = Version.Parse(AppUtil.GetAssemblyVersion()); + var localVersion = Program.CoreVersion; return new VersionCheckResult { From 17b0509d475782a890613dda71e5bba000b2c188 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Thu, 23 May 2024 12:38:58 -0700 Subject: [PATCH 21/23] Show flatpak steam instructions for all non-steamdeck users --- .../SettingsPage/Tabs/SettingsTabSteamTool.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabSteamTool.cs b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabSteamTool.cs index 58a84036..0175eb2b 100644 --- a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabSteamTool.cs +++ b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabSteamTool.cs @@ -49,9 +49,9 @@ public override void Draw() ImGui.Dummy(new Vector2(10)); ImGui.Text("You are currently running XIVLauncher.Core as a Steam compatibility tool."); ImGui.Dummy(new Vector2(10)); - ImGui.Text("If you are trying to upgrade, you must first update your local install of XIVLauncher.Core. Then launch the local" + + ImGui.Text("If you are trying to upgrade, you must first update your flatpak install of XIVLauncher.Core. Then launch the flatpak" + "\nversion, navigate back to this tab, and re-install as a Steam compatibility tool."); - ImGui.Text("\nIf you are trying to uninstall, you should likewise launch the native version of XIVLauncher, and click the appropriate" + + ImGui.Text("\nIf you are trying to uninstall, you should likewise launch the flatpak version of XIVLauncher, and click the appropriate" + "\nuninstall button."); return; } @@ -60,11 +60,12 @@ public override void Draw() ImGui.Text("in your steam library and open the 'Properties' menu and navigate to the 'Compatibility' tab. Enable 'Force the use of a specific Steam Play compatibility tool'"); ImGui.Text("and from the dropdown menu select 'XIVLauncher.Core'. If this option does not show up then restart Steam and try again. After finishing these steps,"); ImGui.Text("XIVLauncher will now be used when launching FINAL FANTASY XIV from steam."); - if (Program.IsSteamDeckHardware != true && steamFlatpakInstalled) + // Steam deck should never have flatpak steam + if (Program.IsSteamDeckHardware != true) { ImGui.Text("\nIf you wish to install into Flatpak Steam, you must use Flatseal to give XIVLauncher access to Steam's flatpak path. This is commonly found at:"); - ImGui.Text($"{CoreEnvironmentSettings.HOME}/.var/app/com.valvesoftware.Steam. If you do not give this permission, installation will fail. You will also want to"); - ImGui.Text($"give Steam permission to {CoreEnvironmentSettings.HOME}/.xlcore, so that you can continue to use your current xlcore folder."); + ImGui.Text($"~/.var/app/com.valvesoftware.Steam. If you do not give this permission, the install option will not even appear. You will also need to give Steam"); + ImGui.Text($"access to ~/.xlcore, so that you can continue to use your current xlcore folder."); ImGui.Text("\nDO NOT use native XIVLauncher to install to flatpak Steam. Use flatpak XIVLauncher instead."); } From 2357bdd3877fbb265b3c4052a78f0598bf637dc4 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Thu, 23 May 2024 13:07:31 -0700 Subject: [PATCH 22/23] Improve handling of different versions --- .../Components/SettingsPage/Tabs/SettingsTabSteamTool.cs | 7 ++++--- src/XIVLauncher.Core/Program.cs | 8 ++++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabSteamTool.cs b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabSteamTool.cs index 0175eb2b..91cfe18b 100644 --- a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabSteamTool.cs +++ b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabSteamTool.cs @@ -31,7 +31,7 @@ public SettingsTabSteamTool() steamFlatpakPath = new SettingsEntry("Steam Path (flatpak)", "Path to the flatpak Steam installation. Only change this if you have your flatpak Steam installed to a non-default location.", () => Program.Config.SteamFlatpakPath ?? Path.Combine(CoreEnvironmentSettings.HOME, ".var", "app", "com.valvesoftware.Steam", "data", "Steam" ), s => Program.Config.SteamFlatpakPath = s) { - CheckVisibility = () => Program.IsSteamDeckHardware != true && SteamCompatibilityTool.IsSteamFlatpakInstalled, + CheckVisibility = () => Program.IsSteamDeckHardware != true, }, }; } @@ -49,8 +49,9 @@ public override void Draw() ImGui.Dummy(new Vector2(10)); ImGui.Text("You are currently running XIVLauncher.Core as a Steam compatibility tool."); ImGui.Dummy(new Vector2(10)); - ImGui.Text("If you are trying to upgrade, you must first update your flatpak install of XIVLauncher.Core. Then launch the flatpak" + - "\nversion, navigate back to this tab, and re-install as a Steam compatibility tool."); + ImGui.Text("If you are trying to upgrade, you must first update your install of XIVLauncher.Core. Then launch the flatpak or native" + + "\nversion once, and then close it. This should automatically update the steam compatibility tool. Alternately, you" + + "\ncould run \"flatpak run dev.goats.xivlauncher --update-tools\" after updating your native or flatpak install."); ImGui.Text("\nIf you are trying to uninstall, you should likewise launch the flatpak version of XIVLauncher, and click the appropriate" + "\nuninstall button."); return; diff --git a/src/XIVLauncher.Core/Program.cs b/src/XIVLauncher.Core/Program.cs index ccfe298c..9e90f7ac 100644 --- a/src/XIVLauncher.Core/Program.cs +++ b/src/XIVLauncher.Core/Program.cs @@ -73,7 +73,9 @@ class Program public static string CType = CoreEnvironmentSettings.GetCType(); - public static Version CoreVersion = Version.Parse(AppUtil.GetAssemblyVersion()); + public static Version CoreVersion { get; } = Version.Parse(AppUtil.GetAssemblyVersion()); + + public const string CoreRelease = "Official"; public static string CoreHash = AppUtil.GetGitHash() ?? ""; @@ -512,6 +514,7 @@ private static bool LinuxCommandLineOptions() if (mainArgs.Contains("--info")) { + Console.WriteLine($"This program: XIVLauncher.Core {CoreVersion.ToString()} - {CoreRelease}"); Console.WriteLine($"Steam compatibility tool {(SteamCompatibilityTool.IsSteamToolInstalled ? "is installed: " + SteamCompatibilityTool.CheckVersion(isFlatpak: false).Replace(",", " ") : "is not installed.")}"); Console.WriteLine($"Steam (flatpak) compatibility tool {(SteamCompatibilityTool.IsSteamFlatpakToolInstalled ? "is installed: " + SteamCompatibilityTool.CheckVersion(isFlatpak: true).Replace(",", " ") : "is not installed.")}"); exit = true; @@ -563,7 +566,7 @@ private static bool LinuxCommandLineOptions() if (mainArgs.Contains("--version")) { - Console.WriteLine($"XIVLauncher.Core {CoreVersion.ToString()}"); + Console.WriteLine($"XIVLauncher.Core {CoreVersion.ToString()} - {CoreRelease}"); Console.WriteLine("Copyright (C) 2024 goatcorp.\nLicense GPLv3+: GNU GPL version 3 or later ."); exit = true; } @@ -571,6 +574,7 @@ private static bool LinuxCommandLineOptions() if (mainArgs.Contains("-V")) { Console.WriteLine(CoreVersion.ToString()); + Console.WriteLine(CoreRelease); exit = true; } From 0eebea87f22dbb80030525986a7b3f497b953508 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Thu, 23 May 2024 15:07:59 -0700 Subject: [PATCH 23/23] Use Program.CoreRelease in SteamCompatibilityTool.cs --- .../UnixCompatibility/SteamCompatibilityTool.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/XIVLauncher.Core/UnixCompatibility/SteamCompatibilityTool.cs b/src/XIVLauncher.Core/UnixCompatibility/SteamCompatibilityTool.cs index ac743ebb..90d98de3 100644 --- a/src/XIVLauncher.Core/UnixCompatibility/SteamCompatibilityTool.cs +++ b/src/XIVLauncher.Core/UnixCompatibility/SteamCompatibilityTool.cs @@ -10,7 +10,6 @@ namespace XIVLauncher.Core.UnixCompatibility; public static class SteamCompatibilityTool { // This is here to prevent auto-updating with different releases of XLCore. So XIVLauncher-RB will not overwrite official, vice versa. - private const string RELEASE = "Official"; public static bool IsSteamInstalled => Directory.Exists(Program.Config.SteamPath); public static bool IsSteamFlatpakInstalled => Directory.Exists(Program.Config.SteamFlatpakPath); @@ -100,7 +99,7 @@ public static void CreateTool(bool isFlatpak) } using (var fs = version.Create()) { - byte[] resource = new System.Text.UTF8Encoding(true).GetBytes(Program.CoreVersion.ToString() + "\n" + RELEASE); + byte[] resource = new System.Text.UTF8Encoding(true).GetBytes(Program.CoreVersion.ToString() + "\n" + Program.CoreRelease); fs.Write(resource, 0, resource.Length); fs.Close(); } @@ -211,9 +210,9 @@ private static string UpdateTool(bool isFlatpak) try { - if (release != RELEASE) + if (release != Program.CoreRelease) { - message = $"Steam {(isFlatpak ? "(flatpak) " : "")}compatibility Tool mismatch! \"{release}\" release is installed, but this is \"{RELEASE}\" release. Not installing update."; + message = $"Steam {(isFlatpak ? "(flatpak) " : "")}compatibility Tool mismatch! \"{release}\" release is installed, but this is \"{Program.CoreRelease}\" release. Not installing update."; Log.Warning(message); return message; }