1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-17 18:13:18 +08:00

Move application of scaling to tablet output area to scaling container

It's the safest place for it to be there, really.
This commit is contained in:
Bartłomiej Dach
2025-11-18 14:41:10 +01:00
Unverified
parent 9c2319b989
commit 80fbcd5fbd
2 changed files with 14 additions and 26 deletions
@@ -1,11 +1,13 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Input.Handlers.Tablet;
using osu.Framework.Layout;
using osu.Framework.Platform;
using osu.Framework.Screens;
@@ -50,6 +52,8 @@ namespace osu.Game.Graphics.Containers
private RectangleF? customRect;
private bool customRectIsRelativePosition;
private ITabletHandler? tabletHandler;
/// <summary>
/// Set a custom position and scale which overrides any user specification.
/// </summary>
@@ -123,7 +127,7 @@ namespace osu.Game.Graphics.Containers
}
[BackgroundDependencyLoader]
private void load(OsuConfigManager config, ISafeArea safeArea)
private void load(GameHost host, OsuConfigManager config, ISafeArea safeArea)
{
scalingMode = config.GetBindable<ScalingMode>(OsuSetting.Scaling);
scalingMode.ValueChanged += _ => Scheduler.AddOnce(updateSize);
@@ -148,6 +152,8 @@ namespace osu.Game.Graphics.Containers
scalingMenuBackgroundDim = config.GetBindable<float>(OsuSetting.ScalingBackgroundDim);
scalingMenuBackgroundDim.ValueChanged += _ => Scheduler.AddOnce(updateSize);
tabletHandler = host.AvailableInputHandlers.OfType<ITabletHandler>().SingleOrDefault();
}
protected override void LoadComplete()
@@ -222,6 +228,13 @@ namespace osu.Game.Graphics.Containers
// An example of how this can occur is when the skin editor is visible and the game screen scaling is set to "Everything".
sizableContainer.TransformTo(nameof(CornerRadius), requiresMasking ? corner_radius : 0, TRANSITION_DURATION, requiresMasking ? Easing.OutQuart : Easing.None)
.OnComplete(_ => { sizableContainer.Masking = requiresMasking; });
// when "everything" scaling mode is active, tablets are expected to constrain output area to the scaled size of the game
if (tabletHandler != null)
{
tabletHandler.OutputAreaSize.Value = scalingMode.Value == ScalingMode.Everything ? new Vector2(sizeX.Value, sizeY.Value) : Vector2.One;
tabletHandler.OutputAreaOffset.Value = scalingMode.Value == ScalingMode.Everything ? new Vector2(posX.Value, posY.Value) : new Vector2(0.5f);
}
}
private partial class ScalingBackgroundScreen : BackgroundScreenDefault
@@ -52,8 +52,6 @@ namespace osu.Game.Overlays.Settings.Sections.Input
private Bindable<ScalingMode> scalingMode = null!;
private Bindable<float> scalingSizeX = null!;
private Bindable<float> scalingSizeY = null!;
private Bindable<float> scalingPositionX = new Bindable<float>();
private Bindable<float> scalingPositionY = new Bindable<float>();
[Resolved]
private GameHost host { get; set; }
@@ -91,8 +89,6 @@ namespace osu.Game.Overlays.Settings.Sections.Input
scalingMode = osuConfig.GetBindable<ScalingMode>(OsuSetting.Scaling);
scalingSizeX = osuConfig.GetBindable<float>(OsuSetting.ScalingSizeX);
scalingSizeY = osuConfig.GetBindable<float>(OsuSetting.ScalingSizeY);
scalingPositionX = osuConfig.GetBindable<float>(OsuSetting.ScalingPositionX);
scalingPositionY = osuConfig.GetBindable<float>(OsuSetting.ScalingPositionY);
Children = new Drawable[]
{
@@ -299,13 +295,6 @@ namespace osu.Game.Overlays.Settings.Sections.Input
aspectRatioApplication = Schedule(() => forceAspectRatio(aspect.NewValue));
});
updateScaling();
scalingMode.BindValueChanged(_ => updateScaling());
scalingSizeX.BindValueChanged(_ => updateScaling());
scalingSizeY.BindValueChanged(_ => updateScaling());
scalingPositionX.BindValueChanged(_ => updateScaling());
scalingPositionY.BindValueChanged(_ => updateScaling());
pressureThreshold.BindTo(tabletHandler.PressureThreshold);
tablet.BindTo(tabletHandler.Tablet);
@@ -393,20 +382,6 @@ namespace osu.Game.Overlays.Settings.Sections.Input
aspectLock.Value = true;
}
private void updateScaling()
{
if (scalingMode.Value == ScalingMode.Everything)
{
outputAreaSize.Value = new Vector2(scalingSizeX.Value, scalingSizeY.Value);
outputAreaOffset.Value = new Vector2(scalingPositionX.Value, scalingPositionY.Value);
}
else
{
outputAreaSize.Value = new Vector2(1, 1);
outputAreaOffset.Value = new Vector2(0.5f, 0.5f);
}
}
private void updateAspectRatio() => aspectRatio.Value = currentAspectRatio;
private float currentAspectRatio => sizeX.Value / sizeY.Value;