CallResult implementation

This commit is contained in:
Garry Newman 2016-10-31 11:46:53 +00:00
parent 7ddc054890
commit bae105dbc9
49 changed files with 4699 additions and 3498 deletions

View File

@ -21,7 +21,7 @@ public virtual void Dispose()
{ {
foreach ( var h in CallbackHandles ) foreach ( var h in CallbackHandles )
{ {
h.Remove( this ); h.UnregisterCallback();
} }
CallbackHandles.Clear(); CallbackHandles.Clear();
@ -77,8 +77,8 @@ public enum MessageType : int
public Action<MessageType, string> OnMessage; public Action<MessageType, string> OnMessage;
private List<SteamNative.Callback.Handle> CallbackHandles = new List<SteamNative.Callback.Handle>(); private List<SteamNative.CallbackHandle> CallbackHandles = new List<SteamNative.CallbackHandle>();
internal void RegisterCallbackHandle( SteamNative.Callback.Handle handle ) internal void RegisterCallbackHandle( SteamNative.CallbackHandle handle )
{ {
CallbackHandles.Add( handle ); CallbackHandles.Add( handle );
} }
@ -88,59 +88,11 @@ internal void RegisterCallbackHandle( SteamNative.Callback.Handle handle )
public virtual void Update() public virtual void Update()
{ {
RunCallbackQueue();
Inventory.Update(); Inventory.Update();
Networking.Update(); Networking.Update();
if ( OnUpdate != null ) if ( OnUpdate != null )
OnUpdate(); OnUpdate();
} }
List<CallResult> Callbacks = new List<CallResult>();
/// <summary>
/// Call results are results to specific actions
/// </summary>
internal void AddCallResult( CallResult call )
{
if ( call == null ) throw new ArgumentNullException( "call" );
if ( FinishCallback( call ) )
return;
Callbacks.Add( call );
}
void RunCallbackQueue()
{
for ( int i=0; i< Callbacks.Count(); i++ )
{
if ( !FinishCallback( Callbacks[i] ) )
continue;
Callbacks.RemoveAt( i );
i--;
}
}
bool FinishCallback( CallResult call )
{
bool failed = true;
if ( !native.utils.IsAPICallCompleted( call.Handle, ref failed ) )
return false;
if ( failed )
{
//
// TODO - failure reason?
//
return true;
}
call.Run( native.utils );
return true;
}
} }
} }

View File

@ -1,22 +0,0 @@
using System.Runtime.InteropServices;
using Facepunch.Steamworks.Interop;
namespace Facepunch.Steamworks.Callbacks.Workshop
{
internal class QueryCompleted : CallResult<SteamNative.SteamUGCQueryCompleted_t, SteamNative.SteamUGCQueryCompleted_t.PackSmall>
{
public override int CallbackId { get { return SteamNative.SteamUGCQueryCompleted_t.CallbackId; } }
}
internal class CreateItem : CallResult<SteamNative.CreateItemResult_t, SteamNative.CreateItemResult_t.PackSmall>
{
public override int CallbackId { get { return SteamNative.CreateItemResult_t.CallbackId; } }
}
internal class SubmitItemUpdate : CallResult<SteamNative.SubmitItemUpdateResult_t, SteamNative.SubmitItemUpdateResult_t.PackSmall>
{
public override int CallbackId { get { return SteamNative.SubmitItemUpdateResult_t.CallbackId; } }
public SteamNative.UGCUpdateHandle_t UpdateHandle;
}
}

View File

@ -29,7 +29,7 @@ public Client( uint appId )
// //
// Get other interfaces // Get other interfaces
// //
if ( !native.InitClient() ) if ( !native.InitClient( this ) )
{ {
native.Dispose(); native.Dispose();
native = null; native = null;

View File

@ -114,7 +114,6 @@
<ItemGroup> <ItemGroup>
<Compile Include="BaseSteamworks.cs" /> <Compile Include="BaseSteamworks.cs" />
<Compile Include="Callbacks\Index.cs" /> <Compile Include="Callbacks\Index.cs" />
<Compile Include="Callbacks\Workshop.cs" />
<Compile Include="Interfaces\Inventory.Item.cs" /> <Compile Include="Interfaces\Inventory.Item.cs" />
<Compile Include="Interfaces\Inventory.Result.cs" /> <Compile Include="Interfaces\Inventory.Result.cs" />
<Compile Include="Interfaces\Networking.cs" /> <Compile Include="Interfaces\Networking.cs" />
@ -137,7 +136,6 @@
<Compile Include="Interfaces\Workshop.Editor.cs" /> <Compile Include="Interfaces\Workshop.Editor.cs" />
<Compile Include="Interfaces\Workshop.Item.cs" /> <Compile Include="Interfaces\Workshop.Item.cs" />
<Compile Include="Interfaces\Workshop.Query.cs" /> <Compile Include="Interfaces\Workshop.Query.cs" />
<Compile Include="Interop\CallResult.cs" />
<Compile Include="Interop\Native.cs" /> <Compile Include="Interop\Native.cs" />
<Compile Include="Interop\ServerRules.cs" /> <Compile Include="Interop\ServerRules.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />

View File

@ -1,6 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Facepunch.Steamworks.Callbacks.Workshop; using SteamNative;
namespace Facepunch.Steamworks namespace Facepunch.Steamworks
{ {
@ -10,8 +10,9 @@ public class Editor
{ {
internal Workshop workshop; internal Workshop workshop;
internal CreateItem CreateItem; internal CallbackHandle CreateItem;
internal SubmitItemUpdate SubmitItemUpdate; internal CallbackHandle SubmitItemUpdate;
internal SteamNative.UGCUpdateHandle_t UpdateHandle;
public ulong Id { get; internal set; } public ulong Id { get; internal set; }
public string Title { get; set; } = null; public string Title { get; set; } = null;
@ -48,7 +49,7 @@ public double Progress
ulong b = 0; ulong b = 0;
ulong t = 0; ulong t = 0;
workshop.steamworks.native.ugc.GetItemUpdateProgress( SubmitItemUpdate.UpdateHandle, out b, out t ); workshop.steamworks.native.ugc.GetItemUpdateProgress( UpdateHandle, out b, out t );
if ( t == 0 ) if ( t == 0 )
return 0; return 0;
@ -68,7 +69,7 @@ public int BytesUploaded
ulong b = 0; ulong b = 0;
ulong t = 0; ulong t = 0;
workshop.steamworks.native.ugc.GetItemUpdateProgress( SubmitItemUpdate.UpdateHandle, out b, out t ); workshop.steamworks.native.ugc.GetItemUpdateProgress( UpdateHandle, out b, out t );
return (int) b; return (int) b;
} }
} }
@ -84,7 +85,7 @@ public int BytesTotal
ulong b = 0; ulong b = 0;
ulong t = 0; ulong t = 0;
workshop.steamworks.native.ugc.GetItemUpdateProgress( SubmitItemUpdate.UpdateHandle, out b, out t ); workshop.steamworks.native.ugc.GetItemUpdateProgress( UpdateHandle, out b, out t );
return (int)t; return (int)t;
} }
} }
@ -108,14 +109,14 @@ private void StartCreatingItem()
if ( !Type.HasValue ) if ( !Type.HasValue )
throw new System.Exception( "Editor.Type must be set when creating a new item!" ); throw new System.Exception( "Editor.Type must be set when creating a new item!" );
CreateItem = new CreateItem(); CreateItem = workshop.ugc.CreateItem( workshop.steamworks.AppId, (SteamNative.WorkshopFileType)(uint)Type, OnItemCreated );
CreateItem.Handle = workshop.ugc.CreateItem( workshop.steamworks.AppId, (SteamNative.WorkshopFileType)(uint)Type );
CreateItem.OnResult = OnItemCreated;
workshop.steamworks.AddCallResult( CreateItem );
} }
private void OnItemCreated( SteamNative.CreateItemResult_t obj ) private void OnItemCreated( SteamNative.CreateItemResult_t obj, bool Failed )
{ {
if ( Failed )
throw new System.Exception( "CreateItemResult_t Failed" );
NeedToAgreeToWorkshopLegal = obj.UserNeedsToAcceptWorkshopLegalAgreement; NeedToAgreeToWorkshopLegal = obj.UserNeedsToAcceptWorkshopLegalAgreement;
CreateItem = null; CreateItem = null;
@ -132,7 +133,7 @@ private void OnItemCreated( SteamNative.CreateItemResult_t obj )
private void PublishChanges() private void PublishChanges()
{ {
SteamNative.UGCUpdateHandle_t UpdateHandle = workshop.ugc.StartItemUpdate( workshop.steamworks.AppId, Id ); UpdateHandle = workshop.ugc.StartItemUpdate( workshop.steamworks.AppId, Id );
if ( Title != null ) if ( Title != null )
workshop.ugc.SetItemTitle( UpdateHandle, Title ); workshop.ugc.SetItemTitle( UpdateHandle, Title );
@ -164,15 +165,14 @@ private void PublishChanges()
workshop.ugc.RemoveItemPreview( UpdateId, uint32 index ) = 0; // remove a preview by index starting at 0 (previews are sorted) workshop.ugc.RemoveItemPreview( UpdateId, uint32 index ) = 0; // remove a preview by index starting at 0 (previews are sorted)
*/ */
SubmitItemUpdate = new SubmitItemUpdate(); SubmitItemUpdate = workshop.ugc.SubmitItemUpdate( UpdateHandle, ChangeNote, OnChangesSubmitted );
SubmitItemUpdate.Handle = workshop.ugc.SubmitItemUpdate( UpdateHandle, ChangeNote );
SubmitItemUpdate.OnResult = OnChangesSubmitted;
SubmitItemUpdate.UpdateHandle = UpdateHandle;
workshop.steamworks.AddCallResult( SubmitItemUpdate );
} }
private void OnChangesSubmitted( SteamNative.SubmitItemUpdateResult_t obj ) private void OnChangesSubmitted( SteamNative.SubmitItemUpdateResult_t obj, bool Failed )
{ {
if ( Failed )
throw new System.Exception( "CreateItemResult_t Failed" );
SubmitItemUpdate = null; SubmitItemUpdate = null;
NeedToAgreeToWorkshopLegal = obj.UserNeedsToAcceptWorkshopLegalAgreement; NeedToAgreeToWorkshopLegal = obj.UserNeedsToAcceptWorkshopLegalAgreement;
Publishing = false; Publishing = false;

View File

@ -4,7 +4,6 @@
using System.Linq; using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
using Facepunch.Steamworks.Callbacks.Workshop;
namespace Facepunch.Steamworks namespace Facepunch.Steamworks
{ {

View File

@ -1,7 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Facepunch.Steamworks.Callbacks.Workshop;
namespace Facepunch.Steamworks namespace Facepunch.Steamworks
{ {
@ -12,7 +11,7 @@ public class Query : IDisposable
internal const int SteamResponseSize = 50; internal const int SteamResponseSize = 50;
internal SteamNative.UGCQueryHandle_t Handle; internal SteamNative.UGCQueryHandle_t Handle;
internal QueryCompleted Callback; internal SteamNative.CallbackHandle Callback;
/// <summary> /// <summary>
/// The AppId you're querying. This defaults to this appid. /// The AppId you're querying. This defaults to this appid.
@ -107,15 +106,15 @@ unsafe void RunInternal()
foreach ( var tag in ExcludeTags ) foreach ( var tag in ExcludeTags )
workshop.ugc.AddExcludedTag( Handle, tag ); workshop.ugc.AddExcludedTag( Handle, tag );
Callback = new QueryCompleted(); Callback = workshop.ugc.SendQueryUGCRequest( Handle, OnResult );
Callback.Handle = workshop.ugc.SendQueryUGCRequest( Handle ); // workshop.steamworks.AddCallResult( Callback );
Callback.OnResult = OnResult;
workshop.steamworks.AddCallResult( Callback );
} }
void OnResult( SteamNative.SteamUGCQueryCompleted_t data ) void OnResult( SteamNative.SteamUGCQueryCompleted_t data, bool bFailed )
{ {
if ( bFailed )
throw new System.Exception( "bFailed!" );
var gotFiles = 0; var gotFiles = 0;
for ( int i = 0; i < data.NumResultsReturned; i++ ) for ( int i = 0; i < data.NumResultsReturned; i++ )
{ {

View File

@ -1,6 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Facepunch.Steamworks.Callbacks.Workshop; using SteamNative;
namespace Facepunch.Steamworks namespace Facepunch.Steamworks
{ {
@ -24,6 +24,7 @@ internal Workshop( BaseSteamworks steamworks, SteamNative.SteamUGC ugc, SteamNat
SteamNative.DownloadItemResult_t.RegisterCallback( steamworks, onDownloadResult ); SteamNative.DownloadItemResult_t.RegisterCallback( steamworks, onDownloadResult );
SteamNative.ItemInstalled_t.RegisterCallback( steamworks, onItemInstalled ); SteamNative.ItemInstalled_t.RegisterCallback( steamworks, onItemInstalled );
// SteamNative.SteamUGCQueryCompleted_t.RegisterCallback( steamworks, onQueryComplete );
// steamworks.AddCallback<ItemInstalled, ItemInstalled.Small>( onItemInstalled, ItemInstalled.CallbackId ); // steamworks.AddCallback<ItemInstalled, ItemInstalled.Small>( onItemInstalled, ItemInstalled.CallbackId );
} }

View File

@ -1,65 +0,0 @@
using System;
using System.Reflection;
using System.Runtime.InteropServices;
namespace Facepunch.Steamworks.Interop
{
internal unsafe abstract class CallResult : IDisposable
{
public SteamNative.SteamAPICall_t Handle;
public void Dispose()
{
Handle = 0;
}
internal abstract void Run( SteamNative.SteamUtils utils );
}
internal unsafe abstract class CallResult<T, TSmall> : CallResult where T: new()
{
public static FieldInfo[] SourceFields = typeof( TSmall ).GetFields();
public static FieldInfo[] DestFields = typeof( T ).GetFields();
public abstract int CallbackId { get; }
public Action<T> OnResult;
internal override void Run( SteamNative.SteamUtils utils )
{
var packSmall = SteamNative.Platform.PackSmall;
var datasize = packSmall ? Marshal.SizeOf( typeof( TSmall ) ) : Marshal.SizeOf( typeof( T ) );
var data = stackalloc byte[ datasize ];
bool failed = false;
if ( !utils.GetAPICallResult( Handle, (IntPtr) data, datasize, CallbackId, ref failed ) || failed )
{
Console.WriteLine( "FAILURE" );
return;
}
if ( packSmall )
{
var dataTarget = new T();
var dataObject = (TSmall)Marshal.PtrToStructure( (IntPtr) data, typeof( TSmall ) );
for ( int i=0; i<SourceFields.Length; i++ )
{
DestFields[i].SetValue( dataTarget, SourceFields[i].GetValue( dataObject ) );
}
if ( OnResult != null )
OnResult( dataTarget );
}
else
{
var dataObject = (T)Marshal.PtrToStructure( (IntPtr) data, typeof( T ) );
if ( OnResult != null )
OnResult( dataObject );
}
}
}
}

View File

@ -30,11 +30,11 @@ internal class NativeInterface : IDisposable
private HSteamUser hUser; private HSteamUser hUser;
private HSteamPipe hPipe; private HSteamPipe hPipe;
internal bool InitClient() internal bool InitClient( BaseSteamworks steamworks )
{ {
isServer = false; isServer = false;
api = new SteamNative.SteamApi( (IntPtr) 1 ); api = new SteamNative.SteamApi( steamworks, (IntPtr) 1 );
if ( !api.SteamAPI_Init() ) if ( !api.SteamAPI_Init() )
return false; return false;
@ -44,7 +44,7 @@ internal bool InitClient()
if ( hPipe == 0 ) if ( hPipe == 0 )
return false; return false;
FillInterfaces( hUser, hPipe ); FillInterfaces( steamworks, hUser, hPipe );
// Ensure that the user has logged into Steam. This will always return true if the game is launched // Ensure that the user has logged into Steam. This will always return true if the game is launched
// from Steam, but if Steam is at the login prompt when you run your game it will return false. // from Steam, but if Steam is at the login prompt when you run your game it will return false.
@ -54,11 +54,11 @@ internal bool InitClient()
return true; return true;
} }
internal bool InitServer( uint IpAddress /*uint32*/, ushort usPort /*uint16*/, ushort GamePort /*uint16*/, ushort QueryPort /*uint16*/, int eServerMode /*int*/, string pchVersionString /*const char **/) internal bool InitServer( BaseSteamworks steamworks, uint IpAddress /*uint32*/, ushort usPort /*uint16*/, ushort GamePort /*uint16*/, ushort QueryPort /*uint16*/, int eServerMode /*int*/, string pchVersionString /*const char **/)
{ {
isServer = true; isServer = true;
api = new SteamNative.SteamApi( (IntPtr)1 ); api = new SteamNative.SteamApi( steamworks, ( IntPtr)1 );
if ( !api.SteamInternal_GameServer_Init( IpAddress, usPort, GamePort, QueryPort, eServerMode, pchVersionString ) ) if ( !api.SteamInternal_GameServer_Init( IpAddress, usPort, GamePort, QueryPort, eServerMode, pchVersionString ) )
{ {
@ -70,7 +70,7 @@ internal bool InitServer( uint IpAddress /*uint32*/, ushort usPort /*uint16*/, u
if ( hPipe == 0 ) if ( hPipe == 0 )
return false; return false;
FillInterfaces( hPipe, hUser ); FillInterfaces( steamworks, hPipe, hUser );
if ( !gameServer.IsValid ) if ( !gameServer.IsValid )
{ {
@ -81,7 +81,7 @@ internal bool InitServer( uint IpAddress /*uint32*/, ushort usPort /*uint16*/, u
return true; return true;
} }
public void FillInterfaces( int hpipe, int huser ) public void FillInterfaces( BaseSteamworks steamworks, int hpipe, int huser )
{ {
var clientPtr = api.SteamInternal_CreateInterface( "SteamClient017" ); var clientPtr = api.SteamInternal_CreateInterface( "SteamClient017" );
if ( clientPtr == IntPtr.Zero ) if ( clientPtr == IntPtr.Zero )
@ -89,7 +89,7 @@ public void FillInterfaces( int hpipe, int huser )
throw new System.Exception( "Steam Server: Couldn't load SteamClient017" ); throw new System.Exception( "Steam Server: Couldn't load SteamClient017" );
} }
client = new SteamNative.SteamClient( clientPtr ); client = new SteamNative.SteamClient( steamworks, clientPtr );
user = client.GetISteamUser( huser, hpipe, SteamNative.Defines.STEAMUSER_INTERFACE_VERSION ); user = client.GetISteamUser( huser, hpipe, SteamNative.Defines.STEAMUSER_INTERFACE_VERSION );
utils = client.GetISteamUtils( hpipe, SteamNative.Defines.STEAMUTILS_INTERFACE_VERSION ); utils = client.GetISteamUtils( hpipe, SteamNative.Defines.STEAMUTILS_INTERFACE_VERSION );

View File

@ -27,7 +27,7 @@ public Server( uint appId, uint IpAddress, ushort GamePort, ushort QueryPort, bo
// //
// Get other interfaces // Get other interfaces
// //
if ( !native.InitServer( IpAddress, 0, GamePort, QueryPort, Secure ? 3 : 2, VersionString ) ) if ( !native.InitServer( this, IpAddress, 0, GamePort, QueryPort, Secure ? 3 : 2, VersionString ) )
{ {
native.Dispose(); native.Dispose();
native = null; native = null;

View File

@ -32,12 +32,17 @@ public class VTable
[UnmanagedFunctionPointer( CallingConvention.ThisCall )] public delegate void Result( IntPtr thisptr, IntPtr pvParam ); [UnmanagedFunctionPointer( CallingConvention.ThisCall )] public delegate void Result( IntPtr thisptr, IntPtr pvParam );
[UnmanagedFunctionPointer( CallingConvention.ThisCall )] public delegate void ResultWithInfo( IntPtr thisptr, IntPtr pvParam, bool bIOFailure, SteamNative.SteamAPICall_t hSteamAPICall ); [UnmanagedFunctionPointer( CallingConvention.ThisCall )] public delegate void ResultWithInfo( IntPtr thisptr, IntPtr pvParam, bool bIOFailure, SteamNative.SteamAPICall_t hSteamAPICall );
[UnmanagedFunctionPointer( CallingConvention.ThisCall )] public delegate int GetSize( IntPtr thisptr ); [UnmanagedFunctionPointer( CallingConvention.ThisCall )] public delegate int GetSize( IntPtr thisptr );
};
// //
// Created on registration of a callback // Created on registration of a callback
// //
public class Handle : IDisposable public class CallbackHandle : IDisposable
{ {
internal BaseSteamworks steamworks;
internal SteamAPICall_t callHandle;
public GCHandle FuncA; public GCHandle FuncA;
public GCHandle FuncB; public GCHandle FuncB;
public GCHandle FuncC; public GCHandle FuncC;
@ -67,17 +72,50 @@ public void Dispose()
} }
} }
internal void Remove( BaseSteamworks baseSteamworks ) internal void UnregisterCallback()
{ {
if ( PinnedCallback.IsAllocated ) if ( PinnedCallback.IsAllocated )
{ {
baseSteamworks.native.api.SteamAPI_UnregisterCallback( PinnedCallback.AddrOfPinnedObject() ); steamworks.native.api.SteamAPI_UnregisterCallback( PinnedCallback.AddrOfPinnedObject() );
}
Dispose();
}
internal void UnregisterCallResult()
{
if ( PinnedCallback.IsAllocated )
{
steamworks.native.api.SteamAPI_UnregisterCallResult( PinnedCallback.AddrOfPinnedObject(), callHandle );
} }
Dispose(); Dispose();
} }
} }
}; /*
public class CallResult<T> : IDisposable
{
public SteamAPICall_t Handle { get; private set; }
private Callback.Handle CallbackHandle;
internal CallResult( BaseSteamworks steamworks, SteamAPICall_t Handle, Callback.Handle CallbackHandle )
{
this.Handle = Handle;
this.CallbackHandle = CallbackHandle;
this.steamworks = steamworks;
}
public void Dispose()
{
if ( !steamworks.IsValid ) return;
if ( this.Handle == 0 ) return;
steamworks.native.api.SteamAPI_UnregisterCallResult( CallbackHandle.PinnedCallback.AddrOfPinnedObject(), Handle );
CallbackHandle.Dispose();
Handle = 0;
}
}
*/
} }

View File

@ -661,6 +661,8 @@ public interface Interface : IDisposable
void /*void*/ SteamApi_SteamGameServer_RunCallbacks(); void /*void*/ SteamApi_SteamGameServer_RunCallbacks();
void /*void*/ SteamApi_SteamAPI_RegisterCallback( IntPtr /*void **/ pCallback, int /*int*/ callback ); void /*void*/ SteamApi_SteamAPI_RegisterCallback( IntPtr /*void **/ pCallback, int /*int*/ callback );
void /*void*/ SteamApi_SteamAPI_UnregisterCallback( IntPtr /*void **/ pCallback ); void /*void*/ SteamApi_SteamAPI_UnregisterCallback( IntPtr /*void **/ pCallback );
void /*void*/ SteamApi_SteamAPI_RegisterCallResult( IntPtr /*void **/ pCallback, ulong callback );
void /*void*/ SteamApi_SteamAPI_UnregisterCallResult( IntPtr /*void **/ pCallback, ulong callback );
bool /*bool*/ SteamApi_SteamInternal_GameServer_Init( uint /*uint32*/ unIP, ushort /*uint16*/ usPort, ushort /*uint16*/ usGamePort, ushort /*uint16*/ usQueryPort, int /*int*/ eServerMode, string /*const char **/ pchVersionString ); bool /*bool*/ SteamApi_SteamInternal_GameServer_Init( uint /*uint32*/ unIP, ushort /*uint16*/ usPort, ushort /*uint16*/ usGamePort, ushort /*uint16*/ usQueryPort, int /*int*/ eServerMode, string /*const char **/ pchVersionString );
void /*void*/ SteamApi_SteamAPI_Shutdown(); void /*void*/ SteamApi_SteamAPI_Shutdown();
void /*void*/ SteamApi_SteamGameServer_Shutdown(); void /*void*/ SteamApi_SteamGameServer_Shutdown();

View File

@ -3978,6 +3978,14 @@ public virtual IntPtr ISteamApps_GetLaunchQueryParam( string /*const char **/ pc
{ {
Native.SteamAPI_UnregisterCallback(pCallback); Native.SteamAPI_UnregisterCallback(pCallback);
} }
public virtual void /*void*/ SteamApi_SteamAPI_RegisterCallResult( IntPtr /*void **/ pCallback, ulong callback )
{
Native.SteamAPI_RegisterCallResult(pCallback, callback);
}
public virtual void /*void*/ SteamApi_SteamAPI_UnregisterCallResult( IntPtr /*void **/ pCallback, ulong callback )
{
Native.SteamAPI_UnregisterCallResult(pCallback, callback);
}
public virtual bool /*bool*/ SteamApi_SteamInternal_GameServer_Init( uint /*uint32*/ unIP, ushort /*uint16*/ usPort, ushort /*uint16*/ usGamePort, ushort /*uint16*/ usQueryPort, int /*int*/ eServerMode, string /*const char **/ pchVersionString ) public virtual bool /*bool*/ SteamApi_SteamInternal_GameServer_Init( uint /*uint32*/ unIP, ushort /*uint16*/ usPort, ushort /*uint16*/ usGamePort, ushort /*uint16*/ usQueryPort, int /*int*/ eServerMode, string /*const char **/ pchVersionString )
{ {
return Native.SteamInternal_GameServer_Init(unIP, usPort, usGamePort, usQueryPort, eServerMode, pchVersionString); return Native.SteamInternal_GameServer_Init(unIP, usPort, usGamePort, usQueryPort, eServerMode, pchVersionString);
@ -4759,6 +4767,8 @@ internal static unsafe class Native
[DllImportAttribute( "libsteam_api.so" )] internal static extern void /*void*/ SteamGameServer_RunCallbacks(); [DllImportAttribute( "libsteam_api.so" )] internal static extern void /*void*/ SteamGameServer_RunCallbacks();
[DllImportAttribute( "libsteam_api.so" )] internal static extern void /*void*/ SteamAPI_RegisterCallback( IntPtr /*void **/ pCallback, int /*int*/ callback ); [DllImportAttribute( "libsteam_api.so" )] internal static extern void /*void*/ SteamAPI_RegisterCallback( IntPtr /*void **/ pCallback, int /*int*/ callback );
[DllImportAttribute( "libsteam_api.so" )] internal static extern void /*void*/ SteamAPI_UnregisterCallback( IntPtr /*void **/ pCallback ); [DllImportAttribute( "libsteam_api.so" )] internal static extern void /*void*/ SteamAPI_UnregisterCallback( IntPtr /*void **/ pCallback );
[DllImportAttribute( "libsteam_api.so" )] internal static extern void /*void*/ SteamAPI_RegisterCallResult( IntPtr /*void **/ pCallback, ulong callback );
[DllImportAttribute( "libsteam_api.so" )] internal static extern void /*void*/ SteamAPI_UnregisterCallResult( IntPtr /*void **/ pCallback, ulong callback );
[DllImportAttribute( "libsteam_api.so" )] internal static extern bool /*bool*/ SteamInternal_GameServer_Init( uint /*uint32*/ unIP, ushort /*uint16*/ usPort, ushort /*uint16*/ usGamePort, ushort /*uint16*/ usQueryPort, int /*int*/ eServerMode, string /*const char **/ pchVersionString ); [DllImportAttribute( "libsteam_api.so" )] internal static extern bool /*bool*/ SteamInternal_GameServer_Init( uint /*uint32*/ unIP, ushort /*uint16*/ usPort, ushort /*uint16*/ usGamePort, ushort /*uint16*/ usQueryPort, int /*int*/ eServerMode, string /*const char **/ pchVersionString );
[DllImportAttribute( "libsteam_api.so" )] internal static extern void /*void*/ SteamAPI_Shutdown(); [DllImportAttribute( "libsteam_api.so" )] internal static extern void /*void*/ SteamAPI_Shutdown();
[DllImportAttribute( "libsteam_api.so" )] internal static extern void /*void*/ SteamGameServer_Shutdown(); [DllImportAttribute( "libsteam_api.so" )] internal static extern void /*void*/ SteamGameServer_Shutdown();

View File

@ -3978,6 +3978,14 @@ public virtual IntPtr ISteamApps_GetLaunchQueryParam( string /*const char **/ pc
{ {
Native.SteamAPI_UnregisterCallback(pCallback); Native.SteamAPI_UnregisterCallback(pCallback);
} }
public virtual void /*void*/ SteamApi_SteamAPI_RegisterCallResult( IntPtr /*void **/ pCallback, ulong callback )
{
Native.SteamAPI_RegisterCallResult(pCallback, callback);
}
public virtual void /*void*/ SteamApi_SteamAPI_UnregisterCallResult( IntPtr /*void **/ pCallback, ulong callback )
{
Native.SteamAPI_UnregisterCallResult(pCallback, callback);
}
public virtual bool /*bool*/ SteamApi_SteamInternal_GameServer_Init( uint /*uint32*/ unIP, ushort /*uint16*/ usPort, ushort /*uint16*/ usGamePort, ushort /*uint16*/ usQueryPort, int /*int*/ eServerMode, string /*const char **/ pchVersionString ) public virtual bool /*bool*/ SteamApi_SteamInternal_GameServer_Init( uint /*uint32*/ unIP, ushort /*uint16*/ usPort, ushort /*uint16*/ usGamePort, ushort /*uint16*/ usQueryPort, int /*int*/ eServerMode, string /*const char **/ pchVersionString )
{ {
return Native.SteamInternal_GameServer_Init(unIP, usPort, usGamePort, usQueryPort, eServerMode, pchVersionString); return Native.SteamInternal_GameServer_Init(unIP, usPort, usGamePort, usQueryPort, eServerMode, pchVersionString);
@ -4759,6 +4767,8 @@ internal static unsafe class Native
[DllImportAttribute( "libsteam_api64.so" )] internal static extern void /*void*/ SteamGameServer_RunCallbacks(); [DllImportAttribute( "libsteam_api64.so" )] internal static extern void /*void*/ SteamGameServer_RunCallbacks();
[DllImportAttribute( "libsteam_api64.so" )] internal static extern void /*void*/ SteamAPI_RegisterCallback( IntPtr /*void **/ pCallback, int /*int*/ callback ); [DllImportAttribute( "libsteam_api64.so" )] internal static extern void /*void*/ SteamAPI_RegisterCallback( IntPtr /*void **/ pCallback, int /*int*/ callback );
[DllImportAttribute( "libsteam_api64.so" )] internal static extern void /*void*/ SteamAPI_UnregisterCallback( IntPtr /*void **/ pCallback ); [DllImportAttribute( "libsteam_api64.so" )] internal static extern void /*void*/ SteamAPI_UnregisterCallback( IntPtr /*void **/ pCallback );
[DllImportAttribute( "libsteam_api64.so" )] internal static extern void /*void*/ SteamAPI_RegisterCallResult( IntPtr /*void **/ pCallback, ulong callback );
[DllImportAttribute( "libsteam_api64.so" )] internal static extern void /*void*/ SteamAPI_UnregisterCallResult( IntPtr /*void **/ pCallback, ulong callback );
[DllImportAttribute( "libsteam_api64.so" )] internal static extern bool /*bool*/ SteamInternal_GameServer_Init( uint /*uint32*/ unIP, ushort /*uint16*/ usPort, ushort /*uint16*/ usGamePort, ushort /*uint16*/ usQueryPort, int /*int*/ eServerMode, string /*const char **/ pchVersionString ); [DllImportAttribute( "libsteam_api64.so" )] internal static extern bool /*bool*/ SteamInternal_GameServer_Init( uint /*uint32*/ unIP, ushort /*uint16*/ usPort, ushort /*uint16*/ usGamePort, ushort /*uint16*/ usQueryPort, int /*int*/ eServerMode, string /*const char **/ pchVersionString );
[DllImportAttribute( "libsteam_api64.so" )] internal static extern void /*void*/ SteamAPI_Shutdown(); [DllImportAttribute( "libsteam_api64.so" )] internal static extern void /*void*/ SteamAPI_Shutdown();
[DllImportAttribute( "libsteam_api64.so" )] internal static extern void /*void*/ SteamGameServer_Shutdown(); [DllImportAttribute( "libsteam_api64.so" )] internal static extern void /*void*/ SteamGameServer_Shutdown();

View File

@ -3978,6 +3978,14 @@ public virtual IntPtr ISteamApps_GetLaunchQueryParam( string /*const char **/ pc
{ {
Native.SteamAPI_UnregisterCallback(pCallback); Native.SteamAPI_UnregisterCallback(pCallback);
} }
public virtual void /*void*/ SteamApi_SteamAPI_RegisterCallResult( IntPtr /*void **/ pCallback, ulong callback )
{
Native.SteamAPI_RegisterCallResult(pCallback, callback);
}
public virtual void /*void*/ SteamApi_SteamAPI_UnregisterCallResult( IntPtr /*void **/ pCallback, ulong callback )
{
Native.SteamAPI_UnregisterCallResult(pCallback, callback);
}
public virtual bool /*bool*/ SteamApi_SteamInternal_GameServer_Init( uint /*uint32*/ unIP, ushort /*uint16*/ usPort, ushort /*uint16*/ usGamePort, ushort /*uint16*/ usQueryPort, int /*int*/ eServerMode, string /*const char **/ pchVersionString ) public virtual bool /*bool*/ SteamApi_SteamInternal_GameServer_Init( uint /*uint32*/ unIP, ushort /*uint16*/ usPort, ushort /*uint16*/ usGamePort, ushort /*uint16*/ usQueryPort, int /*int*/ eServerMode, string /*const char **/ pchVersionString )
{ {
return Native.SteamInternal_GameServer_Init(unIP, usPort, usGamePort, usQueryPort, eServerMode, pchVersionString); return Native.SteamInternal_GameServer_Init(unIP, usPort, usGamePort, usQueryPort, eServerMode, pchVersionString);
@ -4759,6 +4767,8 @@ internal static unsafe class Native
[DllImportAttribute( "libsteam_api.dylib" )] internal static extern void /*void*/ SteamGameServer_RunCallbacks(); [DllImportAttribute( "libsteam_api.dylib" )] internal static extern void /*void*/ SteamGameServer_RunCallbacks();
[DllImportAttribute( "libsteam_api.dylib" )] internal static extern void /*void*/ SteamAPI_RegisterCallback( IntPtr /*void **/ pCallback, int /*int*/ callback ); [DllImportAttribute( "libsteam_api.dylib" )] internal static extern void /*void*/ SteamAPI_RegisterCallback( IntPtr /*void **/ pCallback, int /*int*/ callback );
[DllImportAttribute( "libsteam_api.dylib" )] internal static extern void /*void*/ SteamAPI_UnregisterCallback( IntPtr /*void **/ pCallback ); [DllImportAttribute( "libsteam_api.dylib" )] internal static extern void /*void*/ SteamAPI_UnregisterCallback( IntPtr /*void **/ pCallback );
[DllImportAttribute( "libsteam_api.dylib" )] internal static extern void /*void*/ SteamAPI_RegisterCallResult( IntPtr /*void **/ pCallback, ulong callback );
[DllImportAttribute( "libsteam_api.dylib" )] internal static extern void /*void*/ SteamAPI_UnregisterCallResult( IntPtr /*void **/ pCallback, ulong callback );
[DllImportAttribute( "libsteam_api.dylib" )] internal static extern bool /*bool*/ SteamInternal_GameServer_Init( uint /*uint32*/ unIP, ushort /*uint16*/ usPort, ushort /*uint16*/ usGamePort, ushort /*uint16*/ usQueryPort, int /*int*/ eServerMode, string /*const char **/ pchVersionString ); [DllImportAttribute( "libsteam_api.dylib" )] internal static extern bool /*bool*/ SteamInternal_GameServer_Init( uint /*uint32*/ unIP, ushort /*uint16*/ usPort, ushort /*uint16*/ usGamePort, ushort /*uint16*/ usQueryPort, int /*int*/ eServerMode, string /*const char **/ pchVersionString );
[DllImportAttribute( "libsteam_api.dylib" )] internal static extern void /*void*/ SteamAPI_Shutdown(); [DllImportAttribute( "libsteam_api.dylib" )] internal static extern void /*void*/ SteamAPI_Shutdown();
[DllImportAttribute( "libsteam_api.dylib" )] internal static extern void /*void*/ SteamGameServer_Shutdown(); [DllImportAttribute( "libsteam_api.dylib" )] internal static extern void /*void*/ SteamGameServer_Shutdown();

View File

@ -3944,6 +3944,14 @@ public virtual IntPtr ISteamApps_GetLaunchQueryParam( string /*const char **/ pc
{ {
Native.SteamAPI_UnregisterCallback(pCallback); Native.SteamAPI_UnregisterCallback(pCallback);
} }
public virtual void /*void*/ SteamApi_SteamAPI_RegisterCallResult( IntPtr /*void **/ pCallback, ulong callback )
{
Native.SteamAPI_RegisterCallResult(pCallback, callback);
}
public virtual void /*void*/ SteamApi_SteamAPI_UnregisterCallResult( IntPtr /*void **/ pCallback, ulong callback )
{
Native.SteamAPI_UnregisterCallResult(pCallback, callback);
}
public virtual bool /*bool*/ SteamApi_SteamInternal_GameServer_Init( uint /*uint32*/ unIP, ushort /*uint16*/ usPort, ushort /*uint16*/ usGamePort, ushort /*uint16*/ usQueryPort, int /*int*/ eServerMode, string /*const char **/ pchVersionString ) public virtual bool /*bool*/ SteamApi_SteamInternal_GameServer_Init( uint /*uint32*/ unIP, ushort /*uint16*/ usPort, ushort /*uint16*/ usGamePort, ushort /*uint16*/ usQueryPort, int /*int*/ eServerMode, string /*const char **/ pchVersionString )
{ {
return Native.SteamInternal_GameServer_Init(unIP, usPort, usGamePort, usQueryPort, eServerMode, pchVersionString); return Native.SteamInternal_GameServer_Init(unIP, usPort, usGamePort, usQueryPort, eServerMode, pchVersionString);
@ -4725,6 +4733,8 @@ internal static unsafe class Native
[DllImportAttribute( "steam_api.dll" )] internal static extern void /*void*/ SteamGameServer_RunCallbacks(); [DllImportAttribute( "steam_api.dll" )] internal static extern void /*void*/ SteamGameServer_RunCallbacks();
[DllImportAttribute( "steam_api.dll" )] internal static extern void /*void*/ SteamAPI_RegisterCallback( IntPtr /*void **/ pCallback, int /*int*/ callback ); [DllImportAttribute( "steam_api.dll" )] internal static extern void /*void*/ SteamAPI_RegisterCallback( IntPtr /*void **/ pCallback, int /*int*/ callback );
[DllImportAttribute( "steam_api.dll" )] internal static extern void /*void*/ SteamAPI_UnregisterCallback( IntPtr /*void **/ pCallback ); [DllImportAttribute( "steam_api.dll" )] internal static extern void /*void*/ SteamAPI_UnregisterCallback( IntPtr /*void **/ pCallback );
[DllImportAttribute( "steam_api.dll" )] internal static extern void /*void*/ SteamAPI_RegisterCallResult( IntPtr /*void **/ pCallback, ulong callback );
[DllImportAttribute( "steam_api.dll" )] internal static extern void /*void*/ SteamAPI_UnregisterCallResult( IntPtr /*void **/ pCallback, ulong callback );
[DllImportAttribute( "steam_api.dll" )] internal static extern bool /*bool*/ SteamInternal_GameServer_Init( uint /*uint32*/ unIP, ushort /*uint16*/ usPort, ushort /*uint16*/ usGamePort, ushort /*uint16*/ usQueryPort, int /*int*/ eServerMode, string /*const char **/ pchVersionString ); [DllImportAttribute( "steam_api.dll" )] internal static extern bool /*bool*/ SteamInternal_GameServer_Init( uint /*uint32*/ unIP, ushort /*uint16*/ usPort, ushort /*uint16*/ usGamePort, ushort /*uint16*/ usQueryPort, int /*int*/ eServerMode, string /*const char **/ pchVersionString );
[DllImportAttribute( "steam_api.dll" )] internal static extern void /*void*/ SteamAPI_Shutdown(); [DllImportAttribute( "steam_api.dll" )] internal static extern void /*void*/ SteamAPI_Shutdown();
[DllImportAttribute( "steam_api.dll" )] internal static extern void /*void*/ SteamGameServer_Shutdown(); [DllImportAttribute( "steam_api.dll" )] internal static extern void /*void*/ SteamGameServer_Shutdown();

View File

@ -3944,6 +3944,14 @@ public virtual IntPtr ISteamApps_GetLaunchQueryParam( string /*const char **/ pc
{ {
Native.SteamAPI_UnregisterCallback(pCallback); Native.SteamAPI_UnregisterCallback(pCallback);
} }
public virtual void /*void*/ SteamApi_SteamAPI_RegisterCallResult( IntPtr /*void **/ pCallback, ulong callback )
{
Native.SteamAPI_RegisterCallResult(pCallback, callback);
}
public virtual void /*void*/ SteamApi_SteamAPI_UnregisterCallResult( IntPtr /*void **/ pCallback, ulong callback )
{
Native.SteamAPI_UnregisterCallResult(pCallback, callback);
}
public virtual bool /*bool*/ SteamApi_SteamInternal_GameServer_Init( uint /*uint32*/ unIP, ushort /*uint16*/ usPort, ushort /*uint16*/ usGamePort, ushort /*uint16*/ usQueryPort, int /*int*/ eServerMode, string /*const char **/ pchVersionString ) public virtual bool /*bool*/ SteamApi_SteamInternal_GameServer_Init( uint /*uint32*/ unIP, ushort /*uint16*/ usPort, ushort /*uint16*/ usGamePort, ushort /*uint16*/ usQueryPort, int /*int*/ eServerMode, string /*const char **/ pchVersionString )
{ {
return Native.SteamInternal_GameServer_Init(unIP, usPort, usGamePort, usQueryPort, eServerMode, pchVersionString); return Native.SteamInternal_GameServer_Init(unIP, usPort, usGamePort, usQueryPort, eServerMode, pchVersionString);
@ -4725,6 +4733,8 @@ internal static unsafe class Native
[DllImportAttribute( "steam_api64.dll" )] internal static extern void /*void*/ SteamGameServer_RunCallbacks(); [DllImportAttribute( "steam_api64.dll" )] internal static extern void /*void*/ SteamGameServer_RunCallbacks();
[DllImportAttribute( "steam_api64.dll" )] internal static extern void /*void*/ SteamAPI_RegisterCallback( IntPtr /*void **/ pCallback, int /*int*/ callback ); [DllImportAttribute( "steam_api64.dll" )] internal static extern void /*void*/ SteamAPI_RegisterCallback( IntPtr /*void **/ pCallback, int /*int*/ callback );
[DllImportAttribute( "steam_api64.dll" )] internal static extern void /*void*/ SteamAPI_UnregisterCallback( IntPtr /*void **/ pCallback ); [DllImportAttribute( "steam_api64.dll" )] internal static extern void /*void*/ SteamAPI_UnregisterCallback( IntPtr /*void **/ pCallback );
[DllImportAttribute( "steam_api64.dll" )] internal static extern void /*void*/ SteamAPI_RegisterCallResult( IntPtr /*void **/ pCallback, ulong callback );
[DllImportAttribute( "steam_api64.dll" )] internal static extern void /*void*/ SteamAPI_UnregisterCallResult( IntPtr /*void **/ pCallback, ulong callback );
[DllImportAttribute( "steam_api64.dll" )] internal static extern bool /*bool*/ SteamInternal_GameServer_Init( uint /*uint32*/ unIP, ushort /*uint16*/ usPort, ushort /*uint16*/ usGamePort, ushort /*uint16*/ usQueryPort, int /*int*/ eServerMode, string /*const char **/ pchVersionString ); [DllImportAttribute( "steam_api64.dll" )] internal static extern bool /*bool*/ SteamInternal_GameServer_Init( uint /*uint32*/ unIP, ushort /*uint16*/ usPort, ushort /*uint16*/ usGamePort, ushort /*uint16*/ usQueryPort, int /*int*/ eServerMode, string /*const char **/ pchVersionString );
[DllImportAttribute( "steam_api64.dll" )] internal static extern void /*void*/ SteamAPI_Shutdown(); [DllImportAttribute( "steam_api64.dll" )] internal static extern void /*void*/ SteamAPI_Shutdown();
[DllImportAttribute( "steam_api64.dll" )] internal static extern void /*void*/ SteamGameServer_Shutdown(); [DllImportAttribute( "steam_api64.dll" )] internal static extern void /*void*/ SteamGameServer_Shutdown();

View File

@ -3,118 +3,133 @@
namespace SteamNative namespace SteamNative
{ {
public unsafe class SteamApi : IDisposable internal unsafe class SteamApi : IDisposable
{ {
// //
// Holds a platform specific implentation // Holds a platform specific implentation
// //
internal Platform.Interface _pi; internal Platform.Interface platform;
internal Facepunch.Steamworks.BaseSteamworks steamworks;
// //
// Constructor decides which implementation to use based on current platform // Constructor decides which implementation to use based on current platform
// //
public SteamApi( IntPtr pointer ) public SteamApi( Facepunch.Steamworks.BaseSteamworks steamworks, IntPtr pointer )
{ {
if ( Platform.IsWindows64 ) _pi = new Platform.Win64( pointer ); this.steamworks = steamworks;
else if ( Platform.IsWindows32 ) _pi = new Platform.Win32( pointer );
else if ( Platform.IsLinux32 ) _pi = new Platform.Linux32( pointer ); if ( Platform.IsWindows64 ) platform = new Platform.Win64( pointer );
else if ( Platform.IsLinux64 ) _pi = new Platform.Linux64( pointer ); else if ( Platform.IsWindows32 ) platform = new Platform.Win32( pointer );
else if ( Platform.IsOsx ) _pi = new Platform.Mac( pointer ); else if ( Platform.IsLinux32 ) platform = new Platform.Linux32( pointer );
else if ( Platform.IsLinux64 ) platform = new Platform.Linux64( pointer );
else if ( Platform.IsOsx ) platform = new Platform.Mac( pointer );
} }
// //
// Class is invalid if we don't have a valid implementation // Class is invalid if we don't have a valid implementation
// //
public bool IsValid{ get{ return _pi != null && _pi.IsValid; } } public bool IsValid{ get{ return platform != null && platform.IsValid; } }
// //
// When shutting down clear all the internals to avoid accidental use // When shutting down clear all the internals to avoid accidental use
// //
public virtual void Dispose() public virtual void Dispose()
{ {
if ( _pi != null ) if ( platform != null )
{ {
_pi.Dispose(); platform.Dispose();
_pi = null; platform = null;
} }
} }
// HSteamPipe // HSteamPipe
public HSteamPipe SteamAPI_GetHSteamPipe() public HSteamPipe SteamAPI_GetHSteamPipe()
{ {
return _pi.SteamApi_SteamAPI_GetHSteamPipe(); return platform.SteamApi_SteamAPI_GetHSteamPipe();
} }
// HSteamUser // HSteamUser
public HSteamUser SteamAPI_GetHSteamUser() public HSteamUser SteamAPI_GetHSteamUser()
{ {
return _pi.SteamApi_SteamAPI_GetHSteamUser(); return platform.SteamApi_SteamAPI_GetHSteamUser();
} }
// bool // bool
public bool SteamAPI_Init() public bool SteamAPI_Init()
{ {
return _pi.SteamApi_SteamAPI_Init(); return platform.SteamApi_SteamAPI_Init();
} }
// void // void
public void SteamAPI_RegisterCallback( IntPtr pCallback /*void **/, int callback /*int*/ ) public void SteamAPI_RegisterCallback( IntPtr pCallback /*void **/, int callback /*int*/ )
{ {
_pi.SteamApi_SteamAPI_RegisterCallback( (IntPtr) pCallback, callback ); platform.SteamApi_SteamAPI_RegisterCallback( (IntPtr) pCallback, callback );
}
// void
public void SteamAPI_RegisterCallResult( IntPtr pCallback /*void **/, SteamAPICall_t callback /*SteamAPICall_t*/ )
{
platform.SteamApi_SteamAPI_RegisterCallResult( (IntPtr) pCallback, callback.Value );
} }
// void // void
public void SteamAPI_RunCallbacks() public void SteamAPI_RunCallbacks()
{ {
_pi.SteamApi_SteamAPI_RunCallbacks(); platform.SteamApi_SteamAPI_RunCallbacks();
} }
// void // void
public void SteamAPI_Shutdown() public void SteamAPI_Shutdown()
{ {
_pi.SteamApi_SteamAPI_Shutdown(); platform.SteamApi_SteamAPI_Shutdown();
} }
// void // void
public void SteamAPI_UnregisterCallback( IntPtr pCallback /*void **/ ) public void SteamAPI_UnregisterCallback( IntPtr pCallback /*void **/ )
{ {
_pi.SteamApi_SteamAPI_UnregisterCallback( (IntPtr) pCallback ); platform.SteamApi_SteamAPI_UnregisterCallback( (IntPtr) pCallback );
}
// void
public void SteamAPI_UnregisterCallResult( IntPtr pCallback /*void **/, SteamAPICall_t callback /*SteamAPICall_t*/ )
{
platform.SteamApi_SteamAPI_UnregisterCallResult( (IntPtr) pCallback, callback.Value );
} }
// HSteamPipe // HSteamPipe
public HSteamPipe SteamGameServer_GetHSteamPipe() public HSteamPipe SteamGameServer_GetHSteamPipe()
{ {
return _pi.SteamApi_SteamGameServer_GetHSteamPipe(); return platform.SteamApi_SteamGameServer_GetHSteamPipe();
} }
// HSteamUser // HSteamUser
public HSteamUser SteamGameServer_GetHSteamUser() public HSteamUser SteamGameServer_GetHSteamUser()
{ {
return _pi.SteamApi_SteamGameServer_GetHSteamUser(); return platform.SteamApi_SteamGameServer_GetHSteamUser();
} }
// void // void
public void SteamGameServer_RunCallbacks() public void SteamGameServer_RunCallbacks()
{ {
_pi.SteamApi_SteamGameServer_RunCallbacks(); platform.SteamApi_SteamGameServer_RunCallbacks();
} }
// void // void
public void SteamGameServer_Shutdown() public void SteamGameServer_Shutdown()
{ {
_pi.SteamApi_SteamGameServer_Shutdown(); platform.SteamApi_SteamGameServer_Shutdown();
} }
// IntPtr // IntPtr
public IntPtr SteamInternal_CreateInterface( string version /*const char **/ ) public IntPtr SteamInternal_CreateInterface( string version /*const char **/ )
{ {
return _pi.SteamApi_SteamInternal_CreateInterface( version ); return platform.SteamApi_SteamInternal_CreateInterface( version );
} }
// bool // bool
public bool SteamInternal_GameServer_Init( uint unIP /*uint32*/, ushort usPort /*uint16*/, ushort usGamePort /*uint16*/, ushort usQueryPort /*uint16*/, int eServerMode /*int*/, string pchVersionString /*const char **/ ) public bool SteamInternal_GameServer_Init( uint unIP /*uint32*/, ushort usPort /*uint16*/, ushort usGamePort /*uint16*/, ushort usQueryPort /*uint16*/, int eServerMode /*int*/, string pchVersionString /*const char **/ )
{ {
return _pi.SteamApi_SteamInternal_GameServer_Init( unIP, usPort, usGamePort, usQueryPort, eServerMode, pchVersionString ); return platform.SteamApi_SteamInternal_GameServer_Init( unIP, usPort, usGamePort, usQueryPort, eServerMode, pchVersionString );
} }
} }

View File

@ -3,46 +3,49 @@
namespace SteamNative namespace SteamNative
{ {
public unsafe class SteamAppList : IDisposable internal unsafe class SteamAppList : IDisposable
{ {
// //
// Holds a platform specific implentation // Holds a platform specific implentation
// //
internal Platform.Interface _pi; internal Platform.Interface platform;
internal Facepunch.Steamworks.BaseSteamworks steamworks;
// //
// Constructor decides which implementation to use based on current platform // Constructor decides which implementation to use based on current platform
// //
public SteamAppList( IntPtr pointer ) public SteamAppList( Facepunch.Steamworks.BaseSteamworks steamworks, IntPtr pointer )
{ {
if ( Platform.IsWindows64 ) _pi = new Platform.Win64( pointer ); this.steamworks = steamworks;
else if ( Platform.IsWindows32 ) _pi = new Platform.Win32( pointer );
else if ( Platform.IsLinux32 ) _pi = new Platform.Linux32( pointer ); if ( Platform.IsWindows64 ) platform = new Platform.Win64( pointer );
else if ( Platform.IsLinux64 ) _pi = new Platform.Linux64( pointer ); else if ( Platform.IsWindows32 ) platform = new Platform.Win32( pointer );
else if ( Platform.IsOsx ) _pi = new Platform.Mac( pointer ); else if ( Platform.IsLinux32 ) platform = new Platform.Linux32( pointer );
else if ( Platform.IsLinux64 ) platform = new Platform.Linux64( pointer );
else if ( Platform.IsOsx ) platform = new Platform.Mac( pointer );
} }
// //
// Class is invalid if we don't have a valid implementation // Class is invalid if we don't have a valid implementation
// //
public bool IsValid{ get{ return _pi != null && _pi.IsValid; } } public bool IsValid{ get{ return platform != null && platform.IsValid; } }
// //
// When shutting down clear all the internals to avoid accidental use // When shutting down clear all the internals to avoid accidental use
// //
public virtual void Dispose() public virtual void Dispose()
{ {
if ( _pi != null ) if ( platform != null )
{ {
_pi.Dispose(); platform.Dispose();
_pi = null; platform = null;
} }
} }
// int // int
public int GetAppBuildId( AppId_t nAppID /*AppId_t*/ ) public int GetAppBuildId( AppId_t nAppID /*AppId_t*/ )
{ {
return _pi.ISteamAppList_GetAppBuildId( nAppID.Value ); return platform.ISteamAppList_GetAppBuildId( nAppID.Value );
} }
// int // int
@ -52,7 +55,7 @@ public string GetAppInstallDir( AppId_t nAppID /*AppId_t*/ )
int bSuccess = default( int ); int bSuccess = default( int );
System.Text.StringBuilder pchDirectory_sb = new System.Text.StringBuilder( 4096 ); System.Text.StringBuilder pchDirectory_sb = new System.Text.StringBuilder( 4096 );
int cchNameMax = 4096; int cchNameMax = 4096;
bSuccess = _pi.ISteamAppList_GetAppInstallDir( nAppID.Value, pchDirectory_sb, cchNameMax ); bSuccess = platform.ISteamAppList_GetAppInstallDir( nAppID.Value, pchDirectory_sb, cchNameMax );
if ( bSuccess <= 0 ) return null; if ( bSuccess <= 0 ) return null;
return pchDirectory_sb.ToString(); return pchDirectory_sb.ToString();
} }
@ -64,7 +67,7 @@ public string GetAppName( AppId_t nAppID /*AppId_t*/ )
int bSuccess = default( int ); int bSuccess = default( int );
System.Text.StringBuilder pchName_sb = new System.Text.StringBuilder( 4096 ); System.Text.StringBuilder pchName_sb = new System.Text.StringBuilder( 4096 );
int cchNameMax = 4096; int cchNameMax = 4096;
bSuccess = _pi.ISteamAppList_GetAppName( nAppID.Value, pchName_sb, cchNameMax ); bSuccess = platform.ISteamAppList_GetAppName( nAppID.Value, pchName_sb, cchNameMax );
if ( bSuccess <= 0 ) return null; if ( bSuccess <= 0 ) return null;
return pchName_sb.ToString(); return pchName_sb.ToString();
} }
@ -76,14 +79,14 @@ public uint GetInstalledApps( AppId_t[] pvecAppID /*AppId_t **/ )
var unMaxAppIDs = (uint) pvecAppID.Length; var unMaxAppIDs = (uint) pvecAppID.Length;
fixed ( AppId_t* pvecAppID_ptr = pvecAppID ) fixed ( AppId_t* pvecAppID_ptr = pvecAppID )
{ {
return _pi.ISteamAppList_GetInstalledApps( (IntPtr) pvecAppID_ptr, unMaxAppIDs ); return platform.ISteamAppList_GetInstalledApps( (IntPtr) pvecAppID_ptr, unMaxAppIDs );
} }
} }
// uint // uint
public uint GetNumInstalledApps() public uint GetNumInstalledApps()
{ {
return _pi.ISteamAppList_GetNumInstalledApps(); return platform.ISteamAppList_GetNumInstalledApps();
} }
} }

View File

@ -3,39 +3,42 @@
namespace SteamNative namespace SteamNative
{ {
public unsafe class SteamApps : IDisposable internal unsafe class SteamApps : IDisposable
{ {
// //
// Holds a platform specific implentation // Holds a platform specific implentation
// //
internal Platform.Interface _pi; internal Platform.Interface platform;
internal Facepunch.Steamworks.BaseSteamworks steamworks;
// //
// Constructor decides which implementation to use based on current platform // Constructor decides which implementation to use based on current platform
// //
public SteamApps( IntPtr pointer ) public SteamApps( Facepunch.Steamworks.BaseSteamworks steamworks, IntPtr pointer )
{ {
if ( Platform.IsWindows64 ) _pi = new Platform.Win64( pointer ); this.steamworks = steamworks;
else if ( Platform.IsWindows32 ) _pi = new Platform.Win32( pointer );
else if ( Platform.IsLinux32 ) _pi = new Platform.Linux32( pointer ); if ( Platform.IsWindows64 ) platform = new Platform.Win64( pointer );
else if ( Platform.IsLinux64 ) _pi = new Platform.Linux64( pointer ); else if ( Platform.IsWindows32 ) platform = new Platform.Win32( pointer );
else if ( Platform.IsOsx ) _pi = new Platform.Mac( pointer ); else if ( Platform.IsLinux32 ) platform = new Platform.Linux32( pointer );
else if ( Platform.IsLinux64 ) platform = new Platform.Linux64( pointer );
else if ( Platform.IsOsx ) platform = new Platform.Mac( pointer );
} }
// //
// Class is invalid if we don't have a valid implementation // Class is invalid if we don't have a valid implementation
// //
public bool IsValid{ get{ return _pi != null && _pi.IsValid; } } public bool IsValid{ get{ return platform != null && platform.IsValid; } }
// //
// When shutting down clear all the internals to avoid accidental use // When shutting down clear all the internals to avoid accidental use
// //
public virtual void Dispose() public virtual void Dispose()
{ {
if ( _pi != null ) if ( platform != null )
{ {
_pi.Dispose(); platform.Dispose();
_pi = null; platform = null;
} }
} }
@ -47,7 +50,7 @@ public bool BGetDLCDataByIndex( int iDLC /*int*/, ref AppId_t pAppID /*AppId_t *
pchName = string.Empty; pchName = string.Empty;
System.Text.StringBuilder pchName_sb = new System.Text.StringBuilder( 4096 ); System.Text.StringBuilder pchName_sb = new System.Text.StringBuilder( 4096 );
int cchNameBufferSize = 4096; int cchNameBufferSize = 4096;
bSuccess = _pi.ISteamApps_BGetDLCDataByIndex( iDLC, ref pAppID.Value, ref pbAvailable, pchName_sb, cchNameBufferSize ); bSuccess = platform.ISteamApps_BGetDLCDataByIndex( iDLC, ref pAppID.Value, ref pbAvailable, pchName_sb, cchNameBufferSize );
if ( !bSuccess ) return bSuccess; if ( !bSuccess ) return bSuccess;
pchName = pchName_sb.ToString(); pchName = pchName_sb.ToString();
return bSuccess; return bSuccess;
@ -56,55 +59,55 @@ public bool BGetDLCDataByIndex( int iDLC /*int*/, ref AppId_t pAppID /*AppId_t *
// bool // bool
public bool BIsAppInstalled( AppId_t appID /*AppId_t*/ ) public bool BIsAppInstalled( AppId_t appID /*AppId_t*/ )
{ {
return _pi.ISteamApps_BIsAppInstalled( appID.Value ); return platform.ISteamApps_BIsAppInstalled( appID.Value );
} }
// bool // bool
public bool BIsCybercafe() public bool BIsCybercafe()
{ {
return _pi.ISteamApps_BIsCybercafe(); return platform.ISteamApps_BIsCybercafe();
} }
// bool // bool
public bool BIsDlcInstalled( AppId_t appID /*AppId_t*/ ) public bool BIsDlcInstalled( AppId_t appID /*AppId_t*/ )
{ {
return _pi.ISteamApps_BIsDlcInstalled( appID.Value ); return platform.ISteamApps_BIsDlcInstalled( appID.Value );
} }
// bool // bool
public bool BIsLowViolence() public bool BIsLowViolence()
{ {
return _pi.ISteamApps_BIsLowViolence(); return platform.ISteamApps_BIsLowViolence();
} }
// bool // bool
public bool BIsSubscribed() public bool BIsSubscribed()
{ {
return _pi.ISteamApps_BIsSubscribed(); return platform.ISteamApps_BIsSubscribed();
} }
// bool // bool
public bool BIsSubscribedApp( AppId_t appID /*AppId_t*/ ) public bool BIsSubscribedApp( AppId_t appID /*AppId_t*/ )
{ {
return _pi.ISteamApps_BIsSubscribedApp( appID.Value ); return platform.ISteamApps_BIsSubscribedApp( appID.Value );
} }
// bool // bool
public bool BIsSubscribedFromFreeWeekend() public bool BIsSubscribedFromFreeWeekend()
{ {
return _pi.ISteamApps_BIsSubscribedFromFreeWeekend(); return platform.ISteamApps_BIsSubscribedFromFreeWeekend();
} }
// bool // bool
public bool BIsVACBanned() public bool BIsVACBanned()
{ {
return _pi.ISteamApps_BIsVACBanned(); return platform.ISteamApps_BIsVACBanned();
} }
// int // int
public int GetAppBuildId() public int GetAppBuildId()
{ {
return _pi.ISteamApps_GetAppBuildId(); return platform.ISteamApps_GetAppBuildId();
} }
// uint // uint
@ -114,7 +117,7 @@ public string GetAppInstallDir( AppId_t appID /*AppId_t*/ )
uint bSuccess = default( uint ); uint bSuccess = default( uint );
System.Text.StringBuilder pchFolder_sb = new System.Text.StringBuilder( 4096 ); System.Text.StringBuilder pchFolder_sb = new System.Text.StringBuilder( 4096 );
uint cchFolderBufferSize = 4096; uint cchFolderBufferSize = 4096;
bSuccess = _pi.ISteamApps_GetAppInstallDir( appID.Value, pchFolder_sb, cchFolderBufferSize ); bSuccess = platform.ISteamApps_GetAppInstallDir( appID.Value, pchFolder_sb, cchFolderBufferSize );
if ( bSuccess <= 0 ) return null; if ( bSuccess <= 0 ) return null;
return pchFolder_sb.ToString(); return pchFolder_sb.ToString();
} }
@ -122,7 +125,7 @@ public string GetAppInstallDir( AppId_t appID /*AppId_t*/ )
// ulong // ulong
public ulong GetAppOwner() public ulong GetAppOwner()
{ {
return _pi.ISteamApps_GetAppOwner(); return platform.ISteamApps_GetAppOwner();
} }
// string // string
@ -130,7 +133,7 @@ public ulong GetAppOwner()
public string GetAvailableGameLanguages() public string GetAvailableGameLanguages()
{ {
IntPtr string_pointer; IntPtr string_pointer;
string_pointer = _pi.ISteamApps_GetAvailableGameLanguages(); string_pointer = platform.ISteamApps_GetAvailableGameLanguages();
return Marshal.PtrToStringAnsi( string_pointer ); return Marshal.PtrToStringAnsi( string_pointer );
} }
@ -141,7 +144,7 @@ public string GetCurrentBetaName()
bool bSuccess = default( bool ); bool bSuccess = default( bool );
System.Text.StringBuilder pchName_sb = new System.Text.StringBuilder( 4096 ); System.Text.StringBuilder pchName_sb = new System.Text.StringBuilder( 4096 );
int cchNameBufferSize = 4096; int cchNameBufferSize = 4096;
bSuccess = _pi.ISteamApps_GetCurrentBetaName( pchName_sb, cchNameBufferSize ); bSuccess = platform.ISteamApps_GetCurrentBetaName( pchName_sb, cchNameBufferSize );
if ( !bSuccess ) return null; if ( !bSuccess ) return null;
return pchName_sb.ToString(); return pchName_sb.ToString();
} }
@ -151,38 +154,43 @@ public string GetCurrentBetaName()
public string GetCurrentGameLanguage() public string GetCurrentGameLanguage()
{ {
IntPtr string_pointer; IntPtr string_pointer;
string_pointer = _pi.ISteamApps_GetCurrentGameLanguage(); string_pointer = platform.ISteamApps_GetCurrentGameLanguage();
return Marshal.PtrToStringAnsi( string_pointer ); return Marshal.PtrToStringAnsi( string_pointer );
} }
// int // int
public int GetDLCCount() public int GetDLCCount()
{ {
return _pi.ISteamApps_GetDLCCount(); return platform.ISteamApps_GetDLCCount();
} }
// bool // bool
public bool GetDlcDownloadProgress( AppId_t nAppID /*AppId_t*/, out ulong punBytesDownloaded /*uint64 **/, out ulong punBytesTotal /*uint64 **/ ) public bool GetDlcDownloadProgress( AppId_t nAppID /*AppId_t*/, out ulong punBytesDownloaded /*uint64 **/, out ulong punBytesTotal /*uint64 **/ )
{ {
return _pi.ISteamApps_GetDlcDownloadProgress( nAppID.Value, out punBytesDownloaded, out punBytesTotal ); return platform.ISteamApps_GetDlcDownloadProgress( nAppID.Value, out punBytesDownloaded, out punBytesTotal );
} }
// uint // uint
public uint GetEarliestPurchaseUnixTime( AppId_t nAppID /*AppId_t*/ ) public uint GetEarliestPurchaseUnixTime( AppId_t nAppID /*AppId_t*/ )
{ {
return _pi.ISteamApps_GetEarliestPurchaseUnixTime( nAppID.Value ); return platform.ISteamApps_GetEarliestPurchaseUnixTime( nAppID.Value );
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t GetFileDetails( string pszFileName /*const char **/ ) public CallbackHandle GetFileDetails( string pszFileName /*const char **/, Action<FileDetailsResult_t, bool> CallbackFunction = null /*Action<FileDetailsResult_t, bool>*/ )
{ {
return _pi.ISteamApps_GetFileDetails( pszFileName ); SteamAPICall_t callback = 0;
callback = platform.ISteamApps_GetFileDetails( pszFileName );
if ( CallbackFunction == null ) return null;
return FileDetailsResult_t.CallResult( steamworks, callback, CallbackFunction );
} }
// uint // uint
public uint GetInstalledDepots( AppId_t appID /*AppId_t*/, IntPtr pvecDepots /*DepotId_t **/, uint cMaxDepots /*uint32*/ ) public uint GetInstalledDepots( AppId_t appID /*AppId_t*/, IntPtr pvecDepots /*DepotId_t **/, uint cMaxDepots /*uint32*/ )
{ {
return _pi.ISteamApps_GetInstalledDepots( appID.Value, (IntPtr) pvecDepots, cMaxDepots ); return platform.ISteamApps_GetInstalledDepots( appID.Value, (IntPtr) pvecDepots, cMaxDepots );
} }
// string // string
@ -190,38 +198,38 @@ public uint GetInstalledDepots( AppId_t appID /*AppId_t*/, IntPtr pvecDepots /*D
public string GetLaunchQueryParam( string pchKey /*const char **/ ) public string GetLaunchQueryParam( string pchKey /*const char **/ )
{ {
IntPtr string_pointer; IntPtr string_pointer;
string_pointer = _pi.ISteamApps_GetLaunchQueryParam( pchKey ); string_pointer = platform.ISteamApps_GetLaunchQueryParam( pchKey );
return Marshal.PtrToStringAnsi( string_pointer ); return Marshal.PtrToStringAnsi( string_pointer );
} }
// void // void
public void InstallDLC( AppId_t nAppID /*AppId_t*/ ) public void InstallDLC( AppId_t nAppID /*AppId_t*/ )
{ {
_pi.ISteamApps_InstallDLC( nAppID.Value ); platform.ISteamApps_InstallDLC( nAppID.Value );
} }
// bool // bool
public bool MarkContentCorrupt( bool bMissingFilesOnly /*bool*/ ) public bool MarkContentCorrupt( bool bMissingFilesOnly /*bool*/ )
{ {
return _pi.ISteamApps_MarkContentCorrupt( bMissingFilesOnly ); return platform.ISteamApps_MarkContentCorrupt( bMissingFilesOnly );
} }
// void // void
public void RequestAllProofOfPurchaseKeys() public void RequestAllProofOfPurchaseKeys()
{ {
_pi.ISteamApps_RequestAllProofOfPurchaseKeys(); platform.ISteamApps_RequestAllProofOfPurchaseKeys();
} }
// void // void
public void RequestAppProofOfPurchaseKey( AppId_t nAppID /*AppId_t*/ ) public void RequestAppProofOfPurchaseKey( AppId_t nAppID /*AppId_t*/ )
{ {
_pi.ISteamApps_RequestAppProofOfPurchaseKey( nAppID.Value ); platform.ISteamApps_RequestAppProofOfPurchaseKey( nAppID.Value );
} }
// void // void
public void UninstallDLC( AppId_t nAppID /*AppId_t*/ ) public void UninstallDLC( AppId_t nAppID /*AppId_t*/ )
{ {
_pi.ISteamApps_UninstallDLC( nAppID.Value ); platform.ISteamApps_UninstallDLC( nAppID.Value );
} }
} }

View File

@ -3,276 +3,279 @@
namespace SteamNative namespace SteamNative
{ {
public unsafe class SteamClient : IDisposable internal unsafe class SteamClient : IDisposable
{ {
// //
// Holds a platform specific implentation // Holds a platform specific implentation
// //
internal Platform.Interface _pi; internal Platform.Interface platform;
internal Facepunch.Steamworks.BaseSteamworks steamworks;
// //
// Constructor decides which implementation to use based on current platform // Constructor decides which implementation to use based on current platform
// //
public SteamClient( IntPtr pointer ) public SteamClient( Facepunch.Steamworks.BaseSteamworks steamworks, IntPtr pointer )
{ {
if ( Platform.IsWindows64 ) _pi = new Platform.Win64( pointer ); this.steamworks = steamworks;
else if ( Platform.IsWindows32 ) _pi = new Platform.Win32( pointer );
else if ( Platform.IsLinux32 ) _pi = new Platform.Linux32( pointer ); if ( Platform.IsWindows64 ) platform = new Platform.Win64( pointer );
else if ( Platform.IsLinux64 ) _pi = new Platform.Linux64( pointer ); else if ( Platform.IsWindows32 ) platform = new Platform.Win32( pointer );
else if ( Platform.IsOsx ) _pi = new Platform.Mac( pointer ); else if ( Platform.IsLinux32 ) platform = new Platform.Linux32( pointer );
else if ( Platform.IsLinux64 ) platform = new Platform.Linux64( pointer );
else if ( Platform.IsOsx ) platform = new Platform.Mac( pointer );
} }
// //
// Class is invalid if we don't have a valid implementation // Class is invalid if we don't have a valid implementation
// //
public bool IsValid{ get{ return _pi != null && _pi.IsValid; } } public bool IsValid{ get{ return platform != null && platform.IsValid; } }
// //
// When shutting down clear all the internals to avoid accidental use // When shutting down clear all the internals to avoid accidental use
// //
public virtual void Dispose() public virtual void Dispose()
{ {
if ( _pi != null ) if ( platform != null )
{ {
_pi.Dispose(); platform.Dispose();
_pi = null; platform = null;
} }
} }
// bool // bool
public bool BReleaseSteamPipe( HSteamPipe hSteamPipe /*HSteamPipe*/ ) public bool BReleaseSteamPipe( HSteamPipe hSteamPipe /*HSteamPipe*/ )
{ {
return _pi.ISteamClient_BReleaseSteamPipe( hSteamPipe.Value ); return platform.ISteamClient_BReleaseSteamPipe( hSteamPipe.Value );
} }
// bool // bool
public bool BShutdownIfAllPipesClosed() public bool BShutdownIfAllPipesClosed()
{ {
return _pi.ISteamClient_BShutdownIfAllPipesClosed(); return platform.ISteamClient_BShutdownIfAllPipesClosed();
} }
// HSteamUser // HSteamUser
public HSteamUser ConnectToGlobalUser( HSteamPipe hSteamPipe /*HSteamPipe*/ ) public HSteamUser ConnectToGlobalUser( HSteamPipe hSteamPipe /*HSteamPipe*/ )
{ {
return _pi.ISteamClient_ConnectToGlobalUser( hSteamPipe.Value ); return platform.ISteamClient_ConnectToGlobalUser( hSteamPipe.Value );
} }
// HSteamUser // HSteamUser
public HSteamUser CreateLocalUser( out HSteamPipe phSteamPipe /*HSteamPipe **/, AccountType eAccountType /*EAccountType*/ ) public HSteamUser CreateLocalUser( out HSteamPipe phSteamPipe /*HSteamPipe **/, AccountType eAccountType /*EAccountType*/ )
{ {
return _pi.ISteamClient_CreateLocalUser( out phSteamPipe.Value, eAccountType ); return platform.ISteamClient_CreateLocalUser( out phSteamPipe.Value, eAccountType );
} }
// HSteamPipe // HSteamPipe
public HSteamPipe CreateSteamPipe() public HSteamPipe CreateSteamPipe()
{ {
return _pi.ISteamClient_CreateSteamPipe(); return platform.ISteamClient_CreateSteamPipe();
} }
// uint // uint
public uint GetIPCCallCount() public uint GetIPCCallCount()
{ {
return _pi.ISteamClient_GetIPCCallCount(); return platform.ISteamClient_GetIPCCallCount();
} }
// ISteamAppList * // ISteamAppList *
public SteamAppList GetISteamAppList( HSteamUser hSteamUser /*HSteamUser*/, HSteamPipe hSteamPipe /*HSteamPipe*/, string pchVersion /*const char **/ ) public SteamAppList GetISteamAppList( HSteamUser hSteamUser /*HSteamUser*/, HSteamPipe hSteamPipe /*HSteamPipe*/, string pchVersion /*const char **/ )
{ {
IntPtr interface_pointer; IntPtr interface_pointer;
interface_pointer = _pi.ISteamClient_GetISteamAppList( hSteamUser.Value, hSteamPipe.Value, pchVersion ); interface_pointer = platform.ISteamClient_GetISteamAppList( hSteamUser.Value, hSteamPipe.Value, pchVersion );
return new SteamAppList( interface_pointer ); return new SteamAppList( steamworks, interface_pointer );
} }
// ISteamApps * // ISteamApps *
public SteamApps GetISteamApps( HSteamUser hSteamUser /*HSteamUser*/, HSteamPipe hSteamPipe /*HSteamPipe*/, string pchVersion /*const char **/ ) public SteamApps GetISteamApps( HSteamUser hSteamUser /*HSteamUser*/, HSteamPipe hSteamPipe /*HSteamPipe*/, string pchVersion /*const char **/ )
{ {
IntPtr interface_pointer; IntPtr interface_pointer;
interface_pointer = _pi.ISteamClient_GetISteamApps( hSteamUser.Value, hSteamPipe.Value, pchVersion ); interface_pointer = platform.ISteamClient_GetISteamApps( hSteamUser.Value, hSteamPipe.Value, pchVersion );
return new SteamApps( interface_pointer ); return new SteamApps( steamworks, interface_pointer );
} }
// ISteamController * // ISteamController *
public SteamController GetISteamController( HSteamUser hSteamUser /*HSteamUser*/, HSteamPipe hSteamPipe /*HSteamPipe*/, string pchVersion /*const char **/ ) public SteamController GetISteamController( HSteamUser hSteamUser /*HSteamUser*/, HSteamPipe hSteamPipe /*HSteamPipe*/, string pchVersion /*const char **/ )
{ {
IntPtr interface_pointer; IntPtr interface_pointer;
interface_pointer = _pi.ISteamClient_GetISteamController( hSteamUser.Value, hSteamPipe.Value, pchVersion ); interface_pointer = platform.ISteamClient_GetISteamController( hSteamUser.Value, hSteamPipe.Value, pchVersion );
return new SteamController( interface_pointer ); return new SteamController( steamworks, interface_pointer );
} }
// ISteamFriends * // ISteamFriends *
public SteamFriends GetISteamFriends( HSteamUser hSteamUser /*HSteamUser*/, HSteamPipe hSteamPipe /*HSteamPipe*/, string pchVersion /*const char **/ ) public SteamFriends GetISteamFriends( HSteamUser hSteamUser /*HSteamUser*/, HSteamPipe hSteamPipe /*HSteamPipe*/, string pchVersion /*const char **/ )
{ {
IntPtr interface_pointer; IntPtr interface_pointer;
interface_pointer = _pi.ISteamClient_GetISteamFriends( hSteamUser.Value, hSteamPipe.Value, pchVersion ); interface_pointer = platform.ISteamClient_GetISteamFriends( hSteamUser.Value, hSteamPipe.Value, pchVersion );
return new SteamFriends( interface_pointer ); return new SteamFriends( steamworks, interface_pointer );
} }
// ISteamGameServer * // ISteamGameServer *
public SteamGameServer GetISteamGameServer( HSteamUser hSteamUser /*HSteamUser*/, HSteamPipe hSteamPipe /*HSteamPipe*/, string pchVersion /*const char **/ ) public SteamGameServer GetISteamGameServer( HSteamUser hSteamUser /*HSteamUser*/, HSteamPipe hSteamPipe /*HSteamPipe*/, string pchVersion /*const char **/ )
{ {
IntPtr interface_pointer; IntPtr interface_pointer;
interface_pointer = _pi.ISteamClient_GetISteamGameServer( hSteamUser.Value, hSteamPipe.Value, pchVersion ); interface_pointer = platform.ISteamClient_GetISteamGameServer( hSteamUser.Value, hSteamPipe.Value, pchVersion );
return new SteamGameServer( interface_pointer ); return new SteamGameServer( steamworks, interface_pointer );
} }
// ISteamGameServerStats * // ISteamGameServerStats *
public SteamGameServerStats GetISteamGameServerStats( HSteamUser hSteamuser /*HSteamUser*/, HSteamPipe hSteamPipe /*HSteamPipe*/, string pchVersion /*const char **/ ) public SteamGameServerStats GetISteamGameServerStats( HSteamUser hSteamuser /*HSteamUser*/, HSteamPipe hSteamPipe /*HSteamPipe*/, string pchVersion /*const char **/ )
{ {
IntPtr interface_pointer; IntPtr interface_pointer;
interface_pointer = _pi.ISteamClient_GetISteamGameServerStats( hSteamuser.Value, hSteamPipe.Value, pchVersion ); interface_pointer = platform.ISteamClient_GetISteamGameServerStats( hSteamuser.Value, hSteamPipe.Value, pchVersion );
return new SteamGameServerStats( interface_pointer ); return new SteamGameServerStats( steamworks, interface_pointer );
} }
// IntPtr // IntPtr
public IntPtr GetISteamGenericInterface( HSteamUser hSteamUser /*HSteamUser*/, HSteamPipe hSteamPipe /*HSteamPipe*/, string pchVersion /*const char **/ ) public IntPtr GetISteamGenericInterface( HSteamUser hSteamUser /*HSteamUser*/, HSteamPipe hSteamPipe /*HSteamPipe*/, string pchVersion /*const char **/ )
{ {
return _pi.ISteamClient_GetISteamGenericInterface( hSteamUser.Value, hSteamPipe.Value, pchVersion ); return platform.ISteamClient_GetISteamGenericInterface( hSteamUser.Value, hSteamPipe.Value, pchVersion );
} }
// ISteamHTMLSurface * // ISteamHTMLSurface *
public SteamHTMLSurface GetISteamHTMLSurface( HSteamUser hSteamuser /*HSteamUser*/, HSteamPipe hSteamPipe /*HSteamPipe*/, string pchVersion /*const char **/ ) public SteamHTMLSurface GetISteamHTMLSurface( HSteamUser hSteamuser /*HSteamUser*/, HSteamPipe hSteamPipe /*HSteamPipe*/, string pchVersion /*const char **/ )
{ {
IntPtr interface_pointer; IntPtr interface_pointer;
interface_pointer = _pi.ISteamClient_GetISteamHTMLSurface( hSteamuser.Value, hSteamPipe.Value, pchVersion ); interface_pointer = platform.ISteamClient_GetISteamHTMLSurface( hSteamuser.Value, hSteamPipe.Value, pchVersion );
return new SteamHTMLSurface( interface_pointer ); return new SteamHTMLSurface( steamworks, interface_pointer );
} }
// ISteamHTTP * // ISteamHTTP *
public SteamHTTP GetISteamHTTP( HSteamUser hSteamuser /*HSteamUser*/, HSteamPipe hSteamPipe /*HSteamPipe*/, string pchVersion /*const char **/ ) public SteamHTTP GetISteamHTTP( HSteamUser hSteamuser /*HSteamUser*/, HSteamPipe hSteamPipe /*HSteamPipe*/, string pchVersion /*const char **/ )
{ {
IntPtr interface_pointer; IntPtr interface_pointer;
interface_pointer = _pi.ISteamClient_GetISteamHTTP( hSteamuser.Value, hSteamPipe.Value, pchVersion ); interface_pointer = platform.ISteamClient_GetISteamHTTP( hSteamuser.Value, hSteamPipe.Value, pchVersion );
return new SteamHTTP( interface_pointer ); return new SteamHTTP( steamworks, interface_pointer );
} }
// ISteamInventory * // ISteamInventory *
public SteamInventory GetISteamInventory( HSteamUser hSteamuser /*HSteamUser*/, HSteamPipe hSteamPipe /*HSteamPipe*/, string pchVersion /*const char **/ ) public SteamInventory GetISteamInventory( HSteamUser hSteamuser /*HSteamUser*/, HSteamPipe hSteamPipe /*HSteamPipe*/, string pchVersion /*const char **/ )
{ {
IntPtr interface_pointer; IntPtr interface_pointer;
interface_pointer = _pi.ISteamClient_GetISteamInventory( hSteamuser.Value, hSteamPipe.Value, pchVersion ); interface_pointer = platform.ISteamClient_GetISteamInventory( hSteamuser.Value, hSteamPipe.Value, pchVersion );
return new SteamInventory( interface_pointer ); return new SteamInventory( steamworks, interface_pointer );
} }
// ISteamMatchmaking * // ISteamMatchmaking *
public SteamMatchmaking GetISteamMatchmaking( HSteamUser hSteamUser /*HSteamUser*/, HSteamPipe hSteamPipe /*HSteamPipe*/, string pchVersion /*const char **/ ) public SteamMatchmaking GetISteamMatchmaking( HSteamUser hSteamUser /*HSteamUser*/, HSteamPipe hSteamPipe /*HSteamPipe*/, string pchVersion /*const char **/ )
{ {
IntPtr interface_pointer; IntPtr interface_pointer;
interface_pointer = _pi.ISteamClient_GetISteamMatchmaking( hSteamUser.Value, hSteamPipe.Value, pchVersion ); interface_pointer = platform.ISteamClient_GetISteamMatchmaking( hSteamUser.Value, hSteamPipe.Value, pchVersion );
return new SteamMatchmaking( interface_pointer ); return new SteamMatchmaking( steamworks, interface_pointer );
} }
// ISteamMatchmakingServers * // ISteamMatchmakingServers *
public SteamMatchmakingServers GetISteamMatchmakingServers( HSteamUser hSteamUser /*HSteamUser*/, HSteamPipe hSteamPipe /*HSteamPipe*/, string pchVersion /*const char **/ ) public SteamMatchmakingServers GetISteamMatchmakingServers( HSteamUser hSteamUser /*HSteamUser*/, HSteamPipe hSteamPipe /*HSteamPipe*/, string pchVersion /*const char **/ )
{ {
IntPtr interface_pointer; IntPtr interface_pointer;
interface_pointer = _pi.ISteamClient_GetISteamMatchmakingServers( hSteamUser.Value, hSteamPipe.Value, pchVersion ); interface_pointer = platform.ISteamClient_GetISteamMatchmakingServers( hSteamUser.Value, hSteamPipe.Value, pchVersion );
return new SteamMatchmakingServers( interface_pointer ); return new SteamMatchmakingServers( steamworks, interface_pointer );
} }
// ISteamMusic * // ISteamMusic *
public SteamMusic GetISteamMusic( HSteamUser hSteamuser /*HSteamUser*/, HSteamPipe hSteamPipe /*HSteamPipe*/, string pchVersion /*const char **/ ) public SteamMusic GetISteamMusic( HSteamUser hSteamuser /*HSteamUser*/, HSteamPipe hSteamPipe /*HSteamPipe*/, string pchVersion /*const char **/ )
{ {
IntPtr interface_pointer; IntPtr interface_pointer;
interface_pointer = _pi.ISteamClient_GetISteamMusic( hSteamuser.Value, hSteamPipe.Value, pchVersion ); interface_pointer = platform.ISteamClient_GetISteamMusic( hSteamuser.Value, hSteamPipe.Value, pchVersion );
return new SteamMusic( interface_pointer ); return new SteamMusic( steamworks, interface_pointer );
} }
// ISteamMusicRemote * // ISteamMusicRemote *
public SteamMusicRemote GetISteamMusicRemote( HSteamUser hSteamuser /*HSteamUser*/, HSteamPipe hSteamPipe /*HSteamPipe*/, string pchVersion /*const char **/ ) public SteamMusicRemote GetISteamMusicRemote( HSteamUser hSteamuser /*HSteamUser*/, HSteamPipe hSteamPipe /*HSteamPipe*/, string pchVersion /*const char **/ )
{ {
IntPtr interface_pointer; IntPtr interface_pointer;
interface_pointer = _pi.ISteamClient_GetISteamMusicRemote( hSteamuser.Value, hSteamPipe.Value, pchVersion ); interface_pointer = platform.ISteamClient_GetISteamMusicRemote( hSteamuser.Value, hSteamPipe.Value, pchVersion );
return new SteamMusicRemote( interface_pointer ); return new SteamMusicRemote( steamworks, interface_pointer );
} }
// ISteamNetworking * // ISteamNetworking *
public SteamNetworking GetISteamNetworking( HSteamUser hSteamUser /*HSteamUser*/, HSteamPipe hSteamPipe /*HSteamPipe*/, string pchVersion /*const char **/ ) public SteamNetworking GetISteamNetworking( HSteamUser hSteamUser /*HSteamUser*/, HSteamPipe hSteamPipe /*HSteamPipe*/, string pchVersion /*const char **/ )
{ {
IntPtr interface_pointer; IntPtr interface_pointer;
interface_pointer = _pi.ISteamClient_GetISteamNetworking( hSteamUser.Value, hSteamPipe.Value, pchVersion ); interface_pointer = platform.ISteamClient_GetISteamNetworking( hSteamUser.Value, hSteamPipe.Value, pchVersion );
return new SteamNetworking( interface_pointer ); return new SteamNetworking( steamworks, interface_pointer );
} }
// ISteamRemoteStorage * // ISteamRemoteStorage *
public SteamRemoteStorage GetISteamRemoteStorage( HSteamUser hSteamuser /*HSteamUser*/, HSteamPipe hSteamPipe /*HSteamPipe*/, string pchVersion /*const char **/ ) public SteamRemoteStorage GetISteamRemoteStorage( HSteamUser hSteamuser /*HSteamUser*/, HSteamPipe hSteamPipe /*HSteamPipe*/, string pchVersion /*const char **/ )
{ {
IntPtr interface_pointer; IntPtr interface_pointer;
interface_pointer = _pi.ISteamClient_GetISteamRemoteStorage( hSteamuser.Value, hSteamPipe.Value, pchVersion ); interface_pointer = platform.ISteamClient_GetISteamRemoteStorage( hSteamuser.Value, hSteamPipe.Value, pchVersion );
return new SteamRemoteStorage( interface_pointer ); return new SteamRemoteStorage( steamworks, interface_pointer );
} }
// ISteamScreenshots * // ISteamScreenshots *
public SteamScreenshots GetISteamScreenshots( HSteamUser hSteamuser /*HSteamUser*/, HSteamPipe hSteamPipe /*HSteamPipe*/, string pchVersion /*const char **/ ) public SteamScreenshots GetISteamScreenshots( HSteamUser hSteamuser /*HSteamUser*/, HSteamPipe hSteamPipe /*HSteamPipe*/, string pchVersion /*const char **/ )
{ {
IntPtr interface_pointer; IntPtr interface_pointer;
interface_pointer = _pi.ISteamClient_GetISteamScreenshots( hSteamuser.Value, hSteamPipe.Value, pchVersion ); interface_pointer = platform.ISteamClient_GetISteamScreenshots( hSteamuser.Value, hSteamPipe.Value, pchVersion );
return new SteamScreenshots( interface_pointer ); return new SteamScreenshots( steamworks, interface_pointer );
} }
// ISteamUGC * // ISteamUGC *
public SteamUGC GetISteamUGC( HSteamUser hSteamUser /*HSteamUser*/, HSteamPipe hSteamPipe /*HSteamPipe*/, string pchVersion /*const char **/ ) public SteamUGC GetISteamUGC( HSteamUser hSteamUser /*HSteamUser*/, HSteamPipe hSteamPipe /*HSteamPipe*/, string pchVersion /*const char **/ )
{ {
IntPtr interface_pointer; IntPtr interface_pointer;
interface_pointer = _pi.ISteamClient_GetISteamUGC( hSteamUser.Value, hSteamPipe.Value, pchVersion ); interface_pointer = platform.ISteamClient_GetISteamUGC( hSteamUser.Value, hSteamPipe.Value, pchVersion );
return new SteamUGC( interface_pointer ); return new SteamUGC( steamworks, interface_pointer );
} }
// ISteamUnifiedMessages * // ISteamUnifiedMessages *
public SteamUnifiedMessages GetISteamUnifiedMessages( HSteamUser hSteamuser /*HSteamUser*/, HSteamPipe hSteamPipe /*HSteamPipe*/, string pchVersion /*const char **/ ) public SteamUnifiedMessages GetISteamUnifiedMessages( HSteamUser hSteamuser /*HSteamUser*/, HSteamPipe hSteamPipe /*HSteamPipe*/, string pchVersion /*const char **/ )
{ {
IntPtr interface_pointer; IntPtr interface_pointer;
interface_pointer = _pi.ISteamClient_GetISteamUnifiedMessages( hSteamuser.Value, hSteamPipe.Value, pchVersion ); interface_pointer = platform.ISteamClient_GetISteamUnifiedMessages( hSteamuser.Value, hSteamPipe.Value, pchVersion );
return new SteamUnifiedMessages( interface_pointer ); return new SteamUnifiedMessages( steamworks, interface_pointer );
} }
// ISteamUser * // ISteamUser *
public SteamUser GetISteamUser( HSteamUser hSteamUser /*HSteamUser*/, HSteamPipe hSteamPipe /*HSteamPipe*/, string pchVersion /*const char **/ ) public SteamUser GetISteamUser( HSteamUser hSteamUser /*HSteamUser*/, HSteamPipe hSteamPipe /*HSteamPipe*/, string pchVersion /*const char **/ )
{ {
IntPtr interface_pointer; IntPtr interface_pointer;
interface_pointer = _pi.ISteamClient_GetISteamUser( hSteamUser.Value, hSteamPipe.Value, pchVersion ); interface_pointer = platform.ISteamClient_GetISteamUser( hSteamUser.Value, hSteamPipe.Value, pchVersion );
return new SteamUser( interface_pointer ); return new SteamUser( steamworks, interface_pointer );
} }
// ISteamUserStats * // ISteamUserStats *
public SteamUserStats GetISteamUserStats( HSteamUser hSteamUser /*HSteamUser*/, HSteamPipe hSteamPipe /*HSteamPipe*/, string pchVersion /*const char **/ ) public SteamUserStats GetISteamUserStats( HSteamUser hSteamUser /*HSteamUser*/, HSteamPipe hSteamPipe /*HSteamPipe*/, string pchVersion /*const char **/ )
{ {
IntPtr interface_pointer; IntPtr interface_pointer;
interface_pointer = _pi.ISteamClient_GetISteamUserStats( hSteamUser.Value, hSteamPipe.Value, pchVersion ); interface_pointer = platform.ISteamClient_GetISteamUserStats( hSteamUser.Value, hSteamPipe.Value, pchVersion );
return new SteamUserStats( interface_pointer ); return new SteamUserStats( steamworks, interface_pointer );
} }
// ISteamUtils * // ISteamUtils *
public SteamUtils GetISteamUtils( HSteamPipe hSteamPipe /*HSteamPipe*/, string pchVersion /*const char **/ ) public SteamUtils GetISteamUtils( HSteamPipe hSteamPipe /*HSteamPipe*/, string pchVersion /*const char **/ )
{ {
IntPtr interface_pointer; IntPtr interface_pointer;
interface_pointer = _pi.ISteamClient_GetISteamUtils( hSteamPipe.Value, pchVersion ); interface_pointer = platform.ISteamClient_GetISteamUtils( hSteamPipe.Value, pchVersion );
return new SteamUtils( interface_pointer ); return new SteamUtils( steamworks, interface_pointer );
} }
// ISteamVideo * // ISteamVideo *
public SteamVideo GetISteamVideo( HSteamUser hSteamuser /*HSteamUser*/, HSteamPipe hSteamPipe /*HSteamPipe*/, string pchVersion /*const char **/ ) public SteamVideo GetISteamVideo( HSteamUser hSteamuser /*HSteamUser*/, HSteamPipe hSteamPipe /*HSteamPipe*/, string pchVersion /*const char **/ )
{ {
IntPtr interface_pointer; IntPtr interface_pointer;
interface_pointer = _pi.ISteamClient_GetISteamVideo( hSteamuser.Value, hSteamPipe.Value, pchVersion ); interface_pointer = platform.ISteamClient_GetISteamVideo( hSteamuser.Value, hSteamPipe.Value, pchVersion );
return new SteamVideo( interface_pointer ); return new SteamVideo( steamworks, interface_pointer );
} }
// void // void
public void ReleaseUser( HSteamPipe hSteamPipe /*HSteamPipe*/, HSteamUser hUser /*HSteamUser*/ ) public void ReleaseUser( HSteamPipe hSteamPipe /*HSteamPipe*/, HSteamUser hUser /*HSteamUser*/ )
{ {
_pi.ISteamClient_ReleaseUser( hSteamPipe.Value, hUser.Value ); platform.ISteamClient_ReleaseUser( hSteamPipe.Value, hUser.Value );
} }
// void // void
public void SetLocalIPBinding( uint unIP /*uint32*/, ushort usPort /*uint16*/ ) public void SetLocalIPBinding( uint unIP /*uint32*/, ushort usPort /*uint16*/ )
{ {
_pi.ISteamClient_SetLocalIPBinding( unIP, usPort ); platform.ISteamClient_SetLocalIPBinding( unIP, usPort );
} }
// void // void
public void SetWarningMessageHook( IntPtr pFunction /*SteamAPIWarningMessageHook_t*/ ) public void SetWarningMessageHook( IntPtr pFunction /*SteamAPIWarningMessageHook_t*/ )
{ {
_pi.ISteamClient_SetWarningMessageHook( (IntPtr) pFunction ); platform.ISteamClient_SetWarningMessageHook( (IntPtr) pFunction );
} }
} }

View File

@ -3,172 +3,175 @@
namespace SteamNative namespace SteamNative
{ {
public unsafe class SteamController : IDisposable internal unsafe class SteamController : IDisposable
{ {
// //
// Holds a platform specific implentation // Holds a platform specific implentation
// //
internal Platform.Interface _pi; internal Platform.Interface platform;
internal Facepunch.Steamworks.BaseSteamworks steamworks;
// //
// Constructor decides which implementation to use based on current platform // Constructor decides which implementation to use based on current platform
// //
public SteamController( IntPtr pointer ) public SteamController( Facepunch.Steamworks.BaseSteamworks steamworks, IntPtr pointer )
{ {
if ( Platform.IsWindows64 ) _pi = new Platform.Win64( pointer ); this.steamworks = steamworks;
else if ( Platform.IsWindows32 ) _pi = new Platform.Win32( pointer );
else if ( Platform.IsLinux32 ) _pi = new Platform.Linux32( pointer ); if ( Platform.IsWindows64 ) platform = new Platform.Win64( pointer );
else if ( Platform.IsLinux64 ) _pi = new Platform.Linux64( pointer ); else if ( Platform.IsWindows32 ) platform = new Platform.Win32( pointer );
else if ( Platform.IsOsx ) _pi = new Platform.Mac( pointer ); else if ( Platform.IsLinux32 ) platform = new Platform.Linux32( pointer );
else if ( Platform.IsLinux64 ) platform = new Platform.Linux64( pointer );
else if ( Platform.IsOsx ) platform = new Platform.Mac( pointer );
} }
// //
// Class is invalid if we don't have a valid implementation // Class is invalid if we don't have a valid implementation
// //
public bool IsValid{ get{ return _pi != null && _pi.IsValid; } } public bool IsValid{ get{ return platform != null && platform.IsValid; } }
// //
// When shutting down clear all the internals to avoid accidental use // When shutting down clear all the internals to avoid accidental use
// //
public virtual void Dispose() public virtual void Dispose()
{ {
if ( _pi != null ) if ( platform != null )
{ {
_pi.Dispose(); platform.Dispose();
_pi = null; platform = null;
} }
} }
// void // void
public void ActivateActionSet( ControllerHandle_t controllerHandle /*ControllerHandle_t*/, ControllerActionSetHandle_t actionSetHandle /*ControllerActionSetHandle_t*/ ) public void ActivateActionSet( ControllerHandle_t controllerHandle /*ControllerHandle_t*/, ControllerActionSetHandle_t actionSetHandle /*ControllerActionSetHandle_t*/ )
{ {
_pi.ISteamController_ActivateActionSet( controllerHandle.Value, actionSetHandle.Value ); platform.ISteamController_ActivateActionSet( controllerHandle.Value, actionSetHandle.Value );
} }
// ControllerActionSetHandle_t // ControllerActionSetHandle_t
public ControllerActionSetHandle_t GetActionSetHandle( string pszActionSetName /*const char **/ ) public ControllerActionSetHandle_t GetActionSetHandle( string pszActionSetName /*const char **/ )
{ {
return _pi.ISteamController_GetActionSetHandle( pszActionSetName ); return platform.ISteamController_GetActionSetHandle( pszActionSetName );
} }
// ControllerAnalogActionData_t // ControllerAnalogActionData_t
public ControllerAnalogActionData_t GetAnalogActionData( ControllerHandle_t controllerHandle /*ControllerHandle_t*/, ControllerAnalogActionHandle_t analogActionHandle /*ControllerAnalogActionHandle_t*/ ) public ControllerAnalogActionData_t GetAnalogActionData( ControllerHandle_t controllerHandle /*ControllerHandle_t*/, ControllerAnalogActionHandle_t analogActionHandle /*ControllerAnalogActionHandle_t*/ )
{ {
return _pi.ISteamController_GetAnalogActionData( controllerHandle.Value, analogActionHandle.Value ); return platform.ISteamController_GetAnalogActionData( controllerHandle.Value, analogActionHandle.Value );
} }
// ControllerAnalogActionHandle_t // ControllerAnalogActionHandle_t
public ControllerAnalogActionHandle_t GetAnalogActionHandle( string pszActionName /*const char **/ ) public ControllerAnalogActionHandle_t GetAnalogActionHandle( string pszActionName /*const char **/ )
{ {
return _pi.ISteamController_GetAnalogActionHandle( pszActionName ); return platform.ISteamController_GetAnalogActionHandle( pszActionName );
} }
// int // int
public int GetAnalogActionOrigins( ControllerHandle_t controllerHandle /*ControllerHandle_t*/, ControllerActionSetHandle_t actionSetHandle /*ControllerActionSetHandle_t*/, ControllerAnalogActionHandle_t analogActionHandle /*ControllerAnalogActionHandle_t*/, out ControllerActionOrigin originsOut /*EControllerActionOrigin **/ ) public int GetAnalogActionOrigins( ControllerHandle_t controllerHandle /*ControllerHandle_t*/, ControllerActionSetHandle_t actionSetHandle /*ControllerActionSetHandle_t*/, ControllerAnalogActionHandle_t analogActionHandle /*ControllerAnalogActionHandle_t*/, out ControllerActionOrigin originsOut /*EControllerActionOrigin **/ )
{ {
return _pi.ISteamController_GetAnalogActionOrigins( controllerHandle.Value, actionSetHandle.Value, analogActionHandle.Value, out originsOut ); return platform.ISteamController_GetAnalogActionOrigins( controllerHandle.Value, actionSetHandle.Value, analogActionHandle.Value, out originsOut );
} }
// int // int
public int GetConnectedControllers( IntPtr handlesOut /*ControllerHandle_t **/ ) public int GetConnectedControllers( IntPtr handlesOut /*ControllerHandle_t **/ )
{ {
return _pi.ISteamController_GetConnectedControllers( (IntPtr) handlesOut ); return platform.ISteamController_GetConnectedControllers( (IntPtr) handlesOut );
} }
// ControllerHandle_t // ControllerHandle_t
public ControllerHandle_t GetControllerForGamepadIndex( int nIndex /*int*/ ) public ControllerHandle_t GetControllerForGamepadIndex( int nIndex /*int*/ )
{ {
return _pi.ISteamController_GetControllerForGamepadIndex( nIndex ); return platform.ISteamController_GetControllerForGamepadIndex( nIndex );
} }
// ControllerActionSetHandle_t // ControllerActionSetHandle_t
public ControllerActionSetHandle_t GetCurrentActionSet( ControllerHandle_t controllerHandle /*ControllerHandle_t*/ ) public ControllerActionSetHandle_t GetCurrentActionSet( ControllerHandle_t controllerHandle /*ControllerHandle_t*/ )
{ {
return _pi.ISteamController_GetCurrentActionSet( controllerHandle.Value ); return platform.ISteamController_GetCurrentActionSet( controllerHandle.Value );
} }
// ControllerDigitalActionData_t // ControllerDigitalActionData_t
public ControllerDigitalActionData_t GetDigitalActionData( ControllerHandle_t controllerHandle /*ControllerHandle_t*/, ControllerDigitalActionHandle_t digitalActionHandle /*ControllerDigitalActionHandle_t*/ ) public ControllerDigitalActionData_t GetDigitalActionData( ControllerHandle_t controllerHandle /*ControllerHandle_t*/, ControllerDigitalActionHandle_t digitalActionHandle /*ControllerDigitalActionHandle_t*/ )
{ {
return _pi.ISteamController_GetDigitalActionData( controllerHandle.Value, digitalActionHandle.Value ); return platform.ISteamController_GetDigitalActionData( controllerHandle.Value, digitalActionHandle.Value );
} }
// ControllerDigitalActionHandle_t // ControllerDigitalActionHandle_t
public ControllerDigitalActionHandle_t GetDigitalActionHandle( string pszActionName /*const char **/ ) public ControllerDigitalActionHandle_t GetDigitalActionHandle( string pszActionName /*const char **/ )
{ {
return _pi.ISteamController_GetDigitalActionHandle( pszActionName ); return platform.ISteamController_GetDigitalActionHandle( pszActionName );
} }
// int // int
public int GetDigitalActionOrigins( ControllerHandle_t controllerHandle /*ControllerHandle_t*/, ControllerActionSetHandle_t actionSetHandle /*ControllerActionSetHandle_t*/, ControllerDigitalActionHandle_t digitalActionHandle /*ControllerDigitalActionHandle_t*/, out ControllerActionOrigin originsOut /*EControllerActionOrigin **/ ) public int GetDigitalActionOrigins( ControllerHandle_t controllerHandle /*ControllerHandle_t*/, ControllerActionSetHandle_t actionSetHandle /*ControllerActionSetHandle_t*/, ControllerDigitalActionHandle_t digitalActionHandle /*ControllerDigitalActionHandle_t*/, out ControllerActionOrigin originsOut /*EControllerActionOrigin **/ )
{ {
return _pi.ISteamController_GetDigitalActionOrigins( controllerHandle.Value, actionSetHandle.Value, digitalActionHandle.Value, out originsOut ); return platform.ISteamController_GetDigitalActionOrigins( controllerHandle.Value, actionSetHandle.Value, digitalActionHandle.Value, out originsOut );
} }
// int // int
public int GetGamepadIndexForController( ControllerHandle_t ulControllerHandle /*ControllerHandle_t*/ ) public int GetGamepadIndexForController( ControllerHandle_t ulControllerHandle /*ControllerHandle_t*/ )
{ {
return _pi.ISteamController_GetGamepadIndexForController( ulControllerHandle.Value ); return platform.ISteamController_GetGamepadIndexForController( ulControllerHandle.Value );
} }
// ControllerMotionData_t // ControllerMotionData_t
public ControllerMotionData_t GetMotionData( ControllerHandle_t controllerHandle /*ControllerHandle_t*/ ) public ControllerMotionData_t GetMotionData( ControllerHandle_t controllerHandle /*ControllerHandle_t*/ )
{ {
return _pi.ISteamController_GetMotionData( controllerHandle.Value ); return platform.ISteamController_GetMotionData( controllerHandle.Value );
} }
// bool // bool
public bool Init() public bool Init()
{ {
return _pi.ISteamController_Init(); return platform.ISteamController_Init();
} }
// void // void
public void RunFrame() public void RunFrame()
{ {
_pi.ISteamController_RunFrame(); platform.ISteamController_RunFrame();
} }
// bool // bool
public bool ShowAnalogActionOrigins( ControllerHandle_t controllerHandle /*ControllerHandle_t*/, ControllerAnalogActionHandle_t analogActionHandle /*ControllerAnalogActionHandle_t*/, float flScale /*float*/, float flXPosition /*float*/, float flYPosition /*float*/ ) public bool ShowAnalogActionOrigins( ControllerHandle_t controllerHandle /*ControllerHandle_t*/, ControllerAnalogActionHandle_t analogActionHandle /*ControllerAnalogActionHandle_t*/, float flScale /*float*/, float flXPosition /*float*/, float flYPosition /*float*/ )
{ {
return _pi.ISteamController_ShowAnalogActionOrigins( controllerHandle.Value, analogActionHandle.Value, flScale, flXPosition, flYPosition ); return platform.ISteamController_ShowAnalogActionOrigins( controllerHandle.Value, analogActionHandle.Value, flScale, flXPosition, flYPosition );
} }
// bool // bool
public bool ShowBindingPanel( ControllerHandle_t controllerHandle /*ControllerHandle_t*/ ) public bool ShowBindingPanel( ControllerHandle_t controllerHandle /*ControllerHandle_t*/ )
{ {
return _pi.ISteamController_ShowBindingPanel( controllerHandle.Value ); return platform.ISteamController_ShowBindingPanel( controllerHandle.Value );
} }
// bool // bool
public bool ShowDigitalActionOrigins( ControllerHandle_t controllerHandle /*ControllerHandle_t*/, ControllerDigitalActionHandle_t digitalActionHandle /*ControllerDigitalActionHandle_t*/, float flScale /*float*/, float flXPosition /*float*/, float flYPosition /*float*/ ) public bool ShowDigitalActionOrigins( ControllerHandle_t controllerHandle /*ControllerHandle_t*/, ControllerDigitalActionHandle_t digitalActionHandle /*ControllerDigitalActionHandle_t*/, float flScale /*float*/, float flXPosition /*float*/, float flYPosition /*float*/ )
{ {
return _pi.ISteamController_ShowDigitalActionOrigins( controllerHandle.Value, digitalActionHandle.Value, flScale, flXPosition, flYPosition ); return platform.ISteamController_ShowDigitalActionOrigins( controllerHandle.Value, digitalActionHandle.Value, flScale, flXPosition, flYPosition );
} }
// bool // bool
public bool Shutdown() public bool Shutdown()
{ {
return _pi.ISteamController_Shutdown(); return platform.ISteamController_Shutdown();
} }
// void // void
public void StopAnalogActionMomentum( ControllerHandle_t controllerHandle /*ControllerHandle_t*/, ControllerAnalogActionHandle_t eAction /*ControllerAnalogActionHandle_t*/ ) public void StopAnalogActionMomentum( ControllerHandle_t controllerHandle /*ControllerHandle_t*/, ControllerAnalogActionHandle_t eAction /*ControllerAnalogActionHandle_t*/ )
{ {
_pi.ISteamController_StopAnalogActionMomentum( controllerHandle.Value, eAction.Value ); platform.ISteamController_StopAnalogActionMomentum( controllerHandle.Value, eAction.Value );
} }
// void // void
public void TriggerHapticPulse( ControllerHandle_t controllerHandle /*ControllerHandle_t*/, SteamControllerPad eTargetPad /*ESteamControllerPad*/, ushort usDurationMicroSec /*unsigned short*/ ) public void TriggerHapticPulse( ControllerHandle_t controllerHandle /*ControllerHandle_t*/, SteamControllerPad eTargetPad /*ESteamControllerPad*/, ushort usDurationMicroSec /*unsigned short*/ )
{ {
_pi.ISteamController_TriggerHapticPulse( controllerHandle.Value, eTargetPad, usDurationMicroSec ); platform.ISteamController_TriggerHapticPulse( controllerHandle.Value, eTargetPad, usDurationMicroSec );
} }
// void // void
public void TriggerRepeatedHapticPulse( ControllerHandle_t controllerHandle /*ControllerHandle_t*/, SteamControllerPad eTargetPad /*ESteamControllerPad*/, ushort usDurationMicroSec /*unsigned short*/, ushort usOffMicroSec /*unsigned short*/, ushort unRepeat /*unsigned short*/, uint nFlags /*unsigned int*/ ) public void TriggerRepeatedHapticPulse( ControllerHandle_t controllerHandle /*ControllerHandle_t*/, SteamControllerPad eTargetPad /*ESteamControllerPad*/, ushort usDurationMicroSec /*unsigned short*/, ushort usOffMicroSec /*unsigned short*/, ushort unRepeat /*unsigned short*/, uint nFlags /*unsigned int*/ )
{ {
_pi.ISteamController_TriggerRepeatedHapticPulse( controllerHandle.Value, eTargetPad, usDurationMicroSec, usOffMicroSec, unRepeat, nFlags ); platform.ISteamController_TriggerRepeatedHapticPulse( controllerHandle.Value, eTargetPad, usDurationMicroSec, usOffMicroSec, unRepeat, nFlags );
} }
} }

View File

@ -3,130 +3,138 @@
namespace SteamNative namespace SteamNative
{ {
public unsafe class SteamFriends : IDisposable internal unsafe class SteamFriends : IDisposable
{ {
// //
// Holds a platform specific implentation // Holds a platform specific implentation
// //
internal Platform.Interface _pi; internal Platform.Interface platform;
internal Facepunch.Steamworks.BaseSteamworks steamworks;
// //
// Constructor decides which implementation to use based on current platform // Constructor decides which implementation to use based on current platform
// //
public SteamFriends( IntPtr pointer ) public SteamFriends( Facepunch.Steamworks.BaseSteamworks steamworks, IntPtr pointer )
{ {
if ( Platform.IsWindows64 ) _pi = new Platform.Win64( pointer ); this.steamworks = steamworks;
else if ( Platform.IsWindows32 ) _pi = new Platform.Win32( pointer );
else if ( Platform.IsLinux32 ) _pi = new Platform.Linux32( pointer ); if ( Platform.IsWindows64 ) platform = new Platform.Win64( pointer );
else if ( Platform.IsLinux64 ) _pi = new Platform.Linux64( pointer ); else if ( Platform.IsWindows32 ) platform = new Platform.Win32( pointer );
else if ( Platform.IsOsx ) _pi = new Platform.Mac( pointer ); else if ( Platform.IsLinux32 ) platform = new Platform.Linux32( pointer );
else if ( Platform.IsLinux64 ) platform = new Platform.Linux64( pointer );
else if ( Platform.IsOsx ) platform = new Platform.Mac( pointer );
} }
// //
// Class is invalid if we don't have a valid implementation // Class is invalid if we don't have a valid implementation
// //
public bool IsValid{ get{ return _pi != null && _pi.IsValid; } } public bool IsValid{ get{ return platform != null && platform.IsValid; } }
// //
// When shutting down clear all the internals to avoid accidental use // When shutting down clear all the internals to avoid accidental use
// //
public virtual void Dispose() public virtual void Dispose()
{ {
if ( _pi != null ) if ( platform != null )
{ {
_pi.Dispose(); platform.Dispose();
_pi = null; platform = null;
} }
} }
// void // void
public void ActivateGameOverlay( string pchDialog /*const char **/ ) public void ActivateGameOverlay( string pchDialog /*const char **/ )
{ {
_pi.ISteamFriends_ActivateGameOverlay( pchDialog ); platform.ISteamFriends_ActivateGameOverlay( pchDialog );
} }
// void // void
public void ActivateGameOverlayInviteDialog( CSteamID steamIDLobby /*class CSteamID*/ ) public void ActivateGameOverlayInviteDialog( CSteamID steamIDLobby /*class CSteamID*/ )
{ {
_pi.ISteamFriends_ActivateGameOverlayInviteDialog( steamIDLobby.Value ); platform.ISteamFriends_ActivateGameOverlayInviteDialog( steamIDLobby.Value );
} }
// void // void
public void ActivateGameOverlayToStore( AppId_t nAppID /*AppId_t*/, OverlayToStoreFlag eFlag /*EOverlayToStoreFlag*/ ) public void ActivateGameOverlayToStore( AppId_t nAppID /*AppId_t*/, OverlayToStoreFlag eFlag /*EOverlayToStoreFlag*/ )
{ {
_pi.ISteamFriends_ActivateGameOverlayToStore( nAppID.Value, eFlag ); platform.ISteamFriends_ActivateGameOverlayToStore( nAppID.Value, eFlag );
} }
// void // void
public void ActivateGameOverlayToUser( string pchDialog /*const char **/, CSteamID steamID /*class CSteamID*/ ) public void ActivateGameOverlayToUser( string pchDialog /*const char **/, CSteamID steamID /*class CSteamID*/ )
{ {
_pi.ISteamFriends_ActivateGameOverlayToUser( pchDialog, steamID.Value ); platform.ISteamFriends_ActivateGameOverlayToUser( pchDialog, steamID.Value );
} }
// void // void
public void ActivateGameOverlayToWebPage( string pchURL /*const char **/ ) public void ActivateGameOverlayToWebPage( string pchURL /*const char **/ )
{ {
_pi.ISteamFriends_ActivateGameOverlayToWebPage( pchURL ); platform.ISteamFriends_ActivateGameOverlayToWebPage( pchURL );
} }
// void // void
public void ClearRichPresence() public void ClearRichPresence()
{ {
_pi.ISteamFriends_ClearRichPresence(); platform.ISteamFriends_ClearRichPresence();
} }
// bool // bool
public bool CloseClanChatWindowInSteam( CSteamID steamIDClanChat /*class CSteamID*/ ) public bool CloseClanChatWindowInSteam( CSteamID steamIDClanChat /*class CSteamID*/ )
{ {
return _pi.ISteamFriends_CloseClanChatWindowInSteam( steamIDClanChat.Value ); return platform.ISteamFriends_CloseClanChatWindowInSteam( steamIDClanChat.Value );
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t DownloadClanActivityCounts( IntPtr psteamIDClans /*class CSteamID **/, int cClansToRequest /*int*/ ) public SteamAPICall_t DownloadClanActivityCounts( IntPtr psteamIDClans /*class CSteamID **/, int cClansToRequest /*int*/ )
{ {
return _pi.ISteamFriends_DownloadClanActivityCounts( (IntPtr) psteamIDClans, cClansToRequest ); return platform.ISteamFriends_DownloadClanActivityCounts( (IntPtr) psteamIDClans, cClansToRequest );
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t EnumerateFollowingList( uint unStartIndex /*uint32*/ ) public CallbackHandle EnumerateFollowingList( uint unStartIndex /*uint32*/, Action<FriendsEnumerateFollowingList_t, bool> CallbackFunction = null /*Action<FriendsEnumerateFollowingList_t, bool>*/ )
{ {
return _pi.ISteamFriends_EnumerateFollowingList( unStartIndex ); SteamAPICall_t callback = 0;
callback = platform.ISteamFriends_EnumerateFollowingList( unStartIndex );
if ( CallbackFunction == null ) return null;
return FriendsEnumerateFollowingList_t.CallResult( steamworks, callback, CallbackFunction );
} }
// ulong // ulong
public ulong GetChatMemberByIndex( CSteamID steamIDClan /*class CSteamID*/, int iUser /*int*/ ) public ulong GetChatMemberByIndex( CSteamID steamIDClan /*class CSteamID*/, int iUser /*int*/ )
{ {
return _pi.ISteamFriends_GetChatMemberByIndex( steamIDClan.Value, iUser ); return platform.ISteamFriends_GetChatMemberByIndex( steamIDClan.Value, iUser );
} }
// bool // bool
public bool GetClanActivityCounts( CSteamID steamIDClan /*class CSteamID*/, out int pnOnline /*int **/, out int pnInGame /*int **/, out int pnChatting /*int **/ ) public bool GetClanActivityCounts( CSteamID steamIDClan /*class CSteamID*/, out int pnOnline /*int **/, out int pnInGame /*int **/, out int pnChatting /*int **/ )
{ {
return _pi.ISteamFriends_GetClanActivityCounts( steamIDClan.Value, out pnOnline, out pnInGame, out pnChatting ); return platform.ISteamFriends_GetClanActivityCounts( steamIDClan.Value, out pnOnline, out pnInGame, out pnChatting );
} }
// ulong // ulong
public ulong GetClanByIndex( int iClan /*int*/ ) public ulong GetClanByIndex( int iClan /*int*/ )
{ {
return _pi.ISteamFriends_GetClanByIndex( iClan ); return platform.ISteamFriends_GetClanByIndex( iClan );
} }
// int // int
public int GetClanChatMemberCount( CSteamID steamIDClan /*class CSteamID*/ ) public int GetClanChatMemberCount( CSteamID steamIDClan /*class CSteamID*/ )
{ {
return _pi.ISteamFriends_GetClanChatMemberCount( steamIDClan.Value ); return platform.ISteamFriends_GetClanChatMemberCount( steamIDClan.Value );
} }
// int // int
public int GetClanChatMessage( CSteamID steamIDClanChat /*class CSteamID*/, int iMessage /*int*/, IntPtr prgchText /*void **/, int cchTextMax /*int*/, out ChatEntryType peChatEntryType /*EChatEntryType **/, out CSteamID psteamidChatter /*class CSteamID **/ ) public int GetClanChatMessage( CSteamID steamIDClanChat /*class CSteamID*/, int iMessage /*int*/, IntPtr prgchText /*void **/, int cchTextMax /*int*/, out ChatEntryType peChatEntryType /*EChatEntryType **/, out CSteamID psteamidChatter /*class CSteamID **/ )
{ {
return _pi.ISteamFriends_GetClanChatMessage( steamIDClanChat.Value, iMessage, (IntPtr) prgchText, cchTextMax, out peChatEntryType, out psteamidChatter.Value ); return platform.ISteamFriends_GetClanChatMessage( steamIDClanChat.Value, iMessage, (IntPtr) prgchText, cchTextMax, out peChatEntryType, out psteamidChatter.Value );
} }
// int // int
public int GetClanCount() public int GetClanCount()
{ {
return _pi.ISteamFriends_GetClanCount(); return platform.ISteamFriends_GetClanCount();
} }
// string // string
@ -134,26 +142,26 @@ public int GetClanCount()
public string GetClanName( CSteamID steamIDClan /*class CSteamID*/ ) public string GetClanName( CSteamID steamIDClan /*class CSteamID*/ )
{ {
IntPtr string_pointer; IntPtr string_pointer;
string_pointer = _pi.ISteamFriends_GetClanName( steamIDClan.Value ); string_pointer = platform.ISteamFriends_GetClanName( steamIDClan.Value );
return Marshal.PtrToStringAnsi( string_pointer ); return Marshal.PtrToStringAnsi( string_pointer );
} }
// ulong // ulong
public ulong GetClanOfficerByIndex( CSteamID steamIDClan /*class CSteamID*/, int iOfficer /*int*/ ) public ulong GetClanOfficerByIndex( CSteamID steamIDClan /*class CSteamID*/, int iOfficer /*int*/ )
{ {
return _pi.ISteamFriends_GetClanOfficerByIndex( steamIDClan.Value, iOfficer ); return platform.ISteamFriends_GetClanOfficerByIndex( steamIDClan.Value, iOfficer );
} }
// int // int
public int GetClanOfficerCount( CSteamID steamIDClan /*class CSteamID*/ ) public int GetClanOfficerCount( CSteamID steamIDClan /*class CSteamID*/ )
{ {
return _pi.ISteamFriends_GetClanOfficerCount( steamIDClan.Value ); return platform.ISteamFriends_GetClanOfficerCount( steamIDClan.Value );
} }
// ulong // ulong
public ulong GetClanOwner( CSteamID steamIDClan /*class CSteamID*/ ) public ulong GetClanOwner( CSteamID steamIDClan /*class CSteamID*/ )
{ {
return _pi.ISteamFriends_GetClanOwner( steamIDClan.Value ); return platform.ISteamFriends_GetClanOwner( steamIDClan.Value );
} }
// string // string
@ -161,74 +169,79 @@ public ulong GetClanOwner( CSteamID steamIDClan /*class CSteamID*/ )
public string GetClanTag( CSteamID steamIDClan /*class CSteamID*/ ) public string GetClanTag( CSteamID steamIDClan /*class CSteamID*/ )
{ {
IntPtr string_pointer; IntPtr string_pointer;
string_pointer = _pi.ISteamFriends_GetClanTag( steamIDClan.Value ); string_pointer = platform.ISteamFriends_GetClanTag( steamIDClan.Value );
return Marshal.PtrToStringAnsi( string_pointer ); return Marshal.PtrToStringAnsi( string_pointer );
} }
// ulong // ulong
public ulong GetCoplayFriend( int iCoplayFriend /*int*/ ) public ulong GetCoplayFriend( int iCoplayFriend /*int*/ )
{ {
return _pi.ISteamFriends_GetCoplayFriend( iCoplayFriend ); return platform.ISteamFriends_GetCoplayFriend( iCoplayFriend );
} }
// int // int
public int GetCoplayFriendCount() public int GetCoplayFriendCount()
{ {
return _pi.ISteamFriends_GetCoplayFriendCount(); return platform.ISteamFriends_GetCoplayFriendCount();
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t GetFollowerCount( CSteamID steamID /*class CSteamID*/ ) public CallbackHandle GetFollowerCount( CSteamID steamID /*class CSteamID*/, Action<FriendsGetFollowerCount_t, bool> CallbackFunction = null /*Action<FriendsGetFollowerCount_t, bool>*/ )
{ {
return _pi.ISteamFriends_GetFollowerCount( steamID.Value ); SteamAPICall_t callback = 0;
callback = platform.ISteamFriends_GetFollowerCount( steamID.Value );
if ( CallbackFunction == null ) return null;
return FriendsGetFollowerCount_t.CallResult( steamworks, callback, CallbackFunction );
} }
// ulong // ulong
public ulong GetFriendByIndex( int iFriend /*int*/, int iFriendFlags /*int*/ ) public ulong GetFriendByIndex( int iFriend /*int*/, int iFriendFlags /*int*/ )
{ {
return _pi.ISteamFriends_GetFriendByIndex( iFriend, iFriendFlags ); return platform.ISteamFriends_GetFriendByIndex( iFriend, iFriendFlags );
} }
// AppId_t // AppId_t
public AppId_t GetFriendCoplayGame( CSteamID steamIDFriend /*class CSteamID*/ ) public AppId_t GetFriendCoplayGame( CSteamID steamIDFriend /*class CSteamID*/ )
{ {
return _pi.ISteamFriends_GetFriendCoplayGame( steamIDFriend.Value ); return platform.ISteamFriends_GetFriendCoplayGame( steamIDFriend.Value );
} }
// int // int
public int GetFriendCoplayTime( CSteamID steamIDFriend /*class CSteamID*/ ) public int GetFriendCoplayTime( CSteamID steamIDFriend /*class CSteamID*/ )
{ {
return _pi.ISteamFriends_GetFriendCoplayTime( steamIDFriend.Value ); return platform.ISteamFriends_GetFriendCoplayTime( steamIDFriend.Value );
} }
// int // int
public int GetFriendCount( int iFriendFlags /*int*/ ) public int GetFriendCount( int iFriendFlags /*int*/ )
{ {
return _pi.ISteamFriends_GetFriendCount( iFriendFlags ); return platform.ISteamFriends_GetFriendCount( iFriendFlags );
} }
// int // int
public int GetFriendCountFromSource( CSteamID steamIDSource /*class CSteamID*/ ) public int GetFriendCountFromSource( CSteamID steamIDSource /*class CSteamID*/ )
{ {
return _pi.ISteamFriends_GetFriendCountFromSource( steamIDSource.Value ); return platform.ISteamFriends_GetFriendCountFromSource( steamIDSource.Value );
} }
// ulong // ulong
public ulong GetFriendFromSourceByIndex( CSteamID steamIDSource /*class CSteamID*/, int iFriend /*int*/ ) public ulong GetFriendFromSourceByIndex( CSteamID steamIDSource /*class CSteamID*/, int iFriend /*int*/ )
{ {
return _pi.ISteamFriends_GetFriendFromSourceByIndex( steamIDSource.Value, iFriend ); return platform.ISteamFriends_GetFriendFromSourceByIndex( steamIDSource.Value, iFriend );
} }
// bool // bool
public bool GetFriendGamePlayed( CSteamID steamIDFriend /*class CSteamID*/, ref FriendGameInfo_t pFriendGameInfo /*struct FriendGameInfo_t **/ ) public bool GetFriendGamePlayed( CSteamID steamIDFriend /*class CSteamID*/, ref FriendGameInfo_t pFriendGameInfo /*struct FriendGameInfo_t **/ )
{ {
return _pi.ISteamFriends_GetFriendGamePlayed( steamIDFriend.Value, ref pFriendGameInfo ); return platform.ISteamFriends_GetFriendGamePlayed( steamIDFriend.Value, ref pFriendGameInfo );
} }
// int // int
public int GetFriendMessage( CSteamID steamIDFriend /*class CSteamID*/, int iMessageID /*int*/, IntPtr pvData /*void **/, int cubData /*int*/, out ChatEntryType peChatEntryType /*EChatEntryType **/ ) public int GetFriendMessage( CSteamID steamIDFriend /*class CSteamID*/, int iMessageID /*int*/, IntPtr pvData /*void **/, int cubData /*int*/, out ChatEntryType peChatEntryType /*EChatEntryType **/ )
{ {
return _pi.ISteamFriends_GetFriendMessage( steamIDFriend.Value, iMessageID, (IntPtr) pvData, cubData, out peChatEntryType ); return platform.ISteamFriends_GetFriendMessage( steamIDFriend.Value, iMessageID, (IntPtr) pvData, cubData, out peChatEntryType );
} }
// string // string
@ -236,7 +249,7 @@ public int GetFriendMessage( CSteamID steamIDFriend /*class CSteamID*/, int iMes
public string GetFriendPersonaName( CSteamID steamIDFriend /*class CSteamID*/ ) public string GetFriendPersonaName( CSteamID steamIDFriend /*class CSteamID*/ )
{ {
IntPtr string_pointer; IntPtr string_pointer;
string_pointer = _pi.ISteamFriends_GetFriendPersonaName( steamIDFriend.Value ); string_pointer = platform.ISteamFriends_GetFriendPersonaName( steamIDFriend.Value );
return Marshal.PtrToStringAnsi( string_pointer ); return Marshal.PtrToStringAnsi( string_pointer );
} }
@ -245,20 +258,20 @@ public string GetFriendPersonaName( CSteamID steamIDFriend /*class CSteamID*/ )
public string GetFriendPersonaNameHistory( CSteamID steamIDFriend /*class CSteamID*/, int iPersonaName /*int*/ ) public string GetFriendPersonaNameHistory( CSteamID steamIDFriend /*class CSteamID*/, int iPersonaName /*int*/ )
{ {
IntPtr string_pointer; IntPtr string_pointer;
string_pointer = _pi.ISteamFriends_GetFriendPersonaNameHistory( steamIDFriend.Value, iPersonaName ); string_pointer = platform.ISteamFriends_GetFriendPersonaNameHistory( steamIDFriend.Value, iPersonaName );
return Marshal.PtrToStringAnsi( string_pointer ); return Marshal.PtrToStringAnsi( string_pointer );
} }
// PersonaState // PersonaState
public PersonaState GetFriendPersonaState( CSteamID steamIDFriend /*class CSteamID*/ ) public PersonaState GetFriendPersonaState( CSteamID steamIDFriend /*class CSteamID*/ )
{ {
return _pi.ISteamFriends_GetFriendPersonaState( steamIDFriend.Value ); return platform.ISteamFriends_GetFriendPersonaState( steamIDFriend.Value );
} }
// FriendRelationship // FriendRelationship
public FriendRelationship GetFriendRelationship( CSteamID steamIDFriend /*class CSteamID*/ ) public FriendRelationship GetFriendRelationship( CSteamID steamIDFriend /*class CSteamID*/ )
{ {
return _pi.ISteamFriends_GetFriendRelationship( steamIDFriend.Value ); return platform.ISteamFriends_GetFriendRelationship( steamIDFriend.Value );
} }
// string // string
@ -266,7 +279,7 @@ public FriendRelationship GetFriendRelationship( CSteamID steamIDFriend /*class
public string GetFriendRichPresence( CSteamID steamIDFriend /*class CSteamID*/, string pchKey /*const char **/ ) public string GetFriendRichPresence( CSteamID steamIDFriend /*class CSteamID*/, string pchKey /*const char **/ )
{ {
IntPtr string_pointer; IntPtr string_pointer;
string_pointer = _pi.ISteamFriends_GetFriendRichPresence( steamIDFriend.Value, pchKey ); string_pointer = platform.ISteamFriends_GetFriendRichPresence( steamIDFriend.Value, pchKey );
return Marshal.PtrToStringAnsi( string_pointer ); return Marshal.PtrToStringAnsi( string_pointer );
} }
@ -275,38 +288,38 @@ public string GetFriendRichPresence( CSteamID steamIDFriend /*class CSteamID*/,
public string GetFriendRichPresenceKeyByIndex( CSteamID steamIDFriend /*class CSteamID*/, int iKey /*int*/ ) public string GetFriendRichPresenceKeyByIndex( CSteamID steamIDFriend /*class CSteamID*/, int iKey /*int*/ )
{ {
IntPtr string_pointer; IntPtr string_pointer;
string_pointer = _pi.ISteamFriends_GetFriendRichPresenceKeyByIndex( steamIDFriend.Value, iKey ); string_pointer = platform.ISteamFriends_GetFriendRichPresenceKeyByIndex( steamIDFriend.Value, iKey );
return Marshal.PtrToStringAnsi( string_pointer ); return Marshal.PtrToStringAnsi( string_pointer );
} }
// int // int
public int GetFriendRichPresenceKeyCount( CSteamID steamIDFriend /*class CSteamID*/ ) public int GetFriendRichPresenceKeyCount( CSteamID steamIDFriend /*class CSteamID*/ )
{ {
return _pi.ISteamFriends_GetFriendRichPresenceKeyCount( steamIDFriend.Value ); return platform.ISteamFriends_GetFriendRichPresenceKeyCount( steamIDFriend.Value );
} }
// int // int
public int GetFriendsGroupCount() public int GetFriendsGroupCount()
{ {
return _pi.ISteamFriends_GetFriendsGroupCount(); return platform.ISteamFriends_GetFriendsGroupCount();
} }
// FriendsGroupID_t // FriendsGroupID_t
public FriendsGroupID_t GetFriendsGroupIDByIndex( int iFG /*int*/ ) public FriendsGroupID_t GetFriendsGroupIDByIndex( int iFG /*int*/ )
{ {
return _pi.ISteamFriends_GetFriendsGroupIDByIndex( iFG ); return platform.ISteamFriends_GetFriendsGroupIDByIndex( iFG );
} }
// int // int
public int GetFriendsGroupMembersCount( FriendsGroupID_t friendsGroupID /*FriendsGroupID_t*/ ) public int GetFriendsGroupMembersCount( FriendsGroupID_t friendsGroupID /*FriendsGroupID_t*/ )
{ {
return _pi.ISteamFriends_GetFriendsGroupMembersCount( friendsGroupID.Value ); return platform.ISteamFriends_GetFriendsGroupMembersCount( friendsGroupID.Value );
} }
// void // void
public void GetFriendsGroupMembersList( FriendsGroupID_t friendsGroupID /*FriendsGroupID_t*/, IntPtr pOutSteamIDMembers /*class CSteamID **/, int nMembersCount /*int*/ ) public void GetFriendsGroupMembersList( FriendsGroupID_t friendsGroupID /*FriendsGroupID_t*/, IntPtr pOutSteamIDMembers /*class CSteamID **/, int nMembersCount /*int*/ )
{ {
_pi.ISteamFriends_GetFriendsGroupMembersList( friendsGroupID.Value, (IntPtr) pOutSteamIDMembers, nMembersCount ); platform.ISteamFriends_GetFriendsGroupMembersList( friendsGroupID.Value, (IntPtr) pOutSteamIDMembers, nMembersCount );
} }
// string // string
@ -314,26 +327,26 @@ public void GetFriendsGroupMembersList( FriendsGroupID_t friendsGroupID /*Friend
public string GetFriendsGroupName( FriendsGroupID_t friendsGroupID /*FriendsGroupID_t*/ ) public string GetFriendsGroupName( FriendsGroupID_t friendsGroupID /*FriendsGroupID_t*/ )
{ {
IntPtr string_pointer; IntPtr string_pointer;
string_pointer = _pi.ISteamFriends_GetFriendsGroupName( friendsGroupID.Value ); string_pointer = platform.ISteamFriends_GetFriendsGroupName( friendsGroupID.Value );
return Marshal.PtrToStringAnsi( string_pointer ); return Marshal.PtrToStringAnsi( string_pointer );
} }
// int // int
public int GetFriendSteamLevel( CSteamID steamIDFriend /*class CSteamID*/ ) public int GetFriendSteamLevel( CSteamID steamIDFriend /*class CSteamID*/ )
{ {
return _pi.ISteamFriends_GetFriendSteamLevel( steamIDFriend.Value ); return platform.ISteamFriends_GetFriendSteamLevel( steamIDFriend.Value );
} }
// int // int
public int GetLargeFriendAvatar( CSteamID steamIDFriend /*class CSteamID*/ ) public int GetLargeFriendAvatar( CSteamID steamIDFriend /*class CSteamID*/ )
{ {
return _pi.ISteamFriends_GetLargeFriendAvatar( steamIDFriend.Value ); return platform.ISteamFriends_GetLargeFriendAvatar( steamIDFriend.Value );
} }
// int // int
public int GetMediumFriendAvatar( CSteamID steamIDFriend /*class CSteamID*/ ) public int GetMediumFriendAvatar( CSteamID steamIDFriend /*class CSteamID*/ )
{ {
return _pi.ISteamFriends_GetMediumFriendAvatar( steamIDFriend.Value ); return platform.ISteamFriends_GetMediumFriendAvatar( steamIDFriend.Value );
} }
// string // string
@ -341,14 +354,14 @@ public int GetMediumFriendAvatar( CSteamID steamIDFriend /*class CSteamID*/ )
public string GetPersonaName() public string GetPersonaName()
{ {
IntPtr string_pointer; IntPtr string_pointer;
string_pointer = _pi.ISteamFriends_GetPersonaName(); string_pointer = platform.ISteamFriends_GetPersonaName();
return Marshal.PtrToStringAnsi( string_pointer ); return Marshal.PtrToStringAnsi( string_pointer );
} }
// PersonaState // PersonaState
public PersonaState GetPersonaState() public PersonaState GetPersonaState()
{ {
return _pi.ISteamFriends_GetPersonaState(); return platform.ISteamFriends_GetPersonaState();
} }
// string // string
@ -356,134 +369,154 @@ public PersonaState GetPersonaState()
public string GetPlayerNickname( CSteamID steamIDPlayer /*class CSteamID*/ ) public string GetPlayerNickname( CSteamID steamIDPlayer /*class CSteamID*/ )
{ {
IntPtr string_pointer; IntPtr string_pointer;
string_pointer = _pi.ISteamFriends_GetPlayerNickname( steamIDPlayer.Value ); string_pointer = platform.ISteamFriends_GetPlayerNickname( steamIDPlayer.Value );
return Marshal.PtrToStringAnsi( string_pointer ); return Marshal.PtrToStringAnsi( string_pointer );
} }
// int // int
public int GetSmallFriendAvatar( CSteamID steamIDFriend /*class CSteamID*/ ) public int GetSmallFriendAvatar( CSteamID steamIDFriend /*class CSteamID*/ )
{ {
return _pi.ISteamFriends_GetSmallFriendAvatar( steamIDFriend.Value ); return platform.ISteamFriends_GetSmallFriendAvatar( steamIDFriend.Value );
} }
// uint // uint
public uint GetUserRestrictions() public uint GetUserRestrictions()
{ {
return _pi.ISteamFriends_GetUserRestrictions(); return platform.ISteamFriends_GetUserRestrictions();
} }
// bool // bool
public bool HasFriend( CSteamID steamIDFriend /*class CSteamID*/, int iFriendFlags /*int*/ ) public bool HasFriend( CSteamID steamIDFriend /*class CSteamID*/, int iFriendFlags /*int*/ )
{ {
return _pi.ISteamFriends_HasFriend( steamIDFriend.Value, iFriendFlags ); return platform.ISteamFriends_HasFriend( steamIDFriend.Value, iFriendFlags );
} }
// bool // bool
public bool InviteUserToGame( CSteamID steamIDFriend /*class CSteamID*/, string pchConnectString /*const char **/ ) public bool InviteUserToGame( CSteamID steamIDFriend /*class CSteamID*/, string pchConnectString /*const char **/ )
{ {
return _pi.ISteamFriends_InviteUserToGame( steamIDFriend.Value, pchConnectString ); return platform.ISteamFriends_InviteUserToGame( steamIDFriend.Value, pchConnectString );
} }
// bool // bool
public bool IsClanChatAdmin( CSteamID steamIDClanChat /*class CSteamID*/, CSteamID steamIDUser /*class CSteamID*/ ) public bool IsClanChatAdmin( CSteamID steamIDClanChat /*class CSteamID*/, CSteamID steamIDUser /*class CSteamID*/ )
{ {
return _pi.ISteamFriends_IsClanChatAdmin( steamIDClanChat.Value, steamIDUser.Value ); return platform.ISteamFriends_IsClanChatAdmin( steamIDClanChat.Value, steamIDUser.Value );
} }
// bool // bool
public bool IsClanChatWindowOpenInSteam( CSteamID steamIDClanChat /*class CSteamID*/ ) public bool IsClanChatWindowOpenInSteam( CSteamID steamIDClanChat /*class CSteamID*/ )
{ {
return _pi.ISteamFriends_IsClanChatWindowOpenInSteam( steamIDClanChat.Value ); return platform.ISteamFriends_IsClanChatWindowOpenInSteam( steamIDClanChat.Value );
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t IsFollowing( CSteamID steamID /*class CSteamID*/ ) public CallbackHandle IsFollowing( CSteamID steamID /*class CSteamID*/, Action<FriendsIsFollowing_t, bool> CallbackFunction = null /*Action<FriendsIsFollowing_t, bool>*/ )
{ {
return _pi.ISteamFriends_IsFollowing( steamID.Value ); SteamAPICall_t callback = 0;
callback = platform.ISteamFriends_IsFollowing( steamID.Value );
if ( CallbackFunction == null ) return null;
return FriendsIsFollowing_t.CallResult( steamworks, callback, CallbackFunction );
} }
// bool // bool
public bool IsUserInSource( CSteamID steamIDUser /*class CSteamID*/, CSteamID steamIDSource /*class CSteamID*/ ) public bool IsUserInSource( CSteamID steamIDUser /*class CSteamID*/, CSteamID steamIDSource /*class CSteamID*/ )
{ {
return _pi.ISteamFriends_IsUserInSource( steamIDUser.Value, steamIDSource.Value ); return platform.ISteamFriends_IsUserInSource( steamIDUser.Value, steamIDSource.Value );
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t JoinClanChatRoom( CSteamID steamIDClan /*class CSteamID*/ ) public CallbackHandle JoinClanChatRoom( CSteamID steamIDClan /*class CSteamID*/, Action<JoinClanChatRoomCompletionResult_t, bool> CallbackFunction = null /*Action<JoinClanChatRoomCompletionResult_t, bool>*/ )
{ {
return _pi.ISteamFriends_JoinClanChatRoom( steamIDClan.Value ); SteamAPICall_t callback = 0;
callback = platform.ISteamFriends_JoinClanChatRoom( steamIDClan.Value );
if ( CallbackFunction == null ) return null;
return JoinClanChatRoomCompletionResult_t.CallResult( steamworks, callback, CallbackFunction );
} }
// bool // bool
public bool LeaveClanChatRoom( CSteamID steamIDClan /*class CSteamID*/ ) public bool LeaveClanChatRoom( CSteamID steamIDClan /*class CSteamID*/ )
{ {
return _pi.ISteamFriends_LeaveClanChatRoom( steamIDClan.Value ); return platform.ISteamFriends_LeaveClanChatRoom( steamIDClan.Value );
} }
// bool // bool
public bool OpenClanChatWindowInSteam( CSteamID steamIDClanChat /*class CSteamID*/ ) public bool OpenClanChatWindowInSteam( CSteamID steamIDClanChat /*class CSteamID*/ )
{ {
return _pi.ISteamFriends_OpenClanChatWindowInSteam( steamIDClanChat.Value ); return platform.ISteamFriends_OpenClanChatWindowInSteam( steamIDClanChat.Value );
} }
// bool // bool
public bool ReplyToFriendMessage( CSteamID steamIDFriend /*class CSteamID*/, string pchMsgToSend /*const char **/ ) public bool ReplyToFriendMessage( CSteamID steamIDFriend /*class CSteamID*/, string pchMsgToSend /*const char **/ )
{ {
return _pi.ISteamFriends_ReplyToFriendMessage( steamIDFriend.Value, pchMsgToSend ); return platform.ISteamFriends_ReplyToFriendMessage( steamIDFriend.Value, pchMsgToSend );
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t RequestClanOfficerList( CSteamID steamIDClan /*class CSteamID*/ ) public CallbackHandle RequestClanOfficerList( CSteamID steamIDClan /*class CSteamID*/, Action<ClanOfficerListResponse_t, bool> CallbackFunction = null /*Action<ClanOfficerListResponse_t, bool>*/ )
{ {
return _pi.ISteamFriends_RequestClanOfficerList( steamIDClan.Value ); SteamAPICall_t callback = 0;
callback = platform.ISteamFriends_RequestClanOfficerList( steamIDClan.Value );
if ( CallbackFunction == null ) return null;
return ClanOfficerListResponse_t.CallResult( steamworks, callback, CallbackFunction );
} }
// void // void
public void RequestFriendRichPresence( CSteamID steamIDFriend /*class CSteamID*/ ) public void RequestFriendRichPresence( CSteamID steamIDFriend /*class CSteamID*/ )
{ {
_pi.ISteamFriends_RequestFriendRichPresence( steamIDFriend.Value ); platform.ISteamFriends_RequestFriendRichPresence( steamIDFriend.Value );
} }
// bool // bool
public bool RequestUserInformation( CSteamID steamIDUser /*class CSteamID*/, bool bRequireNameOnly /*bool*/ ) public bool RequestUserInformation( CSteamID steamIDUser /*class CSteamID*/, bool bRequireNameOnly /*bool*/ )
{ {
return _pi.ISteamFriends_RequestUserInformation( steamIDUser.Value, bRequireNameOnly ); return platform.ISteamFriends_RequestUserInformation( steamIDUser.Value, bRequireNameOnly );
} }
// bool // bool
public bool SendClanChatMessage( CSteamID steamIDClanChat /*class CSteamID*/, string pchText /*const char **/ ) public bool SendClanChatMessage( CSteamID steamIDClanChat /*class CSteamID*/, string pchText /*const char **/ )
{ {
return _pi.ISteamFriends_SendClanChatMessage( steamIDClanChat.Value, pchText ); return platform.ISteamFriends_SendClanChatMessage( steamIDClanChat.Value, pchText );
} }
// void // void
public void SetInGameVoiceSpeaking( CSteamID steamIDUser /*class CSteamID*/, bool bSpeaking /*bool*/ ) public void SetInGameVoiceSpeaking( CSteamID steamIDUser /*class CSteamID*/, bool bSpeaking /*bool*/ )
{ {
_pi.ISteamFriends_SetInGameVoiceSpeaking( steamIDUser.Value, bSpeaking ); platform.ISteamFriends_SetInGameVoiceSpeaking( steamIDUser.Value, bSpeaking );
} }
// bool // bool
public bool SetListenForFriendsMessages( bool bInterceptEnabled /*bool*/ ) public bool SetListenForFriendsMessages( bool bInterceptEnabled /*bool*/ )
{ {
return _pi.ISteamFriends_SetListenForFriendsMessages( bInterceptEnabled ); return platform.ISteamFriends_SetListenForFriendsMessages( bInterceptEnabled );
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t SetPersonaName( string pchPersonaName /*const char **/ ) public CallbackHandle SetPersonaName( string pchPersonaName /*const char **/, Action<SetPersonaNameResponse_t, bool> CallbackFunction = null /*Action<SetPersonaNameResponse_t, bool>*/ )
{ {
return _pi.ISteamFriends_SetPersonaName( pchPersonaName ); SteamAPICall_t callback = 0;
callback = platform.ISteamFriends_SetPersonaName( pchPersonaName );
if ( CallbackFunction == null ) return null;
return SetPersonaNameResponse_t.CallResult( steamworks, callback, CallbackFunction );
} }
// void // void
public void SetPlayedWith( CSteamID steamIDUserPlayedWith /*class CSteamID*/ ) public void SetPlayedWith( CSteamID steamIDUserPlayedWith /*class CSteamID*/ )
{ {
_pi.ISteamFriends_SetPlayedWith( steamIDUserPlayedWith.Value ); platform.ISteamFriends_SetPlayedWith( steamIDUserPlayedWith.Value );
} }
// bool // bool
public bool SetRichPresence( string pchKey /*const char **/, string pchValue /*const char **/ ) public bool SetRichPresence( string pchKey /*const char **/, string pchValue /*const char **/ )
{ {
return _pi.ISteamFriends_SetRichPresence( pchKey, pchValue ); return platform.ISteamFriends_SetRichPresence( pchKey, pchValue );
} }
} }

View File

@ -3,304 +3,322 @@
namespace SteamNative namespace SteamNative
{ {
public unsafe class SteamGameServer : IDisposable internal unsafe class SteamGameServer : IDisposable
{ {
// //
// Holds a platform specific implentation // Holds a platform specific implentation
// //
internal Platform.Interface _pi; internal Platform.Interface platform;
internal Facepunch.Steamworks.BaseSteamworks steamworks;
// //
// Constructor decides which implementation to use based on current platform // Constructor decides which implementation to use based on current platform
// //
public SteamGameServer( IntPtr pointer ) public SteamGameServer( Facepunch.Steamworks.BaseSteamworks steamworks, IntPtr pointer )
{ {
if ( Platform.IsWindows64 ) _pi = new Platform.Win64( pointer ); this.steamworks = steamworks;
else if ( Platform.IsWindows32 ) _pi = new Platform.Win32( pointer );
else if ( Platform.IsLinux32 ) _pi = new Platform.Linux32( pointer ); if ( Platform.IsWindows64 ) platform = new Platform.Win64( pointer );
else if ( Platform.IsLinux64 ) _pi = new Platform.Linux64( pointer ); else if ( Platform.IsWindows32 ) platform = new Platform.Win32( pointer );
else if ( Platform.IsOsx ) _pi = new Platform.Mac( pointer ); else if ( Platform.IsLinux32 ) platform = new Platform.Linux32( pointer );
else if ( Platform.IsLinux64 ) platform = new Platform.Linux64( pointer );
else if ( Platform.IsOsx ) platform = new Platform.Mac( pointer );
} }
// //
// Class is invalid if we don't have a valid implementation // Class is invalid if we don't have a valid implementation
// //
public bool IsValid{ get{ return _pi != null && _pi.IsValid; } } public bool IsValid{ get{ return platform != null && platform.IsValid; } }
// //
// When shutting down clear all the internals to avoid accidental use // When shutting down clear all the internals to avoid accidental use
// //
public virtual void Dispose() public virtual void Dispose()
{ {
if ( _pi != null ) if ( platform != null )
{ {
_pi.Dispose(); platform.Dispose();
_pi = null; platform = null;
} }
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t AssociateWithClan( CSteamID steamIDClan /*class CSteamID*/ ) public CallbackHandle AssociateWithClan( CSteamID steamIDClan /*class CSteamID*/, Action<AssociateWithClanResult_t, bool> CallbackFunction = null /*Action<AssociateWithClanResult_t, bool>*/ )
{ {
return _pi.ISteamGameServer_AssociateWithClan( steamIDClan.Value ); SteamAPICall_t callback = 0;
callback = platform.ISteamGameServer_AssociateWithClan( steamIDClan.Value );
if ( CallbackFunction == null ) return null;
return AssociateWithClanResult_t.CallResult( steamworks, callback, CallbackFunction );
} }
// BeginAuthSessionResult // BeginAuthSessionResult
public BeginAuthSessionResult BeginAuthSession( IntPtr pAuthTicket /*const void **/, int cbAuthTicket /*int*/, CSteamID steamID /*class CSteamID*/ ) public BeginAuthSessionResult BeginAuthSession( IntPtr pAuthTicket /*const void **/, int cbAuthTicket /*int*/, CSteamID steamID /*class CSteamID*/ )
{ {
return _pi.ISteamGameServer_BeginAuthSession( (IntPtr) pAuthTicket, cbAuthTicket, steamID.Value ); return platform.ISteamGameServer_BeginAuthSession( (IntPtr) pAuthTicket, cbAuthTicket, steamID.Value );
} }
// bool // bool
public bool BLoggedOn() public bool BLoggedOn()
{ {
return _pi.ISteamGameServer_BLoggedOn(); return platform.ISteamGameServer_BLoggedOn();
} }
// bool // bool
public bool BSecure() public bool BSecure()
{ {
return _pi.ISteamGameServer_BSecure(); return platform.ISteamGameServer_BSecure();
} }
// bool // bool
public bool BUpdateUserData( CSteamID steamIDUser /*class CSteamID*/, string pchPlayerName /*const char **/, uint uScore /*uint32*/ ) public bool BUpdateUserData( CSteamID steamIDUser /*class CSteamID*/, string pchPlayerName /*const char **/, uint uScore /*uint32*/ )
{ {
return _pi.ISteamGameServer_BUpdateUserData( steamIDUser.Value, pchPlayerName, uScore ); return platform.ISteamGameServer_BUpdateUserData( steamIDUser.Value, pchPlayerName, uScore );
} }
// void // void
public void CancelAuthTicket( HAuthTicket hAuthTicket /*HAuthTicket*/ ) public void CancelAuthTicket( HAuthTicket hAuthTicket /*HAuthTicket*/ )
{ {
_pi.ISteamGameServer_CancelAuthTicket( hAuthTicket.Value ); platform.ISteamGameServer_CancelAuthTicket( hAuthTicket.Value );
} }
// void // void
public void ClearAllKeyValues() public void ClearAllKeyValues()
{ {
_pi.ISteamGameServer_ClearAllKeyValues(); platform.ISteamGameServer_ClearAllKeyValues();
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t ComputeNewPlayerCompatibility( CSteamID steamIDNewPlayer /*class CSteamID*/ ) public CallbackHandle ComputeNewPlayerCompatibility( CSteamID steamIDNewPlayer /*class CSteamID*/, Action<ComputeNewPlayerCompatibilityResult_t, bool> CallbackFunction = null /*Action<ComputeNewPlayerCompatibilityResult_t, bool>*/ )
{ {
return _pi.ISteamGameServer_ComputeNewPlayerCompatibility( steamIDNewPlayer.Value ); SteamAPICall_t callback = 0;
callback = platform.ISteamGameServer_ComputeNewPlayerCompatibility( steamIDNewPlayer.Value );
if ( CallbackFunction == null ) return null;
return ComputeNewPlayerCompatibilityResult_t.CallResult( steamworks, callback, CallbackFunction );
} }
// ulong // ulong
public ulong CreateUnauthenticatedUserConnection() public ulong CreateUnauthenticatedUserConnection()
{ {
return _pi.ISteamGameServer_CreateUnauthenticatedUserConnection(); return platform.ISteamGameServer_CreateUnauthenticatedUserConnection();
} }
// void // void
public void EnableHeartbeats( bool bActive /*bool*/ ) public void EnableHeartbeats( bool bActive /*bool*/ )
{ {
_pi.ISteamGameServer_EnableHeartbeats( bActive ); platform.ISteamGameServer_EnableHeartbeats( bActive );
} }
// void // void
public void EndAuthSession( CSteamID steamID /*class CSteamID*/ ) public void EndAuthSession( CSteamID steamID /*class CSteamID*/ )
{ {
_pi.ISteamGameServer_EndAuthSession( steamID.Value ); platform.ISteamGameServer_EndAuthSession( steamID.Value );
} }
// void // void
public void ForceHeartbeat() public void ForceHeartbeat()
{ {
_pi.ISteamGameServer_ForceHeartbeat(); platform.ISteamGameServer_ForceHeartbeat();
} }
// HAuthTicket // HAuthTicket
public HAuthTicket GetAuthSessionTicket( IntPtr pTicket /*void **/, int cbMaxTicket /*int*/, out uint pcbTicket /*uint32 **/ ) public HAuthTicket GetAuthSessionTicket( IntPtr pTicket /*void **/, int cbMaxTicket /*int*/, out uint pcbTicket /*uint32 **/ )
{ {
return _pi.ISteamGameServer_GetAuthSessionTicket( (IntPtr) pTicket, cbMaxTicket, out pcbTicket ); return platform.ISteamGameServer_GetAuthSessionTicket( (IntPtr) pTicket, cbMaxTicket, out pcbTicket );
} }
// void // void
public void GetGameplayStats() public void GetGameplayStats()
{ {
_pi.ISteamGameServer_GetGameplayStats(); platform.ISteamGameServer_GetGameplayStats();
} }
// int // int
public int GetNextOutgoingPacket( IntPtr pOut /*void **/, int cbMaxOut /*int*/, out uint pNetAdr /*uint32 **/, out ushort pPort /*uint16 **/ ) public int GetNextOutgoingPacket( IntPtr pOut /*void **/, int cbMaxOut /*int*/, out uint pNetAdr /*uint32 **/, out ushort pPort /*uint16 **/ )
{ {
return _pi.ISteamGameServer_GetNextOutgoingPacket( (IntPtr) pOut, cbMaxOut, out pNetAdr, out pPort ); return platform.ISteamGameServer_GetNextOutgoingPacket( (IntPtr) pOut, cbMaxOut, out pNetAdr, out pPort );
} }
// uint // uint
public uint GetPublicIP() public uint GetPublicIP()
{ {
return _pi.ISteamGameServer_GetPublicIP(); return platform.ISteamGameServer_GetPublicIP();
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t GetServerReputation() public CallbackHandle GetServerReputation( Action<GSReputation_t, bool> CallbackFunction = null /*Action<GSReputation_t, bool>*/ )
{ {
return _pi.ISteamGameServer_GetServerReputation(); SteamAPICall_t callback = 0;
callback = platform.ISteamGameServer_GetServerReputation();
if ( CallbackFunction == null ) return null;
return GSReputation_t.CallResult( steamworks, callback, CallbackFunction );
} }
// ulong // ulong
public ulong GetSteamID() public ulong GetSteamID()
{ {
return _pi.ISteamGameServer_GetSteamID(); return platform.ISteamGameServer_GetSteamID();
} }
// bool // bool
public bool HandleIncomingPacket( IntPtr pData /*const void **/, int cbData /*int*/, uint srcIP /*uint32*/, ushort srcPort /*uint16*/ ) public bool HandleIncomingPacket( IntPtr pData /*const void **/, int cbData /*int*/, uint srcIP /*uint32*/, ushort srcPort /*uint16*/ )
{ {
return _pi.ISteamGameServer_HandleIncomingPacket( (IntPtr) pData, cbData, srcIP, srcPort ); return platform.ISteamGameServer_HandleIncomingPacket( (IntPtr) pData, cbData, srcIP, srcPort );
} }
// bool // bool
public bool InitGameServer( uint unIP /*uint32*/, ushort usGamePort /*uint16*/, ushort usQueryPort /*uint16*/, uint unFlags /*uint32*/, AppId_t nGameAppId /*AppId_t*/, string pchVersionString /*const char **/ ) public bool InitGameServer( uint unIP /*uint32*/, ushort usGamePort /*uint16*/, ushort usQueryPort /*uint16*/, uint unFlags /*uint32*/, AppId_t nGameAppId /*AppId_t*/, string pchVersionString /*const char **/ )
{ {
return _pi.ISteamGameServer_InitGameServer( unIP, usGamePort, usQueryPort, unFlags, nGameAppId.Value, pchVersionString ); return platform.ISteamGameServer_InitGameServer( unIP, usGamePort, usQueryPort, unFlags, nGameAppId.Value, pchVersionString );
} }
// void // void
public void LogOff() public void LogOff()
{ {
_pi.ISteamGameServer_LogOff(); platform.ISteamGameServer_LogOff();
} }
// void // void
public void LogOn( string pszToken /*const char **/ ) public void LogOn( string pszToken /*const char **/ )
{ {
_pi.ISteamGameServer_LogOn( pszToken ); platform.ISteamGameServer_LogOn( pszToken );
} }
// void // void
public void LogOnAnonymous() public void LogOnAnonymous()
{ {
_pi.ISteamGameServer_LogOnAnonymous(); platform.ISteamGameServer_LogOnAnonymous();
} }
// bool // bool
public bool RequestUserGroupStatus( CSteamID steamIDUser /*class CSteamID*/, CSteamID steamIDGroup /*class CSteamID*/ ) public bool RequestUserGroupStatus( CSteamID steamIDUser /*class CSteamID*/, CSteamID steamIDGroup /*class CSteamID*/ )
{ {
return _pi.ISteamGameServer_RequestUserGroupStatus( steamIDUser.Value, steamIDGroup.Value ); return platform.ISteamGameServer_RequestUserGroupStatus( steamIDUser.Value, steamIDGroup.Value );
} }
// bool // bool
public bool SendUserConnectAndAuthenticate( uint unIPClient /*uint32*/, IntPtr pvAuthBlob /*const void **/, uint cubAuthBlobSize /*uint32*/, out CSteamID pSteamIDUser /*class CSteamID **/ ) public bool SendUserConnectAndAuthenticate( uint unIPClient /*uint32*/, IntPtr pvAuthBlob /*const void **/, uint cubAuthBlobSize /*uint32*/, out CSteamID pSteamIDUser /*class CSteamID **/ )
{ {
return _pi.ISteamGameServer_SendUserConnectAndAuthenticate( unIPClient, (IntPtr) pvAuthBlob, cubAuthBlobSize, out pSteamIDUser.Value ); return platform.ISteamGameServer_SendUserConnectAndAuthenticate( unIPClient, (IntPtr) pvAuthBlob, cubAuthBlobSize, out pSteamIDUser.Value );
} }
// void // void
public void SendUserDisconnect( CSteamID steamIDUser /*class CSteamID*/ ) public void SendUserDisconnect( CSteamID steamIDUser /*class CSteamID*/ )
{ {
_pi.ISteamGameServer_SendUserDisconnect( steamIDUser.Value ); platform.ISteamGameServer_SendUserDisconnect( steamIDUser.Value );
} }
// void // void
public void SetBotPlayerCount( int cBotplayers /*int*/ ) public void SetBotPlayerCount( int cBotplayers /*int*/ )
{ {
_pi.ISteamGameServer_SetBotPlayerCount( cBotplayers ); platform.ISteamGameServer_SetBotPlayerCount( cBotplayers );
} }
// void // void
public void SetDedicatedServer( bool bDedicated /*bool*/ ) public void SetDedicatedServer( bool bDedicated /*bool*/ )
{ {
_pi.ISteamGameServer_SetDedicatedServer( bDedicated ); platform.ISteamGameServer_SetDedicatedServer( bDedicated );
} }
// void // void
public void SetGameData( string pchGameData /*const char **/ ) public void SetGameData( string pchGameData /*const char **/ )
{ {
_pi.ISteamGameServer_SetGameData( pchGameData ); platform.ISteamGameServer_SetGameData( pchGameData );
} }
// void // void
public void SetGameDescription( string pszGameDescription /*const char **/ ) public void SetGameDescription( string pszGameDescription /*const char **/ )
{ {
_pi.ISteamGameServer_SetGameDescription( pszGameDescription ); platform.ISteamGameServer_SetGameDescription( pszGameDescription );
} }
// void // void
public void SetGameTags( string pchGameTags /*const char **/ ) public void SetGameTags( string pchGameTags /*const char **/ )
{ {
_pi.ISteamGameServer_SetGameTags( pchGameTags ); platform.ISteamGameServer_SetGameTags( pchGameTags );
} }
// void // void
public void SetHeartbeatInterval( int iHeartbeatInterval /*int*/ ) public void SetHeartbeatInterval( int iHeartbeatInterval /*int*/ )
{ {
_pi.ISteamGameServer_SetHeartbeatInterval( iHeartbeatInterval ); platform.ISteamGameServer_SetHeartbeatInterval( iHeartbeatInterval );
} }
// void // void
public void SetKeyValue( string pKey /*const char **/, string pValue /*const char **/ ) public void SetKeyValue( string pKey /*const char **/, string pValue /*const char **/ )
{ {
_pi.ISteamGameServer_SetKeyValue( pKey, pValue ); platform.ISteamGameServer_SetKeyValue( pKey, pValue );
} }
// void // void
public void SetMapName( string pszMapName /*const char **/ ) public void SetMapName( string pszMapName /*const char **/ )
{ {
_pi.ISteamGameServer_SetMapName( pszMapName ); platform.ISteamGameServer_SetMapName( pszMapName );
} }
// void // void
public void SetMaxPlayerCount( int cPlayersMax /*int*/ ) public void SetMaxPlayerCount( int cPlayersMax /*int*/ )
{ {
_pi.ISteamGameServer_SetMaxPlayerCount( cPlayersMax ); platform.ISteamGameServer_SetMaxPlayerCount( cPlayersMax );
} }
// void // void
public void SetModDir( string pszModDir /*const char **/ ) public void SetModDir( string pszModDir /*const char **/ )
{ {
_pi.ISteamGameServer_SetModDir( pszModDir ); platform.ISteamGameServer_SetModDir( pszModDir );
} }
// void // void
public void SetPasswordProtected( bool bPasswordProtected /*bool*/ ) public void SetPasswordProtected( bool bPasswordProtected /*bool*/ )
{ {
_pi.ISteamGameServer_SetPasswordProtected( bPasswordProtected ); platform.ISteamGameServer_SetPasswordProtected( bPasswordProtected );
} }
// void // void
public void SetProduct( string pszProduct /*const char **/ ) public void SetProduct( string pszProduct /*const char **/ )
{ {
_pi.ISteamGameServer_SetProduct( pszProduct ); platform.ISteamGameServer_SetProduct( pszProduct );
} }
// void // void
public void SetRegion( string pszRegion /*const char **/ ) public void SetRegion( string pszRegion /*const char **/ )
{ {
_pi.ISteamGameServer_SetRegion( pszRegion ); platform.ISteamGameServer_SetRegion( pszRegion );
} }
// void // void
public void SetServerName( string pszServerName /*const char **/ ) public void SetServerName( string pszServerName /*const char **/ )
{ {
_pi.ISteamGameServer_SetServerName( pszServerName ); platform.ISteamGameServer_SetServerName( pszServerName );
} }
// void // void
public void SetSpectatorPort( ushort unSpectatorPort /*uint16*/ ) public void SetSpectatorPort( ushort unSpectatorPort /*uint16*/ )
{ {
_pi.ISteamGameServer_SetSpectatorPort( unSpectatorPort ); platform.ISteamGameServer_SetSpectatorPort( unSpectatorPort );
} }
// void // void
public void SetSpectatorServerName( string pszSpectatorServerName /*const char **/ ) public void SetSpectatorServerName( string pszSpectatorServerName /*const char **/ )
{ {
_pi.ISteamGameServer_SetSpectatorServerName( pszSpectatorServerName ); platform.ISteamGameServer_SetSpectatorServerName( pszSpectatorServerName );
} }
// UserHasLicenseForAppResult // UserHasLicenseForAppResult
public UserHasLicenseForAppResult UserHasLicenseForApp( CSteamID steamID /*class CSteamID*/, AppId_t appID /*AppId_t*/ ) public UserHasLicenseForAppResult UserHasLicenseForApp( CSteamID steamID /*class CSteamID*/, AppId_t appID /*AppId_t*/ )
{ {
return _pi.ISteamGameServer_UserHasLicenseForApp( steamID.Value, appID.Value ); return platform.ISteamGameServer_UserHasLicenseForApp( steamID.Value, appID.Value );
} }
// bool // bool
public bool WasRestartRequested() public bool WasRestartRequested()
{ {
return _pi.ISteamGameServer_WasRestartRequested(); return platform.ISteamGameServer_WasRestartRequested();
} }
} }

View File

@ -3,100 +3,113 @@
namespace SteamNative namespace SteamNative
{ {
public unsafe class SteamGameServerStats : IDisposable internal unsafe class SteamGameServerStats : IDisposable
{ {
// //
// Holds a platform specific implentation // Holds a platform specific implentation
// //
internal Platform.Interface _pi; internal Platform.Interface platform;
internal Facepunch.Steamworks.BaseSteamworks steamworks;
// //
// Constructor decides which implementation to use based on current platform // Constructor decides which implementation to use based on current platform
// //
public SteamGameServerStats( IntPtr pointer ) public SteamGameServerStats( Facepunch.Steamworks.BaseSteamworks steamworks, IntPtr pointer )
{ {
if ( Platform.IsWindows64 ) _pi = new Platform.Win64( pointer ); this.steamworks = steamworks;
else if ( Platform.IsWindows32 ) _pi = new Platform.Win32( pointer );
else if ( Platform.IsLinux32 ) _pi = new Platform.Linux32( pointer ); if ( Platform.IsWindows64 ) platform = new Platform.Win64( pointer );
else if ( Platform.IsLinux64 ) _pi = new Platform.Linux64( pointer ); else if ( Platform.IsWindows32 ) platform = new Platform.Win32( pointer );
else if ( Platform.IsOsx ) _pi = new Platform.Mac( pointer ); else if ( Platform.IsLinux32 ) platform = new Platform.Linux32( pointer );
else if ( Platform.IsLinux64 ) platform = new Platform.Linux64( pointer );
else if ( Platform.IsOsx ) platform = new Platform.Mac( pointer );
} }
// //
// Class is invalid if we don't have a valid implementation // Class is invalid if we don't have a valid implementation
// //
public bool IsValid{ get{ return _pi != null && _pi.IsValid; } } public bool IsValid{ get{ return platform != null && platform.IsValid; } }
// //
// When shutting down clear all the internals to avoid accidental use // When shutting down clear all the internals to avoid accidental use
// //
public virtual void Dispose() public virtual void Dispose()
{ {
if ( _pi != null ) if ( platform != null )
{ {
_pi.Dispose(); platform.Dispose();
_pi = null; platform = null;
} }
} }
// bool // bool
public bool ClearUserAchievement( CSteamID steamIDUser /*class CSteamID*/, string pchName /*const char **/ ) public bool ClearUserAchievement( CSteamID steamIDUser /*class CSteamID*/, string pchName /*const char **/ )
{ {
return _pi.ISteamGameServerStats_ClearUserAchievement( steamIDUser.Value, pchName ); return platform.ISteamGameServerStats_ClearUserAchievement( steamIDUser.Value, pchName );
} }
// bool // bool
public bool GetUserAchievement( CSteamID steamIDUser /*class CSteamID*/, string pchName /*const char **/, ref bool pbAchieved /*bool **/ ) public bool GetUserAchievement( CSteamID steamIDUser /*class CSteamID*/, string pchName /*const char **/, ref bool pbAchieved /*bool **/ )
{ {
return _pi.ISteamGameServerStats_GetUserAchievement( steamIDUser.Value, pchName, ref pbAchieved ); return platform.ISteamGameServerStats_GetUserAchievement( steamIDUser.Value, pchName, ref pbAchieved );
} }
// bool // bool
public bool GetUserStat( CSteamID steamIDUser /*class CSteamID*/, string pchName /*const char **/, out int pData /*int32 **/ ) public bool GetUserStat( CSteamID steamIDUser /*class CSteamID*/, string pchName /*const char **/, out int pData /*int32 **/ )
{ {
return _pi.ISteamGameServerStats_GetUserStat( steamIDUser.Value, pchName, out pData ); return platform.ISteamGameServerStats_GetUserStat( steamIDUser.Value, pchName, out pData );
} }
// bool // bool
public bool GetUserStat0( CSteamID steamIDUser /*class CSteamID*/, string pchName /*const char **/, out float pData /*float **/ ) public bool GetUserStat0( CSteamID steamIDUser /*class CSteamID*/, string pchName /*const char **/, out float pData /*float **/ )
{ {
return _pi.ISteamGameServerStats_GetUserStat0( steamIDUser.Value, pchName, out pData ); return platform.ISteamGameServerStats_GetUserStat0( steamIDUser.Value, pchName, out pData );
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t RequestUserStats( CSteamID steamIDUser /*class CSteamID*/ ) public CallbackHandle RequestUserStats( CSteamID steamIDUser /*class CSteamID*/, Action<UserStatsReceived_t, bool> CallbackFunction = null /*Action<UserStatsReceived_t, bool>*/ )
{ {
return _pi.ISteamGameServerStats_RequestUserStats( steamIDUser.Value ); SteamAPICall_t callback = 0;
callback = platform.ISteamGameServerStats_RequestUserStats( steamIDUser.Value );
if ( CallbackFunction == null ) return null;
return UserStatsReceived_t.CallResult( steamworks, callback, CallbackFunction );
} }
// bool // bool
public bool SetUserAchievement( CSteamID steamIDUser /*class CSteamID*/, string pchName /*const char **/ ) public bool SetUserAchievement( CSteamID steamIDUser /*class CSteamID*/, string pchName /*const char **/ )
{ {
return _pi.ISteamGameServerStats_SetUserAchievement( steamIDUser.Value, pchName ); return platform.ISteamGameServerStats_SetUserAchievement( steamIDUser.Value, pchName );
} }
// bool // bool
public bool SetUserStat( CSteamID steamIDUser /*class CSteamID*/, string pchName /*const char **/, int nData /*int32*/ ) public bool SetUserStat( CSteamID steamIDUser /*class CSteamID*/, string pchName /*const char **/, int nData /*int32*/ )
{ {
return _pi.ISteamGameServerStats_SetUserStat( steamIDUser.Value, pchName, nData ); return platform.ISteamGameServerStats_SetUserStat( steamIDUser.Value, pchName, nData );
} }
// bool // bool
public bool SetUserStat0( CSteamID steamIDUser /*class CSteamID*/, string pchName /*const char **/, float fData /*float*/ ) public bool SetUserStat0( CSteamID steamIDUser /*class CSteamID*/, string pchName /*const char **/, float fData /*float*/ )
{ {
return _pi.ISteamGameServerStats_SetUserStat0( steamIDUser.Value, pchName, fData ); return platform.ISteamGameServerStats_SetUserStat0( steamIDUser.Value, pchName, fData );
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t StoreUserStats( CSteamID steamIDUser /*class CSteamID*/ ) public CallbackHandle StoreUserStats( CSteamID steamIDUser /*class CSteamID*/, Action<GSStatsStored_t, bool> CallbackFunction = null /*Action<GSStatsStored_t, bool>*/ )
{ {
return _pi.ISteamGameServerStats_StoreUserStats( steamIDUser.Value ); SteamAPICall_t callback = 0;
callback = platform.ISteamGameServerStats_StoreUserStats( steamIDUser.Value );
if ( CallbackFunction == null ) return null;
return GSStatsStored_t.CallResult( steamworks, callback, CallbackFunction );
} }
// bool // bool
public bool UpdateUserAvgRateStat( CSteamID steamIDUser /*class CSteamID*/, string pchName /*const char **/, float flCountThisSession /*float*/, double dSessionLength /*double*/ ) public bool UpdateUserAvgRateStat( CSteamID steamIDUser /*class CSteamID*/, string pchName /*const char **/, float flCountThisSession /*float*/, double dSessionLength /*double*/ )
{ {
return _pi.ISteamGameServerStats_UpdateUserAvgRateStat( steamIDUser.Value, pchName, flCountThisSession, dSessionLength ); return platform.ISteamGameServerStats_UpdateUserAvgRateStat( steamIDUser.Value, pchName, flCountThisSession, dSessionLength );
} }
} }

View File

@ -3,250 +3,258 @@
namespace SteamNative namespace SteamNative
{ {
public unsafe class SteamHTMLSurface : IDisposable internal unsafe class SteamHTMLSurface : IDisposable
{ {
// //
// Holds a platform specific implentation // Holds a platform specific implentation
// //
internal Platform.Interface _pi; internal Platform.Interface platform;
internal Facepunch.Steamworks.BaseSteamworks steamworks;
// //
// Constructor decides which implementation to use based on current platform // Constructor decides which implementation to use based on current platform
// //
public SteamHTMLSurface( IntPtr pointer ) public SteamHTMLSurface( Facepunch.Steamworks.BaseSteamworks steamworks, IntPtr pointer )
{ {
if ( Platform.IsWindows64 ) _pi = new Platform.Win64( pointer ); this.steamworks = steamworks;
else if ( Platform.IsWindows32 ) _pi = new Platform.Win32( pointer );
else if ( Platform.IsLinux32 ) _pi = new Platform.Linux32( pointer ); if ( Platform.IsWindows64 ) platform = new Platform.Win64( pointer );
else if ( Platform.IsLinux64 ) _pi = new Platform.Linux64( pointer ); else if ( Platform.IsWindows32 ) platform = new Platform.Win32( pointer );
else if ( Platform.IsOsx ) _pi = new Platform.Mac( pointer ); else if ( Platform.IsLinux32 ) platform = new Platform.Linux32( pointer );
else if ( Platform.IsLinux64 ) platform = new Platform.Linux64( pointer );
else if ( Platform.IsOsx ) platform = new Platform.Mac( pointer );
} }
// //
// Class is invalid if we don't have a valid implementation // Class is invalid if we don't have a valid implementation
// //
public bool IsValid{ get{ return _pi != null && _pi.IsValid; } } public bool IsValid{ get{ return platform != null && platform.IsValid; } }
// //
// When shutting down clear all the internals to avoid accidental use // When shutting down clear all the internals to avoid accidental use
// //
public virtual void Dispose() public virtual void Dispose()
{ {
if ( _pi != null ) if ( platform != null )
{ {
_pi.Dispose(); platform.Dispose();
_pi = null; platform = null;
} }
} }
// void // void
public void AddHeader( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/, string pchKey /*const char **/, string pchValue /*const char **/ ) public void AddHeader( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/, string pchKey /*const char **/, string pchValue /*const char **/ )
{ {
_pi.ISteamHTMLSurface_AddHeader( unBrowserHandle.Value, pchKey, pchValue ); platform.ISteamHTMLSurface_AddHeader( unBrowserHandle.Value, pchKey, pchValue );
} }
// void // void
public void AllowStartRequest( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/, bool bAllowed /*bool*/ ) public void AllowStartRequest( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/, bool bAllowed /*bool*/ )
{ {
_pi.ISteamHTMLSurface_AllowStartRequest( unBrowserHandle.Value, bAllowed ); platform.ISteamHTMLSurface_AllowStartRequest( unBrowserHandle.Value, bAllowed );
} }
// void // void
public void CopyToClipboard( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/ ) public void CopyToClipboard( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/ )
{ {
_pi.ISteamHTMLSurface_CopyToClipboard( unBrowserHandle.Value ); platform.ISteamHTMLSurface_CopyToClipboard( unBrowserHandle.Value );
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t CreateBrowser( string pchUserAgent /*const char **/, string pchUserCSS /*const char **/ ) public CallbackHandle CreateBrowser( string pchUserAgent /*const char **/, string pchUserCSS /*const char **/, Action<HTML_BrowserReady_t, bool> CallbackFunction = null /*Action<HTML_BrowserReady_t, bool>*/ )
{ {
return _pi.ISteamHTMLSurface_CreateBrowser( pchUserAgent, pchUserCSS ); SteamAPICall_t callback = 0;
callback = platform.ISteamHTMLSurface_CreateBrowser( pchUserAgent, pchUserCSS );
if ( CallbackFunction == null ) return null;
return HTML_BrowserReady_t.CallResult( steamworks, callback, CallbackFunction );
} }
// void // void
public void DestructISteamHTMLSurface() public void DestructISteamHTMLSurface()
{ {
_pi.ISteamHTMLSurface_DestructISteamHTMLSurface(); platform.ISteamHTMLSurface_DestructISteamHTMLSurface();
} }
// void // void
public void ExecuteJavascript( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/, string pchScript /*const char **/ ) public void ExecuteJavascript( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/, string pchScript /*const char **/ )
{ {
_pi.ISteamHTMLSurface_ExecuteJavascript( unBrowserHandle.Value, pchScript ); platform.ISteamHTMLSurface_ExecuteJavascript( unBrowserHandle.Value, pchScript );
} }
// void // void
public void Find( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/, string pchSearchStr /*const char **/, bool bCurrentlyInFind /*bool*/, bool bReverse /*bool*/ ) public void Find( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/, string pchSearchStr /*const char **/, bool bCurrentlyInFind /*bool*/, bool bReverse /*bool*/ )
{ {
_pi.ISteamHTMLSurface_Find( unBrowserHandle.Value, pchSearchStr, bCurrentlyInFind, bReverse ); platform.ISteamHTMLSurface_Find( unBrowserHandle.Value, pchSearchStr, bCurrentlyInFind, bReverse );
} }
// void // void
public void GetLinkAtPosition( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/, int x /*int*/, int y /*int*/ ) public void GetLinkAtPosition( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/, int x /*int*/, int y /*int*/ )
{ {
_pi.ISteamHTMLSurface_GetLinkAtPosition( unBrowserHandle.Value, x, y ); platform.ISteamHTMLSurface_GetLinkAtPosition( unBrowserHandle.Value, x, y );
} }
// void // void
public void GoBack( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/ ) public void GoBack( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/ )
{ {
_pi.ISteamHTMLSurface_GoBack( unBrowserHandle.Value ); platform.ISteamHTMLSurface_GoBack( unBrowserHandle.Value );
} }
// void // void
public void GoForward( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/ ) public void GoForward( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/ )
{ {
_pi.ISteamHTMLSurface_GoForward( unBrowserHandle.Value ); platform.ISteamHTMLSurface_GoForward( unBrowserHandle.Value );
} }
// bool // bool
public bool Init() public bool Init()
{ {
return _pi.ISteamHTMLSurface_Init(); return platform.ISteamHTMLSurface_Init();
} }
// void // void
public void JSDialogResponse( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/, bool bResult /*bool*/ ) public void JSDialogResponse( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/, bool bResult /*bool*/ )
{ {
_pi.ISteamHTMLSurface_JSDialogResponse( unBrowserHandle.Value, bResult ); platform.ISteamHTMLSurface_JSDialogResponse( unBrowserHandle.Value, bResult );
} }
// void // void
public void KeyChar( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/, uint cUnicodeChar /*uint32*/, HTMLKeyModifiers eHTMLKeyModifiers /*ISteamHTMLSurface::EHTMLKeyModifiers*/ ) public void KeyChar( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/, uint cUnicodeChar /*uint32*/, HTMLKeyModifiers eHTMLKeyModifiers /*ISteamHTMLSurface::EHTMLKeyModifiers*/ )
{ {
_pi.ISteamHTMLSurface_KeyChar( unBrowserHandle.Value, cUnicodeChar, eHTMLKeyModifiers ); platform.ISteamHTMLSurface_KeyChar( unBrowserHandle.Value, cUnicodeChar, eHTMLKeyModifiers );
} }
// void // void
public void KeyDown( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/, uint nNativeKeyCode /*uint32*/, HTMLKeyModifiers eHTMLKeyModifiers /*ISteamHTMLSurface::EHTMLKeyModifiers*/ ) public void KeyDown( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/, uint nNativeKeyCode /*uint32*/, HTMLKeyModifiers eHTMLKeyModifiers /*ISteamHTMLSurface::EHTMLKeyModifiers*/ )
{ {
_pi.ISteamHTMLSurface_KeyDown( unBrowserHandle.Value, nNativeKeyCode, eHTMLKeyModifiers ); platform.ISteamHTMLSurface_KeyDown( unBrowserHandle.Value, nNativeKeyCode, eHTMLKeyModifiers );
} }
// void // void
public void KeyUp( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/, uint nNativeKeyCode /*uint32*/, HTMLKeyModifiers eHTMLKeyModifiers /*ISteamHTMLSurface::EHTMLKeyModifiers*/ ) public void KeyUp( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/, uint nNativeKeyCode /*uint32*/, HTMLKeyModifiers eHTMLKeyModifiers /*ISteamHTMLSurface::EHTMLKeyModifiers*/ )
{ {
_pi.ISteamHTMLSurface_KeyUp( unBrowserHandle.Value, nNativeKeyCode, eHTMLKeyModifiers ); platform.ISteamHTMLSurface_KeyUp( unBrowserHandle.Value, nNativeKeyCode, eHTMLKeyModifiers );
} }
// void // void
public void LoadURL( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/, string pchURL /*const char **/, string pchPostData /*const char **/ ) public void LoadURL( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/, string pchURL /*const char **/, string pchPostData /*const char **/ )
{ {
_pi.ISteamHTMLSurface_LoadURL( unBrowserHandle.Value, pchURL, pchPostData ); platform.ISteamHTMLSurface_LoadURL( unBrowserHandle.Value, pchURL, pchPostData );
} }
// void // void
public void MouseDoubleClick( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/, HTMLMouseButton eMouseButton /*ISteamHTMLSurface::EHTMLMouseButton*/ ) public void MouseDoubleClick( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/, HTMLMouseButton eMouseButton /*ISteamHTMLSurface::EHTMLMouseButton*/ )
{ {
_pi.ISteamHTMLSurface_MouseDoubleClick( unBrowserHandle.Value, eMouseButton ); platform.ISteamHTMLSurface_MouseDoubleClick( unBrowserHandle.Value, eMouseButton );
} }
// void // void
public void MouseDown( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/, HTMLMouseButton eMouseButton /*ISteamHTMLSurface::EHTMLMouseButton*/ ) public void MouseDown( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/, HTMLMouseButton eMouseButton /*ISteamHTMLSurface::EHTMLMouseButton*/ )
{ {
_pi.ISteamHTMLSurface_MouseDown( unBrowserHandle.Value, eMouseButton ); platform.ISteamHTMLSurface_MouseDown( unBrowserHandle.Value, eMouseButton );
} }
// void // void
public void MouseMove( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/, int x /*int*/, int y /*int*/ ) public void MouseMove( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/, int x /*int*/, int y /*int*/ )
{ {
_pi.ISteamHTMLSurface_MouseMove( unBrowserHandle.Value, x, y ); platform.ISteamHTMLSurface_MouseMove( unBrowserHandle.Value, x, y );
} }
// void // void
public void MouseUp( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/, HTMLMouseButton eMouseButton /*ISteamHTMLSurface::EHTMLMouseButton*/ ) public void MouseUp( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/, HTMLMouseButton eMouseButton /*ISteamHTMLSurface::EHTMLMouseButton*/ )
{ {
_pi.ISteamHTMLSurface_MouseUp( unBrowserHandle.Value, eMouseButton ); platform.ISteamHTMLSurface_MouseUp( unBrowserHandle.Value, eMouseButton );
} }
// void // void
public void MouseWheel( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/, int nDelta /*int32*/ ) public void MouseWheel( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/, int nDelta /*int32*/ )
{ {
_pi.ISteamHTMLSurface_MouseWheel( unBrowserHandle.Value, nDelta ); platform.ISteamHTMLSurface_MouseWheel( unBrowserHandle.Value, nDelta );
} }
// void // void
public void PasteFromClipboard( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/ ) public void PasteFromClipboard( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/ )
{ {
_pi.ISteamHTMLSurface_PasteFromClipboard( unBrowserHandle.Value ); platform.ISteamHTMLSurface_PasteFromClipboard( unBrowserHandle.Value );
} }
// void // void
public void Reload( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/ ) public void Reload( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/ )
{ {
_pi.ISteamHTMLSurface_Reload( unBrowserHandle.Value ); platform.ISteamHTMLSurface_Reload( unBrowserHandle.Value );
} }
// void // void
public void RemoveBrowser( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/ ) public void RemoveBrowser( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/ )
{ {
_pi.ISteamHTMLSurface_RemoveBrowser( unBrowserHandle.Value ); platform.ISteamHTMLSurface_RemoveBrowser( unBrowserHandle.Value );
} }
// void // void
public void SetBackgroundMode( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/, bool bBackgroundMode /*bool*/ ) public void SetBackgroundMode( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/, bool bBackgroundMode /*bool*/ )
{ {
_pi.ISteamHTMLSurface_SetBackgroundMode( unBrowserHandle.Value, bBackgroundMode ); platform.ISteamHTMLSurface_SetBackgroundMode( unBrowserHandle.Value, bBackgroundMode );
} }
// void // void
public void SetCookie( string pchHostname /*const char **/, string pchKey /*const char **/, string pchValue /*const char **/, string pchPath /*const char **/, RTime32 nExpires /*RTime32*/, bool bSecure /*bool*/, bool bHTTPOnly /*bool*/ ) public void SetCookie( string pchHostname /*const char **/, string pchKey /*const char **/, string pchValue /*const char **/, string pchPath /*const char **/, RTime32 nExpires /*RTime32*/, bool bSecure /*bool*/, bool bHTTPOnly /*bool*/ )
{ {
_pi.ISteamHTMLSurface_SetCookie( pchHostname, pchKey, pchValue, pchPath, nExpires.Value, bSecure, bHTTPOnly ); platform.ISteamHTMLSurface_SetCookie( pchHostname, pchKey, pchValue, pchPath, nExpires.Value, bSecure, bHTTPOnly );
} }
// void // void
public void SetHorizontalScroll( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/, uint nAbsolutePixelScroll /*uint32*/ ) public void SetHorizontalScroll( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/, uint nAbsolutePixelScroll /*uint32*/ )
{ {
_pi.ISteamHTMLSurface_SetHorizontalScroll( unBrowserHandle.Value, nAbsolutePixelScroll ); platform.ISteamHTMLSurface_SetHorizontalScroll( unBrowserHandle.Value, nAbsolutePixelScroll );
} }
// void // void
public void SetKeyFocus( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/, bool bHasKeyFocus /*bool*/ ) public void SetKeyFocus( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/, bool bHasKeyFocus /*bool*/ )
{ {
_pi.ISteamHTMLSurface_SetKeyFocus( unBrowserHandle.Value, bHasKeyFocus ); platform.ISteamHTMLSurface_SetKeyFocus( unBrowserHandle.Value, bHasKeyFocus );
} }
// void // void
public void SetPageScaleFactor( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/, float flZoom /*float*/, int nPointX /*int*/, int nPointY /*int*/ ) public void SetPageScaleFactor( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/, float flZoom /*float*/, int nPointX /*int*/, int nPointY /*int*/ )
{ {
_pi.ISteamHTMLSurface_SetPageScaleFactor( unBrowserHandle.Value, flZoom, nPointX, nPointY ); platform.ISteamHTMLSurface_SetPageScaleFactor( unBrowserHandle.Value, flZoom, nPointX, nPointY );
} }
// void // void
public void SetSize( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/, uint unWidth /*uint32*/, uint unHeight /*uint32*/ ) public void SetSize( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/, uint unWidth /*uint32*/, uint unHeight /*uint32*/ )
{ {
_pi.ISteamHTMLSurface_SetSize( unBrowserHandle.Value, unWidth, unHeight ); platform.ISteamHTMLSurface_SetSize( unBrowserHandle.Value, unWidth, unHeight );
} }
// void // void
public void SetVerticalScroll( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/, uint nAbsolutePixelScroll /*uint32*/ ) public void SetVerticalScroll( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/, uint nAbsolutePixelScroll /*uint32*/ )
{ {
_pi.ISteamHTMLSurface_SetVerticalScroll( unBrowserHandle.Value, nAbsolutePixelScroll ); platform.ISteamHTMLSurface_SetVerticalScroll( unBrowserHandle.Value, nAbsolutePixelScroll );
} }
// bool // bool
public bool Shutdown() public bool Shutdown()
{ {
return _pi.ISteamHTMLSurface_Shutdown(); return platform.ISteamHTMLSurface_Shutdown();
} }
// void // void
public void StopFind( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/ ) public void StopFind( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/ )
{ {
_pi.ISteamHTMLSurface_StopFind( unBrowserHandle.Value ); platform.ISteamHTMLSurface_StopFind( unBrowserHandle.Value );
} }
// void // void
public void StopLoad( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/ ) public void StopLoad( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/ )
{ {
_pi.ISteamHTMLSurface_StopLoad( unBrowserHandle.Value ); platform.ISteamHTMLSurface_StopLoad( unBrowserHandle.Value );
} }
// void // void
public void ViewSource( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/ ) public void ViewSource( HHTMLBrowser unBrowserHandle /*HHTMLBrowser*/ )
{ {
_pi.ISteamHTMLSurface_ViewSource( unBrowserHandle.Value ); platform.ISteamHTMLSurface_ViewSource( unBrowserHandle.Value );
} }
} }

View File

@ -3,190 +3,193 @@
namespace SteamNative namespace SteamNative
{ {
public unsafe class SteamHTTP : IDisposable internal unsafe class SteamHTTP : IDisposable
{ {
// //
// Holds a platform specific implentation // Holds a platform specific implentation
// //
internal Platform.Interface _pi; internal Platform.Interface platform;
internal Facepunch.Steamworks.BaseSteamworks steamworks;
// //
// Constructor decides which implementation to use based on current platform // Constructor decides which implementation to use based on current platform
// //
public SteamHTTP( IntPtr pointer ) public SteamHTTP( Facepunch.Steamworks.BaseSteamworks steamworks, IntPtr pointer )
{ {
if ( Platform.IsWindows64 ) _pi = new Platform.Win64( pointer ); this.steamworks = steamworks;
else if ( Platform.IsWindows32 ) _pi = new Platform.Win32( pointer );
else if ( Platform.IsLinux32 ) _pi = new Platform.Linux32( pointer ); if ( Platform.IsWindows64 ) platform = new Platform.Win64( pointer );
else if ( Platform.IsLinux64 ) _pi = new Platform.Linux64( pointer ); else if ( Platform.IsWindows32 ) platform = new Platform.Win32( pointer );
else if ( Platform.IsOsx ) _pi = new Platform.Mac( pointer ); else if ( Platform.IsLinux32 ) platform = new Platform.Linux32( pointer );
else if ( Platform.IsLinux64 ) platform = new Platform.Linux64( pointer );
else if ( Platform.IsOsx ) platform = new Platform.Mac( pointer );
} }
// //
// Class is invalid if we don't have a valid implementation // Class is invalid if we don't have a valid implementation
// //
public bool IsValid{ get{ return _pi != null && _pi.IsValid; } } public bool IsValid{ get{ return platform != null && platform.IsValid; } }
// //
// When shutting down clear all the internals to avoid accidental use // When shutting down clear all the internals to avoid accidental use
// //
public virtual void Dispose() public virtual void Dispose()
{ {
if ( _pi != null ) if ( platform != null )
{ {
_pi.Dispose(); platform.Dispose();
_pi = null; platform = null;
} }
} }
// HTTPCookieContainerHandle // HTTPCookieContainerHandle
public HTTPCookieContainerHandle CreateCookieContainer( bool bAllowResponsesToModify /*bool*/ ) public HTTPCookieContainerHandle CreateCookieContainer( bool bAllowResponsesToModify /*bool*/ )
{ {
return _pi.ISteamHTTP_CreateCookieContainer( bAllowResponsesToModify ); return platform.ISteamHTTP_CreateCookieContainer( bAllowResponsesToModify );
} }
// HTTPRequestHandle // HTTPRequestHandle
public HTTPRequestHandle CreateHTTPRequest( HTTPMethod eHTTPRequestMethod /*EHTTPMethod*/, string pchAbsoluteURL /*const char **/ ) public HTTPRequestHandle CreateHTTPRequest( HTTPMethod eHTTPRequestMethod /*EHTTPMethod*/, string pchAbsoluteURL /*const char **/ )
{ {
return _pi.ISteamHTTP_CreateHTTPRequest( eHTTPRequestMethod, pchAbsoluteURL ); return platform.ISteamHTTP_CreateHTTPRequest( eHTTPRequestMethod, pchAbsoluteURL );
} }
// bool // bool
public bool DeferHTTPRequest( HTTPRequestHandle hRequest /*HTTPRequestHandle*/ ) public bool DeferHTTPRequest( HTTPRequestHandle hRequest /*HTTPRequestHandle*/ )
{ {
return _pi.ISteamHTTP_DeferHTTPRequest( hRequest.Value ); return platform.ISteamHTTP_DeferHTTPRequest( hRequest.Value );
} }
// bool // bool
public bool GetHTTPDownloadProgressPct( HTTPRequestHandle hRequest /*HTTPRequestHandle*/, out float pflPercentOut /*float **/ ) public bool GetHTTPDownloadProgressPct( HTTPRequestHandle hRequest /*HTTPRequestHandle*/, out float pflPercentOut /*float **/ )
{ {
return _pi.ISteamHTTP_GetHTTPDownloadProgressPct( hRequest.Value, out pflPercentOut ); return platform.ISteamHTTP_GetHTTPDownloadProgressPct( hRequest.Value, out pflPercentOut );
} }
// bool // bool
public bool GetHTTPRequestWasTimedOut( HTTPRequestHandle hRequest /*HTTPRequestHandle*/, ref bool pbWasTimedOut /*bool **/ ) public bool GetHTTPRequestWasTimedOut( HTTPRequestHandle hRequest /*HTTPRequestHandle*/, ref bool pbWasTimedOut /*bool **/ )
{ {
return _pi.ISteamHTTP_GetHTTPRequestWasTimedOut( hRequest.Value, ref pbWasTimedOut ); return platform.ISteamHTTP_GetHTTPRequestWasTimedOut( hRequest.Value, ref pbWasTimedOut );
} }
// bool // bool
public bool GetHTTPResponseBodyData( HTTPRequestHandle hRequest /*HTTPRequestHandle*/, out byte pBodyDataBuffer /*uint8 **/, uint unBufferSize /*uint32*/ ) public bool GetHTTPResponseBodyData( HTTPRequestHandle hRequest /*HTTPRequestHandle*/, out byte pBodyDataBuffer /*uint8 **/, uint unBufferSize /*uint32*/ )
{ {
return _pi.ISteamHTTP_GetHTTPResponseBodyData( hRequest.Value, out pBodyDataBuffer, unBufferSize ); return platform.ISteamHTTP_GetHTTPResponseBodyData( hRequest.Value, out pBodyDataBuffer, unBufferSize );
} }
// bool // bool
public bool GetHTTPResponseBodySize( HTTPRequestHandle hRequest /*HTTPRequestHandle*/, out uint unBodySize /*uint32 **/ ) public bool GetHTTPResponseBodySize( HTTPRequestHandle hRequest /*HTTPRequestHandle*/, out uint unBodySize /*uint32 **/ )
{ {
return _pi.ISteamHTTP_GetHTTPResponseBodySize( hRequest.Value, out unBodySize ); return platform.ISteamHTTP_GetHTTPResponseBodySize( hRequest.Value, out unBodySize );
} }
// bool // bool
public bool GetHTTPResponseHeaderSize( HTTPRequestHandle hRequest /*HTTPRequestHandle*/, string pchHeaderName /*const char **/, out uint unResponseHeaderSize /*uint32 **/ ) public bool GetHTTPResponseHeaderSize( HTTPRequestHandle hRequest /*HTTPRequestHandle*/, string pchHeaderName /*const char **/, out uint unResponseHeaderSize /*uint32 **/ )
{ {
return _pi.ISteamHTTP_GetHTTPResponseHeaderSize( hRequest.Value, pchHeaderName, out unResponseHeaderSize ); return platform.ISteamHTTP_GetHTTPResponseHeaderSize( hRequest.Value, pchHeaderName, out unResponseHeaderSize );
} }
// bool // bool
public bool GetHTTPResponseHeaderValue( HTTPRequestHandle hRequest /*HTTPRequestHandle*/, string pchHeaderName /*const char **/, out byte pHeaderValueBuffer /*uint8 **/, uint unBufferSize /*uint32*/ ) public bool GetHTTPResponseHeaderValue( HTTPRequestHandle hRequest /*HTTPRequestHandle*/, string pchHeaderName /*const char **/, out byte pHeaderValueBuffer /*uint8 **/, uint unBufferSize /*uint32*/ )
{ {
return _pi.ISteamHTTP_GetHTTPResponseHeaderValue( hRequest.Value, pchHeaderName, out pHeaderValueBuffer, unBufferSize ); return platform.ISteamHTTP_GetHTTPResponseHeaderValue( hRequest.Value, pchHeaderName, out pHeaderValueBuffer, unBufferSize );
} }
// bool // bool
public bool GetHTTPStreamingResponseBodyData( HTTPRequestHandle hRequest /*HTTPRequestHandle*/, uint cOffset /*uint32*/, out byte pBodyDataBuffer /*uint8 **/, uint unBufferSize /*uint32*/ ) public bool GetHTTPStreamingResponseBodyData( HTTPRequestHandle hRequest /*HTTPRequestHandle*/, uint cOffset /*uint32*/, out byte pBodyDataBuffer /*uint8 **/, uint unBufferSize /*uint32*/ )
{ {
return _pi.ISteamHTTP_GetHTTPStreamingResponseBodyData( hRequest.Value, cOffset, out pBodyDataBuffer, unBufferSize ); return platform.ISteamHTTP_GetHTTPStreamingResponseBodyData( hRequest.Value, cOffset, out pBodyDataBuffer, unBufferSize );
} }
// bool // bool
public bool PrioritizeHTTPRequest( HTTPRequestHandle hRequest /*HTTPRequestHandle*/ ) public bool PrioritizeHTTPRequest( HTTPRequestHandle hRequest /*HTTPRequestHandle*/ )
{ {
return _pi.ISteamHTTP_PrioritizeHTTPRequest( hRequest.Value ); return platform.ISteamHTTP_PrioritizeHTTPRequest( hRequest.Value );
} }
// bool // bool
public bool ReleaseCookieContainer( HTTPCookieContainerHandle hCookieContainer /*HTTPCookieContainerHandle*/ ) public bool ReleaseCookieContainer( HTTPCookieContainerHandle hCookieContainer /*HTTPCookieContainerHandle*/ )
{ {
return _pi.ISteamHTTP_ReleaseCookieContainer( hCookieContainer.Value ); return platform.ISteamHTTP_ReleaseCookieContainer( hCookieContainer.Value );
} }
// bool // bool
public bool ReleaseHTTPRequest( HTTPRequestHandle hRequest /*HTTPRequestHandle*/ ) public bool ReleaseHTTPRequest( HTTPRequestHandle hRequest /*HTTPRequestHandle*/ )
{ {
return _pi.ISteamHTTP_ReleaseHTTPRequest( hRequest.Value ); return platform.ISteamHTTP_ReleaseHTTPRequest( hRequest.Value );
} }
// bool // bool
public bool SendHTTPRequest( HTTPRequestHandle hRequest /*HTTPRequestHandle*/, ref SteamAPICall_t pCallHandle /*SteamAPICall_t **/ ) public bool SendHTTPRequest( HTTPRequestHandle hRequest /*HTTPRequestHandle*/, ref SteamAPICall_t pCallHandle /*SteamAPICall_t **/ )
{ {
return _pi.ISteamHTTP_SendHTTPRequest( hRequest.Value, ref pCallHandle.Value ); return platform.ISteamHTTP_SendHTTPRequest( hRequest.Value, ref pCallHandle.Value );
} }
// bool // bool
public bool SendHTTPRequestAndStreamResponse( HTTPRequestHandle hRequest /*HTTPRequestHandle*/, ref SteamAPICall_t pCallHandle /*SteamAPICall_t **/ ) public bool SendHTTPRequestAndStreamResponse( HTTPRequestHandle hRequest /*HTTPRequestHandle*/, ref SteamAPICall_t pCallHandle /*SteamAPICall_t **/ )
{ {
return _pi.ISteamHTTP_SendHTTPRequestAndStreamResponse( hRequest.Value, ref pCallHandle.Value ); return platform.ISteamHTTP_SendHTTPRequestAndStreamResponse( hRequest.Value, ref pCallHandle.Value );
} }
// bool // bool
public bool SetCookie( HTTPCookieContainerHandle hCookieContainer /*HTTPCookieContainerHandle*/, string pchHost /*const char **/, string pchUrl /*const char **/, string pchCookie /*const char **/ ) public bool SetCookie( HTTPCookieContainerHandle hCookieContainer /*HTTPCookieContainerHandle*/, string pchHost /*const char **/, string pchUrl /*const char **/, string pchCookie /*const char **/ )
{ {
return _pi.ISteamHTTP_SetCookie( hCookieContainer.Value, pchHost, pchUrl, pchCookie ); return platform.ISteamHTTP_SetCookie( hCookieContainer.Value, pchHost, pchUrl, pchCookie );
} }
// bool // bool
public bool SetHTTPRequestAbsoluteTimeoutMS( HTTPRequestHandle hRequest /*HTTPRequestHandle*/, uint unMilliseconds /*uint32*/ ) public bool SetHTTPRequestAbsoluteTimeoutMS( HTTPRequestHandle hRequest /*HTTPRequestHandle*/, uint unMilliseconds /*uint32*/ )
{ {
return _pi.ISteamHTTP_SetHTTPRequestAbsoluteTimeoutMS( hRequest.Value, unMilliseconds ); return platform.ISteamHTTP_SetHTTPRequestAbsoluteTimeoutMS( hRequest.Value, unMilliseconds );
} }
// bool // bool
public bool SetHTTPRequestContextValue( HTTPRequestHandle hRequest /*HTTPRequestHandle*/, ulong ulContextValue /*uint64*/ ) public bool SetHTTPRequestContextValue( HTTPRequestHandle hRequest /*HTTPRequestHandle*/, ulong ulContextValue /*uint64*/ )
{ {
return _pi.ISteamHTTP_SetHTTPRequestContextValue( hRequest.Value, ulContextValue ); return platform.ISteamHTTP_SetHTTPRequestContextValue( hRequest.Value, ulContextValue );
} }
// bool // bool
public bool SetHTTPRequestCookieContainer( HTTPRequestHandle hRequest /*HTTPRequestHandle*/, HTTPCookieContainerHandle hCookieContainer /*HTTPCookieContainerHandle*/ ) public bool SetHTTPRequestCookieContainer( HTTPRequestHandle hRequest /*HTTPRequestHandle*/, HTTPCookieContainerHandle hCookieContainer /*HTTPCookieContainerHandle*/ )
{ {
return _pi.ISteamHTTP_SetHTTPRequestCookieContainer( hRequest.Value, hCookieContainer.Value ); return platform.ISteamHTTP_SetHTTPRequestCookieContainer( hRequest.Value, hCookieContainer.Value );
} }
// bool // bool
public bool SetHTTPRequestGetOrPostParameter( HTTPRequestHandle hRequest /*HTTPRequestHandle*/, string pchParamName /*const char **/, string pchParamValue /*const char **/ ) public bool SetHTTPRequestGetOrPostParameter( HTTPRequestHandle hRequest /*HTTPRequestHandle*/, string pchParamName /*const char **/, string pchParamValue /*const char **/ )
{ {
return _pi.ISteamHTTP_SetHTTPRequestGetOrPostParameter( hRequest.Value, pchParamName, pchParamValue ); return platform.ISteamHTTP_SetHTTPRequestGetOrPostParameter( hRequest.Value, pchParamName, pchParamValue );
} }
// bool // bool
public bool SetHTTPRequestHeaderValue( HTTPRequestHandle hRequest /*HTTPRequestHandle*/, string pchHeaderName /*const char **/, string pchHeaderValue /*const char **/ ) public bool SetHTTPRequestHeaderValue( HTTPRequestHandle hRequest /*HTTPRequestHandle*/, string pchHeaderName /*const char **/, string pchHeaderValue /*const char **/ )
{ {
return _pi.ISteamHTTP_SetHTTPRequestHeaderValue( hRequest.Value, pchHeaderName, pchHeaderValue ); return platform.ISteamHTTP_SetHTTPRequestHeaderValue( hRequest.Value, pchHeaderName, pchHeaderValue );
} }
// bool // bool
public bool SetHTTPRequestNetworkActivityTimeout( HTTPRequestHandle hRequest /*HTTPRequestHandle*/, uint unTimeoutSeconds /*uint32*/ ) public bool SetHTTPRequestNetworkActivityTimeout( HTTPRequestHandle hRequest /*HTTPRequestHandle*/, uint unTimeoutSeconds /*uint32*/ )
{ {
return _pi.ISteamHTTP_SetHTTPRequestNetworkActivityTimeout( hRequest.Value, unTimeoutSeconds ); return platform.ISteamHTTP_SetHTTPRequestNetworkActivityTimeout( hRequest.Value, unTimeoutSeconds );
} }
// bool // bool
public bool SetHTTPRequestRawPostBody( HTTPRequestHandle hRequest /*HTTPRequestHandle*/, string pchContentType /*const char **/, out byte pubBody /*uint8 **/, uint unBodyLen /*uint32*/ ) public bool SetHTTPRequestRawPostBody( HTTPRequestHandle hRequest /*HTTPRequestHandle*/, string pchContentType /*const char **/, out byte pubBody /*uint8 **/, uint unBodyLen /*uint32*/ )
{ {
return _pi.ISteamHTTP_SetHTTPRequestRawPostBody( hRequest.Value, pchContentType, out pubBody, unBodyLen ); return platform.ISteamHTTP_SetHTTPRequestRawPostBody( hRequest.Value, pchContentType, out pubBody, unBodyLen );
} }
// bool // bool
public bool SetHTTPRequestRequiresVerifiedCertificate( HTTPRequestHandle hRequest /*HTTPRequestHandle*/, bool bRequireVerifiedCertificate /*bool*/ ) public bool SetHTTPRequestRequiresVerifiedCertificate( HTTPRequestHandle hRequest /*HTTPRequestHandle*/, bool bRequireVerifiedCertificate /*bool*/ )
{ {
return _pi.ISteamHTTP_SetHTTPRequestRequiresVerifiedCertificate( hRequest.Value, bRequireVerifiedCertificate ); return platform.ISteamHTTP_SetHTTPRequestRequiresVerifiedCertificate( hRequest.Value, bRequireVerifiedCertificate );
} }
// bool // bool
public bool SetHTTPRequestUserAgentInfo( HTTPRequestHandle hRequest /*HTTPRequestHandle*/, string pchUserAgentInfo /*const char **/ ) public bool SetHTTPRequestUserAgentInfo( HTTPRequestHandle hRequest /*HTTPRequestHandle*/, string pchUserAgentInfo /*const char **/ )
{ {
return _pi.ISteamHTTP_SetHTTPRequestUserAgentInfo( hRequest.Value, pchUserAgentInfo ); return platform.ISteamHTTP_SetHTTPRequestUserAgentInfo( hRequest.Value, pchUserAgentInfo );
} }
} }

View File

@ -3,94 +3,97 @@
namespace SteamNative namespace SteamNative
{ {
public unsafe class SteamInventory : IDisposable internal unsafe class SteamInventory : IDisposable
{ {
// //
// Holds a platform specific implentation // Holds a platform specific implentation
// //
internal Platform.Interface _pi; internal Platform.Interface platform;
internal Facepunch.Steamworks.BaseSteamworks steamworks;
// //
// Constructor decides which implementation to use based on current platform // Constructor decides which implementation to use based on current platform
// //
public SteamInventory( IntPtr pointer ) public SteamInventory( Facepunch.Steamworks.BaseSteamworks steamworks, IntPtr pointer )
{ {
if ( Platform.IsWindows64 ) _pi = new Platform.Win64( pointer ); this.steamworks = steamworks;
else if ( Platform.IsWindows32 ) _pi = new Platform.Win32( pointer );
else if ( Platform.IsLinux32 ) _pi = new Platform.Linux32( pointer ); if ( Platform.IsWindows64 ) platform = new Platform.Win64( pointer );
else if ( Platform.IsLinux64 ) _pi = new Platform.Linux64( pointer ); else if ( Platform.IsWindows32 ) platform = new Platform.Win32( pointer );
else if ( Platform.IsOsx ) _pi = new Platform.Mac( pointer ); else if ( Platform.IsLinux32 ) platform = new Platform.Linux32( pointer );
else if ( Platform.IsLinux64 ) platform = new Platform.Linux64( pointer );
else if ( Platform.IsOsx ) platform = new Platform.Mac( pointer );
} }
// //
// Class is invalid if we don't have a valid implementation // Class is invalid if we don't have a valid implementation
// //
public bool IsValid{ get{ return _pi != null && _pi.IsValid; } } public bool IsValid{ get{ return platform != null && platform.IsValid; } }
// //
// When shutting down clear all the internals to avoid accidental use // When shutting down clear all the internals to avoid accidental use
// //
public virtual void Dispose() public virtual void Dispose()
{ {
if ( _pi != null ) if ( platform != null )
{ {
_pi.Dispose(); platform.Dispose();
_pi = null; platform = null;
} }
} }
// bool // bool
public bool AddPromoItem( ref SteamInventoryResult_t pResultHandle /*SteamInventoryResult_t **/, SteamItemDef_t itemDef /*SteamItemDef_t*/ ) public bool AddPromoItem( ref SteamInventoryResult_t pResultHandle /*SteamInventoryResult_t **/, SteamItemDef_t itemDef /*SteamItemDef_t*/ )
{ {
return _pi.ISteamInventory_AddPromoItem( ref pResultHandle.Value, itemDef.Value ); return platform.ISteamInventory_AddPromoItem( ref pResultHandle.Value, itemDef.Value );
} }
// bool // bool
public bool AddPromoItems( ref SteamInventoryResult_t pResultHandle /*SteamInventoryResult_t **/, IntPtr pArrayItemDefs /*const SteamItemDef_t **/, uint unArrayLength /*uint32*/ ) public bool AddPromoItems( ref SteamInventoryResult_t pResultHandle /*SteamInventoryResult_t **/, IntPtr pArrayItemDefs /*const SteamItemDef_t **/, uint unArrayLength /*uint32*/ )
{ {
return _pi.ISteamInventory_AddPromoItems( ref pResultHandle.Value, (IntPtr) pArrayItemDefs, unArrayLength ); return platform.ISteamInventory_AddPromoItems( ref pResultHandle.Value, (IntPtr) pArrayItemDefs, unArrayLength );
} }
// bool // bool
public bool CheckResultSteamID( SteamInventoryResult_t resultHandle /*SteamInventoryResult_t*/, CSteamID steamIDExpected /*class CSteamID*/ ) public bool CheckResultSteamID( SteamInventoryResult_t resultHandle /*SteamInventoryResult_t*/, CSteamID steamIDExpected /*class CSteamID*/ )
{ {
return _pi.ISteamInventory_CheckResultSteamID( resultHandle.Value, steamIDExpected.Value ); return platform.ISteamInventory_CheckResultSteamID( resultHandle.Value, steamIDExpected.Value );
} }
// bool // bool
public bool ConsumeItem( ref SteamInventoryResult_t pResultHandle /*SteamInventoryResult_t **/, SteamItemInstanceID_t itemConsume /*SteamItemInstanceID_t*/, uint unQuantity /*uint32*/ ) public bool ConsumeItem( ref SteamInventoryResult_t pResultHandle /*SteamInventoryResult_t **/, SteamItemInstanceID_t itemConsume /*SteamItemInstanceID_t*/, uint unQuantity /*uint32*/ )
{ {
return _pi.ISteamInventory_ConsumeItem( ref pResultHandle.Value, itemConsume.Value, unQuantity ); return platform.ISteamInventory_ConsumeItem( ref pResultHandle.Value, itemConsume.Value, unQuantity );
} }
// bool // bool
public bool DeserializeResult( ref SteamInventoryResult_t pOutResultHandle /*SteamInventoryResult_t **/, IntPtr pBuffer /*const void **/, uint unBufferSize /*uint32*/, bool bRESERVED_MUST_BE_FALSE /*bool*/ ) public bool DeserializeResult( ref SteamInventoryResult_t pOutResultHandle /*SteamInventoryResult_t **/, IntPtr pBuffer /*const void **/, uint unBufferSize /*uint32*/, bool bRESERVED_MUST_BE_FALSE /*bool*/ )
{ {
return _pi.ISteamInventory_DeserializeResult( ref pOutResultHandle.Value, (IntPtr) pBuffer, unBufferSize, bRESERVED_MUST_BE_FALSE ); return platform.ISteamInventory_DeserializeResult( ref pOutResultHandle.Value, (IntPtr) pBuffer, unBufferSize, bRESERVED_MUST_BE_FALSE );
} }
// void // void
public void DestroyResult( SteamInventoryResult_t resultHandle /*SteamInventoryResult_t*/ ) public void DestroyResult( SteamInventoryResult_t resultHandle /*SteamInventoryResult_t*/ )
{ {
_pi.ISteamInventory_DestroyResult( resultHandle.Value ); platform.ISteamInventory_DestroyResult( resultHandle.Value );
} }
// bool // bool
public bool ExchangeItems( ref SteamInventoryResult_t pResultHandle /*SteamInventoryResult_t **/, ref SteamItemDef_t pArrayGenerate /*const SteamItemDef_t **/, out uint punArrayGenerateQuantity /*const uint32 **/, uint unArrayGenerateLength /*uint32*/, IntPtr pArrayDestroy /*const SteamItemInstanceID_t **/, IntPtr punArrayDestroyQuantity /*const uint32 **/, uint unArrayDestroyLength /*uint32*/ ) public bool ExchangeItems( ref SteamInventoryResult_t pResultHandle /*SteamInventoryResult_t **/, ref SteamItemDef_t pArrayGenerate /*const SteamItemDef_t **/, out uint punArrayGenerateQuantity /*const uint32 **/, uint unArrayGenerateLength /*uint32*/, IntPtr pArrayDestroy /*const SteamItemInstanceID_t **/, IntPtr punArrayDestroyQuantity /*const uint32 **/, uint unArrayDestroyLength /*uint32*/ )
{ {
return _pi.ISteamInventory_ExchangeItems( ref pResultHandle.Value, ref pArrayGenerate.Value, out punArrayGenerateQuantity, unArrayGenerateLength, (IntPtr) pArrayDestroy, (IntPtr) punArrayDestroyQuantity, unArrayDestroyLength ); return platform.ISteamInventory_ExchangeItems( ref pResultHandle.Value, ref pArrayGenerate.Value, out punArrayGenerateQuantity, unArrayGenerateLength, (IntPtr) pArrayDestroy, (IntPtr) punArrayDestroyQuantity, unArrayDestroyLength );
} }
// bool // bool
public bool GenerateItems( ref SteamInventoryResult_t pResultHandle /*SteamInventoryResult_t **/, IntPtr pArrayItemDefs /*const SteamItemDef_t **/, out uint punArrayQuantity /*const uint32 **/, uint unArrayLength /*uint32*/ ) public bool GenerateItems( ref SteamInventoryResult_t pResultHandle /*SteamInventoryResult_t **/, IntPtr pArrayItemDefs /*const SteamItemDef_t **/, out uint punArrayQuantity /*const uint32 **/, uint unArrayLength /*uint32*/ )
{ {
return _pi.ISteamInventory_GenerateItems( ref pResultHandle.Value, (IntPtr) pArrayItemDefs, out punArrayQuantity, unArrayLength ); return platform.ISteamInventory_GenerateItems( ref pResultHandle.Value, (IntPtr) pArrayItemDefs, out punArrayQuantity, unArrayLength );
} }
// bool // bool
public bool GetAllItems( ref SteamInventoryResult_t pResultHandle /*SteamInventoryResult_t **/ ) public bool GetAllItems( ref SteamInventoryResult_t pResultHandle /*SteamInventoryResult_t **/ )
{ {
return _pi.ISteamInventory_GetAllItems( ref pResultHandle.Value ); return platform.ISteamInventory_GetAllItems( ref pResultHandle.Value );
} }
// bool // bool
@ -100,13 +103,13 @@ public SteamItemDef_t[] GetItemDefinitionIDs()
uint punItemDefIDsArraySize = 0; uint punItemDefIDsArraySize = 0;
bool success = false; bool success = false;
success = _pi.ISteamInventory_GetItemDefinitionIDs( IntPtr.Zero, out punItemDefIDsArraySize ); success = platform.ISteamInventory_GetItemDefinitionIDs( IntPtr.Zero, out punItemDefIDsArraySize );
if ( !success || punItemDefIDsArraySize == 0) return null; if ( !success || punItemDefIDsArraySize == 0) return null;
var pItemDefIDs = new SteamItemDef_t[punItemDefIDsArraySize]; var pItemDefIDs = new SteamItemDef_t[punItemDefIDsArraySize];
fixed ( void* pItemDefIDs_ptr = pItemDefIDs ) fixed ( void* pItemDefIDs_ptr = pItemDefIDs )
{ {
success = _pi.ISteamInventory_GetItemDefinitionIDs( (IntPtr) pItemDefIDs_ptr, out punItemDefIDsArraySize ); success = platform.ISteamInventory_GetItemDefinitionIDs( (IntPtr) pItemDefIDs_ptr, out punItemDefIDsArraySize );
if ( !success ) return null; if ( !success ) return null;
return pItemDefIDs; return pItemDefIDs;
} }
@ -120,7 +123,7 @@ public bool GetItemDefinitionProperty( SteamItemDef_t iDefinition /*SteamItemDef
pchValueBuffer = string.Empty; pchValueBuffer = string.Empty;
System.Text.StringBuilder pchValueBuffer_sb = new System.Text.StringBuilder( 4096 ); System.Text.StringBuilder pchValueBuffer_sb = new System.Text.StringBuilder( 4096 );
uint punValueBufferSizeOut = 4096; uint punValueBufferSizeOut = 4096;
bSuccess = _pi.ISteamInventory_GetItemDefinitionProperty( iDefinition.Value, pchPropertyName, pchValueBuffer_sb, out punValueBufferSizeOut ); bSuccess = platform.ISteamInventory_GetItemDefinitionProperty( iDefinition.Value, pchPropertyName, pchValueBuffer_sb, out punValueBufferSizeOut );
if ( !bSuccess ) return bSuccess; if ( !bSuccess ) return bSuccess;
pchValueBuffer = pchValueBuffer_sb.ToString(); pchValueBuffer = pchValueBuffer_sb.ToString();
return bSuccess; return bSuccess;
@ -129,7 +132,7 @@ public bool GetItemDefinitionProperty( SteamItemDef_t iDefinition /*SteamItemDef
// bool // bool
public bool GetItemsByID( ref SteamInventoryResult_t pResultHandle /*SteamInventoryResult_t **/, IntPtr pInstanceIDs /*const SteamItemInstanceID_t **/, uint unCountInstanceIDs /*uint32*/ ) public bool GetItemsByID( ref SteamInventoryResult_t pResultHandle /*SteamInventoryResult_t **/, IntPtr pInstanceIDs /*const SteamItemInstanceID_t **/, uint unCountInstanceIDs /*uint32*/ )
{ {
return _pi.ISteamInventory_GetItemsByID( ref pResultHandle.Value, (IntPtr) pInstanceIDs, unCountInstanceIDs ); return platform.ISteamInventory_GetItemsByID( ref pResultHandle.Value, (IntPtr) pInstanceIDs, unCountInstanceIDs );
} }
// bool // bool
@ -139,13 +142,13 @@ public SteamItemDetails_t[] GetResultItems( SteamInventoryResult_t resultHandle
uint punOutItemsArraySize = 0; uint punOutItemsArraySize = 0;
bool success = false; bool success = false;
success = _pi.ISteamInventory_GetResultItems( resultHandle.Value, IntPtr.Zero, out punOutItemsArraySize ); success = platform.ISteamInventory_GetResultItems( resultHandle.Value, IntPtr.Zero, out punOutItemsArraySize );
if ( !success || punOutItemsArraySize == 0) return null; if ( !success || punOutItemsArraySize == 0) return null;
var pOutItemsArray = new SteamItemDetails_t[punOutItemsArraySize]; var pOutItemsArray = new SteamItemDetails_t[punOutItemsArraySize];
fixed ( void* pOutItemsArray_ptr = pOutItemsArray ) fixed ( void* pOutItemsArray_ptr = pOutItemsArray )
{ {
success = _pi.ISteamInventory_GetResultItems( resultHandle.Value, (IntPtr) pOutItemsArray_ptr, out punOutItemsArraySize ); success = platform.ISteamInventory_GetResultItems( resultHandle.Value, (IntPtr) pOutItemsArray_ptr, out punOutItemsArraySize );
if ( !success ) return null; if ( !success ) return null;
return pOutItemsArray; return pOutItemsArray;
} }
@ -154,55 +157,55 @@ public SteamItemDetails_t[] GetResultItems( SteamInventoryResult_t resultHandle
// Result // Result
public Result GetResultStatus( SteamInventoryResult_t resultHandle /*SteamInventoryResult_t*/ ) public Result GetResultStatus( SteamInventoryResult_t resultHandle /*SteamInventoryResult_t*/ )
{ {
return _pi.ISteamInventory_GetResultStatus( resultHandle.Value ); return platform.ISteamInventory_GetResultStatus( resultHandle.Value );
} }
// uint // uint
public uint GetResultTimestamp( SteamInventoryResult_t resultHandle /*SteamInventoryResult_t*/ ) public uint GetResultTimestamp( SteamInventoryResult_t resultHandle /*SteamInventoryResult_t*/ )
{ {
return _pi.ISteamInventory_GetResultTimestamp( resultHandle.Value ); return platform.ISteamInventory_GetResultTimestamp( resultHandle.Value );
} }
// bool // bool
public bool GrantPromoItems( ref SteamInventoryResult_t pResultHandle /*SteamInventoryResult_t **/ ) public bool GrantPromoItems( ref SteamInventoryResult_t pResultHandle /*SteamInventoryResult_t **/ )
{ {
return _pi.ISteamInventory_GrantPromoItems( ref pResultHandle.Value ); return platform.ISteamInventory_GrantPromoItems( ref pResultHandle.Value );
} }
// bool // bool
public bool LoadItemDefinitions() public bool LoadItemDefinitions()
{ {
return _pi.ISteamInventory_LoadItemDefinitions(); return platform.ISteamInventory_LoadItemDefinitions();
} }
// void // void
public void SendItemDropHeartbeat() public void SendItemDropHeartbeat()
{ {
_pi.ISteamInventory_SendItemDropHeartbeat(); platform.ISteamInventory_SendItemDropHeartbeat();
} }
// bool // bool
public bool SerializeResult( SteamInventoryResult_t resultHandle /*SteamInventoryResult_t*/, IntPtr pOutBuffer /*void **/, out uint punOutBufferSize /*uint32 **/ ) public bool SerializeResult( SteamInventoryResult_t resultHandle /*SteamInventoryResult_t*/, IntPtr pOutBuffer /*void **/, out uint punOutBufferSize /*uint32 **/ )
{ {
return _pi.ISteamInventory_SerializeResult( resultHandle.Value, (IntPtr) pOutBuffer, out punOutBufferSize ); return platform.ISteamInventory_SerializeResult( resultHandle.Value, (IntPtr) pOutBuffer, out punOutBufferSize );
} }
// bool // bool
public bool TradeItems( ref SteamInventoryResult_t pResultHandle /*SteamInventoryResult_t **/, CSteamID steamIDTradePartner /*class CSteamID*/, ref SteamItemInstanceID_t pArrayGive /*const SteamItemInstanceID_t **/, out uint pArrayGiveQuantity /*const uint32 **/, uint nArrayGiveLength /*uint32*/, ref SteamItemInstanceID_t pArrayGet /*const SteamItemInstanceID_t **/, out uint pArrayGetQuantity /*const uint32 **/, uint nArrayGetLength /*uint32*/ ) public bool TradeItems( ref SteamInventoryResult_t pResultHandle /*SteamInventoryResult_t **/, CSteamID steamIDTradePartner /*class CSteamID*/, ref SteamItemInstanceID_t pArrayGive /*const SteamItemInstanceID_t **/, out uint pArrayGiveQuantity /*const uint32 **/, uint nArrayGiveLength /*uint32*/, ref SteamItemInstanceID_t pArrayGet /*const SteamItemInstanceID_t **/, out uint pArrayGetQuantity /*const uint32 **/, uint nArrayGetLength /*uint32*/ )
{ {
return _pi.ISteamInventory_TradeItems( ref pResultHandle.Value, steamIDTradePartner.Value, ref pArrayGive.Value, out pArrayGiveQuantity, nArrayGiveLength, ref pArrayGet.Value, out pArrayGetQuantity, nArrayGetLength ); return platform.ISteamInventory_TradeItems( ref pResultHandle.Value, steamIDTradePartner.Value, ref pArrayGive.Value, out pArrayGiveQuantity, nArrayGiveLength, ref pArrayGet.Value, out pArrayGetQuantity, nArrayGetLength );
} }
// bool // bool
public bool TransferItemQuantity( ref SteamInventoryResult_t pResultHandle /*SteamInventoryResult_t **/, SteamItemInstanceID_t itemIdSource /*SteamItemInstanceID_t*/, uint unQuantity /*uint32*/, SteamItemInstanceID_t itemIdDest /*SteamItemInstanceID_t*/ ) public bool TransferItemQuantity( ref SteamInventoryResult_t pResultHandle /*SteamInventoryResult_t **/, SteamItemInstanceID_t itemIdSource /*SteamItemInstanceID_t*/, uint unQuantity /*uint32*/, SteamItemInstanceID_t itemIdDest /*SteamItemInstanceID_t*/ )
{ {
return _pi.ISteamInventory_TransferItemQuantity( ref pResultHandle.Value, itemIdSource.Value, unQuantity, itemIdDest.Value ); return platform.ISteamInventory_TransferItemQuantity( ref pResultHandle.Value, itemIdSource.Value, unQuantity, itemIdDest.Value );
} }
// bool // bool
public bool TriggerItemDrop( ref SteamInventoryResult_t pResultHandle /*SteamInventoryResult_t **/, SteamItemDef_t dropListDefinition /*SteamItemDef_t*/ ) public bool TriggerItemDrop( ref SteamInventoryResult_t pResultHandle /*SteamInventoryResult_t **/, SteamItemDef_t dropListDefinition /*SteamItemDef_t*/ )
{ {
return _pi.ISteamInventory_TriggerItemDrop( ref pResultHandle.Value, dropListDefinition.Value ); return platform.ISteamInventory_TriggerItemDrop( ref pResultHandle.Value, dropListDefinition.Value );
} }
} }

View File

@ -3,124 +3,132 @@
namespace SteamNative namespace SteamNative
{ {
public unsafe class SteamMatchmaking : IDisposable internal unsafe class SteamMatchmaking : IDisposable
{ {
// //
// Holds a platform specific implentation // Holds a platform specific implentation
// //
internal Platform.Interface _pi; internal Platform.Interface platform;
internal Facepunch.Steamworks.BaseSteamworks steamworks;
// //
// Constructor decides which implementation to use based on current platform // Constructor decides which implementation to use based on current platform
// //
public SteamMatchmaking( IntPtr pointer ) public SteamMatchmaking( Facepunch.Steamworks.BaseSteamworks steamworks, IntPtr pointer )
{ {
if ( Platform.IsWindows64 ) _pi = new Platform.Win64( pointer ); this.steamworks = steamworks;
else if ( Platform.IsWindows32 ) _pi = new Platform.Win32( pointer );
else if ( Platform.IsLinux32 ) _pi = new Platform.Linux32( pointer ); if ( Platform.IsWindows64 ) platform = new Platform.Win64( pointer );
else if ( Platform.IsLinux64 ) _pi = new Platform.Linux64( pointer ); else if ( Platform.IsWindows32 ) platform = new Platform.Win32( pointer );
else if ( Platform.IsOsx ) _pi = new Platform.Mac( pointer ); else if ( Platform.IsLinux32 ) platform = new Platform.Linux32( pointer );
else if ( Platform.IsLinux64 ) platform = new Platform.Linux64( pointer );
else if ( Platform.IsOsx ) platform = new Platform.Mac( pointer );
} }
// //
// Class is invalid if we don't have a valid implementation // Class is invalid if we don't have a valid implementation
// //
public bool IsValid{ get{ return _pi != null && _pi.IsValid; } } public bool IsValid{ get{ return platform != null && platform.IsValid; } }
// //
// When shutting down clear all the internals to avoid accidental use // When shutting down clear all the internals to avoid accidental use
// //
public virtual void Dispose() public virtual void Dispose()
{ {
if ( _pi != null ) if ( platform != null )
{ {
_pi.Dispose(); platform.Dispose();
_pi = null; platform = null;
} }
} }
// int // int
public int AddFavoriteGame( AppId_t nAppID /*AppId_t*/, uint nIP /*uint32*/, ushort nConnPort /*uint16*/, ushort nQueryPort /*uint16*/, uint unFlags /*uint32*/, uint rTime32LastPlayedOnServer /*uint32*/ ) public int AddFavoriteGame( AppId_t nAppID /*AppId_t*/, uint nIP /*uint32*/, ushort nConnPort /*uint16*/, ushort nQueryPort /*uint16*/, uint unFlags /*uint32*/, uint rTime32LastPlayedOnServer /*uint32*/ )
{ {
return _pi.ISteamMatchmaking_AddFavoriteGame( nAppID.Value, nIP, nConnPort, nQueryPort, unFlags, rTime32LastPlayedOnServer ); return platform.ISteamMatchmaking_AddFavoriteGame( nAppID.Value, nIP, nConnPort, nQueryPort, unFlags, rTime32LastPlayedOnServer );
} }
// void // void
public void AddRequestLobbyListCompatibleMembersFilter( CSteamID steamIDLobby /*class CSteamID*/ ) public void AddRequestLobbyListCompatibleMembersFilter( CSteamID steamIDLobby /*class CSteamID*/ )
{ {
_pi.ISteamMatchmaking_AddRequestLobbyListCompatibleMembersFilter( steamIDLobby.Value ); platform.ISteamMatchmaking_AddRequestLobbyListCompatibleMembersFilter( steamIDLobby.Value );
} }
// void // void
public void AddRequestLobbyListDistanceFilter( LobbyDistanceFilter eLobbyDistanceFilter /*ELobbyDistanceFilter*/ ) public void AddRequestLobbyListDistanceFilter( LobbyDistanceFilter eLobbyDistanceFilter /*ELobbyDistanceFilter*/ )
{ {
_pi.ISteamMatchmaking_AddRequestLobbyListDistanceFilter( eLobbyDistanceFilter ); platform.ISteamMatchmaking_AddRequestLobbyListDistanceFilter( eLobbyDistanceFilter );
} }
// void // void
public void AddRequestLobbyListFilterSlotsAvailable( int nSlotsAvailable /*int*/ ) public void AddRequestLobbyListFilterSlotsAvailable( int nSlotsAvailable /*int*/ )
{ {
_pi.ISteamMatchmaking_AddRequestLobbyListFilterSlotsAvailable( nSlotsAvailable ); platform.ISteamMatchmaking_AddRequestLobbyListFilterSlotsAvailable( nSlotsAvailable );
} }
// void // void
public void AddRequestLobbyListNearValueFilter( string pchKeyToMatch /*const char **/, int nValueToBeCloseTo /*int*/ ) public void AddRequestLobbyListNearValueFilter( string pchKeyToMatch /*const char **/, int nValueToBeCloseTo /*int*/ )
{ {
_pi.ISteamMatchmaking_AddRequestLobbyListNearValueFilter( pchKeyToMatch, nValueToBeCloseTo ); platform.ISteamMatchmaking_AddRequestLobbyListNearValueFilter( pchKeyToMatch, nValueToBeCloseTo );
} }
// void // void
public void AddRequestLobbyListNumericalFilter( string pchKeyToMatch /*const char **/, int nValueToMatch /*int*/, LobbyComparison eComparisonType /*ELobbyComparison*/ ) public void AddRequestLobbyListNumericalFilter( string pchKeyToMatch /*const char **/, int nValueToMatch /*int*/, LobbyComparison eComparisonType /*ELobbyComparison*/ )
{ {
_pi.ISteamMatchmaking_AddRequestLobbyListNumericalFilter( pchKeyToMatch, nValueToMatch, eComparisonType ); platform.ISteamMatchmaking_AddRequestLobbyListNumericalFilter( pchKeyToMatch, nValueToMatch, eComparisonType );
} }
// void // void
public void AddRequestLobbyListResultCountFilter( int cMaxResults /*int*/ ) public void AddRequestLobbyListResultCountFilter( int cMaxResults /*int*/ )
{ {
_pi.ISteamMatchmaking_AddRequestLobbyListResultCountFilter( cMaxResults ); platform.ISteamMatchmaking_AddRequestLobbyListResultCountFilter( cMaxResults );
} }
// void // void
public void AddRequestLobbyListStringFilter( string pchKeyToMatch /*const char **/, string pchValueToMatch /*const char **/, LobbyComparison eComparisonType /*ELobbyComparison*/ ) public void AddRequestLobbyListStringFilter( string pchKeyToMatch /*const char **/, string pchValueToMatch /*const char **/, LobbyComparison eComparisonType /*ELobbyComparison*/ )
{ {
_pi.ISteamMatchmaking_AddRequestLobbyListStringFilter( pchKeyToMatch, pchValueToMatch, eComparisonType ); platform.ISteamMatchmaking_AddRequestLobbyListStringFilter( pchKeyToMatch, pchValueToMatch, eComparisonType );
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t CreateLobby( LobbyType eLobbyType /*ELobbyType*/, int cMaxMembers /*int*/ ) public CallbackHandle CreateLobby( LobbyType eLobbyType /*ELobbyType*/, int cMaxMembers /*int*/, Action<LobbyCreated_t, bool> CallbackFunction = null /*Action<LobbyCreated_t, bool>*/ )
{ {
return _pi.ISteamMatchmaking_CreateLobby( eLobbyType, cMaxMembers ); SteamAPICall_t callback = 0;
callback = platform.ISteamMatchmaking_CreateLobby( eLobbyType, cMaxMembers );
if ( CallbackFunction == null ) return null;
return LobbyCreated_t.CallResult( steamworks, callback, CallbackFunction );
} }
// bool // bool
public bool DeleteLobbyData( CSteamID steamIDLobby /*class CSteamID*/, string pchKey /*const char **/ ) public bool DeleteLobbyData( CSteamID steamIDLobby /*class CSteamID*/, string pchKey /*const char **/ )
{ {
return _pi.ISteamMatchmaking_DeleteLobbyData( steamIDLobby.Value, pchKey ); return platform.ISteamMatchmaking_DeleteLobbyData( steamIDLobby.Value, pchKey );
} }
// bool // bool
public bool GetFavoriteGame( int iGame /*int*/, ref AppId_t pnAppID /*AppId_t **/, out uint pnIP /*uint32 **/, out ushort pnConnPort /*uint16 **/, out ushort pnQueryPort /*uint16 **/, IntPtr punFlags /*uint32 **/, out uint pRTime32LastPlayedOnServer /*uint32 **/ ) public bool GetFavoriteGame( int iGame /*int*/, ref AppId_t pnAppID /*AppId_t **/, out uint pnIP /*uint32 **/, out ushort pnConnPort /*uint16 **/, out ushort pnQueryPort /*uint16 **/, IntPtr punFlags /*uint32 **/, out uint pRTime32LastPlayedOnServer /*uint32 **/ )
{ {
return _pi.ISteamMatchmaking_GetFavoriteGame( iGame, ref pnAppID.Value, out pnIP, out pnConnPort, out pnQueryPort, (IntPtr) punFlags, out pRTime32LastPlayedOnServer ); return platform.ISteamMatchmaking_GetFavoriteGame( iGame, ref pnAppID.Value, out pnIP, out pnConnPort, out pnQueryPort, (IntPtr) punFlags, out pRTime32LastPlayedOnServer );
} }
// int // int
public int GetFavoriteGameCount() public int GetFavoriteGameCount()
{ {
return _pi.ISteamMatchmaking_GetFavoriteGameCount(); return platform.ISteamMatchmaking_GetFavoriteGameCount();
} }
// ulong // ulong
public ulong GetLobbyByIndex( int iLobby /*int*/ ) public ulong GetLobbyByIndex( int iLobby /*int*/ )
{ {
return _pi.ISteamMatchmaking_GetLobbyByIndex( iLobby ); return platform.ISteamMatchmaking_GetLobbyByIndex( iLobby );
} }
// int // int
public int GetLobbyChatEntry( CSteamID steamIDLobby /*class CSteamID*/, int iChatID /*int*/, out CSteamID pSteamIDUser /*class CSteamID **/, IntPtr pvData /*void **/, int cubData /*int*/, out ChatEntryType peChatEntryType /*EChatEntryType **/ ) public int GetLobbyChatEntry( CSteamID steamIDLobby /*class CSteamID*/, int iChatID /*int*/, out CSteamID pSteamIDUser /*class CSteamID **/, IntPtr pvData /*void **/, int cubData /*int*/, out ChatEntryType peChatEntryType /*EChatEntryType **/ )
{ {
return _pi.ISteamMatchmaking_GetLobbyChatEntry( steamIDLobby.Value, iChatID, out pSteamIDUser.Value, (IntPtr) pvData, cubData, out peChatEntryType ); return platform.ISteamMatchmaking_GetLobbyChatEntry( steamIDLobby.Value, iChatID, out pSteamIDUser.Value, (IntPtr) pvData, cubData, out peChatEntryType );
} }
// string // string
@ -128,7 +136,7 @@ public int GetLobbyChatEntry( CSteamID steamIDLobby /*class CSteamID*/, int iCha
public string GetLobbyData( CSteamID steamIDLobby /*class CSteamID*/, string pchKey /*const char **/ ) public string GetLobbyData( CSteamID steamIDLobby /*class CSteamID*/, string pchKey /*const char **/ )
{ {
IntPtr string_pointer; IntPtr string_pointer;
string_pointer = _pi.ISteamMatchmaking_GetLobbyData( steamIDLobby.Value, pchKey ); string_pointer = platform.ISteamMatchmaking_GetLobbyData( steamIDLobby.Value, pchKey );
return Marshal.PtrToStringAnsi( string_pointer ); return Marshal.PtrToStringAnsi( string_pointer );
} }
@ -144,7 +152,7 @@ public bool GetLobbyDataByIndex( CSteamID steamIDLobby /*class CSteamID*/, int i
pchValue = string.Empty; pchValue = string.Empty;
System.Text.StringBuilder pchValue_sb = new System.Text.StringBuilder( 4096 ); System.Text.StringBuilder pchValue_sb = new System.Text.StringBuilder( 4096 );
int cchValueBufferSize = 4096; int cchValueBufferSize = 4096;
bSuccess = _pi.ISteamMatchmaking_GetLobbyDataByIndex( steamIDLobby.Value, iLobbyData, pchKey_sb, cchKeyBufferSize, pchValue_sb, cchValueBufferSize ); bSuccess = platform.ISteamMatchmaking_GetLobbyDataByIndex( steamIDLobby.Value, iLobbyData, pchKey_sb, cchKeyBufferSize, pchValue_sb, cchValueBufferSize );
if ( !bSuccess ) return bSuccess; if ( !bSuccess ) return bSuccess;
pchValue = pchValue_sb.ToString(); pchValue = pchValue_sb.ToString();
if ( !bSuccess ) return bSuccess; if ( !bSuccess ) return bSuccess;
@ -155,19 +163,19 @@ public bool GetLobbyDataByIndex( CSteamID steamIDLobby /*class CSteamID*/, int i
// int // int
public int GetLobbyDataCount( CSteamID steamIDLobby /*class CSteamID*/ ) public int GetLobbyDataCount( CSteamID steamIDLobby /*class CSteamID*/ )
{ {
return _pi.ISteamMatchmaking_GetLobbyDataCount( steamIDLobby.Value ); return platform.ISteamMatchmaking_GetLobbyDataCount( steamIDLobby.Value );
} }
// bool // bool
public bool GetLobbyGameServer( CSteamID steamIDLobby /*class CSteamID*/, out uint punGameServerIP /*uint32 **/, out ushort punGameServerPort /*uint16 **/, out CSteamID psteamIDGameServer /*class CSteamID **/ ) public bool GetLobbyGameServer( CSteamID steamIDLobby /*class CSteamID*/, out uint punGameServerIP /*uint32 **/, out ushort punGameServerPort /*uint16 **/, out CSteamID psteamIDGameServer /*class CSteamID **/ )
{ {
return _pi.ISteamMatchmaking_GetLobbyGameServer( steamIDLobby.Value, out punGameServerIP, out punGameServerPort, out psteamIDGameServer.Value ); return platform.ISteamMatchmaking_GetLobbyGameServer( steamIDLobby.Value, out punGameServerIP, out punGameServerPort, out psteamIDGameServer.Value );
} }
// ulong // ulong
public ulong GetLobbyMemberByIndex( CSteamID steamIDLobby /*class CSteamID*/, int iMember /*int*/ ) public ulong GetLobbyMemberByIndex( CSteamID steamIDLobby /*class CSteamID*/, int iMember /*int*/ )
{ {
return _pi.ISteamMatchmaking_GetLobbyMemberByIndex( steamIDLobby.Value, iMember ); return platform.ISteamMatchmaking_GetLobbyMemberByIndex( steamIDLobby.Value, iMember );
} }
// string // string
@ -175,116 +183,126 @@ public ulong GetLobbyMemberByIndex( CSteamID steamIDLobby /*class CSteamID*/, in
public string GetLobbyMemberData( CSteamID steamIDLobby /*class CSteamID*/, CSteamID steamIDUser /*class CSteamID*/, string pchKey /*const char **/ ) public string GetLobbyMemberData( CSteamID steamIDLobby /*class CSteamID*/, CSteamID steamIDUser /*class CSteamID*/, string pchKey /*const char **/ )
{ {
IntPtr string_pointer; IntPtr string_pointer;
string_pointer = _pi.ISteamMatchmaking_GetLobbyMemberData( steamIDLobby.Value, steamIDUser.Value, pchKey ); string_pointer = platform.ISteamMatchmaking_GetLobbyMemberData( steamIDLobby.Value, steamIDUser.Value, pchKey );
return Marshal.PtrToStringAnsi( string_pointer ); return Marshal.PtrToStringAnsi( string_pointer );
} }
// int // int
public int GetLobbyMemberLimit( CSteamID steamIDLobby /*class CSteamID*/ ) public int GetLobbyMemberLimit( CSteamID steamIDLobby /*class CSteamID*/ )
{ {
return _pi.ISteamMatchmaking_GetLobbyMemberLimit( steamIDLobby.Value ); return platform.ISteamMatchmaking_GetLobbyMemberLimit( steamIDLobby.Value );
} }
// ulong // ulong
public ulong GetLobbyOwner( CSteamID steamIDLobby /*class CSteamID*/ ) public ulong GetLobbyOwner( CSteamID steamIDLobby /*class CSteamID*/ )
{ {
return _pi.ISteamMatchmaking_GetLobbyOwner( steamIDLobby.Value ); return platform.ISteamMatchmaking_GetLobbyOwner( steamIDLobby.Value );
} }
// int // int
public int GetNumLobbyMembers( CSteamID steamIDLobby /*class CSteamID*/ ) public int GetNumLobbyMembers( CSteamID steamIDLobby /*class CSteamID*/ )
{ {
return _pi.ISteamMatchmaking_GetNumLobbyMembers( steamIDLobby.Value ); return platform.ISteamMatchmaking_GetNumLobbyMembers( steamIDLobby.Value );
} }
// bool // bool
public bool InviteUserToLobby( CSteamID steamIDLobby /*class CSteamID*/, CSteamID steamIDInvitee /*class CSteamID*/ ) public bool InviteUserToLobby( CSteamID steamIDLobby /*class CSteamID*/, CSteamID steamIDInvitee /*class CSteamID*/ )
{ {
return _pi.ISteamMatchmaking_InviteUserToLobby( steamIDLobby.Value, steamIDInvitee.Value ); return platform.ISteamMatchmaking_InviteUserToLobby( steamIDLobby.Value, steamIDInvitee.Value );
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t JoinLobby( CSteamID steamIDLobby /*class CSteamID*/ ) public CallbackHandle JoinLobby( CSteamID steamIDLobby /*class CSteamID*/, Action<LobbyEnter_t, bool> CallbackFunction = null /*Action<LobbyEnter_t, bool>*/ )
{ {
return _pi.ISteamMatchmaking_JoinLobby( steamIDLobby.Value ); SteamAPICall_t callback = 0;
callback = platform.ISteamMatchmaking_JoinLobby( steamIDLobby.Value );
if ( CallbackFunction == null ) return null;
return LobbyEnter_t.CallResult( steamworks, callback, CallbackFunction );
} }
// void // void
public void LeaveLobby( CSteamID steamIDLobby /*class CSteamID*/ ) public void LeaveLobby( CSteamID steamIDLobby /*class CSteamID*/ )
{ {
_pi.ISteamMatchmaking_LeaveLobby( steamIDLobby.Value ); platform.ISteamMatchmaking_LeaveLobby( steamIDLobby.Value );
} }
// bool // bool
public bool RemoveFavoriteGame( AppId_t nAppID /*AppId_t*/, uint nIP /*uint32*/, ushort nConnPort /*uint16*/, ushort nQueryPort /*uint16*/, uint unFlags /*uint32*/ ) public bool RemoveFavoriteGame( AppId_t nAppID /*AppId_t*/, uint nIP /*uint32*/, ushort nConnPort /*uint16*/, ushort nQueryPort /*uint16*/, uint unFlags /*uint32*/ )
{ {
return _pi.ISteamMatchmaking_RemoveFavoriteGame( nAppID.Value, nIP, nConnPort, nQueryPort, unFlags ); return platform.ISteamMatchmaking_RemoveFavoriteGame( nAppID.Value, nIP, nConnPort, nQueryPort, unFlags );
} }
// bool // bool
public bool RequestLobbyData( CSteamID steamIDLobby /*class CSteamID*/ ) public bool RequestLobbyData( CSteamID steamIDLobby /*class CSteamID*/ )
{ {
return _pi.ISteamMatchmaking_RequestLobbyData( steamIDLobby.Value ); return platform.ISteamMatchmaking_RequestLobbyData( steamIDLobby.Value );
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t RequestLobbyList() public CallbackHandle RequestLobbyList( Action<LobbyMatchList_t, bool> CallbackFunction = null /*Action<LobbyMatchList_t, bool>*/ )
{ {
return _pi.ISteamMatchmaking_RequestLobbyList(); SteamAPICall_t callback = 0;
callback = platform.ISteamMatchmaking_RequestLobbyList();
if ( CallbackFunction == null ) return null;
return LobbyMatchList_t.CallResult( steamworks, callback, CallbackFunction );
} }
// bool // bool
public bool SendLobbyChatMsg( CSteamID steamIDLobby /*class CSteamID*/, IntPtr pvMsgBody /*const void **/, int cubMsgBody /*int*/ ) public bool SendLobbyChatMsg( CSteamID steamIDLobby /*class CSteamID*/, IntPtr pvMsgBody /*const void **/, int cubMsgBody /*int*/ )
{ {
return _pi.ISteamMatchmaking_SendLobbyChatMsg( steamIDLobby.Value, (IntPtr) pvMsgBody, cubMsgBody ); return platform.ISteamMatchmaking_SendLobbyChatMsg( steamIDLobby.Value, (IntPtr) pvMsgBody, cubMsgBody );
} }
// bool // bool
public bool SetLinkedLobby( CSteamID steamIDLobby /*class CSteamID*/, CSteamID steamIDLobbyDependent /*class CSteamID*/ ) public bool SetLinkedLobby( CSteamID steamIDLobby /*class CSteamID*/, CSteamID steamIDLobbyDependent /*class CSteamID*/ )
{ {
return _pi.ISteamMatchmaking_SetLinkedLobby( steamIDLobby.Value, steamIDLobbyDependent.Value ); return platform.ISteamMatchmaking_SetLinkedLobby( steamIDLobby.Value, steamIDLobbyDependent.Value );
} }
// bool // bool
public bool SetLobbyData( CSteamID steamIDLobby /*class CSteamID*/, string pchKey /*const char **/, string pchValue /*const char **/ ) public bool SetLobbyData( CSteamID steamIDLobby /*class CSteamID*/, string pchKey /*const char **/, string pchValue /*const char **/ )
{ {
return _pi.ISteamMatchmaking_SetLobbyData( steamIDLobby.Value, pchKey, pchValue ); return platform.ISteamMatchmaking_SetLobbyData( steamIDLobby.Value, pchKey, pchValue );
} }
// void // void
public void SetLobbyGameServer( CSteamID steamIDLobby /*class CSteamID*/, uint unGameServerIP /*uint32*/, ushort unGameServerPort /*uint16*/, CSteamID steamIDGameServer /*class CSteamID*/ ) public void SetLobbyGameServer( CSteamID steamIDLobby /*class CSteamID*/, uint unGameServerIP /*uint32*/, ushort unGameServerPort /*uint16*/, CSteamID steamIDGameServer /*class CSteamID*/ )
{ {
_pi.ISteamMatchmaking_SetLobbyGameServer( steamIDLobby.Value, unGameServerIP, unGameServerPort, steamIDGameServer.Value ); platform.ISteamMatchmaking_SetLobbyGameServer( steamIDLobby.Value, unGameServerIP, unGameServerPort, steamIDGameServer.Value );
} }
// bool // bool
public bool SetLobbyJoinable( CSteamID steamIDLobby /*class CSteamID*/, bool bLobbyJoinable /*bool*/ ) public bool SetLobbyJoinable( CSteamID steamIDLobby /*class CSteamID*/, bool bLobbyJoinable /*bool*/ )
{ {
return _pi.ISteamMatchmaking_SetLobbyJoinable( steamIDLobby.Value, bLobbyJoinable ); return platform.ISteamMatchmaking_SetLobbyJoinable( steamIDLobby.Value, bLobbyJoinable );
} }
// void // void
public void SetLobbyMemberData( CSteamID steamIDLobby /*class CSteamID*/, string pchKey /*const char **/, string pchValue /*const char **/ ) public void SetLobbyMemberData( CSteamID steamIDLobby /*class CSteamID*/, string pchKey /*const char **/, string pchValue /*const char **/ )
{ {
_pi.ISteamMatchmaking_SetLobbyMemberData( steamIDLobby.Value, pchKey, pchValue ); platform.ISteamMatchmaking_SetLobbyMemberData( steamIDLobby.Value, pchKey, pchValue );
} }
// bool // bool
public bool SetLobbyMemberLimit( CSteamID steamIDLobby /*class CSteamID*/, int cMaxMembers /*int*/ ) public bool SetLobbyMemberLimit( CSteamID steamIDLobby /*class CSteamID*/, int cMaxMembers /*int*/ )
{ {
return _pi.ISteamMatchmaking_SetLobbyMemberLimit( steamIDLobby.Value, cMaxMembers ); return platform.ISteamMatchmaking_SetLobbyMemberLimit( steamIDLobby.Value, cMaxMembers );
} }
// bool // bool
public bool SetLobbyOwner( CSteamID steamIDLobby /*class CSteamID*/, CSteamID steamIDNewOwner /*class CSteamID*/ ) public bool SetLobbyOwner( CSteamID steamIDLobby /*class CSteamID*/, CSteamID steamIDNewOwner /*class CSteamID*/ )
{ {
return _pi.ISteamMatchmaking_SetLobbyOwner( steamIDLobby.Value, steamIDNewOwner.Value ); return platform.ISteamMatchmaking_SetLobbyOwner( steamIDLobby.Value, steamIDNewOwner.Value );
} }
// bool // bool
public bool SetLobbyType( CSteamID steamIDLobby /*class CSteamID*/, LobbyType eLobbyType /*ELobbyType*/ ) public bool SetLobbyType( CSteamID steamIDLobby /*class CSteamID*/, LobbyType eLobbyType /*ELobbyType*/ )
{ {
return _pi.ISteamMatchmaking_SetLobbyType( steamIDLobby.Value, eLobbyType ); return platform.ISteamMatchmaking_SetLobbyType( steamIDLobby.Value, eLobbyType );
} }
} }

View File

@ -3,58 +3,61 @@
namespace SteamNative namespace SteamNative
{ {
public unsafe class SteamMatchmakingServers : IDisposable internal unsafe class SteamMatchmakingServers : IDisposable
{ {
// //
// Holds a platform specific implentation // Holds a platform specific implentation
// //
internal Platform.Interface _pi; internal Platform.Interface platform;
internal Facepunch.Steamworks.BaseSteamworks steamworks;
// //
// Constructor decides which implementation to use based on current platform // Constructor decides which implementation to use based on current platform
// //
public SteamMatchmakingServers( IntPtr pointer ) public SteamMatchmakingServers( Facepunch.Steamworks.BaseSteamworks steamworks, IntPtr pointer )
{ {
if ( Platform.IsWindows64 ) _pi = new Platform.Win64( pointer ); this.steamworks = steamworks;
else if ( Platform.IsWindows32 ) _pi = new Platform.Win32( pointer );
else if ( Platform.IsLinux32 ) _pi = new Platform.Linux32( pointer ); if ( Platform.IsWindows64 ) platform = new Platform.Win64( pointer );
else if ( Platform.IsLinux64 ) _pi = new Platform.Linux64( pointer ); else if ( Platform.IsWindows32 ) platform = new Platform.Win32( pointer );
else if ( Platform.IsOsx ) _pi = new Platform.Mac( pointer ); else if ( Platform.IsLinux32 ) platform = new Platform.Linux32( pointer );
else if ( Platform.IsLinux64 ) platform = new Platform.Linux64( pointer );
else if ( Platform.IsOsx ) platform = new Platform.Mac( pointer );
} }
// //
// Class is invalid if we don't have a valid implementation // Class is invalid if we don't have a valid implementation
// //
public bool IsValid{ get{ return _pi != null && _pi.IsValid; } } public bool IsValid{ get{ return platform != null && platform.IsValid; } }
// //
// When shutting down clear all the internals to avoid accidental use // When shutting down clear all the internals to avoid accidental use
// //
public virtual void Dispose() public virtual void Dispose()
{ {
if ( _pi != null ) if ( platform != null )
{ {
_pi.Dispose(); platform.Dispose();
_pi = null; platform = null;
} }
} }
// void // void
public void CancelQuery( HServerListRequest hRequest /*HServerListRequest*/ ) public void CancelQuery( HServerListRequest hRequest /*HServerListRequest*/ )
{ {
_pi.ISteamMatchmakingServers_CancelQuery( hRequest.Value ); platform.ISteamMatchmakingServers_CancelQuery( hRequest.Value );
} }
// void // void
public void CancelServerQuery( HServerQuery hServerQuery /*HServerQuery*/ ) public void CancelServerQuery( HServerQuery hServerQuery /*HServerQuery*/ )
{ {
_pi.ISteamMatchmakingServers_CancelServerQuery( hServerQuery.Value ); platform.ISteamMatchmakingServers_CancelServerQuery( hServerQuery.Value );
} }
// int // int
public int GetServerCount( HServerListRequest hRequest /*HServerListRequest*/ ) public int GetServerCount( HServerListRequest hRequest /*HServerListRequest*/ )
{ {
return _pi.ISteamMatchmakingServers_GetServerCount( hRequest.Value ); return platform.ISteamMatchmakingServers_GetServerCount( hRequest.Value );
} }
// gameserveritem_t * // gameserveritem_t *
@ -62,7 +65,7 @@ public int GetServerCount( HServerListRequest hRequest /*HServerListRequest*/ )
public gameserveritem_t GetServerDetails( HServerListRequest hRequest /*HServerListRequest*/, int iServer /*int*/ ) public gameserveritem_t GetServerDetails( HServerListRequest hRequest /*HServerListRequest*/, int iServer /*int*/ )
{ {
IntPtr struct_pointer; IntPtr struct_pointer;
struct_pointer = _pi.ISteamMatchmakingServers_GetServerDetails( hRequest.Value, iServer ); struct_pointer = platform.ISteamMatchmakingServers_GetServerDetails( hRequest.Value, iServer );
if ( struct_pointer == IntPtr.Zero ) return default(gameserveritem_t); if ( struct_pointer == IntPtr.Zero ) return default(gameserveritem_t);
return gameserveritem_t.FromPointer( struct_pointer ); return gameserveritem_t.FromPointer( struct_pointer );
} }
@ -70,84 +73,84 @@ public gameserveritem_t GetServerDetails( HServerListRequest hRequest /*HServerL
// bool // bool
public bool IsRefreshing( HServerListRequest hRequest /*HServerListRequest*/ ) public bool IsRefreshing( HServerListRequest hRequest /*HServerListRequest*/ )
{ {
return _pi.ISteamMatchmakingServers_IsRefreshing( hRequest.Value ); return platform.ISteamMatchmakingServers_IsRefreshing( hRequest.Value );
} }
// HServerQuery // HServerQuery
public HServerQuery PingServer( uint unIP /*uint32*/, ushort usPort /*uint16*/, IntPtr pRequestServersResponse /*class ISteamMatchmakingPingResponse **/ ) public HServerQuery PingServer( uint unIP /*uint32*/, ushort usPort /*uint16*/, IntPtr pRequestServersResponse /*class ISteamMatchmakingPingResponse **/ )
{ {
return _pi.ISteamMatchmakingServers_PingServer( unIP, usPort, (IntPtr) pRequestServersResponse ); return platform.ISteamMatchmakingServers_PingServer( unIP, usPort, (IntPtr) pRequestServersResponse );
} }
// HServerQuery // HServerQuery
public HServerQuery PlayerDetails( uint unIP /*uint32*/, ushort usPort /*uint16*/, IntPtr pRequestServersResponse /*class ISteamMatchmakingPlayersResponse **/ ) public HServerQuery PlayerDetails( uint unIP /*uint32*/, ushort usPort /*uint16*/, IntPtr pRequestServersResponse /*class ISteamMatchmakingPlayersResponse **/ )
{ {
return _pi.ISteamMatchmakingServers_PlayerDetails( unIP, usPort, (IntPtr) pRequestServersResponse ); return platform.ISteamMatchmakingServers_PlayerDetails( unIP, usPort, (IntPtr) pRequestServersResponse );
} }
// void // void
public void RefreshQuery( HServerListRequest hRequest /*HServerListRequest*/ ) public void RefreshQuery( HServerListRequest hRequest /*HServerListRequest*/ )
{ {
_pi.ISteamMatchmakingServers_RefreshQuery( hRequest.Value ); platform.ISteamMatchmakingServers_RefreshQuery( hRequest.Value );
} }
// void // void
public void RefreshServer( HServerListRequest hRequest /*HServerListRequest*/, int iServer /*int*/ ) public void RefreshServer( HServerListRequest hRequest /*HServerListRequest*/, int iServer /*int*/ )
{ {
_pi.ISteamMatchmakingServers_RefreshServer( hRequest.Value, iServer ); platform.ISteamMatchmakingServers_RefreshServer( hRequest.Value, iServer );
} }
// void // void
public void ReleaseRequest( HServerListRequest hServerListRequest /*HServerListRequest*/ ) public void ReleaseRequest( HServerListRequest hServerListRequest /*HServerListRequest*/ )
{ {
_pi.ISteamMatchmakingServers_ReleaseRequest( hServerListRequest.Value ); platform.ISteamMatchmakingServers_ReleaseRequest( hServerListRequest.Value );
} }
// HServerListRequest // HServerListRequest
// with: Detect_MatchmakingFilters // with: Detect_MatchmakingFilters
public HServerListRequest RequestFavoritesServerList( AppId_t iApp /*AppId_t*/, IntPtr ppchFilters /*struct MatchMakingKeyValuePair_t ***/, uint nFilters /*uint32*/, IntPtr pRequestServersResponse /*class ISteamMatchmakingServerListResponse **/ ) public HServerListRequest RequestFavoritesServerList( AppId_t iApp /*AppId_t*/, IntPtr ppchFilters /*struct MatchMakingKeyValuePair_t ***/, uint nFilters /*uint32*/, IntPtr pRequestServersResponse /*class ISteamMatchmakingServerListResponse **/ )
{ {
return _pi.ISteamMatchmakingServers_RequestFavoritesServerList( iApp.Value, (IntPtr) ppchFilters, nFilters, (IntPtr) pRequestServersResponse ); return platform.ISteamMatchmakingServers_RequestFavoritesServerList( iApp.Value, (IntPtr) ppchFilters, nFilters, (IntPtr) pRequestServersResponse );
} }
// HServerListRequest // HServerListRequest
// with: Detect_MatchmakingFilters // with: Detect_MatchmakingFilters
public HServerListRequest RequestFriendsServerList( AppId_t iApp /*AppId_t*/, IntPtr ppchFilters /*struct MatchMakingKeyValuePair_t ***/, uint nFilters /*uint32*/, IntPtr pRequestServersResponse /*class ISteamMatchmakingServerListResponse **/ ) public HServerListRequest RequestFriendsServerList( AppId_t iApp /*AppId_t*/, IntPtr ppchFilters /*struct MatchMakingKeyValuePair_t ***/, uint nFilters /*uint32*/, IntPtr pRequestServersResponse /*class ISteamMatchmakingServerListResponse **/ )
{ {
return _pi.ISteamMatchmakingServers_RequestFriendsServerList( iApp.Value, (IntPtr) ppchFilters, nFilters, (IntPtr) pRequestServersResponse ); return platform.ISteamMatchmakingServers_RequestFriendsServerList( iApp.Value, (IntPtr) ppchFilters, nFilters, (IntPtr) pRequestServersResponse );
} }
// HServerListRequest // HServerListRequest
// with: Detect_MatchmakingFilters // with: Detect_MatchmakingFilters
public HServerListRequest RequestHistoryServerList( AppId_t iApp /*AppId_t*/, IntPtr ppchFilters /*struct MatchMakingKeyValuePair_t ***/, uint nFilters /*uint32*/, IntPtr pRequestServersResponse /*class ISteamMatchmakingServerListResponse **/ ) public HServerListRequest RequestHistoryServerList( AppId_t iApp /*AppId_t*/, IntPtr ppchFilters /*struct MatchMakingKeyValuePair_t ***/, uint nFilters /*uint32*/, IntPtr pRequestServersResponse /*class ISteamMatchmakingServerListResponse **/ )
{ {
return _pi.ISteamMatchmakingServers_RequestHistoryServerList( iApp.Value, (IntPtr) ppchFilters, nFilters, (IntPtr) pRequestServersResponse ); return platform.ISteamMatchmakingServers_RequestHistoryServerList( iApp.Value, (IntPtr) ppchFilters, nFilters, (IntPtr) pRequestServersResponse );
} }
// HServerListRequest // HServerListRequest
// with: Detect_MatchmakingFilters // with: Detect_MatchmakingFilters
public HServerListRequest RequestInternetServerList( AppId_t iApp /*AppId_t*/, IntPtr ppchFilters /*struct MatchMakingKeyValuePair_t ***/, uint nFilters /*uint32*/, IntPtr pRequestServersResponse /*class ISteamMatchmakingServerListResponse **/ ) public HServerListRequest RequestInternetServerList( AppId_t iApp /*AppId_t*/, IntPtr ppchFilters /*struct MatchMakingKeyValuePair_t ***/, uint nFilters /*uint32*/, IntPtr pRequestServersResponse /*class ISteamMatchmakingServerListResponse **/ )
{ {
return _pi.ISteamMatchmakingServers_RequestInternetServerList( iApp.Value, (IntPtr) ppchFilters, nFilters, (IntPtr) pRequestServersResponse ); return platform.ISteamMatchmakingServers_RequestInternetServerList( iApp.Value, (IntPtr) ppchFilters, nFilters, (IntPtr) pRequestServersResponse );
} }
// HServerListRequest // HServerListRequest
public HServerListRequest RequestLANServerList( AppId_t iApp /*AppId_t*/, IntPtr pRequestServersResponse /*class ISteamMatchmakingServerListResponse **/ ) public HServerListRequest RequestLANServerList( AppId_t iApp /*AppId_t*/, IntPtr pRequestServersResponse /*class ISteamMatchmakingServerListResponse **/ )
{ {
return _pi.ISteamMatchmakingServers_RequestLANServerList( iApp.Value, (IntPtr) pRequestServersResponse ); return platform.ISteamMatchmakingServers_RequestLANServerList( iApp.Value, (IntPtr) pRequestServersResponse );
} }
// HServerListRequest // HServerListRequest
// with: Detect_MatchmakingFilters // with: Detect_MatchmakingFilters
public HServerListRequest RequestSpectatorServerList( AppId_t iApp /*AppId_t*/, IntPtr ppchFilters /*struct MatchMakingKeyValuePair_t ***/, uint nFilters /*uint32*/, IntPtr pRequestServersResponse /*class ISteamMatchmakingServerListResponse **/ ) public HServerListRequest RequestSpectatorServerList( AppId_t iApp /*AppId_t*/, IntPtr ppchFilters /*struct MatchMakingKeyValuePair_t ***/, uint nFilters /*uint32*/, IntPtr pRequestServersResponse /*class ISteamMatchmakingServerListResponse **/ )
{ {
return _pi.ISteamMatchmakingServers_RequestSpectatorServerList( iApp.Value, (IntPtr) ppchFilters, nFilters, (IntPtr) pRequestServersResponse ); return platform.ISteamMatchmakingServers_RequestSpectatorServerList( iApp.Value, (IntPtr) ppchFilters, nFilters, (IntPtr) pRequestServersResponse );
} }
// HServerQuery // HServerQuery
public HServerQuery ServerRules( uint unIP /*uint32*/, ushort usPort /*uint16*/, IntPtr pRequestServersResponse /*class ISteamMatchmakingRulesResponse **/ ) public HServerQuery ServerRules( uint unIP /*uint32*/, ushort usPort /*uint16*/, IntPtr pRequestServersResponse /*class ISteamMatchmakingRulesResponse **/ )
{ {
return _pi.ISteamMatchmakingServers_ServerRules( unIP, usPort, (IntPtr) pRequestServersResponse ); return platform.ISteamMatchmakingServers_ServerRules( unIP, usPort, (IntPtr) pRequestServersResponse );
} }
} }

View File

@ -3,94 +3,97 @@
namespace SteamNative namespace SteamNative
{ {
public unsafe class SteamMusic : IDisposable internal unsafe class SteamMusic : IDisposable
{ {
// //
// Holds a platform specific implentation // Holds a platform specific implentation
// //
internal Platform.Interface _pi; internal Platform.Interface platform;
internal Facepunch.Steamworks.BaseSteamworks steamworks;
// //
// Constructor decides which implementation to use based on current platform // Constructor decides which implementation to use based on current platform
// //
public SteamMusic( IntPtr pointer ) public SteamMusic( Facepunch.Steamworks.BaseSteamworks steamworks, IntPtr pointer )
{ {
if ( Platform.IsWindows64 ) _pi = new Platform.Win64( pointer ); this.steamworks = steamworks;
else if ( Platform.IsWindows32 ) _pi = new Platform.Win32( pointer );
else if ( Platform.IsLinux32 ) _pi = new Platform.Linux32( pointer ); if ( Platform.IsWindows64 ) platform = new Platform.Win64( pointer );
else if ( Platform.IsLinux64 ) _pi = new Platform.Linux64( pointer ); else if ( Platform.IsWindows32 ) platform = new Platform.Win32( pointer );
else if ( Platform.IsOsx ) _pi = new Platform.Mac( pointer ); else if ( Platform.IsLinux32 ) platform = new Platform.Linux32( pointer );
else if ( Platform.IsLinux64 ) platform = new Platform.Linux64( pointer );
else if ( Platform.IsOsx ) platform = new Platform.Mac( pointer );
} }
// //
// Class is invalid if we don't have a valid implementation // Class is invalid if we don't have a valid implementation
// //
public bool IsValid{ get{ return _pi != null && _pi.IsValid; } } public bool IsValid{ get{ return platform != null && platform.IsValid; } }
// //
// When shutting down clear all the internals to avoid accidental use // When shutting down clear all the internals to avoid accidental use
// //
public virtual void Dispose() public virtual void Dispose()
{ {
if ( _pi != null ) if ( platform != null )
{ {
_pi.Dispose(); platform.Dispose();
_pi = null; platform = null;
} }
} }
// bool // bool
public bool BIsEnabled() public bool BIsEnabled()
{ {
return _pi.ISteamMusic_BIsEnabled(); return platform.ISteamMusic_BIsEnabled();
} }
// bool // bool
public bool BIsPlaying() public bool BIsPlaying()
{ {
return _pi.ISteamMusic_BIsPlaying(); return platform.ISteamMusic_BIsPlaying();
} }
// AudioPlayback_Status // AudioPlayback_Status
public AudioPlayback_Status GetPlaybackStatus() public AudioPlayback_Status GetPlaybackStatus()
{ {
return _pi.ISteamMusic_GetPlaybackStatus(); return platform.ISteamMusic_GetPlaybackStatus();
} }
// float // float
public float GetVolume() public float GetVolume()
{ {
return _pi.ISteamMusic_GetVolume(); return platform.ISteamMusic_GetVolume();
} }
// void // void
public void Pause() public void Pause()
{ {
_pi.ISteamMusic_Pause(); platform.ISteamMusic_Pause();
} }
// void // void
public void Play() public void Play()
{ {
_pi.ISteamMusic_Play(); platform.ISteamMusic_Play();
} }
// void // void
public void PlayNext() public void PlayNext()
{ {
_pi.ISteamMusic_PlayNext(); platform.ISteamMusic_PlayNext();
} }
// void // void
public void PlayPrevious() public void PlayPrevious()
{ {
_pi.ISteamMusic_PlayPrevious(); platform.ISteamMusic_PlayPrevious();
} }
// void // void
public void SetVolume( float flVolume /*float*/ ) public void SetVolume( float flVolume /*float*/ )
{ {
_pi.ISteamMusic_SetVolume( flVolume ); platform.ISteamMusic_SetVolume( flVolume );
} }
} }

View File

@ -3,232 +3,235 @@
namespace SteamNative namespace SteamNative
{ {
public unsafe class SteamMusicRemote : IDisposable internal unsafe class SteamMusicRemote : IDisposable
{ {
// //
// Holds a platform specific implentation // Holds a platform specific implentation
// //
internal Platform.Interface _pi; internal Platform.Interface platform;
internal Facepunch.Steamworks.BaseSteamworks steamworks;
// //
// Constructor decides which implementation to use based on current platform // Constructor decides which implementation to use based on current platform
// //
public SteamMusicRemote( IntPtr pointer ) public SteamMusicRemote( Facepunch.Steamworks.BaseSteamworks steamworks, IntPtr pointer )
{ {
if ( Platform.IsWindows64 ) _pi = new Platform.Win64( pointer ); this.steamworks = steamworks;
else if ( Platform.IsWindows32 ) _pi = new Platform.Win32( pointer );
else if ( Platform.IsLinux32 ) _pi = new Platform.Linux32( pointer ); if ( Platform.IsWindows64 ) platform = new Platform.Win64( pointer );
else if ( Platform.IsLinux64 ) _pi = new Platform.Linux64( pointer ); else if ( Platform.IsWindows32 ) platform = new Platform.Win32( pointer );
else if ( Platform.IsOsx ) _pi = new Platform.Mac( pointer ); else if ( Platform.IsLinux32 ) platform = new Platform.Linux32( pointer );
else if ( Platform.IsLinux64 ) platform = new Platform.Linux64( pointer );
else if ( Platform.IsOsx ) platform = new Platform.Mac( pointer );
} }
// //
// Class is invalid if we don't have a valid implementation // Class is invalid if we don't have a valid implementation
// //
public bool IsValid{ get{ return _pi != null && _pi.IsValid; } } public bool IsValid{ get{ return platform != null && platform.IsValid; } }
// //
// When shutting down clear all the internals to avoid accidental use // When shutting down clear all the internals to avoid accidental use
// //
public virtual void Dispose() public virtual void Dispose()
{ {
if ( _pi != null ) if ( platform != null )
{ {
_pi.Dispose(); platform.Dispose();
_pi = null; platform = null;
} }
} }
// bool // bool
public bool BActivationSuccess( bool bValue /*bool*/ ) public bool BActivationSuccess( bool bValue /*bool*/ )
{ {
return _pi.ISteamMusicRemote_BActivationSuccess( bValue ); return platform.ISteamMusicRemote_BActivationSuccess( bValue );
} }
// bool // bool
public bool BIsCurrentMusicRemote() public bool BIsCurrentMusicRemote()
{ {
return _pi.ISteamMusicRemote_BIsCurrentMusicRemote(); return platform.ISteamMusicRemote_BIsCurrentMusicRemote();
} }
// bool // bool
public bool CurrentEntryDidChange() public bool CurrentEntryDidChange()
{ {
return _pi.ISteamMusicRemote_CurrentEntryDidChange(); return platform.ISteamMusicRemote_CurrentEntryDidChange();
} }
// bool // bool
public bool CurrentEntryIsAvailable( bool bAvailable /*bool*/ ) public bool CurrentEntryIsAvailable( bool bAvailable /*bool*/ )
{ {
return _pi.ISteamMusicRemote_CurrentEntryIsAvailable( bAvailable ); return platform.ISteamMusicRemote_CurrentEntryIsAvailable( bAvailable );
} }
// bool // bool
public bool CurrentEntryWillChange() public bool CurrentEntryWillChange()
{ {
return _pi.ISteamMusicRemote_CurrentEntryWillChange(); return platform.ISteamMusicRemote_CurrentEntryWillChange();
} }
// bool // bool
public bool DeregisterSteamMusicRemote() public bool DeregisterSteamMusicRemote()
{ {
return _pi.ISteamMusicRemote_DeregisterSteamMusicRemote(); return platform.ISteamMusicRemote_DeregisterSteamMusicRemote();
} }
// bool // bool
public bool EnableLooped( bool bValue /*bool*/ ) public bool EnableLooped( bool bValue /*bool*/ )
{ {
return _pi.ISteamMusicRemote_EnableLooped( bValue ); return platform.ISteamMusicRemote_EnableLooped( bValue );
} }
// bool // bool
public bool EnablePlaylists( bool bValue /*bool*/ ) public bool EnablePlaylists( bool bValue /*bool*/ )
{ {
return _pi.ISteamMusicRemote_EnablePlaylists( bValue ); return platform.ISteamMusicRemote_EnablePlaylists( bValue );
} }
// bool // bool
public bool EnablePlayNext( bool bValue /*bool*/ ) public bool EnablePlayNext( bool bValue /*bool*/ )
{ {
return _pi.ISteamMusicRemote_EnablePlayNext( bValue ); return platform.ISteamMusicRemote_EnablePlayNext( bValue );
} }
// bool // bool
public bool EnablePlayPrevious( bool bValue /*bool*/ ) public bool EnablePlayPrevious( bool bValue /*bool*/ )
{ {
return _pi.ISteamMusicRemote_EnablePlayPrevious( bValue ); return platform.ISteamMusicRemote_EnablePlayPrevious( bValue );
} }
// bool // bool
public bool EnableQueue( bool bValue /*bool*/ ) public bool EnableQueue( bool bValue /*bool*/ )
{ {
return _pi.ISteamMusicRemote_EnableQueue( bValue ); return platform.ISteamMusicRemote_EnableQueue( bValue );
} }
// bool // bool
public bool EnableShuffled( bool bValue /*bool*/ ) public bool EnableShuffled( bool bValue /*bool*/ )
{ {
return _pi.ISteamMusicRemote_EnableShuffled( bValue ); return platform.ISteamMusicRemote_EnableShuffled( bValue );
} }
// bool // bool
public bool PlaylistDidChange() public bool PlaylistDidChange()
{ {
return _pi.ISteamMusicRemote_PlaylistDidChange(); return platform.ISteamMusicRemote_PlaylistDidChange();
} }
// bool // bool
public bool PlaylistWillChange() public bool PlaylistWillChange()
{ {
return _pi.ISteamMusicRemote_PlaylistWillChange(); return platform.ISteamMusicRemote_PlaylistWillChange();
} }
// bool // bool
public bool QueueDidChange() public bool QueueDidChange()
{ {
return _pi.ISteamMusicRemote_QueueDidChange(); return platform.ISteamMusicRemote_QueueDidChange();
} }
// bool // bool
public bool QueueWillChange() public bool QueueWillChange()
{ {
return _pi.ISteamMusicRemote_QueueWillChange(); return platform.ISteamMusicRemote_QueueWillChange();
} }
// bool // bool
public bool RegisterSteamMusicRemote( string pchName /*const char **/ ) public bool RegisterSteamMusicRemote( string pchName /*const char **/ )
{ {
return _pi.ISteamMusicRemote_RegisterSteamMusicRemote( pchName ); return platform.ISteamMusicRemote_RegisterSteamMusicRemote( pchName );
} }
// bool // bool
public bool ResetPlaylistEntries() public bool ResetPlaylistEntries()
{ {
return _pi.ISteamMusicRemote_ResetPlaylistEntries(); return platform.ISteamMusicRemote_ResetPlaylistEntries();
} }
// bool // bool
public bool ResetQueueEntries() public bool ResetQueueEntries()
{ {
return _pi.ISteamMusicRemote_ResetQueueEntries(); return platform.ISteamMusicRemote_ResetQueueEntries();
} }
// bool // bool
public bool SetCurrentPlaylistEntry( int nID /*int*/ ) public bool SetCurrentPlaylistEntry( int nID /*int*/ )
{ {
return _pi.ISteamMusicRemote_SetCurrentPlaylistEntry( nID ); return platform.ISteamMusicRemote_SetCurrentPlaylistEntry( nID );
} }
// bool // bool
public bool SetCurrentQueueEntry( int nID /*int*/ ) public bool SetCurrentQueueEntry( int nID /*int*/ )
{ {
return _pi.ISteamMusicRemote_SetCurrentQueueEntry( nID ); return platform.ISteamMusicRemote_SetCurrentQueueEntry( nID );
} }
// bool // bool
public bool SetDisplayName( string pchDisplayName /*const char **/ ) public bool SetDisplayName( string pchDisplayName /*const char **/ )
{ {
return _pi.ISteamMusicRemote_SetDisplayName( pchDisplayName ); return platform.ISteamMusicRemote_SetDisplayName( pchDisplayName );
} }
// bool // bool
public bool SetPlaylistEntry( int nID /*int*/, int nPosition /*int*/, string pchEntryText /*const char **/ ) public bool SetPlaylistEntry( int nID /*int*/, int nPosition /*int*/, string pchEntryText /*const char **/ )
{ {
return _pi.ISteamMusicRemote_SetPlaylistEntry( nID, nPosition, pchEntryText ); return platform.ISteamMusicRemote_SetPlaylistEntry( nID, nPosition, pchEntryText );
} }
// bool // bool
public bool SetPNGIcon_64x64( IntPtr pvBuffer /*void **/, uint cbBufferLength /*uint32*/ ) public bool SetPNGIcon_64x64( IntPtr pvBuffer /*void **/, uint cbBufferLength /*uint32*/ )
{ {
return _pi.ISteamMusicRemote_SetPNGIcon_64x64( (IntPtr) pvBuffer, cbBufferLength ); return platform.ISteamMusicRemote_SetPNGIcon_64x64( (IntPtr) pvBuffer, cbBufferLength );
} }
// bool // bool
public bool SetQueueEntry( int nID /*int*/, int nPosition /*int*/, string pchEntryText /*const char **/ ) public bool SetQueueEntry( int nID /*int*/, int nPosition /*int*/, string pchEntryText /*const char **/ )
{ {
return _pi.ISteamMusicRemote_SetQueueEntry( nID, nPosition, pchEntryText ); return platform.ISteamMusicRemote_SetQueueEntry( nID, nPosition, pchEntryText );
} }
// bool // bool
public bool UpdateCurrentEntryCoverArt( IntPtr pvBuffer /*void **/, uint cbBufferLength /*uint32*/ ) public bool UpdateCurrentEntryCoverArt( IntPtr pvBuffer /*void **/, uint cbBufferLength /*uint32*/ )
{ {
return _pi.ISteamMusicRemote_UpdateCurrentEntryCoverArt( (IntPtr) pvBuffer, cbBufferLength ); return platform.ISteamMusicRemote_UpdateCurrentEntryCoverArt( (IntPtr) pvBuffer, cbBufferLength );
} }
// bool // bool
public bool UpdateCurrentEntryElapsedSeconds( int nValue /*int*/ ) public bool UpdateCurrentEntryElapsedSeconds( int nValue /*int*/ )
{ {
return _pi.ISteamMusicRemote_UpdateCurrentEntryElapsedSeconds( nValue ); return platform.ISteamMusicRemote_UpdateCurrentEntryElapsedSeconds( nValue );
} }
// bool // bool
public bool UpdateCurrentEntryText( string pchText /*const char **/ ) public bool UpdateCurrentEntryText( string pchText /*const char **/ )
{ {
return _pi.ISteamMusicRemote_UpdateCurrentEntryText( pchText ); return platform.ISteamMusicRemote_UpdateCurrentEntryText( pchText );
} }
// bool // bool
public bool UpdateLooped( bool bValue /*bool*/ ) public bool UpdateLooped( bool bValue /*bool*/ )
{ {
return _pi.ISteamMusicRemote_UpdateLooped( bValue ); return platform.ISteamMusicRemote_UpdateLooped( bValue );
} }
// bool // bool
public bool UpdatePlaybackStatus( AudioPlayback_Status nStatus /*AudioPlayback_Status*/ ) public bool UpdatePlaybackStatus( AudioPlayback_Status nStatus /*AudioPlayback_Status*/ )
{ {
return _pi.ISteamMusicRemote_UpdatePlaybackStatus( nStatus ); return platform.ISteamMusicRemote_UpdatePlaybackStatus( nStatus );
} }
// bool // bool
public bool UpdateShuffled( bool bValue /*bool*/ ) public bool UpdateShuffled( bool bValue /*bool*/ )
{ {
return _pi.ISteamMusicRemote_UpdateShuffled( bValue ); return platform.ISteamMusicRemote_UpdateShuffled( bValue );
} }
// bool // bool
public bool UpdateVolume( float flValue /*float*/ ) public bool UpdateVolume( float flValue /*float*/ )
{ {
return _pi.ISteamMusicRemote_UpdateVolume( flValue ); return platform.ISteamMusicRemote_UpdateVolume( flValue );
} }
} }

View File

@ -3,172 +3,175 @@
namespace SteamNative namespace SteamNative
{ {
public unsafe class SteamNetworking : IDisposable internal unsafe class SteamNetworking : IDisposable
{ {
// //
// Holds a platform specific implentation // Holds a platform specific implentation
// //
internal Platform.Interface _pi; internal Platform.Interface platform;
internal Facepunch.Steamworks.BaseSteamworks steamworks;
// //
// Constructor decides which implementation to use based on current platform // Constructor decides which implementation to use based on current platform
// //
public SteamNetworking( IntPtr pointer ) public SteamNetworking( Facepunch.Steamworks.BaseSteamworks steamworks, IntPtr pointer )
{ {
if ( Platform.IsWindows64 ) _pi = new Platform.Win64( pointer ); this.steamworks = steamworks;
else if ( Platform.IsWindows32 ) _pi = new Platform.Win32( pointer );
else if ( Platform.IsLinux32 ) _pi = new Platform.Linux32( pointer ); if ( Platform.IsWindows64 ) platform = new Platform.Win64( pointer );
else if ( Platform.IsLinux64 ) _pi = new Platform.Linux64( pointer ); else if ( Platform.IsWindows32 ) platform = new Platform.Win32( pointer );
else if ( Platform.IsOsx ) _pi = new Platform.Mac( pointer ); else if ( Platform.IsLinux32 ) platform = new Platform.Linux32( pointer );
else if ( Platform.IsLinux64 ) platform = new Platform.Linux64( pointer );
else if ( Platform.IsOsx ) platform = new Platform.Mac( pointer );
} }
// //
// Class is invalid if we don't have a valid implementation // Class is invalid if we don't have a valid implementation
// //
public bool IsValid{ get{ return _pi != null && _pi.IsValid; } } public bool IsValid{ get{ return platform != null && platform.IsValid; } }
// //
// When shutting down clear all the internals to avoid accidental use // When shutting down clear all the internals to avoid accidental use
// //
public virtual void Dispose() public virtual void Dispose()
{ {
if ( _pi != null ) if ( platform != null )
{ {
_pi.Dispose(); platform.Dispose();
_pi = null; platform = null;
} }
} }
// bool // bool
public bool AcceptP2PSessionWithUser( CSteamID steamIDRemote /*class CSteamID*/ ) public bool AcceptP2PSessionWithUser( CSteamID steamIDRemote /*class CSteamID*/ )
{ {
return _pi.ISteamNetworking_AcceptP2PSessionWithUser( steamIDRemote.Value ); return platform.ISteamNetworking_AcceptP2PSessionWithUser( steamIDRemote.Value );
} }
// bool // bool
public bool AllowP2PPacketRelay( bool bAllow /*bool*/ ) public bool AllowP2PPacketRelay( bool bAllow /*bool*/ )
{ {
return _pi.ISteamNetworking_AllowP2PPacketRelay( bAllow ); return platform.ISteamNetworking_AllowP2PPacketRelay( bAllow );
} }
// bool // bool
public bool CloseP2PChannelWithUser( CSteamID steamIDRemote /*class CSteamID*/, int nChannel /*int*/ ) public bool CloseP2PChannelWithUser( CSteamID steamIDRemote /*class CSteamID*/, int nChannel /*int*/ )
{ {
return _pi.ISteamNetworking_CloseP2PChannelWithUser( steamIDRemote.Value, nChannel ); return platform.ISteamNetworking_CloseP2PChannelWithUser( steamIDRemote.Value, nChannel );
} }
// bool // bool
public bool CloseP2PSessionWithUser( CSteamID steamIDRemote /*class CSteamID*/ ) public bool CloseP2PSessionWithUser( CSteamID steamIDRemote /*class CSteamID*/ )
{ {
return _pi.ISteamNetworking_CloseP2PSessionWithUser( steamIDRemote.Value ); return platform.ISteamNetworking_CloseP2PSessionWithUser( steamIDRemote.Value );
} }
// SNetSocket_t // SNetSocket_t
public SNetSocket_t CreateConnectionSocket( uint nIP /*uint32*/, ushort nPort /*uint16*/, int nTimeoutSec /*int*/ ) public SNetSocket_t CreateConnectionSocket( uint nIP /*uint32*/, ushort nPort /*uint16*/, int nTimeoutSec /*int*/ )
{ {
return _pi.ISteamNetworking_CreateConnectionSocket( nIP, nPort, nTimeoutSec ); return platform.ISteamNetworking_CreateConnectionSocket( nIP, nPort, nTimeoutSec );
} }
// SNetListenSocket_t // SNetListenSocket_t
public SNetListenSocket_t CreateListenSocket( int nVirtualP2PPort /*int*/, uint nIP /*uint32*/, ushort nPort /*uint16*/, bool bAllowUseOfPacketRelay /*bool*/ ) public SNetListenSocket_t CreateListenSocket( int nVirtualP2PPort /*int*/, uint nIP /*uint32*/, ushort nPort /*uint16*/, bool bAllowUseOfPacketRelay /*bool*/ )
{ {
return _pi.ISteamNetworking_CreateListenSocket( nVirtualP2PPort, nIP, nPort, bAllowUseOfPacketRelay ); return platform.ISteamNetworking_CreateListenSocket( nVirtualP2PPort, nIP, nPort, bAllowUseOfPacketRelay );
} }
// SNetSocket_t // SNetSocket_t
public SNetSocket_t CreateP2PConnectionSocket( CSteamID steamIDTarget /*class CSteamID*/, int nVirtualPort /*int*/, int nTimeoutSec /*int*/, bool bAllowUseOfPacketRelay /*bool*/ ) public SNetSocket_t CreateP2PConnectionSocket( CSteamID steamIDTarget /*class CSteamID*/, int nVirtualPort /*int*/, int nTimeoutSec /*int*/, bool bAllowUseOfPacketRelay /*bool*/ )
{ {
return _pi.ISteamNetworking_CreateP2PConnectionSocket( steamIDTarget.Value, nVirtualPort, nTimeoutSec, bAllowUseOfPacketRelay ); return platform.ISteamNetworking_CreateP2PConnectionSocket( steamIDTarget.Value, nVirtualPort, nTimeoutSec, bAllowUseOfPacketRelay );
} }
// bool // bool
public bool DestroyListenSocket( SNetListenSocket_t hSocket /*SNetListenSocket_t*/, bool bNotifyRemoteEnd /*bool*/ ) public bool DestroyListenSocket( SNetListenSocket_t hSocket /*SNetListenSocket_t*/, bool bNotifyRemoteEnd /*bool*/ )
{ {
return _pi.ISteamNetworking_DestroyListenSocket( hSocket.Value, bNotifyRemoteEnd ); return platform.ISteamNetworking_DestroyListenSocket( hSocket.Value, bNotifyRemoteEnd );
} }
// bool // bool
public bool DestroySocket( SNetSocket_t hSocket /*SNetSocket_t*/, bool bNotifyRemoteEnd /*bool*/ ) public bool DestroySocket( SNetSocket_t hSocket /*SNetSocket_t*/, bool bNotifyRemoteEnd /*bool*/ )
{ {
return _pi.ISteamNetworking_DestroySocket( hSocket.Value, bNotifyRemoteEnd ); return platform.ISteamNetworking_DestroySocket( hSocket.Value, bNotifyRemoteEnd );
} }
// bool // bool
public bool GetListenSocketInfo( SNetListenSocket_t hListenSocket /*SNetListenSocket_t*/, out uint pnIP /*uint32 **/, out ushort pnPort /*uint16 **/ ) public bool GetListenSocketInfo( SNetListenSocket_t hListenSocket /*SNetListenSocket_t*/, out uint pnIP /*uint32 **/, out ushort pnPort /*uint16 **/ )
{ {
return _pi.ISteamNetworking_GetListenSocketInfo( hListenSocket.Value, out pnIP, out pnPort ); return platform.ISteamNetworking_GetListenSocketInfo( hListenSocket.Value, out pnIP, out pnPort );
} }
// int // int
public int GetMaxPacketSize( SNetSocket_t hSocket /*SNetSocket_t*/ ) public int GetMaxPacketSize( SNetSocket_t hSocket /*SNetSocket_t*/ )
{ {
return _pi.ISteamNetworking_GetMaxPacketSize( hSocket.Value ); return platform.ISteamNetworking_GetMaxPacketSize( hSocket.Value );
} }
// bool // bool
public bool GetP2PSessionState( CSteamID steamIDRemote /*class CSteamID*/, ref P2PSessionState_t pConnectionState /*struct P2PSessionState_t **/ ) public bool GetP2PSessionState( CSteamID steamIDRemote /*class CSteamID*/, ref P2PSessionState_t pConnectionState /*struct P2PSessionState_t **/ )
{ {
return _pi.ISteamNetworking_GetP2PSessionState( steamIDRemote.Value, ref pConnectionState ); return platform.ISteamNetworking_GetP2PSessionState( steamIDRemote.Value, ref pConnectionState );
} }
// SNetSocketConnectionType // SNetSocketConnectionType
public SNetSocketConnectionType GetSocketConnectionType( SNetSocket_t hSocket /*SNetSocket_t*/ ) public SNetSocketConnectionType GetSocketConnectionType( SNetSocket_t hSocket /*SNetSocket_t*/ )
{ {
return _pi.ISteamNetworking_GetSocketConnectionType( hSocket.Value ); return platform.ISteamNetworking_GetSocketConnectionType( hSocket.Value );
} }
// bool // bool
public bool GetSocketInfo( SNetSocket_t hSocket /*SNetSocket_t*/, out CSteamID pSteamIDRemote /*class CSteamID **/, IntPtr peSocketStatus /*int **/, out uint punIPRemote /*uint32 **/, out ushort punPortRemote /*uint16 **/ ) public bool GetSocketInfo( SNetSocket_t hSocket /*SNetSocket_t*/, out CSteamID pSteamIDRemote /*class CSteamID **/, IntPtr peSocketStatus /*int **/, out uint punIPRemote /*uint32 **/, out ushort punPortRemote /*uint16 **/ )
{ {
return _pi.ISteamNetworking_GetSocketInfo( hSocket.Value, out pSteamIDRemote.Value, (IntPtr) peSocketStatus, out punIPRemote, out punPortRemote ); return platform.ISteamNetworking_GetSocketInfo( hSocket.Value, out pSteamIDRemote.Value, (IntPtr) peSocketStatus, out punIPRemote, out punPortRemote );
} }
// bool // bool
public bool IsDataAvailable( SNetListenSocket_t hListenSocket /*SNetListenSocket_t*/, out uint pcubMsgSize /*uint32 **/, ref SNetSocket_t phSocket /*SNetSocket_t **/ ) public bool IsDataAvailable( SNetListenSocket_t hListenSocket /*SNetListenSocket_t*/, out uint pcubMsgSize /*uint32 **/, ref SNetSocket_t phSocket /*SNetSocket_t **/ )
{ {
return _pi.ISteamNetworking_IsDataAvailable( hListenSocket.Value, out pcubMsgSize, ref phSocket.Value ); return platform.ISteamNetworking_IsDataAvailable( hListenSocket.Value, out pcubMsgSize, ref phSocket.Value );
} }
// bool // bool
public bool IsDataAvailableOnSocket( SNetSocket_t hSocket /*SNetSocket_t*/, out uint pcubMsgSize /*uint32 **/ ) public bool IsDataAvailableOnSocket( SNetSocket_t hSocket /*SNetSocket_t*/, out uint pcubMsgSize /*uint32 **/ )
{ {
return _pi.ISteamNetworking_IsDataAvailableOnSocket( hSocket.Value, out pcubMsgSize ); return platform.ISteamNetworking_IsDataAvailableOnSocket( hSocket.Value, out pcubMsgSize );
} }
// bool // bool
public bool IsP2PPacketAvailable( out uint pcubMsgSize /*uint32 **/, int nChannel /*int*/ ) public bool IsP2PPacketAvailable( out uint pcubMsgSize /*uint32 **/, int nChannel /*int*/ )
{ {
return _pi.ISteamNetworking_IsP2PPacketAvailable( out pcubMsgSize, nChannel ); return platform.ISteamNetworking_IsP2PPacketAvailable( out pcubMsgSize, nChannel );
} }
// bool // bool
public bool ReadP2PPacket( IntPtr pubDest /*void **/, uint cubDest /*uint32*/, out uint pcubMsgSize /*uint32 **/, out CSteamID psteamIDRemote /*class CSteamID **/, int nChannel /*int*/ ) public bool ReadP2PPacket( IntPtr pubDest /*void **/, uint cubDest /*uint32*/, out uint pcubMsgSize /*uint32 **/, out CSteamID psteamIDRemote /*class CSteamID **/, int nChannel /*int*/ )
{ {
return _pi.ISteamNetworking_ReadP2PPacket( (IntPtr) pubDest, cubDest, out pcubMsgSize, out psteamIDRemote.Value, nChannel ); return platform.ISteamNetworking_ReadP2PPacket( (IntPtr) pubDest, cubDest, out pcubMsgSize, out psteamIDRemote.Value, nChannel );
} }
// bool // bool
public bool RetrieveData( SNetListenSocket_t hListenSocket /*SNetListenSocket_t*/, IntPtr pubDest /*void **/, uint cubDest /*uint32*/, out uint pcubMsgSize /*uint32 **/, ref SNetSocket_t phSocket /*SNetSocket_t **/ ) public bool RetrieveData( SNetListenSocket_t hListenSocket /*SNetListenSocket_t*/, IntPtr pubDest /*void **/, uint cubDest /*uint32*/, out uint pcubMsgSize /*uint32 **/, ref SNetSocket_t phSocket /*SNetSocket_t **/ )
{ {
return _pi.ISteamNetworking_RetrieveData( hListenSocket.Value, (IntPtr) pubDest, cubDest, out pcubMsgSize, ref phSocket.Value ); return platform.ISteamNetworking_RetrieveData( hListenSocket.Value, (IntPtr) pubDest, cubDest, out pcubMsgSize, ref phSocket.Value );
} }
// bool // bool
public bool RetrieveDataFromSocket( SNetSocket_t hSocket /*SNetSocket_t*/, IntPtr pubDest /*void **/, uint cubDest /*uint32*/, out uint pcubMsgSize /*uint32 **/ ) public bool RetrieveDataFromSocket( SNetSocket_t hSocket /*SNetSocket_t*/, IntPtr pubDest /*void **/, uint cubDest /*uint32*/, out uint pcubMsgSize /*uint32 **/ )
{ {
return _pi.ISteamNetworking_RetrieveDataFromSocket( hSocket.Value, (IntPtr) pubDest, cubDest, out pcubMsgSize ); return platform.ISteamNetworking_RetrieveDataFromSocket( hSocket.Value, (IntPtr) pubDest, cubDest, out pcubMsgSize );
} }
// bool // bool
public bool SendDataOnSocket( SNetSocket_t hSocket /*SNetSocket_t*/, IntPtr pubData /*void **/, uint cubData /*uint32*/, bool bReliable /*bool*/ ) public bool SendDataOnSocket( SNetSocket_t hSocket /*SNetSocket_t*/, IntPtr pubData /*void **/, uint cubData /*uint32*/, bool bReliable /*bool*/ )
{ {
return _pi.ISteamNetworking_SendDataOnSocket( hSocket.Value, (IntPtr) pubData, cubData, bReliable ); return platform.ISteamNetworking_SendDataOnSocket( hSocket.Value, (IntPtr) pubData, cubData, bReliable );
} }
// bool // bool
public bool SendP2PPacket( CSteamID steamIDRemote /*class CSteamID*/, IntPtr pubData /*const void **/, uint cubData /*uint32*/, P2PSend eP2PSendType /*EP2PSend*/, int nChannel /*int*/ ) public bool SendP2PPacket( CSteamID steamIDRemote /*class CSteamID*/, IntPtr pubData /*const void **/, uint cubData /*uint32*/, P2PSend eP2PSendType /*EP2PSend*/, int nChannel /*int*/ )
{ {
return _pi.ISteamNetworking_SendP2PPacket( steamIDRemote.Value, (IntPtr) pubData, cubData, eP2PSendType, nChannel ); return platform.ISteamNetworking_SendP2PPacket( steamIDRemote.Value, (IntPtr) pubData, cubData, eP2PSendType, nChannel );
} }
} }

View File

@ -3,76 +3,97 @@
namespace SteamNative namespace SteamNative
{ {
public unsafe class SteamRemoteStorage : IDisposable internal unsafe class SteamRemoteStorage : IDisposable
{ {
// //
// Holds a platform specific implentation // Holds a platform specific implentation
// //
internal Platform.Interface _pi; internal Platform.Interface platform;
internal Facepunch.Steamworks.BaseSteamworks steamworks;
// //
// Constructor decides which implementation to use based on current platform // Constructor decides which implementation to use based on current platform
// //
public SteamRemoteStorage( IntPtr pointer ) public SteamRemoteStorage( Facepunch.Steamworks.BaseSteamworks steamworks, IntPtr pointer )
{ {
if ( Platform.IsWindows64 ) _pi = new Platform.Win64( pointer ); this.steamworks = steamworks;
else if ( Platform.IsWindows32 ) _pi = new Platform.Win32( pointer );
else if ( Platform.IsLinux32 ) _pi = new Platform.Linux32( pointer ); if ( Platform.IsWindows64 ) platform = new Platform.Win64( pointer );
else if ( Platform.IsLinux64 ) _pi = new Platform.Linux64( pointer ); else if ( Platform.IsWindows32 ) platform = new Platform.Win32( pointer );
else if ( Platform.IsOsx ) _pi = new Platform.Mac( pointer ); else if ( Platform.IsLinux32 ) platform = new Platform.Linux32( pointer );
else if ( Platform.IsLinux64 ) platform = new Platform.Linux64( pointer );
else if ( Platform.IsOsx ) platform = new Platform.Mac( pointer );
} }
// //
// Class is invalid if we don't have a valid implementation // Class is invalid if we don't have a valid implementation
// //
public bool IsValid{ get{ return _pi != null && _pi.IsValid; } } public bool IsValid{ get{ return platform != null && platform.IsValid; } }
// //
// When shutting down clear all the internals to avoid accidental use // When shutting down clear all the internals to avoid accidental use
// //
public virtual void Dispose() public virtual void Dispose()
{ {
if ( _pi != null ) if ( platform != null )
{ {
_pi.Dispose(); platform.Dispose();
_pi = null; platform = null;
} }
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t CommitPublishedFileUpdate( PublishedFileUpdateHandle_t updateHandle /*PublishedFileUpdateHandle_t*/ ) public CallbackHandle CommitPublishedFileUpdate( PublishedFileUpdateHandle_t updateHandle /*PublishedFileUpdateHandle_t*/, Action<RemoteStorageUpdatePublishedFileResult_t, bool> CallbackFunction = null /*Action<RemoteStorageUpdatePublishedFileResult_t, bool>*/ )
{ {
return _pi.ISteamRemoteStorage_CommitPublishedFileUpdate( updateHandle.Value ); SteamAPICall_t callback = 0;
callback = platform.ISteamRemoteStorage_CommitPublishedFileUpdate( updateHandle.Value );
if ( CallbackFunction == null ) return null;
return RemoteStorageUpdatePublishedFileResult_t.CallResult( steamworks, callback, CallbackFunction );
} }
// PublishedFileUpdateHandle_t // PublishedFileUpdateHandle_t
public PublishedFileUpdateHandle_t CreatePublishedFileUpdateRequest( PublishedFileId_t unPublishedFileId /*PublishedFileId_t*/ ) public PublishedFileUpdateHandle_t CreatePublishedFileUpdateRequest( PublishedFileId_t unPublishedFileId /*PublishedFileId_t*/ )
{ {
return _pi.ISteamRemoteStorage_CreatePublishedFileUpdateRequest( unPublishedFileId.Value ); return platform.ISteamRemoteStorage_CreatePublishedFileUpdateRequest( unPublishedFileId.Value );
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t DeletePublishedFile( PublishedFileId_t unPublishedFileId /*PublishedFileId_t*/ ) public CallbackHandle DeletePublishedFile( PublishedFileId_t unPublishedFileId /*PublishedFileId_t*/, Action<RemoteStorageDeletePublishedFileResult_t, bool> CallbackFunction = null /*Action<RemoteStorageDeletePublishedFileResult_t, bool>*/ )
{ {
return _pi.ISteamRemoteStorage_DeletePublishedFile( unPublishedFileId.Value ); SteamAPICall_t callback = 0;
callback = platform.ISteamRemoteStorage_DeletePublishedFile( unPublishedFileId.Value );
if ( CallbackFunction == null ) return null;
return RemoteStorageDeletePublishedFileResult_t.CallResult( steamworks, callback, CallbackFunction );
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t EnumeratePublishedFilesByUserAction( WorkshopFileAction eAction /*EWorkshopFileAction*/, uint unStartIndex /*uint32*/ ) public CallbackHandle EnumeratePublishedFilesByUserAction( WorkshopFileAction eAction /*EWorkshopFileAction*/, uint unStartIndex /*uint32*/, Action<RemoteStorageEnumeratePublishedFilesByUserActionResult_t, bool> CallbackFunction = null /*Action<RemoteStorageEnumeratePublishedFilesByUserActionResult_t, bool>*/ )
{ {
return _pi.ISteamRemoteStorage_EnumeratePublishedFilesByUserAction( eAction, unStartIndex ); SteamAPICall_t callback = 0;
callback = platform.ISteamRemoteStorage_EnumeratePublishedFilesByUserAction( eAction, unStartIndex );
if ( CallbackFunction == null ) return null;
return RemoteStorageEnumeratePublishedFilesByUserActionResult_t.CallResult( steamworks, callback, CallbackFunction );
} }
// SteamAPICall_t // SteamAPICall_t
// using: Detect_StringArray // using: Detect_StringArray
public SteamAPICall_t EnumeratePublishedWorkshopFiles( WorkshopEnumerationType eEnumerationType /*EWorkshopEnumerationType*/, uint unStartIndex /*uint32*/, uint unCount /*uint32*/, uint unDays /*uint32*/, string[] pTags /*struct SteamParamStringArray_t **/, ref SteamParamStringArray_t pUserTags /*struct SteamParamStringArray_t **/ ) public CallbackHandle EnumeratePublishedWorkshopFiles( WorkshopEnumerationType eEnumerationType /*EWorkshopEnumerationType*/, uint unStartIndex /*uint32*/, uint unCount /*uint32*/, uint unDays /*uint32*/, string[] pTags /*struct SteamParamStringArray_t **/, ref SteamParamStringArray_t pUserTags /*struct SteamParamStringArray_t **/, Action<RemoteStorageEnumerateWorkshopFilesResult_t, bool> CallbackFunction = null /*Action<RemoteStorageEnumerateWorkshopFilesResult_t, bool>*/ )
{ {
SteamAPICall_t callback = 0;
// Create strings // Create strings
var nativeStrings = new IntPtr[pTags.Length]; var nativeStrings = new IntPtr[pTags.Length];
for ( int i = 0; i < pTags.Length; i++ ) for ( int i = 0; i < pTags.Length; i++ )
{ {
nativeStrings[i] = Marshal.StringToHGlobalAnsi( pTags[i] ); nativeStrings[i] = Marshal.StringToHGlobalAnsi( pTags[i] );
} }
try
{
// Create string array // Create string array
var size = Marshal.SizeOf( typeof( IntPtr ) ) * nativeStrings.Length; var size = Marshal.SizeOf( typeof( IntPtr ) ) * nativeStrings.Length;
@ -83,29 +104,44 @@ public SteamAPICall_t EnumeratePublishedWorkshopFiles( WorkshopEnumerationType e
var tags = new SteamParamStringArray_t(); var tags = new SteamParamStringArray_t();
tags.Strings = nativeArray; tags.Strings = nativeArray;
tags.NumStrings = pTags.Length; tags.NumStrings = pTags.Length;
var result = _pi.ISteamRemoteStorage_EnumeratePublishedWorkshopFiles( eEnumerationType, unStartIndex, unCount, unDays, ref tags, ref pUserTags ); callback = platform.ISteamRemoteStorage_EnumeratePublishedWorkshopFiles( eEnumerationType, unStartIndex, unCount, unDays, ref tags, ref pUserTags );
}
finally
{
foreach ( var x in nativeStrings ) foreach ( var x in nativeStrings )
Marshal.FreeHGlobal( x ); Marshal.FreeHGlobal( x );
return result; }
if ( CallbackFunction == null ) return null;
return RemoteStorageEnumerateWorkshopFilesResult_t.CallResult( steamworks, callback, CallbackFunction );
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t EnumerateUserPublishedFiles( uint unStartIndex /*uint32*/ ) public CallbackHandle EnumerateUserPublishedFiles( uint unStartIndex /*uint32*/, Action<RemoteStorageEnumerateUserPublishedFilesResult_t, bool> CallbackFunction = null /*Action<RemoteStorageEnumerateUserPublishedFilesResult_t, bool>*/ )
{ {
return _pi.ISteamRemoteStorage_EnumerateUserPublishedFiles( unStartIndex ); SteamAPICall_t callback = 0;
callback = platform.ISteamRemoteStorage_EnumerateUserPublishedFiles( unStartIndex );
if ( CallbackFunction == null ) return null;
return RemoteStorageEnumerateUserPublishedFilesResult_t.CallResult( steamworks, callback, CallbackFunction );
} }
// SteamAPICall_t // SteamAPICall_t
// using: Detect_StringArray // using: Detect_StringArray
public SteamAPICall_t EnumerateUserSharedWorkshopFiles( CSteamID steamId /*class CSteamID*/, uint unStartIndex /*uint32*/, string[] pRequiredTags /*struct SteamParamStringArray_t **/, ref SteamParamStringArray_t pExcludedTags /*struct SteamParamStringArray_t **/ ) public CallbackHandle EnumerateUserSharedWorkshopFiles( CSteamID steamId /*class CSteamID*/, uint unStartIndex /*uint32*/, string[] pRequiredTags /*struct SteamParamStringArray_t **/, ref SteamParamStringArray_t pExcludedTags /*struct SteamParamStringArray_t **/, Action<RemoteStorageEnumerateUserPublishedFilesResult_t, bool> CallbackFunction = null /*Action<RemoteStorageEnumerateUserPublishedFilesResult_t, bool>*/ )
{ {
SteamAPICall_t callback = 0;
// Create strings // Create strings
var nativeStrings = new IntPtr[pRequiredTags.Length]; var nativeStrings = new IntPtr[pRequiredTags.Length];
for ( int i = 0; i < pRequiredTags.Length; i++ ) for ( int i = 0; i < pRequiredTags.Length; i++ )
{ {
nativeStrings[i] = Marshal.StringToHGlobalAnsi( pRequiredTags[i] ); nativeStrings[i] = Marshal.StringToHGlobalAnsi( pRequiredTags[i] );
} }
try
{
// Create string array // Create string array
var size = Marshal.SizeOf( typeof( IntPtr ) ) * nativeStrings.Length; var size = Marshal.SizeOf( typeof( IntPtr ) ) * nativeStrings.Length;
@ -116,119 +152,146 @@ public SteamAPICall_t EnumerateUserSharedWorkshopFiles( CSteamID steamId /*class
var tags = new SteamParamStringArray_t(); var tags = new SteamParamStringArray_t();
tags.Strings = nativeArray; tags.Strings = nativeArray;
tags.NumStrings = pRequiredTags.Length; tags.NumStrings = pRequiredTags.Length;
var result = _pi.ISteamRemoteStorage_EnumerateUserSharedWorkshopFiles( steamId.Value, unStartIndex, ref tags, ref pExcludedTags ); callback = platform.ISteamRemoteStorage_EnumerateUserSharedWorkshopFiles( steamId.Value, unStartIndex, ref tags, ref pExcludedTags );
}
finally
{
foreach ( var x in nativeStrings ) foreach ( var x in nativeStrings )
Marshal.FreeHGlobal( x ); Marshal.FreeHGlobal( x );
return result; }
if ( CallbackFunction == null ) return null;
return RemoteStorageEnumerateUserPublishedFilesResult_t.CallResult( steamworks, callback, CallbackFunction );
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t EnumerateUserSubscribedFiles( uint unStartIndex /*uint32*/ ) public CallbackHandle EnumerateUserSubscribedFiles( uint unStartIndex /*uint32*/, Action<RemoteStorageEnumerateUserSubscribedFilesResult_t, bool> CallbackFunction = null /*Action<RemoteStorageEnumerateUserSubscribedFilesResult_t, bool>*/ )
{ {
return _pi.ISteamRemoteStorage_EnumerateUserSubscribedFiles( unStartIndex ); SteamAPICall_t callback = 0;
callback = platform.ISteamRemoteStorage_EnumerateUserSubscribedFiles( unStartIndex );
if ( CallbackFunction == null ) return null;
return RemoteStorageEnumerateUserSubscribedFilesResult_t.CallResult( steamworks, callback, CallbackFunction );
} }
// bool // bool
public bool FileDelete( string pchFile /*const char **/ ) public bool FileDelete( string pchFile /*const char **/ )
{ {
return _pi.ISteamRemoteStorage_FileDelete( pchFile ); return platform.ISteamRemoteStorage_FileDelete( pchFile );
} }
// bool // bool
public bool FileExists( string pchFile /*const char **/ ) public bool FileExists( string pchFile /*const char **/ )
{ {
return _pi.ISteamRemoteStorage_FileExists( pchFile ); return platform.ISteamRemoteStorage_FileExists( pchFile );
} }
// bool // bool
public bool FileForget( string pchFile /*const char **/ ) public bool FileForget( string pchFile /*const char **/ )
{ {
return _pi.ISteamRemoteStorage_FileForget( pchFile ); return platform.ISteamRemoteStorage_FileForget( pchFile );
} }
// bool // bool
public bool FilePersisted( string pchFile /*const char **/ ) public bool FilePersisted( string pchFile /*const char **/ )
{ {
return _pi.ISteamRemoteStorage_FilePersisted( pchFile ); return platform.ISteamRemoteStorage_FilePersisted( pchFile );
} }
// int // int
public int FileRead( string pchFile /*const char **/, IntPtr pvData /*void **/, int cubDataToRead /*int32*/ ) public int FileRead( string pchFile /*const char **/, IntPtr pvData /*void **/, int cubDataToRead /*int32*/ )
{ {
return _pi.ISteamRemoteStorage_FileRead( pchFile, (IntPtr) pvData, cubDataToRead ); return platform.ISteamRemoteStorage_FileRead( pchFile, (IntPtr) pvData, cubDataToRead );
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t FileReadAsync( string pchFile /*const char **/, uint nOffset /*uint32*/, uint cubToRead /*uint32*/ ) public CallbackHandle FileReadAsync( string pchFile /*const char **/, uint nOffset /*uint32*/, uint cubToRead /*uint32*/, Action<RemoteStorageFileReadAsyncComplete_t, bool> CallbackFunction = null /*Action<RemoteStorageFileReadAsyncComplete_t, bool>*/ )
{ {
return _pi.ISteamRemoteStorage_FileReadAsync( pchFile, nOffset, cubToRead ); SteamAPICall_t callback = 0;
callback = platform.ISteamRemoteStorage_FileReadAsync( pchFile, nOffset, cubToRead );
if ( CallbackFunction == null ) return null;
return RemoteStorageFileReadAsyncComplete_t.CallResult( steamworks, callback, CallbackFunction );
} }
// bool // bool
public bool FileReadAsyncComplete( SteamAPICall_t hReadCall /*SteamAPICall_t*/, IntPtr pvBuffer /*void **/, uint cubToRead /*uint32*/ ) public bool FileReadAsyncComplete( SteamAPICall_t hReadCall /*SteamAPICall_t*/, IntPtr pvBuffer /*void **/, uint cubToRead /*uint32*/ )
{ {
return _pi.ISteamRemoteStorage_FileReadAsyncComplete( hReadCall.Value, (IntPtr) pvBuffer, cubToRead ); return platform.ISteamRemoteStorage_FileReadAsyncComplete( hReadCall.Value, (IntPtr) pvBuffer, cubToRead );
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t FileShare( string pchFile /*const char **/ ) public CallbackHandle FileShare( string pchFile /*const char **/, Action<RemoteStorageFileShareResult_t, bool> CallbackFunction = null /*Action<RemoteStorageFileShareResult_t, bool>*/ )
{ {
return _pi.ISteamRemoteStorage_FileShare( pchFile ); SteamAPICall_t callback = 0;
callback = platform.ISteamRemoteStorage_FileShare( pchFile );
if ( CallbackFunction == null ) return null;
return RemoteStorageFileShareResult_t.CallResult( steamworks, callback, CallbackFunction );
} }
// bool // bool
public bool FileWrite( string pchFile /*const char **/, IntPtr pvData /*const void **/, int cubData /*int32*/ ) public bool FileWrite( string pchFile /*const char **/, IntPtr pvData /*const void **/, int cubData /*int32*/ )
{ {
return _pi.ISteamRemoteStorage_FileWrite( pchFile, (IntPtr) pvData, cubData ); return platform.ISteamRemoteStorage_FileWrite( pchFile, (IntPtr) pvData, cubData );
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t FileWriteAsync( string pchFile /*const char **/, IntPtr pvData /*const void **/, uint cubData /*uint32*/ ) public CallbackHandle FileWriteAsync( string pchFile /*const char **/, IntPtr pvData /*const void **/, uint cubData /*uint32*/, Action<RemoteStorageFileWriteAsyncComplete_t, bool> CallbackFunction = null /*Action<RemoteStorageFileWriteAsyncComplete_t, bool>*/ )
{ {
return _pi.ISteamRemoteStorage_FileWriteAsync( pchFile, (IntPtr) pvData, cubData ); SteamAPICall_t callback = 0;
callback = platform.ISteamRemoteStorage_FileWriteAsync( pchFile, (IntPtr) pvData, cubData );
if ( CallbackFunction == null ) return null;
return RemoteStorageFileWriteAsyncComplete_t.CallResult( steamworks, callback, CallbackFunction );
} }
// bool // bool
public bool FileWriteStreamCancel( UGCFileWriteStreamHandle_t writeHandle /*UGCFileWriteStreamHandle_t*/ ) public bool FileWriteStreamCancel( UGCFileWriteStreamHandle_t writeHandle /*UGCFileWriteStreamHandle_t*/ )
{ {
return _pi.ISteamRemoteStorage_FileWriteStreamCancel( writeHandle.Value ); return platform.ISteamRemoteStorage_FileWriteStreamCancel( writeHandle.Value );
} }
// bool // bool
public bool FileWriteStreamClose( UGCFileWriteStreamHandle_t writeHandle /*UGCFileWriteStreamHandle_t*/ ) public bool FileWriteStreamClose( UGCFileWriteStreamHandle_t writeHandle /*UGCFileWriteStreamHandle_t*/ )
{ {
return _pi.ISteamRemoteStorage_FileWriteStreamClose( writeHandle.Value ); return platform.ISteamRemoteStorage_FileWriteStreamClose( writeHandle.Value );
} }
// UGCFileWriteStreamHandle_t // UGCFileWriteStreamHandle_t
public UGCFileWriteStreamHandle_t FileWriteStreamOpen( string pchFile /*const char **/ ) public UGCFileWriteStreamHandle_t FileWriteStreamOpen( string pchFile /*const char **/ )
{ {
return _pi.ISteamRemoteStorage_FileWriteStreamOpen( pchFile ); return platform.ISteamRemoteStorage_FileWriteStreamOpen( pchFile );
} }
// bool // bool
public bool FileWriteStreamWriteChunk( UGCFileWriteStreamHandle_t writeHandle /*UGCFileWriteStreamHandle_t*/, IntPtr pvData /*const void **/, int cubData /*int32*/ ) public bool FileWriteStreamWriteChunk( UGCFileWriteStreamHandle_t writeHandle /*UGCFileWriteStreamHandle_t*/, IntPtr pvData /*const void **/, int cubData /*int32*/ )
{ {
return _pi.ISteamRemoteStorage_FileWriteStreamWriteChunk( writeHandle.Value, (IntPtr) pvData, cubData ); return platform.ISteamRemoteStorage_FileWriteStreamWriteChunk( writeHandle.Value, (IntPtr) pvData, cubData );
} }
// int // int
public int GetCachedUGCCount() public int GetCachedUGCCount()
{ {
return _pi.ISteamRemoteStorage_GetCachedUGCCount(); return platform.ISteamRemoteStorage_GetCachedUGCCount();
} }
// UGCHandle_t // UGCHandle_t
public UGCHandle_t GetCachedUGCHandle( int iCachedContent /*int32*/ ) public UGCHandle_t GetCachedUGCHandle( int iCachedContent /*int32*/ )
{ {
return _pi.ISteamRemoteStorage_GetCachedUGCHandle( iCachedContent ); return platform.ISteamRemoteStorage_GetCachedUGCHandle( iCachedContent );
} }
// int // int
public int GetFileCount() public int GetFileCount()
{ {
return _pi.ISteamRemoteStorage_GetFileCount(); return platform.ISteamRemoteStorage_GetFileCount();
} }
// string // string
@ -236,44 +299,54 @@ public int GetFileCount()
public string GetFileNameAndSize( int iFile /*int*/, IntPtr pnFileSizeInBytes /*int32 **/ ) public string GetFileNameAndSize( int iFile /*int*/, IntPtr pnFileSizeInBytes /*int32 **/ )
{ {
IntPtr string_pointer; IntPtr string_pointer;
string_pointer = _pi.ISteamRemoteStorage_GetFileNameAndSize( iFile, (IntPtr) pnFileSizeInBytes ); string_pointer = platform.ISteamRemoteStorage_GetFileNameAndSize( iFile, (IntPtr) pnFileSizeInBytes );
return Marshal.PtrToStringAnsi( string_pointer ); return Marshal.PtrToStringAnsi( string_pointer );
} }
// int // int
public int GetFileSize( string pchFile /*const char **/ ) public int GetFileSize( string pchFile /*const char **/ )
{ {
return _pi.ISteamRemoteStorage_GetFileSize( pchFile ); return platform.ISteamRemoteStorage_GetFileSize( pchFile );
} }
// long // long
public long GetFileTimestamp( string pchFile /*const char **/ ) public long GetFileTimestamp( string pchFile /*const char **/ )
{ {
return _pi.ISteamRemoteStorage_GetFileTimestamp( pchFile ); return platform.ISteamRemoteStorage_GetFileTimestamp( pchFile );
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t GetPublishedFileDetails( PublishedFileId_t unPublishedFileId /*PublishedFileId_t*/, uint unMaxSecondsOld /*uint32*/ ) public CallbackHandle GetPublishedFileDetails( PublishedFileId_t unPublishedFileId /*PublishedFileId_t*/, uint unMaxSecondsOld /*uint32*/, Action<RemoteStorageGetPublishedFileDetailsResult_t, bool> CallbackFunction = null /*Action<RemoteStorageGetPublishedFileDetailsResult_t, bool>*/ )
{ {
return _pi.ISteamRemoteStorage_GetPublishedFileDetails( unPublishedFileId.Value, unMaxSecondsOld ); SteamAPICall_t callback = 0;
callback = platform.ISteamRemoteStorage_GetPublishedFileDetails( unPublishedFileId.Value, unMaxSecondsOld );
if ( CallbackFunction == null ) return null;
return RemoteStorageGetPublishedFileDetailsResult_t.CallResult( steamworks, callback, CallbackFunction );
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t GetPublishedItemVoteDetails( PublishedFileId_t unPublishedFileId /*PublishedFileId_t*/ ) public CallbackHandle GetPublishedItemVoteDetails( PublishedFileId_t unPublishedFileId /*PublishedFileId_t*/, Action<RemoteStorageGetPublishedItemVoteDetailsResult_t, bool> CallbackFunction = null /*Action<RemoteStorageGetPublishedItemVoteDetailsResult_t, bool>*/ )
{ {
return _pi.ISteamRemoteStorage_GetPublishedItemVoteDetails( unPublishedFileId.Value ); SteamAPICall_t callback = 0;
callback = platform.ISteamRemoteStorage_GetPublishedItemVoteDetails( unPublishedFileId.Value );
if ( CallbackFunction == null ) return null;
return RemoteStorageGetPublishedItemVoteDetailsResult_t.CallResult( steamworks, callback, CallbackFunction );
} }
// bool // bool
public bool GetQuota( IntPtr pnTotalBytes /*uint64 **/, IntPtr puAvailableBytes /*uint64 **/ ) public bool GetQuota( IntPtr pnTotalBytes /*uint64 **/, IntPtr puAvailableBytes /*uint64 **/ )
{ {
return _pi.ISteamRemoteStorage_GetQuota( (IntPtr) pnTotalBytes, (IntPtr) puAvailableBytes ); return platform.ISteamRemoteStorage_GetQuota( (IntPtr) pnTotalBytes, (IntPtr) puAvailableBytes );
} }
// RemoteStoragePlatform // RemoteStoragePlatform
public RemoteStoragePlatform GetSyncPlatforms( string pchFile /*const char **/ ) public RemoteStoragePlatform GetSyncPlatforms( string pchFile /*const char **/ )
{ {
return _pi.ISteamRemoteStorage_GetSyncPlatforms( pchFile ); return platform.ISteamRemoteStorage_GetSyncPlatforms( pchFile );
} }
// bool // bool
@ -284,7 +357,7 @@ public bool GetUGCDetails( UGCHandle_t hContent /*UGCHandle_t*/, ref AppId_t pnA
ppchName = string.Empty; ppchName = string.Empty;
System.Text.StringBuilder ppchName_sb = new System.Text.StringBuilder( 4096 ); System.Text.StringBuilder ppchName_sb = new System.Text.StringBuilder( 4096 );
int pnFileSizeInBytes = 4096; int pnFileSizeInBytes = 4096;
bSuccess = _pi.ISteamRemoteStorage_GetUGCDetails( hContent.Value, ref pnAppID.Value, ppchName_sb, (IntPtr) pnFileSizeInBytes, out pSteamIDOwner.Value ); bSuccess = platform.ISteamRemoteStorage_GetUGCDetails( hContent.Value, ref pnAppID.Value, ppchName_sb, (IntPtr) pnFileSizeInBytes, out pSteamIDOwner.Value );
if ( !bSuccess ) return bSuccess; if ( !bSuccess ) return bSuccess;
ppchName = ppchName_sb.ToString(); ppchName = ppchName_sb.ToString();
return bSuccess; return bSuccess;
@ -293,37 +366,45 @@ public bool GetUGCDetails( UGCHandle_t hContent /*UGCHandle_t*/, ref AppId_t pnA
// bool // bool
public bool GetUGCDownloadProgress( UGCHandle_t hContent /*UGCHandle_t*/, out int pnBytesDownloaded /*int32 **/, out int pnBytesExpected /*int32 **/ ) public bool GetUGCDownloadProgress( UGCHandle_t hContent /*UGCHandle_t*/, out int pnBytesDownloaded /*int32 **/, out int pnBytesExpected /*int32 **/ )
{ {
return _pi.ISteamRemoteStorage_GetUGCDownloadProgress( hContent.Value, out pnBytesDownloaded, out pnBytesExpected ); return platform.ISteamRemoteStorage_GetUGCDownloadProgress( hContent.Value, out pnBytesDownloaded, out pnBytesExpected );
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t GetUserPublishedItemVoteDetails( PublishedFileId_t unPublishedFileId /*PublishedFileId_t*/ ) public CallbackHandle GetUserPublishedItemVoteDetails( PublishedFileId_t unPublishedFileId /*PublishedFileId_t*/, Action<RemoteStorageGetPublishedItemVoteDetailsResult_t, bool> CallbackFunction = null /*Action<RemoteStorageGetPublishedItemVoteDetailsResult_t, bool>*/ )
{ {
return _pi.ISteamRemoteStorage_GetUserPublishedItemVoteDetails( unPublishedFileId.Value ); SteamAPICall_t callback = 0;
callback = platform.ISteamRemoteStorage_GetUserPublishedItemVoteDetails( unPublishedFileId.Value );
if ( CallbackFunction == null ) return null;
return RemoteStorageGetPublishedItemVoteDetailsResult_t.CallResult( steamworks, callback, CallbackFunction );
} }
// bool // bool
public bool IsCloudEnabledForAccount() public bool IsCloudEnabledForAccount()
{ {
return _pi.ISteamRemoteStorage_IsCloudEnabledForAccount(); return platform.ISteamRemoteStorage_IsCloudEnabledForAccount();
} }
// bool // bool
public bool IsCloudEnabledForApp() public bool IsCloudEnabledForApp()
{ {
return _pi.ISteamRemoteStorage_IsCloudEnabledForApp(); return platform.ISteamRemoteStorage_IsCloudEnabledForApp();
} }
// SteamAPICall_t // SteamAPICall_t
// using: Detect_StringArray // using: Detect_StringArray
public SteamAPICall_t PublishVideo( WorkshopVideoProvider eVideoProvider /*EWorkshopVideoProvider*/, string pchVideoAccount /*const char **/, string pchVideoIdentifier /*const char **/, string pchPreviewFile /*const char **/, AppId_t nConsumerAppId /*AppId_t*/, string pchTitle /*const char **/, string pchDescription /*const char **/, RemoteStoragePublishedFileVisibility eVisibility /*ERemoteStoragePublishedFileVisibility*/, string[] pTags /*struct SteamParamStringArray_t **/ ) public CallbackHandle PublishVideo( WorkshopVideoProvider eVideoProvider /*EWorkshopVideoProvider*/, string pchVideoAccount /*const char **/, string pchVideoIdentifier /*const char **/, string pchPreviewFile /*const char **/, AppId_t nConsumerAppId /*AppId_t*/, string pchTitle /*const char **/, string pchDescription /*const char **/, RemoteStoragePublishedFileVisibility eVisibility /*ERemoteStoragePublishedFileVisibility*/, string[] pTags /*struct SteamParamStringArray_t **/, Action<RemoteStoragePublishFileProgress_t, bool> CallbackFunction = null /*Action<RemoteStoragePublishFileProgress_t, bool>*/ )
{ {
SteamAPICall_t callback = 0;
// Create strings // Create strings
var nativeStrings = new IntPtr[pTags.Length]; var nativeStrings = new IntPtr[pTags.Length];
for ( int i = 0; i < pTags.Length; i++ ) for ( int i = 0; i < pTags.Length; i++ )
{ {
nativeStrings[i] = Marshal.StringToHGlobalAnsi( pTags[i] ); nativeStrings[i] = Marshal.StringToHGlobalAnsi( pTags[i] );
} }
try
{
// Create string array // Create string array
var size = Marshal.SizeOf( typeof( IntPtr ) ) * nativeStrings.Length; var size = Marshal.SizeOf( typeof( IntPtr ) ) * nativeStrings.Length;
@ -334,23 +415,33 @@ public SteamAPICall_t PublishVideo( WorkshopVideoProvider eVideoProvider /*EWork
var tags = new SteamParamStringArray_t(); var tags = new SteamParamStringArray_t();
tags.Strings = nativeArray; tags.Strings = nativeArray;
tags.NumStrings = pTags.Length; tags.NumStrings = pTags.Length;
var result = _pi.ISteamRemoteStorage_PublishVideo( eVideoProvider, pchVideoAccount, pchVideoIdentifier, pchPreviewFile, nConsumerAppId.Value, pchTitle, pchDescription, eVisibility, ref tags ); callback = platform.ISteamRemoteStorage_PublishVideo( eVideoProvider, pchVideoAccount, pchVideoIdentifier, pchPreviewFile, nConsumerAppId.Value, pchTitle, pchDescription, eVisibility, ref tags );
}
finally
{
foreach ( var x in nativeStrings ) foreach ( var x in nativeStrings )
Marshal.FreeHGlobal( x ); Marshal.FreeHGlobal( x );
return result; }
if ( CallbackFunction == null ) return null;
return RemoteStoragePublishFileProgress_t.CallResult( steamworks, callback, CallbackFunction );
} }
// SteamAPICall_t // SteamAPICall_t
// using: Detect_StringArray // using: Detect_StringArray
public SteamAPICall_t PublishWorkshopFile( string pchFile /*const char **/, string pchPreviewFile /*const char **/, AppId_t nConsumerAppId /*AppId_t*/, string pchTitle /*const char **/, string pchDescription /*const char **/, RemoteStoragePublishedFileVisibility eVisibility /*ERemoteStoragePublishedFileVisibility*/, string[] pTags /*struct SteamParamStringArray_t **/, WorkshopFileType eWorkshopFileType /*EWorkshopFileType*/ ) public CallbackHandle PublishWorkshopFile( string pchFile /*const char **/, string pchPreviewFile /*const char **/, AppId_t nConsumerAppId /*AppId_t*/, string pchTitle /*const char **/, string pchDescription /*const char **/, RemoteStoragePublishedFileVisibility eVisibility /*ERemoteStoragePublishedFileVisibility*/, string[] pTags /*struct SteamParamStringArray_t **/, WorkshopFileType eWorkshopFileType /*EWorkshopFileType*/, Action<RemoteStoragePublishFileProgress_t, bool> CallbackFunction = null /*Action<RemoteStoragePublishFileProgress_t, bool>*/ )
{ {
SteamAPICall_t callback = 0;
// Create strings // Create strings
var nativeStrings = new IntPtr[pTags.Length]; var nativeStrings = new IntPtr[pTags.Length];
for ( int i = 0; i < pTags.Length; i++ ) for ( int i = 0; i < pTags.Length; i++ )
{ {
nativeStrings[i] = Marshal.StringToHGlobalAnsi( pTags[i] ); nativeStrings[i] = Marshal.StringToHGlobalAnsi( pTags[i] );
} }
try
{
// Create string array // Create string array
var size = Marshal.SizeOf( typeof( IntPtr ) ) * nativeStrings.Length; var size = Marshal.SizeOf( typeof( IntPtr ) ) * nativeStrings.Length;
@ -361,83 +452,115 @@ public SteamAPICall_t PublishWorkshopFile( string pchFile /*const char **/, stri
var tags = new SteamParamStringArray_t(); var tags = new SteamParamStringArray_t();
tags.Strings = nativeArray; tags.Strings = nativeArray;
tags.NumStrings = pTags.Length; tags.NumStrings = pTags.Length;
var result = _pi.ISteamRemoteStorage_PublishWorkshopFile( pchFile, pchPreviewFile, nConsumerAppId.Value, pchTitle, pchDescription, eVisibility, ref tags, eWorkshopFileType ); callback = platform.ISteamRemoteStorage_PublishWorkshopFile( pchFile, pchPreviewFile, nConsumerAppId.Value, pchTitle, pchDescription, eVisibility, ref tags, eWorkshopFileType );
}
finally
{
foreach ( var x in nativeStrings ) foreach ( var x in nativeStrings )
Marshal.FreeHGlobal( x ); Marshal.FreeHGlobal( x );
return result; }
if ( CallbackFunction == null ) return null;
return RemoteStoragePublishFileProgress_t.CallResult( steamworks, callback, CallbackFunction );
} }
// void // void
public void SetCloudEnabledForApp( bool bEnabled /*bool*/ ) public void SetCloudEnabledForApp( bool bEnabled /*bool*/ )
{ {
_pi.ISteamRemoteStorage_SetCloudEnabledForApp( bEnabled ); platform.ISteamRemoteStorage_SetCloudEnabledForApp( bEnabled );
} }
// bool // bool
public bool SetSyncPlatforms( string pchFile /*const char **/, RemoteStoragePlatform eRemoteStoragePlatform /*ERemoteStoragePlatform*/ ) public bool SetSyncPlatforms( string pchFile /*const char **/, RemoteStoragePlatform eRemoteStoragePlatform /*ERemoteStoragePlatform*/ )
{ {
return _pi.ISteamRemoteStorage_SetSyncPlatforms( pchFile, eRemoteStoragePlatform ); return platform.ISteamRemoteStorage_SetSyncPlatforms( pchFile, eRemoteStoragePlatform );
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t SetUserPublishedFileAction( PublishedFileId_t unPublishedFileId /*PublishedFileId_t*/, WorkshopFileAction eAction /*EWorkshopFileAction*/ ) public CallbackHandle SetUserPublishedFileAction( PublishedFileId_t unPublishedFileId /*PublishedFileId_t*/, WorkshopFileAction eAction /*EWorkshopFileAction*/, Action<RemoteStorageSetUserPublishedFileActionResult_t, bool> CallbackFunction = null /*Action<RemoteStorageSetUserPublishedFileActionResult_t, bool>*/ )
{ {
return _pi.ISteamRemoteStorage_SetUserPublishedFileAction( unPublishedFileId.Value, eAction ); SteamAPICall_t callback = 0;
callback = platform.ISteamRemoteStorage_SetUserPublishedFileAction( unPublishedFileId.Value, eAction );
if ( CallbackFunction == null ) return null;
return RemoteStorageSetUserPublishedFileActionResult_t.CallResult( steamworks, callback, CallbackFunction );
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t SubscribePublishedFile( PublishedFileId_t unPublishedFileId /*PublishedFileId_t*/ ) public CallbackHandle SubscribePublishedFile( PublishedFileId_t unPublishedFileId /*PublishedFileId_t*/, Action<RemoteStorageSubscribePublishedFileResult_t, bool> CallbackFunction = null /*Action<RemoteStorageSubscribePublishedFileResult_t, bool>*/ )
{ {
return _pi.ISteamRemoteStorage_SubscribePublishedFile( unPublishedFileId.Value ); SteamAPICall_t callback = 0;
callback = platform.ISteamRemoteStorage_SubscribePublishedFile( unPublishedFileId.Value );
if ( CallbackFunction == null ) return null;
return RemoteStorageSubscribePublishedFileResult_t.CallResult( steamworks, callback, CallbackFunction );
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t UGCDownload( UGCHandle_t hContent /*UGCHandle_t*/, uint unPriority /*uint32*/ ) public CallbackHandle UGCDownload( UGCHandle_t hContent /*UGCHandle_t*/, uint unPriority /*uint32*/, Action<RemoteStorageDownloadUGCResult_t, bool> CallbackFunction = null /*Action<RemoteStorageDownloadUGCResult_t, bool>*/ )
{ {
return _pi.ISteamRemoteStorage_UGCDownload( hContent.Value, unPriority ); SteamAPICall_t callback = 0;
callback = platform.ISteamRemoteStorage_UGCDownload( hContent.Value, unPriority );
if ( CallbackFunction == null ) return null;
return RemoteStorageDownloadUGCResult_t.CallResult( steamworks, callback, CallbackFunction );
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t UGCDownloadToLocation( UGCHandle_t hContent /*UGCHandle_t*/, string pchLocation /*const char **/, uint unPriority /*uint32*/ ) public CallbackHandle UGCDownloadToLocation( UGCHandle_t hContent /*UGCHandle_t*/, string pchLocation /*const char **/, uint unPriority /*uint32*/, Action<RemoteStorageDownloadUGCResult_t, bool> CallbackFunction = null /*Action<RemoteStorageDownloadUGCResult_t, bool>*/ )
{ {
return _pi.ISteamRemoteStorage_UGCDownloadToLocation( hContent.Value, pchLocation, unPriority ); SteamAPICall_t callback = 0;
callback = platform.ISteamRemoteStorage_UGCDownloadToLocation( hContent.Value, pchLocation, unPriority );
if ( CallbackFunction == null ) return null;
return RemoteStorageDownloadUGCResult_t.CallResult( steamworks, callback, CallbackFunction );
} }
// int // int
public int UGCRead( UGCHandle_t hContent /*UGCHandle_t*/, IntPtr pvData /*void **/, int cubDataToRead /*int32*/, uint cOffset /*uint32*/, UGCReadAction eAction /*EUGCReadAction*/ ) public int UGCRead( UGCHandle_t hContent /*UGCHandle_t*/, IntPtr pvData /*void **/, int cubDataToRead /*int32*/, uint cOffset /*uint32*/, UGCReadAction eAction /*EUGCReadAction*/ )
{ {
return _pi.ISteamRemoteStorage_UGCRead( hContent.Value, (IntPtr) pvData, cubDataToRead, cOffset, eAction ); return platform.ISteamRemoteStorage_UGCRead( hContent.Value, (IntPtr) pvData, cubDataToRead, cOffset, eAction );
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t UnsubscribePublishedFile( PublishedFileId_t unPublishedFileId /*PublishedFileId_t*/ ) public CallbackHandle UnsubscribePublishedFile( PublishedFileId_t unPublishedFileId /*PublishedFileId_t*/, Action<RemoteStorageUnsubscribePublishedFileResult_t, bool> CallbackFunction = null /*Action<RemoteStorageUnsubscribePublishedFileResult_t, bool>*/ )
{ {
return _pi.ISteamRemoteStorage_UnsubscribePublishedFile( unPublishedFileId.Value ); SteamAPICall_t callback = 0;
callback = platform.ISteamRemoteStorage_UnsubscribePublishedFile( unPublishedFileId.Value );
if ( CallbackFunction == null ) return null;
return RemoteStorageUnsubscribePublishedFileResult_t.CallResult( steamworks, callback, CallbackFunction );
} }
// bool // bool
public bool UpdatePublishedFileDescription( PublishedFileUpdateHandle_t updateHandle /*PublishedFileUpdateHandle_t*/, string pchDescription /*const char **/ ) public bool UpdatePublishedFileDescription( PublishedFileUpdateHandle_t updateHandle /*PublishedFileUpdateHandle_t*/, string pchDescription /*const char **/ )
{ {
return _pi.ISteamRemoteStorage_UpdatePublishedFileDescription( updateHandle.Value, pchDescription ); return platform.ISteamRemoteStorage_UpdatePublishedFileDescription( updateHandle.Value, pchDescription );
} }
// bool // bool
public bool UpdatePublishedFileFile( PublishedFileUpdateHandle_t updateHandle /*PublishedFileUpdateHandle_t*/, string pchFile /*const char **/ ) public bool UpdatePublishedFileFile( PublishedFileUpdateHandle_t updateHandle /*PublishedFileUpdateHandle_t*/, string pchFile /*const char **/ )
{ {
return _pi.ISteamRemoteStorage_UpdatePublishedFileFile( updateHandle.Value, pchFile ); return platform.ISteamRemoteStorage_UpdatePublishedFileFile( updateHandle.Value, pchFile );
} }
// bool // bool
public bool UpdatePublishedFilePreviewFile( PublishedFileUpdateHandle_t updateHandle /*PublishedFileUpdateHandle_t*/, string pchPreviewFile /*const char **/ ) public bool UpdatePublishedFilePreviewFile( PublishedFileUpdateHandle_t updateHandle /*PublishedFileUpdateHandle_t*/, string pchPreviewFile /*const char **/ )
{ {
return _pi.ISteamRemoteStorage_UpdatePublishedFilePreviewFile( updateHandle.Value, pchPreviewFile ); return platform.ISteamRemoteStorage_UpdatePublishedFilePreviewFile( updateHandle.Value, pchPreviewFile );
} }
// bool // bool
public bool UpdatePublishedFileSetChangeDescription( PublishedFileUpdateHandle_t updateHandle /*PublishedFileUpdateHandle_t*/, string pchChangeDescription /*const char **/ ) public bool UpdatePublishedFileSetChangeDescription( PublishedFileUpdateHandle_t updateHandle /*PublishedFileUpdateHandle_t*/, string pchChangeDescription /*const char **/ )
{ {
return _pi.ISteamRemoteStorage_UpdatePublishedFileSetChangeDescription( updateHandle.Value, pchChangeDescription ); return platform.ISteamRemoteStorage_UpdatePublishedFileSetChangeDescription( updateHandle.Value, pchChangeDescription );
} }
// bool // bool
@ -450,6 +573,8 @@ public bool UpdatePublishedFileTags( PublishedFileUpdateHandle_t updateHandle /*
{ {
nativeStrings[i] = Marshal.StringToHGlobalAnsi( pTags[i] ); nativeStrings[i] = Marshal.StringToHGlobalAnsi( pTags[i] );
} }
try
{
// Create string array // Create string array
var size = Marshal.SizeOf( typeof( IntPtr ) ) * nativeStrings.Length; var size = Marshal.SizeOf( typeof( IntPtr ) ) * nativeStrings.Length;
@ -460,29 +585,37 @@ public bool UpdatePublishedFileTags( PublishedFileUpdateHandle_t updateHandle /*
var tags = new SteamParamStringArray_t(); var tags = new SteamParamStringArray_t();
tags.Strings = nativeArray; tags.Strings = nativeArray;
tags.NumStrings = pTags.Length; tags.NumStrings = pTags.Length;
var result = _pi.ISteamRemoteStorage_UpdatePublishedFileTags( updateHandle.Value, ref tags ); return platform.ISteamRemoteStorage_UpdatePublishedFileTags( updateHandle.Value, ref tags );
}
finally
{
foreach ( var x in nativeStrings ) foreach ( var x in nativeStrings )
Marshal.FreeHGlobal( x ); Marshal.FreeHGlobal( x );
return result; }
} }
// bool // bool
public bool UpdatePublishedFileTitle( PublishedFileUpdateHandle_t updateHandle /*PublishedFileUpdateHandle_t*/, string pchTitle /*const char **/ ) public bool UpdatePublishedFileTitle( PublishedFileUpdateHandle_t updateHandle /*PublishedFileUpdateHandle_t*/, string pchTitle /*const char **/ )
{ {
return _pi.ISteamRemoteStorage_UpdatePublishedFileTitle( updateHandle.Value, pchTitle ); return platform.ISteamRemoteStorage_UpdatePublishedFileTitle( updateHandle.Value, pchTitle );
} }
// bool // bool
public bool UpdatePublishedFileVisibility( PublishedFileUpdateHandle_t updateHandle /*PublishedFileUpdateHandle_t*/, RemoteStoragePublishedFileVisibility eVisibility /*ERemoteStoragePublishedFileVisibility*/ ) public bool UpdatePublishedFileVisibility( PublishedFileUpdateHandle_t updateHandle /*PublishedFileUpdateHandle_t*/, RemoteStoragePublishedFileVisibility eVisibility /*ERemoteStoragePublishedFileVisibility*/ )
{ {
return _pi.ISteamRemoteStorage_UpdatePublishedFileVisibility( updateHandle.Value, eVisibility ); return platform.ISteamRemoteStorage_UpdatePublishedFileVisibility( updateHandle.Value, eVisibility );
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t UpdateUserPublishedItemVote( PublishedFileId_t unPublishedFileId /*PublishedFileId_t*/, bool bVoteUp /*bool*/ ) public CallbackHandle UpdateUserPublishedItemVote( PublishedFileId_t unPublishedFileId /*PublishedFileId_t*/, bool bVoteUp /*bool*/, Action<RemoteStorageUpdateUserPublishedItemVoteResult_t, bool> CallbackFunction = null /*Action<RemoteStorageUpdateUserPublishedItemVoteResult_t, bool>*/ )
{ {
return _pi.ISteamRemoteStorage_UpdateUserPublishedItemVote( unPublishedFileId.Value, bVoteUp ); SteamAPICall_t callback = 0;
callback = platform.ISteamRemoteStorage_UpdateUserPublishedItemVote( unPublishedFileId.Value, bVoteUp );
if ( CallbackFunction == null ) return null;
return RemoteStorageUpdateUserPublishedItemVoteResult_t.CallResult( steamworks, callback, CallbackFunction );
} }
} }

View File

@ -3,94 +3,97 @@
namespace SteamNative namespace SteamNative
{ {
public unsafe class SteamScreenshots : IDisposable internal unsafe class SteamScreenshots : IDisposable
{ {
// //
// Holds a platform specific implentation // Holds a platform specific implentation
// //
internal Platform.Interface _pi; internal Platform.Interface platform;
internal Facepunch.Steamworks.BaseSteamworks steamworks;
// //
// Constructor decides which implementation to use based on current platform // Constructor decides which implementation to use based on current platform
// //
public SteamScreenshots( IntPtr pointer ) public SteamScreenshots( Facepunch.Steamworks.BaseSteamworks steamworks, IntPtr pointer )
{ {
if ( Platform.IsWindows64 ) _pi = new Platform.Win64( pointer ); this.steamworks = steamworks;
else if ( Platform.IsWindows32 ) _pi = new Platform.Win32( pointer );
else if ( Platform.IsLinux32 ) _pi = new Platform.Linux32( pointer ); if ( Platform.IsWindows64 ) platform = new Platform.Win64( pointer );
else if ( Platform.IsLinux64 ) _pi = new Platform.Linux64( pointer ); else if ( Platform.IsWindows32 ) platform = new Platform.Win32( pointer );
else if ( Platform.IsOsx ) _pi = new Platform.Mac( pointer ); else if ( Platform.IsLinux32 ) platform = new Platform.Linux32( pointer );
else if ( Platform.IsLinux64 ) platform = new Platform.Linux64( pointer );
else if ( Platform.IsOsx ) platform = new Platform.Mac( pointer );
} }
// //
// Class is invalid if we don't have a valid implementation // Class is invalid if we don't have a valid implementation
// //
public bool IsValid{ get{ return _pi != null && _pi.IsValid; } } public bool IsValid{ get{ return platform != null && platform.IsValid; } }
// //
// When shutting down clear all the internals to avoid accidental use // When shutting down clear all the internals to avoid accidental use
// //
public virtual void Dispose() public virtual void Dispose()
{ {
if ( _pi != null ) if ( platform != null )
{ {
_pi.Dispose(); platform.Dispose();
_pi = null; platform = null;
} }
} }
// ScreenshotHandle // ScreenshotHandle
public ScreenshotHandle AddScreenshotToLibrary( string pchFilename /*const char **/, string pchThumbnailFilename /*const char **/, int nWidth /*int*/, int nHeight /*int*/ ) public ScreenshotHandle AddScreenshotToLibrary( string pchFilename /*const char **/, string pchThumbnailFilename /*const char **/, int nWidth /*int*/, int nHeight /*int*/ )
{ {
return _pi.ISteamScreenshots_AddScreenshotToLibrary( pchFilename, pchThumbnailFilename, nWidth, nHeight ); return platform.ISteamScreenshots_AddScreenshotToLibrary( pchFilename, pchThumbnailFilename, nWidth, nHeight );
} }
// ScreenshotHandle // ScreenshotHandle
public ScreenshotHandle AddVRScreenshotToLibrary( VRScreenshotType eType /*EVRScreenshotType*/, string pchFilename /*const char **/, string pchVRFilename /*const char **/ ) public ScreenshotHandle AddVRScreenshotToLibrary( VRScreenshotType eType /*EVRScreenshotType*/, string pchFilename /*const char **/, string pchVRFilename /*const char **/ )
{ {
return _pi.ISteamScreenshots_AddVRScreenshotToLibrary( eType, pchFilename, pchVRFilename ); return platform.ISteamScreenshots_AddVRScreenshotToLibrary( eType, pchFilename, pchVRFilename );
} }
// void // void
public void HookScreenshots( bool bHook /*bool*/ ) public void HookScreenshots( bool bHook /*bool*/ )
{ {
_pi.ISteamScreenshots_HookScreenshots( bHook ); platform.ISteamScreenshots_HookScreenshots( bHook );
} }
// bool // bool
public bool IsScreenshotsHooked() public bool IsScreenshotsHooked()
{ {
return _pi.ISteamScreenshots_IsScreenshotsHooked(); return platform.ISteamScreenshots_IsScreenshotsHooked();
} }
// bool // bool
public bool SetLocation( ScreenshotHandle hScreenshot /*ScreenshotHandle*/, string pchLocation /*const char **/ ) public bool SetLocation( ScreenshotHandle hScreenshot /*ScreenshotHandle*/, string pchLocation /*const char **/ )
{ {
return _pi.ISteamScreenshots_SetLocation( hScreenshot.Value, pchLocation ); return platform.ISteamScreenshots_SetLocation( hScreenshot.Value, pchLocation );
} }
// bool // bool
public bool TagPublishedFile( ScreenshotHandle hScreenshot /*ScreenshotHandle*/, PublishedFileId_t unPublishedFileID /*PublishedFileId_t*/ ) public bool TagPublishedFile( ScreenshotHandle hScreenshot /*ScreenshotHandle*/, PublishedFileId_t unPublishedFileID /*PublishedFileId_t*/ )
{ {
return _pi.ISteamScreenshots_TagPublishedFile( hScreenshot.Value, unPublishedFileID.Value ); return platform.ISteamScreenshots_TagPublishedFile( hScreenshot.Value, unPublishedFileID.Value );
} }
// bool // bool
public bool TagUser( ScreenshotHandle hScreenshot /*ScreenshotHandle*/, CSteamID steamID /*class CSteamID*/ ) public bool TagUser( ScreenshotHandle hScreenshot /*ScreenshotHandle*/, CSteamID steamID /*class CSteamID*/ )
{ {
return _pi.ISteamScreenshots_TagUser( hScreenshot.Value, steamID.Value ); return platform.ISteamScreenshots_TagUser( hScreenshot.Value, steamID.Value );
} }
// void // void
public void TriggerScreenshot() public void TriggerScreenshot()
{ {
_pi.ISteamScreenshots_TriggerScreenshot(); platform.ISteamScreenshots_TriggerScreenshot();
} }
// ScreenshotHandle // ScreenshotHandle
public ScreenshotHandle WriteScreenshot( IntPtr pubRGB /*void **/, uint cubRGB /*uint32*/, int nWidth /*int*/, int nHeight /*int*/ ) public ScreenshotHandle WriteScreenshot( IntPtr pubRGB /*void **/, uint cubRGB /*uint32*/, int nWidth /*int*/, int nHeight /*int*/ )
{ {
return _pi.ISteamScreenshots_WriteScreenshot( (IntPtr) pubRGB, cubRGB, nWidth, nHeight ); return platform.ISteamScreenshots_WriteScreenshot( (IntPtr) pubRGB, cubRGB, nWidth, nHeight );
} }
} }

View File

@ -3,100 +3,113 @@
namespace SteamNative namespace SteamNative
{ {
public unsafe class SteamUGC : IDisposable internal unsafe class SteamUGC : IDisposable
{ {
// //
// Holds a platform specific implentation // Holds a platform specific implentation
// //
internal Platform.Interface _pi; internal Platform.Interface platform;
internal Facepunch.Steamworks.BaseSteamworks steamworks;
// //
// Constructor decides which implementation to use based on current platform // Constructor decides which implementation to use based on current platform
// //
public SteamUGC( IntPtr pointer ) public SteamUGC( Facepunch.Steamworks.BaseSteamworks steamworks, IntPtr pointer )
{ {
if ( Platform.IsWindows64 ) _pi = new Platform.Win64( pointer ); this.steamworks = steamworks;
else if ( Platform.IsWindows32 ) _pi = new Platform.Win32( pointer );
else if ( Platform.IsLinux32 ) _pi = new Platform.Linux32( pointer ); if ( Platform.IsWindows64 ) platform = new Platform.Win64( pointer );
else if ( Platform.IsLinux64 ) _pi = new Platform.Linux64( pointer ); else if ( Platform.IsWindows32 ) platform = new Platform.Win32( pointer );
else if ( Platform.IsOsx ) _pi = new Platform.Mac( pointer ); else if ( Platform.IsLinux32 ) platform = new Platform.Linux32( pointer );
else if ( Platform.IsLinux64 ) platform = new Platform.Linux64( pointer );
else if ( Platform.IsOsx ) platform = new Platform.Mac( pointer );
} }
// //
// Class is invalid if we don't have a valid implementation // Class is invalid if we don't have a valid implementation
// //
public bool IsValid{ get{ return _pi != null && _pi.IsValid; } } public bool IsValid{ get{ return platform != null && platform.IsValid; } }
// //
// When shutting down clear all the internals to avoid accidental use // When shutting down clear all the internals to avoid accidental use
// //
public virtual void Dispose() public virtual void Dispose()
{ {
if ( _pi != null ) if ( platform != null )
{ {
_pi.Dispose(); platform.Dispose();
_pi = null; platform = null;
} }
} }
// bool // bool
public bool AddExcludedTag( UGCQueryHandle_t handle /*UGCQueryHandle_t*/, string pTagName /*const char **/ ) public bool AddExcludedTag( UGCQueryHandle_t handle /*UGCQueryHandle_t*/, string pTagName /*const char **/ )
{ {
return _pi.ISteamUGC_AddExcludedTag( handle.Value, pTagName ); return platform.ISteamUGC_AddExcludedTag( handle.Value, pTagName );
} }
// bool // bool
public bool AddItemKeyValueTag( UGCUpdateHandle_t handle /*UGCUpdateHandle_t*/, string pchKey /*const char **/, string pchValue /*const char **/ ) public bool AddItemKeyValueTag( UGCUpdateHandle_t handle /*UGCUpdateHandle_t*/, string pchKey /*const char **/, string pchValue /*const char **/ )
{ {
return _pi.ISteamUGC_AddItemKeyValueTag( handle.Value, pchKey, pchValue ); return platform.ISteamUGC_AddItemKeyValueTag( handle.Value, pchKey, pchValue );
} }
// bool // bool
public bool AddItemPreviewFile( UGCUpdateHandle_t handle /*UGCUpdateHandle_t*/, string pszPreviewFile /*const char **/, ItemPreviewType type /*EItemPreviewType*/ ) public bool AddItemPreviewFile( UGCUpdateHandle_t handle /*UGCUpdateHandle_t*/, string pszPreviewFile /*const char **/, ItemPreviewType type /*EItemPreviewType*/ )
{ {
return _pi.ISteamUGC_AddItemPreviewFile( handle.Value, pszPreviewFile, type ); return platform.ISteamUGC_AddItemPreviewFile( handle.Value, pszPreviewFile, type );
} }
// bool // bool
public bool AddItemPreviewVideo( UGCUpdateHandle_t handle /*UGCUpdateHandle_t*/, string pszVideoID /*const char **/ ) public bool AddItemPreviewVideo( UGCUpdateHandle_t handle /*UGCUpdateHandle_t*/, string pszVideoID /*const char **/ )
{ {
return _pi.ISteamUGC_AddItemPreviewVideo( handle.Value, pszVideoID ); return platform.ISteamUGC_AddItemPreviewVideo( handle.Value, pszVideoID );
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t AddItemToFavorites( AppId_t nAppId /*AppId_t*/, PublishedFileId_t nPublishedFileID /*PublishedFileId_t*/ ) public CallbackHandle AddItemToFavorites( AppId_t nAppId /*AppId_t*/, PublishedFileId_t nPublishedFileID /*PublishedFileId_t*/, Action<UserFavoriteItemsListChanged_t, bool> CallbackFunction = null /*Action<UserFavoriteItemsListChanged_t, bool>*/ )
{ {
return _pi.ISteamUGC_AddItemToFavorites( nAppId.Value, nPublishedFileID.Value ); SteamAPICall_t callback = 0;
callback = platform.ISteamUGC_AddItemToFavorites( nAppId.Value, nPublishedFileID.Value );
if ( CallbackFunction == null ) return null;
return UserFavoriteItemsListChanged_t.CallResult( steamworks, callback, CallbackFunction );
} }
// bool // bool
public bool AddRequiredKeyValueTag( UGCQueryHandle_t handle /*UGCQueryHandle_t*/, string pKey /*const char **/, string pValue /*const char **/ ) public bool AddRequiredKeyValueTag( UGCQueryHandle_t handle /*UGCQueryHandle_t*/, string pKey /*const char **/, string pValue /*const char **/ )
{ {
return _pi.ISteamUGC_AddRequiredKeyValueTag( handle.Value, pKey, pValue ); return platform.ISteamUGC_AddRequiredKeyValueTag( handle.Value, pKey, pValue );
} }
// bool // bool
public bool AddRequiredTag( UGCQueryHandle_t handle /*UGCQueryHandle_t*/, string pTagName /*const char **/ ) public bool AddRequiredTag( UGCQueryHandle_t handle /*UGCQueryHandle_t*/, string pTagName /*const char **/ )
{ {
return _pi.ISteamUGC_AddRequiredTag( handle.Value, pTagName ); return platform.ISteamUGC_AddRequiredTag( handle.Value, pTagName );
} }
// bool // bool
public bool BInitWorkshopForGameServer( DepotId_t unWorkshopDepotID /*DepotId_t*/, string pszFolder /*const char **/ ) public bool BInitWorkshopForGameServer( DepotId_t unWorkshopDepotID /*DepotId_t*/, string pszFolder /*const char **/ )
{ {
return _pi.ISteamUGC_BInitWorkshopForGameServer( unWorkshopDepotID.Value, pszFolder ); return platform.ISteamUGC_BInitWorkshopForGameServer( unWorkshopDepotID.Value, pszFolder );
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t CreateItem( AppId_t nConsumerAppId /*AppId_t*/, WorkshopFileType eFileType /*EWorkshopFileType*/ ) public CallbackHandle CreateItem( AppId_t nConsumerAppId /*AppId_t*/, WorkshopFileType eFileType /*EWorkshopFileType*/, Action<CreateItemResult_t, bool> CallbackFunction = null /*Action<CreateItemResult_t, bool>*/ )
{ {
return _pi.ISteamUGC_CreateItem( nConsumerAppId.Value, eFileType ); SteamAPICall_t callback = 0;
callback = platform.ISteamUGC_CreateItem( nConsumerAppId.Value, eFileType );
if ( CallbackFunction == null ) return null;
return CreateItemResult_t.CallResult( steamworks, callback, CallbackFunction );
} }
// UGCQueryHandle_t // UGCQueryHandle_t
public UGCQueryHandle_t CreateQueryAllUGCRequest( UGCQuery eQueryType /*EUGCQuery*/, UGCMatchingUGCType eMatchingeMatchingUGCTypeFileType /*EUGCMatchingUGCType*/, AppId_t nCreatorAppID /*AppId_t*/, AppId_t nConsumerAppID /*AppId_t*/, uint unPage /*uint32*/ ) public UGCQueryHandle_t CreateQueryAllUGCRequest( UGCQuery eQueryType /*EUGCQuery*/, UGCMatchingUGCType eMatchingeMatchingUGCTypeFileType /*EUGCMatchingUGCType*/, AppId_t nCreatorAppID /*AppId_t*/, AppId_t nConsumerAppID /*AppId_t*/, uint unPage /*uint32*/ )
{ {
return _pi.ISteamUGC_CreateQueryAllUGCRequest( eQueryType, eMatchingeMatchingUGCTypeFileType, nCreatorAppID.Value, nConsumerAppID.Value, unPage ); return platform.ISteamUGC_CreateQueryAllUGCRequest( eQueryType, eMatchingeMatchingUGCTypeFileType, nCreatorAppID.Value, nConsumerAppID.Value, unPage );
} }
// with: Detect_VectorReturn // with: Detect_VectorReturn
@ -106,26 +119,26 @@ public UGCQueryHandle_t CreateQueryUGCDetailsRequest( PublishedFileId_t[] pvecPu
var unNumPublishedFileIDs = (uint) pvecPublishedFileID.Length; var unNumPublishedFileIDs = (uint) pvecPublishedFileID.Length;
fixed ( PublishedFileId_t* pvecPublishedFileID_ptr = pvecPublishedFileID ) fixed ( PublishedFileId_t* pvecPublishedFileID_ptr = pvecPublishedFileID )
{ {
return _pi.ISteamUGC_CreateQueryUGCDetailsRequest( (IntPtr) pvecPublishedFileID_ptr, unNumPublishedFileIDs ); return platform.ISteamUGC_CreateQueryUGCDetailsRequest( (IntPtr) pvecPublishedFileID_ptr, unNumPublishedFileIDs );
} }
} }
// UGCQueryHandle_t // UGCQueryHandle_t
public UGCQueryHandle_t CreateQueryUserUGCRequest( AccountID_t unAccountID /*AccountID_t*/, UserUGCList eListType /*EUserUGCList*/, UGCMatchingUGCType eMatchingUGCType /*EUGCMatchingUGCType*/, UserUGCListSortOrder eSortOrder /*EUserUGCListSortOrder*/, AppId_t nCreatorAppID /*AppId_t*/, AppId_t nConsumerAppID /*AppId_t*/, uint unPage /*uint32*/ ) public UGCQueryHandle_t CreateQueryUserUGCRequest( AccountID_t unAccountID /*AccountID_t*/, UserUGCList eListType /*EUserUGCList*/, UGCMatchingUGCType eMatchingUGCType /*EUGCMatchingUGCType*/, UserUGCListSortOrder eSortOrder /*EUserUGCListSortOrder*/, AppId_t nCreatorAppID /*AppId_t*/, AppId_t nConsumerAppID /*AppId_t*/, uint unPage /*uint32*/ )
{ {
return _pi.ISteamUGC_CreateQueryUserUGCRequest( unAccountID.Value, eListType, eMatchingUGCType, eSortOrder, nCreatorAppID.Value, nConsumerAppID.Value, unPage ); return platform.ISteamUGC_CreateQueryUserUGCRequest( unAccountID.Value, eListType, eMatchingUGCType, eSortOrder, nCreatorAppID.Value, nConsumerAppID.Value, unPage );
} }
// bool // bool
public bool DownloadItem( PublishedFileId_t nPublishedFileID /*PublishedFileId_t*/, bool bHighPriority /*bool*/ ) public bool DownloadItem( PublishedFileId_t nPublishedFileID /*PublishedFileId_t*/, bool bHighPriority /*bool*/ )
{ {
return _pi.ISteamUGC_DownloadItem( nPublishedFileID.Value, bHighPriority ); return platform.ISteamUGC_DownloadItem( nPublishedFileID.Value, bHighPriority );
} }
// bool // bool
public bool GetItemDownloadInfo( PublishedFileId_t nPublishedFileID /*PublishedFileId_t*/, out ulong punBytesDownloaded /*uint64 **/, out ulong punBytesTotal /*uint64 **/ ) public bool GetItemDownloadInfo( PublishedFileId_t nPublishedFileID /*PublishedFileId_t*/, out ulong punBytesDownloaded /*uint64 **/, out ulong punBytesTotal /*uint64 **/ )
{ {
return _pi.ISteamUGC_GetItemDownloadInfo( nPublishedFileID.Value, out punBytesDownloaded, out punBytesTotal ); return platform.ISteamUGC_GetItemDownloadInfo( nPublishedFileID.Value, out punBytesDownloaded, out punBytesTotal );
} }
// bool // bool
@ -136,7 +149,7 @@ public bool GetItemInstallInfo( PublishedFileId_t nPublishedFileID /*PublishedFi
pchFolder = string.Empty; pchFolder = string.Empty;
System.Text.StringBuilder pchFolder_sb = new System.Text.StringBuilder( 4096 ); System.Text.StringBuilder pchFolder_sb = new System.Text.StringBuilder( 4096 );
uint cchFolderSize = 4096; uint cchFolderSize = 4096;
bSuccess = _pi.ISteamUGC_GetItemInstallInfo( nPublishedFileID.Value, out punSizeOnDisk, pchFolder_sb, cchFolderSize, out punTimeStamp ); bSuccess = platform.ISteamUGC_GetItemInstallInfo( nPublishedFileID.Value, out punSizeOnDisk, pchFolder_sb, cchFolderSize, out punTimeStamp );
if ( !bSuccess ) return bSuccess; if ( !bSuccess ) return bSuccess;
pchFolder = pchFolder_sb.ToString(); pchFolder = pchFolder_sb.ToString();
return bSuccess; return bSuccess;
@ -145,19 +158,19 @@ public bool GetItemInstallInfo( PublishedFileId_t nPublishedFileID /*PublishedFi
// uint // uint
public uint GetItemState( PublishedFileId_t nPublishedFileID /*PublishedFileId_t*/ ) public uint GetItemState( PublishedFileId_t nPublishedFileID /*PublishedFileId_t*/ )
{ {
return _pi.ISteamUGC_GetItemState( nPublishedFileID.Value ); return platform.ISteamUGC_GetItemState( nPublishedFileID.Value );
} }
// ItemUpdateStatus // ItemUpdateStatus
public ItemUpdateStatus GetItemUpdateProgress( UGCUpdateHandle_t handle /*UGCUpdateHandle_t*/, out ulong punBytesProcessed /*uint64 **/, out ulong punBytesTotal /*uint64 **/ ) public ItemUpdateStatus GetItemUpdateProgress( UGCUpdateHandle_t handle /*UGCUpdateHandle_t*/, out ulong punBytesProcessed /*uint64 **/, out ulong punBytesTotal /*uint64 **/ )
{ {
return _pi.ISteamUGC_GetItemUpdateProgress( handle.Value, out punBytesProcessed, out punBytesTotal ); return platform.ISteamUGC_GetItemUpdateProgress( handle.Value, out punBytesProcessed, out punBytesTotal );
} }
// uint // uint
public uint GetNumSubscribedItems() public uint GetNumSubscribedItems()
{ {
return _pi.ISteamUGC_GetNumSubscribedItems(); return platform.ISteamUGC_GetNumSubscribedItems();
} }
// bool // bool
@ -172,7 +185,7 @@ public bool GetQueryUGCAdditionalPreview( UGCQueryHandle_t handle /*UGCQueryHand
pchOriginalFileName = string.Empty; pchOriginalFileName = string.Empty;
System.Text.StringBuilder pchOriginalFileName_sb = new System.Text.StringBuilder( 4096 ); System.Text.StringBuilder pchOriginalFileName_sb = new System.Text.StringBuilder( 4096 );
uint cchOriginalFileNameSize = 4096; uint cchOriginalFileNameSize = 4096;
bSuccess = _pi.ISteamUGC_GetQueryUGCAdditionalPreview( handle.Value, index, previewIndex, pchURLOrVideoID_sb, cchURLSize, pchOriginalFileName_sb, cchOriginalFileNameSize, out pPreviewType ); bSuccess = platform.ISteamUGC_GetQueryUGCAdditionalPreview( handle.Value, index, previewIndex, pchURLOrVideoID_sb, cchURLSize, pchOriginalFileName_sb, cchOriginalFileNameSize, out pPreviewType );
if ( !bSuccess ) return bSuccess; if ( !bSuccess ) return bSuccess;
pchOriginalFileName = pchOriginalFileName_sb.ToString(); pchOriginalFileName = pchOriginalFileName_sb.ToString();
if ( !bSuccess ) return bSuccess; if ( !bSuccess ) return bSuccess;
@ -183,7 +196,7 @@ public bool GetQueryUGCAdditionalPreview( UGCQueryHandle_t handle /*UGCQueryHand
// bool // bool
public bool GetQueryUGCChildren( UGCQueryHandle_t handle /*UGCQueryHandle_t*/, uint index /*uint32*/, PublishedFileId_t* pvecPublishedFileID /*PublishedFileId_t **/, uint cMaxEntries /*uint32*/ ) public bool GetQueryUGCChildren( UGCQueryHandle_t handle /*UGCQueryHandle_t*/, uint index /*uint32*/, PublishedFileId_t* pvecPublishedFileID /*PublishedFileId_t **/, uint cMaxEntries /*uint32*/ )
{ {
return _pi.ISteamUGC_GetQueryUGCChildren( handle.Value, index, (IntPtr) pvecPublishedFileID, cMaxEntries ); return platform.ISteamUGC_GetQueryUGCChildren( handle.Value, index, (IntPtr) pvecPublishedFileID, cMaxEntries );
} }
// bool // bool
@ -198,7 +211,7 @@ public bool GetQueryUGCKeyValueTag( UGCQueryHandle_t handle /*UGCQueryHandle_t*/
pchValue = string.Empty; pchValue = string.Empty;
System.Text.StringBuilder pchValue_sb = new System.Text.StringBuilder( 4096 ); System.Text.StringBuilder pchValue_sb = new System.Text.StringBuilder( 4096 );
uint cchValueSize = 4096; uint cchValueSize = 4096;
bSuccess = _pi.ISteamUGC_GetQueryUGCKeyValueTag( handle.Value, index, keyValueTagIndex, pchKey_sb, cchKeySize, pchValue_sb, cchValueSize ); bSuccess = platform.ISteamUGC_GetQueryUGCKeyValueTag( handle.Value, index, keyValueTagIndex, pchKey_sb, cchKeySize, pchValue_sb, cchValueSize );
if ( !bSuccess ) return bSuccess; if ( !bSuccess ) return bSuccess;
pchValue = pchValue_sb.ToString(); pchValue = pchValue_sb.ToString();
if ( !bSuccess ) return bSuccess; if ( !bSuccess ) return bSuccess;
@ -214,7 +227,7 @@ public bool GetQueryUGCMetadata( UGCQueryHandle_t handle /*UGCQueryHandle_t*/, u
pchMetadata = string.Empty; pchMetadata = string.Empty;
System.Text.StringBuilder pchMetadata_sb = new System.Text.StringBuilder( 4096 ); System.Text.StringBuilder pchMetadata_sb = new System.Text.StringBuilder( 4096 );
uint cchMetadatasize = 4096; uint cchMetadatasize = 4096;
bSuccess = _pi.ISteamUGC_GetQueryUGCMetadata( handle.Value, index, pchMetadata_sb, cchMetadatasize ); bSuccess = platform.ISteamUGC_GetQueryUGCMetadata( handle.Value, index, pchMetadata_sb, cchMetadatasize );
if ( !bSuccess ) return bSuccess; if ( !bSuccess ) return bSuccess;
pchMetadata = pchMetadata_sb.ToString(); pchMetadata = pchMetadata_sb.ToString();
return bSuccess; return bSuccess;
@ -223,13 +236,13 @@ public bool GetQueryUGCMetadata( UGCQueryHandle_t handle /*UGCQueryHandle_t*/, u
// uint // uint
public uint GetQueryUGCNumAdditionalPreviews( UGCQueryHandle_t handle /*UGCQueryHandle_t*/, uint index /*uint32*/ ) public uint GetQueryUGCNumAdditionalPreviews( UGCQueryHandle_t handle /*UGCQueryHandle_t*/, uint index /*uint32*/ )
{ {
return _pi.ISteamUGC_GetQueryUGCNumAdditionalPreviews( handle.Value, index ); return platform.ISteamUGC_GetQueryUGCNumAdditionalPreviews( handle.Value, index );
} }
// uint // uint
public uint GetQueryUGCNumKeyValueTags( UGCQueryHandle_t handle /*UGCQueryHandle_t*/, uint index /*uint32*/ ) public uint GetQueryUGCNumKeyValueTags( UGCQueryHandle_t handle /*UGCQueryHandle_t*/, uint index /*uint32*/ )
{ {
return _pi.ISteamUGC_GetQueryUGCNumKeyValueTags( handle.Value, index ); return platform.ISteamUGC_GetQueryUGCNumKeyValueTags( handle.Value, index );
} }
// bool // bool
@ -240,7 +253,7 @@ public bool GetQueryUGCPreviewURL( UGCQueryHandle_t handle /*UGCQueryHandle_t*/,
pchURL = string.Empty; pchURL = string.Empty;
System.Text.StringBuilder pchURL_sb = new System.Text.StringBuilder( 4096 ); System.Text.StringBuilder pchURL_sb = new System.Text.StringBuilder( 4096 );
uint cchURLSize = 4096; uint cchURLSize = 4096;
bSuccess = _pi.ISteamUGC_GetQueryUGCPreviewURL( handle.Value, index, pchURL_sb, cchURLSize ); bSuccess = platform.ISteamUGC_GetQueryUGCPreviewURL( handle.Value, index, pchURL_sb, cchURLSize );
if ( !bSuccess ) return bSuccess; if ( !bSuccess ) return bSuccess;
pchURL = pchURL_sb.ToString(); pchURL = pchURL_sb.ToString();
return bSuccess; return bSuccess;
@ -249,97 +262,112 @@ public bool GetQueryUGCPreviewURL( UGCQueryHandle_t handle /*UGCQueryHandle_t*/,
// bool // bool
public bool GetQueryUGCResult( UGCQueryHandle_t handle /*UGCQueryHandle_t*/, uint index /*uint32*/, ref SteamUGCDetails_t pDetails /*struct SteamUGCDetails_t **/ ) public bool GetQueryUGCResult( UGCQueryHandle_t handle /*UGCQueryHandle_t*/, uint index /*uint32*/, ref SteamUGCDetails_t pDetails /*struct SteamUGCDetails_t **/ )
{ {
return _pi.ISteamUGC_GetQueryUGCResult( handle.Value, index, ref pDetails ); return platform.ISteamUGC_GetQueryUGCResult( handle.Value, index, ref pDetails );
} }
// bool // bool
public bool GetQueryUGCStatistic( UGCQueryHandle_t handle /*UGCQueryHandle_t*/, uint index /*uint32*/, ItemStatistic eStatType /*EItemStatistic*/, out ulong pStatValue /*uint64 **/ ) public bool GetQueryUGCStatistic( UGCQueryHandle_t handle /*UGCQueryHandle_t*/, uint index /*uint32*/, ItemStatistic eStatType /*EItemStatistic*/, out ulong pStatValue /*uint64 **/ )
{ {
return _pi.ISteamUGC_GetQueryUGCStatistic( handle.Value, index, eStatType, out pStatValue ); return platform.ISteamUGC_GetQueryUGCStatistic( handle.Value, index, eStatType, out pStatValue );
} }
// uint // uint
public uint GetSubscribedItems( PublishedFileId_t* pvecPublishedFileID /*PublishedFileId_t **/, uint cMaxEntries /*uint32*/ ) public uint GetSubscribedItems( PublishedFileId_t* pvecPublishedFileID /*PublishedFileId_t **/, uint cMaxEntries /*uint32*/ )
{ {
return _pi.ISteamUGC_GetSubscribedItems( (IntPtr) pvecPublishedFileID, cMaxEntries ); return platform.ISteamUGC_GetSubscribedItems( (IntPtr) pvecPublishedFileID, cMaxEntries );
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t GetUserItemVote( PublishedFileId_t nPublishedFileID /*PublishedFileId_t*/ ) public CallbackHandle GetUserItemVote( PublishedFileId_t nPublishedFileID /*PublishedFileId_t*/, Action<GetUserItemVoteResult_t, bool> CallbackFunction = null /*Action<GetUserItemVoteResult_t, bool>*/ )
{ {
return _pi.ISteamUGC_GetUserItemVote( nPublishedFileID.Value ); SteamAPICall_t callback = 0;
callback = platform.ISteamUGC_GetUserItemVote( nPublishedFileID.Value );
if ( CallbackFunction == null ) return null;
return GetUserItemVoteResult_t.CallResult( steamworks, callback, CallbackFunction );
} }
// bool // bool
public bool ReleaseQueryUGCRequest( UGCQueryHandle_t handle /*UGCQueryHandle_t*/ ) public bool ReleaseQueryUGCRequest( UGCQueryHandle_t handle /*UGCQueryHandle_t*/ )
{ {
return _pi.ISteamUGC_ReleaseQueryUGCRequest( handle.Value ); return platform.ISteamUGC_ReleaseQueryUGCRequest( handle.Value );
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t RemoveItemFromFavorites( AppId_t nAppId /*AppId_t*/, PublishedFileId_t nPublishedFileID /*PublishedFileId_t*/ ) public CallbackHandle RemoveItemFromFavorites( AppId_t nAppId /*AppId_t*/, PublishedFileId_t nPublishedFileID /*PublishedFileId_t*/, Action<UserFavoriteItemsListChanged_t, bool> CallbackFunction = null /*Action<UserFavoriteItemsListChanged_t, bool>*/ )
{ {
return _pi.ISteamUGC_RemoveItemFromFavorites( nAppId.Value, nPublishedFileID.Value ); SteamAPICall_t callback = 0;
callback = platform.ISteamUGC_RemoveItemFromFavorites( nAppId.Value, nPublishedFileID.Value );
if ( CallbackFunction == null ) return null;
return UserFavoriteItemsListChanged_t.CallResult( steamworks, callback, CallbackFunction );
} }
// bool // bool
public bool RemoveItemKeyValueTags( UGCUpdateHandle_t handle /*UGCUpdateHandle_t*/, string pchKey /*const char **/ ) public bool RemoveItemKeyValueTags( UGCUpdateHandle_t handle /*UGCUpdateHandle_t*/, string pchKey /*const char **/ )
{ {
return _pi.ISteamUGC_RemoveItemKeyValueTags( handle.Value, pchKey ); return platform.ISteamUGC_RemoveItemKeyValueTags( handle.Value, pchKey );
} }
// bool // bool
public bool RemoveItemPreview( UGCUpdateHandle_t handle /*UGCUpdateHandle_t*/, uint index /*uint32*/ ) public bool RemoveItemPreview( UGCUpdateHandle_t handle /*UGCUpdateHandle_t*/, uint index /*uint32*/ )
{ {
return _pi.ISteamUGC_RemoveItemPreview( handle.Value, index ); return platform.ISteamUGC_RemoveItemPreview( handle.Value, index );
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t RequestUGCDetails( PublishedFileId_t nPublishedFileID /*PublishedFileId_t*/, uint unMaxAgeSeconds /*uint32*/ ) public SteamAPICall_t RequestUGCDetails( PublishedFileId_t nPublishedFileID /*PublishedFileId_t*/, uint unMaxAgeSeconds /*uint32*/ )
{ {
return _pi.ISteamUGC_RequestUGCDetails( nPublishedFileID.Value, unMaxAgeSeconds ); return platform.ISteamUGC_RequestUGCDetails( nPublishedFileID.Value, unMaxAgeSeconds );
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t SendQueryUGCRequest( UGCQueryHandle_t handle /*UGCQueryHandle_t*/ ) public CallbackHandle SendQueryUGCRequest( UGCQueryHandle_t handle /*UGCQueryHandle_t*/, Action<SteamUGCQueryCompleted_t, bool> CallbackFunction = null /*Action<SteamUGCQueryCompleted_t, bool>*/ )
{ {
return _pi.ISteamUGC_SendQueryUGCRequest( handle.Value ); SteamAPICall_t callback = 0;
callback = platform.ISteamUGC_SendQueryUGCRequest( handle.Value );
if ( CallbackFunction == null ) return null;
return SteamUGCQueryCompleted_t.CallResult( steamworks, callback, CallbackFunction );
} }
// bool // bool
public bool SetAllowCachedResponse( UGCQueryHandle_t handle /*UGCQueryHandle_t*/, uint unMaxAgeSeconds /*uint32*/ ) public bool SetAllowCachedResponse( UGCQueryHandle_t handle /*UGCQueryHandle_t*/, uint unMaxAgeSeconds /*uint32*/ )
{ {
return _pi.ISteamUGC_SetAllowCachedResponse( handle.Value, unMaxAgeSeconds ); return platform.ISteamUGC_SetAllowCachedResponse( handle.Value, unMaxAgeSeconds );
} }
// bool // bool
public bool SetCloudFileNameFilter( UGCQueryHandle_t handle /*UGCQueryHandle_t*/, string pMatchCloudFileName /*const char **/ ) public bool SetCloudFileNameFilter( UGCQueryHandle_t handle /*UGCQueryHandle_t*/, string pMatchCloudFileName /*const char **/ )
{ {
return _pi.ISteamUGC_SetCloudFileNameFilter( handle.Value, pMatchCloudFileName ); return platform.ISteamUGC_SetCloudFileNameFilter( handle.Value, pMatchCloudFileName );
} }
// bool // bool
public bool SetItemContent( UGCUpdateHandle_t handle /*UGCUpdateHandle_t*/, string pszContentFolder /*const char **/ ) public bool SetItemContent( UGCUpdateHandle_t handle /*UGCUpdateHandle_t*/, string pszContentFolder /*const char **/ )
{ {
return _pi.ISteamUGC_SetItemContent( handle.Value, pszContentFolder ); return platform.ISteamUGC_SetItemContent( handle.Value, pszContentFolder );
} }
// bool // bool
public bool SetItemDescription( UGCUpdateHandle_t handle /*UGCUpdateHandle_t*/, string pchDescription /*const char **/ ) public bool SetItemDescription( UGCUpdateHandle_t handle /*UGCUpdateHandle_t*/, string pchDescription /*const char **/ )
{ {
return _pi.ISteamUGC_SetItemDescription( handle.Value, pchDescription ); return platform.ISteamUGC_SetItemDescription( handle.Value, pchDescription );
} }
// bool // bool
public bool SetItemMetadata( UGCUpdateHandle_t handle /*UGCUpdateHandle_t*/, string pchMetaData /*const char **/ ) public bool SetItemMetadata( UGCUpdateHandle_t handle /*UGCUpdateHandle_t*/, string pchMetaData /*const char **/ )
{ {
return _pi.ISteamUGC_SetItemMetadata( handle.Value, pchMetaData ); return platform.ISteamUGC_SetItemMetadata( handle.Value, pchMetaData );
} }
// bool // bool
public bool SetItemPreview( UGCUpdateHandle_t handle /*UGCUpdateHandle_t*/, string pszPreviewFile /*const char **/ ) public bool SetItemPreview( UGCUpdateHandle_t handle /*UGCUpdateHandle_t*/, string pszPreviewFile /*const char **/ )
{ {
return _pi.ISteamUGC_SetItemPreview( handle.Value, pszPreviewFile ); return platform.ISteamUGC_SetItemPreview( handle.Value, pszPreviewFile );
} }
// bool // bool
@ -352,6 +380,8 @@ public bool SetItemTags( UGCUpdateHandle_t updateHandle /*UGCUpdateHandle_t*/, s
{ {
nativeStrings[i] = Marshal.StringToHGlobalAnsi( pTags[i] ); nativeStrings[i] = Marshal.StringToHGlobalAnsi( pTags[i] );
} }
try
{
// Create string array // Create string array
var size = Marshal.SizeOf( typeof( IntPtr ) ) * nativeStrings.Length; var size = Marshal.SizeOf( typeof( IntPtr ) ) * nativeStrings.Length;
@ -362,171 +392,209 @@ public bool SetItemTags( UGCUpdateHandle_t updateHandle /*UGCUpdateHandle_t*/, s
var tags = new SteamParamStringArray_t(); var tags = new SteamParamStringArray_t();
tags.Strings = nativeArray; tags.Strings = nativeArray;
tags.NumStrings = pTags.Length; tags.NumStrings = pTags.Length;
var result = _pi.ISteamUGC_SetItemTags( updateHandle.Value, ref tags ); return platform.ISteamUGC_SetItemTags( updateHandle.Value, ref tags );
}
finally
{
foreach ( var x in nativeStrings ) foreach ( var x in nativeStrings )
Marshal.FreeHGlobal( x ); Marshal.FreeHGlobal( x );
return result; }
} }
// bool // bool
public bool SetItemTitle( UGCUpdateHandle_t handle /*UGCUpdateHandle_t*/, string pchTitle /*const char **/ ) public bool SetItemTitle( UGCUpdateHandle_t handle /*UGCUpdateHandle_t*/, string pchTitle /*const char **/ )
{ {
return _pi.ISteamUGC_SetItemTitle( handle.Value, pchTitle ); return platform.ISteamUGC_SetItemTitle( handle.Value, pchTitle );
} }
// bool // bool
public bool SetItemUpdateLanguage( UGCUpdateHandle_t handle /*UGCUpdateHandle_t*/, string pchLanguage /*const char **/ ) public bool SetItemUpdateLanguage( UGCUpdateHandle_t handle /*UGCUpdateHandle_t*/, string pchLanguage /*const char **/ )
{ {
return _pi.ISteamUGC_SetItemUpdateLanguage( handle.Value, pchLanguage ); return platform.ISteamUGC_SetItemUpdateLanguage( handle.Value, pchLanguage );
} }
// bool // bool
public bool SetItemVisibility( UGCUpdateHandle_t handle /*UGCUpdateHandle_t*/, RemoteStoragePublishedFileVisibility eVisibility /*ERemoteStoragePublishedFileVisibility*/ ) public bool SetItemVisibility( UGCUpdateHandle_t handle /*UGCUpdateHandle_t*/, RemoteStoragePublishedFileVisibility eVisibility /*ERemoteStoragePublishedFileVisibility*/ )
{ {
return _pi.ISteamUGC_SetItemVisibility( handle.Value, eVisibility ); return platform.ISteamUGC_SetItemVisibility( handle.Value, eVisibility );
} }
// bool // bool
public bool SetLanguage( UGCQueryHandle_t handle /*UGCQueryHandle_t*/, string pchLanguage /*const char **/ ) public bool SetLanguage( UGCQueryHandle_t handle /*UGCQueryHandle_t*/, string pchLanguage /*const char **/ )
{ {
return _pi.ISteamUGC_SetLanguage( handle.Value, pchLanguage ); return platform.ISteamUGC_SetLanguage( handle.Value, pchLanguage );
} }
// bool // bool
public bool SetMatchAnyTag( UGCQueryHandle_t handle /*UGCQueryHandle_t*/, bool bMatchAnyTag /*bool*/ ) public bool SetMatchAnyTag( UGCQueryHandle_t handle /*UGCQueryHandle_t*/, bool bMatchAnyTag /*bool*/ )
{ {
return _pi.ISteamUGC_SetMatchAnyTag( handle.Value, bMatchAnyTag ); return platform.ISteamUGC_SetMatchAnyTag( handle.Value, bMatchAnyTag );
} }
// bool // bool
public bool SetRankedByTrendDays( UGCQueryHandle_t handle /*UGCQueryHandle_t*/, uint unDays /*uint32*/ ) public bool SetRankedByTrendDays( UGCQueryHandle_t handle /*UGCQueryHandle_t*/, uint unDays /*uint32*/ )
{ {
return _pi.ISteamUGC_SetRankedByTrendDays( handle.Value, unDays ); return platform.ISteamUGC_SetRankedByTrendDays( handle.Value, unDays );
} }
// bool // bool
public bool SetReturnAdditionalPreviews( UGCQueryHandle_t handle /*UGCQueryHandle_t*/, bool bReturnAdditionalPreviews /*bool*/ ) public bool SetReturnAdditionalPreviews( UGCQueryHandle_t handle /*UGCQueryHandle_t*/, bool bReturnAdditionalPreviews /*bool*/ )
{ {
return _pi.ISteamUGC_SetReturnAdditionalPreviews( handle.Value, bReturnAdditionalPreviews ); return platform.ISteamUGC_SetReturnAdditionalPreviews( handle.Value, bReturnAdditionalPreviews );
} }
// bool // bool
public bool SetReturnChildren( UGCQueryHandle_t handle /*UGCQueryHandle_t*/, bool bReturnChildren /*bool*/ ) public bool SetReturnChildren( UGCQueryHandle_t handle /*UGCQueryHandle_t*/, bool bReturnChildren /*bool*/ )
{ {
return _pi.ISteamUGC_SetReturnChildren( handle.Value, bReturnChildren ); return platform.ISteamUGC_SetReturnChildren( handle.Value, bReturnChildren );
} }
// bool // bool
public bool SetReturnKeyValueTags( UGCQueryHandle_t handle /*UGCQueryHandle_t*/, bool bReturnKeyValueTags /*bool*/ ) public bool SetReturnKeyValueTags( UGCQueryHandle_t handle /*UGCQueryHandle_t*/, bool bReturnKeyValueTags /*bool*/ )
{ {
return _pi.ISteamUGC_SetReturnKeyValueTags( handle.Value, bReturnKeyValueTags ); return platform.ISteamUGC_SetReturnKeyValueTags( handle.Value, bReturnKeyValueTags );
} }
// bool // bool
public bool SetReturnLongDescription( UGCQueryHandle_t handle /*UGCQueryHandle_t*/, bool bReturnLongDescription /*bool*/ ) public bool SetReturnLongDescription( UGCQueryHandle_t handle /*UGCQueryHandle_t*/, bool bReturnLongDescription /*bool*/ )
{ {
return _pi.ISteamUGC_SetReturnLongDescription( handle.Value, bReturnLongDescription ); return platform.ISteamUGC_SetReturnLongDescription( handle.Value, bReturnLongDescription );
} }
// bool // bool
public bool SetReturnMetadata( UGCQueryHandle_t handle /*UGCQueryHandle_t*/, bool bReturnMetadata /*bool*/ ) public bool SetReturnMetadata( UGCQueryHandle_t handle /*UGCQueryHandle_t*/, bool bReturnMetadata /*bool*/ )
{ {
return _pi.ISteamUGC_SetReturnMetadata( handle.Value, bReturnMetadata ); return platform.ISteamUGC_SetReturnMetadata( handle.Value, bReturnMetadata );
} }
// bool // bool
public bool SetReturnOnlyIDs( UGCQueryHandle_t handle /*UGCQueryHandle_t*/, bool bReturnOnlyIDs /*bool*/ ) public bool SetReturnOnlyIDs( UGCQueryHandle_t handle /*UGCQueryHandle_t*/, bool bReturnOnlyIDs /*bool*/ )
{ {
return _pi.ISteamUGC_SetReturnOnlyIDs( handle.Value, bReturnOnlyIDs ); return platform.ISteamUGC_SetReturnOnlyIDs( handle.Value, bReturnOnlyIDs );
} }
// bool // bool
public bool SetReturnTotalOnly( UGCQueryHandle_t handle /*UGCQueryHandle_t*/, bool bReturnTotalOnly /*bool*/ ) public bool SetReturnTotalOnly( UGCQueryHandle_t handle /*UGCQueryHandle_t*/, bool bReturnTotalOnly /*bool*/ )
{ {
return _pi.ISteamUGC_SetReturnTotalOnly( handle.Value, bReturnTotalOnly ); return platform.ISteamUGC_SetReturnTotalOnly( handle.Value, bReturnTotalOnly );
} }
// bool // bool
public bool SetSearchText( UGCQueryHandle_t handle /*UGCQueryHandle_t*/, string pSearchText /*const char **/ ) public bool SetSearchText( UGCQueryHandle_t handle /*UGCQueryHandle_t*/, string pSearchText /*const char **/ )
{ {
return _pi.ISteamUGC_SetSearchText( handle.Value, pSearchText ); return platform.ISteamUGC_SetSearchText( handle.Value, pSearchText );
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t SetUserItemVote( PublishedFileId_t nPublishedFileID /*PublishedFileId_t*/, bool bVoteUp /*bool*/ ) public CallbackHandle SetUserItemVote( PublishedFileId_t nPublishedFileID /*PublishedFileId_t*/, bool bVoteUp /*bool*/, Action<SetUserItemVoteResult_t, bool> CallbackFunction = null /*Action<SetUserItemVoteResult_t, bool>*/ )
{ {
return _pi.ISteamUGC_SetUserItemVote( nPublishedFileID.Value, bVoteUp ); SteamAPICall_t callback = 0;
callback = platform.ISteamUGC_SetUserItemVote( nPublishedFileID.Value, bVoteUp );
if ( CallbackFunction == null ) return null;
return SetUserItemVoteResult_t.CallResult( steamworks, callback, CallbackFunction );
} }
// UGCUpdateHandle_t // UGCUpdateHandle_t
public UGCUpdateHandle_t StartItemUpdate( AppId_t nConsumerAppId /*AppId_t*/, PublishedFileId_t nPublishedFileID /*PublishedFileId_t*/ ) public UGCUpdateHandle_t StartItemUpdate( AppId_t nConsumerAppId /*AppId_t*/, PublishedFileId_t nPublishedFileID /*PublishedFileId_t*/ )
{ {
return _pi.ISteamUGC_StartItemUpdate( nConsumerAppId.Value, nPublishedFileID.Value ); return platform.ISteamUGC_StartItemUpdate( nConsumerAppId.Value, nPublishedFileID.Value );
} }
// with: Detect_VectorReturn // with: Detect_VectorReturn
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t StartPlaytimeTracking( PublishedFileId_t[] pvecPublishedFileID /*PublishedFileId_t **/ ) public CallbackHandle StartPlaytimeTracking( PublishedFileId_t[] pvecPublishedFileID /*PublishedFileId_t **/, Action<StartPlaytimeTrackingResult_t, bool> CallbackFunction = null /*Action<StartPlaytimeTrackingResult_t, bool>*/ )
{ {
SteamAPICall_t callback = 0;
var unNumPublishedFileIDs = (uint) pvecPublishedFileID.Length; var unNumPublishedFileIDs = (uint) pvecPublishedFileID.Length;
fixed ( PublishedFileId_t* pvecPublishedFileID_ptr = pvecPublishedFileID ) fixed ( PublishedFileId_t* pvecPublishedFileID_ptr = pvecPublishedFileID )
{ {
return _pi.ISteamUGC_StartPlaytimeTracking( (IntPtr) pvecPublishedFileID_ptr, unNumPublishedFileIDs ); callback = platform.ISteamUGC_StartPlaytimeTracking( (IntPtr) pvecPublishedFileID_ptr, unNumPublishedFileIDs );
} }
if ( CallbackFunction == null ) return null;
return StartPlaytimeTrackingResult_t.CallResult( steamworks, callback, CallbackFunction );
} }
// with: Detect_VectorReturn // with: Detect_VectorReturn
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t StopPlaytimeTracking( PublishedFileId_t[] pvecPublishedFileID /*PublishedFileId_t **/ ) public CallbackHandle StopPlaytimeTracking( PublishedFileId_t[] pvecPublishedFileID /*PublishedFileId_t **/, Action<StopPlaytimeTrackingResult_t, bool> CallbackFunction = null /*Action<StopPlaytimeTrackingResult_t, bool>*/ )
{ {
SteamAPICall_t callback = 0;
var unNumPublishedFileIDs = (uint) pvecPublishedFileID.Length; var unNumPublishedFileIDs = (uint) pvecPublishedFileID.Length;
fixed ( PublishedFileId_t* pvecPublishedFileID_ptr = pvecPublishedFileID ) fixed ( PublishedFileId_t* pvecPublishedFileID_ptr = pvecPublishedFileID )
{ {
return _pi.ISteamUGC_StopPlaytimeTracking( (IntPtr) pvecPublishedFileID_ptr, unNumPublishedFileIDs ); callback = platform.ISteamUGC_StopPlaytimeTracking( (IntPtr) pvecPublishedFileID_ptr, unNumPublishedFileIDs );
} }
if ( CallbackFunction == null ) return null;
return StopPlaytimeTrackingResult_t.CallResult( steamworks, callback, CallbackFunction );
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t StopPlaytimeTrackingForAllItems() public CallbackHandle StopPlaytimeTrackingForAllItems( Action<StopPlaytimeTrackingResult_t, bool> CallbackFunction = null /*Action<StopPlaytimeTrackingResult_t, bool>*/ )
{ {
return _pi.ISteamUGC_StopPlaytimeTrackingForAllItems(); SteamAPICall_t callback = 0;
callback = platform.ISteamUGC_StopPlaytimeTrackingForAllItems();
if ( CallbackFunction == null ) return null;
return StopPlaytimeTrackingResult_t.CallResult( steamworks, callback, CallbackFunction );
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t SubmitItemUpdate( UGCUpdateHandle_t handle /*UGCUpdateHandle_t*/, string pchChangeNote /*const char **/ ) public CallbackHandle SubmitItemUpdate( UGCUpdateHandle_t handle /*UGCUpdateHandle_t*/, string pchChangeNote /*const char **/, Action<SubmitItemUpdateResult_t, bool> CallbackFunction = null /*Action<SubmitItemUpdateResult_t, bool>*/ )
{ {
return _pi.ISteamUGC_SubmitItemUpdate( handle.Value, pchChangeNote ); SteamAPICall_t callback = 0;
callback = platform.ISteamUGC_SubmitItemUpdate( handle.Value, pchChangeNote );
if ( CallbackFunction == null ) return null;
return SubmitItemUpdateResult_t.CallResult( steamworks, callback, CallbackFunction );
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t SubscribeItem( PublishedFileId_t nPublishedFileID /*PublishedFileId_t*/ ) public CallbackHandle SubscribeItem( PublishedFileId_t nPublishedFileID /*PublishedFileId_t*/, Action<RemoteStorageSubscribePublishedFileResult_t, bool> CallbackFunction = null /*Action<RemoteStorageSubscribePublishedFileResult_t, bool>*/ )
{ {
return _pi.ISteamUGC_SubscribeItem( nPublishedFileID.Value ); SteamAPICall_t callback = 0;
callback = platform.ISteamUGC_SubscribeItem( nPublishedFileID.Value );
if ( CallbackFunction == null ) return null;
return RemoteStorageSubscribePublishedFileResult_t.CallResult( steamworks, callback, CallbackFunction );
} }
// void // void
public void SuspendDownloads( bool bSuspend /*bool*/ ) public void SuspendDownloads( bool bSuspend /*bool*/ )
{ {
_pi.ISteamUGC_SuspendDownloads( bSuspend ); platform.ISteamUGC_SuspendDownloads( bSuspend );
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t UnsubscribeItem( PublishedFileId_t nPublishedFileID /*PublishedFileId_t*/ ) public CallbackHandle UnsubscribeItem( PublishedFileId_t nPublishedFileID /*PublishedFileId_t*/, Action<RemoteStorageUnsubscribePublishedFileResult_t, bool> CallbackFunction = null /*Action<RemoteStorageUnsubscribePublishedFileResult_t, bool>*/ )
{ {
return _pi.ISteamUGC_UnsubscribeItem( nPublishedFileID.Value ); SteamAPICall_t callback = 0;
callback = platform.ISteamUGC_UnsubscribeItem( nPublishedFileID.Value );
if ( CallbackFunction == null ) return null;
return RemoteStorageUnsubscribePublishedFileResult_t.CallResult( steamworks, callback, CallbackFunction );
} }
// bool // bool
public bool UpdateItemPreviewFile( UGCUpdateHandle_t handle /*UGCUpdateHandle_t*/, uint index /*uint32*/, string pszPreviewFile /*const char **/ ) public bool UpdateItemPreviewFile( UGCUpdateHandle_t handle /*UGCUpdateHandle_t*/, uint index /*uint32*/, string pszPreviewFile /*const char **/ )
{ {
return _pi.ISteamUGC_UpdateItemPreviewFile( handle.Value, index, pszPreviewFile ); return platform.ISteamUGC_UpdateItemPreviewFile( handle.Value, index, pszPreviewFile );
} }
// bool // bool
public bool UpdateItemPreviewVideo( UGCUpdateHandle_t handle /*UGCUpdateHandle_t*/, uint index /*uint32*/, string pszVideoID /*const char **/ ) public bool UpdateItemPreviewVideo( UGCUpdateHandle_t handle /*UGCUpdateHandle_t*/, uint index /*uint32*/, string pszVideoID /*const char **/ )
{ {
return _pi.ISteamUGC_UpdateItemPreviewVideo( handle.Value, index, pszVideoID ); return platform.ISteamUGC_UpdateItemPreviewVideo( handle.Value, index, pszVideoID );
} }
} }

View File

@ -3,70 +3,73 @@
namespace SteamNative namespace SteamNative
{ {
public unsafe class SteamUnifiedMessages : IDisposable internal unsafe class SteamUnifiedMessages : IDisposable
{ {
// //
// Holds a platform specific implentation // Holds a platform specific implentation
// //
internal Platform.Interface _pi; internal Platform.Interface platform;
internal Facepunch.Steamworks.BaseSteamworks steamworks;
// //
// Constructor decides which implementation to use based on current platform // Constructor decides which implementation to use based on current platform
// //
public SteamUnifiedMessages( IntPtr pointer ) public SteamUnifiedMessages( Facepunch.Steamworks.BaseSteamworks steamworks, IntPtr pointer )
{ {
if ( Platform.IsWindows64 ) _pi = new Platform.Win64( pointer ); this.steamworks = steamworks;
else if ( Platform.IsWindows32 ) _pi = new Platform.Win32( pointer );
else if ( Platform.IsLinux32 ) _pi = new Platform.Linux32( pointer ); if ( Platform.IsWindows64 ) platform = new Platform.Win64( pointer );
else if ( Platform.IsLinux64 ) _pi = new Platform.Linux64( pointer ); else if ( Platform.IsWindows32 ) platform = new Platform.Win32( pointer );
else if ( Platform.IsOsx ) _pi = new Platform.Mac( pointer ); else if ( Platform.IsLinux32 ) platform = new Platform.Linux32( pointer );
else if ( Platform.IsLinux64 ) platform = new Platform.Linux64( pointer );
else if ( Platform.IsOsx ) platform = new Platform.Mac( pointer );
} }
// //
// Class is invalid if we don't have a valid implementation // Class is invalid if we don't have a valid implementation
// //
public bool IsValid{ get{ return _pi != null && _pi.IsValid; } } public bool IsValid{ get{ return platform != null && platform.IsValid; } }
// //
// When shutting down clear all the internals to avoid accidental use // When shutting down clear all the internals to avoid accidental use
// //
public virtual void Dispose() public virtual void Dispose()
{ {
if ( _pi != null ) if ( platform != null )
{ {
_pi.Dispose(); platform.Dispose();
_pi = null; platform = null;
} }
} }
// bool // bool
public bool GetMethodResponseData( ClientUnifiedMessageHandle hHandle /*ClientUnifiedMessageHandle*/, IntPtr pResponseBuffer /*void **/, uint unResponseBufferSize /*uint32*/, bool bAutoRelease /*bool*/ ) public bool GetMethodResponseData( ClientUnifiedMessageHandle hHandle /*ClientUnifiedMessageHandle*/, IntPtr pResponseBuffer /*void **/, uint unResponseBufferSize /*uint32*/, bool bAutoRelease /*bool*/ )
{ {
return _pi.ISteamUnifiedMessages_GetMethodResponseData( hHandle.Value, (IntPtr) pResponseBuffer, unResponseBufferSize, bAutoRelease ); return platform.ISteamUnifiedMessages_GetMethodResponseData( hHandle.Value, (IntPtr) pResponseBuffer, unResponseBufferSize, bAutoRelease );
} }
// bool // bool
public bool GetMethodResponseInfo( ClientUnifiedMessageHandle hHandle /*ClientUnifiedMessageHandle*/, out uint punResponseSize /*uint32 **/, out Result peResult /*EResult **/ ) public bool GetMethodResponseInfo( ClientUnifiedMessageHandle hHandle /*ClientUnifiedMessageHandle*/, out uint punResponseSize /*uint32 **/, out Result peResult /*EResult **/ )
{ {
return _pi.ISteamUnifiedMessages_GetMethodResponseInfo( hHandle.Value, out punResponseSize, out peResult ); return platform.ISteamUnifiedMessages_GetMethodResponseInfo( hHandle.Value, out punResponseSize, out peResult );
} }
// bool // bool
public bool ReleaseMethod( ClientUnifiedMessageHandle hHandle /*ClientUnifiedMessageHandle*/ ) public bool ReleaseMethod( ClientUnifiedMessageHandle hHandle /*ClientUnifiedMessageHandle*/ )
{ {
return _pi.ISteamUnifiedMessages_ReleaseMethod( hHandle.Value ); return platform.ISteamUnifiedMessages_ReleaseMethod( hHandle.Value );
} }
// ClientUnifiedMessageHandle // ClientUnifiedMessageHandle
public ClientUnifiedMessageHandle SendMethod( string pchServiceMethod /*const char **/, IntPtr pRequestBuffer /*const void **/, uint unRequestBufferSize /*uint32*/, ulong unContext /*uint64*/ ) public ClientUnifiedMessageHandle SendMethod( string pchServiceMethod /*const char **/, IntPtr pRequestBuffer /*const void **/, uint unRequestBufferSize /*uint32*/, ulong unContext /*uint64*/ )
{ {
return _pi.ISteamUnifiedMessages_SendMethod( pchServiceMethod, (IntPtr) pRequestBuffer, unRequestBufferSize, unContext ); return platform.ISteamUnifiedMessages_SendMethod( pchServiceMethod, (IntPtr) pRequestBuffer, unRequestBufferSize, unContext );
} }
// bool // bool
public bool SendNotification( string pchServiceNotification /*const char **/, IntPtr pNotificationBuffer /*const void **/, uint unNotificationBufferSize /*uint32*/ ) public bool SendNotification( string pchServiceNotification /*const char **/, IntPtr pNotificationBuffer /*const void **/, uint unNotificationBufferSize /*uint32*/ )
{ {
return _pi.ISteamUnifiedMessages_SendNotification( pchServiceNotification, (IntPtr) pNotificationBuffer, unNotificationBufferSize ); return platform.ISteamUnifiedMessages_SendNotification( pchServiceNotification, (IntPtr) pNotificationBuffer, unNotificationBufferSize );
} }
} }

View File

@ -3,148 +3,151 @@
namespace SteamNative namespace SteamNative
{ {
public unsafe class SteamUser : IDisposable internal unsafe class SteamUser : IDisposable
{ {
// //
// Holds a platform specific implentation // Holds a platform specific implentation
// //
internal Platform.Interface _pi; internal Platform.Interface platform;
internal Facepunch.Steamworks.BaseSteamworks steamworks;
// //
// Constructor decides which implementation to use based on current platform // Constructor decides which implementation to use based on current platform
// //
public SteamUser( IntPtr pointer ) public SteamUser( Facepunch.Steamworks.BaseSteamworks steamworks, IntPtr pointer )
{ {
if ( Platform.IsWindows64 ) _pi = new Platform.Win64( pointer ); this.steamworks = steamworks;
else if ( Platform.IsWindows32 ) _pi = new Platform.Win32( pointer );
else if ( Platform.IsLinux32 ) _pi = new Platform.Linux32( pointer ); if ( Platform.IsWindows64 ) platform = new Platform.Win64( pointer );
else if ( Platform.IsLinux64 ) _pi = new Platform.Linux64( pointer ); else if ( Platform.IsWindows32 ) platform = new Platform.Win32( pointer );
else if ( Platform.IsOsx ) _pi = new Platform.Mac( pointer ); else if ( Platform.IsLinux32 ) platform = new Platform.Linux32( pointer );
else if ( Platform.IsLinux64 ) platform = new Platform.Linux64( pointer );
else if ( Platform.IsOsx ) platform = new Platform.Mac( pointer );
} }
// //
// Class is invalid if we don't have a valid implementation // Class is invalid if we don't have a valid implementation
// //
public bool IsValid{ get{ return _pi != null && _pi.IsValid; } } public bool IsValid{ get{ return platform != null && platform.IsValid; } }
// //
// When shutting down clear all the internals to avoid accidental use // When shutting down clear all the internals to avoid accidental use
// //
public virtual void Dispose() public virtual void Dispose()
{ {
if ( _pi != null ) if ( platform != null )
{ {
_pi.Dispose(); platform.Dispose();
_pi = null; platform = null;
} }
} }
// void // void
public void AdvertiseGame( CSteamID steamIDGameServer /*class CSteamID*/, uint unIPServer /*uint32*/, ushort usPortServer /*uint16*/ ) public void AdvertiseGame( CSteamID steamIDGameServer /*class CSteamID*/, uint unIPServer /*uint32*/, ushort usPortServer /*uint16*/ )
{ {
_pi.ISteamUser_AdvertiseGame( steamIDGameServer.Value, unIPServer, usPortServer ); platform.ISteamUser_AdvertiseGame( steamIDGameServer.Value, unIPServer, usPortServer );
} }
// BeginAuthSessionResult // BeginAuthSessionResult
public BeginAuthSessionResult BeginAuthSession( IntPtr pAuthTicket /*const void **/, int cbAuthTicket /*int*/, CSteamID steamID /*class CSteamID*/ ) public BeginAuthSessionResult BeginAuthSession( IntPtr pAuthTicket /*const void **/, int cbAuthTicket /*int*/, CSteamID steamID /*class CSteamID*/ )
{ {
return _pi.ISteamUser_BeginAuthSession( (IntPtr) pAuthTicket, cbAuthTicket, steamID.Value ); return platform.ISteamUser_BeginAuthSession( (IntPtr) pAuthTicket, cbAuthTicket, steamID.Value );
} }
// bool // bool
public bool BIsBehindNAT() public bool BIsBehindNAT()
{ {
return _pi.ISteamUser_BIsBehindNAT(); return platform.ISteamUser_BIsBehindNAT();
} }
// bool // bool
public bool BIsPhoneIdentifying() public bool BIsPhoneIdentifying()
{ {
return _pi.ISteamUser_BIsPhoneIdentifying(); return platform.ISteamUser_BIsPhoneIdentifying();
} }
// bool // bool
public bool BIsPhoneRequiringVerification() public bool BIsPhoneRequiringVerification()
{ {
return _pi.ISteamUser_BIsPhoneRequiringVerification(); return platform.ISteamUser_BIsPhoneRequiringVerification();
} }
// bool // bool
public bool BIsPhoneVerified() public bool BIsPhoneVerified()
{ {
return _pi.ISteamUser_BIsPhoneVerified(); return platform.ISteamUser_BIsPhoneVerified();
} }
// bool // bool
public bool BIsTwoFactorEnabled() public bool BIsTwoFactorEnabled()
{ {
return _pi.ISteamUser_BIsTwoFactorEnabled(); return platform.ISteamUser_BIsTwoFactorEnabled();
} }
// bool // bool
public bool BLoggedOn() public bool BLoggedOn()
{ {
return _pi.ISteamUser_BLoggedOn(); return platform.ISteamUser_BLoggedOn();
} }
// void // void
public void CancelAuthTicket( HAuthTicket hAuthTicket /*HAuthTicket*/ ) public void CancelAuthTicket( HAuthTicket hAuthTicket /*HAuthTicket*/ )
{ {
_pi.ISteamUser_CancelAuthTicket( hAuthTicket.Value ); platform.ISteamUser_CancelAuthTicket( hAuthTicket.Value );
} }
// VoiceResult // VoiceResult
public VoiceResult DecompressVoice( IntPtr pCompressed /*const void **/, uint cbCompressed /*uint32*/, IntPtr pDestBuffer /*void **/, uint cbDestBufferSize /*uint32*/, out uint nBytesWritten /*uint32 **/, uint nDesiredSampleRate /*uint32*/ ) public VoiceResult DecompressVoice( IntPtr pCompressed /*const void **/, uint cbCompressed /*uint32*/, IntPtr pDestBuffer /*void **/, uint cbDestBufferSize /*uint32*/, out uint nBytesWritten /*uint32 **/, uint nDesiredSampleRate /*uint32*/ )
{ {
return _pi.ISteamUser_DecompressVoice( (IntPtr) pCompressed, cbCompressed, (IntPtr) pDestBuffer, cbDestBufferSize, out nBytesWritten, nDesiredSampleRate ); return platform.ISteamUser_DecompressVoice( (IntPtr) pCompressed, cbCompressed, (IntPtr) pDestBuffer, cbDestBufferSize, out nBytesWritten, nDesiredSampleRate );
} }
// void // void
public void EndAuthSession( CSteamID steamID /*class CSteamID*/ ) public void EndAuthSession( CSteamID steamID /*class CSteamID*/ )
{ {
_pi.ISteamUser_EndAuthSession( steamID.Value ); platform.ISteamUser_EndAuthSession( steamID.Value );
} }
// HAuthTicket // HAuthTicket
public HAuthTicket GetAuthSessionTicket( IntPtr pTicket /*void **/, int cbMaxTicket /*int*/, out uint pcbTicket /*uint32 **/ ) public HAuthTicket GetAuthSessionTicket( IntPtr pTicket /*void **/, int cbMaxTicket /*int*/, out uint pcbTicket /*uint32 **/ )
{ {
return _pi.ISteamUser_GetAuthSessionTicket( (IntPtr) pTicket, cbMaxTicket, out pcbTicket ); return platform.ISteamUser_GetAuthSessionTicket( (IntPtr) pTicket, cbMaxTicket, out pcbTicket );
} }
// VoiceResult // VoiceResult
public VoiceResult GetAvailableVoice( out uint pcbCompressed /*uint32 **/, out uint pcbUncompressed /*uint32 **/, uint nUncompressedVoiceDesiredSampleRate /*uint32*/ ) public VoiceResult GetAvailableVoice( out uint pcbCompressed /*uint32 **/, out uint pcbUncompressed /*uint32 **/, uint nUncompressedVoiceDesiredSampleRate /*uint32*/ )
{ {
return _pi.ISteamUser_GetAvailableVoice( out pcbCompressed, out pcbUncompressed, nUncompressedVoiceDesiredSampleRate ); return platform.ISteamUser_GetAvailableVoice( out pcbCompressed, out pcbUncompressed, nUncompressedVoiceDesiredSampleRate );
} }
// bool // bool
public bool GetEncryptedAppTicket( IntPtr pTicket /*void **/, int cbMaxTicket /*int*/, out uint pcbTicket /*uint32 **/ ) public bool GetEncryptedAppTicket( IntPtr pTicket /*void **/, int cbMaxTicket /*int*/, out uint pcbTicket /*uint32 **/ )
{ {
return _pi.ISteamUser_GetEncryptedAppTicket( (IntPtr) pTicket, cbMaxTicket, out pcbTicket ); return platform.ISteamUser_GetEncryptedAppTicket( (IntPtr) pTicket, cbMaxTicket, out pcbTicket );
} }
// int // int
public int GetGameBadgeLevel( int nSeries /*int*/, bool bFoil /*bool*/ ) public int GetGameBadgeLevel( int nSeries /*int*/, bool bFoil /*bool*/ )
{ {
return _pi.ISteamUser_GetGameBadgeLevel( nSeries, bFoil ); return platform.ISteamUser_GetGameBadgeLevel( nSeries, bFoil );
} }
// HSteamUser // HSteamUser
public HSteamUser GetHSteamUser() public HSteamUser GetHSteamUser()
{ {
return _pi.ISteamUser_GetHSteamUser(); return platform.ISteamUser_GetHSteamUser();
} }
// int // int
public int GetPlayerSteamLevel() public int GetPlayerSteamLevel()
{ {
return _pi.ISteamUser_GetPlayerSteamLevel(); return platform.ISteamUser_GetPlayerSteamLevel();
} }
// ulong // ulong
public ulong GetSteamID() public ulong GetSteamID()
{ {
return _pi.ISteamUser_GetSteamID(); return platform.ISteamUser_GetSteamID();
} }
// bool // bool
@ -154,7 +157,7 @@ public string GetUserDataFolder()
bool bSuccess = default( bool ); bool bSuccess = default( bool );
System.Text.StringBuilder pchBuffer_sb = new System.Text.StringBuilder( 4096 ); System.Text.StringBuilder pchBuffer_sb = new System.Text.StringBuilder( 4096 );
int cubBuffer = 4096; int cubBuffer = 4096;
bSuccess = _pi.ISteamUser_GetUserDataFolder( pchBuffer_sb, cubBuffer ); bSuccess = platform.ISteamUser_GetUserDataFolder( pchBuffer_sb, cubBuffer );
if ( !bSuccess ) return null; if ( !bSuccess ) return null;
return pchBuffer_sb.ToString(); return pchBuffer_sb.ToString();
} }
@ -162,61 +165,71 @@ public string GetUserDataFolder()
// VoiceResult // VoiceResult
public VoiceResult GetVoice( bool bWantCompressed /*bool*/, IntPtr pDestBuffer /*void **/, uint cbDestBufferSize /*uint32*/, out uint nBytesWritten /*uint32 **/, bool bWantUncompressed /*bool*/, IntPtr pUncompressedDestBuffer /*void **/, uint cbUncompressedDestBufferSize /*uint32*/, out uint nUncompressBytesWritten /*uint32 **/, uint nUncompressedVoiceDesiredSampleRate /*uint32*/ ) public VoiceResult GetVoice( bool bWantCompressed /*bool*/, IntPtr pDestBuffer /*void **/, uint cbDestBufferSize /*uint32*/, out uint nBytesWritten /*uint32 **/, bool bWantUncompressed /*bool*/, IntPtr pUncompressedDestBuffer /*void **/, uint cbUncompressedDestBufferSize /*uint32*/, out uint nUncompressBytesWritten /*uint32 **/, uint nUncompressedVoiceDesiredSampleRate /*uint32*/ )
{ {
return _pi.ISteamUser_GetVoice( bWantCompressed, (IntPtr) pDestBuffer, cbDestBufferSize, out nBytesWritten, bWantUncompressed, (IntPtr) pUncompressedDestBuffer, cbUncompressedDestBufferSize, out nUncompressBytesWritten, nUncompressedVoiceDesiredSampleRate ); return platform.ISteamUser_GetVoice( bWantCompressed, (IntPtr) pDestBuffer, cbDestBufferSize, out nBytesWritten, bWantUncompressed, (IntPtr) pUncompressedDestBuffer, cbUncompressedDestBufferSize, out nUncompressBytesWritten, nUncompressedVoiceDesiredSampleRate );
} }
// uint // uint
public uint GetVoiceOptimalSampleRate() public uint GetVoiceOptimalSampleRate()
{ {
return _pi.ISteamUser_GetVoiceOptimalSampleRate(); return platform.ISteamUser_GetVoiceOptimalSampleRate();
} }
// int // int
public int InitiateGameConnection( IntPtr pAuthBlob /*void **/, int cbMaxAuthBlob /*int*/, CSteamID steamIDGameServer /*class CSteamID*/, uint unIPServer /*uint32*/, ushort usPortServer /*uint16*/, bool bSecure /*bool*/ ) public int InitiateGameConnection( IntPtr pAuthBlob /*void **/, int cbMaxAuthBlob /*int*/, CSteamID steamIDGameServer /*class CSteamID*/, uint unIPServer /*uint32*/, ushort usPortServer /*uint16*/, bool bSecure /*bool*/ )
{ {
return _pi.ISteamUser_InitiateGameConnection( (IntPtr) pAuthBlob, cbMaxAuthBlob, steamIDGameServer.Value, unIPServer, usPortServer, bSecure ); return platform.ISteamUser_InitiateGameConnection( (IntPtr) pAuthBlob, cbMaxAuthBlob, steamIDGameServer.Value, unIPServer, usPortServer, bSecure );
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t RequestEncryptedAppTicket( IntPtr pDataToInclude /*void **/, int cbDataToInclude /*int*/ ) public CallbackHandle RequestEncryptedAppTicket( IntPtr pDataToInclude /*void **/, int cbDataToInclude /*int*/, Action<EncryptedAppTicketResponse_t, bool> CallbackFunction = null /*Action<EncryptedAppTicketResponse_t, bool>*/ )
{ {
return _pi.ISteamUser_RequestEncryptedAppTicket( (IntPtr) pDataToInclude, cbDataToInclude ); SteamAPICall_t callback = 0;
callback = platform.ISteamUser_RequestEncryptedAppTicket( (IntPtr) pDataToInclude, cbDataToInclude );
if ( CallbackFunction == null ) return null;
return EncryptedAppTicketResponse_t.CallResult( steamworks, callback, CallbackFunction );
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t RequestStoreAuthURL( string pchRedirectURL /*const char **/ ) public CallbackHandle RequestStoreAuthURL( string pchRedirectURL /*const char **/, Action<StoreAuthURLResponse_t, bool> CallbackFunction = null /*Action<StoreAuthURLResponse_t, bool>*/ )
{ {
return _pi.ISteamUser_RequestStoreAuthURL( pchRedirectURL ); SteamAPICall_t callback = 0;
callback = platform.ISteamUser_RequestStoreAuthURL( pchRedirectURL );
if ( CallbackFunction == null ) return null;
return StoreAuthURLResponse_t.CallResult( steamworks, callback, CallbackFunction );
} }
// void // void
public void StartVoiceRecording() public void StartVoiceRecording()
{ {
_pi.ISteamUser_StartVoiceRecording(); platform.ISteamUser_StartVoiceRecording();
} }
// void // void
public void StopVoiceRecording() public void StopVoiceRecording()
{ {
_pi.ISteamUser_StopVoiceRecording(); platform.ISteamUser_StopVoiceRecording();
} }
// void // void
public void TerminateGameConnection( uint unIPServer /*uint32*/, ushort usPortServer /*uint16*/ ) public void TerminateGameConnection( uint unIPServer /*uint32*/, ushort usPortServer /*uint16*/ )
{ {
_pi.ISteamUser_TerminateGameConnection( unIPServer, usPortServer ); platform.ISteamUser_TerminateGameConnection( unIPServer, usPortServer );
} }
// void // void
public void TrackAppUsageEvent( CGameID gameID /*class CGameID*/, int eAppUsageEvent /*int*/, string pchExtraInfo /*const char **/ ) public void TrackAppUsageEvent( CGameID gameID /*class CGameID*/, int eAppUsageEvent /*int*/, string pchExtraInfo /*const char **/ )
{ {
_pi.ISteamUser_TrackAppUsageEvent( gameID.Value, eAppUsageEvent, pchExtraInfo ); platform.ISteamUser_TrackAppUsageEvent( gameID.Value, eAppUsageEvent, pchExtraInfo );
} }
// UserHasLicenseForAppResult // UserHasLicenseForAppResult
public UserHasLicenseForAppResult UserHasLicenseForApp( CSteamID steamID /*class CSteamID*/, AppId_t appID /*AppId_t*/ ) public UserHasLicenseForAppResult UserHasLicenseForApp( CSteamID steamID /*class CSteamID*/, AppId_t appID /*AppId_t*/ )
{ {
return _pi.ISteamUser_UserHasLicenseForApp( steamID.Value, appID.Value ); return platform.ISteamUser_UserHasLicenseForApp( steamID.Value, appID.Value );
} }
} }

View File

@ -3,94 +3,122 @@
namespace SteamNative namespace SteamNative
{ {
public unsafe class SteamUserStats : IDisposable internal unsafe class SteamUserStats : IDisposable
{ {
// //
// Holds a platform specific implentation // Holds a platform specific implentation
// //
internal Platform.Interface _pi; internal Platform.Interface platform;
internal Facepunch.Steamworks.BaseSteamworks steamworks;
// //
// Constructor decides which implementation to use based on current platform // Constructor decides which implementation to use based on current platform
// //
public SteamUserStats( IntPtr pointer ) public SteamUserStats( Facepunch.Steamworks.BaseSteamworks steamworks, IntPtr pointer )
{ {
if ( Platform.IsWindows64 ) _pi = new Platform.Win64( pointer ); this.steamworks = steamworks;
else if ( Platform.IsWindows32 ) _pi = new Platform.Win32( pointer );
else if ( Platform.IsLinux32 ) _pi = new Platform.Linux32( pointer ); if ( Platform.IsWindows64 ) platform = new Platform.Win64( pointer );
else if ( Platform.IsLinux64 ) _pi = new Platform.Linux64( pointer ); else if ( Platform.IsWindows32 ) platform = new Platform.Win32( pointer );
else if ( Platform.IsOsx ) _pi = new Platform.Mac( pointer ); else if ( Platform.IsLinux32 ) platform = new Platform.Linux32( pointer );
else if ( Platform.IsLinux64 ) platform = new Platform.Linux64( pointer );
else if ( Platform.IsOsx ) platform = new Platform.Mac( pointer );
} }
// //
// Class is invalid if we don't have a valid implementation // Class is invalid if we don't have a valid implementation
// //
public bool IsValid{ get{ return _pi != null && _pi.IsValid; } } public bool IsValid{ get{ return platform != null && platform.IsValid; } }
// //
// When shutting down clear all the internals to avoid accidental use // When shutting down clear all the internals to avoid accidental use
// //
public virtual void Dispose() public virtual void Dispose()
{ {
if ( _pi != null ) if ( platform != null )
{ {
_pi.Dispose(); platform.Dispose();
_pi = null; platform = null;
} }
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t AttachLeaderboardUGC( SteamLeaderboard_t hSteamLeaderboard /*SteamLeaderboard_t*/, UGCHandle_t hUGC /*UGCHandle_t*/ ) public CallbackHandle AttachLeaderboardUGC( SteamLeaderboard_t hSteamLeaderboard /*SteamLeaderboard_t*/, UGCHandle_t hUGC /*UGCHandle_t*/, Action<LeaderboardUGCSet_t, bool> CallbackFunction = null /*Action<LeaderboardUGCSet_t, bool>*/ )
{ {
return _pi.ISteamUserStats_AttachLeaderboardUGC( hSteamLeaderboard.Value, hUGC.Value ); SteamAPICall_t callback = 0;
callback = platform.ISteamUserStats_AttachLeaderboardUGC( hSteamLeaderboard.Value, hUGC.Value );
if ( CallbackFunction == null ) return null;
return LeaderboardUGCSet_t.CallResult( steamworks, callback, CallbackFunction );
} }
// bool // bool
public bool ClearAchievement( string pchName /*const char **/ ) public bool ClearAchievement( string pchName /*const char **/ )
{ {
return _pi.ISteamUserStats_ClearAchievement( pchName ); return platform.ISteamUserStats_ClearAchievement( pchName );
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t DownloadLeaderboardEntries( SteamLeaderboard_t hSteamLeaderboard /*SteamLeaderboard_t*/, LeaderboardDataRequest eLeaderboardDataRequest /*ELeaderboardDataRequest*/, int nRangeStart /*int*/, int nRangeEnd /*int*/ ) public CallbackHandle DownloadLeaderboardEntries( SteamLeaderboard_t hSteamLeaderboard /*SteamLeaderboard_t*/, LeaderboardDataRequest eLeaderboardDataRequest /*ELeaderboardDataRequest*/, int nRangeStart /*int*/, int nRangeEnd /*int*/, Action<LeaderboardScoresDownloaded_t, bool> CallbackFunction = null /*Action<LeaderboardScoresDownloaded_t, bool>*/ )
{ {
return _pi.ISteamUserStats_DownloadLeaderboardEntries( hSteamLeaderboard.Value, eLeaderboardDataRequest, nRangeStart, nRangeEnd ); SteamAPICall_t callback = 0;
callback = platform.ISteamUserStats_DownloadLeaderboardEntries( hSteamLeaderboard.Value, eLeaderboardDataRequest, nRangeStart, nRangeEnd );
if ( CallbackFunction == null ) return null;
return LeaderboardScoresDownloaded_t.CallResult( steamworks, callback, CallbackFunction );
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t DownloadLeaderboardEntriesForUsers( SteamLeaderboard_t hSteamLeaderboard /*SteamLeaderboard_t*/, IntPtr prgUsers /*class CSteamID **/, int cUsers /*int*/ ) public CallbackHandle DownloadLeaderboardEntriesForUsers( SteamLeaderboard_t hSteamLeaderboard /*SteamLeaderboard_t*/, IntPtr prgUsers /*class CSteamID **/, int cUsers /*int*/, Action<LeaderboardScoresDownloaded_t, bool> CallbackFunction = null /*Action<LeaderboardScoresDownloaded_t, bool>*/ )
{ {
return _pi.ISteamUserStats_DownloadLeaderboardEntriesForUsers( hSteamLeaderboard.Value, (IntPtr) prgUsers, cUsers ); SteamAPICall_t callback = 0;
callback = platform.ISteamUserStats_DownloadLeaderboardEntriesForUsers( hSteamLeaderboard.Value, (IntPtr) prgUsers, cUsers );
if ( CallbackFunction == null ) return null;
return LeaderboardScoresDownloaded_t.CallResult( steamworks, callback, CallbackFunction );
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t FindLeaderboard( string pchLeaderboardName /*const char **/ ) public CallbackHandle FindLeaderboard( string pchLeaderboardName /*const char **/, Action<LeaderboardFindResult_t, bool> CallbackFunction = null /*Action<LeaderboardFindResult_t, bool>*/ )
{ {
return _pi.ISteamUserStats_FindLeaderboard( pchLeaderboardName ); SteamAPICall_t callback = 0;
callback = platform.ISteamUserStats_FindLeaderboard( pchLeaderboardName );
if ( CallbackFunction == null ) return null;
return LeaderboardFindResult_t.CallResult( steamworks, callback, CallbackFunction );
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t FindOrCreateLeaderboard( string pchLeaderboardName /*const char **/, LeaderboardSortMethod eLeaderboardSortMethod /*ELeaderboardSortMethod*/, LeaderboardDisplayType eLeaderboardDisplayType /*ELeaderboardDisplayType*/ ) public CallbackHandle FindOrCreateLeaderboard( string pchLeaderboardName /*const char **/, LeaderboardSortMethod eLeaderboardSortMethod /*ELeaderboardSortMethod*/, LeaderboardDisplayType eLeaderboardDisplayType /*ELeaderboardDisplayType*/, Action<LeaderboardFindResult_t, bool> CallbackFunction = null /*Action<LeaderboardFindResult_t, bool>*/ )
{ {
return _pi.ISteamUserStats_FindOrCreateLeaderboard( pchLeaderboardName, eLeaderboardSortMethod, eLeaderboardDisplayType ); SteamAPICall_t callback = 0;
callback = platform.ISteamUserStats_FindOrCreateLeaderboard( pchLeaderboardName, eLeaderboardSortMethod, eLeaderboardDisplayType );
if ( CallbackFunction == null ) return null;
return LeaderboardFindResult_t.CallResult( steamworks, callback, CallbackFunction );
} }
// bool // bool
public bool GetAchievement( string pchName /*const char **/, ref bool pbAchieved /*bool **/ ) public bool GetAchievement( string pchName /*const char **/, ref bool pbAchieved /*bool **/ )
{ {
return _pi.ISteamUserStats_GetAchievement( pchName, ref pbAchieved ); return platform.ISteamUserStats_GetAchievement( pchName, ref pbAchieved );
} }
// bool // bool
public bool GetAchievementAchievedPercent( string pchName /*const char **/, out float pflPercent /*float **/ ) public bool GetAchievementAchievedPercent( string pchName /*const char **/, out float pflPercent /*float **/ )
{ {
return _pi.ISteamUserStats_GetAchievementAchievedPercent( pchName, out pflPercent ); return platform.ISteamUserStats_GetAchievementAchievedPercent( pchName, out pflPercent );
} }
// bool // bool
public bool GetAchievementAndUnlockTime( string pchName /*const char **/, ref bool pbAchieved /*bool **/, out uint punUnlockTime /*uint32 **/ ) public bool GetAchievementAndUnlockTime( string pchName /*const char **/, ref bool pbAchieved /*bool **/, out uint punUnlockTime /*uint32 **/ )
{ {
return _pi.ISteamUserStats_GetAchievementAndUnlockTime( pchName, ref pbAchieved, out punUnlockTime ); return platform.ISteamUserStats_GetAchievementAndUnlockTime( pchName, ref pbAchieved, out punUnlockTime );
} }
// string // string
@ -98,14 +126,14 @@ public bool GetAchievementAndUnlockTime( string pchName /*const char **/, ref bo
public string GetAchievementDisplayAttribute( string pchName /*const char **/, string pchKey /*const char **/ ) public string GetAchievementDisplayAttribute( string pchName /*const char **/, string pchKey /*const char **/ )
{ {
IntPtr string_pointer; IntPtr string_pointer;
string_pointer = _pi.ISteamUserStats_GetAchievementDisplayAttribute( pchName, pchKey ); string_pointer = platform.ISteamUserStats_GetAchievementDisplayAttribute( pchName, pchKey );
return Marshal.PtrToStringAnsi( string_pointer ); return Marshal.PtrToStringAnsi( string_pointer );
} }
// int // int
public int GetAchievementIcon( string pchName /*const char **/ ) public int GetAchievementIcon( string pchName /*const char **/ )
{ {
return _pi.ISteamUserStats_GetAchievementIcon( pchName ); return platform.ISteamUserStats_GetAchievementIcon( pchName );
} }
// string // string
@ -113,50 +141,50 @@ public int GetAchievementIcon( string pchName /*const char **/ )
public string GetAchievementName( uint iAchievement /*uint32*/ ) public string GetAchievementName( uint iAchievement /*uint32*/ )
{ {
IntPtr string_pointer; IntPtr string_pointer;
string_pointer = _pi.ISteamUserStats_GetAchievementName( iAchievement ); string_pointer = platform.ISteamUserStats_GetAchievementName( iAchievement );
return Marshal.PtrToStringAnsi( string_pointer ); return Marshal.PtrToStringAnsi( string_pointer );
} }
// bool // bool
public bool GetDownloadedLeaderboardEntry( SteamLeaderboardEntries_t hSteamLeaderboardEntries /*SteamLeaderboardEntries_t*/, int index /*int*/, ref LeaderboardEntry_t pLeaderboardEntry /*struct LeaderboardEntry_t **/, IntPtr pDetails /*int32 **/, int cDetailsMax /*int*/ ) public bool GetDownloadedLeaderboardEntry( SteamLeaderboardEntries_t hSteamLeaderboardEntries /*SteamLeaderboardEntries_t*/, int index /*int*/, ref LeaderboardEntry_t pLeaderboardEntry /*struct LeaderboardEntry_t **/, IntPtr pDetails /*int32 **/, int cDetailsMax /*int*/ )
{ {
return _pi.ISteamUserStats_GetDownloadedLeaderboardEntry( hSteamLeaderboardEntries.Value, index, ref pLeaderboardEntry, (IntPtr) pDetails, cDetailsMax ); return platform.ISteamUserStats_GetDownloadedLeaderboardEntry( hSteamLeaderboardEntries.Value, index, ref pLeaderboardEntry, (IntPtr) pDetails, cDetailsMax );
} }
// bool // bool
public bool GetGlobalStat( string pchStatName /*const char **/, out long pData /*int64 **/ ) public bool GetGlobalStat( string pchStatName /*const char **/, out long pData /*int64 **/ )
{ {
return _pi.ISteamUserStats_GetGlobalStat( pchStatName, out pData ); return platform.ISteamUserStats_GetGlobalStat( pchStatName, out pData );
} }
// bool // bool
public bool GetGlobalStat0( string pchStatName /*const char **/, out double pData /*double **/ ) public bool GetGlobalStat0( string pchStatName /*const char **/, out double pData /*double **/ )
{ {
return _pi.ISteamUserStats_GetGlobalStat0( pchStatName, out pData ); return platform.ISteamUserStats_GetGlobalStat0( pchStatName, out pData );
} }
// int // int
public int GetGlobalStatHistory( string pchStatName /*const char **/, out long pData /*int64 **/, uint cubData /*uint32*/ ) public int GetGlobalStatHistory( string pchStatName /*const char **/, out long pData /*int64 **/, uint cubData /*uint32*/ )
{ {
return _pi.ISteamUserStats_GetGlobalStatHistory( pchStatName, out pData, cubData ); return platform.ISteamUserStats_GetGlobalStatHistory( pchStatName, out pData, cubData );
} }
// int // int
public int GetGlobalStatHistory0( string pchStatName /*const char **/, out double pData /*double **/, uint cubData /*uint32*/ ) public int GetGlobalStatHistory0( string pchStatName /*const char **/, out double pData /*double **/, uint cubData /*uint32*/ )
{ {
return _pi.ISteamUserStats_GetGlobalStatHistory0( pchStatName, out pData, cubData ); return platform.ISteamUserStats_GetGlobalStatHistory0( pchStatName, out pData, cubData );
} }
// LeaderboardDisplayType // LeaderboardDisplayType
public LeaderboardDisplayType GetLeaderboardDisplayType( SteamLeaderboard_t hSteamLeaderboard /*SteamLeaderboard_t*/ ) public LeaderboardDisplayType GetLeaderboardDisplayType( SteamLeaderboard_t hSteamLeaderboard /*SteamLeaderboard_t*/ )
{ {
return _pi.ISteamUserStats_GetLeaderboardDisplayType( hSteamLeaderboard.Value ); return platform.ISteamUserStats_GetLeaderboardDisplayType( hSteamLeaderboard.Value );
} }
// int // int
public int GetLeaderboardEntryCount( SteamLeaderboard_t hSteamLeaderboard /*SteamLeaderboard_t*/ ) public int GetLeaderboardEntryCount( SteamLeaderboard_t hSteamLeaderboard /*SteamLeaderboard_t*/ )
{ {
return _pi.ISteamUserStats_GetLeaderboardEntryCount( hSteamLeaderboard.Value ); return platform.ISteamUserStats_GetLeaderboardEntryCount( hSteamLeaderboard.Value );
} }
// string // string
@ -164,14 +192,14 @@ public int GetLeaderboardEntryCount( SteamLeaderboard_t hSteamLeaderboard /*Stea
public string GetLeaderboardName( SteamLeaderboard_t hSteamLeaderboard /*SteamLeaderboard_t*/ ) public string GetLeaderboardName( SteamLeaderboard_t hSteamLeaderboard /*SteamLeaderboard_t*/ )
{ {
IntPtr string_pointer; IntPtr string_pointer;
string_pointer = _pi.ISteamUserStats_GetLeaderboardName( hSteamLeaderboard.Value ); string_pointer = platform.ISteamUserStats_GetLeaderboardName( hSteamLeaderboard.Value );
return Marshal.PtrToStringAnsi( string_pointer ); return Marshal.PtrToStringAnsi( string_pointer );
} }
// LeaderboardSortMethod // LeaderboardSortMethod
public LeaderboardSortMethod GetLeaderboardSortMethod( SteamLeaderboard_t hSteamLeaderboard /*SteamLeaderboard_t*/ ) public LeaderboardSortMethod GetLeaderboardSortMethod( SteamLeaderboard_t hSteamLeaderboard /*SteamLeaderboard_t*/ )
{ {
return _pi.ISteamUserStats_GetLeaderboardSortMethod( hSteamLeaderboard.Value ); return platform.ISteamUserStats_GetLeaderboardSortMethod( hSteamLeaderboard.Value );
} }
// int // int
@ -182,7 +210,7 @@ public int GetMostAchievedAchievementInfo( out string pchName /*char **/, out fl
pchName = string.Empty; pchName = string.Empty;
System.Text.StringBuilder pchName_sb = new System.Text.StringBuilder( 4096 ); System.Text.StringBuilder pchName_sb = new System.Text.StringBuilder( 4096 );
uint unNameBufLen = 4096; uint unNameBufLen = 4096;
bSuccess = _pi.ISteamUserStats_GetMostAchievedAchievementInfo( pchName_sb, unNameBufLen, out pflPercent, ref pbAchieved ); bSuccess = platform.ISteamUserStats_GetMostAchievedAchievementInfo( pchName_sb, unNameBufLen, out pflPercent, ref pbAchieved );
if ( bSuccess <= 0 ) return bSuccess; if ( bSuccess <= 0 ) return bSuccess;
pchName = pchName_sb.ToString(); pchName = pchName_sb.ToString();
return bSuccess; return bSuccess;
@ -196,7 +224,7 @@ public int GetNextMostAchievedAchievementInfo( int iIteratorPrevious /*int*/, ou
pchName = string.Empty; pchName = string.Empty;
System.Text.StringBuilder pchName_sb = new System.Text.StringBuilder( 4096 ); System.Text.StringBuilder pchName_sb = new System.Text.StringBuilder( 4096 );
uint unNameBufLen = 4096; uint unNameBufLen = 4096;
bSuccess = _pi.ISteamUserStats_GetNextMostAchievedAchievementInfo( iIteratorPrevious, pchName_sb, unNameBufLen, out pflPercent, ref pbAchieved ); bSuccess = platform.ISteamUserStats_GetNextMostAchievedAchievementInfo( iIteratorPrevious, pchName_sb, unNameBufLen, out pflPercent, ref pbAchieved );
if ( bSuccess <= 0 ) return bSuccess; if ( bSuccess <= 0 ) return bSuccess;
pchName = pchName_sb.ToString(); pchName = pchName_sb.ToString();
return bSuccess; return bSuccess;
@ -205,121 +233,146 @@ public int GetNextMostAchievedAchievementInfo( int iIteratorPrevious /*int*/, ou
// uint // uint
public uint GetNumAchievements() public uint GetNumAchievements()
{ {
return _pi.ISteamUserStats_GetNumAchievements(); return platform.ISteamUserStats_GetNumAchievements();
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t GetNumberOfCurrentPlayers() public CallbackHandle GetNumberOfCurrentPlayers( Action<NumberOfCurrentPlayers_t, bool> CallbackFunction = null /*Action<NumberOfCurrentPlayers_t, bool>*/ )
{ {
return _pi.ISteamUserStats_GetNumberOfCurrentPlayers(); SteamAPICall_t callback = 0;
callback = platform.ISteamUserStats_GetNumberOfCurrentPlayers();
if ( CallbackFunction == null ) return null;
return NumberOfCurrentPlayers_t.CallResult( steamworks, callback, CallbackFunction );
} }
// bool // bool
public bool GetStat( string pchName /*const char **/, out int pData /*int32 **/ ) public bool GetStat( string pchName /*const char **/, out int pData /*int32 **/ )
{ {
return _pi.ISteamUserStats_GetStat( pchName, out pData ); return platform.ISteamUserStats_GetStat( pchName, out pData );
} }
// bool // bool
public bool GetStat0( string pchName /*const char **/, out float pData /*float **/ ) public bool GetStat0( string pchName /*const char **/, out float pData /*float **/ )
{ {
return _pi.ISteamUserStats_GetStat0( pchName, out pData ); return platform.ISteamUserStats_GetStat0( pchName, out pData );
} }
// bool // bool
public bool GetUserAchievement( CSteamID steamIDUser /*class CSteamID*/, string pchName /*const char **/, ref bool pbAchieved /*bool **/ ) public bool GetUserAchievement( CSteamID steamIDUser /*class CSteamID*/, string pchName /*const char **/, ref bool pbAchieved /*bool **/ )
{ {
return _pi.ISteamUserStats_GetUserAchievement( steamIDUser.Value, pchName, ref pbAchieved ); return platform.ISteamUserStats_GetUserAchievement( steamIDUser.Value, pchName, ref pbAchieved );
} }
// bool // bool
public bool GetUserAchievementAndUnlockTime( CSteamID steamIDUser /*class CSteamID*/, string pchName /*const char **/, ref bool pbAchieved /*bool **/, out uint punUnlockTime /*uint32 **/ ) public bool GetUserAchievementAndUnlockTime( CSteamID steamIDUser /*class CSteamID*/, string pchName /*const char **/, ref bool pbAchieved /*bool **/, out uint punUnlockTime /*uint32 **/ )
{ {
return _pi.ISteamUserStats_GetUserAchievementAndUnlockTime( steamIDUser.Value, pchName, ref pbAchieved, out punUnlockTime ); return platform.ISteamUserStats_GetUserAchievementAndUnlockTime( steamIDUser.Value, pchName, ref pbAchieved, out punUnlockTime );
} }
// bool // bool
public bool GetUserStat( CSteamID steamIDUser /*class CSteamID*/, string pchName /*const char **/, out int pData /*int32 **/ ) public bool GetUserStat( CSteamID steamIDUser /*class CSteamID*/, string pchName /*const char **/, out int pData /*int32 **/ )
{ {
return _pi.ISteamUserStats_GetUserStat( steamIDUser.Value, pchName, out pData ); return platform.ISteamUserStats_GetUserStat( steamIDUser.Value, pchName, out pData );
} }
// bool // bool
public bool GetUserStat0( CSteamID steamIDUser /*class CSteamID*/, string pchName /*const char **/, out float pData /*float **/ ) public bool GetUserStat0( CSteamID steamIDUser /*class CSteamID*/, string pchName /*const char **/, out float pData /*float **/ )
{ {
return _pi.ISteamUserStats_GetUserStat0( steamIDUser.Value, pchName, out pData ); return platform.ISteamUserStats_GetUserStat0( steamIDUser.Value, pchName, out pData );
} }
// bool // bool
public bool IndicateAchievementProgress( string pchName /*const char **/, uint nCurProgress /*uint32*/, uint nMaxProgress /*uint32*/ ) public bool IndicateAchievementProgress( string pchName /*const char **/, uint nCurProgress /*uint32*/, uint nMaxProgress /*uint32*/ )
{ {
return _pi.ISteamUserStats_IndicateAchievementProgress( pchName, nCurProgress, nMaxProgress ); return platform.ISteamUserStats_IndicateAchievementProgress( pchName, nCurProgress, nMaxProgress );
} }
// bool // bool
public bool RequestCurrentStats() public bool RequestCurrentStats()
{ {
return _pi.ISteamUserStats_RequestCurrentStats(); return platform.ISteamUserStats_RequestCurrentStats();
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t RequestGlobalAchievementPercentages() public CallbackHandle RequestGlobalAchievementPercentages( Action<GlobalAchievementPercentagesReady_t, bool> CallbackFunction = null /*Action<GlobalAchievementPercentagesReady_t, bool>*/ )
{ {
return _pi.ISteamUserStats_RequestGlobalAchievementPercentages(); SteamAPICall_t callback = 0;
callback = platform.ISteamUserStats_RequestGlobalAchievementPercentages();
if ( CallbackFunction == null ) return null;
return GlobalAchievementPercentagesReady_t.CallResult( steamworks, callback, CallbackFunction );
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t RequestGlobalStats( int nHistoryDays /*int*/ ) public CallbackHandle RequestGlobalStats( int nHistoryDays /*int*/, Action<GlobalStatsReceived_t, bool> CallbackFunction = null /*Action<GlobalStatsReceived_t, bool>*/ )
{ {
return _pi.ISteamUserStats_RequestGlobalStats( nHistoryDays ); SteamAPICall_t callback = 0;
callback = platform.ISteamUserStats_RequestGlobalStats( nHistoryDays );
if ( CallbackFunction == null ) return null;
return GlobalStatsReceived_t.CallResult( steamworks, callback, CallbackFunction );
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t RequestUserStats( CSteamID steamIDUser /*class CSteamID*/ ) public CallbackHandle RequestUserStats( CSteamID steamIDUser /*class CSteamID*/, Action<UserStatsReceived_t, bool> CallbackFunction = null /*Action<UserStatsReceived_t, bool>*/ )
{ {
return _pi.ISteamUserStats_RequestUserStats( steamIDUser.Value ); SteamAPICall_t callback = 0;
callback = platform.ISteamUserStats_RequestUserStats( steamIDUser.Value );
if ( CallbackFunction == null ) return null;
return UserStatsReceived_t.CallResult( steamworks, callback, CallbackFunction );
} }
// bool // bool
public bool ResetAllStats( bool bAchievementsToo /*bool*/ ) public bool ResetAllStats( bool bAchievementsToo /*bool*/ )
{ {
return _pi.ISteamUserStats_ResetAllStats( bAchievementsToo ); return platform.ISteamUserStats_ResetAllStats( bAchievementsToo );
} }
// bool // bool
public bool SetAchievement( string pchName /*const char **/ ) public bool SetAchievement( string pchName /*const char **/ )
{ {
return _pi.ISteamUserStats_SetAchievement( pchName ); return platform.ISteamUserStats_SetAchievement( pchName );
} }
// bool // bool
public bool SetStat( string pchName /*const char **/, int nData /*int32*/ ) public bool SetStat( string pchName /*const char **/, int nData /*int32*/ )
{ {
return _pi.ISteamUserStats_SetStat( pchName, nData ); return platform.ISteamUserStats_SetStat( pchName, nData );
} }
// bool // bool
public bool SetStat0( string pchName /*const char **/, float fData /*float*/ ) public bool SetStat0( string pchName /*const char **/, float fData /*float*/ )
{ {
return _pi.ISteamUserStats_SetStat0( pchName, fData ); return platform.ISteamUserStats_SetStat0( pchName, fData );
} }
// bool // bool
public bool StoreStats() public bool StoreStats()
{ {
return _pi.ISteamUserStats_StoreStats(); return platform.ISteamUserStats_StoreStats();
} }
// bool // bool
public bool UpdateAvgRateStat( string pchName /*const char **/, float flCountThisSession /*float*/, double dSessionLength /*double*/ ) public bool UpdateAvgRateStat( string pchName /*const char **/, float flCountThisSession /*float*/, double dSessionLength /*double*/ )
{ {
return _pi.ISteamUserStats_UpdateAvgRateStat( pchName, flCountThisSession, dSessionLength ); return platform.ISteamUserStats_UpdateAvgRateStat( pchName, flCountThisSession, dSessionLength );
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t UploadLeaderboardScore( SteamLeaderboard_t hSteamLeaderboard /*SteamLeaderboard_t*/, LeaderboardUploadScoreMethod eLeaderboardUploadScoreMethod /*ELeaderboardUploadScoreMethod*/, int nScore /*int32*/, IntPtr pScoreDetails /*const int32 **/, int cScoreDetailsCount /*int*/ ) public CallbackHandle UploadLeaderboardScore( SteamLeaderboard_t hSteamLeaderboard /*SteamLeaderboard_t*/, LeaderboardUploadScoreMethod eLeaderboardUploadScoreMethod /*ELeaderboardUploadScoreMethod*/, int nScore /*int32*/, IntPtr pScoreDetails /*const int32 **/, int cScoreDetailsCount /*int*/, Action<LeaderboardScoreUploaded_t, bool> CallbackFunction = null /*Action<LeaderboardScoreUploaded_t, bool>*/ )
{ {
return _pi.ISteamUserStats_UploadLeaderboardScore( hSteamLeaderboard.Value, eLeaderboardUploadScoreMethod, nScore, (IntPtr) pScoreDetails, cScoreDetailsCount ); SteamAPICall_t callback = 0;
callback = platform.ISteamUserStats_UploadLeaderboardScore( hSteamLeaderboard.Value, eLeaderboardUploadScoreMethod, nScore, (IntPtr) pScoreDetails, cScoreDetailsCount );
if ( CallbackFunction == null ) return null;
return LeaderboardScoreUploaded_t.CallResult( steamworks, callback, CallbackFunction );
} }
} }

View File

@ -3,88 +3,96 @@
namespace SteamNative namespace SteamNative
{ {
public unsafe class SteamUtils : IDisposable internal unsafe class SteamUtils : IDisposable
{ {
// //
// Holds a platform specific implentation // Holds a platform specific implentation
// //
internal Platform.Interface _pi; internal Platform.Interface platform;
internal Facepunch.Steamworks.BaseSteamworks steamworks;
// //
// Constructor decides which implementation to use based on current platform // Constructor decides which implementation to use based on current platform
// //
public SteamUtils( IntPtr pointer ) public SteamUtils( Facepunch.Steamworks.BaseSteamworks steamworks, IntPtr pointer )
{ {
if ( Platform.IsWindows64 ) _pi = new Platform.Win64( pointer ); this.steamworks = steamworks;
else if ( Platform.IsWindows32 ) _pi = new Platform.Win32( pointer );
else if ( Platform.IsLinux32 ) _pi = new Platform.Linux32( pointer ); if ( Platform.IsWindows64 ) platform = new Platform.Win64( pointer );
else if ( Platform.IsLinux64 ) _pi = new Platform.Linux64( pointer ); else if ( Platform.IsWindows32 ) platform = new Platform.Win32( pointer );
else if ( Platform.IsOsx ) _pi = new Platform.Mac( pointer ); else if ( Platform.IsLinux32 ) platform = new Platform.Linux32( pointer );
else if ( Platform.IsLinux64 ) platform = new Platform.Linux64( pointer );
else if ( Platform.IsOsx ) platform = new Platform.Mac( pointer );
} }
// //
// Class is invalid if we don't have a valid implementation // Class is invalid if we don't have a valid implementation
// //
public bool IsValid{ get{ return _pi != null && _pi.IsValid; } } public bool IsValid{ get{ return platform != null && platform.IsValid; } }
// //
// When shutting down clear all the internals to avoid accidental use // When shutting down clear all the internals to avoid accidental use
// //
public virtual void Dispose() public virtual void Dispose()
{ {
if ( _pi != null ) if ( platform != null )
{ {
_pi.Dispose(); platform.Dispose();
_pi = null; platform = null;
} }
} }
// bool // bool
public bool BOverlayNeedsPresent() public bool BOverlayNeedsPresent()
{ {
return _pi.ISteamUtils_BOverlayNeedsPresent(); return platform.ISteamUtils_BOverlayNeedsPresent();
} }
// SteamAPICall_t // SteamAPICall_t
public SteamAPICall_t CheckFileSignature( string szFileName /*const char **/ ) public CallbackHandle CheckFileSignature( string szFileName /*const char **/, Action<CheckFileSignature_t, bool> CallbackFunction = null /*Action<CheckFileSignature_t, bool>*/ )
{ {
return _pi.ISteamUtils_CheckFileSignature( szFileName ); SteamAPICall_t callback = 0;
callback = platform.ISteamUtils_CheckFileSignature( szFileName );
if ( CallbackFunction == null ) return null;
return CheckFileSignature_t.CallResult( steamworks, callback, CallbackFunction );
} }
// SteamAPICallFailure // SteamAPICallFailure
public SteamAPICallFailure GetAPICallFailureReason( SteamAPICall_t hSteamAPICall /*SteamAPICall_t*/ ) public SteamAPICallFailure GetAPICallFailureReason( SteamAPICall_t hSteamAPICall /*SteamAPICall_t*/ )
{ {
return _pi.ISteamUtils_GetAPICallFailureReason( hSteamAPICall.Value ); return platform.ISteamUtils_GetAPICallFailureReason( hSteamAPICall.Value );
} }
// bool // bool
public bool GetAPICallResult( SteamAPICall_t hSteamAPICall /*SteamAPICall_t*/, IntPtr pCallback /*void **/, int cubCallback /*int*/, int iCallbackExpected /*int*/, ref bool pbFailed /*bool **/ ) public bool GetAPICallResult( SteamAPICall_t hSteamAPICall /*SteamAPICall_t*/, IntPtr pCallback /*void **/, int cubCallback /*int*/, int iCallbackExpected /*int*/, ref bool pbFailed /*bool **/ )
{ {
return _pi.ISteamUtils_GetAPICallResult( hSteamAPICall.Value, (IntPtr) pCallback, cubCallback, iCallbackExpected, ref pbFailed ); return platform.ISteamUtils_GetAPICallResult( hSteamAPICall.Value, (IntPtr) pCallback, cubCallback, iCallbackExpected, ref pbFailed );
} }
// uint // uint
public uint GetAppID() public uint GetAppID()
{ {
return _pi.ISteamUtils_GetAppID(); return platform.ISteamUtils_GetAppID();
} }
// Universe // Universe
public Universe GetConnectedUniverse() public Universe GetConnectedUniverse()
{ {
return _pi.ISteamUtils_GetConnectedUniverse(); return platform.ISteamUtils_GetConnectedUniverse();
} }
// bool // bool
public bool GetCSERIPPort( out uint unIP /*uint32 **/, out ushort usPort /*uint16 **/ ) public bool GetCSERIPPort( out uint unIP /*uint32 **/, out ushort usPort /*uint16 **/ )
{ {
return _pi.ISteamUtils_GetCSERIPPort( out unIP, out usPort ); return platform.ISteamUtils_GetCSERIPPort( out unIP, out usPort );
} }
// byte // byte
public byte GetCurrentBatteryPower() public byte GetCurrentBatteryPower()
{ {
return _pi.ISteamUtils_GetCurrentBatteryPower(); return platform.ISteamUtils_GetCurrentBatteryPower();
} }
// bool // bool
@ -94,7 +102,7 @@ public string GetEnteredGamepadTextInput()
bool bSuccess = default( bool ); bool bSuccess = default( bool );
System.Text.StringBuilder pchText_sb = new System.Text.StringBuilder( 4096 ); System.Text.StringBuilder pchText_sb = new System.Text.StringBuilder( 4096 );
uint cchText = 4096; uint cchText = 4096;
bSuccess = _pi.ISteamUtils_GetEnteredGamepadTextInput( pchText_sb, cchText ); bSuccess = platform.ISteamUtils_GetEnteredGamepadTextInput( pchText_sb, cchText );
if ( !bSuccess ) return null; if ( !bSuccess ) return null;
return pchText_sb.ToString(); return pchText_sb.ToString();
} }
@ -102,25 +110,25 @@ public string GetEnteredGamepadTextInput()
// uint // uint
public uint GetEnteredGamepadTextLength() public uint GetEnteredGamepadTextLength()
{ {
return _pi.ISteamUtils_GetEnteredGamepadTextLength(); return platform.ISteamUtils_GetEnteredGamepadTextLength();
} }
// bool // bool
public bool GetImageRGBA( int iImage /*int*/, IntPtr pubDest /*uint8 **/, int nDestBufferSize /*int*/ ) public bool GetImageRGBA( int iImage /*int*/, IntPtr pubDest /*uint8 **/, int nDestBufferSize /*int*/ )
{ {
return _pi.ISteamUtils_GetImageRGBA( iImage, (IntPtr) pubDest, nDestBufferSize ); return platform.ISteamUtils_GetImageRGBA( iImage, (IntPtr) pubDest, nDestBufferSize );
} }
// bool // bool
public bool GetImageSize( int iImage /*int*/, out uint pnWidth /*uint32 **/, out uint pnHeight /*uint32 **/ ) public bool GetImageSize( int iImage /*int*/, out uint pnWidth /*uint32 **/, out uint pnHeight /*uint32 **/ )
{ {
return _pi.ISteamUtils_GetImageSize( iImage, out pnWidth, out pnHeight ); return platform.ISteamUtils_GetImageSize( iImage, out pnWidth, out pnHeight );
} }
// uint // uint
public uint GetIPCCallCount() public uint GetIPCCallCount()
{ {
return _pi.ISteamUtils_GetIPCCallCount(); return platform.ISteamUtils_GetIPCCallCount();
} }
// string // string
@ -128,26 +136,26 @@ public uint GetIPCCallCount()
public string GetIPCountry() public string GetIPCountry()
{ {
IntPtr string_pointer; IntPtr string_pointer;
string_pointer = _pi.ISteamUtils_GetIPCountry(); string_pointer = platform.ISteamUtils_GetIPCountry();
return Marshal.PtrToStringAnsi( string_pointer ); return Marshal.PtrToStringAnsi( string_pointer );
} }
// uint // uint
public uint GetSecondsSinceAppActive() public uint GetSecondsSinceAppActive()
{ {
return _pi.ISteamUtils_GetSecondsSinceAppActive(); return platform.ISteamUtils_GetSecondsSinceAppActive();
} }
// uint // uint
public uint GetSecondsSinceComputerActive() public uint GetSecondsSinceComputerActive()
{ {
return _pi.ISteamUtils_GetSecondsSinceComputerActive(); return platform.ISteamUtils_GetSecondsSinceComputerActive();
} }
// uint // uint
public uint GetServerRealTime() public uint GetServerRealTime()
{ {
return _pi.ISteamUtils_GetServerRealTime(); return platform.ISteamUtils_GetServerRealTime();
} }
// string // string
@ -155,62 +163,62 @@ public uint GetServerRealTime()
public string GetSteamUILanguage() public string GetSteamUILanguage()
{ {
IntPtr string_pointer; IntPtr string_pointer;
string_pointer = _pi.ISteamUtils_GetSteamUILanguage(); string_pointer = platform.ISteamUtils_GetSteamUILanguage();
return Marshal.PtrToStringAnsi( string_pointer ); return Marshal.PtrToStringAnsi( string_pointer );
} }
// bool // bool
public bool IsAPICallCompleted( SteamAPICall_t hSteamAPICall /*SteamAPICall_t*/, ref bool pbFailed /*bool **/ ) public bool IsAPICallCompleted( SteamAPICall_t hSteamAPICall /*SteamAPICall_t*/, ref bool pbFailed /*bool **/ )
{ {
return _pi.ISteamUtils_IsAPICallCompleted( hSteamAPICall.Value, ref pbFailed ); return platform.ISteamUtils_IsAPICallCompleted( hSteamAPICall.Value, ref pbFailed );
} }
// bool // bool
public bool IsOverlayEnabled() public bool IsOverlayEnabled()
{ {
return _pi.ISteamUtils_IsOverlayEnabled(); return platform.ISteamUtils_IsOverlayEnabled();
} }
// bool // bool
public bool IsSteamInBigPictureMode() public bool IsSteamInBigPictureMode()
{ {
return _pi.ISteamUtils_IsSteamInBigPictureMode(); return platform.ISteamUtils_IsSteamInBigPictureMode();
} }
// bool // bool
public bool IsSteamRunningInVR() public bool IsSteamRunningInVR()
{ {
return _pi.ISteamUtils_IsSteamRunningInVR(); return platform.ISteamUtils_IsSteamRunningInVR();
} }
// void // void
public void SetOverlayNotificationInset( int nHorizontalInset /*int*/, int nVerticalInset /*int*/ ) public void SetOverlayNotificationInset( int nHorizontalInset /*int*/, int nVerticalInset /*int*/ )
{ {
_pi.ISteamUtils_SetOverlayNotificationInset( nHorizontalInset, nVerticalInset ); platform.ISteamUtils_SetOverlayNotificationInset( nHorizontalInset, nVerticalInset );
} }
// void // void
public void SetOverlayNotificationPosition( NotificationPosition eNotificationPosition /*ENotificationPosition*/ ) public void SetOverlayNotificationPosition( NotificationPosition eNotificationPosition /*ENotificationPosition*/ )
{ {
_pi.ISteamUtils_SetOverlayNotificationPosition( eNotificationPosition ); platform.ISteamUtils_SetOverlayNotificationPosition( eNotificationPosition );
} }
// void // void
public void SetWarningMessageHook( IntPtr pFunction /*SteamAPIWarningMessageHook_t*/ ) public void SetWarningMessageHook( IntPtr pFunction /*SteamAPIWarningMessageHook_t*/ )
{ {
_pi.ISteamUtils_SetWarningMessageHook( (IntPtr) pFunction ); platform.ISteamUtils_SetWarningMessageHook( (IntPtr) pFunction );
} }
// bool // bool
public bool ShowGamepadTextInput( GamepadTextInputMode eInputMode /*EGamepadTextInputMode*/, GamepadTextInputLineMode eLineInputMode /*EGamepadTextInputLineMode*/, string pchDescription /*const char **/, uint unCharMax /*uint32*/, string pchExistingText /*const char **/ ) public bool ShowGamepadTextInput( GamepadTextInputMode eInputMode /*EGamepadTextInputMode*/, GamepadTextInputLineMode eLineInputMode /*EGamepadTextInputLineMode*/, string pchDescription /*const char **/, uint unCharMax /*uint32*/, string pchExistingText /*const char **/ )
{ {
return _pi.ISteamUtils_ShowGamepadTextInput( eInputMode, eLineInputMode, pchDescription, unCharMax, pchExistingText ); return platform.ISteamUtils_ShowGamepadTextInput( eInputMode, eLineInputMode, pchDescription, unCharMax, pchExistingText );
} }
// void // void
public void StartVRDashboard() public void StartVRDashboard()
{ {
_pi.ISteamUtils_StartVRDashboard(); platform.ISteamUtils_StartVRDashboard();
} }
} }

View File

@ -3,52 +3,55 @@
namespace SteamNative namespace SteamNative
{ {
public unsafe class SteamVideo : IDisposable internal unsafe class SteamVideo : IDisposable
{ {
// //
// Holds a platform specific implentation // Holds a platform specific implentation
// //
internal Platform.Interface _pi; internal Platform.Interface platform;
internal Facepunch.Steamworks.BaseSteamworks steamworks;
// //
// Constructor decides which implementation to use based on current platform // Constructor decides which implementation to use based on current platform
// //
public SteamVideo( IntPtr pointer ) public SteamVideo( Facepunch.Steamworks.BaseSteamworks steamworks, IntPtr pointer )
{ {
if ( Platform.IsWindows64 ) _pi = new Platform.Win64( pointer ); this.steamworks = steamworks;
else if ( Platform.IsWindows32 ) _pi = new Platform.Win32( pointer );
else if ( Platform.IsLinux32 ) _pi = new Platform.Linux32( pointer ); if ( Platform.IsWindows64 ) platform = new Platform.Win64( pointer );
else if ( Platform.IsLinux64 ) _pi = new Platform.Linux64( pointer ); else if ( Platform.IsWindows32 ) platform = new Platform.Win32( pointer );
else if ( Platform.IsOsx ) _pi = new Platform.Mac( pointer ); else if ( Platform.IsLinux32 ) platform = new Platform.Linux32( pointer );
else if ( Platform.IsLinux64 ) platform = new Platform.Linux64( pointer );
else if ( Platform.IsOsx ) platform = new Platform.Mac( pointer );
} }
// //
// Class is invalid if we don't have a valid implementation // Class is invalid if we don't have a valid implementation
// //
public bool IsValid{ get{ return _pi != null && _pi.IsValid; } } public bool IsValid{ get{ return platform != null && platform.IsValid; } }
// //
// When shutting down clear all the internals to avoid accidental use // When shutting down clear all the internals to avoid accidental use
// //
public virtual void Dispose() public virtual void Dispose()
{ {
if ( _pi != null ) if ( platform != null )
{ {
_pi.Dispose(); platform.Dispose();
_pi = null; platform = null;
} }
} }
// void // void
public void GetVideoURL( AppId_t unVideoAppID /*AppId_t*/ ) public void GetVideoURL( AppId_t unVideoAppID /*AppId_t*/ )
{ {
_pi.ISteamVideo_GetVideoURL( unVideoAppID.Value ); platform.ISteamVideo_GetVideoURL( unVideoAppID.Value );
} }
// bool // bool
public bool IsBroadcasting( IntPtr pnNumViewers /*int **/ ) public bool IsBroadcasting( IntPtr pnNumViewers /*int **/ )
{ {
return _pi.ISteamVideo_IsBroadcasting( (IntPtr) pnNumViewers ); return platform.ISteamVideo_IsBroadcasting( (IntPtr) pnNumViewers );
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -25,7 +25,7 @@ private void Build( Dictionary<string, CodeWriter.TypeDef> typeDefs )
{ {
var cleanNative = NativeType.Trim( '*', ' ' ).Replace( "class ", "" ).Replace( "const ", "" ); var cleanNative = NativeType.Trim( '*', ' ' ).Replace( "class ", "" ).Replace( "const ", "" );
if ( typeDefs.ContainsKey( cleanNative ) ) if ( typeDefs != null && typeDefs.ContainsKey( cleanNative ) )
{ {
TypeDef = typeDefs[cleanNative]; TypeDef = typeDefs[cleanNative];
} }

View File

@ -38,12 +38,37 @@ internal void ExtendDefinition( SteamApiDefinition def )
} }
} }
// //
// Associate callbackIds with structs // Associate callbackIds with structs
// //
foreach ( var t in def.structs ) foreach ( var t in def.structs )
{ {
var r = new Regex( @"struct "+t.Name+@"\n{ ?\n(?:.)+enum { k_iCallback = (.+) \+ ([0-9]+)", RegexOptions.Multiline | RegexOptions.IgnoreCase ); // Standard style
{
var r = new Regex( @"struct "+t.Name+@"\n{ ?\n(?:.)+enum { k_iCallback = (?:(.+) \+ ([0-9]+)|(.+)) };", RegexOptions.Multiline | RegexOptions.IgnoreCase );
var m = r.Match( Content );
if ( m.Success )
{
var kName = m.Groups[1].Value;
var num = m.Groups[2].Value;
if ( string.IsNullOrEmpty( kName ) )
{
kName = m.Groups[3].Value;
num = "0";
}
kName = kName.Replace( "k_i", "CallbackIdentifiers." ).Replace( "Callbacks", "" );
t.CallbackId = $"{kName} + {num}";
}
}
// New style
{
var r = new Regex( @"DEFINE_CALLBACK\( "+t.Name+@", (.+) \+ ([0-9]+) \)" );
var m = r.Match( Content ); var m = r.Match( Content );
if ( m.Success ) if ( m.Success )
{ {
@ -55,6 +80,7 @@ internal void ExtendDefinition( SteamApiDefinition def )
t.CallbackId = $"{kName} + {num}"; t.CallbackId = $"{kName} + {num}";
} }
} }
}
// //
// Find defines // Find defines
@ -70,6 +96,25 @@ internal void ExtendDefinition( SteamApiDefinition def )
} }
} }
//
// Find CALL_RESULTs
//
{
var r = new Regex( @"CALL_RESULT\( (.+) \)(?:.+)?\n(?:.+)virtual\s+SteamAPICall_t\s+(\w+)\(" );
var ma = r.Matches( Content );
foreach ( Match m in ma )
{
var s = def.structs.Single( x => x.Name == m.Groups[1].Value );
s.IsCallResult = true;
foreach ( var t in def.methods.Where( x => x.Name == m.Groups[2].Value ) )
{
t.CallResult = s.Name;
}
}
}
} }
} }
} }

View File

@ -35,24 +35,27 @@ void GenerateClasses( string FileName )
private void Class( string classname, SteamApiDefinition.MethodDef[] methodDef ) private void Class( string classname, SteamApiDefinition.MethodDef[] methodDef )
{ {
StartBlock( $"public unsafe class {InterfaceNameToClass(classname)} : IDisposable" ); StartBlock( $"internal unsafe class {InterfaceNameToClass(classname)} : IDisposable" );
{ {
WriteLine( "//" ); WriteLine( "//" );
WriteLine( "// Holds a platform specific implentation" ); WriteLine( "// Holds a platform specific implentation" );
WriteLine( "//" ); WriteLine( "//" );
WriteLine( "internal Platform.Interface _pi;" ); WriteLine( "internal Platform.Interface platform;" );
WriteLine( "internal Facepunch.Steamworks.BaseSteamworks steamworks;" );
WriteLine(); WriteLine();
WriteLine( "//" ); WriteLine( "//" );
WriteLine( "// Constructor decides which implementation to use based on current platform" ); WriteLine( "// Constructor decides which implementation to use based on current platform" );
WriteLine( "//" ); WriteLine( "//" );
StartBlock( $"public {InterfaceNameToClass( classname )}( IntPtr pointer )" ); StartBlock( $"public {InterfaceNameToClass( classname )}( Facepunch.Steamworks.BaseSteamworks steamworks, IntPtr pointer )" );
{ {
WriteLine( "if ( Platform.IsWindows64 ) _pi = new Platform.Win64( pointer );" ); WriteLine( "this.steamworks = steamworks;" );
WriteLine( "else if ( Platform.IsWindows32 ) _pi = new Platform.Win32( pointer );" ); WriteLine( "" );
WriteLine( "else if ( Platform.IsLinux32 ) _pi = new Platform.Linux32( pointer );" ); WriteLine( "if ( Platform.IsWindows64 ) platform = new Platform.Win64( pointer );" );
WriteLine( "else if ( Platform.IsLinux64 ) _pi = new Platform.Linux64( pointer );" ); WriteLine( "else if ( Platform.IsWindows32 ) platform = new Platform.Win32( pointer );" );
WriteLine( "else if ( Platform.IsOsx ) _pi = new Platform.Mac( pointer );" ); WriteLine( "else if ( Platform.IsLinux32 ) platform = new Platform.Linux32( pointer );" );
WriteLine( "else if ( Platform.IsLinux64 ) platform = new Platform.Linux64( pointer );" );
WriteLine( "else if ( Platform.IsOsx ) platform = new Platform.Mac( pointer );" );
} }
EndBlock(); EndBlock();
WriteLine(); WriteLine();
@ -60,7 +63,7 @@ private void Class( string classname, SteamApiDefinition.MethodDef[] methodDef )
WriteLine( "//" ); WriteLine( "//" );
WriteLine( "// Class is invalid if we don't have a valid implementation" ); WriteLine( "// Class is invalid if we don't have a valid implementation" );
WriteLine( "//" ); WriteLine( "//" );
WriteLine( "public bool IsValid{ get{ return _pi != null && _pi.IsValid; } }" ); WriteLine( "public bool IsValid{ get{ return platform != null && platform.IsValid; } }" );
WriteLine(); WriteLine();
WriteLine( "//" ); WriteLine( "//" );
@ -68,10 +71,10 @@ private void Class( string classname, SteamApiDefinition.MethodDef[] methodDef )
WriteLine( "//" ); WriteLine( "//" );
StartBlock( $"public virtual void Dispose()" ); StartBlock( $"public virtual void Dispose()" );
{ {
StartBlock( " if ( _pi != null )" ); StartBlock( " if ( platform != null )" );
{ {
WriteLine( "_pi.Dispose();" ); WriteLine( "platform.Dispose();" );
WriteLine( "_pi = null;" ); WriteLine( "platform = null;" );
} }
EndBlock(); EndBlock();
} }
@ -114,6 +117,7 @@ private void ClassMethod( string classname, SteamApiDefinition.MethodDef m )
Detect_IntPtrArgs( argList, callargs ); Detect_IntPtrArgs( argList, callargs );
Detect_MultiSizeArrayReturn( argList, callargs ); Detect_MultiSizeArrayReturn( argList, callargs );
Detect_StringArray( argList, callargs ); Detect_StringArray( argList, callargs );
Detect_CallResult( argList, callargs );
var methodName = m.Name; var methodName = m.Name;
@ -136,6 +140,24 @@ private void ClassMethod( string classname, SteamApiDefinition.MethodDef m )
LastMethodName = m.Name; LastMethodName = m.Name;
} }
private void Detect_CallResult( List<Argument> argList, List<Argument> callargs )
{
if ( ReturnType != "SteamAPICall_t" ) return;
if ( string.IsNullOrEmpty( MethodDef.CallResult ) ) return;
argList.Insert( argList.Count, new Argument( "CallbackFunction = null", $"Action<{MethodDef.CallResult}, bool>", null ) );
BeforeLines.Insert( 0, "SteamAPICall_t callback = 0;" );
ReturnVar = "callback";
ReturnType = $"CallbackHandle";
AfterLines.Add( "" );
AfterLines.Add( "if ( CallbackFunction == null ) return null;" );
AfterLines.Add( "" );
AfterLines.Add( $"return {MethodDef.CallResult}.CallResult( steamworks, callback, CallbackFunction );" );
}
private void Detect_StringArray( List<Argument> argList, List<Argument> callargs ) private void Detect_StringArray( List<Argument> argList, List<Argument> callargs )
{ {
var arg = argList.FirstOrDefault( x => x.NativeType.Contains( "SteamParamStringArray_t") ); var arg = argList.FirstOrDefault( x => x.NativeType.Contains( "SteamParamStringArray_t") );
@ -152,6 +174,9 @@ private void Detect_StringArray( List<Argument> argList, List<Argument> callargs
BeforeLines.Add( $"nativeStrings[i] = Marshal.StringToHGlobalAnsi( {arg.Name}[i] );" ); BeforeLines.Add( $"nativeStrings[i] = Marshal.StringToHGlobalAnsi( {arg.Name}[i] );" );
BeforeLines.Add( $"}}" ); BeforeLines.Add( $"}}" );
BeforeLines.Add( "try" );
BeforeLines.Add( "{" );
BeforeLines.Add( "" ); BeforeLines.Add( "" );
BeforeLines.Add( "// Create string array" ); BeforeLines.Add( "// Create string array" );
BeforeLines.Add( $"var size = Marshal.SizeOf( typeof( IntPtr ) ) * nativeStrings.Length;" ); BeforeLines.Add( $"var size = Marshal.SizeOf( typeof( IntPtr ) ) * nativeStrings.Length;" );
@ -164,14 +189,13 @@ private void Detect_StringArray( List<Argument> argList, List<Argument> callargs
BeforeLines.Add( $"tags.Strings = nativeArray;" ); BeforeLines.Add( $"tags.Strings = nativeArray;" );
BeforeLines.Add( $"tags.NumStrings = {arg.Name}.Length;" ); BeforeLines.Add( $"tags.NumStrings = {arg.Name}.Length;" );
ReturnVar = "var result"; AfterLines.Add( "}" );
AfterLines.Add( "finally" );
AfterLines.Add( "{" );
AfterLines.Add( $"foreach ( var x in nativeStrings )" ); AfterLines.Add( $"foreach ( var x in nativeStrings )" );
AfterLines.Add( $" Marshal.FreeHGlobal( x );" ); AfterLines.Add( $" Marshal.FreeHGlobal( x );" );
AfterLines.Add( $"" ); AfterLines.Add( $"" );
AfterLines.Add( $"return result;" ); AfterLines.Add( "}" );
foreach ( var a in callargs ) foreach ( var a in callargs )
if ( a.Name == arg.Name ) a.Name = "ref tags"; if ( a.Name == arg.Name ) a.Name = "ref tags";
@ -375,7 +399,7 @@ private void Detect_InterfaceReturn( List<Argument> argList, List<Argument> call
ReturnVar = "interface_pointer"; ReturnVar = "interface_pointer";
ReturnType = ReturnType.Substring( 1 ).Trim( '*', ' ' ); ReturnType = ReturnType.Substring( 1 ).Trim( '*', ' ' );
AfterLines.Add( $"return new {ReturnType}( interface_pointer );" ); AfterLines.Add( $"return new {ReturnType}( steamworks, interface_pointer );" );
} }
private void Detect_VectorReturn( List<Argument> argList, List<Argument> callArgs ) private void Detect_VectorReturn( List<Argument> argList, List<Argument> callArgs )
@ -429,7 +453,7 @@ private void CallPlatformClass( string classname, SteamApiDefinition.MethodDef m
if ( returnVar != "" ) if ( returnVar != "" )
r = returnVar + " = "; r = returnVar + " = ";
BeforeLines.Add( $"{r}_pi.{classname}_{methodName}({args});" ); BeforeLines.Add( $"{r}platform.{classname}_{methodName}({args});" );
} }
} }
} }

View File

@ -63,10 +63,12 @@ void Structs()
WriteLine(); WriteLine();
WriteLine( "//" ); WriteLine( "//" );
WriteLine( "// Read this struct from a pointer, usually from Native" ); WriteLine( "// Read this struct from a pointer, usually from Native. It will automatically do the awesome stuff." );
WriteLine( "//" ); WriteLine( "//" );
StartBlock( $"public static {c.Name} FromPointer( IntPtr p )" ); StartBlock( $"public static {c.Name} FromPointer( IntPtr p )" );
{ {
WriteLine( $"if ( Platform.PackSmall ) return ({c.Name}.PackSmall) Marshal.PtrToStructure( p, typeof({c.Name}.PackSmall) );" );
WriteLine( $"return ({c.Name}) Marshal.PtrToStructure( p, typeof({c.Name}) );" ); WriteLine( $"return ({c.Name}) Marshal.PtrToStructure( p, typeof({c.Name}) );" );
} }
EndBlock(); EndBlock();
@ -103,20 +105,14 @@ void Structs()
} }
EndBlock(); EndBlock();
WriteLine(); }
WriteLine( "//" ); EndBlock();
WriteLine( "// Read this struct from a pointer, usually from Native" );
WriteLine( "//" ); if ( c.IsCallResult )
StartBlock( $"public static PackSmall FromPointer( IntPtr p )" );
{ {
WriteLine( $"return (PackSmall) Marshal.PtrToStructure( p, typeof(PackSmall) );" ); CallResult( c );
} }
EndBlock(); else if ( !string.IsNullOrEmpty( c.CallbackId ) )
}
EndBlock();
if ( !string.IsNullOrEmpty( c.CallbackId ) )
{ {
Callback( c ); Callback( c );
} }
@ -199,14 +195,15 @@ private void Callback( SteamApiDefinition.StructDef c )
WriteLine(); WriteLine();
StartBlock( $"public static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action<{c.Name}, bool> CallbackFunction )" ); StartBlock( $"public static void RegisterCallback( Facepunch.Steamworks.BaseSteamworks steamworks, Action<{c.Name}, bool> CallbackFunction )" );
{ {
WriteLine( $"var handle = new Callback.Handle();" ); WriteLine( $"var handle = new CallbackHandle();" );
WriteLine( $"handle.steamworks = steamworks;" );
WriteLine( $"" ); WriteLine( $"" );
WriteLine( "//" ); WriteLine( "//" );
WriteLine( "// Create the functions we need for the vtable" ); WriteLine( "// Create the functions we need for the vtable" );
WriteLine( "//" ); WriteLine( "//" );
WriteLine( $"Callback.Result funcA = ( _, p ) => {{ CallbackFunction( FromPointer( p ), false ); }};" ); WriteLine( $"Callback.Result funcA = ( _, p ) => {{ CallbackFunction( FromPointer( p ), false ); }};" );
WriteLine( $"Callback.ResultWithInfo funcB = ( _, p, iofailure, call ) => {{ CallbackFunction( FromPointer( p ), iofailure ); }};" ); WriteLine( $"Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => {{ CallbackFunction( FromPointer( p ), bIOFailure ); }};" );
WriteLine( $"Callback.GetSize funcC = ( _ ) => {{ return Marshal.SizeOf( typeof( {c.Name} ) ); }};" ); WriteLine( $"Callback.GetSize funcC = ( _ ) => {{ return Marshal.SizeOf( typeof( {c.Name} ) ); }};" );
WriteLine(); WriteLine();
WriteLine( "//" ); WriteLine( "//" );
@ -214,8 +211,6 @@ private void Callback( SteamApiDefinition.StructDef c )
WriteLine( "//" ); WriteLine( "//" );
StartBlock( "if ( Platform.PackSmall )" ); StartBlock( "if ( Platform.PackSmall )" );
{ {
WriteLine( $"funcA = ( _, p ) => {{ CallbackFunction( PackSmall.FromPointer( p ), false ); }};" );
WriteLine( $"funcB = ( _, p, iofailure, call ) => {{ CallbackFunction( PackSmall.FromPointer( p ), iofailure ); }};" );
WriteLine( $"funcC = ( _ ) => {{ return Marshal.SizeOf( typeof( PackSmall ) ); }};" ); WriteLine( $"funcC = ( _ ) => {{ return Marshal.SizeOf( typeof( PackSmall ) ); }};" );
} }
EndBlock(); EndBlock();
@ -269,5 +264,81 @@ private void Callback( SteamApiDefinition.StructDef c )
} }
EndBlock(); EndBlock();
} }
private void CallResult( SteamApiDefinition.StructDef c )
{
WriteLine();
StartBlock( $"public static CallbackHandle CallResult( Facepunch.Steamworks.BaseSteamworks steamworks, SteamAPICall_t call, Action<{c.Name}, bool> CallbackFunction )" );
{
WriteLine( $"var handle = new CallbackHandle();" );
WriteLine( $"handle.steamworks = steamworks;" );
WriteLine( $"handle.callHandle = call;" );
WriteLine( $"" );
WriteLine( "//" );
WriteLine( "// Create the functions we need for the vtable" );
WriteLine( "//" );
WriteLine( $"Callback.Result funcA = ( _, p ) => {{ CallbackFunction( FromPointer( p ), false ); handle.UnregisterCallResult(); }};" );
WriteLine( $"Callback.ResultWithInfo funcB = ( _, p, bIOFailure, hSteamAPICall ) => {{ CallbackFunction( FromPointer( p ), bIOFailure ); handle.UnregisterCallResult(); }};" );
WriteLine( $"Callback.GetSize funcC = ( _ ) => {{ return Marshal.SizeOf( typeof( {c.Name} ) ); }};" );
WriteLine();
WriteLine( "//" );
WriteLine( "// If this platform is PackSmall, use PackSmall versions of everything instead" );
WriteLine( "//" );
StartBlock( "if ( Platform.PackSmall )" );
{
WriteLine( $"funcC = ( _ ) => {{ return Marshal.SizeOf( typeof( PackSmall ) ); }};" );
}
EndBlock();
WriteLine( "" );
WriteLine( "//" );
WriteLine( "// Allocate a handle to each function, so they don't get disposed" );
WriteLine( "//" );
WriteLine( "handle.FuncA = GCHandle.Alloc( funcA );" );
WriteLine( "handle.FuncB = GCHandle.Alloc( funcB );" );
WriteLine( "handle.FuncC = GCHandle.Alloc( funcC );" );
WriteLine();
WriteLine( "//" );
WriteLine( "// Create the VTable by manually allocating the memory and copying across" );
WriteLine( "//" );
WriteLine( "handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) );" );
StartBlock( "var vTable = new Callback.VTable()" );
{
WriteLine( "ResultA = Marshal.GetFunctionPointerForDelegate( funcB ), // The order of these functions is a point of contention" );
WriteLine( "ResultB = Marshal.GetFunctionPointerForDelegate( funcA ), // Doesn't seem to matter win64, but win32 crashes if WithInfo not first" );
WriteLine( "GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), // Which is the opposite of how they are in code, but whatever works" );
}
EndBlock( ";" );
WriteLine( "Marshal.StructureToPtr( vTable, handle.vTablePtr, false );" );
WriteLine( "" );
WriteLine( "//" );
WriteLine( "// Create the callback object" );
WriteLine( "//" );
WriteLine( $"var cb = new Callback();" );
WriteLine( $"cb.vTablePtr = handle.vTablePtr;" );
WriteLine( $"cb.CallbackFlags = steamworks.IsGameServer ? (byte) SteamNative.Callback.Flags.GameServer : (byte) 0;" );
WriteLine( $"cb.CallbackId = CallbackId;" );
WriteLine( "" );
WriteLine( "//" );
WriteLine( "// Pin the callback, so it doesn't get garbage collected and we can pass the pointer to native" );
WriteLine( "//" );
WriteLine( $"handle.PinnedCallback = GCHandle.Alloc( cb, GCHandleType.Pinned );" );
WriteLine( "" );
WriteLine( "//" );
WriteLine( "// Register the callback with Steam" );
WriteLine( "//" );
WriteLine( $"steamworks.native.api.SteamAPI_RegisterCallResult( handle.PinnedCallback.AddrOfPinnedObject(), call );" );
WriteLine();
WriteLine( "return handle;" );
}
EndBlock();
}
} }
} }

View File

@ -107,6 +107,48 @@ private static void AddExtras( SteamApiDefinition def )
} }
} ); } );
def.methods.Add( new SteamApiDefinition.MethodDef()
{
ClassName = "SteamApi",
Name = "SteamAPI_RegisterCallResult",
ReturnType = "void",
NeedsSelfPointer = false,
Params = new SteamApiDefinition.MethodDef.ParamType[]
{
new SteamApiDefinition.MethodDef.ParamType()
{
Name = "pCallback",
Type = "void *"
},
new SteamApiDefinition.MethodDef.ParamType()
{
Name = "callback",
Type = "SteamAPICall_t"
},
}
} );
def.methods.Add( new SteamApiDefinition.MethodDef()
{
ClassName = "SteamApi",
Name = "SteamAPI_UnregisterCallResult",
ReturnType = "void",
NeedsSelfPointer = false,
Params = new SteamApiDefinition.MethodDef.ParamType[]
{
new SteamApiDefinition.MethodDef.ParamType()
{
Name = "pCallback",
Type = "void *"
},
new SteamApiDefinition.MethodDef.ParamType()
{
Name = "callback",
Type = "SteamAPICall_t"
},
}
} );
def.methods.Add( new SteamApiDefinition.MethodDef() def.methods.Add( new SteamApiDefinition.MethodDef()
{ {
ClassName = "SteamApi", ClassName = "SteamApi",

View File

@ -53,6 +53,7 @@ public class StructFields
public StructFields[] Fields { get; set; } public StructFields[] Fields { get; set; }
public string CallbackId { get; set; } public string CallbackId { get; set; }
public bool IsCallResult { get; set; }
} }
public List<StructDef> structs { get; set; } public List<StructDef> structs { get; set; }
@ -76,6 +77,9 @@ public class ParamType
[JsonProperty( PropertyName = "params" )] [JsonProperty( PropertyName = "params" )]
public ParamType[] Params { get; set; } public ParamType[] Params { get; set; }
[JsonProperty( PropertyName = "callresult" )]
public string CallResult { get; set; }
public bool NeedsSelfPointer = true; public bool NeedsSelfPointer = true;
} }