private void AddRow(MyTerminalBlock block)
 {
     MyGuiControlTable.Row row;
     MyGuiControlTable.Cell cell;
     row = new MyGuiControlTable.Row(block);
     cell = new MyGuiControlTable.Cell(block.CustomName);
     row.AddCell(cell);
     m_selectedBlocks.Add(row);
 }
        private void PopulateOwnedCubeGrids(HashSet <CubeGridInfo> gridInfoList)
        {
            float scrollBarValue = m_shipsData.ScrollBar.Value;
            m_shipsData.Clear();
            foreach (var gridInfo in gridInfoList)
            {
                UserData data;
                MyGuiControlTable.Row row;
                MyGuiControlTable.Cell nameCell, distanceCell, statusCell;

                data.GridEntityId = gridInfo.EntityId;
                if (gridInfo.Status == MyCubeGridConnectionStatus.Connected || gridInfo.Status == MyCubeGridConnectionStatus.PhysicallyConnected || gridInfo.Status == MyCubeGridConnectionStatus.Me)
                {
                    StringBuilder minDistance = new StringBuilder();
                    if(gridInfo.Status == MyCubeGridConnectionStatus.Connected)
                        minDistance = gridInfo.AppendedDistance.Append(" m");

                    data.IsSelectable = true;
                    nameCell = new MyGuiControlTable.Cell(new StringBuilder(gridInfo.Name), textColor: Color.White);
                    distanceCell = new MyGuiControlTable.Cell(minDistance, userData: gridInfo.Distance, textColor: Color.White);
                    switch (gridInfo.Status)
                    {
                        case MyCubeGridConnectionStatus.PhysicallyConnected:
                            statusCell = new MyGuiControlTable.Cell(MyTexts.Get(MySpaceTexts.BroadcastStatus_PhysicallyConnected), userData: gridInfo.Status, textColor: Color.White);
                            break;
                        case MyCubeGridConnectionStatus.Me:
                            statusCell = new MyGuiControlTable.Cell(MyTexts.Get(MySpaceTexts.BroadcastStatus_Me), userData: gridInfo.Status, textColor: Color.White);
                            break;

                        case MyCubeGridConnectionStatus.Connected:
                        default:
                            statusCell = new MyGuiControlTable.Cell(MyTexts.Get(MySpaceTexts.BroadcastStatus_Connected), userData: gridInfo.Status, textColor: Color.White);
                            break;
                    }
                }

                else
                {
                    data.IsSelectable = false;
                    nameCell = new MyGuiControlTable.Cell(new StringBuilder(gridInfo.Name), textColor: Color.Gray);
                    distanceCell = new MyGuiControlTable.Cell(new StringBuilder(""), userData: float.MaxValue, textColor: Color.Gray);
                    if (gridInfo.Status == MyCubeGridConnectionStatus.OutOfReceivingRange)
                        statusCell = new MyGuiControlTable.Cell(MyTexts.Get(MySpaceTexts.BroadcastStatus_OutOfReceivingRange), userData: gridInfo.Status, textColor: Color.Gray);
                    else if (gridInfo.Status == MyCubeGridConnectionStatus.OutOfBroadcastingRange)
                        statusCell = new MyGuiControlTable.Cell(MyTexts.Get(MySpaceTexts.BroadcastStatus_OutOfBroadcastingRange), userData: gridInfo.Status, textColor: Color.Gray);
                    else
                        statusCell = new MyGuiControlTable.Cell(MyTexts.Get(MySpaceTexts.BroadcastStatus_IsPreviewGrid), userData: gridInfo.Status, textColor: Color.Gray);
                }

                row = new MyGuiControlTable.Row(data);
                row.AddCell(nameCell);
                row.AddCell(distanceCell);
                row.AddCell(statusCell);
                m_shipsData.Add(row);
                m_shipsData.SortByColumn(m_columnToSort, MyGuiControlTable.SortStateEnum.Ascending, false);
            }
            m_shipsData.ScrollBar.ChangeValue(scrollBarValue);
        }
        protected void AddPlayer(ulong userId)
        {
            //string playerName = SteamAPI.Instance.Friends.GetPersonaName(userId);
            string playerName = MyMultiplayer.Static.GetMemberName(userId);

            if (String.IsNullOrEmpty(playerName))
                return;

            bool isAdmin = MyMultiplayer.Static.IsAdmin(userId);
            bool hasAdminRights = MySession.Static.HasPlayerAdminRights(userId);

            var row = new MyGuiControlTable.Row(userData: userId);
            row.AddCell(new MyGuiControlTable.Cell(text: new StringBuilder(playerName), userData: playerName));

            var playerId = Sync.Players.TryGetIdentityId(userId);
            var faction = MySession.Static.Factions.GetPlayerFaction(playerId);
            row.AddCell(new MyGuiControlTable.Cell(text: new StringBuilder(faction != null ? faction.Tag : "")));
            row.AddCell(new MyGuiControlTable.Cell(text: new StringBuilder(faction != null ? faction.Name : "")));

            // cell with/without mute checkbox
            MyGuiControlTable.Cell cell = new MyGuiControlTable.Cell(text: new StringBuilder(""));
            row.AddCell(cell);

            if (MyPerGameSettings.EnableMutePlayer && userId != Sync.MyId)
            {
                MyGuiControlCheckbox check = new MyGuiControlCheckbox(toolTip: "", visualStyle: MyGuiControlCheckboxStyleEnum.Muted);
                check.IsChecked = MySandboxGame.Config.MutedPlayers.Contains(userId);
                check.IsCheckedChanged += IsMuteCheckedChanged;
                check.UserData = userId;
                cell.Control = check;

                m_playersTable.Controls.Add(check);
            }

            // cell with admin marker
            string adminString = isAdmin ? GAME_OWNER_MARKER : (hasAdminRights ? GAME_MASTER_MARKER : String.Empty);
            row.AddCell(new MyGuiControlTable.Cell(text: new StringBuilder(adminString)));
            m_playersTable.Add(row);
        }
        private void RefreshSpawnShips()
        {
            var respawnShips = MyDefinitionManager.Static.GetRespawnShipDefinitions();
            foreach (var pair in respawnShips)
            {
                var respawnShip = pair.Value;
                var row = new MyGuiControlTable.Row(respawnShip);

                //Add description or name?
                row.AddCell(new MyGuiControlTable.Cell(text: respawnShip.DisplayNameText));

                var respawnTimeCell = new MyGuiControlTable.Cell(String.Empty);
                AddShipRespawnInfo(respawnShip, respawnTimeCell.Text);
                row.AddCell(respawnTimeCell);

                m_respawnsTable.Add(row);
            }
        }