v1.4.4
This commit is contained in:
commit
9c94d113d3
10260 changed files with 1237388 additions and 0 deletions
|
@ -0,0 +1,60 @@
|
|||
#include "StarUserGeneratedContentService_pc_steam.hpp"
|
||||
#include "StarLogging.hpp"
|
||||
#include "StarLexicalCast.hpp"
|
||||
|
||||
namespace Star {
|
||||
|
||||
SteamUserGeneratedContentService::SteamUserGeneratedContentService(PcPlatformServicesStatePtr)
|
||||
: m_callbackDownloadResult(this, &SteamUserGeneratedContentService::onDownloadResult) {};
|
||||
|
||||
StringList SteamUserGeneratedContentService::subscribedContentIds() const {
|
||||
List<PublishedFileId_t> contentIds(SteamUGC()->GetNumSubscribedItems(), {});
|
||||
SteamUGC()->GetSubscribedItems(contentIds.ptr(), contentIds.size());
|
||||
return contentIds.transformed([](PublishedFileId_t id) {
|
||||
return String(toString(id));
|
||||
});
|
||||
}
|
||||
|
||||
Maybe<String> SteamUserGeneratedContentService::contentDownloadDirectory(String const& contentId) const {
|
||||
PublishedFileId_t id = lexicalCast<PublishedFileId_t>(contentId);
|
||||
uint32 itemState = SteamUGC()->GetItemState(id);
|
||||
if (itemState & k_EItemStateInstalled) {
|
||||
char path[4096];
|
||||
if (SteamUGC()->GetItemInstallInfo(id, nullptr, path, sizeof(path), nullptr))
|
||||
return String(path);
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
bool SteamUserGeneratedContentService::triggerContentDownload() {
|
||||
List<PublishedFileId_t> contentIds(SteamUGC()->GetNumSubscribedItems(), {});
|
||||
SteamUGC()->GetSubscribedItems(contentIds.ptr(), contentIds.size());
|
||||
|
||||
for (uint64 contentId : contentIds) {
|
||||
if (!m_currentDownloadState.contains(contentId)) {
|
||||
uint32 itemState = SteamUGC()->GetItemState(contentId);
|
||||
if (!(itemState & k_EItemStateInstalled) || itemState & k_EItemStateNeedsUpdate) {
|
||||
SteamUGC()->DownloadItem(contentId, true);
|
||||
itemState = SteamUGC()->GetItemState(contentId);
|
||||
m_currentDownloadState[contentId] = !(itemState & k_EItemStateDownloading);
|
||||
} else {
|
||||
m_currentDownloadState[contentId] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool allDownloaded = true;
|
||||
for (auto const& p : m_currentDownloadState) {
|
||||
if (!p.second)
|
||||
allDownloaded = false;
|
||||
}
|
||||
|
||||
return allDownloaded;
|
||||
}
|
||||
|
||||
void SteamUserGeneratedContentService::onDownloadResult(DownloadItemResult_t* result) {
|
||||
m_currentDownloadState[result->m_nPublishedFileId] = true;
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue