diff --git a/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs index bb21e39767..e563ae6dc7 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs @@ -29,6 +29,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic static readonly WindowMode OriginalGraphicsMode; static readonly int2 OriginalGraphicsWindowedSize; static readonly int2 OriginalGraphicsFullscreenSize; + static readonly GLProfile OriginalGLProfile; static readonly bool OriginalServerDiscoverNatDevices; readonly Dictionary leavePanelActions = new Dictionary(); @@ -57,6 +58,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic OriginalVideoDisplay = original.Graphics.VideoDisplay; OriginalGraphicsWindowedSize = original.Graphics.WindowedSize; OriginalGraphicsFullscreenSize = original.Graphics.FullscreenSize; + OriginalGLProfile = original.Graphics.GLProfile; OriginalServerDiscoverNatDevices = original.Server.DiscoverNatDevices; } @@ -98,6 +100,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic current.Graphics.VideoDisplay != OriginalVideoDisplay || current.Graphics.WindowedSize != OriginalGraphicsWindowedSize || current.Graphics.FullscreenSize != OriginalGraphicsFullscreenSize || + current.Graphics.GLProfile != OriginalGLProfile || current.Server.DiscoverNatDevices != OriginalServerDiscoverNatDevices) { Action restart = () => @@ -253,16 +256,18 @@ namespace OpenRA.Mods.Common.Widgets.Logic windowModeDropdown.GetText = () => ds.Mode == WindowMode.Windowed ? "Windowed" : ds.Mode == WindowMode.Fullscreen ? "Fullscreen (Legacy)" : "Fullscreen"; - var modeChangesDesc = panel.Get("MODE_CHANGES_DESC"); - modeChangesDesc.IsVisible = () => ds.Mode != WindowMode.Windowed && (ds.Mode != OriginalGraphicsMode || - ds.VideoDisplay != OriginalVideoDisplay); - var displaySelectionDropDown = panel.Get("DISPLAY_SELECTION_DROPDOWN"); displaySelectionDropDown.OnMouseDown = _ => ShowDisplaySelectionDropdown(displaySelectionDropDown, ds); var displaySelectionLabel = new CachedTransform(i => "Display {0}".F(i + 1)); displaySelectionDropDown.GetText = () => displaySelectionLabel.Update(ds.VideoDisplay); displaySelectionDropDown.IsDisabled = () => Game.Renderer.DisplayCount < 2; + var glProfileLabel = new CachedTransform(p => p.ToString()); + var glProfileDropdown = panel.Get("GL_PROFILE_DROPDOWN"); + glProfileDropdown.OnMouseDown = _ => ShowGLProfileDropdown(glProfileDropdown, ds); + glProfileDropdown.GetText = () => glProfileLabel.Update(ds.GLProfile); + glProfileDropdown.IsDisabled = () => Game.Renderer.SupportedGLProfiles.Length < 2; + var statusBarsDropDown = panel.Get("STATUS_BAR_DROPDOWN"); statusBarsDropDown.OnMouseDown = _ => ShowStatusBarsDropdown(statusBarsDropDown, gs); statusBarsDropDown.GetText = () => gs.StatusBars == StatusBarsType.Standard ? @@ -307,10 +312,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic var windowHeight = panel.Get("WINDOW_HEIGHT"); var origHeightText = windowHeight.Text = ds.WindowedSize.Y.ToString(); + windowHeight.Text = ds.WindowedSize.Y.ToString(); - var windowChangesDesc = panel.Get("WINDOW_CHANGES_DESC"); - windowChangesDesc.IsVisible = () => ds.Mode == WindowMode.Windowed && - (ds.Mode != OriginalGraphicsMode || origWidthText != windowWidth.Text || origHeightText != windowHeight.Text); + var restartDesc = panel.Get("RESTART_REQUIRED_DESC"); + restartDesc.IsVisible = () => ds.Mode != OriginalGraphicsMode || ds.VideoDisplay != OriginalVideoDisplay || ds.GLProfile != OriginalGLProfile || + (ds.Mode == WindowMode.Windowed && (origWidthText != windowWidth.Text || origHeightText != windowHeight.Text)); var frameLimitCheckbox = panel.Get("FRAME_LIMIT_CHECKBOX"); var frameLimitOrigLabel = frameLimitCheckbox.Text; @@ -380,6 +386,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic ds.CapFramerate = dds.CapFramerate; ds.MaxFramerate = dds.MaxFramerate; ds.Language = dds.Language; + ds.GLProfile = dds.GLProfile; ds.Mode = dds.Mode; ds.VideoDisplay = dds.VideoDisplay; ds.WindowedSize = dds.WindowedSize; @@ -872,6 +879,22 @@ namespace OpenRA.Mods.Common.Widgets.Logic dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, Enumerable.Range(0, Game.Renderer.DisplayCount), setupItem); } + static void ShowGLProfileDropdown(DropDownButtonWidget dropdown, GraphicSettings s) + { + Func setupItem = (o, itemTemplate) => + { + var item = ScrollItemWidget.Setup(itemTemplate, + () => s.GLProfile == o, + () => s.GLProfile = o); + + var label = o.ToString(); + item.Get("LABEL").GetText = () => label; + return item; + }; + + dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 500, Game.Renderer.SupportedGLProfiles, setupItem); + } + static void ShowTargetLinesDropdown(DropDownButtonWidget dropdown, GameSettings s) { var options = new Dictionary() diff --git a/mods/cnc/chrome/settings.yaml b/mods/cnc/chrome/settings.yaml index 4b938dd832..9d89f9d42b 100644 --- a/mods/cnc/chrome/settings.yaml +++ b/mods/cnc/chrome/settings.yaml @@ -228,13 +228,6 @@ Container@SETTINGS_PANEL: Height: 25 MaxLength: 5 Type: Integer - Label@WINDOW_CHANGES_DESC: - X: 60 - Y: 27 - Width: 200 - Height: 15 - Font: Tiny - Text: Video mode and window size changes require restart Container@DISPLAY_SELECTION: Y: 240 Children: @@ -249,13 +242,6 @@ Container@SETTINGS_PANEL: Width: 160 Height: 25 Font: Regular - Label@MODE_CHANGES_DESC: - X: 60 - Y: 27 - Width: 200 - Height: 15 - Font: Tiny - Text: Video mode and display changes require restart Checkbox@VSYNC_CHECKBOX: X: 310 Y: 210 @@ -278,6 +264,27 @@ Container@SETTINGS_PANEL: Ticks: 20 MinimumValue: 50 MaximumValue: 240 + Label@GL_PROFILE: + X: 15 + Y: 270 + Width: 120 + Height: 25 + Align: Right + Text: OpenGL Profile: + DropDownButton@GL_PROFILE_DROPDOWN: + X: 140 + Y: 270 + Width: 160 + Height: 25 + Font: Regular + Label@RESTART_REQUIRED_DESC: + X: 300 + Y: PARENT_BOTTOM + 10 + Width: PARENT_RIGHT - 300 + Height: 15 + Font: TinyBold + Text: Display and OpenGL changes require restart + Align: Center Container@AUDIO_PANEL: Width: PARENT_RIGHT Height: PARENT_BOTTOM diff --git a/mods/common/chrome/settings.yaml b/mods/common/chrome/settings.yaml index 324071a4a8..46f87be14f 100644 --- a/mods/common/chrome/settings.yaml +++ b/mods/common/chrome/settings.yaml @@ -91,7 +91,7 @@ Background@SETTINGS_PANEL: X: 5 Y: 50 Width: PARENT_RIGHT - 10 - Height: PARENT_BOTTOM + Height: PARENT_BOTTOM - 50 Children: Label@PLAYER: Text: Player Name: @@ -249,13 +249,6 @@ Background@SETTINGS_PANEL: Height: 25 MaxLength: 5 Type: Integer - Label@WINDOW_CHANGES_DESC: - X: 60 - Y: 27 - Width: 200 - Height: 15 - Font: Tiny - Text: Video mode and window size changes require restart Container@DISPLAY_SELECTION: Y: 240 Children: @@ -271,13 +264,6 @@ Background@SETTINGS_PANEL: Height: 25 Font: Regular Text: Standard - Label@MODE_CHANGES_DESC: - X: 60 - Y: 27 - Width: 200 - Height: 15 - Font: Tiny - Text: Video mode and display changes require restart Checkbox@FRAME_LIMIT_CHECKBOX: X: 310 Y: 243 @@ -293,6 +279,26 @@ Background@SETTINGS_PANEL: Ticks: 20 MinimumValue: 50 MaximumValue: 240 + Label@GL_PROFILE: + X: 15 + Y: 270 + Width: 120 + Height: 25 + Align: Right + Text: OpenGL Profile: + DropDownButton@GL_PROFILE_DROPDOWN: + X: 140 + Y: 270 + Width: 160 + Height: 25 + Font: Regular + Label@RESTART_REQUIRED_DESC: + Y: PARENT_BOTTOM - 40 + Width: PARENT_RIGHT + Height: 15 + Font: Tiny + Text: Display and OpenGL changes require restart + Align: Center Container@AUDIO_PANEL: X: 5 Y: 50