diff --git a/osu.Game/Overlays/Settings/Sections/Graphics/LayoutSettings.cs b/osu.Game/Overlays/Settings/Sections/Graphics/LayoutSettings.cs index 1f87a635de..b3a2243ca3 100644 --- a/osu.Game/Overlays/Settings/Sections/Graphics/LayoutSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Graphics/LayoutSettings.cs @@ -1,10 +1,14 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; +using System.Collections.Generic; +using System.Linq; using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Platform; namespace osu.Game.Overlays.Settings.Sections.Graphics { @@ -16,20 +20,32 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics private Bindable letterboxing; + private OsuGame game; + private SettingsDropdown resolutionDropdown; + private SettingsEnumDropdown windowModeDropdown; + private const int transition_duration = 400; [BackgroundDependencyLoader] - private void load(FrameworkConfigManager config) + private void load(FrameworkConfigManager config, OsuGame game) { + this.game = game; + letterboxing = config.GetBindable(FrameworkSetting.Letterboxing); Children = new Drawable[] { - new SettingsEnumDropdown + windowModeDropdown = new SettingsEnumDropdown { LabelText = "Screen mode", Bindable = config.GetBindable(FrameworkSetting.WindowMode), }, + resolutionDropdown = new SettingsDropdown + { + LabelText = "Resolution", + Items = getResolutions(), + Bindable = config.GetBindable(FrameworkSetting.FullscreenResolution) + }, new SettingsCheckbox { LabelText = "Letterboxing", @@ -62,6 +78,15 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics }, }; + windowModeDropdown.Bindable.ValueChanged += (s) => + { + if (windowModeDropdown.Bindable.Value == WindowMode.Fullscreen) + resolutionDropdown.Show(); + else + resolutionDropdown.Hide(); + }; + windowModeDropdown.Bindable.TriggerChange(); + letterboxing.ValueChanged += isVisible => { letterboxSettings.ClearTransforms(); @@ -72,5 +97,12 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics }; letterboxing.TriggerChange(); } + + private IEnumerable> getResolutions() + { + var availableDisplayResolutions = (game.Window as DesktopGameWindow)?.AvailableDisplayResolutions; + + return (availableDisplayResolutions ?? throw new InvalidOperationException()).Select((t, i) => new KeyValuePair($"{t.Width}x{t.Height}@{t.RefreshRate}Hz", i)); + } } }