mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2025-01-26 05:28:07 +03:00
Merge branch 'master' into workshop
This commit is contained in:
commit
719bfbf8dd
@ -56,7 +56,7 @@ namespace Facepunch.Steamworks.Test
|
|||||||
Console.WriteLine( " - - " + ach.Description );
|
Console.WriteLine( " - - " + ach.Description );
|
||||||
Console.WriteLine( " - - " + ach.State );
|
Console.WriteLine( " - - " + ach.State );
|
||||||
Console.WriteLine( " - - " + ach.UnlockTime );
|
Console.WriteLine( " - - " + ach.UnlockTime );
|
||||||
Console.WriteLine( " - - " + ach.Percentage );
|
Console.WriteLine( " - - " + ach.GlobalUnlockedPercentage );
|
||||||
|
|
||||||
if ( ach.Icon != null )
|
if ( ach.Icon != null )
|
||||||
{
|
{
|
@ -84,6 +84,8 @@ namespace Facepunch.Steamworks.Test
|
|||||||
var sw = new Stopwatch();
|
var sw = new Stopwatch();
|
||||||
using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
|
using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
|
||||||
{
|
{
|
||||||
|
Assert.IsTrue(client.IsValid);
|
||||||
|
|
||||||
for( int i=0; i<1024; i++ )
|
for( int i=0; i<1024; i++ )
|
||||||
{
|
{
|
||||||
sw.Restart();
|
sw.Restart();
|
@ -24,6 +24,8 @@ namespace Facepunch.Steamworks.Test
|
|||||||
foreach ( var friend in client.Friends.All )
|
foreach ( var friend in client.Friends.All )
|
||||||
{
|
{
|
||||||
Console.WriteLine( "{0}: {1} (Friend:{2}) (Blocked:{3})", friend.Id, friend.Name, friend.IsFriend, friend.IsBlocked );
|
Console.WriteLine( "{0}: {1} (Friend:{2}) (Blocked:{3})", friend.Id, friend.Name, friend.IsFriend, friend.IsBlocked );
|
||||||
|
|
||||||
|
Assert.IsNotNull(friend.GetAvatar( Steamworks.Friends.AvatarSize.Medium ));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -50,21 +52,43 @@ namespace Facepunch.Steamworks.Test
|
|||||||
Assert.IsTrue( client.IsValid );
|
Assert.IsTrue( client.IsValid );
|
||||||
|
|
||||||
var friend = client.Friends.All.First();
|
var friend = client.Friends.All.First();
|
||||||
|
bool passed = false;
|
||||||
|
|
||||||
var img = client.Friends.GetAvatar( Steamworks.Friends.AvatarSize.Medium, friend.Id );
|
client.Friends.GetAvatar( Steamworks.Friends.AvatarSize.Medium, friend.Id, (avatar) =>
|
||||||
|
{
|
||||||
|
Assert.AreEqual(avatar.Width, 64);
|
||||||
|
Assert.AreEqual(avatar.Height, 64);
|
||||||
|
Assert.AreEqual(avatar.Data.Length, avatar.Width * avatar.Height * 4);
|
||||||
|
|
||||||
Assert.AreEqual( img.Width, 64 );
|
DrawImage(avatar);
|
||||||
Assert.AreEqual( img.Height, 64 );
|
passed = true;
|
||||||
|
});
|
||||||
|
|
||||||
while ( !img.IsLoaded && !img.IsError )
|
while (passed == false )
|
||||||
{
|
{
|
||||||
client.Update();
|
client.Update();
|
||||||
System.Threading.Thread.Sleep( 10 );
|
System.Threading.Thread.Sleep( 10 );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Assert.AreEqual( img.Data.Length, img.Width * img.Height * 4 );
|
[TestMethod]
|
||||||
|
public void CachedAvatar()
|
||||||
|
{
|
||||||
|
using (var client = new Facepunch.Steamworks.Client(252490))
|
||||||
|
{
|
||||||
|
Assert.IsTrue(client.IsValid);
|
||||||
|
|
||||||
DrawImage( img );
|
var friend = client.Friends.All.First();
|
||||||
|
|
||||||
|
var image = client.Friends.GetCachedAvatar( Steamworks.Friends.AvatarSize.Medium, friend.Id );
|
||||||
|
|
||||||
|
if (image != null)
|
||||||
|
{
|
||||||
|
Assert.AreEqual(image.Width, 64);
|
||||||
|
Assert.AreEqual(image.Height, 64);
|
||||||
|
Assert.AreEqual(image.Data.Length, image.Width * image.Height * 4);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -273,6 +273,12 @@ namespace Facepunch.Steamworks.Test
|
|||||||
Assert.IsTrue(message == testString);
|
Assert.IsTrue(message == testString);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
client.Lobby.OnChatStringRecieved = (steamID, message) =>
|
||||||
|
{
|
||||||
|
Console.WriteLine("message recieved");
|
||||||
|
Assert.IsTrue(message == testString);
|
||||||
|
};
|
||||||
|
|
||||||
client.Lobby.Create(Steamworks.Lobby.Type.Public, 10);
|
client.Lobby.Create(Steamworks.Lobby.Type.Public, 10);
|
||||||
|
|
||||||
var sw = Stopwatch.StartNew();
|
var sw = Stopwatch.StartNew();
|
@ -433,6 +433,21 @@ namespace Facepunch.Steamworks.Test
|
|||||||
item.Tags.Add( "Apple" );
|
item.Tags.Add( "Apple" );
|
||||||
item.Tags.Add( "Banana" );
|
item.Tags.Add( "Banana" );
|
||||||
|
|
||||||
|
// Make a folder
|
||||||
|
var testFolder = new System.IO.DirectoryInfo("BlahBlah");
|
||||||
|
if (!testFolder.Exists) testFolder.Create();
|
||||||
|
|
||||||
|
item.Folder = testFolder.FullName;
|
||||||
|
|
||||||
|
// Upload a file of random bytes
|
||||||
|
var rand = new Random();
|
||||||
|
var testFile = new byte[1024 * 1024 * 32];
|
||||||
|
rand.NextBytes(testFile);
|
||||||
|
System.IO.File.WriteAllBytes( testFolder.FullName + "/testfile1.bin", testFile);
|
||||||
|
|
||||||
|
|
||||||
|
Console.WriteLine(item.Folder);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
item.Publish();
|
item.Publish();
|
||||||
@ -440,7 +455,11 @@ namespace Facepunch.Steamworks.Test
|
|||||||
while ( item.Publishing )
|
while ( item.Publishing )
|
||||||
{
|
{
|
||||||
client.Update();
|
client.Update();
|
||||||
Thread.Sleep( 100 );
|
Thread.Sleep( 10 );
|
||||||
|
|
||||||
|
Console.WriteLine("Progress: " + item.Progress);
|
||||||
|
Console.WriteLine("BytesUploaded: " + item.BytesUploaded);
|
||||||
|
Console.WriteLine("BytesTotal: " + item.BytesTotal);
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert.IsFalse( item.Publishing );
|
Assert.IsFalse( item.Publishing );
|
||||||
@ -469,6 +488,8 @@ namespace Facepunch.Steamworks.Test
|
|||||||
{
|
{
|
||||||
Console.WriteLine( "Deleting: {0}", item.Id );
|
Console.WriteLine( "Deleting: {0}", item.Id );
|
||||||
item.Delete();
|
item.Delete();
|
||||||
|
|
||||||
|
System.IO.File.Delete(testFolder.FullName + "/testfile.bin");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -92,25 +92,25 @@
|
|||||||
</Otherwise>
|
</Otherwise>
|
||||||
</Choose>
|
</Choose>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Client\Achievements.cs" />
|
<Compile Include="Client\AchievementsTest.cs" />
|
||||||
<Compile Include="Client\Client.cs" />
|
<Compile Include="Client\ClientTest.cs" />
|
||||||
<Compile Include="Client\Lobby.cs" />
|
<Compile Include="Client\LobbyTest.cs" />
|
||||||
<Compile Include="Client\RichPresence.cs" />
|
<Compile Include="Client\RichPresenceTest.cs" />
|
||||||
<Compile Include="Client\Leaderboard.cs" />
|
<Compile Include="Client\LeaderboardTest.cs" />
|
||||||
<Compile Include="Client\App.cs" />
|
<Compile Include="Client\AppTest.cs" />
|
||||||
<Compile Include="Client\RemoteStorage.cs" />
|
<Compile Include="Client\RemoteStorageTest.cs" />
|
||||||
<Compile Include="Client\Voice.cs" />
|
<Compile Include="Client\VoiceTest.cs" />
|
||||||
<Compile Include="Client\Inventory.cs" />
|
<Compile Include="Client\InventoryTest.cs" />
|
||||||
<Compile Include="Client\Workshop.cs" />
|
<Compile Include="Client\WorkshopTest.cs" />
|
||||||
<Compile Include="Client\Networking.cs" />
|
<Compile Include="Client\NetworkingTest.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Client\Friends.cs" />
|
<Compile Include="Client\FriendsTest.cs" />
|
||||||
<Compile Include="Server\Server.cs" />
|
<Compile Include="Client\Server\ServerTest.cs" />
|
||||||
<Compile Include="Server\Stats.cs" />
|
<Compile Include="Client\Server\StatsTest.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Client\Serverlist.cs" />
|
<Compile Include="Client\ServerlistTest.cs" />
|
||||||
<Compile Include="Client\Stats.cs" />
|
<Compile Include="Client\StatsTest.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
|
@ -143,9 +143,9 @@ namespace Facepunch.Steamworks
|
|||||||
private int refreshCount = 0;
|
private int refreshCount = 0;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// If this achievement is linked to a stat this will return the progress.
|
/// Returns the percentage of users who have unlocked the specified achievement, or -1 if no data available.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float Percentage
|
public float GlobalUnlockedPercentage
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
@ -127,6 +127,15 @@ namespace Facepunch.Steamworks
|
|||||||
|
|
||||||
Client.native.friends.RequestFriendRichPresence( Id );
|
Client.native.friends.RequestFriendRichPresence( Id );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This will return null if you don't have the target user's avatar in your cache.
|
||||||
|
/// Which usually happens for people not on your friends list.
|
||||||
|
/// </summary>
|
||||||
|
public Image GetAvatar( Friends.AvatarSize size )
|
||||||
|
{
|
||||||
|
return Client.Friends.GetCachedAvatar( size, Id );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -145,6 +154,8 @@ namespace Facepunch.Steamworks
|
|||||||
internal Friends( Client c )
|
internal Friends( Client c )
|
||||||
{
|
{
|
||||||
client = c;
|
client = c;
|
||||||
|
|
||||||
|
SteamNative.PersonaStateChange_t.RegisterCallback( client, OnPersonaStateChange );
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -253,20 +264,23 @@ namespace Facepunch.Steamworks
|
|||||||
Large
|
Large
|
||||||
}
|
}
|
||||||
|
|
||||||
public Image GetAvatar( AvatarSize size, ulong steamid )
|
/// <summary>
|
||||||
|
/// Try to get the avatar immediately. This should work for people on your friends list.
|
||||||
|
/// </summary>
|
||||||
|
public Image GetCachedAvatar( AvatarSize size, ulong steamid )
|
||||||
{
|
{
|
||||||
var imageid = 0;
|
var imageid = 0;
|
||||||
|
|
||||||
switch ( size )
|
switch (size)
|
||||||
{
|
{
|
||||||
case AvatarSize.Small:
|
case AvatarSize.Small:
|
||||||
imageid = client.native.friends.GetSmallFriendAvatar( steamid );
|
imageid = client.native.friends.GetSmallFriendAvatar(steamid);
|
||||||
break;
|
break;
|
||||||
case AvatarSize.Medium:
|
case AvatarSize.Medium:
|
||||||
imageid = client.native.friends.GetMediumFriendAvatar( steamid );
|
imageid = client.native.friends.GetMediumFriendAvatar(steamid);
|
||||||
break;
|
break;
|
||||||
case AvatarSize.Large:
|
case AvatarSize.Large:
|
||||||
imageid = client.native.friends.GetLargeFriendAvatar( steamid );
|
imageid = client.native.friends.GetLargeFriendAvatar(steamid);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,19 +289,53 @@ namespace Facepunch.Steamworks
|
|||||||
Id = imageid
|
Id = imageid
|
||||||
};
|
};
|
||||||
|
|
||||||
if ( imageid == 0 )
|
if (imageid != 0 && img.TryLoad(client.native.utils))
|
||||||
return img;
|
return img;
|
||||||
|
|
||||||
if ( img.TryLoad( client.native.utils ) )
|
return null;
|
||||||
return img;
|
|
||||||
|
|
||||||
throw new System.NotImplementedException( "Deferred Avatar Loading Todo" );
|
|
||||||
// Add to image loading list
|
|
||||||
|
|
||||||
//return img;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Callback will be called when the avatar is ready. If we fail to get an
|
||||||
|
/// avatar, it'll be called with a null Image.
|
||||||
|
/// </summary>
|
||||||
|
public void GetAvatar( AvatarSize size, ulong steamid, Action<Image> callback )
|
||||||
|
{
|
||||||
|
// Maybe we already have it downloaded?
|
||||||
|
var image = GetCachedAvatar(size, steamid);
|
||||||
|
if ( image != null )
|
||||||
|
{
|
||||||
|
callback(image);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lets request it from Steam
|
||||||
|
if (!client.native.friends.RequestUserInformation(steamid, false))
|
||||||
|
{
|
||||||
|
// Steam told us to get fucked
|
||||||
|
callback(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
PersonaCallbacks.Add( new PersonaCallback
|
||||||
|
{
|
||||||
|
SteamId = steamid,
|
||||||
|
Callback = () =>
|
||||||
|
{
|
||||||
|
callback( GetCachedAvatar(size, steamid) );
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private class PersonaCallback
|
||||||
|
{
|
||||||
|
public ulong SteamId;
|
||||||
|
public Action Callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<PersonaCallback> PersonaCallbacks = new List<PersonaCallback>();
|
||||||
|
|
||||||
public SteamFriend Get( ulong steamid )
|
public SteamFriend Get( ulong steamid )
|
||||||
{
|
{
|
||||||
var f = new SteamFriend()
|
var f = new SteamFriend()
|
||||||
@ -300,5 +348,11 @@ namespace Facepunch.Steamworks
|
|||||||
|
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnPersonaStateChange( PersonaStateChange_t data, bool error )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -100,6 +100,11 @@ namespace Facepunch.Steamworks
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Called when the leaderboard information is successfully recieved from Steam
|
||||||
|
/// </summary>
|
||||||
|
public Action OnBoardInformation;
|
||||||
|
|
||||||
internal void OnBoardCreated( LeaderboardFindResult_t result, bool error )
|
internal void OnBoardCreated( LeaderboardFindResult_t result, bool error )
|
||||||
{
|
{
|
||||||
if ( error || ( result.LeaderboardFound == 0 ) )
|
if ( error || ( result.LeaderboardFound == 0 ) )
|
||||||
@ -114,6 +119,8 @@ namespace Facepunch.Steamworks
|
|||||||
{
|
{
|
||||||
Name = client.native.userstats.GetLeaderboardName( BoardId );
|
Name = client.native.userstats.GetLeaderboardName( BoardId );
|
||||||
TotalEntries = client.native.userstats.GetLeaderboardEntryCount( BoardId );
|
TotalEntries = client.native.userstats.GetLeaderboardEntryCount( BoardId );
|
||||||
|
|
||||||
|
OnBoardInformation?.Invoke();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,7 +132,8 @@ namespace Facepunch.Steamworks
|
|||||||
/// Subscores are totally optional, and can be used for other game defined data such as laps etc.. although
|
/// Subscores are totally optional, and can be used for other game defined data such as laps etc.. although
|
||||||
/// they have no bearing on sorting at all
|
/// they have no bearing on sorting at all
|
||||||
/// If onlyIfBeatsOldScore is true, the score will only be updated if it beats the existing score, else it will always
|
/// If onlyIfBeatsOldScore is true, the score will only be updated if it beats the existing score, else it will always
|
||||||
/// be updated.
|
/// be updated. Beating the existing score is subjective - and depends on how your leaderboard was set up as to whether
|
||||||
|
/// that means higher or lower.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool AddScore( bool onlyIfBeatsOldScore, int score, params int[] subscores )
|
public bool AddScore( bool onlyIfBeatsOldScore, int score, params int[] subscores )
|
||||||
{
|
{
|
||||||
@ -141,10 +149,9 @@ namespace Facepunch.Steamworks
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Callback invoked by <see cref="AddScore(bool, int, int[], AddScoreCallback)"/> when score submission
|
/// Callback invoked by <see cref="AddScore(bool, int, int[], AddScoreCallback, FailureCallback)"/> when score submission
|
||||||
/// is complete.
|
/// is complete.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="success">If true, the score was submitted</param>
|
|
||||||
/// <param name="result">If successful, information about the new entry</param>
|
/// <param name="result">If successful, information about the new entry</param>
|
||||||
public delegate void AddScoreCallback( AddScoreResult result );
|
public delegate void AddScoreCallback( AddScoreResult result );
|
||||||
|
|
||||||
@ -278,13 +285,13 @@ namespace Facepunch.Steamworks
|
|||||||
[ThreadStatic] private static List<Entry> _sEntryBuffer;
|
[ThreadStatic] private static List<Entry> _sEntryBuffer;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Callback invoked by <see cref="FetchScores(RequestType, int, int, FetchScoresCallback)"/> when
|
/// Callback invoked by <see cref="FetchScores(RequestType, int, int, FetchScoresCallback, FailureCallback)"/> when
|
||||||
/// a query is complete.
|
/// a query is complete.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public delegate void FetchScoresCallback( Entry[] results );
|
public delegate void FetchScoresCallback( Entry[] results );
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Fetch a subset of scores. The scores are passed to <paramref name="callback"/>.
|
/// Fetch a subset of scores. The scores are passed to <paramref name="onSuccess"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Returns true if we have started the query</returns>
|
/// <returns>Returns true if we have started the query</returns>
|
||||||
public bool FetchScores( RequestType RequestType, int start, int end, FetchScoresCallback onSuccess, FailureCallback onFailure = null )
|
public bool FetchScores( RequestType RequestType, int start, int end, FetchScoresCallback onSuccess, FailureCallback onFailure = null )
|
||||||
|
@ -318,28 +318,24 @@ namespace Facepunch.Steamworks
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static byte[] chatMessageData = new byte[1024 * 4];
|
||||||
|
|
||||||
private unsafe void OnLobbyChatMessageRecievedAPI(LobbyChatMsg_t callback, bool error)
|
private unsafe void OnLobbyChatMessageRecievedAPI(LobbyChatMsg_t callback, bool error)
|
||||||
{
|
{
|
||||||
//from Client.Networking
|
//from Client.Networking
|
||||||
if(error || callback.SteamIDLobby != CurrentLobby) { return; }
|
if(error || callback.SteamIDLobby != CurrentLobby)
|
||||||
|
return;
|
||||||
|
|
||||||
byte[] ReceiveBuffer = new byte[1024];
|
|
||||||
SteamNative.CSteamID steamid = 1;
|
SteamNative.CSteamID steamid = 1;
|
||||||
ChatEntryType chatEntryType; //not used
|
ChatEntryType chatEntryType; // "If set then this will just always return k_EChatEntryTypeChatMsg. This can usually just be set to NULL."
|
||||||
int readData = 0;
|
int readData = 0;
|
||||||
fixed (byte* p = ReceiveBuffer)
|
fixed (byte* p = chatMessageData)
|
||||||
{
|
{
|
||||||
readData = client.native.matchmaking.GetLobbyChatEntry(CurrentLobby, (int)callback.ChatID, out steamid, (IntPtr)p, ReceiveBuffer.Length, out chatEntryType);
|
readData = client.native.matchmaking.GetLobbyChatEntry(CurrentLobby, (int)callback.ChatID, out steamid, (IntPtr)p, chatMessageData.Length, out chatEntryType);
|
||||||
while (ReceiveBuffer.Length < readData)
|
|
||||||
{
|
|
||||||
ReceiveBuffer = new byte[readData + 1024];
|
|
||||||
readData = client.native.matchmaking.GetLobbyChatEntry(CurrentLobby, (int)callback.ChatID, out steamid, (IntPtr)p, ReceiveBuffer.Length, out chatEntryType);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
OnChatMessageRecieved?.Invoke(steamid, chatMessageData, readData);
|
||||||
|
OnChatStringRecieved?.Invoke(steamid, Encoding.UTF8.GetString(chatMessageData));
|
||||||
if (OnChatMessageRecieved != null) { OnChatMessageRecieved(steamid, ReceiveBuffer, readData); }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -347,6 +343,11 @@ namespace Facepunch.Steamworks
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public Action<ulong, byte[], int> OnChatMessageRecieved;
|
public Action<ulong, byte[], int> OnChatMessageRecieved;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Like OnChatMessageRecieved but the data is converted to a string
|
||||||
|
/// </summary>
|
||||||
|
public Action<ulong, string> OnChatStringRecieved;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Broadcasts a chat message to the all the users in the lobby users in the lobby (including the local user) will receive a LobbyChatMsg_t callback.
|
/// Broadcasts a chat message to the all the users in the lobby users in the lobby (including the local user) will receive a LobbyChatMsg_t callback.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -376,12 +377,14 @@ namespace Facepunch.Steamworks
|
|||||||
|
|
||||||
internal void OnLobbyStateUpdatedAPI(LobbyChatUpdate_t callback, bool error)
|
internal void OnLobbyStateUpdatedAPI(LobbyChatUpdate_t callback, bool error)
|
||||||
{
|
{
|
||||||
if (error || callback.SteamIDLobby != CurrentLobby) { return; }
|
if (error || callback.SteamIDLobby != CurrentLobby)
|
||||||
|
return;
|
||||||
|
|
||||||
MemberStateChange change = (MemberStateChange)callback.GfChatMemberStateChange;
|
MemberStateChange change = (MemberStateChange)callback.GfChatMemberStateChange;
|
||||||
ulong initiator = callback.SteamIDMakingChange;
|
ulong initiator = callback.SteamIDMakingChange;
|
||||||
ulong affected = callback.SteamIDUserChanged;
|
ulong affected = callback.SteamIDUserChanged;
|
||||||
|
|
||||||
if (OnLobbyStateChanged != null) { OnLobbyStateChanged(change, initiator, affected); }
|
OnLobbyStateChanged?.Invoke(change, initiator, affected);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -487,7 +490,11 @@ namespace Facepunch.Steamworks
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void Leave()
|
public void Leave()
|
||||||
{
|
{
|
||||||
if (CurrentLobby != 0) { client.native.matchmaking.LeaveLobby(CurrentLobby); }
|
if (CurrentLobby != 0)
|
||||||
|
{
|
||||||
|
client.native.matchmaking.LeaveLobby(CurrentLobby);
|
||||||
|
}
|
||||||
|
|
||||||
CurrentLobby = 0;
|
CurrentLobby = 0;
|
||||||
CurrentLobbyData = null;
|
CurrentLobbyData = null;
|
||||||
}
|
}
|
||||||
@ -505,7 +512,6 @@ namespace Facepunch.Steamworks
|
|||||||
/// <returns>Array of member SteamIDs</returns>
|
/// <returns>Array of member SteamIDs</returns>
|
||||||
public ulong[] GetMemberIDs()
|
public ulong[] GetMemberIDs()
|
||||||
{
|
{
|
||||||
|
|
||||||
ulong[] memIDs = new ulong[NumMembers];
|
ulong[] memIDs = new ulong[NumMembers];
|
||||||
for (int i = 0; i < NumMembers; i++)
|
for (int i = 0; i < NumMembers; i++)
|
||||||
{
|
{
|
||||||
@ -521,15 +527,16 @@ namespace Facepunch.Steamworks
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public bool UserIsInCurrentLobby(ulong steamID)
|
public bool UserIsInCurrentLobby(ulong steamID)
|
||||||
{
|
{
|
||||||
if(CurrentLobby == 0) { return false; }
|
if ( CurrentLobby == 0 )
|
||||||
|
return false;
|
||||||
|
|
||||||
ulong[] mems = GetMemberIDs();
|
ulong[] mems = GetMemberIDs();
|
||||||
|
|
||||||
for (int i = 0; i < mems.Length; i++)
|
for (int i = 0; i < mems.Length; i++)
|
||||||
{
|
{
|
||||||
if(mems[i] == steamID)
|
if ( mems[i] == steamID )
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -170,7 +170,7 @@ namespace Facepunch.Steamworks
|
|||||||
{
|
{
|
||||||
uint DataAvailable = 0;
|
uint DataAvailable = 0;
|
||||||
|
|
||||||
if ( !networking.IsP2PPacketAvailable( out DataAvailable, channel ) || DataAvailable == 0 )
|
if ( !networking.IsP2PPacketAvailable( out DataAvailable, channel ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ( ReceiveBuffer.Length < DataAvailable )
|
if ( ReceiveBuffer.Length < DataAvailable )
|
||||||
|
@ -208,6 +208,7 @@ namespace Facepunch.Steamworks
|
|||||||
else throw new System.Exception( "CreateItemResult_t Failed" );
|
else throw new System.Exception( "CreateItemResult_t Failed" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UpdateHandle = 0;
|
||||||
SubmitItemUpdate = null;
|
SubmitItemUpdate = null;
|
||||||
NeedToAgreeToWorkshopLegal = obj.UserNeedsToAcceptWorkshopLegalAgreement;
|
NeedToAgreeToWorkshopLegal = obj.UserNeedsToAcceptWorkshopLegalAgreement;
|
||||||
Publishing = false;
|
Publishing = false;
|
||||||
|
@ -29,11 +29,11 @@ namespace Facepunch.Steamworks.Interop
|
|||||||
|
|
||||||
private bool isServer;
|
private bool isServer;
|
||||||
|
|
||||||
private HSteamUser hUser;
|
|
||||||
private HSteamPipe hPipe;
|
|
||||||
|
|
||||||
internal bool InitClient( BaseSteamworks steamworks )
|
internal bool InitClient( BaseSteamworks steamworks )
|
||||||
{
|
{
|
||||||
|
if ( Steamworks.Server.Instance != null )
|
||||||
|
throw new System.Exception("Steam client should be initialized before steam server - or there's big trouble.");
|
||||||
|
|
||||||
isServer = false;
|
isServer = false;
|
||||||
|
|
||||||
api = new SteamNative.SteamApi();
|
api = new SteamNative.SteamApi();
|
||||||
@ -44,8 +44,8 @@ namespace Facepunch.Steamworks.Interop
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
hUser = api.SteamAPI_GetHSteamUser();
|
var hUser = api.SteamAPI_GetHSteamUser();
|
||||||
hPipe = api.SteamAPI_GetHSteamPipe();
|
var hPipe = api.SteamAPI_GetHSteamPipe();
|
||||||
if ( hPipe == 0 )
|
if ( hPipe == 0 )
|
||||||
{
|
{
|
||||||
Console.Error.WriteLine( "InitClient: hPipe == 0" );
|
Console.Error.WriteLine( "InitClient: hPipe == 0" );
|
||||||
@ -83,8 +83,8 @@ namespace Facepunch.Steamworks.Interop
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
hUser = api.SteamGameServer_GetHSteamUser();
|
var hUser = api.SteamGameServer_GetHSteamUser();
|
||||||
hPipe = api.SteamGameServer_GetHSteamPipe();
|
var hPipe = api.SteamGameServer_GetHSteamPipe();
|
||||||
if ( hPipe == 0 )
|
if ( hPipe == 0 )
|
||||||
{
|
{
|
||||||
Console.Error.WriteLine( "InitServer: hPipe == 0" );
|
Console.Error.WriteLine( "InitServer: hPipe == 0" );
|
||||||
@ -216,6 +216,12 @@ namespace Facepunch.Steamworks.Interop
|
|||||||
remoteStorage = null;
|
remoteStorage = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( matchmaking != null )
|
||||||
|
{
|
||||||
|
matchmaking.Dispose();
|
||||||
|
matchmaking = null;
|
||||||
|
}
|
||||||
|
|
||||||
if ( applist != null )
|
if ( applist != null )
|
||||||
{
|
{
|
||||||
applist.Dispose();
|
applist.Dispose();
|
||||||
@ -242,9 +248,6 @@ namespace Facepunch.Steamworks.Interop
|
|||||||
// pointers we stored are not invalid.
|
// pointers we stored are not invalid.
|
||||||
//
|
//
|
||||||
|
|
||||||
hPipe = 0;
|
|
||||||
hUser = 0;
|
|
||||||
|
|
||||||
api.Dispose();
|
api.Dispose();
|
||||||
api = null;
|
api = null;
|
||||||
}
|
}
|
||||||
|
@ -71,9 +71,9 @@ namespace Facepunch.Steamworks.Interop
|
|||||||
ThisVTable.InternalRulesFailedToRespond db = ( _ ) => InternalOnRulesFailedToRespond();
|
ThisVTable.InternalRulesFailedToRespond db = ( _ ) => InternalOnRulesFailedToRespond();
|
||||||
ThisVTable.InternalRulesRefreshComplete dc = ( _ ) => InternalOnRulesRefreshComplete();
|
ThisVTable.InternalRulesRefreshComplete dc = ( _ ) => InternalOnRulesRefreshComplete();
|
||||||
|
|
||||||
RulesRespondPin = GCHandle.Alloc( da, GCHandleType.Pinned );
|
RulesRespondPin = GCHandle.Alloc( da );
|
||||||
FailedRespondPin = GCHandle.Alloc( db, GCHandleType.Pinned );
|
FailedRespondPin = GCHandle.Alloc( db );
|
||||||
CompletePin = GCHandle.Alloc( dc, GCHandleType.Pinned );
|
CompletePin = GCHandle.Alloc( dc );
|
||||||
|
|
||||||
var t = new ThisVTable()
|
var t = new ThisVTable()
|
||||||
{
|
{
|
||||||
@ -93,9 +93,9 @@ namespace Facepunch.Steamworks.Interop
|
|||||||
StdVTable.InternalRulesFailedToRespond db = InternalOnRulesFailedToRespond;
|
StdVTable.InternalRulesFailedToRespond db = InternalOnRulesFailedToRespond;
|
||||||
StdVTable.InternalRulesRefreshComplete dc = InternalOnRulesRefreshComplete;
|
StdVTable.InternalRulesRefreshComplete dc = InternalOnRulesRefreshComplete;
|
||||||
|
|
||||||
RulesRespondPin = GCHandle.Alloc( da, GCHandleType.Pinned );
|
RulesRespondPin = GCHandle.Alloc( da );
|
||||||
FailedRespondPin = GCHandle.Alloc( db, GCHandleType.Pinned );
|
FailedRespondPin = GCHandle.Alloc( db );
|
||||||
CompletePin = GCHandle.Alloc( dc, GCHandleType.Pinned );
|
CompletePin = GCHandle.Alloc( dc );
|
||||||
|
|
||||||
var t = new StdVTable()
|
var t = new StdVTable()
|
||||||
{
|
{
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -317,9 +317,9 @@ namespace Generator
|
|||||||
WriteLine( "//" );
|
WriteLine( "//" );
|
||||||
WriteLine( "// Allocate a handle to each function, so they don't get disposed" );
|
WriteLine( "// Allocate a handle to each function, so they don't get disposed" );
|
||||||
WriteLine( "//" );
|
WriteLine( "//" );
|
||||||
WriteLine( "handle.FuncA = GCHandle.Alloc( funcA, GCHandleType.Pinned );" );
|
WriteLine( "handle.FuncA = GCHandle.Alloc( funcA );" );
|
||||||
WriteLine( "handle.FuncB = GCHandle.Alloc( funcB, GCHandleType.Pinned );" );
|
WriteLine( "handle.FuncB = GCHandle.Alloc( funcB );" );
|
||||||
WriteLine( "handle.FuncC = GCHandle.Alloc( funcC, GCHandleType.Pinned );" );
|
WriteLine( "handle.FuncC = GCHandle.Alloc( funcC );" );
|
||||||
WriteLine();
|
WriteLine();
|
||||||
|
|
||||||
WriteLine( "//" );
|
WriteLine( "//" );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user