Exemplo n.º 1
0
    public override void OnConnectionFail(DisconnectCause cause)
    {
        if (cause == DisconnectCause.InvalidRegion)
        {
            OnInvalidJoinCodeRegion();
        }
        else
        {
            voosEngine.HackyForceSetIsRunning(false);

            if (Time.unscaledTime > 10f)
            {
                autosaves.SetPaused(true);
                autosaves.TriggerAutosave(autosaveBundleId =>
                {
                    if (numOthersWhenConnected == 0)
                    {
                        string userMessage = $"Woops! You were disconnected. Reason:\n{cause.ToString()}\nWe've auto-saved the project, so you can recover it and restart the multiplayer session.";
                        Util.LogError(userMessage);
                        popups.ShowTwoButtons(userMessage,
                                              "Recover Autosave",
                                              () =>
                        {
                            scenes.RestartAndLoadLibraryBundle(gameBundleLibrary.GetBundleEntry(autosaveBundleId), new GameBuilderApplication.PlayOptions());
                        },
                                              "Go to Main Menu",
                                              () => scenes.LoadSplashScreen(),
                                              800f
                                              );
                    }
                    else
                    {
                        string userMessage = $"Woops! You were disconnected. Reason:\n{cause.ToString()}. Please reconnect.\n<size=80%><color=#888888>NOTE: If the multiplayer game is gone, you can recover the autosave in your Game Library.</color></size>";
                        Util.LogError(userMessage);
                        popups.ShowTwoButtons(
                            userMessage,
                            $"Reconnect to {roomNameWhenConnected}",
                            () => scenes.JoinMultiplayerGameByCode(roomNameWhenConnected),
                            "Go to Main Menu",
                            () => scenes.LoadSplashScreen(),
                            800f);
                    }
                });
            }
            else
            {
                string userMessage = $"Woops! You were disconnected. Reason:\n{cause.ToString()}.";
                Util.LogError(userMessage);
                popups.Show(userMessage, "Back to Main Menu", () =>
                {
                    scenes.LoadSplashScreen();
                });
            }
        }
    }
    // 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", () => { });
        }
    }
Exemplo n.º 3
0
    public void TriggerUndo()
    {
        if (IsEmpty())
        {
            return;
        }
        if (waitingOnPopup)
        {
            return;
        }

        var node = stack.Last;
        var item = node.Value;

        string unableReason = item.getUnableToUndoReason();

        if (unableReason != null)
        {
            waitingOnPopup = true;
            popups.ShowTwoButtons(
                $"Woops, we cannot undo '{item.actionLabel}'. {unableReason}",
                "Try again later", () =>
            {
                waitingOnPopup = false;
            },
                "Delete this undo step", () =>
            {
                // Remove this from undo history
                stack.Remove(node);
                waitingOnPopup = false;
            },
                600f);
        }
        else
        {
            // Undo it, and move it onto redo stack.
            item.undo();
            stack.Remove(node);
            redoStack.AddLast(item);

            onUndone?.Invoke(item);
        }
    }
Exemplo n.º 4
0
    IEnumerator SavingCoroutine()
    {
        while (true)
        {
            yield return(new WaitForSecondsRealtime(periodSeconds));

            // Don't autosave during recovery mode. You might be overwriting an
            // autosave that the user wants to recover!
            if (this.isActiveAndEnabled && !GameBuilderApplication.IsRecoveryMode && !paused)
            {
                try
                {
                    DoAutosave(bundleId =>
                    {
                        // HACK HACK. Only because CMS is tied to player panels, when it really should be global.
                        if (notes == null)
                        {
                            notes = FindObjectOfType <HudNotifications>();
                        }

                        if (notes != null)
                        {
                            notes.AddMessage($"Auto-saved!");
                        }
                    });
                }
                catch (System.Exception e)
                {
                    popups.ShowTwoButtons(
                        $"Woops! Failed to autosave due to error:\n{e.Message}\nWe will disable autosaves until you restart Game Builder. Apologies for the error!",
                        "OK", () => { },
                        "Copy error details", () => { Util.CopyToUserClipboard(e.ToString()); },
                        800f);
                    SetPaused(true);
                }
            }
        }
    }