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 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 void RenderRoomList(List <Room> list) { _roomListGrid.RemoveChild(_loading); _loading.Dispose(); int i = 0; foreach (Room r in list) { if (i >= 10) { break; } MenuItemText roomName = new MenuItemText($"roomName{i}"); roomName.SetText(r.Name); roomName.SetFontSize(5, 15); _roomListGrid.AddChild(0, i, 3, 1, roomName); MenuItemText roomCapacity = new MenuItemText($"roomCapacity{i}"); roomCapacity.SetText($"{r.Players.Count}/{r.Capacity}"); roomCapacity.SetFontSize(5, 15); _roomListGrid.AddChild(3, i, 1, 1, roomCapacity); MenuItemButton connect = new MenuItemButton($"roomConnect{i}"); connect.SetText("Connect"); connect.Clicked += () => ConnectRoom(r); _roomListGrid.AddChild(4, i, 2, 1, connect); i++; } }
private void InitMenuItems() { // MAIN BODY _root = new MenuItemGrid("friendsManagement", 4, 7); _currentRoomButton = new MenuItemButton("currentRoomButton"); _currentRoomButton.SetText("Current Room"); _currentRoomButton.Clicked += SetCurrentRoomActive; _root.AddChild(0, 0, 1, 1, _currentRoomButton); _friendsListButton = new MenuItemButton("friendsListButton"); _friendsListButton.SetText("My Friends"); _friendsListButton.Clicked += SetFriendsListActive; _root.AddChild(1, 0, 1, 1, _friendsListButton); _friendSearchButton = new MenuItemButton("friendSearchButton"); _friendSearchButton.SetText("Find Friends"); _friendSearchButton.Clicked += SetFriendSearchActive; _root.AddChild(2, 0, 1, 1, _friendSearchButton); _friendRequestsButton = new MenuItemButton("friendRequestsButton"); _friendRequestsButton.SetText("Friend Requests"); _friendRequestsButton.Clicked += SetFriendRequestsActive; _root.AddChild(3, 0, 1, 1, _friendRequestsButton); _currentRoom = new CurrentRoom(_api); _friendRequests = new FriendRequests(_api); _friendsList = new FriendsList(_api); _friendSearch = new FriendsSearch(_api); SetCurrentRoomActive(); }
private IMenuItem CreateBlock(FriendsAppUser friend) { MenuItemGrid item = new MenuItemGrid(friend.Username, 5, 1); MenuItemText username = new MenuItemText("username"); item.AddChild(0, 0, 4, 1, username); username.SetText(friend.Username); username.SetFontSize(8, 15); username.SetTextStyle(UnityEngine.FontStyle.Bold); MenuItemButton selectButton = new MenuItemButton("selectButton"); item.AddChild(4, 0, 1, 1, selectButton); selectButton.SetText(">"); selectButton.Clicked += () => FriendSelected?.Invoke(friend.UserId); return(item); }
private void SetActiveLeftPanel(IMenuItem item) { if (_active != null) { _leftPanel.RemoveChild(_active); } _leftPanel.AddChild(0, 1, 1, 6, item); _active = item; }
private void SetActive(IFriendsManagementView item) { if (_active != null) { _root.RemoveChild(_active.GetRoot()); } _root.AddChild(0, 1, 4, 6, item.GetRoot()); _active = item; }
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; }
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 void Refresh() { _root.GetChildren().ForEach(x => x.Dispose()); _root.Clear(); MenuItemImage loading = new MenuItemImage("loadingGif"); _root.AddChild(2, 2, 2, 5, loading); loading.SetGif(GetLoadingGif(), 12); _requests = _api.DefaultApps.Friends.GetFriendRequests().Wait(); _root.Clear(); loading.Dispose(); RenderPage(0); }
public void Refresh() { _root.GetChildren().ForEach(x => x.Dispose()); _root.Clear(); MenuItemImage loading = new MenuItemImage("loadingGif"); _root.AddChild(2, 2, 2, 5, loading); loading.SetGif(GetLoadingGif(), 12); _users = _api.User.CurrentRoomUsers().Wait().Users.ToList(); _users.Remove(_users.Find(x => x.UserId == _api.User.UserId)); _friends = _api.DefaultApps.Friends.ListFriends().Wait().Select(x => x.UserId).ToList(); _root.Clear(); loading.Dispose(); RenderPage(0); }