Esempio n. 1
0
 public void Dispose()
 {
     _root.RemoveChild(_active.GetRoot());
     _root.Dispose();
     _currentRoom.GetRoot().Dispose();
     _friendsList.GetRoot().Dispose();
     _friendSearch.GetRoot().Dispose();
     _friendRequests.GetRoot().Dispose();
 }
Esempio n. 2
0
        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++;
            }
        }
Esempio n. 3
0
 private void SetActiveLeftPanel(IMenuItem item)
 {
     if (_active != null)
     {
         _leftPanel.RemoveChild(_active);
     }
     _leftPanel.AddChild(0, 1, 1, 6, item);
     _active = item;
 }
Esempio n. 4
0
 private void RenderPage(int pageNum)
 {
     if (_friends == null || _users == null)
     {
         Refresh();
     }
     _root.GetChildren().ForEach(x => x.Dispose());
     _root.Clear();
     for (int i = 0; i <= ROWS; ++i)
     {
         if (pageNum * ROWS + i >= _users.Count)
         {
             break;
         }
         UserDetailMsg user     = _users[pageNum * ROWS + i];
         MenuItemText  username = new MenuItemText($"username{user.Username}");
         username.SetText(user.Username);
         _root.AddChild(0, i, 3, 1, username);
         if (!_friends.Contains(user.UserId))
         {
             MenuItemButton addFriend = new MenuItemButton($"addFriend{user.Username}");
             addFriend.SetText("Add Friend");
             addFriend.Clicked += () =>
             {
                 _api.DefaultApps.Friends.SendFriendRequest(user.UserId).Wait();
                 MenuItemText requestSent = new MenuItemText("requestSent");
                 _root.RemoveChild(addFriend);
                 addFriend.Dispose();
                 _root.AddChild(3, i, 1, 1, requestSent);
             };
             _root.AddChild(3, i, 1, 1, addFriend);
         }
     }
     if (pageNum > 0)
     {
         MenuItemButton prevPage = new MenuItemButton("prevPage");
         prevPage.SetText("<");
         prevPage.Clicked += () =>
         {
             RenderPage(pageNum - 1);
         };
         _root.AddChild(0, ROWS, 1, 1, prevPage);
     }
     if ((pageNum + 1) * ROWS < _users.Count)
     {
         MenuItemButton nextPage = new MenuItemButton("nextPage");
         nextPage.SetText(">");
         nextPage.Clicked += () =>
         {
             RenderPage(pageNum + 1);
         };
         _root.AddChild(3, ROWS, 1, 1, nextPage);
     }
 }