mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 10:42:54 +08:00
Merge pull request #12218 from peppy/tablet-rotation-configuration
Add tablet rotation configuration
This commit is contained in:
commit
8bd03c2e2a
@ -52,6 +52,6 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.211.1" />
|
||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2021.329.0" />
|
||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2021.330.0" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
@ -45,6 +45,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<float> Rotation { get; } = new Bindable<float>();
|
||||
|
||||
public IBindable<TabletInfo> Tablet => tablet;
|
||||
|
||||
private readonly Bindable<TabletInfo> tablet = new Bindable<TabletInfo>();
|
||||
|
@ -0,0 +1,109 @@
|
||||
// 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.Input.Handlers.Tablet;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
|
||||
namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
{
|
||||
internal class RotationPresetButtons : FillFlowContainer
|
||||
{
|
||||
private readonly ITabletHandler tabletHandler;
|
||||
|
||||
private Bindable<float> rotation;
|
||||
|
||||
private const int height = 50;
|
||||
|
||||
public RotationPresetButtons(ITabletHandler tabletHandler)
|
||||
{
|
||||
this.tabletHandler = tabletHandler;
|
||||
|
||||
RelativeSizeAxes = Axes.X;
|
||||
Height = height;
|
||||
|
||||
for (int i = 0; i < 360; i += 90)
|
||||
{
|
||||
var presetRotation = i;
|
||||
|
||||
Add(new RotationButton(i)
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = height,
|
||||
Width = 0.25f,
|
||||
Text = $"{presetRotation}º",
|
||||
Action = () => tabletHandler.Rotation.Value = presetRotation,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
rotation = tabletHandler.Rotation.GetBoundCopy();
|
||||
rotation.BindValueChanged(val =>
|
||||
{
|
||||
foreach (var b in Children.OfType<RotationButton>())
|
||||
b.IsSelected = b.Preset == val.NewValue;
|
||||
}, true);
|
||||
}
|
||||
|
||||
public class RotationButton : TriangleButton
|
||||
{
|
||||
[Resolved]
|
||||
private OsuColour colours { get; set; }
|
||||
|
||||
public readonly int Preset;
|
||||
|
||||
public RotationButton(int preset)
|
||||
{
|
||||
Preset = preset;
|
||||
}
|
||||
|
||||
private bool isSelected;
|
||||
|
||||
public bool IsSelected
|
||||
{
|
||||
get => isSelected;
|
||||
set
|
||||
{
|
||||
if (value == isSelected)
|
||||
return;
|
||||
|
||||
isSelected = value;
|
||||
|
||||
if (IsLoaded)
|
||||
updateColour();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
updateColour();
|
||||
}
|
||||
|
||||
private void updateColour()
|
||||
{
|
||||
if (isSelected)
|
||||
{
|
||||
BackgroundColour = colours.BlueDark;
|
||||
Triangles.ColourDark = colours.BlueDarker;
|
||||
Triangles.ColourLight = colours.Blue;
|
||||
}
|
||||
else
|
||||
{
|
||||
BackgroundColour = colours.Gray4;
|
||||
Triangles.ColourDark = colours.Gray5;
|
||||
Triangles.ColourLight = colours.Gray6;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -25,6 +25,8 @@ 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 BindableNumber<float> rotation = new BindableNumber<float>();
|
||||
|
||||
private readonly IBindable<TabletInfo> tablet = new Bindable<TabletInfo>();
|
||||
|
||||
private OsuSpriteText tabletName;
|
||||
@ -124,6 +126,13 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
usableAreaText.Text = $"{(float)x / commonDivider}:{(float)y / commonDivider}";
|
||||
}, true);
|
||||
|
||||
rotation.BindTo(handler.Rotation);
|
||||
rotation.BindValueChanged(val =>
|
||||
{
|
||||
usableAreaContainer.RotateTo(val.NewValue, 100, Easing.OutQuint)
|
||||
.OnComplete(_ => checkBounds()); // required as we are using SSDQ.
|
||||
});
|
||||
|
||||
tablet.BindTo(handler.Tablet);
|
||||
tablet.BindValueChanged(_ => Scheduler.AddOnce(updateTabletDetails));
|
||||
|
||||
|
@ -27,6 +27,8 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
private readonly BindableNumber<float> sizeX = new BindableNumber<float> { MinValue = 10 };
|
||||
private readonly BindableNumber<float> sizeY = new BindableNumber<float> { MinValue = 10 };
|
||||
|
||||
private readonly BindableNumber<float> rotation = new BindableNumber<float> { MinValue = 0, MaxValue = 360 };
|
||||
|
||||
[Resolved]
|
||||
private GameHost host { get; set; }
|
||||
|
||||
@ -110,12 +112,6 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
}
|
||||
},
|
||||
new SettingsSlider<float>
|
||||
{
|
||||
TransferValueOnCommit = true,
|
||||
LabelText = "Aspect Ratio",
|
||||
Current = aspectRatio
|
||||
},
|
||||
new SettingsSlider<float>
|
||||
{
|
||||
TransferValueOnCommit = true,
|
||||
LabelText = "X Offset",
|
||||
@ -127,6 +123,19 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
LabelText = "Y Offset",
|
||||
Current = offsetY
|
||||
},
|
||||
new SettingsSlider<float>
|
||||
{
|
||||
TransferValueOnCommit = true,
|
||||
LabelText = "Rotation",
|
||||
Current = rotation
|
||||
},
|
||||
new RotationPresetButtons(tabletHandler),
|
||||
new SettingsSlider<float>
|
||||
{
|
||||
TransferValueOnCommit = true,
|
||||
LabelText = "Aspect Ratio",
|
||||
Current = aspectRatio
|
||||
},
|
||||
new SettingsCheckbox
|
||||
{
|
||||
LabelText = "Lock aspect ratio",
|
||||
@ -153,6 +162,8 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
rotation.BindTo(tabletHandler.Rotation);
|
||||
|
||||
areaOffset.BindTo(tabletHandler.AreaOffset);
|
||||
areaOffset.BindValueChanged(val =>
|
||||
{
|
||||
|
@ -29,7 +29,7 @@
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="5.0.0" />
|
||||
<PackageReference Include="Microsoft.NETCore.Targets" Version="3.1.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2021.329.0" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2021.330.0" />
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.211.1" />
|
||||
<PackageReference Include="Sentry" Version="3.2.0" />
|
||||
<PackageReference Include="SharpCompress" Version="0.28.1" />
|
||||
|
@ -70,7 +70,7 @@
|
||||
<Reference Include="System.Net.Http" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Label="Package References">
|
||||
<PackageReference Include="ppy.osu.Framework.iOS" Version="2021.329.0" />
|
||||
<PackageReference Include="ppy.osu.Framework.iOS" Version="2021.330.0" />
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.211.1" />
|
||||
</ItemGroup>
|
||||
<!-- See https://github.com/dotnet/runtime/issues/35988 (can be removed after Xamarin uses net5.0 / net6.0) -->
|
||||
@ -93,7 +93,7 @@
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2021.329.0" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2021.330.0" />
|
||||
<PackageReference Include="SharpCompress" Version="0.28.1" />
|
||||
<PackageReference Include="NUnit" Version="3.12.0" />
|
||||
<PackageReference Include="SharpRaven" Version="2.4.0" />
|
||||
|
Loading…
Reference in New Issue
Block a user