Example #1
0
 void LoadGame(GameBuilderApplication.PlayOptions playOpts)
 {
     if (localVoosFile != null)
     {
         // Two action logs intentional.
     }
     else
     {
         ulong itemId = workshopItem.SteamNative.m_nPublishedFileId.m_PublishedFileId;
         // Two action logs intentional.
     }
     loadingScreen.ShowAndDo(() =>
     {
         if (localVoosFile != null)
         {
             var gameOpts = new GameBuilderApplication.GameOptions {
                 playOptions = playOpts
             };
             loadingScreen.ShowAndDo(() => sceneController.RestartAndLoad(localVoosFile, gameOpts));
         }
         else
         {
             sceneController.LoadWorkshopItem(
                 new LoadableWorkshopItem(workshopItem),
                 playOpts,
                 thumbnailImage.sprite.texture);
         }
     });
 }
    // Update is called once per frame
    void Update()
    {
        string url = GUIUtility.systemCopyBuffer;

        // Don't incur cost of checking, or bother the player, if buffer is unchanged.
        if (url == lastCopyBuffer)
        {
            return;
        }
        lastCopyBuffer = url;

        ulong workshopId = Util.ExtractIdFromWorkshopUrl(url);

        if (workshopId != 0)
        {
            popups.ShowTwoButtons($"You copied a Steam Workshop URL! Play it?\nDetected item ID: {workshopId}",
                                  $"Play", () =>
            {
                float progress                 = 0f;
                bool keepShowing               = true;
                var downloadingPopup           = new DynamicPopup.Popup();
                downloadingPopup.getMessage    = () => $"Downloading.. {Mathf.Floor((progress * 100))} %";
                downloadingPopup.keepShowing   = () => keepShowing;
                downloadingPopup.isCancellable = false;
                popups.Show(downloadingPopup);

                string displayName = $"Item {workshopId}";

                workshopSource.Get(workshopId, path =>
                {
                    keepShowing = false;
                    if (path.IsEmpty())
                    {
                        popups.ShowWithCancel($"Woops - could not download the workshop item. Maybe restart and try again?\nMessage: {path.GetErrorMessage()}", "OK", null, 800f);
                    }
                    else
                    {
                        loadingScreen.ShowAndDo(() =>
                                                sceneController.LoadWorkshopItem(
                                                    new LoadableWorkshopItem
                        {
                            displayName          = displayName,
                            installedLocalFolder = path.Get(),
                            steamId = workshopId
                        },
                                                    new GameBuilderApplication.PlayOptions(), null));
                    }
                },
                                   prog => progress = prog,
                                   // TODO could also grab thumbnail async..
                                   item => displayName = item.Name
                                   );
            },
                                  "Cancel", () => { });
        }
    }
Example #3
0
    void LoadByWorkshopItem(WorkshopItem item, GameBuilderApplication.PlayOptions playOpts)
    {
        Debug.Assert(item.IsSubscribed, "Item is not subscribed");
        Debug.Assert(!item.IsDownloading, "Item is still downloading");
        Debug.Assert(item.IsInstalled, "Item is not installed");

        if (thumbnailImage.sprite == null)
        {
            Util.LogError($"WARNING tn sprite is null");
        }
        Texture2D tnTexture = thumbnailImage.sprite?.texture;

        loadingScreen.ShowAndDo(() =>
        {
            sceneController.LoadWorkshopItem(new LoadableWorkshopItem(item), playOpts, tnTexture);
        });
    }
 void GameResuming.ResumeOptionHandler.HandleWorkshopItem(WorkshopItem item)
 {
     // tutorialButton.gameObject.SetActive(false);
     resumeButton.gameObject.SetActive(true);
     resumeButton.SetThumbnailUrl(item.PreviewImageURL);
     resumeButton.SetName(item.Name);
     resumeButton.OnClick = () =>
     {
         popups.AskHowToPlay(playOpts =>
         {
             loadingScreen.ShowAndDo(() =>
             {
                 scenes.LoadWorkshopItem(new LoadableWorkshopItem(item), playOpts, null);
             });
         });
     };
 }