Workshop fixes

This commit is contained in:
Garry Newman 2016-10-09 20:07:59 +01:00
parent f51ca35a34
commit f0e09d4331
3 changed files with 34 additions and 12 deletions

View File

@ -58,14 +58,29 @@ namespace Facepunch.Steamworks
} }
workshop.OnFileDownloaded += OnFileDownloaded; workshop.OnFileDownloaded += OnFileDownloaded;
workshop.OnItemInstalled += OnItemInstalled;
UpdateState(); UpdateState();
Downloading = true; Downloading = true;
} }
private void OnFileDownloaded( ulong fileid, Callbacks.Result result ) private void OnFileDownloaded( ulong fileid, Callbacks.Result result )
{ {
workshop.OnFileDownloaded -= OnFileDownloaded; workshop.OnFileDownloaded -= OnFileDownloaded;
UpdateState(); 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; } } public ulong BytesDownloaded { get { UpdateDownloadProgress(); return _BytesDownloaded; } }
@ -110,19 +125,23 @@ namespace Facepunch.Steamworks
if ( Installed && Directory == null ) if ( Installed && Directory == null )
{ {
Size = 0;
Directory = null;
ulong sizeOnDisk; ulong sizeOnDisk;
string folder; string folder;
uint timestamp; uint timestamp;
workshop.ugc.GetItemInstallInfo( Id, out sizeOnDisk, out folder, out timestamp ); if ( workshop.ugc.GetItemInstallInfo( Id, out sizeOnDisk, out folder, out timestamp ) )
Directory = new DirectoryInfo( folder );
Size = sizeOnDisk;
if ( !Directory.Exists )
{ {
Size = 0; Directory = new DirectoryInfo( folder );
Directory = null; Size = sizeOnDisk;
Installed = false;
if ( !Directory.Exists )
{
Size = 0;
Directory = null;
Installed = false;
}
} }
} }
} }

View File

@ -89,6 +89,9 @@ namespace Facepunch.Steamworks.Interop
private void OnRunCallback( IntPtr ptr ) 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) ); T data = (T) Marshal.PtrToStructure( ptr, typeof(T) );
Function( data ); Function( data );
} }
@ -96,6 +99,7 @@ namespace Facepunch.Steamworks.Interop
private int GetSize() private int GetSize()
{ {
Console.WriteLine( "GET SIZE CALLED" );
throw new System.NotImplementedException(); throw new System.NotImplementedException();
} }

View File

@ -5986,14 +5986,13 @@ namespace Valve.Steamworks
return result; 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 ) internal override bool GetItemInstallInfo( ulong nPublishedFileID, out ulong punSizeOnDisk, out string pchFolder, out uint punTimeStamp )
{ {
CheckIfUsable(); CheckIfUsable();
punSizeOnDisk = 0; punSizeOnDisk = 0;
punTimeStamp = 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 ); bool result = NativeEntrypoints.SteamAPI_ISteamUGC_GetItemInstallInfo (m_pSteamUGC,nPublishedFileID, out punSizeOnDisk, StringBuffer, (uint)StringBuffer.Capacity, out punTimeStamp );
pchFolder = StringBuffer.ToString(); pchFolder = StringBuffer.ToString();
return result; return result;