Exemplo n.º 1
0
        private void CreateSlider(MyGuiControlList list, float usableWidth, float min, float max, ref MyGuiControlSlider slider)
        {
            slider = new MyGuiControlSlider(
                position: m_currentPosition,
                width: 400f / MyGuiConstants.GUI_OPTIMAL_SIZE.X,
                minValue: min,
                maxValue: max,
                labelText: String.Empty,
                labelDecimalPlaces: 4,
                labelScale: 0.75f * m_scale,
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                labelFont: MyFontEnum.Debug);

            slider.DebugScale = m_sliderDebugScale;
            slider.ColorMask  = Color.White.ToVector4();
            list.Controls.Add(slider);
        }
        void RightHandChanged(MyGuiControlSlider slider)
        {
            if (m_canUpdateValues)
            {
                m_rightHandRotationX = m_rightHandRotationXSlider.Value;
                m_rightHandRotationY = m_rightHandRotationYSlider.Value;
                m_rightHandRotationZ = m_rightHandRotationZSlider.Value;
                m_rightHandPositionX = m_rightHandPositionXSlider.Value;
                m_rightHandPositionY = m_rightHandPositionYSlider.Value;
                m_rightHandPositionZ = m_rightHandPositionZSlider.Value;

                CurrentSelectedItem.RightHand = m_storedRightHand
                                                * Matrix.CreateRotationX(MathHelper.ToRadians(m_rightHandRotationX))
                                                * Matrix.CreateRotationY(MathHelper.ToRadians(m_rightHandRotationY))
                                                * Matrix.CreateRotationZ(MathHelper.ToRadians(m_rightHandRotationZ));
                CurrentSelectedItem.RightHand.Translation = new Vector3(m_rightHandPositionX, m_rightHandPositionY, m_rightHandPositionZ);
            }
        }
        public override void RecreateControls(bool constructor)
        {
            base.RecreateControls(constructor);
            BackgroundColor = new Vector4(1f, 1f, 1f, 0.5f);

            m_currentPosition = -m_size.Value / 2.0f + new Vector2(0.02f, 0.13f);

            AddCaption("Voxel materials", Color.Yellow.ToVector4());
            AddShareFocusHint();

            m_materialsCombo = AddCombo();

            var defList = MyDefinitionManager.Static.GetVoxelMaterialDefinitions().OrderBy(x => x.Id.SubtypeName).ToList();

            foreach (var material in defList)
            {
                m_materialsCombo.AddItem(material.Index, new StringBuilder(material.Id.SubtypeName));
            }
            m_materialsCombo.ItemSelected += materialsCombo_OnSelect;
            m_currentPosition.Y           += 0.01f;

            m_sliderInitialScale       = AddSlider("Initial scale", 0, 1f, 100f, null);
            m_sliderScaleMultiplier    = AddSlider("Scale multiplier", 0, 1f, 100f, null);
            m_sliderInitialDistance    = AddSlider("Initial distance", 0, 1f, 100f, null);
            m_sliderDistanceMultiplier = AddSlider("Distance multiplier", 0, 1f, 100f, null);

            m_sliderFar1Distance = AddSlider("Far1 distance", 0, 0f, 20000f, null);
            m_sliderFar1Scale    = AddSlider("Far1 scale", 0, 1f, 50000f, null);
            m_sliderFar2Distance = AddSlider("Far2 distance", 0, 0f, 20000f, null);
            m_sliderFar2Scale    = AddSlider("Far2 scale", 0, 1f, 50000f, null);
            m_sliderFar3Distance = AddSlider("Far3 distance", 0, 0f, 40000f, null);
            m_sliderFar3Scale    = AddSlider("Far3 scale", 0, 1f, 50000f, null);

            m_sliderExtScale = AddSlider("Detail scale (/1000)", 0, 0.01f, 1f, null);

            m_materialsCombo.SelectItemByIndex(0);

            m_colorFar3 = AddColor(new StringBuilder("Far3 color"), m_selectedVoxelMaterial, MemberHelper.GetMember(() => m_selectedVoxelMaterial.Far3Color));
            m_colorFar3.SetColor(m_selectedVoxelMaterial.Far3Color);

            m_currentPosition.Y += 0.01f;

            AddButton(new StringBuilder("Reload definition"), OnReloadDefinition);
        }
        void ItemChanged(MyGuiControlSlider slider)
        {
            if (m_canUpdateValues)
            {
                m_itemRotationX = m_itemRotationXSlider.Value;
                m_itemRotationY = m_itemRotationYSlider.Value;
                m_itemRotationZ = m_itemRotationZSlider.Value;
                m_itemPositionX = m_itemPositionXSlider.Value;
                m_itemPositionY = m_itemPositionYSlider.Value;
                m_itemPositionZ = m_itemPositionZSlider.Value;

                CurrentSelectedItem.ItemShootLocation = m_storedShootLocation
                                                        * Matrix.CreateRotationX(MathHelper.ToRadians(m_itemRotationX))
                                                        * Matrix.CreateRotationY(MathHelper.ToRadians(m_itemRotationY))
                                                        * Matrix.CreateRotationZ(MathHelper.ToRadians(m_itemRotationZ));
                CurrentSelectedItem.ItemShootLocation.Translation = new Vector3(m_itemPositionX, m_itemPositionY, m_itemPositionZ);


                m_itemRotationX3rd = m_itemRotationX3rdSlider.Value;
                m_itemRotationY3rd = m_itemRotationY3rdSlider.Value;
                m_itemRotationZ3rd = m_itemRotationZ3rdSlider.Value;
                m_itemPositionX3rd = m_itemPositionX3rdSlider.Value;
                m_itemPositionY3rd = m_itemPositionY3rdSlider.Value;
                m_itemPositionZ3rd = m_itemPositionZ3rdSlider.Value;

                CurrentSelectedItem.ItemShootLocation3rd = m_storedShootLocation3rd
                                                           * Matrix.CreateRotationX(MathHelper.ToRadians(m_itemRotationX3rd))
                                                           * Matrix.CreateRotationY(MathHelper.ToRadians(m_itemRotationY3rd))
                                                           * Matrix.CreateRotationZ(MathHelper.ToRadians(m_itemRotationZ3rd));
                CurrentSelectedItem.ItemShootLocation3rd.Translation = new Vector3(m_itemPositionX3rd, m_itemPositionY3rd, m_itemPositionZ3rd);

                CurrentSelectedItem.ShootBlend = m_blendSlider.Value;

                CurrentSelectedItem.MuzzlePosition.X = m_itemMuzzlePositionXSlider.Value;
                CurrentSelectedItem.MuzzlePosition.Y = m_itemMuzzlePositionYSlider.Value;
                CurrentSelectedItem.MuzzlePosition.Z = m_itemMuzzlePositionZSlider.Value;

                CurrentSelectedItem.ShootScatter.X = m_shootScatterXSlider.Value;
                CurrentSelectedItem.ShootScatter.Y = m_shootScatterYSlider.Value;
                CurrentSelectedItem.ShootScatter.Z = m_shootScatterZSlider.Value;
                CurrentSelectedItem.ScatterSpeed   = m_scatterSpeedSlider.Value;
            }
        }
Exemplo n.º 5
0
        protected MyGuiControlSlider addSlider(StringBuilder text, float valueMin, float valueMax, Vector4?color = null)
        {
            MyGuiControlLabel label = new MyGuiControlLabel(this, m_currentPosition, null, text, color ?? m_defaultColor, MyGuiConstants.LABEL_TEXT_SCALE * 0.8f * m_scale,
                                                            MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);
            float labelWidth = label.GetTextSize().Size.X + 0.02f;

            m_maxWidth = Math.Max(m_maxWidth, labelWidth);
            Controls.Add(label);

            m_currentPosition.Y += 0.04f * m_scale;

            MyGuiControlSlider slider = new MyGuiControlSlider(this, m_currentPosition + new Vector2(0.1f, 0) * m_scale, 0.2f, valueMin, valueMax, color ?? m_defaultColor,
                                                               new System.Text.StringBuilder(" {0}"), 0.1f, 3, 0.65f * m_scale, m_scale);

            Controls.Add(slider);
            m_currentPosition.Y += 0.05f * m_scale;

            return(slider);
        }
Exemplo n.º 6
0
        private void InitControls()
        {
            Vector2 position      = new Vector2(-m_size.Value.X / 2f, 0f);
            Vector2 controlsDelta = new Vector2(m_offset, 0f);

            // create description label
            if ((m_flags & MyGuiSizeEnumFlags.Description) > 0)
            {
                m_descriptionLabel = new MyGuiControlLabel(this, position, null, m_description, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);
                Controls.Add(m_descriptionLabel);
                position += controlsDelta;
            }

            // create value slider
            if ((m_flags & MyGuiSizeEnumFlags.Slider) > 0)
            {
                // slider
                m_valueSlider = new MyGuiControlSlider(this, position, MyGuiConstants.SLIDER_WIDTH, m_minValue, m_maxValue, MyGuiConstants.SLIDER_BACKGROUND_COLOR,
                                                       new StringBuilder(), MyGuiConstants.SLIDER_WIDTH_LABEL, 0, MyGuiConstants.LABEL_TEXT_SCALE * 0.85f);
                m_valueSlider.OnChange = OnSliderChange;
                Controls.Add(m_valueSlider);
                position += controlsDelta;
            }

            // create value textbox
            if ((m_flags & MyGuiSizeEnumFlags.TextBox) > 0)
            {
                m_valueTextBox             = new MyGuiControlTextbox(this, position, MyGuiControlPreDefinedSize.MEDIUM, string.Empty, 9, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiControlTextboxType.DIGITS_ONLY);
                m_valueTextBox.TextChanged = OnTextBoxChange;
                Controls.Add(m_valueTextBox);
            }
            else if ((m_flags & MyGuiSizeEnumFlags.Slider) > 0)
            {
                // slider value label
                m_valueLabel = new MyGuiControlLabel(this, position, null, MyTextsWrapperEnum.None, MyGuiConstants.LABEL_TEXT_COLOR,
                                                     MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);
                Controls.Add(m_valueLabel);
            }
        }
Exemplo n.º 7
0
        private void DrawColors()
        {
            if (m_prefabLights.Count > 0)
            {
                MyPrefabLight myLight = m_prefabLights[0] as MyPrefabLight;

                MyGuiControlSlider rS = m_spotNormalLightColorSlider[0];
                Color color           = new Color(myLight.GetLight().ReflectorColor);
                color.A = 255;

                if (m_pointLightCheckbox.Visible)
                {
                    rS      = m_pointNormalLightColorSlider[0];
                    color   = new Color(myLight.GetLight().Color);
                    color.A = 255;
                }

                Vector2 posOffset      = new Vector2(-0.08f, -0.005f);
                Vector2 pos            = MyGuiManager.GetScreenCoordinateFromNormalizedCoordinate(rS.GetPosition() - MyGuiConstants.CONTROLS_DELTA + posOffset);
                Vector2 colorLabelSize = MyGuiManager.GetScreenSizeFromNormalizedSize(new Vector2(0.5f * MyGuiConstants.SLIDER_HEIGHT, 0.5f * MyGuiConstants.SLIDER_HEIGHT));

                // Draw one big final color rectangle to see result of each RGBA component in one
                MyGuiManager.DrawSpriteBatch(MyGuiManager.GetBlankTexture(), (int)pos.X, (int)pos.Y, (int)colorLabelSize.X, (int)colorLabelSize.Y, color);

                if (m_pointLightCheckbox.Visible)
                {
                    Vector2 pos2 = MyGuiManager.GetScreenCoordinateFromNormalizedCoordinate(m_specularLightColorSlider[0].GetPosition() - MyGuiConstants.CONTROLS_DELTA + posOffset);

                    Color color2 = new Color(myLight.GetLight().SpecularColor);
                    color2.A = 255;

                    // Draw color rectangles next to each color slider and then draw one big final color rectangle to see result of each RGBA component in one
                    MyGuiManager.DrawSpriteBatch(MyGuiManager.GetBlankTexture(), (int)pos2.X, (int)pos2.Y, (int)colorLabelSize.X, (int)colorLabelSize.Y, color2);
                }
            }
        }
        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 Model FX", Color.Yellow.ToVector4());
            AddShareFocusHint();

            //if (MySession.Static.ControlledObject == null)
            //return;

            AddButton(new StringBuilder("Reload textures"), delegate { VRageRender.MyRenderProxy.ReloadTextures(); });


            //Line line = new Line(MySector.MainCamera.Position, MySector.MainCamera.Position + MySector.MainCamera.ForwardVector * 10);
            //var res = MyEntities.GetIntersectionWithLine(ref line, null, null);
            //if (!res.HasValue)
            //    return;

            ////MyModel model = MySession.Static.ControlledObject.ModelLod0;
            //m_model = res.Value.Entity.ModelLod0;

            m_modelsCombo = AddCombo();
            var modelList = VRage.Game.Models.MyModels.GetLoadedModels();

            if (modelList.Count == 0)
            {
                return;
            }

            for (int i = 0; i < modelList.Count; i++)
            {
                var model = modelList[i];
                m_modelsCombo.AddItem((int)i, new StringBuilder(System.IO.Path.GetFileNameWithoutExtension(model.AssetName)));
            }

            m_modelsCombo.SelectItemByIndex(m_currentModelSelectedItem);
            m_modelsCombo.ItemSelected += new MyGuiControlCombobox.ItemSelectedDelegate(modelsCombo_OnSelect);

            m_model = modelList[m_currentModelSelectedItem];

            if (m_model == null)
            {
                return;
            }

            m_meshesCombo = AddCombo();
            for (int i = 0; i < m_model.GetMeshList().Count; i++)
            {
                var mesh = m_model.GetMeshList()[i];
                m_meshesCombo.AddItem((int)i, new StringBuilder(mesh.Material.Name));
            }
            m_meshesCombo.SelectItemByIndex(m_currentSelectedMeshItem);
            m_meshesCombo.ItemSelected += new MyGuiControlCombobox.ItemSelectedDelegate(meshesCombo_OnSelect);

            if (MySector.MainCamera != null)
            {
                m_voxelsCombo = AddCombo();
                m_voxelsCombo.AddItem(-1, new StringBuilder("None"));
                int i = 0;
                foreach (var voxelMaterial in MyDefinitionManager.Static.GetVoxelMaterialDefinitions())
                {
                    m_voxelsCombo.AddItem(i++, new StringBuilder(voxelMaterial.Id.SubtypeName));
                }
                m_voxelsCombo.SelectItemByIndex(m_currentSelectedVoxelItem + 1);
                m_voxelsCombo.ItemSelected += new MyGuiControlCombobox.ItemSelectedDelegate(voxelsCombo_OnSelect);
            }

            if (m_model.GetMeshList().Count <= m_currentSelectedMeshItem)
            {
                return;
            }

            var selectedMesh     = m_model.GetMeshList()[m_currentSelectedMeshItem];
            var selectedMaterial = selectedMesh.Material;

            m_diffuseColor = AddColor(new StringBuilder("Diffuse"), selectedMaterial, MemberHelper.GetMember(() => selectedMaterial.DiffuseColor));

            m_specularIntensity = AddSlider("Specular intensity", selectedMaterial.SpecularIntensity, 0, 32, null);

            m_specularPower = AddSlider("Specular power", selectedMaterial.SpecularPower, 0, 128, null);
        }
        public override void RecreateControls(bool constructor)
        {
            base.RecreateControls(constructor);

            m_scale = 0.7f;

            AddCaption("Hand item shoot", Color.Yellow.ToVector4());
            AddShareFocusHint();

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

            RecreateHandItemsCombo();

            m_sliderDebugScale = 0.6f;

            m_itemRotationXSlider = AddSlider("item rotation X", 0f, 0f, 360f, null);
            m_itemRotationXSlider.ValueChanged = ItemChanged;
            m_itemRotationYSlider = AddSlider("item rotation Y", 0f, 0f, 360f, null);
            m_itemRotationYSlider.ValueChanged = ItemChanged;
            m_itemRotationZSlider = AddSlider("item rotation Z", 0f, 0f, 360f, null);
            m_itemRotationZSlider.ValueChanged = ItemChanged;
            m_itemPositionXSlider = AddSlider("item position X", 0f, -1f, 1f, null);
            m_itemPositionXSlider.ValueChanged = ItemChanged;
            m_itemPositionYSlider = AddSlider("item position Y", 0f, -1f, 1f, null);
            m_itemPositionYSlider.ValueChanged = ItemChanged;
            m_itemPositionZSlider = AddSlider("item position Z", 0f, -1f, 1f, null);
            m_itemPositionZSlider.ValueChanged = ItemChanged;

            m_itemRotationX3rdSlider = AddSlider("item rotation X 3rd", 0f, 0f, 360f, null);
            m_itemRotationX3rdSlider.ValueChanged = ItemChanged;
            m_itemRotationY3rdSlider = AddSlider("item rotation Y 3rd", 0f, 0f, 360f, null);
            m_itemRotationY3rdSlider.ValueChanged = ItemChanged;
            m_itemRotationZ3rdSlider = AddSlider("item rotation Z 3rd", 0f, 0f, 360f, null);
            m_itemRotationZ3rdSlider.ValueChanged = ItemChanged;
            m_itemPositionX3rdSlider = AddSlider("item position X 3rd", 0f, -1f, 1f, null);
            m_itemPositionX3rdSlider.ValueChanged = ItemChanged;
            m_itemPositionY3rdSlider = AddSlider("item position Y 3rd", 0f, -1f, 1f, null);
            m_itemPositionY3rdSlider.ValueChanged = ItemChanged;
            m_itemPositionZ3rdSlider = AddSlider("item position Z 3rd", 0f, -1f, 1f, null);
            m_itemPositionZ3rdSlider.ValueChanged = ItemChanged;


            m_itemMuzzlePositionXSlider = AddSlider("item muzzle X", 0f, -1f, 1f, null);
            m_itemMuzzlePositionXSlider.ValueChanged = ItemChanged;
            m_itemMuzzlePositionYSlider = AddSlider("item muzzle Y", 0f, -1f, 1f, null);
            m_itemMuzzlePositionYSlider.ValueChanged = ItemChanged;
            m_itemMuzzlePositionZSlider = AddSlider("item muzzle Z", 0f, -1f, 1f, null);
            m_itemMuzzlePositionZSlider.ValueChanged = ItemChanged;


            m_blendSlider = AddSlider("Shoot blend", 0f, 0f, 3f, null);
            m_blendSlider.ValueChanged = ItemChanged;

            m_shootScatterXSlider = AddSlider("Scatter X", 0f, 0, 1f, null);
            m_shootScatterXSlider.ValueChanged = ItemChanged;
            m_shootScatterYSlider = AddSlider("Scatter Y", 0f, 0, 1f, null);
            m_shootScatterYSlider.ValueChanged = ItemChanged;
            m_shootScatterZSlider = AddSlider("Scatter Z", 0f, 0, 1f, null);
            m_shootScatterZSlider.ValueChanged = ItemChanged;
            m_scatterSpeedSlider = AddSlider("Scatter speed", 0f, 0f, 1f, null);
            m_scatterSpeedSlider.ValueChanged = ItemChanged;


            AddButton(new StringBuilder("Walk!"), OnWalk);
            AddButton(new StringBuilder("Run!"), OnRun);
            RecreateSaveAndReloadButtons();

            SelectFirstHandItem();

            m_currentPosition.Y += 0.01f;
        }
        public override void RecreateControls(bool constructor)
        {
            if (!constructor)
            {
                return;
            }

            base.RecreateControls(constructor);

            AddCaption(MyTexts.GetString(MyCommonTexts.ScreenCaptionGraphicsOptions));

            const float TEXT_SCALE = Sandbox.Graphics.GUI.MyGuiConstants.DEFAULT_TEXT_SCALE * 0.85f;

            var labelRenderer               = new MyGuiControlLabel(textScale: TEXT_SCALE, text: MyTexts.GetString(MySpaceTexts.ScreenGraphicsOptions_Renderer));
            var labelHwCursor               = new MyGuiControlLabel(textScale: TEXT_SCALE, text: MyTexts.GetString(MyCommonTexts.HardwareCursor));
            var labelFov                    = new MyGuiControlLabel(textScale: TEXT_SCALE, text: MyTexts.GetString(MyCommonTexts.FieldOfView));
            var labelFovDefault             = new MyGuiControlLabel(textScale: TEXT_SCALE, text: MyTexts.GetString(MyCommonTexts.DefaultFOV));
            var labelRenderInterpolation    = new MyGuiControlLabel(textScale: TEXT_SCALE, text: MyTexts.GetString(MyCommonTexts.RenderIterpolation));
            var labelAntiAliasing           = new MyGuiControlLabel(textScale: TEXT_SCALE, text: MyTexts.GetString(MyCommonTexts.ScreenGraphicsOptions_AntiAliasing));
            var labelShadowMapResolution    = new MyGuiControlLabel(textScale: TEXT_SCALE, text: MyTexts.GetString(MySpaceTexts.ScreenGraphicsOptions_ShadowMapResolution));
            var labelMultithreadedRendering = new MyGuiControlLabel(textScale: TEXT_SCALE, text: MyTexts.GetString(MyCommonTexts.ScreenGraphicsOptions_MultiThreadedRendering));
            //var labelTonemapping            = new MyGuiControlLabel(textScale: TEXT_SCALE, text: MyTexts.GetString(MyCommonTexts.ScreenGraphicsOptions_Tonemapping));
            var labelTextureQuality       = new MyGuiControlLabel(textScale: TEXT_SCALE, text: MyTexts.GetString(MyCommonTexts.ScreenGraphicsOptions_TextureQuality));
            var labelVoxelQuality         = new MyGuiControlLabel(textScale: TEXT_SCALE, text: MyTexts.GetString(MySpaceTexts.ScreenGraphicsOptions_VoxelQuality));
            var labelAnisotropicFiltering = new MyGuiControlLabel(textScale: TEXT_SCALE, text: MyTexts.GetString(MyCommonTexts.ScreenGraphicsOptions_AnisotropicFiltering));
            var labelGraphicsPresets      = new MyGuiControlLabel(textScale: TEXT_SCALE, text: MyTexts.GetString(MyCommonTexts.ScreenGraphicsOptions_QualityPreset));
            var labelFoliageDetails       = new MyGuiControlLabel(textScale: TEXT_SCALE, text: MyTexts.GetString(MyCommonTexts.ScreenGraphicsOptions_FoliageDetails));
            var labelGrassDensity         = new MyGuiControlLabel(textScale: TEXT_SCALE, text: MyTexts.GetString(MyCommonTexts.WorldSettings_GrassDensity));
            var labelEnableDamageEffects  = new MyGuiControlLabel(textScale: TEXT_SCALE, text: MyTexts.GetString(MySpaceTexts.EnableDamageEffects));
            var labelDx9RenderQuality     = new MyGuiControlLabel(textScale: TEXT_SCALE, text: MyTexts.GetString(MySpaceTexts.RenderQuality));

            m_comboRenderer               = new MyGuiControlCombobox(toolTip: MyTexts.GetString(MySpaceTexts.ToolTipVideoOptionsRenderer));
            m_comboGraphicsPresets        = new MyGuiControlCombobox();
            m_comboAntialiasing           = new MyGuiControlCombobox();
            m_comboShadowMapResolution    = new MyGuiControlCombobox();
            m_comboTextureQuality         = new MyGuiControlCombobox();
            m_comboAnisotropicFiltering   = new MyGuiControlCombobox();
            m_comboDx9RenderQuality       = new MyGuiControlCombobox(toolTip: MyTexts.GetString(MyCommonTexts.ToolTipVideoOptionsRenderQuality));
            m_checkboxHardwareCursor      = new MyGuiControlCheckbox(toolTip: MyTexts.GetString(MyCommonTexts.ToolTipVideoOptionsHardwareCursor));
            m_checkboxRenderInterpolation = new MyGuiControlCheckbox(toolTip: MyTexts.GetString(MyCommonTexts.ToolTipVideoOptionRenderIterpolation));
            //m_checkboxMultithreadedRender = new MyGuiControlCheckbox();
            //m_checkboxTonemapping         = new MyGuiControlCheckbox();
            m_checkboxEnableDamageEffects = new MyGuiControlCheckbox(toolTip: MyTexts.GetString(MySpaceTexts.ToolTipVideoOptionsEnableDamageEffects));
            m_sliderFov = new MyGuiControlSlider(toolTip: MyTexts.GetString(MyCommonTexts.ToolTipVideoOptionsFieldOfView),
                                                 labelText: new StringBuilder("{0}").ToString(),
                                                 labelSpaceWidth: 0.035f,
                                                 labelScale: TEXT_SCALE,
                                                 labelFont: MyFontEnum.Blue);

            m_comboVoxelQuality = new MyGuiControlCombobox();

            m_comboFoliageDetails = new MyGuiControlCombobox();
            m_grassDensitySlider  = new MyGuiControlSlider(minValue: 0f, maxValue: 10f,
                                                           labelText: new StringBuilder("{0}").ToString(),
                                                           labelSpaceWidth: 0.035f,
                                                           labelScale: TEXT_SCALE,
                                                           labelFont: MyFontEnum.Blue);

            var okButton     = new MyGuiControlButton(text: MyTexts.Get(MyCommonTexts.Ok), onButtonClick: OnOkClick);
            var cancelButton = new MyGuiControlButton(text: MyTexts.Get(MyCommonTexts.Cancel), onButtonClick: OnCancelClick);

            m_comboDx9RenderQuality.AddItem((int)MyRenderQualityEnum.NORMAL, MySpaceTexts.RenderQualityNormal);
            m_comboDx9RenderQuality.AddItem((int)MyRenderQualityEnum.HIGH, MySpaceTexts.RenderQualityHigh);
            m_comboDx9RenderQuality.AddItem((int)MyRenderQualityEnum.EXTREME, MySpaceTexts.RenderQualityExtreme);

            m_comboGraphicsPresets.AddItem((int)PresetEnum.Low, MyTexts.GetString(MyCommonTexts.ScreenGraphicsOptions_QualityPreset_Low));
            m_comboGraphicsPresets.AddItem((int)PresetEnum.Medium, MyTexts.GetString(MyCommonTexts.ScreenGraphicsOptions_QualityPreset_Medium));
            m_comboGraphicsPresets.AddItem((int)PresetEnum.High, MyTexts.GetString(MyCommonTexts.ScreenGraphicsOptions_QualityPreset_High));
            m_comboGraphicsPresets.AddItem((int)PresetEnum.Custom, MyTexts.GetString(MyCommonTexts.ScreenGraphicsOptions_QualityPreset_Custom));

            m_comboAntialiasing.AddItem((int)MyAntialiasingMode.NONE, MyTexts.GetString(MyCommonTexts.ScreenGraphicsOptions_AntiAliasing_None));
            m_comboAntialiasing.AddItem((int)MyAntialiasingMode.FXAA, "FXAA");
            m_comboAntialiasing.AddItem((int)MyAntialiasingMode.MSAA_2, "MSAA 2x");
            m_comboAntialiasing.AddItem((int)MyAntialiasingMode.MSAA_4, "MSAA 4x");
            m_comboAntialiasing.AddItem((int)MyAntialiasingMode.MSAA_8, "MSAA 8x");

            m_comboShadowMapResolution.AddItem((int)MyShadowsQuality.LOW, MyTexts.GetString(MyCommonTexts.ScreenGraphicsOptions_ShadowMapResolution_Low));
            m_comboShadowMapResolution.AddItem((int)MyShadowsQuality.MEDIUM, MyTexts.GetString(MySpaceTexts.ScreenGraphicsOptions_ShadowMapResolution_Medium));
            m_comboShadowMapResolution.AddItem((int)MyShadowsQuality.HIGH, MyTexts.GetString(MyCommonTexts.ScreenGraphicsOptions_ShadowMapResolution_High));

            m_comboTextureQuality.AddItem((int)MyTextureQuality.LOW, MyTexts.GetString(MyCommonTexts.ScreenGraphicsOptions_TextureQuality_Low));
            m_comboTextureQuality.AddItem((int)MyTextureQuality.MEDIUM, MyTexts.GetString(MyCommonTexts.ScreenGraphicsOptions_TextureQuality_Medium));
            m_comboTextureQuality.AddItem((int)MyTextureQuality.HIGH, MyTexts.GetString(MyCommonTexts.ScreenGraphicsOptions_TextureQuality_High));

            m_comboAnisotropicFiltering.AddItem((int)MyTextureAnisoFiltering.NONE, MyTexts.GetString(MyCommonTexts.ScreenGraphicsOptions_AnisotropicFiltering_Off));
            m_comboAnisotropicFiltering.AddItem((int)MyTextureAnisoFiltering.ANISO_1, "1x");
            m_comboAnisotropicFiltering.AddItem((int)MyTextureAnisoFiltering.ANISO_4, "4x");
            m_comboAnisotropicFiltering.AddItem((int)MyTextureAnisoFiltering.ANISO_8, "8x");
            m_comboAnisotropicFiltering.AddItem((int)MyTextureAnisoFiltering.ANISO_16, "16x");

            m_comboFoliageDetails.AddItem((int)MyFoliageDetails.DISABLED, MyTexts.GetString(MyCommonTexts.ScreenGraphicsOptions_FoliageDetails_Disabled));
            m_comboFoliageDetails.AddItem((int)MyFoliageDetails.LOW, MyTexts.GetString(MyCommonTexts.ScreenGraphicsOptions_FoliageDetails_Low));
            m_comboFoliageDetails.AddItem((int)MyFoliageDetails.MEDIUM, MyTexts.GetString(MyCommonTexts.ScreenGraphicsOptions_FoliageDetails_Medium));
            m_comboFoliageDetails.AddItem((int)MyFoliageDetails.HIGH, MyTexts.GetString(MyCommonTexts.ScreenGraphicsOptions_FoliageDetails_High));

            m_comboVoxelQuality.AddItem((int)MyRenderQualityEnum.LOW, MyTexts.GetString(MyCommonTexts.ScreenGraphicsOptions_FoliageDetails_Low));
            m_comboVoxelQuality.AddItem((int)MyRenderQualityEnum.NORMAL, MyTexts.GetString(MyCommonTexts.ScreenGraphicsOptions_FoliageDetails_Medium));
            m_comboVoxelQuality.AddItem((int)MyRenderQualityEnum.HIGH, MyTexts.GetString(MyCommonTexts.ScreenGraphicsOptions_FoliageDetails_High));

            for (int i = 0; i < m_renderers.Length; i++)
            {
                m_comboRenderer.AddItem(i, m_renderers[i]);
            }

            labelFovDefault.UpdateFormatParams(MathHelper.ToDegrees(MyConstants.FIELD_OF_VIEW_CONFIG_DEFAULT));


            var table = new MyLayoutTable(this);
            {
                const float h = 60f;
                table.SetColumnWidths(60f, 400f, 460f);
                table.SetRowHeights(100f, h, h, h, h, h, 40f, h, h, h, h, h, h, h, h, h, 120f);
            }
            int            row      = 1;
            const int      leftCol  = 1;
            const int      rightCol = 2;
            const MyAlignH hAlign   = MyAlignH.Left;
            const MyAlignV vAlign   = MyAlignV.Center;

            table.Add(labelRenderer, hAlign, vAlign, row, leftCol);
            table.Add(m_comboRenderer, hAlign, vAlign, row++, rightCol);
            table.Add(labelHwCursor, hAlign, vAlign, row, leftCol);
            table.Add(m_checkboxHardwareCursor, hAlign, vAlign, row++, rightCol);
            table.Add(labelRenderInterpolation, hAlign, vAlign, row, leftCol);
            table.Add(m_checkboxRenderInterpolation, hAlign, vAlign, row++, rightCol);
            table.Add(labelEnableDamageEffects, hAlign, vAlign, row, leftCol);
            table.Add(m_checkboxEnableDamageEffects, hAlign, vAlign, row++, rightCol);
            table.Add(labelFov, hAlign, vAlign, row, leftCol);
            table.Add(m_sliderFov, hAlign, vAlign, row++, rightCol);
            table.Add(labelFovDefault, hAlign, MyAlignV.Top, row++, rightCol);
            int moveWhenDirX9 = 0;

            if (MyVideoSettingsManager.RunningGraphicsRenderer == MySandboxGame.DirectX11RendererKey)
            {
                table.Add(labelGraphicsPresets, hAlign, vAlign, row, leftCol);
                table.Add(m_comboGraphicsPresets, hAlign, vAlign, row++, rightCol);
                table.Add(labelAntiAliasing, hAlign, vAlign, row, leftCol);
                table.Add(m_comboAntialiasing, hAlign, vAlign, row++, rightCol);
                table.Add(labelShadowMapResolution, hAlign, vAlign, row, leftCol);
                table.Add(m_comboShadowMapResolution, hAlign, vAlign, row++, rightCol);
                table.Add(labelTextureQuality, hAlign, vAlign, row, leftCol);
                table.Add(m_comboTextureQuality, hAlign, vAlign, row++, rightCol);
                table.Add(labelVoxelQuality, hAlign, vAlign, row, leftCol);
                table.Add(m_comboVoxelQuality, hAlign, vAlign, row++, rightCol);
                table.Add(labelAnisotropicFiltering, hAlign, vAlign, row, leftCol);
                table.Add(m_comboAnisotropicFiltering, hAlign, vAlign, row++, rightCol);
                //table.Add(labelMultithreadedRendering, hAlign, vAlign, row, leftCol);
                //table.Add(m_checkboxMultithreadedRender, hAlign, vAlign, row++, rightCol);
                //table.Add(labelTonemapping, hAlign, vAlign, row, leftCol);
                //table.Add(m_checkboxTonemapping, hAlign, vAlign, row++, rightCol);
                if (MyFakes.ENABLE_PLANETS)
                {
                    table.Add(labelFoliageDetails, hAlign, vAlign, row, leftCol);
                    table.Add(m_comboFoliageDetails, hAlign, vAlign, row++, rightCol);
                    table.Add(labelGrassDensity, hAlign, vAlign, row, leftCol);
                    table.Add(m_grassDensitySlider, hAlign, vAlign, row++, rightCol);
                }
            }
            else // Dx9 or nothing specified
            {
                table.Add(labelDx9RenderQuality, hAlign, vAlign, row, leftCol);
                table.Add(m_comboDx9RenderQuality, hAlign, vAlign, row++, rightCol);
                moveWhenDirX9 = 1;
            }

            table.Add(okButton, MyAlignH.Left, MyAlignV.Bottom, table.LastRow - moveWhenDirX9, leftCol);
            table.Add(cancelButton, MyAlignH.Right, MyAlignV.Bottom, table.LastRow - moveWhenDirX9, rightCol);

            { // Set FoV bounds based on current display setting.
                float fovMin, fovMax;
                MyVideoSettingsManager.GetFovBounds(out fovMin, out fovMax);
                m_sliderFov.SetBounds(MathHelper.ToDegrees(fovMin), MathHelper.ToDegrees(fovMax));
            }

            {
                m_grassDensitySlider.SetBounds(0f, 10f);
            }

            //  Update controls with values from config file
            m_settingsOld = MyVideoSettingsManager.CurrentGraphicsSettings;
            m_settingsNew = m_settingsOld;
            WriteSettingsToControls(m_settingsOld);

            //  Update OLD settings
            ReadSettingsFromControls(ref m_settingsOld);
            ReadSettingsFromControls(ref m_settingsNew);

            {
                MyGuiControlCombobox.ItemSelectedDelegate onComboItemSelected = OnSettingsChanged;
                Action <MyGuiControlCheckbox>             onCheckboxChanged   = (checkbox) => OnSettingsChanged();

                m_comboGraphicsPresets.ItemSelected      += OnPresetSelected;
                m_comboAnisotropicFiltering.ItemSelected += onComboItemSelected;
                m_comboAntialiasing.ItemSelected         += onComboItemSelected;
                m_comboShadowMapResolution.ItemSelected  += onComboItemSelected;
                m_comboFoliageDetails.ItemSelected       += onComboItemSelected;
                m_comboVoxelQuality.ItemSelected         += onComboItemSelected;
                m_comboTextureQuality.ItemSelected       += onComboItemSelected;
                m_comboDx9RenderQuality.ItemSelected     += onComboItemSelected;

                m_checkboxHardwareCursor.IsCheckedChanged = onCheckboxChanged;
                //m_checkboxMultithreadedRender.IsCheckedChanged = onCheckboxChanged;
                m_checkboxRenderInterpolation.IsCheckedChanged = onCheckboxChanged;
                //m_checkboxTonemapping.IsCheckedChanged = onCheckboxChanged;
                m_checkboxEnableDamageEffects.IsCheckedChanged = onCheckboxChanged;

                m_sliderFov.ValueChanged = (slider) => OnSettingsChanged();
                //          m_grassDensitySlider.ValueChanged = (slider) => OnSettingsChanged();
            }
            RefreshPresetCombo(m_settingsOld.Render);

            CloseButtonEnabled = true;
            CloseButtonOffset  = new Vector2(-50f, 50f) / MyGuiConstants.GUI_OPTIMAL_SIZE;
        }
Exemplo n.º 11
0
        public override void RecreateControls(bool constructor)
        {
            base.RecreateControls(constructor);

            CloseButtonEnabled = true;

            var caption             = AddCaption(MyCommonTexts.ScreenCaptionPlayers);
            var captionCenter       = MyUtils.GetCoordCenterFromAligned(caption.Position, caption.Size, caption.OriginAlign);
            var captionBottomCenter = captionCenter + new Vector2(0f, 0.5f * caption.Size.Y);

            Vector2 sizeScale = Size.Value / MyGuiConstants.TEXTURE_SCREEN_BACKGROUND.SizeGui;
            Vector2 topLeft   = -0.5f * Size.Value + sizeScale * MyGuiConstants.TEXTURE_SCREEN_BACKGROUND.PaddingSizeGui * 1.1f;

            float verticalSpacing = 0.0045f;

            m_lobbyTypeCombo = new MyGuiControlCombobox(
                position: new Vector2(-topLeft.X, captionBottomCenter.Y + verticalSpacing),
                openAreaItemsCount: 3);
            m_lobbyTypeCombo.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP;
            m_lobbyTypeCombo.AddItem((int)LobbyTypeEnum.Private, MyCommonTexts.ScreenPlayersLobby_Private);
            m_lobbyTypeCombo.AddItem((int)LobbyTypeEnum.FriendsOnly, MyCommonTexts.ScreenPlayersLobby_Friends);
            m_lobbyTypeCombo.AddItem((int)LobbyTypeEnum.Public, MyCommonTexts.ScreenPlayersLobby_Public);
            m_lobbyTypeCombo.SelectItemByKey((int)MyMultiplayer.Static.GetLobbyType());

            MyGuiControlBase aboveControl;

            m_inviteButton = new MyGuiControlButton(
                position: new Vector2(-m_lobbyTypeCombo.Position.X, m_lobbyTypeCombo.Position.Y + m_lobbyTypeCombo.Size.Y + verticalSpacing),
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                text: MyTexts.Get(MyCommonTexts.ScreenPlayers_Invite));
            aboveControl = m_inviteButton;

            m_promoteButton = new MyGuiControlButton(
                position: aboveControl.Position + new Vector2(0f, aboveControl.Size.Y + verticalSpacing),
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                text: MyTexts.Get(MyCommonTexts.ScreenPlayers_Promote));
            aboveControl = m_promoteButton;

            m_demoteButton = new MyGuiControlButton(
                position: aboveControl.Position + new Vector2(0f, aboveControl.Size.Y + verticalSpacing),
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                text: MyTexts.Get(MyCommonTexts.ScreenPlayers_Demote));
            aboveControl = m_demoteButton;

            m_kickButton = new MyGuiControlButton(
                position: aboveControl.Position + new Vector2(0f, aboveControl.Size.Y + verticalSpacing),
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                text: MyTexts.Get(MyCommonTexts.ScreenPlayers_Kick));
            aboveControl = m_kickButton;

            m_banButton = new MyGuiControlButton(
                position: aboveControl.Position + new Vector2(0f, aboveControl.Size.Y + verticalSpacing),
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                text: MyTexts.Get(MyCommonTexts.ScreenPlayers_Ban));
            aboveControl = m_banButton;

            var maxPlayersLabel = new MyGuiControlLabel(
                position: aboveControl.Position + new Vector2(0f, aboveControl.Size.Y + verticalSpacing),
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                text: MyTexts.GetString(MyCommonTexts.MaxPlayers));

            aboveControl = maxPlayersLabel;

            m_maxPlayersSlider = new MyGuiControlSlider(
                position: aboveControl.Position + new Vector2(0f, aboveControl.Size.Y),
                width: 0.15f,
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                minValue: 2,
                maxValue: MyMultiplayer.Static != null ? MyMultiplayer.Static.MaxPlayers : 16,
                labelText: new StringBuilder("{0}").ToString(),
                labelDecimalPlaces: 0,
                labelSpaceWidth: 0.02f,
                defaultValue: Sync.IsServer ? MySession.Static.MaxPlayers : MyMultiplayer.Static.MemberLimit,
                intValue: true);
            m_maxPlayersSlider.ValueChanged = MaxPlayersSlider_Changed;
            aboveControl = m_maxPlayersSlider;

            var playerBlockLimitLabel = new MyGuiControlLabel(
                position: aboveControl.Position + new Vector2(0f, aboveControl.Size.Y + 0.05f),
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                text: MyTexts.GetString(MyCommonTexts.PlayerMaxBlocks));

            aboveControl = playerBlockLimitLabel;

            m_playerBlockLimitTextbox = new MyGuiControlTextbox(
                position: aboveControl.Position + new Vector2(0.09f, aboveControl.Size.Y + verticalSpacing + 0.02f),
                maxLength: 6,
                type: MyGuiControlTextboxType.DigitsOnly);
            aboveControl = m_playerBlockLimitTextbox;

            m_playerBlockLimitTextbox.Size = new Vector2(0.18f, m_playerBlockLimitTextbox.Size.Y);

            m_confirmLimitChangeButton = new MyGuiControlButton(
                position: new Vector2(topLeft.X, aboveControl.Position.Y + aboveControl.Size.Y + verticalSpacing),
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                text: MyTexts.Get(MyCommonTexts.ScreenMenuButtonSave));

            m_playersTable = new MyGuiControlTable()
            {
                Position         = new Vector2(-m_inviteButton.Position.X, m_inviteButton.Position.Y),
                Size             = new Vector2(1200f / MyGuiConstants.GUI_OPTIMAL_SIZE.X, 1f) - m_inviteButton.Size * 1.05f,
                VisibleRowsCount = 21,
                OriginAlign      = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP,
                ColumnsCount     = 5,
            };
            float PlayerNameWidth  = 0.3f;
            float FactionTagWidth  = 0.12f;
            float FactionNameWidth = MyPerGameSettings.EnableMutePlayer ? 0.3f : 0.34f;
            float MutedWidth       = MyPerGameSettings.EnableMutePlayer ? 0.13f : 0;

            m_playersTable.SetCustomColumnWidths(new float[] { PlayerNameWidth, FactionTagWidth, FactionNameWidth, MutedWidth, 1 - PlayerNameWidth - FactionTagWidth - FactionNameWidth - MutedWidth });
            m_playersTable.SetColumnName(PlayerNameColumn, MyTexts.Get(MyCommonTexts.ScreenPlayers_PlayerName));
            m_playersTable.SetColumnName(PlayerFactionTagColumn, MyTexts.Get(MyCommonTexts.ScreenPlayers_FactionTag));
            m_playersTable.SetColumnName(PlayerFactionNameColumn, MyTexts.Get(MyCommonTexts.ScreenPlayers_FactionName));
            m_playersTable.SetColumnName(PlayerMutedColumn, new StringBuilder(MyTexts.GetString(MyCommonTexts.ScreenPlayers_Muted)));
            m_playersTable.SetColumnName(GameAdminColumn, MyTexts.Get(MyCommonTexts.ScreenPlayers_GameAdmin));
            m_playersTable.SetColumnComparison(0, (a, b) => (a.Text.CompareToIgnoreCase(b.Text)));
            m_playersTable.ItemSelected += playersTable_ItemSelected;

            // CH: To show the clients correctly, we would need to know, whether the game is a dedicated-server-hosted game.
            // We don't know that, so I just show all clients with players
            foreach (var player in Sync.Players.GetOnlinePlayers())
            {
                if (player.Id.SerialId != 0)
                {
                    continue;
                }

                for (int i = 0; i < m_playersTable.RowsCount; ++i)
                {
                    var row = m_playersTable.GetRow(i);
                    if (row.UserData is ulong && (ulong)row.UserData == player.Id.SteamId)
                    {
                        continue;
                    }
                }

                AddPlayer(player.Id.SteamId);
            }

            m_inviteButton.ButtonClicked             += inviteButton_ButtonClicked;
            m_promoteButton.ButtonClicked            += promoteButton_ButtonClicked;
            m_demoteButton.ButtonClicked             += demoteButton_ButtonClicked;
            m_kickButton.ButtonClicked               += kickButton_ButtonClicked;
            m_banButton.ButtonClicked                += banButton_ButtonClicked;
            m_lobbyTypeCombo.ItemSelected            += lobbyTypeCombo_OnSelect;
            m_confirmLimitChangeButton.ButtonClicked += confirmLimitChange_ButtonClicked;

            Controls.Add(m_inviteButton);
            Controls.Add(m_promoteButton);
            Controls.Add(m_demoteButton);
            Controls.Add(m_kickButton);
            Controls.Add(m_banButton);
            Controls.Add(m_playersTable);
            Controls.Add(m_lobbyTypeCombo);
            Controls.Add(m_maxPlayersSlider);
            Controls.Add(maxPlayersLabel);
            if (MySession.Static.MaxBlocksPerPlayer > 0)
            {
                Controls.Add(m_playerBlockLimitTextbox);
                Controls.Add(m_confirmLimitChangeButton);
                Controls.Add(playerBlockLimitLabel);
            }

            UpdateButtonsEnabledState();
        }