void search_content() { handle = SteamUGC()->CreateQueryUserUGCRequest( SteamUser()->GetSteamID().GetAccountID(), k_EUserUGCList_Published, k_EUGCMatchingUGCType_Items, k_EUserUGCListSortOrder_CreationOrderDesc, 0, CHOWDREN_STEAM_APPID, 1); SteamAPICall_t call_handle = SteamUGC()->SendQueryUGCRequest(handle); content_call.Set(call_handle, this, &SubCallback::on_content_callback); }
UGCUpdateHandle_t CSteamCtx::UpdateItemStart (PublishedFileId_t FileId) const // UpdateItemStart // // Creates an update handle for the given item. { return SteamUGC()->StartItemUpdate(TRANSCENDENCE_APP_ID, FileId); }
void on_content_callback(SteamUGCQueryCompleted_t * result, bool fail) { if (fail || result->m_eResult != k_EResultOK) { (manager.frame->*finish_callback)(); return; } received = 0; ids.resize(result->m_unNumResultsReturned); details.resize(result->m_unNumResultsReturned); for (int i = 0; i < int(result->m_unNumResultsReturned); ++i) { SteamUGC()->GetQueryUGCResult(handle, i, &details[i]); ids[i] = details[i].m_nPublishedFileId; } SteamUGC()->ReleaseQueryUGCRequest(handle); finish(); }
void search_subs() { int count = std::min<int>(50, SteamUGC()->GetNumSubscribedItems()); if (count <= 0) { (manager.frame->*finish_callback)(); return; } received = 0; ids.resize(count); calls.resize(count); details.resize(count); SteamUGC()->GetSubscribedItems(&ids[0], count); SteamAPICall_t call_handle; for (int i = 0; i < count; ++i) { std::cout << "Requesting for " << ids[i] << std::endl; call_handle = SteamUGC()->RequestUGCDetails(ids[i], 0); calls[i].call.Set(call_handle, this, &SubCallback::on_callback); } }
bool CSteamCtx::GetOrCreateItem (DWORD dwUNID, PublishedFileId_t *retFileId, bool *retbCreated, CString *retsError) // GetOrCreateItem // // Looks for the given item by the current user and returns a fileId for it. // If necessary, we create it. { if (!ValidateConnected(retsError)) return false; CString sUNID = ComposeUNID(dwUNID); // Get a list of all items with the given UNID (there should only be one). TSortMap<CString, CString> Tags; Tags.Insert(FIELD_UNID, sUNID); TArray<SteamUGCDetails_t> List; if (!GetUserContent(Tags, List, retsError)) return false; // If we found some content, get the FileID PublishedFileId_t FileId; if (List.GetCount() > 0) { FileId = List[0].m_nPublishedFileId; if (retbCreated) *retbCreated = false; } // Otherwise, we need to create a new item else { // Create the item bool bAgreementRequired; if (!CreateItem(&FileId, &bAgreementRequired, retsError)) return false; // Associate an UNID with this item UGCUpdateHandle_t Update = SteamUGC()->StartItemUpdate(TRANSCENDENCE_APP_ID, FileId); if (!SteamUGC()->AddItemKeyValueTag(Update, (LPSTR)FIELD_UNID, (LPSTR)sUNID)) return false; if (!UpdateItem(Update, CONSTLIT("Extension created."), retsError)) return false; if (retbCreated) *retbCreated = true; } // Done if (retFileId) *retFileId = FileId; return true; }
DLL(ISteamUGC*) BS_SteamUGC() { return SteamUGC(); }