From fd50e3ba713156aa822c581118689fd34a90af45 Mon Sep 17 00:00:00 2001 From: Garry Newman Date: Fri, 21 Jun 2019 11:59:11 +0100 Subject: [PATCH] Added SteamClient.RestartAppIfNecessary --- Facepunch.Steamworks/SteamClient.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Facepunch.Steamworks/SteamClient.cs b/Facepunch.Steamworks/SteamClient.cs index 2fbee516..d7154e69 100644 --- a/Facepunch.Steamworks/SteamClient.cs +++ b/Facepunch.Steamworks/SteamClient.cs @@ -168,5 +168,24 @@ internal static void UnregisterCallback( IntPtr intPtr ) /// returns the appID of the current process /// public static AppId AppId { get; internal set; } + + /// + /// Checks if your executable was launched through Steam and relaunches it through Steam if it wasn't + /// this returns true then it starts the Steam client if required and launches your game again through it, + /// and you should quit your process as soon as possible. This effectively runs steam://run/AppId so it + /// may not relaunch the exact executable that called it, as it will always relaunch from the version + /// installed in your Steam library folder/ + /// Note that during development, when not launching via Steam, this might always return true. + /// + public static bool RestartAppIfNecessary( uint appid ) + { + // Having these here would probably mean it always returns false? + + //System.Environment.SetEnvironmentVariable( "SteamAppId", appid.ToString() ); + //System.Environment.SetEnvironmentVariable( "SteamGameId", appid.ToString() ); + + return SteamAPI.RestartAppIfNecessary( appid ); + } + } } \ No newline at end of file