From 66eff14d2b800dcfd3d18c41dab7023e02146d49 Mon Sep 17 00:00:00 2001 From: Daniel Power Date: Mon, 16 Dec 2024 01:17:35 -0330 Subject: [PATCH] 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 5ca08e0bba..74578205bf 100644 --- a/osu.Game.Tests/Visual/Settings/TestSceneTabletSettings.cs +++ b/osu.Game.Tests/Visual/Settings/TestSceneTabletSettings.cs @@ -134,6 +134,8 @@ namespace osu.Game.Tests.Visual.Settings 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 00ffbc1120..22e0bc99b9 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.Input.Handlers.Tablet; 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 @@ namespace osu.Game.Overlays.Settings.Sections.Input 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 @@ namespace osu.Game.Overlays.Settings.Sections.Input 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 @@ namespace osu.Game.Overlays.Settings.Sections.Input } [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 @@ namespace osu.Game.Overlays.Settings.Sections.Input 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 @@ namespace osu.Game.Overlays.Settings.Sections.Input 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 @@ namespace osu.Game.Overlays.Settings.Sections.Input 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;