From 66eff14d2b800dcfd3d18c41dab7023e02146d49 Mon Sep 17 00:00:00 2001 From: Daniel Power Date: Mon, 16 Dec 2024 01:17:35 -0330 Subject: [PATCH 1/4] Initial proof of concept for tablet output scaling --- .../Settings/TestSceneTabletSettings.cs | 2 ++ .../Settings/Sections/Input/TabletSettings.cs | 35 ++++++++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/Settings/TestSceneTabletSettings.cs b/osu.Game.Tests/Visual/Settings/TestSceneTabletSettings.cs index 5ca08e0bbaa0..74578205bfd4 100644 --- a/osu.Game.Tests/Visual/Settings/TestSceneTabletSettings.cs +++ b/osu.Game.Tests/Visual/Settings/TestSceneTabletSettings.cs @@ -134,6 +134,8 @@ public class TestTabletHandler : ITabletHandler public Bindable AreaOffset { get; } = new Bindable(); public Bindable AreaSize { get; } = new Bindable(); + public Bindable OutputSize { get; } = new Bindable(); + public Bindable Rotation { get; } = new Bindable(); public IBindable Tablet => tablet; diff --git a/osu.Game/Overlays/Settings/Sections/Input/TabletSettings.cs b/osu.Game/Overlays/Settings/Sections/Input/TabletSettings.cs index 00ffbc1120cd..22e0bc99b9f1 100644 --- a/osu.Game/Overlays/Settings/Sections/Input/TabletSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Input/TabletSettings.cs @@ -14,6 +14,7 @@ using osu.Framework.Localisation; using osu.Framework.Platform; using osu.Framework.Threading; +using osu.Game.Configuration; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; @@ -35,6 +36,7 @@ public partial class TabletSettings : SettingsSubsection private readonly Bindable areaOffset = new Bindable(); private readonly Bindable areaSize = new Bindable(); + private readonly Bindable outputSize = new Bindable(); private readonly IBindable tablet = new Bindable(); private readonly BindableNumber offsetX = new BindableNumber { MinValue = 0 }; @@ -45,6 +47,10 @@ public partial class TabletSettings : SettingsSubsection private readonly BindableNumber rotation = new BindableNumber { MinValue = 0, MaxValue = 360 }; + private Bindable scalingMode = null!; + private Bindable scalingSizeX = null!; + private Bindable scalingSizeY = null!; + [Resolved] private GameHost host { get; set; } @@ -76,8 +82,12 @@ public TabletSettings(ITabletHandler tabletHandler) } [BackgroundDependencyLoader] - private void load(OsuColour colours, LocalisationManager localisation) + private void load(OsuColour colours, LocalisationManager localisation, OsuConfigManager osuConfig) { + scalingMode = osuConfig.GetBindable(OsuSetting.Scaling); + scalingSizeX = osuConfig.GetBindable(OsuSetting.ScalingSizeX); + scalingSizeY = osuConfig.GetBindable(OsuSetting.ScalingSizeY); + Children = new Drawable[] { new SettingsCheckbox @@ -244,6 +254,8 @@ protected override void LoadComplete() sizeY.Value = val.NewValue.Y; }), true); + outputSize.BindTo(tabletHandler.OutputSize); + sizeX.BindValueChanged(val => { areaSize.Value = new Vector2(val.NewValue, areaSize.Value.Y); @@ -267,6 +279,11 @@ protected override void LoadComplete() aspectRatioApplication = Schedule(() => forceAspectRatio(aspect.NewValue)); }); + updateScaling(); + scalingSizeX.BindValueChanged(size => updateScaling()); + scalingSizeY.BindValueChanged(size => updateScaling()); + scalingMode.BindValueChanged(mode => updateScaling()); + tablet.BindTo(tabletHandler.Tablet); tablet.BindValueChanged(val => Schedule(() => { @@ -352,6 +369,22 @@ private void forceAspectRatio(float aspectRatio) aspectLock.Value = true; } + private void updateScaling() + { + switch (scalingMode.Value) + { + case ScalingMode.Everything: + outputSize.Value = new Vector2( + host.Window.ClientSize.Width * scalingSizeX.Value, + host.Window.ClientSize.Height * scalingSizeY.Value); + break; + + default: + outputSize.Value = new Vector2(host.Window.ClientSize.Width, host.Window.ClientSize.Height); + break; + } + } + private void updateAspectRatio() => aspectRatio.Value = currentAspectRatio; private float currentAspectRatio => sizeX.Value / sizeY.Value; From 4dd0672aa5a5dd0865497ceae68723e4a2f83b46 Mon Sep 17 00:00:00 2001 From: Daniel Power Date: Mon, 16 Dec 2024 21:04:08 -0330 Subject: [PATCH 2/4] Address screen scale positioning --- .../Settings/Sections/Input/TabletSettings.cs | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/osu.Game/Overlays/Settings/Sections/Input/TabletSettings.cs b/osu.Game/Overlays/Settings/Sections/Input/TabletSettings.cs index 22e0bc99b9f1..db670a0939ea 100644 --- a/osu.Game/Overlays/Settings/Sections/Input/TabletSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Input/TabletSettings.cs @@ -36,7 +36,8 @@ public partial class TabletSettings : SettingsSubsection private readonly Bindable areaOffset = new Bindable(); private readonly Bindable areaSize = new Bindable(); - private readonly Bindable outputSize = new Bindable(); + private readonly Bindable outputAreaSize = new Bindable(); + private readonly Bindable outputAreaPosition = new Bindable(); private readonly IBindable tablet = new Bindable(); private readonly BindableNumber offsetX = new BindableNumber { MinValue = 0 }; @@ -50,6 +51,8 @@ public partial class TabletSettings : SettingsSubsection private Bindable scalingMode = null!; private Bindable scalingSizeX = null!; private Bindable scalingSizeY = null!; + private Bindable scalingPositionX = new Bindable(); + private Bindable scalingPositionY = new Bindable(); [Resolved] private GameHost host { get; set; } @@ -87,6 +90,8 @@ private void load(OsuColour colours, LocalisationManager localisation, OsuConfig scalingMode = osuConfig.GetBindable(OsuSetting.Scaling); scalingSizeX = osuConfig.GetBindable(OsuSetting.ScalingSizeX); scalingSizeY = osuConfig.GetBindable(OsuSetting.ScalingSizeY); + scalingPositionX = osuConfig.GetBindable(OsuSetting.ScalingPositionX); + scalingPositionY = osuConfig.GetBindable(OsuSetting.ScalingPositionY); Children = new Drawable[] { @@ -254,7 +259,8 @@ protected override void LoadComplete() sizeY.Value = val.NewValue.Y; }), true); - outputSize.BindTo(tabletHandler.OutputSize); + outputAreaSize.BindTo(tabletHandler.OutputAreaSize); + outputAreaPosition.BindTo(tabletHandler.OutputAreaPosition); sizeX.BindValueChanged(val => { @@ -280,9 +286,11 @@ protected override void LoadComplete() }); updateScaling(); - scalingSizeX.BindValueChanged(size => updateScaling()); - scalingSizeY.BindValueChanged(size => updateScaling()); - scalingMode.BindValueChanged(mode => updateScaling()); + scalingMode.BindValueChanged(_ => updateScaling()); + scalingSizeX.BindValueChanged(_ => updateScaling()); + scalingSizeY.BindValueChanged(_ => updateScaling()); + scalingPositionX.BindValueChanged(_ => updateScaling()); + scalingPositionY.BindValueChanged(_ => updateScaling()); tablet.BindTo(tabletHandler.Tablet); tablet.BindValueChanged(val => Schedule(() => @@ -371,17 +379,15 @@ private void forceAspectRatio(float aspectRatio) private void updateScaling() { - switch (scalingMode.Value) + if (scalingMode.Value == ScalingMode.Everything) { - case ScalingMode.Everything: - outputSize.Value = new Vector2( - host.Window.ClientSize.Width * scalingSizeX.Value, - host.Window.ClientSize.Height * scalingSizeY.Value); - break; - - default: - outputSize.Value = new Vector2(host.Window.ClientSize.Width, host.Window.ClientSize.Height); - break; + outputAreaSize.Value = new Vector2(scalingSizeX.Value, scalingSizeY.Value); + outputAreaPosition.Value = new Vector2(scalingPositionX.Value, scalingPositionY.Value); + } + else + { + outputAreaSize.Value = new Vector2(1, 1); + outputAreaPosition.Value = new Vector2(0.5f, 0.5f); } } From 93ed0483b6a6ca70b988ed1d0623640d7a3b3559 Mon Sep 17 00:00:00 2001 From: Daniel Power Date: Mon, 16 Dec 2024 22:59:04 -0330 Subject: [PATCH 3/4] Fix TestSceneTabletSettings --- osu.Game.Tests/Visual/Settings/TestSceneTabletSettings.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/Settings/TestSceneTabletSettings.cs b/osu.Game.Tests/Visual/Settings/TestSceneTabletSettings.cs index 74578205bfd4..f44a08e03a64 100644 --- a/osu.Game.Tests/Visual/Settings/TestSceneTabletSettings.cs +++ b/osu.Game.Tests/Visual/Settings/TestSceneTabletSettings.cs @@ -134,7 +134,9 @@ public class TestTabletHandler : ITabletHandler public Bindable AreaOffset { get; } = new Bindable(); public Bindable AreaSize { get; } = new Bindable(); - public Bindable OutputSize { get; } = new Bindable(); + public Bindable OutputAreaSize { get; } = new Bindable(); + + public Bindable OutputAreaPosition { get; } = new Bindable(); public Bindable Rotation { get; } = new Bindable(); From fd504e5641c0fbd0fb46dd9d97ccf52e11c150e9 Mon Sep 17 00:00:00 2001 From: Daniel Power Date: Mon, 16 Dec 2024 23:17:22 -0330 Subject: [PATCH 4/4] Minor cleanup --- osu.Game.Tests/Visual/Settings/TestSceneTabletSettings.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game.Tests/Visual/Settings/TestSceneTabletSettings.cs b/osu.Game.Tests/Visual/Settings/TestSceneTabletSettings.cs index f44a08e03a64..b94069aa7b55 100644 --- a/osu.Game.Tests/Visual/Settings/TestSceneTabletSettings.cs +++ b/osu.Game.Tests/Visual/Settings/TestSceneTabletSettings.cs @@ -135,7 +135,6 @@ public class TestTabletHandler : ITabletHandler public Bindable AreaSize { get; } = new Bindable(); public Bindable OutputAreaSize { get; } = new Bindable(); - public Bindable OutputAreaPosition { get; } = new Bindable(); public Bindable Rotation { get; } = new Bindable();