Merge branch 'k3-item-dependency' into k7-addit-prevs

This commit is contained in:
kamyker 2020-08-28 13:09:55 +02:00
commit 11bc35f254
3 changed files with 28 additions and 2 deletions

View File

@ -108,6 +108,10 @@ public Item( PublishedFileId id ) : this()
/// 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;
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;
@ -383,6 +387,18 @@ public Ugc.Editor Edit()
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,7 @@ public Query WithFileId( params PublishedFileId[] files )
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,
}; };
} }

View File

@ -15,6 +15,7 @@ public struct ResultPage : System.IDisposable
internal bool ReturnsKeyValueTags; internal bool ReturnsKeyValueTags;
internal bool ReturnsDefaultStats; internal bool ReturnsDefaultStats;
internal bool ReturnsMetadata; internal bool ReturnsMetadata;
internal bool ReturnsChildren;
public IEnumerable<Item> Entries public IEnumerable<Item> Entries
{ {
@ -73,8 +74,16 @@ public IEnumerable<Item> Entries
} }
} }
uint numChildren = item.details.NumChildren;
if ( ReturnsChildren && numChildren > 0 )
{
var children = new PublishedFileId[numChildren];
if ( SteamUGC.Internal.GetQueryUGCChildren( Handle, i, children, numChildren ) )
{
item.Children = children;
}
}
// TODO GetQueryUGCAdditionalPreview // TODO GetQueryUGCAdditionalPreview
// TODO GetQueryUGCChildren
yield return item; yield return item;
} }