Added option to toggle vsync

For the ultimate PC master race experience.

Also calling water scroll on every frame with deltatime instead of being called at fixed intervals, making it look smoother as framerate increases.
This commit is contained in:
juanjp600
2016-09-18 18:17:15 -03:00
parent 5da2bc9523
commit c97f729fb3
8 changed files with 35 additions and 16 deletions
+18
View File
@@ -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;