Exemplo n.º 1
0
        public static ChangeResult Apply(MyGraphicsSettings settings)
        {
            MySandboxGame.Log.WriteLine("MyVideoModeManager.Apply(MyGraphicsSettings1)");
            using (MySandboxGame.Log.IndentUsing())
            {
                MySandboxGame.Log.WriteLine("HardwareCursor: " + settings.HardwareCursor);
                MySandboxGame.Log.WriteLine("Field of view: " + settings.FieldOfView);
                MySandboxGame.Log.WriteLine("Render.InterpolationEnabled: " + settings.Render.InterpolationEnabled);
                MySandboxGame.Log.WriteLine("Render.MultithreadingEnabled: " + settings.Render.MultithreadingEnabled);
                MySandboxGame.Log.WriteLine("Render.AntialiasingMode: " + settings.Render.AntialiasingMode);
                MySandboxGame.Log.WriteLine("Render.ShadowQuality: " + settings.Render.ShadowQuality);
                MySandboxGame.Log.WriteLine("Render.TextureQuality: " + settings.Render.TextureQuality);
                MySandboxGame.Log.WriteLine("Render.AnisotropicFiltering: " + settings.Render.AnisotropicFiltering);
                MySandboxGame.Log.WriteLine("Render.FoliageDetails: " + settings.Render.FoliageDetails);

                if (m_currentGraphicsSettings.Equals(ref settings))
                {
                    return(ChangeResult.NothingChanged);
                }

                SetEnableDamageEffects(settings.EnableDamageEffects);
                SetFov(settings.FieldOfView);
                SetHardwareCursor(settings.HardwareCursor);

                if (!m_currentGraphicsSettings.Render.Equals(ref settings.Render))
                {
                    MyRenderProxy.SwitchRenderSettings(settings.Render);
                }
                m_currentGraphicsSettings = settings;
            }

            return(ChangeResult.Success);
        }
Exemplo n.º 2
0
        public static MyGraphicsSettings GetGraphicsSettingsFromConfig(ref MyPerformanceSettings defaults)
        {
            MyGraphicsSettings currentGraphicsSettings = CurrentGraphicsSettings;
            MyConfig           config = MySandboxGame.Config;

            currentGraphicsSettings.PerformanceSettings   = defaults;
            currentGraphicsSettings.GraphicsRenderer      = config.GraphicsRenderer;
            currentGraphicsSettings.FieldOfView           = config.FieldOfView;
            currentGraphicsSettings.PostProcessingEnabled = config.PostProcessingEnabled;
            currentGraphicsSettings.FlaresIntensity       = config.FlaresIntensity;
            if (config.EnableDamageEffects == null)
            {
                config.EnableDamageEffects = new bool?(defaults.EnableDamageEffects);
            }
            currentGraphicsSettings.PerformanceSettings.EnableDamageEffects = config.EnableDamageEffects.Value;
            float?vegetationDrawDistance = config.VegetationDrawDistance;

            currentGraphicsSettings.PerformanceSettings.RenderSettings.DistanceFade = (vegetationDrawDistance != null) ? vegetationDrawDistance.GetValueOrDefault() : defaults.RenderSettings.DistanceFade;
            vegetationDrawDistance = config.GrassDensityFactor;
            currentGraphicsSettings.PerformanceSettings.RenderSettings.GrassDensityFactor = (vegetationDrawDistance != null) ? vegetationDrawDistance.GetValueOrDefault() : defaults.RenderSettings.GrassDensityFactor;
            vegetationDrawDistance = config.GrassDrawDistance;
            currentGraphicsSettings.PerformanceSettings.RenderSettings.GrassDrawDistance = (vegetationDrawDistance != null) ? vegetationDrawDistance.GetValueOrDefault() : defaults.RenderSettings.GrassDrawDistance;
            MyAntialiasingMode?antialiasingMode = config.AntialiasingMode;

            currentGraphicsSettings.PerformanceSettings.RenderSettings.AntialiasingMode = (antialiasingMode != null) ? antialiasingMode.GetValueOrDefault() : defaults.RenderSettings.AntialiasingMode;
            MyShadowsQuality?shadowQuality = config.ShadowQuality;

            currentGraphicsSettings.PerformanceSettings.RenderSettings.ShadowQuality = (shadowQuality != null) ? shadowQuality.GetValueOrDefault() : defaults.RenderSettings.ShadowQuality;
            bool?ambientOcclusionEnabled = config.AmbientOcclusionEnabled;

            currentGraphicsSettings.PerformanceSettings.RenderSettings.AmbientOcclusionEnabled = (ambientOcclusionEnabled != null) ? ambientOcclusionEnabled.GetValueOrDefault() : defaults.RenderSettings.AmbientOcclusionEnabled;
            MyTextureQuality?textureQuality = config.TextureQuality;

            currentGraphicsSettings.PerformanceSettings.RenderSettings.TextureQuality = (textureQuality != null) ? textureQuality.GetValueOrDefault() : defaults.RenderSettings.TextureQuality;
            MyTextureAnisoFiltering?anisotropicFiltering = config.AnisotropicFiltering;

            currentGraphicsSettings.PerformanceSettings.RenderSettings.AnisotropicFiltering = (anisotropicFiltering != null) ? anisotropicFiltering.GetValueOrDefault() : defaults.RenderSettings.AnisotropicFiltering;
            MyRenderQualityEnum?modelQuality = config.ModelQuality;

            currentGraphicsSettings.PerformanceSettings.RenderSettings.ModelQuality = (modelQuality != null) ? modelQuality.GetValueOrDefault() : defaults.RenderSettings.ModelQuality;
            modelQuality = config.VoxelQuality;
            currentGraphicsSettings.PerformanceSettings.RenderSettings.VoxelQuality = (modelQuality != null) ? modelQuality.GetValueOrDefault() : defaults.RenderSettings.VoxelQuality;
            currentGraphicsSettings.PerformanceSettings.RenderSettings.HqDepth      = true;
            modelQuality = config.ShaderQuality;
            currentGraphicsSettings.PerformanceSettings.RenderSettings.VoxelShaderQuality = (modelQuality != null) ? modelQuality.GetValueOrDefault() : defaults.RenderSettings.VoxelShaderQuality;
            modelQuality = config.ShaderQuality;
            currentGraphicsSettings.PerformanceSettings.RenderSettings.AlphaMaskedShaderQuality = (modelQuality != null) ? modelQuality.GetValueOrDefault() : defaults.RenderSettings.AlphaMaskedShaderQuality;
            modelQuality = config.ShaderQuality;
            currentGraphicsSettings.PerformanceSettings.RenderSettings.AtmosphereShaderQuality = (modelQuality != null) ? modelQuality.GetValueOrDefault() : defaults.RenderSettings.AtmosphereShaderQuality;
            return(currentGraphicsSettings);
        }
Exemplo n.º 3
0
 public static ChangeResult Apply(MyGraphicsSettings settings)
 {
     MySandboxGame.Log.WriteLine("MyVideoModeManager.Apply(MyGraphicsSettings1)");
     using (MySandboxGame.Log.IndentUsing(LoggingOptions.NONE))
     {
         MySandboxGame.Log.WriteLine("Flares Intensity: " + settings.FlaresIntensity);
         MySandboxGame.Log.WriteLine("Field of view: " + settings.FieldOfView);
         MySandboxGame.Log.WriteLine("PostProcessingEnabled: " + settings.PostProcessingEnabled.ToString());
         MySandboxGame.Log.WriteLine("Render.GrassDensityFactor: " + settings.PerformanceSettings.RenderSettings.GrassDensityFactor);
         MySandboxGame.Log.WriteLine("Render.GrassDrawDistance: " + settings.PerformanceSettings.RenderSettings.GrassDrawDistance);
         MySandboxGame.Log.WriteLine("Render.DistanceFade: " + settings.PerformanceSettings.RenderSettings.DistanceFade);
         MySandboxGame.Log.WriteLine("Render.AntialiasingMode: " + settings.PerformanceSettings.RenderSettings.AntialiasingMode);
         MySandboxGame.Log.WriteLine("Render.ShadowQuality: " + settings.PerformanceSettings.RenderSettings.ShadowQuality);
         MySandboxGame.Log.WriteLine("Render.AmbientOcclusionEnabled: " + settings.PerformanceSettings.RenderSettings.AmbientOcclusionEnabled.ToString());
         MySandboxGame.Log.WriteLine("Render.TextureQuality: " + settings.PerformanceSettings.RenderSettings.TextureQuality);
         MySandboxGame.Log.WriteLine("Render.AnisotropicFiltering: " + settings.PerformanceSettings.RenderSettings.AnisotropicFiltering);
         MySandboxGame.Log.WriteLine("Render.VoxelShaderQuality: " + settings.PerformanceSettings.RenderSettings.VoxelShaderQuality);
         MySandboxGame.Log.WriteLine("Render.AlphaMaskedShaderQuality: " + settings.PerformanceSettings.RenderSettings.AlphaMaskedShaderQuality);
         MySandboxGame.Log.WriteLine("Render.AtmosphereShaderQuality: " + settings.PerformanceSettings.RenderSettings.AtmosphereShaderQuality);
         if (!m_currentGraphicsSettings.Equals(ref settings))
         {
             SetEnableDamageEffects(settings.PerformanceSettings.EnableDamageEffects);
             SetFov(settings.FieldOfView);
             SetPostProcessingEnabled(settings.PostProcessingEnabled);
             if (MyRenderProxy.Settings.FlaresIntensity != settings.FlaresIntensity)
             {
                 MyRenderProxy.Settings.FlaresIntensity = settings.FlaresIntensity;
                 MyRenderProxy.SetSettingsDirty();
             }
             if (!m_currentGraphicsSettings.PerformanceSettings.RenderSettings.Equals(ref settings.PerformanceSettings.RenderSettings))
             {
                 MyRenderProxy.SwitchRenderSettings(settings.PerformanceSettings.RenderSettings);
             }
             if (m_currentGraphicsSettings.PerformanceSettings.RenderSettings.VoxelQuality != settings.PerformanceSettings.RenderSettings.VoxelQuality)
             {
                 MyRenderComponentVoxelMap.SetLodQuality(settings.PerformanceSettings.RenderSettings.VoxelQuality);
             }
             m_currentGraphicsSettings = settings;
             MySector.Lodding.SelectQuality(settings.PerformanceSettings.RenderSettings.ModelQuality);
         }
         else
         {
             return(ChangeResult.NothingChanged);
         }
     }
     return(ChangeResult.Success);
 }
        private static ChangeResult Apply(MyGraphicsSettings settings)
        {
            MySandboxGame.Log.WriteLine("MyVideoModeManager.Apply(MyGraphicsSettings)");
            using (MySandboxGame.Log.IndentUsing())
            {
                MySandboxGame.Log.WriteLine("HardwareCursor: " + settings.HardwareCursor);
                MySandboxGame.Log.WriteLine("RenderQuality: " + (int)settings.RenderQuality);
                MySandboxGame.Log.WriteLine("RenderInterpolation: " + settings.RenderInterpolation);
                MySandboxGame.Log.WriteLine("Field of view: " + settings.FieldOfView);

                bool qualityChange             = MyRenderConstants.RenderQualityProfile.RenderQuality != settings.RenderQuality;
                bool fovChange                 = settings.FieldOfView != m_currentGraphicsSettings1.FieldOfView;
                bool hardwareCursorChange      = settings.HardwareCursor != m_currentGraphicsSettings1.HardwareCursor;
                bool enableDamageEffectsChange = settings.EnableDamageEffects != m_currentGraphicsSettings1.EnableDamageEffects;
                bool renderInterpolationChange = settings.RenderInterpolation != m_currentGraphicsSettings1.Render.InterpolationEnabled;

                {
                    bool somethingChanged = qualityChange || fovChange || hardwareCursorChange || renderInterpolationChange || enableDamageEffectsChange;
                    if (!somethingChanged)
                    {
                        return(ChangeResult.NothingChanged);
                    }
                }
                if (enableDamageEffectsChange)
                {
                    SetEnableDamageEffects(settings.EnableDamageEffects);
                }
                if (fovChange)
                {
                    SetFov(settings.FieldOfView);
                }

                if (hardwareCursorChange)
                {
                    SetHardwareCursor(settings.HardwareCursor);
                }

                if (qualityChange || renderInterpolationChange)
                {
                    m_currentGraphicsSettings1.Render.InterpolationEnabled = settings.RenderInterpolation;
                    MyRenderProxy.SwitchRenderSettings(settings.RenderQuality, settings.RenderInterpolation);
                }
            }

            return(ChangeResult.Success);
        }
Exemplo n.º 5
0
 public bool Equals(ref MyGraphicsSettings other) =>
 ((this.FieldOfView == other.FieldOfView) && ((this.PostProcessingEnabled == other.PostProcessingEnabled) && ((this.FlaresIntensity == other.FlaresIntensity) && ((this.GraphicsRenderer == other.GraphicsRenderer) && this.PerformanceSettings.Equals(other.PerformanceSettings)))));
Exemplo n.º 6
0
        public override bool Equals(object other)
        {
            MyGraphicsSettings settings = (MyGraphicsSettings)other;

            return(this.Equals(ref settings));
        }
Exemplo n.º 7
0
        public static ChangeResult ApplyVideoSettings(MyRenderDeviceSettings deviceSettings, MyGraphicsSettings graphicsSettings)
        {
            var res = Apply(deviceSettings);

            if (res == ChangeResult.Failed)
            {
                return(res);
            }

            var res2 = Apply(graphicsSettings);

            Debug.Assert(res2 != ChangeResult.Failed, "Changing graphics settings should never fail, only device settings can!");
            return(res == ChangeResult.Success ? res : res2);
        }
Exemplo n.º 8
0
        public static ChangeResult ApplyVideoSettings(MyRenderDeviceSettings deviceSettings, MyGraphicsSettings graphicsSettings)
        {
            ChangeResult result = Apply(deviceSettings);

            if (result == ChangeResult.Failed)
            {
                return(result);
            }
            ChangeResult result2 = Apply(graphicsSettings);

            return((result == ChangeResult.Success) ? result : result2);
        }