IEnumerator CreateMyLibraryThumbnails() { foreach (GameBundleLibrary.Entry entry in gameBundleLibrary.Enumerate()) { GameThumbnail gameThumbnail = Instantiate(gameThumbnailPrefab).GetComponent <GameThumbnail>(); GameBundle.Metadata metadata = entry.bundle.GetMetadata(); Texture2D texture = entry.bundle.GetThumbnail(); if (texture != null) { gameThumbnail.SetThumbnail(texture); } else { gameThumbnail.SetThumbnail(placeholderThumbnailTexture); } if (AutoSaveController.IsAutosave(entry)) { gameThumbnail.SetGameSource(GameDetail.GameSource.Autosave); } else { gameThumbnail.SetGameSource(GameDetail.GameSource.Local); } gameThumbnail.SetName(metadata.name); gameThumbnail.OnClick = () => OpenLibraryEntry(gameThumbnail, entry); gameThumbnail.GetWriteTime = () => GetBundleWriteTime(entry.id); gameThumbnail.GetDescription = () => { return(metadata.description); }; AddThumbnail(gameThumbnail, AutoSaveController.IsAutosave(entry) ? AUTOSAVES : SAVED); yield return(null); } }
void UploadActiveSaveToWorkshop(bool newUpload = false) { var bundleId = GetActiveBundleId(); Debug.Assert(bundleId != null); uploaddesired = false; uploading = true; string contentPath = gameBundleLibrary.GetBundleDirectory(bundleId); WorkshopItemUpdate uploadItem = null; if (File.Exists(Path.Combine(contentPath, SteamUtil.WorkshopItemInfoFileName))) { uploadItem = SteamWorkshopMain.Instance.GetItemUpdateFromFolder(contentPath); } if (uploadItem == null || newUpload) { uploadItem = new WorkshopItemUpdate(); } GameBundle.Metadata metadata = GetMetadataFromUI(); uploadItem.Name = metadata.name; uploadItem.Description = metadata.description; uploadItem.ContentPath = contentPath; if (gameBundleLibrary.GetBundle(bundleId).GetThumbnail() != null) { uploadItem.IconPath = gameBundleLibrary.GetBundle(bundleId).GetThumbnailPath(); } uploadItem.Tags.Add(SteamUtil.GameBuilderTags.Project.ToString()); SteamWorkshopMain.Instance.Upload(uploadItem, (args) => UploadCallback(args, uploadItem)); currentUploadItem = uploadItem; }
void DoAutosave(System.Action <string> onComplete) { using (Util.Profile("autosave")) { var sw = new System.Diagnostics.Stopwatch(); sw.Restart(); string destId = GetSlotBundleId(nextSlot); nextSlot = (nextSlot + 1) % maxSlots; // SaveMaybeOverwrite doesn't delete all files. Like thumbnails, if any. using (Util.Profile("deleteSlotBundle")) { if (bundleLibrary.BundleExists(destId)) { bundleLibrary.DeletePermanently(destId); } } GameBundle.Metadata meta = new GameBundle.Metadata { name = $"{System.DateTime.Now} Autosave", description = $"" }; // Copy from the active bundle so our autosave looks like it. string srcId = GameBuilderApplication.ActiveBundleId; using (Util.Profile("CopyBundle")) { if (srcId != null && bundleLibrary.BundleExists(srcId)) { var srcBundle = bundleLibrary.GetBundle(srcId); meta = srcBundle.GetMetadata(); meta.name += $" ({System.DateTime.Now} Autosave)"; bundleLibrary.CopyBundle(srcId, destId); } } using (Util.Profile("SaveBundle")) { // Now overwrite just the scene.voos file bundleLibrary.SaveMaybeOverwrite(saveLoad, destId, meta, null, () => { sw.Stop(); Util.Log($"autosave took total of {sw.ElapsedMilliseconds}ms"); // TODO copy the steam workshop meta data too, if it's there. lastAutosaveId = destId; lastAutosaveTime = Time.unscaledTime; onComplete?.Invoke(destId); }); } } }
public void OpenLocal(GameBundleLibrary.Entry entry) { gameObject.SetActive(true); gameSource = GameSource.Local; GameBundle.Metadata metadata = entry.bundle.GetMetadata(); descriptionField.text = $"<b>{metadata.name}</b>\n{metadata.description}"; Texture2D texture = entry.bundle.GetThumbnail(); SetThumbnail(texture != null ? texture : placeholderThumbnailTexture); playAction = () => OnPlayTriggered(playOpts => { LoadLibraryBundle(entry, playOpts); }); buildAction = () => popups.Show("Not implemented", "OK", () => { }); }
GameBundle.Metadata GetMetadataFromUI() { GameBundle.Metadata metadata = new GameBundle.Metadata(); if (saveUI.nameInput.text.Length > 0) { metadata.name = saveUI.nameInput.text; } else { metadata.name = "(unnamed scene)"; } if (saveUI.descriptionInput.text.Length > 0) { metadata.description = saveUI.descriptionInput.text; } else { metadata.description = "(no description)"; } return(metadata); }