mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2025-04-26 23:09:37 +03:00
RichPresence
This commit is contained in:
parent
e4ddd1fe6c
commit
b134c8708f
@ -1,56 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading;
|
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
||||||
|
|
||||||
namespace Facepunch.Steamworks.Test
|
|
||||||
{
|
|
||||||
[TestClass]
|
|
||||||
[DeploymentItem( "steam_api64.dll" )]
|
|
||||||
public class RichPresence
|
|
||||||
{
|
|
||||||
[TestMethod]
|
|
||||||
public void MissingKeyIsNull()
|
|
||||||
{
|
|
||||||
using ( var client = new Steamworks.Client( 252490 ) )
|
|
||||||
{
|
|
||||||
var key = client.User.GetRichPresence( "Missing Key" );
|
|
||||||
Assert.IsNull( key );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void ReadBackSetKey()
|
|
||||||
{
|
|
||||||
using ( var client = new Steamworks.Client( 252490 ) )
|
|
||||||
{
|
|
||||||
var success = client.User.SetRichPresence( "One", "Two" );
|
|
||||||
Assert.IsTrue( success );
|
|
||||||
|
|
||||||
var value = client.User.GetRichPresence( "One" );
|
|
||||||
Assert.IsNotNull( value );
|
|
||||||
Assert.AreEqual( value, "Two" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void ClearingKeys()
|
|
||||||
{
|
|
||||||
using ( var client = new Steamworks.Client( 252490 ) )
|
|
||||||
{
|
|
||||||
var success = client.User.SetRichPresence( "One", "Two" );
|
|
||||||
Assert.IsTrue( success );
|
|
||||||
|
|
||||||
var value = client.User.GetRichPresence( "One" );
|
|
||||||
Assert.IsNotNull( value );
|
|
||||||
Assert.AreEqual( value, "Two" );
|
|
||||||
|
|
||||||
client.User.ClearRichPresence();
|
|
||||||
|
|
||||||
value = client.User.GetRichPresence( "One" );
|
|
||||||
Assert.IsNull( value );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -93,7 +93,6 @@
|
|||||||
<Compile Include="Client\UtilsTest.cs" />
|
<Compile Include="Client\UtilsTest.cs" />
|
||||||
<Compile Include="Client\ClientTest.cs" />
|
<Compile Include="Client\ClientTest.cs" />
|
||||||
<Compile Include="Client\LobbyTest.cs" />
|
<Compile Include="Client\LobbyTest.cs" />
|
||||||
<Compile Include="Client\RichPresenceTest.cs" />
|
|
||||||
<Compile Include="Client\LeaderboardTest.cs" />
|
<Compile Include="Client\LeaderboardTest.cs" />
|
||||||
<Compile Include="Client\AppTest.cs" />
|
<Compile Include="Client\AppTest.cs" />
|
||||||
<Compile Include="Client\RemoteStorageTest.cs" />
|
<Compile Include="Client\RemoteStorageTest.cs" />
|
||||||
|
@ -63,7 +63,6 @@ namespace Facepunch.Steamworks
|
|||||||
public Achievements Achievements { get; private set; }
|
public Achievements Achievements { get; private set; }
|
||||||
public Stats Stats { get; private set; }
|
public Stats Stats { get; private set; }
|
||||||
public MicroTransactions MicroTransactions { get; private set; }
|
public MicroTransactions MicroTransactions { get; private set; }
|
||||||
public User User { get; private set; }
|
|
||||||
public RemoteStorage RemoteStorage { get; private set; }
|
public RemoteStorage RemoteStorage { get; private set; }
|
||||||
|
|
||||||
public Client( uint appId ) : base( appId )
|
public Client( uint appId ) : base( appId )
|
||||||
@ -106,7 +105,6 @@ namespace Facepunch.Steamworks
|
|||||||
Stats = new Stats( this );
|
Stats = new Stats( this );
|
||||||
Achievements = new Achievements( this );
|
Achievements = new Achievements( this );
|
||||||
MicroTransactions = new MicroTransactions( this );
|
MicroTransactions = new MicroTransactions( this );
|
||||||
User = new User( this );
|
|
||||||
RemoteStorage = new RemoteStorage( this );
|
RemoteStorage = new RemoteStorage( this );
|
||||||
|
|
||||||
Workshop.friends = Friends;
|
Workshop.friends = Friends;
|
||||||
@ -201,12 +199,6 @@ namespace Facepunch.Steamworks
|
|||||||
MicroTransactions = null;
|
MicroTransactions = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( User != null )
|
|
||||||
{
|
|
||||||
User.Dispose();
|
|
||||||
User = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( RemoteStorage != null )
|
if ( RemoteStorage != null )
|
||||||
{
|
{
|
||||||
RemoteStorage.Dispose();
|
RemoteStorage.Dispose();
|
||||||
|
@ -1,57 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Collections.Specialized;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Text;
|
|
||||||
using SteamNative;
|
|
||||||
|
|
||||||
namespace Facepunch.Steamworks
|
|
||||||
{
|
|
||||||
public class User : IDisposable
|
|
||||||
{
|
|
||||||
internal Client client;
|
|
||||||
internal Dictionary<string, string> richPresence = new Dictionary<string, string>();
|
|
||||||
|
|
||||||
internal User( Client c )
|
|
||||||
{
|
|
||||||
client = c;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
client = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Find a rich presence value by key for current user. Will be null if not found.
|
|
||||||
/// </summary>
|
|
||||||
public string GetRichPresence( string key )
|
|
||||||
{
|
|
||||||
if ( richPresence.TryGetValue( key, out var val ) )
|
|
||||||
return val;
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Sets a rich presence value by key for current user.
|
|
||||||
/// </summary>
|
|
||||||
public bool SetRichPresence( string key, string value )
|
|
||||||
{
|
|
||||||
richPresence[key] = value;
|
|
||||||
return client.native.friends.SetRichPresence( key, value );
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clears all of the current user's rich presence data.
|
|
||||||
/// </summary>
|
|
||||||
public void ClearRichPresence()
|
|
||||||
{
|
|
||||||
richPresence.Clear();
|
|
||||||
client.native.friends.ClearRichPresence();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -19,12 +19,18 @@ namespace Steamworks
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
if ( _internal == null )
|
if ( _internal == null )
|
||||||
|
{
|
||||||
_internal = new Internal.ISteamFriends();
|
_internal = new Internal.ISteamFriends();
|
||||||
|
|
||||||
|
richPresence = new Dictionary<string, string>();
|
||||||
|
}
|
||||||
|
|
||||||
return _internal;
|
return _internal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Dictionary<string, string> richPresence;
|
||||||
|
|
||||||
internal static void InstallEvents()
|
internal static void InstallEvents()
|
||||||
{
|
{
|
||||||
//new Event<BroadcastUploadStart_t>( x => OnBroadcastStarted?.Invoke() );
|
//new Event<BroadcastUploadStart_t>( x => OnBroadcastStarted?.Invoke() );
|
||||||
@ -161,5 +167,34 @@ namespace Steamworks
|
|||||||
return Utils.GetImage( imageid );
|
return Utils.GetImage( imageid );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Find a rich presence value by key for current user. Will be null if not found.
|
||||||
|
/// </summary>
|
||||||
|
public static string GetRichPresence( string key )
|
||||||
|
{
|
||||||
|
if ( richPresence.TryGetValue( key, out var val ) )
|
||||||
|
return val;
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets a rich presence value by key for current user.
|
||||||
|
/// </summary>
|
||||||
|
public static bool SetRichPresence( string key, string value )
|
||||||
|
{
|
||||||
|
richPresence[key] = value;
|
||||||
|
return Internal.SetRichPresence( key, value );
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clears all of the current user's rich presence data.
|
||||||
|
/// </summary>
|
||||||
|
public static void ClearRichPresence()
|
||||||
|
{
|
||||||
|
richPresence.Clear();
|
||||||
|
Internal.ClearRichPresence();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user