/// <summary> /// 开始上传进度协程跟进 /// </summary> /// <param name="updateHandle"></param> /// <returns></returns> private IEnumerator ProgressCoroutine(UGCUpdateHandle_t updateHandle, PublishedFileId_t fileId) { mIsComplete = false; while (!mIsComplete) { ulong progressBytes; ulong totalBytes; EItemUpdateStatus state = SteamUGC.GetItemUpdateProgress(updateHandle, out progressBytes, out totalBytes); if (this.mUpdateCallBack != null) { if (state == EItemUpdateStatus.k_EItemUpdateStatusCommittingChanges) { mIsComplete = true; this.mUpdateCallBack.UpdateSuccess(); } else if (state == EItemUpdateStatus.k_EItemUpdateStatusInvalid) { mIsComplete = true; this.mUpdateCallBack.UpdateFail(SteamWorkshopUpdateFailEnum.REQUEST_FAIL); SteamUGC.DeleteItem(fileId); } else { this.mUpdateCallBack.UpdateProgress(state, progressBytes, totalBytes); } } yield return(new WaitForSeconds(0.1f)); } }
/// <summary> /// 设置item的相关数据 /// </summary> /// <param name="fileId"></param> private void SetCreateItemInfo(PublishedFileId_t fileId) { //获取设置参数基类 mUpdateHandle = SteamUGC.StartItemUpdate(mAppId, fileId); //设置标题 SteamUGC.SetItemTitle(mUpdateHandle, this.mUpdateData.title); //设置介绍 SteamUGC.SetItemDescription(mUpdateHandle, this.mUpdateData.description); //设置语言 SteamUGC.SetItemUpdateLanguage(mUpdateHandle, this.mUpdateData.updateLanguage); //设置原数据 SteamUGC.SetItemMetadata(mUpdateHandle, this.mUpdateData.metadata); //设置公开 SteamUGC.SetItemVisibility(mUpdateHandle, this.mUpdateData.visibility); //设置标签 SteamUGC.SetItemTags(mUpdateHandle, this.mUpdateData.tags); //设置键值对 //SteamUGC.AddItemKeyValueTag(); //移除键值对 //SteamUGC.RemoveItemKeyValueTags(); //设置文件地址 SteamUGC.SetItemContent(mUpdateHandle, this.mUpdateData.content); //设置浏览图片 SteamUGC.SetItemPreview(mUpdateHandle, this.mUpdateData.preview); CallResult <SubmitItemUpdateResult_t> callResult = CallResult <SubmitItemUpdateResult_t> .Create(OnSubmitItemCallBack); SteamAPICall_t apiCallBack = SteamUGC.SubmitItemUpdate(mUpdateHandle, null); callResult.Set(apiCallBack); mContent.StartCoroutine(ProgressCoroutine(mUpdateHandle, fileId)); }
// I'm a f****n idiot... public void ResetUploader() { publishID = 0; Message = ""; m_itemCreated?.Dispose(); m_itemSubmitted?.Dispose(); ugcUpdateHandle = UGCUpdateHandle_t.Invalid; }
private void UpdateItem(ulong itemID, string changeMessage, string filePath, string previewImagePath, string title, string description, string[] tags, bool?visibility, SimplePromise <WorkshopPublishResult> promise) { UGCUpdateHandle_t handle = SteamUGC.StartItemUpdate(new AppId_t(App.Info.SteamAppID), new PublishedFileId_t(itemID)); if (filePath != null) { SteamUGC.SetItemContent(handle, filePath + Path.DirectorySeparatorChar); } if (previewImagePath != null) { SteamUGC.SetItemPreview(handle, previewImagePath); } if (title != null) { SteamUGC.SetItemTitle(handle, title); } if (description != null) { SteamUGC.SetItemDescription(handle, description); } if (tags != null) { SteamUGC.SetItemTags(handle, new List <string>(tags)); } if (visibility.HasValue) { SteamUGC.SetItemVisibility(handle, visibility.Value ? (App.Debug ? ERemoteStoragePublishedFileVisibility.k_ERemoteStoragePublishedFileVisibilityFriendsOnly : ERemoteStoragePublishedFileVisibility.k_ERemoteStoragePublishedFileVisibilityPublic) : ERemoteStoragePublishedFileVisibility.k_ERemoteStoragePublishedFileVisibilityPrivate ); } m_network.MakeCall( SteamUGC.SubmitItemUpdate(handle, changeMessage), delegate(SubmitItemUpdateResult_t args, bool ioFailure) { if (ioFailure || args.m_eResult != EResult.k_EResultOK) { if (!ioFailure) { promise.Fail("Failed to update file: " + args.m_eResult); } else { promise.Fail("Failed to update file"); } } else { var result = new WorkshopPublishResult(itemID); result.AgreementNeeded = args.m_bUserNeedsToAcceptWorkshopLegalAgreement; promise.Succeed(result); } } ); }
public static void SubmitItem( PublishedFileId_t itemID, string title, string description, int visibility, string contentPath, string previewFilePath, List <string> tagList, string changeLog, bool bIsUpdate ) { _ugcUpdateHandle = SteamUGC.StartItemUpdate((AppId_t)346330, itemID); if (_ugcUpdateHandle == null) { return; } if (tagList == null) { return; } if (tagList.Count() <= 0) { return; } if (!string.IsNullOrEmpty(contentPath)) { if (bIsUpdate) { SteamUGC.RemoveItemKeyValueTags(_ugcUpdateHandle, "map_name"); SteamUGC.RemoveItemKeyValueTags(_ugcUpdateHandle, "map_size"); } PerformMapItemCheck(_ugcUpdateHandle, contentPath); SteamUGC.SetItemContent(_ugcUpdateHandle, contentPath); } if (!string.IsNullOrEmpty(previewFilePath)) { SteamUGC.SetItemPreview(_ugcUpdateHandle, previewFilePath); } SteamUGC.SetItemTitle(_ugcUpdateHandle, title); SteamUGC.SetItemDescription(_ugcUpdateHandle, description); SteamUGC.SetItemVisibility(_ugcUpdateHandle, (ERemoteStoragePublishedFileVisibility)visibility); SteamUGC.SetItemTags(_ugcUpdateHandle, tagList); AddNewItemToList(bIsUpdate, title, description, visibility, tagList, itemID, _ugcUpdateHandle); SteamAPICall_t registerCallback = SteamUGC.SubmitItemUpdate(_ugcUpdateHandle, changeLog); m_SubmitItemUpdate.Set(registerCallback); }
static void SetWorkshopItemDataFrom_Postfix(UGCUpdateHandle_t updateHandle, WorkshopItemHook hook) { var taggedVersions = GetTaggedVersions(hook.Directory.FullName); if (!taggedVersions.NullOrEmpty()) { var tags = taggedVersions.Select(version => version.Major + "." + version.Minor); tags.Add("Mod"); SteamUGC.SetItemTags(updateHandle, tags.Distinct().ToList()); } }
public static void Init() { publishedWorkshopItems = null; subscribedItems = null; subscribedItemDetails = null; hUpdate = UGCUpdateHandle_t.Invalid; m_SteamUGCQueryCompletedCallback = CallResult <SteamUGCQueryCompleted_t> .Create(OnUGCQueryCompleted); m_CreateItemResultCallback = CallResult <CreateItemResult_t> .Create(OnCreateItemResult); m_SubmitItemUpdateResultCallback = CallResult <SubmitItemUpdateResult_t> .Create(OnSubmitItemUpdateResult); }
public void StartUploading(UGCUpdateHandle_t updHandle) { updateHandle = updHandle; m_bUploading = timFrame.Enabled = true; if (btnUpdate != null) { btnUpdate.Visible = btnUpdate.Enabled = false; } Invalidate(); }
public static void uploadToWorkshop(PublishedFileId_t PublisherID, List <string> tags, string contentPath, string title, string description, string imagePreviewFile) { //FileStream stream = new FileStream(contentPath + @"LevelPreview.jpg", FileMode.Create); //level.Preview.LevelPreview.SaveAsJpeg(stream, level.Preview.LevelPreview.Width, level.Preview.LevelPreview.Height); //stream.Close(); UGCUpdateHandle_t updateHandle = SteamManager.SteamUGCworkshop.registerFileInfoOrUpdate(PublisherID, title, description, ERemoteStoragePublishedFileVisibility.k_ERemoteStoragePublishedFileVisibilityPrivate, tags, contentPath, imagePreviewFile); SteamAPICall_t SteamAPICall_t_handle = SteamManager.SteamUGCworkshop.sendFileOrUpdate(updateHandle, "Update NOtes are helpful... " + PublisherID); Console.WriteLine("sendFileOrUpdate (SteamAPICall_t_handle): " + SteamAPICall_t_handle); }
private void SetupModPack(UGCUpdateHandle_t handle, WorkshopModPack pack) { SteamUGC.SetItemTitle(handle, pack.title); SteamUGC.SetItemDescription(handle, pack.description); SteamUGC.SetItemVisibility(handle, (ERemoteStoragePublishedFileVisibility)pack.visibility); SteamUGC.SetItemContent(handle, basePath + pack.contentfolder); SteamUGC.SetItemPreview(handle, basePath + pack.previewfile); SteamUGC.SetItemMetadata(handle, pack.metadata); pack.ValidateTags(); SteamUGC.SetItemTags(handle, pack.tags); }
internal static void Upload(WorkshopUploadable item) { if (Workshop.curStage != WorkshopInteractStage.None) { Messages.Message("UploadAlreadyInProgress".Translate(), MessageTypeDefOf.RejectInput, false); } else { Workshop.uploadingHook = item.GetWorkshopItemHook(); if (Workshop.uploadingHook.PublishedFileId != PublishedFileId_t.Invalid) { if (Prefs.LogVerbose) { Log.Message(string.Concat(new object[] { "Workshop: Starting item update for mod '", Workshop.uploadingHook.Name, "' with PublishedFileId ", Workshop.uploadingHook.PublishedFileId }), false); } Workshop.curStage = WorkshopInteractStage.SubmittingItem; Workshop.curUpdateHandle = SteamUGC.StartItemUpdate(SteamUtils.GetAppID(), Workshop.uploadingHook.PublishedFileId); Workshop.SetWorkshopItemDataFrom(Workshop.curUpdateHandle, Workshop.uploadingHook, false); SteamAPICall_t hAPICall = SteamUGC.SubmitItemUpdate(Workshop.curUpdateHandle, "[Auto-generated text]: Update on " + DateTime.Now.ToString() + "."); if (Workshop.< > f__mg$cache3 == null) { Workshop.< > f__mg$cache3 = new CallResult <SubmitItemUpdateResult_t> .APIDispatchDelegate(Workshop.OnItemSubmitted); } Workshop.submitResult = CallResult <SubmitItemUpdateResult_t> .Create(Workshop.< > f__mg$cache3); Workshop.submitResult.Set(hAPICall, null); } else { if (Prefs.LogVerbose) { Log.Message("Workshop: Starting item creation for mod '" + Workshop.uploadingHook.Name + "'.", false); } Workshop.curStage = WorkshopInteractStage.CreatingItem; SteamAPICall_t hAPICall2 = SteamUGC.CreateItem(SteamUtils.GetAppID(), EWorkshopFileType.k_EWorkshopFileTypeFirst); if (Workshop.< > f__mg$cache4 == null) { Workshop.< > f__mg$cache4 = new CallResult <CreateItemResult_t> .APIDispatchDelegate(Workshop.OnItemCreated); } Workshop.createResult = CallResult <CreateItemResult_t> .Create(Workshop.< > f__mg$cache4); Workshop.createResult.Set(hAPICall2, null); } Find.WindowStack.Add(new Dialog_WorkshopOperationInProgress()); } }
private static void PerformMapItemCheck(UGCUpdateHandle_t handle, string contentPath) { if (handle == null || string.IsNullOrEmpty(contentPath)) { return; } foreach (string file in Directory.EnumerateFiles(contentPath, "*.bsp", SearchOption.AllDirectories)) { FileInfo info = new FileInfo(file); SteamUGC.AddItemKeyValueTag(handle, "map_name", Path.GetFileNameWithoutExtension(file)); SteamUGC.AddItemKeyValueTag(handle, "map_size", info.Length.ToString()); } }
private static void SetItemAttributes(UGCUpdateHandle_t handle, Mod mod, bool creating) { SteamUGC.SetItemTitle(handle, mod.Name); SteamUGC.SetItemTags(handle, mod.Tags); SteamUGC.SetItemContent(handle, mod.ContentFolder); if (mod.Preview != null) { SteamUGC.SetItemPreview(handle, mod.Preview); } if (creating) { SteamUGC.SetItemVisibility(handle, ERemoteStoragePublishedFileVisibility.k_ERemoteStoragePublishedFileVisibilityPrivate); } }
private void Reset() { m_State = EState.Initialized; m_tmpPublishedFileId = PublishedFileId_t.Invalid; m_tmpNeedsToAcceptTOS = false; m_tmpUpdateHandle = UGCUpdateHandle_t.Invalid; m_tmpContentFolder = ""; m_tmpPreviewFile = ""; m_tmpName = ""; m_tmpDescription = ""; m_tmpVisibility = ERemoteStoragePublishedFileVisibility.k_ERemoteStoragePublishedFileVisibilityPrivate; m_CrateItemResult.Cancel(); m_SubmitItemUpdateResult.Cancel(); }
protected void OnSubmitItemUpdate(SubmitItemUpdateResult_t result, bool failed) { if (result.m_eResult == EResult.k_EResultOK) { Debug.LogFormat("OnSubmitItemUpdate complete: {0}", result.m_eResult); } else { Debug.LogErrorFormat("OnSubmitItemUpdate complete: {0}", result.m_eResult); } ugcUpdateHandle = UGCUpdateHandle_t.Invalid; ugcUpdateStatus = string.Format("Upload Status: {0} ({1})", result.m_eResult, System.DateTime.Now.ToShortTimeString()); Repaint(); }
private static void OnItemSubmitted(SubmitItemUpdateResult_t param, bool bIOFailure) { if (bIOFailure) { Console.WriteLine("Error: I/O Failure! :("); return; } switch (param.m_eResult) { case EResult.k_EResultOK: Console.WriteLine("SUCCESS! Item submitted! :D :D :D"); ugcUpdateHandle = UGCUpdateHandle_t.Invalid; break; } }
private void OnItemSubmitted(SubmitItemUpdateResult_t callback, bool ioFailure) { if (ioFailure) { statusText.text = "Error: I/O Failure! :("; return; } switch (callback.m_eResult) { case EResult.k_EResultOK: statusText.text = "SUCCESS! Item submitted! :D :D :D"; currentHandle = UGCUpdateHandle_t.Invalid; break; } }
private void OnItemSubmitted(SubmitItemUpdateResult_t callback, bool ioFailure) { if (ioFailure) { statusText.text = "Error: I/O Failure! :("; return; } if (callback.m_bUserNeedsToAcceptWorkshopLegalAgreement) { statusText.text = "You need to accept the Steam Workshop legal agreement for this game before you can upload items!"; return; } currentHandle = UGCUpdateHandle_t.Invalid; switch (callback.m_eResult) { case EResult.k_EResultOK: statusText.text = "SUCCESS! Item submitted! :D :D :D"; break; case EResult.k_EResultFail: statusText.text = "Failed, dunno why :("; break; case EResult.k_EResultInvalidParam: statusText.text = "Either the provided app ID is invalid or doesn't match the consumer app ID of the item or, you have not enabled ISteamUGC for the provided app ID on the Steam Workshop Configuration App Admin page. The preview file is smaller than 16 bytes."; break; case EResult.k_EResultAccessDenied: statusText.text = "ERROR: The user doesn't own a license for the provided app ID."; break; case EResult.k_EResultFileNotFound: statusText.text = "Failed to get the workshop info for the item or failed to read the preview file."; break; case EResult.k_EResultLockingFailed: statusText.text = "Failed to aquire UGC Lock."; break; case EResult.k_EResultLimitExceeded: statusText.text = "The preview image is too large, it must be less than 1 Megabyte; or there is not enough space available on the users Steam Cloud."; break; } }
private void UploadModPack(WorkshopModPack pack) { ulong ulongId = ulong.Parse(pack.publishedfileid); var id = new PublishedFileId_t(ulongId); UGCUpdateHandle_t handle = SteamUGC.StartItemUpdate(new AppId_t(SteamManager.m_steamAppId), id); //m_itemUpdated.Set(call); //OnItemUpdated(call, false); // Only set the changenotes when clicking submit pack.changenote = modPackChangeNotes.text; currentHandle = handle; SetupModPack(handle, pack); SubmitModPack(handle, pack); }
//Used to update a workshop item, the callback function is called after the update is completed. The return value will indicate success or failure. public bool UpdateItem(PublishedFileId_t fileId, string title, string description, string contentPath, string previewImagePath, string changeNote, SubmitItemCallBack submitItemCallBack) { bool result = false; if (SteamManager.Initialized && fileId.m_PublishedFileId != 0) { updateHandle = SteamUGC.StartItemUpdate(SteamUtils.GetAppID(), fileId); result = true; result = result && SteamUGC.SetItemTitle(updateHandle, title); if (result) { result = result && SteamUGC.SetItemDescription(updateHandle, description); } if (result) { result = result && SteamUGC.SetItemContent(updateHandle, contentPath); } if (result) { result = result && SteamUGC.SetItemPreview(updateHandle, previewImagePath); } if (result) { result = result && SteamUGC.SetItemVisibility(updateHandle, ERemoteStoragePublishedFileVisibility.k_ERemoteStoragePublishedFileVisibilityPublic); } if (result) { SteamAPICall_t apiCall = SteamUGC.SubmitItemUpdate(updateHandle, changeNote); if (submitItemResult.IsActive()) { submitItemResult.Cancel(); submitItemResult.Dispose(); } submitItemResult.Set(apiCall); this.submitItemCallBack = submitItemCallBack; } } return(result); }
private void UpdateItem(PublishedFileId_t m_nPublishedFileId) { this.bIsUploading = true; updateHandle = SteamUGC.StartItemUpdate((AppId_t)252950, m_nPublishedFileId); SteamUGC.SetItemTitle(updateHandle, this.WorkshopItemInfo.Title); SteamUGC.SetItemDescription(updateHandle, this.WorkshopItemInfo.Description); SteamUGC.SetItemVisibility(updateHandle, (ERemoteStoragePublishedFileVisibility)this.WorkshopItemInfo.Visibility); SteamUGC.SetItemTags(updateHandle, this.WorkshopItemInfo.Tags); SteamUGC.SetItemContent(updateHandle, this.txtContentFolder.Text); SteamUGC.SetItemPreview(updateHandle, this.WorkshopItemInfo.Preview); this.btnSendContentButton.Text = "Uploading Content..."; m_SubmitItemUpdateCallResult = CallResult <SubmitItemUpdateResult_t> .Create(OnSubmitItemUpdate); SteamAPICall_t callHandle = SteamUGC.SubmitItemUpdate(updateHandle, null); m_SubmitItemUpdateCallResult.Set(callHandle); }
public static bool UpdateItem(AppId_t GameAppId, PublishedFileId_t ItemToUpdate, bool bIsNewItem, string foldername, string previewfilename, string title, string tags, string description, UpdateItemDelegate InUpdateItemDelegate) { UpdateItem_delegate = InUpdateItemDelegate; hUpdate = SteamUGC.StartItemUpdate(GameAppId, ItemToUpdate); if (title == "") { ErrorMessage = "No title was provided."; return(false); } if (tags == "") { ErrorMessage = "No tags were provided."; return(false); } if (description == "") { ErrorMessage = "No description was provided."; return(false); } string[] tags_array = tags.Split(' '); List <string> tags_list = new List <string>(tags_array); SteamUGC.SetItemTitle(hUpdate, title); SteamUGC.SetItemTags(hUpdate, tags_list); SteamUGC.SetItemDescription(hUpdate, description); if (bIsNewItem) { SteamUGC.SetItemVisibility(hUpdate, ERemoteStoragePublishedFileVisibility.k_ERemoteStoragePublishedFileVisibilityPrivate); } SteamUGC.SetItemContent(hUpdate, foldername); SteamUGC.SetItemPreview(hUpdate, previewfilename); SteamAPICall_t hSteamAPICall = SteamUGC.SubmitItemUpdate(hUpdate, ""); if (hSteamAPICall != SteamAPICall_t.Invalid) { m_SubmitItemUpdateResultCallback.Set(hSteamAPICall, null); } else { UpdateItem_delegate(EResult.k_EResultFail); } return(true); }
IEnumerator startPictureUpdate(RemoteStoragePublishFileResult_t pCallback) { //Wait 1 second just to make sure initial upload is 100% complete. Although technically entering this Coroutine indicated 100% completion. Consider it a fail safe. yield return(new WaitForSeconds(1.0f)); UGCUpdateHandle_t m_UGCUpdateHandle = SteamUGC.StartItemUpdate(SteamUtils.GetAppID(), pCallback.m_nPublishedFileId); bool ret = SteamUGC.SetItemPreview(m_UGCUpdateHandle, thisUploadsIamgeLoc); if (ret) { Debug.Log("Thumbnail upload intialization success"); SteamAPICall_t handle = SteamUGC.SubmitItemUpdate(m_UGCUpdateHandle, "Add Screenshot"); ItemUpdateResult.Set(handle); } else { Debug.Log("Thumbnail upload intialization failed, but file upload succeded"); } }
private void PerformUpdate(ExtensionInfo info) { this.updateHandle = SteamUGC.StartItemUpdate(this.hacknetAppID, new PublishedFileId_t((ulong)Convert.ToInt64(info.WorkshopPublishID))); this.isInUpload = true; bool flag1 = ((true & SteamUGC.SetItemTitle(this.updateHandle, info.Name) & SteamUGC.SetItemDescription(this.updateHandle, info.WorkshopDescription) ? 1 : 0) & (SteamUGC.SetItemTags(this.updateHandle, (IList <string>)info.WorkshopTags.Split(new string[3] { " ,", ", ", "," }, StringSplitOptions.RemoveEmptyEntries)) ? 1 : 0)) != 0; string str = (Path.Combine(Directory.GetCurrentDirectory(), info.FolderPath) + "/" + info.WorkshopPreviewImagePath).Replace("\\", "/"); if (File.Exists(str)) { if (new FileInfo(str).Length < 1000000L) { flag1 &= SteamUGC.SetItemPreview(this.updateHandle, str); } else { this.currentStatusMessage = "Workshop Preview Image too large! Max size 1mb. Ignoring..."; } } ERemoteStoragePublishedFileVisibility eVisibility = (int)info.WorkshopVisibility <= 0 ? ERemoteStoragePublishedFileVisibility.k_ERemoteStoragePublishedFileVisibilityPublic : ((int)info.WorkshopVisibility == 1 ? ERemoteStoragePublishedFileVisibility.k_ERemoteStoragePublishedFileVisibilityFriendsOnly : ERemoteStoragePublishedFileVisibility.k_ERemoteStoragePublishedFileVisibilityPrivate); bool flag2 = flag1 & SteamUGC.SetItemVisibility(this.updateHandle, eVisibility); string pszContentFolder = Path.Combine(Directory.GetCurrentDirectory(), info.FolderPath).Replace("\\", "/"); Console.WriteLine("Content Path: " + pszContentFolder); if (!(flag2 & SteamUGC.SetItemContent(this.updateHandle, pszContentFolder))) { Console.WriteLine("Error!"); } string path = info.FolderPath + "/Changelog.txt"; string pchChangeNote = ""; if (File.Exists(path)) { pchChangeNote = File.ReadAllText(path); } this.SubmitItemUpdateResult_t.Set(SteamUGC.SubmitItemUpdate(this.updateHandle, pchChangeNote), (CallResult <Steamworks.SubmitItemUpdateResult_t> .APIDispatchDelegate)null); this.transferStarted = DateTime.Now; this.showLoadingSpinner = true; this.isInUpload = true; this.currentBodyMessage = "Uploading to Steam Workshop..."; this.currentTitleMessage = "Upload in progress"; }
static void SubmitItemTask(SteamAPICall_t handle, UGCUpdateHandle_t updateHandle) { while (!IsCompleted(handle)) { if (updateHandle != UGCUpdateHandle_t.Invalid) { System.Threading.Thread.Sleep(1); EItemUpdateStatus status = SteamUGC.GetItemUpdateProgress(updateHandle, out ulong punBytesProcessed, out ulong punBytesTotal); float progress = (float)punBytesProcessed / (float)punBytesTotal * 100.0f; if (status == EItemUpdateStatus.k_EItemUpdateStatusPreparingConfig) { ClearLine("Processing configuration data..."); } else if (status == EItemUpdateStatus.k_EItemUpdateStatusPreparingContent && !Single.IsNaN(progress)) { ClearLine("Processing files: " + progress.ToString("F2") + " % "); } else if (status == EItemUpdateStatus.k_EItemUpdateStatusUploadingContent && !Single.IsNaN(progress)) { ClearLine("Upload files: " + progress.ToString("F2") + " % "); } else if (status == EItemUpdateStatus.k_EItemUpdateStatusUploadingPreviewFile) { ClearLine("Upload preview file..."); } else if (status == EItemUpdateStatus.k_EItemUpdateStatusCommittingChanges) { ClearLine("Commiting changes..."); } } } SubmitItemUpdateResult_t callback = AllocCallback <SubmitItemUpdateResult_t>(handle, out IntPtr pCallback, SubmitItemUpdateResult_t.k_iCallback); if (callback.m_eResult == EResult.k_EResultOK) { Console.WriteLine("\nSuccessfully submitted item to Steam ! Press any key to continue..."); } else { Console.WriteLine("\nCouldn't submit the item to Steam (" + callback.m_eResult.ToString() + ") ! Press any key to continue..."); } ReleaseCallback(pCallback); }
public void StartUploading(PublishedFileId_t fileID, UGCUpdateHandle_t handle) { AddonItem pItem = null; foreach (Control control in Controls) { if (control is AddonItem) { if (((AddonItem)control).GetItemFileID() == fileID) { pItem = ((AddonItem)control); break; } } } if (pItem != null) { pItem.StartUploading(handle); } }
private static void SetItemAttributes(UGCUpdateHandle_t handle, Mod mod, bool creating) { SteamUGC.SetItemTitle(handle, mod.Name); SteamUGC.SetItemTags(handle, mod.Tags); SteamUGC.SetItemContent(handle, mod.ContentFolder); if (!mod.OriginalUploader) { return; } //only the original uploader (i.e. not contributors) can do the following operations SteamUGC.SetItemDescription(handle, mod.Description); if (mod.Preview != null) { SteamUGC.SetItemPreview(handle, mod.Preview); } if (creating) { SteamUGC.SetItemVisibility(handle, ERemoteStoragePublishedFileVisibility.k_ERemoteStoragePublishedFileVisibilityPrivate); } }
private static void SetWorkshopItemDataFrom(UGCUpdateHandle_t updateHandle, WorkshopItemHook hook, bool creating) { hook.PrepareForWorkshopUpload(); SteamUGC.SetItemTitle(updateHandle, hook.Name); if (creating) { SteamUGC.SetItemDescription(updateHandle, hook.Description); } if (!File.Exists(hook.PreviewImagePath)) { Log.Warning("Missing preview file at " + hook.PreviewImagePath); } else { SteamUGC.SetItemPreview(updateHandle, hook.PreviewImagePath); } IList <string> tags = hook.Tags; tags.Add(VersionControl.CurrentMajor + "." + VersionControl.CurrentMinor); SteamUGC.SetItemTags(updateHandle, tags); SteamUGC.SetItemContent(updateHandle, hook.Directory.FullName); }
internal static void Upload(WorkshopUploadable item) { if (curStage != 0) { Messages.Message("UploadAlreadyInProgress".Translate(), MessageTypeDefOf.RejectInput, historical: false); } else { uploadingHook = item.GetWorkshopItemHook(); if (uploadingHook.PublishedFileId != PublishedFileId_t.Invalid) { if (Prefs.LogVerbose) { Log.Message("Workshop: Starting item update for mod '" + uploadingHook.Name + "' with PublishedFileId " + uploadingHook.PublishedFileId); } curStage = WorkshopInteractStage.SubmittingItem; curUpdateHandle = SteamUGC.StartItemUpdate(SteamUtils.GetAppID(), uploadingHook.PublishedFileId); SetWorkshopItemDataFrom(curUpdateHandle, uploadingHook, creating: false); SteamAPICall_t hAPICall = SteamUGC.SubmitItemUpdate(curUpdateHandle, "[Auto-generated text]: Update on " + DateTime.Now.ToString() + "."); submitResult = CallResult <SubmitItemUpdateResult_t> .Create(OnItemSubmitted); submitResult.Set(hAPICall); } else { if (Prefs.LogVerbose) { Log.Message("Workshop: Starting item creation for mod '" + uploadingHook.Name + "'."); } curStage = WorkshopInteractStage.CreatingItem; SteamAPICall_t hAPICall2 = SteamUGC.CreateItem(SteamUtils.GetAppID(), EWorkshopFileType.k_EWorkshopFileTypeFirst); createResult = CallResult <CreateItemResult_t> .Create(OnItemCreated); createResult.Set(hAPICall2); } Find.WindowStack.Add(new Dialog_WorkshopOperationInProgress()); } }
void PerformWorkshopVisibilityCheck(ulong fileId, System.Action <Util.Maybe <ulong> > onComplete, bool makePrivate) { GameBuilder.SteamUtil.QueryWorkShopItemVisibility(fileId, maybeVisible => { if (maybeVisible.IsEmpty() || maybeVisible.Value == false) { onComplete(Util.Maybe <ulong> .CreateError($"Item was uploaded with ID {fileId}, but we could not look it up afterwards. Are you sure you have agreed to the Steam Subscriber Agreement?")); return; } else { // All goooood onComplete(Util.Maybe <ulong> .CreateWith(fileId)); if (makePrivate) { UGCUpdateHandle_t itemUpdateHandle = SteamUGC.StartItemUpdate(SteamUtils.GetAppID(), new Steamworks.PublishedFileId_t(fileId)); SteamUGC.SetItemVisibility(itemUpdateHandle, ERemoteStoragePublishedFileVisibility.k_ERemoteStoragePublishedFileVisibilityPrivate); SteamUGC.SubmitItemUpdate(itemUpdateHandle, "hide asset"); } } }); }
private void UpdateProgressBar(UGCUpdateHandle_t handle) { ulong bytesDone; ulong bytesTotal; EItemUpdateStatus status = SteamUGC.GetItemUpdateProgress(handle, out bytesDone, out bytesTotal); float progress = (float)bytesDone / (float)bytesTotal; progressBar.value = progress; switch (status) { case EItemUpdateStatus.k_EItemUpdateStatusCommittingChanges: statusText.text = "Committing changes..."; break; case EItemUpdateStatus.k_EItemUpdateStatusUploadingPreviewFile: statusText.text = "Uploading preview image..."; break; case EItemUpdateStatus.k_EItemUpdateStatusUploadingContent: statusText.text = "Uploading content..."; break; case EItemUpdateStatus.k_EItemUpdateStatusPreparingConfig: statusText.text = "Preparing configuration..."; break; case EItemUpdateStatus.k_EItemUpdateStatusPreparingContent: statusText.text = "Preparing content..."; break; // from the docs: "The item update handle was invalid, the job might be finished, a SubmitItemUpdateResult_t call result should have been returned for it." // case EItemUpdateStatus.k_EItemUpdateStatusInvalid: // statusText.text = "Item invalid ... dunno why! :("; // break; } }
/// <summary> /// <para> change preview image file for this item. pszPreviewFile points to local image file, which must be under 1MB in size</para> /// </summary> public static bool SetItemPreview(UGCUpdateHandle_t handle, string pszPreviewFile) { InteropHelp.TestIfAvailableGameServer(); using (var pszPreviewFile2 = new InteropHelp.UTF8StringHandle(pszPreviewFile)) { return NativeMethods.ISteamGameServerUGC_SetItemPreview(handle, pszPreviewFile2); } }
/// <summary> /// <para> change the tags of an UGC item</para> /// </summary> public static bool SetItemTags(UGCUpdateHandle_t updateHandle, System.Collections.Generic.IList<string> pTags) { InteropHelp.TestIfAvailableGameServer(); return NativeMethods.ISteamGameServerUGC_SetItemTags(updateHandle, new InteropHelp.SteamParamStringArray(pTags)); }
/// <summary> /// <para> change the metadata of an UGC item (max = k_cchDeveloperMetadataMax)</para> /// </summary> public static bool SetItemMetadata(UGCUpdateHandle_t handle, string pchMetaData) { InteropHelp.TestIfAvailableGameServer(); using (var pchMetaData2 = new InteropHelp.UTF8StringHandle(pchMetaData)) { return NativeMethods.ISteamGameServerUGC_SetItemMetadata(handle, pchMetaData2); } }
/// <summary> /// <para> change the description of an UGC item</para> /// </summary> public static bool SetItemDescription(UGCUpdateHandle_t handle, string pchDescription) { InteropHelp.TestIfAvailableGameServer(); using (var pchDescription2 = new InteropHelp.UTF8StringHandle(pchDescription)) { return NativeMethods.ISteamGameServerUGC_SetItemDescription(handle, pchDescription2); } }
/// <summary> /// <para> updates an existing preview video for this item</para> /// </summary> public static bool UpdateItemPreviewVideo(UGCUpdateHandle_t handle, uint index, string pszVideoID) { InteropHelp.TestIfAvailableClient(); using (var pszVideoID2 = new InteropHelp.UTF8StringHandle(pszVideoID)) { return NativeMethods.ISteamUGC_UpdateItemPreviewVideo(handle, index, pszVideoID2); } }
/// <summary> /// <para> remove any existing key-value tags with the specified key</para> /// </summary> public static bool RemoveItemKeyValueTags(UGCUpdateHandle_t handle, string pchKey) { InteropHelp.TestIfAvailableClient(); using (var pchKey2 = new InteropHelp.UTF8StringHandle(pchKey)) { return NativeMethods.ISteamUGC_RemoveItemKeyValueTags(handle, pchKey2); } }
public static extern bool ISteamGameServerUGC_SetItemPreview(UGCUpdateHandle_t handle, InteropHelp.UTF8StringHandle pszPreviewFile);
public static extern bool ISteamGameServerUGC_SetItemContent(UGCUpdateHandle_t handle, InteropHelp.UTF8StringHandle pszContentFolder);
public static extern bool ISteamGameServerUGC_SetItemTags(UGCUpdateHandle_t updateHandle, IntPtr pTags);
public static extern bool ISteamGameServerUGC_SetItemVisibility(UGCUpdateHandle_t handle, ERemoteStoragePublishedFileVisibility eVisibility);
public static extern bool ISteamGameServerUGC_SetItemMetadata(UGCUpdateHandle_t handle, InteropHelp.UTF8StringHandle pchMetaData);
public static extern bool ISteamGameServerUGC_SetItemUpdateLanguage(UGCUpdateHandle_t handle, InteropHelp.UTF8StringHandle pchLanguage);
public static extern bool ISteamGameServerUGC_RemoveItemKeyValueTags(UGCUpdateHandle_t handle, InteropHelp.UTF8StringHandle pchKey);
/// <summary> /// <para> change the title of an UGC item</para> /// </summary> public static bool SetItemTitle(UGCUpdateHandle_t handle, string pchTitle) { InteropHelp.TestIfAvailableClient(); using (var pchTitle2 = new InteropHelp.UTF8StringHandle(pchTitle)) { return NativeMethods.ISteamUGC_SetItemTitle(handle, pchTitle2); } }
public static extern bool ISteamGameServerUGC_AddItemKeyValueTag(UGCUpdateHandle_t handle, InteropHelp.UTF8StringHandle pchKey, InteropHelp.UTF8StringHandle pchValue);
/// <summary> /// <para> add preview file for this item. pszPreviewFile points to local file, which must be under 1MB in size</para> /// </summary> public static bool AddItemPreviewFile(UGCUpdateHandle_t handle, string pszPreviewFile, EItemPreviewType type) { InteropHelp.TestIfAvailableClient(); using (var pszPreviewFile2 = new InteropHelp.UTF8StringHandle(pszPreviewFile)) { return NativeMethods.ISteamUGC_AddItemPreviewFile(handle, pszPreviewFile2, type); } }
public static extern bool ISteamGameServerUGC_AddItemPreviewFile(UGCUpdateHandle_t handle, InteropHelp.UTF8StringHandle pszPreviewFile, EItemPreviewType type);
/// <summary> /// <para> remove a preview by index starting at 0 (previews are sorted)</para> /// </summary> public static bool RemoveItemPreview(UGCUpdateHandle_t handle, uint index) { InteropHelp.TestIfAvailableClient(); return NativeMethods.ISteamUGC_RemoveItemPreview(handle, index); }
public static extern bool ISteamGameServerUGC_UpdateItemPreviewVideo(UGCUpdateHandle_t handle, uint index, InteropHelp.UTF8StringHandle pszVideoID);
/// <summary> /// <para> specify the language of the title or description that will be set</para> /// </summary> public static bool SetItemUpdateLanguage(UGCUpdateHandle_t handle, string pchLanguage) { InteropHelp.TestIfAvailableGameServer(); using (var pchLanguage2 = new InteropHelp.UTF8StringHandle(pchLanguage)) { return NativeMethods.ISteamGameServerUGC_SetItemUpdateLanguage(handle, pchLanguage2); } }
public static extern bool ISteamGameServerUGC_RemoveItemPreview(UGCUpdateHandle_t handle, uint index);
/// <summary> /// <para> change the visibility of an UGC item</para> /// </summary> public static bool SetItemVisibility(UGCUpdateHandle_t handle, ERemoteStoragePublishedFileVisibility eVisibility) { InteropHelp.TestIfAvailableGameServer(); return NativeMethods.ISteamGameServerUGC_SetItemVisibility(handle, eVisibility); }
public static extern ulong ISteamGameServerUGC_SubmitItemUpdate(UGCUpdateHandle_t handle, InteropHelp.UTF8StringHandle pchChangeNote);
/// <summary> /// <para> update item content from this local folder</para> /// </summary> public static bool SetItemContent(UGCUpdateHandle_t handle, string pszContentFolder) { InteropHelp.TestIfAvailableGameServer(); using (var pszContentFolder2 = new InteropHelp.UTF8StringHandle(pszContentFolder)) { return NativeMethods.ISteamGameServerUGC_SetItemContent(handle, pszContentFolder2); } }
public static extern EItemUpdateStatus ISteamGameServerUGC_GetItemUpdateProgress(UGCUpdateHandle_t handle, out ulong punBytesProcessed, out ulong punBytesTotal);
/// <summary> /// <para> add new key-value tags for the item. Note that there can be multiple values for a tag.</para> /// </summary> public static bool AddItemKeyValueTag(UGCUpdateHandle_t handle, string pchKey, string pchValue) { InteropHelp.TestIfAvailableGameServer(); using (var pchKey2 = new InteropHelp.UTF8StringHandle(pchKey)) using (var pchValue2 = new InteropHelp.UTF8StringHandle(pchValue)) { return NativeMethods.ISteamGameServerUGC_AddItemKeyValueTag(handle, pchKey2, pchValue2); } }
/// <summary> /// <para> commit update process started with StartItemUpdate()</para> /// </summary> public static SteamAPICall_t SubmitItemUpdate(UGCUpdateHandle_t handle, string pchChangeNote) { InteropHelp.TestIfAvailableGameServer(); using (var pchChangeNote2 = new InteropHelp.UTF8StringHandle(pchChangeNote)) { return (SteamAPICall_t)NativeMethods.ISteamGameServerUGC_SubmitItemUpdate(handle, pchChangeNote2); } }
public static EItemUpdateStatus GetItemUpdateProgress(UGCUpdateHandle_t handle, out ulong punBytesProcessed, out ulong punBytesTotal) { InteropHelp.TestIfAvailableGameServer(); return NativeMethods.ISteamGameServerUGC_GetItemUpdateProgress(handle, out punBytesProcessed, out punBytesTotal); }
public static extern bool ISteamGameServerUGC_SetItemDescription(UGCUpdateHandle_t handle, InteropHelp.UTF8StringHandle pchDescription);