public void DoUpload() { if (NameView.Text.Trim().Length == 0 || DescriptionView.Text.Trim().Length == 0) { return; } CloseButton.AllowMouseEvents.Value = UploadButton.AllowMouseEvents.Value = false; string filePath = this.main.GetFullMapPath(); string imagePath = string.Format("{0}.png", filePath.Substring(0, filePath.LastIndexOf('.'))); string description = DescriptionView.Text; string name = NameView.Text; string steamFilePath = string.Format("workshop/maps/{0}.map", MD5(filePath)); string steamImagePath = string.Format("workshop/maps/{0}.png", MD5(imagePath)); StatusString.Value = "Storing map..."; if (SteamWorker.WriteFileUGC(filePath, steamFilePath)) { StatusString.Value = "Storing image..."; if (!SteamWorker.WriteFileUGC(imagePath, steamImagePath)) { StatusString.Value = "Failed to store image."; CloseButton.AllowMouseEvents.Value = UploadButton.AllowMouseEvents.Value = true; return; } } else { CloseButton.AllowMouseEvents.Value = UploadButton.AllowMouseEvents.Value = true; StatusString.Value = "Failed to store map."; return; } StatusString.Value = "Uploading map..."; this.fileShareResult = SteamWorker.ShareFileUGC(steamFilePath, (b, t) => { if (b) { StatusString.Value = "Uploading image..."; this.fileShareResult = SteamWorker.ShareFileUGC(steamImagePath, (b1, handleT) => { if (b1) { StatusString.Value = "Finalizing Entry..."; if (string.IsNullOrEmpty(this.currentPublishedFile.m_pchFileName)) { // Upload new this.filePublishResult = SteamWorker.UploadWorkShop(steamFilePath, steamImagePath, name, description, (publishSuccess, needsAcceptEULA, publishedFile) => { if (publishSuccess) { StatusString.Value = "Entry created!"; DescriptionView.ClearText(); NameView.ClearText(); CloseButton.AllowMouseEvents.Value = UploadButton.AllowMouseEvents.Value = true; SteamWorker.SetAchievement("level_editor"); } else { StatusString.Value = "Publish failed."; CloseButton.AllowMouseEvents.Value = UploadButton.AllowMouseEvents.Value = true; } }); } else { // Update existing this.fileUpdateResult = SteamWorker.UpdateWorkshopMap(currentPublishedFile.m_nPublishedFileId, steamFilePath, steamImagePath, name, description, publishSuccess => { if (publishSuccess) { StatusString.Value = "Entry updated!"; CloseButton.AllowMouseEvents.Value = UploadButton.AllowMouseEvents.Value = true; SteamRemoteStorage.FileDelete(this.currentPublishedFile.m_pchFileName); } else { StatusString.Value = "Update failed."; CloseButton.AllowMouseEvents.Value = UploadButton.AllowMouseEvents.Value = true; } }); } } else { StatusString.Value = "Failed to upload image."; CloseButton.AllowMouseEvents.Value = UploadButton.AllowMouseEvents.Value = true; } }); } else { StatusString.Value = "Failed to upload map."; CloseButton.AllowMouseEvents.Value = UploadButton.AllowMouseEvents.Value = true; } }); }
public void OnTextSubmitted() { this.historyIndex = -1; main.Console.ConsoleUserInput(ConsoleInputView.Text); ConsoleInputView.ClearText(); }