public override void RecreateControls(bool constructor)
        {
            base.RecreateControls(constructor);

            AddCaption(MyCommonTexts.ScreenCaptionControls);

            MyInput.Static.TakeSnapshot();

            var topCenter = m_size.Value * new Vector2(0f, -0.5f);
            var bottomCenter = m_size.Value * new Vector2(0f, 0.5f);
            var topLeft = m_size.Value * -0.5f;
            m_controlsOriginLeft = topLeft + new Vector2(96f, 122f) / MyGuiConstants.GUI_OPTIMAL_SIZE;
            m_controlsOriginRight = topCenter + new Vector2(-60f, 122f) / MyGuiConstants.GUI_OPTIMAL_SIZE;

            #region Add Revert, OK, Cancel and selection combobox
            var buttonSize = MyGuiControlButton.GetVisualStyle(MyGuiControlButtonStyleEnum.Default).NormalTexture.MinSizeGui;
            float buttonsY = bottomCenter.Y - 110f / MyGuiConstants.GUI_OPTIMAL_SIZE.Y;
            var okButton = new MyGuiControlButton(
                position: new Vector2(-buttonSize.X - 20f / MyGuiConstants.GUI_OPTIMAL_SIZE.X, buttonsY),
                size: MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE_SMALL,
                text: MyTexts.Get(MyCommonTexts.Ok),
                onButtonClick: OnOkClick,
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);
            var cancelButton = new MyGuiControlButton(
                position: new Vector2(0f, buttonsY),
                size: MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE_SMALL,
                text: MyTexts.Get(MyCommonTexts.Cancel),
                onButtonClick: OnCancelClick,
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);
            var resetButton = new MyGuiControlButton(
                position: new Vector2(buttonSize.X + 20f / MyGuiConstants.GUI_OPTIMAL_SIZE.X, buttonsY),
                size: MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE_SMALL,
                text: MyTexts.Get(MyCommonTexts.Revert),
                onButtonClick: OnResetDefaultsClick,
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);
            Controls.Add(okButton);
            Controls.Add(cancelButton);
            Controls.Add(resetButton);

            //  Page selection combobox
            m_currentControlType = MyGuiControlTypeEnum.General;
            var cBoxPosition = m_controlsOriginRight + 0.5f * MyGuiConstants.CONTROLS_DELTA +
                               new Vector2(MyGuiConstants.COMBOBOX_MEDIUM_SIZE.X / 2.0f, 0) - new Vector2(0.065f, 0);
            m_controlTypeList = new MyGuiControlCombobox(cBoxPosition);
            m_controlTypeList.AddItem((int)MyGuiControlTypeEnum.General, MyCommonTexts.ControlTypeGeneral);
            m_controlTypeList.AddItem((int)MyGuiControlTypeEnum.Navigation, MyCommonTexts.ControlTypeNavigation);
            m_controlTypeList.AddItem((int)MyGuiControlTypeEnum.ToolsOrWeapons, MyCommonTexts.ControlTypeToolsOrWeapons);
            m_controlTypeList.AddItem((int)MyGuiControlTypeEnum.ToolsOrWeapons2, MyCommonTexts.ControlTypeToolsOrWeapons2);
            m_controlTypeList.AddItem((int)MyGuiControlTypeEnum.Systems1, MyCommonTexts.ControlTypeSystems1);
            m_controlTypeList.AddItem((int)MyGuiControlTypeEnum.Systems2, MyCommonTexts.ControlTypeSystems2);
            m_controlTypeList.AddItem((int)MyGuiControlTypeEnum.Systems3, MyCommonTexts.ControlTypeSystems3);
            m_controlTypeList.AddItem((int)MyGuiControlTypeEnum.Spectator, MyCommonTexts.Spectator);
            m_controlTypeList.SelectItemByKey((int)m_currentControlType);
            Controls.Add(m_controlTypeList);

            #endregion

            AddControls();

            ActivateControls(m_currentControlType);

            CloseButtonEnabled = true;
        }
            public override void RecreateControls(bool constructor)
            {
                base.RecreateControls(constructor);

                m_sizeCombobox = new MyGuiControlCombobox()
                {
                    OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER,
                    Position = Vector2.Zero,
                };
                foreach (var val in typeof(MyCubeSize).GetEnumValues())
                {
                    m_sizeCombobox.AddItem((int)(MyCubeSize)val, new StringBuilder(val.ToString()));
                }
                m_sizeCombobox.SelectItemByKey((int)MyCubeSize.Large);

                m_staticCheckbox = new MyGuiControlCheckbox()
                {
                    OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER,
                    IsChecked = true,
                };
                var staticLabel = new MyGuiControlLabel()
                {
                    OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER,
                    Position = new Vector2(m_staticCheckbox.Size.X, 0f),
                    Text = "Static grid"
                };

                var okButton = new MyGuiControlButton()
                {
                    OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_TOP,
                    Text = "Ok",
                    Position = new Vector2(0f, 0.05f),
                };
                okButton.ButtonClicked += okButton_ButtonClicked;

                Elements.Add(m_sizeCombobox);
                Elements.Add(m_staticCheckbox);
                Elements.Add(staticLabel);
                Elements.Add(okButton);

            }
        private void UpdateOwnerGui()
        {
            long?owner;
            bool propertyMixed = GetOwnershipStatus(out owner);

            m_transferToCombobox.ClearItems();

            if (!propertyMixed && !owner.HasValue)
            {
                return; //selected block without id module
            }
            if (propertyMixed || owner.Value != 0)
            {
                m_transferToCombobox.AddItem(0, MyTexts.Get(MySpaceTexts.BlockOwner_Nobody));
            }

            if (propertyMixed || owner.Value != MySession.Static.LocalPlayerId)
            {
                m_transferToCombobox.AddItem(MySession.Static.LocalPlayerId, MyTexts.Get(MySpaceTexts.BlockOwner_Me));
            }

            foreach (var playerEntry in Sync.Players.GetOnlinePlayers())
            {
                var identity = playerEntry.Identity;
                if (identity.IdentityId != MySession.Static.LocalPlayerId && !identity.IsDead)
                {
                    var relation = MySession.Static.LocalHumanPlayer.GetRelationTo(identity.IdentityId);
                    if (relation != VRage.Game.MyRelationsBetweenPlayerAndBlock.Enemies)
                    {
                        m_transferToCombobox.AddItem(identity.IdentityId, new StringBuilder(identity.DisplayName));
                    }
                }
            }

            foreach (var identityId in Sync.Players.GetNPCIdentities())
            {
                var identity = Sync.Players.TryGetIdentity(identityId);
                Debug.Assert(identity != null, "Couldn't find NPC identity!");
                if (identity == null)
                {
                    continue;
                }

                var relation = MySession.Static.LocalHumanPlayer.GetRelationTo(identity.IdentityId);
                m_transferToCombobox.AddItem(identity.IdentityId, new StringBuilder(identity.DisplayName));
            }

            if (!propertyMixed)
            {
                if (owner.Value == MySession.Static.LocalPlayerId)
                {
                    m_shareModeCombobox.Enabled = true;
                }
                else
                {
                    m_shareModeCombobox.Enabled = false;
                }

                if (owner.Value == 0)
                {
                    m_transferToCombobox.Enabled = true;
                    m_ownerLabel.TextEnum        = MySpaceTexts.BlockOwner_Nobody;
                }
                else
                {
                    m_transferToCombobox.Enabled = owner.Value == MySession.Static.LocalPlayerId;
                    m_ownerLabel.TextEnum        = MySpaceTexts.BlockOwner_Me;
                    if (owner.Value != MySession.Static.LocalPlayerId)
                    {
                        var identity = Sync.Players.TryGetIdentity(owner.Value);
                        if (identity != null)
                        {
                            m_ownerLabel.Text = identity.DisplayName + (identity.IsDead ? " [" + MyTexts.Get(MyCommonTexts.PlayerInfo_Dead).ToString() + "]" : "");
                        }
                        else
                        {
                            m_ownerLabel.TextEnum = MySpaceTexts.BlockOwner_Unknown;
                        }
                    }
                }

                MyOwnershipShareModeEnum?shareMode;
                propertyMixed        = GetShareMode(out shareMode);
                m_canChangeShareMode = false;
                if (!propertyMixed && shareMode.HasValue && owner.Value != 0)
                {
                    m_shareModeCombobox.SelectItemByKey((long)shareMode.Value);
                }
                else
                {
                    m_shareModeCombobox.SelectItemByIndex(-1);
                }
                m_canChangeShareMode = true;
            }
            else
            {
                m_shareModeCombobox.Enabled = true;
                m_ownerLabel.Text           = "";

                m_canChangeShareMode = false;
                m_shareModeCombobox.SelectItemByIndex(-1);
                m_canChangeShareMode = true;
            }
        }
Пример #4
0
        public override void RecreateControls(bool constructor)
        {
            base.RecreateControls(constructor);

            var caption = AddCaption(MySpaceTexts.PlayerCharacterModel);
            var listSize = MyGuiControlListbox.GetVisualStyle(MyGuiControlListboxStyleEnum.Default).ItemSize;

            //m_modelPicker = new MyGuiControlCombobox(position: new Vector2(0f, -0.18f));
            float currY = -0.19f;
            m_modelPicker = new MyGuiControlCombobox(position: new Vector2(0f, currY));
            foreach (var entry in m_displayModels)
                m_modelPicker.AddItem(entry.Value, new StringBuilder(entry.Key));

            if (m_displayModels.ContainsKey(m_selectedModel))
                m_modelPicker.SelectItemByKey(m_displayModels[m_selectedModel]);
            else if (m_displayModels.Count > 0)
                m_modelPicker.SelectItemByKey(m_displayModels.First().Value);
            else
                System.Diagnostics.Debug.Fail("No character models loaded.");

            m_modelPicker.ItemSelected += OnItemSelected;
            currY += 0.045f;
            var positionOffset = listSize + caption.Size;

            m_position.X -= (positionOffset.X / 2.5f);
            m_position.Y += (positionOffset.Y * 3.6f);

            Controls.Add(new MyGuiControlLabel(position: new Vector2(0f, currY), text: MyTexts.GetString(MySpaceTexts.PlayerCharacterColor), originAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER));
            currY += 0.04f;

            Controls.Add( new MyGuiControlLabel(position: new Vector2(-0.135f, currY), text: "Hue:", originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER));
            m_labelHue = new MyGuiControlLabel(position: new Vector2(0.090f, currY), text: String.Empty, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);
            currY += 0.035f;
            m_sliderHue = new MyGuiControlSlider(
                position: new Vector2(-0.135f, currY),
                width: 0.3f,
                minValue: 0,
                maxValue: 360,
                labelDecimalPlaces: 0,
                labelSpaceWidth: 50 / 1200f,
                intValue: true,
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER,
                visualStyle: MyGuiControlSliderStyleEnum.Hue
                );
            currY += 0.045f;
            Controls.Add(new MyGuiControlLabel(position: new Vector2(-0.135f, currY), text: "Saturation:", originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER));
            m_labelSaturation = new MyGuiControlLabel(position: new Vector2(0.09f, currY), text: String.Empty, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);
            currY += 0.035f;
            m_sliderSaturation = new MyGuiControlSlider(
                position: new Vector2(-0.135f, currY),
                width: 0.3f,
                minValue: -100,
                maxValue: 100,
                defaultValue: 0,
                labelDecimalPlaces: 0,
                labelSpaceWidth: 50 / 1200f,
                intValue: true,
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER
                );
            currY += 0.045f;
            Controls.Add(new MyGuiControlLabel(position: new Vector2(-0.135f, currY), text: "Value:", originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER));
            m_labelValue = new MyGuiControlLabel(position: new Vector2(0.09f, currY), text: String.Empty, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);
            currY += 0.035f;
            m_sliderValue = new MyGuiControlSlider(
               position: new Vector2(-0.135f, currY),
               width: 0.3f,
               minValue: -100,
               maxValue: 100,
               defaultValue: 0,
               labelDecimalPlaces: 0,
               labelSpaceWidth: 50 / 1200f,
               intValue: true,
               originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER
               );
            currY += 0.045f;

            Controls.Add(caption);
            Controls.Add(m_modelPicker);
            Controls.Add(m_labelHue);
            Controls.Add(m_labelSaturation);
            Controls.Add(m_labelValue);
            Controls.Add(m_sliderHue);
            Controls.Add(m_sliderSaturation);
            Controls.Add(m_sliderValue);
            Controls.Add(new MyGuiControlButton(position: new Vector2(0f, 0.16f), text: new StringBuilder("OK"), onButtonClick: OnOkClick));
            Controls.Add(new MyGuiControlButton(position: new Vector2(0f, 0.22f), text: new StringBuilder("Cancel"), onButtonClick: OnCancelClick));
        }
        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();
        }
Пример #6
0
        public override void RecreateControls(bool constructor)
        {
            base.RecreateControls(constructor);

            CloseButtonEnabled = true;

            var caption = AddCaption(MySpaceTexts.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.5f * caption.Size.Y;

            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, MySpaceTexts.ScreenPlayersLobby_Private);
            m_lobbyTypeCombo.AddItem((int)LobbyTypeEnum.FriendsOnly, MySpaceTexts.ScreenPlayersLobby_Friends);
            m_lobbyTypeCombo.AddItem((int)LobbyTypeEnum.Public, MySpaceTexts.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(MySpaceTexts.ScreenPlayers_Invite));
            aboveControl = m_inviteButton;

            m_kickButton = new MyGuiControlButton(
                position: aboveControl.Position + new Vector2(0f, aboveControl.Size.Y),
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                text: MyTexts.Get(MySpaceTexts.ScreenPlayers_Kick));
            aboveControl = m_kickButton;

            m_banButton = new MyGuiControlButton(
                position: aboveControl.Position + new Vector2(0f, aboveControl.Size.Y),
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                text: MyTexts.Get(MySpaceTexts.ScreenPlayers_Ban));
            aboveControl = m_banButton;

            var maxPlayersLabel = new MyGuiControlLabel(
                position: aboveControl.Position + new Vector2(0f, aboveControl.Size.Y),
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                text: MyTexts.GetString(MySpaceTexts.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: 0,
                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(1075f / MyGuiConstants.GUI_OPTIMAL_SIZE.X, 1f) - m_inviteButton.Size * 1.05f,
                VisibleRowsCount = 21,
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP,
                ColumnsCount = 2,
            };
            m_playersTable.SetCustomColumnWidths(new float[] { 0.7f, 0.3f });
            m_playersTable.SetColumnName(0, MyTexts.Get(MySpaceTexts.ScreenPlayers_PlayerName));
            m_playersTable.SetColumnName(1, MyTexts.Get(MySpaceTexts.ScreenPlayers_GameAdmin));
            m_playersTable.SetColumnComparison(0, (a, b) => (a.Text.CompareToIgnoreCase(b.Text)));
            m_playersTable.ItemSelected += playersTable_ItemSelected;
            foreach (var userId in MyMultiplayer.Static.Members)
                AddPlayer(userId);

            m_inviteButton.ButtonClicked  += inviteButton_ButtonClicked;
            m_kickButton.ButtonClicked    += kickButton_ButtonClicked;
            m_banButton.ButtonClicked     += banButton_ButtonClicked;
            m_lobbyTypeCombo.ItemSelected += lobbyTypeCombo_OnSelect;

            Controls.Add(m_inviteButton);
            Controls.Add(m_kickButton);
            Controls.Add(m_banButton);
            Controls.Add(m_playersTable);
            Controls.Add(m_lobbyTypeCombo);
            Controls.Add(m_maxPlayersSlider);
            Controls.Add(maxPlayersLabel);

            UpdateButtonsEnabledState();
        }
        public override void RecreateControls(bool constructor)
        {
            base.RecreateControls(constructor);

            AddCaption(MyCommonTexts.ScreenCaptionGameOptions);

            var leftAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER;
            var rightAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER;
            Vector2 controlsOriginLeft = new Vector2(-m_size.Value.X / 2.0f + 0.025f, -m_size.Value.Y / 2.0f + 0.1f);
            Vector2 controlsOriginRight = new Vector2(m_size.Value.X / 2.0f - 0.025f, -m_size.Value.Y / 2.0f + 0.1f);
            Vector2 controlsDelta = new Vector2(0, 0.0525f);
            float rowIndex = 0;

            //  Language
            var languageLabel = new MyGuiControlLabel(text: MyTexts.GetString(MyCommonTexts.Language))
            {
                Position = controlsOriginLeft + rowIndex * controlsDelta,
                OriginAlign = leftAlign,
            };
            m_languageCombobox = new MyGuiControlCombobox()
            {
                Position = controlsOriginRight + rowIndex * controlsDelta,
                OriginAlign = rightAlign,
            };

            foreach (var languageId in MyLanguage.SupportedLanguages)
            {
                var description = MyTexts.Languages[languageId];
                var name = description.Name;
                if (description.IsCommunityLocalized)
                    name += " *";
                m_languageCombobox.AddItem(languageId, name);
            }
            m_languageCombobox.CustomSortItems((a, b) => a.Key.CompareTo(b.Key));
            m_languageCombobox.ItemSelected += m_languageCombobox_ItemSelected;

            rowIndex += 0.65f;
            m_localizationWebButton = new MyGuiControlButton(
               position: controlsOriginRight + rowIndex * controlsDelta,
               text: MyTexts.Get(MyCommonTexts.ScreenOptionsGame_MoreInfo),
               textScale: MyGuiConstants.DEFAULT_TEXT_SCALE * 0.85f * 0.85f,
               onButtonClick: LocalizationWebButtonClicked,
               originAlign: rightAlign);
            m_localizationWebButton.VisualStyle = MyGuiControlButtonStyleEnum.ClickableText;
            var tmp = new MyGuiControlLabel(text: MyTexts.GetString(MyCommonTexts.ScreenOptionsGame_MoreInfo), textScale: MyGuiConstants.DEFAULT_TEXT_SCALE * 0.85f * 0.85f);
            m_localizationWarningLabel = new MyGuiControlLabel(text: MyTexts.GetString(MyCommonTexts.ScreenOptionsGame_LocalizationWarning), textScale: MyGuiConstants.DEFAULT_TEXT_SCALE * 0.85f * 0.85f)
            {
                Position = controlsOriginRight + rowIndex * controlsDelta - new Vector2(tmp.Size.X + 0.005f, 0),
                OriginAlign = rightAlign,
            };
            rowIndex += 0.8f;

            if (MyFakes.ENABLE_NON_PUBLIC_GUI_ELEMENTS && MyGuiSkinManager.Static.SkinCount > 0)
            {
                m_skinLabel = new MyGuiControlLabel(text: MyTexts.GetString(MyCommonTexts.ScreenOptionsGame_Skin))
                {
                    Position = controlsOriginLeft + rowIndex * controlsDelta,
                    OriginAlign = leftAlign,
                };
                m_skinCombobox = new MyGuiControlCombobox()
                {
                    Position = controlsOriginRight + rowIndex * controlsDelta,
                    OriginAlign = rightAlign,
                };
                foreach (var skin in MyGuiSkinManager.Static.AvailableSkins)
                {
                    m_skinCombobox.AddItem(skin.Key, skin.Value.DisplayNameText);
                }
                m_skinCombobox.SelectItemByKey(MyGuiSkinManager.Static.CurrentSkinId);
                rowIndex += 0.65f;
                m_skinWarningLabel = new MyGuiControlLabel(text: MyTexts.GetString(MyCommonTexts.ScreenOptionsGame_SkinWarning),
                    textScale: MyGuiConstants.DEFAULT_TEXT_SCALE * 0.85f * 0.85f)
                {
                    Position = controlsOriginRight + rowIndex * controlsDelta,
                    OriginAlign = rightAlign,
                };
                rowIndex += 0.8f;
            }

            var buildingModeLabel = new MyGuiControlLabel(text: MyTexts.GetString(MyCommonTexts.ScreenOptionsGame_BuildingMode))
            {
                Position = controlsOriginLeft + rowIndex * controlsDelta,
                OriginAlign = leftAlign,
            };
            m_buildingModeCombobox = new MyGuiControlCombobox()
            {
                Position = controlsOriginRight + rowIndex * controlsDelta,
                OriginAlign = rightAlign,
            };
            m_buildingModeCombobox.AddItem((int)MyCubeBuilder.BuildingModeEnum.SingleBlock, MyCommonTexts.ScreenOptionsGame_SingleBlock);
            m_buildingModeCombobox.AddItem((int)MyCubeBuilder.BuildingModeEnum.Line, MyCommonTexts.ScreenOptionsGame_Line);
            m_buildingModeCombobox.AddItem((int)MyCubeBuilder.BuildingModeEnum.Plane, MyCommonTexts.ScreenOptionsGame_Plane);
            m_buildingModeCombobox.ItemSelected += m_buildingModeCombobox_ItemSelected;

            //  Notifications
            rowIndex++;
            var controlHintsLabel = new MyGuiControlLabel(text: MyTexts.GetString(MyCommonTexts.ShowControlsHints))
            {
                Position = controlsOriginLeft + rowIndex * controlsDelta,
                OriginAlign = leftAlign
            };
            m_controlHintsCheckbox = new MyGuiControlCheckbox(toolTip: MyTexts.GetString(MyCommonTexts.ToolTipGameOptionsShowControlsHints))
            {
                Position = controlsOriginRight + rowIndex * controlsDelta,
                OriginAlign = rightAlign,
            };
            m_controlHintsCheckbox.IsCheckedChanged += checkboxChanged;

            //  Rotation gizmo
            MyGuiControlLabel rotationHintsLabel = null;
            if (MyFakes.ENABLE_ROTATION_HINTS)
            {
                rowIndex++;
                rotationHintsLabel = new MyGuiControlLabel(text: MyTexts.GetString(MyCommonTexts.ShowRotationHints))
                {
                    Position = controlsOriginLeft + rowIndex * controlsDelta,
                    OriginAlign = leftAlign
                };
                m_rotationHintsCheckbox = new MyGuiControlCheckbox(toolTip: MyTexts.GetString(MyCommonTexts.ToolTipGameOptionsShowRotationHints))
                {
                    Position = controlsOriginRight + rowIndex * controlsDelta,
                    OriginAlign = rightAlign,
                };
                m_rotationHintsCheckbox.IsCheckedChanged += checkboxChanged;
            }

            //  Animated Gizmo Rotation
            rowIndex++;
            var animatedRotationLabel = new MyGuiControlLabel(text: MyTexts.GetString(MyCommonTexts.AnimatedRotation))
            {
                Position = controlsOriginLeft + rowIndex * controlsDelta,
                OriginAlign = leftAlign
            };
            m_animatedRotationCheckbox = new MyGuiControlCheckbox(toolTip: MyTexts.GetString(MyCommonTexts.AnimatedRotation))
            {
                Position = controlsOriginRight + rowIndex * controlsDelta,
                OriginAlign = rightAlign,
            };
            m_animatedRotationCheckbox.IsCheckedChanged += checkboxChanged;

            //  Building Size Hints
            rowIndex++;
            var buildingSizeHintLabel = new MyGuiControlLabel(text: MyTexts.GetString(MyCommonTexts.BuildingSizeHint))
            {
                Position = controlsOriginLeft + rowIndex * controlsDelta,
                OriginAlign = leftAlign
            };
            m_showBuildingSizeHintCheckbox = new MyGuiControlCheckbox(toolTip: MyTexts.GetString(MyCommonTexts.BuildingSizeHint))
            {
                Position = controlsOriginRight + rowIndex * controlsDelta,
                OriginAlign = rightAlign,
            };
            m_showBuildingSizeHintCheckbox.IsCheckedChanged += checkboxChanged;

            //  Show crosshair?
            rowIndex++;
            var crosshairLabel = new MyGuiControlLabel(text: MyTexts.GetString(MyCommonTexts.ShowCrosshair))
            {
                Position = controlsOriginLeft + rowIndex * controlsDelta,
                OriginAlign = leftAlign
            };
            m_crosshairCheckbox = new MyGuiControlCheckbox(toolTip: MyTexts.GetString(MyCommonTexts.ToolTipGameOptionsShowCrosshair))
            {
                Position = controlsOriginRight + rowIndex * controlsDelta,
                OriginAlign = rightAlign,
            };
            m_crosshairCheckbox.IsCheckedChanged += checkboxChanged;

            //  Headbob
            rowIndex++;
            var headbobLabel = new MyGuiControlLabel(text: MyTexts.GetString(MyCommonTexts.Headbob))
            {
                Position = controlsOriginLeft + rowIndex * controlsDelta,
                OriginAlign = leftAlign
            };
            m_disableHeadbobCheckbox = new MyGuiControlCheckbox(toolTip: MyTexts.GetString(MyCommonTexts.Headbob))
            {
                Position = controlsOriginRight + rowIndex * controlsDelta,
                OriginAlign = rightAlign,
            };
            m_disableHeadbobCheckbox.IsCheckedChanged += checkboxChanged;

            //  Compress save games checkbox
            rowIndex++;
            var compressSavesLabel = new MyGuiControlLabel(text: MyTexts.GetString(MyCommonTexts.CompressSaveGames))
            {
                Position = controlsOriginLeft + rowIndex * controlsDelta,
                OriginAlign = leftAlign
            };
            m_compressSavesCheckbox = new MyGuiControlCheckbox(toolTip: MyTexts.GetString(MyCommonTexts.ToolTipGameOptionsCompressSaveGames))
            {
                Position = controlsOriginRight + rowIndex * controlsDelta,
                OriginAlign = rightAlign,
            };
            m_compressSavesCheckbox.IsCheckedChanged += checkboxChanged;

            rowIndex++;
            var showPlayerNamesOnHudLabel = new MyGuiControlLabel(text: MyTexts.GetString(MyCommonTexts.ScreenOptionsGame_ShowPlayerNames))
            {
                Position = controlsOriginLeft + rowIndex * controlsDelta,
                OriginAlign = leftAlign
            };
            m_showPlayerNamesCheckbox = new MyGuiControlCheckbox(toolTip: MyTexts.GetString(MyCommonTexts.ToolTipGameOptionsShowPlayerNames))
            {
                Position = controlsOriginRight + rowIndex * controlsDelta,
                OriginAlign = rightAlign,
            };
            m_showPlayerNamesCheckbox.IsCheckedChanged += checkboxChanged;

            rowIndex++;
            var releasingAltResetsCameraLabel = new MyGuiControlLabel(text: MyTexts.GetString(MyCommonTexts.ScreenOptionsGame_ReleasingAltResetsCamera))
            {
                Position = controlsOriginLeft + rowIndex * controlsDelta,
                OriginAlign = leftAlign
            };
            m_releasingAltResetsCameraCheckbox = new MyGuiControlCheckbox(toolTip: MyTexts.GetString(MyCommonTexts.ToolTipGameOptionsReleasingAltResetsCamera))
            {
                Position = controlsOriginRight + rowIndex * controlsDelta,
                OriginAlign = rightAlign,
            };
            m_releasingAltResetsCameraCheckbox.IsCheckedChanged += checkboxChanged;

            rowIndex++;
            var UIOpacityLabel = new MyGuiControlLabel(text: MyTexts.GetString(MyCommonTexts.ScreenOptionsGame_UIOpacity))
            {
                Position = controlsOriginLeft + rowIndex * controlsDelta,
                OriginAlign = leftAlign
            };
            m_UIOpacitySlider = new MyGuiControlSlider(toolTip: MyTexts.GetString(MyCommonTexts.ToolTipGameOptionsUIOpacity), minValue: 0.1f, maxValue: 1.0f, defaultValue: 1.0f)
            {
                Position = controlsOriginRight + rowIndex * controlsDelta,
                OriginAlign = rightAlign,
            };
            m_UIOpacitySlider.ValueChanged += sliderChanged;

            rowIndex++;
            var UIBkOpacityLabel = new MyGuiControlLabel(text: MyTexts.GetString(MyCommonTexts.ScreenOptionsGame_UIBkOpacity))
            {
                Position = controlsOriginLeft + rowIndex * controlsDelta,
                OriginAlign = leftAlign
            };
            m_UIBkOpacitySlider = new MyGuiControlSlider(toolTip: MyTexts.GetString(MyCommonTexts.ToolTipGameOptionsUIBkOpacity), minValue: 0, maxValue: 1.0f, defaultValue: 1.0f)
            {
                Position = controlsOriginRight + rowIndex * controlsDelta,
                OriginAlign = rightAlign,
            };
            m_UIBkOpacitySlider.ValueChanged += sliderChanged;

            rowIndex++;

            //  Buttons OK and CANCEL
            var buttonOk = new MyGuiControlButton(text: MyTexts.Get(MyCommonTexts.Ok), onButtonClick: OnOkClick);
            var buttonCancel = new MyGuiControlButton(text: MyTexts.Get(MyCommonTexts.Cancel), onButtonClick: OnCancelClick);
            float buttonX = 0.01f;
            float buttonY = m_size.Value.Y / 2.0f - (buttonOk.Size.Y + 0.03f)+0.025f;
            buttonOk.Position = new Vector2(-buttonX, buttonY);
            buttonOk.OriginAlign = rightAlign;
            buttonCancel.Position = new Vector2(buttonX, buttonY);
            buttonCancel.OriginAlign = leftAlign;

            Controls.Add(languageLabel);
            Controls.Add(m_languageCombobox);
            Controls.Add(m_localizationWebButton);
            Controls.Add(m_localizationWarningLabel);
            if (MyFakes.ENABLE_NON_PUBLIC_GUI_ELEMENTS && MyGuiSkinManager.Static.SkinCount > 0)
            {
                Controls.Add(m_skinLabel);
                Controls.Add(m_skinCombobox);
                Controls.Add(m_skinWarningLabel);
            }
            Controls.Add(buildingModeLabel);
            Controls.Add(m_buildingModeCombobox);
            Controls.Add(controlHintsLabel);
            if (rotationHintsLabel != null)
                Controls.Add(rotationHintsLabel);
            Controls.Add(m_controlHintsCheckbox);
            if (m_rotationHintsCheckbox != null)
                Controls.Add(m_rotationHintsCheckbox);
            Controls.Add(animatedRotationLabel);
            Controls.Add(m_animatedRotationCheckbox);
            Controls.Add(buildingSizeHintLabel);
            Controls.Add(m_showBuildingSizeHintCheckbox);
            Controls.Add(crosshairLabel);
            Controls.Add(m_crosshairCheckbox);
            Controls.Add(headbobLabel);
            Controls.Add(m_disableHeadbobCheckbox);
            Controls.Add(compressSavesLabel);
            Controls.Add(m_compressSavesCheckbox);
            Controls.Add(showPlayerNamesOnHudLabel);
            Controls.Add(m_showPlayerNamesCheckbox);
            Controls.Add(releasingAltResetsCameraLabel);
            Controls.Add(m_releasingAltResetsCameraCheckbox);
            Controls.Add(UIOpacityLabel);
            Controls.Add(m_UIOpacitySlider);
            Controls.Add(UIBkOpacityLabel);
            Controls.Add(m_UIBkOpacitySlider);
            Controls.Add(buttonOk);
            Controls.Add(buttonCancel);

            //  Update controls with values from config file
            UpdateControls(constructor);

            CloseButtonEnabled = true;
        }