private void StartPreviewUpload() { if (UpdatePreview && !PreviewPath.IsNullOrWhiteSpace()) { bool failed = true; try { // 1 MB limit on preview images byte[] prevData = File.ReadAllBytes(PreviewPath); PUtil.LogDebug("PREVIEW: " + PreviewPath + " => " + REMOTE_MOD_PREVIEW); failed = !WriteToSteamStorage(prevData, REMOTE_MOD_PREVIEW, OnPreviewUploaded); } catch (IOException e) { PUtil.LogWarning("Unable to open preview image:"); PUtil.LogExcWarn(e); } if (failed) { OnModifyFailed?.Invoke(); } } else { FinishModify(); } }
private void OnDataUploaded(RemoteStorageFileWriteAsyncComplete_t result, bool failed) { var steamStatus = result.m_eResult; if (!failed && steamStatus == EResult.k_EResultOK && SteamRemoteStorage. UpdatePublishedFileFile(updateHandle, REMOTE_MOD_DATA)) { PUtil.LogDebug("PUBLISH DATA: " + REMOTE_MOD_DATA); StartPreviewUpload(); } else { PUtil.LogWarning("Unable to update mod data: " + steamStatus); OnModifyFailed?.Invoke(); } }
private void FinishModify() { PUtil.LogDebug("SUBMITTING UPDATE: " + Mod.label.title); var call = SteamRemoteStorage.CommitPublishedFileUpdate(updateHandle); if (call.Equals(SteamAPICall_t.Invalid)) { DeleteFromSteamStorage(REMOTE_MOD_DATA); DeleteFromSteamStorage(REMOTE_MOD_PREVIEW); OnModifyFailed?.Invoke(); } else { updateCaller.Set(call); } }
private void OnPreviewUploaded(RemoteStorageFileWriteAsyncComplete_t result, bool failed) { var steamStatus = result.m_eResult; if (!failed && steamStatus == EResult.k_EResultOK && SteamRemoteStorage. UpdatePublishedFilePreviewFile(updateHandle, REMOTE_MOD_PREVIEW)) { PUtil.LogDebug("PUBLISH PREVIEW: " + REMOTE_MOD_PREVIEW); FinishModify(); } else { PUtil.LogWarning("Unable to update preview image: " + steamStatus); OnModifyFailed?.Invoke(); } }
private void OnUpdateDone(RemoteStorageUpdatePublishedFileResult_t result, bool failed) { var steamStatus = result.m_eResult; DeleteFromSteamStorage(REMOTE_MOD_DATA); DeleteFromSteamStorage(REMOTE_MOD_PREVIEW); if (!failed && !result.m_bUserNeedsToAcceptWorkshopLegalAgreement && steamStatus == EResult.k_EResultOK) { OnModifyComplete?.Invoke(); } else { PUtil.LogWarning("Update failed: " + steamStatus); OnModifyFailed?.Invoke(); } }
public void StartModify() { if (!updateHandle.Equals(PublishedFileUpdateHandle_t.Invalid)) { throw new InvalidOperationException("Upload already started"); } // Legacy Workshop item updateHandle = SteamRemoteStorage.CreatePublishedFileUpdateRequest(details. m_nPublishedFileId); if (updateHandle.Equals(PublishedFileUpdateHandle_t.Invalid)) { OnModifyFailed?.Invoke(); } else { PUtil.LogDebug("MODIFYING MOD: " + Mod.label.title); string desc = Description?.Trim(), title = Title?.Trim(); if (!desc.IsNullOrWhiteSpace() && desc != details.m_rgchDescription) { PUtil.LogDebug("DESCRIPTION: " + desc); if (!SteamRemoteStorage.UpdatePublishedFileDescription(updateHandle, desc)) { PUtil.LogWarning("Failed to set item description!"); } } if (!title.IsNullOrWhiteSpace() && title != details.m_rgchTitle) { PUtil.LogDebug("TITLE: " + title); if (!SteamRemoteStorage.UpdatePublishedFileTitle(updateHandle, title)) { PUtil.LogWarning("Failed to set item title!"); } } if (!PatchInfo.IsNullOrWhiteSpace()) { PUtil.LogDebug("PATCH INFO: " + PatchInfo); if (!SteamRemoteStorage.UpdatePublishedFileSetChangeDescription( updateHandle, PatchInfo)) { PUtil.LogWarning("Failed to set change notes!"); } } if (UpdateData && !DataPath.IsNullOrWhiteSpace()) { byte[] zipData = ZipModFolder(DataPath); if (zipData != null) { PUtil.LogDebug("DATA: " + DataPath + " => " + REMOTE_MOD_DATA); if (!WriteToSteamStorage(zipData, REMOTE_MOD_DATA, OnDataUploaded)) { OnModifyFailed?.Invoke(); } } else { OnModifyFailed?.Invoke(); } } else { StartPreviewUpload(); } } }