Merge pull request #475 from kamyker/k7-addit-prevs

Added ugc addtional previews
This commit is contained in:
Garry Newman 2020-09-04 10:34:35 +01:00 committed by GitHub
commit b71c83ad13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 100 additions and 3 deletions

View File

@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Steamworks.Data
{
public struct UgcAdditionalPreview
{
internal UgcAdditionalPreview( string urlOrVideoID, string originalFileName, ItemPreviewType itemPreviewType )
{
this.UrlOrVideoID = urlOrVideoID;
this.OriginalFileName = originalFileName;
this.ItemPreviewType = itemPreviewType;
}
public string UrlOrVideoID { get; private set; }
public string OriginalFileName { get; private set; }
internal ItemPreviewType ItemPreviewType { get; private set; }
/// <summary>
/// Flags that specify the type of preview an item has:
/// Image = 0,
/// YouTubeVideo = 1,
/// Sketchfab = 2,
/// EnvironmentMap_HorizontalCross = 3,
/// EnvironmentMap_LatLong = 4,
/// ReservedMax = 255
/// </summary>
public int GetItemPreviewType() => (int)ItemPreviewType;
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 48f086235d5dbeb44bccbb40802e30fb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -108,6 +108,15 @@ namespace Steamworks.Ugc
/// The number of downvotes of this item /// The number of downvotes of this item
/// </summary> /// </summary>
public uint VotesDown => details.VotesDown; public uint VotesDown => details.VotesDown;
/// <summary>
/// Dependencies/children of this item or collection, available only from WithDependencies(true) queries
/// </summary>
public PublishedFileId[] Children;
/// <summary>
/// Additional previews of this item or collection, available only from WithAdditionalPreviews(true) queries
/// </summary>
public UgcAdditionalPreview[] AdditionalPreviews { get; internal set; }
public bool IsInstalled => (State & ItemState.Installed) == ItemState.Installed; public bool IsInstalled => (State & ItemState.Installed) == ItemState.Installed;
public bool IsDownloading => (State & ItemState.Downloading) == ItemState.Downloading; public bool IsDownloading => (State & ItemState.Downloading) == ItemState.Downloading;
@ -382,7 +391,19 @@ namespace Steamworks.Ugc
{ {
return new Ugc.Editor( Id ); return new Ugc.Editor( Id );
} }
public async Task<bool> AddDependency( PublishedFileId child )
{
var r = await SteamUGC.Internal.AddDependency( Id, child );
return r?.Result == Result.OK;
}
public async Task<bool> RemoveDependency( PublishedFileId child )
{
var r = await SteamUGC.Internal.RemoveDependency( Id, child );
return r?.Result == Result.OK;
}
public Result Result => details.Result; public Result Result => details.Result;
} }
} }

View File

@ -152,6 +152,8 @@ namespace Steamworks.Ugc
ReturnsKeyValueTags = WantsReturnKeyValueTags ?? false, ReturnsKeyValueTags = WantsReturnKeyValueTags ?? false,
ReturnsDefaultStats = WantsDefaultStats ?? true, //true by default ReturnsDefaultStats = WantsDefaultStats ?? true, //true by default
ReturnsMetadata = WantsReturnMetadata ?? false, ReturnsMetadata = WantsReturnMetadata ?? false,
ReturnsChildren = WantsReturnChildren ?? false,
ReturnsAdditionalPreviews = WantsReturnAdditionalPreviews ?? false,
}; };
} }

View File

@ -15,6 +15,8 @@ namespace Steamworks.Ugc
internal bool ReturnsKeyValueTags; internal bool ReturnsKeyValueTags;
internal bool ReturnsDefaultStats; internal bool ReturnsDefaultStats;
internal bool ReturnsMetadata; internal bool ReturnsMetadata;
internal bool ReturnsChildren;
internal bool ReturnsAdditionalPreviews;
public IEnumerable<Item> Entries public IEnumerable<Item> Entries
{ {
@ -73,8 +75,36 @@ namespace Steamworks.Ugc
} }
} }
// TODO GetQueryUGCAdditionalPreview uint numChildren = item.details.NumChildren;
// TODO GetQueryUGCChildren if ( ReturnsChildren && numChildren > 0 )
{
var children = new PublishedFileId[numChildren];
if ( SteamUGC.Internal.GetQueryUGCChildren( Handle, i, children, numChildren ) )
{
item.Children = children;
}
}
if ( ReturnsAdditionalPreviews )
{
var previewsCount = SteamUGC.Internal.GetQueryUGCNumAdditionalPreviews( Handle, i );
if ( previewsCount > 0 )
{
item.AdditionalPreviews = new UgcAdditionalPreview[previewsCount];
for ( uint j = 0; j < previewsCount; j++ )
{
string previewUrlOrVideo;
string originalFileName; //what is this???
ItemPreviewType previewType = default;
if ( SteamUGC.Internal.GetQueryUGCAdditionalPreview(
Handle, i, j, out previewUrlOrVideo, out originalFileName, ref previewType ) )
{
item.AdditionalPreviews[j] = new UgcAdditionalPreview(
previewUrlOrVideo, originalFileName, previewType );
}
}
}
}
yield return item; yield return item;
} }