/// <summary> /// Add this area into a list /// </summary> public void Add(MyGuiControlList list, bool showAll) { m_header.Position = Vector2.Zero; if (m_header.Controls.Count == 0) { m_header.Controls.Add(m_titleBackground); m_header.Controls.Add(m_title); m_header.Controls.Add(m_lastOccurence); m_header.Controls.Add(m_separator); } bool headerAdded = false; Warnings.Sort(delegate(WarningLine x, WarningLine y) { return(x.Warning.Time - y.Warning.Time); }); foreach (var warning in Warnings) { if (warning.Warning.Time < 120 || showAll) { if (!headerAdded) { list.Controls.Add(m_header); headerAdded = true; } warning.Prepare(); list.Controls.Add(warning.Parent); } } if (headerAdded && m_graphicsButton != null) { list.Controls.Add(m_graphicsButton); } }
private void InitCampaignList() { Vector2 originL = -m_size.Value / 2 + new Vector2(0.07f, MARGIN_TOP); m_campaignTypesGroup = new MyGuiControlRadioButtonGroup(); m_campaignTypesGroup.SelectedChanged += CampaignSelectionChanged; m_campaignList = new MyGuiControlList { OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, Position = originL, Size = new Vector2(0.19f, m_size.Value.Y - 0.03f - MARGIN_TOP), }; var separator = new MyGuiControlSeparatorList() { Size = new Vector2(0.03f, m_campaignList.Size.Y), OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, Position = m_campaignList.Position + new Vector2(m_campaignList.Size.X + 0.015f, 0f) }; separator.AddVertical(new Vector2(0f, -m_campaignList.Size.Y / 2), separator.Size.Y); Controls.Add(separator); Controls.Add(m_campaignList); }
private static List <MyInventory> Inventories(MyGuiControlList inventoriesControl) { var dstControlEnumerator = inventoriesControl.Controls.GetEnumerator(); List <MyInventory> availableInventories = new List <MyInventory>(); MyGuiControlInventoryOwner dstControl = null; while (dstControlEnumerator.MoveNext()) { if (dstControlEnumerator.Current.Visible) { dstControl = dstControlEnumerator.Current as MyGuiControlInventoryOwner; if (dstControl == null || !dstControl.Enabled) { continue; } var dstOwner = dstControl.InventoryOwner; for (int i = 0; i < dstOwner.InventoryCount; ++i) { var tmp = dstOwner.GetInventory(i); if (tmp != null) { availableInventories.Add(tmp); } } } } return(availableInventories); }
private void CreatePlanetControls(MyGuiControlList list, float usableWidth) { var asteroidSizeLabel = CreateSliderWithDescription(list, usableWidth, 8000f, 120000f, MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_ProceduralSize), ref m_procAsteroidSize); m_procAsteroidSize.ValueChanged += (MyGuiControlSlider s) => { asteroidSizeLabel.Text = MyValueFormatter.GetFormatedFloat(s.Value, 0) + "m"; m_procAsteroidSizeValue = s.Value; }; m_procAsteroidSize.Value = 8000.1f; m_procAsteroidSeed = CreateSeedButton(list, m_procAsteroidSeedValue, usableWidth); }
private static void AddSeparator(MyGuiControlList list) { var separator = new MyGuiControlSeparatorList(); separator.Size = new Vector2(1, 0.01f); separator.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP; separator.AddHorizontal(Vector2.Zero, 1); list.Controls.Add(separator); }
private MyGuiControlLabel CreateSliderWithDescription(MyGuiControlList list, float usableWidth, float min, float max, string description, ref MyGuiControlSlider slider) { var label = AddLabel(description, Vector4.One, m_scale); Controls.Remove(label); list.Controls.Add(label); CreateSlider(list, usableWidth, min, max, ref slider); var labelNoise = AddLabel("", Vector4.One, m_scale); Controls.Remove(labelNoise); list.Controls.Add(labelNoise); return(labelNoise); }
private void CreateSlider(MyGuiControlList list, float usableWidth, float min, float max, ref MyGuiControlSlider slider) { slider = new MyGuiControlSlider( position: m_currentPosition, width: 400f / MyGuiConstants.GUI_OPTIMAL_SIZE.X, minValue: min, maxValue: max, labelText: String.Empty, labelDecimalPlaces: 4, labelScale: 0.75f * m_scale, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, labelFont: MyFontEnum.Debug); slider.DebugScale = m_sliderDebugScale; slider.ColorMask = Color.White.ToVector4(); list.Controls.Add(slider); }
public override void RecreateControls(bool constructor) { base.RecreateControls(constructor); AddCaption(MyTexts.GetString(MyCommonTexts.PerformanceWarningHelpHeader)); m_warningsList = new MyGuiControlList(position: new Vector2(0f, -0.05f), size: new Vector2(0.92f, 0.7f)); var m_showWarningsLabel = new MyGuiControlLabel( text: MyTexts.GetString(MyCommonTexts.ScreenOptionsGame_EnablePerformanceWarnings), position: new Vector2(-0.17f, 0.35f), originAlign: VRage.Utils.MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER ); m_showWarningsCheckBox = new MyGuiControlCheckbox( toolTip: MyTexts.GetString(MyCommonTexts.ToolTipGameOptionsEnablePerformanceWarnings), position: new Vector2(-0.15f, 0.35f), originAlign: VRage.Utils.MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER ); m_showWarningsCheckBox.IsChecked = MySandboxGame.Config.EnablePerformanceWarnings; m_showWarningsCheckBox.IsCheckedChanged += ShowWarningsChanged; var m_showAllLabel = new MyGuiControlLabel( text: MyTexts.GetString(MyCommonTexts.PerformanceWarningShowAll), position: new Vector2(0.25f, 0.35f), originAlign: VRage.Utils.MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER ); m_showAllCheckBox = new MyGuiControlCheckbox( toolTip: MyTexts.GetString(MyCommonTexts.ToolTipPerformanceWarningShowAll), position: new Vector2(0.27f, 0.35f), originAlign: VRage.Utils.MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER ); m_showAllCheckBox.IsChecked = m_showAll; m_showAllCheckBox.IsCheckedChanged += KeepInListChanged; m_okButton = new MyGuiControlButton(position: new Vector2(0, 0.42f), text: MyTexts.Get(MyCommonTexts.Ok)); m_okButton.ButtonClicked += m_okButton_ButtonClicked; Controls.Add(m_warningsList); Controls.Add(m_showWarningsLabel); Controls.Add(m_showWarningsCheckBox); Controls.Add(m_showAllLabel); Controls.Add(m_showAllCheckBox); Controls.Add(m_okButton); }
private MyGuiControlTextbox CreateSeedButton(MyGuiControlList list, string seedValue, float usableWidth) { var label = AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_ProceduralSeed), Color.White.ToVector4(), m_scale); Controls.Remove(label); list.Controls.Add(label); var textBox = new MyGuiControlTextbox(m_currentPosition, seedValue, 20, Color.White.ToVector4(), m_scale, MyGuiControlTextboxType.Normal); textBox.TextChanged += (MyGuiControlTextbox t) => { seedValue = t.Text; }; textBox.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; list.Controls.Add(textBox); var button = CreateDebugButton(usableWidth, MySpaceTexts.ScreenDebugSpawnMenu_GenerateSeed, (MyGuiControlButton buttonClicked) => { textBox.Text = MyRandom.Instance.Next().ToString(); }); Controls.Remove(button); list.Controls.Add(button); return(textBox); }
private void CreatePlanetMenu() { m_currentVoxel = null; MyGuiControlList list = new MyGuiControlList(size: new Vector2(SCREEN_SIZE.X, 1.0f)); Vector2 controlPadding = new Vector2(0.02f, 0.02f); // X: Left & Right, Y: Bottom & Top float textScale = 0.8f; float usableWidth = SCREEN_SIZE.X - HIDDEN_PART_RIGHT - controlPadding.X * 2; m_currentPosition = Vector2.Zero;/* -m_size.Value / 2.0f; * m_currentPosition += controlPadding;*/ m_scale = textScale; var label = AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_SelectAsteroidType), Vector4.One, m_scale); Controls.Remove(label); list.Controls.Add(label); var combo = AddCombo(); combo.AddItem(1, MySpaceTexts.ScreenDebugSpawnMenu_PredefinedAsteroids); combo.AddItem(2, MySpaceTexts.ScreenDebugSpawnMenu_ProceduralAsteroids); combo.AddItem(3, MySpaceTexts.ScreenDebugSpawnMenu_Planets); combo.SelectItemByKey(m_asteroid_showPlanet ? 3 : m_asteroid_showPredefinedOrProcedural ? 1 : 2); combo.ItemSelected += () => { m_asteroid_showPredefinedOrProcedural = combo.GetSelectedKey() == 1; m_asteroid_showPlanet = combo.GetSelectedKey() == 3; RecreateControls(false); }; Controls.Remove(combo); list.Controls.Add(combo); CreatePlanetControls(list, usableWidth); AddSeparator(list); var button = CreateDebugButton(usableWidth, MySpaceTexts.ScreenDebugSpawnMenu_SpawnAsteroid, OnSpawnProceduralAsteroid); Controls.Remove(button); list.Controls.Add(button); Controls.Add(list); }
public override void RecreateControls(bool contructor) { base.RecreateControls(contructor); ProfilerShort.Begin("MyGuiScreenCubeBuilder.RecreateControls"); m_gridBlocks.MouseOverIndexChanged += OnGridMouseOverIndexChanged; m_gridBlocks.ItemSelected += OnSelectedItemChanged; m_blockInfoStyle = new MyGuiControlBlockInfo.MyControlBlockInfoStyle() { BlockNameLabelFont = MyFontEnum.White, EnableBlockTypeLabel = false, ComponentsLabelText = MySpaceTexts.HudBlockInfo_Components, ComponentsLabelFont = MyFontEnum.Blue, InstalledRequiredLabelText = MySpaceTexts.HudBlockInfo_Installed_Required, InstalledRequiredLabelFont = MyFontEnum.Blue, RequiredLabelText = MyCommonTexts.HudBlockInfo_Required, IntegrityLabelFont = MyFontEnum.White, IntegrityBackgroundColor = new Vector4(78 / 255.0f, 116 / 255.0f, 137 / 255.0f, 1.0f), IntegrityForegroundColor = new Vector4(0.5f, 0.1f, 0.1f, 1), IntegrityForegroundColorOverCritical = new Vector4(118 / 255.0f, 166 / 255.0f, 192 / 255.0f, 1.0f), LeftColumnBackgroundColor = new Vector4(46 / 255.0f, 76 / 255.0f, 94 / 255.0f, 1.0f), TitleBackgroundColor = new Vector4(72 / 255.0f, 109 / 255.0f, 130 / 255.0f, 1.0f), ComponentLineMissingFont = MyFontEnum.Red, ComponentLineAllMountedFont = MyFontEnum.White, ComponentLineAllInstalledFont = MyFontEnum.Blue, ComponentLineDefaultFont = MyFontEnum.White, ComponentLineDefaultColor = new Vector4(0.6f, 0.6f, 0.6f, 1f), ShowAvailableComponents = false, EnableBlockTypePanel = false, }; m_blockInfoList = (MyGuiControlList)Controls.GetControlByName("BlockInfoPanel"); if (m_blockInfoList == null) { Debug.Fail("Someone changed CubeBuilder.gsc file in Content folder? Please check"); } ProfilerShort.End(); }
public override void RecreateControls(bool contructor) { base.RecreateControls(contructor); ProfilerShort.Begin("MyGuiScreenCubeBuilder.RecreateControls"); m_gridBlocks.MouseOverIndexChanged += OnGridMouseOverIndexChanged; m_gridBlocks.ItemSelected += OnSelectedItemChanged; m_blockInfoStyle = new MyGuiControlBlockInfo.MyControlBlockInfoStyle() { BlockNameLabelFont = MyFontEnum.White, EnableBlockTypeLabel = false, ComponentsLabelText = MySpaceTexts.HudBlockInfo_Components, ComponentsLabelFont = MyFontEnum.Blue, InstalledRequiredLabelText = MySpaceTexts.HudBlockInfo_Installed_Required, InstalledRequiredLabelFont = MyFontEnum.Blue, RequiredLabelText = MyCommonTexts.HudBlockInfo_Required, IntegrityLabelFont = MyFontEnum.White, IntegrityBackgroundColor = new Vector4(78 / 255.0f, 116 / 255.0f, 137 / 255.0f, 1.0f), IntegrityForegroundColor = new Vector4(0.5f, 0.1f, 0.1f, 1), IntegrityForegroundColorOverCritical = new Vector4(118 / 255.0f, 166 / 255.0f, 192 / 255.0f, 1.0f), LeftColumnBackgroundColor = new Vector4(46 / 255.0f, 76 / 255.0f, 94 / 255.0f, 1.0f), TitleBackgroundColor = new Vector4(72 / 255.0f, 109 / 255.0f, 130 / 255.0f, 1.0f), ComponentLineMissingFont = MyFontEnum.Red, ComponentLineAllMountedFont = MyFontEnum.White, ComponentLineAllInstalledFont = MyFontEnum.Blue, ComponentLineDefaultFont = MyFontEnum.White, ComponentLineDefaultColor = new Vector4(0.6f, 0.6f, 0.6f, 1f), ShowAvailableComponents = false, EnableBlockTypePanel = false, }; m_rbGridSizeSmall = (MyGuiControlRadioButton)Controls.GetControlByName("GridSizeSmall"); if (m_rbGridSizeSmall == null) { Debug.Fail("Someone changed CubeBuilder.gsc file in Content folder? Please check"); } m_rbGridSizeSmall.HighlightType = MyGuiControlHighlightType.NEVER; m_rbGridSizeSmall.SelectedChanged += OnGridSizeSmallSelected; m_rbGridSizeLarge = (MyGuiControlRadioButton)Controls.GetControlByName("GridSizeLarge"); if (m_rbGridSizeLarge == null) { Debug.Fail("Someone changed CubeBuilder.gsc file in Content folder? Please check"); } m_rbGridSizeLarge.HighlightType = MyGuiControlHighlightType.NEVER; m_rbGridSizeLarge.SelectedChanged += OnGridSizeLargeSelected; m_rbGroupGridSize = new MyGuiControlRadioButtonGroup { m_rbGridSizeSmall, m_rbGridSizeLarge }; if (MyCubeBuilder.Static != null) { m_rbGroupGridSize.SelectedIndex = MyCubeBuilder.Static.CubeBuilderState.CubeSizeMode == MyCubeSize.Small ? 0 : 1; } MyGuiControlLabel gridSizeLabel = (MyGuiControlLabel)Controls.GetControlByName("GridSizeHintLabel"); gridSizeLabel.Text = string.Format(MyTexts.GetString(gridSizeLabel.TextEnum), MyGuiSandbox.GetKeyName(MyControlsSpace.CUBE_BUILDER_CUBESIZE_MODE)); m_blockInfoList = (MyGuiControlList)Controls.GetControlByName("BlockInfoPanel"); if (m_blockInfoList == null) { Debug.Fail("Someone changed CubeBuilder.gsc file in Content folder? Please check"); } //m_blockInfoSmall = new MyGuiControlBlockInfo(style, false, false); //m_blockInfoSmall.Visible = false; //m_blockInfoSmall.IsActiveControl = false; //m_blockInfoSmall.BlockInfo = new MyHudBlockInfo(); //m_blockInfoSmall.Position = new Vector2(0.28f, -0.04f); //m_blockInfoSmall.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; //Controls.Add(m_blockInfoSmall); //m_blockInfoLarge = new MyGuiControlBlockInfo(style, false, true); //m_blockInfoLarge.Visible = false; //m_blockInfoLarge.IsActiveControl = false; //m_blockInfoLarge.BlockInfo = new MyHudBlockInfo(); //m_blockInfoLarge.Position = new Vector2(0.28f, -0.06f); //m_blockInfoLarge.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM; //Controls.Add(m_blockInfoLarge); ProfilerShort.End(); }
protected override void BuildControls() { base.BuildControls(); Vector2 buttonSize = MyGuiConstants.BACK_BUTTON_SIZE; Vector2 buttonsOrigin = m_size.Value / 2 - new Vector2(0.65f, 0.1f); var difficultyLabel = MakeLabel(MySpaceTexts.Difficulty); var onlineModeLabel = MakeLabel(MySpaceTexts.WorldSettings_OnlineMode); m_maxPlayersLabel = MakeLabel(MySpaceTexts.MaxPlayers); float width = 0.284375f + 0.025f; m_difficultyCombo = new MyGuiControlCombobox(size: new Vector2(width, 0.04f)); m_difficultyCombo.Enabled = false; m_difficultyCombo.AddItem((int)0, MySpaceTexts.DifficultyEasy); m_difficultyCombo.AddItem((int)1, MySpaceTexts.DifficultyNormal); m_difficultyCombo.AddItem((int)2, MySpaceTexts.DifficultyHard); m_onlineMode = new MyGuiControlCombobox(size: new Vector2(width, 0.04f)); m_onlineMode.Enabled = false; m_onlineMode.ItemSelected += OnOnlineModeSelect; m_onlineMode.AddItem((int)MyOnlineModeEnum.OFFLINE, MySpaceTexts.WorldSettings_OnlineModeOffline); m_onlineMode.AddItem((int)MyOnlineModeEnum.PRIVATE, MySpaceTexts.WorldSettings_OnlineModePrivate); m_onlineMode.AddItem((int)MyOnlineModeEnum.FRIENDS, MySpaceTexts.WorldSettings_OnlineModeFriends); m_onlineMode.AddItem((int)MyOnlineModeEnum.PUBLIC, MySpaceTexts.WorldSettings_OnlineModePublic); 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_scenarioTypesList = new MyGuiControlList(); //BUTTONS m_removeButton = new MyGuiControlButton(text: MyTexts.Get(MySpaceTexts.buttonRemove), onButtonClick: OnOkButtonClick); m_publishButton = new MyGuiControlButton(text: MyTexts.Get(MySpaceTexts.buttonPublish), onButtonClick: OnPublishButtonClick); m_editButton = new MyGuiControlButton(text: MyTexts.Get(MySpaceTexts.buttonEdit), onButtonClick: OnEditButtonClick); m_browseWorkshopButton = new MyGuiControlButton(text: MyTexts.Get(MySpaceTexts.buttonBrowseWorkshop), onButtonClick: OnBrowseWorkshopClick); m_refreshButton = new MyGuiControlButton(text: MyTexts.Get(MySpaceTexts.buttonRefresh), onButtonClick: OnRefreshButtonClick); m_openInWorkshopButton = new MyGuiControlButton(text: MyTexts.Get(MySpaceTexts.buttonOpenInWorkshop), onButtonClick: OnOkButtonClick); m_removeButton.Enabled = false; m_publishButton.Enabled = false; m_editButton.Enabled = false; m_openInWorkshopButton.Enabled = false; CloseButtonEnabled = true; //m_nameTextbox.TextChanged += m_nameTextbox_TextChanged; m_sideMenuLayout.Add(difficultyLabel, MyAlignH.Left, MyAlignV.Top, 2, 0); m_sideMenuLayout.Add(m_difficultyCombo, MyAlignH.Left, MyAlignV.Top, 2, 1); m_sideMenuLayout.Add(onlineModeLabel, MyAlignH.Left, MyAlignV.Top, 3, 0); m_sideMenuLayout.Add(m_onlineMode, MyAlignH.Left, MyAlignV.Top, 3, 1); m_sideMenuLayout.Add(m_maxPlayersLabel, MyAlignH.Left, MyAlignV.Top, 4, 0); m_sideMenuLayout.Add(m_maxPlayersSlider, MyAlignH.Left, MyAlignV.Top, 4, 1); m_buttonsLayout.Add(m_removeButton, MyAlignH.Left, MyAlignV.Top, 0, 0); m_buttonsLayout.Add(m_publishButton, MyAlignH.Left, MyAlignV.Top, 0, 1); m_buttonsLayout.Add(m_editButton, MyAlignH.Left, MyAlignV.Top, 0, 2); m_buttonsLayout.Add(m_browseWorkshopButton, MyAlignH.Left, MyAlignV.Top, 0, 3); m_buttonsLayout.Add(m_refreshButton, MyAlignH.Left, MyAlignV.Top, 1, 0); m_buttonsLayout.Add(m_openInWorkshopButton, MyAlignH.Left, MyAlignV.Top, 1, 1); }
protected virtual void BuildControls() { Vector2 buttonSize = MyGuiConstants.BACK_BUTTON_SIZE; Vector2 buttonsOrigin = m_size.Value / 2 - new Vector2(0.65f, 0.1f); AddCaption(MySpaceTexts.ScreenCaptionScenario); //RIGHT: int numControls = 0; var nameLabel = MakeLabel(MySpaceTexts.Name); var descriptionLabel = MakeLabel(MySpaceTexts.Description); var difficultyLabel = MakeLabel(MySpaceTexts.Difficulty); var onlineModeLabel = MakeLabel(MySpaceTexts.WorldSettings_OnlineMode); m_maxPlayersLabel = MakeLabel(MySpaceTexts.MaxPlayers); float width = 0.284375f + 0.025f; m_nameTextbox = new MyGuiControlTextbox(maxLength: MySession.MAX_NAME_LENGTH); m_nameTextbox.Enabled = false; m_descriptionTextbox = new MyGuiControlTextbox(maxLength: MySession.MAX_DESCRIPTION_LENGTH); m_descriptionTextbox.Enabled = false; m_difficultyCombo = new MyGuiControlCombobox(size: new Vector2(width, 0.04f)); m_difficultyCombo.AddItem((int)0, MySpaceTexts.DifficultyEasy); m_difficultyCombo.AddItem((int)1, MySpaceTexts.DifficultyNormal); m_difficultyCombo.AddItem((int)2, MySpaceTexts.DifficultyHard); m_onlineMode = 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_onlineMode.Enabled = false; m_scenarioTypesList = new MyGuiControlList(); //BUTTONS m_removeButton = new MyGuiControlButton(position: buttonsOrigin, size: buttonSize, text: MyTexts.Get(MySpaceTexts.buttonRemove), onButtonClick: OnOkButtonClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM); m_publishButton = new MyGuiControlButton(position: buttonsOrigin + new Vector2(0.01f + m_removeButton.Size.X, 0f), size: buttonSize, text: MyTexts.Get(MySpaceTexts.buttonPublish), onButtonClick: OnPublishButtonClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM); m_editButton = new MyGuiControlButton(position: buttonsOrigin + new Vector2(2 * (0.01f + m_removeButton.Size.X), 0f), size: buttonSize, text: MyTexts.Get(MySpaceTexts.buttonEdit), onButtonClick: OnEditButtonClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM); m_browseWorkshopButton = new MyGuiControlButton(position: buttonsOrigin + new Vector2(3 * (0.01f + m_removeButton.Size.X), 0f), size: buttonSize, text: MyTexts.Get(MySpaceTexts.buttonBrowseWorkshop), onButtonClick: OnBrowseWorkshopClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM); m_refreshButton = new MyGuiControlButton(position: buttonsOrigin + new Vector2(0.0f, m_removeButton.Size.Y + 0.01f), size: buttonSize, text: MyTexts.Get(MySpaceTexts.buttonRefresh), onButtonClick: OnRefreshButtonClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM); m_openInWorkshopButton = new MyGuiControlButton(position: buttonsOrigin + new Vector2((0.01f + m_removeButton.Size.X), m_removeButton.Size.Y + 0.01f), size: buttonSize, text: MyTexts.Get(MySpaceTexts.buttonOpenInWorkshop), onButtonClick: OnOkButtonClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM); m_okButton = new MyGuiControlButton(position: buttonsOrigin + new Vector2(2 * (0.01f + m_removeButton.Size.X), m_removeButton.Size.Y + 0.01f), size: buttonSize, text: MyTexts.Get(MySpaceTexts.Ok), onButtonClick: OnOkButtonClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM); m_cancelButton = new MyGuiControlButton(position: buttonsOrigin + new Vector2(3 * (0.01f + m_removeButton.Size.X), m_removeButton.Size.Y + 0.01f), size: buttonSize, text: MyTexts.Get(MySpaceTexts.Cancel), onButtonClick: OnCancelButtonClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM); m_onlineMode.ItemSelected += OnOnlineModeSelect; m_onlineMode.AddItem((int)MyOnlineModeEnum.OFFLINE, MySpaceTexts.WorldSettings_OnlineModeOffline); m_onlineMode.AddItem((int)MyOnlineModeEnum.PRIVATE, MySpaceTexts.WorldSettings_OnlineModePrivate); m_onlineMode.AddItem((int)MyOnlineModeEnum.FRIENDS, MySpaceTexts.WorldSettings_OnlineModeFriends); m_onlineMode.AddItem((int)MyOnlineModeEnum.PUBLIC, MySpaceTexts.WorldSettings_OnlineModePublic); m_nameTextbox.TextChanged += m_nameTextbox_TextChanged; // Add controls in pairs; label first, control second. They will be laid out automatically this way. Controls.Add(nameLabel); Controls.Add(m_nameTextbox); //m_nameTextbox.Enabled = false; Controls.Add(descriptionLabel); Controls.Add(m_descriptionTextbox); //m_descriptionTextbox.Enabled = false; Controls.Add(difficultyLabel); Controls.Add(m_difficultyCombo); m_difficultyCombo.Enabled = false; Controls.Add(onlineModeLabel); Controls.Add(m_onlineMode); //m_onlineMode.Enabled = false; Controls.Add(m_maxPlayersLabel); Controls.Add(m_maxPlayersSlider); float labelSize = 0.12f; float MARGIN_TOP = 0.1f; float MARGIN_LEFT = 0.42f;// m_isNewGame ? 0.315f : 0.08f; // 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++; } } //BRIEFING: //var textBackgroundPanel = AddCompositePanel(MyGuiConstants.TEXTURE_RECTANGLE_DARK, new Vector2(0f,0f), new Vector2(0.43f, 0.422f), MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP); //textBackgroundPanel.InnerHeight = 6; MyGuiControlParent briefing = new MyGuiControlParent();//new Vector2(0f, 0f), new Vector2(0.43f, 0.422f)); var briefingScrollableArea = new MyGuiControlScrollablePanel( scrolledControl: briefing) { Name = "BriefingScrollableArea", ScrollbarVEnabled = true, Position = new Vector2(-0.02f, -0.12f), Size = new Vector2(0.43f, 0.422f), OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, BackgroundTexture = MyGuiConstants.TEXTURE_SCROLLABLE_LIST, ScrolledAreaPadding = new MyGuiBorderThickness(0.005f), }; Controls.Add(briefingScrollableArea); //inside scrollable area: m_descriptionBox = AddMultilineText(offset: new Vector2(0.0f, 0.0f), size: new Vector2(1f, 1f), selectable: false); briefing.Controls.Add(m_descriptionBox); //LEFT: m_scenarioTable = new MyGuiControlTable(); m_scenarioTable.Position = new Vector2(-0.42f, -0.5f + MARGIN_TOP); m_scenarioTable.Size = new Vector2(0.38f, 1.8f); m_scenarioTable.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; m_scenarioTable.VisibleRowsCount = 20; m_scenarioTable.ColumnsCount = 2; m_scenarioTable.SetCustomColumnWidths(new float[] { 0.085f, 0.905f }); m_scenarioTable.SetColumnName(1, MyTexts.Get(MySpaceTexts.Name)); m_scenarioTable.ItemSelected += OnTableItemSelected; //m_scenarioTable.ItemDoubleClicked += OnTableItemConfirmedOrDoubleClick; //m_scenarioTable.ItemConfirmed += OnTableItemConfirmedOrDoubleClick; Controls.Add(m_scenarioTable); //BUTTONS: Controls.Add(m_removeButton); m_removeButton.Enabled = false; Controls.Add(m_publishButton); m_publishButton.Enabled = false; Controls.Add(m_editButton); m_editButton.Enabled = false; Controls.Add(m_browseWorkshopButton); Controls.Add(m_refreshButton); Controls.Add(m_openInWorkshopButton); m_openInWorkshopButton.Enabled = false; Controls.Add(m_okButton); Controls.Add(m_cancelButton); CloseButtonEnabled = true; SetDefaultValues(); }
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; }
private void RecreateControls() { Debug.Assert(m_infoPage != null, "Terminal page is null"); if (m_infoPage == null) { return; } if (MyFakes.ENABLE_CENTER_OF_MASS) { var centerBtn = (MyGuiControlCheckbox)m_infoPage.Controls.GetControlByName("CenterBtn"); centerBtn.IsChecked = MyCubeGrid.ShowCenterOfMass; centerBtn.IsCheckedChanged = centerBtn_IsCheckedChanged; var pivotBtn = (MyGuiControlCheckbox)m_infoPage.Controls.GetControlByName("PivotBtn"); pivotBtn.IsChecked = MyCubeGrid.ShowGridPivot; pivotBtn.IsCheckedChanged = pivotBtn_IsCheckedChanged; } var showGravityGizmoBtn = (MyGuiControlCheckbox)m_infoPage.Controls.GetControlByName("ShowGravityGizmo"); showGravityGizmoBtn.IsChecked = MyCubeGrid.ShowGravityGizmos; showGravityGizmoBtn.IsCheckedChanged = showGravityGizmos_IsCheckedChanged; var showSenzorGizmoBtn = (MyGuiControlCheckbox)m_infoPage.Controls.GetControlByName("ShowSenzorGizmo"); showSenzorGizmoBtn.IsChecked = MyCubeGrid.ShowSenzorGizmos; showSenzorGizmoBtn.IsCheckedChanged = showSenzorGizmos_IsCheckedChanged; var showAntenaGizmoBtn = (MyGuiControlCheckbox)m_infoPage.Controls.GetControlByName("ShowAntenaGizmo"); showAntenaGizmoBtn.IsChecked = MyCubeGrid.ShowAntennaGizmos; showAntenaGizmoBtn.IsCheckedChanged = showAntenaGizmos_IsCheckedChanged; var friendAntennaRange = (MyGuiControlSlider)m_infoPage.Controls.GetControlByName("FriendAntennaRange"); friendAntennaRange.Value = MyHudMarkerRender.FriendAntennaRange; friendAntennaRange.ValueChanged += (MyGuiControlSlider s) => { MyHudMarkerRender.FriendAntennaRange = s.Value; }; var enemyAntennaRange = (MyGuiControlSlider)m_infoPage.Controls.GetControlByName("EnemyAntennaRange"); enemyAntennaRange.Value = MyHudMarkerRender.EnemyAntennaRange; enemyAntennaRange.ValueChanged += (MyGuiControlSlider s) => { MyHudMarkerRender.EnemyAntennaRange = s.Value; }; var ownedAntennaRange = (MyGuiControlSlider)m_infoPage.Controls.GetControlByName("OwnedAntennaRange"); ownedAntennaRange.Value = MyHudMarkerRender.OwnerAntennaRange; ownedAntennaRange.ValueChanged += (MyGuiControlSlider s) => { MyHudMarkerRender.OwnerAntennaRange = s.Value; }; if (MyFakes.ENABLE_TERMINAL_PROPERTIES) { var renameShipLabel = (MyGuiControlLabel)m_infoPage.Controls.GetControlByName("RenameShipLabel"); var renameShipBtn = (MyGuiControlButton)m_infoPage.Controls.GetControlByName("RenameShipButton"); var renameShipText = (MyGuiControlTextbox)m_infoPage.Controls.GetControlByName("RenameShipText"); if (renameShipText != null && m_grid != null) { renameShipText.Text = m_grid.DisplayName; } var showRenameShip = IsPlayerOwner(m_grid); renameShipLabel.Visible = showRenameShip; renameShipBtn.Visible = showRenameShip; renameShipText.Visible = showRenameShip; } var convertBtn = (MyGuiControlButton)m_infoPage.Controls.GetControlByName("ConvertBtn"); MyGuiControlList list = (MyGuiControlList)m_infoPage.Controls.GetControlByName("InfoList"); list.Controls.Clear(); if (m_grid == null || m_grid.Physics == null) { convertBtn.Enabled = false; MyGuiControlLabel noShip = new MyGuiControlLabel(text: MyTexts.GetString(MySpaceTexts.ScreenTerminalError_ShipNotConnected), font: Common.MyFontEnum.Red); list.Controls.Add(noShip); return; } if (!m_grid.IsStatic || m_grid.MarkedForClose) { convertBtn.Enabled = false; } int gravityCounter = 0; if (m_grid.BlocksCounters.ContainsKey(typeof(MyGravityGenerator))) { gravityCounter = m_grid.BlocksCounters[typeof(MyGravityGenerator)]; } int massCounter = 0; if (m_grid.BlocksCounters.ContainsKey(typeof(MyVirtualMass))) { massCounter = m_grid.BlocksCounters[typeof(MyVirtualMass)]; } int lightCounter = 0; if (m_grid.BlocksCounters.ContainsKey(typeof(MyInteriorLight))) { lightCounter = m_grid.BlocksCounters[typeof(MyInteriorLight)]; } var conveyorCounter = 0; foreach (var key in m_grid.BlocksCounters.Keys) { if (typeof(IMyConveyorSegmentBlock).IsAssignableFrom(key) || typeof(IMyConveyorEndpointBlock).IsAssignableFrom(key)) { conveyorCounter += m_grid.BlocksCounters[key]; } } int polygonCounter = 0; foreach (var block in m_grid.GetBlocks()) { if (block.FatBlock != null) { polygonCounter += block.FatBlock.Model.GetTrianglesCount(); } } foreach (var cell in m_grid.RenderData.Cells.Values) { foreach (var part in cell.CubeParts) { polygonCounter += part.Model.GetTrianglesCount(); } } MyGuiControlLabel polygonCount = new MyGuiControlLabel(text: new StringBuilder().AppendStringBuilder(MyTexts.Get(MySpaceTexts.TerminalTab_Info_Triangles)).AppendInt32(polygonCounter).ToString()); polygonCount.SetToolTip(MySpaceTexts.TerminalTab_Info_TrianglesTooltip); MyGuiControlLabel cubeCount = new MyGuiControlLabel(text: new StringBuilder().AppendStringBuilder(MyTexts.Get(MySpaceTexts.TerminalTab_Info_Blocks)).AppendInt32(m_grid.GetBlocks().Count).ToString()); cubeCount.SetToolTip(MySpaceTexts.TerminalTab_Info_BlocksTooltip); MyGuiControlLabel blockCount = new MyGuiControlLabel(text: new StringBuilder().AppendStringBuilder(MyTexts.Get(MySpaceTexts.TerminalTab_Info_NonArmor)).AppendInt32(m_grid.Hierarchy.Children.Count).ToString()); MyGuiControlLabel thrustCount = new MyGuiControlLabel(text: new StringBuilder().AppendStringBuilder(MyTexts.Get(MySpaceTexts.TerminalTab_Info_Thrusters)).AppendInt32(m_grid.GridSystems.ThrustSystem.ThrustCount).ToString()); MyGuiControlLabel lightCount = new MyGuiControlLabel(text: new StringBuilder().Clear().AppendStringBuilder(MyTexts.Get(MySpaceTexts.TerminalTab_Info_Lights)).AppendInt32(lightCounter).ToString()); MyGuiControlLabel reflectorCount = new MyGuiControlLabel(text: new StringBuilder().AppendStringBuilder(MyTexts.Get(MySpaceTexts.TerminalTab_Info_Reflectors)).AppendInt32(m_grid.GridSystems.ReflectorLightSystem.ReflectorCount).ToString()); //MyGuiControlLabel wheelCount = new MyGuiControlLabel(text: new StringBuilder().AppendStringBuilder(MyTexts.Get(MySpaceTexts.TerminalTab_Info_Rotors)).AppendInt32(m_grid.WheelSystem.WheelCount)); MyGuiControlLabel gravityCount = new MyGuiControlLabel(text: new StringBuilder().AppendStringBuilder(MyTexts.Get(MySpaceTexts.TerminalTab_Info_GravGens)).AppendInt32(gravityCounter).ToString()); MyGuiControlLabel massCount = new MyGuiControlLabel(text: new StringBuilder().AppendStringBuilder(MyTexts.Get(MySpaceTexts.TerminalTab_Info_VirtualMass)).AppendInt32(massCounter).ToString()); MyGuiControlLabel conveyorCount = new MyGuiControlLabel(text: new StringBuilder().AppendStringBuilder(MyTexts.Get(MySpaceTexts.TerminalTab_Info_Conveyors)).AppendInt32(conveyorCounter).ToString()); list.InitControls(new MyGuiControlBase[] { cubeCount, blockCount, conveyorCount, thrustCount, lightCount, reflectorCount, gravityCount, massCount, polygonCount }); }
public override void RecreateControls(bool contructor) { base.RecreateControls(contructor); Controls.Clear(); m_entitiesGuiList = new MyGuiControlList( this, new Vector2(0.0034f, -0.030f), new Vector2(0.489f, 0.65f), Vector4.Zero, null,//MyTextsWrapper.Get(MyTextsWrapperEnum.SecurityControlHUB), MyGuiManager.GetBlankTexture(), new Vector2(0.01f, 0.0f)); if (!contructor) { foreach (var entityGui in m_entitiesGui) { entityGui.ClearAfterRemove(); } } m_entitiesGui.Clear(); foreach (IMyUseableEntity connectedEntity in m_prefabSecurityControlHUB.ConnectedEntities) { MyEntity entity = connectedEntity as MyEntity; if (!entity.Visible) { continue; } Debug.Assert((connectedEntity.UseProperties.UseType & MyUseType.FromHUB) != 0); IMyHasGuiControl entityWithGuiControl = connectedEntity as IMyHasGuiControl; Debug.Assert(entityWithGuiControl != null); // if entity is not hacked and could be hacked from HUB, then try hack it if (!connectedEntity.UseProperties.IsHacked && (connectedEntity.UseProperties.HackType & MyUseType.FromHUB) != 0) { if (m_useBy.HackingTool != null && m_useBy.HackingTool.HackingLevel >= connectedEntity.UseProperties.HackingLevel) { connectedEntity.UseProperties.IsHacked = true; } } MyGuiControlEntityUse entityGui = entityWithGuiControl.GetGuiControl(m_entitiesGuiList); entityGui.ParentScreen = this; m_entitiesGui.Add(entityGui); } m_entitiesGuiList.InitControls(m_entitiesGui); Controls.Add(m_entitiesGuiList); var exitButton = new MyGuiControlButton( this, new Vector2(0f, 0.3740f), new Vector2(0.161f, 0.0637f), Vector4.One, MyGuiManager.GetConfirmButton(), null, null, MyTextsWrapperEnum.Exit, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, MyGuiControlButtonTextAlignment.CENTERED, OnExitClick, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, true); Controls.Add(exitButton); }
public MyGuiScreenFake() : base(new Vector2(0.5f, 0.5f), new Vector4(0f, 1f, 0f, 0.5f), new Vector2(1f, 1f)) { MyGuiControlList controlList = new MyGuiControlList(this, new Vector2(0f, 0f), new Vector2(0.8f, 0.5f), MyGuiConstants.DEFAULT_CONTROL_BACKGROUND_COLOR, new StringBuilder("ToolTip"), MyGuiManager.GetBlankTexture()); Controls.Add(controlList); List <MyGuiControlBase> fakeControls = new List <MyGuiControlBase>(); MyGuiControlParent parent1 = new MyGuiControlParent(this, Vector2.Zero, new Vector2(0.4f, 0.2f), new Vector4(1f, 0f, 0f, 1f), new StringBuilder("Parent1"), null); parent1.Controls.Add(new MyGuiControlTextbox(parent1, new Vector2(0f, 0f), MyGuiControlPreDefinedSize.LARGE, "AAA", 50, MyGuiConstants.TEXTBOX_BACKGROUND_COLOR, 0.7f, MyGuiControlTextboxType.NORMAL)); parent1.Controls.Add(new MyGuiControlCheckbox(parent1, new Vector2(0f, 0.07f), MyGuiConstants.CHECKBOX_SIZE, true, MyGuiConstants.CHECKBOX_BACKGROUND_COLOR)); fakeControls.Add(parent1); MyGuiControlParent parent2 = new MyGuiControlParent(this, Vector2.Zero, new Vector2(0.4f, 0.2f), new Vector4(0f, 1f, 0f, 1f), new StringBuilder("Parent2"), null); parent2.Controls.Add(new MyGuiControlTextbox(parent2, new Vector2(0f, 0f), MyGuiControlPreDefinedSize.LARGE, "CCC", 50, MyGuiConstants.TEXTBOX_BACKGROUND_COLOR, 0.7f, MyGuiControlTextboxType.NORMAL)); MyGuiControlCombobox combobox1 = new MyGuiControlCombobox(parent2, new Vector2(0f, 0.07f), MyGuiControlPreDefinedSize.MEDIUM, MyGuiConstants.COMBOBOX_BACKGROUND_COLOR, MyGuiConstants.COMBOBOX_TEXT_SCALE, 10, false, true, false); combobox1.AddItem(0, new StringBuilder("Item1 Item1 Item1 Item1 Item1 Item1 Item1 ")); combobox1.AddItem(1, new StringBuilder("Item2 Item2 Item2 Item2 Item2 Item2 Item2 ")); combobox1.AddItem(2, new StringBuilder("Item3 Item3 Item3 Item3 Item3 Item3 Item3 ")); combobox1.AddItem(3, new StringBuilder("Item4")); combobox1.AddItem(4, new StringBuilder("Item5")); combobox1.AddItem(5, new StringBuilder("Item6")); combobox1.AddItem(6, new StringBuilder("Item7")); combobox1.AddItem(7, new StringBuilder("Item8")); combobox1.AddItem(8, new StringBuilder("Item9")); combobox1.AddItem(9, new StringBuilder("Item10")); combobox1.AddItem(10, new StringBuilder("Item11")); combobox1.AddItem(11, new StringBuilder("Item12")); combobox1.AddItem(12, new StringBuilder("Item13")); parent2.Controls.Add(combobox1); fakeControls.Add(parent2); MyGuiControlParent parent3 = new MyGuiControlParent(this, Vector2.Zero, new Vector2(0.4f, 0.2f), new Vector4(0f, 0f, 1f, 1f), new StringBuilder("Parent3"), null); parent3.Controls.Add(new MyGuiControlTextbox(parent3, new Vector2(0f, 0f), MyGuiControlPreDefinedSize.LARGE, "EEE", 50, MyGuiConstants.TEXTBOX_BACKGROUND_COLOR, 0.7f, MyGuiControlTextboxType.NORMAL)); MyGuiControlCombobox combobox2 = new MyGuiControlCombobox(parent3, new Vector2(0f, 0.07f), MyGuiControlPreDefinedSize.MEDIUM, MyGuiConstants.COMBOBOX_BACKGROUND_COLOR, MyGuiConstants.COMBOBOX_TEXT_SCALE, 10, false, true, false); combobox2.AddItem(0, new StringBuilder("Item1 Item1 Item1 Item1 Item1 Item1 Item1 ")); combobox2.AddItem(1, new StringBuilder("Item2 Item2 Item2 Item2 Item2 Item2 Item2 ")); combobox2.AddItem(2, new StringBuilder("Item3 Item3 Item3 Item3 Item3 Item3 Item3 ")); combobox2.AddItem(3, new StringBuilder("Item4")); combobox2.AddItem(4, new StringBuilder("Item5")); combobox2.AddItem(5, new StringBuilder("Item6")); combobox2.AddItem(6, new StringBuilder("Item7")); combobox2.AddItem(7, new StringBuilder("Item8")); combobox2.AddItem(8, new StringBuilder("Item9")); combobox2.AddItem(9, new StringBuilder("Item10")); combobox2.AddItem(10, new StringBuilder("Item11")); combobox2.AddItem(11, new StringBuilder("Item12")); combobox2.AddItem(12, new StringBuilder("Item13")); parent3.Controls.Add(combobox2); fakeControls.Add(parent3); MyGuiControlParent parent4 = new MyGuiControlParent(this, Vector2.Zero, new Vector2(0.4f, 0.2f), new Vector4(1f, 0f, 1f, 1f), new StringBuilder("Parent4"), null); parent4.Controls.Add(new MyGuiControlTextbox(parent4, new Vector2(0f, 0f), MyGuiControlPreDefinedSize.LARGE, "GGG", 50, MyGuiConstants.TEXTBOX_BACKGROUND_COLOR, 0.7f, MyGuiControlTextboxType.NORMAL)); parent4.Controls.Add(new MyGuiControlTextbox(parent4, new Vector2(0f, 0.07f), MyGuiControlPreDefinedSize.LARGE, "HHH", 50, MyGuiConstants.TEXTBOX_BACKGROUND_COLOR, 0.7f, MyGuiControlTextboxType.NORMAL)); fakeControls.Add(parent4); MyGuiControlParent parent5 = new MyGuiControlParent(this, Vector2.Zero, new Vector2(0.4f, 0.2f), new Vector4(1f, 1f, 0f, 1f), new StringBuilder("Parent5"), null); parent5.Controls.Add(new MyGuiControlTextbox(parent5, new Vector2(0f, 0f), MyGuiControlPreDefinedSize.LARGE, "III", 50, MyGuiConstants.TEXTBOX_BACKGROUND_COLOR, 0.7f, MyGuiControlTextboxType.NORMAL)); parent5.Controls.Add(new MyGuiControlTextbox(parent5, new Vector2(0f, 0.07f), MyGuiControlPreDefinedSize.LARGE, "JJJ", 50, MyGuiConstants.TEXTBOX_BACKGROUND_COLOR, 0.7f, MyGuiControlTextboxType.NORMAL)); fakeControls.Add(parent5); controlList.InitControls(fakeControls); }
protected virtual void BuildControls() { if (m_isNewGame) { //AddCaption(MyCommonTexts.ScreenCaptionCustomWorld); } else { AddCaption(MyCommonTexts.ScreenCaptionEditSettings); } int numControls = 0; float MARGIN_TOP = m_isNewGame ? 0.18f : 0.1f; float MARGIN_BOTTOM = 0.11f; float MARGIN_LEFT = m_isNewGame ? 0.23f : 0.03f; float MARGIN_RIGHT = m_isNewGame ? 0.03f : 0.03f; float MARGIN_BOTTOM_LISTBOX = 0.015f; // Automatic layout. Vector2 originL, originC, sizeL, sizeC, sizeControls; Vector2 controlsDelta = new Vector2(0f, 0.052f); float rightColumnOffset; originL = -m_size.Value / 2 + new Vector2(MARGIN_LEFT, MARGIN_TOP) + controlsDelta / 2; sizeControls = m_size.Value / 2 - originL; sizeControls.X -= MARGIN_RIGHT + 0.005f; sizeControls.Y -= MARGIN_BOTTOM; sizeL = sizeControls * (m_isNewGame ? 0.44f : 0.395f); originC = originL + new Vector2(sizeL.X, 0f); sizeC = sizeControls - sizeL; //rightColumnOffset = originC.X + m_onlineMode.Size.X - labelSize - 0.017f; // Button positioning Vector2 buttonSize = MyGuiConstants.BACK_BUTTON_SIZE; Vector2 buttonsOrigin = m_size.Value / 2; buttonsOrigin.X -= MARGIN_RIGHT; buttonsOrigin.Y -= 0.03f; 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 soundModeLabel = MakeLabel(MySpaceTexts.WorldSettings_SoundMode); 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(sizeC.X, 0.04f)); m_environment = new MyGuiControlCombobox(size: new Vector2(sizeC.X, 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(sizeC.X, 0.04f)); m_asteroidAmountCombo.ItemSelected += m_asteroidAmountCombo_ItemSelected; m_soundModeCombo = new MyGuiControlCombobox(size: new Vector2(sizeC.X, 0.04f)); m_scenarioTypesList = new MyGuiControlList(); // Ok/Cancel m_cancelButton = new MyGuiControlButton(position: buttonsOrigin, size: buttonSize, text: MyTexts.Get(MyCommonTexts.Cancel), onButtonClick: OnCancelButtonClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM); buttonsOrigin.X -= m_cancelButton.Size.X + MyGuiConstants.GENERIC_BUTTON_SPACING.X; m_okButton = new MyGuiControlButton(position: buttonsOrigin, size: buttonSize, text: MyTexts.Get(MyCommonTexts.Ok), onButtonClick: OnOkButtonClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_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; m_soundModeCombo.AddItem((int)MySoundModeEnum.Arcade, MySpaceTexts.WorldSettings_ArcadeSound); m_soundModeCombo.AddItem((int)MySoundModeEnum.Realistic, MySpaceTexts.WorldSettings_RealisticSound); if (m_isNewGame) { if (MyDefinitionManager.Static.GetScenarioDefinitions().Count == 0) { MyDefinitionManager.Static.LoadScenarios(); } m_scenarioTypesGroup = new MyGuiControlRadioButtonGroup(); m_scenarioTypesGroup.SelectedChanged += scenario_SelectedChanged; RefreshCustomWorldsList(); } 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_soundModeCombo.SetToolTip(MyTexts.GetString(MySpaceTexts.ToolTipWorldSettingsSoundMode)); m_nameTextbox.TextChanged += m_nameTextbox_TextChanged; m_soundModeCombo.ItemSelected += m_soundModeCombo_ItemSelected; var advanced = new MyGuiControlButton(highlightType: MyGuiControlHighlightType.WHEN_ACTIVE, text: MyTexts.Get(MySpaceTexts.WorldSettings_Advanced), onButtonClick: OnAdvancedClick); #if !XB1 // XB1_NOWORKSHOP var mods = new MyGuiControlButton(highlightType: MyGuiControlHighlightType.WHEN_ACTIVE, text: MyTexts.Get(MyCommonTexts.WorldSettings_Mods), onButtonClick: OnModsClick); #endif // !XB1 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); if (MyFakes.ENABLE_NEW_SOUNDS) { Controls.Add(soundModeLabel); Controls.Add(m_soundModeCombo); } 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 blockLimitsLabel = MakeLabel(MyCommonTexts.WorldSettings_BlockLimits); m_blockLimits = new MyGuiControlCheckbox(); m_blockLimits.IsCheckedChanged = blockLimits_CheckedChanged; m_blockLimits.SetToolTip(MyTexts.GetString(MyCommonTexts.ToolTipWorldSettingsBlockLimits)); Controls.Add(blockLimitsLabel); Controls.Add(m_blockLimits); 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); #if !XB1 // XB1_NOWORKSHOP if (!MyFakes.XB1_PREVIEW) { if (MyFakes.ENABLE_WORKSHOP_MODS) { Controls.Add(mods); } } #endif // !XB1 Controls.Add(advanced); // Uncomment to show the World generator button again if (m_isNewGame && MyFakes.ENABLE_PLANETS == true) { Controls.Add(m_worldGeneratorButton); } 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); m_nameTextbox.Size = m_onlineMode.Size; m_descriptionTextbox.Size = m_nameTextbox.Size; if (m_isNewGame) { Vector2 scenarioPosition = -m_size.Value / 2 + new Vector2(0.015f, MARGIN_TOP); m_scenarioTypesList.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; m_scenarioTypesList.Position = scenarioPosition; m_scenarioTypesList.Size = new Vector2(MyGuiConstants.LISTBOX_WIDTH, m_size.Value.Y - 0.02f - MARGIN_TOP); 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; #if !XB1 // XB1_NOWORKSHOP mods.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM; mods.Position = advanced.Position - new Vector2(advanced.Size.X + MyGuiConstants.GENERIC_BUTTON_SPACING.X, 0); #endif // !XB1 m_worldGeneratorButton.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM; m_worldGeneratorButton.Position = advanced.Position - new Vector2(advanced.Size.X + MyGuiConstants.GENERIC_BUTTON_SPACING.X, -0.06f); if (MyFakes.XB1_PREVIEW) { var pos2p = m_worldGeneratorButton.Position; pos2p.X = Size.HasValue ? Size.Value.X / 2.0f - m_worldGeneratorButton.Size.X - MARGIN_RIGHT : 0.0f; m_worldGeneratorButton.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM; m_worldGeneratorButton.Position = pos2p; advanced.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM; if (m_isNewGame) { advanced.Position = m_worldGeneratorButton.Position - new Vector2(m_worldGeneratorButton.Size.X + 0.017f, 0); } else { advanced.Position = m_worldGeneratorButton.Position - new Vector2(m_worldGeneratorButton.Size.X + 0.017f, 0.008f); } } Controls.Add(m_okButton); Controls.Add(m_cancelButton); CloseButtonEnabled = true; }
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); } }
private void RecreateControls() { Debug.Assert(m_infoPage != null, "Terminal page is null"); if (m_infoPage == null) { return; } if (MyFakes.ENABLE_CENTER_OF_MASS) { var centerBtn = (MyGuiControlCheckbox)m_infoPage.Controls.GetControlByName("CenterBtn"); centerBtn.IsChecked = MyCubeGrid.ShowCenterOfMass; centerBtn.IsCheckedChanged = centerBtn_IsCheckedChanged; var pivotBtn = (MyGuiControlCheckbox)m_infoPage.Controls.GetControlByName("PivotBtn"); pivotBtn.IsChecked = MyCubeGrid.ShowGridPivot; pivotBtn.IsCheckedChanged = pivotBtn_IsCheckedChanged; } var showGravityGizmoBtn = (MyGuiControlCheckbox)m_infoPage.Controls.GetControlByName("ShowGravityGizmo"); showGravityGizmoBtn.IsChecked = MyCubeGrid.ShowGravityGizmos; showGravityGizmoBtn.IsCheckedChanged = showGravityGizmos_IsCheckedChanged; var showSenzorGizmoBtn = (MyGuiControlCheckbox)m_infoPage.Controls.GetControlByName("ShowSenzorGizmo"); showSenzorGizmoBtn.IsChecked = MyCubeGrid.ShowSenzorGizmos; showSenzorGizmoBtn.IsCheckedChanged = showSenzorGizmos_IsCheckedChanged; var showAntenaGizmoBtn = (MyGuiControlCheckbox)m_infoPage.Controls.GetControlByName("ShowAntenaGizmo"); showAntenaGizmoBtn.IsChecked = MyCubeGrid.ShowAntennaGizmos; showAntenaGizmoBtn.IsCheckedChanged = showAntenaGizmos_IsCheckedChanged; var friendAntennaRange = (MyGuiControlSlider)m_infoPage.Controls.GetControlByName("FriendAntennaRange"); friendAntennaRange.Value = MyHudMarkerRender.FriendAntennaRange; friendAntennaRange.ValueChanged += (MyGuiControlSlider s) => { MyHudMarkerRender.FriendAntennaRange = s.Value; }; var enemyAntennaRange = (MyGuiControlSlider)m_infoPage.Controls.GetControlByName("EnemyAntennaRange"); enemyAntennaRange.Value = MyHudMarkerRender.EnemyAntennaRange; enemyAntennaRange.ValueChanged += (MyGuiControlSlider s) => { MyHudMarkerRender.EnemyAntennaRange = s.Value; }; var ownedAntennaRange = (MyGuiControlSlider)m_infoPage.Controls.GetControlByName("OwnedAntennaRange"); ownedAntennaRange.Value = MyHudMarkerRender.OwnerAntennaRange; ownedAntennaRange.ValueChanged += (MyGuiControlSlider s) => { MyHudMarkerRender.OwnerAntennaRange = s.Value; }; if (MyFakes.ENABLE_TERMINAL_PROPERTIES) { var renameShipLabel = (MyGuiControlLabel)m_infoPage.Controls.GetControlByName("RenameShipLabel"); var renameShipBtn = (MyGuiControlButton)m_infoPage.Controls.GetControlByName("RenameShipButton"); var renameShipText = (MyGuiControlTextbox)m_infoPage.Controls.GetControlByName("RenameShipText"); if (renameShipText != null && m_grid != null) { renameShipText.Text = m_grid.DisplayName; } var showRenameShip = IsPlayerOwner(m_grid); renameShipLabel.Visible = showRenameShip; renameShipBtn.Visible = showRenameShip; renameShipText.Visible = showRenameShip; } var convertBtn = (MyGuiControlButton)m_infoPage.Controls.GetControlByName("ConvertBtn"); var convertToStationBtn = (MyGuiControlButton)m_infoPage.Controls.GetControlByName("ConvertToStationBtn"); MyGuiControlList list = (MyGuiControlList)m_infoPage.Controls.GetControlByName("InfoList"); list.Controls.Clear(); var setDestructibleBlocks = (MyGuiControlCheckbox)m_infoPage.Controls.GetControlByName("SetDestructibleBlocks"); setDestructibleBlocks.Visible = MySession.Static.Settings.ScenarioEditMode || MySession.Static.IsScenario; setDestructibleBlocks.Enabled = MySession.Static.Settings.ScenarioEditMode; if (m_grid == null || m_grid.Physics == null) { convertBtn.Enabled = false; convertToStationBtn.Enabled = false; RecreateServerLimitInfo(list); return; } if (!m_grid.IsStatic) { convertBtn.Enabled = false; convertToStationBtn.Enabled = true; } else { convertBtn.Enabled = true; convertToStationBtn.Enabled = false; } if (m_grid.GridSizeEnum == MyCubeSize.Small) { convertToStationBtn.Enabled = false; } if (!m_grid.BigOwners.Contains(MySession.Static.LocalPlayerId)) { convertBtn.Enabled = false; convertToStationBtn.Enabled = false; } setDestructibleBlocks.IsChecked = m_grid.DestructibleBlocks; setDestructibleBlocks.IsCheckedChanged = setDestructibleBlocks_IsCheckedChanged; int gravityCounter = 0; if (m_grid.BlocksCounters.ContainsKey(typeof(MyObjectBuilder_GravityGenerator))) { gravityCounter = m_grid.BlocksCounters[typeof(MyObjectBuilder_GravityGenerator)]; } int massCounter = 0; if (m_grid.BlocksCounters.ContainsKey(typeof(MyObjectBuilder_VirtualMass))) { massCounter = m_grid.BlocksCounters[typeof(MyObjectBuilder_VirtualMass)]; } int lightCounter = 0; if (m_grid.BlocksCounters.ContainsKey(typeof(MyObjectBuilder_InteriorLight))) { lightCounter = m_grid.BlocksCounters[typeof(MyObjectBuilder_InteriorLight)]; } var conveyorCounter = 0; foreach (var key in m_grid.BlocksCounters.Keys) { Type blockType = MyCubeBlockFactory.GetProducedType(key); if (typeof(IMyConveyorSegmentBlock).IsAssignableFrom(blockType) || typeof(IMyConveyorEndpointBlock).IsAssignableFrom(blockType)) { conveyorCounter += m_grid.BlocksCounters[key]; } } int polygonCounter = 0; foreach (var block in m_grid.GetBlocks()) { if (block.FatBlock != null) { polygonCounter += block.FatBlock.Model.GetTrianglesCount(); } } foreach (var cell in m_grid.RenderData.Cells.Values) { foreach (var part in cell.CubeParts) { polygonCounter += part.Model.GetTrianglesCount(); } } int thrustCount = 0; var thrustComp = m_grid.Components.Get <MyEntityThrustComponent>(); if (thrustComp != null) { thrustCount = thrustComp.ThrustCount; } MyGuiControlLabel thrustCountLabel = new MyGuiControlLabel(text: new StringBuilder().AppendStringBuilder(MyTexts.Get(MySpaceTexts.TerminalTab_Info_Thrusters)).AppendInt32(thrustCount).ToString()); MyGuiControlLabel polygonCount = new MyGuiControlLabel(text: new StringBuilder().AppendStringBuilder(MyTexts.Get(MySpaceTexts.TerminalTab_Info_Triangles)).AppendInt32(polygonCounter).ToString()); polygonCount.SetToolTip(MySpaceTexts.TerminalTab_Info_TrianglesTooltip); MyGuiControlLabel cubeCount = new MyGuiControlLabel(text: new StringBuilder().AppendStringBuilder(MyTexts.Get(MySpaceTexts.TerminalTab_Info_Blocks)).AppendInt32(m_grid.GetBlocks().Count).ToString()); cubeCount.SetToolTip(MySpaceTexts.TerminalTab_Info_BlocksTooltip); MyGuiControlLabel blockCount = new MyGuiControlLabel(text: new StringBuilder().AppendStringBuilder(MyTexts.Get(MySpaceTexts.TerminalTab_Info_NonArmor)).AppendInt32(m_grid.Hierarchy.Children.Count).ToString()); MyGuiControlLabel lightCount = new MyGuiControlLabel(text: new StringBuilder().Clear().AppendStringBuilder(MyTexts.Get(MySpaceTexts.TerminalTab_Info_Lights)).AppendInt32(lightCounter).ToString()); MyGuiControlLabel reflectorCount = new MyGuiControlLabel(text: new StringBuilder().AppendStringBuilder(MyTexts.Get(MySpaceTexts.TerminalTab_Info_Reflectors)).AppendInt32(m_grid.GridSystems.ReflectorLightSystem.ReflectorCount).ToString()); //MyGuiControlLabel wheelCount = new MyGuiControlLabel(text: new StringBuilder().AppendStringBuilder(MyTexts.Get(MySpaceTexts.TerminalTab_Info_Rotors)).AppendInt32(m_grid.WheelSystem.WheelCount)); MyGuiControlLabel gravityCount = new MyGuiControlLabel(text: new StringBuilder().AppendStringBuilder(MyTexts.Get(MySpaceTexts.TerminalTab_Info_GravGens)).AppendInt32(gravityCounter).ToString()); MyGuiControlLabel massCount = new MyGuiControlLabel(text: new StringBuilder().AppendStringBuilder(MyTexts.Get(MySpaceTexts.TerminalTab_Info_VirtualMass)).AppendInt32(massCounter).ToString()); MyGuiControlLabel conveyorCount = new MyGuiControlLabel(text: new StringBuilder().AppendStringBuilder(MyTexts.Get(MySpaceTexts.TerminalTab_Info_Conveyors)).AppendInt32(conveyorCounter).ToString()); var mainCockpit = m_grid.MainCockpit as MyShipController; MyCharacter pilot = null; if (mainCockpit != null) { pilot = mainCockpit.Pilot; } MyGuiControlLabel gridMass = new MyGuiControlLabel(text: new StringBuilder().AppendStringBuilder(MyTexts.Get(MySpaceTexts.TerminalTab_Info_GridMass)).AppendInt32(m_grid.GetCurrentMass(pilot)).ToString()); list.InitControls(new MyGuiControlBase[] { cubeCount, blockCount, conveyorCount, thrustCountLabel, lightCount, reflectorCount, gravityCount, massCount, polygonCount, gridMass }); }