void OnRemoteStorageDownloadFileUGCResultPrimaryFile(RemoteStorageDownloadUGCResult_t pCallback, bool bIOFailure) { //GetPrimaryFile step 2 if (CallBackGetPrimaryFileResult != null) { try { if (pCallback.m_eResult == EResult.k_EResultOK) { byte[] Data = new byte[pCallback.m_nSizeInBytes]; SteamRemoteStorage.UGCRead(pCallback.m_hFile, Data, pCallback.m_nSizeInBytes, 0, EUGCReadAction.k_EUGCRead_Close); //Debug.Log("[" + RemoteStorageDownloadUGCResult_t.k_iCallback + " - RemoteStorageDownloadUGCResult] - " + pCallback.m_eResult + " -- " + pCallback.m_hFile + " -- " + pCallback.m_nAppID + " -- " + pCallback.m_nSizeInBytes + " -- " + pCallback.m_pchFileName + " -- " + pCallback.m_ulSteamIDOwner); Finish(Data, _PublishedFileId, true); } else { Finish(null, _PublishedFileId, false); LogManager.Warning("OnRemoteStorageDownloadFileUGCResult error"); } } catch (Exception e) { Finish(null, _PublishedFileId, false); Debug.Log("SteamGetPrimaryFileProcess OnRemoteStorageDownloadFileUGCResultPrimaryFile " + e.ToString()); } } }
void OnRemoteStorageDownloadPreUGCResult(RemoteStorageDownloadUGCResult_t pCallback, bool bIOFailure) { //GetPreFileDetail step 3 try { if (pCallback.m_eResult == EResult.k_EResultOK) { byte[] Data = new byte[pCallback.m_nSizeInBytes]; SteamRemoteStorage.UGCRead(pCallback.m_hFile, Data, pCallback.m_nSizeInBytes, 0, EUGCReadAction.k_EUGCRead_Close); //combin data for Prefile and votedetail // parsing _PreFileDetail.m_aPreFileData = ParsingName(Data, out _PreFileDetail.m_sUploader); GetVoteDetail(_PreFileDetail.m_nPublishedFileId); //Debug.Log("[" + RemoteStorageDownloadUGCResult_t.k_iCallback + " - RemoteStorageDownloadUGCResult] - " + pCallback.m_eResult + " -- " + pCallback.m_hFile + " -- " + pCallback.m_nAppID + " -- " + pCallback.m_nSizeInBytes + " -- " + pCallback.m_pchFileName + " -- " + pCallback.m_ulSteamIDOwner); } else { Finish(_PublishID, null, false); LogManager.Warning("OnRemoteStorageDownloadPreUGCResult ", pCallback.m_eResult); } } catch (Exception e) { Finish(_PublishID, null, false); Debug.Log("SteamGetPreFileDetailProcess OnRemoteStorageDownloadPreUGCResultAllUser " + e.ToString()); } }
private void OnPreviewDownloaded(RemoteStorageDownloadUGCResult_t result, bool failure) { Debug.Log($"Received preview image for {_details.m_rgchTitle}: failure: {failure}, result: {result.m_eResult}"); if (result.m_eResult != EResult.k_EResultOK) { return; } LoadPreview(); }
/// <summary> /// Generic handler useful for testing and debugging /// </summary> /// <param name="param"></param> /// <param name="bIOFailure"></param> private void HandleUGCDownload(RemoteStorageDownloadUGCResult_t param, bool bIOFailure) { if (!bIOFailure) { Debug.LogError("UGC Download generic handler loaded without failure."); } else { Debug.LogError("UGC Download request failed."); } }
void OnRemoteStorageDownloadUGCResult(RemoteStorageDownloadUGCResult_t pCallback, bool bIOFailure) { //finally downloading the file byte[] Data = new byte[pCallback.m_nSizeInBytes]; int ret = SteamRemoteStorage.UGCRead(UGCHandle, Data, pCallback.m_nSizeInBytes, 0, EUGCReadAction.k_EUGCRead_Close); itemContent = System.Text.Encoding.UTF8.GetString(Data, 0, ret); File.WriteAllText(pCallback.m_pchFileName, itemContent); //time to continue to the next one. fetchedContent = true; }
// SteamAPICall_t public CallbackHandle UGCDownloadToLocation(UGCHandle_t hContent /*UGCHandle_t*/, string pchLocation /*const char **/, uint unPriority /*uint32*/, Action <RemoteStorageDownloadUGCResult_t, bool> CallbackFunction = null /*Action<RemoteStorageDownloadUGCResult_t, bool>*/) { SteamAPICall_t callback = 0; callback = platform.ISteamRemoteStorage_UGCDownloadToLocation(hContent.Value, pchLocation, unPriority); if (CallbackFunction == null) { return(null); } return(RemoteStorageDownloadUGCResult_t.CallResult(steamworks, callback, CallbackFunction)); }
private void HandleUGCDownload(RemoteStorageDownloadUGCResult_t param, bool bIOFailure) { //TODO: we shoudl probably setup a unique handler for each type of file .. at the moment we are assuming we only ever load the preview image PreviewImageLocation = param.m_pchFileName; Texture2D image; if (SteamUtilities.LoadImageFromDisk(param.m_pchFileName, out image)) { previewImage = image; } else { Debug.LogError("Failed to load preview image (" + param.m_pchFileName + ") from disk!"); } }
private void OnDownloadComplete(RemoteStorageDownloadUGCResult_t callback, bool ioError) { var result = callback.m_eResult; if (ioError || result != EResult.k_EResultOK) { OnError(pending, ioError ? EResult.k_EResultIOFailure : result); } else { OnComplete(pending, callback.m_nSizeInBytes); } DestroyCallbacks(); pending = PublishedFileId_t.Invalid; Check(); }
private void OnRemoteStorageDownloadUGCThumbnailResult(RemoteStorageDownloadUGCResult_t pCallback, bool bIOFailure) { Console.WriteLine("Downloaded thumbnail for " + pCallback.m_pchFileName); if (pCallback.m_eResult == EResult.k_EResultOK) { byte[] Data = new byte[pCallback.m_nSizeInBytes]; int ret = SteamRemoteStorage.UGCRead(pCallback.m_hFile, Data, pCallback.m_nSizeInBytes, 0, EUGCReadAction.k_EUGCRead_Close); Texture2D thumbnail = Texture2D.FromStream(MainMethod.device, new MemoryStream(Data), 160, 120, true); instance.subscribedThumbnailButtonMap[pCallback.m_hFile].Thumbnail = thumbnail; DownloadNextLevelThumbnail(); } else { System.Windows.Forms.MessageBox.Show( "An unexpected error occured (Download UGC Thumbnail result)\n" + pCallback.m_eResult, "Error"); } }
private void OnDownloadComplete(RemoteStorageDownloadUGCResult_t callback, bool ioError) { var result = callback.m_eResult; if (ioError || result != EResult.k_EResultOK) { OnError(pending); } else { OnComplete(pending, callback.m_nSizeInBytes); } onComplete?.Dispose(); onComplete = null; pending = PublishedFileId_t.Invalid; Check(); }
private void OnRemoteStorageDownloadUGCResult(RemoteStorageDownloadUGCResult_t pCallback, bool bIOFailure) { Console.WriteLine("Downloaded level data for " + pCallback.m_pchFileName); if (pCallback.m_eResult == EResult.k_EResultOK) { byte[] Data = new byte[pCallback.m_nSizeInBytes]; int ret = SteamRemoteStorage.UGCRead(pCallback.m_hFile, Data, pCallback.m_nSizeInBytes, 0, EUGCReadAction.k_EUGCRead_Close); string itemContent = Encoding.UTF8.GetString(Data, 0, ret); instance.subscribedItemButtonMap[pCallback.m_hFile].IsReady = true; instance.subscribedItemButtonMap[pCallback.m_hFile].LevelData = itemContent; DownloadNextLevelData(); } else { System.Windows.Forms.MessageBox.Show( "An unexpected error occured (Download UGC result)\n" + pCallback.m_eResult, "Error"); } }
private void OnDownloadThumbnail(RemoteStorageDownloadUGCResult_t param, bool bIOFailure) { if (param.m_eResult != EResult.k_EResultOK) { onRead(null); onRead = null; return; } byte[] array = new byte[param.m_nSizeInBytes]; SteamRemoteStorage.UGCRead(UGCDetails.m_hPreviewFile, array, array.Length, 0u, EUGCReadAction.k_EUGCRead_Close); onRead(new BuiltinLevelMetadata { folder = "none", workshopId = UGCDetails.m_nPublishedFileId.m_PublishedFileId, itemType = WorkshopItemType.Level, title = UGCDetails.m_rgchTitle, cachedThumbnailBytes = array }); onRead = null; }
private void HandleUGCDownloadPreviewFile(RemoteStorageDownloadUGCResult_t param, bool bIOFailure) { if (!bIOFailure) { if (param.m_eResult == EResult.k_EResultOK) { byte[] imageBuffer = new byte[param.m_nSizeInBytes]; var count = SteamRemoteStorage.UGCRead(param.m_hFile, imageBuffer, param.m_nSizeInBytes, 0, EUGCReadAction.k_EUGCRead_ContinueReadingUntilFinished); //Initalize the image, the LoadImage call will resize as required previewImage = new Texture2D(2, 2); previewImage.LoadImage(imageBuffer); PreviewImageLocation = param.m_pchFileName; } else { Debug.LogError("UGC Download: unexpected result state: " + param.m_eResult.ToString() + "\nImage will not be loaded."); } } else { Debug.LogError("UGC Download request failed."); } }
void OnRemoteStorageDownloadUGCResult(RemoteStorageDownloadUGCResult_t pCallback, bool bIOFailure) { Debug.Log("[" + RemoteStorageDownloadUGCResult_t.k_iCallback + " - RemoteStorageDownloadUGCResult] - " + pCallback.m_eResult + " -- " + pCallback.m_hFile + " -- " + pCallback.m_nAppID + " -- " + pCallback.m_nSizeInBytes + " -- " + pCallback.m_pchFileName + " -- " + pCallback.m_ulSteamIDOwner); }
static void OnSteamUGCDownloadResult(RemoteStorageDownloadUGCResult_t pCallback, bool bIOFailure) { Debug.Log("[SteamUGCDownloadResult] -- " + pCallback.m_eResult + " -- Name:" + pCallback.m_pchFileName + " -- Size:" + pCallback.m_nSizeInBytes); if (pCallback.m_eResult == EResult.k_EResultOK) { RegisteredISO iso = _DownloadList.Find(iter => iter.UGCHandle == pCallback.m_hFile.m_UGCHandle); if (iso != null) { string fielName = VCConfig.s_CreationNetCachePath + iso._hashCode.ToString("X").PadLeft(16, '0') + VCConfig.s_CreationNetCacheFileExt; byte[] fileData = new byte[pCallback.m_nSizeInBytes]; int length = SteamRemoteStorage.UGCRead(pCallback.m_hFile, fileData, pCallback.m_nSizeInBytes, 0, EUGCReadAction.k_EUGCRead_Close); using (FileStream fs = new FileStream(fielName, FileMode.Create, FileAccess.Write, FileShare.Read)) { fs.Write(fileData, 0, length); } _DownloadList.RemoveAll(iter => iter.UGCHandle == pCallback.m_hFile.m_UGCHandle); _SteamItems[iso._hashCode] = pCallback.m_pchFileName; } if (BaseNetwork.MainPlayer.NetworkState == ENetworkState.Null) { NetworkManager.SyncServer(EPacketType.PT_Common_UGCDownloaded, pCallback.m_hFile.m_UGCHandle); } else { for (int i = 0; i < _CurDownloadList.Count; i++) { if (_CurDownloadList[i] == pCallback.m_hFile.m_UGCHandle) { NetworkManager.SyncServer(EPacketType.PT_Common_UGCDownloaded, pCallback.m_hFile.m_UGCHandle); _CurDownloadList[i] = 0; } } } _CurDownload = 0; if (_DownloadList.Count <= 0) { RoomGui_N.SetMapInfo("Download complete"); if (null != RoomGui_N.Instance && RoomGui_N.Instance.isShow) { RoomGui_N.Instance.ActiveStartBtn(); } } else { RoomGui_N.SetMapInfo("Downloading " + pCallback.m_pchFileName + "...[100%]"); } RoomGui_N.UpdateDownLoadInfo(_DownloadList.Count, 0); } else if (pCallback.m_eResult == EResult.k_EResultFileNotFound) { Debug.LogWarning(pCallback.m_hFile.m_UGCHandle + " does not exits."); //_DownloadList.RemoveAll(iter => iter.UGCHandle == pCallback.m_hFile.m_UGCHandle); //_CurDownload = 0; //if (_DownloadList.Count <= 0) //{ // RoomGui_N.SetMapInfo("Download complete"); // if (null != RoomGui_N.Instance && RoomGui_N.Instance.isShow) // RoomGui_N.Instance.ActiveStartBtn(); //} //RoomGui_N.UpdateDownLoadInfo(_DownloadList.Count, 0); NetworkManager.SyncServer(EPacketType.PT_Common_InvalidUGC, _DownloadList[0]._hashCode, pCallback.m_hFile.m_UGCHandle); } else if (pCallback.m_eResult == EResult.k_EResultTimeout) { NetworkManager.SyncServer(EPacketType.PT_Common_DownTimeOut, _DownloadList[0]._hashCode, pCallback.m_hFile.m_UGCHandle); } else { RoomGui_N.SetMapInfo("Download failed"); MessageBox_N.ShowYNBox(PELocalization.GetString(8000116), OnYesEvent, OnNoEvent); } }