public MyGuiScreenProgress(StringBuilder text, MyStringId? cancelText = null)
     : base(MySpaceTexts.Blank, cancelText)
 {
     // Copy
     Text = new StringBuilder(text.Length);
     Text.AppendStringBuilder(text);
 }
        bool AddServerItem(GameServerItem server, Action onAddedServerItem, bool isFiltered = false)
        {
            if (m_allowedGroups.IsChecked && !SteamAPI.Instance.Friends.IsUserInGroup(server.GetGameTagByPrefixUlong("groupId")))
                return false;

            if (server.AppID != MySteam.AppId)
                return false;

            if (!isFiltered && !string.IsNullOrWhiteSpace(m_blockSearch.Text)) // this must be here for filtering LAN games
            {
                if (!server.Name.ToLower().Contains(m_blockSearch.Text.ToLower()))
                    return false;
            }

            string sessionName = server.Map;
            int appVersion = server.ServerVersion;
            m_gameTypeText.Clear();
            m_gameTypeToolTip.Clear();

            // Skip world without name (not fully initialized)
            if (string.IsNullOrEmpty(sessionName))
                return false;

            // Show only same app versions
            if (m_showOnlyCompatibleGames.IsChecked && appVersion != MyFinalBuildConstants.APP_VERSION)
                return false;
            
            // Show only if the game data match
            string remoteHash = server.GetGameTagByPrefix("datahash");
            if (m_showOnlyWithSameMods.IsChecked && MyFakes.ENABLE_MP_DATA_HASHES && remoteHash != "" && remoteHash != MyDataIntegrityChecker.GetHashBase64())
                return false;

            var gamemodeSB = new StringBuilder();
            var gamemodeToolTipSB = new StringBuilder();

            string gamemode = server.GetGameTagByPrefix("gamemode");
            if (gamemode == "C")
            {
                gamemodeSB.Append(MyTexts.Get(MySpaceTexts.WorldSettings_GameModeCreative));
                gamemodeToolTipSB.AppendStringBuilder(MyTexts.Get(MySpaceTexts.WorldSettings_GameModeCreative));
            }
            else if (gamemode == "B")
            {
                IPEndPoint endpoint = server.NetAdr;
                if (endpoint == null)
                    return false;

                // Started battle write key value "BattleCanBeJoinedTag" "0" to server which can be accessed asynchronously from rules.
                MySandboxGame.Services.SteamService.SteamAPI.GetServerRules(endpoint.Address.ToIPv4NetworkOrder(), (ushort)endpoint.Port, delegate(Dictionary<string, string> rules)
                {
                    if (rules == null)
                        return;

                    bool canBeJoined = true;
                    string strCanBeJoined;
                    if (rules.TryGetValue(MyMultiplayer.BattleCanBeJoinedTag, out strCanBeJoined))
                    {
                        canBeJoined = strCanBeJoined != 0.ToString();
                    }

                    if (canBeJoined)
                    {
                        gamemodeSB.Append(MyTexts.Get(MySpaceTexts.WorldSettings_Battle));
                        gamemodeToolTipSB.AppendStringBuilder(MyTexts.Get(MySpaceTexts.WorldSettings_Battle));

                        AddServerItem(server, sessionName, gamemodeSB, gamemodeToolTipSB);

                        if (onAddedServerItem != null)
                            onAddedServerItem();
                    }
                },
                delegate() { });

                return false;
            }
            else if(!string.IsNullOrWhiteSpace(gamemode))
            {
                var multipliers = gamemode.Substring(1);
                var split = multipliers.Split('-');
                //TODO: refactor
                if (split.Length == 3 && server.AppID == 244850)
                {
                    gamemodeSB.Append(MyTexts.Get(MySpaceTexts.WorldSettings_GameModeSurvival)).Append(" ").Append(multipliers);
                    gamemodeToolTipSB.AppendFormat(MyTexts.Get(MySpaceTexts.JoinGame_GameTypeToolTip_MultipliersFormat).ToString(), split[0], split[1], split[2]);
                }
                else
                {
                    gamemodeSB.Append(MyTexts.Get(MySpaceTexts.WorldSettings_GameModeSurvival));
                    gamemodeToolTipSB.AppendStringBuilder(MyTexts.Get(MySpaceTexts.WorldSettings_GameModeSurvival));
                }
            }

            AddServerItem(server, sessionName, gamemodeSB, gamemodeToolTipSB);

            if (onAddedServerItem != null)
                onAddedServerItem();

            return true;
        }
 public void WriteLockStateValue(StringBuilder sb)
 {
     if (InConstraint && Connected)
         sb.AppendStringBuilder(MyTexts.Get(MySpaceTexts.BlockPropertyValue_Locked));
     else if (InConstraint)
         sb.AppendStringBuilder(MyTexts.Get(MySpaceTexts.BlockPropertyValue_ReadyToLock));
     else
         sb.AppendStringBuilder(MyTexts.Get(MySpaceTexts.BlockPropertyValue_Unlocked));
 }
 private void WriteLockStateValue(StringBuilder sb)
 {
     if (LockMode == LandingGearMode.Locked)
         sb.AppendStringBuilder(MyTexts.Get(MySpaceTexts.BlockPropertyValue_Locked));
     else if (LockMode == LandingGearMode.ReadyToLock)
         sb.AppendStringBuilder(MyTexts.Get(MySpaceTexts.BlockPropertyValue_ReadyToLock));
     else
         sb.AppendStringBuilder(MyTexts.Get(MySpaceTexts.BlockPropertyValue_Unlocked));
 }
 public void GetText(StringBuilder result)
 {
     result.AppendStringBuilder(m_text);
 }
        private void RefreshMedicalRooms()
        {
            List<MyMedicalRoom> medicalRooms;
            GetAvailableMedicalRooms(MySession.LocalPlayerId, out medicalRooms);

            foreach (var medRoom in medicalRooms)
            {
                var row = new MyGuiControlTable.Row(medRoom);
                row.AddCell(new MyGuiControlTable.Cell(text: medRoom.CustomName));


                var ownerText = new StringBuilder();
                if (MySession.Static.Settings.EnableOxygen)
                {
                    ownerText.Append("O2 ");
                    ownerText.Append((medRoom.GetOxygenLevel() * 100).ToString("F0"));
                    ownerText.Append("% ");
                }
                ownerText.AppendStringBuilder(GetOwnerDisplayName(medRoom));

                row.AddCell(new MyGuiControlTable.Cell(text: ownerText));
                m_respawnsTable.Add(row);
            }
        }
        void RefreshMedicalRooms(List<MyMedicalRoomInfo> medicalRooms)
        {
            m_respawnsTable.Clear();
           
            foreach (var medRoom in medicalRooms)
            {
                var row = new MyGuiControlTable.Row(medRoom);
                row.AddCell(new MyGuiControlTable.Cell(text: medRoom.MedicalRoomName));


                var ownerText = new StringBuilder();
                if (MySession.Static.Settings.EnableOxygen)
                {
                    ownerText.Append("O2 ");
                    ownerText.Append((medRoom.OxygenLevel * 100).ToString("F0"));
                    ownerText.Append("% ");
                }
                ownerText.AppendStringBuilder(GetOwnerDisplayName(medRoom.OwnerId));

                row.AddCell(new MyGuiControlTable.Cell(text: ownerText));
                m_respawnsTable.Add(row);
            }

            if (!MySession.Static.Settings.DisableRespawnShips && !MySession.Static.Settings.Scenario)
            {
                RefreshSpawnShips();
                AddRespawnInSuit();
            }

            if (m_respawnsTable.RowsCount > 0)
            {
                m_respawnsTable.SelectedRowIndex = 0;
                OnTableItemSelected(null, new MyGuiControlTable.EventArgs());
                m_noRespawnText.Visible = false;
            }
            else
            {
                m_noRespawnText.Visible = true;
            }
        }
        bool AddServerItem(GameServerItem server, bool isFiltered = false)
        {
            if (m_allowedGroups.IsChecked && !SteamAPI.Instance.Friends.IsUserInGroup(server.GetGameTagByPrefixUlong("groupId")))
                return false;

            if (server.AppID != MySteam.AppId)
                return false;

            if (!isFiltered && !string.IsNullOrWhiteSpace(m_blockSearch.Text)) // this must be here for filtering LAN games
            {
                if (!server.Name.ToLower().Contains(m_blockSearch.Text.ToLower()))
                    return false;
            }

            var row = new MyGuiControlTable.Row(server);

            string sessionName = server.Map;
            int appVersion = server.ServerVersion;
            m_gameTypeText.Clear();
            m_gameTypeToolTip.Clear();

            // Skip world without name (not fully initialized)
            if (string.IsNullOrEmpty(sessionName))
                return false;

            // Show only same app versions
            if (m_showOnlyCompatibleGames.IsChecked && appVersion != MyFinalBuildConstants.APP_VERSION)
                return false;
            
            // Show only if the game data match
            string remoteHash = server.GetGameTagByPrefix("datahash");
            if (m_showOnlyWithSameMods.IsChecked && MyFakes.ENABLE_MP_DATA_HASHES && remoteHash != "" && remoteHash != MyDataIntegrityChecker.GetHashBase64())
                return false;

            var gamemodeSB = new StringBuilder();
            var gamemodeToolTipSB = new StringBuilder();

            string gamemode = server.GetGameTagByPrefix("gamemode");
            if (gamemode == "C")
            {
                gamemodeSB.Append(MyTexts.Get(MySpaceTexts.WorldSettings_GameModeCreative));
                gamemodeToolTipSB.AppendStringBuilder(MyTexts.Get(MySpaceTexts.WorldSettings_GameModeCreative));
            }
            else if(!string.IsNullOrWhiteSpace(gamemode))
            {
                var multipliers = gamemode.Substring(1);
                var split = multipliers.Split('-');
                //TODO: refactor
                if (split.Length == 3 && server.AppID == 244850)
                {
                    gamemodeSB.Append(MyTexts.Get(MySpaceTexts.WorldSettings_GameModeSurvival)).Append(" ").Append(multipliers);
                    gamemodeToolTipSB.AppendFormat(MyTexts.Get(MySpaceTexts.JoinGame_GameTypeToolTip_MultipliersFormat).ToString(), split[0], split[1], split[2]);
                }
                else
                {
                    gamemodeSB.Append(MyTexts.Get(MySpaceTexts.WorldSettings_GameModeSurvival));
                    gamemodeToolTipSB.AppendStringBuilder(MyTexts.Get(MySpaceTexts.WorldSettings_GameModeSurvival));
                }
            }

            ulong modCount = server.GetGameTagByPrefixUlong(MyMultiplayer.ModCountTag);

            string limit = server.MaxPlayers.ToString();
            StringBuilder userCount = new StringBuilder(server.Players + "/" + limit);

            var viewDistance = server.GetGameTagByPrefix(MyMultiplayer.ViewDistanceTag);
            //TODO: refactor
            if (!String.IsNullOrEmpty(viewDistance) && server.AppID == 244850)
            {
                gamemodeToolTipSB.AppendLine();
                gamemodeToolTipSB.AppendFormat(MyTexts.Get(MySpaceTexts.JoinGame_GameTypeToolTip_ViewDistance).ToString(), viewDistance);
            }

            row.AddCell(new MyGuiControlTable.Cell(text: m_textCache.Clear().Append(sessionName), userData: server.SteamID, toolTip: m_textCache.ToString()));
            row.AddCell(new MyGuiControlTable.Cell(text: gamemodeSB, toolTip: gamemodeToolTipSB.ToString()));
            row.AddCell(new MyGuiControlTable.Cell(text: m_textCache.Clear().Append(server.Name), toolTip: m_gameTypeToolTip.Clear().AppendLine(server.Name).Append(server.NetAdr.ToString()).ToString()));
            row.AddCell(new MyGuiControlTable.Cell(text: userCount, toolTip: userCount.ToString()));
            row.AddCell(new MyGuiControlTable.Cell(text: m_textCache.Clear().Append(server.Ping), toolTip: m_textCache.ToString()));
            row.AddCell(new MyGuiControlTable.Cell(text: m_textCache.Clear().Append(modCount == 0 ? "---" : modCount.ToString()), toolTip: MyTexts.GetString(MySpaceTexts.JoinGame_SelectServerToShowModList)));
            m_gamesTable.Add(row);
            
            var selectedRow = m_gamesTable.SelectedRow;
            m_gamesTable.Sort(false);

            m_gamesTable.SelectedRowIndex = m_gamesTable.FindRow(selectedRow);

            return true;
        }
        static void RefreshMedicalRoomsResponse_Implementation(List<MyMedicalRoomInfo> medicalRooms)
        {
           foreach (var medRoom in medicalRooms)
           {
               var row = new MyGuiControlTable.Row(medRoom);
               row.AddCell(new MyGuiControlTable.Cell(text: medRoom.MedicalRoomName));


               var ownerText = new StringBuilder();
               if (MySession.Static.Settings.EnableOxygen)
               {
                   ownerText.Append("O2 ");
                   ownerText.Append((medRoom.OxygenLevel * 100).ToString("F0"));
                   ownerText.Append("% ");
               }
               ownerText.AppendStringBuilder(GetOwnerDisplayName(medRoom.OwnerId));

               row.AddCell(new MyGuiControlTable.Cell(text: ownerText));
               MyGuiScreenMedicals.Static.m_respawnsTable.Add(row);
           }
        }
Example #10
0
        public void Log(MyLogSeverity severity, StringBuilder builder)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("{0}: ", severity);
            sb.AppendStringBuilder(builder);
            sb.Append('\n');

            WriteStringBuilder(sb);

            if ((int)severity >= (int)AssertLevel)
                SystemTrace.Fail(sb.ToString());
        }