public bool EnterChatMessage(GUITextBox textBox, string message) { textBox.TextColor = ChatMessage.MessageColor[(int)ChatMessageType.Default]; if (string.IsNullOrWhiteSpace(message)) { if (textBox == chatBox.InputBox) { textBox.Deselect(); } return(false); } if (this == GameMain.Server) { GameMain.Server.SendChatMessage(message, null, null); } else if (this == GameMain.Client) { GameMain.Client.SendChatMessage(message); } textBox.Deselect(); textBox.Text = ""; return(true); }
public virtual void Update(float deltaTime) { if (gameStarted && Screen.Selected == GameMain.GameScreen) { chatMsgBox.Visible = Character.Controlled == null || Character.Controlled.CanSpeak; inGameHUD.Update(deltaTime); GameMain.GameSession.CrewManager.Update(deltaTime); if (Character.Controlled == null || Character.Controlled.IsDead) { GameMain.GameScreen.Cam.TargetPos = Vector2.Zero; GameMain.LightManager.LosEnabled = false; } } if (PlayerInput.KeyHit(InputType.Chat) && chatMsgBox.Visible) { if (chatMsgBox.Selected) { chatMsgBox.Text = ""; chatMsgBox.Deselect(); } else { chatMsgBox.Select(); } } }
public void UpdateHUD(float deltaTime) { GUITextBox msgBox = (Screen.Selected == GameMain.GameScreen ? chatBox.InputBox : GameMain.NetLobbyScreen.TextBox); if (gameStarted && Screen.Selected == GameMain.GameScreen) { if (!GUI.DisableHUD) { inGameHUD.UpdateManually(deltaTime); chatBox.Update(deltaTime); if (Character.Controlled == null) { myCharacterFrameOpenState = GameMain.NetLobbyScreen.MyCharacterFrameOpen ? myCharacterFrameOpenState + deltaTime * 5 : myCharacterFrameOpenState - deltaTime * 5; myCharacterFrameOpenState = MathHelper.Clamp(myCharacterFrameOpenState, 0.0f, 1.0f); var myCharFrame = GameMain.NetLobbyScreen.MyCharacterFrame; int padding = GameMain.GraphicsWidth - myCharFrame.Parent.Rect.Right; myCharFrame.RectTransform.AbsoluteOffset = Vector2.SmoothStep(new Vector2(-myCharFrame.Rect.Width - padding, 0.0f), new Vector2(-padding, 0), myCharacterFrameOpenState).ToPoint(); } } if (Character.Controlled == null || Character.Controlled.IsDead) { GameMain.GameScreen.Cam.TargetPos = Vector2.Zero; GameMain.LightManager.LosEnabled = false; } } //tab doesn't autoselect the chatbox when debug console is open, //because tab is used for autocompleting console commands if ((PlayerInput.KeyHit(InputType.Chat) || PlayerInput.KeyHit(InputType.RadioChat)) && !DebugConsole.IsOpen && (Screen.Selected != GameMain.GameScreen || msgBox.Visible)) { if (msgBox.Selected) { msgBox.Text = ""; msgBox.Deselect(); } else { msgBox.Select(); if (Screen.Selected == GameMain.GameScreen && PlayerInput.KeyHit(InputType.RadioChat)) { msgBox.Text = "r; "; } } } if (ServerLog.LogFrame != null) ServerLog.LogFrame.AddToGUIUpdateList(); }
public virtual void Update(float deltaTime) { #if CLIENT GUITextBox msgBox = (Screen.Selected == GameMain.GameScreen ? chatMsgBox : GameMain.NetLobbyScreen.TextBox); if (gameStarted && Screen.Selected == GameMain.GameScreen) { msgBox.Visible = Character.Controlled == null || Character.Controlled.CanSpeak; if (!GUI.DisableHUD) { inGameHUD.Update(deltaTime); GameMain.GameSession.CrewManager.Update(deltaTime); } if (Character.Controlled == null || Character.Controlled.IsDead) { GameMain.GameScreen.Cam.TargetPos = Vector2.Zero; GameMain.LightManager.LosEnabled = false; } } //tab doesn't autoselect the chatbox when debug console is open, //because tab is used for autocompleting console commands if ((PlayerInput.KeyHit(InputType.Chat) || PlayerInput.KeyHit(InputType.RadioChat)) && !DebugConsole.IsOpen && (Screen.Selected != GameMain.GameScreen || msgBox.Visible)) { if (msgBox.Selected) { msgBox.Text = ""; msgBox.Deselect(); } else { msgBox.Select(); if (Screen.Selected == GameMain.GameScreen && PlayerInput.KeyHit(InputType.RadioChat)) { msgBox.Text = "r; "; msgBox.OnTextChanged?.Invoke(msgBox, msgBox.Text); } } } #endif }