Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scale tablet output size when UI Scaling mode is "Everything" #31141

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions osu.Game.Tests/Visual/Settings/TestSceneTabletSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ public class TestTabletHandler : ITabletHandler
public Bindable<Vector2> AreaOffset { get; } = new Bindable<Vector2>();
public Bindable<Vector2> AreaSize { get; } = new Bindable<Vector2>();

public Bindable<Vector2> OutputAreaSize { get; } = new Bindable<Vector2>();
public Bindable<Vector2> OutputAreaPosition { get; } = new Bindable<Vector2>();

public Bindable<float> Rotation { get; } = new Bindable<float>();

public IBindable<TabletInfo> Tablet => tablet;
Expand Down
41 changes: 40 additions & 1 deletion osu.Game/Overlays/Settings/Sections/Input/TabletSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -35,6 +36,8 @@

private readonly Bindable<Vector2> areaOffset = new Bindable<Vector2>();
private readonly Bindable<Vector2> areaSize = new Bindable<Vector2>();
private readonly Bindable<Vector2> outputAreaSize = new Bindable<Vector2>();
private readonly Bindable<Vector2> outputAreaPosition = new Bindable<Vector2>();
private readonly IBindable<TabletInfo> tablet = new Bindable<TabletInfo>();

private readonly BindableNumber<float> offsetX = new BindableNumber<float> { MinValue = 0 };
Expand All @@ -45,6 +48,12 @@

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!;
private Bindable<float> scalingPositionX = new Bindable<float>();
private Bindable<float> scalingPositionY = new Bindable<float>();

[Resolved]
private GameHost host { get; set; }

Expand Down Expand Up @@ -76,8 +85,14 @@
}

[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);
scalingPositionX = osuConfig.GetBindable<float>(OsuSetting.ScalingPositionX);
scalingPositionY = osuConfig.GetBindable<float>(OsuSetting.ScalingPositionY);

Children = new Drawable[]
{
new SettingsCheckbox
Expand Down Expand Up @@ -244,6 +259,9 @@
sizeY.Value = val.NewValue.Y;
}), true);

outputAreaSize.BindTo(tabletHandler.OutputAreaSize);

Check failure on line 262 in osu.Game/Overlays/Settings/Sections/Input/TabletSettings.cs

View workflow job for this annotation

GitHub Actions / Code Quality

'ITabletHandler' does not contain a definition for 'OutputAreaSize' and no accessible extension method 'OutputAreaSize' accepting a first argument of type 'ITabletHandler' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 262 in osu.Game/Overlays/Settings/Sections/Input/TabletSettings.cs

View workflow job for this annotation

GitHub Actions / Code Quality

'ITabletHandler' does not contain a definition for 'OutputAreaSize' and no accessible extension method 'OutputAreaSize' accepting a first argument of type 'ITabletHandler' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 262 in osu.Game/Overlays/Settings/Sections/Input/TabletSettings.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, SingleThread)

'ITabletHandler' does not contain a definition for 'OutputAreaSize' and no accessible extension method 'OutputAreaSize' accepting a first argument of type 'ITabletHandler' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 262 in osu.Game/Overlays/Settings/Sections/Input/TabletSettings.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, SingleThread)

'ITabletHandler' does not contain a definition for 'OutputAreaSize' and no accessible extension method 'OutputAreaSize' accepting a first argument of type 'ITabletHandler' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 262 in osu.Game/Overlays/Settings/Sections/Input/TabletSettings.cs

View workflow job for this annotation

GitHub Actions / Build only (Android)

'ITabletHandler' does not contain a definition for 'OutputAreaSize' and no accessible extension method 'OutputAreaSize' accepting a first argument of type 'ITabletHandler' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 262 in osu.Game/Overlays/Settings/Sections/Input/TabletSettings.cs

View workflow job for this annotation

GitHub Actions / Build only (Android)

'ITabletHandler' does not contain a definition for 'OutputAreaSize' and no accessible extension method 'OutputAreaSize' accepting a first argument of type 'ITabletHandler' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 262 in osu.Game/Overlays/Settings/Sections/Input/TabletSettings.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, MultiThreaded)

'ITabletHandler' does not contain a definition for 'OutputAreaSize' and no accessible extension method 'OutputAreaSize' accepting a first argument of type 'ITabletHandler' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 262 in osu.Game/Overlays/Settings/Sections/Input/TabletSettings.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, MultiThreaded)

'ITabletHandler' does not contain a definition for 'OutputAreaSize' and no accessible extension method 'OutputAreaSize' accepting a first argument of type 'ITabletHandler' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 262 in osu.Game/Overlays/Settings/Sections/Input/TabletSettings.cs

View workflow job for this annotation

GitHub Actions / Build only (iOS)

'ITabletHandler' does not contain a definition for 'OutputAreaSize' and no accessible extension method 'OutputAreaSize' accepting a first argument of type 'ITabletHandler' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 262 in osu.Game/Overlays/Settings/Sections/Input/TabletSettings.cs

View workflow job for this annotation

GitHub Actions / Build only (iOS)

'ITabletHandler' does not contain a definition for 'OutputAreaSize' and no accessible extension method 'OutputAreaSize' accepting a first argument of type 'ITabletHandler' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 262 in osu.Game/Overlays/Settings/Sections/Input/TabletSettings.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, SingleThread)

'ITabletHandler' does not contain a definition for 'OutputAreaSize' and no accessible extension method 'OutputAreaSize' accepting a first argument of type 'ITabletHandler' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 262 in osu.Game/Overlays/Settings/Sections/Input/TabletSettings.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, SingleThread)

'ITabletHandler' does not contain a definition for 'OutputAreaSize' and no accessible extension method 'OutputAreaSize' accepting a first argument of type 'ITabletHandler' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 262 in osu.Game/Overlays/Settings/Sections/Input/TabletSettings.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, MultiThreaded)

'ITabletHandler' does not contain a definition for 'OutputAreaSize' and no accessible extension method 'OutputAreaSize' accepting a first argument of type 'ITabletHandler' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 262 in osu.Game/Overlays/Settings/Sections/Input/TabletSettings.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, MultiThreaded)

'ITabletHandler' does not contain a definition for 'OutputAreaSize' and no accessible extension method 'OutputAreaSize' accepting a first argument of type 'ITabletHandler' could be found (are you missing a using directive or an assembly reference?)
outputAreaPosition.BindTo(tabletHandler.OutputAreaPosition);

Check failure on line 263 in osu.Game/Overlays/Settings/Sections/Input/TabletSettings.cs

View workflow job for this annotation

GitHub Actions / Code Quality

'ITabletHandler' does not contain a definition for 'OutputAreaPosition' and no accessible extension method 'OutputAreaPosition' accepting a first argument of type 'ITabletHandler' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 263 in osu.Game/Overlays/Settings/Sections/Input/TabletSettings.cs

View workflow job for this annotation

GitHub Actions / Code Quality

'ITabletHandler' does not contain a definition for 'OutputAreaPosition' and no accessible extension method 'OutputAreaPosition' accepting a first argument of type 'ITabletHandler' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 263 in osu.Game/Overlays/Settings/Sections/Input/TabletSettings.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, SingleThread)

'ITabletHandler' does not contain a definition for 'OutputAreaPosition' and no accessible extension method 'OutputAreaPosition' accepting a first argument of type 'ITabletHandler' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 263 in osu.Game/Overlays/Settings/Sections/Input/TabletSettings.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, SingleThread)

'ITabletHandler' does not contain a definition for 'OutputAreaPosition' and no accessible extension method 'OutputAreaPosition' accepting a first argument of type 'ITabletHandler' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 263 in osu.Game/Overlays/Settings/Sections/Input/TabletSettings.cs

View workflow job for this annotation

GitHub Actions / Build only (Android)

'ITabletHandler' does not contain a definition for 'OutputAreaPosition' and no accessible extension method 'OutputAreaPosition' accepting a first argument of type 'ITabletHandler' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 263 in osu.Game/Overlays/Settings/Sections/Input/TabletSettings.cs

View workflow job for this annotation

GitHub Actions / Build only (Android)

'ITabletHandler' does not contain a definition for 'OutputAreaPosition' and no accessible extension method 'OutputAreaPosition' accepting a first argument of type 'ITabletHandler' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 263 in osu.Game/Overlays/Settings/Sections/Input/TabletSettings.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, MultiThreaded)

'ITabletHandler' does not contain a definition for 'OutputAreaPosition' and no accessible extension method 'OutputAreaPosition' accepting a first argument of type 'ITabletHandler' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 263 in osu.Game/Overlays/Settings/Sections/Input/TabletSettings.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, MultiThreaded)

'ITabletHandler' does not contain a definition for 'OutputAreaPosition' and no accessible extension method 'OutputAreaPosition' accepting a first argument of type 'ITabletHandler' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 263 in osu.Game/Overlays/Settings/Sections/Input/TabletSettings.cs

View workflow job for this annotation

GitHub Actions / Build only (iOS)

'ITabletHandler' does not contain a definition for 'OutputAreaPosition' and no accessible extension method 'OutputAreaPosition' accepting a first argument of type 'ITabletHandler' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 263 in osu.Game/Overlays/Settings/Sections/Input/TabletSettings.cs

View workflow job for this annotation

GitHub Actions / Build only (iOS)

'ITabletHandler' does not contain a definition for 'OutputAreaPosition' and no accessible extension method 'OutputAreaPosition' accepting a first argument of type 'ITabletHandler' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 263 in osu.Game/Overlays/Settings/Sections/Input/TabletSettings.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, SingleThread)

'ITabletHandler' does not contain a definition for 'OutputAreaPosition' and no accessible extension method 'OutputAreaPosition' accepting a first argument of type 'ITabletHandler' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 263 in osu.Game/Overlays/Settings/Sections/Input/TabletSettings.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, SingleThread)

'ITabletHandler' does not contain a definition for 'OutputAreaPosition' and no accessible extension method 'OutputAreaPosition' accepting a first argument of type 'ITabletHandler' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 263 in osu.Game/Overlays/Settings/Sections/Input/TabletSettings.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, MultiThreaded)

'ITabletHandler' does not contain a definition for 'OutputAreaPosition' and no accessible extension method 'OutputAreaPosition' accepting a first argument of type 'ITabletHandler' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 263 in osu.Game/Overlays/Settings/Sections/Input/TabletSettings.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, MultiThreaded)

'ITabletHandler' does not contain a definition for 'OutputAreaPosition' and no accessible extension method 'OutputAreaPosition' accepting a first argument of type 'ITabletHandler' could be found (are you missing a using directive or an assembly reference?)

sizeX.BindValueChanged(val =>
{
areaSize.Value = new Vector2(val.NewValue, areaSize.Value.Y);
Expand All @@ -267,6 +285,13 @@
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(() =>
{
Expand Down Expand Up @@ -352,6 +377,20 @@
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;
Expand Down
Loading