mirror of
https://github.com/osukey/osukey.git
synced 2025-08-03 22:56:36 +09:00
Merge pull request #12218 from peppy/tablet-rotation-configuration
Add tablet rotation configuration
This commit is contained in:
@ -52,6 +52,6 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.211.1" />
|
<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>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -45,6 +45,8 @@ namespace osu.Game.Tests.Visual.Settings
|
|||||||
public Bindable<Vector2> AreaOffset { get; } = new Bindable<Vector2>();
|
public Bindable<Vector2> AreaOffset { get; } = new Bindable<Vector2>();
|
||||||
public Bindable<Vector2> AreaSize { 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;
|
public IBindable<TabletInfo> Tablet => tablet;
|
||||||
|
|
||||||
private readonly Bindable<TabletInfo> tablet = new Bindable<TabletInfo>();
|
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> areaOffset = new Bindable<Vector2>();
|
||||||
private readonly Bindable<Vector2> areaSize = 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 readonly IBindable<TabletInfo> tablet = new Bindable<TabletInfo>();
|
||||||
|
|
||||||
private OsuSpriteText tabletName;
|
private OsuSpriteText tabletName;
|
||||||
@ -124,6 +126,13 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
|||||||
usableAreaText.Text = $"{(float)x / commonDivider}:{(float)y / commonDivider}";
|
usableAreaText.Text = $"{(float)x / commonDivider}:{(float)y / commonDivider}";
|
||||||
}, true);
|
}, 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.BindTo(handler.Tablet);
|
||||||
tablet.BindValueChanged(_ => Scheduler.AddOnce(updateTabletDetails));
|
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> sizeX = new BindableNumber<float> { MinValue = 10 };
|
||||||
private readonly BindableNumber<float> sizeY = 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]
|
[Resolved]
|
||||||
private GameHost host { get; set; }
|
private GameHost host { get; set; }
|
||||||
|
|
||||||
@ -110,12 +112,6 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
new SettingsSlider<float>
|
new SettingsSlider<float>
|
||||||
{
|
|
||||||
TransferValueOnCommit = true,
|
|
||||||
LabelText = "Aspect Ratio",
|
|
||||||
Current = aspectRatio
|
|
||||||
},
|
|
||||||
new SettingsSlider<float>
|
|
||||||
{
|
{
|
||||||
TransferValueOnCommit = true,
|
TransferValueOnCommit = true,
|
||||||
LabelText = "X Offset",
|
LabelText = "X Offset",
|
||||||
@ -127,6 +123,19 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
|||||||
LabelText = "Y Offset",
|
LabelText = "Y Offset",
|
||||||
Current = offsetY
|
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
|
new SettingsCheckbox
|
||||||
{
|
{
|
||||||
LabelText = "Lock aspect ratio",
|
LabelText = "Lock aspect ratio",
|
||||||
@ -153,6 +162,8 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
|||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
|
rotation.BindTo(tabletHandler.Rotation);
|
||||||
|
|
||||||
areaOffset.BindTo(tabletHandler.AreaOffset);
|
areaOffset.BindTo(tabletHandler.AreaOffset);
|
||||||
areaOffset.BindValueChanged(val =>
|
areaOffset.BindValueChanged(val =>
|
||||||
{
|
{
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="5.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="5.0.0" />
|
||||||
<PackageReference Include="Microsoft.NETCore.Targets" Version="3.1.0" />
|
<PackageReference Include="Microsoft.NETCore.Targets" Version="3.1.0" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
<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="ppy.osu.Game.Resources" Version="2021.211.1" />
|
||||||
<PackageReference Include="Sentry" Version="3.2.0" />
|
<PackageReference Include="Sentry" Version="3.2.0" />
|
||||||
<PackageReference Include="SharpCompress" Version="0.28.1" />
|
<PackageReference Include="SharpCompress" Version="0.28.1" />
|
||||||
|
@ -70,7 +70,7 @@
|
|||||||
<Reference Include="System.Net.Http" />
|
<Reference Include="System.Net.Http" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup Label="Package References">
|
<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" />
|
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.211.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<!-- See https://github.com/dotnet/runtime/issues/35988 (can be removed after Xamarin uses net5.0 / net6.0) -->
|
<!-- 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" Version="2.2.6" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
<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="SharpCompress" Version="0.28.1" />
|
||||||
<PackageReference Include="NUnit" Version="3.12.0" />
|
<PackageReference Include="NUnit" Version="3.12.0" />
|
||||||
<PackageReference Include="SharpRaven" Version="2.4.0" />
|
<PackageReference Include="SharpRaven" Version="2.4.0" />
|
||||||
|
Reference in New Issue
Block a user