diff --git a/osu.Game.Tests/Visual/Settings/TestSceneTabletSettings.cs b/osu.Game.Tests/Visual/Settings/TestSceneTabletSettings.cs index 5ca08e0bbaa0..b94069aa7b55 100644 --- a/osu.Game.Tests/Visual/Settings/TestSceneTabletSettings.cs +++ b/osu.Game.Tests/Visual/Settings/TestSceneTabletSettings.cs @@ -134,6 +134,9 @@ public class TestTabletHandler : ITabletHandler public Bindable AreaOffset { get; } = new Bindable(); public Bindable AreaSize { get; } = new Bindable(); + public Bindable OutputAreaSize { get; } = new Bindable(); + public Bindable OutputAreaPosition { 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..db670a0939ea 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,8 @@ public partial class TabletSettings : SettingsSubsection private readonly Bindable areaOffset = new Bindable(); private readonly Bindable areaSize = 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 }; @@ -45,6 +48,12 @@ 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!; + private Bindable scalingPositionX = new Bindable(); + private Bindable scalingPositionY = new Bindable(); + [Resolved] private GameHost host { get; set; } @@ -76,8 +85,14 @@ 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); + scalingPositionX = osuConfig.GetBindable(OsuSetting.ScalingPositionX); + scalingPositionY = osuConfig.GetBindable(OsuSetting.ScalingPositionY); + Children = new Drawable[] { new SettingsCheckbox @@ -244,6 +259,9 @@ protected override void LoadComplete() sizeY.Value = val.NewValue.Y; }), true); + outputAreaSize.BindTo(tabletHandler.OutputAreaSize); + outputAreaPosition.BindTo(tabletHandler.OutputAreaPosition); + sizeX.BindValueChanged(val => { areaSize.Value = new Vector2(val.NewValue, areaSize.Value.Y); @@ -267,6 +285,13 @@ protected override void LoadComplete() aspectRatioApplication = Schedule(() => forceAspectRatio(aspect.NewValue)); }); + updateScaling(); + scalingMode.BindValueChanged(_ => updateScaling()); + scalingSizeX.BindValueChanged(_ => updateScaling()); + scalingSizeY.BindValueChanged(_ => updateScaling()); + scalingPositionX.BindValueChanged(_ => updateScaling()); + scalingPositionY.BindValueChanged(_ => updateScaling()); + tablet.BindTo(tabletHandler.Tablet); tablet.BindValueChanged(val => Schedule(() => { @@ -352,6 +377,20 @@ private void forceAspectRatio(float aspectRatio) aspectLock.Value = true; } + private void updateScaling() + { + if (scalingMode.Value == ScalingMode.Everything) + { + 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); + } + } + private void updateAspectRatio() => aspectRatio.Value = currentAspectRatio; private float currentAspectRatio => sizeX.Value / sizeY.Value;