Unstable 1.1.14.0
This commit is contained in:
@@ -17,34 +17,59 @@ namespace Steamworks
|
||||
{
|
||||
internal static ISteamUGC? Internal => Interface as ISteamUGC;
|
||||
|
||||
internal override void InitializeInterface( bool server )
|
||||
internal override bool InitializeInterface( bool server )
|
||||
{
|
||||
SetInterface( server, new ISteamUGC( server ) );
|
||||
if ( Interface is null || Interface.Self == IntPtr.Zero ) return false;
|
||||
|
||||
InstallEvents( server );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
internal static void InstallEvents( bool server )
|
||||
{
|
||||
Dispatch.Install<DownloadItemResult_t>( x =>
|
||||
{
|
||||
if (x.AppID == SteamClient.AppId)
|
||||
if ( x.AppID == SteamClient.AppId )
|
||||
{
|
||||
OnDownloadItemResult?.Invoke(x.Result, x.PublishedFileId);
|
||||
}
|
||||
}, server );
|
||||
Dispatch.Install<ItemInstalled_t>(x =>
|
||||
{
|
||||
if (x.AppID == SteamClient.AppId)
|
||||
{
|
||||
GlobalOnItemInstalled?.Invoke(x.PublishedFileId);
|
||||
OnDownloadItemResult?.Invoke( x.Result, x.PublishedFileId );
|
||||
}
|
||||
}, server);
|
||||
Dispatch.Install<RemoteStoragePublishedFileSubscribed_t>( x =>
|
||||
{
|
||||
if ( x.AppID == SteamClient.AppId )
|
||||
{
|
||||
OnItemSubscribed?.Invoke( x.AppID.Value, x.PublishedFileId );
|
||||
}
|
||||
}, server );
|
||||
Dispatch.Install<RemoteStoragePublishedFileUnsubscribed_t>( x =>
|
||||
{
|
||||
if ( x.AppID == SteamClient.AppId )
|
||||
{
|
||||
OnItemUnsubscribed?.Invoke( x.AppID.Value, x.PublishedFileId );
|
||||
}
|
||||
}, server );
|
||||
Dispatch.Install<ItemInstalled_t>( x =>
|
||||
{
|
||||
if ( x.AppID == SteamClient.AppId )
|
||||
{
|
||||
OnItemInstalled?.Invoke( x.AppID.Value, x.PublishedFileId );
|
||||
}
|
||||
}, server );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Posted after Download call
|
||||
/// Invoked after an item is downloaded.
|
||||
/// </summary>
|
||||
public static event Action<Result, ulong>? OnDownloadItemResult;
|
||||
public static event Action<Result, PublishedFileId>? OnDownloadItemResult;
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when a new item is subscribed.
|
||||
/// </summary>
|
||||
public static event Action<AppId, PublishedFileId>? OnItemSubscribed;
|
||||
public static event Action<AppId, PublishedFileId>? OnItemUnsubscribed;
|
||||
public static event Action<AppId, PublishedFileId>? OnItemInstalled;
|
||||
|
||||
public static async Task<bool> DeleteFileAsync( PublishedFileId fileId )
|
||||
{
|
||||
@@ -54,29 +79,29 @@ namespace Steamworks
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Start downloading this item. You'll get notified of completion via OnDownloadItemResult.
|
||||
/// Start downloading this item. You'll get notified of completion via <see cref="OnDownloadItemResult"/>.
|
||||
/// </summary>
|
||||
/// <param name="fileId">The ID of the file you want to download</param>
|
||||
/// <param name="highPriority">If true this should go straight to the top of the download list</param>
|
||||
/// <returns>true if nothing went wrong and the download is started</returns>
|
||||
/// <param name="fileId">The ID of the file to download.</param>
|
||||
/// <param name="highPriority">If <see langword="true"/> this should go straight to the top of the download list.</param>
|
||||
/// <returns><see langword="true"/> if nothing went wrong and the download is started.</returns>
|
||||
public static bool Download( PublishedFileId fileId, bool highPriority = false )
|
||||
{
|
||||
return Internal != null && Internal.DownloadItem( fileId, highPriority );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Will attempt to download this item asyncronously - allowing you to instantly react to its installation
|
||||
/// Will attempt to download this item asyncronously - allowing you to instantly react to its installation.
|
||||
/// </summary>
|
||||
/// <param name="fileId">The ID of the file you want to download</param>
|
||||
/// <param name="fileId">The ID of the file you download.</param>
|
||||
/// <param name="progress">An optional callback</param>
|
||||
/// <param name="ct">Allows you to send a message to cancel the download anywhere during the process</param>
|
||||
/// <param name="millisecondsUpdateDelay">How often to call the progress function</param>
|
||||
/// <returns>true if downloaded and installed correctly</returns>
|
||||
/// <param name="ct">Allows to send a message to cancel the download anywhere during the process.</param>
|
||||
/// <param name="milisecondsUpdateDelay">How often to call the progress function.</param>
|
||||
/// <returns><see langword="true"/> if downloaded and installed properly.</returns>
|
||||
public static async Task<bool> DownloadAsync(
|
||||
PublishedFileId fileId,
|
||||
Action<float>? progress = null,
|
||||
int millisecondsUpdateDelay = 60,
|
||||
CancellationToken? ct = null)
|
||||
PublishedFileId fileId,
|
||||
Action<float>? progress = null,
|
||||
int millisecondsUpdateDelay = 60,
|
||||
CancellationToken? ct = default )
|
||||
{
|
||||
var item = new Steamworks.Ugc.Item( fileId );
|
||||
|
||||
@@ -92,7 +117,7 @@ namespace Steamworks
|
||||
|
||||
Result downloadStartResult = Result.None;
|
||||
|
||||
void onDownloadFinished(Result r, ulong id)
|
||||
void onDownloadFinished(Result r, PublishedFileId id)
|
||||
{
|
||||
if (id != item.Id) { return; }
|
||||
downloadStartResult = r;
|
||||
@@ -143,7 +168,7 @@ namespace Steamworks
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Utility function to fetch a single item. Internally this uses Ugc.FileQuery -
|
||||
/// Utility function to fetch a single item. Internally this uses <c>Ugc.FileQuery</c> -
|
||||
/// which you can use to query multiple items if you need to.
|
||||
/// </summary>
|
||||
public static async Task<Ugc.Item?> QueryFileAsync( PublishedFileId fileId )
|
||||
@@ -183,8 +208,6 @@ namespace Steamworks
|
||||
return result?.Result == Result.OK;
|
||||
}
|
||||
|
||||
public static Action<ulong>? GlobalOnItemInstalled;
|
||||
|
||||
public static uint NumSubscribedItems { get { return Internal?.GetNumSubscribedItems() ?? 0; } }
|
||||
|
||||
public static PublishedFileId[] GetSubscribedItems()
|
||||
@@ -195,6 +218,36 @@ namespace Steamworks
|
||||
Internal.GetSubscribedItems(ids, numSubscribed);
|
||||
return ids;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Suspends all workshop downloads.
|
||||
/// Downloads will be suspended until you resume them by calling <see cref="ResumeDownloads"/> or when the game ends.
|
||||
/// </summary>
|
||||
public static void SuspendDownloads() => Internal?.SuspendDownloads(true);
|
||||
|
||||
/// <summary>
|
||||
/// Resumes all workshop downloads.
|
||||
/// </summary>
|
||||
public static void ResumeDownloads() => Internal?.SuspendDownloads(false);
|
||||
|
||||
/// <summary>
|
||||
/// Show the app's latest Workshop EULA to the user in an overlay window, where they can accept it or not.
|
||||
/// </summary>
|
||||
public static bool ShowWorkshopEula()
|
||||
{
|
||||
return Internal != null && Internal.ShowWorkshopEULA();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve information related to the user's acceptance or not of the app's specific Workshop EULA.
|
||||
/// </summary>
|
||||
public static async Task<bool?> GetWorkshopEulaStatus()
|
||||
{
|
||||
if ( Internal is null ) { return null; }
|
||||
var status = await Internal.GetWorkshopEULAStatus();
|
||||
return status?.Accepted;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user