From d058fce2e30d6fddc484345df873345e60bec377 Mon Sep 17 00:00:00 2001 From: Valters Tomsons Date: Thu, 2 May 2024 18:44:51 +0300 Subject: [PATCH] Try detecting default game install when running patcher --- src/DayZLauncher.UnixPatcher/Common.cs | 14 ++++++++++++++ src/DayZLauncher.UnixPatcher/Program.cs | 11 ++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/DayZLauncher.UnixPatcher/Common.cs b/src/DayZLauncher.UnixPatcher/Common.cs index a65fadf..58cde21 100644 --- a/src/DayZLauncher.UnixPatcher/Common.cs +++ b/src/DayZLauncher.UnixPatcher/Common.cs @@ -22,6 +22,20 @@ public static string MoveFileToBackup(string filePath) return newPath; } + public static string? TryGetGameInstallPathFromSystem() + { + var homePath = Environment.GetEnvironmentVariable("HOME"); + var gameInstallPath = $"{homePath}/.steam/steam/steamapps/common/DayZ"; + + if (Directory.Exists(gameInstallPath)) + { + WriteLine($"Game data found from system: '{gameInstallPath}'"); + return gameInstallPath; + } + + return null; + } + public static string? TryGetGamePrefixFromSystem() { var homePath = Environment.GetEnvironmentVariable("HOME"); diff --git a/src/DayZLauncher.UnixPatcher/Program.cs b/src/DayZLauncher.UnixPatcher/Program.cs index e64d6b5..147b583 100644 --- a/src/DayZLauncher.UnixPatcher/Program.cs +++ b/src/DayZLauncher.UnixPatcher/Program.cs @@ -4,9 +4,18 @@ Common.WriteLine("NOTICE: This version will not enable settings saving, but mod installing should still work.", ConsoleColor.Yellow); Common.WriteLine("Be sure to verify game files and delete compatdata for `221100` before continuing!", ConsoleColor.Red); +var gameSystemPath = Common.TryGetGameInstallPathFromSystem(); +var gameFound = !string.IsNullOrWhiteSpace(gameSystemPath); + string? userInput; -if (args is null || args.Length < 1) +if (gameFound) +{ + Common.WriteLine($"Found DayZ installation at '{gameSystemPath}'"); + userInput = gameSystemPath; +} +else if (args is null || args.Length < 1) { + Common.WriteLine(""); Common.WriteLine("Enter full DayZ installation path and press ENTER"); Console.Write("> ");