mirror of
https://github.com/ppy/osu.git
synced 2025-01-31 05:13:22 +08:00
Initial proof of concept for tablet output scaling
This commit is contained in:
parent
c93b6dba2b
commit
66eff14d2b
@ -134,6 +134,8 @@ namespace osu.Game.Tests.Visual.Settings
|
||||
public Bindable<Vector2> AreaOffset { get; } = new Bindable<Vector2>();
|
||||
public Bindable<Vector2> AreaSize { get; } = new Bindable<Vector2>();
|
||||
|
||||
public Bindable<Vector2> OutputSize { get; } = new Bindable<Vector2>();
|
||||
|
||||
public Bindable<float> Rotation { get; } = new Bindable<float>();
|
||||
|
||||
public IBindable<TabletInfo> Tablet => tablet;
|
||||
|
@ -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<Vector2> areaOffset = new Bindable<Vector2>();
|
||||
private readonly Bindable<Vector2> areaSize = new Bindable<Vector2>();
|
||||
private readonly Bindable<Vector2> outputSize = new Bindable<Vector2>();
|
||||
private readonly IBindable<TabletInfo> tablet = new Bindable<TabletInfo>();
|
||||
|
||||
private readonly BindableNumber<float> offsetX = new BindableNumber<float> { MinValue = 0 };
|
||||
@ -45,6 +47,10 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
|
||||
private readonly BindableNumber<float> rotation = new BindableNumber<float> { MinValue = 0, MaxValue = 360 };
|
||||
|
||||
private Bindable<ScalingMode> scalingMode = null!;
|
||||
private Bindable<float> scalingSizeX = null!;
|
||||
private Bindable<float> 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<ScalingMode>(OsuSetting.Scaling);
|
||||
scalingSizeX = osuConfig.GetBindable<float>(OsuSetting.ScalingSizeX);
|
||||
scalingSizeY = osuConfig.GetBindable<float>(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;
|
||||
|
Loading…
Reference in New Issue
Block a user