public override void RecreateControls(bool constructor) { base.RecreateControls(constructor); CloseButtonEnabled = true; var caption = AddCaption(MyCommonTexts.ScreenCaptionPlayers); var captionCenter = MyUtils.GetCoordCenterFromAligned(caption.Position, caption.Size, caption.OriginAlign); var captionBottomCenter = captionCenter + new Vector2(0f, 0.5f * caption.Size.Y); Vector2 sizeScale = Size.Value / MyGuiConstants.TEXTURE_SCREEN_BACKGROUND.SizeGui; Vector2 topLeft = -0.5f * Size.Value + sizeScale * MyGuiConstants.TEXTURE_SCREEN_BACKGROUND.PaddingSizeGui * 1.1f; float verticalSpacing = 0.0045f; m_lobbyTypeCombo = new MyGuiControlCombobox( position: new Vector2(-topLeft.X, captionBottomCenter.Y + verticalSpacing), openAreaItemsCount: 3); m_lobbyTypeCombo.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP; m_lobbyTypeCombo.AddItem((int)LobbyTypeEnum.Private, MyCommonTexts.ScreenPlayersLobby_Private); m_lobbyTypeCombo.AddItem((int)LobbyTypeEnum.FriendsOnly, MyCommonTexts.ScreenPlayersLobby_Friends); m_lobbyTypeCombo.AddItem((int)LobbyTypeEnum.Public, MyCommonTexts.ScreenPlayersLobby_Public); m_lobbyTypeCombo.SelectItemByKey((int)MyMultiplayer.Static.GetLobbyType()); MyGuiControlBase aboveControl; m_inviteButton = new MyGuiControlButton( position: new Vector2(-m_lobbyTypeCombo.Position.X, m_lobbyTypeCombo.Position.Y + m_lobbyTypeCombo.Size.Y + verticalSpacing), originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, text: MyTexts.Get(MyCommonTexts.ScreenPlayers_Invite)); aboveControl = m_inviteButton; m_promoteButton = new MyGuiControlButton( position: aboveControl.Position + new Vector2(0f, aboveControl.Size.Y + verticalSpacing), originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, text: MyTexts.Get(MyCommonTexts.ScreenPlayers_Promote)); aboveControl = m_promoteButton; m_demoteButton = new MyGuiControlButton( position: aboveControl.Position + new Vector2(0f, aboveControl.Size.Y + verticalSpacing), originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, text: MyTexts.Get(MyCommonTexts.ScreenPlayers_Demote)); aboveControl = m_demoteButton; m_kickButton = new MyGuiControlButton( position: aboveControl.Position + new Vector2(0f, aboveControl.Size.Y + verticalSpacing), originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, text: MyTexts.Get(MyCommonTexts.ScreenPlayers_Kick)); aboveControl = m_kickButton; m_banButton = new MyGuiControlButton( position: aboveControl.Position + new Vector2(0f, aboveControl.Size.Y + verticalSpacing), originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, text: MyTexts.Get(MyCommonTexts.ScreenPlayers_Ban)); aboveControl = m_banButton; var maxPlayersLabel = new MyGuiControlLabel( position: aboveControl.Position + new Vector2(0f, aboveControl.Size.Y + verticalSpacing), originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, text: MyTexts.GetString(MyCommonTexts.MaxPlayers)); aboveControl = maxPlayersLabel; m_maxPlayersSlider = new MyGuiControlSlider( position: aboveControl.Position + new Vector2(0f, aboveControl.Size.Y), width: 0.15f, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, minValue: 2, maxValue: MyMultiplayer.Static != null ? MyMultiplayer.Static.MaxPlayers : 16, labelText: new StringBuilder("{0}").ToString(), labelDecimalPlaces: 0, labelSpaceWidth: 0.02f, defaultValue: Sync.IsServer ? MySession.Static.MaxPlayers : MyMultiplayer.Static.MemberLimit, intValue: true); m_maxPlayersSlider.ValueChanged = MaxPlayersSlider_Changed; aboveControl = m_maxPlayersSlider; m_playersTable = new MyGuiControlTable() { Position = new Vector2(-m_inviteButton.Position.X, m_inviteButton.Position.Y), Size = new Vector2(1200f / MyGuiConstants.GUI_OPTIMAL_SIZE.X, 1f) - m_inviteButton.Size * 1.05f, VisibleRowsCount = 21, OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP, ColumnsCount = 5, }; float PlayerNameWidth = 0.3f; float FactionTagWidth = 0.1f; float FactionNameWidth = MyPerGameSettings.EnableMutePlayer ? 0.3f : 0.34f; float MutedWidth = MyPerGameSettings.EnableMutePlayer ? 0.13f : 0; m_playersTable.SetCustomColumnWidths(new float[] { PlayerNameWidth, FactionTagWidth, FactionNameWidth, MutedWidth, 1 - PlayerNameWidth - FactionTagWidth - FactionNameWidth - MutedWidth }); m_playersTable.SetColumnName(PlayerNameColumn, MyTexts.Get(MyCommonTexts.ScreenPlayers_PlayerName)); m_playersTable.SetColumnName(PlayerFactionTagColumn, MyTexts.Get(MyCommonTexts.ScreenPlayers_FactionTag)); m_playersTable.SetColumnName(PlayerFactionNameColumn, MyTexts.Get(MyCommonTexts.ScreenPlayers_FactionName)); m_playersTable.SetColumnName(PlayerMutedColumn, new StringBuilder(MyTexts.GetString(MyCommonTexts.ScreenPlayers_Muted))); m_playersTable.SetColumnName(GameAdminColumn, MyTexts.Get(MyCommonTexts.ScreenPlayers_GameAdmin)); m_playersTable.SetColumnComparison(0, (a, b) => (a.Text.CompareToIgnoreCase(b.Text))); m_playersTable.ItemSelected += playersTable_ItemSelected; // CH: To show the clients correctly, we would need to know, whether the game is a dedicated-server-hosted game. // We don't know that, so I just show all clients with players foreach (var player in Sync.Players.GetOnlinePlayers()) { if (player.Id.SerialId != 0) continue; for (int i = 0; i < m_playersTable.RowsCount; ++i) { var row = m_playersTable.GetRow(i); if (row.UserData is ulong && (ulong)row.UserData == player.Id.SteamId) continue; } AddPlayer(player.Id.SteamId); } m_inviteButton.ButtonClicked += inviteButton_ButtonClicked; m_promoteButton.ButtonClicked += promoteButton_ButtonClicked; m_demoteButton.ButtonClicked += demoteButton_ButtonClicked; m_kickButton.ButtonClicked += kickButton_ButtonClicked; m_banButton.ButtonClicked += banButton_ButtonClicked; m_lobbyTypeCombo.ItemSelected += lobbyTypeCombo_OnSelect; Controls.Add(m_inviteButton); Controls.Add(m_promoteButton); Controls.Add(m_demoteButton); Controls.Add(m_kickButton); Controls.Add(m_banButton); Controls.Add(m_playersTable); Controls.Add(m_lobbyTypeCombo); Controls.Add(m_maxPlayersSlider); Controls.Add(maxPlayersLabel); UpdateButtonsEnabledState(); }