Borderless windowed mode, mid-round settings menu

This commit is contained in:
Regalis
2016-04-22 20:55:56 +03:00
parent 3347fcdd20
commit e84e72bba6
8 changed files with 111 additions and 41 deletions
+5
View File
@@ -14,6 +14,8 @@
<MonoGamePlatform>Windows</MonoGamePlatform> <MonoGamePlatform>Windows</MonoGamePlatform>
<MonoGameContentBuilderExe> <MonoGameContentBuilderExe>
</MonoGameContentBuilderExe> </MonoGameContentBuilderExe>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>x86</PlatformTarget>
@@ -24,6 +26,7 @@
<DefineConstants>DEBUG;TRACE;WINDOWS</DefineConstants> <DefineConstants>DEBUG;TRACE;WINDOWS</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>x86</PlatformTarget>
@@ -33,6 +36,7 @@
<DefineConstants>TRACE;WINDOWS</DefineConstants> <DefineConstants>TRACE;WINDOWS</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<ApplicationIcon>Icon.ico</ApplicationIcon> <ApplicationIcon>Icon.ico</ApplicationIcon>
@@ -68,6 +72,7 @@
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="app.config" />
<None Include="packages.config" /> <None Include="packages.config" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+24 -14
View File
@@ -31,7 +31,7 @@ namespace Launcher2
private List<DisplayMode> supportedModes; private List<DisplayMode> supportedModes;
private GUIDropDown resolutionDD, contentPackageDD; private GUIDropDown resolutionDD, contentPackageDD, displayModeDD;
private GUITextBlock updateInfoText; private GUITextBlock updateInfoText;
private GUIListBox updateInfoBox; private GUIListBox updateInfoBox;
@@ -40,11 +40,11 @@ namespace Launcher2
GUIButton launchButton; GUIButton launchButton;
public bool FullScreenEnabled //public bool FullScreenEnabled
{ //{
get { return settings.FullScreenEnabled; } // get { return settings.FullScreenEnabled; }
set { settings.FullScreenEnabled = value; } // set { settings.FullScreenEnabled = value; }
} //}
public bool AutoCheckUpdates public bool AutoCheckUpdates
{ {
@@ -160,9 +160,19 @@ namespace Launcher2
//new GUIButton(new Rectangle(x,y+120,150,20), "Package Manager", GUI.Style, guiRoot); //new GUIButton(new Rectangle(x,y+120,150,20), "Package Manager", GUI.Style, guiRoot);
var fullScreenTick = new GUITickBox(new Rectangle(x,y+150,20,20), "Fullscreen", Alignment.TopLeft, guiRoot); new GUITextBlock(new Rectangle(x, y + 130, 20, 20), "Display mode", GUI.Style, Alignment.TopLeft, Alignment.TopLeft, guiRoot);
fullScreenTick.OnSelected = ToggleFullScreen; displayModeDD = new GUIDropDown(new Rectangle(x, y + 150, 200, 20), "", GUI.Style, guiRoot);
fullScreenTick.Selected = settings.FullScreenEnabled; displayModeDD.AddItem("Fullscreen", WindowMode.Fullscreen);
displayModeDD.AddItem("Windowed", WindowMode.Windowed);
displayModeDD.AddItem("Borderless windowed", WindowMode.BorderlessWindowed);
displayModeDD.SelectItem(settings.WindowMode);
displayModeDD.OnSelected = (guiComponent) => { settings.WindowMode = (WindowMode)guiComponent.UserData; return true; };
//var fullScreenTick = new GUITickBox(new Rectangle(x,y+150,20,20), "Fullscreen", Alignment.TopLeft, guiRoot);
//fullScreenTick.OnSelected = ToggleFullScreen;
//fullScreenTick.Selected = settings.FullScreenEnabled;
if (settings.AutoCheckUpdates) if (settings.AutoCheckUpdates)
{ {
@@ -243,11 +253,11 @@ namespace Launcher2
return true; return true;
} }
private bool ToggleFullScreen(GUITickBox tickBox) //private bool ToggleFullScreen(GUITickBox tickBox)
{ //{
settings.FullScreenEnabled = !settings.FullScreenEnabled; // settings.FullScreenEnabled = !settings.FullScreenEnabled;
return true; // return true;
} //}
private bool LaunchClick(GUIButton button, object obj) private bool LaunchClick(GUIButton button, object obj)
{ {
+1 -1
View File
@@ -509,7 +509,7 @@ namespace Barotrauma
GameMain.Config.GraphicsWidth = 0; GameMain.Config.GraphicsWidth = 0;
GameMain.Config.GraphicsHeight = 0; GameMain.Config.GraphicsHeight = 0;
GameMain.Config.FullScreenEnabled = true; GameMain.Config.WindowMode = WindowMode.Fullscreen;
DebugConsole.NewMessage("Resolution set to 0 x 0 (screen resolution will be used)", Color.Green); DebugConsole.NewMessage("Resolution set to 0 x 0 (screen resolution will be used)", Color.Green);
DebugConsole.NewMessage("Fullscreen enabled", Color.Green); DebugConsole.NewMessage("Fullscreen enabled", Color.Green);
+27 -2
View File
@@ -40,7 +40,7 @@ namespace Barotrauma
private static Sound[] sounds; private static Sound[] sounds;
private static bool pauseMenuOpen; private static bool pauseMenuOpen, settingsMenuOpen;
private static GUIFrame pauseMenu; private static GUIFrame pauseMenu;
public static Color ScreenOverlayColor; public static Color ScreenOverlayColor;
@@ -77,6 +77,11 @@ namespace Barotrauma
get { return pauseMenuOpen; } get { return pauseMenuOpen; }
} }
public static bool SettingsMenuOpen
{
get { return settingsMenuOpen; }
}
public static void LoadContent(GraphicsDevice graphics, bool loadSounds = true) public static void LoadContent(GraphicsDevice graphics, bool loadSounds = true)
{ {
graphicsDevice = graphics; graphicsDevice = graphics;
@@ -110,6 +115,8 @@ namespace Barotrauma
{ {
if (Screen.Selected == GameMain.MainMenuScreen) return; if (Screen.Selected == GameMain.MainMenuScreen) return;
settingsMenuOpen = false;
TogglePauseMenu(null, null); TogglePauseMenu(null, null);
if (pauseMenuOpen) if (pauseMenuOpen)
@@ -120,6 +127,18 @@ namespace Barotrauma
var button = new GUIButton(new Rectangle(0, y, 0, 30), "Resume", Alignment.CenterX, Style, pauseMenu); var button = new GUIButton(new Rectangle(0, y, 0, 30), "Resume", Alignment.CenterX, Style, pauseMenu);
button.OnClicked = TogglePauseMenu; button.OnClicked = TogglePauseMenu;
y += 60;
button = new GUIButton(new Rectangle(0, y, 0, 30), "Settings", Alignment.CenterX, Style, pauseMenu);
button.OnClicked = (btn, userData) =>
{
TogglePauseMenu();
settingsMenuOpen = !settingsMenuOpen;
return true;
};
y += 60; y += 60;
if (Screen.Selected == GameMain.GameScreen && GameMain.GameSession != null) if (Screen.Selected == GameMain.GameScreen && GameMain.GameSession != null)
@@ -415,10 +434,16 @@ namespace Barotrauma
if (pauseMenuOpen) if (pauseMenuOpen)
{ {
pauseMenu.Update(1.0f); pauseMenu.Update(0.016f);
pauseMenu.Draw(spriteBatch); pauseMenu.Draw(spriteBatch);
} }
if (settingsMenuOpen)
{
GameMain.Config.SettingsFrame.Update(0.016f);
GameMain.Config.SettingsFrame.Draw(spriteBatch);
}
DebugConsole.Draw(spriteBatch); DebugConsole.Draw(spriteBatch);
if (GUIComponent.MouseOn != null && !string.IsNullOrWhiteSpace(GUIComponent.MouseOn.ToolTip)) GUIComponent.MouseOn.DrawToolTip(spriteBatch); if (GUIComponent.MouseOn != null && !string.IsNullOrWhiteSpace(GUIComponent.MouseOn.ToolTip)) GUIComponent.MouseOn.DrawToolTip(spriteBatch);
+1 -1
View File
@@ -162,7 +162,7 @@ namespace Barotrauma
{ {
for (int i = 0; i < children.Count; i++) for (int i = 0; i < children.Count; i++)
{ {
if (children[i].UserData != selection) continue; if (!children[i].UserData.Equals(selection)) continue;
Select(i, force); Select(i, force);
+4 -2
View File
@@ -121,7 +121,9 @@ namespace Barotrauma
graphicsWidth = Config.GraphicsWidth; graphicsWidth = Config.GraphicsWidth;
graphicsHeight = Config.GraphicsHeight; graphicsHeight = Config.GraphicsHeight;
Graphics.IsFullScreen = Config.FullScreenEnabled; Graphics.HardwareModeSwitch = Config.WindowMode != WindowMode.BorderlessWindowed;
Graphics.IsFullScreen = Config.WindowMode == WindowMode.Fullscreen || Config.WindowMode == WindowMode.BorderlessWindowed;
Graphics.PreferredBackBufferWidth = graphicsWidth; Graphics.PreferredBackBufferWidth = graphicsWidth;
Graphics.PreferredBackBufferHeight = graphicsHeight; Graphics.PreferredBackBufferHeight = graphicsHeight;
Content.RootDirectory = "Content"; Content.RootDirectory = "Content";
@@ -293,7 +295,7 @@ namespace Barotrauma
DebugConsole.Update(this, (float)deltaTime); DebugConsole.Update(this, (float)deltaTime);
paused = (DebugConsole.IsOpen || GUI.PauseMenuOpen) && paused = (DebugConsole.IsOpen || GUI.PauseMenuOpen || GUI.SettingsMenuOpen) &&
(NetworkMember == null || !NetworkMember.GameStarted); (NetworkMember == null || !NetworkMember.GameStarted);
if (!paused) Screen.Selected.Update(deltaTime); if (!paused) Screen.Selected.Update(deltaTime);
+6 -4
View File
@@ -257,7 +257,7 @@ namespace Barotrauma
{ {
if (Mission == null) if (Mission == null)
{ {
new GUITextBlock(new Rectangle(0,0,0,400), "No mission", GUI.Style, infoFrame, true); new GUITextBlock(new Rectangle(0,0,0,50), "No mission", GUI.Style, infoFrame, true);
return; return;
} }
@@ -274,12 +274,10 @@ namespace Barotrauma
TaskManager.Update(deltaTime); TaskManager.Update(deltaTime);
//guiRoot.Update(deltaTime); //guiRoot.Update(deltaTime);
infoButton.Update(deltaTime); infoButton.Update(deltaTime);
if (gameMode != null) gameMode.Update(deltaTime); if (gameMode != null) gameMode.Update(deltaTime);
if (Mission != null) Mission.Update(deltaTime); if (Mission != null) Mission.Update(deltaTime);
if (infoFrame != null) infoFrame.Update(deltaTime);
} }
public void Draw(SpriteBatch spriteBatch) public void Draw(SpriteBatch spriteBatch)
@@ -288,7 +286,11 @@ namespace Barotrauma
infoButton.Draw(spriteBatch); infoButton.Draw(spriteBatch);
if (gameMode != null) gameMode.Draw(spriteBatch); if (gameMode != null) gameMode.Draw(spriteBatch);
if (infoFrame != null) infoFrame.Draw(spriteBatch); if (infoFrame != null)
{
infoFrame.Update(0.016f);
infoFrame.Draw(spriteBatch);
}
} }
public void Save(string filePath) public void Save(string filePath)
+43 -17
View File
@@ -9,6 +9,11 @@ using System.Xml.Linq;
namespace Barotrauma namespace Barotrauma
{ {
public enum WindowMode
{
Windowed, Fullscreen, BorderlessWindowed
}
public class GameSettings public class GameSettings
{ {
private GUIFrame settingsFrame; private GUIFrame settingsFrame;
@@ -16,6 +21,8 @@ namespace Barotrauma
private float soundVolume, musicVolume; private float soundVolume, musicVolume;
private WindowMode windowMode;
private KeyOrMouse[] keyMapping; private KeyOrMouse[] keyMapping;
@@ -39,7 +46,13 @@ namespace Barotrauma
public int GraphicsWidth { get; set; } public int GraphicsWidth { get; set; }
public int GraphicsHeight { get; set; } public int GraphicsHeight { get; set; }
public bool FullScreenEnabled { get; set; } //public bool FullScreenEnabled { get; set; }
public WindowMode WindowMode
{
get { return windowMode; }
set { windowMode = value; }
}
public ContentPackage SelectedContentPackage { get; set; } public ContentPackage SelectedContentPackage { get; set; }
@@ -122,7 +135,10 @@ namespace Barotrauma
GraphicsHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height; GraphicsHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;
} }
FullScreenEnabled = ToolBox.GetAttributeBool(graphicsMode, "fullscreen", true); //FullScreenEnabled = ToolBox.GetAttributeBool(graphicsMode, "fullscreen", true);
var windowModeStr = ToolBox.GetAttributeString(graphicsMode, "displaymode", "Fullscreen");
if (Enum.TryParse<WindowMode>(windowModeStr, out windowMode));
MasterServerUrl = ToolBox.GetAttributeString(doc.Root, "masterserverurl", ""); MasterServerUrl = ToolBox.GetAttributeString(doc.Root, "masterserverurl", "");
@@ -218,14 +234,14 @@ namespace Barotrauma
if (GraphicsWidth==0 || GraphicsHeight==0) if (GraphicsWidth==0 || GraphicsHeight==0)
{ {
gMode.ReplaceAttributes(new XAttribute("fullscreen", FullScreenEnabled ? "true" : "false")); gMode.ReplaceAttributes(new XAttribute("displaymode", windowMode));
} }
else else
{ {
gMode.ReplaceAttributes( gMode.ReplaceAttributes(
new XAttribute("width", GraphicsWidth), new XAttribute("width", GraphicsWidth),
new XAttribute("height", GraphicsHeight), new XAttribute("height", GraphicsHeight),
new XAttribute("fullscreen", FullScreenEnabled ? "true" : "false")); new XAttribute("displaymode", windowMode));
} }
@@ -270,16 +286,16 @@ namespace Barotrauma
return true; return true;
} }
private bool ToggleFullScreen(object userData) //private bool ToggleFullScreen(object userData)
{ //{
UnsavedSettings = true; // UnsavedSettings = true;
FullScreenEnabled = !FullScreenEnabled; // FullScreenEnabled = !FullScreenEnabled;
GameMain.Graphics.IsFullScreen = FullScreenEnabled; // GameMain.Graphics.IsFullScreen = FullScreenEnabled;
GameMain.Graphics.ApplyChanges(); // GameMain.Graphics.ApplyChanges();
return true; // return true;
} //}
public void ResetSettingsFrame() public void ResetSettingsFrame()
{ {
@@ -316,11 +332,21 @@ namespace Barotrauma
y += 50; y += 50;
var fullScreenTick = new GUITickBox(new Rectangle(x, y, 20, 20), "Fullscreen", Alignment.TopLeft, settingsFrame); //var fullScreenTick = new GUITickBox(new Rectangle(x, y, 20, 20), "Fullscreen", Alignment.TopLeft, settingsFrame);
fullScreenTick.OnSelected = ToggleFullScreen; //fullScreenTick.OnSelected = ToggleFullScreen;
fullScreenTick.Selected = FullScreenEnabled; //fullScreenTick.Selected = FullScreenEnabled;
y += 50; new GUITextBlock(new Rectangle(x, y, 20, 20), "Display mode", GUI.Style, Alignment.TopLeft, Alignment.TopLeft, settingsFrame);
var displayModeDD = new GUIDropDown(new Rectangle(x, y + 20, 180, 20), "", GUI.Style, settingsFrame);
displayModeDD.AddItem("Fullscreen", WindowMode.Fullscreen);
displayModeDD.AddItem("Windowed", WindowMode.Windowed);
displayModeDD.AddItem("Borderless windowed", WindowMode.BorderlessWindowed);
displayModeDD.SelectItem(GameMain.Config.WindowMode);
displayModeDD.OnSelected = (guiComponent) => { GameMain.Config.WindowMode = (WindowMode)guiComponent.UserData; return true; };
y += 70;
new GUITextBlock(new Rectangle(0, y, 100, 20), "Sound volume:", GUI.Style, settingsFrame); 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); GUIScrollBar soundScrollBar = new GUIScrollBar(new Rectangle(0, y+20, 150, 20), GUI.Style,0.1f, settingsFrame);
@@ -409,7 +435,7 @@ namespace Barotrauma
while (keyBox.Selected && PlayerInput.GetKeyboardState.GetPressedKeys().Length==0 while (keyBox.Selected && PlayerInput.GetKeyboardState.GetPressedKeys().Length==0
&& !PlayerInput.LeftButtonClicked() && !PlayerInput.RightButtonClicked()) && !PlayerInput.LeftButtonClicked() && !PlayerInput.RightButtonClicked())
{ {
if (Screen.Selected != GameMain.MainMenuScreen) yield return CoroutineStatus.Success; if (Screen.Selected != GameMain.MainMenuScreen && !GUI.SettingsMenuOpen) yield return CoroutineStatus.Success;
yield return CoroutineStatus.Running; yield return CoroutineStatus.Running;
} }