private void AddInternal(MyGuiControlBase control, MyAlignH alignH, MyAlignV alignV, bool advance, float horizontalSize) { control.OriginAlign = (MyGuiDrawAlignEnum)(3 * (int)alignH + (int)alignV); int alignVSign = (-1 + (int)alignV); var offsetH = horizontalSize * 0.5f * (int)alignH; control.Position = new Vector2(m_currentPosX + offsetH, alignVSign * (0.5f * m_parentSize.Y - m_verticalPadding)); m_currentPosX += (advance) ? (horizontalSize - offsetH) : 0f; m_parent.Controls.Add(control); }
private void AddInternal(MyGuiControlBase control, MyAlignH alignH, MyAlignV alignV, bool advance, float verticalSize) { control.OriginAlign = (MyGuiDrawAlignEnum)(3 * (int)alignH + (int)alignV); int alignHSign = (-1 + (int)alignH); var offsetV = verticalSize * 0.5f * (int)alignV; control.Position = new Vector2( alignHSign * (0.5f * m_parentSize.X - m_horizontalPadding), m_currentPosY + offsetV); m_currentPosY += (advance) ? (verticalSize - offsetV) : 0f; m_parent.Controls.Add(control); }
public void Add(MyGuiControlBase control, MyAlignH alignH, MyAlignV alignV, int row, int col, int rowSpan = 1, int colSpan = 1) { var min = new Vector2(m_prefixScanX[col], m_prefixScanY[row]); var max = new Vector2(m_prefixScanX[col + colSpan], m_prefixScanY[row + rowSpan]); var size = max - min; control.Position = new Vector2( min.X + size.X * 0.5f * (int)alignH, min.Y + size.Y * 0.5f * (int)alignV); control.OriginAlign = (MyGuiDrawAlignEnum)(3 * (int)alignH + (int)alignV); m_parent.Controls.Add(control); }
private void AddInternal(MyGuiControlBase control, MyAlignH alignH, MyAlignV alignV, bool advance, float verticalSize) { control.OriginAlign = (MyGuiDrawAlignEnum)(3 * (int)alignH + (int)alignV); int alignHSign = (-1 + (int)alignH); var offsetV = verticalSize * 0.5f * (int)alignV; control.Position = new Vector2( alignHSign * (0.5f * m_parentSize.X - m_horizontalPadding), m_currentPosY + offsetV); m_currentPosY += (advance) ? (verticalSize - offsetV) : 0f; m_parent.Controls.Add(control); }
public void Add(MyGuiControlBase control, MyAlignH alignH, MyAlignV alignV, int row, int col, int rowSpan = 1, int colSpan = 1) { var min = new Vector2(m_prefixScanX[col], m_prefixScanY[row]); var max = new Vector2(m_prefixScanX[col + colSpan], m_prefixScanY[row + rowSpan]); var size = max - min; control.Position = new Vector2( min.X + size.X * 0.5f * (int)alignH, min.Y + size.Y * 0.5f * (int)alignV); control.OriginAlign = (MyGuiDrawAlignEnum)(3 * (int)alignH + (int)alignV); m_parent.Controls.Add(control); }
public void Add(MyGuiControlBase control, float preferredWidthPx, float preferredHeightPx, MyAlignH align) { control.Size = new Vector2(preferredWidthPx, preferredHeightPx) / MyGuiConstants.GUI_OPTIMAL_SIZE; Add(control, align); }
public void Add(MyGuiControlBase control, MyAlignH align, bool advance = true) { AddInternal(control, align, MyAlignV.Top, advance, control.Size.Y); }
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 labelDx9RenderQuality = new MyGuiControlLabel(textScale: TEXT_SCALE, text: MyTexts.GetString(MySpaceTexts.RenderQuality)); 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_comboDx9RenderQuality = new MyGuiControlCombobox(toolTip: MyTexts.GetString(MyCommonTexts.ToolTipVideoOptionsRenderQuality)); 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); 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); var okButton = new MyGuiControlButton(text: MyTexts.Get(MyCommonTexts.Ok), onButtonClick: OnOkClick); var cancelButton = new MyGuiControlButton(text: MyTexts.Get(MyCommonTexts.Cancel), onButtonClick: OnCancelClick); m_comboDx9RenderQuality.AddItem((int)MyRenderQualityEnum.NORMAL, MySpaceTexts.RenderQualityNormal); m_comboDx9RenderQuality.AddItem((int)MyRenderQualityEnum.HIGH, MySpaceTexts.RenderQualityHigh); m_comboDx9RenderQuality.AddItem((int)MyRenderQualityEnum.EXTREME, MySpaceTexts.RenderQualityExtreme); 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.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); int moveWhenDirX9 = 0; 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); } } else // Dx9 or nothing specified { table.Add(labelDx9RenderQuality, hAlign, vAlign, row, leftCol); table.Add(m_comboDx9RenderQuality, hAlign, vAlign, row++, rightCol); moveWhenDirX9 = 1; } table.Add(okButton, MyAlignH.Left, MyAlignV.Bottom, table.LastRow - moveWhenDirX9, leftCol); table.Add(cancelButton, MyAlignH.Right, MyAlignV.Bottom, table.LastRow - moveWhenDirX9, 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_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_comboDx9RenderQuality.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 void Add(MyGuiControlBase control, float preferredWidthPx, float preferredHeightPx, MyAlignH align) { control.Size = new Vector2(preferredWidthPx, preferredHeightPx) / MyGuiConstants.GUI_OPTIMAL_SIZE; Add(control, align); }
public void Add(MyGuiControlBase control, MyAlignH align, bool advance = true) { AddInternal(control, align, MyAlignV.Top, advance, control.Size.Y); }
private void AddInternal(MyGuiControlBase control, MyAlignH alignH, MyAlignV alignV, bool advance, float horizontalSize) { control.OriginAlign = (MyGuiDrawAlignEnum)(3 * (int)alignH + (int)alignV); int alignVSign = (-1 + (int)alignV); var offsetH = horizontalSize * 0.5f * (int)alignH; control.Position = new Vector2(m_currentPosX + offsetH, alignVSign * (0.5f * m_parentSize.Y - m_verticalPadding)); m_currentPosX += (advance) ? (horizontalSize - offsetH) : 0f; m_parent.Controls.Add(control); }