diff --git a/Facepunch.Steamworks/Interfaces/Workshop.Item.cs b/Facepunch.Steamworks/Interfaces/Workshop.Item.cs index 70b3a59..96eaaf7 100644 --- a/Facepunch.Steamworks/Interfaces/Workshop.Item.cs +++ b/Facepunch.Steamworks/Interfaces/Workshop.Item.cs @@ -58,14 +58,29 @@ namespace Facepunch.Steamworks } workshop.OnFileDownloaded += OnFileDownloaded; + workshop.OnItemInstalled += OnItemInstalled; UpdateState(); Downloading = true; } private void OnFileDownloaded( ulong fileid, Callbacks.Result result ) { + workshop.OnFileDownloaded -= OnFileDownloaded; UpdateState(); + + if ( result == Callbacks.Result.OK ) + Downloading = false; + } + + private void OnItemInstalled( ulong fileid ) + { + + workshop.OnItemInstalled -= OnItemInstalled; + UpdateState(); + + Downloading = false; + Installed = true; } public ulong BytesDownloaded { get { UpdateDownloadProgress(); return _BytesDownloaded; } } @@ -110,19 +125,23 @@ namespace Facepunch.Steamworks if ( Installed && Directory == null ) { + Size = 0; + Directory = null; + ulong sizeOnDisk; string folder; uint timestamp; - workshop.ugc.GetItemInstallInfo( Id, out sizeOnDisk, out folder, out timestamp ); - - Directory = new DirectoryInfo( folder ); - Size = sizeOnDisk; - - if ( !Directory.Exists ) + if ( workshop.ugc.GetItemInstallInfo( Id, out sizeOnDisk, out folder, out timestamp ) ) { - Size = 0; - Directory = null; - Installed = false; + Directory = new DirectoryInfo( folder ); + Size = sizeOnDisk; + + if ( !Directory.Exists ) + { + Size = 0; + Directory = null; + Installed = false; + } } } } diff --git a/Facepunch.Steamworks/Interop/Callback.cs b/Facepunch.Steamworks/Interop/Callback.cs index 8b3e6bf..c6667f8 100644 --- a/Facepunch.Steamworks/Interop/Callback.cs +++ b/Facepunch.Steamworks/Interop/Callback.cs @@ -89,6 +89,9 @@ namespace Facepunch.Steamworks.Interop private void OnRunCallback( IntPtr ptr ) { + if ( callbackPin == null ) throw new System.Exception( "Callback wasn't pinned!" ); + if ( vTablePtr == IntPtr.Zero ) throw new System.Exception( "vTablePtr wasn't pinned!" ); + T data = (T) Marshal.PtrToStructure( ptr, typeof(T) ); Function( data ); } @@ -96,6 +99,7 @@ namespace Facepunch.Steamworks.Interop private int GetSize() { + Console.WriteLine( "GET SIZE CALLED" ); throw new System.NotImplementedException(); } diff --git a/Facepunch.Steamworks/Interop/steam_api_interop.cs b/Facepunch.Steamworks/Interop/steam_api_interop.cs index 7f6de1e..ad89eec 100644 --- a/Facepunch.Steamworks/Interop/steam_api_interop.cs +++ b/Facepunch.Steamworks/Interop/steam_api_interop.cs @@ -5986,14 +5986,13 @@ namespace Valve.Steamworks return result; } - static System.Text.StringBuilder StringBuffer = new System.Text.StringBuilder(1024 * 16); - internal override bool GetItemInstallInfo( ulong nPublishedFileID, out ulong punSizeOnDisk, out string pchFolder, out uint punTimeStamp ) { CheckIfUsable(); punSizeOnDisk = 0; punTimeStamp = 0; - + + var StringBuffer = new System.Text.StringBuilder(2048); bool result = NativeEntrypoints.SteamAPI_ISteamUGC_GetItemInstallInfo (m_pSteamUGC,nPublishedFileID, out punSizeOnDisk, StringBuffer, (uint)StringBuffer.Capacity, out punTimeStamp ); pchFolder = StringBuffer.ToString(); return result;