From 72507b80c784d03d1a72a102e953f93d2c74e7cf Mon Sep 17 00:00:00 2001 From: Kawaritai <72053972+Kawaritai@users.noreply.github.com> Date: Wed, 12 Nov 2025 06:51:55 +1100 Subject: [PATCH] Add window sizes in dropdown menu options --- .../Sections/Graphics/LayoutSettings.cs | 52 +++++++++++++++++-- 1 file changed, 48 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/Settings/Sections/Graphics/LayoutSettings.cs b/osu.Game/Overlays/Settings/Sections/Graphics/LayoutSettings.cs index f40a4c941f..0028d21376 100644 --- a/osu.Game/Overlays/Settings/Sections/Graphics/LayoutSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Graphics/LayoutSettings.cs @@ -36,6 +36,8 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics private Bindable scalingMode = null!; private Bindable sizeFullscreen = null!; + private Bindable sizeWindowed = null!; + private readonly BindableWithCurrent currentResolution = new BindableWithCurrent(); private readonly BindableList resolutions = new BindableList(new[] { new Size(9999, 9999) }); private readonly IBindable fullscreenCapability = new Bindable(FullscreenCapability.Capable); @@ -70,6 +72,7 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics scalingMode = osuConfig.GetBindable(OsuSetting.Scaling); sizeFullscreen = config.GetBindable(FrameworkSetting.SizeFullscreen); + sizeWindowed = config.GetBindable(FrameworkSetting.WindowedSize); scalingSizeX = osuConfig.GetBindable(OsuSetting.ScalingSizeX); scalingSizeY = osuConfig.GetBindable(OsuSetting.ScalingSizeY); scalingPositionX = osuConfig.GetBindable(OsuSetting.ScalingPositionX); @@ -105,7 +108,7 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics LabelText = GraphicsSettingsStrings.Resolution, ShowsDefaultIndicator = false, ItemSource = resolutions, - Current = sizeFullscreen + Current = currentResolution }, minimiseOnFocusLossCheckbox = new SettingsCheckbox { @@ -196,6 +199,7 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics { updateDisplaySettingsVisibility(); updateScreenModeWarning(); + updateCurrentResolutionBinding(); }, true); currentDisplay.BindValueChanged(display => Schedule(() => @@ -206,15 +210,41 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics return; } + var buffer = new Bindable(currentResolution.Value); + currentResolution.Current = buffer; + resolutions.ReplaceRange(1, resolutions.Count - 1, display.NewValue.DisplayModes .Where(m => m.Size.Width >= 800 && m.Size.Height >= 600) .OrderByDescending(m => Math.Max(m.Size.Height, m.Size.Width)) .Select(m => m.Size) .Distinct()); + updateCurrentResolutionBinding(); + updateDisplaySettingsVisibility(); }), true); + sizeWindowed.BindValueChanged(size => + { + if (windowModeDropdown.Current.Value != WindowMode.Windowed) + return; + + if (window?.WindowState == Framework.Platform.WindowState.Normal && + size.NewValue == new Size(9999, 9999) + ) + { + window.WindowState = Framework.Platform.WindowState.Maximised; + return; + } + + if (window?.WindowState == Framework.Platform.WindowState.Maximised && + size.NewValue != new Size(9999, 9999) + ) + { + window.WindowState = Framework.Platform.WindowState.Normal; + } + }); + scalingMode.BindValueChanged(_ => { scalingSettings.ClearTransforms(); @@ -223,8 +253,6 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics updateScalingModeVisibility(); }); - - // initial update bypasses transforms updateScalingModeVisibility(); void updateScalingModeVisibility() @@ -248,6 +276,20 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics } } + private void updateCurrentResolutionBinding() + { + switch (windowModeDropdown.Current.Value) + { + case WindowMode.Fullscreen: + currentResolution.Current = sizeFullscreen; + break; + + case WindowMode.Windowed: + currentResolution.Current = sizeWindowed; + break; + } + } + private void onDisplaysChanged(IEnumerable displays) { Scheduler.AddOnce(d => @@ -260,7 +302,9 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics private void updateDisplaySettingsVisibility() { - resolutionDropdown.CanBeShown.Value = resolutions.Count > 1 && windowModeDropdown.Current.Value == WindowMode.Fullscreen; + resolutionDropdown.CanBeShown.Value = resolutions.Count > 1 + && (windowModeDropdown.Current.Value == WindowMode.Fullscreen || + windowModeDropdown.Current.Value == WindowMode.Windowed); displayDropdown.CanBeShown.Value = displayDropdown.Items.Count() > 1; minimiseOnFocusLossCheckbox.CanBeShown.Value = RuntimeInfo.IsDesktop && windowModeDropdown.Current.Value == WindowMode.Fullscreen; safeAreaConsiderationsCheckbox.CanBeShown.Value = host.Window?.SafeAreaPadding.Value.Total != Vector2.Zero;