public override void RecreateControls(bool constructor)
        {
            base.RecreateControls(constructor);

            AddCaption(MyStringId.GetOrCompute("Waiting for other players"));

            var label = new MyGuiControlLabel(text: "Game will start when all players join the world", originAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);
            m_timeOutLabel = new MyGuiControlLabel(originAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);

            m_leaveButton = new MyGuiControlButton(text: new StringBuilder("Leave"), visualStyle: MyGuiControlButtonStyleEnum.Rectangular, highlightType: MyGuiControlHighlightType.WHEN_ACTIVE,
                size: new Vector2(190f, 48f) / MyGuiConstants.GUI_OPTIMAL_SIZE, onButtonClick: OnLeaveClicked);

            const float colMargin = 60f;
            const float rowHeight = 65f;
            var layout = new MyLayoutTable(this);
            layout.SetColumnWidths(colMargin, 680, colMargin);
            layout.SetRowHeights(110, rowHeight, rowHeight, rowHeight, rowHeight, rowHeight);

            layout.Add(label, MyAlignH.Center, MyAlignV.Center, 1, 1);
            layout.Add(m_timeOutLabel, MyAlignH.Center, MyAlignV.Center, 2, 1);
            layout.Add(m_leaveButton, MyAlignH.Center, MyAlignV.Center, 3, 1);
        }
        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;
        }