(ded4a3e0a) v0.9.0.7
This commit is contained in:
@@ -186,46 +186,39 @@ namespace Barotrauma
|
||||
var rightColumn = new GUILayoutGroup(new RectTransform(new Vector2(0.46f, 0.95f), tabs[(int)Tab.Graphics].RectTransform, Anchor.TopRight)
|
||||
{ RelativeOffset = new Vector2(0.025f, 0.02f) })
|
||||
{ RelativeSpacing = 0.01f };
|
||||
|
||||
var supportedDisplayModes = new List<DisplayMode>();
|
||||
foreach (DisplayMode mode in GraphicsAdapter.DefaultAdapter.SupportedDisplayModes)
|
||||
{
|
||||
if (supportedDisplayModes.Any(m => m.Width == mode.Width && m.Height == mode.Height)) { continue; }
|
||||
#if OSX
|
||||
// Monogame currently doesn't support retina displays
|
||||
// so we need to disable resolutions above the viewport size.
|
||||
|
||||
// In a bundled .app you just disable HiDPI in the info.plist
|
||||
// but that's probably not gonna happen.
|
||||
if (mode.Width > GameMain.Instance.GraphicsDevice.DisplayMode.Width || mode.Height > GameMain.Instance.GraphicsDevice.DisplayMode.Height) { continue; }
|
||||
#endif
|
||||
supportedDisplayModes.Add(mode);
|
||||
}
|
||||
|
||||
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), leftColumn.RectTransform), TextManager.Get("Resolution"));
|
||||
var resolutionDD = new GUIDropDown(new RectTransform(new Vector2(1.0f, 0.05f), leftColumn.RectTransform), elementCount: supportedDisplayModes.Count)
|
||||
var resolutionDD = new GUIDropDown(new RectTransform(new Vector2(1.0f, 0.05f), leftColumn.RectTransform))
|
||||
{
|
||||
OnSelected = SelectResolution,
|
||||
#if !LINUX
|
||||
ButtonEnabled = GameMain.Config.WindowMode == WindowMode.Windowed
|
||||
#endif
|
||||
};
|
||||
|
||||
foreach (DisplayMode mode in supportedDisplayModes)
|
||||
{
|
||||
if (mode.Width < MinSupportedResolution.X || mode.Height < MinSupportedResolution.Y) { continue; }
|
||||
resolutionDD.AddItem(mode.Width + "x" + mode.Height, mode);
|
||||
if (GraphicsWidth == mode.Width && GraphicsHeight == mode.Height) resolutionDD.SelectItem(mode);
|
||||
}
|
||||
|
||||
if (resolutionDD.SelectedItemData == null)
|
||||
{
|
||||
resolutionDD.SelectItem(GraphicsAdapter.DefaultAdapter.SupportedDisplayModes.Last());
|
||||
}
|
||||
ButtonEnabled = GameMain.Config.WindowMode != WindowMode.BorderlessWindowed
|
||||
};
|
||||
|
||||
var supportedDisplayModes = UpdateResolutionDD(resolutionDD);
|
||||
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), leftColumn.RectTransform), TextManager.Get("DisplayMode"));
|
||||
var displayModeDD = new GUIDropDown(new RectTransform(new Vector2(1.0f, 0.05f), leftColumn.RectTransform));
|
||||
|
||||
displayModeDD.OnSelected = (guiComponent, obj) =>
|
||||
{
|
||||
UnsavedSettings = true;
|
||||
GameMain.Config.WindowMode = (WindowMode)guiComponent.UserData;
|
||||
supportedDisplayModes = UpdateResolutionDD(resolutionDD);
|
||||
resolutionDD.ButtonEnabled = GameMain.Config.WindowMode != WindowMode.BorderlessWindowed;
|
||||
GameMain.Instance.ApplyGraphicsSettings();
|
||||
if (GameMain.Config.WindowMode == WindowMode.BorderlessWindowed)
|
||||
{
|
||||
GraphicsWidth = GameMain.GraphicsWidth;
|
||||
GraphicsHeight = GameMain.GraphicsHeight;
|
||||
var displayMode = supportedDisplayModes.Find(m => m.Width == GameMain.GraphicsWidth && m.Height == GameMain.GraphicsHeight);
|
||||
if (displayMode != null)
|
||||
{
|
||||
resolutionDD.SelectItem(displayMode);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
displayModeDD.AddItem(TextManager.Get("Fullscreen"), WindowMode.Fullscreen);
|
||||
displayModeDD.AddItem(TextManager.Get("Windowed"), WindowMode.Windowed);
|
||||
#if (!OSX)
|
||||
@@ -242,15 +235,6 @@ namespace Barotrauma
|
||||
displayModeDD.SelectItem(GameMain.Config.WindowMode);
|
||||
}
|
||||
#endif
|
||||
displayModeDD.OnSelected = (guiComponent, obj) =>
|
||||
{
|
||||
UnsavedSettings = true;
|
||||
GameMain.Config.WindowMode = (WindowMode)guiComponent.UserData;
|
||||
#if !LINUX
|
||||
resolutionDD.ButtonEnabled = GameMain.Config.WindowMode == WindowMode.Windowed;
|
||||
#endif
|
||||
return true;
|
||||
};
|
||||
|
||||
GUITickBox vsyncTickBox = new GUITickBox(new RectTransform(tickBoxScale, leftColumn.RectTransform, scaleBasis: ScaleBasis.BothHeight), TextManager.Get("EnableVSync"))
|
||||
{
|
||||
@@ -811,6 +795,62 @@ namespace Barotrauma
|
||||
SelectTab(selectedTab);
|
||||
}
|
||||
|
||||
private List<DisplayMode> UpdateResolutionDD(GUIDropDown resolutionDD)
|
||||
{
|
||||
var supportedDisplayModes = new List<DisplayMode>();
|
||||
foreach (DisplayMode mode in GraphicsAdapter.DefaultAdapter.SupportedDisplayModes)
|
||||
{
|
||||
if (supportedDisplayModes.Any(m => m.Width == mode.Width && m.Height == mode.Height)) { continue; }
|
||||
#if OSX
|
||||
// Monogame currently doesn't support retina displays
|
||||
// so we need to disable resolutions above the viewport size.
|
||||
|
||||
// In a bundled .app you just disable HiDPI in the info.plist
|
||||
// but that's probably not gonna happen.
|
||||
if (mode.Width > GameMain.Instance.GraphicsDevice.DisplayMode.Width || mode.Height > GameMain.Instance.GraphicsDevice.DisplayMode.Height) { continue; }
|
||||
#endif
|
||||
supportedDisplayModes.Add(mode);
|
||||
}
|
||||
supportedDisplayModes.Sort((a, b) =>
|
||||
{
|
||||
if (a.Width < b.Width)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if (a.Width > b.Width)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (a.Height < b.Height)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if (a.Height > b.Height)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
|
||||
resolutionDD.ClearChildren();
|
||||
|
||||
foreach (DisplayMode mode in supportedDisplayModes)
|
||||
{
|
||||
if (mode.Width < MinSupportedResolution.X || mode.Height < MinSupportedResolution.Y) { continue; }
|
||||
resolutionDD.AddItem(mode.Width + "x" + mode.Height, mode);
|
||||
if (GraphicsWidth == mode.Width && GraphicsHeight == mode.Height) resolutionDD.SelectItem(mode);
|
||||
}
|
||||
|
||||
if (resolutionDD.SelectedItemData == null)
|
||||
{
|
||||
resolutionDD.SelectItem(GraphicsAdapter.DefaultAdapter.SupportedDisplayModes.Last());
|
||||
}
|
||||
|
||||
resolutionDD.ListBox.RectTransform.Resize(new Point(resolutionDD.Rect.Width, resolutionDD.Rect.Height * MathHelper.Clamp(supportedDisplayModes.Count, 2, 10)));
|
||||
|
||||
return supportedDisplayModes;
|
||||
}
|
||||
|
||||
private string TrimAudioDeviceName(string name)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(name)) { return string.Empty; }
|
||||
@@ -1024,12 +1064,12 @@ namespace Barotrauma
|
||||
|
||||
SettingsFrame.Flash(Color.Green);
|
||||
|
||||
if (GameMain.WindowMode != GameMain.Config.WindowMode)
|
||||
if (GameMain.WindowMode != GameMain.Config.WindowMode || GameMain.Config.GraphicsWidth != GameMain.GraphicsWidth || GameMain.Config.GraphicsHeight != GameMain.GraphicsHeight)
|
||||
{
|
||||
GameMain.Instance.ApplyGraphicsSettings();
|
||||
}
|
||||
|
||||
if (GameMain.GraphicsWidth != GameMain.Config.GraphicsWidth || GameMain.GraphicsHeight != GameMain.Config.GraphicsHeight)
|
||||
/*if (GameMain.GraphicsWidth != GameMain.Config.GraphicsWidth || GameMain.GraphicsHeight != GameMain.Config.GraphicsHeight)
|
||||
{
|
||||
#if OSX
|
||||
if (GameMain.Config.WindowMode != WindowMode.BorderlessWindowed)
|
||||
@@ -1039,7 +1079,7 @@ namespace Barotrauma
|
||||
#if OSX
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
private bool ApplyClicked(GUIButton button, object userData)
|
||||
|
||||
Reference in New Issue
Block a user