private void _joinLobby(MsgTickerJoinLobby message) { if (_tickerState == TickerState.InLobby) { return; } if (_gameChat != null) { _gameChat.TextSubmitted -= _chatConsole.ParseChatMessage; _chatConsole.AddString -= _gameChat.AddLine; _gameChat.Dispose(); _gameChat = null; } _tickerState = TickerState.InLobby; _lobby = new LobbyGui(); _userInterfaceManager.StateRoot.AddChild(_lobby); _lobby.Chat.TextSubmitted += _chatConsole.ParseChatMessage; _chatConsole.AddString += _lobby.Chat.AddLine; _lobby.Chat.DefaultChatFormat = "ooc \"{0}\""; _lobby.ServerName.Text = _baseClient.GameInfo.ServerName; _inputManager.SetInputCommand(EngineKeyFunctions.FocusChat, InputCmdHandler.FromDelegate(session => { _lobby.Chat.Input.GrabKeyboardFocus(); })); _updateLobbyUi(); _lobby.ObserveButton.OnPressed += args => { _chatConsole.ProcessCommand("observe"); }; _lobby.ReadyButton.OnPressed += args => { if (!_gameStarted) { return; } _chatConsole.ProcessCommand("joingame"); }; _lobby.ReadyButton.OnToggled += args => { if (_gameStarted) { return; } _chatConsole.ProcessCommand($"toggleready {args.Pressed}"); }; _lobby.LeaveButton.OnPressed += args => _chatConsole.ProcessCommand("disconnect"); }
private void BaseClientOnRunLevelChanged(object sender, RunLevelChangedEventArgs e) { if (e.NewLevel != ClientRunLevel.Initialize) { return; } _tickerState = TickerState.Unset; _lobby?.Dispose(); _lobby = null; _gameChat?.Dispose(); _gameChat = null; }