Steamuser

This commit is contained in:
Garry Newman 2016-07-15 10:25:52 +01:00
parent 19385ed951
commit ee502cce8b
4 changed files with 61 additions and 4 deletions

View File

@ -12,6 +12,7 @@ public partial class Client : IDisposable
internal Valve.Steamworks.ISteamClient _client; internal Valve.Steamworks.ISteamClient _client;
internal Valve.Steamworks.ISteamUser _user; internal Valve.Steamworks.ISteamUser _user;
internal Valve.Steamworks.ISteamApps _apps;
internal Valve.Steamworks.ISteamFriends _friends; internal Valve.Steamworks.ISteamFriends _friends;
internal Valve.Steamworks.ISteamMatchmakingServers _servers; internal Valve.Steamworks.ISteamMatchmakingServers _servers;
internal Valve.Steamworks.ISteamInventory _inventory; internal Valve.Steamworks.ISteamInventory _inventory;
@ -32,6 +33,17 @@ public partial class Client : IDisposable
/// </summary> /// </summary>
public ulong SteamId; public ulong SteamId;
public enum MessageType : int
{
Message = 0,
Warning = 1
}
/// <summary>
/// Called with a message from Steam
/// </summary>
public Action<MessageType, string> OnMessage;
public Client( uint appId ) public Client( uint appId )
{ {
Valve.Steamworks.SteamAPI.Init( appId ); Valve.Steamworks.SteamAPI.Init( appId );
@ -46,7 +58,7 @@ public Client( uint appId )
// //
// Set up warning hook callback // Set up warning hook callback
// //
SteamAPIWarningMessageHook ptr = OnWarning; SteamAPIWarningMessageHook ptr = InternalOnWarning;
_client.SetWarningMessageHook( Marshal.GetFunctionPointerForDelegate( ptr ) ); _client.SetWarningMessageHook( Marshal.GetFunctionPointerForDelegate( ptr ) );
// //
@ -64,6 +76,7 @@ public Client( uint appId )
_servers = _client.GetISteamMatchmakingServers( _huser, _hpipe, "SteamMatchMakingServers002" ); _servers = _client.GetISteamMatchmakingServers( _huser, _hpipe, "SteamMatchMakingServers002" );
_inventory = _client.GetISteamInventory( _huser, _hpipe, "STEAMINVENTORY_INTERFACE_V001" ); _inventory = _client.GetISteamInventory( _huser, _hpipe, "STEAMINVENTORY_INTERFACE_V001" );
_networking = _client.GetISteamNetworking( _huser, _hpipe, "SteamNetworking005" ); _networking = _client.GetISteamNetworking( _huser, _hpipe, "SteamNetworking005" );
_apps = _client.GetISteamApps( _huser, _hpipe, "STEAMAPPS_INTERFACE_VERSION008" );
AppId = appId; AppId = appId;
Username = _friends.GetPersonaName(); Username = _friends.GetPersonaName();
@ -95,9 +108,12 @@ public void Dispose()
[UnmanagedFunctionPointer( CallingConvention.Cdecl )] [UnmanagedFunctionPointer( CallingConvention.Cdecl )]
public delegate void SteamAPIWarningMessageHook( int nSeverity, System.Text.StringBuilder pchDebugText ); 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() );
}
} }
/// <summary> /// <summary>

View File

@ -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 );
}
}
}

View File

@ -120,6 +120,7 @@
<Compile Include="Client.Voice.cs" /> <Compile Include="Client.Voice.cs" />
<Compile Include="Client.Auth.cs" /> <Compile Include="Client.Auth.cs" />
<Compile Include="Client.cs" /> <Compile Include="Client.cs" />
<Compile Include="Client\App.cs" />
<Compile Include="Client\Inventory.cs" /> <Compile Include="Client\Inventory.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="steam_api_interop.cs" /> <Compile Include="steam_api_interop.cs" />

View File

@ -2469,7 +2469,7 @@ internal override ISteamApps GetISteamApps( uint hSteamUser, uint hSteamPipe, st
{ {
CheckIfUsable(); CheckIfUsable();
IntPtr result = NativeEntrypoints.SteamAPI_ISteamClient_GetISteamApps(m_pSteamClient,hSteamUser,hSteamPipe,pchVersion); 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 ) internal override ISteamNetworking GetISteamNetworking( uint hSteamUser, uint hSteamPipe, string pchVersion )
{ {