Skip to content

Commit

Permalink
Try detecting default game install when running patcher
Browse files Browse the repository at this point in the history
  • Loading branch information
valters-tomsons committed May 2, 2024
1 parent f01a13d commit d058fce
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/DayZLauncher.UnixPatcher/Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
11 changes: 10 additions & 1 deletion src/DayZLauncher.UnixPatcher/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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("> ");
Expand Down

0 comments on commit d058fce

Please sign in to comment.