From 2d2be118d388c57d00f1dc24a088a05bf5cfc6a2 Mon Sep 17 00:00:00 2001 From: Garry Newman Date: Sun, 14 Apr 2019 21:48:11 +0100 Subject: [PATCH] Parental settings --- .../Interfaces/ISteamParentalSettings.cs | 97 +++++++++++++++++++ Facepunch.Steamworks/Redux/Parental.cs | 68 +++++++++++++ Generator/CodeWriter/CodeWriter.cs | 1 + 3 files changed, 166 insertions(+) create mode 100644 Facepunch.Steamworks/Generated/Interfaces/ISteamParentalSettings.cs create mode 100644 Facepunch.Steamworks/Redux/Parental.cs diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamParentalSettings.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamParentalSettings.cs new file mode 100644 index 0000000..691dfff --- /dev/null +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamParentalSettings.cs @@ -0,0 +1,97 @@ +using System; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; +using SteamNative; + + +namespace Steamworks.Internal +{ + public class ISteamParentalSettings : BaseSteamInterface + { + public override string InterfaceName => "STEAMPARENTALSETTINGS_INTERFACE_VERSION001"; + + public override void InitInternals() + { + BIsParentalLockEnabledDelegatePointer = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 0) ); + BIsParentalLockLockedDelegatePointer = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 8) ); + BIsAppBlockedDelegatePointer = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 16) ); + BIsAppInBlockListDelegatePointer = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 24) ); + BIsFeatureBlockedDelegatePointer = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 32) ); + BIsFeatureInBlockListDelegatePointer = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 40) ); + } + + #region FunctionMeta + [UnmanagedFunctionPointer( CallingConvention.ThisCall )] + [return: MarshalAs( UnmanagedType.I1 )] + public delegate bool BIsParentalLockEnabledDelegate( IntPtr self ); + private BIsParentalLockEnabledDelegate BIsParentalLockEnabledDelegatePointer; + + #endregion + public bool BIsParentalLockEnabled() + { + return BIsParentalLockEnabledDelegatePointer( Self ); + } + + #region FunctionMeta + [UnmanagedFunctionPointer( CallingConvention.ThisCall )] + [return: MarshalAs( UnmanagedType.I1 )] + public delegate bool BIsParentalLockLockedDelegate( IntPtr self ); + private BIsParentalLockLockedDelegate BIsParentalLockLockedDelegatePointer; + + #endregion + public bool BIsParentalLockLocked() + { + return BIsParentalLockLockedDelegatePointer( Self ); + } + + #region FunctionMeta + [UnmanagedFunctionPointer( CallingConvention.ThisCall )] + [return: MarshalAs( UnmanagedType.I1 )] + public delegate bool BIsAppBlockedDelegate( IntPtr self, AppId_t nAppID ); + private BIsAppBlockedDelegate BIsAppBlockedDelegatePointer; + + #endregion + public bool BIsAppBlocked( AppId_t nAppID ) + { + return BIsAppBlockedDelegatePointer( Self, nAppID ); + } + + #region FunctionMeta + [UnmanagedFunctionPointer( CallingConvention.ThisCall )] + [return: MarshalAs( UnmanagedType.I1 )] + public delegate bool BIsAppInBlockListDelegate( IntPtr self, AppId_t nAppID ); + private BIsAppInBlockListDelegate BIsAppInBlockListDelegatePointer; + + #endregion + public bool BIsAppInBlockList( AppId_t nAppID ) + { + return BIsAppInBlockListDelegatePointer( Self, nAppID ); + } + + #region FunctionMeta + [UnmanagedFunctionPointer( CallingConvention.ThisCall )] + [return: MarshalAs( UnmanagedType.I1 )] + public delegate bool BIsFeatureBlockedDelegate( IntPtr self, ParentalFeature eFeature ); + private BIsFeatureBlockedDelegate BIsFeatureBlockedDelegatePointer; + + #endregion + public bool BIsFeatureBlocked( ParentalFeature eFeature ) + { + return BIsFeatureBlockedDelegatePointer( Self, eFeature ); + } + + #region FunctionMeta + [UnmanagedFunctionPointer( CallingConvention.ThisCall )] + [return: MarshalAs( UnmanagedType.I1 )] + public delegate bool BIsFeatureInBlockListDelegate( IntPtr self, ParentalFeature eFeature ); + private BIsFeatureInBlockListDelegate BIsFeatureInBlockListDelegatePointer; + + #endregion + public bool BIsFeatureInBlockList( ParentalFeature eFeature ) + { + return BIsFeatureInBlockListDelegatePointer( Self, eFeature ); + } + + } +} diff --git a/Facepunch.Steamworks/Redux/Parental.cs b/Facepunch.Steamworks/Redux/Parental.cs new file mode 100644 index 0000000..d2b3224 --- /dev/null +++ b/Facepunch.Steamworks/Redux/Parental.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; +using SteamNative; + +namespace Steamworks +{ + /// + /// Undocumented Parental Settings + /// + public static class Parental + { + static Internal.ISteamParentalSettings _internal; + internal static Internal.ISteamParentalSettings parentalsettings + { + get + { + if ( _internal == null ) + _internal = new Internal.ISteamParentalSettings(); + + return _internal; + } + } + + internal static void InstallEvents() + { + new Event( x => OnSettingsChanged?.Invoke() ); + } + + /// + /// Parental Settings Changed + /// + public static event Action OnSettingsChanged; + + + /// + /// + /// + public static bool IsParentalLockEnabled => parentalsettings.BIsParentalLockEnabled(); + + /// + /// + /// + public static bool IsParentalLockLocked => parentalsettings.BIsParentalLockLocked(); + + /// + /// + /// + public static bool IsAppBlocked( AppId app ) => parentalsettings.BIsAppBlocked( app.Value ); + + /// + /// + /// + public static bool BIsAppInBlockList( AppId app ) => parentalsettings.BIsAppInBlockList( app.Value ); + + /// + /// + /// + public static bool IsFeatureBlocked( ParentalFeature feature ) => parentalsettings.BIsFeatureBlocked( feature ); + + /// + /// + /// + public static bool BIsFeatureInBlockList( ParentalFeature feature ) => parentalsettings.BIsFeatureInBlockList( feature ); + } +} \ No newline at end of file diff --git a/Generator/CodeWriter/CodeWriter.cs b/Generator/CodeWriter/CodeWriter.cs index 72b846c..61a3a89 100644 --- a/Generator/CodeWriter/CodeWriter.cs +++ b/Generator/CodeWriter/CodeWriter.cs @@ -94,6 +94,7 @@ namespace Generator { GenerateVTableClass( "ISteamApps", $"{folder}../Generated/Interfaces/ISteamApps.cs" ); GenerateVTableClass( "ISteamUtils", $"{folder}../Generated/Interfaces/ISteamUtils.cs" ); + GenerateVTableClass( "ISteamParentalSettings", $"{folder}../Generated/Interfaces/ISteamParentalSettings.cs" ); } }