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("Character feet IK debug draw", Color.Yellow.ToVector4());
            AddShareFocusHint();

            AddCheckBox("Draw IK Settings ", null, MemberHelper.GetMember(() => MyDebugDrawSettings.DEBUG_DRAW_CHARACTER_IK_SETTINGS));
            AddCheckBox("Draw ankle final position", null, MemberHelper.GetMember(() => MyDebugDrawSettings.DEBUG_DRAW_CHARACTER_IK_ANKLE_FINALPOS));
            AddCheckBox("Draw raycast lines and foot lines", null, MemberHelper.GetMember(() => MyDebugDrawSettings.DEBUG_DRAW_CHARACTER_IK_RAYCASTLINE));
            AddCheckBox("Draw bones", null, MemberHelper.GetMember(() => MyDebugDrawSettings.DEBUG_DRAW_CHARACTER_IK_BONES));
            AddCheckBox("Draw raycast hits", null, MemberHelper.GetMember(() => MyDebugDrawSettings.DEBUG_DRAW_CHARACTER_IK_RAYCASTHITS));
            AddCheckBox("Draw ankle desired positions", null, MemberHelper.GetMember(() => MyDebugDrawSettings.DEBUG_DRAW_CHARACTER_IK_ANKLE_DESIREDPOSITION));
            AddCheckBox("Draw closest support position", null, MemberHelper.GetMember(() => MyDebugDrawSettings.DEBUG_DRAW_CHARACTER_IK_CLOSESTSUPPORTPOSITION));
            AddCheckBox("Draw IK solvers debug", null, MemberHelper.GetMember(() => MyDebugDrawSettings.DEBUG_DRAW_CHARACTER_IK_IKSOLVERS));
            AddCheckBox("Enable/Disable Feet IK", null, MemberHelper.GetMember(() => MyFakes.ENABLE_FOOT_IK));

            //characterMovementStateCombo = AddCombo<Sandbox.Common.ObjectBuilders.MyCharacterMovementEnum>(null,  MemberHelper.GetMember(() => MyDebugDrawSettings.DEBUG_DRAW_CHARACTER_IK_MOVEMENT_STATE));
            enabledIKState = AddCheckBox("Enable IK for this state", null, MemberHelper.GetMember(() => ikSettingsEnabled));
            belowReachableDistance = AddSlider("Reachable distance below character", 0f, 0f, 2f, null);           
            aboveReachableDistance = AddSlider("Reachable distance above character", 0f, 0f, 2f, null);
            verticalChangeUpGain = AddSlider("Shift Up Gain", 0.1f, 0f, 1f, null);
            verticalChangeDownGain = AddSlider("Sift Down Gain", 0.1f, 0f, 1f, null);
            ankleHeight = AddSlider("Ankle height", 0.1f, 0.001f, 0.3f, null);
            footWidth = AddSlider("Foot width", 0.1f, 0.001f, 0.3f, null);
            footLength = AddSlider("Foot length", 0.3f, 0.001f, 0.2f, null);
            RegisterEvents();
        }       
        public void BuildControls()
        {
            MyGuiControlParent parent = new MyGuiControlParent(size: new Vector2(Size.Value.X - 0.05f, Size.Value.Y-0.1f));
            MyGuiControlScrollablePanel scrollPanel = new MyGuiControlScrollablePanel(parent);
            scrollPanel.ScrollbarVEnabled = true;
            scrollPanel.Size = new Vector2(Size.Value.X - 0.05f, 0.8f);
            Controls.Add(scrollPanel);

            Vector2 buttonSize = MyGuiConstants.BACK_BUTTON_SIZE;
            Vector2 buttonsOrigin = m_size.Value / 2 - new Vector2(0.23f, 0.03f);

            //AddCaption(MySpaceTexts.ScreenCaptionAdvancedSettings);
            // Ok/Cancel
            m_okButton = new MyGuiControlButton(position: buttonsOrigin - new Vector2(0.01f, 0f), size: buttonSize, text: MyTexts.Get(MyCommonTexts.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(MyCommonTexts.Cancel), onButtonClick: CancelButtonClicked, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM);
            Controls.Add(m_okButton);
            Controls.Add(m_cancelButton);

            float buttonsOffset = 0.055f;

            var canJoinrunningLabel = MakeLabel(MySpaceTexts.ScenarioSettings_CanJoinRunning);
            m_canJoinRunning = new MyGuiControlCheckbox();
            m_canJoinRunning.Position = new Vector2(-scrollPanel.Size.X / 2 + buttonsOffset, -scrollPanel.Size.Y / 2 + buttonsOffset);
            canJoinrunningLabel.Position = new Vector2(m_canJoinRunning.Position.X + buttonsOffset, m_canJoinRunning.Position.Y);
            m_canJoinRunning.IsChecked = MySession.Static.Settings.CanJoinRunning;
            parent.Controls.Add(m_canJoinRunning);
            parent.Controls.Add(canJoinrunningLabel);

            CloseButtonEnabled = true;
        }
        public override void RecreateControls(bool constructor)
        {
            base.RecreateControls(constructor);

            m_currentPosition = -m_size.Value / 2.0f + new Vector2(0.02f, 0.10f);
            m_currentPosition.Y += 0.01f;
            m_scale = 0.7f;

            AddCaption("Render Overrides", Color.Yellow.ToVector4());
            AddShareFocusHint();

            m_currentPosition.Y += 0.01f;
            AddLabel("Lighting Pass", Color.Yellow.ToVector4(), 1.2f);
            m_lighting = AddCheckBox("Enabled", MyRenderProxy.DebugOverrides, MemberHelper.GetMember(() => MyRenderProxy.DebugOverrides.Lighting));
            m_sun = AddCheckBox("Sun", MyRenderProxy.DebugOverrides, MemberHelper.GetMember(() => MyRenderProxy.DebugOverrides.Sun));
            m_additionalSuns = AddCheckBox("Additional Suns", MyRenderProxy.DebugOverrides, MemberHelper.GetMember(() => MyRenderProxy.DebugOverrides.AdditionalSuns));
            m_pointLights = AddCheckBox("Point lights", MyRenderProxy.DebugOverrides, MemberHelper.GetMember(() => MyRenderProxy.DebugOverrides.PointLights));
            m_spotLights = AddCheckBox("Spot lights", MyRenderProxy.DebugOverrides, MemberHelper.GetMember(() => MyRenderProxy.DebugOverrides.SpotLights));
            m_envLight = AddCheckBox("Env light", MyRenderProxy.DebugOverrides, MemberHelper.GetMember(() => MyRenderProxy.DebugOverrides.EnvLight));
            m_currentPosition.Y += 0.01f;
            AddCheckBox("Shadows", MyRenderProxy.DebugOverrides, MemberHelper.GetMember(() => MyRenderProxy.DebugOverrides.Shadows));
            AddCheckBox("Fog", MyRenderProxy.DebugOverrides, MemberHelper.GetMember(() => MyRenderProxy.DebugOverrides.Fog));
            AddCheckBox("Flares", MyRenderProxy.DebugOverrides, MemberHelper.GetMember(() => MyRenderProxy.DebugOverrides.Flares));

            m_currentPosition.Y += 0.01f;
            AddLabel("Transparent Pass", Color.Yellow.ToVector4(), 1.2f);
            m_transparent = AddCheckBox("Enabled", MyRenderProxy.DebugOverrides, MemberHelper.GetMember(() => MyRenderProxy.DebugOverrides.Transparent));
            m_oit = AddCheckBox("Order independent", MyRenderProxy.DebugOverrides, MemberHelper.GetMember(() => MyRenderProxy.DebugOverrides.OIT));
            m_billboardsDynamic = AddCheckBox("Billboards dynamic", MyRenderProxy.DebugOverrides, MemberHelper.GetMember(() => MyRenderProxy.DebugOverrides.BillboardsDynamic));
            m_billboardsStatic = AddCheckBox("Billboards static", MyRenderProxy.DebugOverrides, MemberHelper.GetMember(() => MyRenderProxy.DebugOverrides.BillboardsStatic));
            m_gpuParticles = AddCheckBox("GPU Particles", MyRenderProxy.DebugOverrides, MemberHelper.GetMember(() => MyRenderProxy.DebugOverrides.GPUParticles));
            m_cloud = AddCheckBox("Cloud", MyRenderProxy.DebugOverrides, MemberHelper.GetMember(() => MyRenderProxy.DebugOverrides.Clouds));
            m_atmosphere = AddCheckBox("Atmosphere", MyRenderProxy.DebugOverrides, MemberHelper.GetMember(() => MyRenderProxy.DebugOverrides.Atmosphere));

            m_currentPosition.Y += 0.01f;
            AddLabel("Postprocessing", Color.Yellow.ToVector4(), 1.2f);
            m_postprocess = AddCheckBox("Enabled", MyRenderProxy.DebugOverrides, MemberHelper.GetMember(() => MyRenderProxy.DebugOverrides.Postprocessing));
            m_ssao = AddCheckBox("SSAO", MyRenderProxy.DebugOverrides, MemberHelper.GetMember(() => MyRenderProxy.DebugOverrides.SSAO));
            m_bloom = AddCheckBox("Bloom", MyRenderProxy.DebugOverrides, MemberHelper.GetMember(() => MyRenderProxy.DebugOverrides.Bloom));
            m_fxaa = AddCheckBox("Fxaa", MyRenderProxy.DebugOverrides, MemberHelper.GetMember(() => MyRenderProxy.DebugOverrides.Fxaa));
            m_tonemapping = AddCheckBox("Tonemapping", MyRenderProxy.DebugOverrides, MemberHelper.GetMember(() => MyRenderProxy.DebugOverrides.Tonemapping));

            m_currentPosition.Y += 0.01f;
            //m_pause = AddCheckBox("Enabled", MyRenderProxy.DebugOverrides, MemberHelper.GetMember(() => MyRenderProxy.DebugOverrides.Postprocessing));
        }
        public override void RecreateControls(bool constructor)
        {
            base.RecreateControls(constructor);

            base.m_position = new Vector2(MyGuiManager.GetMaxMouseCoord().X - 0.25f, 0.5f);

            var layout = new MyLayoutVertical(this, 35f);

            layout.Advance(20);

            {
                layout.Add(new MyGuiControlLabel(text: MyTexts.GetString(MyCommonTexts.BotSettingsScreen_Title)), MyAlignH.Center);
            }

            layout.Advance(30);

            {
                var enableDebuggingCheckBox = new MyGuiControlCheckbox(isChecked: MyDebugDrawSettings.DEBUG_DRAW_BOTS);
                enableDebuggingCheckBox.IsCheckedChanged += enableDebuggingCheckBox_IsCheckedChanged;
                layout.Add(new MyGuiControlLabel(text: MyTexts.GetString(MyCommonTexts.BotSettingsScreen_EnableBotsDebugging)), MyAlignH.Left, advance: false);
                layout.Add(enableDebuggingCheckBox, MyAlignH.Right);
            }

            layout.Advance(15);

            {
                MyGuiControlButton nextButton = new MyGuiControlButton(
                    text: MyTexts.Get(MyCommonTexts.BotSettingsScreen_NextBot),
                    onButtonClick: nextButton_OnButtonClick);
                MyGuiControlButton previousButton = new MyGuiControlButton(
                    text: MyTexts.Get(MyCommonTexts.BotSettingsScreen_PreviousBot),
                    onButtonClick: previousButton_OnButtonClick);
                layout.Add(nextButton, previousButton);
            }

            layout.Advance(30);

            {
                layout.Add(new MyGuiControlButton(text: MyTexts.Get(MyCommonTexts.Close), onButtonClick: OnCloseClicked), MyAlignH.Center);
            }
        }
        // mk:TODO Modify MyGuiControlList to allow different alignments and remove scale from this control.
        public MyGuiControlOnOffSwitch(
            bool initialValue = false,
            String onText = null,
            String offText = null)
        : base(canHaveFocus: true)
        {
            m_onButton = new MyGuiControlCheckbox(
                visualStyle: MyGuiControlCheckboxStyleEnum.SwitchOnOffLeft,
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER);

            m_offButton = new MyGuiControlCheckbox(
                visualStyle: MyGuiControlCheckboxStyleEnum.SwitchOnOffRight,
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);

            m_onLabel = new MyGuiControlLabel(
                position: new Vector2(m_onButton.Size.X * -0.5f, 0.0f),
                text: onText ?? MyTexts.GetString(MySpaceTexts.SwitchText_On),
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);

            m_offLabel = new MyGuiControlLabel(
                position: new Vector2(m_onButton.Size.X * 0.5f, 0.0f),
                text: offText ?? MyTexts.GetString(MySpaceTexts.SwitchText_Off),
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);

            // Set the size to contain the 2 buttons and space between them.
            // Buttons should not overlap, otherwise this will give us wrong results.
            Size = new Vector2(m_onButton.Size.X + m_offButton.Size.X, Math.Max(m_onButton.Size.Y, m_offButton.Size.Y));

            Elements.Add(m_onButton);
            Elements.Add(m_offButton);
            Elements.Add(m_onLabel);
            Elements.Add(m_offLabel);

            m_value = initialValue;
            UpdateButtonState();
        }
        private void AddGeneralControls()
        {
            m_allControls[MyGuiControlTypeEnum.General] = new List<MyGuiControlBase>();


            MyGuiControlLabel tmp = MakeLabel(2f, MyCommonTexts.InvertMouseX);
            m_allControls[MyGuiControlTypeEnum.General].Add(MakeLabel(2f, MyCommonTexts.InvertMouseX));
            m_allControls[MyGuiControlTypeEnum.General].Add(MakeLabel(3f, MyCommonTexts.InvertMouseY));
            m_allControls[MyGuiControlTypeEnum.General].Add(MakeLabel(4f, MyCommonTexts.MouseSensitivity));

            m_invertMouseXCheckbox = new MyGuiControlCheckbox(
                     position: m_controlsOriginRight + 2 * MyGuiConstants.CONTROLS_DELTA,
                     isChecked: MyInput.Static.GetMouseXInversion(),
                     originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);

            m_allControls[MyGuiControlTypeEnum.General].Add(m_invertMouseXCheckbox);


            m_invertMouseYCheckbox = new MyGuiControlCheckbox(
                 position: m_controlsOriginRight + 3 * MyGuiConstants.CONTROLS_DELTA,
                 isChecked: MyInput.Static.GetMouseYInversion(),
                 originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);

            m_allControls[MyGuiControlTypeEnum.General].Add(m_invertMouseYCheckbox);

            m_mouseSensitivitySlider = new MyGuiControlSlider(
                position: m_controlsOriginRight + 4 * MyGuiConstants.CONTROLS_DELTA,
                minValue: 0.0f,
                maxValue: 3.0f,
                defaultValue: MyInput.Static.GetMouseSensitivity(),
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);
            m_allControls[MyGuiControlTypeEnum.General].Add(m_mouseSensitivitySlider);

            if (MyFakes.ENABLE_JOYSTICK_SETTINGS)
            {
                const float multiplierJoystick = 6.5f;
                const float multiplierSensitivity = 8;
                const float multiplierExponent = 9;
                const float multiplierDeadzone = 10;

                m_allControls[MyGuiControlTypeEnum.General].Add(MakeLabel(multiplierJoystick, MyCommonTexts.Joystick));
                m_allControls[MyGuiControlTypeEnum.General].Add(MakeLabel(multiplierSensitivity, MyCommonTexts.JoystickSensitivity));
                m_allControls[MyGuiControlTypeEnum.General].Add(MakeLabel(multiplierExponent, MyCommonTexts.JoystickExponent));
                m_allControls[MyGuiControlTypeEnum.General].Add(MakeLabel(multiplierDeadzone, MyCommonTexts.JoystickDeadzone));

                m_joystickCombobox = new MyGuiControlCombobox(m_controlsOriginRight + multiplierJoystick * MyGuiConstants.CONTROLS_DELTA + new Vector2(MyGuiConstants.COMBOBOX_MEDIUM_SIZE.X / 2.0f, 0));
                m_joystickCombobox.ItemSelected += OnSelectJoystick;
                AddJoysticksToComboBox();
                m_joystickCombobox.Enabled = !MyFakes.ENFORCE_CONTROLLER || !MyInput.Static.IsJoystickConnected();
                m_allControls[MyGuiControlTypeEnum.General].Add(m_joystickCombobox);

                m_joystickSensitivitySlider = new MyGuiControlSlider(
                    position: m_controlsOriginRight + multiplierSensitivity * MyGuiConstants.CONTROLS_DELTA + new Vector2(MyGuiConstants.COMBOBOX_MEDIUM_SIZE.X / 2.0f, 0),
                    minValue: 0.1f,
                    maxValue: 6.0f);
                m_joystickSensitivitySlider.Value = MyInput.Static.GetJoystickSensitivity();
                m_allControls[MyGuiControlTypeEnum.General].Add(m_joystickSensitivitySlider);

                m_joystickExponentSlider = new MyGuiControlSlider(
                    position: m_controlsOriginRight + multiplierExponent * MyGuiConstants.CONTROLS_DELTA + new Vector2(MyGuiConstants.COMBOBOX_MEDIUM_SIZE.X / 2.0f, 0),
                    minValue: 1.0f,
                    maxValue: 8.0f);
                m_joystickExponentSlider.Value = MyInput.Static.GetJoystickExponent();
                m_allControls[MyGuiControlTypeEnum.General].Add(m_joystickExponentSlider);

                m_joystickDeadzoneSlider = new MyGuiControlSlider(
                    position: m_controlsOriginRight + multiplierDeadzone * MyGuiConstants.CONTROLS_DELTA + new Vector2(MyGuiConstants.COMBOBOX_MEDIUM_SIZE.X / 2.0f, 0),
                    minValue: 0.0f,
                    maxValue: 0.5f);
                m_joystickDeadzoneSlider.Value = MyInput.Static.GetJoystickDeadzone();
                m_allControls[MyGuiControlTypeEnum.General].Add(m_joystickDeadzoneSlider);
            }

        }
        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;
        }
 private MyGuiControlCheckbox MakeCheckbox(Vector2 position, MyStringId tooltip)
 {
     var checkbox = new MyGuiControlCheckbox(position: position, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER, toolTip: MyTexts.GetString(tooltip));
     checkbox.IsCheckedChanged += OnCheckboxChanged;
     return checkbox;
 }
 void SoloChanged(MyGuiControlCheckbox checkbox)
 {
     if (m_canUpdateValues)
     {
         if (checkbox.IsChecked)
             MyAudio.Static.SoloCue = m_currentCue;
         else
             MyAudio.Static.SoloCue = null;
     }
 }
        private void HideEmptyRight_Checked(MyGuiControlCheckbox obj)
        {
            if (m_rightFilterType == MyInventoryOwnerTypeEnum.Character)
                return;

            SearchInList(m_blockSearchRight, m_rightOwnersControl, obj.IsChecked);
        }
 void pivotBtn_IsCheckedChanged(MyGuiControlCheckbox obj)
 {
     MyCubeGrid.ShowGridPivot = obj.IsChecked;
 }
 void centerBtn_IsCheckedChanged(MyGuiControlCheckbox obj)
 {
     MyCubeGrid.ShowCenterOfMass = obj.IsChecked;
 }
 void showGravityGizmos_IsCheckedChanged(MyGuiControlCheckbox obj)
 {
     MyCubeGrid.ShowGravityGizmos = obj.IsChecked;
 }
 void showAntenaGizmos_IsCheckedChanged(MyGuiControlCheckbox obj)
 {
     MyCubeGrid.ShowAntennaGizmos = obj.IsChecked;
 }
        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 void Close()
        {
            foreach (var system in m_registeredConveyorSystems)
            {
                system.BlockAdded -= ConveyorSystem_BlockAdded;
                system.BlockRemoved -= ConveyorSystem_BlockRemoved;
            }
            m_registeredConveyorSystems.Clear();
            
            m_leftTypeGroup.Clear();
            m_leftFilterGroup.Clear();
            m_rightTypeGroup.Clear();
            m_rightFilterGroup.Clear();
            m_controlsDisabledWhileDragged.Clear();

            m_leftOwnersControl = null;
            m_leftSuitButton = null;
            m_leftGridButton = null;
            m_leftFilterStorageButton = null;
            m_leftFilterSystemButton = null;
            m_leftFilterEnergyButton = null;
            m_leftFilterAllButton = null;
            m_rightOwnersControl = null;
            m_rightSuitButton = null;
            m_rightGridButton = null;
            m_rightFilterStorageButton = null;
            m_rightFilterSystemButton = null;
            m_rightFilterEnergyButton = null;
            m_rightFilterAllButton = null;
            m_throwOutButton = null;
            m_dragAndDrop = null;
            m_dragAndDropInfo = null;
            m_focusedOwnerControl = null;
            m_focusedGridControl = null;
            m_selectedInventory = null;

            m_hideEmptyLeft.IsCheckedChanged      -= HideEmptyLeft_Checked;
            m_hideEmptyRight.IsCheckedChanged     -= HideEmptyRight_Checked;
            m_blockSearchLeft.TextChanged         -= BlockSearchLeft_TextChanged;
            m_blockSearchClearLeft.ButtonClicked  -= BlockSearchClearLeft_ButtonClicked;
            m_blockSearchRight.TextChanged        -= BlockSearchRight_TextChanged;
            m_blockSearchClearRight.ButtonClicked -= BlockSearchClearRight_ButtonClicked;

            m_hideEmptyLeft         = null;
            m_hideEmptyLeftLabel    = null;
            m_hideEmptyRight        = null;
            m_hideEmptyRightLabel   = null;
            m_blockSearchLeft       = null;
            m_blockSearchClearLeft  = null;
            m_blockSearchRight      = null;
            m_blockSearchClearRight = null;
        }
        private void ApplyTypeGroupSelectionChange(
            MyGuiControlRadioButtonGroup obj,
            ref bool showsGrid,
            MyGuiControlList targetControlList,
            MyInventoryOwnerTypeEnum? filterType,
            MyGuiControlRadioButtonGroup filterButtonGroup,
            MyGuiControlCheckbox showEmpty,
            MyGuiControlLabel    showEmptyLabel,
            MyGuiControlTextbox blockSearch,
            MyGuiControlButton  blockSearchClear,
            bool isLeftControllist)
        {
            switch (obj.SelectedButton.VisualStyle)
            {
                case MyGuiControlRadioButtonStyleEnum.FilterCharacter:
                    showsGrid = false;

                    showEmpty.Visible        = false;
                    showEmptyLabel.Visible   = false;
                    blockSearch.Visible      = false;
                    blockSearchClear.Visible = false;

                    targetControlList.Position = (isLeftControllist) ? m_leftControlListPosition : m_rightControlListPosition;
                    targetControlList.Size     = m_controlListFullSize;

                    // hack to allow looting, force user on left and interacted corpse on right
                    if (targetControlList == m_leftOwnersControl)
                        CreateInventoryControlInList(m_userAsOwner, targetControlList);
                    else
                        CreateInventoryControlInList(m_interactedAsOwner, targetControlList);
                    break;

                case MyGuiControlRadioButtonStyleEnum.FilterGrid:
                    showsGrid = true;
                    CreateInventoryControlsInList(m_interactedGridOwners, targetControlList, filterType);

                    showEmpty.Visible        = true;
                    showEmptyLabel.Visible   = true;
                    blockSearch.Visible      = true;
                    blockSearchClear.Visible = true;

                    blockSearch.Text = blockSearch.Text;

                    targetControlList.Position = (isLeftControllist) ? m_leftControlListPosWithSearch : m_rightControlListPosWithSearch;
                    targetControlList.Size     = m_controlListSizeWithSearch;
                    break;

                default:
                    Debug.Assert(false, "Invalid branch!");
                    break;
            }
            foreach (var button in filterButtonGroup)
                button.Visible = button.Enabled = showsGrid;

            RefreshSelectedInventoryItem();

            //GR: Do this to return the scrolbar position to zero. Other solution would be to add it to Scrollbar Init but that would cause other bugs so I commented it out for now
            targetControlList.SetScrollBarPage();
        }
 void setDestructibleBlocksBtn_IsCheckedChanged(MyGuiControlCheckbox obj)
 {
     m_grid.SyncObject.SetDestructibleBlocks(obj.IsChecked);
 }
 private void OnServerCheckboxCheckChanged(MyGuiControlCheckbox checkbox)
 {
     RefreshServerGameList();
 }
 private void OnHistoryCheckboxCheckChanged(MyGuiControlCheckbox checkbox)
 {
     RefreshHistoryGameList();
 }
 private void enableDebuggingCheckBox_IsCheckedChanged(MyGuiControlCheckbox checkBox)
 {
     MyDebugDrawSettings.DEBUG_DRAW_BOTS = checkBox.IsChecked;
 }
        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;
        }
        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 void Init(IMyGuiControlsParent controlsParent, MyCubeGrid grid)
        {
            if (grid == null)
            {
                ShowError(MySpaceTexts.ScreenTerminalError_ShipNotConnected, controlsParent);
                return;
            }

            grid.RaiseGridChanged();
            m_assemblerKeyCounter = 0;
            m_assemblersByKey.Clear();
            foreach (var block in grid.GridSystems.TerminalSystem.Blocks)
            {
                var assembler = block as MyAssembler;
                if (assembler == null) continue;
                if (!assembler.HasLocalPlayerAccess()) continue;

                m_assemblersByKey.Add(m_assemblerKeyCounter++, assembler);
            }

            m_controlsParent = controlsParent;
            m_terminalSystem = grid.GridSystems.TerminalSystem;

            m_blueprintsArea = (MyGuiControlScrollablePanel)controlsParent.Controls.GetControlByName("BlueprintsScrollableArea");
            m_queueArea = (MyGuiControlScrollablePanel)controlsParent.Controls.GetControlByName("QueueScrollableArea");
            m_inventoryArea = (MyGuiControlScrollablePanel)controlsParent.Controls.GetControlByName("InventoryScrollableArea");
            m_blueprintsBgPanel = controlsParent.Controls.GetControlByName("BlueprintsBackgroundPanel");
            m_blueprintsLabel = controlsParent.Controls.GetControlByName("BlueprintsLabel");
            m_comboboxAssemblers = (MyGuiControlCombobox)controlsParent.Controls.GetControlByName("AssemblersCombobox");
            m_blueprintsGrid = (MyGuiControlGrid)m_blueprintsArea.ScrolledControl;
            m_queueGrid = (MyGuiControlGrid)m_queueArea.ScrolledControl;
            m_inventoryGrid = (MyGuiControlGrid)m_inventoryArea.ScrolledControl;
            m_materialsList = (MyGuiControlComponentList)controlsParent.Controls.GetControlByName("MaterialsList");
            m_repeatCheckbox = (MyGuiControlCheckbox)controlsParent.Controls.GetControlByName("RepeatCheckbox");
            m_slaveCheckbox = (MyGuiControlCheckbox)controlsParent.Controls.GetControlByName("SlaveCheckbox");
            m_disassembleAllButton = (MyGuiControlButton)controlsParent.Controls.GetControlByName("DisassembleAllButton");
            m_controlPanelButton = (MyGuiControlButton)controlsParent.Controls.GetControlByName("ControlPanelButton");
            m_inventoryButton = (MyGuiControlButton)controlsParent.Controls.GetControlByName("InventoryButton");

            {
                var assemblingButton = (MyGuiControlRadioButton)controlsParent.Controls.GetControlByName("AssemblingButton");
                var disassemblingButton = (MyGuiControlRadioButton)controlsParent.Controls.GetControlByName("DisassemblingButton");
                assemblingButton.Key = (int)AssemblerMode.Assembling;
                disassemblingButton.Key = (int)AssemblerMode.Disassembling;
                m_modeButtonGroup.Add(assemblingButton);
                m_modeButtonGroup.Add(disassemblingButton);
            }

            foreach (var entry in m_assemblersByKey)
            {
                if (entry.Value.IsFunctional == false)
                {
                    m_incompleteAssemblerName.Clear();
                    m_incompleteAssemblerName.AppendStringBuilder(entry.Value.CustomName);
                    m_incompleteAssemblerName.AppendStringBuilder(MyTexts.Get(MySpaceTexts.Terminal_BlockIncomplete));
                    m_comboboxAssemblers.AddItem(entry.Key, m_incompleteAssemblerName);
                }
                else
                {
                    m_comboboxAssemblers.AddItem(entry.Key, entry.Value.CustomName);
                }
            }
            m_comboboxAssemblers.ItemSelected += Assemblers_ItemSelected;

            m_comboboxAssemblers.SelectItemByIndex(0);

            m_dragAndDrop = new MyGuiControlGridDragAndDrop(MyGuiConstants.DRAG_AND_DROP_BACKGROUND_COLOR,
                                                            MyGuiConstants.DRAG_AND_DROP_TEXT_COLOR,
                                                            0.7f,
                                                            MyGuiConstants.DRAG_AND_DROP_TEXT_OFFSET, true);
            controlsParent.Controls.Add(m_dragAndDrop);
            m_dragAndDrop.DrawBackgroundTexture = false;
            m_dragAndDrop.ItemDropped += dragDrop_OnItemDropped;

            RefreshBlueprints();
            Assemblers_ItemSelected();

            RegisterEvents();

            if (m_assemblersByKey.Count == 0)
                ShowError(MySpaceTexts.ScreenTerminalError_NoAssemblers, controlsParent);
        }
        private static void OnCheckboxChanged(MyGuiControlCheckbox obj)
        {
            if (obj == null)
                return;

            if (obj.IsChecked)
            {
                if (Static.GetSelectedTagsLength() >= TAGS_MAX_LENGTH)
                {
                    obj.IsChecked = false;
                }
            }
        }
 void repeatCheckbox_IsCheckedChanged(MyGuiControlCheckbox control)
 {
     Debug.Assert(control == m_repeatCheckbox);
     RefreshRepeatMode(control.IsChecked);
     RefreshAssemblerModeView();
 }
        public override void RecreateControls(bool constructor)
        {
            if (!constructor)
                return;

            base.RecreateControls(constructor);

            AddCaption(MySpaceTexts.ScreenCaptionVideoOptions);

            Vector2 controlsOriginLeft = new Vector2(-m_size.Value.X / 2.0f + 0.05f, -m_size.Value.Y / 2.0f + 0.145f) + new Vector2(0.02f, 0f);
            Vector2 controlsOriginRight = new Vector2(-m_size.Value.X / 2.0f + 0.225f, -m_size.Value.Y / 2.0f + 0.145f) + new Vector2(0.043f, 0f);

            const float TEXT_SCALE = MyGuiConstants.DEFAULT_TEXT_SCALE * 0.85f;

            var labelVideoAdapter        = new MyGuiControlLabel(textScale: TEXT_SCALE, text: MyTexts.GetString(MySpaceTexts.VideoAdapter));
            var labelVideoMode           = 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));
            var labelHwCursor            = new MyGuiControlLabel(textScale: TEXT_SCALE, text: MyTexts.GetString(MySpaceTexts.HardwareCursor));
            var labelRenderQuality       = new MyGuiControlLabel(textScale: TEXT_SCALE, text: MyTexts.GetString(MySpaceTexts.RenderQuality));
            var labelFoV                 = new MyGuiControlLabel(textScale: TEXT_SCALE, text: MyTexts.GetString(MySpaceTexts.FieldOfView));
            m_fieldOfViewDefaultLabel    = new MyGuiControlLabel(textScale: TEXT_SCALE, text: MyTexts.GetString(MySpaceTexts.DefaultFOV));
            var labelRenderInterpolation = new MyGuiControlLabel(textScale: TEXT_SCALE, text: MyTexts.GetString(MySpaceTexts.RenderIterpolation));
            var labelEnableDamageEffects = new MyGuiControlLabel(textScale: TEXT_SCALE, text: MyTexts.GetString(MySpaceTexts.EnableDamageEffects));

            m_videoAdapterCombobox   = new MyGuiControlCombobox(toolTip: MyTexts.GetString(MySpaceTexts.ToolTipVideoOptionsVideoAdapter));
            m_resolutionCombobox     = new MyGuiControlCombobox(toolTip: MyTexts.GetString(MySpaceTexts.ToolTipVideoOptionsVideoMode));
            m_windowModeCombobox     = new MyGuiControlCombobox();
            m_verticalSyncCheckbox   = new MyGuiControlCheckbox(toolTip: MyTexts.GetString(MySpaceTexts.ToolTipVideoOptionsVerticalSync));
            m_hardwareCursorCheckbox = new MyGuiControlCheckbox(toolTip: MyTexts.GetString(MySpaceTexts.ToolTipVideoOptionsHardwareCursor));
            m_enableDamageEffectsCheckbox = new MyGuiControlCheckbox(toolTip: MyTexts.GetString(MySpaceTexts.ToolTipVideoOptionsEnableDamageEffects));

            m_renderQualityCombobox  = new MyGuiControlCombobox(toolTip: MyTexts.GetString(MySpaceTexts.ToolTipVideoOptionsRenderQuality));
            m_fieldOfViewSlider      = new MyGuiControlSlider(toolTip: MyTexts.GetString(MySpaceTexts.ToolTipVideoOptionsFieldOfView),
                labelText: new StringBuilder("{0}").ToString(),
                labelSpaceWidth: 0.035f,
                labelScale: TEXT_SCALE,
                labelFont: MyFontEnum.Blue,
                minValue: MathHelper.ToDegrees(MyConstants.FIELD_OF_VIEW_CONFIG_MIN),
                maxValue: MathHelper.ToDegrees(MyConstants.FIELD_OF_VIEW_CONFIG_MAX),
                defaultValue: MathHelper.ToDegrees(MyConstants.FIELD_OF_VIEW_CONFIG_DEFAULT));

            m_renderInterpolationCheckbox = new MyGuiControlCheckbox(toolTip: MyTexts.GetString(MySpaceTexts.ToolTipVideoOptionRenderIterpolation));

            m_unsupportedAspectRatioLabel = new MyGuiControlLabel(colorMask: MyGuiConstants.LABEL_TEXT_COLOR * 0.9f, textScale: TEXT_SCALE * 0.85f);
            m_recommendAspectRatioLabel = new MyGuiControlLabel(colorMask: MyGuiConstants.LABEL_TEXT_COLOR * 0.9f, textScale: TEXT_SCALE * 0.85f);


            var hintLineOffset = new Vector2(0f, m_unsupportedAspectRatioLabel.Size.Y);
            var hintOffset = new Vector2(0.01f, -0.35f * MyGuiConstants.CONTROLS_DELTA.Y);

            labelVideoAdapter.Position      = controlsOriginLeft; controlsOriginLeft += MyGuiConstants.CONTROLS_DELTA;
            m_videoAdapterCombobox.Position = controlsOriginRight; controlsOriginRight += MyGuiConstants.CONTROLS_DELTA;

            labelVideoMode.Position                = controlsOriginLeft; controlsOriginLeft += MyGuiConstants.CONTROLS_DELTA;
            m_resolutionCombobox.Position          = controlsOriginRight; controlsOriginRight += MyGuiConstants.CONTROLS_DELTA;
            m_unsupportedAspectRatioLabel.Position = controlsOriginRight + hintOffset;
            m_recommendAspectRatioLabel.Position   = controlsOriginRight + hintOffset + hintLineOffset;
            controlsOriginLeft                    += MyGuiConstants.CONTROLS_DELTA;
            controlsOriginRight                   += MyGuiConstants.CONTROLS_DELTA;

            labelWindowMode.Position               = controlsOriginLeft; controlsOriginLeft += MyGuiConstants.CONTROLS_DELTA;
            m_windowModeCombobox.Position          = controlsOriginRight; controlsOriginRight += MyGuiConstants.CONTROLS_DELTA;
            labelVSync.Position                    = controlsOriginLeft; controlsOriginLeft += MyGuiConstants.CONTROLS_DELTA;
            m_verticalSyncCheckbox.Position        = controlsOriginRight; controlsOriginRight += MyGuiConstants.CONTROLS_DELTA;
            labelHwCursor.Position                 = controlsOriginLeft; controlsOriginLeft += MyGuiConstants.CONTROLS_DELTA;
            m_hardwareCursorCheckbox.Position      = controlsOriginRight; controlsOriginRight += MyGuiConstants.CONTROLS_DELTA;
            labelRenderQuality.Position            = controlsOriginLeft; controlsOriginLeft += MyGuiConstants.CONTROLS_DELTA;
            m_renderQualityCombobox.Position       = controlsOriginRight; controlsOriginRight += MyGuiConstants.CONTROLS_DELTA;
            labelRenderInterpolation.Position      = controlsOriginLeft; controlsOriginLeft += MyGuiConstants.CONTROLS_DELTA;
            m_renderInterpolationCheckbox.Position = controlsOriginRight; controlsOriginRight += MyGuiConstants.CONTROLS_DELTA;
            labelEnableDamageEffects.Position      = controlsOriginLeft; controlsOriginLeft += MyGuiConstants.CONTROLS_DELTA;
            m_enableDamageEffectsCheckbox.Position = controlsOriginRight; controlsOriginRight += MyGuiConstants.CONTROLS_DELTA;

            labelFoV.Position                  = controlsOriginLeft; controlsOriginLeft += MyGuiConstants.CONTROLS_DELTA;
            m_fieldOfViewSlider.Position       = controlsOriginRight; controlsOriginRight += MyGuiConstants.CONTROLS_DELTA;
            m_fieldOfViewDefaultLabel.Position = controlsOriginRight + hintOffset;

            Controls.Add(labelVideoAdapter); Controls.Add(m_videoAdapterCombobox);
            Controls.Add(labelVideoMode); Controls.Add(m_resolutionCombobox);
            Controls.Add(m_unsupportedAspectRatioLabel);
            Controls.Add(m_recommendAspectRatioLabel);
            Controls.Add(labelWindowMode); Controls.Add(m_windowModeCombobox);
            Controls.Add(labelVSync); Controls.Add(m_verticalSyncCheckbox);
            Controls.Add(labelHwCursor); Controls.Add(m_hardwareCursorCheckbox);
            Controls.Add(labelRenderQuality); Controls.Add(m_renderQualityCombobox);
            Controls.Add(labelRenderInterpolation); Controls.Add(m_renderInterpolationCheckbox);
            Controls.Add(labelEnableDamageEffects); Controls.Add(m_enableDamageEffectsCheckbox);

            Controls.Add(labelFoV); Controls.Add(m_fieldOfViewSlider);
            Controls.Add(m_fieldOfViewDefaultLabel);

            foreach (var control in Controls)
                control.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER;

            m_unsupportedAspectRatioLabel.Text = string.Format("* {0}", MyTexts.Get(MySpaceTexts.UnsupportedAspectRatio));
            AddAdaptersToComboBox();
            AddRenderQualitiesToComboBox();
            AddWindowModesToComboBox();
            m_fieldOfViewDefaultLabel.UpdateFormatParams(MathHelper.ToDegrees(MyConstants.FIELD_OF_VIEW_CONFIG_DEFAULT));

            m_videoAdapterCombobox.ItemSelected += OnVideoAdapterSelected;
            m_resolutionCombobox.ItemSelected += OnResolutionSelected;
            m_windowModeCombobox.ItemSelected += OnWindowModeSelected;

            //  Buttons APPLY and BACK
            Controls.Add(new MyGuiControlButton(
                position: new Vector2(-0.05f, 0.31f),
                size: MyGuiConstants.OK_BUTTON_SIZE,
                text: MyTexts.Get(MySpaceTexts.Ok),
                onButtonClick: OnOkClick,
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER));

            Controls.Add(new MyGuiControlButton(
                position: new Vector2(0.05f, 0.31f),
                size: MyGuiConstants.OK_BUTTON_SIZE,
                text: MyTexts.Get(MySpaceTexts.Cancel),
                onButtonClick: OnCancelClick,
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER));

            //  Update controls with values from config file
            m_deviceSettingsOld = MyVideoSettingsManager.CurrentDeviceSettings;
            m_graphicsSettingsOld = MyVideoSettingsManager.CurrentGraphicsSettings;
            m_deviceSettingsNew = m_deviceSettingsOld;
            m_graphicsSettingsNew = m_graphicsSettingsOld;
            WriteSettingsToControls(m_deviceSettingsOld, m_graphicsSettingsOld);

            //  Update OLD settings
            ReadSettingsFromControls(ref m_deviceSettingsOld, ref m_graphicsSettingsOld);
            ReadSettingsFromControls(ref m_deviceSettingsNew, ref m_graphicsSettingsNew);

            CloseButtonEnabled = true;
        }
 void slaveCheckbox_IsCheckedChanged(MyGuiControlCheckbox control)
 {
     Debug.Assert(control == m_slaveCheckbox);
     RefreshSlaveMode(control.IsChecked);
     RefreshAssemblerModeView();
 }
            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);

            }
        public void Init(IMyGuiControlsParent controlsParent, MyEntity thisEntity, MyEntity interactedEntity, MyGridColorHelper colorHelper)
        {
            ProfilerShort.Begin("MyGuiScreenTerminal.ControllerInventory.Init");
            m_userAsEntity = thisEntity;
            m_interactedAsEntity = interactedEntity;
            m_colorHelper = colorHelper;

            m_leftOwnersControl = (MyGuiControlList)controlsParent.Controls.GetControlByName("LeftInventory");
            m_rightOwnersControl = (MyGuiControlList)controlsParent.Controls.GetControlByName("RightInventory");

            m_leftSuitButton = (MyGuiControlRadioButton)controlsParent.Controls.GetControlByName("LeftSuitButton");
            m_leftGridButton = (MyGuiControlRadioButton)controlsParent.Controls.GetControlByName("LeftGridButton");
            m_leftFilterStorageButton = (MyGuiControlRadioButton)controlsParent.Controls.GetControlByName("LeftFilterStorageButton");
            m_leftFilterSystemButton = (MyGuiControlRadioButton)controlsParent.Controls.GetControlByName("LeftFilterSystemButton");
            m_leftFilterEnergyButton = (MyGuiControlRadioButton)controlsParent.Controls.GetControlByName("LeftFilterEnergyButton");
            m_leftFilterAllButton = (MyGuiControlRadioButton)controlsParent.Controls.GetControlByName("LeftFilterAllButton");

            m_rightSuitButton = (MyGuiControlRadioButton)controlsParent.Controls.GetControlByName("RightSuitButton");
            m_rightGridButton = (MyGuiControlRadioButton)controlsParent.Controls.GetControlByName("RightGridButton");
            m_rightFilterStorageButton = (MyGuiControlRadioButton)controlsParent.Controls.GetControlByName("RightFilterStorageButton");
            m_rightFilterSystemButton = (MyGuiControlRadioButton)controlsParent.Controls.GetControlByName("RightFilterSystemButton");
            m_rightFilterEnergyButton = (MyGuiControlRadioButton)controlsParent.Controls.GetControlByName("RightFilterEnergyButton");
            m_rightFilterAllButton = (MyGuiControlRadioButton)controlsParent.Controls.GetControlByName("RightFilterAllButton");

            m_throwOutButton = (MyGuiControlButton)controlsParent.Controls.GetControlByName("ThrowOutButton");

            m_hideEmptyLeft         = (MyGuiControlCheckbox)controlsParent.Controls.GetControlByName("CheckboxHideEmptyLeft");
            m_hideEmptyLeftLabel    = (MyGuiControlLabel)controlsParent.Controls.GetControlByName("LabelHideEmptyLeft");
            m_hideEmptyRight        = (MyGuiControlCheckbox)controlsParent.Controls.GetControlByName("CheckboxHideEmptyRight");
            m_hideEmptyRightLabel   = (MyGuiControlLabel)controlsParent.Controls.GetControlByName("LabelHideEmptyRight");
            m_blockSearchLeft       = (MyGuiControlTextbox)controlsParent.Controls.GetControlByName("BlockSearchLeft");
            m_blockSearchClearLeft  = (MyGuiControlButton)controlsParent.Controls.GetControlByName("BlockSearchClearLeft");
            m_blockSearchRight      = (MyGuiControlTextbox)controlsParent.Controls.GetControlByName("BlockSearchRight");
            m_blockSearchClearRight = (MyGuiControlButton)controlsParent.Controls.GetControlByName("BlockSearchClearRight");

            m_hideEmptyLeft.Visible         = false;
            m_hideEmptyLeftLabel.Visible    = false;
            m_hideEmptyRight.Visible        = true;
            m_hideEmptyRightLabel.Visible   = true;
            m_blockSearchLeft.Visible       = false;
            m_blockSearchClearLeft.Visible  = false;
            m_blockSearchRight.Visible      = true;
            m_blockSearchClearRight.Visible = true;

            m_hideEmptyLeft.IsCheckedChanged      += HideEmptyLeft_Checked;
            m_hideEmptyRight.IsCheckedChanged     += HideEmptyRight_Checked;
            m_blockSearchLeft.TextChanged         += BlockSearchLeft_TextChanged;
            m_blockSearchClearLeft.ButtonClicked  += BlockSearchClearLeft_ButtonClicked;
            m_blockSearchRight.TextChanged        += BlockSearchRight_TextChanged;
            m_blockSearchClearRight.ButtonClicked += BlockSearchClearRight_ButtonClicked;

            m_leftSuitButton.SetToolTip(MySpaceTexts.ToolTipTerminalInventory_ShowCharacter);
            m_leftGridButton.SetToolTip(MySpaceTexts.ToolTipTerminalInventory_ShowConnected);
            m_rightSuitButton.SetToolTip(MySpaceTexts.ToolTipTerminalInventory_ShowInteracted);
            m_rightGridButton.SetToolTip(MySpaceTexts.ToolTipTerminalInventory_ShowConnected);

            m_leftFilterAllButton.SetToolTip(MySpaceTexts.ToolTipTerminalInventory_FilterAll);
            m_leftFilterEnergyButton.SetToolTip(MySpaceTexts.ToolTipTerminalInventory_FilterEnergy);
            m_leftFilterStorageButton.SetToolTip(MySpaceTexts.ToolTipTerminalInventory_FilterStorage);
            m_leftFilterSystemButton.SetToolTip(MySpaceTexts.ToolTipTerminalInventory_FilterSystem);

            m_rightFilterAllButton.SetToolTip(MySpaceTexts.ToolTipTerminalInventory_FilterAll);
            m_rightFilterEnergyButton.SetToolTip(MySpaceTexts.ToolTipTerminalInventory_FilterEnergy);
            m_rightFilterStorageButton.SetToolTip(MySpaceTexts.ToolTipTerminalInventory_FilterStorage);
            m_rightFilterSystemButton.SetToolTip(MySpaceTexts.ToolTipTerminalInventory_FilterSystem);

            m_throwOutButton.SetToolTip(MySpaceTexts.ToolTipTerminalInventory_ThrowOut);
            m_throwOutButton.CueEnum = GuiSounds.None;

            m_leftTypeGroup.Add(m_leftSuitButton);
            m_leftTypeGroup.Add(m_leftGridButton);
            m_rightTypeGroup.Add(m_rightSuitButton);
            m_rightTypeGroup.Add(m_rightGridButton);

            m_leftFilterGroup.Add(m_leftFilterAllButton);
            m_leftFilterGroup.Add(m_leftFilterEnergyButton);
            m_leftFilterGroup.Add(m_leftFilterStorageButton);
            m_leftFilterGroup.Add(m_leftFilterSystemButton);

            m_rightFilterGroup.Add(m_rightFilterAllButton);
            m_rightFilterGroup.Add(m_rightFilterEnergyButton);
            m_rightFilterGroup.Add(m_rightFilterStorageButton);
            m_rightFilterGroup.Add(m_rightFilterSystemButton);

            m_throwOutButton.DrawCrossTextureWhenDisabled = false;
            //m_throwOutButton.Enabled = false;

            // initialize drag and drop
            // maybe this requires screen?
            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_throwOutButton.ButtonClicked += throwOutButton_OnButtonClick;
            m_dragAndDrop.ItemDropped += dragDrop_OnItemDropped;

            var thisInventoryOwner = (m_userAsEntity != null && m_userAsEntity.HasInventory) ? m_userAsEntity : null;
            if (thisInventoryOwner != null)
                m_userAsOwner = thisInventoryOwner;

            var targetInventoryOwner = (m_interactedAsEntity != null && m_interactedAsEntity.HasInventory) ? m_interactedAsEntity : null;
            if (targetInventoryOwner != null)
                m_interactedAsOwner = targetInventoryOwner;

            var parentGrid = (m_interactedAsEntity != null) ? m_interactedAsEntity.Parent as MyCubeGrid : null;
            m_interactedGridOwners.Clear();
            if (parentGrid != null)
            {
                var group = MyCubeGridGroups.Static.Logical.GetGroup(parentGrid);
                foreach (var node in group.Nodes)
                {
                    GetGridInventories(node.NodeData, m_interactedGridOwners);
                    node.NodeData.GridSystems.ConveyorSystem.BlockAdded += ConveyorSystem_BlockAdded;
                    node.NodeData.GridSystems.ConveyorSystem.BlockRemoved += ConveyorSystem_BlockRemoved;

                    m_registeredConveyorSystems.Add(node.NodeData.GridSystems.ConveyorSystem);
                }
            }
            
            m_leftTypeGroup.SelectedIndex = 0;
            m_rightTypeGroup.SelectedIndex = (m_interactedAsEntity is MyCharacter) || (m_interactedAsEntity is MyInventoryBagEntity) ? 0 : 1;
            m_leftFilterGroup.SelectedIndex = 0;
            m_rightFilterGroup.SelectedIndex = 0;

            LeftTypeGroup_SelectedChanged(m_leftTypeGroup);
            RightTypeGroup_SelectedChanged(m_rightTypeGroup);
            SetLeftFilter(null);
            SetRightFilter(null);

            m_leftTypeGroup.SelectedChanged += LeftTypeGroup_SelectedChanged;
            m_rightTypeGroup.SelectedChanged += RightTypeGroup_SelectedChanged;

            m_leftFilterAllButton.SelectedChanged += (button) => { if (button.Selected) SetLeftFilter(null); };
            m_leftFilterEnergyButton.SelectedChanged += (button) => { if (button.Selected) SetLeftFilter(MyInventoryOwnerTypeEnum.Energy); };
            m_leftFilterStorageButton.SelectedChanged += (button) => { if (button.Selected) SetLeftFilter(MyInventoryOwnerTypeEnum.Storage); };
            m_leftFilterSystemButton.SelectedChanged += (button) => { if (button.Selected) SetLeftFilter(MyInventoryOwnerTypeEnum.System); };

            m_rightFilterAllButton.SelectedChanged += (button) => { if (button.Selected) SetRightFilter(null); };
            m_rightFilterEnergyButton.SelectedChanged += (button) => { if (button.Selected) SetRightFilter(MyInventoryOwnerTypeEnum.Energy); };
            m_rightFilterStorageButton.SelectedChanged += (button) => { if (button.Selected) SetRightFilter(MyInventoryOwnerTypeEnum.Storage); };
            m_rightFilterSystemButton.SelectedChanged += (button) => { if (button.Selected) SetRightFilter(MyInventoryOwnerTypeEnum.System); };

            if (m_interactedAsEntity == null)
            {
                m_leftGridButton.Enabled = false;
                m_rightGridButton.Enabled = false;
                m_rightTypeGroup.SelectedIndex = 0;
            }

            RefreshSelectedInventoryItem();
            ProfilerShort.End();
        }