using OmegaLeo.HelperLib.Shared.Attributes; namespace OmegaLeo.HelperLib.Steamworks { [Documentation(nameof(SteamUgcSubmitItemUpdateResult), "Result of ISteamUGC::SubmitItemUpdate (SubmitItemUpdateResult_t).", null, null)] public sealed class SteamUgcSubmitItemUpdateResult { [Documentation(nameof(Result), "Numeric EResult value (1 = OK).", null, null)] public int Result { get; private set; } [Documentation(nameof(UserNeedsToAcceptWorkshopLegalAgreement), "True when the user must accept the Workshop legal agreement before the item becomes visible.", null, null)] public bool UserNeedsToAcceptWorkshopLegalAgreement { get; private set; } [Documentation(nameof(PublishedFileId), "The updated Workshop item ID.", null, null)] public ulong PublishedFileId { get; private set; } [Documentation(nameof(IoFailure), "True when the result could not be retrieved; the other fields are then not valid.", null, null)] public bool IoFailure { get; private set; } [Documentation(nameof(IsSuccess), "True when the result was retrieved and EResult is OK.", null, null)] public bool IsSuccess => !IoFailure && Result == 1; internal static SteamUgcSubmitItemUpdateResult FromCallResult(SteamApiCallResult callResult) { // SubmitItemUpdateResult_t { EResult m_eResult; bool m_bUserNeedsToAcceptWorkshopLegalAgreement; PublishedFileId_t m_nPublishedFileId; } // Offsets 0/4/8 under both pack 4 and pack 8. return new SteamUgcSubmitItemUpdateResult { IoFailure = IsFailure(callResult, SteamCallbackIds.SubmitItemUpdateResult, 16), Result = callResult.ReadInt32(0), UserNeedsToAcceptWorkshopLegalAgreement = callResult.ReadBoolean(4), PublishedFileId = callResult.ReadUInt64(8) }; } internal static bool IsFailure(SteamApiCallResult callResult, int expectedCallbackId, int minimumSize) { return callResult.IoFailure || callResult.CallbackId != expectedCallbackId || callResult.Payload.Length < minimumSize; } } [Documentation(nameof(SteamUgcCreateItemResult), "Result of ISteamUGC::CreateItem (CreateItemResult_t).", null, null)] public sealed class SteamUgcCreateItemResult { [Documentation(nameof(Result), "Numeric EResult value (1 = OK).", null, null)] public int Result { get; private set; } [Documentation(nameof(PublishedFileId), "The new Workshop item ID. Pass it to StartItemUpdate to upload content.", null, null)] public ulong PublishedFileId { get; private set; } [Documentation(nameof(UserNeedsToAcceptWorkshopLegalAgreement), "True when the user must accept the Workshop legal agreement before the item becomes visible.", null, null)] public bool UserNeedsToAcceptWorkshopLegalAgreement { get; private set; } [Documentation(nameof(IoFailure), "True when the result could not be retrieved; the other fields are then not valid.", null, null)] public bool IoFailure { get; private set; } [Documentation(nameof(IsSuccess), "True when the result was retrieved and EResult is OK.", null, null)] public bool IsSuccess => !IoFailure && Result == 1; internal static SteamUgcCreateItemResult FromCallResult(SteamApiCallResult callResult) { // CreateItemResult_t { EResult m_eResult; PublishedFileId_t m_nPublishedFileId; bool m_bUserNeedsToAcceptWorkshopLegalAgreement; } // Pack 8 (Windows): offsets 0/8/16, size 24. Pack 4 (Linux/macOS): offsets 0/4/12, size 16. var large = SteamCallbackDispatcher.UsesLargeCallbackPack; var idOffset = large ? 8 : 4; var legalOffset = large ? 16 : 12; return new SteamUgcCreateItemResult { IoFailure = SteamUgcSubmitItemUpdateResult.IsFailure(callResult, SteamCallbackIds.CreateItemResult, legalOffset + 1), Result = callResult.ReadInt32(0), PublishedFileId = callResult.ReadUInt64(idOffset), UserNeedsToAcceptWorkshopLegalAgreement = callResult.ReadBoolean(legalOffset) }; } } [Documentation(nameof(SteamUgcQueryCompletedResult), "Result of ISteamUGC::SendQueryUGCRequest (SteamUGCQueryCompleted_t). Release the query handle with ReleaseQueryUgcRequest when done.", null, null)] public sealed class SteamUgcQueryCompletedResult { [Documentation(nameof(QueryHandle), "The UGC query handle the results belong to.", null, null)] public ulong QueryHandle { get; private set; } [Documentation(nameof(Result), "Numeric EResult value (1 = OK).", null, null)] public int Result { get; private set; } [Documentation(nameof(NumResultsReturned), "Number of items returned in this page.", null, null)] public uint NumResultsReturned { get; private set; } [Documentation(nameof(TotalMatchingResults), "Total number of items matching the query.", null, null)] public uint TotalMatchingResults { get; private set; } [Documentation(nameof(CachedData), "True when the results came from the local cache.", null, null)] public bool CachedData { get; private set; } [Documentation(nameof(NextCursor), "Cursor for the next page (cursor-based queries only).", null, null)] public string NextCursor { get; private set; } = string.Empty; [Documentation(nameof(IoFailure), "True when the result could not be retrieved; the other fields are then not valid.", null, null)] public bool IoFailure { get; private set; } [Documentation(nameof(IsSuccess), "True when the result was retrieved and EResult is OK.", null, null)] public bool IsSuccess => !IoFailure && Result == 1; internal static SteamUgcQueryCompletedResult FromCallResult(SteamApiCallResult callResult) { // SteamUGCQueryCompleted_t { UGCQueryHandle_t m_handle; EResult m_eResult; uint32 m_unNumResultsReturned; // uint32 m_unTotalMatchingResults; bool m_bCachedData; char m_rgchNextCursor[256]; } // Offsets 0/8/12/16/20/21 under both pack 4 and pack 8. return new SteamUgcQueryCompletedResult { IoFailure = SteamUgcSubmitItemUpdateResult.IsFailure(callResult, SteamCallbackIds.SteamUgcQueryCompleted, 21), QueryHandle = callResult.ReadUInt64(0), Result = callResult.ReadInt32(8), NumResultsReturned = callResult.ReadUInt32(12), TotalMatchingResults = callResult.ReadUInt32(16), CachedData = callResult.ReadBoolean(20), NextCursor = callResult.ReadString(21, 256) }; } } }