コード例 #1
0
        private static async void ClientShowWelcomeMessageInternal(string welcomeMessage)
        {
            var game       = Client.CurrentGame;
            var serverInfo = game.ServerInfo;

            await LoadingSplashScreenManager.WaitHiddenAsync();

            if (game.ConnectionState != ConnectionState.Connected ||
                serverInfo != Client.CurrentGame.ServerInfo)
            {
                return;
            }

            var dialogWindow = DialogWindow.ShowDialog(
                string.Format(WelcomeToServerTitleFormat, serverInfo.ServerName),
                new ScrollViewer()
            {
                MaxHeight = 380,
                VerticalScrollBarVisibility = ScrollBarVisibility.Auto,
                Content = new FormattedTextBlock()
                {
                    Content             = welcomeMessage,
                    TextWrapping        = TextWrapping.Wrap,
                    TextTrimming        = TextTrimming.None,
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    VerticalAlignment   = VerticalAlignment.Center
                }
            },
                closeByEscapeKey: false);

            dialogWindow.HorizontalContentAlignment = HorizontalAlignment.Stretch;
            dialogWindow.GameWindow.FocusOnControl  = null;
            dialogWindow.GameWindow.Width           = 530;
            dialogWindow.GameWindow.UpdateLayout();
        }
コード例 #2
0
        private static void RefreshCurrentGameServerConnectionState()
        {
            ClientCursorSystem.CurrentCursorId = CursorId.Default;

            MainMenuOverlay.UpdateActiveTab();

            var currentGameService = Client.CurrentGame;
            var isConnected        = currentGameService.ConnectionState == ConnectionState.Connected;
            var isConnecting       = currentGameService.ConnectionState == ConnectionState.Connecting;

            if (!isConnected &&
                !isConnecting &&
                Client.MasterServer.CurrentPlayerIsLoggedIn)
            {
                var isEditor = Api.IsEditor;
                if (isEditor || Api.Client.Input.IsKeyHeld(InputKey.F1))
                {
                    if (isEditor)
                    {
                        Logger.Important("Editor mode: automatically connect to the local game server");
                    }

                    currentGameService.ConnectToServer(new ServerAddress());
                    isConnecting = true;
                }
            }

            if (isConnecting)
            {
                // ReSharper disable once CanExtractXamlLocalizableStringCSharp
                LoadingSplashScreenManager.Show("connecting to the server");
                MainMenuOverlay.IsHidden = true;
                return;
            }

            if (isConnected &&
                !Client.Scene.IsEverythingLoaded)
            {
                // ensure it's shown
                // ReSharper disable once CanExtractXamlLocalizableStringCSharp
                LoadingSplashScreenManager.Show("not everything is loaded yet");
                // ensure it's allowed to hide (when everything will be loaded)
                LoadingSplashScreenManager.Hide();
                MainMenuOverlay.IsHidden = true;
                return;
            }

            LoadingSplashScreenManager.Hide();

            if (isConnected)
            {
                // connected and everything is loaded - can play now
                return;
            }

            // not connected to the game server
            // force menu overlay in non-game mode
            MainMenuOverlay.IsHidden = false;
        }
コード例 #3
0
        private async void CreateCharacter()
        {
            (CharacterHumanFaceStyle style, bool isMale)selectedStyle
                = this.characterCustomizationControl.GetSelectedStyle();

            // show splash screen
            LoadingSplashScreenManager.Show("Character created", displayStructureInfos: false);
            await LoadingSplashScreenManager.WaitShownAsync();

            // select the style only now, when the loading splash is displayed,
            // so there is no stuttering of the loading splash screen animation
            CharacterStyleSystem.ClientChangeStyle(selectedStyle.style, selectedStyle.isMale);
            CharacterCreationSystem.ClientSelectOrigin(this.SelectedOrigin.ProtoCharacterOrigin);

            this.closeCallback();

            // allow hiding after a short delay (it will still check whether everything is loaded)
            ClientTimersSystem.AddAction(
                delaySeconds: 1.0 + Math.Min(1, Api.Client.CurrentGame.PingGameSeconds),
                LoadingSplashScreenManager.Hide);
        }