Skip to content

Commit

Permalink
Make gamemode check a separate function
Browse files Browse the repository at this point in the history
  • Loading branch information
rankynbass committed Mar 13, 2024
1 parent 124e9b9 commit 78376e2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public SettingsTabWine()
CheckVisibility = () => RuntimeInformation.IsOSPlatform(OSPlatform.Linux),
CheckValidity = b =>
{
if (b == true && !CoreEnvironmentSettings.GameModeInstalled)
if (b == true && !CoreEnvironmentSettings.IsGameModeInstalled())
return "GameMode was not detected on your system.";
return null;
}
Expand Down
13 changes: 8 additions & 5 deletions src/XIVLauncher.Core/CoreEnvironmentSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,20 @@ public static string GetCleanEnvironmentVariable(string envvar, string badstring
return string.Join(separator, Array.FindAll<string>(dirty.Split(separator, StringSplitOptions.RemoveEmptyEntries), s => !s.Contains(badstring)));
}

static public bool GameModeInstalled { get; }
static private bool? gameModeInstalled = null;

static CoreEnvironmentSettings()
{
static public bool IsGameModeInstalled()
{
if (gameModeInstalled is not null)
return gameModeInstalled ?? false;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
var handle = IntPtr.Zero;
GameModeInstalled = NativeLibrary.TryLoad("libgamemodeauto.so.0", out handle);
gameModeInstalled = NativeLibrary.TryLoad("libgamemodeauto.so.0", out handle);
NativeLibrary.Free(handle);
}
else
GameModeInstalled = false;
gameModeInstalled = false;
return gameModeInstalled ?? false;
}
}

0 comments on commit 78376e2

Please sign in to comment.