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); }
/// <summary> /// Builds the spawn menu /// </summary> private void BuildSpawnMenu() { MyPluginLog.Debug("Create Spawn Menu"); var topCombo = GetCombo(); Vector2 start = topCombo.Position + new Vector2(0, MARGIN_VERT * 2 + GetCombo().Size.Y); Vector2 end = start + new Vector2(topCombo.Size.X, 0.8f - MARGIN_VERT); MyGuiControlParentTableLayout table = new MyGuiControlParentTableLayout(1, false, Vector2.Zero); table.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; m_spawnTypeCombo = new MyGuiControlCombobox(); m_spawnTypeCombo.AddItem(0L, "Planet"); m_spawnTypeCombo.AddItem(1L, "Asteroid object"); m_spawnTypeCombo.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; m_spawnTypeCombo.SelectItemByKey(m_spawnType); m_spawnTypeCombo.ItemSelected += OnSpawnTypeChange; m_spawnTypeCombo.Size = new Vector2(m_usableWidth * 0.9f, m_spawnTypeCombo.Size.Y); m_spawnTypeCombo.SetToolTip(MyPluginTexts.TOOLTIPS.ADMIN_SPAWN_TYPE); table.AddTableRow(m_spawnTypeCombo); table.AddTableSeparator(); switch (m_spawnType) { case 0L: CreatePlanetSpawnMenu(table); break; case 1L: CreateAsteroidSpawnMenu(table); break; } table.AddTableSeparator(); table.ApplyRows(); MyGuiControlScrollablePanel scrollPane = new MyGuiControlScrollablePanel(table); scrollPane.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_TOP; scrollPane.ScrollbarVEnabled = true; scrollPane.Size = end - start; scrollPane.Size = new Vector2(0.315f, scrollPane.Size.Y); scrollPane.Position = new Vector2(0, start.Y); Controls.Add(scrollPane); MyGuiControlSeparatorList sep = new MyGuiControlSeparatorList(); sep.AddHorizontal(new Vector2(scrollPane.Position.X - scrollPane.Size.X / 2, scrollPane.Position.Y + scrollPane.Size.Y), m_usableWidth); Controls.Add(sep); MyPluginLog.Debug("Added spawn menu"); }
public void Init(IMyGuiControlsParent controlsParent, MyCubeGrid grid) { if (grid == null) { ShowError(MySpaceTexts.ScreenTerminalError_ShipNotConnected, controlsParent); return; } grid.RaiseGridChanged(); m_assemblerKeyCounter = 0; m_assemblersByKey.Clear(); foreach (var block in grid.GridSystems.TerminalSystem.Blocks) { var assembler = block as MyAssembler; if (assembler == null) { continue; } if (!assembler.HasLocalPlayerAccess()) { continue; } m_assemblersByKey.Add(m_assemblerKeyCounter++, assembler); } m_controlsParent = controlsParent; m_terminalSystem = grid.GridSystems.TerminalSystem; m_blueprintsArea = (MyGuiControlScrollablePanel)controlsParent.Controls.GetControlByName("BlueprintsScrollableArea"); m_queueArea = (MyGuiControlScrollablePanel)controlsParent.Controls.GetControlByName("QueueScrollableArea"); m_inventoryArea = (MyGuiControlScrollablePanel)controlsParent.Controls.GetControlByName("InventoryScrollableArea"); m_blueprintsBgPanel = controlsParent.Controls.GetControlByName("BlueprintsBackgroundPanel"); m_blueprintsLabel = controlsParent.Controls.GetControlByName("BlueprintsLabel"); m_comboboxAssemblers = (MyGuiControlCombobox)controlsParent.Controls.GetControlByName("AssemblersCombobox"); m_blueprintsGrid = (MyGuiControlGrid)m_blueprintsArea.ScrolledControl; m_queueGrid = (MyGuiControlGrid)m_queueArea.ScrolledControl; m_inventoryGrid = (MyGuiControlGrid)m_inventoryArea.ScrolledControl; m_materialsList = (MyGuiControlComponentList)controlsParent.Controls.GetControlByName("MaterialsList"); m_repeatCheckbox = (MyGuiControlCheckbox)controlsParent.Controls.GetControlByName("RepeatCheckbox"); m_slaveCheckbox = (MyGuiControlCheckbox)controlsParent.Controls.GetControlByName("SlaveCheckbox"); m_disassembleAllButton = (MyGuiControlButton)controlsParent.Controls.GetControlByName("DisassembleAllButton"); m_controlPanelButton = (MyGuiControlButton)controlsParent.Controls.GetControlByName("ControlPanelButton"); m_inventoryButton = (MyGuiControlButton)controlsParent.Controls.GetControlByName("InventoryButton"); { var assemblingButton = (MyGuiControlRadioButton)controlsParent.Controls.GetControlByName("AssemblingButton"); var disassemblingButton = (MyGuiControlRadioButton)controlsParent.Controls.GetControlByName("DisassemblingButton"); assemblingButton.Key = (int)AssemblerMode.Assembling; disassemblingButton.Key = (int)AssemblerMode.Disassembling; m_modeButtonGroup.Add(assemblingButton); m_modeButtonGroup.Add(disassemblingButton); } foreach (var entry in m_assemblersByKey) { if (entry.Value.IsFunctional == false) { m_incompleteAssemblerName.Clear(); m_incompleteAssemblerName.AppendStringBuilder(entry.Value.CustomName); m_incompleteAssemblerName.AppendStringBuilder(MyTexts.Get(MySpaceTexts.Terminal_BlockIncomplete)); m_comboboxAssemblers.AddItem(entry.Key, m_incompleteAssemblerName); } else { m_comboboxAssemblers.AddItem(entry.Key, entry.Value.CustomName); } } m_comboboxAssemblers.ItemSelected += Assemblers_ItemSelected; m_comboboxAssemblers.SelectItemByIndex(0); m_dragAndDrop = new MyGuiControlGridDragAndDrop(MyGuiConstants.DRAG_AND_DROP_BACKGROUND_COLOR, MyGuiConstants.DRAG_AND_DROP_TEXT_COLOR, 0.7f, MyGuiConstants.DRAG_AND_DROP_TEXT_OFFSET, true); controlsParent.Controls.Add(m_dragAndDrop); m_dragAndDrop.DrawBackgroundTexture = false; m_dragAndDrop.ItemDropped += dragDrop_OnItemDropped; RefreshBlueprints(); Assemblers_ItemSelected(); RegisterEvents(); if (m_assemblersByKey.Count == 0) { ShowError(MySpaceTexts.ScreenTerminalError_NoAssemblers, controlsParent); } }
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(); }
public override void RecreateControls(bool constructor) { base.RecreateControls(constructor); var caption = AddCaption("SEWorldGenPlugin world settings"); caption.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_TOP; caption.Position = new Vector2(0, SIZE.Y / -2 + PADDING.Y); MyGuiControlButton OkButton = new MyGuiControlButton(null, VRage.Game.MyGuiControlButtonStyleEnum.Default, null, null, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_BOTTOM, null, VRage.MyTexts.Get(MyCommonTexts.Ok), 0.8f, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyGuiControlHighlightType.WHEN_ACTIVE, OkButtonClicked); OkButton.Position = new Vector2(0, SIZE.Y / 2 - PADDING.Y); Controls.Add(OkButton); MyGuiControlSeparatorList separators = new MyGuiControlSeparatorList(); separators.AddHorizontal(SIZE / -2 + PADDING + new Vector2(0, caption.Size.Y) + CHILD_MARGINS_VERT, SIZE.X - 2 * PADDING.X); separators.AddHorizontal(new Vector2(SIZE.X / -2 + PADDING.X, SIZE.Y / 2 - PADDING.Y - OkButton.Size.Y) - CHILD_MARGINS_VERT, SIZE.X - 2 * PADDING.X); Controls.Add(separators); MyGuiControlParentTableLayout parent = new MyGuiControlParentTableLayout(2); parent.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; //Generate rows for parent layout containing settings var systemGenLabel = new MyGuiControlLabel(null, null, "Generator mode"); var asteroidGenLabel = new MyGuiControlLabel(null, null, "Asteroid generator mode"); var enableVanillaLabel = new MyGuiControlLabel(null, null, "Use vanilla planets"); var planetCountLabel = new MyGuiControlLabel(null, null, "Planet count"); var asteroidCountLabel = new MyGuiControlLabel(null, null, "Asteroid object count"); var oribtDistanceLabel = new MyGuiControlLabel(null, null, "Orbit distances"); var asteroidDensityLabel = new MyGuiControlLabel(null, null, "Asteroid density"); var worldSizeLabel = new MyGuiControlLabel(null, null, "World size"); var planetSizeCapLabel = new MyGuiControlLabel(null, null, "Planet size cap"); var planetSizeMultLabel = new MyGuiControlLabel(null, null, "Planet size multiplier"); var planetMoonPropLabel = new MyGuiControlLabel(null, null, "Planet moon probability"); var planetRingPropLabel = new MyGuiControlLabel(null, null, "Planet ring probability"); var planetMoonCountLabel = new MyGuiControlLabel(null, null, "Planet moon count"); var planetGpsModeLabel = new MyGuiControlLabel(null, null, "Planet gps mode"); var moonGpsModeLabel = new MyGuiControlLabel(null, null, "Moon gps mode"); var asteroidGpsModeLabel = new MyGuiControlLabel(null, null, "Asteroid gps mode"); m_systemGeneratorCombo = new MyGuiControlCombobox(null, null); m_systemGeneratorCombo.SetToolTip(MyPluginTexts.TOOLTIPS.SYS_GEN_MODE_COMBO); m_systemGeneratorCombo.AddItem((long)SystemGenerationMethod.FULL_RANDOM, "Full random"); m_systemGeneratorCombo.AddItem((long)SystemGenerationMethod.UNIQUE, "Unique"); m_systemGeneratorCombo.AddItem((long)SystemGenerationMethod.MANDATORY_FIRST, "Mandatory first"); m_systemGeneratorCombo.AddItem((long)SystemGenerationMethod.MANDATORY_ONLY, "Mandatory only"); m_systemGeneratorCombo.Size = new Vector2(0.25f, m_systemGeneratorCombo.Size.Y); parent.AddTableRow(systemGenLabel, m_systemGeneratorCombo); m_asteroidGeneratorCombo = new MyGuiControlCombobox(); m_asteroidGeneratorCombo.SetToolTip(MyPluginTexts.TOOLTIPS.ASTEROID_GEN_MODE_COMBO); m_asteroidGeneratorCombo.AddItem((long)AsteroidGenerationMethod.PLUGIN, "Plugin"); m_asteroidGeneratorCombo.AddItem((long)AsteroidGenerationMethod.VANILLA, "Vanilla"); m_asteroidGeneratorCombo.AddItem((long)AsteroidGenerationMethod.BOTH, "Combined"); m_asteroidGeneratorCombo.ItemSelected += delegate { m_asteroidGPSModeCombo.Enabled = m_asteroidGPSModeCombo.GetSelectedIndex() != (long)AsteroidGenerationMethod.VANILLA; m_asteroidDensitySlider.Enabled = m_asteroidGPSModeCombo.GetSelectedIndex() != (long)AsteroidGenerationMethod.VANILLA; }; m_asteroidGeneratorCombo.Size = new Vector2(0.25f, m_asteroidGeneratorCombo.Size.Y); parent.AddTableRow(asteroidGenLabel, m_asteroidGeneratorCombo); m_enableVanillaPlanetsCheckbox = new MyGuiControlCheckbox(); m_enableVanillaPlanetsCheckbox.SetToolTip(MyPluginTexts.TOOLTIPS.VANILLA_PLANETS_CHECK); parent.AddTableRow(enableVanillaLabel, m_enableVanillaPlanetsCheckbox); m_planetCountSlider = new MyGuiControlRangedSlider(0, 50, 5, 15, true, width: 0.25f); m_planetCountSlider.SetToolTip(MyPluginTexts.TOOLTIPS.PLANET_COUNT_SLIDER); parent.AddTableRow(planetCountLabel, m_planetCountSlider); m_asteroidCountSlider = new MyGuiControlRangedSlider(0, 50, 5, 15, true, width: 0.25f); m_asteroidCountSlider.SetToolTip(MyPluginTexts.TOOLTIPS.ASTEROID_COUNT_SLIDER); parent.AddTableRow(asteroidCountLabel, m_asteroidCountSlider); m_orbitDistancesSlider = new MyGuiControlRangedSlider(100, 10000000, 40000, 1000000, width: 0.25f, useLogScale: true); m_orbitDistancesSlider.SetToolTip(MyPluginTexts.TOOLTIPS.ORBIT_DISTANCE_SLIDER); parent.AddTableRow(oribtDistanceLabel, m_orbitDistancesSlider); m_asteroidDensitySlider = new MyGuiControlClickableSlider(minValue: 0, maxValue: 1, defaultValue: 0.6f, width: 0.25f, showLabel: true); m_asteroidDensitySlider.SetToolTip(MyPluginTexts.TOOLTIPS.ASTEROID_DENS_SLIDER); parent.AddTableRow(asteroidDensityLabel, m_asteroidDensitySlider); m_worldSizeSlider = new MyGuiControlClickableSlider(minValue: -1, maxValue: 1000000000, defaultValue: -1, width: 0.25f, showLabel: true, labelSuffix: " Km"); m_worldSizeSlider.SetToolTip(MyPluginTexts.TOOLTIPS.WORLD_SIZE_SLIDER); m_worldSizeSlider.OnLabelUpdate += delegate(MyGuiControlLabel l) { if (m_worldSizeSlider.Value < 0) { l.Text = "Infinite"; } }; parent.AddTableRow(worldSizeLabel, m_worldSizeSlider); m_planetSizeCapSlider = new MyGuiControlClickableSlider(minValue: 1, maxValue: 2400000, defaultValue: 1200000, intValue: true, width: 0.25f, showLabel: true, labelSuffix: " m"); m_planetSizeCapSlider.SetToolTip(MyPluginTexts.TOOLTIPS.PLANET_SIZE_CAP_SLIDER); parent.AddTableRow(planetSizeCapLabel, m_planetSizeCapSlider); m_planetSizeMultSlider = new MyGuiControlClickableSlider(minValue: 0.1f, maxValue: 10, defaultValue: 2, width: 0.25f, showLabel: true); m_planetSizeMultSlider.SetToolTip(MyPluginTexts.TOOLTIPS.PLANET_SIZE_MULT); parent.AddTableRow(planetSizeMultLabel, m_planetSizeMultSlider); m_planetMoonBasePropSlider = new MyGuiControlClickableSlider(minValue: 0f, maxValue: 1f, defaultValue: 0.5f, width: 0.25f, showLabel: true); m_planetMoonBasePropSlider.SetToolTip(MyPluginTexts.TOOLTIPS.PLANET_MOON_PROP); parent.AddTableRow(planetMoonPropLabel, m_planetMoonBasePropSlider); m_planetRingBasePropSlider = new MyGuiControlClickableSlider(minValue: 0f, maxValue: 1f, defaultValue: 0.5f, width: 0.25f, showLabel: true); m_planetRingBasePropSlider.SetToolTip(MyPluginTexts.TOOLTIPS.PLANET_RING_PROP); parent.AddTableRow(planetRingPropLabel, m_planetRingBasePropSlider); m_planetMoonMinMaxSlider = new MyGuiControlRangedSlider(1, 50, 1, 25, true, showLabel: true, width: 0.25f); m_planetMoonMinMaxSlider.SetToolTip(MyPluginTexts.TOOLTIPS.PLANET_MOON_COUNT); parent.AddTableRow(planetMoonCountLabel, m_planetMoonMinMaxSlider); m_planetGPSModeCombo = new MyGuiControlCombobox(); m_planetGPSModeCombo.SetToolTip(MyPluginTexts.TOOLTIPS.PLANET_GPS_COMBO); m_planetGPSModeCombo.AddItem((long)MyGPSGenerationMode.DISCOVERY, "Discovery"); m_planetGPSModeCombo.AddItem((long)MyGPSGenerationMode.PERSISTENT, "Persistent"); m_planetGPSModeCombo.AddItem((long)MyGPSGenerationMode.NONE, "None"); m_planetGPSModeCombo.Size = new Vector2(0.25f, m_planetGPSModeCombo.Size.Y); parent.AddTableRow(planetGpsModeLabel, m_planetGPSModeCombo); m_moonGPSModeCombo = new MyGuiControlCombobox(); m_moonGPSModeCombo.SetToolTip(MyPluginTexts.TOOLTIPS.MOON_GPS_COMBO); m_moonGPSModeCombo.AddItem((long)MyGPSGenerationMode.DISCOVERY, "Discovery"); m_moonGPSModeCombo.AddItem((long)MyGPSGenerationMode.PERSISTENT, "Persistent"); m_moonGPSModeCombo.AddItem((long)MyGPSGenerationMode.NONE, "None"); m_moonGPSModeCombo.Size = new Vector2(0.25f, m_moonGPSModeCombo.Size.Y); parent.AddTableRow(moonGpsModeLabel, m_moonGPSModeCombo); m_asteroidGPSModeCombo = new MyGuiControlCombobox(); m_asteroidGPSModeCombo.SetToolTip(MyPluginTexts.TOOLTIPS.ASTEROID_GPS_COMBO); m_asteroidGPSModeCombo.AddItem((long)MyGPSGenerationMode.DISCOVERY, "Discovery"); m_asteroidGPSModeCombo.AddItem((long)MyGPSGenerationMode.PERSISTENT, "Persistent"); m_asteroidGPSModeCombo.AddItem((long)MyGPSGenerationMode.NONE, "None"); m_asteroidGPSModeCombo.Size = new Vector2(0.25f, m_asteroidGPSModeCombo.Size.Y); parent.AddTableRow(asteroidGpsModeLabel, m_asteroidGPSModeCombo); parent.ApplyRows(); Vector2 start = SIZE / -2 + PADDING + new Vector2(0, caption.Size.Y) + CHILD_MARGINS_VERT * 2; Vector2 end = new Vector2(SIZE.X / 2 - PADDING.X, SIZE.Y / 2 - PADDING.Y - OkButton.Size.Y) - CHILD_MARGINS_VERT * 2; MyGuiControlScrollablePanel scrollPane = new MyGuiControlScrollablePanel(parent); scrollPane.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; scrollPane.ScrollbarVEnabled = true; scrollPane.Size = end - start; scrollPane.Position = start; Controls.Add(scrollPane); }
/// <summary> /// Creates the sub menu for the currently selected system object, that contains the /// elements to edit it. /// </summary> private void BuildEditingSubMenu() { if (m_scrollTable != null) { Controls.Remove(m_scrollPane); } m_scrollTable = new MyGuiControlParentTableLayout(1, false, Vector2.Zero, m_usableWidth); m_scrollTable.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; m_scrollTable.AddTableSeparator(); if (m_scrollTable == null) { m_scrollTable = new MyGuiControlParentTableLayout(1, false, Vector2.Zero, m_usableWidth); } else { m_scrollTable.ClearTable(); } m_currentAsteroidAdminMenu = null; if (m_selectedObject != null) { if (m_selectedObject.Type == MySystemObjectType.PLANET || m_selectedObject.Type == MySystemObjectType.MOON) { BuildPlanetEditingMenu(m_scrollTable, m_selectedObject as MySystemPlanet); m_scrollTable.AddTableSeparator(); CameraLookAt(m_selectedObject.CenterPosition, (float)(m_selectedObject as MySystemPlanet).Diameter * 1.5f); } else if (m_selectedObject.Type == MySystemObjectType.ASTEROIDS) { var asteroidObject = m_selectedObject as MySystemAsteroids; if (!MyAsteroidObjectsManager.Static.AsteroidObjectProviders.ContainsKey(asteroidObject.AsteroidTypeName)) { return; } var provider = MyAsteroidObjectsManager.Static.AsteroidObjectProviders[asteroidObject.AsteroidTypeName]; var creator = provider.GetAdminMenuCreator(); if (creator != null) { if (!creator.OnEditMenuSelectItem(m_usableWidth, m_scrollTable, this, asteroidObject, m_fetchedStarSytem)) { m_scrollTable.AddTableRow(new MyGuiControlLabel(null, null, "This object cant be edited.", font: "Red")); m_scrollTable.AddTableSeparator(); } m_currentAsteroidAdminMenu = creator; } } } m_scrollTable.ApplyRows(); var topCombo = GetCombo(); Vector2 start = m_systemObjectsBox.Position + new Vector2(-0.001f, MARGIN_VERT * 2 + m_systemObjectsBox.Size.Y); Vector2 end = new Vector2(topCombo.Size.X, 0.5f - MARGIN_VERT); m_scrollPane = new MyGuiControlScrollablePanel(m_scrollTable); m_scrollPane.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_TOP; m_scrollPane.ScrollbarVEnabled = true; m_scrollPane.Size = end - start; m_scrollPane.Size = new Vector2(0.315f, m_scrollPane.Size.Y); m_scrollPane.Position = new Vector2(0, start.Y); Controls.Add(m_scrollPane); }
/// <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); }
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); }
public override void RecreateControls(bool constructor) { base.RecreateControls(constructor); var caption = AddCaption("SEWorldGenPlugin global settings"); caption.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_TOP; caption.Position = new Vector2(0, SIZE.Y / -2 + PADDING.Y); MyGuiControlButton OkButton = new MyGuiControlButton(null, VRage.Game.MyGuiControlButtonStyleEnum.Default, null, null, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_BOTTOM, "Saves the global settings file now and exits this menu", VRage.MyTexts.Get(MyCommonTexts.Ok), 0.8f, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyGuiControlHighlightType.WHEN_ACTIVE, OnOkButtonClicked); OkButton.Position = new Vector2(0, SIZE.Y / 2 - PADDING.Y); Controls.Add(OkButton); MyGuiControlSeparatorList separators = new MyGuiControlSeparatorList(); separators.AddHorizontal(SIZE / -2 + PADDING + new Vector2(0, caption.Size.Y) + CHILD_MARGINS_VERT, SIZE.X - 2 * PADDING.X); separators.AddHorizontal(new Vector2(SIZE.X / -2 + PADDING.X, SIZE.Y / 2 - PADDING.Y - OkButton.Size.Y) - CHILD_MARGINS_VERT, SIZE.X - 2 * PADDING.X); Controls.Add(separators); MyGuiControlParentTableLayout parent = new MyGuiControlParentTableLayout(2, overflowColumns: true, minWidth: WIDTH); parent.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; var moonsLabel = new MyGuiControlLabel(null, null, "Moons"); var gasGiantLabel = new MyGuiControlLabel(null, null, "Gas giants"); var sunLabel = new MyGuiControlLabel(null, null, "Suns"); var mandatoryLabel = new MyGuiControlLabel(null, null, "Mandatory planets and moons"); var blacklistLabel = new MyGuiControlLabel(null, null, "Blacklisted planets and moons"); var planetNameLabel = new MyGuiControlLabel(null, null, "Planet name format"); var moonNameLabel = new MyGuiControlLabel(null, null, "Moon name format"); var beltNameLabel = new MyGuiControlLabel(null, null, "Belt name format"); #region Tables ///Moons table m_moonDefsTable = new MyGuiControlTable(); m_moonDefsTable.VisibleRowsCount = 8; m_moonDefsTable.Size = new Vector2(WIDTH, m_moonDefsTable.Size.Y); m_moonDefsTable.ColumnsCount = 1; m_moonDefsTable.SetCustomColumnWidths(new float[] { WIDTH }); m_moonDefsTable.SetColumnName(0, new System.Text.StringBuilder("Subtype ID")); var addMoonBtn = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Add Moon", delegate { OpenEnterIdDialog(m_moonDefsTable, delegate(string name) { MySettings.Static.Settings.MoonDefinitions.Add(name); }); }); var remMoonBtn = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Remove Moon", delegate { MySettings.Static.Settings.MoonDefinitions.Remove(m_moonDefsTable.SelectedRow.UserData as string); m_moonDefsTable.RemoveSelectedRow(); }); remMoonBtn.Enabled = false; m_moonDefsTable.FocusChanged += delegate { remMoonBtn.Enabled = m_moonDefsTable.HasFocus && m_moonDefsTable.SelectedRow != null; }; m_moonDefsTable.ItemSelected += delegate(MyGuiControlTable table, MyGuiControlTable.EventArgs args) { remMoonBtn.Enabled = m_moonDefsTable.HasFocus && m_moonDefsTable.SelectedRow != null; }; parent.AddTableRow(moonsLabel); parent.AddTableRow(m_moonDefsTable); parent.AddTableRow(addMoonBtn, remMoonBtn); parent.AddTableSeparator(); ///Gas giant table m_gasGiantsDefsTable = new MyGuiControlTable(); m_gasGiantsDefsTable.VisibleRowsCount = 8; m_gasGiantsDefsTable.Size = new Vector2(WIDTH, m_gasGiantsDefsTable.Size.Y); m_gasGiantsDefsTable.ColumnsCount = 1; m_gasGiantsDefsTable.SetCustomColumnWidths(new float[] { WIDTH }); m_gasGiantsDefsTable.SetColumnName(0, new System.Text.StringBuilder("Subtype ID")); MyGuiControlParentTableLayout gasGiantBtns = new MyGuiControlParentTableLayout(2, padding: new Vector2(0)); var addGasGiantBtn = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Add Gas Giant", delegate { OpenEnterIdDialog(m_gasGiantsDefsTable, delegate(string name) { MySettings.Static.Settings.GasGiantDefinitions.Add(name); }); }); var remGasGiantBtn = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Remove Gas Giant", delegate { MySettings.Static.Settings.GasGiantDefinitions.Remove(m_gasGiantsDefsTable.SelectedRow.UserData as string); m_gasGiantsDefsTable.RemoveSelectedRow(); }); remGasGiantBtn.Enabled = false; m_gasGiantsDefsTable.FocusChanged += delegate { remGasGiantBtn.Enabled = m_gasGiantsDefsTable.HasFocus && m_gasGiantsDefsTable.SelectedRow != null; }; m_gasGiantsDefsTable.ItemSelected += delegate(MyGuiControlTable table, MyGuiControlTable.EventArgs args) { remGasGiantBtn.Enabled = table.SelectedRow != null; }; parent.AddTableRow(gasGiantLabel); parent.AddTableRow(m_gasGiantsDefsTable); parent.AddTableRow(addGasGiantBtn, remGasGiantBtn); parent.AddTableSeparator(); ///Suns table m_sunDefsTable = new MyGuiControlTable(); m_sunDefsTable.VisibleRowsCount = 8; m_sunDefsTable.Size = new Vector2(WIDTH, m_sunDefsTable.Size.Y); m_sunDefsTable.ColumnsCount = 1; m_sunDefsTable.SetCustomColumnWidths(new float[] { WIDTH }); m_sunDefsTable.SetColumnName(0, new System.Text.StringBuilder("Subtype ID")); var addSunBtn = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Add Sun", delegate { OpenEnterIdDialog(m_sunDefsTable, delegate(string name) { MySettings.Static.Settings.SunDefinitions.Add(name); }); }); var remSunBtn = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Remove Sun", delegate { MySettings.Static.Settings.SunDefinitions.Remove(m_sunDefsTable.SelectedRow.UserData as string); m_sunDefsTable.RemoveSelectedRow(); }); remSunBtn.Enabled = false; m_sunDefsTable.FocusChanged += delegate { remSunBtn.Enabled = m_sunDefsTable.HasFocus && m_sunDefsTable.SelectedRow != null; }; m_sunDefsTable.ItemSelected += delegate(MyGuiControlTable table, MyGuiControlTable.EventArgs args) { remSunBtn.Enabled = table.SelectedRow != null; }; parent.AddTableRow(sunLabel); parent.AddTableRow(m_sunDefsTable); parent.AddTableRow(addSunBtn, remSunBtn); parent.AddTableSeparator(); ///Mandatory table m_mandatoryDefsTable = new MyGuiControlTable(); m_mandatoryDefsTable.VisibleRowsCount = 8; m_mandatoryDefsTable.Size = new Vector2(WIDTH, m_mandatoryDefsTable.Size.Y); m_mandatoryDefsTable.ColumnsCount = 1; m_mandatoryDefsTable.SetCustomColumnWidths(new float[] { WIDTH }); m_mandatoryDefsTable.SetColumnName(0, new System.Text.StringBuilder("Subtype ID")); var addMandatoryBtn = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Add Mandatory", delegate { OpenEnterIdDialog(m_mandatoryDefsTable, delegate(string name) { MySettings.Static.Settings.MandatoryPlanetDefinitions.Add(name); }); }); var remMandatoryBtn = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Remove Mandatory", delegate { MySettings.Static.Settings.MandatoryPlanetDefinitions.Remove(m_mandatoryDefsTable.SelectedRow.UserData as string); m_mandatoryDefsTable.RemoveSelectedRow(); }); remMandatoryBtn.Enabled = false; m_mandatoryDefsTable.FocusChanged += delegate { remMandatoryBtn.Enabled = m_mandatoryDefsTable.HasFocus && m_mandatoryDefsTable.SelectedRow != null; }; m_mandatoryDefsTable.ItemSelected += delegate(MyGuiControlTable table, MyGuiControlTable.EventArgs args) { remMandatoryBtn.Enabled = table.SelectedRow != null; }; parent.AddTableRow(mandatoryLabel); parent.AddTableRow(m_mandatoryDefsTable); parent.AddTableRow(addMandatoryBtn, remMandatoryBtn); parent.AddTableSeparator(); ///Blacklist table m_blacklistDefsTable = new MyGuiControlTable(); m_blacklistDefsTable.VisibleRowsCount = 8; m_blacklistDefsTable.Size = new Vector2(WIDTH, m_blacklistDefsTable.Size.Y); m_blacklistDefsTable.ColumnsCount = 1; m_blacklistDefsTable.SetCustomColumnWidths(new float[] { WIDTH }); m_blacklistDefsTable.SetColumnName(0, new System.Text.StringBuilder("Subtype ID")); var addBlacklistBtn = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Add to Blacklist", delegate { OpenEnterIdDialog(m_blacklistDefsTable, delegate(string name) { MySettings.Static.Settings.BlacklistedPlanetDefinitions.Add(name); }); }); var remBlacklistBtn = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Remove from Blacklist", delegate { MySettings.Static.Settings.BlacklistedPlanetDefinitions.Remove(m_blacklistDefsTable.SelectedRow.UserData as string); m_blacklistDefsTable.RemoveSelectedRow(); }); remBlacklistBtn.Enabled = false; m_blacklistDefsTable.FocusChanged += delegate { remBlacklistBtn.Enabled = m_blacklistDefsTable.HasFocus && m_blacklistDefsTable.SelectedRow != null; }; m_blacklistDefsTable.ItemSelected += delegate(MyGuiControlTable table, MyGuiControlTable.EventArgs args) { remBlacklistBtn.Enabled = table.SelectedRow != null; }; parent.AddTableRow(blacklistLabel); parent.AddTableRow(m_blacklistDefsTable); parent.AddTableRow(addBlacklistBtn, remBlacklistBtn); #endregion parent.AddTableSeparator(); #region NameFormats ///Planet name box m_planetNameBox = new MyGuiControlTextbox(); m_planetNameBox.Size = new Vector2(WIDTH, m_planetNameBox.Size.Y); m_planetNameBox.TextChanged += delegate { StringBuilder s = new StringBuilder(); m_planetNameBox.GetText(s); MySettings.Static.Settings.PlanetNameFormat = s.ToString(); }; MyGuiControlParentTableLayout formatButtons = new MyGuiControlParentTableLayout(3, padding: new Vector2(0)); var planetNameButtons1 = new MyGuiControlButton[3]; var planetNameButtons2 = new MyGuiControlButton[3]; planetNameButtons1[0] = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Add Object Number", delegate { MySettings.Static.Settings.PlanetNameFormat = AddNameProperty(m_planetNameBox, MyNamingUtils.PROP_OBJ_NUMBER); }); planetNameButtons1[1] = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Add Roman number", delegate { MySettings.Static.Settings.PlanetNameFormat = AddNameProperty(m_planetNameBox, MyNamingUtils.PROP_OBJ_NUMBER_ROMAN); }); planetNameButtons1[2] = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Add Greek number", delegate { MySettings.Static.Settings.PlanetNameFormat = AddNameProperty(m_planetNameBox, MyNamingUtils.PROP_OBJ_NUMBER_GREEK); }); planetNameButtons2[0] = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Add lower letter", delegate { MySettings.Static.Settings.PlanetNameFormat = AddNameProperty(m_planetNameBox, MyNamingUtils.PROP_OBJ_LETTER_LOWER); }); planetNameButtons2[1] = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Add upper letter", delegate { MySettings.Static.Settings.PlanetNameFormat = AddNameProperty(m_planetNameBox, MyNamingUtils.PROP_OBJ_LETTER_UPPER); }); planetNameButtons2[2] = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Add id", delegate { MySettings.Static.Settings.PlanetNameFormat = AddNameProperty(m_planetNameBox, MyNamingUtils.PROP_OBJ_ID); }); m_planetNameBox.TextChanged += delegate(MyGuiControlTextbox t) { var sb = new StringBuilder(); t.GetText(sb); MySettings.Static.Settings.PlanetNameFormat = sb.ToString(); }; formatButtons.AddTableRow(planetNameButtons1); formatButtons.AddTableRow(planetNameButtons2); formatButtons.ApplyRows(); parent.AddTableRow(planetNameLabel); parent.AddTableRow(m_planetNameBox); parent.AddTableRow(formatButtons); parent.AddTableSeparator(); ///Moon name box m_moonNameBox = new MyGuiControlTextbox(); m_moonNameBox.Size = new Vector2(WIDTH, m_moonNameBox.Size.Y); m_moonNameBox.TextChanged += delegate { StringBuilder s = new StringBuilder(); m_moonNameBox.GetText(s); MySettings.Static.Settings.MoonNameFormat = s.ToString(); }; MyGuiControlParentTableLayout formatButtonsMoon = new MyGuiControlParentTableLayout(3, padding: new Vector2(0)); var moonNameButtons1 = new MyGuiControlButton[3]; var moonNameButtons2 = new MyGuiControlButton[3]; moonNameButtons1[0] = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Add Object Number", delegate { MySettings.Static.Settings.MoonNameFormat = AddNameProperty(m_moonNameBox, MyNamingUtils.PROP_OBJ_NUMBER); }); moonNameButtons1[1] = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Add Roman number", delegate { MySettings.Static.Settings.MoonNameFormat = AddNameProperty(m_moonNameBox, MyNamingUtils.PROP_OBJ_NUMBER_ROMAN); }); moonNameButtons1[2] = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Add Greek number", delegate { MySettings.Static.Settings.MoonNameFormat = AddNameProperty(m_moonNameBox, MyNamingUtils.PROP_OBJ_NUMBER_GREEK); }); moonNameButtons2[0] = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Add lower letter", delegate { MySettings.Static.Settings.MoonNameFormat = AddNameProperty(m_moonNameBox, MyNamingUtils.PROP_OBJ_LETTER_LOWER); }); moonNameButtons2[1] = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Add upper letter", delegate { MySettings.Static.Settings.MoonNameFormat = AddNameProperty(m_moonNameBox, MyNamingUtils.PROP_OBJ_LETTER_UPPER); }); moonNameButtons2[2] = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Add id", delegate { MySettings.Static.Settings.MoonNameFormat = AddNameProperty(m_moonNameBox, MyNamingUtils.PROP_OBJ_ID); }); var btnExtra = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Add parent name", delegate { MySettings.Static.Settings.MoonNameFormat = AddNameProperty(m_moonNameBox, MyNamingUtils.PROP_OBJ_PARENT); }); m_moonNameBox.TextChanged += delegate(MyGuiControlTextbox t) { var sb = new StringBuilder(); t.GetText(sb); MySettings.Static.Settings.MoonNameFormat = sb.ToString(); }; formatButtonsMoon.AddTableRow(moonNameButtons1); formatButtonsMoon.AddTableRow(moonNameButtons2); formatButtonsMoon.AddTableRow(btnExtra); formatButtonsMoon.ApplyRows(); parent.AddTableRow(moonNameLabel); parent.AddTableRow(m_moonNameBox); parent.AddTableRow(formatButtonsMoon); parent.AddTableSeparator(); ///Belt name box m_beltNameBox = new MyGuiControlTextbox(); m_beltNameBox.Size = new Vector2(WIDTH, m_beltNameBox.Size.Y); m_beltNameBox.TextChanged += delegate { StringBuilder s = new StringBuilder(); m_beltNameBox.GetText(s); MySettings.Static.Settings.BeltNameFormat = s.ToString(); }; MyGuiControlParentTableLayout formatButtonsBelt = new MyGuiControlParentTableLayout(3, padding: new Vector2(0)); var beltNameButtons1 = new MyGuiControlButton[3]; var beltNameButtons2 = new MyGuiControlButton[2]; beltNameButtons1[0] = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Add Object Number", delegate { MySettings.Static.Settings.BeltNameFormat = AddNameProperty(m_beltNameBox, MyNamingUtils.PROP_OBJ_NUMBER); }); beltNameButtons1[1] = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Add Roman number", delegate { MySettings.Static.Settings.BeltNameFormat = AddNameProperty(m_beltNameBox, MyNamingUtils.PROP_OBJ_NUMBER_ROMAN); }); beltNameButtons1[2] = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Add Greek number", delegate { MySettings.Static.Settings.BeltNameFormat = AddNameProperty(m_beltNameBox, MyNamingUtils.PROP_OBJ_NUMBER_GREEK); }); beltNameButtons2[0] = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Add lower letter", delegate { MySettings.Static.Settings.BeltNameFormat = AddNameProperty(m_beltNameBox, MyNamingUtils.PROP_OBJ_LETTER_LOWER); }); beltNameButtons2[1] = MyPluginGuiHelper.CreateDebugButton(DBG_BTN_WIDTH, "Add upper letter", delegate { MySettings.Static.Settings.BeltNameFormat = AddNameProperty(m_beltNameBox, MyNamingUtils.PROP_OBJ_LETTER_UPPER); }); m_beltNameBox.TextChanged += delegate(MyGuiControlTextbox t) { var sb = new StringBuilder(); t.GetText(sb); MySettings.Static.Settings.BeltNameFormat = sb.ToString(); }; formatButtonsBelt.AddTableRow(beltNameButtons1); formatButtonsBelt.AddTableRow(beltNameButtons2); formatButtonsBelt.ApplyRows(); parent.AddTableRow(beltNameLabel); parent.AddTableRow(m_beltNameBox); parent.AddTableRow(formatButtonsBelt); #endregion parent.ApplyRows(); Vector2 start = SIZE / -2 + PADDING + new Vector2(0, caption.Size.Y) + CHILD_MARGINS_VERT * 2; Vector2 end = new Vector2(SIZE.X / 2 - PADDING.X, SIZE.Y / 2 - PADDING.Y - OkButton.Size.Y) - CHILD_MARGINS_VERT * 2; MyGuiControlScrollablePanel scrollPane = new MyGuiControlScrollablePanel(parent); scrollPane.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; scrollPane.ScrollbarVEnabled = true; scrollPane.Size = end - start; scrollPane.Position = start; Controls.Add(scrollPane); }
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); } }
public static TType ScrollableChild <TType>(this MyGuiControlScrollablePanel scrollablePanel) where TType : MyGuiControlBase { return((TType)scrollablePanel.Controls[0]); }