当前位置: 首页>>代码示例>>C#>>正文


C# MyGuiControlCombobox.SelectItemByKey方法代码示例

本文整理汇总了C#中Sandbox.Graphics.GUI.MyGuiControlCombobox.SelectItemByKey方法的典型用法代码示例。如果您正苦于以下问题:C# MyGuiControlCombobox.SelectItemByKey方法的具体用法?C# MyGuiControlCombobox.SelectItemByKey怎么用?C# MyGuiControlCombobox.SelectItemByKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sandbox.Graphics.GUI.MyGuiControlCombobox的用法示例。


在下文中一共展示了MyGuiControlCombobox.SelectItemByKey方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RecreateControls

            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);

            }
开发者ID:Chrus,项目名称:SpaceEngineers,代码行数:41,代码来源:MyTomasDebugInputComponent.cs

示例2: RecreateControls

        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;
        }
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:63,代码来源:MyGuiScreenOptionsControls.cs

示例3: RecreateControls

        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));
        }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:87,代码来源:MyGuiScreenWardrobe.cs

示例4: RecreateControls

        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())
//.........这里部分代码省略.........
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:101,代码来源:MyGuiScreenPlayers.cs

示例5: RecreateControls

        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();
        }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:95,代码来源:MyGuiScreenPlayers.cs

示例6: RecreateControls

        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
//.........这里部分代码省略.........
开发者ID:rem02,项目名称:SpaceEngineers,代码行数:101,代码来源:MyGuiScreenOptionsGame.cs


注:本文中的Sandbox.Graphics.GUI.MyGuiControlCombobox.SelectItemByKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。