public void UpdateChats() { ChatScroller.RemoveAllChildren(); float by = 0; for (int i = 0; i < ChatMessages.Count; i++) { if (Channels[(int)ChatMessages[i].Channel]) { by += FontSets.Standard.font_default.Height; int y = (int)by; string ch = (ChatMessages[i].Channel == TextChannel.ALWAYS) ? "" : (ChatMessages[i].Channel.ToString() + ": "); ChatScroller.AddChild(new UILabel(ch + ChatMessages[i].Text, FontSets.Standard, UIAnchor.TOP_LEFT, () => 0, () => y, () => (int)ChatScroller.GetWidth())); } } by += FontSets.Standard.font_default.Height; ChatBottom = (int)(by - ChatScroller.GetHeight()); ChatScroller.MaxScroll = ChatBottom; }
public void InitChatSystem() { FontSet font = FontSets.Standard; int minY = 10 + (int)font.font_default.Height; ChatMenu = new UIGroup(UIAnchor.TOP_CENTER, () => Window.Width, () => Window.Height - minY - UIBottomHeight, () => 0, () => 0); ChatScroller = new UIScrollBox(UIAnchor.TOP_CENTER, () => ChatMenu.GetWidth() - (30 * 2), () => ChatMenu.GetHeight() - minY, () => 0, () => minY) { Color = new Vector4(0f, 0.5f, 0.5f, 0.6f) }; ChatBox = new UIInputBox("", "Enter a /command or a chat message...", font, UIAnchor.TOP_CENTER, ChatScroller.GetWidth, () => 0, () => (int)ChatScroller.GetHeight() + minY) { EnterPressed = EnterChatMessage }; ChatMenu.AddChild(ChatBox); ChatMenu.AddChild(ChatScroller); Channels = new bool[(int)TextChannel.COUNT]; Func <int> xer = () => 30; Channels[0] = true; for (int i = 1; i < Channels.Length; i++) { Channels[i] = true; string n = ((TextChannel)i).ToString(); int len = (int)FontSets.Standard.MeasureFancyText(n); UITextLink link = null; Func <int> fxer = xer; int chan = i; link = new UITextLink(null, "^r^t^0^h^o^2" + n, "^!^e^t^0^h^o^2" + n, "^2^e^t^0^h^o^0" + n, FontSets.Standard, () => ToggleLink(link, n, chan), UIAnchor.TOP_LEFT, fxer, () => 10); xer = () => fxer() + len + 10; ChatMenu.AddChild(link); } ClearChat(); ChatScrollToBottom(); }