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.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,11 +125,14 @@ 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 );
if ( workshop.ugc.GetItemInstallInfo( Id, out sizeOnDisk, out folder, out timestamp ) )
{
Directory = new DirectoryInfo( folder );
Size = sizeOnDisk;
@ -126,6 +144,7 @@ namespace Facepunch.Steamworks
}
}
}
}
public void VoteUp()

View File

@ -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();
}

View File

@ -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;