Exemplo n.º 1
0
        public GameSettings.Settings GetNewSettings()
        {
            GameSettings.Settings toReturn = GameSettings.Default.Clone();
            // Copy all the states from widgets to game settings.
            // Gameplay settings
            toReturn.CameraScrollSpeed     = this.MoveSpeed.ScrollPosition;
            toReturn.CameraZoomSpeed       = this.ZoomSpeed.ScrollPosition;
            toReturn.EnableEdgeScroll      = this.EdgeScrolling.CheckState;
            toReturn.CameraFollowSurface   = this.FollowSurface.CheckState;
            toReturn.FogofWar              = this.FogOfWar.CheckState;
            toReturn.InvertZoom            = this.InvertZoom.CheckState;
            toReturn.ZoomCameraTowardMouse = this.ZoomTowardMouse.CheckState;
            toReturn.DisplayIntro          = this.PlayIntro.CheckState;
            toReturn.AutoSave              = this.Autosave.CheckState;
            toReturn.AutoSaveTimeMinutes   =
                (this.AutoSaveFrequency.GetChild(1) as HorizontalSlider).ScrollPosition + 5.0f;
            toReturn.SaveLocation = this.SaveLocation.Text;

            // Audio settings
            toReturn.MasterVolume      = this.MasterVolume.ScrollPosition;
            toReturn.SoundEffectVolume = this.SFXVolume.ScrollPosition;
            toReturn.MusicVolume       = this.MusicVolume.ScrollPosition;

            var newDisplayMode = DisplayModes[this.Resolution.SelectedItem];

            toReturn.ResolutionX = newDisplayMode.Width;
            toReturn.ResolutionY = newDisplayMode.Height;

            toReturn.Fullscreen        = this.Fullscreen.CheckState;
            toReturn.ChunkDrawDistance = this.ChunkDrawDistance.ScrollPosition + 1.0f;
            //toReturn.VertexCullDistance = this.VertexCullDistance.ScrollPosition + 0.1f;
            //toReturn.ChunkGenerateDistance = this.GenerateDistance.ScrollPosition + 1.0f;
            toReturn.EnableGlow              = this.Glow.CheckState;
            toReturn.AntiAliasing            = AntialiasingOptions[this.Antialiasing.SelectedItem];
            toReturn.DrawChunksReflected     = this.ReflectTerrain.CheckState;
            toReturn.DrawEntityReflected     = this.ReflectEntities.CheckState;
            toReturn.AmbientOcclusion        = this.AmbientOcclusion.CheckState;
            toReturn.CursorLightEnabled      = this.CursorLight.CheckState;
            toReturn.EntityLighting          = this.EntityLight.CheckState;
            toReturn.SelfIlluminationEnabled = this.SelfIllumination.CheckState;
            toReturn.ParticlePhysics         = this.ParticlePhysics.CheckState;
            toReturn.GrassMotes              = this.Motes.CheckState;
            //toReturn.NumMotes = (int)this.NumMotes.ScrollPosition + 100;

            toReturn.GuiScale     = GuiScale.SelectedIndex + 1;
            toReturn.GuiAutoScale = this.GuiAutoScale.CheckState;
            return(toReturn);
        }
Exemplo n.º 2
0
        public void ApplySettings(GameSettings.Settings settings)
        {
            // Graphics settings
            var preResolutionX = StateManager.Game.Graphics.PreferredBackBufferWidth;
            var preResolutionY = StateManager.Game.Graphics.PreferredBackBufferHeight;
            var preFullscreen  = GameSettings.Default.Fullscreen;
            var preGuiScale    = GameSettings.Default.GuiScale;
            var preVsync       = GameSettings.Default.VSync;

            GameSettings.Default = settings.Clone();

            GameSettings.Default.ResolutionX = settings.ResolutionX;
            GameSettings.Default.ResolutionY = settings.ResolutionY;

            GameSettings.Default.Fullscreen        = this.Fullscreen.CheckState;
            GameSettings.Default.ChunkDrawDistance = this.ChunkDrawDistance.ScrollPosition + 1.0f;
            //GameSettings.Default.VertexCullDistance = this.VertexCullDistance.ScrollPosition + 0.1f;
            //GameSettings.Default.ChunkGenerateDistance = this.GenerateDistance.ScrollPosition + 1.0f;
            GameSettings.Default.EnableGlow          = this.Glow.CheckState;
            GameSettings.Default.AntiAliasing        = AntialiasingOptions[this.Antialiasing.SelectedItem];
            GameSettings.Default.DrawChunksReflected = this.ReflectTerrain.CheckState;
            GameSettings.Default.DrawEntityReflected = this.ReflectEntities.CheckState;
            //GameSettings.Default.CalculateSunlight = this.Sunlight.CheckState;
            GameSettings.Default.AmbientOcclusion = this.AmbientOcclusion.CheckState;
            //GameSettings.Default.CalculateRamps = this.Ramps.CheckState;
            GameSettings.Default.CursorLightEnabled      = this.CursorLight.CheckState;
            GameSettings.Default.EntityLighting          = this.EntityLight.CheckState;
            GameSettings.Default.SelfIlluminationEnabled = this.SelfIllumination.CheckState;
            GameSettings.Default.ParticlePhysics         = this.ParticlePhysics.CheckState;
            GameSettings.Default.GrassMotes = this.Motes.CheckState;
            GameSettings.Default.VSync      = this.VSync.CheckState;
            //GameSettings.Default.NumMotes = (int)this.NumMotes.ScrollPosition + 100;
            //GameSettings.Default.UseLightmaps = this.LightMap.CheckState;
            //GameSettings.Default.UseDynamicShadows = this.DynamicShadows.CheckState;
            GameSettings.Default.TutorialDisabledGlobally = this.DisableTutorialForAllGames.CheckState;
            GameSettings.Default.SaveLocation             = settings.SaveLocation;

            GameSettings.Default.GuiScale = GuiScale.SelectedIndex + 1;

            if (preResolutionX != GameSettings.Default.ResolutionX ||
                preResolutionY != GameSettings.Default.ResolutionY ||
                preFullscreen != GameSettings.Default.Fullscreen ||
                preVsync != GameSettings.Default.VSync)
            {
                StateManager.Game.Graphics.PreferredBackBufferWidth  = GameSettings.Default.ResolutionX;
                StateManager.Game.Graphics.PreferredBackBufferHeight = GameSettings.Default.ResolutionY;
                StateManager.Game.Graphics.IsFullScreen = GameSettings.Default.Fullscreen;
                StateManager.Game.Graphics.SynchronizeWithVerticalRetrace = GameSettings.Default.VSync;
                try
                {
                    StateManager.Game.Graphics.ApplyChanges();
                }
                catch (NoSuitableGraphicsDeviceException)
                {
                    GameSettings.Default.ResolutionX = preResolutionX;
                    GameSettings.Default.ResolutionY = preResolutionY;
                    GameSettings.Default.Fullscreen  = preFullscreen;
                    SetBestResolution();
                    this.Fullscreen.CheckState = GameSettings.Default.Fullscreen;
                    GuiRoot.ShowModalPopup(new Gui.Widgets.Popup
                    {
                        Text                 = "Could not change display mode. Previous settings restored.",
                        TextSize             = 1,
                        PopupDestructionType = PopupDestructionType.DestroyOnOffClick
                    });
                }
            }

            if (preResolutionX != GameSettings.Default.ResolutionX ||
                preResolutionY != GameSettings.Default.ResolutionY ||
                preGuiScale != GameSettings.Default.GuiScale)
            {
                GuiRoot.RenderData.CalculateScreenSize();
                RebuildGui();
            }

            HasChanges = false;



            if (World != null && EnableTutorial != null)
            {
                World.TutorialManager.TutorialEnabled = EnableTutorial.CheckState;
            }

            GameSettings.Save();
        }