Esempio n. 1
0
        private MyGuiControlTable.Cell CreateTerminalCell(CubeGridInfo gridInfo, bool isActive)
        {
            MyGuiControlTable.Cell cell = new MyGuiControlTable.Cell();

            Vector2 size = new Vector2(0.1f, m_shipsData.RowHeight * 0.9f);

            MyStringId     tooltip = MySpaceTexts.BroadcastScreen_TerminalButton_ToolTip;
            MyRefuseReason reason  = CanTakeTerminal(gridInfo);

            switch (reason)
            {
            case MyRefuseReason.NoStableConnection:
            case MyRefuseReason.PlayerBroadcastOff:
            case MyRefuseReason.NoOwner:
                isActive = false;
                break;
            }

            cell.Control = new MyGuiControlButton(text: MyTexts.Get(MySpaceTexts.Terminal),
                                                  visualStyle: VRage.Game.MyGuiControlButtonStyleEnum.Rectangular,
                                                  size: size,
                                                  textScale: 0.9f,
                                                  onButtonClick: OnButtonClicked_OpenTerminal
                                                  );
            cell.Control.SetToolTip(tooltip);
            cell.Control.Enabled = isActive;
            m_shipsData.Controls.Add(cell.Control);
            return(cell);
        }
Esempio n. 2
0
        private int PlayerCountComparisonLobbies(MyGuiControlTable.Cell a, MyGuiControlTable.Cell b)
        {
            var playersA    = int.Parse(a.Text.Split('/')[0].ToString());
            var playersB    = int.Parse(b.Text.Split('/')[0].ToString());
            var maxPlayersA = int.Parse(a.Text.Split('/')[1].ToString());
            var maxPlayersB = int.Parse(b.Text.Split('/')[1].ToString());

            if (playersA == playersB)
            {
                if (maxPlayersA == maxPlayersB)
                {
                    var serverA = (Lobby)a.Row.UserData;
                    var serverB = (Lobby)b.Row.UserData;
                    return(serverA.LobbyId.CompareTo(serverB.LobbyId));
                }
                else
                {
                    return(maxPlayersA.CompareTo(maxPlayersB));
                }
            }
            else
            {
                return(playersA.CompareTo(playersB));
            }
        }
Esempio n. 3
0
        private int PlayerCountComparisonServers(MyGuiControlTable.Cell a, MyGuiControlTable.Cell b)
        {
            var playersA    = int.Parse(a.Text.Split('/')[0].ToString());
            var playersB    = int.Parse(b.Text.Split('/')[0].ToString());
            var maxPlayersA = int.Parse(a.Text.Split('/')[1].ToString());
            var maxPlayersB = int.Parse(b.Text.Split('/')[1].ToString());

            if (playersA == playersB)
            {
                if (maxPlayersA == maxPlayersB)
                {
                    var serverA = (GameServerItem)a.Row.UserData;
                    var serverB = (GameServerItem)b.Row.UserData;
                    return(serverA.SteamID.CompareTo(serverB.SteamID));
                }
                else
                {
                    return(maxPlayersA.CompareTo(maxPlayersB));
                }
            }
            else
            {
                return(playersA.CompareTo(playersB));
            }
        }
Esempio n. 4
0
 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);
 }
Esempio n. 5
0
        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, controlCell, distanceCell, statusCell, accessCell;

                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);
                    controlCell       = CreateControlCell(gridInfo, true);
                    distanceCell      = new MyGuiControlTable.Cell(minDistance, userData: gridInfo.Distance, textColor: Color.White);
                    statusCell        = CreateStatusIcons(gridInfo, true);
                    accessCell        = CreateTerminalCell(gridInfo, true);
                }

                else
                {
                    data.IsSelectable = false;
                    nameCell          = new MyGuiControlTable.Cell(new StringBuilder(gridInfo.Name), textColor: Color.Gray);
                    controlCell       = CreateControlCell(gridInfo, false);
                    distanceCell      = new MyGuiControlTable.Cell(new StringBuilder("Not Available"), userData: float.MaxValue, textColor: Color.Gray);
                    statusCell        = CreateStatusIcons(gridInfo, true);
                    accessCell        = CreateTerminalCell(gridInfo, false);
                }

                row = new MyGuiControlTable.Row(data);
                row.AddCell(nameCell);
                row.AddCell(controlCell);
                row.AddCell(distanceCell);
                row.AddCell(statusCell);
                row.AddCell(accessCell);
                m_shipsData.Add(row);
                m_shipsData.SortByColumn(m_columnToSort, MyGuiControlTable.SortStateEnum.Ascending, false);
            }
            m_shipsData.ScrollBar.ChangeValue(scrollBarValue);
        }
 private int TableSortingComparison(MyGuiControlTable.Cell a, MyGuiControlTable.Cell b)
 {
     if (((MyGps)a.UserData).DiscardAt != null && ((MyGps)b.UserData).DiscardAt != null
         || ((MyGps)a.UserData).DiscardAt == null && ((MyGps)b.UserData).DiscardAt == null)
     {//sort by name
         return a.Text.CompareToIgnoreCase(b.Text);
     }
     else
     {//final first
         if (((MyGps)a.UserData).DiscardAt == null)
             return -1;
         else
             return 1;
     }
 }
Esempio n. 7
0
        private int TextComparisonLobbies(MyGuiControlTable.Cell a, MyGuiControlTable.Cell b)
        {
            var comp = a.Text.CompareToIgnoreCase(b.Text);

            if (comp == 0)
            {
                var serverA = (Lobby)a.Row.UserData;
                var serverB = (Lobby)b.Row.UserData;
                return(serverA.LobbyId.CompareTo(serverB.LobbyId));
            }
            else
            {
                return(comp);
            }
        }
Esempio n. 8
0
        private int TextComparisonServers(MyGuiControlTable.Cell a, MyGuiControlTable.Cell b)
        {
            var comp = a.Text.CompareToIgnoreCase(b.Text);

            if (comp == 0)
            {
                var serverA = (GameServerItem)a.Row.UserData;
                var serverB = (GameServerItem)b.Row.UserData;
                return(serverA.SteamID.CompareTo(serverB.SteamID));
            }
            else
            {
                return(comp);
            }
        }
Esempio n. 9
0
        private int PingComparison(MyGuiControlTable.Cell a, MyGuiControlTable.Cell b)
        {
            var pingA = int.Parse(a.Text.ToString());
            var pingB = int.Parse(b.Text.ToString());

            if (pingA == pingB)
            {
                var serverA = (GameServerItem)a.Row.UserData;
                var serverB = (GameServerItem)b.Row.UserData;
                return(serverA.SteamID.CompareTo(serverB.SteamID));
            }
            else
            {
                return(pingA.CompareTo(pingB));
            }
        }
        protected void AddPlayer(ulong userId)
        {
            //string playerName = SteamAPI.Instance.Friends.GetPersonaName(userId);
            string playerName = MyMultiplayer.Static.GetMemberName(userId);

            if (String.IsNullOrEmpty(playerName))
            {
                return;
            }

            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
            StringBuilder  adminString = new StringBuilder();
            MyPromoteLevel userLevel   = MySession.Static.GetUserPromoteLevel(userId);

            for (int i = 0; i < (int)userLevel; i++)
            {
                adminString.Append("*");
            }

            row.AddCell(new MyGuiControlTable.Cell(adminString));
            m_playersTable.Add(row);
        }
Esempio n. 11
0
        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);
        }
Esempio n. 12
0
        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);
            }
        }
Esempio n. 13
0
        private int ModsComparisonLobbies(MyGuiControlTable.Cell a, MyGuiControlTable.Cell b)
        {
            int modCountA = 0;

            int.TryParse(a.Text.ToString(), out modCountA);
            int modCountB = 0;

            int.TryParse(b.Text.ToString(), out modCountB);

            if (modCountA == modCountB)
            {
                var serverA = (Lobby)a.Row.UserData;
                var serverB = (Lobby)b.Row.UserData;
                return(serverA.LobbyId.CompareTo(serverB.LobbyId));
            }
            else
            {
                return(modCountA.CompareTo(modCountB));
            }
        }
Esempio n. 14
0
        private int ModsComparisonServers(MyGuiControlTable.Cell a, MyGuiControlTable.Cell b)
        {
            int modCountA = 0;

            int.TryParse(a.Text.ToString(), out modCountA);
            int modCountB = 0;

            int.TryParse(b.Text.ToString(), out modCountB);

            if (modCountA == modCountB)
            {
                var serverA = (GameServerItem)a.Row.UserData;
                var serverB = (GameServerItem)b.Row.UserData;
                return(serverA.SteamID.CompareTo(serverB.SteamID));
            }
            else
            {
                return(modCountA.CompareTo(modCountB));
            }
        }
Esempio n. 15
0
        private int WorldSizeComparison(MyGuiControlTable.Cell a, MyGuiControlTable.Cell b)
        {
            string aString = a.Text.ToString().Trim();
            string bString = b.Text.ToString().Trim();
            string aUnit   = aString.Substring(aString.Length - 2);
            string bUnit   = bString.Substring(bString.Length - 2);

            if (aUnit.Equals(bUnit))
            {
                int aAmount = int.Parse(aString.Substring(0, aString.Length - 2));
                int bAmount = int.Parse(bString.Substring(0, bString.Length - 2));
                return(aAmount.CompareTo(bAmount));
            }
            else if (aUnit.Equals("MB", StringComparison.OrdinalIgnoreCase))
            {
                return(1);
            }
            else
            {
                return(-1);
            }
        }
Esempio n. 16
0
        private MyGuiControlTable.Cell CreateStatusIcons(CubeGridInfo gridInfo, bool isActive)
        {
            MyGuiControlTable.Cell cell = new MyGuiControlTable.Cell();
            float iconSize = m_shipsData.RowHeight * 0.7f;

            bool antIsActive, keyIsActive, remIsActive;

            antIsActive = keyIsActive = remIsActive = isActive;
            MyStringId antTooltip, remTooltip;

            antTooltip = remTooltip = MyStringId.NullOrEmpty;
            StringBuilder keyTooltip = new StringBuilder();

            MyGuiControlParent gr = new MyGuiControlParent();

            MyRefuseReason reasonT  = CanTakeTerminal(gridInfo);
            MyRefuseReason reasonRC = CanTakeRemoteControl(gridInfo);

            //Antenna icon
            switch (reasonT)
            {
            case MyRefuseReason.PlayerBroadcastOff:
                antIsActive = false;
                antTooltip  = MySpaceTexts.BroadcastScreen_TerminalButton_PlayerBroadcastOffToolTip;
                break;

            case MyRefuseReason.NoStableConnection:
                antIsActive = false;
                antTooltip  = MySpaceTexts.BroadcastScreen_TerminalButton_NoStableConnectionToolTip;
                break;

            case MyRefuseReason.NoOwner:
            case MyRefuseReason.NoProblem:
                antTooltip = MySpaceTexts.BroadcastScreen_TerminalButton_StableConnectionToolTip;
                break;
            }
            MyGuiControlImage antenna = new MyGuiControlImage(
                position: new Vector2(-2 * iconSize, 0),
                size: new Vector2(iconSize, iconSize),
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER,
                backgroundTexture: (antIsActive ? MyGuiConstants.BS_ANTENNA_ON : MyGuiConstants.BS_ANTENNA_OFF)
                );

            antenna.SetToolTip(antTooltip);
            gr.Controls.Add(antenna);

            //Remote Control icon
            switch (reasonRC)
            {
            case MyRefuseReason.NoRemoteControl:
                remTooltip  = MySpaceTexts.BroadcastScreen_TakeControlButton_NoRemoteToolTip;
                remIsActive = false;
                break;

            case MyRefuseReason.NoMainRemoteControl:
                remTooltip  = MySpaceTexts.BroadcastScreen_TakeControlButton_NoMainRemoteControl;
                remIsActive = false;
                break;

            case MyRefuseReason.NoOwner:
            case MyRefuseReason.NoProblem:
                remTooltip = MySpaceTexts.BroadcastScreen_TakeControlButton_RemoteToolTip;
                break;
            }
            MyGuiControlImage remote = new MyGuiControlImage(
                position: new Vector2(-1 * iconSize, 0),
                size: new Vector2(iconSize, iconSize),
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER,
                backgroundTexture: (remIsActive ? MyGuiConstants.BS_REMOTE_ON : MyGuiConstants.BS_REMOTE_OFF)
                );

            remote.SetToolTip(remTooltip);
            gr.Controls.Add(remote);

            //Key icon
            if ((reasonT == MyRefuseReason.NoStableConnection || reasonT == MyRefuseReason.PlayerBroadcastOff) && reasonRC == MyRefuseReason.NoRemoteControl)
            {
                keyTooltip.Append(MyTexts.Get(MySpaceTexts.BroadcastScreen_UnavailableControlButton));
                keyIsActive = false;
            }
            if (keyIsActive && (reasonT == MyRefuseReason.NoOwner || reasonRC == MyRefuseReason.NoOwner || reasonT == MyRefuseReason.NoStableConnection || reasonT == MyRefuseReason.PlayerBroadcastOff))
            {
                keyIsActive = false;
                keyTooltip.Append(MyTexts.Get(MySpaceTexts.BroadcastScreen_NoOwnership));
            }
            if (reasonT == MyRefuseReason.NoOwner)
            {
                keyTooltip.AppendLine();
                keyTooltip.Append(MyTexts.Get(MySpaceTexts.DisplayName_Block_Antenna));
            }
            if (reasonRC == MyRefuseReason.NoOwner)
            {
                keyTooltip.AppendLine();
                keyTooltip.Append(MyTexts.Get(MySpaceTexts.DisplayName_Block_RemoteControl));
            }
            if (keyIsActive)
            {
                keyTooltip.Append(MyTexts.Get(MySpaceTexts.BroadcastScreen_Ownership));
            }
            MyGuiControlImage key = new MyGuiControlImage(
                size: new Vector2(iconSize, iconSize),
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER,
                backgroundTexture: (keyIsActive ? MyGuiConstants.BS_KEY_ON : MyGuiConstants.BS_KEY_OFF)
                );

            key.SetToolTip(keyTooltip.ToString());
            gr.Controls.Add(key);


            cell.Control = gr;
            m_shipsData.Controls.Add(gr);
            return(cell);
        }
        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
                    {
                        statusCell = new MyGuiControlTable.Cell(MyTexts.Get(MySpaceTexts.BroadcastStatus_OutOfBroadcastingRange), 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);
        }