diff --git a/Facepunch.Steamworks/Client.cs b/Facepunch.Steamworks/Client.cs index 122be17..2e26673 100644 --- a/Facepunch.Steamworks/Client.cs +++ b/Facepunch.Steamworks/Client.cs @@ -12,6 +12,7 @@ public partial class Client : IDisposable internal Valve.Steamworks.ISteamClient _client; internal Valve.Steamworks.ISteamUser _user; + internal Valve.Steamworks.ISteamApps _apps; internal Valve.Steamworks.ISteamFriends _friends; internal Valve.Steamworks.ISteamMatchmakingServers _servers; internal Valve.Steamworks.ISteamInventory _inventory; @@ -32,6 +33,17 @@ public partial class Client : IDisposable /// public ulong SteamId; + public enum MessageType : int + { + Message = 0, + Warning = 1 + } + + /// + /// Called with a message from Steam + /// + public Action OnMessage; + public Client( uint appId ) { Valve.Steamworks.SteamAPI.Init( appId ); @@ -46,7 +58,7 @@ public Client( uint appId ) // // Set up warning hook callback // - SteamAPIWarningMessageHook ptr = OnWarning; + SteamAPIWarningMessageHook ptr = InternalOnWarning; _client.SetWarningMessageHook( Marshal.GetFunctionPointerForDelegate( ptr ) ); // @@ -64,6 +76,7 @@ public Client( uint appId ) _servers = _client.GetISteamMatchmakingServers( _huser, _hpipe, "SteamMatchMakingServers002" ); _inventory = _client.GetISteamInventory( _huser, _hpipe, "STEAMINVENTORY_INTERFACE_V001" ); _networking = _client.GetISteamNetworking( _huser, _hpipe, "SteamNetworking005" ); + _apps = _client.GetISteamApps( _huser, _hpipe, "STEAMAPPS_INTERFACE_VERSION008" ); AppId = appId; Username = _friends.GetPersonaName(); @@ -95,9 +108,12 @@ public void Dispose() [UnmanagedFunctionPointer( CallingConvention.Cdecl )] public delegate void SteamAPIWarningMessageHook( int nSeverity, System.Text.StringBuilder pchDebugText ); - private void OnWarning( int nSeverity, System.Text.StringBuilder text ) + private void InternalOnWarning( int nSeverity, System.Text.StringBuilder text ) { - Console.Write( text.ToString() ); + if ( OnMessage != null ) + { + OnMessage( ( MessageType)nSeverity, text.ToString() ); + } } /// diff --git a/Facepunch.Steamworks/Client/App.cs b/Facepunch.Steamworks/Client/App.cs new file mode 100644 index 0000000..7dd6556 --- /dev/null +++ b/Facepunch.Steamworks/Client/App.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Facepunch.Steamworks +{ + public partial class Client : IDisposable + { + App _app; + + public App App + { + get + { + if ( _app == null ) + _app = new App( this ); + + return _app; + } + } + } + + public class App + { + internal Client client; + + internal App( Client c ) + { + client = c; + } + + public void MarkContentCorrupt( bool missingFilesOnly = false ) + { + client._apps.MarkContentCorrupt( missingFilesOnly ); + } + + + } +} diff --git a/Facepunch.Steamworks/Facepunch.Steamworks.csproj b/Facepunch.Steamworks/Facepunch.Steamworks.csproj index b6e4825..e3130b5 100644 --- a/Facepunch.Steamworks/Facepunch.Steamworks.csproj +++ b/Facepunch.Steamworks/Facepunch.Steamworks.csproj @@ -120,6 +120,7 @@ + diff --git a/Facepunch.Steamworks/steam_api_interop.cs b/Facepunch.Steamworks/steam_api_interop.cs index 98afd33..7b819f4 100644 --- a/Facepunch.Steamworks/steam_api_interop.cs +++ b/Facepunch.Steamworks/steam_api_interop.cs @@ -2469,7 +2469,7 @@ internal override ISteamApps GetISteamApps( uint hSteamUser, uint hSteamPipe, st { CheckIfUsable(); IntPtr result = NativeEntrypoints.SteamAPI_ISteamClient_GetISteamApps(m_pSteamClient,hSteamUser,hSteamPipe,pchVersion); - return (ISteamApps)Marshal.PtrToStructure( result, typeof( ISteamApps ) ); + return new CSteamApps( result ); } internal override ISteamNetworking GetISteamNetworking( uint hSteamUser, uint hSteamPipe, string pchVersion ) {