diff --git a/osu.Game/Extensions/DrawableExtensions.cs b/osu.Game/Extensions/DrawableExtensions.cs index 5b92600cd1..46105218c5 100644 --- a/osu.Game/Extensions/DrawableExtensions.cs +++ b/osu.Game/Extensions/DrawableExtensions.cs @@ -82,11 +82,12 @@ namespace osu.Game.Extensions } /// - /// Keeps the drawable upright no matter the Rotation of its parents. + /// Keeps the drawable upright and prevents it from being scaled or flipped with its Parent. /// /// The drawable. - public static void KeepUpright(this Drawable drawable) + public static void KeepUprightAndUnstretched(this Drawable drawable) { + // Fix the rotation var result = drawable.Parent.DrawInfo; var scale = result.Matrix.ExtractScale(); var rotation = new Matrix3( @@ -94,9 +95,30 @@ namespace osu.Game.Extensions result.Matrix.Row1 / scale.Y, new Vector3(0.0f, 0.0f, 1.0f) ); - float angle = MathF.Atan2(rotation.M12, rotation.M11); + rotation.Invert(); + float angle = MathF.Atan(rotation.M12 / rotation.M11); angle *= (360 / (2 * MathF.PI)); - drawable.Rotation = -angle; + drawable.Rotation = angle; + + // Fix the scale (includes flip) + var containerOriginToSpaceOrigin = new Matrix3( + new Vector3(1.0f, 0.0f, 0.0f), + new Vector3(0.0f, 1.0f, 0.0f), + new Vector3(drawable.DrawSize.X / 2, drawable.DrawSize.Y / 2, 1.0f) + ); + var containerOriginToSpaceOriginInverse = containerOriginToSpaceOrigin; + containerOriginToSpaceOriginInverse.Invert(); + Matrix3 rotatedBack = (containerOriginToSpaceOriginInverse * (rotation * (containerOriginToSpaceOrigin * result.Matrix))); + + bool xFliped = rotation.M11 < 0; + bool yFliped = rotation.M22 < 0; + + var rotatedBackScale = rotatedBack.ExtractScale(); + + drawable.Scale = new Vector2( + (xFliped ? -1 : 1) / rotatedBackScale.X, + (yFliped ? -1 : 1) / rotatedBackScale.Y + ); } } diff --git a/osu.Game/Screens/Play/HUD/DefaultSongProgress.cs b/osu.Game/Screens/Play/HUD/DefaultSongProgress.cs index 96a6c56860..9ed99ab5f6 100644 --- a/osu.Game/Screens/Play/HUD/DefaultSongProgress.cs +++ b/osu.Game/Screens/Play/HUD/DefaultSongProgress.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; +using osu.Framework.Graphics.Shapes; using osu.Game.Configuration; using osu.Game.Graphics; using osu.Game.Rulesets.Objects; @@ -16,7 +17,6 @@ namespace osu.Game.Screens.Play.HUD { public class DefaultSongProgress : SongProgress { - private const float info_height = 20; private const float bottom_bar_height = 5; private const float graph_height = SquareGraph.Column.WIDTH * 6; private const float handle_height = 18; @@ -67,7 +67,6 @@ namespace osu.Game.Screens.Play.HUD Origin = Anchor.BottomLeft, Anchor = Anchor.BottomLeft, RelativeSizeAxes = Axes.X, - Height = info_height, }, graph = new SongProgressGraph { @@ -180,7 +179,7 @@ namespace osu.Game.Screens.Play.HUD protected override void Update() { base.Update(); - Height = bottom_bar_height + graph_height + handle_size.Y + info_height - graph.Y; + Height = bottom_bar_height + graph_height + handle_size.Y + info.Height - graph.Y; } private void updateBarVisibility() diff --git a/osu.Game/Screens/Play/HUD/SongProgressInfo.cs b/osu.Game/Screens/Play/HUD/SongProgressInfo.cs index 520d0c661d..656498fc43 100644 --- a/osu.Game/Screens/Play/HUD/SongProgressInfo.cs +++ b/osu.Game/Screens/Play/HUD/SongProgressInfo.cs @@ -46,6 +46,7 @@ namespace osu.Game.Screens.Play.HUD if (clock != null) gameplayClock = clock; + AutoSizeAxes = Axes.Y; Children = new Drawable[] { new Container @@ -138,9 +139,9 @@ namespace osu.Game.Screens.Play.HUD private void keepTextSpritesUpright() { - timeCurrent.OnUpdate += (timeCurrent) => { Extensions.DrawableExtensions.KeepUpright(timeCurrent); }; - progress.OnUpdate += (timeCurrent) => { Extensions.DrawableExtensions.KeepUpright(timeCurrent); }; - timeLeft.OnUpdate += (timeCurrent) => { Extensions.DrawableExtensions.KeepUpright(timeCurrent); }; + timeCurrent.OnUpdate += (timeCurrent) => { Extensions.DrawableExtensions.KeepUprightAndUnstretched(timeCurrent); }; + progress.OnUpdate += (timeCurrent) => { Extensions.DrawableExtensions.KeepUprightAndUnstretched(timeCurrent); }; + timeLeft.OnUpdate += (timeCurrent) => { Extensions.DrawableExtensions.KeepUprightAndUnstretched(timeCurrent); }; } }