partial void ShowOnDisplay(string input) { while (historyBox.Content.CountChildren > 60) { historyBox.RemoveChild(historyBox.Content.Children.First()); } GUITextBlock newBlock = new GUITextBlock( new RectTransform(new Vector2(1, 0), historyBox.Content.RectTransform, anchor: Anchor.TopCenter), "> " + input, textColor: Color.LimeGreen, wrap: true) { CanBeFocused = false }; if (fillerBlock != null) { float y = fillerBlock.RectTransform.RelativeSize.Y - newBlock.RectTransform.RelativeSize.Y; if (y > 0) { fillerBlock.RectTransform.RelativeSize = new Vector2(1, y); } else { historyBox.RemoveChild(fillerBlock); fillerBlock = null; } } historyBox.RecalculateChildren(); historyBox.UpdateScrollBarSize(); historyBox.ScrollBar.BarScrollValue = 1; }
public void WriteLine(string line, MessageType messageType) { //string logLine = "[" + DateTime.Now.ToLongTimeString() + "] " + line; var newText = new LogMessage(line, messageType); lines.Enqueue(newText); if (LogFrame != null) { AddLine(newText); listBox.UpdateScrollBarSize(); } unsavedLineCount++; if (unsavedLineCount >= LinesPerFile) { Save(); unsavedLineCount = 0; } while (lines.Count > LinesPerFile) { lines.Dequeue(); } while (listBox != null && listBox.children.Count > LinesPerFile) { listBox.RemoveChild(listBox.children[0]); } }
public void AddChatMessage(ChatMessage message) { GameServer.Log(message.TextWithSender, ServerLog.MessageType.Chat); string displayedText = message.Text; if (message.Sender != null && !message.Sender.IsDead) { message.Sender.ShowSpeechBubble(2.0f, ChatMessage.MessageColor[(int)message.Type]); } GameMain.NetLobbyScreen.NewChatMessage(message); while (chatBox.CountChildren > 20) { chatBox.RemoveChild(chatBox.children[1]); } if (!string.IsNullOrWhiteSpace(message.SenderName)) { displayedText = message.SenderName + ": " + displayedText; } GUITextBlock msg = new GUITextBlock(new Rectangle(0, 0, chatBox.Rect.Width - 40, 0), displayedText, ((chatBox.CountChildren % 2) == 0) ? Color.Transparent : Color.Black * 0.1f, message.Color, Alignment.Left, Alignment.TopLeft, "", null, true, GUI.SmallFont); msg.UserData = message.SenderName; msg.Padding = new Vector4(20.0f, 0, 0, 0); float prevSize = chatBox.BarSize; msg.Padding = new Vector4(20, 0, 0, 0); chatBox.AddChild(msg); if ((prevSize == 1.0f && chatBox.BarScroll == 0.0f) || (prevSize < 1.0f && chatBox.BarScroll == 1.0f)) { chatBox.BarScroll = 1.0f; } GUISoundType soundType = GUISoundType.Message; if (message.Type == ChatMessageType.Radio) { soundType = GUISoundType.RadioMessage; } else if (message.Type == ChatMessageType.Dead) { soundType = GUISoundType.DeadMessage; } GUI.PlayUISound(soundType); }
partial void ShowOnDisplay(string input, bool addToHistory) { if (addToHistory) { messageHistory.Add(input); while (messageHistory.Count > MaxMessages) { messageHistory.RemoveAt(0); } while (historyBox.Content.CountChildren > MaxMessages) { historyBox.RemoveChild(historyBox.Content.Children.First()); } } GUITextBlock newBlock = new GUITextBlock( new RectTransform(new Vector2(1, 0), historyBox.Content.RectTransform, anchor: Anchor.TopCenter), "> " + input, textColor: Color.LimeGreen, wrap: true, font: UseMonospaceFont ? GUI.MonospacedFont : GUI.GlobalFont) { CanBeFocused = false }; if (fillerBlock != null) { float y = fillerBlock.RectTransform.RelativeSize.Y - newBlock.RectTransform.RelativeSize.Y; if (y > 0) { fillerBlock.RectTransform.RelativeSize = new Vector2(1, y); } else { historyBox.RemoveChild(fillerBlock); fillerBlock = null; } } historyBox.RecalculateChildren(); historyBox.UpdateScrollBarSize(); historyBox.ScrollBar.BarScrollValue = 1; }