diff --git a/Facepunch.Steamworks.Test/Client/AppTest.cs b/Facepunch.Steamworks.Test/Client/AppTest.cs index 15d5494..60f703a 100644 --- a/Facepunch.Steamworks.Test/Client/AppTest.cs +++ b/Facepunch.Steamworks.Test/Client/AppTest.cs @@ -26,6 +26,26 @@ public void GameLangauge() Console.WriteLine( $"{gl}" ); } + [TestMethod] + public void AppInstallDir() + { + var str = Apps.AppInstallDir( 4000 ); + Assert.IsNotNull( str ); + Assert.IsTrue( str.Length > 3 ); + + Console.WriteLine( $"{str}" ); + } + + [TestMethod] + public void AppOwner() + { + var steamid = Apps.AppOwner; + Assert.IsTrue( steamid.Value > 70561197960279927 ); + Assert.IsTrue( steamid.Value < 80561197960279927 ); + + Console.WriteLine( $"{steamid.Value}" ); + } + [TestMethod] public void InstalledDepots() { @@ -38,8 +58,6 @@ public void InstalledDepots() { Console.WriteLine( $"{depot.Value}" ); } - - } } diff --git a/Facepunch.Steamworks/Redux/Apps.cs b/Facepunch.Steamworks/Redux/Apps.cs index c5ff7dc..134768f 100644 --- a/Facepunch.Steamworks/Redux/Apps.cs +++ b/Facepunch.Steamworks/Redux/Apps.cs @@ -152,5 +152,57 @@ public static IEnumerable InstalledDepots( AppId appid ) } } + /// + /// Gets the install folder for a specific AppID. + /// This works even if the application is not installed, based on where the game would be installed with the default Steam library location. + /// + public static string AppInstallDir( AppId appid ) + { + var sb = SteamNative.Helpers.TakeStringBuilder(); + + if ( steamapps.GetAppInstallDir( appid.Value, sb, (uint) sb.Capacity ) == 0 ) + return null; + + return sb.ToString(); + } + + /// + /// The app may not actually be owned by the current user, they may have it left over from a free weekend, etc. + /// + public static bool IsAppInstalled( AppId appid ) => steamapps.BIsAppInstalled( appid.Value ); + + /// + /// Gets the Steam ID of the original owner of the current app. If it's different from the current user then it is borrowed.. + /// + public static SteamId AppOwner => steamapps.GetAppOwner().Value; + + /// + /// Gets the associated launch parameter if the game is run via steam://run//?param1=value1;param2=value2;param3=value3 etc. + /// Parameter names starting with the character '@' are reserved for internal use and will always return an empty string. + /// Parameter names starting with an underscore '_' are reserved for steam features -- they can be queried by the game, + /// but it is advised that you not param names beginning with an underscore for your own features. + /// + public static string GetLaunchParam( string param ) => steamapps.GetLaunchQueryParam( param ); + + /// + /// Gets the download progress for optional DLC. + /// + public static DownloadProgress DlcDownloadProgress( AppId appid ) + { + ulong punBytesDownloaded = 0; + ulong punBytesTotal = 0; + + if ( !steamapps.GetDlcDownloadProgress( appid.Value, ref punBytesDownloaded, ref punBytesTotal ) ) + return default( DownloadProgress ); + + return new DownloadProgress { BytesDownloaded = punBytesDownloaded, BytesTotal = punBytesTotal, Active = true }; + } + + /// + /// Gets the buildid of this app, may change at any time based on backend updates to the game. + /// Defaults to 0 if you're not running a build downloaded from steam. + /// + public static int BuildId => steamapps.GetAppBuildId(); + } } \ No newline at end of file diff --git a/Facepunch.Steamworks/Redux/Structs/DownloadProgress.cs b/Facepunch.Steamworks/Redux/Structs/DownloadProgress.cs new file mode 100644 index 0000000..005e8cd --- /dev/null +++ b/Facepunch.Steamworks/Redux/Structs/DownloadProgress.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; + + +namespace Steamworks +{ + public struct DownloadProgress + { + public bool Active; + public ulong BytesDownloaded; + public ulong BytesTotal; + } +} \ No newline at end of file diff --git a/Facepunch.Steamworks/Redux/Structs/SteamId.cs b/Facepunch.Steamworks/Redux/Structs/SteamId.cs new file mode 100644 index 0000000..2536698 --- /dev/null +++ b/Facepunch.Steamworks/Redux/Structs/SteamId.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; + + +namespace Steamworks +{ + public struct SteamId + { + public ulong Value; + + public static implicit operator SteamId( ulong value ) + { + return new SteamId { Value = value }; + } + + public static implicit operator ulong( SteamId value ) + { + return value.Value; + } + } +} \ No newline at end of file