Example #1
0
 public void SaveFromShortcut()
 {
     if (HasCurrentBeenSaved())
     {
         userMain.AddDebugMessage("Project saved!");
         if (!IsOpen())
         {
             string existingBundleId = GetActiveBundleId();
             if (existingBundleId != null)
             {
                 GameBundle bundle = gameBundleLibrary.GetBundle(existingBundleId);
                 saveUI.nameInput.text        = bundle.GetMetadata().name;
                 saveUI.descriptionInput.text = bundle.GetMetadata().description;
                 currentSaveImage             = bundle.GetThumbnail();
             }
         }
         SaveOverwrite();
     }
     else
     {
         Open();
     }
 }
Example #2
0
 public void SaveBeforeExit(System.Action quitCallback)
 {
     this.quitAfterSave = true;
     this.quitCallback  = quitCallback;
     if (HasCurrentBeenSaved())
     {
         if (!IsOpen())
         {
             string existingBundleId = GetActiveBundleId();
             if (existingBundleId != null)
             {
                 GameBundle bundle = gameBundleLibrary.GetBundle(existingBundleId);
                 saveUI.nameInput.text        = bundle.GetMetadata().name;
                 saveUI.descriptionInput.text = bundle.GetMetadata().description;
                 currentSaveImage             = bundle.GetThumbnail();
             }
         }
         SaveOverwrite();
     }
     else
     {
         Open();
     }
 }
Example #3
0
    public void Open()
    {
        if (IsOpen())
        {
            return;
        }
        UpdateSaveButtonTextAndVisibility();

        saveUI.feedbackTextPrimary.gameObject.SetActive(false);

        saveUI.feedbackTextSecondary.gameObject.SetActive(false);
        gameObject.SetActive(true);
        Update();

        string existingBundleId = GetActiveBundleId();

        if (existingBundleId != null)
        {
            GameBundle bundle = gameBundleLibrary.GetBundle(existingBundleId);
            saveUI.nameInput.text        = bundle.GetMetadata().name;
            saveUI.descriptionInput.text = bundle.GetMetadata().description;
            currentSaveImage             = bundle.GetThumbnail();

#if USE_STEAMWORKS
            WorkshopItemUpdate uploadItem = null;

            //see if the xml file is there
            if (File.Exists(Path.Combine(gameBundleLibrary.GetBundleDirectory(existingBundleId), SteamUtil.WorkshopItemInfoFileName)))
            {
                uploadItem = SteamWorkshopMain.Instance.GetItemUpdateFromFolder(gameBundleLibrary.GetBundleDirectory(existingBundleId));
            }

            if (uploadItem != null)
            {
                string url = $"https://steamcommunity.com/sharedfiles/filedetails/?id={uploadItem.SteamNative.m_nPublishedFileId.ToString()}";
                saveUI.feedbackTextSecondary.SetText($"Workshop URL (must be logged in):\n{url}");
                saveUI.feedbackTextSecondaryButton.onClick.AddListener(() => Application.OpenURL(url));
                saveUI.feedbackTextSecondary.gameObject.SetActive(true);
                fileOnSteamWorkshop = true;
            }
            else
#endif
            {
                saveUI.feedbackTextSecondary.gameObject.SetActive(false);
                fileOnSteamWorkshop = false;
            }
        }
        else if (GameBuilderApplication.IsRecoveryMode)
        {
            saveUI.feedbackTextPrimary.gameObject.SetActive(true);
            saveUI.feedbackTextPrimary.text = "Recovering will create a new save, and you can continue building normally from it. Your old project will still exist in your game library in case you need to go back to it.";
            saveUI.feedbackTextPrimaryButton.onClick.RemoveAllListeners();

            // Fill in these fields for convenience
            string     autosaveBundleId = GameBuilderApplication.CurrentGameOptions.bundleIdToLoad;
            GameBundle bundle           = gameBundleLibrary.GetBundle(autosaveBundleId);
            saveUI.nameInput.text        = bundle.GetMetadata().name;
            saveUI.descriptionInput.text = bundle.GetMetadata().description;
            currentSaveImage             = bundle.GetThumbnail();
        }

        if (currentSaveImage != null)
        {
            saveUI.screenshotImage.gameObject.SetActive(true);
            saveUI.screenshotImage.sprite = Sprite.Create(currentSaveImage, new Rect(0, 0, currentSaveImage.width, currentSaveImage.height), new Vector2(.5f, .5f), 100);
        }
    }