diff --git a/Facepunch.Steamworks/Redux/Apps.cs b/Facepunch.Steamworks/Redux/Apps.cs index 70026d7..f867df9 100644 --- a/Facepunch.Steamworks/Redux/Apps.cs +++ b/Facepunch.Steamworks/Redux/Apps.cs @@ -54,5 +54,62 @@ namespace Steamworks /// Gets a list of the languages the current app supports. /// public static string[] AvailablLanguages => steamapps.GetAvailableGameLanguages().Split( new[] { ',' }, StringSplitOptions.RemoveEmptyEntries ); + + /// + /// Checks if the active user is subscribed to a specified AppId. + /// Only use this if you need to check ownership of another game related to yours, a demo for example. + /// + public static bool IsSubscribedToApp( AppId appid ) => steamapps.BIsSubscribedApp( appid.Value ); + + /// + /// Checks if the user owns a specific DLC and if the DLC is installed + /// + public static bool IsDlcInstalled( AppId appid ) => steamapps.BIsDlcInstalled( appid.Value ); + + /// + /// Returns the time of the purchase of the app + /// + public static DateTime PurchaseTime( AppId appid ) => Facepunch.Steamworks.Utility.Epoch.ToDateTime( steamapps.GetEarliestPurchaseUnixTime( appid.Value ) ); + + /// + /// Checks if the user is subscribed to the current app through a free weekend + /// This function will return false for users who have a retail or other type of license + /// Before using, please ask your Valve technical contact how to package and secure your free weekened + /// + public static bool IsSubscribedFromFreeWeekend => steamapps.BIsSubscribedFromFreeWeekend(); + + /// + /// Returns metadata for all available DLC + /// + public static IEnumerable DlcInformation() + { + var appid = default( SteamNative.AppId_t ); + var sb = new StringBuilder( 512 ); + var available = false; + + for ( int i = 0; i < steamapps.GetDLCCount(); i++ ) + { + if ( !steamapps.BGetDLCDataByIndex( i, ref appid, ref available, sb, sb.Capacity ) ) + continue; + + yield return new DlcInformation + { + AppId = appid.Value, + Name = sb.ToString(), + Available = available + }; + } + } + + /// + /// Install/Uninstall control for optional DLC + /// + public static void InstallDlc( AppId appid ) => steamapps.InstallDLC( appid.Value ); + + /// + /// Install/Uninstall control for optional DLC + /// + public static void UninstallDlc( AppId appid ) => steamapps.UninstallDLC( appid.Value ); + } } \ No newline at end of file diff --git a/Facepunch.Steamworks/Redux/Structs/AppId.cs b/Facepunch.Steamworks/Redux/Structs/AppId.cs new file mode 100644 index 0000000..d4d994c --- /dev/null +++ b/Facepunch.Steamworks/Redux/Structs/AppId.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; + + +namespace Steamworks +{ + public struct AppId + { + public uint Value; + + public static implicit operator AppId( uint value ) + { + return new AppId{ Value = value }; + } + + public static implicit operator AppId( int value ) + { + return new AppId { Value = (uint) value }; + } + + public static implicit operator uint( AppId value ) + { + return value.Value; + } + } +} \ No newline at end of file diff --git a/Facepunch.Steamworks/Redux/Structs/DlcInformation.cs b/Facepunch.Steamworks/Redux/Structs/DlcInformation.cs new file mode 100644 index 0000000..19f3a61 --- /dev/null +++ b/Facepunch.Steamworks/Redux/Structs/DlcInformation.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; + + +namespace Steamworks +{ + public struct DlcInformation + { + public AppId AppId { get; internal set; } + public string Name { get; internal set; } + public bool Available { get; internal set; } + } +} \ No newline at end of file