private void InitMenuItems() { _root = new MenuItemGrid("chatAppGrid", 6, 1); MenuItemGrid leftGrid = new MenuItemGrid("leftPanelGrid", 1, 7); _root.AddChild(0, 0, 1, 1, leftGrid); _root.AddChild(1, 0, 5, 1, _chatBlock.GetRoot()); MenuItemGrid leftPanelTabs = new MenuItemGrid("leftPanelTabs", 2, 1); leftGrid.AddChild(0, 0, 1, 1, leftPanelTabs); MenuItemText recentText = new MenuItemText("recentText"); recentText.SetText("Recent"); recentText.SetFontSize(5, 20); recentText.SetAlignment(UnityEngine.TextAnchor.MiddleCenter); leftPanelTabs.AddChild(0, 0, 1, 1, recentText); MenuItemText friendsText = new MenuItemText("friendsText"); friendsText.SetText("Friends"); friendsText.SetFontSize(5, 20); friendsText.SetAlignment(UnityEngine.TextAnchor.MiddleCenter); leftPanelTabs.AddChild(1, 0, 1, 1, friendsText); leftPanelTabs.ItemClicked += OnLeftPanelTabClick; _leftPanel = leftGrid; }
private IMenuItem CreateUserBlock(string username, ChatObj chat) { MenuItemGrid item = new MenuItemGrid(username, 5, 3); MenuItemText usernameBlock = new MenuItemText("username"); item.AddChild(0, 0, 4, 1, usernameBlock); usernameBlock.SetText(username); usernameBlock.SetFontSize(8, 15); usernameBlock.SetTextStyle(UnityEngine.FontStyle.Bold); MenuItemText lastMsgBlock = new MenuItemText("lastMsg"); item.AddChild(0, 1, 4, 2, lastMsgBlock); string text = chat.Messages.Last().Message; if (text.Length > MAX_MSG_LEN) { text = text.Substring(0, MAX_MSG_LEN - 3); text += "..."; } lastMsgBlock.SetText(text); lastMsgBlock.SetFontSize(5, 10); lastMsgBlock.SetAlignment(UnityEngine.TextAnchor.MiddleLeft); MenuItemButton openChat = new MenuItemButton("openChat"); item.AddChild(4, 0, 1, 3, openChat); openChat.SetText(">"); openChat.Clicked += () => ChatSelected?.Invoke(chat); return(item); }
private void CreateMenuItems() { _root = new MenuItemGrid("roomListGrid", 7, 7); MenuItemText roomText = new MenuItemText("roomText"); roomText.SetText("Room List"); roomText.SetTextColor(Color.black); roomText.SetAlignment(TextAnchor.MiddleCenter); _root.AddChild(0, 0, 2, 1, roomText); MenuItemText searchText = new MenuItemText("searchText"); searchText.SetText("Search:"); searchText.SetAlignment(TextAnchor.LowerLeft); searchText.SetFontSize(5, 7); _root.AddChild(0, 2, 2, 1, searchText); MenuItemInput searchInput = new MenuItemInput("searchInput"); searchInput.SetPlaceholder("Name..."); _root.AddChild(0, 3, 2, 1, searchInput); searchInput.SetPadding(10f, 0f, 10f, 10f); MenuItemCheckbox notEmpty = new MenuItemCheckbox("notEmpty"); notEmpty.SetValue(false); notEmpty.SetText("Filter empty"); _root.AddChild(0, 4, 2, 1, notEmpty); notEmpty.SetPadding(10f, 6f); MenuItemCheckbox notFull = new MenuItemCheckbox("notFull"); notFull.SetValue(false); notFull.SetText("Filter full"); _root.AddChild(0, 5, 2, 1, notFull); notFull.SetPadding(10f, 6f); MenuItemButton filter = new MenuItemButton("filter"); filter.SetText("Filter"); filter.Clicked += () => { List <Room> roomList = GetRoomList(searchInput.GetText(), notEmpty.IsChecked(), notFull.IsChecked()); RenderRoomList(roomList); }; _root.AddChild(0, 6, 2, 1, filter); filter.SetPadding(20f, 4f); _roomListGrid = new MenuItemGrid("roomItems", 6, 10); _root.AddChild(2, 0, 5, 7, _roomListGrid); }
public IMenuItem CreateMessageObj(ChatObjMsg msg) { int lines = (int)Math.Ceiling(msg.Message.Length / (float)CHARS_PER_LINE) + 1; MenuItemGrid item = new MenuItemGrid(msg.Time.ToString(), 1, lines); MenuItemText header = new MenuItemText("header"); item.AddChild(0, 0, 1, 1, header); header.SetTextStyle(FontStyle.Bold); header.SetFontSize(5, HEADER_FONT_SIZE); TextAnchor alignment; if (msg.From == _userId) { alignment = TextAnchor.MiddleRight; header.SetText("You"); } else { alignment = TextAnchor.MiddleLeft; header.SetText(_toUsername); } header.SetAlignment(alignment); string text = msg.Message; int i; string textPart; MenuItemText message; for (i = 0; i < lines - 2; ++i) { textPart = text.Substring(i * CHARS_PER_LINE, CHARS_PER_LINE); message = new MenuItemText($"message_line{i+1}"); message.SetFontSize(5, FONT_SIZE); message.SetText(textPart); message.SetAlignment(alignment); item.AddChild(0, i + 1, 1, 1, message); } textPart = text.Substring(i * CHARS_PER_LINE); message = new MenuItemText($"message_line{i + 1}"); message.SetFontSize(5, FONT_SIZE); message.SetText(textPart); message.SetAlignment(alignment); item.AddChild(0, i + 1, 1, 1, message); return(item); }
public void InitMenuItems() { _root = new MenuItemGrid("chatBlock", 1, 10); _headerItem = new MenuItemText("headerChat"); _root.AddChild(0, 0, 1, 1, _headerItem); _headerItem.SetText("None"); _headerItem.SetFontSize(2, 20); _headerItem.SetAlignment(UnityEngine.TextAnchor.MiddleLeft); _chatItem = new MenuItemScrollable("chatScrollable", UnityEngine.TextAnchor.LowerCenter); _root.AddChild(0, 1, 1, 7, _chatItem); _bottomBlock = new MenuItemGrid("bottomPartChatBlock", 5, 1); _root.AddChild(0, 8, 1, 2, _bottomBlock); _msgInput = new MenuItemInput("chatMsgInput"); _bottomBlock.AddChild(0, 0, 4, 1, _msgInput); _msgInput.SetPlaceholder("Message..."); _msgInput.SetLineType(UnityEngine.UI.InputField.LineType.MultiLineSubmit); _msgInput.onSubmit += OnSendClicked; _sendButton = new MenuItemButton("chatSendButton"); _bottomBlock.AddChild(4, 0, 1, 1, _sendButton); _sendButton.SetText("Send"); _sendButton.Clicked += OnSendClicked; }