public MyGuiScreenProgress(StringBuilder text, MyStringId? cancelText = null) : base(MySpaceTexts.Blank, cancelText) { // Copy Text = new StringBuilder(text.Length); Text.AppendStringBuilder(text); }
public void ReadText(StringBuilder buffer, bool append = false) { Debug.Assert(buffer != null, $"{nameof(buffer)} cannot be null"); if (!append) { buffer.Clear(); } buffer.AppendStringBuilder(_text); }
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()); } }
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.CreativeMode) { AddRespawnInSuit(); } else if ((MySession.Static.Settings.EnableRespawnShips && !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; } }
public virtual bool WritePublicText(StringBuilder value, bool append = false) { Debug.Assert(value != null, $"{nameof(value)} cannot be null"); if (!append) { _publicText.Clear(); } if (_publicText.Length + value.Length > MaxCharacterCount) { _publicText.AppendSubstring(value, 0, MaxCharacterCount); } else { _publicText.AppendStringBuilder(value); } 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); } }
public override ChangeInfo Update(MyEntity owner, long playerID = 0) { ChangeInfo changed = base.Update(owner, playerID); bool genericType; var blocks = GetBlocks(); var action = FindAction(GetActions(blocks, out genericType), ActionId); var firstFunctional = FirstFunctional(blocks, owner, playerID); changed |= SetEnabled(action != null && firstFunctional != null); changed |= SetIcon(genericType ? "Textures\\GUI\\Icons\\GroupIcon.dds" : blocks.ItemAt(0).BlockDefinition.Icon); changed |= SetSubIcon(action != null ? action.Icon : null); if (action != null && !m_wasValid) { m_tmpStringBuilder.Clear(); m_tmpStringBuilder.AppendStringBuilder(this.m_groupName); m_tmpStringBuilder.Append(" - "); m_tmpStringBuilder.Append(action.Name); changed |= SetDisplayName(m_tmpStringBuilder.ToString()); m_tmpStringBuilder.Clear(); m_wasValid = true; } else if (action == null) { m_wasValid = false; } if (action != null && blocks.Count > 0) { // When everything is disabled, write value of first disabled block m_tmpStringBuilder.Clear(); action.WriteValue(firstFunctional ?? blocks.ItemAt(0), m_tmpStringBuilder); changed |= SetIconText(m_tmpStringBuilder); m_tmpStringBuilder.Clear(); } return(changed); }
public void Log(MyLogSeverity severity, StringBuilder builder) { if (m_enabled) { lock (m_lock) { WriteDateTimeAndThreadId(); StringBuilder sb = m_stringBuilder; sb.Clear(); sb.AppendFormat("{0}: ", severity); sb.AppendStringBuilder(builder); sb.Append('\n'); WriteStringBuilder(sb); if ((int)severity >= (int)AssertLevel) { SystemTrace.Fail(sb.ToString()); } } } }
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); }
void Writer(TBlock block, StringBuilder result, StringBuilder onText, StringBuilder offText) { result.AppendStringBuilder(Getter(block) ? onText : offText); }
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)); }
public void Init(IMyGuiControlsParent controlsParent, MyCubeGrid grid) { if (grid == null) { ShowError(MySpaceTexts.ScreenTerminalError_ShipNotConnected, controlsParent); return; } grid.RaiseGridChanged(); m_assemblerKeyCounter = 0; m_assemblersByKey.Clear(); foreach (var block in grid.GridSystems.TerminalSystem.Blocks) { var assembler = block as MyAssembler; if (assembler == null) { continue; } if (!assembler.HasLocalPlayerAccess()) { continue; } m_assemblersByKey.Add(m_assemblerKeyCounter++, assembler); } m_controlsParent = controlsParent; m_terminalSystem = grid.GridSystems.TerminalSystem; m_blueprintsArea = (MyGuiControlScrollablePanel)controlsParent.Controls.GetControlByName("BlueprintsScrollableArea"); m_queueArea = (MyGuiControlScrollablePanel)controlsParent.Controls.GetControlByName("QueueScrollableArea"); m_inventoryArea = (MyGuiControlScrollablePanel)controlsParent.Controls.GetControlByName("InventoryScrollableArea"); m_blueprintsBgPanel = controlsParent.Controls.GetControlByName("BlueprintsBackgroundPanel"); m_blueprintsLabel = controlsParent.Controls.GetControlByName("BlueprintsLabel"); m_comboboxAssemblers = (MyGuiControlCombobox)controlsParent.Controls.GetControlByName("AssemblersCombobox"); m_blueprintsGrid = (MyGuiControlGrid)m_blueprintsArea.ScrolledControl; m_queueGrid = (MyGuiControlGrid)m_queueArea.ScrolledControl; m_inventoryGrid = (MyGuiControlGrid)m_inventoryArea.ScrolledControl; m_materialsList = (MyGuiControlComponentList)controlsParent.Controls.GetControlByName("MaterialsList"); m_repeatCheckbox = (MyGuiControlCheckbox)controlsParent.Controls.GetControlByName("RepeatCheckbox"); m_slaveCheckbox = (MyGuiControlCheckbox)controlsParent.Controls.GetControlByName("SlaveCheckbox"); m_disassembleAllButton = (MyGuiControlButton)controlsParent.Controls.GetControlByName("DisassembleAllButton"); m_controlPanelButton = (MyGuiControlButton)controlsParent.Controls.GetControlByName("ControlPanelButton"); m_inventoryButton = (MyGuiControlButton)controlsParent.Controls.GetControlByName("InventoryButton"); { var assemblingButton = (MyGuiControlRadioButton)controlsParent.Controls.GetControlByName("AssemblingButton"); var disassemblingButton = (MyGuiControlRadioButton)controlsParent.Controls.GetControlByName("DisassemblingButton"); assemblingButton.Key = (int)AssemblerMode.Assembling; disassemblingButton.Key = (int)AssemblerMode.Disassembling; m_modeButtonGroup.Add(assemblingButton); m_modeButtonGroup.Add(disassemblingButton); } foreach (var entry in m_assemblersByKey) { if (entry.Value.IsFunctional == false) { m_incompleteAssemblerName.Clear(); m_incompleteAssemblerName.AppendStringBuilder(entry.Value.CustomName); m_incompleteAssemblerName.AppendStringBuilder(MyTexts.Get(MySpaceTexts.Terminal_BlockIncomplete)); m_comboboxAssemblers.AddItem(entry.Key, m_incompleteAssemblerName); } else { m_comboboxAssemblers.AddItem(entry.Key, entry.Value.CustomName); } } m_comboboxAssemblers.ItemSelected += Assemblers_ItemSelected; m_comboboxAssemblers.SelectItemByIndex(0); m_dragAndDrop = new MyGuiControlGridDragAndDrop(MyGuiConstants.DRAG_AND_DROP_BACKGROUND_COLOR, MyGuiConstants.DRAG_AND_DROP_TEXT_COLOR, 0.7f, MyGuiConstants.DRAG_AND_DROP_TEXT_OFFSET, true); controlsParent.Controls.Add(m_dragAndDrop); m_dragAndDrop.DrawBackgroundTexture = false; m_dragAndDrop.ItemDropped += dragDrop_OnItemDropped; RefreshBlueprints(); Assemblers_ItemSelected(); RegisterEvents(); if (m_assemblersByKey.Count == 0) { ShowError(MySpaceTexts.ScreenTerminalError_NoAssemblers, controlsParent); } }
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; }
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 (gamemode == "B") { gamemodeSB.Append(MyTexts.Get(MySpaceTexts.WorldSettings_Battle)); gamemodeToolTipSB.AppendStringBuilder(MyTexts.Get(MySpaceTexts.WorldSettings_Battle)); } 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); }
public void Append(StringBuilder sb) { m_text.AppendStringBuilder(sb); }
// Frame Debug Text - is cleared at the begining of Update and rendered at the end of Draw public void AddToFrameDebugText(StringBuilder s) { m_frameDebugText.AppendStringBuilder(s); m_frameDebugText.AppendLine(); }
// Frame Debug Text Right Aligned - is cleared at the begining of Update and rendered at the end of Draw public void AddDebugTextRA(StringBuilder s) { m_frameDebugTextRA.AppendStringBuilder(s); m_frameDebugTextRA.AppendLine(); }
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()); }
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; }
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); } }
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(MyCommonTexts.WorldSettings_GameModeCreative)); gamemodeToolTipSB.AppendStringBuilder(MyTexts.Get(MyCommonTexts.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) { string remainingTimeText = null; float?remainingTimeSeconds = null; if (MyFakes.ENABLE_JOIN_SCREEN_REMAINING_TIME && rules.TryGetValue(MyMultiplayer.BattleRemainingTimeTag, out remainingTimeText)) { float remainingTime; if (float.TryParse(remainingTimeText, NumberStyles.Float, CultureInfo.InvariantCulture, out remainingTime)) { if (remainingTime >= 0f) { remainingTimeSeconds = remainingTime; remainingTimeText = null; } else if (remainingTime == -1f) { remainingTimeText = MyTexts.Get(MyCommonTexts.JoinGame_Lobby).ToString(); } else if (remainingTime == -2f) { remainingTimeText = MyTexts.Get(MyCommonTexts.JoinGame_Waiting).ToString(); } } } gamemodeSB.Append(MyTexts.Get(MySpaceTexts.WorldSettings_Battle)); gamemodeToolTipSB.AppendStringBuilder(MyTexts.Get(MySpaceTexts.WorldSettings_Battle)); AddServerItem(server, sessionName, gamemodeSB, gamemodeToolTipSB, remainingTimeText: remainingTimeText, remainingTimeSeconds: remainingTimeSeconds); 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(MyCommonTexts.WorldSettings_GameModeSurvival)).Append(" ").Append(multipliers); gamemodeToolTipSB.AppendFormat(MyTexts.Get(MyCommonTexts.JoinGame_GameTypeToolTip_MultipliersFormat).ToString(), split[0], split[1], split[2]); } else { gamemodeSB.Append(MyTexts.Get(MyCommonTexts.WorldSettings_GameModeSurvival)); gamemodeToolTipSB.AppendStringBuilder(MyTexts.Get(MyCommonTexts.WorldSettings_GameModeSurvival)); } } AddServerItem(server, sessionName, gamemodeSB, gamemodeToolTipSB); if (onAddedServerItem != null) { onAddedServerItem(); } return(true); }
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); } }