mirror of
https://github.com/ppy/osu
synced 2024-12-15 19:36:34 +00:00
Show aspect ratio for current usable area
This commit is contained in:
parent
196f95ae54
commit
fb7d095e4a
@ -29,6 +29,9 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
|
||||
private OsuSpriteText tabletName;
|
||||
|
||||
private Box usableFill;
|
||||
private OsuSpriteText usableAreaText;
|
||||
|
||||
public TabletAreaSelection(ITabletHandler handler)
|
||||
{
|
||||
this.handler = handler;
|
||||
@ -59,17 +62,16 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
Origin = Anchor.Centre,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
usableFill = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Alpha = 0.6f,
|
||||
},
|
||||
new OsuSpriteText
|
||||
usableAreaText = new OsuSpriteText
|
||||
{
|
||||
Text = "usable area",
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Colour = Color4.Black,
|
||||
Colour = Color4.White,
|
||||
Font = OsuFont.Default.With(size: 12)
|
||||
}
|
||||
}
|
||||
@ -99,6 +101,12 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
{
|
||||
usableAreaContainer.ResizeTo(val.NewValue, 100, Easing.OutQuint)
|
||||
.OnComplete(_ => checkBounds()); // required as we are using SSDQ.
|
||||
|
||||
int x = (int)val.NewValue.X;
|
||||
int y = (int)val.NewValue.Y;
|
||||
int commonDivider = greatestCommonDivider(x, y);
|
||||
|
||||
usableAreaText.Text = $"{(float)x / commonDivider}:{(float)y / commonDivider}";
|
||||
}, true);
|
||||
|
||||
tablet.BindTo(handler.Tablet);
|
||||
@ -113,6 +121,18 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
FinishTransforms(true);
|
||||
}
|
||||
|
||||
private static int greatestCommonDivider(int a, int b)
|
||||
{
|
||||
while (b != 0)
|
||||
{
|
||||
int remainder = a % b;
|
||||
a = b;
|
||||
b = remainder;
|
||||
}
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
[Resolved]
|
||||
private OsuColour colour { get; set; }
|
||||
|
||||
@ -126,7 +146,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
bool isWithinBounds = tabletContainer.ScreenSpaceDrawQuad.Contains(usableSsdq.TopLeft) &&
|
||||
tabletContainer.ScreenSpaceDrawQuad.Contains(usableSsdq.BottomRight);
|
||||
|
||||
usableAreaContainer.FadeColour(isWithinBounds ? colour.Blue : colour.RedLight, 100);
|
||||
usableFill.FadeColour(isWithinBounds ? colour.Blue : colour.RedLight, 100);
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
|
Loading…
Reference in New Issue
Block a user