public void Init(MyGuiControlParent menuParent, MyGuiControlParent panelParent, MyEntity interactedEntity, MyEntity openInventoryInteractedEntity) { m_interactedEntityRepresentative = GetInteractedEntityRepresentative(interactedEntity); m_openInventoryInteractedEntityRepresentative = GetInteractedEntityRepresentative(openInventoryInteractedEntity); if (menuParent == null) { MySandboxGame.Log.WriteLine("menuParent is null"); } if (panelParent == null) { MySandboxGame.Log.WriteLine("panelParent is null"); } if (menuParent == null || panelParent == null) { return; } m_shipsInRange = (MyGuiControlCombobox)menuParent.Controls.GetControlByName("ShipsInRange"); m_button = (MyGuiControlButton)menuParent.Controls.GetControlByName("SelectShip"); m_shipsData = (MyGuiControlTable)panelParent.Controls.GetControlByName("ShipsData"); //sort by status by default m_columnToSort = 2; m_button.ButtonClicked += Menu_ButtonClicked; m_shipsData.ColumnClicked += shipsData_ColumnClicked; m_shipsInRange.ItemSelected += shipsInRange_ItemSelected; Refresh(); }
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 void BuildControls() { MyGuiControlParent parent = new MyGuiControlParent(size: new Vector2(Size.Value.X - 0.05f, Size.Value.Y - 0.1f)); MyGuiControlScrollablePanel scrollPanel = new MyGuiControlScrollablePanel(parent); scrollPanel.ScrollbarVEnabled = true; scrollPanel.Size = new Vector2(Size.Value.X - 0.05f, 0.8f); Controls.Add(scrollPanel); Vector2 buttonSize = MyGuiConstants.BACK_BUTTON_SIZE; Vector2 buttonsOrigin = m_size.Value / 2 - new Vector2(0.23f, 0.03f); //AddCaption(MySpaceTexts.ScreenCaptionAdvancedSettings); // Ok/Cancel m_okButton = new MyGuiControlButton(position: buttonsOrigin - new Vector2(0.01f, 0f), size: buttonSize, text: MyTexts.Get(MySpaceTexts.Ok), onButtonClick: OkButtonClicked, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM); m_cancelButton = new MyGuiControlButton(position: buttonsOrigin + new Vector2(0.01f, 0f), size: buttonSize, text: MyTexts.Get(MySpaceTexts.Cancel), onButtonClick: CancelButtonClicked, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM); Controls.Add(m_okButton); Controls.Add(m_cancelButton); float buttonsOffset = 0.055f; var canJoinrunningLabel = MakeLabel(MySpaceTexts.ScenarioSettings_CanJoinRunning); m_canJoinRunning = new MyGuiControlCheckbox(); m_canJoinRunning.Position = new Vector2(-scrollPanel.Size.X / 2 + buttonsOffset, -scrollPanel.Size.Y / 2 + buttonsOffset); canJoinrunningLabel.Position = new Vector2(m_canJoinRunning.Position.X + buttonsOffset, m_canJoinRunning.Position.Y); m_canJoinRunning.IsChecked = MySession.Static.Settings.CanJoinRunning; parent.Controls.Add(m_canJoinRunning); parent.Controls.Add(canJoinrunningLabel); CloseButtonEnabled = true; }
public override void RecreateControls(bool constructor) { base.RecreateControls(constructor); AddCaption(MySpaceTexts.ScreenControlMenu_Title, captionScale: 1.3f); MyGuiControlParent parent = new MyGuiControlParent(size: new Vector2(Size.Value.X - 0.05f, m_items.Count * ITEM_SIZE)); m_scrollPanel = new MyGuiControlScrollablePanel(parent); m_scrollPanel.ScrollbarVEnabled = true; m_scrollPanel.ScrollBarVScale = 1f; m_scrollPanel.Size = new Vector2(Size.Value.X - 0.05f, Size.Value.Y - 0.2f); MyLayoutVertical layout = new MyLayoutVertical(parent, 20); foreach (var item in m_items) { layout.Add(item, MyAlignH.Left, true); } m_itemsRect.Position = m_scrollPanel.GetPositionAbsoluteTopLeft(); m_itemsRect.Size = new Vector2(Size.Value.X - 0.05f, Size.Value.Y - 0.2f); FocusedControl = parent; m_selectedItem = m_items.Count != 0 ? 0 : -1; Controls.Add(m_scrollPanel); }
private void AddSeparator(string sectionName) { var panel = new MyGuiControlCompositePanel() { BackgroundTexture = MyGuiConstants.TEXTURE_RECTANGLE_DARK, OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, Position = Vector2.Zero }; var label = new MyGuiControlLabel() { OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, Text = sectionName, Font = MyFontEnum.Blue, PositionX = 0.005f }; var imageOffset = 0.003f; var colorMask = MyGuiConstants.THEMED_GUI_LINE_COLOR; var img = new MyGuiControlImage(textures: new[] { @"Textures\GUI\FogSmall3.dds" }) { Size = new Vector2(label.Size.X + imageOffset * 10, 0.007f), OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, //ColorMask = new Vector4(0,0,0,1), ColorMask = colorMask.ToVector4(), Position = new Vector2(-imageOffset, label.Size.Y) }; var parent = new MyGuiControlParent { Size = new Vector2(m_campaignList.Size.X, label.Size.Y), OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, Position = Vector2.Zero }; panel.Size = parent.Size + new Vector2(-0.035f, 0.01f); panel.Position -= parent.Size / 2 - new Vector2(-0.01f, 0f); label.Position -= parent.Size / 2; img.Position -= parent.Size / 2; parent.Controls.Add(panel); parent.Controls.Add(img); parent.Controls.Add(label); m_campaignList.Controls.Add(parent); }
private MyGuiControlBase CreateImageTooltip(string path, string text) { MyGuiControlParent myGuiControlParent = new MyGuiControlParent { OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, BackgroundTexture = new MyGuiCompositeTexture("Textures\\GUI\\Blank.dds"), ColorMask = MyGuiConstants.THEMED_GUI_BACKGROUND_COLOR }; myGuiControlParent.CanHaveFocus = false; myGuiControlParent.HighlightType = MyGuiControlHighlightType.NEVER; myGuiControlParent.BorderEnabled = true; Vector2 vector = new Vector2(0.005f, 0.002f); MyGuiControlLabel myGuiControlLabel = new MyGuiControlLabel(Vector2.Zero, null, text) { OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP }; myGuiControlLabel.CanHaveFocus = false; myGuiControlLabel.HighlightType = MyGuiControlHighlightType.NEVER; MyGuiControlImage myGuiControlImage = null; if (!string.IsNullOrEmpty(path)) { myGuiControlImage = new MyGuiControlImage(Vector2.Zero, new Vector2(0.175625f, 0.131718755f)) { OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_BOTTOM }; myGuiControlImage.SetTexture(path); myGuiControlImage.CanHaveFocus = false; myGuiControlImage.HighlightType = MyGuiControlHighlightType.NEVER; } else { myGuiControlImage = new MyGuiControlImage(Vector2.Zero, Vector2.Zero) { OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_BOTTOM }; } myGuiControlParent.Size = new Vector2(Math.Max(myGuiControlLabel.Size.X, myGuiControlImage.Size.X) + vector.X * 2f, myGuiControlLabel.Size.Y + myGuiControlImage.Size.Y + vector.Y * 4f); myGuiControlParent.Controls.Add(myGuiControlImage); myGuiControlParent.Controls.Add(myGuiControlLabel); myGuiControlLabel.Position = -myGuiControlParent.Size / 2f + vector; myGuiControlImage.Position = new Vector2(0f, myGuiControlParent.Size.Y / 2f - vector.Y); return(myGuiControlParent); }
public WarningArea(string name, bool graphicsButton) { Warnings = new List <WarningLine>(); m_header = new MyGuiControlParent(); m_titleBackground = new MyGuiControlPanel(texture: @"Textures\GUI\Controls\item_highlight_dark.dds"); m_title = new MyGuiControlLabel(text: name); m_lastOccurence = new MyGuiControlLabel(text: MyTexts.GetString(MyCommonTexts.PerformanceWarningLastOccurrence), originAlign: VRage.Utils.MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER); m_separator = new MyGuiControlSeparatorList(); m_separator.AddHorizontal(new Vector2(-0.45f, 0.018f), 0.9f); m_title.Position = new Vector2(-0.43f, 0f); m_lastOccurence.Position = new Vector2(0.43f, 0f); m_titleBackground.Size = new Vector2(m_titleBackground.Size.X, 0.035f); m_header.Size = new Vector2(m_header.Size.X, m_titleBackground.Size.Y); if (graphicsButton) { m_graphicsButton = new MyGuiControlButton(text: MyTexts.Get(MyCommonTexts.ScreenCaptionGraphicsOptions), onButtonClick: (sender) => { MyGuiSandbox.AddScreen(new MyGuiScreenOptionsGraphics()); }); } }
private MyGuiControlTable.Cell CreateStatusIcons(CubeGridInfo gridInfo, bool isActive) { MyGuiControlTable.Cell cell = new MyGuiControlTable.Cell(); float iconSize = m_shipsData.RowHeight * 0.7f; bool antIsActive, keyIsActive, remIsActive; antIsActive = keyIsActive = remIsActive = isActive; MyStringId antTooltip, remTooltip; antTooltip = remTooltip = MyStringId.NullOrEmpty; StringBuilder keyTooltip = new StringBuilder(); MyGuiControlParent gr = new MyGuiControlParent(); MyRefuseReason reasonT = CanTakeTerminal(gridInfo); MyRefuseReason reasonRC = CanTakeRemoteControl(gridInfo); //Antenna icon switch (reasonT) { case MyRefuseReason.PlayerBroadcastOff: antIsActive = false; antTooltip = MySpaceTexts.BroadcastScreen_TerminalButton_PlayerBroadcastOffToolTip; break; case MyRefuseReason.NoStableConnection: antIsActive = false; antTooltip = MySpaceTexts.BroadcastScreen_TerminalButton_NoStableConnectionToolTip; break; case MyRefuseReason.NoOwner: case MyRefuseReason.NoProblem: antTooltip = MySpaceTexts.BroadcastScreen_TerminalButton_StableConnectionToolTip; break; } MyGuiControlImage antenna = new MyGuiControlImage( position: new Vector2(-2 * iconSize, 0), size: new Vector2(iconSize, iconSize), originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, backgroundTexture: (antIsActive ? MyGuiConstants.BS_ANTENNA_ON : MyGuiConstants.BS_ANTENNA_OFF) ); antenna.SetToolTip(antTooltip); gr.Controls.Add(antenna); //Remote Control icon switch (reasonRC) { case MyRefuseReason.NoRemoteControl: remTooltip = MySpaceTexts.BroadcastScreen_TakeControlButton_NoRemoteToolTip; remIsActive = false; break; case MyRefuseReason.NoMainRemoteControl: remTooltip = MySpaceTexts.BroadcastScreen_TakeControlButton_NoMainRemoteControl; remIsActive = false; break; case MyRefuseReason.NoOwner: case MyRefuseReason.NoProblem: remTooltip = MySpaceTexts.BroadcastScreen_TakeControlButton_RemoteToolTip; break; } MyGuiControlImage remote = new MyGuiControlImage( position: new Vector2(-1 * iconSize, 0), size: new Vector2(iconSize, iconSize), originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, backgroundTexture: (remIsActive ? MyGuiConstants.BS_REMOTE_ON : MyGuiConstants.BS_REMOTE_OFF) ); remote.SetToolTip(remTooltip); gr.Controls.Add(remote); //Key icon if ((reasonT == MyRefuseReason.NoStableConnection || reasonT == MyRefuseReason.PlayerBroadcastOff) && reasonRC == MyRefuseReason.NoRemoteControl) { keyTooltip.Append(MyTexts.Get(MySpaceTexts.BroadcastScreen_UnavailableControlButton)); keyIsActive = false; } if (keyIsActive && (reasonT == MyRefuseReason.NoOwner || reasonRC == MyRefuseReason.NoOwner || reasonT == MyRefuseReason.NoStableConnection || reasonT == MyRefuseReason.PlayerBroadcastOff)) { keyIsActive = false; keyTooltip.Append(MyTexts.Get(MySpaceTexts.BroadcastScreen_NoOwnership)); } if (reasonT == MyRefuseReason.NoOwner) { keyTooltip.AppendLine(); keyTooltip.Append(MyTexts.Get(MySpaceTexts.DisplayName_Block_Antenna)); } if (reasonRC == MyRefuseReason.NoOwner) { keyTooltip.AppendLine(); keyTooltip.Append(MyTexts.Get(MySpaceTexts.DisplayName_Block_RemoteControl)); } if (keyIsActive) { keyTooltip.Append(MyTexts.Get(MySpaceTexts.BroadcastScreen_Ownership)); } MyGuiControlImage key = new MyGuiControlImage( size: new Vector2(iconSize, iconSize), originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, backgroundTexture: (keyIsActive ? MyGuiConstants.BS_KEY_ON : MyGuiConstants.BS_KEY_OFF) ); key.SetToolTip(keyTooltip.ToString()); gr.Controls.Add(key); cell.Control = gr; m_shipsData.Controls.Add(gr); return(cell); }
private void BuildRingMenu() { ClearControls(); Vector2 controlPadding = new Vector2(0.02f, 0.02f); float num = SCREEN_SIZE.X - HIDDEN_PART_RIGHT - controlPadding.X * 2f; BuildPluginMenuHeader(); MyGuiControlLabel listBoxLabel = new MyGuiControlLabel { Position = new Vector2(-0.153f, -0.334f), OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, Text = "List of Planets" }; MyGuiControlPanel listBoxLabelBg = new MyGuiControlPanel(new Vector2(listBoxLabel.PositionX - 0.0085f, listBoxLabel.Position.Y - 0.005f), new Vector2(0.2865f, 0.035f), null, null, null, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP) { BackgroundTexture = MyGuiConstants.TEXTURE_RECTANGLE_DARK_BORDER }; Controls.Add(listBoxLabelBg); Controls.Add(listBoxLabel); m_currentPosition.Y += 0.020f; m_planetListBox = new MyGuiControlListbox(Vector2.Zero, VRage.Game.MyGuiControlListboxStyleEnum.Blueprints); m_planetListBox.Size = new Vector2(num, 0f); m_planetListBox.Enabled = true; m_planetListBox.VisibleRowsCount = 8; m_planetListBox.Position = m_planetListBox.Size / 2f + m_currentPosition; m_planetListBox.ItemClicked += PlanetListItemClicked; m_planetListBox.MultiSelect = false; MyGuiControlSeparatorList separator = new MyGuiControlSeparatorList(); separator.AddHorizontal(new Vector2(0f, 0f) - new Vector2(m_size.Value.X * 0.83f / 2f, -0.00f), m_size.Value.X * 0.73f); Controls.Add(separator); m_currentPosition = m_planetListBox.GetPositionAbsoluteBottomLeft(); m_currentPosition.Y += 0.045f; MyGuiControlParent myGuiControlParent = new MyGuiControlParent { OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, Position = Vector2.Zero, Size = new Vector2(0.32f, 0.56f) }; MyGuiControlScrollablePanel m_optionsGroup = new MyGuiControlScrollablePanel(myGuiControlParent) { OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, Position = m_currentPosition, Size = new Vector2(0.32f, 0.32f) }; m_optionsGroup.ScrollbarVEnabled = true; m_optionsGroup.ScrollBarOffset = new Vector2(-0.01f, 0f); Controls.Add(m_optionsGroup); Vector2 vector = -myGuiControlParent.Size * 0.5f; MyGuiControlLabel ringDistLabel = new MyGuiControlLabel { Position = vector + new Vector2(0.001f, 0f), OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, Text = "Ring distance" }; myGuiControlParent.Controls.Add(ringDistLabel); m_ringDistanceValue = new MyGuiControlLabel { Position = vector + new Vector2(0.285f, 0f), OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP, Text = "0" }; myGuiControlParent.Controls.Add(m_ringDistanceValue); vector.Y += 0.025f; m_ringDistanceSlider = new MyGuiControlClickableSlider(vector + new Vector2(0.001f, 0f), 5000f, 1000000f, intValue: true, toolTip: MyPluginTexts.TOOLTIPS.ADMIN_RING_DISTANCE, showLabel: false);//Make dynamic m_ringDistanceSlider.Size = new Vector2(0.285f, 1f); m_ringDistanceSlider.DefaultValue = 100000; m_ringDistanceSlider.Value = m_ringDistanceSlider.DefaultValue.Value; m_ringDistanceSlider.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; m_ringDistanceSlider.ValueChanged = (Action <MyGuiControlSlider>) Delegate.Combine(m_ringDistanceSlider.ValueChanged, (Action <MyGuiControlSlider>) delegate(MyGuiControlSlider s) { UpdateRingVisual(); m_ringDistanceValue.Text = s.Value.ToString(); }); m_ringDistanceValue.Text = m_ringDistanceSlider.Value.ToString(); myGuiControlParent.Controls.Add(m_ringDistanceSlider); vector.Y += 0.055f; MyGuiControlLabel ringWidthLabel = new MyGuiControlLabel { Position = vector + new Vector2(0.001f, 0f), OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, Text = "Ring width" }; myGuiControlParent.Controls.Add(ringWidthLabel); m_ringWidthValue = new MyGuiControlLabel { Position = vector + new Vector2(0.285f, 0f), OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP, Text = "0" }; myGuiControlParent.Controls.Add(m_ringWidthValue); vector.Y += 0.025f; m_ringWidthSlider = new MyGuiControlClickableSlider(vector + new Vector2(0.001f, 0f), SettingsSession.Static.Settings.GeneratorSettings.PlanetSettings.RingSettings.MinPlanetRingWidth, SettingsSession.Static.Settings.GeneratorSettings.PlanetSettings.RingSettings.MaxPlanetRingWidth, intValue: true, toolTip: MyPluginTexts.TOOLTIPS.ADMIN_RING_WIDTH, showLabel: false); m_ringWidthSlider.Size = new Vector2(0.285f, 1f); m_ringWidthSlider.DefaultValue = (SettingsSession.Static.Settings.GeneratorSettings.PlanetSettings.RingSettings.MinPlanetRingWidth + SettingsSession.Static.Settings.GeneratorSettings.PlanetSettings.RingSettings.MaxPlanetRingWidth) / 2; m_ringWidthSlider.Value = m_ringWidthSlider.DefaultValue.Value; m_ringWidthSlider.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; m_ringWidthSlider.ValueChanged = (Action <MyGuiControlSlider>) Delegate.Combine(m_ringWidthSlider.ValueChanged, (Action <MyGuiControlSlider>) delegate(MyGuiControlSlider s) { UpdateRingVisual(); m_ringWidthValue.Text = s.Value.ToString(); }); m_ringWidthValue.Text = m_ringWidthSlider.Value.ToString(); myGuiControlParent.Controls.Add(m_ringWidthSlider); vector.Y += 0.055f; MyGuiControlLabel ringAngleXLabel = new MyGuiControlLabel { Position = vector + new Vector2(0.001f, 0f), OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, Text = "Ring angle X" }; myGuiControlParent.Controls.Add(ringAngleXLabel); m_ringAngleXValue = new MyGuiControlLabel { Position = vector + new Vector2(0.285f, 0f), OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP, Text = "0.00" }; myGuiControlParent.Controls.Add(m_ringAngleXValue); vector.Y += 0.025f; m_ringAngleXSlider = new MyGuiControlClickableSlider(vector + new Vector2(0.001f, 0f), -90, 90, intValue: false, toolTip: MyPluginTexts.TOOLTIPS.ADMIN_RING_ANGLE); m_ringAngleXSlider.Size = new Vector2(0.285f, 1f); m_ringAngleXSlider.DefaultValue = 0; m_ringAngleXSlider.Value = m_ringAngleXSlider.DefaultValue.Value; m_ringAngleXSlider.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; m_ringAngleXSlider.ValueChanged = (Action <MyGuiControlSlider>) Delegate.Combine(m_ringAngleXSlider.ValueChanged, (Action <MyGuiControlSlider>) delegate(MyGuiControlSlider s) { UpdateRingVisual(); m_ringAngleXValue.Text = String.Format("{0:0.00}", s.Value); }); m_ringAngleXValue.Text = String.Format("{0:0.00}", m_ringAngleXSlider.Value); myGuiControlParent.Controls.Add(m_ringAngleXSlider); vector.Y += 0.055f; MyGuiControlLabel ringAngleYLabel = new MyGuiControlLabel { Position = vector + new Vector2(0.001f, 0f), OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, Text = "Ring angle Y" }; myGuiControlParent.Controls.Add(ringAngleYLabel); m_ringAngleYValue = new MyGuiControlLabel { Position = vector + new Vector2(0.285f, 0f), OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP, Text = "0.00" }; myGuiControlParent.Controls.Add(m_ringAngleYValue); vector.Y += 0.025f; m_ringAngleYSlider = new MyGuiControlClickableSlider(vector + new Vector2(0.001f, 0f), -90, 90, intValue: false, toolTip: MyPluginTexts.TOOLTIPS.ADMIN_RING_ANGLE); m_ringAngleYSlider.Size = new Vector2(0.285f, 1f); m_ringAngleYSlider.DefaultValue = 0; m_ringAngleYSlider.Value = m_ringAngleYSlider.DefaultValue.Value; m_ringAngleYSlider.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; m_ringAngleYSlider.ValueChanged = (Action <MyGuiControlSlider>) Delegate.Combine(m_ringAngleYSlider.ValueChanged, (Action <MyGuiControlSlider>) delegate(MyGuiControlSlider s) { UpdateRingVisual(); m_ringAngleYValue.Text = String.Format("{0:0.00}", s.Value); }); m_ringAngleYValue.Text = String.Format("{0:0.00}", m_ringAngleYSlider.Value); myGuiControlParent.Controls.Add(m_ringAngleYSlider); vector.Y += 0.055f; MyGuiControlLabel ringAngleZLabel = new MyGuiControlLabel { Position = vector + new Vector2(0.001f, 0f), OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, Text = "Ring angle Z" }; myGuiControlParent.Controls.Add(ringAngleZLabel); m_ringAngleZValue = new MyGuiControlLabel { Position = vector + new Vector2(0.285f, 0f), OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP, Text = "0.00" }; myGuiControlParent.Controls.Add(m_ringAngleZValue); vector.Y += 0.025f; m_ringAngleZSlider = new MyGuiControlClickableSlider(vector + new Vector2(0.001f, 0f), -90, 90, intValue: false, toolTip: MyPluginTexts.TOOLTIPS.ADMIN_RING_ANGLE); m_ringAngleZSlider.Size = new Vector2(0.285f, 1f); m_ringAngleZSlider.DefaultValue = 0; m_ringAngleZSlider.Value = m_ringAngleZSlider.DefaultValue.Value; m_ringAngleZSlider.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; m_ringAngleZSlider.ValueChanged = (Action <MyGuiControlSlider>) Delegate.Combine(m_ringAngleZSlider.ValueChanged, (Action <MyGuiControlSlider>) delegate(MyGuiControlSlider s) { UpdateRingVisual(); m_ringAngleZValue.Text = String.Format("{0:0.00}", s.Value); }); m_ringAngleZValue.Text = String.Format("{0:0.00}", m_ringAngleZSlider.Value); myGuiControlParent.Controls.Add(m_ringAngleZSlider); vector.Y += 0.055f; MyGuiControlLabel ringRoidSizeLabel = new MyGuiControlLabel { Position = vector + new Vector2(0.001f, 0f), OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, Text = "Asteroid min size" }; myGuiControlParent.Controls.Add(ringRoidSizeLabel); m_ringRoidSizeValue = new MyGuiControlLabel { Position = vector + new Vector2(0.285f, 0f), OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP, Text = "0" }; myGuiControlParent.Controls.Add(m_ringRoidSizeValue); vector.Y += 0.025f; m_ringRoidSizeSlider = new MyGuiControlClickableSlider(vector + new Vector2(0.001f, 0f), 128, 1024, intValue: true, toolTip: MyPluginTexts.TOOLTIPS.ADMIN_RING_ROID_SIZE); m_ringRoidSizeSlider.Size = new Vector2(0.285f, 1f); m_ringRoidSizeSlider.DefaultValue = 128; m_ringRoidSizeSlider.Value = m_ringRoidSizeSlider.DefaultValue.Value; m_ringRoidSizeSlider.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; m_ringRoidSizeSlider.ValueChanged = (Action <MyGuiControlSlider>) Delegate.Combine(m_ringRoidSizeSlider.ValueChanged, (Action <MyGuiControlSlider>) delegate(MyGuiControlSlider s) { m_ringRoidSizeValue.Text = s.Value.ToString(); if (s.Value > m_ringRoidSizeMaxSlider.Value) { m_ringRoidSizeSlider.Value = m_ringRoidSizeMaxSlider.Value; } }); m_ringRoidSizeValue.Text = m_ringRoidSizeSlider.Value.ToString(); myGuiControlParent.Controls.Add(m_ringRoidSizeSlider); vector.Y += 0.055f; MyGuiControlLabel ringRoidSizeMaxLabel = new MyGuiControlLabel { Position = vector + new Vector2(0.001f, 0f), OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, Text = "Asteroid max size" }; myGuiControlParent.Controls.Add(ringRoidSizeMaxLabel); m_ringRoidSizeMaxValue = new MyGuiControlLabel { Position = vector + new Vector2(0.285f, 0f), OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP, Text = "0" }; myGuiControlParent.Controls.Add(m_ringRoidSizeMaxValue); vector.Y += 0.025f; m_ringRoidSizeMaxSlider = new MyGuiControlClickableSlider(vector + new Vector2(0.001f, 0f), 128, 1024, intValue: true, toolTip: MyPluginTexts.TOOLTIPS.ADMIN_RING_ROID_SIZE_MAX); m_ringRoidSizeMaxSlider.Size = new Vector2(0.285f, 1f); m_ringRoidSizeMaxSlider.DefaultValue = 1028; m_ringRoidSizeMaxSlider.Value = m_ringRoidSizeSlider.DefaultValue.Value; m_ringRoidSizeMaxSlider.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; m_ringRoidSizeMaxSlider.ValueChanged = (Action <MyGuiControlSlider>) Delegate.Combine(m_ringRoidSizeMaxSlider.ValueChanged, (Action <MyGuiControlSlider>) delegate(MyGuiControlSlider s) { m_ringRoidSizeMaxValue.Text = s.Value.ToString(); if (s.Value < m_ringRoidSizeSlider.Value) { m_ringRoidSizeMaxSlider.Value = m_ringRoidSizeSlider.Value; } }); m_ringRoidSizeMaxValue.Text = m_ringRoidSizeMaxSlider.Value.ToString(); myGuiControlParent.Controls.Add(m_ringRoidSizeMaxSlider); m_optionsGroup.RefreshInternals(); m_currentPosition.Y += m_optionsGroup.Size.Y; MyGuiControlSeparatorList separator2 = new MyGuiControlSeparatorList(); separator2.AddHorizontal(new Vector2(0f, 0f) - new Vector2(m_size.Value.X * 0.83f / 2f, -0.00f), m_size.Value.X * 0.73f); Controls.Add(separator2); m_addRingButton = CreateDebugButton(0.284f, "Add ring to planet", OnAddRingToPlanetButton, true, MyPluginTexts.TOOLTIPS.ADMIN_ADD_RING_BUTTON); m_currentPosition.Y += 0.003f; m_removeRingButton = CreateDebugButton(0.284f, "Remove ring from planet", OnRemoveRingFromPlanetButton, true, MyPluginTexts.TOOLTIPS.ADMIN_REMOVE_RING_BUTTON); m_currentPosition.Y += 0.003f; m_teleportToRingButton = CreateDebugButton(0.284f, "Teleport to ring", OnTeleportToRingButton, true, MyPluginTexts.TOOLTIPS.ADMIN_TP_RING_BUTTON); m_teleportToRingButton.Enabled = false; Controls.Add(m_planetListBox); m_ringAngleXSlider.Enabled = false; m_ringAngleYSlider.Enabled = false; m_ringAngleZSlider.Enabled = false; m_ringDistanceSlider.Enabled = false; m_ringWidthSlider.Enabled = false; m_ringRoidSizeSlider.Enabled = false; m_addRingButton.Enabled = false; m_removeRingButton.Enabled = false; m_teleportToRingButton.Enabled = false; LoadPlanetsInWorld(); }
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); } }
/// <summary> /// Builds the plugin settings controls from top to bottom. /// </summary> public void BuildControls() { Vector2 vector = new Vector2(50f) / MyGuiConstants.GUI_OPTIMAL_SIZE; float x2 = 0.209375018f; int mod = m_isNewGame ? 6 : 0; AddCaption("SEWorldGenPlugin Settings", null, new Vector2(0f, 0.003f)); MyGuiControlParent parent = new MyGuiControlParent(null, new Vector2(base.Size.Value.X - vector.X * 2f, 0.052f * (15 + mod))); parent.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; MyGuiControlSeparatorList myGuiControlSeparatorList = new MyGuiControlSeparatorList(); myGuiControlSeparatorList.AddHorizontal(new Vector2(0f, 0f) - new Vector2(m_size.Value.X * 0.835f / 2f, m_size.Value.Y / 2f - 0.075f), m_size.Value.X * 0.835f); Controls.Add(myGuiControlSeparatorList); MyGuiControlSeparatorList myGuiControlSeparatorList2 = new MyGuiControlSeparatorList(); myGuiControlSeparatorList2.AddHorizontal(new Vector2(0f, 0f) - new Vector2(m_size.Value.X * 0.835f / 2f, (0f - m_size.Value.Y) / 2f + 0.123f), m_size.Value.X * 0.835f); Controls.Add(myGuiControlSeparatorList2); m_useGlobalSettignsLabel = MakeLabel("Use global Config"); m_useSemiRandomGenerationLabel = MakeLabel("Use all planets"); m_useVanillaPlanetsLabel = MakeLabel("Use vanilla planets"); m_planetsOnlyOnceLabel = MakeLabel("Generate Planets Once"); m_moonsOnlyOnceLabel = MakeLabel("Generate Moons Once"); m_planetGpsLabel = MakeLabel("Create GPS for Planets"); m_moonGpsLabel = MakeLabel("Create GPS for Moons"); m_beltGpsLabel = MakeLabel("Create GPS for Belts"); m_ringGpsLabel = MakeLabel("Create GPS for Rings"); m_asteroidGeneratorLabel = MakeLabel("Asteroid generator"); m_asteroidDensityLabel = MakeLabel("Asteroid density"); m_objAmountLabel = MakeLabel("Objects in System"); m_orbDistanceLabel = MakeLabel("Average Orbit distance"); m_sizeMultiplierLabel = MakeLabel("Planet size multiplier"); m_sizeCapLabel = MakeLabel("Planet size cap"); m_moonProbLabel = MakeLabel("Moon spawn probability"); m_ringWidthLabel = MakeLabel("Average ring width"); m_ringProbLabel = MakeLabel("Ring spawn probability"); m_beltHeightLabel = MakeLabel("Average belt height"); m_beltProbLabel = MakeLabel("Belt spawn probability"); m_worldSizeLabel = MakeLabel("World Size"); m_useGlobalCheck = new MyGuiControlCheckbox(); m_useSemiRandomGenerationCheck = new MyGuiControlCheckbox(); m_useVanillaPlanetsCheck = new MyGuiControlCheckbox(); m_planetsOnlyOnceCheck = new MyGuiControlCheckbox(); m_moonsOnlyOnceCheck = new MyGuiControlCheckbox(); m_planetGpsCheck = new MyGuiControlCheckbox(); m_moonGpsCheck = new MyGuiControlCheckbox(); m_beltGpsCheck = new MyGuiControlCheckbox(); m_ringGpsCheck = new MyGuiControlCheckbox(); m_asteroidGeneratorCombo = new MyGuiControlCombobox(null, new Vector2(x2, 0.04f)); x2 += 0.05f; m_asteroidDensitySlider = new MyGuiControlClickableSlider(Vector2.Zero, 0.1f, 1f, x2, 0.6f, null, null, 0, 0.8f, 0.05f, "White", MyPluginTexts.TOOLTIPS.ROID_DENS_SLIDER, MyGuiControlSliderStyleEnum.Default, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, intValue: false); m_objAmountSlider = new MyGuiControlClickableSlider(Vector2.Zero, 0f, 100f, x2, 15f, null, null, 0, 0.8f, 0.05f, "White", MyPluginTexts.TOOLTIPS.SYS_OBJ_SLIDER, MyGuiControlSliderStyleEnum.Default, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, intValue: true); m_orbDistanceSlider = new MyGuiControlClickableSlider(Vector2.Zero, 500f, 100000f, x2, 50500f, null, null, 0, 0.8f, 0.05f, "White", MyPluginTexts.TOOLTIPS.ORB_DIST_SLIDER, MyGuiControlSliderStyleEnum.Default, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, intValue: true); m_sizeMultiplierSlider = new MyGuiControlClickableSlider(Vector2.Zero, 1f, 10f, x2, 2f, null, null, 0, 0.8f, 0.05f, "White", MyPluginTexts.TOOLTIPS.SIZE_MUL_SLIDER, MyGuiControlSliderStyleEnum.Default, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, intValue: true); m_sizeCapSlider = new MyGuiControlClickableSlider(Vector2.Zero, 120f, 2400f, x2, 1200f, null, null, 0, 0.8f, 0.05f, "White", MyPluginTexts.TOOLTIPS.SIZE_CAP_SLIDER, MyGuiControlSliderStyleEnum.Default, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, intValue: true); m_moonProbSlider = new MyGuiControlClickableSlider(Vector2.Zero, 0f, 1f, x2, 0.5f, null, null, 0, 0.8f, 0.05f, "White", MyPluginTexts.TOOLTIPS.MOON_PROB_SLIDER, MyGuiControlSliderStyleEnum.Default, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, intValue: false); m_ringWidthSlider = new MyGuiControlClickableSlider(Vector2.Zero, 10000f, 100000f, x2, 15000f, null, null, 0, 0.8f, 0.05f, "White", MyPluginTexts.TOOLTIPS.RING_WIDTH_SLIDER, MyGuiControlSliderStyleEnum.Default, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, intValue: true); m_ringProbSlider = new MyGuiControlClickableSlider(Vector2.Zero, 0f, 1f, x2, 0.5f, null, null, 0, 0.8f, 0.05f, "White", MyPluginTexts.TOOLTIPS.RING_PROB_SLIDER, MyGuiControlSliderStyleEnum.Default, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, intValue: false); m_beltHeightSlider = new MyGuiControlClickableSlider(Vector2.Zero, 4000f, 40000f, x2, 22000f, null, null, 0, 0.8f, 0.05f, "White", MyPluginTexts.TOOLTIPS.BELT_HEIGHT_SLIDER, MyGuiControlSliderStyleEnum.Default, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, intValue: true); m_beltProbSlider = new MyGuiControlClickableSlider(Vector2.Zero, 0f, 1f, x2, 0.4f, null, null, 0, 0.8f, 0.05f, "White", MyPluginTexts.TOOLTIPS.BELT_PROB_SLIDER, MyGuiControlSliderStyleEnum.Default, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, intValue: false); m_worldSizeSlider = new MyGuiControlClickableSlider(Vector2.Zero, -1f, 1000000 - 1, x2, -1, null, null, 0, 0.8f, 0.05f, "White", MyPluginTexts.TOOLTIPS.WORLD_SIZE_SLIDER, MyGuiControlSliderStyleEnum.Default, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, intValue: true); m_asteroidDensityValue = MakeLabel(String.Format("{0:0.00}", m_asteroidDensitySlider.Value)); m_asteroidDensityValue.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER; m_objAmountValue = MakeLabel(m_objAmountSlider.Value.ToString()); m_objAmountValue.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER; m_orbDistanceValue = MakeLabel(m_orbDistanceSlider.Value.ToString()); m_orbDistanceValue.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER; m_sizeMultiplierValue = MakeLabel(m_sizeMultiplierSlider.Value.ToString()); m_sizeMultiplierValue.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER; m_sizeCapValue = MakeLabel(m_sizeCapSlider.Value.ToString()); m_sizeCapValue.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER; m_moonProbValue = MakeLabel(String.Format("{0:0.00}", m_moonProbSlider.Value)); m_moonProbValue.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER; m_ringWidthValue = MakeLabel(m_ringWidthSlider.Value.ToString()); m_ringWidthValue.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER; m_ringProbValue = MakeLabel(m_ringProbSlider.Value.ToString()); m_ringProbValue.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER; m_beltHeightValue = MakeLabel(m_beltHeightSlider.Value.ToString()); m_beltHeightValue.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER; m_beltProbValue = MakeLabel(String.Format("{0:0.00}", m_beltProbSlider.Value)); m_beltProbValue.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER; m_useGlobalCheck.SetToolTip(MyPluginTexts.TOOLTIPS.USE_GLOBAL_CHECK); m_useGlobalCheck.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER; m_useSemiRandomGenerationCheck.SetToolTip(MyPluginTexts.TOOLTIPS.USE_SEMI_RAND_GEN_CHECK); m_useSemiRandomGenerationCheck.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER; m_useVanillaPlanetsCheck.SetToolTip(MyPluginTexts.TOOLTIPS.USE_VANILLA_PLANETS); m_useVanillaPlanetsCheck.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER; m_planetsOnlyOnceCheck.SetToolTip(MyPluginTexts.TOOLTIPS.PLANETS_ONLY_ONCE); m_planetsOnlyOnceCheck.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER; m_moonsOnlyOnceCheck.SetToolTip(MyPluginTexts.TOOLTIPS.MOONS_ONLY_ONCE); m_moonsOnlyOnceCheck.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER; m_planetGpsCheck.SetToolTip(MyPluginTexts.TOOLTIPS.PLANET_GPSL_CHECK); m_planetGpsCheck.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER; m_moonGpsCheck.SetToolTip(MyPluginTexts.TOOLTIPS.MOON_GPS_CHECK); m_moonGpsCheck.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER; m_beltGpsCheck.SetToolTip(MyPluginTexts.TOOLTIPS.BELT_GPS_CHECK); m_beltGpsCheck.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER; m_ringGpsCheck.SetToolTip(MyPluginTexts.TOOLTIPS.RING_GPS_CHECK); m_ringGpsCheck.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER; m_asteroidGeneratorCombo.SetToolTip(MyPluginTexts.TOOLTIPS.ROID_GEN_COMBO); m_asteroidGeneratorCombo.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER; m_worldSizeValue = MakeLabel(m_worldSizeSlider.Value.ToString()); m_worldSizeValue.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER; m_asteroidGeneratorCombo.AddItem(0L, "Plugin"); m_asteroidGeneratorCombo.AddItem(1L, "Vanilla"); m_asteroidGeneratorCombo.AddItem(2L, "Mixed"); m_asteroidGeneratorCombo.SelectItemByIndex(0); m_asteroidGeneratorCombo.ItemSelected += delegate { bool val = m_asteroidGeneratorCombo.GetSelectedKey() == 01L; m_beltGpsCheck.Enabled = !val; m_ringProbSlider.Enabled = !val; m_ringWidthSlider.Enabled = !val; m_beltHeightSlider.Enabled = !val; m_beltProbSlider.Enabled = !val; m_asteroidDensitySlider.Enabled = !val; }; m_asteroidDensitySlider.ValueChanged = (Action <MyGuiControlSlider>) Delegate.Combine(m_asteroidDensitySlider.ValueChanged, (Action <MyGuiControlSlider>) delegate(MyGuiControlSlider s) { m_asteroidDensityValue.Text = String.Format("{0:0.00}", s.Value); }); m_objAmountSlider.ValueChanged = (Action <MyGuiControlSlider>) Delegate.Combine(m_objAmountSlider.ValueChanged, (Action <MyGuiControlSlider>) delegate(MyGuiControlSlider s) { m_objAmountValue.Text = s.Value.ToString(); }); m_orbDistanceSlider.ValueChanged = (Action <MyGuiControlSlider>) Delegate.Combine(m_orbDistanceSlider.ValueChanged, (Action <MyGuiControlSlider>) delegate(MyGuiControlSlider s) { m_orbDistanceValue.Text = s.Value.ToString(); }); m_sizeMultiplierSlider.ValueChanged = (Action <MyGuiControlSlider>) Delegate.Combine(m_sizeMultiplierSlider.ValueChanged, (Action <MyGuiControlSlider>) delegate(MyGuiControlSlider s) { m_sizeMultiplierValue.Text = s.Value.ToString(); }); m_sizeCapSlider.ValueChanged = (Action <MyGuiControlSlider>) Delegate.Combine(m_sizeCapSlider.ValueChanged, (Action <MyGuiControlSlider>) delegate(MyGuiControlSlider s) { m_sizeCapValue.Text = s.Value.ToString(); }); m_moonProbSlider.ValueChanged = (Action <MyGuiControlSlider>) Delegate.Combine(m_moonProbSlider.ValueChanged, (Action <MyGuiControlSlider>) delegate(MyGuiControlSlider s) { m_moonProbValue.Text = String.Format("{0:0.00}", s.Value); }); m_ringWidthSlider.ValueChanged = (Action <MyGuiControlSlider>) Delegate.Combine(m_ringWidthSlider.ValueChanged, (Action <MyGuiControlSlider>) delegate(MyGuiControlSlider s) { m_ringWidthValue.Text = s.Value.ToString(); }); m_ringProbSlider.ValueChanged = (Action <MyGuiControlSlider>) Delegate.Combine(m_ringProbSlider.ValueChanged, (Action <MyGuiControlSlider>) delegate(MyGuiControlSlider s) { m_ringProbValue.Text = String.Format("{0:0.00}", s.Value); }); m_beltHeightSlider.ValueChanged = (Action <MyGuiControlSlider>) Delegate.Combine(m_beltHeightSlider.ValueChanged, (Action <MyGuiControlSlider>) delegate(MyGuiControlSlider s) { m_beltHeightValue.Text = s.Value.ToString(); }); m_beltProbSlider.ValueChanged = (Action <MyGuiControlSlider>) Delegate.Combine(m_beltProbSlider.ValueChanged, (Action <MyGuiControlSlider>) delegate(MyGuiControlSlider s) { m_beltProbValue.Text = String.Format("{0:0.000}", s.Value); }); m_worldSizeSlider.ValueChanged = (Action <MyGuiControlSlider>) Delegate.Combine(m_worldSizeSlider.ValueChanged, (Action <MyGuiControlSlider>) delegate(MyGuiControlSlider s) { if (s.Value < 0) { m_worldSizeValue.Text = "Infinite"; } else { m_worldSizeValue.Text = s.Value.ToString(); } }); m_useGlobalCheck.IsCheckedChanged = (Action <MyGuiControlCheckbox>) Delegate.Combine(m_useGlobalCheck.IsCheckedChanged, (Action <MyGuiControlCheckbox>) delegate(MyGuiControlCheckbox s) { m_useSemiRandomGenerationCheck.Enabled = !s.IsChecked; m_useVanillaPlanetsCheck.Enabled = !s.IsChecked; m_planetsOnlyOnceCheck.Enabled = !s.IsChecked; m_moonsOnlyOnceCheck.Enabled = !s.IsChecked; m_objAmountSlider.Enabled = !s.IsChecked; m_asteroidDensitySlider.Enabled = !s.IsChecked; m_asteroidGeneratorCombo.Enabled = !s.IsChecked; m_orbDistanceSlider.Enabled = !s.IsChecked; m_sizeMultiplierSlider.Enabled = !s.IsChecked; m_sizeCapSlider.Enabled = !s.IsChecked; m_moonProbSlider.Enabled = !s.IsChecked; m_ringWidthSlider.Enabled = !s.IsChecked; m_ringProbSlider.Enabled = !s.IsChecked; m_beltHeightSlider.Enabled = !s.IsChecked; m_beltProbSlider.Enabled = !s.IsChecked; m_planetGpsCheck.Enabled = !s.IsChecked; m_moonGpsCheck.Enabled = !s.IsChecked; m_beltGpsCheck.Enabled = !s.IsChecked; m_ringGpsCheck.Enabled = !s.IsChecked; m_worldSizeSlider.Enabled = !s.IsChecked && m_isNewGame; }); parent.Controls.Add(m_useGlobalSettignsLabel); parent.Controls.Add(m_useGlobalCheck); if (m_isNewGame) { parent.Controls.Add(m_useSemiRandomGenerationLabel); parent.Controls.Add(m_useSemiRandomGenerationCheck); parent.Controls.Add(m_useVanillaPlanetsLabel); parent.Controls.Add(m_useVanillaPlanetsCheck); parent.Controls.Add(m_planetsOnlyOnceLabel); parent.Controls.Add(m_planetsOnlyOnceCheck); parent.Controls.Add(m_moonsOnlyOnceLabel); parent.Controls.Add(m_moonsOnlyOnceCheck); parent.Controls.Add(m_planetGpsLabel); parent.Controls.Add(m_planetGpsCheck); parent.Controls.Add(m_moonGpsLabel); parent.Controls.Add(m_moonGpsCheck); } parent.Controls.Add(m_beltGpsLabel); parent.Controls.Add(m_beltGpsCheck); parent.Controls.Add(m_ringGpsLabel); parent.Controls.Add(m_ringGpsCheck); parent.Controls.Add(m_asteroidGeneratorLabel); parent.Controls.Add(m_asteroidGeneratorCombo); parent.Controls.Add(m_asteroidDensityLabel); parent.Controls.Add(m_asteroidDensitySlider); parent.Controls.Add(m_asteroidDensityValue); parent.Controls.Add(m_objAmountLabel); parent.Controls.Add(m_objAmountSlider); parent.Controls.Add(m_objAmountValue); parent.Controls.Add(m_orbDistanceLabel); parent.Controls.Add(m_orbDistanceSlider); parent.Controls.Add(m_orbDistanceValue); parent.Controls.Add(m_sizeMultiplierLabel); parent.Controls.Add(m_sizeMultiplierSlider); parent.Controls.Add(m_sizeMultiplierValue); parent.Controls.Add(m_sizeCapLabel); parent.Controls.Add(m_sizeCapSlider); parent.Controls.Add(m_sizeCapValue); parent.Controls.Add(m_moonProbLabel); parent.Controls.Add(m_moonProbSlider); parent.Controls.Add(m_moonProbValue); parent.Controls.Add(m_ringWidthLabel); parent.Controls.Add(m_ringWidthSlider); parent.Controls.Add(m_ringWidthValue); parent.Controls.Add(m_ringProbLabel); parent.Controls.Add(m_ringProbSlider); parent.Controls.Add(m_ringProbValue); parent.Controls.Add(m_beltHeightLabel); parent.Controls.Add(m_beltHeightSlider); parent.Controls.Add(m_beltHeightValue); parent.Controls.Add(m_beltProbLabel); parent.Controls.Add(m_beltProbSlider); parent.Controls.Add(m_beltProbValue); parent.Controls.Add(m_worldSizeLabel); parent.Controls.Add(m_worldSizeSlider); parent.Controls.Add(m_worldSizeValue); //Vector2 start = (new Vector2(0f, (!m_isNewGame) ? 0.052f : 0.026f) - new Vector2(m_size.Value.X * 0.835f / 2f, m_size.Value.Y / 2f - 0.075f)) + (new Vector2(0f, m_useGlobalSettignsLabel.Size.Y)); Vector2 start = Vector2.Zero - new Vector2(parent.Size.X / 2f, parent.Size.Y / 2f - 0.028f); Vector2 offset = new Vector2(0f, 0.050f);//0.028f Vector2 offset2 = new Vector2(m_orbDistanceLabel.Size.X * 1.5f, 0f); Vector2 offset3 = new Vector2(0.4973214f, 0f); int m = 0; m_useGlobalSettignsLabel.Position = start + offset * m++; m_useGlobalCheck.Position = m_useGlobalSettignsLabel.Position + offset2; if (m_isNewGame) { m_useSemiRandomGenerationLabel.Position = start + offset * m++; m_useSemiRandomGenerationCheck.Position = m_useSemiRandomGenerationLabel.Position + offset2; m_useVanillaPlanetsLabel.Position = start + offset * m++; m_useVanillaPlanetsCheck.Position = m_useVanillaPlanetsLabel.Position + offset2; m_planetsOnlyOnceLabel.Position = start + offset * m++; m_planetsOnlyOnceCheck.Position = m_planetsOnlyOnceLabel.Position + offset2; m_moonsOnlyOnceLabel.Position = start + offset * m++; m_moonsOnlyOnceCheck.Position = m_moonsOnlyOnceLabel.Position + offset2; m_planetGpsLabel.Position = start + offset * m++; m_planetGpsCheck.Position = m_planetGpsLabel.Position + offset2; m_moonGpsLabel.Position = start + offset * m++; m_moonGpsCheck.Position = m_moonGpsLabel.Position + offset2; } m_beltGpsLabel.Position = start + offset * m++; m_beltGpsCheck.Position = m_beltGpsLabel.Position + offset2; m_ringGpsLabel.Position = start + offset * m++; m_ringGpsCheck.Position = m_ringGpsLabel.Position + offset2; m_asteroidGeneratorLabel.Position = start + offset * m++; m_asteroidGeneratorCombo.Position = m_asteroidGeneratorLabel.Position + offset2; m_asteroidDensityLabel.Position = start + offset * m++; m_asteroidDensitySlider.Position = m_asteroidDensityLabel.Position + offset2; m_asteroidDensityValue.Position = m_asteroidDensityLabel.Position + offset3; m_objAmountLabel.Position = start + offset * m++; m_objAmountSlider.Position = m_objAmountLabel.Position + offset2; m_objAmountValue.Position = m_objAmountLabel.Position + offset3; m_orbDistanceLabel.Position = start + offset * m++; m_orbDistanceSlider.Position = m_orbDistanceLabel.Position + offset2; m_orbDistanceValue.Position = m_orbDistanceLabel.Position + offset3; m_sizeMultiplierLabel.Position = start + offset * m++; m_sizeMultiplierSlider.Position = m_sizeMultiplierLabel.Position + offset2; m_sizeMultiplierValue.Position = m_sizeMultiplierLabel.Position + offset3; m_sizeCapLabel.Position = start + offset * m++; m_sizeCapSlider.Position = m_sizeCapLabel.Position + offset2; m_sizeCapValue.Position = m_sizeCapLabel.Position + offset3; m_moonProbLabel.Position = start + offset * m++; m_moonProbSlider.Position = m_moonProbLabel.Position + offset2; m_moonProbValue.Position = m_moonProbLabel.Position + offset3; m_ringWidthLabel.Position = start + offset * m++; m_ringWidthSlider.Position = m_ringWidthLabel.Position + offset2; m_ringWidthValue.Position = m_ringWidthLabel.Position + offset3; m_ringProbLabel.Position = start + offset * m++; m_ringProbSlider.Position = m_ringProbLabel.Position + offset2; m_ringProbValue.Position = m_ringProbLabel.Position + offset3; m_beltHeightLabel.Position = start + offset * m++; m_beltHeightSlider.Position = m_beltHeightLabel.Position + offset2; m_beltHeightValue.Position = m_beltHeightLabel.Position + offset3; m_beltProbLabel.Position = start + offset * m++; m_beltProbSlider.Position = m_beltProbLabel.Position + offset2; m_beltProbValue.Position = m_beltProbLabel.Position + offset3; m_worldSizeLabel.Position = start + offset * m++; m_worldSizeSlider.Position = m_worldSizeLabel.Position + offset2; m_worldSizeValue.Position = m_worldSizeLabel.Position + offset3; m_okButton = new MyGuiControlButton(null, VRage.Game.MyGuiControlButtonStyleEnum.Default, null, null, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, null, VRage.MyTexts.Get(MyCommonTexts.Ok), 0.8f, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyGuiControlHighlightType.WHEN_ACTIVE, OkButtonClicked); m_okButton.SetToolTip(VRage.MyTexts.GetString(MySpaceTexts.ToolTipOptionsSpace_Ok)); m_okButton.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM; m_okButton.Position = (m_size.Value / 2f - vector) * new Vector2(0f, 1f) + new Vector2(0f - 25f, 0f) / MyGuiConstants.GUI_OPTIMAL_SIZE; MyGuiControlScrollablePanel scrollPane = new MyGuiControlScrollablePanel(parent); scrollPane.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; scrollPane.ScrollbarVEnabled = true; scrollPane.Size = new Vector2(base.Size.Value.X - vector.X * 2f - 0.035f, 0.74f); scrollPane.Position = new Vector2(-0.27f, -0.394f); if (!m_isNewGame) { m_worldSizeSlider.Enabled = false; } Controls.Add(m_okButton); Controls.Add(scrollPane); }
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() { 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(); }
public override void RecreateControls(bool constructor) { base.RecreateControls(constructor); var layout = new MyLayoutTable(this); layout.SetColumnWidthsNormalized(50, 300, 300, 300, 300, 300, 50); layout.SetRowHeightsNormalized(50, 450, 70, 70, 70, 400, 70, 70, 50); //BRIEFING: MyGuiControlParent briefing = new MyGuiControlParent(); var briefingScrollableArea = new MyGuiControlScrollablePanel( scrolledControl: briefing) { Name = "BriefingScrollableArea", ScrollbarVEnabled = true, OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, BackgroundTexture = MyGuiConstants.TEXTURE_SCROLLABLE_LIST, ScrolledAreaPadding = new MyGuiBorderThickness(0.005f), }; layout.AddWithSize(briefingScrollableArea, MyAlignH.Left, MyAlignV.Top, 1, 1, rowSpan: 4, colSpan: 3); //inside scrollable area: m_descriptionBox = new MyGuiControlMultilineText( position: new Vector2(-0.227f, 5f), size: new Vector2(briefingScrollableArea.Size.X - 0.02f, 11f), textBoxAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, selectable: false); briefing.Controls.Add(m_descriptionBox); m_connectedPlayers = new MyGuiControlTable(); m_connectedPlayers.Size = new Vector2(490f, 150f) / MyGuiConstants.GUI_OPTIMAL_SIZE; m_connectedPlayers.VisibleRowsCount = 8; m_connectedPlayers.ColumnsCount = 2; m_connectedPlayers.SetCustomColumnWidths(new float[] { 0.7f, 0.3f }); m_connectedPlayers.SetColumnName(0, MyTexts.Get(MySpaceTexts.GuiScenarioPlayerName)); m_connectedPlayers.SetColumnName(1, MyTexts.Get(MySpaceTexts.GuiScenarioPlayerStatus)); m_kickPlayerButton = new MyGuiControlButton(text: MyTexts.Get(MyCommonTexts.Kick), visualStyle: MyGuiControlButtonStyleEnum.Rectangular, highlightType: MyGuiControlHighlightType.WHEN_ACTIVE, size: new Vector2(190f, 48f) / MyGuiConstants.GUI_OPTIMAL_SIZE, onButtonClick: OnKick2Clicked); m_kickPlayerButton.Enabled = CanKick(); m_timeoutLabel = new MyGuiControlLabel(text: MyTexts.GetString(MySpaceTexts.GuiScenarioTimeout), originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); TimeoutCombo = new MyGuiControlCombobox(); TimeoutCombo.ItemSelected += OnTimeoutSelected; TimeoutCombo.AddItem(3, MyTexts.Get(MySpaceTexts.GuiScenarioTimeout3min)); TimeoutCombo.AddItem(5, MyTexts.Get(MySpaceTexts.GuiScenarioTimeout5min)); TimeoutCombo.AddItem(10, MyTexts.Get(MySpaceTexts.GuiScenarioTimeout10min)); TimeoutCombo.AddItem(-1, MyTexts.Get(MySpaceTexts.GuiScenarioTimeoutUnlimited)); TimeoutCombo.SelectItemByIndex(0); TimeoutCombo.Enabled = Sync.IsServer; m_canJoinRunningLabel = new MyGuiControlLabel(text: MyTexts.GetString(MySpaceTexts.ScenarioSettings_CanJoinRunningShort), originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); m_canJoinRunning = new MyGuiControlCheckbox(); m_canJoinRunningLabel.Enabled = false; m_canJoinRunning.Enabled = false; m_startButton = new MyGuiControlButton(text: MyTexts.Get(MySpaceTexts.GuiScenarioStart), visualStyle: MyGuiControlButtonStyleEnum.Rectangular, highlightType: MyGuiControlHighlightType.WHEN_ACTIVE, size: new Vector2(200, 48f) / MyGuiConstants.GUI_OPTIMAL_SIZE, onButtonClick: OnStartClicked); m_startButton.Enabled = Sync.IsServer; m_chatControl = new MyHudControlChat( MyHud.Chat, size: new Vector2(1400f, 300f) / MyGuiConstants.GUI_OPTIMAL_SIZE, font: MyFontEnum.DarkBlue, textScale: 0.7f, textAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM, backgroundColor: MyGuiConstants.THEMED_GUI_BACKGROUND_COLOR, contents: null, drawScrollbar: true, textBoxAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM); m_chatControl.BorderEnabled = true; m_chatControl.BorderColor = Color.CornflowerBlue; m_chatTextbox = new MyGuiControlTextbox(maxLength: ChatMessageBuffer.MAX_MESSAGE_SIZE); m_chatTextbox.Size = new Vector2(1400f, 48f) / MyGuiConstants.GUI_OPTIMAL_SIZE; m_chatTextbox.TextScale = 0.8f; m_chatTextbox.VisualStyle = MyGuiControlTextboxStyleEnum.Default; m_chatTextbox.EnterPressed += ChatTextbox_EnterPressed; m_sendChatButton = new MyGuiControlButton(text: MyTexts.Get(MySpaceTexts.GuiScenarioSend), visualStyle: MyGuiControlButtonStyleEnum.Rectangular, highlightType: MyGuiControlHighlightType.WHEN_ACTIVE, size: new Vector2(190f, 48f) / MyGuiConstants.GUI_OPTIMAL_SIZE, onButtonClick: OnSendChatClicked); layout.AddWithSize(m_connectedPlayers, MyAlignH.Left, MyAlignV.Top, 1, 4, rowSpan: 2, colSpan: 2); layout.AddWithSize(m_kickPlayerButton, MyAlignH.Left, MyAlignV.Center, 2, 5); layout.AddWithSize(m_timeoutLabel, MyAlignH.Left, MyAlignV.Center, 3, 4); layout.AddWithSize(TimeoutCombo, MyAlignH.Left, MyAlignV.Center, 3, 5); layout.AddWithSize(m_canJoinRunningLabel, MyAlignH.Left, MyAlignV.Center, 4, 4); layout.AddWithSize(m_canJoinRunning, MyAlignH.Right, MyAlignV.Center, 4, 5); layout.AddWithSize(m_chatControl, MyAlignH.Left, MyAlignV.Top, 5, 1, rowSpan: 1, colSpan: 5); layout.AddWithSize(m_chatTextbox, MyAlignH.Left, MyAlignV.Top, 6, 1, rowSpan: 1, colSpan: 4); layout.AddWithSize(m_sendChatButton, MyAlignH.Right, MyAlignV.Top, 6, 5); layout.AddWithSize(m_startButton, MyAlignH.Left, MyAlignV.Top, 7, 2); }
protected virtual void BuildControls() { AddCaption(ScreenCaption); // side menu { var nameLabel = MakeLabel(MySpaceTexts.Name); var descriptionLabel = MakeLabel(MySpaceTexts.Description); 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; Vector2 originL; Vector2 controlsDelta = new Vector2(0f, 0.052f); originL = -m_size.Value / 2 + new Vector2(MARGIN_LEFT, MARGIN_TOP); var screenSize = m_size.Value; var layoutSize = screenSize / 2 - originL; var columnWidthLabel = layoutSize.X * 0.25f; var columnWidthControl = layoutSize.X - columnWidthLabel; var rowHeight = 0.052f; layoutSize.Y = rowHeight * 5; m_sideMenuLayout = new MyLayoutTable(this, originL, layoutSize); m_sideMenuLayout.SetColumnWidthsNormalized(columnWidthLabel, columnWidthControl); m_sideMenuLayout.SetRowHeightsNormalized(rowHeight, rowHeight, rowHeight, rowHeight, rowHeight); m_sideMenuLayout.Add(nameLabel, MyAlignH.Left, MyAlignV.Top, 0, 0); m_sideMenuLayout.Add(m_nameTextbox, MyAlignH.Left, MyAlignV.Top, 0, 1); m_sideMenuLayout.Add(descriptionLabel, MyAlignH.Left, MyAlignV.Top, 1, 0); m_sideMenuLayout.Add(m_descriptionTextbox, MyAlignH.Left, MyAlignV.Top, 1, 1); } // briefing { MyGuiControlParent briefing = new MyGuiControlParent(); 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.287f, 5f), size: new Vector2(briefingScrollableArea.Size.X - 0.02f, 11f), selectable: false); briefing.Controls.Add(m_descriptionBox); } // buttons { int buttonRowCount = 2; int buttonColumnCount = 4; Vector2 buttonSize = new Vector2(300f / 1600f, 70f / 1200f); Vector2 buttonsOrigin = m_size.Value / 2 - new Vector2(0.83f, 0.16f); Vector2 buttonOffset = new Vector2(0.01f, 0.01f); Vector2 buttonLayoutSize = new Vector2((buttonSize.X + buttonOffset.X) * (buttonColumnCount), (buttonSize.Y + buttonOffset.Y) * (buttonRowCount)); m_buttonsLayout = new MyLayoutTable(this, buttonsOrigin, buttonLayoutSize); float[] columnWidths = Enumerable.Repeat(buttonSize.X + buttonOffset.X, buttonColumnCount).ToArray(); m_buttonsLayout.SetColumnWidthsNormalized(columnWidths); float[] rowHeights = Enumerable.Repeat(buttonSize.Y + buttonOffset.Y, buttonRowCount).ToArray(); m_buttonsLayout.SetRowHeightsNormalized(rowHeights); m_okButton = new MyGuiControlButton(text: MyTexts.Get(MySpaceTexts.Ok), onButtonClick: OnOkButtonClick); m_cancelButton = new MyGuiControlButton(text: MyTexts.Get(MySpaceTexts.Cancel), onButtonClick: OnCancelButtonClick); m_buttonsLayout.Add(m_okButton, MyAlignH.Left, MyAlignV.Top, 1, 2); m_buttonsLayout.Add(m_cancelButton, MyAlignH.Left, MyAlignV.Top, 1, 3); } // left menu { m_scenarioTable = CreateScenarioTable(); Controls.Add(m_scenarioTable); } }