protected override void BuildControls() { base.BuildControls(); // Training level { var trainingLabel = MakeLabel(MySpaceTexts.TrainingLevel); trainingLabel.Position = new Vector2(-0.25f, -0.47f + MARGIN_TOP); trainingLabel.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER; m_trainingLevel = new MyGuiControlCombobox( position: new Vector2(-0.04f, -0.47f + MARGIN_TOP), size: new Vector2(0.2f, trainingLabel.Size.Y), originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER ); m_trainingLevel.AddItem((int)TrainingLevel.BASIC, MySpaceTexts.TrainingLevel_Basic); m_trainingLevel.AddItem((int)TrainingLevel.INTERMEDIATE, MySpaceTexts.TrainingLevel_Intermediate); m_trainingLevel.AddItem((int)TrainingLevel.ADVANCED, MySpaceTexts.TrainingLevel_Advanced); m_trainingLevel.SelectItemByIndex(0); m_trainingLevel.ItemSelected += OnTrainingLevelSelected; Controls.Add(trainingLabel); Controls.Add(m_trainingLevel); } }
public override void RecreateControls(bool contructor) { base.RecreateControls(contructor); this.Controls.Add(new MyGuiControlLabel(new Vector2(0.0f, -0.10f), text: "Select the amount and type of items to spawn in your inventory", originAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER)); m_amountTextbox = new MyGuiControlTextbox(new Vector2(-0.2f, 0.0f), null, 9, null, MyGuiConstants.DEFAULT_TEXT_SCALE, MyGuiControlTextboxType.DigitsOnly); m_items = new MyGuiControlCombobox(new Vector2(0.2f, 0.0f), new Vector2(0.3f, 0.05f), null, null, 10, null); m_confirmButton = new MyGuiControlButton(new Vector2(0.21f, 0.10f), MyGuiControlButtonStyleEnum.Default, new Vector2(0.2f, 0.05f), null, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, null, new System.Text.StringBuilder("Confirm")); m_cancelButton = new MyGuiControlButton(new Vector2(-0.21f, 0.10f), MyGuiControlButtonStyleEnum.Default, new Vector2(0.2f, 0.05f), null, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, null, new System.Text.StringBuilder("Cancel")); foreach (var definition in MyDefinitionManager.Static.GetAllDefinitions()) { var physicalItemDef = definition as MyPhysicalItemDefinition; if (physicalItemDef == null || physicalItemDef.CanSpawnFromScreen == false) continue; int key = m_physicalItemDefinitions.Count; m_physicalItemDefinitions.Add(physicalItemDef); m_items.AddItem(key, definition.DisplayNameText); } this.Controls.Add(m_amountTextbox); this.Controls.Add(m_items); this.Controls.Add(m_confirmButton); this.Controls.Add(m_cancelButton); m_amountTextbox.Text = string.Format("{0}", m_lastAmount); m_items.SelectItemByIndex(m_lastSelectedItem); m_confirmButton.ButtonClicked += confirmButton_OnButtonClick; m_cancelButton.ButtonClicked += cancelButton_OnButtonClick; }
public override void RecreateControls(bool contructor) { base.RecreateControls(contructor); this.Controls.Add(new MyGuiControlLabel(new Vector2(0.0f, -0.10f), text: "Select gps you want to reach. (Dont use for grids with subgrids.)", originAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER)); m_prefabs = new MyGuiControlCombobox(new Vector2(0.2f, 0.0f), new Vector2(0.3f, 0.05f), null, null, 10, null); m_confirmButton = new MyGuiControlButton(new Vector2(0.21f, 0.10f), MyGuiControlButtonStyleEnum.Default, new Vector2(0.2f, 0.05f), null, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, null, new System.Text.StringBuilder("Confirm")); m_cancelButton = new MyGuiControlButton(new Vector2(-0.21f, 0.10f), MyGuiControlButtonStyleEnum.Default, new Vector2(0.2f, 0.05f), null, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, null, new System.Text.StringBuilder("Cancel")); List<IMyGps> outlist = new List<IMyGps>(); MySession.Static.Gpss.GetGpsList(MySession.Static.LocalPlayerId, outlist); foreach (var prefab in outlist) { int key = m_prefabDefinitions.Count; m_prefabDefinitions.Add(prefab); m_prefabs.AddItem(key, prefab.Name); } this.Controls.Add(m_prefabs); this.Controls.Add(m_confirmButton); this.Controls.Add(m_cancelButton); m_confirmButton.ButtonClicked += confirmButton_OnButtonClick; m_cancelButton.ButtonClicked += cancelButton_OnButtonClick; }
public override void RecreateControls(bool constructor) { base.RecreateControls(constructor); BackgroundColor = new Vector4(1f, 1f, 1f, 0.5f); m_currentPosition = -m_size.Value / 2.0f + new Vector2(0.02f, 0.13f); AddCaption("Voxels", Color.Yellow.ToVector4()); AddShareFocusHint(); AddSlider("Max precalc time", 0f, 20f, null, MemberHelper.GetMember(() => MyFakes.MAX_PRECALC_TIME_IN_MILLIS)); AddCheckBox("Enable yielding", null, MemberHelper.GetMember(() => MyFakes.ENABLE_YIELDING_IN_PRECALC_TASK)); m_filesCombo = MakeComboFromFiles(Path.Combine(MyFileSystem.ContentPath, "VoxelMaps")); m_filesCombo.ItemSelected += filesCombo_OnSelect; m_materialsCombo = AddCombo(); foreach (var material in MyDefinitionManager.Static.GetVoxelMaterialDefinitions()) { m_materialsCombo.AddItem(material.Index, new StringBuilder(material.Id.SubtypeName)); } m_materialsCombo.ItemSelected += materialsCombo_OnSelect; m_materialsCombo.SelectItemByIndex(0); AddCombo<MyVoxelDebugDrawMode>(null, MemberHelper.GetMember(() => MyDebugDrawSettings.DEBUG_DRAW_VOXELS_MODE)); AddButton(new StringBuilder("Remove all"), onClick: RemoveAllAsteroids); AddButton(new StringBuilder("Generate render"), onClick: GenerateRender); AddButton(new StringBuilder("Generate physics"), onClick: GeneratePhysics); AddButton(new StringBuilder("Voxelize all"), onClick: ForceVoxelizeAllVoxelMaps); AddButton(new StringBuilder("Resave prefabs"), onClick: ResavePrefabs); AddButton(new StringBuilder("Reset all"), onClick: ResetAll); AddButton(new StringBuilder("Reset part"), onClick: ResetPart); m_currentPosition.Y += 0.01f; AddCheckBox("Geometry cell debug draw", null, MemberHelper.GetMember(() => MyDebugDrawSettings.DEBUG_DRAW_VOXEL_GEOMETRY_CELL)); AddCheckBox("Freeze terrain queries", MyRenderProxy.Settings, MemberHelper.GetMember(() => MyRenderProxy.Settings.FreezeTerrainQueries)); AddCheckBox("Debug render clipmap cells", MyRenderProxy.Settings, MemberHelper.GetMember(() => MyRenderProxy.Settings.DebugRenderClipmapCells)); AddCheckBox("Debug clipmap lod colors", () => MyRenderSettings.DebugClipmapLodColor, (value) => MyRenderSettings.DebugClipmapLodColor = value); AddCheckBox("Enable physics shape discard", null, MemberHelper.GetMember(() => MyFakes.ENABLE_VOXEL_PHYSICS_SHAPE_DISCARDING)); AddCheckBox("Wireframe", MyRenderProxy.Settings, MemberHelper.GetMember(() => MyRenderProxy.Settings.Wireframe)); AddCheckBox("Green background", MyRenderProxy.Settings, MemberHelper.GetMember(() => MyRenderProxy.Settings.ShowGreenBackground)); m_currentPosition.Y += 0.01f; AddSlider("Clipmap highest lod", MyClipmap.DebugClipmapMostDetailedLod, 0f, 15.9f, (slider) => MyClipmap.DebugClipmapMostDetailedLod = slider.Value); m_currentPosition.Y += 0.01f; }
protected void RecreateHandItemsCombo() { m_handItemsCombo = AddCombo(); m_handItemDefinitions.Clear(); foreach (var handItemDef in MyDefinitionManager.Static.GetHandItemDefinitions()) { var def = MyDefinitionManager.Static.GetDefinition(handItemDef.PhysicalItemId); int handItemKey = m_handItemDefinitions.Count; m_handItemDefinitions.Add(handItemDef); m_handItemsCombo.AddItem(handItemKey, def.DisplayNameText); } m_handItemsCombo.SortItemsByValueText(); m_handItemsCombo.ItemSelected += handItemsCombo_ItemSelected; }
public override void RecreateControls(bool constructor) { base.RecreateControls(constructor); BackgroundColor = new Vector4(1f, 1f, 1f, 0.5f); m_currentPosition = -m_size.Value / 2.0f + new Vector2(0.02f, 0.13f); AddCaption("Voxel materials", Color.Yellow.ToVector4()); AddShareFocusHint(); m_materialsCombo = AddCombo(); var defList = MyDefinitionManager.Static.GetVoxelMaterialDefinitions().OrderBy(x => x.Id.SubtypeName).ToList(); foreach (var material in defList) { m_materialsCombo.AddItem(material.Index, new StringBuilder(material.Id.SubtypeName)); } m_materialsCombo.ItemSelected += materialsCombo_OnSelect; m_currentPosition.Y += 0.01f; m_sliderInitialScale = AddSlider("Initial scale", 0, 1f, 100f, null); m_sliderScaleMultiplier = AddSlider("Scale multiplier", 0, 1f, 100f, null); m_sliderInitialDistance = AddSlider("Initial distance", 0, 1f, 100f, null); m_sliderDistanceMultiplier = AddSlider("Distance multiplier", 0, 1f, 100f, null); m_sliderFar1Distance = AddSlider("Far1 distance", 0, 0f, 20000f, null); m_sliderFar1Scale = AddSlider("Far1 scale", 0, 1f, 50000f, null); m_sliderFar2Distance = AddSlider("Far2 distance", 0, 0f, 20000f, null); m_sliderFar2Scale = AddSlider("Far2 scale", 0, 1f, 50000f, null); m_sliderFar3Distance = AddSlider("Far3 distance", 0, 0f, 40000f, null); m_sliderFar3Scale = AddSlider("Far3 scale", 0, 1f, 50000f, null); m_sliderExtScale = AddSlider("Detail scale (/1000)", 0, 0.01f, 1f, null); m_materialsCombo.SelectItemByIndex(0); m_colorFar3 = AddColor(new StringBuilder("Far3 color"), m_selectedVoxelMaterial, MemberHelper.GetMember(() => m_selectedVoxelMaterial.Far3Color)); m_colorFar3.SetColor(m_selectedVoxelMaterial.Far3Color); m_currentPosition.Y += 0.01f; AddButton(new StringBuilder("Reload definition"), OnReloadDefinition); }
public override void RecreateControls(bool constructor) { base.RecreateControls(constructor); var caption = AddCaption(MySpaceTexts.PlayerCharacterModel); var listSize = MyGuiControlListbox.GetVisualStyle(MyGuiControlListboxStyleEnum.Default).ItemSize; //m_modelPicker = new MyGuiControlCombobox(position: new Vector2(0f, -0.18f)); float currY = -0.19f; m_modelPicker = new MyGuiControlCombobox(position: new Vector2(0f, currY)); foreach (var entry in m_displayModels) m_modelPicker.AddItem(entry.Value, new StringBuilder(entry.Key)); if (m_displayModels.ContainsKey(m_selectedModel)) m_modelPicker.SelectItemByKey(m_displayModels[m_selectedModel]); else if (m_displayModels.Count > 0) m_modelPicker.SelectItemByKey(m_displayModels.First().Value); else System.Diagnostics.Debug.Fail("No character models loaded."); m_modelPicker.ItemSelected += OnItemSelected; currY += 0.045f; var positionOffset = listSize + caption.Size; m_position.X -= (positionOffset.X / 2.5f); m_position.Y += (positionOffset.Y * 3.6f); Controls.Add(new MyGuiControlLabel(position: new Vector2(0f, currY), text: MyTexts.GetString(MySpaceTexts.PlayerCharacterColor), originAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER)); currY += 0.04f; Controls.Add( new MyGuiControlLabel(position: new Vector2(-0.135f, currY), text: "Hue:", originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); m_labelHue = new MyGuiControlLabel(position: new Vector2(0.090f, currY), text: String.Empty, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); currY += 0.035f; m_sliderHue = new MyGuiControlSlider( position: new Vector2(-0.135f, currY), width: 0.3f, minValue: 0, maxValue: 360, labelDecimalPlaces: 0, labelSpaceWidth: 50 / 1200f, intValue: true, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, visualStyle: MyGuiControlSliderStyleEnum.Hue ); currY += 0.045f; Controls.Add(new MyGuiControlLabel(position: new Vector2(-0.135f, currY), text: "Saturation:", originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); m_labelSaturation = new MyGuiControlLabel(position: new Vector2(0.09f, currY), text: String.Empty, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); currY += 0.035f; m_sliderSaturation = new MyGuiControlSlider( position: new Vector2(-0.135f, currY), width: 0.3f, minValue: -100, maxValue: 100, defaultValue: 0, labelDecimalPlaces: 0, labelSpaceWidth: 50 / 1200f, intValue: true, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER ); currY += 0.045f; Controls.Add(new MyGuiControlLabel(position: new Vector2(-0.135f, currY), text: "Value:", originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); m_labelValue = new MyGuiControlLabel(position: new Vector2(0.09f, currY), text: String.Empty, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); currY += 0.035f; m_sliderValue = new MyGuiControlSlider( position: new Vector2(-0.135f, currY), width: 0.3f, minValue: -100, maxValue: 100, defaultValue: 0, labelDecimalPlaces: 0, labelSpaceWidth: 50 / 1200f, intValue: true, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER ); currY += 0.045f; Controls.Add(caption); Controls.Add(m_modelPicker); Controls.Add(m_labelHue); Controls.Add(m_labelSaturation); Controls.Add(m_labelValue); Controls.Add(m_sliderHue); Controls.Add(m_sliderSaturation); Controls.Add(m_sliderValue); Controls.Add(new MyGuiControlButton(position: new Vector2(0f, 0.16f), text: new StringBuilder("OK"), onButtonClick: OnOkClick)); Controls.Add(new MyGuiControlButton(position: new Vector2(0f, 0.22f), text: new StringBuilder("Cancel"), onButtonClick: OnCancelClick)); }
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); }
public override void RecreateControls(bool constructor) { if (!constructor) return; base.RecreateControls(constructor); AddCaption("Display settings"); var tmp = new Vector2(0.268f, 0.145f) * MyGuiConstants.GUI_OPTIMAL_SIZE; var topLeft = m_size.Value * -0.5f; var topRight = m_size.Value * new Vector2(0.5f, -0.5f); Vector2 comboboxSize = new Vector2(600f, 0f) / MyGuiConstants.GUI_OPTIMAL_SIZE; Vector2 controlsOriginLeft = topLeft + new Vector2(75f, 125f) / MyGuiConstants.GUI_OPTIMAL_SIZE; Vector2 controlsOriginRight = topRight + new Vector2(-650f, 125f) / MyGuiConstants.GUI_OPTIMAL_SIZE; const float TEXT_SCALE = Sandbox.Graphics.GUI.MyGuiConstants.DEFAULT_TEXT_SCALE * 0.85f; var labelVideoAdapter = new MyGuiControlLabel(textScale: TEXT_SCALE, text: MyTexts.GetString(MySpaceTexts.VideoAdapter)); var labelResolution = new MyGuiControlLabel(textScale: TEXT_SCALE, text: MyTexts.GetString(MySpaceTexts.VideoMode)); var labelWindowMode = new MyGuiControlLabel(textScale: TEXT_SCALE, text: MyTexts.GetString(MySpaceTexts.ScreenOptionsVideo_WindowMode)); var labelVSync = new MyGuiControlLabel(textScale: TEXT_SCALE, text: MyTexts.GetString(MySpaceTexts.VerticalSync)); m_comboVideoAdapter = new MyGuiControlCombobox(size: comboboxSize, toolTip: MyTexts.GetString(MySpaceTexts.ToolTipVideoOptionsVideoAdapter)); m_comboResolution = new MyGuiControlCombobox(size: comboboxSize, toolTip: MyTexts.GetString(MySpaceTexts.ToolTipVideoOptionsVideoMode)); m_comboWindowMode = new MyGuiControlCombobox(size: comboboxSize); m_checkboxVSync = new MyGuiControlCheckbox(toolTip: MyTexts.GetString(MySpaceTexts.ToolTipVideoOptionsVerticalSync)); m_labelUnsupportedAspectRatio = new MyGuiControlLabel(colorMask: MyGuiConstants.LABEL_TEXT_COLOR * 0.9f, textScale: TEXT_SCALE * 0.85f); m_labelRecommendAspectRatio = new MyGuiControlLabel(colorMask: MyGuiConstants.LABEL_TEXT_COLOR * 0.9f, textScale: TEXT_SCALE * 0.85f); var hintLineOffset = new Vector2(0f, m_labelUnsupportedAspectRatio.Size.Y); var hintOffset = new Vector2(0.01f, -0.35f * MyGuiConstants.CONTROLS_DELTA.Y); labelVideoAdapter.Position = controlsOriginLeft; controlsOriginLeft += MyGuiConstants.CONTROLS_DELTA; m_comboVideoAdapter.Position = controlsOriginRight; controlsOriginRight += MyGuiConstants.CONTROLS_DELTA; labelResolution.Position = controlsOriginLeft; controlsOriginLeft += MyGuiConstants.CONTROLS_DELTA; m_comboResolution.Position = controlsOriginRight; controlsOriginRight += MyGuiConstants.CONTROLS_DELTA; m_labelUnsupportedAspectRatio.Position = controlsOriginRight + hintOffset; m_labelRecommendAspectRatio.Position = controlsOriginRight + hintOffset + hintLineOffset; controlsOriginLeft += MyGuiConstants.CONTROLS_DELTA; controlsOriginRight += MyGuiConstants.CONTROLS_DELTA; labelWindowMode.Position = controlsOriginLeft; controlsOriginLeft += MyGuiConstants.CONTROLS_DELTA; m_comboWindowMode.Position = controlsOriginRight; controlsOriginRight += MyGuiConstants.CONTROLS_DELTA; labelVSync.Position = controlsOriginLeft; controlsOriginLeft += MyGuiConstants.CONTROLS_DELTA; m_checkboxVSync.Position = controlsOriginRight; controlsOriginRight += MyGuiConstants.CONTROLS_DELTA; Controls.Add(labelVideoAdapter); Controls.Add(m_comboVideoAdapter); Controls.Add(labelResolution); Controls.Add(m_comboResolution); Controls.Add(m_labelUnsupportedAspectRatio); Controls.Add(m_labelRecommendAspectRatio); Controls.Add(labelWindowMode); Controls.Add(m_comboWindowMode); Controls.Add(labelVSync); Controls.Add(m_checkboxVSync); foreach (var control in Controls) control.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER; m_labelUnsupportedAspectRatio.Text = string.Format("* {0}", MyTexts.Get(MySpaceTexts.UnsupportedAspectRatio)); { // AddAdaptersToComboBox int counter = 0; foreach (var adapter in MyVideoSettingsManager.Adapters) { m_comboVideoAdapter.AddItem(counter++, new StringBuilder(adapter.Name)); } } // These options show up if there are no supported display modes m_comboWindowMode.AddItem((int)MyWindowModeEnum.Window, MySpaceTexts.ScreenOptionsVideo_WindowMode_Window); m_comboWindowMode.AddItem((int)MyWindowModeEnum.FullscreenWindow, MySpaceTexts.ScreenOptionsVideo_WindowMode_FullscreenWindow); m_comboVideoAdapter.ItemSelected += ComboVideoAdapter_ItemSelected; m_comboResolution.ItemSelected += ComboResolution_ItemSelected; // Buttons Ok and Cancel Controls.Add(new MyGuiControlButton( position: Size.Value * new Vector2(-0.5f, 0.5f) + new Vector2(100f, -75f) / MyGuiConstants.GUI_OPTIMAL_SIZE, size: MyGuiConstants.OK_BUTTON_SIZE, text: MyTexts.Get(MySpaceTexts.Ok), onButtonClick: OnOkClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM)); Controls.Add(new MyGuiControlButton( position: Size.Value * new Vector2(0.5f, 0.5f) + new Vector2(-100f, -75f) / MyGuiConstants.GUI_OPTIMAL_SIZE, size: MyGuiConstants.OK_BUTTON_SIZE, text: MyTexts.Get(MySpaceTexts.Cancel), onButtonClick: OnCancelClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM)); // Update controls with values from config file m_settingsOld = MyVideoSettingsManager.CurrentDeviceSettings; m_settingsNew = m_settingsOld; WriteSettingsToControls(m_settingsOld); // Update OLD settings ReadSettingsFromControls(ref m_settingsOld); ReadSettingsFromControls(ref m_settingsNew); CloseButtonEnabled = true; CloseButtonOffset = new Vector2(-50f, 50f) / MyGuiConstants.GUI_OPTIMAL_SIZE; }
private void CreateAsteroidsSpawnMenu(float separatorSize, float usableWidth) { AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_Asteroid), Vector4.One, m_scale); m_asteroidCombobox = AddCombo(); { foreach (var definition in MyDefinitionManager.Static.GetVoxelMapStorageDefinitions()) { m_asteroidCombobox.AddItem((int)definition.Id.SubtypeId, definition.Id.SubtypeId.ToString()); } m_asteroidCombobox.ItemSelected += OnAsteroidCombobox_ItemSelected; m_asteroidCombobox.SortItemsByValueText(); m_asteroidCombobox.SelectItemByIndex(m_lastSelectedAsteroidIndex); } m_currentPosition.Y += separatorSize; AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_AsteroidGenerationCanTakeLong), Color.Red.ToVector4(), m_scale); CreateDebugButton(usableWidth, MySpaceTexts.ScreenDebugSpawnMenu_SpawnAsteroid, OnLoadAsteroid); m_currentPosition.Y += separatorSize; }
private void CreatePlanetsSpawnMenu(float separatorSize, float usableWidth) { float min = MyFakes.ENABLE_EXTENDED_PLANET_OPTIONS ? 100 : 19000; float max = /*MyFakes.ENABLE_EXTENDED_PLANET_OPTIONS ? (6378.1f * 1000 * 2) :*/ 120000f; MyGuiControlSlider slider = null; slider = new MyGuiControlSlider( position: m_currentPosition, width: 400f / MyGuiConstants.GUI_OPTIMAL_SIZE.X, minValue: min, maxValue: max, labelText: String.Empty, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, labelFont: MyFontEnum.Debug, intValue: true); slider.DebugScale = m_sliderDebugScale; slider.ColorMask = Color.White.ToVector4(); Controls.Add(slider); var label = new MyGuiControlLabel( position: m_currentPosition + new Vector2(slider.Size.X + 0.005f, slider.Size.Y / 2), text: String.Empty, colorMask: Color.White.ToVector4(), textScale: MyGuiConstants.DEFAULT_TEXT_SCALE * 0.8f * m_scale, font: MyFontEnum.Debug); label.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER; Controls.Add(label); m_currentPosition.Y += slider.Size.Y; m_currentPosition.Y += separatorSize; slider.ValueChanged += (MyGuiControlSlider s) => { StringBuilder sb = new StringBuilder(); MyValueFormatter.AppendDistanceInBestUnit(s.Value, sb); label.Text = sb.ToString(); m_procAsteroidSizeValue = s.Value; }; slider.Value = 8000; m_procAsteroidSeed = CreateSeedButton(m_procAsteroidSeedValue, usableWidth); m_planetCombobox = AddCombo(); { foreach (var definition in MyDefinitionManager.Static.GetPlanetsGeneratorsDefinitions()) { m_planetCombobox.AddItem((int)definition.Id.SubtypeId, definition.Id.SubtypeId.ToString()); } m_planetCombobox.ItemSelected += OnPlanetCombobox_ItemSelected; m_planetCombobox.SortItemsByValueText(); m_planetCombobox.SelectItemByIndex(0); } CreateDebugButton(usableWidth, MySpaceTexts.ScreenDebugSpawnMenu_SpawnAsteroid, x => { int seed = GetProceduralAsteroidSeed(m_procAsteroidSeed); CreatePlanet(seed, slider.Value); CloseScreenNow(); }); }
void RecreateOwnershipControls() { bool ownershipBlockPresent = false; foreach (var block in m_currentBlocks) { if (block.IDModule != null) { ownershipBlockPresent = true; } } if (ownershipBlockPresent && MyFakes.SHOW_FACTIONS_GUI) { m_ownershipLabel.Visible = true; m_ownerLabel.Visible = true; m_transferToLabel.Visible = true; m_transferToCombobox.Visible = true; m_shareModeCombobox.Visible = true; if (m_npcButton != null) { m_npcButton.Visible = true; } } else { m_ownershipLabel.Visible = false; m_ownerLabel.Visible = false; m_transferToLabel.Visible = false; m_transferToCombobox.Visible = false; m_shareModeCombobox.Visible = false; if (m_npcButton != null) { m_npcButton.Visible = false; } return; } var topLeftRelative = Vector2.One * -0.5f; Vector2 leftColumnSize = new Vector2(0.3f, 0.55f); m_ownershipLabel.Position = topLeftRelative + new Vector2(leftColumnSize.X + 0.22f, 0.38f); m_ownerLabel.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER; m_ownerLabel.Position = topLeftRelative + new Vector2(leftColumnSize.X + 0.46f, 0.38f); m_transferToLabel.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; m_transferToLabel.Position = topLeftRelative + new Vector2(leftColumnSize.X + 0.22f, 0.405f); m_transferToCombobox.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; m_transferToCombobox.Position = topLeftRelative + new Vector2(leftColumnSize.X + 0.32f, 0.4f); m_shareModeCombobox.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; m_shareModeCombobox.Position = topLeftRelative + new Vector2(leftColumnSize.X + 0.22f, 0.45f); m_shareModeCombobox.ClearItems(); m_shareModeCombobox.AddItem((long)MyOwnershipShareModeEnum.None, MyTexts.Get(MySpaceTexts.BlockOwner_ShareNone)); m_shareModeCombobox.AddItem((long)MyOwnershipShareModeEnum.Faction, MyTexts.Get(MySpaceTexts.BlockOwner_ShareFaction)); m_shareModeCombobox.AddItem((long)MyOwnershipShareModeEnum.All, MyTexts.Get(MySpaceTexts.BlockOwner_ShareAll)); UpdateOwnerGui(); }
public override void RecreateControls(bool constructor) { base.RecreateControls(constructor); if (m_asteroid_showPlanet) { CreatePlanetMenu(); return; } Vector2 cbOffset = new Vector2(-0.05f, 0.0f); Vector2 controlPadding = new Vector2(0.02f, 0.02f); // X: Left & Right, Y: Bottom & Top float textScale = 0.8f; float separatorSize = 0.01f; float usableWidth = SCREEN_SIZE.X - HIDDEN_PART_RIGHT - controlPadding.X * 2; float hiddenPartTop = (SCREEN_SIZE.Y - 1.0f) / 2.0f; m_currentPosition = -m_size.Value / 2.0f; m_currentPosition += controlPadding; m_currentPosition.Y += hiddenPartTop; m_scale = textScale; var caption = AddCaption(MySpaceTexts.ScreenDebugSpawnMenu_Caption, Color.White.ToVector4(), controlPadding + new Vector2(-HIDDEN_PART_RIGHT, hiddenPartTop)); m_currentPosition.Y += MyGuiConstants.SCREEN_CAPTION_DELTA_Y + separatorSize; if (MyFakes.ENABLE_SPAWN_MENU_ASTEROIDS || MyFakes.ENABLE_SPAWN_MENU_PROCEDURAL_ASTEROIDS) { AddSubcaption(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_Asteroids), Color.White.ToVector4(), new Vector2(-HIDDEN_PART_RIGHT, 0.0f)); } if (MyFakes.ENABLE_SPAWN_MENU_ASTEROIDS && MyFakes.ENABLE_SPAWN_MENU_PROCEDURAL_ASTEROIDS) { AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_SelectAsteroidType), Vector4.One, m_scale); var combo = AddCombo(); combo.AddItem(1, MySpaceTexts.ScreenDebugSpawnMenu_PredefinedAsteroids); combo.AddItem(2, MySpaceTexts.ScreenDebugSpawnMenu_ProceduralAsteroids); // DA: Remove from MySpaceTexts and just hardcode until release. Leave a todo so you don't forget about it before release of planets. combo.AddItem(3, MySpaceTexts.ScreenDebugSpawnMenu_Planets); combo.SelectItemByKey(m_asteroid_showPlanet ? 3 : m_asteroid_showPredefinedOrProcedural ? 1 : 2); combo.ItemSelected += () => { m_asteroid_showPredefinedOrProcedural = combo.GetSelectedKey() == 1; m_asteroid_showPlanet = combo.GetSelectedKey() == 3; RecreateControls(false); }; } if (MyFakes.ENABLE_SPAWN_MENU_ASTEROIDS && m_asteroid_showPredefinedOrProcedural) { AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_Asteroid), Vector4.One, m_scale); m_asteroidCombobox = AddCombo(); { foreach (var definition in MyDefinitionManager.Static.GetVoxelMapStorageDefinitions()) { m_asteroidCombobox.AddItem((int)definition.Id.SubtypeId, definition.Id.SubtypeId.ToString()); } m_asteroidCombobox.ItemSelected += OnAsteroidCombobox_ItemSelected; m_asteroidCombobox.SortItemsByValueText(); m_asteroidCombobox.SelectItemByIndex(m_lastSelectedAsteroidIndex); } m_currentPosition.Y += separatorSize; AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_AsteroidGenerationCanTakeLong), Color.Red.ToVector4(), m_scale); CreateDebugButton(usableWidth, MySpaceTexts.ScreenDebugSpawnMenu_SpawnAsteroid, OnLoadAsteroid); m_currentPosition.Y += separatorSize; } if (MyFakes.ENABLE_SPAWN_MENU_PROCEDURAL_ASTEROIDS && !m_asteroid_showPredefinedOrProcedural) { AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_ProceduralSize), Vector4.One, m_scale); m_procAsteroidSize = new MyGuiControlSlider( position: m_currentPosition, width: 400f / MyGuiConstants.GUI_OPTIMAL_SIZE.X, minValue: 5.0f, maxValue: 500f, labelText: String.Empty, labelDecimalPlaces: 2, labelScale: 0.75f * m_scale, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, labelFont: MyFontEnum.Debug); m_procAsteroidSize.DebugScale = m_sliderDebugScale; m_procAsteroidSize.ColorMask = Color.White.ToVector4(); Controls.Add(m_procAsteroidSize); MyGuiControlLabel label = new MyGuiControlLabel( position: m_currentPosition + new Vector2(m_procAsteroidSize.Size.X + 0.005f, m_procAsteroidSize.Size.Y / 2), text: String.Empty, colorMask: Color.White.ToVector4(), textScale: MyGuiConstants.DEFAULT_TEXT_SCALE * 0.8f * m_scale, font: MyFontEnum.Debug); label.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER; Controls.Add(label); m_procAsteroidSize.ValueChanged += (MyGuiControlSlider s) => { label.Text = MyValueFormatter.GetFormatedFloat(s.Value, 2) + "m"; m_procAsteroidSizeValue = s.Value; }; m_procAsteroidSize.Value = m_procAsteroidSizeValue; m_currentPosition.Y += m_procAsteroidSize.Size.Y; m_currentPosition.Y += separatorSize; AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_ProceduralSeed), Color.White.ToVector4(), m_scale); m_procAsteroidSeed = new MyGuiControlTextbox(m_currentPosition, m_procAsteroidSeedValue, 20, Color.White.ToVector4(), m_scale, MyGuiControlTextboxType.Normal); m_procAsteroidSeed.TextChanged += (MyGuiControlTextbox t) => { m_procAsteroidSeedValue = t.Text; }; m_procAsteroidSeed.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; Controls.Add(m_procAsteroidSeed); m_currentPosition.Y += m_procAsteroidSize.Size.Y + separatorSize; CreateDebugButton(usableWidth, MySpaceTexts.ScreenDebugSpawnMenu_GenerateSeed, generateSeedButton_OnButtonClick); AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_AsteroidGenerationCanTakeLong), Color.Red.ToVector4(), m_scale); CreateDebugButton(usableWidth, MySpaceTexts.ScreenDebugSpawnMenu_SpawnAsteroid, OnSpawnProceduralAsteroid); m_currentPosition.Y += separatorSize; } CreateObjectsSpawnMenu(separatorSize, usableWidth); }
void UdpateCuesCombo(MyGuiControlCombobox box) { box.ClearItems(); long key = 0; foreach (var cue in MyAudio.Static.CueDefinitions) { if ((m_currentCategorySelectedItem == ALL_CATEGORIES) || (m_currentCategorySelectedItem == cue.Category.ToString())) { box.AddItem(key, new StringBuilder(cue.SubtypeId.ToString())); key++; } } box.SortItemsByValueText(); if (box.GetItemsCount() > 0) box.SelectItemByIndex(0); }
public void BuildControls() { MyGuiControlParent parent = new MyGuiControlParent(size: new Vector2(Size.Value.X - 0.05f, Size.Value.Y+0.18f)); MyGuiControlScrollablePanel scrollPanel = new MyGuiControlScrollablePanel(parent); scrollPanel.ScrollbarVEnabled = true; scrollPanel.Size = new Vector2(Size.Value.X - 0.05f, 0.8f); Vector2 buttonSize = MyGuiConstants.BACK_BUTTON_SIZE; Vector2 buttonsOrigin = m_size.Value / 2 - new Vector2(0.23f, 0.03f); AddCaption(MySpaceTexts.ScreenCaptionAdvancedSettings); int numControls = 0; var passwordLabel = MakeLabel(MySpaceTexts.WorldSettings_Password); var onlineModeLabel = MakeLabel(MySpaceTexts.WorldSettings_OnlineMode); m_maxPlayersLabel = MakeLabel(MySpaceTexts.MaxPlayers); m_maxFloatingObjectsLabel = MakeLabel(MySpaceTexts.MaxFloatingObjects); m_sunRotationPeriod = MakeLabel(MySpaceTexts.SunRotationPeriod); m_sunRotationPeriodValue = MakeLabel(MySpaceTexts.SunRotationPeriod); var gameTypeLabel = MakeLabel(MySpaceTexts.WorldSettings_GameMode); var environmentLabel = MakeLabel(MySpaceTexts.WorldSettings_EnvironmentHostility); var gameStyleLabel = MakeLabel(MySpaceTexts.WorldSettings_GameStyle); var scenarioLabel = MakeLabel(MySpaceTexts.WorldSettings_Scenario); var autoHealingLabel = MakeLabel(MySpaceTexts.WorldSettings_AutoHealing); var thrusterDamageLabel = MakeLabel(MySpaceTexts.WorldSettings_ThrusterDamage); var enableSpectatorLabel = MakeLabel(MySpaceTexts.WorldSettings_EnableSpectator); var resetOwnershipLabel = MakeLabel(MySpaceTexts.WorldSettings_ResetOwnership); var permanentDeathLabel = MakeLabel(MySpaceTexts.WorldSettings_PermanentDeath); var destructibleBlocksLabel = MakeLabel(MySpaceTexts.WorldSettings_DestructibleBlocks); var enableIngameScriptsLabel = MakeLabel(MySpaceTexts.WorldSettings_EnableIngameScripts); var enable3rdPersonCameraLabel = MakeLabel(MySpaceTexts.WorldSettings_Enable3rdPersonCamera); var enableEncountersLabel = MakeLabel(MySpaceTexts.WorldSettings_Encounters); var enableToolShakeLabel = MakeLabel(MySpaceTexts.WorldSettings_EnableToolShake); var shipsEnabledLabel = MakeLabel(MySpaceTexts.WorldSettings_EnableCargoShips); var soundInSpaceLabel = MakeLabel(MySpaceTexts.WorldSettings_SoundInSpace); var friendlyFireLabel = MakeLabel(MySpaceTexts.WorldSettings_FriendlyFire); var clientCanSaveLabel = MakeLabel(MySpaceTexts.WorldSettings_ClientCanSave); m_enableCopyPasteLabel = MakeLabel(MySpaceTexts.WorldSettings_EnableCopyPaste); var enableWeaponsLabel = MakeLabel(MySpaceTexts.WorldSettings_EnableWeapons); var showPlayerNamesOnHudLabel = MakeLabel(MySpaceTexts.WorldSettings_ShowPlayerNamesOnHud); var inventorySizeLabel = MakeLabel(MySpaceTexts.WorldSettings_InventorySize); var refineryEfficiencyLabel = MakeLabel(MySpaceTexts.WorldSettings_RefinerySpeed); var assemblerEfficiencyLabel = MakeLabel(MySpaceTexts.WorldSettings_AssemblerEfficiency); var trashRemovalLabel = MakeLabel(MySpaceTexts.WorldSettings_RemoveTrash); var oxygenLabel = MakeLabel(MySpaceTexts.World_Settings_EnableOxygen); var disableRespawnShipsLabel = MakeLabel(MySpaceTexts.WorldSettings_DisableRespawnShips); var respawnShipDeleteLabel = MakeLabel(MySpaceTexts.WorldSettings_RespawnShipDelete); var worldSizeLabel = MakeLabel(MySpaceTexts.WorldSettings_LimitWorldSize); var weldingSpeedLabel = MakeLabel(MySpaceTexts.WorldSettings_WelderSpeed); var grindingSpeedLabel = MakeLabel(MySpaceTexts.WorldSettings_GrinderSpeed); var soundModeLabel = MakeLabel(MySpaceTexts.WorldSettings_SoundMode); var spawnShipTimeLabel = MakeLabel(MySpaceTexts.WorldSettings_RespawnShipCooldown); var viewDistanceLabel = MakeLabel(MySpaceTexts.WorldSettings_ViewDistance); var physicsOptionLabel = MakeLabel(MySpaceTexts.WorldSettings_Physics); var enableStationVoxelLabel = MakeLabel(MySpaceTexts.WorldSettings_EnableStationVoxel); var enableSunRotationLabel = MakeLabel(MySpaceTexts.WorldSettings_EnableSunRotation); var enableJetpackLabel = MakeLabel(MySpaceTexts.WorldSettings_EnableJetpack); var spawnWithToolsLabel = MakeLabel(MySpaceTexts.WorldSettings_SpawnWithTools); var startInRespawnScreenLabel = MakeLabel(MySpaceTexts.WorldSettings_StartInRespawnScreen); var enableVoxelDestructionLabel = MakeLabel(MySpaceTexts.WorldSettings_EnableVoxelDestruction); float width = 0.284375f + 0.025f; m_passwordTextbox = new MyGuiControlTextbox(maxLength: 256); m_onlineMode = new MyGuiControlCombobox(size: new Vector2(width, 0.04f)); m_environment = new MyGuiControlCombobox(size: new Vector2(width, 0.04f)); m_autoHealing = new MyGuiControlCheckbox(); m_thrusterDamage = new MyGuiControlCheckbox(); m_cargoShipsEnabled = new MyGuiControlCheckbox(); m_enableSpectator = new MyGuiControlCheckbox(); m_resetOwnership = new MyGuiControlCheckbox(); m_permanentDeath = new MyGuiControlCheckbox(); m_destructibleBlocks = new MyGuiControlCheckbox(); m_enableIngameScripts = new MyGuiControlCheckbox(); m_enable3rdPersonCamera = new MyGuiControlCheckbox(); m_enableEncounters = new MyGuiControlCheckbox(); m_disableRespawnShips = new MyGuiControlCheckbox(); m_enableToolShake = new MyGuiControlCheckbox(); m_enableOxygen = new MyGuiControlCheckbox(); m_enableOxygen.IsCheckedChanged = (x) => { if (m_showWarningForOxygen && x.IsChecked) { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( buttonType: MyMessageBoxButtonsType.YES_NO, messageText: MyTexts.Get(MySpaceTexts.MessageBoxTextAreYouSureEnableOxygen), messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionPleaseConfirm), callback: (v) => { if (v == MyGuiScreenMessageBox.ResultEnum.NO) { x.IsChecked = false; } })); } }; m_clientCanSave = new MyGuiControlCheckbox(); m_enableCopyPaste = new MyGuiControlCheckbox(); m_weaponsEnabled = new MyGuiControlCheckbox(); m_showPlayerNamesOnHud = new MyGuiControlCheckbox(); m_enableSunRotation = new MyGuiControlCheckbox(); m_enableSunRotation.IsCheckedChanged = (control) => { m_sunRotationIntervalSlider.Enabled = control.IsChecked; m_sunRotationPeriodValue.Visible = control.IsChecked; }; m_enableJetpack = new MyGuiControlCheckbox(); m_spawnWithTools = new MyGuiControlCheckbox(); m_stationVoxelSupport = new MyGuiControlCheckbox(); 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_maxFloatingObjectsSlider = new MyGuiControlSlider( position: Vector2.Zero, width: m_onlineMode.Size.X, minValue: 16, maxValue: 1024, labelText: new StringBuilder("{0}").ToString(), labelDecimalPlaces: 0, labelSpaceWidth: 0.05f, intValue: true ); m_startInRespawnScreen = new MyGuiControlCheckbox(); m_enableVoxelDestruction = new MyGuiControlCheckbox(); m_trashRemoval = new MyGuiControlCheckbox(); m_respawnShipDelete = new MyGuiControlCheckbox(); m_worldSizeCombo = new MyGuiControlCombobox(size: new Vector2(width, 0.04f)); m_soundModeCombo = new MyGuiControlCombobox(size: new Vector2(width, 0.04f)); m_spawnShipTimeCombo = new MyGuiControlCombobox(size: new Vector2(width, 0.04f)); m_viewDistanceCombo = new MyGuiControlCombobox(size: new Vector2(width, 0.04f)); m_physicsOptionsCombo = new MyGuiControlCombobox(size: new Vector2(width, 0.04f)); // 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); m_creativeModeButton = new MyGuiControlButton(visualStyle: MyGuiControlButtonStyleEnum.Small, highlightType: MyGuiControlHighlightType.WHEN_ACTIVE, text: MyTexts.Get(MySpaceTexts.WorldSettings_GameModeCreative), onButtonClick: CreativeClicked); m_creativeModeButton.SetToolTip(MySpaceTexts.ToolTipWorldSettingsModeCreative); m_survivalModeButton = new MyGuiControlButton(visualStyle: MyGuiControlButtonStyleEnum.Small, highlightType: MyGuiControlHighlightType.WHEN_ACTIVE, text: MyTexts.Get(MySpaceTexts.WorldSettings_GameModeSurvival), onButtonClick: SurvivalClicked); m_survivalModeButton.SetToolTip(MySpaceTexts.ToolTipWorldSettingsModeSurvival); m_inventory_x1 = new MyGuiControlButton(visualStyle: MyGuiControlButtonStyleEnum.Small, highlightType: MyGuiControlHighlightType.WHEN_ACTIVE, text: MyTexts.Get(MySpaceTexts.WorldSettings_Realistic), onButtonClick: OnInventoryClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); m_inventory_x3 = new MyGuiControlButton(visualStyle: MyGuiControlButtonStyleEnum.Tiny, highlightType: MyGuiControlHighlightType.WHEN_ACTIVE, text: MyTexts.Get(MySpaceTexts.WorldSettings_Realistic_x3), onButtonClick: OnInventoryClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); m_inventory_x10 = new MyGuiControlButton(visualStyle: MyGuiControlButtonStyleEnum.Tiny, highlightType: MyGuiControlHighlightType.WHEN_ACTIVE, text: MyTexts.Get(MySpaceTexts.WorldSettings_Realistic_x10), onButtonClick: OnInventoryClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); m_inventory_x1.UserData = 1.0f; m_inventory_x3.UserData = 3.0f; m_inventory_x10.UserData = 10.0f; m_inventory_x1.SetToolTip(MySpaceTexts.ToolTipWorldSettings_Inventory_x1); m_inventory_x3.SetToolTip(MySpaceTexts.ToolTipWorldSettings_Inventory_x3); m_inventory_x10.SetToolTip(MySpaceTexts.ToolTipWorldSettings_Inventory_x10); m_assembler_x1 = new MyGuiControlButton(visualStyle: MyGuiControlButtonStyleEnum.Small, highlightType: MyGuiControlHighlightType.WHEN_ACTIVE, text: MyTexts.Get(MySpaceTexts.WorldSettings_Realistic), onButtonClick: OnAssemblerClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); m_assembler_x3 = new MyGuiControlButton(visualStyle: MyGuiControlButtonStyleEnum.Tiny, highlightType: MyGuiControlHighlightType.WHEN_ACTIVE, text: MyTexts.Get(MySpaceTexts.WorldSettings_Realistic_x3), onButtonClick: OnAssemblerClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); m_assembler_x10 = new MyGuiControlButton(visualStyle: MyGuiControlButtonStyleEnum.Tiny, highlightType: MyGuiControlHighlightType.WHEN_ACTIVE, text: MyTexts.Get(MySpaceTexts.WorldSettings_Realistic_x10), onButtonClick: OnAssemblerClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); m_assembler_x1.UserData = 1.0f; m_assembler_x3.UserData = 3.0f; m_assembler_x10.UserData = 10.0f; m_assembler_x1.SetToolTip(MySpaceTexts.ToolTipWorldSettings_Assembler_x1); m_assembler_x3.SetToolTip(MySpaceTexts.ToolTipWorldSettings_Assembler_x3); m_assembler_x10.SetToolTip(MySpaceTexts.ToolTipWorldSettings_Assembler_x10); m_refinery_x1 = new MyGuiControlButton(visualStyle: MyGuiControlButtonStyleEnum.Small, highlightType: MyGuiControlHighlightType.WHEN_ACTIVE, text: MyTexts.Get(MySpaceTexts.WorldSettings_Realistic), onButtonClick: OnRefineryClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); m_refinery_x3 = new MyGuiControlButton(visualStyle: MyGuiControlButtonStyleEnum.Tiny, highlightType: MyGuiControlHighlightType.WHEN_ACTIVE, text: MyTexts.Get(MySpaceTexts.WorldSettings_Realistic_x3), onButtonClick: OnRefineryClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); m_refinery_x10 = new MyGuiControlButton(visualStyle: MyGuiControlButtonStyleEnum.Tiny, highlightType: MyGuiControlHighlightType.WHEN_ACTIVE, text: MyTexts.Get(MySpaceTexts.WorldSettings_Realistic_x10), onButtonClick: OnRefineryClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); m_refinery_x1.UserData = 1.0f; m_refinery_x3.UserData = 3.0f; m_refinery_x10.UserData = 10.0f; m_refinery_x1.SetToolTip(MySpaceTexts.ToolTipWorldSettings_Refinery_x1); m_refinery_x3.SetToolTip(MySpaceTexts.ToolTipWorldSettings_Refinery_x3); m_refinery_x10.SetToolTip(MySpaceTexts.ToolTipWorldSettings_Refinery_x10); m_welder_half = new MyGuiControlButton(visualStyle: MyGuiControlButtonStyleEnum.Tiny, highlightType: MyGuiControlHighlightType.WHEN_ACTIVE, text: MyTexts.Get(MySpaceTexts.WorldSettings_Realistic_half), onButtonClick: OnWelderClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, textScale: MyGuiConstants.HUD_TEXT_SCALE); m_welder_x1 = new MyGuiControlButton(visualStyle: MyGuiControlButtonStyleEnum.Small, highlightType: MyGuiControlHighlightType.WHEN_ACTIVE, text: MyTexts.Get(MySpaceTexts.WorldSettings_Realistic), onButtonClick: OnWelderClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); m_welder_x2 = new MyGuiControlButton(visualStyle: MyGuiControlButtonStyleEnum.Tiny, highlightType: MyGuiControlHighlightType.WHEN_ACTIVE, text: MyTexts.Get(MySpaceTexts.WorldSettings_Realistic_x2), onButtonClick: OnWelderClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); m_welder_x5 = new MyGuiControlButton(visualStyle: MyGuiControlButtonStyleEnum.Tiny, highlightType: MyGuiControlHighlightType.WHEN_ACTIVE, text: MyTexts.Get(MySpaceTexts.WorldSettings_Realistic_x5), onButtonClick: OnWelderClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); m_welder_half.UserData = 0.5f; m_welder_x1.UserData = 1.0f; m_welder_x2.UserData = 2.0f; m_welder_x5.UserData = 5.0f; m_welder_half.SetToolTip(MySpaceTexts.ToolTipWorldSettings_Welder_half); m_welder_x1.SetToolTip(MySpaceTexts.ToolTipWorldSettings_Welder_x1); m_welder_x2.SetToolTip(MySpaceTexts.ToolTipWorldSettings_Welder_x2); m_welder_x5.SetToolTip(MySpaceTexts.ToolTipWorldSettings_Welder_x5); m_grinder_half = new MyGuiControlButton(visualStyle: MyGuiControlButtonStyleEnum.Tiny, highlightType: MyGuiControlHighlightType.WHEN_ACTIVE, text: MyTexts.Get(MySpaceTexts.WorldSettings_Realistic_half), onButtonClick: OnGrinderClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, textScale: MyGuiConstants.HUD_TEXT_SCALE); m_grinder_x1 = new MyGuiControlButton(visualStyle: MyGuiControlButtonStyleEnum.Small, highlightType: MyGuiControlHighlightType.WHEN_ACTIVE, text: MyTexts.Get(MySpaceTexts.WorldSettings_Realistic), onButtonClick: OnGrinderClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); m_grinder_x2 = new MyGuiControlButton(visualStyle: MyGuiControlButtonStyleEnum.Tiny, highlightType: MyGuiControlHighlightType.WHEN_ACTIVE, text: MyTexts.Get(MySpaceTexts.WorldSettings_Realistic_x2), onButtonClick: OnGrinderClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); m_grinder_x5 = new MyGuiControlButton(visualStyle: MyGuiControlButtonStyleEnum.Tiny, highlightType: MyGuiControlHighlightType.WHEN_ACTIVE, text: MyTexts.Get(MySpaceTexts.WorldSettings_Realistic_x5), onButtonClick: OnGrinderClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); m_grinder_half.UserData = 0.5f; m_grinder_x1.UserData = 1.0f; m_grinder_x2.UserData = 2.0f; m_grinder_x5.UserData = 5.0f; m_grinder_half.SetToolTip(MySpaceTexts.ToolTipWorldSettings_Grinder_half); m_grinder_x1.SetToolTip(MySpaceTexts.ToolTipWorldSettings_Grinder_x1); m_grinder_x2.SetToolTip(MySpaceTexts.ToolTipWorldSettings_Grinder_x2); m_grinder_x5.SetToolTip(MySpaceTexts.ToolTipWorldSettings_Grinder_x5); 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_environment.AddItem((int)MyEnvironmentHostilityEnum.SAFE, MySpaceTexts.WorldSettings_EnvironmentHostilitySafe); m_environment.AddItem((int)MyEnvironmentHostilityEnum.NORMAL, MySpaceTexts.WorldSettings_EnvironmentHostilityNormal); m_environment.AddItem((int)MyEnvironmentHostilityEnum.CATACLYSM, MySpaceTexts.WorldSettings_EnvironmentHostilityCataclysm); m_environment.AddItem((int)MyEnvironmentHostilityEnum.CATACLYSM_UNREAL, MySpaceTexts.WorldSettings_EnvironmentHostilityCataclysmUnreal); m_worldSizeCombo.AddItem((int)MyWorldSizeEnum.TEN_KM, MySpaceTexts.WorldSettings_WorldSize10Km); m_worldSizeCombo.AddItem((int)MyWorldSizeEnum.TWENTY_KM, MySpaceTexts.WorldSettings_WorldSize20Km); m_worldSizeCombo.AddItem((int)MyWorldSizeEnum.FIFTY_KM, MySpaceTexts.WorldSettings_WorldSize50Km); m_worldSizeCombo.AddItem((int)MyWorldSizeEnum.HUNDRED_KM, MySpaceTexts.WorldSettings_WorldSize100Km); m_worldSizeCombo.AddItem((int)MyWorldSizeEnum.UNLIMITED, MySpaceTexts.WorldSettings_WorldSizeUnlimited); m_soundModeCombo.AddItem((int)MySoundModeEnum.Arcade, MySpaceTexts.WorldSettings_ArcadeSound); m_soundModeCombo.AddItem((int)MySoundModeEnum.Realistic, MySpaceTexts.WorldSettings_RealisticSound); // Keys will be 10x the represented value (to be able to set them as integers) m_spawnShipTimeCombo.AddItem((int)0, MySpaceTexts.WorldSettings_RespawnShip_CooldownsDisabled); m_spawnShipTimeCombo.AddItem((int)1, MySpaceTexts.WorldSettings_RespawnShip_x01); m_spawnShipTimeCombo.AddItem((int)2, MySpaceTexts.WorldSettings_RespawnShip_x02); m_spawnShipTimeCombo.AddItem((int)5, MySpaceTexts.WorldSettings_RespawnShip_x05); m_spawnShipTimeCombo.AddItem((int)10, MySpaceTexts.WorldSettings_RespawnShip_Default); m_spawnShipTimeCombo.AddItem((int)20, MySpaceTexts.WorldSettings_RespawnShip_x2); m_spawnShipTimeCombo.AddItem((int)50, MySpaceTexts.WorldSettings_RespawnShip_x5); m_spawnShipTimeCombo.AddItem((int)100, MySpaceTexts.WorldSettings_RespawnShip_x10); m_spawnShipTimeCombo.AddItem((int)200, MySpaceTexts.WorldSettings_RespawnShip_x20); m_spawnShipTimeCombo.AddItem((int)500, MySpaceTexts.WorldSettings_RespawnShip_x50); m_spawnShipTimeCombo.AddItem((int)1000, MySpaceTexts.WorldSettings_RespawnShip_x100); m_viewDistanceCombo.AddItem((int)MyViewDistanceEnum.FIVE_KM, MySpaceTexts.WorldSettings_ViewDistance_5_Km); m_viewDistanceCombo.AddItem((int)MyViewDistanceEnum.SEVEN_KM, MySpaceTexts.WorldSettings_ViewDistance_7_Km); m_viewDistanceCombo.AddItem((int)MyViewDistanceEnum.TEN_KM, MySpaceTexts.WorldSettings_ViewDistance_10_Km); m_viewDistanceCombo.AddItem((int)MyViewDistanceEnum.FIFTEEN_KM, MySpaceTexts.WorldSettings_ViewDistance_15_Km); m_viewDistanceCombo.AddItem((int)MyViewDistanceEnum.TWENTY_KM, MySpaceTexts.WorldSettings_ViewDistance_20_Km); m_viewDistanceCombo.AddItem((int)MyViewDistanceEnum.THIRTY_KM, MySpaceTexts.WorldSettings_ViewDistance_30_Km); m_viewDistanceCombo.AddItem((int)MyViewDistanceEnum.FORTY_KM, MySpaceTexts.WorldSettings_ViewDistance_40_Km); m_viewDistanceCombo.AddItem((int)MyViewDistanceEnum.FIFTY_KM, MySpaceTexts.WorldSettings_ViewDistance_50_Km); m_physicsOptionsCombo.SetToolTip(MySpaceTexts.WorldSettings_Physics_Tooltip); m_physicsOptionsCombo.AddItem((int)MyPhysicsPerformanceEnum.Fast, MySpaceTexts.WorldSettings_Physics_Fast); m_physicsOptionsCombo.AddItem((int)MyPhysicsPerformanceEnum.Normal, MySpaceTexts.WorldSettings_Physics_Normal); m_physicsOptionsCombo.AddItem((int)MyPhysicsPerformanceEnum.Precise, MySpaceTexts.WorldSettings_Physics_Precise); m_autoHealing.SetToolTip(MyTexts.GetString(MySpaceTexts.ToolTipWorldSettingsAutoHealing)); m_thrusterDamage.SetToolTip(MyTexts.GetString(MySpaceTexts.ToolTipWorldSettingsThrusterDamage)); m_cargoShipsEnabled.SetToolTip(MyTexts.GetString(MySpaceTexts.ToolTipWorldSettingsEnableCargoShips)); m_enableSpectator.SetToolTip(MyTexts.GetString(MySpaceTexts.ToolTipWorldSettingsEnableSpectator)); m_resetOwnership.SetToolTip(MyTexts.GetString(MySpaceTexts.ToolTipWorldSettingsResetOwnership)); m_permanentDeath.SetToolTip(MyTexts.GetString(MySpaceTexts.ToolTipWorldSettingsPermanentDeath)); m_destructibleBlocks.SetToolTip(MyTexts.GetString(MySpaceTexts.ToolTipWorldSettingsDestructibleBlocks)); m_environment.SetToolTip(MyTexts.GetString(MySpaceTexts.ToolTipWorldSettingsEnvironment)); m_onlineMode.SetToolTip(MyTexts.GetString(MySpaceTexts.ToolTipWorldSettingsOnlineMode)); m_enableCopyPaste.SetToolTip(MyTexts.GetString(MySpaceTexts.ToolTipWorldSettingsEnableCopyPaste)); m_showPlayerNamesOnHud.SetToolTip(MyTexts.GetString(MySpaceTexts.ToolTipWorldSettingsShowPlayerNamesOnHud)); m_maxFloatingObjectsSlider.SetToolTip(MyTexts.GetString(MySpaceTexts.ToolTipWorldSettingsMaxFloatingObjects)); m_maxPlayersSlider.SetToolTip(MyTexts.GetString(MySpaceTexts.ToolTipWorldSettingsMaxPlayer)); m_weaponsEnabled.SetToolTip(MyTexts.GetString(MySpaceTexts.ToolTipWorldSettingsWeapons)); m_trashRemoval.SetToolTip(MyTexts.GetString(MySpaceTexts.ToolTipWorldSettingsRemoveTrash)); m_worldSizeCombo.SetToolTip(MyTexts.GetString(MySpaceTexts.ToolTipWorldSettingsLimitWorldSize)); m_viewDistanceCombo.SetToolTip(MyTexts.GetString(MySpaceTexts.ToolTipWorldSettingsViewDistance)); m_soundModeCombo.SetToolTip(MyTexts.GetString(MySpaceTexts.ToolTipWorldSettingsSoundMode)); m_respawnShipDelete.SetToolTip(MyTexts.GetString(MySpaceTexts.TooltipWorldSettingsRespawnShipDelete)); m_enableToolShake.SetToolTip(MyTexts.GetString(MySpaceTexts.ToolTipWorldSettings_ToolShake)); m_enableOxygen.SetToolTip(MyTexts.GetString(MySpaceTexts.ToolTipWorldSettings_EnableOxygen)); m_enableJetpack.SetToolTip(MyTexts.GetString(MySpaceTexts.ToolTipWorldSettings_EnableJetpack)); m_spawnWithTools.SetToolTip(MyTexts.GetString(MySpaceTexts.ToolTipWorldSettings_SpawnWithTools)); m_startInRespawnScreen.SetToolTip(MyTexts.GetString(MySpaceTexts.ToolTipWorldSettings_StartInRespawnScreen)); m_stationVoxelSupport.SetToolTip(MyTexts.GetString(MySpaceTexts.ToolTipWorldSettings_EnableStationVoxel)); m_disableRespawnShips.SetToolTip(MyTexts.GetString(MySpaceTexts.ToolTipWorldSettings_DisableRespawnShips)); m_enableVoxelDestruction.SetToolTip(MyTexts.GetString(MySpaceTexts.ToolTipWorldSettings_EnableVoxelDestruction)); // Add controls in pairs; label first, control second. They will be laid out automatically this way. parent.Controls.Add(gameTypeLabel); parent.Controls.Add(m_creativeModeButton); parent.Controls.Add(inventorySizeLabel); parent.Controls.Add(m_inventory_x1); parent.Controls.Add(assemblerEfficiencyLabel); parent.Controls.Add(m_assembler_x1); parent.Controls.Add(refineryEfficiencyLabel); parent.Controls.Add(m_refinery_x1); parent.Controls.Add(weldingSpeedLabel); parent.Controls.Add(m_welder_x1); parent.Controls.Add(grindingSpeedLabel); parent.Controls.Add(m_grinder_x1); parent.Controls.Add(m_maxFloatingObjectsLabel); parent.Controls.Add(m_maxFloatingObjectsSlider); if (!MyFakes.OCTOBER_RELEASE_HIDE_WORLD_PARAMS) { parent.Controls.Add(passwordLabel); parent.Controls.Add(m_passwordTextbox); parent.Controls.Add(gameStyleLabel); } parent.Controls.Add(worldSizeLabel); parent.Controls.Add(m_worldSizeCombo); parent.Controls.Add(spawnShipTimeLabel); parent.Controls.Add(m_spawnShipTimeCombo); parent.Controls.Add(viewDistanceLabel); parent.Controls.Add(m_viewDistanceCombo); if (MyFakes.ENABLE_NEW_SOUNDS) { parent.Controls.Add(soundModeLabel); parent.Controls.Add(m_soundModeCombo); } if (MyFakes.ENABLE_PHYSICS_SETTINGS) { parent.Controls.Add(physicsOptionLabel); parent.Controls.Add(m_physicsOptionsCombo); } parent.Controls.Add(autoHealingLabel); parent.Controls.Add(m_autoHealing); parent.Controls.Add(m_enableCopyPasteLabel); parent.Controls.Add(m_enableCopyPaste); if (!MyFakes.OCTOBER_RELEASE_HIDE_WORLD_PARAMS) { parent.Controls.Add(soundInSpaceLabel); parent.Controls.Add(friendlyFireLabel); } parent.Controls.Add(clientCanSaveLabel); parent.Controls.Add(m_clientCanSave); parent.Controls.Add(enableWeaponsLabel); parent.Controls.Add(m_weaponsEnabled); if (MyFakes.ENABLE_TRASH_REMOVAL) { parent.Controls.Add(trashRemovalLabel); parent.Controls.Add(m_trashRemoval); } parent.Controls.Add(oxygenLabel); parent.Controls.Add(m_enableOxygen); parent.Controls.Add(disableRespawnShipsLabel); parent.Controls.Add(m_disableRespawnShips); parent.Controls.Add(enableJetpackLabel); parent.Controls.Add(m_enableJetpack); parent.Controls.Add(enableVoxelDestructionLabel); parent.Controls.Add(m_enableVoxelDestruction); parent.Controls.Add(respawnShipDeleteLabel); parent.Controls.Add(m_respawnShipDelete); float labelSize = 0.21f; float MARGIN_TOP = 0.03f; // Automatic layout. Vector2 originL, originC; Vector2 controlsDelta = new Vector2(0f, 0.052f); originL = -m_size.Value / 2 + new Vector2(0.16f, MARGIN_TOP); originC = originL + new Vector2(labelSize, 0f); float rightColumnOffset = originC.X + m_onlineMode.Size.X - labelSize - 0.017f; foreach (var control in parent.Controls) { control.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER; if (control is MyGuiControlLabel) control.Position = originL + controlsDelta * numControls; else control.Position = originC + controlsDelta * numControls++; } m_sunRotationIntervalSlider = new MyGuiControlSlider( position: Vector2.Zero, width: m_onlineMode.Size.X, labelSpaceWidth: 0.05f); m_sunRotationIntervalSlider.MinValue = 0; m_sunRotationIntervalSlider.MaxValue = 1; m_sunRotationIntervalSlider.DefaultValue = 0; m_sunRotationIntervalSlider.ValueChanged += (MyGuiControlSlider s) => { m_tempBuilder.Clear(); MyValueFormatter.AppendTimeInBestUnit(MathHelper.Clamp(MathHelper.InterpLog(s.Value, MIN_DAY_TIME_MINUTES, MAX_DAY_TIME_MINUTES), MIN_DAY_TIME_MINUTES, MAX_DAY_TIME_MINUTES) * 60, m_tempBuilder); m_sunRotationPeriodValue.Text = m_tempBuilder.ToString(); }; m_sunRotationIntervalSlider.Position = new Vector2(m_sunRotationIntervalSlider.Position.X + 0.075f, autoHealingLabel.Position.Y); m_sunRotationPeriodValue.Position = new Vector2(m_sunRotationIntervalSlider.Position.X +0.12f,m_sunRotationIntervalSlider.Position.Y); m_sunRotationPeriod.Position = new Vector2(m_sunRotationIntervalSlider.Position.X - 0.365f, m_sunRotationIntervalSlider.Position.Y); parent.Controls.Add(m_sunRotationPeriod); parent.Controls.Add(m_sunRotationIntervalSlider); parent.Controls.Add(m_sunRotationPeriodValue); float buttonsOffset = 0.055f; //Left column checkboxes autoHealingLabel.Position = new Vector2(autoHealingLabel.Position.X - labelSize / 2, autoHealingLabel.Position.Y + buttonsOffset); m_autoHealing.Position = new Vector2(m_autoHealing.Position.X - labelSize / 2, m_autoHealing.Position.Y + buttonsOffset); m_enableCopyPasteLabel.Position = new Vector2(m_enableCopyPasteLabel.Position.X - labelSize / 2, m_enableCopyPasteLabel.Position.Y + buttonsOffset); m_enableCopyPaste.Position = new Vector2(m_enableCopyPaste.Position.X - labelSize / 2, m_enableCopyPaste.Position.Y + buttonsOffset); clientCanSaveLabel.Position = new Vector2(clientCanSaveLabel.Position.X - labelSize / 2, clientCanSaveLabel.Position.Y + buttonsOffset); m_clientCanSave.Position = new Vector2(m_clientCanSave.Position.X - labelSize / 2, m_clientCanSave.Position.Y + buttonsOffset); enableWeaponsLabel.Position = new Vector2(enableWeaponsLabel.Position.X - labelSize / 2, enableWeaponsLabel.Position.Y + buttonsOffset); m_weaponsEnabled.Position = new Vector2(m_weaponsEnabled.Position.X - labelSize / 2, m_weaponsEnabled.Position.Y + buttonsOffset); trashRemovalLabel.Position = new Vector2(trashRemovalLabel.Position.X - labelSize / 2, trashRemovalLabel.Position.Y + buttonsOffset); m_trashRemoval.Position = new Vector2(m_trashRemoval.Position.X - labelSize / 2, m_trashRemoval.Position.Y + buttonsOffset); oxygenLabel.Position = new Vector2(oxygenLabel.Position.X - labelSize / 2, oxygenLabel.Position.Y + buttonsOffset); m_enableOxygen.Position = new Vector2(m_enableOxygen.Position.X - labelSize / 2, m_enableOxygen.Position.Y + buttonsOffset); respawnShipDeleteLabel.Position = new Vector2(rightColumnOffset - labelSize / 2, m_autoHealing.Position.Y); m_respawnShipDelete.Position = new Vector2(rightColumnOffset + labelSize / 2, m_autoHealing.Position.Y); m_respawnShipDelete.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER; disableRespawnShipsLabel.Position = new Vector2(disableRespawnShipsLabel.Position.X - labelSize / 2, disableRespawnShipsLabel.Position.Y + buttonsOffset); m_disableRespawnShips.Position = new Vector2(m_disableRespawnShips.Position.X - labelSize / 2, m_disableRespawnShips.Position.Y + buttonsOffset); enableJetpackLabel.Position = new Vector2(enableJetpackLabel.Position.X - labelSize / 2, enableJetpackLabel.Position.Y + buttonsOffset); m_enableJetpack.Position = new Vector2(m_enableJetpack.Position.X - labelSize / 2, m_enableJetpack.Position.Y + buttonsOffset); enableVoxelDestructionLabel.Position = new Vector2(enableVoxelDestructionLabel.Position.X - labelSize / 2, enableVoxelDestructionLabel.Position.Y + buttonsOffset); m_enableVoxelDestruction.Position = new Vector2(m_enableVoxelDestruction.Position.X - labelSize / 2, m_enableVoxelDestruction.Position.Y + buttonsOffset); //Middle column checkboxes showPlayerNamesOnHudLabel.Position = new Vector2(rightColumnOffset - labelSize / 2, m_enableCopyPasteLabel.Position.Y); m_showPlayerNamesOnHud.Position = new Vector2(rightColumnOffset + labelSize / 2, m_enableCopyPasteLabel.Position.Y); thrusterDamageLabel.Position = new Vector2(rightColumnOffset - labelSize / 2, clientCanSaveLabel.Position.Y); m_thrusterDamage.Position = new Vector2(rightColumnOffset + labelSize / 2, clientCanSaveLabel.Position.Y); enableIngameScriptsLabel.Position = new Vector2(rightColumnOffset - labelSize / 2, trashRemovalLabel.Position.Y); m_enableIngameScripts.Position = new Vector2(rightColumnOffset + labelSize / 2, m_trashRemoval.Position.Y); enable3rdPersonCameraLabel.Position = new Vector2(rightColumnOffset - labelSize / 2, m_enableOxygen.Position.Y); m_enable3rdPersonCamera.Position = new Vector2(rightColumnOffset + labelSize / 2, m_enableOxygen.Position.Y); enableSunRotationLabel.Position = new Vector2(rightColumnOffset - labelSize / 2, m_disableRespawnShips.Position.Y); m_enableSunRotation.Position = new Vector2(rightColumnOffset + labelSize / 2, m_disableRespawnShips.Position.Y); spawnWithToolsLabel.Position = new Vector2(rightColumnOffset - labelSize / 2, m_enableJetpack.Position.Y); m_spawnWithTools.Position = new Vector2(rightColumnOffset + labelSize / 2, m_enableJetpack.Position.Y); if (MyFakes.ENABLE_CARGO_SHIPS) { parent.Controls.Add(shipsEnabledLabel); parent.Controls.Add(m_cargoShipsEnabled); shipsEnabledLabel.Position = new Vector2(rightColumnOffset - labelSize / 2, enableWeaponsLabel.Position.Y); m_cargoShipsEnabled.Position = new Vector2(rightColumnOffset + labelSize / 2, enableWeaponsLabel.Position.Y); } enableSpectatorLabel.Position = new Vector2(rightColumnOffset + 0.75f * labelSize, m_autoHealing.Position.Y); m_enableSpectator.Position = new Vector2(rightColumnOffset + labelSize + 0.75f * labelSize, m_autoHealing.Position.Y); resetOwnershipLabel.Position = new Vector2(rightColumnOffset + 0.75f * labelSize, m_enableCopyPasteLabel.Position.Y); m_resetOwnership.Position = new Vector2(rightColumnOffset + labelSize + 0.75f * labelSize, m_enableCopyPasteLabel.Position.Y); permanentDeathLabel.Position = new Vector2(rightColumnOffset + 0.75f * labelSize, clientCanSaveLabel.Position.Y); m_permanentDeath.Position = new Vector2(rightColumnOffset + labelSize + 0.75f * labelSize, clientCanSaveLabel.Position.Y); destructibleBlocksLabel.Position = new Vector2(rightColumnOffset + 0.75f * labelSize, m_cargoShipsEnabled.Position.Y); m_destructibleBlocks.Position = new Vector2(rightColumnOffset + labelSize + 0.75f * labelSize, m_cargoShipsEnabled.Position.Y); enableToolShakeLabel.Position = new Vector2(rightColumnOffset + 0.75f * labelSize, trashRemovalLabel.Position.Y); m_enableToolShake.Position = new Vector2(rightColumnOffset + labelSize + 0.75f * labelSize, m_trashRemoval.Position.Y); enableEncountersLabel.Position = new Vector2(rightColumnOffset + 0.75f * labelSize, enable3rdPersonCameraLabel.Position.Y); m_enableEncounters.Position = new Vector2(rightColumnOffset + labelSize + 0.75f * labelSize, m_enable3rdPersonCamera.Position.Y); enableStationVoxelLabel.Position = new Vector2(rightColumnOffset + 0.75f * labelSize, enableSunRotationLabel.Position.Y); m_stationVoxelSupport.Position = new Vector2(rightColumnOffset + labelSize + 0.75f * labelSize, m_enableSunRotation.Position.Y); startInRespawnScreenLabel.Position = new Vector2(rightColumnOffset + 0.75f * labelSize, spawnWithToolsLabel.Position.Y); m_startInRespawnScreen.Position = new Vector2(rightColumnOffset + labelSize + 0.75f * labelSize, m_spawnWithTools.Position.Y); parent.Controls.Add(showPlayerNamesOnHudLabel); parent.Controls.Add(m_showPlayerNamesOnHud); parent.Controls.Add(thrusterDamageLabel); parent.Controls.Add(m_thrusterDamage); parent.Controls.Add(enableSpectatorLabel); parent.Controls.Add(m_enableSpectator); parent.Controls.Add(resetOwnershipLabel); parent.Controls.Add(m_resetOwnership); parent.Controls.Add(permanentDeathLabel); parent.Controls.Add(m_permanentDeath); parent.Controls.Add(destructibleBlocksLabel); parent.Controls.Add(m_destructibleBlocks); if (MyFakes.ENABLE_PROGRAMMABLE_BLOCK) { parent.Controls.Add(enableIngameScriptsLabel); parent.Controls.Add(m_enableIngameScripts); } if (MyFakes.ENABLE_TOOL_SHAKE) { parent.Controls.Add(enableToolShakeLabel); parent.Controls.Add(m_enableToolShake); } parent.Controls.Add(enableEncountersLabel); parent.Controls.Add(m_enableEncounters); parent.Controls.Add(enable3rdPersonCameraLabel); parent.Controls.Add(m_enable3rdPersonCamera); parent.Controls.Add(enableStationVoxelLabel); parent.Controls.Add(m_stationVoxelSupport); parent.Controls.Add(startInRespawnScreenLabel); parent.Controls.Add(m_startInRespawnScreen); parent.Controls.Add(enableSunRotationLabel); parent.Controls.Add(m_enableSunRotation); parent.Controls.Add(spawnWithToolsLabel); parent.Controls.Add(m_spawnWithTools); m_survivalModeButton.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER; m_survivalModeButton.Position = m_creativeModeButton.Position + new Vector2(m_onlineMode.Size.X, 0); parent.Controls.Add(m_survivalModeButton); parent.Controls.Add(m_inventory_x3); parent.Controls.Add(m_inventory_x10); m_inventory_x3.Position = m_inventory_x1.Position + new Vector2(m_inventory_x1.Size.X + 0.017f, 0); m_inventory_x10.Position = m_inventory_x3.Position + new Vector2(m_inventory_x3.Size.X + 0.017f, 0); parent.Controls.Add(m_refinery_x3); parent.Controls.Add(m_refinery_x10); m_refinery_x3.Position = m_refinery_x1.Position + new Vector2(m_refinery_x1.Size.X + 0.017f, 0); m_refinery_x10.Position = m_refinery_x3.Position + new Vector2(m_refinery_x3.Size.X + 0.017f, 0); parent.Controls.Add(m_assembler_x3); parent.Controls.Add(m_assembler_x10); m_assembler_x3.Position = m_assembler_x1.Position + new Vector2(m_assembler_x1.Size.X + 0.017f, 0); m_assembler_x10.Position = m_assembler_x3.Position + new Vector2(m_assembler_x3.Size.X + 0.017f, 0); parent.Controls.Add(m_welder_half); parent.Controls.Add(m_welder_x2); parent.Controls.Add(m_welder_x5); m_welder_half.Position = m_welder_x1.Position + new Vector2(m_welder_x1.Size.X + 0.017f, 0); m_welder_x2.Position = m_welder_half.Position + new Vector2(m_welder_half.Size.X + 0.017f, 0); m_welder_x5.Position = m_welder_x2.Position + new Vector2(m_welder_x2.Size.X + 0.017f, 0); parent.Controls.Add(m_grinder_half); parent.Controls.Add(m_grinder_x2); parent.Controls.Add(m_grinder_x5); m_grinder_half.Position = m_grinder_x1.Position + new Vector2(m_grinder_x1.Size.X + 0.017f, 0); m_grinder_x2.Position = m_grinder_half.Position + new Vector2(m_grinder_half.Size.X + 0.017f, 0); m_grinder_x5.Position = m_grinder_x2.Position + new Vector2(m_grinder_x2.Size.X + 0.017f, 0); Controls.Add(m_okButton); Controls.Add(m_cancelButton); Controls.Add(scrollPanel); CloseButtonEnabled = true; }
private void RecreateServerLimitInfo(MyGuiControlList list) { var identity = MySession.Static.Players.TryGetIdentity(MySession.Static.LocalPlayerId); int built; if (MySession.Static.MaxBlocksPerPlayer > 0 || MySession.Static.BlockTypeLimits.Keys.Count > 0) { MyGuiControlLabel totalBlocksLabel = new MyGuiControlLabel(text: MyTexts.GetString(MySpaceTexts.TerminalTab_Info_Overview), textScale: 1.3f); list.Controls.Add(totalBlocksLabel); } if (MySession.Static.MaxBlocksPerPlayer > 0) { MyGuiControlLabel totalBlocksLabel = new MyGuiControlLabel(text: String.Format("{0} {1}/{2} {3}", MyTexts.Get(MySpaceTexts.TerminalTab_Info_YouBuilt), identity.BlocksBuilt, MySession.Static.MaxBlocksPerPlayer + identity.BlockLimitModifier, MyTexts.Get(MySpaceTexts.TerminalTab_Info_BlocksLower))); list.Controls.Add(totalBlocksLabel); } foreach (var blockType in MySession.Static.BlockTypeLimits) { identity.BlockTypeBuilt.TryGetValue(blockType.Key, out built); var definition = Sandbox.Definitions.MyDefinitionManager.Static.TryGetDefinitionGroup(blockType.Key); if (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(); identity.LockBlocksBuiltByGrid.AcquireExclusive(); for (int i = 0; i < identity.BlocksBuiltByGrid.Count; i++) { var grid = identity.BlocksBuiltByGrid.ElementAt(i); 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); } identity.LockBlocksBuiltByGrid.ReleaseExclusive(); }
protected override void CreateButtons() { Vector2 buttonPosition = new Vector2(0.215f, -0.173f) + m_offset; Vector2 buttonOffset = new Vector2(0.13f, 0.045f); float width = 0.26f; var openInWorkshopButton = CreateButton(width, new StringBuilder("Open In Workshop"), OnOpenInWorkshop, textScale: m_textScale); openInWorkshopButton.Position = buttonPosition; width = 0.14f; var closeButton = CreateButton(width, new StringBuilder("Close"), OnCloseButton, textScale: m_textScale); closeButton.Position = buttonPosition + new Vector2(0.5f, 2f) * buttonOffset + new Vector2(-0.005f, 0.005f); var sendLabel = MakeLabel("Send to Player", buttonPosition + new Vector2(-1f, 1f) * buttonOffset, m_textScale); Controls.Add(sendLabel); m_sendToCombo = AddCombo(size: new Vector2(0.14f, 0.1f)); m_sendToCombo.Position = buttonPosition + new Vector2(-0.075f, 1f) * buttonOffset; foreach (var player in Sync.Clients.GetClients()) { m_sendToCombo.AddItem(Convert.ToInt64(player.SteamUserId), new StringBuilder(player.DisplayName)); if (player.SteamUserId != MySteam.UserId) { m_sendToCombo.AddItem(Convert.ToInt64(player.SteamUserId), new StringBuilder(player.DisplayName)); } } m_sendToCombo.ItemSelected += OnSendToPlayer; }
private void CreateLayersControls(MyGuiControlList list, float usableWidth) { var button = CreateDebugButton(usableWidth, MySpaceTexts.ScreenDebugSpawnMenu_CreateLayer, OnCreateLayer); Controls.Remove(button); list.Controls.Add(button); button = CreateDebugButton(usableWidth, MySpaceTexts.ScreenDebugSpawnMenu_RemoveLayer, OnRemoveLayer); Controls.Remove(button); list.Controls.Add(button); m_materialLayerDeviationSeed = CreateSeedButton(list, m_materialLayerDeviationSeedValue, usableWidth); var layerNoiseLabel = CreateSliderWithDescription(list, usableWidth, 10f, 200.0f, "Layer deviation noise frequency", ref m_materialLayerDeviationNoise); m_materialLayerDeviationNoise.ValueChanged += (MyGuiControlSlider s) => { layerNoiseLabel.Text = MyValueFormatter.GetFormatedFloat(s.Value, 2); }; m_layerCombobox = AddCombo(); m_layerCombobox.ItemSelected += OnLayerCombobox_ItemSelected; Controls.Remove(m_layerCombobox); list.Controls.Add(m_layerCombobox); m_oreComboboxLabel = AddLabel("Layer ore", Vector4.One, m_scale); Controls.Remove(m_oreComboboxLabel); list.Controls.Add(m_oreComboboxLabel); m_oreComboboxLabel.Visible = false; m_oreCombobox = AddCombo(); { foreach (var definition in MyDefinitionManager.Static.GetVoxelMaterialDefinitions()) { m_oreCombobox.AddItem((int)definition.Id.SubtypeId, definition.Id.SubtypeId); } m_oreCombobox.ItemSelected += OnOreCombobox_ItemSelected; m_oreCombobox.SortItemsByValueText(); } m_oreCombobox.Visible = false; list.Controls.Add(m_oreCombobox); var layerStartLabel = CreateSliderWithDescription(list, usableWidth, -m_procAsteroidSizeValue * m_planetDeviationScaleValue, m_procAsteroidSizeValue * m_planetDeviationScaleValue, "Layer start", ref m_materialLayerStart); m_materialLayerStart.ValueChanged += (MyGuiControlSlider s) => { layerStartLabel.Text = MyValueFormatter.GetFormatedFloat(s.Value, 0) + "m"; int currentLayer = m_layerCombobox.GetSelectedIndex(); if (currentLayer >= 0 && currentLayer < m_materialLayers.Count) { m_materialLayers[currentLayer].StartHeight = s.Value; } if (s.Value > m_materialLayerEnd.Value) { m_materialLayerEnd.Value = s.Value; } }; var layerStartHeigthDeviationLabel = CreateSliderWithDescription(list, usableWidth, 0, 100.0f, "Layer start height deviation", ref m_materialLayerStartHeigthDeviation); m_materialLayerStartHeigthDeviation.ValueChanged += (MyGuiControlSlider s) => { layerStartHeigthDeviationLabel.Text = MyValueFormatter.GetFormatedFloat(s.Value, 0) + "m"; int currentLayer = m_layerCombobox.GetSelectedIndex(); if (currentLayer >= 0 && currentLayer < m_materialLayers.Count) { m_materialLayers[currentLayer].HeightStartDeviation = s.Value; } }; var layerEndLabel = CreateSliderWithDescription(list, usableWidth, -m_procAsteroidSizeValue * m_planetDeviationScaleValue, m_procAsteroidSizeValue * m_planetDeviationScaleValue, "Layer end", ref m_materialLayerEnd); m_materialLayerEnd.ValueChanged += (MyGuiControlSlider s) => { layerEndLabel.Text = MyValueFormatter.GetFormatedFloat(s.Value, 0) + "m"; int currentLayer = m_layerCombobox.GetSelectedIndex(); if (currentLayer >= 0 && currentLayer < m_materialLayers.Count) { m_materialLayers[currentLayer].EndHeight = s.Value; } if (s.Value < m_materialLayerStart.Value) { m_materialLayerStart.Value = s.Value; } }; var layerHeigthDeviationLabel = CreateSliderWithDescription(list, usableWidth,0, 100.0f, "Layer end height deviation", ref m_materialLayerEndHeigthDeviation); m_materialLayerEndHeigthDeviation.ValueChanged += (MyGuiControlSlider s) => { layerHeigthDeviationLabel.Text = MyValueFormatter.GetFormatedFloat(s.Value, 0) + "m"; int currentLayer = m_layerCombobox.GetSelectedIndex(); if (currentLayer >= 0 && currentLayer < m_materialLayers.Count) { m_materialLayers[currentLayer].HeightEndDeviation = s.Value; } }; var layerAngleStartLabel = CreateSliderWithDescription(list, usableWidth, -1, 1, "Layer angle start", ref m_materialLayerAngleStart); m_materialLayerAngleStart.ValueChanged += (MyGuiControlSlider s) => { layerAngleStartLabel.Text = MyValueFormatter.GetFormatedFloat(s.Value, 3); int currentLayer = m_layerCombobox.GetSelectedIndex(); if (currentLayer >= 0 && currentLayer < m_materialLayers.Count) { m_materialLayers[currentLayer].StartAngle = s.Value; } if (s.Value > m_materialLayerAngleEnd.Value) { m_materialLayerAngleEnd.Value = s.Value; } }; var layerStartAngleDeviationLabel = CreateSliderWithDescription(list, usableWidth, 0, 1.0f, "Layer start angle deviation", ref m_materialLayerAngleStartDeviation); m_materialLayerAngleStartDeviation.ValueChanged += (MyGuiControlSlider s) => { layerStartAngleDeviationLabel.Text = MyValueFormatter.GetFormatedFloat(s.Value, 3); int currentLayer = m_layerCombobox.GetSelectedIndex(); if (currentLayer >= 0 && currentLayer < m_materialLayers.Count) { m_materialLayers[currentLayer].AngleStartDeviation = s.Value; } }; var layerAngleEndLabel = CreateSliderWithDescription(list, usableWidth, -1, 1, "Layer angle end", ref m_materialLayerAngleEnd); m_materialLayerAngleEnd.ValueChanged += (MyGuiControlSlider s) => { layerAngleEndLabel.Text = MyValueFormatter.GetFormatedFloat(s.Value, 3); int currentLayer = m_layerCombobox.GetSelectedIndex(); if (currentLayer >= 0 && currentLayer < m_materialLayers.Count) { m_materialLayers[currentLayer].EndAngle = s.Value; } if (s.Value < m_materialLayerAngleStart.Value) { m_materialLayerAngleStart.Value = s.Value; } }; var layerAngleDeviationLabel = CreateSliderWithDescription(list, usableWidth, 0, 1.0f, "Layer end angle deviation", ref m_materialLayerAngleEndDeviation); m_materialLayerAngleEndDeviation.ValueChanged += (MyGuiControlSlider s) => { layerAngleDeviationLabel.Text = MyValueFormatter.GetFormatedFloat(s.Value, 3); int currentLayer = m_layerCombobox.GetSelectedIndex(); if (currentLayer >= 0 && currentLayer < m_materialLayers.Count) { m_materialLayers[currentLayer].AngleEndDeviation = s.Value; } }; }
public override void RecreateControls(bool constructor) { float width = 0.284375f + 0.025f; base.RecreateControls(constructor); AddCaption(MySpaceTexts.ScreenCaptionWorldGeneratorSettings); m_asteroidAmountCombo = new MyGuiControlCombobox(size: new Vector2(width, 0.04f)); m_asteroidAmountCombo.ItemSelected += m_asteroidAmountCombo_ItemSelected; m_asteroidAmountCombo.SetToolTip(MyTexts.GetString(MySpaceTexts.ToolTipWorldSettingsAsteroidAmount)); m_asteroidAmountCombo.AddItem((int)AsteroidAmountEnum.Normal, MySpaceTexts.WorldSettings_AsteroidAmountNormal); m_asteroidAmountCombo.AddItem((int)AsteroidAmountEnum.More, MySpaceTexts.WorldSettings_AsteroidAmountLarge); if (Environment.Is64BitProcess) m_asteroidAmountCombo.AddItem((int)AsteroidAmountEnum.Many, MySpaceTexts.WorldSettings_AsteroidAmountExtreme); if (MyFakes.ENABLE_ASTEROID_FIELDS) { m_asteroidAmountCombo.AddItem((int)AsteroidAmountEnum.ProceduralLow, MySpaceTexts.WorldSettings_AsteroidAmountProceduralLow); m_asteroidAmountCombo.AddItem((int)AsteroidAmountEnum.ProceduralNormal, MySpaceTexts.WorldSettings_AsteroidAmountProceduralNormal); if (Environment.Is64BitProcess) m_asteroidAmountCombo.AddItem((int)AsteroidAmountEnum.ProceduralHigh, MySpaceTexts.WorldSettings_AsteroidAmountProceduralHigh); } m_asteroidAmountLabel = MakeLabel(MySpaceTexts.Asteroid_Amount); Controls.Add(m_asteroidAmountLabel); Controls.Add(m_asteroidAmountCombo); m_floraDensityLabel = MakeLabel(MySpaceTexts.WorldSettings_FloraDensity); m_floraDensityCombo = new MyGuiControlCombobox(size: new Vector2(width, 0.04f)); m_floraDensityCombo.AddItem((int)MyFloraDensityEnum.NONE, MySpaceTexts.WorldSettings_FloraDensity_None); m_floraDensityCombo.AddItem((int)MyFloraDensityEnum.LOW, MySpaceTexts.WorldSettings_FloraDensity_Low); m_floraDensityCombo.AddItem((int)MyFloraDensityEnum.MEDIUM, MySpaceTexts.WorldSettings_FloraDensity_Medium); m_floraDensityCombo.AddItem((int)MyFloraDensityEnum.HIGH, MySpaceTexts.WorldSettings_FloraDensity_High); m_floraDensityCombo.AddItem((int)MyFloraDensityEnum.EXTREME, MySpaceTexts.WorldSettings_FloraDensity_Extreme); m_floraDensityCombo.SetToolTip(MyTexts.GetString(MySpaceTexts.ToolTipWorldSettings_FloraDensity)); Controls.Add(m_floraDensityLabel); Controls.Add(m_floraDensityCombo); int numControls = 0; float MARGIN_TOP = 0.12f; float MARGIN_LEFT = 0.055f; float labelSize = 0.25f; Vector2 originL, originC; Vector2 controlsDelta = new Vector2(0f, 0.052f); float rightColumnOffset; originL = -m_size.Value / 2 + new Vector2(MARGIN_LEFT, MARGIN_TOP); originC = originL + new Vector2(labelSize, 0f); rightColumnOffset = originC.X + width - labelSize - 0.017f; foreach (var control in Controls) { control.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER; if (control is MyGuiControlLabel) control.Position = originL + controlsDelta * numControls; else control.Position = originC + controlsDelta * numControls++; } Vector2 buttonsOrigin = m_size.Value / 2 - new Vector2(0.23f, 0.03f); m_okButton = new MyGuiControlButton(position: buttonsOrigin - new Vector2(0.01f, 0f), size: MyGuiConstants.BACK_BUTTON_SIZE, text: MyTexts.Get(MyCommonTexts.Ok), onButtonClick: OkButtonClicked, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM); m_cancelButton = new MyGuiControlButton(position: buttonsOrigin + new Vector2(0.01f, 0f), size: MyGuiConstants.BACK_BUTTON_SIZE, text: MyTexts.Get(MyCommonTexts.Cancel), onButtonClick: CancelButtonClicked, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM); Controls.Add(m_okButton); Controls.Add(m_cancelButton); }
public override void RecreateControls(bool constructor) { base.RecreateControls(constructor); AddCaption("Cube blocks", Color.Yellow.ToVector4()); m_combo = AddCombo(); m_combo.Position = new Vector2(-0.15f, -0.35f); Dictionary<long, int> dict = new Dictionary<long, int>(); Dictionary<long, StringBuilder> names = new Dictionary<long, StringBuilder>(); foreach (var entity in MyEntities.GetEntities()) { if (entity is MyCubeGrid) { var grid = entity as MyCubeGrid; foreach (var block in grid.GetBlocks()) { long defId = block.BlockDefinition.Id.GetHashCode(); if (!dict.ContainsKey(defId)) dict.Add(defId, 0); dict[defId]++; string cubesize = ""; switch(block.BlockDefinition.CubeSize) { case MyCubeSize.Large: cubesize = "Large"; break; case MyCubeSize.Small: cubesize = "Small"; break; } StringBuilder blockName = new StringBuilder().Append("[").Append(cubesize).Append("] ").Append(block.BlockDefinition.DisplayNameText); if (!names.ContainsKey(defId)) names.Add(defId, blockName); } } } int qt; StringBuilder name; foreach (var key in names.Keys) //could be dict.Keys too { if (names.TryGetValue(key, out name) && dict.TryGetValue(key, out qt)) m_combo.AddItem(key, name.Append(": ").Append(qt)); } m_combo.SortItemsByValueText(); if(m_combo.GetItemsCount() > 0) m_combo.SelectItemByIndex(0); m_button = AddButton(new StringBuilder("Remove All"), onClick_RemoveAllBlocks); m_button.VisualStyle = MyGuiControlButtonStyleEnum.Default; m_button.Position = new Vector2(0.0f, -0.25f); m_currentPosition = -m_size.Value / 2.0f + new Vector2(0.02f, 0.35f); AddCheckBox("Enable use object highlight", null, MemberHelper.GetMember(() => MyFakes.ENABLE_USE_OBJECT_HIGHLIGHT)); AddCheckBox("Show grids decay", null, MemberHelper.GetMember(() => MyDebugDrawSettings.DEBUG_DRAW_GRIDS_DECAY)); m_currentPosition += new Vector2(0.00f, 0.21f); AddCheckBox("Debug draw all mount points", MyDebugDrawSettings.DEBUG_DRAW_MOUNT_POINTS_ALL, onClick_DebugDrawMountPointsAll); AddCheckBox("Debug draw mount points", MyDebugDrawSettings.DEBUG_DRAW_MOUNT_POINTS, onClick_DebugDrawMountPoints); AddCheckBox("Forward", null, MemberHelper.GetMember(() => MyDebugDrawSettings.DEBUG_DRAW_MOUNT_POINTS_AXIS0)); AddCheckBox("Backward", null, MemberHelper.GetMember(() => MyDebugDrawSettings.DEBUG_DRAW_MOUNT_POINTS_AXIS1)); AddCheckBox("Left", null, MemberHelper.GetMember(() => MyDebugDrawSettings.DEBUG_DRAW_MOUNT_POINTS_AXIS2)); AddCheckBox("Right", null, MemberHelper.GetMember(() => MyDebugDrawSettings.DEBUG_DRAW_MOUNT_POINTS_AXIS3)); AddCheckBox("Up", null, MemberHelper.GetMember(() => MyDebugDrawSettings.DEBUG_DRAW_MOUNT_POINTS_AXIS4)); AddCheckBox("Down", null, MemberHelper.GetMember(() => MyDebugDrawSettings.DEBUG_DRAW_MOUNT_POINTS_AXIS5)); AddCheckBox("Draw autogenerated", null, MemberHelper.GetMember(() => MyDebugDrawSettings.DEBUG_DRAW_MOUNT_POINTS_AUTOGENERATE)); AddCheckBox("CubeBlock Integrity", null, MemberHelper.GetMember(() => MyDebugDrawSettings.DEBUG_DRAW_BLOCK_INTEGRITY)); m_button = AddButton(new StringBuilder("Resave mountpoints"), onClick_Save); m_button.VisualStyle = MyGuiControlButtonStyleEnum.Default; }
public override void RecreateControls(bool constructor) { base.RecreateControls(constructor); m_currentPosition = -m_size.Value / 2.0f + new Vector2(0.02f, 0.10f); m_currentPosition.Y += 0.01f; m_scale = 0.7f; AddCaption("Audio FX", Color.Yellow.ToVector4()); AddShareFocusHint(); if (MyAudio.Static is MyNullAudio) return; m_categoriesCombo = AddCombo(); List<MyStringId> categories = MyAudio.Static.GetCategories(); m_categoriesCombo.AddItem(0, new StringBuilder(ALL_CATEGORIES)); int catCount = 1; foreach (var category in categories) { m_categoriesCombo.AddItem(catCount++, new StringBuilder(category.ToString()));//jn:TODO get rid of ToString } m_categoriesCombo.SortItemsByValueText(); m_categoriesCombo.ItemSelected += new MyGuiControlCombobox.ItemSelectedDelegate(categoriesCombo_OnSelect); m_cuesCombo = AddCombo(); m_cuesCombo.ItemSelected += new MyGuiControlCombobox.ItemSelectedDelegate(cuesCombo_OnSelect); m_cueVolumeSlider = AddSlider("Volume", 1f, 0f, 1f, null); m_cueVolumeSlider.ValueChanged = CueVolumeChanged; m_applyVolumeToCategory = AddButton(new StringBuilder("Apply to category"), OnApplyVolumeToCategorySelected); m_applyVolumeToCategory.Enabled = false; m_cueVolumeCurveCombo = AddCombo(); foreach (var curveType in Enum.GetValues(typeof(MyCurveType))) { m_cueVolumeCurveCombo.AddItem((int)curveType, new StringBuilder(curveType.ToString())); } m_effects = AddCombo(); m_effects.AddItem(0,new StringBuilder("")); catCount =1; foreach(var effect in MyDefinitionManager.Static.GetAudioEffectDefinitions()) { m_effects.AddItem(catCount++, new StringBuilder(effect.Id.SubtypeName)); } m_effects.SelectItemByIndex(0); m_effects.ItemSelected += effects_ItemSelected; m_cueMaxDistanceSlider = AddSlider("Max distance", 0, 0, 2000, null); m_cueMaxDistanceSlider.ValueChanged = MaxDistanceChanged; m_applyMaxDistanceToCategory = AddButton(new StringBuilder("Apply to category"), OnApplyMaxDistanceToCategorySelected); m_applyMaxDistanceToCategory.Enabled = false; m_cueVolumeVariationSlider = AddSlider("Volume variation", 0, 0, 10, null); m_cueVolumeVariationSlider.ValueChanged = VolumeVariationChanged; m_cuePitchVariationSlider = AddSlider("Pitch variation", 0, 0, 500, null); m_cuePitchVariationSlider.ValueChanged = PitchVariationChanged; m_soloCheckbox = AddCheckBox("Solo", false, null); m_soloCheckbox.IsCheckedChanged = SoloChanged; MyGuiControlButton btn = AddButton(new StringBuilder("Play selected"), OnPlaySelected); btn.CueEnum = GuiSounds.None; AddButton(new StringBuilder("Stop selected"), OnStopSelected); AddButton(new StringBuilder("Save"), OnSave); AddButton(new StringBuilder("Reload"), OnReload); if (m_categoriesCombo.GetItemsCount() > 0) m_categoriesCombo.SelectItemByIndex(0); }
public override void RecreateControls(bool constructor) { base.RecreateControls(constructor); CloseButtonEnabled = true; var caption = AddCaption(MySpaceTexts.ScreenCaptionPlayers); var captionCenter = MyUtils.GetCoordCenterFromAligned(caption.Position, caption.Size, caption.OriginAlign); var captionBottomCenter = captionCenter + new Vector2(0f, 0.5f * caption.Size.Y); Vector2 sizeScale = Size.Value / MyGuiConstants.TEXTURE_SCREEN_BACKGROUND.SizeGui; Vector2 topLeft = -0.5f * Size.Value + sizeScale * MyGuiConstants.TEXTURE_SCREEN_BACKGROUND.PaddingSizeGui * 1.1f; float verticalSpacing = 0.5f * caption.Size.Y; m_lobbyTypeCombo = new MyGuiControlCombobox( position: new Vector2(-topLeft.X, captionBottomCenter.Y + verticalSpacing), openAreaItemsCount: 3); m_lobbyTypeCombo.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP; m_lobbyTypeCombo.AddItem((int)LobbyTypeEnum.Private, MySpaceTexts.ScreenPlayersLobby_Private); m_lobbyTypeCombo.AddItem((int)LobbyTypeEnum.FriendsOnly, MySpaceTexts.ScreenPlayersLobby_Friends); m_lobbyTypeCombo.AddItem((int)LobbyTypeEnum.Public, MySpaceTexts.ScreenPlayersLobby_Public); m_lobbyTypeCombo.SelectItemByKey((int)MyMultiplayer.Static.GetLobbyType()); MyGuiControlBase aboveControl; m_inviteButton = new MyGuiControlButton( position: new Vector2(-m_lobbyTypeCombo.Position.X, m_lobbyTypeCombo.Position.Y + m_lobbyTypeCombo.Size.Y + verticalSpacing), originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, text: MyTexts.Get(MySpaceTexts.ScreenPlayers_Invite)); aboveControl = m_inviteButton; m_kickButton = new MyGuiControlButton( position: aboveControl.Position + new Vector2(0f, aboveControl.Size.Y), originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, text: MyTexts.Get(MySpaceTexts.ScreenPlayers_Kick)); aboveControl = m_kickButton; m_banButton = new MyGuiControlButton( position: aboveControl.Position + new Vector2(0f, aboveControl.Size.Y), originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, text: MyTexts.Get(MySpaceTexts.ScreenPlayers_Ban)); aboveControl = m_banButton; var maxPlayersLabel = new MyGuiControlLabel( position: aboveControl.Position + new Vector2(0f, aboveControl.Size.Y), originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, text: MyTexts.GetString(MySpaceTexts.MaxPlayers)); aboveControl = maxPlayersLabel; m_maxPlayersSlider = new MyGuiControlSlider( position: aboveControl.Position + new Vector2(0f, aboveControl.Size.Y), width: 0.15f, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, minValue: 0, maxValue: MyMultiplayer.Static != null ? MyMultiplayer.Static.MaxPlayers : 16, labelText: new StringBuilder("{0}").ToString(), labelDecimalPlaces: 0, labelSpaceWidth: 0.02f, defaultValue: Sync.IsServer ? MySession.Static.MaxPlayers : MyMultiplayer.Static.MemberLimit, intValue: true); m_maxPlayersSlider.ValueChanged = MaxPlayersSlider_Changed; aboveControl = m_maxPlayersSlider; m_playersTable = new MyGuiControlTable() { Position = new Vector2(-m_inviteButton.Position.X, m_inviteButton.Position.Y), Size = new Vector2(1075f / MyGuiConstants.GUI_OPTIMAL_SIZE.X, 1f) - m_inviteButton.Size * 1.05f, VisibleRowsCount = 21, OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP, ColumnsCount = 2, }; m_playersTable.SetCustomColumnWidths(new float[] { 0.7f, 0.3f }); m_playersTable.SetColumnName(0, MyTexts.Get(MySpaceTexts.ScreenPlayers_PlayerName)); m_playersTable.SetColumnName(1, MyTexts.Get(MySpaceTexts.ScreenPlayers_GameAdmin)); m_playersTable.SetColumnComparison(0, (a, b) => (a.Text.CompareToIgnoreCase(b.Text))); m_playersTable.ItemSelected += playersTable_ItemSelected; foreach (var userId in MyMultiplayer.Static.Members) AddPlayer(userId); m_inviteButton.ButtonClicked += inviteButton_ButtonClicked; m_kickButton.ButtonClicked += kickButton_ButtonClicked; m_banButton.ButtonClicked += banButton_ButtonClicked; m_lobbyTypeCombo.ItemSelected += lobbyTypeCombo_OnSelect; Controls.Add(m_inviteButton); Controls.Add(m_kickButton); Controls.Add(m_banButton); Controls.Add(m_playersTable); Controls.Add(m_lobbyTypeCombo); Controls.Add(m_maxPlayersSlider); Controls.Add(maxPlayersLabel); UpdateButtonsEnabledState(); }
public override void RecreateControls(bool constructor) { if (!constructor) return; base.RecreateControls(constructor); AddCaption(MyTexts.GetString(MyCommonTexts.ScreenCaptionGraphicsOptions)); const float TEXT_SCALE = Sandbox.Graphics.GUI.MyGuiConstants.DEFAULT_TEXT_SCALE * 0.85f; var labelRenderer = new MyGuiControlLabel(textScale: TEXT_SCALE, text: MyTexts.GetString(MySpaceTexts.ScreenGraphicsOptions_Renderer)); var labelHwCursor = new MyGuiControlLabel(textScale: TEXT_SCALE, text: MyTexts.GetString(MyCommonTexts.HardwareCursor)); var labelFov = new MyGuiControlLabel(textScale: TEXT_SCALE, text: MyTexts.GetString(MyCommonTexts.FieldOfView)); var labelFovDefault = new MyGuiControlLabel(textScale: TEXT_SCALE, text: MyTexts.GetString(MyCommonTexts.DefaultFOV)); var labelRenderInterpolation = new MyGuiControlLabel(textScale: TEXT_SCALE, text: MyTexts.GetString(MyCommonTexts.RenderIterpolation)); var labelAntiAliasing = new MyGuiControlLabel(textScale: TEXT_SCALE, text: MyTexts.GetString(MyCommonTexts.ScreenGraphicsOptions_AntiAliasing)); var labelShadowMapResolution = new MyGuiControlLabel(textScale: TEXT_SCALE, text: MyTexts.GetString(MySpaceTexts.ScreenGraphicsOptions_ShadowMapResolution)); var labelMultithreadedRendering = new MyGuiControlLabel(textScale: TEXT_SCALE, text: MyTexts.GetString(MyCommonTexts.ScreenGraphicsOptions_MultiThreadedRendering)); //var labelTonemapping = new MyGuiControlLabel(textScale: TEXT_SCALE, text: MyTexts.GetString(MyCommonTexts.ScreenGraphicsOptions_Tonemapping)); var labelTextureQuality = new MyGuiControlLabel(textScale: TEXT_SCALE, text: MyTexts.GetString(MyCommonTexts.ScreenGraphicsOptions_TextureQuality)); var labelVoxelQuality = new MyGuiControlLabel(textScale: TEXT_SCALE, text: MyTexts.GetString(MySpaceTexts.ScreenGraphicsOptions_VoxelQuality)); var labelAnisotropicFiltering = new MyGuiControlLabel(textScale: TEXT_SCALE, text: MyTexts.GetString(MyCommonTexts.ScreenGraphicsOptions_AnisotropicFiltering)); var labelGraphicsPresets = new MyGuiControlLabel(textScale: TEXT_SCALE, text: MyTexts.GetString(MyCommonTexts.ScreenGraphicsOptions_QualityPreset)); var labelFoliageDetails = new MyGuiControlLabel(textScale: TEXT_SCALE, text: MyTexts.GetString(MyCommonTexts.ScreenGraphicsOptions_FoliageDetails)); var labelGrassDensity = new MyGuiControlLabel(textScale: TEXT_SCALE, text: MyTexts.GetString(MyCommonTexts.WorldSettings_GrassDensity)); var labelEnableDamageEffects = new MyGuiControlLabel(textScale: TEXT_SCALE, text: MyTexts.GetString(MySpaceTexts.EnableDamageEffects)); var labelVegetationDistance = new MyGuiControlLabel(textScale: TEXT_SCALE, text: MyTexts.GetString(MyCommonTexts.WorldSettings_VegetationDistance)); m_comboRenderer = new MyGuiControlCombobox(toolTip: MyTexts.GetString(MySpaceTexts.ToolTipVideoOptionsRenderer)); m_comboGraphicsPresets = new MyGuiControlCombobox(); m_comboAntialiasing = new MyGuiControlCombobox(); m_comboShadowMapResolution = new MyGuiControlCombobox(); m_comboTextureQuality = new MyGuiControlCombobox(); m_comboAnisotropicFiltering = new MyGuiControlCombobox(); m_checkboxHardwareCursor = new MyGuiControlCheckbox(toolTip: MyTexts.GetString(MyCommonTexts.ToolTipVideoOptionsHardwareCursor)); m_checkboxRenderInterpolation = new MyGuiControlCheckbox(toolTip: MyTexts.GetString(MyCommonTexts.ToolTipVideoOptionRenderIterpolation)); //m_checkboxMultithreadedRender = new MyGuiControlCheckbox(); //m_checkboxTonemapping = new MyGuiControlCheckbox(); m_checkboxEnableDamageEffects = new MyGuiControlCheckbox(toolTip: MyTexts.GetString(MySpaceTexts.ToolTipVideoOptionsEnableDamageEffects)); m_sliderFov = new MyGuiControlSlider(toolTip: MyTexts.GetString(MyCommonTexts.ToolTipVideoOptionsFieldOfView), labelText: new StringBuilder("{0}").ToString(), labelSpaceWidth: 0.035f, labelScale: TEXT_SCALE, labelFont: MyFontEnum.Blue, defaultValue: MathHelper.ToDegrees(MySandboxGame.Config.FieldOfView)); m_comboVoxelQuality = new MyGuiControlCombobox(); m_comboFoliageDetails = new MyGuiControlCombobox(); m_grassDensitySlider = new MyGuiControlSlider(minValue: 0f, maxValue: 10f, labelText: new StringBuilder("{0}").ToString(), labelSpaceWidth: 0.035f, labelScale: TEXT_SCALE, labelFont: MyFontEnum.Blue, defaultValue: MySandboxGame.Config.GrassDensityFactor); /* Vegetation View Distance */ m_vegetationViewDistance = new MyGuiControlSliderBase( props: new MyGuiSliderPropertiesExponential(100, 10 * 1000, 10, true), labelSpaceWidth: 0.063f, labelScale: TEXT_SCALE, labelFont: MyFontEnum.Blue); m_vegetationViewDistance.DefaultRatio = m_vegetationViewDistance.Propeties.ValueToRatio(MySandboxGame.Config.VegetationDrawDistance); var okButton = new MyGuiControlButton(text: MyTexts.Get(MyCommonTexts.Ok), onButtonClick: OnOkClick); var cancelButton = new MyGuiControlButton(text: MyTexts.Get(MyCommonTexts.Cancel), onButtonClick: OnCancelClick); m_comboGraphicsPresets.AddItem((int)PresetEnum.Low, MyTexts.GetString(MyCommonTexts.ScreenGraphicsOptions_QualityPreset_Low)); m_comboGraphicsPresets.AddItem((int)PresetEnum.Medium, MyTexts.GetString(MyCommonTexts.ScreenGraphicsOptions_QualityPreset_Medium)); m_comboGraphicsPresets.AddItem((int)PresetEnum.High, MyTexts.GetString(MyCommonTexts.ScreenGraphicsOptions_QualityPreset_High)); m_comboGraphicsPresets.AddItem((int)PresetEnum.Custom, MyTexts.GetString(MyCommonTexts.ScreenGraphicsOptions_QualityPreset_Custom)); m_comboAntialiasing.AddItem((int)MyAntialiasingMode.NONE, MyTexts.GetString(MyCommonTexts.ScreenGraphicsOptions_AntiAliasing_None)); m_comboAntialiasing.AddItem((int)MyAntialiasingMode.FXAA, "FXAA"); //m_comboAntialiasing.AddItem((int)MyAntialiasingMode.MSAA_2, "MSAA 2x"); //m_comboAntialiasing.AddItem((int)MyAntialiasingMode.MSAA_4, "MSAA 4x"); //m_comboAntialiasing.AddItem((int)MyAntialiasingMode.MSAA_8, "MSAA 8x"); m_comboShadowMapResolution.AddItem((int)MyShadowsQuality.DISABLED, MyTexts.GetString(MyCommonTexts.ScreenGraphicsOptions_ShadowMapResolution_Disabled)); m_comboShadowMapResolution.AddItem((int)MyShadowsQuality.LOW, MyTexts.GetString(MyCommonTexts.ScreenGraphicsOptions_ShadowMapResolution_Low)); m_comboShadowMapResolution.AddItem((int)MyShadowsQuality.MEDIUM, MyTexts.GetString(MySpaceTexts.ScreenGraphicsOptions_ShadowMapResolution_Medium)); m_comboShadowMapResolution.AddItem((int)MyShadowsQuality.HIGH, MyTexts.GetString(MyCommonTexts.ScreenGraphicsOptions_ShadowMapResolution_High)); m_comboTextureQuality.AddItem((int)MyTextureQuality.LOW, MyTexts.GetString(MyCommonTexts.ScreenGraphicsOptions_TextureQuality_Low)); m_comboTextureQuality.AddItem((int)MyTextureQuality.MEDIUM, MyTexts.GetString(MyCommonTexts.ScreenGraphicsOptions_TextureQuality_Medium)); m_comboTextureQuality.AddItem((int)MyTextureQuality.HIGH, MyTexts.GetString(MyCommonTexts.ScreenGraphicsOptions_TextureQuality_High)); m_comboAnisotropicFiltering.AddItem((int)MyTextureAnisoFiltering.NONE, MyTexts.GetString(MyCommonTexts.ScreenGraphicsOptions_AnisotropicFiltering_Off)); m_comboAnisotropicFiltering.AddItem((int)MyTextureAnisoFiltering.ANISO_1, "1x"); m_comboAnisotropicFiltering.AddItem((int)MyTextureAnisoFiltering.ANISO_4, "4x"); m_comboAnisotropicFiltering.AddItem((int)MyTextureAnisoFiltering.ANISO_8, "8x"); m_comboAnisotropicFiltering.AddItem((int)MyTextureAnisoFiltering.ANISO_16, "16x"); m_comboFoliageDetails.AddItem((int)MyFoliageDetails.DISABLED, MyTexts.GetString(MyCommonTexts.ScreenGraphicsOptions_FoliageDetails_Disabled)); m_comboFoliageDetails.AddItem((int)MyFoliageDetails.LOW, MyTexts.GetString(MyCommonTexts.ScreenGraphicsOptions_FoliageDetails_Low)); m_comboFoliageDetails.AddItem((int)MyFoliageDetails.MEDIUM, MyTexts.GetString(MyCommonTexts.ScreenGraphicsOptions_FoliageDetails_Medium)); m_comboFoliageDetails.AddItem((int)MyFoliageDetails.HIGH, MyTexts.GetString(MyCommonTexts.ScreenGraphicsOptions_FoliageDetails_High)); m_comboVoxelQuality.AddItem((int)MyRenderQualityEnum.LOW, MyTexts.GetString(MyCommonTexts.ScreenGraphicsOptions_FoliageDetails_Low)); m_comboVoxelQuality.AddItem((int)MyRenderQualityEnum.NORMAL, MyTexts.GetString(MyCommonTexts.ScreenGraphicsOptions_FoliageDetails_Medium)); m_comboVoxelQuality.AddItem((int)MyRenderQualityEnum.HIGH, MyTexts.GetString(MyCommonTexts.ScreenGraphicsOptions_FoliageDetails_High)); for (int i = 0; i < m_renderers.Length; i++) m_comboRenderer.AddItem(i, m_renderers[i]); labelFovDefault.UpdateFormatParams(MathHelper.ToDegrees(MyConstants.FIELD_OF_VIEW_CONFIG_DEFAULT)); var table = new MyLayoutTable(this); { const float h = 60f; table.SetColumnWidths(60f, 400f, 460f); table.SetRowHeights(100f, h, h, h, h, h, 40f, h, h, h, h, h, h, h, h, h, 120f); } int row = 1; const int leftCol = 1; const int rightCol = 2; const MyAlignH hAlign = MyAlignH.Left; const MyAlignV vAlign = MyAlignV.Center; table.Add(labelRenderer, hAlign, vAlign, row, leftCol); table.Add(m_comboRenderer, hAlign, vAlign, row++, rightCol); table.Add(labelHwCursor, hAlign, vAlign, row, leftCol); table.Add(m_checkboxHardwareCursor, hAlign, vAlign, row++, rightCol); table.Add(labelRenderInterpolation, hAlign, vAlign, row, leftCol); table.Add(m_checkboxRenderInterpolation, hAlign, vAlign, row++, rightCol); table.Add(labelEnableDamageEffects, hAlign, vAlign, row, leftCol); table.Add(m_checkboxEnableDamageEffects, hAlign, vAlign, row++, rightCol); table.Add(labelFov, hAlign, vAlign, row, leftCol); table.Add(m_sliderFov, hAlign, vAlign, row++, rightCol); table.Add(labelFovDefault, hAlign, MyAlignV.Top, row++, rightCol); if (MyVideoSettingsManager.RunningGraphicsRenderer == MySandboxGame.DirectX11RendererKey) { table.Add(labelGraphicsPresets, hAlign, vAlign, row, leftCol); table.Add(m_comboGraphicsPresets, hAlign, vAlign, row++, rightCol); table.Add(labelAntiAliasing, hAlign, vAlign, row, leftCol); table.Add(m_comboAntialiasing, hAlign, vAlign, row++, rightCol); table.Add(labelShadowMapResolution, hAlign, vAlign, row, leftCol); table.Add(m_comboShadowMapResolution, hAlign, vAlign, row++, rightCol); table.Add(labelTextureQuality, hAlign, vAlign, row, leftCol); table.Add(m_comboTextureQuality, hAlign, vAlign, row++, rightCol); table.Add(labelVoxelQuality, hAlign, vAlign, row, leftCol); table.Add(m_comboVoxelQuality, hAlign, vAlign, row++, rightCol); table.Add(labelAnisotropicFiltering, hAlign, vAlign, row, leftCol); table.Add(m_comboAnisotropicFiltering, hAlign, vAlign, row++, rightCol); //table.Add(labelMultithreadedRendering, hAlign, vAlign, row, leftCol); //table.Add(m_checkboxMultithreadedRender, hAlign, vAlign, row++, rightCol); //table.Add(labelTonemapping, hAlign, vAlign, row, leftCol); //table.Add(m_checkboxTonemapping, hAlign, vAlign, row++, rightCol); if (MyFakes.ENABLE_PLANETS) { table.Add(labelFoliageDetails, hAlign, vAlign, row, leftCol); table.Add(m_comboFoliageDetails, hAlign, vAlign, row++, rightCol); table.Add(labelGrassDensity, hAlign, vAlign, row, leftCol); table.Add(m_grassDensitySlider, hAlign, vAlign, row++, rightCol); table.Add(labelVegetationDistance, hAlign, vAlign, row, leftCol); table.Add(m_vegetationViewDistance, hAlign, vAlign, row++, rightCol); } } table.Add(okButton, MyAlignH.Left, MyAlignV.Bottom, table.LastRow, leftCol); table.Add(cancelButton, MyAlignH.Right, MyAlignV.Bottom, table.LastRow, rightCol); { // Set FoV bounds based on current display setting. float fovMin, fovMax; MyVideoSettingsManager.GetFovBounds(out fovMin, out fovMax); m_sliderFov.SetBounds(MathHelper.ToDegrees(fovMin), MathHelper.ToDegrees(fovMax)); m_sliderFov.DefaultValue = MathHelper.ToDegrees(MySandboxGame.Config.FieldOfView); } { m_grassDensitySlider.SetBounds(0f, 10f); } // Update controls with values from config file m_settingsOld = MyVideoSettingsManager.CurrentGraphicsSettings; m_settingsNew = m_settingsOld; WriteSettingsToControls(m_settingsOld); // Update OLD settings ReadSettingsFromControls(ref m_settingsOld); ReadSettingsFromControls(ref m_settingsNew); { MyGuiControlCombobox.ItemSelectedDelegate onComboItemSelected = OnSettingsChanged; Action<MyGuiControlCheckbox> onCheckboxChanged = (checkbox) => OnSettingsChanged(); m_comboGraphicsPresets.ItemSelected += OnPresetSelected; m_comboAnisotropicFiltering.ItemSelected += onComboItemSelected; m_comboAntialiasing.ItemSelected += onComboItemSelected; m_comboShadowMapResolution.ItemSelected += onComboItemSelected; m_comboFoliageDetails.ItemSelected += onComboItemSelected; m_comboVoxelQuality.ItemSelected += onComboItemSelected; m_comboTextureQuality.ItemSelected += onComboItemSelected; m_checkboxHardwareCursor.IsCheckedChanged = onCheckboxChanged; //m_checkboxMultithreadedRender.IsCheckedChanged = onCheckboxChanged; m_checkboxRenderInterpolation.IsCheckedChanged = onCheckboxChanged; //m_checkboxTonemapping.IsCheckedChanged = onCheckboxChanged; m_checkboxEnableDamageEffects.IsCheckedChanged = onCheckboxChanged; m_sliderFov.ValueChanged = (slider) => OnSettingsChanged(); // m_grassDensitySlider.ValueChanged = (slider) => OnSettingsChanged(); } RefreshPresetCombo(m_settingsOld.Render); CloseButtonEnabled = true; CloseButtonOffset = new Vector2(-50f, 50f) / MyGuiConstants.GUI_OPTIMAL_SIZE; }
public override void RecreateControls(bool constructor) { base.RecreateControls(constructor); m_scale = 0.7f; AddCaption("Render Character", Color.Yellow.ToVector4()); AddShareFocusHint(); m_currentPosition = -m_size.Value / 2.0f + new Vector2(0.02f, 0.10f); m_currentPosition.Y += 0.01f; if (MySession.ControlledEntity == null || !(MySession.ControlledEntity is MyCharacter)) { AddLabel("None active character", Color.Yellow.ToVector4(), 1.2f); return; } MyCharacter playerCharacter = MySession.LocalCharacter; if (!constructor) playerCharacter.DebugMode = true; AddSlider("Max slope", playerCharacter.Definition.MaxSlope, 0f, 89f, (slider) => { playerCharacter.Definition.MaxSlope = slider.Value; }); AddLabel(playerCharacter.Model.AssetName, Color.Yellow.ToVector4(), 1.2f); AddLabel("Animation A:", Color.Yellow.ToVector4(), 1.2f); m_animationComboA = AddCombo(); int i = 0; foreach (var animation in playerCharacter.Definition.AnimationNameToSubtypeName) { m_animationComboA.AddItem(i++, new StringBuilder(animation.Key)); } m_animationComboA.SelectItemByIndex(0); AddLabel("Animation B:", Color.Yellow.ToVector4(), 1.2f); m_animationComboB = AddCombo(); i = 0; foreach (var animation in playerCharacter.Definition.AnimationNameToSubtypeName) { m_animationComboB.AddItem(i++, new StringBuilder(animation.Key)); } m_animationComboB.SelectItemByIndex(0); m_blendSlider = AddSlider("Blend time", 0.5f, 0, 3, null); AddButton(new StringBuilder("Play A->B"), OnPlayBlendButtonClick); m_currentPosition.Y += 0.01f; m_animationCombo = AddCombo(); i = 0; foreach (var animation in playerCharacter.Definition.AnimationNameToSubtypeName) { m_animationCombo.AddItem(i++, new StringBuilder(animation.Key)); } m_animationCombo.SortItemsByValueText(); m_animationCombo.SelectItemByIndex(0); m_loopCheckbox = AddCheckBox("Loop", false, null); m_currentPosition.Y += 0.02f; foreach (var val in System.Enum.GetValues(typeof(MyBonesArea))) { string name = System.Enum.GetName(typeof(MyBonesArea), val); var checkBox = AddCheckBox(name, false, null); checkBox.UserData = val; if (name == "Body") checkBox.IsChecked = true; } AddButton(new StringBuilder("Play animation"), OnPlayButtonClick); m_currentPosition.Y += 0.01f; }
private void UpdateOwnerGui() { long?owner; bool propertyMixed = GetOwnershipStatus(out owner); m_transferToCombobox.ClearItems(); if (!propertyMixed && !owner.HasValue) { return; //selected block without id module } if (propertyMixed || owner.Value != 0) { m_transferToCombobox.AddItem(0, MyTexts.Get(MySpaceTexts.BlockOwner_Nobody)); } if (propertyMixed || owner.Value != MySession.Static.LocalPlayerId) { m_transferToCombobox.AddItem(MySession.Static.LocalPlayerId, MyTexts.Get(MySpaceTexts.BlockOwner_Me)); } foreach (var playerEntry in Sync.Players.GetOnlinePlayers()) { var identity = playerEntry.Identity; if (identity.IdentityId != MySession.Static.LocalPlayerId && !identity.IsDead) { var relation = MySession.Static.LocalHumanPlayer.GetRelationTo(identity.IdentityId); if (relation != VRage.Game.MyRelationsBetweenPlayerAndBlock.Enemies) { m_transferToCombobox.AddItem(identity.IdentityId, new StringBuilder(identity.DisplayName)); } } } foreach (var identityId in Sync.Players.GetNPCIdentities()) { var identity = Sync.Players.TryGetIdentity(identityId); Debug.Assert(identity != null, "Couldn't find NPC identity!"); if (identity == null) { continue; } var relation = MySession.Static.LocalHumanPlayer.GetRelationTo(identity.IdentityId); m_transferToCombobox.AddItem(identity.IdentityId, new StringBuilder(identity.DisplayName)); } if (!propertyMixed) { if (owner.Value == MySession.Static.LocalPlayerId) { m_shareModeCombobox.Enabled = true; } else { m_shareModeCombobox.Enabled = false; } if (owner.Value == 0) { m_transferToCombobox.Enabled = true; m_ownerLabel.TextEnum = MySpaceTexts.BlockOwner_Nobody; } else { m_transferToCombobox.Enabled = owner.Value == MySession.Static.LocalPlayerId; m_ownerLabel.TextEnum = MySpaceTexts.BlockOwner_Me; if (owner.Value != MySession.Static.LocalPlayerId) { var identity = Sync.Players.TryGetIdentity(owner.Value); if (identity != null) { m_ownerLabel.Text = identity.DisplayName + (identity.IsDead ? " [" + MyTexts.Get(MyCommonTexts.PlayerInfo_Dead).ToString() + "]" : ""); } else { m_ownerLabel.TextEnum = MySpaceTexts.BlockOwner_Unknown; } } } MyOwnershipShareModeEnum?shareMode; propertyMixed = GetShareMode(out shareMode); m_canChangeShareMode = false; if (!propertyMixed && shareMode.HasValue && owner.Value != 0) { m_shareModeCombobox.SelectItemByKey((long)shareMode.Value); } else { m_shareModeCombobox.SelectItemByIndex(-1); } m_canChangeShareMode = true; } else { m_shareModeCombobox.Enabled = true; m_ownerLabel.Text = ""; m_canChangeShareMode = false; m_shareModeCombobox.SelectItemByIndex(-1); m_canChangeShareMode = true; } }
public override void RecreateControls(bool constructor) { base.RecreateControls(constructor); CloseButtonEnabled = true; var caption = AddCaption(MyCommonTexts.ScreenCaptionPlayers); var captionCenter = MyUtils.GetCoordCenterFromAligned(caption.Position, caption.Size, caption.OriginAlign); var captionBottomCenter = captionCenter + new Vector2(0f, 0.5f * caption.Size.Y); Vector2 sizeScale = Size.Value / MyGuiConstants.TEXTURE_SCREEN_BACKGROUND.SizeGui; Vector2 topLeft = -0.5f * Size.Value + sizeScale * MyGuiConstants.TEXTURE_SCREEN_BACKGROUND.PaddingSizeGui * 1.1f; float verticalSpacing = 0.0045f; m_lobbyTypeCombo = new MyGuiControlCombobox( position: new Vector2(-topLeft.X, captionBottomCenter.Y + verticalSpacing), openAreaItemsCount: 3); m_lobbyTypeCombo.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP; m_lobbyTypeCombo.AddItem((int)LobbyTypeEnum.Private, MyCommonTexts.ScreenPlayersLobby_Private); m_lobbyTypeCombo.AddItem((int)LobbyTypeEnum.FriendsOnly, MyCommonTexts.ScreenPlayersLobby_Friends); m_lobbyTypeCombo.AddItem((int)LobbyTypeEnum.Public, MyCommonTexts.ScreenPlayersLobby_Public); m_lobbyTypeCombo.SelectItemByKey((int)MyMultiplayer.Static.GetLobbyType()); MyGuiControlBase aboveControl; m_inviteButton = new MyGuiControlButton( position: new Vector2(-m_lobbyTypeCombo.Position.X, m_lobbyTypeCombo.Position.Y + m_lobbyTypeCombo.Size.Y + verticalSpacing), originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, text: MyTexts.Get(MyCommonTexts.ScreenPlayers_Invite)); aboveControl = m_inviteButton; m_promoteButton = new MyGuiControlButton( position: aboveControl.Position + new Vector2(0f, aboveControl.Size.Y + verticalSpacing), originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, text: MyTexts.Get(MyCommonTexts.ScreenPlayers_Promote)); aboveControl = m_promoteButton; m_demoteButton = new MyGuiControlButton( position: aboveControl.Position + new Vector2(0f, aboveControl.Size.Y + verticalSpacing), originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, text: MyTexts.Get(MyCommonTexts.ScreenPlayers_Demote)); aboveControl = m_demoteButton; m_kickButton = new MyGuiControlButton( position: aboveControl.Position + new Vector2(0f, aboveControl.Size.Y + verticalSpacing), originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, text: MyTexts.Get(MyCommonTexts.ScreenPlayers_Kick)); aboveControl = m_kickButton; m_banButton = new MyGuiControlButton( position: aboveControl.Position + new Vector2(0f, aboveControl.Size.Y + verticalSpacing), originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, text: MyTexts.Get(MyCommonTexts.ScreenPlayers_Ban)); aboveControl = m_banButton; var maxPlayersLabel = new MyGuiControlLabel( position: aboveControl.Position + new Vector2(0f, aboveControl.Size.Y + verticalSpacing), originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, text: MyTexts.GetString(MyCommonTexts.MaxPlayers)); aboveControl = maxPlayersLabel; m_maxPlayersSlider = new MyGuiControlSlider( position: aboveControl.Position + new Vector2(0f, aboveControl.Size.Y), width: 0.15f, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, minValue: 2, maxValue: MyMultiplayer.Static != null ? MyMultiplayer.Static.MaxPlayers : 16, labelText: new StringBuilder("{0}").ToString(), labelDecimalPlaces: 0, labelSpaceWidth: 0.02f, defaultValue: Sync.IsServer ? MySession.Static.MaxPlayers : MyMultiplayer.Static.MemberLimit, intValue: true); m_maxPlayersSlider.ValueChanged = MaxPlayersSlider_Changed; aboveControl = m_maxPlayersSlider; m_playersTable = new MyGuiControlTable() { Position = new Vector2(-m_inviteButton.Position.X, m_inviteButton.Position.Y), Size = new Vector2(1200f / MyGuiConstants.GUI_OPTIMAL_SIZE.X, 1f) - m_inviteButton.Size * 1.05f, VisibleRowsCount = 21, OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP, ColumnsCount = 5, }; float PlayerNameWidth = 0.3f; float FactionTagWidth = 0.1f; float FactionNameWidth = MyPerGameSettings.EnableMutePlayer ? 0.3f : 0.34f; float MutedWidth = MyPerGameSettings.EnableMutePlayer ? 0.13f : 0; m_playersTable.SetCustomColumnWidths(new float[] { PlayerNameWidth, FactionTagWidth, FactionNameWidth, MutedWidth, 1 - PlayerNameWidth - FactionTagWidth - FactionNameWidth - MutedWidth }); m_playersTable.SetColumnName(PlayerNameColumn, MyTexts.Get(MyCommonTexts.ScreenPlayers_PlayerName)); m_playersTable.SetColumnName(PlayerFactionTagColumn, MyTexts.Get(MyCommonTexts.ScreenPlayers_FactionTag)); m_playersTable.SetColumnName(PlayerFactionNameColumn, MyTexts.Get(MyCommonTexts.ScreenPlayers_FactionName)); m_playersTable.SetColumnName(PlayerMutedColumn, new StringBuilder(MyTexts.GetString(MyCommonTexts.ScreenPlayers_Muted))); m_playersTable.SetColumnName(GameAdminColumn, MyTexts.Get(MyCommonTexts.ScreenPlayers_GameAdmin)); m_playersTable.SetColumnComparison(0, (a, b) => (a.Text.CompareToIgnoreCase(b.Text))); m_playersTable.ItemSelected += playersTable_ItemSelected; // CH: To show the clients correctly, we would need to know, whether the game is a dedicated-server-hosted game. // We don't know that, so I just show all clients with players foreach (var player in Sync.Players.GetOnlinePlayers()) { if (player.Id.SerialId != 0) continue; for (int i = 0; i < m_playersTable.RowsCount; ++i) { var row = m_playersTable.GetRow(i); if (row.UserData is ulong && (ulong)row.UserData == player.Id.SteamId) continue; } AddPlayer(player.Id.SteamId); } m_inviteButton.ButtonClicked += inviteButton_ButtonClicked; m_promoteButton.ButtonClicked += promoteButton_ButtonClicked; m_demoteButton.ButtonClicked += demoteButton_ButtonClicked; m_kickButton.ButtonClicked += kickButton_ButtonClicked; m_banButton.ButtonClicked += banButton_ButtonClicked; m_lobbyTypeCombo.ItemSelected += lobbyTypeCombo_OnSelect; Controls.Add(m_inviteButton); Controls.Add(m_promoteButton); Controls.Add(m_demoteButton); Controls.Add(m_kickButton); Controls.Add(m_banButton); Controls.Add(m_playersTable); Controls.Add(m_lobbyTypeCombo); Controls.Add(m_maxPlayersSlider); Controls.Add(maxPlayersLabel); UpdateButtonsEnabledState(); }
public override void RecreateControls(bool constructor) { base.RecreateControls(constructor); AddCaption(MyCommonTexts.ScreenCaptionControls); MyInput.Static.TakeSnapshot(); var topCenter = m_size.Value * new Vector2(0f, -0.5f); var bottomCenter = m_size.Value * new Vector2(0f, 0.5f); var topLeft = m_size.Value * -0.5f; m_controlsOriginLeft = topLeft + new Vector2(96f, 122f) / MyGuiConstants.GUI_OPTIMAL_SIZE; m_controlsOriginRight = topCenter + new Vector2(-60f, 122f) / MyGuiConstants.GUI_OPTIMAL_SIZE; #region Add Revert, OK, Cancel and selection combobox var buttonSize = MyGuiControlButton.GetVisualStyle(MyGuiControlButtonStyleEnum.Default).NormalTexture.MinSizeGui; float buttonsY = bottomCenter.Y - 110f / MyGuiConstants.GUI_OPTIMAL_SIZE.Y; var okButton = new MyGuiControlButton( position: new Vector2(-buttonSize.X - 20f / MyGuiConstants.GUI_OPTIMAL_SIZE.X, buttonsY), size: MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE_SMALL, text: MyTexts.Get(MyCommonTexts.Ok), onButtonClick: OnOkClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); var cancelButton = new MyGuiControlButton( position: new Vector2(0f, buttonsY), size: MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE_SMALL, text: MyTexts.Get(MyCommonTexts.Cancel), onButtonClick: OnCancelClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); var resetButton = new MyGuiControlButton( position: new Vector2(buttonSize.X + 20f / MyGuiConstants.GUI_OPTIMAL_SIZE.X, buttonsY), size: MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE_SMALL, text: MyTexts.Get(MyCommonTexts.Revert), onButtonClick: OnResetDefaultsClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); Controls.Add(okButton); Controls.Add(cancelButton); Controls.Add(resetButton); // Page selection combobox m_currentControlType = MyGuiControlTypeEnum.General; var cBoxPosition = m_controlsOriginRight + 0.5f * MyGuiConstants.CONTROLS_DELTA + new Vector2(MyGuiConstants.COMBOBOX_MEDIUM_SIZE.X / 2.0f, 0) - new Vector2(0.065f, 0); m_controlTypeList = new MyGuiControlCombobox(cBoxPosition); m_controlTypeList.AddItem((int)MyGuiControlTypeEnum.General, MyCommonTexts.ControlTypeGeneral); m_controlTypeList.AddItem((int)MyGuiControlTypeEnum.Navigation, MyCommonTexts.ControlTypeNavigation); m_controlTypeList.AddItem((int)MyGuiControlTypeEnum.ToolsOrWeapons, MyCommonTexts.ControlTypeToolsOrWeapons); m_controlTypeList.AddItem((int)MyGuiControlTypeEnum.ToolsOrWeapons2, MyCommonTexts.ControlTypeToolsOrWeapons2); m_controlTypeList.AddItem((int)MyGuiControlTypeEnum.Systems1, MyCommonTexts.ControlTypeSystems1); m_controlTypeList.AddItem((int)MyGuiControlTypeEnum.Systems2, MyCommonTexts.ControlTypeSystems2); m_controlTypeList.AddItem((int)MyGuiControlTypeEnum.Systems3, MyCommonTexts.ControlTypeSystems3); m_controlTypeList.AddItem((int)MyGuiControlTypeEnum.Spectator, MyCommonTexts.Spectator); m_controlTypeList.SelectItemByKey((int)m_currentControlType); Controls.Add(m_controlTypeList); #endregion AddControls(); ActivateControls(m_currentControlType); CloseButtonEnabled = true; }
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_descriptionTextbox = new MyGuiControlTextbox(maxLength: MySession.MAX_DESCRIPTION_LENGTH); 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_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: OnOkButtonClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM); m_createButton = new MyGuiControlButton(position: buttonsOrigin + new Vector2(2*(0.01f + m_removeButton.Size.X), 0f), size: buttonSize, text: MyTexts.Get(MySpaceTexts.buttonCreateNew), onButtonClick: OnOkButtonClick, 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: OnOkButtonClick, 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_createButton); m_createButton.Enabled = false; Controls.Add(m_browseWorkshopButton); m_browseWorkshopButton.Enabled = false; Controls.Add(m_refreshButton); Controls.Add(m_openInWorkshopButton); m_openInWorkshopButton.Enabled = false; Controls.Add(m_okButton); Controls.Add(m_cancelButton); CloseButtonEnabled = true; SetDefaultValues(); }
private void CreateObjectsSpawnMenu(float separatorSize, float usableWidth) { AddSubcaption(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_Items), Color.White.ToVector4(), new Vector2(-HIDDEN_PART_RIGHT, 0.0f)); AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_ItemType), Vector4.One, m_scale); m_physicalObjectCombobox = AddCombo(); { foreach (var definition in MyDefinitionManager.Static.GetAllDefinitions()) { if (!definition.Public) continue; var physicalItemDef = definition as MyPhysicalItemDefinition; if (physicalItemDef == null || physicalItemDef.CanSpawnFromScreen == false) continue; int key = m_physicalItemDefinitions.Count; m_physicalItemDefinitions.Add(physicalItemDef); m_physicalObjectCombobox.AddItem(key, definition.DisplayNameText); } m_physicalObjectCombobox.SortItemsByValueText(); m_physicalObjectCombobox.SelectItemByIndex(m_lastSelectedFloatingObjectIndex); m_physicalObjectCombobox.ItemSelected += OnPhysicalObjectCombobox_ItemSelected; } m_currentPosition.Y += separatorSize; AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_ItemAmount), Vector4.One, m_scale); m_amountTextbox = new MyGuiControlTextbox(m_currentPosition, m_amount.ToString(), 6, null, m_scale, MyGuiControlTextboxType.DigitsOnly); m_amountTextbox.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; m_amountTextbox.TextChanged += OnAmountTextChanged; Controls.Add(m_amountTextbox); m_currentPosition.Y += separatorSize + m_amountTextbox.Size.Y; m_errorLabel = AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_InvalidAmount), Color.Red.ToVector4(), m_scale); m_errorLabel.Visible = false; CreateDebugButton(usableWidth, MySpaceTexts.ScreenDebugSpawnMenu_SpawnObject, OnSpawnPhysicalObject); m_currentPosition.Y += separatorSize; }
protected virtual void BuildControls() { Vector2 buttonSize = MyGuiConstants.BACK_BUTTON_SIZE; Vector2 buttonsOrigin = m_size.Value / 2 - new Vector2(0.23f, 0.03f); if (m_isNewGame) AddCaption(MyCommonTexts.ScreenCaptionCustomWorld); else AddCaption(MyCommonTexts.ScreenCaptionEditSettings); int numControls = 0; var nameLabel = MakeLabel(MyCommonTexts.Name); var descriptionLabel = MakeLabel(MyCommonTexts.Description); var gameModeLabel = MakeLabel(MyCommonTexts.WorldSettings_GameMode); var onlineModeLabel = MakeLabel(MyCommonTexts.WorldSettings_OnlineMode); m_maxPlayersLabel = MakeLabel(MyCommonTexts.MaxPlayers); var environmentLabel = MakeLabel(MySpaceTexts.WorldSettings_EnvironmentHostility); var scenarioLabel = MakeLabel(MySpaceTexts.WorldSettings_Scenario); var soundModeLabel = MakeLabel(MySpaceTexts.WorldSettings_SoundMode); float width = 0.284375f + 0.025f; m_nameTextbox = new MyGuiControlTextbox(maxLength: MySession.MAX_NAME_LENGTH); m_descriptionTextbox = new MyGuiControlTextbox(maxLength: MySession.MAX_DESCRIPTION_LENGTH); m_onlineMode = new MyGuiControlCombobox(size: new Vector2(width, 0.04f)); m_environment = new MyGuiControlCombobox(size: new Vector2(width, 0.04f)); m_maxPlayersSlider = new MyGuiControlSlider( position: Vector2.Zero, width: m_onlineMode.Size.X, minValue: 2, maxValue: 16, labelText: new StringBuilder("{0}").ToString(), labelDecimalPlaces: 0, labelSpaceWidth: 0.05f, intValue: true ); m_asteroidAmountLabel = MakeLabel(MySpaceTexts.Asteroid_Amount); m_asteroidAmountCombo = new MyGuiControlCombobox(size: new Vector2(width, 0.04f)); m_asteroidAmountCombo.ItemSelected += m_asteroidAmountCombo_ItemSelected; m_soundModeCombo = new MyGuiControlCombobox(size: new Vector2(width, 0.04f)); m_scenarioTypesList = new MyGuiControlList(); // Ok/Cancel m_okButton = new MyGuiControlButton(position: buttonsOrigin - new Vector2(0.01f, 0f), size: buttonSize, text: MyTexts.Get(MyCommonTexts.Ok), onButtonClick: OnOkButtonClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM); m_cancelButton = new MyGuiControlButton(position: buttonsOrigin + new Vector2(0.01f, 0f), size: buttonSize, text: MyTexts.Get(MyCommonTexts.Cancel), onButtonClick: OnCancelButtonClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM); m_creativeModeButton = new MyGuiControlButton(visualStyle: MyGuiControlButtonStyleEnum.Small, highlightType: MyGuiControlHighlightType.WHEN_ACTIVE, text: MyTexts.Get(MyCommonTexts.WorldSettings_GameModeCreative), onButtonClick: OnCreativeClick); m_creativeModeButton.SetToolTip(MySpaceTexts.ToolTipWorldSettingsModeCreative); m_survivalModeButton = new MyGuiControlButton(visualStyle: MyGuiControlButtonStyleEnum.Small, highlightType: MyGuiControlHighlightType.WHEN_ACTIVE, text: MyTexts.Get(MyCommonTexts.WorldSettings_GameModeSurvival), onButtonClick: OnSurvivalClick); m_survivalModeButton.SetToolTip(MySpaceTexts.ToolTipWorldSettingsModeSurvival); m_onlineMode.ItemSelected += OnOnlineModeSelect; m_onlineMode.AddItem((int)MyOnlineModeEnum.OFFLINE, MyCommonTexts.WorldSettings_OnlineModeOffline); m_onlineMode.AddItem((int)MyOnlineModeEnum.PRIVATE, MyCommonTexts.WorldSettings_OnlineModePrivate); m_onlineMode.AddItem((int)MyOnlineModeEnum.FRIENDS, MyCommonTexts.WorldSettings_OnlineModeFriends); m_onlineMode.AddItem((int)MyOnlineModeEnum.PUBLIC, MyCommonTexts.WorldSettings_OnlineModePublic); m_environment.AddItem((int)MyEnvironmentHostilityEnum.SAFE, MySpaceTexts.WorldSettings_EnvironmentHostilitySafe); m_environment.AddItem((int)MyEnvironmentHostilityEnum.NORMAL, MySpaceTexts.WorldSettings_EnvironmentHostilityNormal); m_environment.AddItem((int)MyEnvironmentHostilityEnum.CATACLYSM, MySpaceTexts.WorldSettings_EnvironmentHostilityCataclysm); m_environment.AddItem((int)MyEnvironmentHostilityEnum.CATACLYSM_UNREAL, MySpaceTexts.WorldSettings_EnvironmentHostilityCataclysmUnreal); m_environment.ItemSelected += HostilityChanged; m_soundModeCombo.AddItem((int)MySoundModeEnum.Arcade, MySpaceTexts.WorldSettings_ArcadeSound); m_soundModeCombo.AddItem((int)MySoundModeEnum.Realistic, MySpaceTexts.WorldSettings_RealisticSound); if (m_isNewGame) { m_scenarioTypesGroup = new MyGuiControlRadioButtonGroup(); m_scenarioTypesGroup.SelectedChanged += scenario_SelectedChanged; foreach (var scenario in MyDefinitionManager.Static.GetScenarioDefinitions()) { if (!scenario.Public && !MyFakes.ENABLE_NON_PUBLIC_SCENARIOS) continue; var button = new MyGuiControlScenarioButton(scenario); m_scenarioTypesGroup.Add(button); m_scenarioTypesList.Controls.Add(button); } } m_nameTextbox.SetToolTip(string.Format(MyTexts.GetString(MyCommonTexts.ToolTipWorldSettingsName), MySession.MIN_NAME_LENGTH, MySession.MAX_NAME_LENGTH)); m_descriptionTextbox.SetToolTip(MyTexts.GetString(MyCommonTexts.ToolTipWorldSettingsDescription)); m_environment.SetToolTip(MyTexts.GetString(MySpaceTexts.ToolTipWorldSettingsEnvironment)); m_onlineMode.SetToolTip(MyTexts.GetString(MySpaceTexts.ToolTipWorldSettingsOnlineMode)); m_maxPlayersSlider.SetToolTip(MyTexts.GetString(MySpaceTexts.ToolTipWorldSettingsMaxPlayer)); m_asteroidAmountCombo.SetToolTip(MyTexts.GetString(MySpaceTexts.ToolTipWorldSettingsAsteroidAmount)); m_soundModeCombo.SetToolTip(MyTexts.GetString(MySpaceTexts.ToolTipWorldSettingsSoundMode)); m_nameTextbox.TextChanged += m_nameTextbox_TextChanged; m_soundModeCombo.ItemSelected += m_soundModeCombo_ItemSelected; var advanced = new MyGuiControlButton(highlightType: MyGuiControlHighlightType.WHEN_ACTIVE, text: MyTexts.Get(MySpaceTexts.WorldSettings_Advanced), onButtonClick: OnAdvancedClick); #if !XB1 // XB1_NOWORKSHOP var mods = new MyGuiControlButton(highlightType: MyGuiControlHighlightType.WHEN_ACTIVE, text: MyTexts.Get(MyCommonTexts.WorldSettings_Mods), onButtonClick: OnModsClick); #endif // !XB1 m_worldGeneratorButton = new MyGuiControlButton(highlightType: MyGuiControlHighlightType.WHEN_ACTIVE, text: MyTexts.Get(MySpaceTexts.WorldSettings_WorldGenerator), onButtonClick: OnWorldGeneratorClick); // Add controls in pairs; label first, control second. They will be laid out automatically this way. Controls.Add(nameLabel); Controls.Add(m_nameTextbox); Controls.Add(descriptionLabel); Controls.Add(m_descriptionTextbox); Controls.Add(gameModeLabel); Controls.Add(m_creativeModeButton); if (MyFakes.ENABLE_NEW_SOUNDS) { Controls.Add(soundModeLabel); Controls.Add(m_soundModeCombo); } Controls.Add(onlineModeLabel); Controls.Add(m_onlineMode); Controls.Add(m_maxPlayersLabel); Controls.Add(m_maxPlayersSlider); if (MyFakes.ENABLE_METEOR_SHOWERS) { Controls.Add(environmentLabel); Controls.Add(m_environment); } if (m_isNewGame && MyFakes.ENABLE_PLANETS == false) { Controls.Add(m_asteroidAmountLabel); Controls.Add(m_asteroidAmountCombo); } var autoSaveLabel = MakeLabel(MyCommonTexts.WorldSettings_AutoSave); m_autoSave = new MyGuiControlCheckbox(); m_autoSave.SetToolTip(new StringBuilder().AppendFormat(MyCommonTexts.ToolTipWorldSettingsAutoSave, MyObjectBuilder_SessionSettings.DEFAULT_AUTOSAVE_IN_MINUTES).ToString()); Controls.Add(autoSaveLabel); Controls.Add(m_autoSave); var scenarioEditModeLabel = MakeLabel(MySpaceTexts.WorldSettings_ScenarioEditMode); m_scenarioEditMode = new MyGuiControlCheckbox(); m_scenarioEditMode.SetToolTip(MyTexts.GetString(MySpaceTexts.ToolTipWorldSettings_ScenarioEditMode)); Controls.Add(scenarioEditModeLabel); Controls.Add(m_scenarioEditMode); #if !XB1 // XB1_NOWORKSHOP if (!MyFakes.XB1_PREVIEW) if (MyFakes.ENABLE_WORKSHOP_MODS) Controls.Add(mods); #endif // !XB1 Controls.Add(advanced); if (m_isNewGame && MyFakes.ENABLE_PLANETS == true) { Controls.Add(m_worldGeneratorButton); } float labelSize = 0.20f; float MARGIN_TOP = 0.12f; float MARGIN_BOTTOM = 0.12f; float MARGIN_LEFT = m_isNewGame ? 0.315f : 0.08f; float MARGIN_RIGHT = m_isNewGame ? 0.075f : 0.045f; // Automatic layout. Vector2 originL, originC; Vector2 controlsDelta = new Vector2(0f, 0.052f); float rightColumnOffset; originL = -m_size.Value / 2 + new Vector2(MARGIN_LEFT, MARGIN_TOP); originC = originL + new Vector2(labelSize, 0f); rightColumnOffset = originC.X + m_onlineMode.Size.X - labelSize - 0.017f; foreach (var control in Controls) { control.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER; if (control is MyGuiControlLabel) control.Position = originL + controlsDelta * numControls; else control.Position = originC + controlsDelta * numControls++; } Controls.Add(m_survivalModeButton); m_survivalModeButton.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER; m_survivalModeButton.Position = m_creativeModeButton.Position + new Vector2(m_onlineMode.Size.X, 0); if (m_isNewGame) { Vector2 scenarioPosition = new Vector2(-0.375f, nameLabel.Position.Y); m_nameTextbox.Size = m_onlineMode.Size; m_descriptionTextbox.Size = m_nameTextbox.Size; scenarioLabel.Position = scenarioPosition; m_scenarioTypesList.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; m_scenarioTypesList.Position = scenarioLabel.Position + new Vector2(0, 0.02f); m_scenarioTypesList.Size = new Vector2(0.19f, m_size.Value.Y - MARGIN_BOTTOM - MARGIN_TOP); Controls.Add(scenarioLabel); Controls.Add(m_scenarioTypesList); MyGuiControlSeparatorList m_verticalLine = new MyGuiControlSeparatorList(); Vector2 position = nameLabel.Position + new Vector2(-0.025f, -0.02f); m_verticalLine.AddVertical(position, m_size.Value.Y - MARGIN_BOTTOM - MARGIN_TOP + 0.04f); Controls.Add(m_verticalLine); } var pos2 = advanced.Position; //pos2.X = m_isNewGame ? 0.160f : 0.0f; pos2.X = Size.HasValue ? Size.Value.X / 2.0f - advanced.Size.X - MARGIN_RIGHT : 0.0f; advanced.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM; advanced.Position = pos2; #if !XB1 // XB1_NOWORKSHOP mods.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM; mods.Position = advanced.Position - new Vector2(advanced.Size.X + 0.017f, 0); #endif // !XB1 m_worldGeneratorButton.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM; m_worldGeneratorButton.Position = advanced.Position - new Vector2(advanced.Size.X + 0.017f, -0.06f); if (MyFakes.XB1_PREVIEW) { var pos2p = m_worldGeneratorButton.Position; pos2p.X = Size.HasValue ? Size.Value.X / 2.0f - m_worldGeneratorButton.Size.X - MARGIN_RIGHT : 0.0f; m_worldGeneratorButton.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM; m_worldGeneratorButton.Position = pos2p; advanced.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM; if (m_isNewGame) { advanced.Position = m_worldGeneratorButton.Position - new Vector2(m_worldGeneratorButton.Size.X + 0.017f, 0); } else { advanced.Position = m_worldGeneratorButton.Position - new Vector2(m_worldGeneratorButton.Size.X + 0.017f, 0.008f); } } Controls.Add(m_okButton); Controls.Add(m_cancelButton); CloseButtonEnabled = true; }
public override void RecreateControls(bool constructor) { base.RecreateControls(constructor); m_sizeCombobox = new MyGuiControlCombobox() { OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER, Position = Vector2.Zero, }; foreach (var val in typeof(MyCubeSize).GetEnumValues()) { m_sizeCombobox.AddItem((int)(MyCubeSize)val, new StringBuilder(val.ToString())); } m_sizeCombobox.SelectItemByKey((int)MyCubeSize.Large); m_staticCheckbox = new MyGuiControlCheckbox() { OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, IsChecked = true, }; var staticLabel = new MyGuiControlLabel() { OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, Position = new Vector2(m_staticCheckbox.Size.X, 0f), Text = "Static grid" }; var okButton = new MyGuiControlButton() { OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_TOP, Text = "Ok", Position = new Vector2(0f, 0.05f), }; okButton.ButtonClicked += okButton_ButtonClicked; Elements.Add(m_sizeCombobox); Elements.Add(m_staticCheckbox); Elements.Add(staticLabel); Elements.Add(okButton); }
protected override void BuildControls() { base.BuildControls(); Vector2 buttonSize = MyGuiConstants.BACK_BUTTON_SIZE; Vector2 buttonsOrigin = m_size.Value / 2 - new Vector2(0.65f, 0.1f); var difficultyLabel = MakeLabel(MySpaceTexts.Difficulty); var onlineModeLabel = MakeLabel(MyCommonTexts.WorldSettings_OnlineMode); m_maxPlayersLabel = MakeLabel(MyCommonTexts.MaxPlayers); float width = 0.284375f + 0.025f; m_difficultyCombo = new MyGuiControlCombobox(size: new Vector2(width, 0.04f)); m_difficultyCombo.Enabled = false; m_difficultyCombo.AddItem((int)0, MySpaceTexts.DifficultyEasy); m_difficultyCombo.AddItem((int)1, MySpaceTexts.DifficultyNormal); m_difficultyCombo.AddItem((int)2, MySpaceTexts.DifficultyHard); m_onlineMode = new MyGuiControlCombobox(size: new Vector2(width, 0.04f)); m_onlineMode.Enabled = false; m_onlineMode.ItemSelected += OnOnlineModeSelect; m_onlineMode.AddItem((int)MyOnlineModeEnum.OFFLINE, MyCommonTexts.WorldSettings_OnlineModeOffline); m_onlineMode.AddItem((int)MyOnlineModeEnum.PRIVATE, MyCommonTexts.WorldSettings_OnlineModePrivate); m_onlineMode.AddItem((int)MyOnlineModeEnum.FRIENDS, MyCommonTexts.WorldSettings_OnlineModeFriends); m_onlineMode.AddItem((int)MyOnlineModeEnum.PUBLIC, MyCommonTexts.WorldSettings_OnlineModePublic); m_maxPlayersSlider = new MyGuiControlSlider( position: Vector2.Zero, width: m_onlineMode.Size.X, minValue: 2, maxValue: 16, labelText: new StringBuilder("{0}").ToString(), labelDecimalPlaces: 0, labelSpaceWidth: 0.05f, intValue: true ); m_scenarioTypesList = new MyGuiControlList(); //BUTTONS m_removeButton = new MyGuiControlButton(text: MyTexts.Get(MySpaceTexts.buttonRemove), onButtonClick: OnOkButtonClick); #if !XB1 // XB1_NOWORKSHOP m_publishButton = new MyGuiControlButton(text: MyTexts.Get(MySpaceTexts.buttonPublish), onButtonClick: OnPublishButtonClick); #else // XB1 m_publishButton = new MyGuiControlButton(text: MyTexts.Get(MySpaceTexts.buttonPublish), onButtonClick: OnOkButtonClick); #endif // XB1 m_editButton = new MyGuiControlButton(text: MyTexts.Get(MySpaceTexts.buttonEdit), onButtonClick: OnEditButtonClick); m_browseWorkshopButton = new MyGuiControlButton(text: MyTexts.Get(MySpaceTexts.buttonBrowseWorkshop), onButtonClick: OnBrowseWorkshopClick); m_refreshButton = new MyGuiControlButton(text: MyTexts.Get(MySpaceTexts.buttonRefresh), onButtonClick: OnRefreshButtonClick); m_openInWorkshopButton = new MyGuiControlButton(text: MyTexts.Get(MySpaceTexts.buttonOpenInWorkshop), onButtonClick: OnOkButtonClick); m_removeButton.Enabled = false; m_publishButton.Enabled = false; m_editButton.Enabled = false; m_openInWorkshopButton.Enabled = false; CloseButtonEnabled = true; //m_nameTextbox.TextChanged += m_nameTextbox_TextChanged; m_sideMenuLayout.Add(difficultyLabel, MyAlignH.Left, MyAlignV.Top, 2, 0); m_sideMenuLayout.Add(m_difficultyCombo, MyAlignH.Left, MyAlignV.Top, 2, 1); m_sideMenuLayout.Add(onlineModeLabel, MyAlignH.Left, MyAlignV.Top, 3, 0); m_sideMenuLayout.Add(m_onlineMode, MyAlignH.Left, MyAlignV.Top, 3, 1); m_sideMenuLayout.Add(m_maxPlayersLabel, MyAlignH.Left, MyAlignV.Top, 4, 0); m_sideMenuLayout.Add(m_maxPlayersSlider, MyAlignH.Left, MyAlignV.Top, 4, 1); m_buttonsLayout.Add(m_removeButton, MyAlignH.Left, MyAlignV.Top, 0, 0); if (!MyFakes.XB1_PREVIEW) { m_buttonsLayout.Add(m_publishButton, MyAlignH.Left, MyAlignV.Top, 0, 1); } m_buttonsLayout.Add(m_editButton, MyAlignH.Left, MyAlignV.Top, 0, 2); if (!MyFakes.XB1_PREVIEW) { m_buttonsLayout.Add(m_browseWorkshopButton, MyAlignH.Left, MyAlignV.Top, 0, 3); } m_buttonsLayout.Add(m_refreshButton, MyAlignH.Left, MyAlignV.Top, 1, 0); if (!MyFakes.XB1_PREVIEW) { m_buttonsLayout.Add(m_openInWorkshopButton, MyAlignH.Left, MyAlignV.Top, 1, 1); } }