From ce4fd6aca51690455f9a1f02ada35d95269883ed Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Fri, 19 Jan 2024 23:48:05 +0300 Subject: [PATCH 1/7] Rename `DEFAULT_HEIGHT` to `BASE_HEIGHT` --- .../Edit/Blueprints/HitPlacementBlueprint.cs | 2 +- .../Edit/Blueprints/TaikoSpanPlacementBlueprint.cs | 6 +++--- osu.Game.Rulesets.Taiko/Mods/TaikoModFlashlight.cs | 2 +- .../Skinning/Legacy/TaikoLegacyHitTarget.cs | 2 +- osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/osu.Game.Rulesets.Taiko/Edit/Blueprints/HitPlacementBlueprint.cs b/osu.Game.Rulesets.Taiko/Edit/Blueprints/HitPlacementBlueprint.cs index 8b1a4f688c..329fff5b42 100644 --- a/osu.Game.Rulesets.Taiko/Edit/Blueprints/HitPlacementBlueprint.cs +++ b/osu.Game.Rulesets.Taiko/Edit/Blueprints/HitPlacementBlueprint.cs @@ -21,7 +21,7 @@ namespace osu.Game.Rulesets.Taiko.Edit.Blueprints { InternalChild = piece = new HitPiece { - Size = new Vector2(TaikoHitObject.DEFAULT_SIZE * TaikoPlayfield.DEFAULT_HEIGHT) + Size = new Vector2(TaikoHitObject.DEFAULT_SIZE * TaikoPlayfield.BASE_HEIGHT) }; } diff --git a/osu.Game.Rulesets.Taiko/Edit/Blueprints/TaikoSpanPlacementBlueprint.cs b/osu.Game.Rulesets.Taiko/Edit/Blueprints/TaikoSpanPlacementBlueprint.cs index b0919417a4..cd52398086 100644 --- a/osu.Game.Rulesets.Taiko/Edit/Blueprints/TaikoSpanPlacementBlueprint.cs +++ b/osu.Game.Rulesets.Taiko/Edit/Blueprints/TaikoSpanPlacementBlueprint.cs @@ -39,15 +39,15 @@ namespace osu.Game.Rulesets.Taiko.Edit.Blueprints { headPiece = new HitPiece { - Size = new Vector2(TaikoHitObject.DEFAULT_SIZE * TaikoPlayfield.DEFAULT_HEIGHT) + Size = new Vector2(TaikoHitObject.DEFAULT_SIZE * TaikoPlayfield.BASE_HEIGHT) }, lengthPiece = new LengthPiece { - Height = TaikoHitObject.DEFAULT_SIZE * TaikoPlayfield.DEFAULT_HEIGHT + Height = TaikoHitObject.DEFAULT_SIZE * TaikoPlayfield.BASE_HEIGHT }, tailPiece = new HitPiece { - Size = new Vector2(TaikoHitObject.DEFAULT_SIZE * TaikoPlayfield.DEFAULT_HEIGHT) + Size = new Vector2(TaikoHitObject.DEFAULT_SIZE * TaikoPlayfield.BASE_HEIGHT) } }; } diff --git a/osu.Game.Rulesets.Taiko/Mods/TaikoModFlashlight.cs b/osu.Game.Rulesets.Taiko/Mods/TaikoModFlashlight.cs index 733772e21f..26bbb6d71b 100644 --- a/osu.Game.Rulesets.Taiko/Mods/TaikoModFlashlight.cs +++ b/osu.Game.Rulesets.Taiko/Mods/TaikoModFlashlight.cs @@ -63,7 +63,7 @@ namespace osu.Game.Rulesets.Taiko.Mods /// private Vector2 adjustSizeForPlayfieldAspectRatio(float size) { - return new Vector2(0, size * taikoPlayfield.DrawHeight / TaikoPlayfield.DEFAULT_HEIGHT); + return new Vector2(0, size * taikoPlayfield.DrawHeight / TaikoPlayfield.BASE_HEIGHT); } protected override void UpdateFlashlightSize(float size) diff --git a/osu.Game.Rulesets.Taiko/Skinning/Legacy/TaikoLegacyHitTarget.cs b/osu.Game.Rulesets.Taiko/Skinning/Legacy/TaikoLegacyHitTarget.cs index 492782f0d1..2f845adcd8 100644 --- a/osu.Game.Rulesets.Taiko/Skinning/Legacy/TaikoLegacyHitTarget.cs +++ b/osu.Game.Rulesets.Taiko/Skinning/Legacy/TaikoLegacyHitTarget.cs @@ -53,7 +53,7 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Legacy // Relying on RelativeSizeAxes.Both + FillMode.Fit doesn't work due to the precise pixel layout requirements. // This is a bit ugly but makes the non-legacy implementations a lot cleaner to implement. - content.Scale = new Vector2(DrawHeight / TaikoPlayfield.DEFAULT_HEIGHT); + content.Scale = new Vector2(DrawHeight / TaikoPlayfield.BASE_HEIGHT); } } } diff --git a/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs b/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs index 7e3ed7a4d4..af4ed0557a 100644 --- a/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs +++ b/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs @@ -28,9 +28,9 @@ namespace osu.Game.Rulesets.Taiko.UI public partial class TaikoPlayfield : ScrollingPlayfield { /// - /// Default height of a when inside a . + /// Base height of a when inside a . /// - public const float DEFAULT_HEIGHT = 200; + public const float BASE_HEIGHT = 200; /// /// Whether the hit target should be nudged further towards the left area, matching the stable "classic" position. From 3e17d01cebc88c56615f67c0deea7351168a46b1 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Fri, 19 Jan 2024 23:49:14 +0300 Subject: [PATCH 2/7] Rewrite taiko playfield adjustment container to keep height constant --- .../UI/TaikoPlayfieldAdjustmentContainer.cs | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/osu.Game.Rulesets.Taiko/UI/TaikoPlayfieldAdjustmentContainer.cs b/osu.Game.Rulesets.Taiko/UI/TaikoPlayfieldAdjustmentContainer.cs index 54608b77de..1bc9f7d89c 100644 --- a/osu.Game.Rulesets.Taiko/UI/TaikoPlayfieldAdjustmentContainer.cs +++ b/osu.Game.Rulesets.Taiko/UI/TaikoPlayfieldAdjustmentContainer.cs @@ -5,23 +5,31 @@ using System; using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Game.Rulesets.UI; +using osuTK; namespace osu.Game.Rulesets.Taiko.UI { public partial class TaikoPlayfieldAdjustmentContainer : PlayfieldAdjustmentContainer { - private const float default_relative_height = TaikoPlayfield.DEFAULT_HEIGHT / 768; - public const float MAXIMUM_ASPECT = 16f / 9f; public const float MINIMUM_ASPECT = 5f / 4f; public readonly IBindable LockPlayfieldAspectRange = new BindableBool(true); + public TaikoPlayfieldAdjustmentContainer() + { + RelativeSizeAxes = Axes.X; + RelativePositionAxes = Axes.Y; + Height = TaikoPlayfield.BASE_HEIGHT; + } + protected override void Update() { base.Update(); - float height = default_relative_height; + const float base_relative_height = TaikoPlayfield.BASE_HEIGHT / 768; + + float relativeHeight = base_relative_height; // Players coming from stable expect to be able to change the aspect ratio regardless of the window size. // We originally wanted to limit this more, but there was considerable pushback from the community. @@ -33,19 +41,20 @@ namespace osu.Game.Rulesets.Taiko.UI float currentAspect = Parent!.ChildSize.X / Parent!.ChildSize.Y; if (currentAspect > MAXIMUM_ASPECT) - height *= currentAspect / MAXIMUM_ASPECT; + relativeHeight *= currentAspect / MAXIMUM_ASPECT; else if (currentAspect < MINIMUM_ASPECT) - height *= currentAspect / MINIMUM_ASPECT; + relativeHeight *= currentAspect / MINIMUM_ASPECT; } // Limit the maximum relative height of the playfield to one-third of available area to avoid it masking out on extreme resolutions. - height = Math.Min(height, 1f / 3f); - Height = height; + relativeHeight = Math.Min(relativeHeight, 1f / 3f); // Position the taiko playfield exactly one playfield from the top of the screen, if there is enough space for it. // Note that the relative height cannot exceed one-third - if that limit is hit, the playfield will be exactly centered. - RelativePositionAxes = Axes.Y; - Y = height; + Y = relativeHeight; + + Scale = new Vector2(Math.Max(relativeHeight / base_relative_height, 1f)); + Width = 1 / Scale.X; } } } From f5ce9eaf7512b27c9df3b03adb8d8a76b7462969 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Fri, 19 Jan 2024 23:58:55 +0300 Subject: [PATCH 3/7] Refactor taiko playfield layout to use constant values --- osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs | 38 ++++++++------------ 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs b/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs index af4ed0557a..4e1691ffe0 100644 --- a/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs +++ b/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs @@ -21,7 +21,6 @@ using osu.Game.Rulesets.Taiko.Judgements; using osu.Game.Rulesets.Taiko.Objects; using osu.Game.Rulesets.Taiko.Scoring; using osu.Game.Skinning; -using osuTK; namespace osu.Game.Rulesets.Taiko.UI { @@ -44,7 +43,6 @@ namespace osu.Game.Rulesets.Taiko.UI private JudgementContainer judgementContainer = null!; private ScrollingHitObjectContainer drumRollHitContainer = null!; internal Drawable HitTarget = null!; - private SkinnableDrawable mascot = null!; private JudgementPooler judgementPooler = null!; private readonly IDictionary explosionPools = new Dictionary(); @@ -59,13 +57,11 @@ namespace osu.Game.Rulesets.Taiko.UI /// private BarLinePlayfield barLinePlayfield = null!; - private Container barLineContent = null!; - private Container hitObjectContent = null!; - private Container overlayContent = null!; - [BackgroundDependencyLoader] private void load(OsuColour colours) { + const float hit_target_width = BASE_HEIGHT; + inputDrum = new InputDrum { Anchor = Anchor.CentreLeft, @@ -89,7 +85,7 @@ namespace osu.Game.Rulesets.Taiko.UI inputDrum.CreateProxy(), } }, - mascot = new SkinnableDrawable(new TaikoSkinComponentLookup(TaikoSkinComponents.Mascot), _ => Empty()) + new SkinnableDrawable(new TaikoSkinComponentLookup(TaikoSkinComponents.Mascot), _ => Empty()) { Origin = Anchor.BottomLeft, Anchor = Anchor.TopLeft, @@ -101,14 +97,13 @@ namespace osu.Game.Rulesets.Taiko.UI { Name = "Right area", RelativeSizeAxes = Axes.Both, - RelativePositionAxes = Axes.Both, Children = new Drawable[] { new Container { - Name = "Elements before hit objects", - RelativeSizeAxes = Axes.Both, - FillMode = FillMode.Fit, + Name = "Elements behind hit objects", + RelativeSizeAxes = Axes.Y, + Width = hit_target_width, Children = new[] { new SkinnableDrawable(new TaikoSkinComponentLookup(TaikoSkinComponents.KiaiGlow), _ => Empty()) @@ -125,10 +120,11 @@ namespace osu.Game.Rulesets.Taiko.UI } } }, - barLineContent = new Container + new Container { Name = "Bar line content", RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Left = hit_target_width / 2 }, Children = new Drawable[] { UnderlayElements = new Container @@ -138,17 +134,19 @@ namespace osu.Game.Rulesets.Taiko.UI barLinePlayfield = new BarLinePlayfield(), } }, - hitObjectContent = new Container + new Container { Name = "Masked hit objects content", RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Left = hit_target_width / 2 }, Masking = true, Child = HitObjectContainer, }, - overlayContent = new Container + new Container { - Name = "Elements after hit objects", + Name = "Overlay content", RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Left = hit_target_width / 2 }, Children = new Drawable[] { drumRollHitContainer = new DrumRollHitContainer(), @@ -226,14 +224,8 @@ namespace osu.Game.Rulesets.Taiko.UI { base.Update(); - // Padding is required to be updated for elements which are based on "absolute" X sized elements. - // This is basically allowing for correct alignment as relative pieces move around them. - rightArea.Padding = new MarginPadding { Left = inputDrum.Width }; - barLineContent.Padding = new MarginPadding { Left = HitTarget.DrawWidth / 2 }; - hitObjectContent.Padding = new MarginPadding { Left = HitTarget.DrawWidth / 2 }; - overlayContent.Padding = new MarginPadding { Left = HitTarget.DrawWidth / 2 }; - - mascot.Scale = new Vector2(DrawHeight / DEFAULT_HEIGHT); + // todo: input drum width should be constant. + rightArea.Padding = new MarginPadding { Left = inputDrum.DrawWidth }; } #region Pooling support From fa2c33c64173d51d5ad14654e12e3f956f17cac8 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Sat, 20 Jan 2024 00:20:43 +0300 Subject: [PATCH 4/7] Upscale playfield by difference in game height as well I honestly don't have much clue about this one but doing so matches master. --- osu.Game.Rulesets.Taiko/UI/TaikoPlayfieldAdjustmentContainer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Taiko/UI/TaikoPlayfieldAdjustmentContainer.cs b/osu.Game.Rulesets.Taiko/UI/TaikoPlayfieldAdjustmentContainer.cs index 1bc9f7d89c..57722b8065 100644 --- a/osu.Game.Rulesets.Taiko/UI/TaikoPlayfieldAdjustmentContainer.cs +++ b/osu.Game.Rulesets.Taiko/UI/TaikoPlayfieldAdjustmentContainer.cs @@ -53,7 +53,7 @@ namespace osu.Game.Rulesets.Taiko.UI // Note that the relative height cannot exceed one-third - if that limit is hit, the playfield will be exactly centered. Y = relativeHeight; - Scale = new Vector2(Math.Max(relativeHeight / base_relative_height, 1f)); + Scale = new Vector2(Math.Max((Parent!.ChildSize.Y / 768f) * (relativeHeight / base_relative_height), 1f)); Width = 1 / Scale.X; } } From 0c03326eaf1bb5954b118c8f58ba721b8058fc8b Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Sat, 20 Jan 2024 01:25:04 +0300 Subject: [PATCH 5/7] Update remaining usages of playfield height --- osu.Game.Rulesets.Taiko/Mods/TaikoModFlashlight.cs | 2 +- .../Skinning/Legacy/TaikoLegacyHitTarget.cs | 14 +------------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/osu.Game.Rulesets.Taiko/Mods/TaikoModFlashlight.cs b/osu.Game.Rulesets.Taiko/Mods/TaikoModFlashlight.cs index 26bbb6d71b..64f2f4c18a 100644 --- a/osu.Game.Rulesets.Taiko/Mods/TaikoModFlashlight.cs +++ b/osu.Game.Rulesets.Taiko/Mods/TaikoModFlashlight.cs @@ -63,7 +63,7 @@ namespace osu.Game.Rulesets.Taiko.Mods /// private Vector2 adjustSizeForPlayfieldAspectRatio(float size) { - return new Vector2(0, size * taikoPlayfield.DrawHeight / TaikoPlayfield.BASE_HEIGHT); + return new Vector2(0, size * taikoPlayfield.Parent!.Scale.Y); } protected override void UpdateFlashlightSize(float size) diff --git a/osu.Game.Rulesets.Taiko/Skinning/Legacy/TaikoLegacyHitTarget.cs b/osu.Game.Rulesets.Taiko/Skinning/Legacy/TaikoLegacyHitTarget.cs index 2f845adcd8..cf9d8dd52e 100644 --- a/osu.Game.Rulesets.Taiko/Skinning/Legacy/TaikoLegacyHitTarget.cs +++ b/osu.Game.Rulesets.Taiko/Skinning/Legacy/TaikoLegacyHitTarget.cs @@ -5,7 +5,6 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; -using osu.Game.Rulesets.Taiko.UI; using osu.Game.Skinning; using osuTK; @@ -13,14 +12,12 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Legacy { public partial class TaikoLegacyHitTarget : CompositeDrawable { - private Container content = null!; - [BackgroundDependencyLoader] private void load(ISkinSource skin) { RelativeSizeAxes = Axes.Both; - InternalChild = content = new Container + InternalChild = new Container { RelativeSizeAxes = Axes.Both, Anchor = Anchor.Centre, @@ -46,14 +43,5 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Legacy } }; } - - protected override void Update() - { - base.Update(); - - // Relying on RelativeSizeAxes.Both + FillMode.Fit doesn't work due to the precise pixel layout requirements. - // This is a bit ugly but makes the non-legacy implementations a lot cleaner to implement. - content.Scale = new Vector2(DrawHeight / TaikoPlayfield.BASE_HEIGHT); - } } } From 5aa4235c3d3649f16b3319e12d14b4ebb83296b5 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 25 Jan 2024 21:02:22 +0900 Subject: [PATCH 6/7] Simplify `TaikoLegacyHitTarget` container hierarchy --- .../Skinning/Legacy/TaikoLegacyHitTarget.cs | 38 ++++++++----------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/osu.Game.Rulesets.Taiko/Skinning/Legacy/TaikoLegacyHitTarget.cs b/osu.Game.Rulesets.Taiko/Skinning/Legacy/TaikoLegacyHitTarget.cs index cf9d8dd52e..0b43f1c845 100644 --- a/osu.Game.Rulesets.Taiko/Skinning/Legacy/TaikoLegacyHitTarget.cs +++ b/osu.Game.Rulesets.Taiko/Skinning/Legacy/TaikoLegacyHitTarget.cs @@ -17,30 +17,24 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Legacy { RelativeSizeAxes = Axes.Both; - InternalChild = new Container + InternalChildren = new Drawable[] { - RelativeSizeAxes = Axes.Both, - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Children = new Drawable[] + new Sprite { - new Sprite - { - Texture = skin.GetTexture("approachcircle"), - Scale = new Vector2(0.83f), - Alpha = 0.47f, // eyeballed to match stable - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - }, - new Sprite - { - Texture = skin.GetTexture("taikobigcircle"), - Scale = new Vector2(0.8f), - Alpha = 0.22f, // eyeballed to match stable - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - }, - } + Texture = skin.GetTexture("approachcircle"), + Scale = new Vector2(0.83f), + Alpha = 0.47f, // eyeballed to match stable + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + }, + new Sprite + { + Texture = skin.GetTexture("taikobigcircle"), + Scale = new Vector2(0.8f), + Alpha = 0.22f, // eyeballed to match stable + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + }, }; } } From c35df0313f758c4747cbfe5f43e983511d005205 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Thu, 25 Jan 2024 16:31:12 +0300 Subject: [PATCH 7/7] Fix taiko playfield test scene --- .../Skinning/TestSceneTaikoPlayfield.cs | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/osu.Game.Rulesets.Taiko.Tests/Skinning/TestSceneTaikoPlayfield.cs b/osu.Game.Rulesets.Taiko.Tests/Skinning/TestSceneTaikoPlayfield.cs index c89e2b727b..d1a8a048ed 100644 --- a/osu.Game.Rulesets.Taiko.Tests/Skinning/TestSceneTaikoPlayfield.cs +++ b/osu.Game.Rulesets.Taiko.Tests/Skinning/TestSceneTaikoPlayfield.cs @@ -1,17 +1,19 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System; using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Extensions.IEnumerableExtensions; +using osu.Framework.Extensions.ObjectExtensions; using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; using osu.Framework.Testing; using osu.Game.Beatmaps.ControlPoints; using osu.Game.Rulesets.Taiko.Beatmaps; using osu.Game.Rulesets.Taiko.UI; using osu.Game.Rulesets.UI.Scrolling; using osu.Game.Tests.Visual; +using osuTK; namespace osu.Game.Rulesets.Taiko.Tests.Skinning { @@ -37,11 +39,14 @@ namespace osu.Game.Rulesets.Taiko.Tests.Skinning Beatmap.Value.Track.Start(); }); - AddStep("Load playfield", () => SetContents(_ => new TaikoPlayfield + AddStep("Load playfield", () => SetContents(_ => new Container { - Height = 0.2f, Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, + RelativeSizeAxes = Axes.Both, + Size = new Vector2(2f, 1f), + Scale = new Vector2(0.5f), + Child = new TaikoPlayfieldAdjustmentContainer { Child = new TaikoPlayfield() }, })); } @@ -54,7 +59,20 @@ namespace osu.Game.Rulesets.Taiko.Tests.Skinning [Test] public void TestHeightChanges() { - AddRepeatStep("change height", () => this.ChildrenOfType().ForEach(p => p.Height = Math.Max(0.2f, (p.Height + 0.2f) % 1f)), 50); + int value = 0; + + AddRepeatStep("change height", () => + { + value = (value + 1) % 5; + + this.ChildrenOfType().ForEach(p => + { + var parent = (Container)p.Parent.AsNonNull(); + parent.Scale = new Vector2(0.5f + 0.1f * value); + parent.Width = 1f / parent.Scale.X; + parent.Height = 0.5f / parent.Scale.Y; + }); + }, 50); } [Test]