diff --git a/Subsurface/Source/GUI/LoadingScreen.cs b/Subsurface/Source/GUI/LoadingScreen.cs index 5a05eb8c3..c01a2ec64 100644 --- a/Subsurface/Source/GUI/LoadingScreen.cs +++ b/Subsurface/Source/GUI/LoadingScreen.cs @@ -101,6 +101,7 @@ namespace Barotrauma if (Hull.renderer != null) { + Hull.renderer.ScrollWater(deltaTime); Hull.renderer.RenderBack(spriteBatch, renderTarget, 0.0f); } @@ -134,13 +135,13 @@ namespace Barotrauma } - public void Update() + /*public void Update() { if (Hull.renderer != null) { Hull.renderer.ScrollWater(); } - } + }*/ bool drawn; public IEnumerable DoLoading(IEnumerable loader) diff --git a/Subsurface/Source/GameMain.cs b/Subsurface/Source/GameMain.cs index be3d99187..19aa4fa31 100644 --- a/Subsurface/Source/GameMain.cs +++ b/Subsurface/Source/GameMain.cs @@ -126,6 +126,7 @@ namespace Barotrauma graphicsWidth = Config.GraphicsWidth; graphicsHeight = Config.GraphicsHeight; + Graphics.SynchronizeWithVerticalRetrace = Config.VSyncEnabled; Graphics.HardwareModeSwitch = Config.WindowMode != WindowMode.BorderlessWindowed; @@ -310,7 +311,7 @@ namespace Barotrauma if (titleScreenOpen) { - TitleScreen.Update(); + //TitleScreen.Update(); } else if (hasLoaded) { diff --git a/Subsurface/Source/GameSettings.cs b/Subsurface/Source/GameSettings.cs index 3a2caff9a..26622489d 100644 --- a/Subsurface/Source/GameSettings.cs +++ b/Subsurface/Source/GameSettings.cs @@ -46,6 +46,8 @@ namespace Barotrauma public int GraphicsWidth { get; set; } public int GraphicsHeight { get; set; } + public bool VSyncEnabled { get; set; } + //public bool FullScreenEnabled { get; set; } public WindowMode WindowMode @@ -128,6 +130,7 @@ namespace Barotrauma XElement graphicsMode = doc.Root.Element("graphicsmode"); GraphicsWidth = ToolBox.GetAttributeInt(graphicsMode, "width", 0); GraphicsHeight = ToolBox.GetAttributeInt(graphicsMode, "height", 0); + VSyncEnabled = ToolBox.GetAttributeBool(graphicsMode, "vsync", true); if (GraphicsWidth==0 || GraphicsHeight==0) { @@ -255,6 +258,7 @@ namespace Barotrauma gMode.ReplaceAttributes( new XAttribute("width", GraphicsWidth), new XAttribute("height", GraphicsHeight), + new XAttribute("vsync", VSyncEnabled), new XAttribute("displaymode", windowMode)); } @@ -362,6 +366,20 @@ namespace Barotrauma y += 70; + GUITickBox vsyncTickBox = new GUITickBox(new Rectangle(0, y, 20, 20), "Enable vertical sync",Alignment.CenterY | Alignment.Left,settingsFrame); + vsyncTickBox.OnSelected = (GUITickBox box) => + { + VSyncEnabled = !VSyncEnabled; + GameMain.Graphics.SynchronizeWithVerticalRetrace = VSyncEnabled; + GameMain.Graphics.ApplyChanges(); + UnsavedSettings = true; + + return true; + }; + vsyncTickBox.Selected = VSyncEnabled; + + y += 70; + new GUITextBlock(new Rectangle(0, y, 100, 20), "Sound volume:", GUI.Style, settingsFrame); GUIScrollBar soundScrollBar = new GUIScrollBar(new Rectangle(0, y+20, 150, 20), GUI.Style,0.1f, settingsFrame); soundScrollBar.BarScroll = SoundVolume; diff --git a/Subsurface/Source/Map/Levels/WaterRenderer.cs b/Subsurface/Source/Map/Levels/WaterRenderer.cs index 4a295cea5..7b93a6885 100644 --- a/Subsurface/Source/Map/Levels/WaterRenderer.cs +++ b/Subsurface/Source/Map/Levels/WaterRenderer.cs @@ -74,10 +74,10 @@ namespace Barotrauma spriteBatch.End(); } - public void ScrollWater() + public void ScrollWater(float deltaTime) { - wavePos.X += 0.0001f; - wavePos.Y += 0.0001f; + wavePos.X += 0.006f*deltaTime; + wavePos.Y += 0.006f*deltaTime; } public void Render(GraphicsDevice graphicsDevice, Camera cam, RenderTarget2D texture, Matrix transform) diff --git a/Subsurface/Source/Screens/GameScreen.cs b/Subsurface/Source/Screens/GameScreen.cs index c2f72688f..80d154e9f 100644 --- a/Subsurface/Source/Screens/GameScreen.cs +++ b/Subsurface/Source/Screens/GameScreen.cs @@ -83,11 +83,6 @@ namespace Barotrauma /// Provides a snapshot of timing values. public override void Update(double deltaTime) { - if (Hull.renderer != null) - { - Hull.renderer.ScrollWater(); - } - //the accumulator code is based on this article: //http://gafferongames.com/game-physics/fix-your-timestep/ Physics.accumulator += deltaTime; @@ -173,8 +168,12 @@ namespace Barotrauma public override void Draw(double deltaTime, GraphicsDevice graphics, SpriteBatch spriteBatch) { - cam.UpdateTransform(true); - + cam.UpdateTransform(true); + + if (Hull.renderer != null) + { + Hull.renderer.ScrollWater((float)deltaTime); + } DrawMap(graphics, spriteBatch); spriteBatch.Begin(); diff --git a/Subsurface/Source/Screens/MainMenuScreen.cs b/Subsurface/Source/Screens/MainMenuScreen.cs index e71552bc0..3548b360b 100644 --- a/Subsurface/Source/Screens/MainMenuScreen.cs +++ b/Subsurface/Source/Screens/MainMenuScreen.cs @@ -490,7 +490,7 @@ namespace Barotrauma public override void Update(double deltaTime) { - GameMain.TitleScreen.Update(); + //GameMain.TitleScreen.Update(); foreach (GUIButton button in menuButtons) { diff --git a/Subsurface/Source/Screens/ServerListScreen.cs b/Subsurface/Source/Screens/ServerListScreen.cs index afb89fee0..7bfce1543 100644 --- a/Subsurface/Source/Screens/ServerListScreen.cs +++ b/Subsurface/Source/Screens/ServerListScreen.cs @@ -336,7 +336,7 @@ namespace Barotrauma public override void Update(double deltaTime) { - GameMain.TitleScreen.Update(); + //GameMain.TitleScreen.Update(); menu.Update((float)deltaTime); diff --git a/Subsurface/config.xml b/Subsurface/config.xml index 32c3373d6..b59175f88 100644 --- a/Subsurface/config.xml +++ b/Subsurface/config.xml @@ -1,6 +1,6 @@  - + \ No newline at end of file