private void RecreateServerLimitInfo(MyGuiControlList list) { var identity = MySession.Static.Players.TryGetIdentity(MySession.Static.LocalPlayerId); int built; if (MySession.Static.MaxBlocksPerPlayer > 0 || MySession.Static.BlockTypeLimits.Keys.Count > 0) { MyGuiControlLabel totalBlocksLabel = new MyGuiControlLabel(text: MyTexts.GetString(MySpaceTexts.TerminalTab_Info_Overview), textScale: 1.3f); list.Controls.Add(totalBlocksLabel); } if (MySession.Static.MaxBlocksPerPlayer > 0) { MyGuiControlLabel totalBlocksLabel = new MyGuiControlLabel(text: String.Format("{0} {1}/{2} {3}", MyTexts.Get(MySpaceTexts.TerminalTab_Info_YouBuilt), identity.BlocksBuilt, MySession.Static.MaxBlocksPerPlayer + identity.BlockLimitModifier, MyTexts.Get(MySpaceTexts.TerminalTab_Info_BlocksLower))); list.Controls.Add(totalBlocksLabel); } foreach (var blockType in MySession.Static.BlockTypeLimits) { identity.BlockTypeBuilt.TryGetValue(blockType.Key, out built); var definition = Sandbox.Definitions.MyDefinitionManager.Static.TryGetDefinitionGroup(blockType.Key); if (built == null || definition == null) { continue; } MyGuiControlLabel blockTypeLabel = new MyGuiControlLabel(text: String.Format("{0} {1}/{2} {3}", MyTexts.Get(MySpaceTexts.TerminalTab_Info_YouBuilt), built, MySession.Static.GetBlockTypeLimit(blockType.Key), definition.Any.DisplayNameText)); list.Controls.Add(blockTypeLabel); } foreach (var grid in m_infoGrids) { grid.OnAuthorshipChanged -= grid_OnAuthorshipChanged; } m_infoGrids.Clear(); foreach (var grid in identity.BlocksBuiltByGrid) { MyGuiControlParent panel = new MyGuiControlParent(); if (m_infoGrids.Count == 0) { MyGuiControlSeparatorList infoSeparator = new MyGuiControlSeparatorList(); infoSeparator.AddHorizontal(new Vector2(-0.2f, -0.052f), 0.4f, width: 0.004f); panel.Controls.Add(infoSeparator); } MyGuiControlLabel gridNameLabel = new MyGuiControlLabel(text: grid.Key.DisplayName, textScale: 0.9f); MyGuiControlLabel gridBlockCountLabel = new MyGuiControlLabel(text: String.Format("{0} {1}", grid.Value, MyTexts.Get(MySpaceTexts.TerminalTab_Info_BlocksLower)), textScale: 0.9f); MyGuiControlLabel assignLabel = new MyGuiControlLabel(text: MyTexts.GetString(MySpaceTexts.TerminalTab_Info_Assign), originAlign: VRage.Utils.MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER, textScale: 0.9f); MyGuiControlCombobox assignCombobox = new MyGuiControlCombobox(originAlign: VRage.Utils.MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER, size: new Vector2(0.11f, 0.008f)); MyGuiControlSeparatorList lineSeparator = new MyGuiControlSeparatorList(); gridNameLabel.Position = new Vector2(-0.15f, -0.025f); gridBlockCountLabel.Position = new Vector2(-0.15f, 0.000f); assignLabel.Position = new Vector2(0.035f, 0.025f); assignCombobox.Position = new Vector2(0.15f, 0.025f); assignCombobox.ItemSelected += delegate() { assignCombobox_ItemSelected(grid.Key, m_playerIds[(int)assignCombobox.GetSelectedKey()]); }; m_playerIds.Clear(); foreach (var player in MySession.Static.Players.GetOnlinePlayers()) { if (MySession.Static.LocalHumanPlayer != player) { assignCombobox.AddItem(m_playerIds.Count, player.DisplayName); m_playerIds.Add(player.Id); } } lineSeparator.AddHorizontal(new Vector2(-0.15f, 0.05f), 0.3f, width: 0.002f); panel.Controls.Add(gridNameLabel); panel.Controls.Add(gridBlockCountLabel); panel.Controls.Add(assignLabel); panel.Controls.Add(assignCombobox); panel.Controls.Add(lineSeparator); if (MySession.Static.EnableRemoteBlockRemoval) { MyGuiControlLabel deleteOwnedBlocksLabel = new MyGuiControlLabel( text: MyTexts.GetString(MySpaceTexts.buttonRemove), originAlign: VRage.Utils.MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER, textScale: 0.9f); MyGuiControlButton deleteOwnedBlocksButton = new MyGuiControlButton( text: new StringBuilder("X"), onButtonClick: deleteOwnedBlocksButton_ButtonClicked, buttonIndex: m_infoGrids.Count, visualStyle: MyGuiControlButtonStyleEnum.SquareSmall, originAlign: VRage.Utils.MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER); deleteOwnedBlocksLabel.Position = new Vector2(0.11f, -0.02f); deleteOwnedBlocksButton.Position = new Vector2(0.15f, -0.02f); panel.Controls.Add(deleteOwnedBlocksLabel); panel.Controls.Add(deleteOwnedBlocksButton); } grid.Key.OnAuthorshipChanged += grid_OnAuthorshipChanged; m_infoGrids.Add(grid.Key); panel.Size = new Vector2(panel.Size.X, 0.09f); list.Controls.Add(panel); } }
internal MyGuiControlGenericFunctionalBlock(MyTerminalBlock[] blocks) : base(canHaveFocus: true, allowFocusingElements: true, isActiveControl: false) { this.m_currentBlocks = blocks; m_separatorList = new MyGuiControlSeparatorList(); Elements.Add(m_separatorList); m_terminalControlList = new MyGuiControlList(); m_terminalControlList.VisualStyle = MyGuiControlListStyleEnum.Simple; m_terminalControlList.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_TOP; m_terminalControlList.Position = new Vector2(0.1f, 0.1f); Elements.Add(m_terminalControlList); m_blockPropertiesMultilineText = new MyGuiControlMultilineText( position: new Vector2(0.049f, -0.195f), size: new Vector2(0.39f, 0.635f), font: MyFontEnum.Blue, textScale: 0.85f, textAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, textBoxAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP ); m_blockPropertiesMultilineText.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; m_blockPropertiesMultilineText.Text = new StringBuilder(); Elements.Add(m_blockPropertiesMultilineText); m_transferToCombobox = new MyGuiControlCombobox( Vector2.Zero, new Vector2(0.15f, 0.1f), null, null); m_transferToCombobox.ItemSelected += m_transferToCombobox_ItemSelected; Elements.Add(m_transferToCombobox); m_shareModeCombobox = new MyGuiControlCombobox( Vector2.Zero, new Vector2(0.25f, 0.1f), null, null); m_shareModeCombobox.ItemSelected += m_shareModeCombobox_ItemSelected; Elements.Add(m_shareModeCombobox); m_ownershipLabel = new MyGuiControlLabel( Vector2.Zero, null, MyTexts.GetString(MySpaceTexts.BlockOwner_Owner) + ":"); Elements.Add(m_ownershipLabel); m_ownerLabel = new MyGuiControlLabel( Vector2.Zero, null, String.Empty); Elements.Add(m_ownerLabel); m_transferToLabel = new MyGuiControlLabel( Vector2.Zero, null, MyTexts.GetString(MySpaceTexts.BlockOwner_TransferTo)); Elements.Add(m_transferToLabel); if (MySession.Static.CreativeMode) { var topLeftRelative = Vector2.One * -0.5f; Vector2 leftColumnSize = new Vector2(0.3f, 0.55f); var position = topLeftRelative + new Vector2(leftColumnSize.X + 0.503f, 0.42f); m_npcButton = new MyGuiControlButton( position, MyGuiControlButtonStyleEnum.Tiny, new Vector2(0.1f, 0.1f), null, MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER, MyTexts.GetString(MyCommonTexts.AddNewNPC), new StringBuilder("+"), MyGuiConstants.DEFAULT_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyGuiControlHighlightType.WHEN_ACTIVE, true, OnNewNpcClick, GuiSounds.MouseClick, 0.75f); Elements.Add(m_npcButton); } RecreateBlockControls(); RecreateOwnershipControls(); if (m_currentBlocks.Length > 0) { m_currentBlocks[0].PropertiesChanged += block_PropertiesChanged; } foreach (var block in m_currentBlocks) { block.OwnershipChanged += block_OwnershipChanged; block.VisibilityChanged += block_VisibilityChanged; } Sync.Players.IdentitiesChanged += Players_IdentitiesChanged; UpdateDetailedInfo(); Size = new Vector2(0.595f, 0.64f); }
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.125f); Vector2 controlsOriginRight = new Vector2(m_size.Value.X / 2.0f - 0.025f, -m_size.Value.Y / 2.0f + 0.125f); 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; } // 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); 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(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; }
public MyGuiScreenHelpSpace() : base(new Vector2(0.5f, 0.5f), MyGuiConstants.SCREEN_BACKGROUND_COLOR, new Vector2(1f, 0.98f)) { EnabledBackgroundFade = true; m_pages = new HelpPage[typeof(HelpPageEnum).GetEnumValues().Length]; m_pageTitles = new String[m_pages.Length]; m_pages[(int)HelpPageEnum.Basic] = new HelpPage(); m_pages[(int)HelpPageEnum.Advanced] = new HelpPage(); m_pages[(int)HelpPageEnum.Advanced2] = new HelpPage(); m_pages[(int)HelpPageEnum.Spectator] = new HelpPage(); m_pages[(int)HelpPageEnum.Developer] = new HelpPage(); m_pages[(int)HelpPageEnum.Developer2] = new HelpPage(); m_pageTitles[(int)HelpPageEnum.Basic] = MyTexts.GetString(MyCommonTexts.BasicControls); m_pageTitles[(int)HelpPageEnum.Advanced] = MyTexts.GetString(MyCommonTexts.AdvancedControls); m_pageTitles[(int)HelpPageEnum.Advanced2] = MyTexts.GetString(MyCommonTexts.AdvancedControls); m_pageTitles[(int)HelpPageEnum.Spectator] = MyTexts.GetString(MyCommonTexts.SpectatorControls); m_pageTitles[(int)HelpPageEnum.Developer] = "Developer Controls"; m_pageTitles[(int)HelpPageEnum.Developer2] = "Developer Controls"; HelpPage basicPage = m_pages[(int)HelpPageEnum.Basic]; HelpPage advancedPage = m_pages[(int)HelpPageEnum.Advanced]; HelpPage advancedPage2 = m_pages[(int)HelpPageEnum.Advanced2]; HelpPage spectatorPage = m_pages[(int)HelpPageEnum.Spectator]; HelpPage developerPage = m_pages[(int)HelpPageEnum.Developer]; HelpPage developer2Page = m_pages[(int)HelpPageEnum.Developer2]; basicPage.LeftColumn.Add(new ControlWithDescription(MyControlsSpace.BUILD_SCREEN)); basicPage.LeftColumn.Add(new ControlWithDescription(MyControlsSpace.FORWARD)); basicPage.LeftColumn.Add(new ControlWithDescription(MyControlsSpace.BACKWARD)); basicPage.LeftColumn.Add(new ControlWithDescription(MyControlsSpace.STRAFE_LEFT)); basicPage.LeftColumn.Add(new ControlWithDescription(MyControlsSpace.STRAFE_RIGHT)); basicPage.LeftColumn.Add(new ControlWithDescription(MyControlsSpace.ROLL_LEFT)); basicPage.LeftColumn.Add(new ControlWithDescription(MyControlsSpace.ROLL_RIGHT)); basicPage.LeftColumn.Add(new ControlWithDescription(MyControlsSpace.JUMP)); basicPage.LeftColumn.Add(new ControlWithDescription(MyControlsSpace.CROUCH)); basicPage.LeftColumn.Add(new ControlWithDescription(MyControlsSpace.SWITCH_WALK)); basicPage.LeftColumn.Add(new ControlWithDescription(MyControlsSpace.CAMERA_MODE)); basicPage.LeftColumn.Add(new ControlWithDescription(MyControlsSpace.DAMPING)); basicPage.LeftColumn.Add(new ControlWithDescription(MyControlsSpace.THRUSTS)); basicPage.LeftColumn.Add(new ControlWithDescription(MyControlsSpace.BROADCASTING)); basicPage.LeftColumn.Add(new ControlWithDescription(MyControlsSpace.HELMET)); if (MySession.Static != null && (MySession.Static.IsScenario || MySession.Static.Settings.ScenarioEditMode)) { basicPage.LeftColumn.Add(new ControlWithDescription(MyControlsSpace.MISSION_SETTINGS)); } basicPage.RightColumn.Add(new ControlWithDescription(MyControlsSpace.PRIMARY_TOOL_ACTION)); basicPage.RightColumn.Add(new ControlWithDescription(MyControlsSpace.SLOT1)); basicPage.RightColumn.Add(new ControlWithDescription(MyControlsSpace.SLOT2)); basicPage.RightColumn.Add(new ControlWithDescription(MyControlsSpace.SLOT3)); basicPage.RightColumn.Add(new ControlWithDescription(MyControlsSpace.SLOT4)); basicPage.RightColumn.Add(new ControlWithDescription(MyControlsSpace.SLOT5)); basicPage.RightColumn.Add(new ControlWithDescription(MyControlsSpace.SLOT6)); basicPage.RightColumn.Add(new ControlWithDescription(MyControlsSpace.SLOT7)); basicPage.RightColumn.Add(new ControlWithDescription(MyControlsSpace.SLOT8)); basicPage.RightColumn.Add(new ControlWithDescription(MyControlsSpace.SLOT9)); basicPage.RightColumn.Add(new ControlWithDescription(MyControlsSpace.SLOT0)); basicPage.RightColumn.Add(new ControlWithDescription(MyControlsSpace.TOOLBAR_UP)); basicPage.RightColumn.Add(new ControlWithDescription(MyControlsSpace.TOOLBAR_DOWN)); basicPage.RightColumn.Add(new ControlWithDescription("Shift + " + MyInput.Static.GetGameControl(MyControlsSpace.SLOT1).ToString(), "Select toolbar page 1")); basicPage.RightColumn.Add(new ControlWithDescription("Shift + " + MyInput.Static.GetGameControl(MyControlsSpace.SLOT2).ToString(), "Select toolbar page 2")); basicPage.RightColumn.Add(new ControlWithDescription("Shift + " + MyInput.Static.GetGameControl(MyControlsSpace.SLOT3).ToString(), "Select toolbar page 3")); basicPage.RightColumn.Add(new ControlWithDescription("Shift + " + MyInput.Static.GetGameControl(MyControlsSpace.SLOT4).ToString(), "Select toolbar page 4")); advancedPage.LeftColumn.Add(new ControlWithDescription(MyControlsSpace.SPRINT)); advancedPage.LeftColumn.Add(new ControlWithDescription(MyControlsSpace.LOOKAROUND)); advancedPage.LeftColumn.Add(new ControlWithDescription(MyControlsSpace.LANDING_GEAR)); advancedPage.LeftColumn.Add(new ControlWithDescription("Shift + " + MyInput.Static.GetGameControl(MyControlsSpace.LANDING_GEAR).ToString(), "Pick color from cube into slot")); advancedPage.LeftColumn.Add(new ControlWithDescription(MyTexts.Get(MyCommonTexts.MouseWheel), MyTexts.Get(MySpaceTexts.ControlDescZoom))); advancedPage.LeftColumn.Add(new ControlWithDescription(MyControlsSpace.SECONDARY_TOOL_ACTION)); advancedPage.LeftColumn.Add(new ControlWithDescription(MyControlsSpace.USE)); advancedPage.LeftColumn.Add(new ControlWithDescription(MyControlsSpace.INVENTORY)); advancedPage.LeftColumn.Add(new ControlWithDescription(MyControlsSpace.TOGGLE_REACTORS)); advancedPage.LeftColumn.Add(new ControlWithDescription(MyControlsSpace.TERMINAL)); advancedPage.LeftColumn.Add(new ControlWithDescription(MyControlsSpace.HEADLIGHTS)); advancedPage.LeftColumn.Add(new ControlWithDescription(MyControlsSpace.SUICIDE)); advancedPage.LeftColumn.Add(new ControlWithDescription(MyControlsSpace.TOGGLE_HUD)); advancedPage.LeftColumn.Add(new ControlWithDescription("Ctrl + C", "Copy object")); advancedPage.LeftColumn.Add(new ControlWithDescription("Ctrl + Shift + C", "Copy object detached")); advancedPage.LeftColumn.Add(new ControlWithDescription("Ctrl + V", "Paste object")); advancedPage.LeftColumn.Add(new ControlWithDescription("Ctrl + X", "Delete object")); advancedPage.LeftColumn.Add(new ControlWithDescription("Ctrl + B", "Create/manage blueprints")); advancedPage.LeftColumn.Add(new ControlWithDescription("F10", "Open blueprint screen")); advancedPage.LeftColumn.Add(new ControlWithDescription("Shift + F10", "Open spawn screen")); advancedPage.LeftColumn.Add(new ControlWithDescription("Alt + F10", "Open admin screen")); advancedPage.LeftColumn.Add(new ControlWithDescription("Ctrl + " + MyTexts.GetString(MyCommonTexts.MouseWheel), MyTexts.GetString(MyCommonTexts.ControlDescCopyPasteMove))); advancedPage.LeftColumn.Add(new ControlWithDescription("Ctrl + Alt+ E", MyTexts.GetString(MyCommonTexts.ControlDescExportModel))); StringBuilder repaintControlText = null; MyInput.Static.GetGameControl(MyControlsSpace.CUBE_COLOR_CHANGE).AppendBoundButtonNames(ref repaintControlText, unassignedText: MyInput.Static.GetUnassignedName()); advancedPage.RightColumn.Add(new ControlWithDescription(MyControlsSpace.HELP_SCREEN)); //advancedPage.RightColumn.Add(new ControlWithDescription(MyControlsSpace.CHAT_SCREEN)); advancedPage.RightColumn.Add(new ControlWithDescription("F3", MyTexts.GetString(MyCommonTexts.ControlDescPlayersList))); advancedPage.RightColumn.Add(new ControlWithDescription(MyControlsSpace.CHAT_SCREEN)); advancedPage.RightColumn.Add(new ControlWithDescription(MyControlsSpace.CONSOLE)); advancedPage.RightColumn.Add(new ControlWithDescription(MyControlsSpace.SCREENSHOT)); //advancedPage.RightColumn.Add(new ControlWithDescription(MyControlsSpace.SHOW_DAMAGED)); advancedPage.RightColumn.Add(new ControlWithDescription("F5", MyTexts.GetString(MyCommonTexts.ControlDescQuickLoad))); advancedPage.RightColumn.Add(new ControlWithDescription("Shift + F5", MyTexts.GetString(MyCommonTexts.ControlDescQuickSave))); advancedPage.RightColumn.Add(new ControlWithDescription(MyControlsSpace.PAUSE_GAME)); advancedPage.RightColumn.Add(new ControlWithDescription(MyInput.Static.GetGameControl(MyControlsSpace.LANDING_GEAR).ToStringBuilder(MyInput.Static.GetUnassignedName()), MyTexts.Get(MySpaceTexts.TerminalControlPanel_Cockpit_Handbrake))); advancedPage.RightColumn.Add(new ControlWithDescription(MyInput.Static.GetGameControl(MyControlsSpace.JUMP).ToStringBuilder(MyInput.Static.GetUnassignedName()), MyTexts.Get(MySpaceTexts.ControlDescBrake))); advancedPage.RightColumn.Add(new ControlWithDescription(MyInput.Static.GetGameControl(MyControlsSpace.INVENTORY).ToStringBuilder(MyInput.Static.GetUnassignedName()).Append("/").Append(MyInput.Static.GetGameControl(MyControlsSpace.TERMINAL).ToString()), MyTexts.Get(MySpaceTexts.ControlDescLoot))); advancedPage.RightColumn.Add(new ControlWithDescription("", "")); advancedPage.RightColumn.Add(new ControlWithDescription(new StringBuilder(), MyTexts.Get(MyCommonTexts.Factions), rightFont: MyFontEnum.Red)); advancedPage.RightColumn.Add(new ControlWithDescription(MyTexts.Get(MySpaceTexts.HelpScreen_FactionColor_Blue), MyTexts.Get(MySpaceTexts.Factions_YourBlock), new StringBuilder("Textures\\HUD\\marker_self.dds"), new Color(117, 201, 241), MyFontEnum.Blue)); advancedPage.RightColumn.Add(new ControlWithDescription(MyTexts.Get(MySpaceTexts.HelpScreen_FactionColor_Green), MyTexts.Get(MySpaceTexts.Factions_YourFaction), new StringBuilder("Textures\\HUD\\marker_friendly.dds"), new Color(101, 178, 90), MyFontEnum.Green)); advancedPage.RightColumn.Add(new ControlWithDescription(MyTexts.Get(MySpaceTexts.HelpScreen_FactionColor_White), MyTexts.Get(MySpaceTexts.Factions_NeutralFaction), new StringBuilder("Textures\\HUD\\marker_neutral.dds"), Color.White, MyFontEnum.White)); advancedPage.RightColumn.Add(new ControlWithDescription(MyTexts.Get(MySpaceTexts.HelpScreen_FactionColor_Red), MyTexts.Get(MySpaceTexts.Factions_EnemyFaction), new StringBuilder("Textures\\HUD\\marker_enemy.dds"), new Color(227, 62, 63))); advancedPage.RightColumn.Add(new ControlWithDescription("", "")); advancedPage.RightColumn.Add(new ControlWithDescription(MyControlsSpace.ROTATION_LEFT)); advancedPage.RightColumn.Add(new ControlWithDescription(MyControlsSpace.ROTATION_RIGHT)); advancedPage.RightColumn.Add(new ControlWithDescription(MyControlsSpace.ROTATION_UP)); advancedPage.RightColumn.Add(new ControlWithDescription(MyControlsSpace.ROTATION_DOWN)); advancedPage2.RightColumn.Add(new ControlWithDescription(repaintControlText, MyTexts.Get(MySpaceTexts.ControlDescSingleAllMode))); advancedPage2.RightColumn.Add(new ControlWithDescription(repaintControlText, MyTexts.Get(MySpaceTexts.ControlDescHoldToColor))); advancedPage2.RightColumn.Add(new ControlWithDescription("Ctrl + " + repaintControlText, MyTexts.GetString(MySpaceTexts.ControlDescMediumBrush))); advancedPage2.RightColumn.Add(new ControlWithDescription("Shift + " + repaintControlText, MyTexts.GetString(MySpaceTexts.ControlDescLargeBrush))); advancedPage2.LeftColumn.Add(new ControlWithDescription(MyControlsSpace.CUBE_ROTATE_VERTICAL_POSITIVE)); advancedPage2.LeftColumn.Add(new ControlWithDescription(MyControlsSpace.CUBE_ROTATE_VERTICAL_NEGATIVE)); advancedPage2.LeftColumn.Add(new ControlWithDescription(MyControlsSpace.CUBE_ROTATE_HORISONTAL_POSITIVE)); advancedPage2.LeftColumn.Add(new ControlWithDescription(MyControlsSpace.CUBE_ROTATE_HORISONTAL_NEGATIVE)); advancedPage2.LeftColumn.Add(new ControlWithDescription(MyControlsSpace.CUBE_ROTATE_ROLL_POSITIVE)); advancedPage2.LeftColumn.Add(new ControlWithDescription(MyControlsSpace.CUBE_ROTATE_ROLL_NEGATIVE)); advancedPage2.LeftColumn.Add(new ControlWithDescription(MyControlsSpace.STATION_ROTATION)); advancedPage2.LeftColumn.Add(new ControlWithDescription("Ctrl + G", MyTexts.GetString(MySpaceTexts.SwitchBuilderMode))); advancedPage2.RightColumn.Add(new ControlWithDescription(MyControlsSpace.SWITCH_LEFT)); advancedPage2.RightColumn.Add(new ControlWithDescription(MyControlsSpace.SWITCH_RIGHT)); advancedPage2.RightColumn.Add(new ControlWithDescription(MyTexts.Get(MyCommonTexts.MouseWheel), MyTexts.Get(MySpaceTexts.ControlDescCameraZoom))); advancedPage2.RightColumn.Add(new ControlWithDescription(MyControlsSpace.SYMMETRY_SWITCH)); advancedPage2.RightColumn.Add(new ControlWithDescription(MyControlsSpace.USE_SYMMETRY)); advancedPage2.RightColumn.Add(new ControlWithDescription("", "")); advancedPage2.RightColumn.Add(new ControlWithDescription("Ctrl + H", MyTexts.GetString(MySpaceTexts.ControlDescNetgraph))); advancedPage2.RightColumn.Add(new ControlWithDescription("[", MyTexts.GetString(MyCommonTexts.ControlDescNextVoxelMaterial))); advancedPage2.RightColumn.Add(new ControlWithDescription("]", MyTexts.GetString(MyCommonTexts.ControlDescPreviousVoxelMaterial))); advancedPage2.RightColumn.Add(new ControlWithDescription("H", MyTexts.GetString(MyCommonTexts.ControlDescOpenVoxelHandSettings))); spectatorPage.LeftColumn.Add(new ControlWithDescription(MyControlsSpace.SPECTATOR_NONE)); spectatorPage.LeftColumn.Add(new ControlWithDescription(MyControlsSpace.SPECTATOR_DELTA)); spectatorPage.LeftColumn.Add(new ControlWithDescription(MyControlsSpace.SPECTATOR_FREE)); spectatorPage.LeftColumn.Add(new ControlWithDescription(MyControlsSpace.SPECTATOR_STATIC)); //These keys are to be used just for developers or testing if (MyInput.Static.ENABLE_DEVELOPER_KEYS) { // Developers developerPage.LeftColumn.Add(new ControlWithDescription("Ctrl + NumPad0", "Enable/Disable debug input - global")); developerPage.LeftColumn.Add(new ControlWithDescription("Ctrl + NumPad1", "Enable/Disable debug input - character")); developerPage.LeftColumn.Add(new ControlWithDescription("Ctrl + NumPad2", "Enable/Disable debug input - Ondra")); developerPage.LeftColumn.Add(new ControlWithDescription("Ctrl + NumPad3", "Enable/Disable debug input - Peta")); developerPage.LeftColumn.Add(new ControlWithDescription("Ctrl + NumPad4", "Enable/Disable debug input - Martin")); developerPage.LeftColumn.Add(new ControlWithDescription("F11", "Game statistics")); developerPage.LeftColumn.Add(new ControlWithDescription("Shift + F11", "Frame info (FPS and stuff)")); developerPage.LeftColumn.Add(new ControlWithDescription("F12", "Debug screen")); developerPage.LeftColumn.Add(new ControlWithDescription("", "")); developerPage.LeftColumn.Add(new ControlWithDescription("", "Character Debug Input")); developerPage.LeftColumn.Add(new ControlWithDescription("U", "Add astronaut (current color)")); developerPage.LeftColumn.Add(new ControlWithDescription("NumPad7", "Switch to next ship")); developerPage.LeftColumn.Add(new ControlWithDescription("NumPad8", "Switch to next character")); developerPage.RightColumn.Add(new ControlWithDescription("", "Global Debug Input")); developerPage.RightColumn.Add(new ControlWithDescription("F6", "Switch between astronauts")); developerPage.RightColumn.Add(new ControlWithDescription("F7", "Switch to fixed dir. 3rd person camera")); developerPage.RightColumn.Add(new ControlWithDescription("F8", "Switch to spectator camera")); developerPage.RightColumn.Add(new ControlWithDescription("Ctrl + F8", "Reset spectator camera")); developerPage.RightColumn.Add(new ControlWithDescription("F9", "Switch to static 3rd person")); developerPage.RightColumn.Add(new ControlWithDescription("Ctrl + Space", "Move character to spectator position")); developerPage.RightColumn.Add(new ControlWithDescription("NumPad3", "Apply large force to controlled object.")); developerPage.RightColumn.Add(new ControlWithDescription("NumPad6", "Apply small force to controlled object.")); developerPage.RightColumn.Add(new ControlWithDescription("Ctrl + Shift + Z", "Save prefab")); developer2Page.LeftColumn.Add(new ControlWithDescription("", "Debug Input - Ondra")); developer2Page.LeftColumn.Add(new ControlWithDescription("Ctrl + Insert", "Merge all grids.")); developer2Page.LeftColumn.Add(new ControlWithDescription("Ctrl + Delete", "Remove all characters.")); developer2Page.LeftColumn.Add(new ControlWithDescription("Ctrl + NumDecimal", "Remove all except controlled object.")); developer2Page.LeftColumn.Add(new ControlWithDescription("Ctrl + J", "Duplicate current grid.")); developer2Page.LeftColumn.Add(new ControlWithDescription("Ctrl + C", "Copy target (of cube builder gizmo)")); developer2Page.LeftColumn.Add(new ControlWithDescription("Ctrl + X", "Cut target (of cube builder gizmo)")); developer2Page.LeftColumn.Add(new ControlWithDescription("Ctrl + V", "Paste")); developer2Page.LeftColumn.Add(new ControlWithDescription("", "")); developer2Page.LeftColumn.Add(new ControlWithDescription("", "Debug Input - Peta")); developer2Page.LeftColumn.Add(new ControlWithDescription("Numpad0", "Add weapons, ammo and components to inventory.")); developer2Page.RightColumn.Add(new ControlWithDescription("", "Debug Input - Martin")); developer2Page.RightColumn.Add(new ControlWithDescription("M + Numpad2", "Toggle thrusts on/off.")); developer2Page.RightColumn.Add(new ControlWithDescription("M + Numpad3", "Toggle shooting turrets.")); developer2Page.RightColumn.Add(new ControlWithDescription("M + Numpad4", "Reload definitions.")); developer2Page.RightColumn.Add(new ControlWithDescription("M + Numpad5", "Show screen with all definition icons.")); developer2Page.RightColumn.Add(new ControlWithDescription("M + Numpad6", "Remove all floating objects.")); } AddProfilerControls(developerPage); m_currentPage = HelpPageEnum.Basic; CloseButtonEnabled = true; RecreateControls(true); }
private MyGuiControlLabel MakeLabel(MyStringId textEnum) { return(new MyGuiControlLabel(text: MyTexts.GetString(textEnum), originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); }
private void AddServerItem(GameServerItem server, string sessionName, StringBuilder gamemodeSB, StringBuilder gamemodeToolTipSB, string remainingTimeText = null, float?remainingTimeSeconds = null) { 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(MyCommonTexts.JoinGame_GameTypeToolTip_ViewDistance).ToString(), viewDistance); } var row = new MyGuiControlTable.Row(server); 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())); if (MyFakes.ENABLE_JOIN_SCREEN_REMAINING_TIME) { if (remainingTimeText != null) { row.AddCell(new MyGuiControlTable.Cell(text: m_textCache.Clear().Append(remainingTimeText))); } else if (remainingTimeSeconds != null) { row.AddCell(new CellRemainingTime(remainingTimeSeconds.Value)); } else { row.AddCell(new MyGuiControlTable.Cell(text: m_textCache.Clear())); } } 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(MyCommonTexts.JoinGame_SelectServerToShowModList))); m_gamesTable.Add(row); var selectedRow = m_gamesTable.SelectedRow; m_gamesTable.Sort(false); m_gamesTable.SelectedRowIndex = m_gamesTable.FindRow(selectedRow); }
protected MyGuiControlCheckbox AddCheckBox(MyStringId textEnum, Func <bool> getter, Action <bool> setter, bool enabled = true, List <MyGuiControlBase> controlGroup = null, Vector4?color = null, Vector2?checkBoxOffset = null) { return(AddCheckBox(MyTexts.GetString(textEnum), getter, setter, enabled, controlGroup, color, checkBoxOffset)); }
private void OnFactionsStateChanged(MyFactionCollection.MyFactionStateChange action, long fromFactionId, long toFactionId, long playerId, long senderId) { System.Diagnostics.Debug.Assert(MySession.Static != null); if (MySession.Static == null) { return; } System.Diagnostics.Debug.Assert(MySession.Static.Factions != null); if (MySession.Static.Factions == null) { return; } System.Diagnostics.Debug.Assert(m_tableFactions != null); if (m_tableFactions == null) { return; } var fromFaction = MySession.Static.Factions.TryGetFactionById(fromFactionId); var toFaction = MySession.Static.Factions.TryGetFactionById(toFactionId); switch (action) { case MyFactionCollection.MyFactionStateChange.SendPeaceRequest: { System.Diagnostics.Debug.Assert(m_userFaction != null); if (m_userFaction == null) { return; } if (m_userFaction.FactionId == fromFactionId) { RemoveFaction(toFactionId); AddFaction(toFaction, COLOR_CUSTOM_RED, MyGuiConstants.TEXTURE_ICON_SENT_WHITE_FLAG, MyTexts.GetString(MySpaceTexts.TerminalTab_Factions_SentPeace)); } else if (m_userFaction.FactionId == toFactionId) { RemoveFaction(fromFactionId); AddFaction(fromFaction, COLOR_CUSTOM_RED, MyGuiConstants.TEXTURE_ICON_WHITE_FLAG, MyTexts.GetString(MySpaceTexts.TerminalTab_Factions_PendingPeace)); } break; } case MyFactionCollection.MyFactionStateChange.AcceptPeace: { System.Diagnostics.Debug.Assert(m_userFaction != null); if (m_userFaction == null) { return; } if (m_userFaction.FactionId == fromFactionId) { RemoveFaction(toFactionId); AddFaction(toFaction); } else if (m_userFaction.FactionId == toFactionId) { RemoveFaction(fromFactionId); AddFaction(fromFaction); } break; } case MyFactionCollection.MyFactionStateChange.CancelPeaceRequest: case MyFactionCollection.MyFactionStateChange.DeclareWar: { System.Diagnostics.Debug.Assert(m_userFaction != null); if (m_userFaction == null) { return; } if (m_userFaction.FactionId == fromFactionId) { RemoveFaction(toFactionId); AddFaction(toFaction, COLOR_CUSTOM_RED); } else if (m_userFaction.FactionId == toFactionId) { RemoveFaction(fromFactionId); AddFaction(fromFaction, COLOR_CUSTOM_RED); } break; } case MyFactionCollection.MyFactionStateChange.RemoveFaction: RemoveFaction(toFactionId); break; default: OnMemberStateChanged(action, fromFaction, playerId); break; } m_tableFactions.Sort(false); m_tableFactions.SelectedRowIndex = m_tableFactions.FindIndex((row) => ((MyFaction)row.UserData).FactionId == toFactionId); OnFactionsTableItemSelected(m_tableFactions, new Sandbox.Graphics.GUI.MyGuiControlTable.EventArgs()); Refresh(); }
protected override MyGuiControlBase CreateGui() { m_textbox = new MyGuiControlTextbox(); m_textbox.Size = new Vector2(PREFERRED_CONTROL_WIDTH, m_textbox.Size.Y); m_textChanged = OnTextChanged; m_textbox.TextChanged += m_textChanged; var propertyControl = new MyGuiControlBlockProperty(MyTexts.GetString(Title), MyTexts.GetString(Tooltip), m_textbox); propertyControl.Size = new Vector2(PREFERRED_CONTROL_WIDTH, propertyControl.Size.Y); return(propertyControl); }
public string ExecuteCode(string argument) { if (m_isRunning) { return(MyTexts.GetString(MySpaceTexts.ProgrammableBlock_Exception_AllreadyRunning)); } if (m_wasTerminated == true) { return(DetailedInfo.ToString()); } DetailedInfo.Clear(); m_echoOutput.Clear(); if (m_assembly == null) { return(MyTexts.GetString(MySpaceTexts.ProgrammableBlock_Exception_NoAssembly)); } if (m_mainMethod == null) { return(MyTexts.GetString(MySpaceTexts.ProgrammableBlock_Exception_NoMain)); } if (this.m_elapsedTimeField != null) { if (m_previousRunTimestamp == 0) { m_previousRunTimestamp = Stopwatch.GetTimestamp(); m_elapsedTimeField.SetValue(m_instance, TimeSpan.Zero); } else { var currentTimestamp = Stopwatch.GetTimestamp(); var elapsedTime = (currentTimestamp - m_previousRunTimestamp) * Sync.RelativeSimulationRatio; m_elapsedTimeField.SetValue(m_instance, TimeSpan.FromSeconds(elapsedTime * STOPWATCH_FREQUENCY)); m_previousRunTimestamp = currentTimestamp; } } if (m_programGridGroup != null) { var gridGroup = MyCubeGridGroups.Static.Logical.GetGroup(CubeGrid); var terminalSystem = gridGroup.GroupData.TerminalSystem; terminalSystem.UpdateGridBlocksOwnership(this.OwnerId); m_programGridGroup.SetValue(m_instance, terminalSystem); } m_isRunning = true; string retVal = ""; IlInjector.RestartCountingInstructions(MAX_NUM_EXECUTED_INSTRUCTIONS); try { if (m_mainMethodSupportsArgument) { // Don't know if it's really necessary to predefine this argument array, I suspect not // due to the cleverness of the compiler, but I do it this way just in case. // Obviously if programmable block execution becomes asynchronous at some point this // must be reworked. m_argumentArray[0] = argument ?? string.Empty; m_mainMethod.Invoke(m_instance, m_argumentArray); } else { m_mainMethod.Invoke(m_instance, null); } if (m_echoOutput.Length > 0) { retVal = m_echoOutput.ToString(); } } catch (TargetInvocationException ex) { // Since we just had an exception I'm not fussed about using old // fashioned string concatenation here. We'll still want the echo // output, since its primary purpose is debugging. if (m_echoOutput.Length > 0) { retVal = m_echoOutput.ToString(); } OnProgramTermination(); if (ex.InnerException is ScriptOutOfRangeException) { retVal += MyTexts.GetString(MySpaceTexts.ProgrammableBlock_Exception_TooComplex); } else if (ex.InnerException != null) { retVal += MyTexts.GetString(MySpaceTexts.ProgrammableBlock_Exception_ExceptionCaught) + ex.InnerException.Message; } } m_isRunning = false; return(retVal); }
private void CompileAndCreateInstance(string program, string storage) { if (MySession.Static.EnableIngameScripts == false) { return; } m_wasTerminated = false; m_mainMethod = null; Assembly temp = null; MyGuiScreenEditor.CompileProgram(program, m_compilerErrors, ref temp); if (temp != null) { try { m_assembly = IlInjector.InjectCodeToAssembly("IngameScript_safe", temp, typeof(IlInjector).GetMethod("CountInstructions", BindingFlags.Public | BindingFlags.Static)); var type = m_assembly.GetType("Program"); if (type != null) { IlInjector.RestartCountingInstructions(MAX_NUM_EXECUTED_INSTRUCTIONS); try { m_instance = Activator.CreateInstance(type); m_programGridGroup = type.GetField("GridTerminalSystem", BindingFlags.NonPublic | BindingFlags.GetField | BindingFlags.Instance); m_storageField = type.GetField("Storage", BindingFlags.NonPublic | BindingFlags.GetField | BindingFlags.Instance); m_meField = type.GetField("Me", BindingFlags.NonPublic | BindingFlags.GetField | BindingFlags.Instance); m_echoField = type.GetField("Echo", BindingFlags.NonPublic | BindingFlags.GetField | BindingFlags.Instance); m_elapsedTimeField = type.GetField("ElapsedTime", BindingFlags.NonPublic | BindingFlags.GetField | BindingFlags.Instance); if (m_programGridGroup != null) { // First try to get the main method with a string argument. If this fails, try to get one without. m_mainMethod = type.GetMethod("Main", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance, null, new[] { typeof(string) }, null); m_mainMethodSupportsArgument = m_mainMethod != null; if (m_mainMethod == null) { m_mainMethod = type.GetMethod("Main", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); } } if (m_storageField != null) { m_storageField.SetValue(m_instance, storage); } if (m_meField != null) { m_meField.SetValue(m_instance, this); } if (m_echoField != null) { m_echoField.SetValue(m_instance, new Action <string>(EchoTextToDetailInfo)); } } catch (TargetInvocationException ex) { if (ex.InnerException != null) { string response = MyTexts.GetString(MySpaceTexts.ProgrammableBlock_Exception_ExceptionCaught) + ex.InnerException.Message; if (DetailedInfo.ToString() != response) { SyncObject.SendProgramResponseMessage(response); WriteProgramResponse(response); } } } } } catch (Exception ex) { string response = MyTexts.GetString(MySpaceTexts.ProgrammableBlock_Exception_ExceptionCaught) + ex.Message; if (DetailedInfo.ToString() != response) { SyncObject.SendProgramResponseMessage(response); WriteProgramResponse(response); } } } }
public override void RecreateControls(bool constructor) { base.RecreateControls(constructor); m_openWorkshopButton = new MyGuiControlButton(position: new Vector2(0.384f, 0.4f), size: MyGuiConstants.BACK_BUTTON_SIZE, text: MyTexts.Get(MySpaceTexts.ScreenLoadSubscribedWorldBrowseWorkshop), toolTip: MyTexts.GetString(MySpaceTexts.ProgrammableBlock_Editor_BrowseWorkshop_Tooltip), onButtonClick: OpenWorkshopButtonClicked, originAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); Controls.Add(m_openWorkshopButton); m_okButton.Position = new Vector2(-0.016f, 0.4f); m_okButton.SetToolTip(MyTexts.GetString(MySpaceTexts.ProgrammableBlock_CodeEditor_SaveExit_Tooltip)); m_saveChanges = new MyGuiControlButton(position: new Vector2(0.184f, 0.4f), size: MyGuiConstants.BACK_BUTTON_SIZE, text: MyTexts.Get(MySpaceTexts.ProgrammableBlock_Editor_RememberCode), toolTip: MyTexts.GetString(MySpaceTexts.ProgrammableBlock_Editor_RememberCode_Tooltip), onButtonClick: SaveCodeButtonClicked, originAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); Controls.Add(m_saveChanges); m_checkCodeButton = new MyGuiControlButton(position: new Vector2(-0.216f, 0.4f), size: MyGuiConstants.BACK_BUTTON_SIZE, text: MyTexts.Get(MySpaceTexts.ProgrammableBlock_Editor_CheckCode), toolTip: MyTexts.GetString(MySpaceTexts.ProgrammableBlock_Editor_CheckCode_Tooltip), onButtonClick: CheckCodeButtonClicked, originAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); Controls.Add(m_checkCodeButton); m_help = new MyGuiControlButton(position: new Vector2(0.384f, -0.4f), size: MyGuiConstants.BACK_BUTTON_SIZE, text: MyTexts.Get(MySpaceTexts.ProgrammableBlock_Editor_Help), toolTip: MyTexts.GetString(MySpaceTexts.ProgrammableBlock_Editor_HelpTooltip), onButtonClick: HelpButtonClicked, originAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); Controls.Add(m_help); m_descriptionBox.Position = Vector2.Zero; m_descriptionBackgroundPanel.Size *= new Vector2(1.01f, 1.01f); m_descriptionBackgroundPanel.Position = new Vector2(-0.48f, -0.37f); m_titleLabel.Position = new Vector2(0.0f, -0.4f); m_lineCounter = new MyGuiControlLabel(new Vector2(-0.479f, 0.4f), null, string.Format(MyTexts.GetString(MySpaceTexts.ProgrammableBlock_Editor_LineNo), 1, m_editorWindow.GetTotalNumLines())); Elements.Add(m_lineCounter); m_LetterCounter = new MyGuiControlLabel(new Vector2(-0.479f, -0.4f)); Elements.Add(m_LetterCounter); m_TextTooLongMessage = new MyGuiControlLabel(new Vector2(-0.34f, -0.4f), font: MyFontEnum.Red); Elements.Add(m_TextTooLongMessage); EnableButtons(); FocusedControl = m_descriptionBox; }
//loads next mission, SP only //id can be workshop ID or save name (in that case official scenarios are searched first, if not found, then user's saves) public static void LoadNextScenario(string id) { if (MySession.Static.OnlineMode != MyOnlineModeEnum.OFFLINE) { return; } MyAPIGateway.Utilities.ShowNotification(MyTexts.GetString(MySpaceTexts.NotificationNextScenarioWillLoad), 10000); ulong workshopID; if (ulong.TryParse(id, out workshopID)) { //scenario from steam, without the user needing to subscribe it first: if (!MySteam.IsOnline) { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageText: MyTexts.Get(MySpaceTexts.MessageBoxTextWorkshopDownloadFailed), messageCaption: MyTexts.Get(MyCommonTexts.ScreenCaptionWorkshop))); } else { MySandboxGame.Log.WriteLine(string.Format("Querying details of file " + workshopID)); Action <bool, RemoteStorageGetPublishedFileDetailsResult> onGetDetailsCallResult = delegate(bool ioFailure, RemoteStorageGetPublishedFileDetailsResult data) { MySandboxGame.Log.WriteLine(string.Format("Obtained details: Id={4}; Result={0}; ugcHandle={1}; title='{2}'; tags='{3}'", data.Result, data.FileHandle, data.Title, data.Tags, data.PublishedFileId)); if (!ioFailure && data.Result == Result.OK && data.Tags.Length != 0) { m_newWorkshopMap.Title = data.Title; m_newWorkshopMap.PublishedFileId = data.PublishedFileId; m_newWorkshopMap.Description = data.Description; m_newWorkshopMap.UGCHandle = data.FileHandle; m_newWorkshopMap.SteamIDOwner = data.SteamIDOwner; m_newWorkshopMap.TimeUpdated = data.TimeUpdated; m_newWorkshopMap.Tags = data.Tags.Split(','); Static.EndAction += EndActionLoadWorkshop; } else { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageText: MyTexts.Get(MySpaceTexts.MessageBoxTextWorkshopDownloadFailed), messageCaption: MyTexts.Get(MyCommonTexts.ScreenCaptionWorkshop))); } }; MySteam.API.RemoteStorage.GetPublishedFileDetails(workshopID, 0, onGetDetailsCallResult); } } else { var contentDir = Path.Combine(MyFileSystem.ContentPath, "Missions", id); if (Directory.Exists(contentDir)) { m_newPath = contentDir; Static.EndAction += EndActionLoadLocal; return; } var saveDir = Path.Combine(MyFileSystem.SavesPath, id); if (Directory.Exists(saveDir)) { m_newPath = saveDir; Static.EndAction += EndActionLoadLocal; return; } //fail msg: StringBuilder error = new StringBuilder(); error.AppendFormat(MyTexts.GetString(MySpaceTexts.MessageBoxTextScenarioNotFound), contentDir, saveDir); MyGuiScreenMessageBox mb = MyGuiSandbox.CreateMessageBox(messageText: error, messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError)); MyGuiSandbox.AddScreen(mb); } }
public WarningLine(MySimpleProfiler.PerformanceWarning warning, MyGuiScreenPerformanceWarnings screen) { Parent = new MyGuiControlParent(); m_name = new MyGuiControlLabel(text: Truncate(warning.Block.DisplayName), position: new Vector2(-0.43f, 0), originAlign: VRage.Utils.MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, font: VRage.Game.MyFontEnum.Red); m_description = new MyGuiControlLabel ( text: String.IsNullOrEmpty(warning.Block.Description.String) ? MyTexts.GetString(MyCommonTexts.PerformanceWarningTooManyBlocks) : MyTexts.GetString(warning.Block.Description), position: new Vector2(-0.24f, 0), originAlign: VRage.Utils.MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER ); m_separator = new MyGuiControlSeparatorList(); Parent.Size = new Vector2(Parent.Size.X, m_description.Size.Y); m_separator.AddVertical(new Vector2(-0.25f, -Parent.Size.Y / 2 - 0.006f), Parent.Size.Y + 0.016f); m_separator.AddVertical(new Vector2(0.35f, -Parent.Size.Y / 2 - 0.006f), Parent.Size.Y + 0.016f); m_time = new MyGuiControlLabel(position: new Vector2(0.43f, 0), originAlign: VRage.Utils.MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER); switch (warning.Block.type) { case MySimpleProfiler.MySimpleProfilingBlock.ProfilingBlockType.GRAPHICS: screen.m_areaTitleGraphics.Warnings.Add(this); break; case MySimpleProfiler.MySimpleProfilingBlock.ProfilingBlockType.BLOCK: screen.m_areaTitleBlocks.Warnings.Add(this); break; case MySimpleProfiler.MySimpleProfilingBlock.ProfilingBlockType.OTHER: screen.m_areaTitleOther.Warnings.Add(this); break; } this.Warning = warning; }
public override void RecreateControls(bool constructor) { base.RecreateControls(constructor); Vector2 cbOffset = new Vector2(-0.05f, 0.0f); Vector2 controlPadding = new Vector2(0.02f, 0.02f); // X: Left & Right, Y: Bottom & Top float textScale = 0.8f; float separatorSize = 0.01f; float usableWidth = SCREEN_SIZE.X - HIDDEN_PART_RIGHT - controlPadding.X * 2; float hiddenPartTop = (SCREEN_SIZE.Y - 1.0f) / 2.0f - 0.02f; m_currentPosition = -m_size.Value / 2.0f; m_currentPosition += controlPadding; m_currentPosition.Y += hiddenPartTop; m_scale = textScale; float y; MyGuiControlButton btn; ///////////////////// SPACE MASTER ///////////////////// var caption = AddCaption(MySpaceTexts.ScreenDebugAdminMenu_Caption, m_labelColor, controlPadding + new Vector2(-HIDDEN_PART_RIGHT, hiddenPartTop)); m_currentPosition.Y += MyGuiConstants.SCREEN_CAPTION_DELTA_Y + separatorSize + controlPadding.Y; m_creativeCheckbox = AddCheckBox(MyCommonTexts.ScreenDebugAdminMenu_EnableAdminMode, false, OnEnableAdminModeChanged, true, null, m_labelColor, cbOffset); m_creativeCheckbox.SetToolTip(MyCommonTexts.ScreenDebugAdminMenu_EnableAdminMode_Tooltip); m_creativeCheckbox.IsChecked = MySession.Static.IsAdminModeEnabled; m_creativeCheckbox.Enabled = MySession.Static.IsAdmin; ///////////////////// CYCLING ///////////////////// AddSubcaption(MyCommonTexts.ScreenDebugAdminMenu_CycleObjects, m_labelColor, new Vector2(-HIDDEN_PART_RIGHT, -0.02f)); m_currentPosition.Y -= 0.04f; CreateSelectionCombo(); m_labelCurrentIndex = AddLabel(String.Empty, m_labelColor, 1); m_labelCurrentIndex.TextToDraw = new StringBuilder().AppendFormat(MyTexts.GetString(MyCommonTexts.ScreenDebugAdminMenu_CurrentValue), m_entityId == 0 ? "-" : m_metricValue.ToString()); y = m_currentPosition.Y; btn = CreateDebugButton(usableWidth / 3, MyCommonTexts.ScreenDebugAdminMenu_First, c => OnCycleClicked(true, true)); btn.PositionX = -usableWidth / 3 - controlPadding.X; m_currentPosition.Y = y; btn = CreateDebugButton(usableWidth / 3, MyCommonTexts.ScreenDebugAdminMenu_Next, c => OnCycleClicked(false, false)); btn.PositionX = -controlPadding.X + separatorSize / 2; m_currentPosition.Y = y; btn = CreateDebugButton(usableWidth / 3, MyCommonTexts.ScreenDebugAdminMenu_Previous, c => OnCycleClicked(false, true)); btn.PositionX = usableWidth / 3 - controlPadding.X + separatorSize; y = m_currentPosition.Y; m_removeItemButton = CreateDebugButton(usableWidth / 3, MyCommonTexts.ScreenDebugAdminMenu_Remove, c => OnEntityRemoveClicked(MyTrashRemovalOperation.Remove)); m_removeItemButton.PositionX = -usableWidth / 3 - controlPadding.X; m_currentPosition.Y = y; btn = CreateDebugButton(usableWidth / 3, MyCommonTexts.ScreenDebugAdminMenu_Stop, c => OnEntityRemoveClicked(MyTrashRemovalOperation.Stop)); btn.PositionX = -controlPadding.X + separatorSize / 2; m_currentPosition.Y = y; CreateDepowerButton(usableWidth, controlPadding.X, separatorSize); CreateDebugButton(usableWidth, MyCommonTexts.SpectatorControls_None, OnPlayerControl, true, MySpaceTexts.SpectatorControls_None_Desc); m_onlySmallGridsCheckbox = AddCheckBox(MyCommonTexts.ScreenDebugAdminMenu_SmallGrids, false, OnSmallGridChanged, true, null, m_labelColor, cbOffset); m_onlySmallGridsCheckbox.SetToolTip(MyCommonTexts.ScreenDebugAdminMenu_EnableAdminMode_Tooltip); m_onlyLargeGridsCheckbox = AddCheckBox(MyCommonTexts.ScreenDebugAdminMenu_LargeGrids, false, OnLargeGridChanged, true, null, m_labelColor, cbOffset); m_onlyLargeGridsCheckbox.IsChecked = m_cyclingOtions.OnlyLargeGrids; m_onlySmallGridsCheckbox.IsChecked = m_cyclingOtions.OnlySmallGrids; ///////////////////// TRASH ///////////////////// AddSubcaption(MyCommonTexts.ScreenDebugAdminMenu_TrashRemoval, m_labelColor, new Vector2(-HIDDEN_PART_RIGHT, -0.02f)); m_currentPosition.Y -= 0.04f; //AddLabel("Select which objects WON'T be removed", white, 1); CreateTrashCheckBoxes(ref cbOffset, ref m_labelColor); var blockCountLabelText = string.Format(MyTexts.GetString(MyCommonTexts.ScreenDebugAdminMenu_WithBlockCount), String.Empty); AddLabel(blockCountLabelText, m_labelColor, 1); var blockCount = AddTextbox(MyTrashRemoval.PreviewSettings.BlockCountThreshold.ToString(), OnBlockCountChanged, m_labelColor, 0.9f, MyGuiControlTextboxType.DigitsOnly); var distancePlayerText = string.Format(MyTexts.GetString(MyCommonTexts.ScreenDebugAdminMenu_DistanceFromPlayer), String.Empty); AddLabel(distancePlayerText, m_labelColor, 1); AddTextbox(MyTrashRemoval.PreviewSettings.PlayerDistanceThreshold.ToString(), OnDistanceChanged, m_labelColor, 0.9f, MyGuiControlTextboxType.DigitsOnly); m_labelNumVisible = AddLabel(MyCommonTexts.ScreenDebugAdminMenu_DistanceFromPlayer.ToString(), m_labelColor, 1); m_labelNumVisible.TextToDraw = new StringBuilder(); AddCheckBox(MyCommonTexts.ScreenDebugAdminMenu_ShowTrashAdminView, () => MyTrashRemoval.PreviewEnabled, v => MyTrashRemoval.PreviewEnabled = v, true, null, m_labelColor, cbOffset); y = m_currentPosition.Y; btn = CreateDebugButton(usableWidth / 3, MyCommonTexts.ScreenDebugAdminMenu_RemoveTrash, c => OnTrashRemoveClicked(MyTrashRemovalOperation.Remove)); btn.PositionX = -usableWidth / 3 - controlPadding.X; m_currentPosition.Y = y; btn = CreateDebugButton(usableWidth / 3, MyCommonTexts.ScreenDebugAdminMenu_StopTrash, c => OnTrashRemoveClicked(MyTrashRemovalOperation.Stop)); btn.PositionX = -controlPadding.X + separatorSize / 2; m_currentPosition.Y = y; CreateDepowerButtonTrash(usableWidth, controlPadding.X, separatorSize); // PREPARED FOR FLOATING REMOVAL //y = m_currentPosition.Y; //btn = CreateDebugButton(usableWidth / 3, MySpaceTexts.ScreenDebugAdminMenu_RemoveTrash, null); //btn.PositionX = -usableWidth / 3 - controlPadding.X; //m_currentPosition.Y = y; //btn = CreateDebugButton(usableWidth / 3, MySpaceTexts.ScreenDebugAdminMenu_StopTrash, null); //btn.PositionX = -controlPadding.X + separatorSize / 2; //m_currentPosition.Y = y; //btn = CreateDebugButton(usableWidth / 3, MySpaceTexts.ScreenDebugAdminMenu_DepowerTrash, null); //btn.PositionX = usableWidth / 3 - controlPadding.X + separatorSize; CreateCustomButtons(usableWidth, controlPadding.X, separatorSize); UpdateSmallLargeGridSelection(); UpdateCyclingAndDepower(); RecalcTrash(); bool isClient = Sync.IsServer == false; CreateDebugButton(usableWidth / 2, MyCommonTexts.ScreenDebugAdminMenu_ReplicateEverything, OnReplicateEverything, isClient, isClient ? MyCommonTexts.ScreenDebugAdminMenu_ReplicateEverything_Tooltip : MySpaceTexts.ScreenDebugAdminMenu_ReplicateEverythingServer_Tooltip); }
private MyGuiControlLabel MakeLabel(float deltaMultip, MyStringId textEnum) { return(new MyGuiControlLabel( position: m_controlsOriginLeft + deltaMultip * MyGuiConstants.CONTROLS_DELTA, text: MyTexts.GetString(textEnum))); }
private void FillSelectedTarget(ICollection <MyGuiControlListbox.Item> selectedTargetList, ICollection <MyGuiControlListbox.Item> emptyList) { if (m_jumpTarget != null) { selectedTargetList.Add(new MyGuiControlListbox.Item(text: new StringBuilder(m_jumpTarget.Name), toolTip: MyTexts.GetString(MySpaceTexts.BlockActionTooltip_SelectedJumpTarget), userData: m_jumpTarget)); } else { selectedTargetList.Add(new MyGuiControlListbox.Item(text: new StringBuilder("Blind Jump"), toolTip: MyTexts.GetString(MySpaceTexts.BlockActionTooltip_SelectedJumpTarget), userData: null)); } }
private void AddControlsByType(MyGuiControlTypeEnum type) { // "General" page is little bit too complex, so I need to create it separately. if (type == MyGuiControlTypeEnum.General) { AddGeneralControls(); return; } var buttonStyle = MyGuiControlButton.GetVisualStyle(MyGuiControlButtonStyleEnum.ControlSetting); Vector2 controlsOriginRight = m_controlsOriginRight; controlsOriginRight.X -= 0.02f; m_allControls[type] = new List <MyGuiControlBase>(); float i = 2; float buttonScale = 0.85f; var controls = MyInput.Static.GetGameControlsList(); var keyboardLabel = MakeLabel(MyCommonTexts.ScreenOptionsControls_Keyboard, Vector2.Zero); var keyboard2Label = MakeLabel(MyCommonTexts.ScreenOptionsControls_Keyboard2, Vector2.Zero); var mouseLabel = MakeLabel(MyCommonTexts.ScreenOptionsControls_Mouse, Vector2.Zero); var gamepadLabel = (MyFakes.ENABLE_JOYSTICK_SETTINGS) ? MakeLabel(MyCommonTexts.ScreenOptionsControls_Gamepad, Vector2.Zero) : null; var analogAxesLabel = (MyFakes.ENABLE_JOYSTICK_SETTINGS) ? MakeLabel(MyCommonTexts.ScreenOptionsControls_AnalogAxes, Vector2.Zero) : null; float columnWidth = 1.1f * Math.Max(Math.Max(keyboardLabel.Size.X, keyboard2Label.Size.X), Math.Max(mouseLabel.Size.X, buttonStyle.SizeOverride.Value.X)); var position = (i - 1) * MyGuiConstants.CONTROLS_DELTA + controlsOriginRight; position.X += columnWidth * 0.5f; // make labels centered keyboardLabel.Position = position; position.X += columnWidth; keyboard2Label.Position = position; position.X += columnWidth; mouseLabel.Position = position; m_allControls[type].Add(keyboardLabel); m_allControls[type].Add(keyboard2Label); m_allControls[type].Add(mouseLabel); if (MyFakes.ENABLE_JOYSTICK_SETTINGS) { //position.X += columnWidth; gamepadLabel.Position = position; //position.X += columnWidth; analogAxesLabel.Position = position; //m_allControls[type].Add(gamepadLabel); //m_allControls[type].Add(analogAxesLabel); } foreach (MyControl control in controls) { if (control.GetControlTypeEnum() == type) { m_allControls[type].Add(new MyGuiControlLabel( position: m_controlsOriginLeft + i * MyGuiConstants.CONTROLS_DELTA, text: MyTexts.GetString(control.GetControlName()))); position = controlsOriginRight + i * MyGuiConstants.CONTROLS_DELTA; position.X += columnWidth * 0.5f; // This is column for keyboard 1 var key1Button = MakeControlButton(control, position, MyGuiInputDeviceEnum.Keyboard); m_allControls[type].Add(key1Button); m_key1Buttons.Add(key1Button); position.X += columnWidth; // This is column for keyboard 2 var key2Button = MakeControlButton(control, position, MyGuiInputDeviceEnum.KeyboardSecond); m_allControls[type].Add(key2Button); m_key2Buttons.Add(key2Button); position.X += columnWidth; // This is column for mouse var mouseButton = MakeControlButton(control, position, MyGuiInputDeviceEnum.Mouse); m_allControls[type].Add(mouseButton); m_mouseButtons.Add(mouseButton); position.X += columnWidth; if (MyFakes.ENABLE_JOYSTICK_SETTINGS) { //// This is column for joystick //var joyButton = MakeControlButton(control, position, MyGuiInputDeviceEnum.Joystick); //m_allControls[type].Add(joyButton); //m_joystickButtons.Add(joyButton); //position.X += columnWidth; //// This is column for joystick axes //var joyAxis = MakeControlButton(control, position, MyGuiInputDeviceEnum.JoystickAxis); //m_allControls[type].Add(joyAxis); //m_joystickAxes.Add(joyAxis); //position.X += columnWidth; } i += buttonScale; } } }
protected MyGuiControlCheckbox AddCheckBox(MyStringId textEnum, bool checkedState, Action <MyGuiControlCheckbox> checkBoxChange, bool enabled = true, List <MyGuiControlBase> controlGroup = null, Vector4?color = null, Vector2?checkBoxOffset = null) { return(AddCheckBox(MyTexts.GetString(textEnum), checkedState, checkBoxChange, enabled, controlGroup, color, checkBoxOffset)); }
public override void RecreateControls(bool constructor) { base.RecreateControls(constructor); var caption = AddCaption(MyCommonTexts.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(MyCommonTexts.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)); }
protected MyGuiControlLabel AddSubcaption(MyStringId textEnum, Vector4?captionTextColor = null, Vector2?captionOffset = null, float captionScale = MyGuiConstants.DEFAULT_TEXT_SCALE) { return(AddSubcaption(MyTexts.GetString(textEnum), captionTextColor: captionTextColor, captionOffset: captionOffset, captionScale: captionScale)); }
public MyGuiScreenOptionsAudio() : base(new Vector2(0.5f, 0.5f), MyGuiConstants.SCREEN_BACKGROUND_COLOR, size: new Vector2(1030f, 650f) / MyGuiConstants.GUI_OPTIMAL_SIZE) { EnabledBackgroundFade = true; AddCaption(MyCommonTexts.ScreenCaptionAudioOptions); var topLeft = m_size.Value * -0.5f; var topCenter = m_size.Value * new Vector2(0f, -0.5f); var bottomCenter = m_size.Value * (MyPerGameSettings.VoiceChatEnabled ? new Vector2(0f, 0.7f) : new Vector2(0f, 0.6f)); float startHeight = MyPerGameSettings.VoiceChatEnabled? 150f : 170f; Vector2 controlsOriginLeft = topLeft + new Vector2(110f, startHeight) / MyGuiConstants.GUI_OPTIMAL_SIZE; Vector2 controlsOriginRight = topCenter + new Vector2(-25f, startHeight) / MyGuiConstants.GUI_OPTIMAL_SIZE; Vector2 controlsDelta = new Vector2(0f, 60f) / MyGuiConstants.GUI_OPTIMAL_SIZE; // Game Volume Controls.Add(new MyGuiControlLabel( position: controlsOriginLeft + 0 * controlsDelta, text: MyTexts.GetString(MyCommonTexts.GameVolume), originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); m_gameVolumeSlider = new MyGuiControlSlider( position: controlsOriginRight + 0 * controlsDelta, minValue: MyAudioConstants.GAME_MASTER_VOLUME_MIN, maxValue: MyAudioConstants.GAME_MASTER_VOLUME_MAX, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, defaultValue: MySandboxGame.Config.GameVolume); m_gameVolumeSlider.ValueChanged = OnGameVolumeChange; Controls.Add(m_gameVolumeSlider); // Music Volume Controls.Add(new MyGuiControlLabel( position: controlsOriginLeft + 1 * controlsDelta, text: MyTexts.GetString(MyCommonTexts.MusicVolume), originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); m_musicVolumeSlider = new MyGuiControlSlider( position: controlsOriginRight + 1 * controlsDelta, minValue: MyAudioConstants.MUSIC_MASTER_VOLUME_MIN, maxValue: MyAudioConstants.MUSIC_MASTER_VOLUME_MAX, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, defaultValue: MySandboxGame.Config.MusicVolume); m_musicVolumeSlider.ValueChanged = OnMusicVolumeChange; Controls.Add(m_musicVolumeSlider); Controls.Add(new MyGuiControlLabel( position: controlsOriginLeft + 2 * controlsDelta, text: MyTexts.GetString(MyCommonTexts.HudWarnings), originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); m_hudWarnings = new MyGuiControlCheckbox( position: controlsOriginRight + 2 * controlsDelta, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); m_hudWarnings.IsCheckedChanged = HudWarningsChecked; Controls.Add(m_hudWarnings); Controls.Add(new MyGuiControlLabel( position: controlsOriginLeft + 3 * controlsDelta, text: MyTexts.GetString(MyCommonTexts.MuteWhenNotInFocus), originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); m_enableMuteWhenNotInFocus = new MyGuiControlCheckbox( position: controlsOriginRight + 3 * controlsDelta, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); m_enableMuteWhenNotInFocus.IsCheckedChanged = EnableMuteWhenNotInFocusChecked; Controls.Add(m_enableMuteWhenNotInFocus); int perGameControls = 4; m_enableDynamicMusic = new MyGuiControlCheckbox( position: controlsOriginRight + perGameControls * controlsDelta, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); m_enableDynamicMusic.IsCheckedChanged = EnableDynamicMusicChecked; if (MyPerGameSettings.UseMusicController) { Controls.Add(new MyGuiControlLabel( position: controlsOriginLeft + perGameControls * controlsDelta, text: MyTexts.GetString(MyCommonTexts.AudioSettings_UseMusicController), originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); Controls.Add(m_enableDynamicMusic); perGameControls++; } m_shipSoundsAreBasedOnSpeed = new MyGuiControlCheckbox( position: controlsOriginRight + perGameControls * controlsDelta, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); m_shipSoundsAreBasedOnSpeed.IsCheckedChanged = ShipSoundsAreBasedOnSpeedChecked; if (MyPerGameSettings.EnableShipSoundSystem) { Controls.Add(new MyGuiControlLabel( position: controlsOriginLeft + perGameControls * controlsDelta, text: MyTexts.GetString(MyCommonTexts.AudioSettings_ShipSoundsBasedOnSpeed), originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); Controls.Add(m_shipSoundsAreBasedOnSpeed); perGameControls++; } m_enableReverb = new MyGuiControlCheckbox( position: controlsOriginRight + perGameControls * controlsDelta, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); m_enableReverb.IsCheckedChanged = EnableReverbChecked; if (MyPerGameSettings.UseReverbEffect) { Controls.Add(new MyGuiControlLabel( position: controlsOriginLeft + perGameControls * controlsDelta, text: MyTexts.GetString(MyCommonTexts.AudioSettings_EnableReverb), originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); Controls.Add(m_enableReverb); perGameControls++; } // Voice chat checkbox m_enableVoiceChat = new MyGuiControlCheckbox( position: controlsOriginRight + perGameControls * controlsDelta, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); m_enableVoiceChat.IsCheckedChanged = VoiceChatChecked; if (MyPerGameSettings.VoiceChatEnabled) { Controls.Add(new MyGuiControlLabel( position: controlsOriginLeft + perGameControls * controlsDelta, text: MyTexts.GetString(MyCommonTexts.EnableVoiceChat), originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); Controls.Add(m_enableVoiceChat); perGameControls++; } // voice chat volume m_voiceChatVolumeSlider = new MyGuiControlSlider( position: controlsOriginRight + perGameControls * controlsDelta, minValue: MyAudioConstants.VOICE_CHAT_VOLUME_MIN, maxValue: MyAudioConstants.VOICE_CHAT_VOLUME_MAX, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, defaultValue: MySandboxGame.Config.VoiceChatVolume); m_voiceChatVolumeSlider.ValueChanged = OnVoiceChatVolumeChange; if (MyPerGameSettings.VoiceChatEnabled) { // label for voice chat Controls.Add(new MyGuiControlLabel( position: controlsOriginLeft + perGameControls * controlsDelta, text: MyTexts.GetString(MyCommonTexts.VoiceChatVolume), originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); Controls.Add(m_voiceChatVolumeSlider); perGameControls++; } // Buttons OK and CANCEL var m_okButton = new MyGuiControlButton( position: bottomCenter + new Vector2(-75f, perGameControls < 6 ? -130f : -90f) / MyGuiConstants.GUI_OPTIMAL_SIZE, size: MyGuiConstants.OK_BUTTON_SIZE, text: MyTexts.Get(MyCommonTexts.Ok), onButtonClick: OnOkClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM); Controls.Add(m_okButton); var m_cancelButton = new MyGuiControlButton( position: bottomCenter + new Vector2(75f, perGameControls < 6 ? -130f : -90f) / MyGuiConstants.GUI_OPTIMAL_SIZE, size: MyGuiConstants.OK_BUTTON_SIZE, text: MyTexts.Get(MyCommonTexts.Cancel), onButtonClick: OnCancelClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM); Controls.Add(m_cancelButton); // Update controls with values from config file UpdateFromConfig(m_settingsOld); UpdateFromConfig(m_settingsNew); UpdateControls(m_settingsOld); CloseButtonEnabled = true; CloseButtonOffset = MakeXAndYEqual(new Vector2(-0.006f, 0.006f)); m_gameAudioPausedWhenOpen = MyAudio.Static.GameSoundIsPaused; if (m_gameAudioPausedWhenOpen) { MyAudio.Static.ResumeGameSounds(); } }
protected virtual void BuildControls() { Vector2 buttonSize = MyGuiConstants.BACK_BUTTON_SIZE; Vector2 buttonsOrigin = m_size.Value / 2 - new Vector2(0.23f, 0.03f); if (m_isNewGame) { AddCaption(MyCommonTexts.ScreenCaptionCustomWorld); } else { AddCaption(MyCommonTexts.ScreenCaptionEditSettings); } int numControls = 0; var nameLabel = MakeLabel(MyCommonTexts.Name); var descriptionLabel = MakeLabel(MyCommonTexts.Description); var gameModeLabel = MakeLabel(MyCommonTexts.WorldSettings_GameMode); var onlineModeLabel = MakeLabel(MyCommonTexts.WorldSettings_OnlineMode); m_maxPlayersLabel = MakeLabel(MyCommonTexts.MaxPlayers); var environmentLabel = MakeLabel(MySpaceTexts.WorldSettings_EnvironmentHostility); var scenarioLabel = MakeLabel(MySpaceTexts.WorldSettings_Scenario); float width = 0.284375f + 0.025f; m_nameTextbox = new MyGuiControlTextbox(maxLength: MySession.MAX_NAME_LENGTH); m_descriptionTextbox = new MyGuiControlTextbox(maxLength: MySession.MAX_DESCRIPTION_LENGTH); m_onlineMode = new MyGuiControlCombobox(size: new Vector2(width, 0.04f)); m_environment = new MyGuiControlCombobox(size: new Vector2(width, 0.04f)); m_maxPlayersSlider = new MyGuiControlSlider( position: Vector2.Zero, width: m_onlineMode.Size.X, minValue: 2, maxValue: 16, labelText: new StringBuilder("{0}").ToString(), labelDecimalPlaces: 0, labelSpaceWidth: 0.05f, intValue: true ); m_asteroidAmountLabel = MakeLabel(MySpaceTexts.Asteroid_Amount); m_asteroidAmountCombo = new MyGuiControlCombobox(size: new Vector2(width, 0.04f)); m_asteroidAmountCombo.ItemSelected += m_asteroidAmountCombo_ItemSelected; m_scenarioTypesList = new MyGuiControlList(); // Ok/Cancel m_okButton = new MyGuiControlButton(position: buttonsOrigin - new Vector2(0.01f, 0f), size: buttonSize, text: MyTexts.Get(MyCommonTexts.Ok), onButtonClick: OnOkButtonClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM); m_cancelButton = new MyGuiControlButton(position: buttonsOrigin + new Vector2(0.01f, 0f), size: buttonSize, text: MyTexts.Get(MyCommonTexts.Cancel), onButtonClick: OnCancelButtonClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM); m_creativeModeButton = new MyGuiControlButton(visualStyle: MyGuiControlButtonStyleEnum.Small, highlightType: MyGuiControlHighlightType.WHEN_ACTIVE, text: MyTexts.Get(MyCommonTexts.WorldSettings_GameModeCreative), onButtonClick: OnCreativeClick); m_creativeModeButton.SetToolTip(MySpaceTexts.ToolTipWorldSettingsModeCreative); m_survivalModeButton = new MyGuiControlButton(visualStyle: MyGuiControlButtonStyleEnum.Small, highlightType: MyGuiControlHighlightType.WHEN_ACTIVE, text: MyTexts.Get(MyCommonTexts.WorldSettings_GameModeSurvival), onButtonClick: OnSurvivalClick); m_survivalModeButton.SetToolTip(MySpaceTexts.ToolTipWorldSettingsModeSurvival); m_onlineMode.ItemSelected += OnOnlineModeSelect; m_onlineMode.AddItem((int)MyOnlineModeEnum.OFFLINE, MyCommonTexts.WorldSettings_OnlineModeOffline); m_onlineMode.AddItem((int)MyOnlineModeEnum.PRIVATE, MyCommonTexts.WorldSettings_OnlineModePrivate); m_onlineMode.AddItem((int)MyOnlineModeEnum.FRIENDS, MyCommonTexts.WorldSettings_OnlineModeFriends); m_onlineMode.AddItem((int)MyOnlineModeEnum.PUBLIC, MyCommonTexts.WorldSettings_OnlineModePublic); m_environment.AddItem((int)MyEnvironmentHostilityEnum.SAFE, MySpaceTexts.WorldSettings_EnvironmentHostilitySafe); m_environment.AddItem((int)MyEnvironmentHostilityEnum.NORMAL, MySpaceTexts.WorldSettings_EnvironmentHostilityNormal); m_environment.AddItem((int)MyEnvironmentHostilityEnum.CATACLYSM, MySpaceTexts.WorldSettings_EnvironmentHostilityCataclysm); m_environment.AddItem((int)MyEnvironmentHostilityEnum.CATACLYSM_UNREAL, MySpaceTexts.WorldSettings_EnvironmentHostilityCataclysmUnreal); m_environment.ItemSelected += HostilityChanged; if (m_isNewGame) { m_scenarioTypesGroup = new MyGuiControlRadioButtonGroup(); m_scenarioTypesGroup.SelectedChanged += scenario_SelectedChanged; foreach (var scenario in MyDefinitionManager.Static.GetScenarioDefinitions()) { if (!scenario.Public && !MyFakes.ENABLE_NON_PUBLIC_SCENARIOS) { continue; } var button = new MyGuiControlScenarioButton(scenario); m_scenarioTypesGroup.Add(button); m_scenarioTypesList.Controls.Add(button); } } m_nameTextbox.SetToolTip(string.Format(MyTexts.GetString(MyCommonTexts.ToolTipWorldSettingsName), MySession.MIN_NAME_LENGTH, MySession.MAX_NAME_LENGTH)); m_descriptionTextbox.SetToolTip(MyTexts.GetString(MyCommonTexts.ToolTipWorldSettingsDescription)); m_environment.SetToolTip(MyTexts.GetString(MySpaceTexts.ToolTipWorldSettingsEnvironment)); m_onlineMode.SetToolTip(MyTexts.GetString(MySpaceTexts.ToolTipWorldSettingsOnlineMode)); m_maxPlayersSlider.SetToolTip(MyTexts.GetString(MySpaceTexts.ToolTipWorldSettingsMaxPlayer)); m_asteroidAmountCombo.SetToolTip(MyTexts.GetString(MySpaceTexts.ToolTipWorldSettingsAsteroidAmount)); m_nameTextbox.TextChanged += m_nameTextbox_TextChanged; var advanced = new MyGuiControlButton(highlightType: MyGuiControlHighlightType.WHEN_ACTIVE, text: MyTexts.Get(MySpaceTexts.WorldSettings_Advanced), onButtonClick: OnAdvancedClick); var mods = new MyGuiControlButton(highlightType: MyGuiControlHighlightType.WHEN_ACTIVE, text: MyTexts.Get(MyCommonTexts.WorldSettings_Mods), onButtonClick: OnModsClick); m_worldGeneratorButton = new MyGuiControlButton(highlightType: MyGuiControlHighlightType.WHEN_ACTIVE, text: MyTexts.Get(MySpaceTexts.WorldSettings_WorldGenerator), onButtonClick: OnWorldGeneratorClick); // Add controls in pairs; label first, control second. They will be laid out automatically this way. Controls.Add(nameLabel); Controls.Add(m_nameTextbox); Controls.Add(descriptionLabel); Controls.Add(m_descriptionTextbox); Controls.Add(gameModeLabel); Controls.Add(m_creativeModeButton); Controls.Add(onlineModeLabel); Controls.Add(m_onlineMode); Controls.Add(m_maxPlayersLabel); Controls.Add(m_maxPlayersSlider); if (MyFakes.ENABLE_METEOR_SHOWERS) { Controls.Add(environmentLabel); Controls.Add(m_environment); } if (m_isNewGame && MyFakes.ENABLE_PLANETS == false) { Controls.Add(m_asteroidAmountLabel); Controls.Add(m_asteroidAmountCombo); } var autoSaveLabel = MakeLabel(MyCommonTexts.WorldSettings_AutoSave); m_autoSave = new MyGuiControlCheckbox(); m_autoSave.SetToolTip(new StringBuilder().AppendFormat(MyCommonTexts.ToolTipWorldSettingsAutoSave, MyObjectBuilder_SessionSettings.DEFAULT_AUTOSAVE_IN_MINUTES).ToString()); Controls.Add(autoSaveLabel); Controls.Add(m_autoSave); var scenarioEditModeLabel = MakeLabel(MySpaceTexts.WorldSettings_ScenarioEditMode); m_scenarioEditMode = new MyGuiControlCheckbox(); m_scenarioEditMode.SetToolTip(MyTexts.GetString(MySpaceTexts.ToolTipWorldSettings_ScenarioEditMode)); Controls.Add(scenarioEditModeLabel); Controls.Add(m_scenarioEditMode); if (MyFakes.ENABLE_WORKSHOP_MODS) { Controls.Add(mods); } Controls.Add(advanced); if (m_isNewGame && MyFakes.ENABLE_PLANETS == true) { Controls.Add(m_worldGeneratorButton); } float labelSize = 0.20f; float MARGIN_TOP = 0.12f; float MARGIN_BOTTOM = 0.12f; float MARGIN_LEFT = m_isNewGame ? 0.315f : 0.08f; float MARGIN_RIGHT = m_isNewGame ? 0.075f : 0.045f; // Automatic layout. Vector2 originL, originC; Vector2 controlsDelta = new Vector2(0f, 0.052f); float rightColumnOffset; originL = -m_size.Value / 2 + new Vector2(MARGIN_LEFT, MARGIN_TOP); originC = originL + new Vector2(labelSize, 0f); rightColumnOffset = originC.X + m_onlineMode.Size.X - labelSize - 0.017f; foreach (var control in Controls) { control.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER; if (control is MyGuiControlLabel) { control.Position = originL + controlsDelta * numControls; } else { control.Position = originC + controlsDelta * numControls++; } } Controls.Add(m_survivalModeButton); m_survivalModeButton.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER; m_survivalModeButton.Position = m_creativeModeButton.Position + new Vector2(m_onlineMode.Size.X, 0); if (m_isNewGame) { Vector2 scenarioPosition = new Vector2(-0.375f, nameLabel.Position.Y); m_nameTextbox.Size = m_onlineMode.Size; m_descriptionTextbox.Size = m_nameTextbox.Size; scenarioLabel.Position = scenarioPosition; m_scenarioTypesList.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; m_scenarioTypesList.Position = scenarioLabel.Position + new Vector2(0, 0.02f); m_scenarioTypesList.Size = new Vector2(0.19f, m_size.Value.Y - MARGIN_BOTTOM - MARGIN_TOP); Controls.Add(scenarioLabel); Controls.Add(m_scenarioTypesList); MyGuiControlSeparatorList m_verticalLine = new MyGuiControlSeparatorList(); Vector2 position = nameLabel.Position + new Vector2(-0.025f, -0.02f); m_verticalLine.AddVertical(position, m_size.Value.Y - MARGIN_BOTTOM - MARGIN_TOP + 0.04f); Controls.Add(m_verticalLine); } var pos2 = advanced.Position; //pos2.X = m_isNewGame ? 0.160f : 0.0f; pos2.X = Size.HasValue ? Size.Value.X / 2.0f - advanced.Size.X - MARGIN_RIGHT : 0.0f; advanced.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM; advanced.Position = pos2; mods.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM; mods.Position = advanced.Position - new Vector2(advanced.Size.X + 0.017f, 0); m_worldGeneratorButton.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM; m_worldGeneratorButton.Position = advanced.Position - new Vector2(advanced.Size.X + 0.017f, -0.06f); Controls.Add(m_okButton); Controls.Add(m_cancelButton); CloseButtonEnabled = true; }
void OnUserJoined(ref JoinResultMsg msg) { if (msg.JoinResult == JoinResult.OK) { if (OnJoin != null) { OnJoin(); OnJoin = null; m_clientJoined = true; } } else if (msg.JoinResult == JoinResult.NotInGroup) { MyGuiScreenMainMenu.UnloadAndExitToMenu(); Dispose(); ulong groupId = Server.GetGameTagByPrefixUlong("groupId"); string groupName = MySteam.API.Friends.GetClanName(groupId); var messageBox = MyGuiSandbox.CreateMessageBox( messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), messageText: new StringBuilder(string.Format( MyTexts.GetString(MyCommonTexts.MultiplayerErrorNotInGroup), groupName)), buttonType: MyMessageBoxButtonsType.YES_NO); messageBox.ResultCallback = delegate(MyGuiScreenMessageBox.ResultEnum result) { if (result == MyGuiScreenMessageBox.ResultEnum.YES) { MySteam.API.OpenOverlayUser(groupId); } ; }; MyGuiSandbox.AddScreen(messageBox); } else if (msg.JoinResult == JoinResult.BannedByAdmins) { MyGuiScreenMainMenu.UnloadAndExitToMenu(); Dispose(); ulong admin = msg.Admin; if (admin != 0) { var messageBox = MyGuiSandbox.CreateMessageBox( messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), messageText: MyTexts.Get(MyCommonTexts.MultiplayerErrorBannedByAdminsWithDialog), buttonType: MyMessageBoxButtonsType.YES_NO); messageBox.ResultCallback = delegate(MyGuiScreenMessageBox.ResultEnum result) { if (result == MyGuiScreenMessageBox.ResultEnum.YES) { MySteam.API.OpenOverlayUser(admin); } ; }; MyGuiSandbox.AddScreen(messageBox); } else { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), messageText: MyTexts.Get(MyCommonTexts.MultiplayerErrorBannedByAdmins))); } } else { MyStringId resultText = MyCommonTexts.MultiplayerErrorConnectionFailed; switch (msg.JoinResult) { case JoinResult.AlreadyJoined: resultText = MyCommonTexts.MultiplayerErrorAlreadyJoined; break; case JoinResult.ServerFull: resultText = MyCommonTexts.MultiplayerErrorServerFull; break; case JoinResult.SteamServersOffline: resultText = MyCommonTexts.MultiplayerErrorSteamServersOffline; break; case JoinResult.TicketInvalid: resultText = MyCommonTexts.MultiplayerErrorTicketInvalid; break; case JoinResult.GroupIdInvalid: resultText = MyCommonTexts.MultiplayerErrorGroupIdInvalid; break; case JoinResult.TicketCanceled: resultText = MyCommonTexts.MultiplayerErrorTicketCanceled; break; case JoinResult.TicketAlreadyUsed: resultText = MyCommonTexts.MultiplayerErrorTicketAlreadyUsed; break; case JoinResult.LoggedInElseWhere: resultText = MyCommonTexts.MultiplayerErrorLoggedInElseWhere; break; case JoinResult.NoLicenseOrExpired: resultText = MyCommonTexts.MultiplayerErrorNoLicenseOrExpired; break; case JoinResult.UserNotConnected: resultText = MyCommonTexts.MultiplayerErrorUserNotConnected; break; case JoinResult.VACBanned: resultText = MyCommonTexts.MultiplayerErrorVACBanned; break; case JoinResult.VACCheckTimedOut: resultText = MyCommonTexts.MultiplayerErrorVACCheckTimedOut; break; default: System.Diagnostics.Debug.Fail("Unknown JoinResult"); break; } Dispose(); MyGuiScreenMainMenu.UnloadAndExitToMenu(); MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), messageText: MyTexts.Get(resultText))); return; } }
void m_transferToCombobox_ItemSelected() { if (m_transferToCombobox.GetSelectedIndex() == -1) { return; } if (m_askForConfirmation) { long ownerKey = m_transferToCombobox.GetSelectedKey(); int ownerIndex = m_transferToCombobox.GetSelectedIndex(); var ownerName = m_transferToCombobox.GetItemByIndex(ownerIndex).Value; var messageBox = MyGuiSandbox.CreateMessageBox( buttonType : MyMessageBoxButtonsType.YES_NO, messageCaption : MyTexts.Get(MyCommonTexts.MessageBoxCaptionPleaseConfirm), messageText : new StringBuilder().AppendFormat(MyTexts.GetString(MyCommonTexts.MessageBoxTextChangeOwner), ownerName.ToString()), focusedResult : MyGuiScreenMessageBox.ResultEnum.NO, callback : delegate(MyGuiScreenMessageBox.ResultEnum retval) { if (retval == MyGuiScreenMessageBox.ResultEnum.YES) { if (m_currentBlocks.Length > 0) { m_requests.Clear(); foreach (var block in m_currentBlocks) { if (block.IDModule != null) { if (block.OwnerId == 0 || block.OwnerId == MySession.Static.LocalPlayerId) { m_requests.Add(new MyCubeGrid.MySingleOwnershipRequest() { BlockId = block.EntityId, Owner = ownerKey }); } } } if (m_requests.Count > 0) { if (MySession.Static.Settings.ScenarioEditMode && Sync.Players.IdentityIsNpc(ownerKey)) { MyCubeGrid.ChangeOwnersRequest(MyOwnershipShareModeEnum.Faction, m_requests, MySession.Static.LocalPlayerId); } else if (MySession.Static.LocalPlayerId == ownerKey) { // this should not be changed to No share, without approval from a designer, see ticket https://app.asana.com/0/64822442925263/64356719169418 MyCubeGrid.ChangeOwnersRequest(MyOwnershipShareModeEnum.Faction, m_requests, MySession.Static.LocalPlayerId); } else { MyCubeGrid.ChangeOwnersRequest(MyOwnershipShareModeEnum.None, m_requests, MySession.Static.LocalPlayerId); } } } RecreateOwnershipControls(); UpdateOwnerGui(); } else { m_askForConfirmation = false; m_transferToCombobox.SelectItemByIndex(-1); m_askForConfirmation = true; } }); messageBox.CanHideOthers = false; MyGuiSandbox.AddScreen(messageBox); } else { UpdateOwnerGui(); } }
private static void OnDownloadProgressChanged(MyGuiScreenProgress progress, MyDownloadWorldResult result, MyMultiplayerBase multiplayer) { switch (result.State) { case MyDownloadWorldStateEnum.Success: progress.CloseScreen(); var world = multiplayer.ProcessWorldDownloadResult(result); if (MyFakes.ENABLE_BATTLE_SYSTEM && multiplayer.Battle) { MyGuiScreenLoadSandbox.LoadMultiplayerBattleWorld(world, multiplayer); } else { MyGuiScreenLoadSandbox.LoadMultiplayerSession(world, multiplayer); } break; case MyDownloadWorldStateEnum.InProgress: if (result.ReceivedBlockCount == 1) { MyLog.Default.WriteLine("First world part received"); } string percent = (result.Progress * 100).ToString("0."); float size = result.ReceivedDatalength; string prefix = MyUtils.FormatByteSizePrefix(ref size); string worldSize = size.ToString("0.") + " " + prefix + "B"; if (progress.Text != null) { progress.Text.Clear(); } if (float.IsNaN(result.Progress)) { MyLog.Default.WriteLine("World requested - preemble received"); if (progress.Text != null) { progress.Text.Append(MyTexts.Get(MySpaceTexts.DialogWaitingForWorldData)); } } else { if (progress.Text != null) { progress.Text.AppendFormat(MyTexts.GetString(MySpaceTexts.DialogTextDownloadingWorld), percent, worldSize); } } break; case MyDownloadWorldStateEnum.WorldNotAvailable: MyLog.Default.WriteLine("World requested - world not available"); progress.Cancel(); MyGuiSandbox.Show(MySpaceTexts.DialogDownloadWorld_WorldDoesNotExists); multiplayer.Dispose(); break; case MyDownloadWorldStateEnum.ConnectionFailed: MyLog.Default.WriteLine("World requested - connection failed"); progress.Cancel(); MyGuiSandbox.Show(MyTexts.AppendFormat(new StringBuilder(), MySpaceTexts.MultiplayerErrorConnectionFailed, result.ConnectionError)); multiplayer.Dispose(); break; case MyDownloadWorldStateEnum.DeserializationFailed: case MyDownloadWorldStateEnum.InvalidMessage: MyLog.Default.WriteLine("World requested - message invalid (wrong version?)"); progress.Cancel(); MyGuiSandbox.Show(MySpaceTexts.DialogTextDownloadWorldFailed); multiplayer.Dispose(); break; default: throw new InvalidBranchException(); } }
void LocalizationWebButtonClicked(MyGuiControlButton obj) { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( buttonType : MyMessageBoxButtonsType.YES_NO, messageCaption : MyTexts.Get(MyCommonTexts.MessageBoxCaptionPleaseConfirm), messageText : new StringBuilder().AppendFormat(MyTexts.GetString(MyCommonTexts.MessageBoxTextOpenBrowser), MyPerGameSettings.GameWebUrl), callback : delegate(MyGuiScreenMessageBox.ResultEnum retval) { if (retval == MyGuiScreenMessageBox.ResultEnum.YES) { if (!MyBrowserHelper.OpenInternetBrowser(MyPerGameSettings.LocalizationWebUrl)) { StringBuilder sbMessage = new StringBuilder(); sbMessage.AppendFormat(MyTexts.GetString(MyCommonTexts.TitleFailedToStartInternetBrowser), MyPerGameSettings.LocalizationWebUrl); StringBuilder sbTitle = MyTexts.Get(MyCommonTexts.TitleFailedToStartInternetBrowser); MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageText: sbMessage, messageCaption: sbTitle)); } } })); }
void RecalcTrash() { int num = MyTrashRemoval.Calculate(MyTrashRemoval.PreviewSettings); m_labelNumVisible.TextToDraw.Clear().ConcatFormat(MyTexts.GetString(MyCommonTexts.ScreenDebugAdminMenu_NumberOfLocalTrash), num); }
public override void RecreateControls(bool constructor) { if (!constructor) { return; } base.RecreateControls(constructor); AddCaption("Display settings"); var tmp = new Vector2(0.268f, 0.145f) * MyGuiConstants.GUI_OPTIMAL_SIZE; var topLeft = m_size.Value * -0.5f; var topRight = m_size.Value * new Vector2(0.5f, -0.5f); Vector2 comboboxSize = new Vector2(600f, 0f) / MyGuiConstants.GUI_OPTIMAL_SIZE; Vector2 controlsOriginLeft = topLeft + new Vector2(75f, 125f) / MyGuiConstants.GUI_OPTIMAL_SIZE; Vector2 controlsOriginRight = topRight + new Vector2(-650f, 125f) / MyGuiConstants.GUI_OPTIMAL_SIZE; const float TEXT_SCALE = Sandbox.Graphics.GUI.MyGuiConstants.DEFAULT_TEXT_SCALE * 0.85f; var labelVideoAdapter = new MyGuiControlLabel(textScale: TEXT_SCALE, text: MyTexts.GetString(MySpaceTexts.VideoAdapter)); var labelResolution = new MyGuiControlLabel(textScale: TEXT_SCALE, text: MyTexts.GetString(MySpaceTexts.VideoMode)); var labelWindowMode = new MyGuiControlLabel(textScale: TEXT_SCALE, text: MyTexts.GetString(MySpaceTexts.ScreenOptionsVideo_WindowMode)); var labelVSync = new MyGuiControlLabel(textScale: TEXT_SCALE, text: MyTexts.GetString(MySpaceTexts.VerticalSync)); m_comboVideoAdapter = new MyGuiControlCombobox(size: comboboxSize, toolTip: MyTexts.GetString(MySpaceTexts.ToolTipVideoOptionsVideoAdapter)); m_comboResolution = new MyGuiControlCombobox(size: comboboxSize, toolTip: MyTexts.GetString(MySpaceTexts.ToolTipVideoOptionsVideoMode)); m_comboWindowMode = new MyGuiControlCombobox(size: comboboxSize); m_checkboxVSync = new MyGuiControlCheckbox(toolTip: MyTexts.GetString(MySpaceTexts.ToolTipVideoOptionsVerticalSync)); m_labelUnsupportedAspectRatio = new MyGuiControlLabel(colorMask: MyGuiConstants.LABEL_TEXT_COLOR * 0.9f, textScale: TEXT_SCALE * 0.85f); m_labelRecommendAspectRatio = new MyGuiControlLabel(colorMask: MyGuiConstants.LABEL_TEXT_COLOR * 0.9f, textScale: TEXT_SCALE * 0.85f); var hintLineOffset = new Vector2(0f, m_labelUnsupportedAspectRatio.Size.Y); var hintOffset = new Vector2(0.01f, -0.35f * MyGuiConstants.CONTROLS_DELTA.Y); labelVideoAdapter.Position = controlsOriginLeft; controlsOriginLeft += MyGuiConstants.CONTROLS_DELTA; m_comboVideoAdapter.Position = controlsOriginRight; controlsOriginRight += MyGuiConstants.CONTROLS_DELTA; labelResolution.Position = controlsOriginLeft; controlsOriginLeft += MyGuiConstants.CONTROLS_DELTA; m_comboResolution.Position = controlsOriginRight; controlsOriginRight += MyGuiConstants.CONTROLS_DELTA; m_labelUnsupportedAspectRatio.Position = controlsOriginRight + hintOffset; m_labelRecommendAspectRatio.Position = controlsOriginRight + hintOffset + hintLineOffset; controlsOriginLeft += MyGuiConstants.CONTROLS_DELTA; controlsOriginRight += MyGuiConstants.CONTROLS_DELTA; labelWindowMode.Position = controlsOriginLeft; controlsOriginLeft += MyGuiConstants.CONTROLS_DELTA; m_comboWindowMode.Position = controlsOriginRight; controlsOriginRight += MyGuiConstants.CONTROLS_DELTA; labelVSync.Position = controlsOriginLeft; controlsOriginLeft += MyGuiConstants.CONTROLS_DELTA; m_checkboxVSync.Position = controlsOriginRight; controlsOriginRight += MyGuiConstants.CONTROLS_DELTA; Controls.Add(labelVideoAdapter); Controls.Add(m_comboVideoAdapter); Controls.Add(labelResolution); Controls.Add(m_comboResolution); Controls.Add(m_labelUnsupportedAspectRatio); Controls.Add(m_labelRecommendAspectRatio); Controls.Add(labelWindowMode); Controls.Add(m_comboWindowMode); Controls.Add(labelVSync); Controls.Add(m_checkboxVSync); foreach (var control in Controls) { control.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER; } m_labelUnsupportedAspectRatio.Text = string.Format("* {0}", MyTexts.Get(MySpaceTexts.UnsupportedAspectRatio)); { // AddAdaptersToComboBox int counter = 0; foreach (var adapter in MyVideoSettingsManager.Adapters) { m_comboVideoAdapter.AddItem(counter++, new StringBuilder(adapter.Name)); } } // These options show up if there are no supported display modes m_comboWindowMode.AddItem((int)MyWindowModeEnum.Window, MySpaceTexts.ScreenOptionsVideo_WindowMode_Window); m_comboWindowMode.AddItem((int)MyWindowModeEnum.FullscreenWindow, MySpaceTexts.ScreenOptionsVideo_WindowMode_FullscreenWindow); m_comboVideoAdapter.ItemSelected += ComboVideoAdapter_ItemSelected; m_comboResolution.ItemSelected += ComboResolution_ItemSelected; // Buttons Ok and Cancel Controls.Add(new MyGuiControlButton( position: Size.Value * new Vector2(-0.5f, 0.5f) + new Vector2(100f, -75f) / MyGuiConstants.GUI_OPTIMAL_SIZE, size: MyGuiConstants.OK_BUTTON_SIZE, text: MyTexts.Get(MySpaceTexts.Ok), onButtonClick: OnOkClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM)); Controls.Add(new MyGuiControlButton( position: Size.Value * new Vector2(0.5f, 0.5f) + new Vector2(-100f, -75f) / MyGuiConstants.GUI_OPTIMAL_SIZE, size: MyGuiConstants.OK_BUTTON_SIZE, text: MyTexts.Get(MySpaceTexts.Cancel), onButtonClick: OnCancelClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM)); // Update controls with values from config file m_settingsOld = MyVideoSettingsManager.CurrentDeviceSettings; m_settingsNew = m_settingsOld; WriteSettingsToControls(m_settingsOld); // Update OLD settings ReadSettingsFromControls(ref m_settingsOld); ReadSettingsFromControls(ref m_settingsNew); CloseButtonEnabled = true; CloseButtonOffset = new Vector2(-50f, 50f) / MyGuiConstants.GUI_OPTIMAL_SIZE; }
public override void RecreateControls(bool constructor) { float width = 0.284375f + 0.025f; base.RecreateControls(constructor); AddCaption(MySpaceTexts.ScreenCaptionWorldGeneratorSettings); m_asteroidAmountCombo = new MyGuiControlCombobox(size: new Vector2(width, 0.04f)); m_asteroidAmountCombo.ItemSelected += m_asteroidAmountCombo_ItemSelected; m_asteroidAmountCombo.SetToolTip(MyTexts.GetString(MySpaceTexts.ToolTipWorldSettingsAsteroidAmount)); m_asteroidAmountCombo.AddItem((int)AsteroidAmountEnum.Normal, MySpaceTexts.WorldSettings_AsteroidAmountNormal); m_asteroidAmountCombo.AddItem((int)AsteroidAmountEnum.More, MySpaceTexts.WorldSettings_AsteroidAmountLarge); if (Environment.Is64BitProcess) { m_asteroidAmountCombo.AddItem((int)AsteroidAmountEnum.Many, MySpaceTexts.WorldSettings_AsteroidAmountExtreme); } if (MyFakes.ENABLE_ASTEROID_FIELDS) { m_asteroidAmountCombo.AddItem((int)AsteroidAmountEnum.ProceduralLow, MySpaceTexts.WorldSettings_AsteroidAmountProceduralLow); m_asteroidAmountCombo.AddItem((int)AsteroidAmountEnum.ProceduralNormal, MySpaceTexts.WorldSettings_AsteroidAmountProceduralNormal); if (Environment.Is64BitProcess) { m_asteroidAmountCombo.AddItem((int)AsteroidAmountEnum.ProceduralHigh, MySpaceTexts.WorldSettings_AsteroidAmountProceduralHigh); } } m_asteroidAmountLabel = MakeLabel(MySpaceTexts.Asteroid_Amount); Controls.Add(m_asteroidAmountLabel); Controls.Add(m_asteroidAmountCombo); m_floraDensityLabel = MakeLabel(MySpaceTexts.WorldSettings_FloraDensity); m_floraDensityCombo = new MyGuiControlCombobox(size: new Vector2(width, 0.04f)); m_floraDensityCombo.AddItem((int)MyFloraDensityEnum.NONE, MySpaceTexts.WorldSettings_FloraDensity_None); m_floraDensityCombo.AddItem((int)MyFloraDensityEnum.LOW, MySpaceTexts.WorldSettings_FloraDensity_Low); m_floraDensityCombo.AddItem((int)MyFloraDensityEnum.MEDIUM, MySpaceTexts.WorldSettings_FloraDensity_Medium); m_floraDensityCombo.AddItem((int)MyFloraDensityEnum.HIGH, MySpaceTexts.WorldSettings_FloraDensity_High); m_floraDensityCombo.AddItem((int)MyFloraDensityEnum.EXTREME, MySpaceTexts.WorldSettings_FloraDensity_Extreme); m_floraDensityCombo.SetToolTip(MyTexts.GetString(MySpaceTexts.ToolTipWorldSettings_FloraDensity)); Controls.Add(m_floraDensityLabel); Controls.Add(m_floraDensityCombo); int numControls = 0; float MARGIN_TOP = 0.12f; float MARGIN_LEFT = 0.055f; float labelSize = 0.25f; Vector2 originL, originC; Vector2 controlsDelta = new Vector2(0f, 0.052f); float rightColumnOffset; originL = -m_size.Value / 2 + new Vector2(MARGIN_LEFT, MARGIN_TOP); originC = originL + new Vector2(labelSize, 0f); rightColumnOffset = originC.X + width - labelSize - 0.017f; foreach (var control in Controls) { control.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER; if (control is MyGuiControlLabel) { control.Position = originL + controlsDelta * numControls; } else { control.Position = originC + controlsDelta * numControls++; } } Vector2 buttonsOrigin = m_size.Value / 2 - new Vector2(0.23f, 0.03f); m_okButton = new MyGuiControlButton(position: buttonsOrigin - new Vector2(0.01f, 0f), size: MyGuiConstants.BACK_BUTTON_SIZE, text: MyTexts.Get(MyCommonTexts.Ok), onButtonClick: OkButtonClicked, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM); m_cancelButton = new MyGuiControlButton(position: buttonsOrigin + new Vector2(0.01f, 0f), size: MyGuiConstants.BACK_BUTTON_SIZE, text: MyTexts.Get(MyCommonTexts.Cancel), onButtonClick: CancelButtonClicked, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM); Controls.Add(m_okButton); Controls.Add(m_cancelButton); }