Esempio n. 1
0
        public static bool Prefix(MultiplayerModeSelectionFlowCoordinator __instance, ConnectionFailedReason reason)
        {
            Plugin.Log.Warn($"Multiplayer connection failed, reason: {reason}");

            if (MpModeSelection.WeInitiatedConnection)
            {
                // We only take over error handling UI if we initiated the connection
                if (reason == ConnectionFailedReason.ConnectionCanceled)
                {
                    // ...and if it's just a self-cancel, return to the browser immediately.
                    MpModeSelection.CancelLobbyJoin();
                    MpModeSelection.MakeServerBrowserTopView();
                }
                else
                {
                    MpModeSelection.PresentConnectionFailedError
                    (
                        errorMessage: ConnectionErrorText.Generate(reason),
                        canRetry: reason != ConnectionFailedReason.InvalidPassword && reason != ConnectionFailedReason.VersionMismatch
                    );
                }
                return(false);
            }
            return(true);
        }
        public static void PresentConnectionError(ConnectionFailedReason reason)
        {
            _mpLobbyConnectionController.LeaveLobby();
            _joiningLobbyViewController.HideLoading();

            if (reason != ConnectionFailedReason.ConnectionCanceled)
            {
                var canRetry = (LastConnectToHostedGame != null &&
                                reason != ConnectionFailedReason.InvalidPassword &&
                                reason != ConnectionFailedReason.VersionMismatch);

                _simpleDialogPromptViewController.Init("Connection failed", ConnectionErrorText.Generate(reason), "Back to browser", canRetry ? "Retry connection" : null, delegate(int btnId)
                {
                    switch (btnId)
                    {
                    default:
                    case 0:     // Back to browser
                        ReplaceTopViewController(PluginUi.ServerBrowserViewController, null, ViewController.AnimationType.In, ViewController.AnimationDirection.Vertical);
                        break;

                    case 1:     // Retry connection
                        ConnectToHostedGame(LastConnectToHostedGame);
                        break;
                    }
                });
                ReplaceTopViewController(_simpleDialogPromptViewController, null, ViewController.AnimationType.In, ViewController.AnimationDirection.Vertical);
            }
            else
            {
                ReplaceTopViewController(PluginUi.ServerBrowserViewController, null, ViewController.AnimationType.In, ViewController.AnimationDirection.Vertical);
            }
        }