Microtransaction callback (requested, but untested)

This commit is contained in:
Garry Newman 2017-06-09 10:30:43 +01:00
parent 67fd7fe00a
commit 303da3753d
2 changed files with 54 additions and 0 deletions

View File

@ -58,6 +58,7 @@ public partial class Client : BaseSteamworks
public App App { get; private set; }
public Achievements Achievements { get; private set; }
public Stats Stats { get; private set; }
public MicroTransactions MicroTransactions { get; private set; }
public Client( uint appId )
{
@ -87,6 +88,7 @@ public Client( uint appId )
App = new App( this );
Stats = new Stats( this );
Achievements = new Achievements( this );
MicroTransactions = new MicroTransactions( this );
Workshop.friends = Friends;
@ -105,6 +107,8 @@ public Client( uint appId )
CurrentLanguage = native.apps.GetCurrentGameLanguage();
AvailableLanguages = native.apps.GetAvailableGameLanguages().Split( new[] {';'}, StringSplitOptions.RemoveEmptyEntries ); // TODO: Assumed colon separated
//
// Run update, first call does some initialization
//
@ -168,6 +172,12 @@ public override void Dispose()
Achievements = null;
}
if ( MicroTransactions != null )
{
MicroTransactions.Dispose();
MicroTransactions = null;
}
if ( Instance == this )
{
Instance = null;

View File

@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using SteamNative;
namespace Facepunch.Steamworks
{
public class MicroTransactions : IDisposable
{
internal Client client;
public delegate void AuthorizationResponse( bool authorized, int appId, ulong orderId );
/// <summary>
/// Called on the MicroTxnAuthorizationResponse_t event
/// </summary>
public event AuthorizationResponse OnAuthorizationResponse;
internal MicroTransactions( Client c )
{
client = c;
SteamNative.MicroTxnAuthorizationResponse_t.RegisterCallback( client, onMicroTxnAuthorizationResponse );
}
private void onMicroTxnAuthorizationResponse( MicroTxnAuthorizationResponse_t arg1, bool arg2 )
{
if ( OnAuthorizationResponse != null )
{
OnAuthorizationResponse( arg1.Authorized == 1, (int) arg1.AppID, arg1.OrderID );
}
throw new NotImplementedException();
}
public void Dispose()
{
client = null;
}
}
}