From 80a383730b1da1d5b6b11550227abffc636b9f06 Mon Sep 17 00:00:00 2001 From: Rohan Singh Date: Tue, 4 Dec 2018 13:39:47 -0500 Subject: [PATCH] Add Overlay.IsOpen --- Facepunch.Steamworks/Client.cs | 2 ++ Facepunch.Steamworks/Client/Overlay.cs | 31 +++++++++++++------------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/Facepunch.Steamworks/Client.cs b/Facepunch.Steamworks/Client.cs index 677dfaa..a518892 100644 --- a/Facepunch.Steamworks/Client.cs +++ b/Facepunch.Steamworks/Client.cs @@ -62,6 +62,7 @@ public partial class Client : BaseSteamworks public MicroTransactions MicroTransactions { get; private set; } public User User { get; private set; } public RemoteStorage RemoteStorage { get; private set; } + public Overlay Overlay { get; private set; } public Client( uint appId ) : base( appId ) { @@ -107,6 +108,7 @@ public Client( uint appId ) : base( appId ) MicroTransactions = new MicroTransactions( this ); User = new User( this ); RemoteStorage = new RemoteStorage( this ); + Overlay = new Overlay( this ); Workshop.friends = Friends; diff --git a/Facepunch.Steamworks/Client/Overlay.cs b/Facepunch.Steamworks/Client/Overlay.cs index 73da7fd..c322ff9 100644 --- a/Facepunch.Steamworks/Client/Overlay.cs +++ b/Facepunch.Steamworks/Client/Overlay.cs @@ -2,25 +2,10 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using SteamNative; namespace Facepunch.Steamworks { - public partial class Client : IDisposable - { - private Overlay _overlay; - - public Overlay Overlay - { - get - { - if ( _overlay == null ) - _overlay = new Overlay { client = this }; - - return _overlay; - } - } - } - public class Overlay { internal Client client; @@ -30,6 +15,20 @@ public bool Enabled get { return client.native.utils.IsOverlayEnabled(); } } + public bool IsOpen { get; private set; } + + internal Overlay( Client c ) + { + client = c; + + c.RegisterCallback( OverlayStateChange ); + } + + private void OverlayStateChange( GameOverlayActivated_t activation ) + { + IsOpen = activation.Active == 1; + } + public void OpenUserPage( string name, ulong steamid ) { client.native.friends.ActivateGameOverlayToUser( name, steamid ); } public void OpenProfile( ulong steamid ) { OpenUserPage( "steamid", steamid ); }