1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 20:07:25 +08:00

Refactor taiko playfield layout to use constant values

This commit is contained in:
Salman Ahmed 2024-01-19 23:58:55 +03:00
parent 3e17d01ceb
commit f5ce9eaf75

View File

@ -21,7 +21,6 @@ using osu.Game.Rulesets.Taiko.Judgements;
using osu.Game.Rulesets.Taiko.Objects; using osu.Game.Rulesets.Taiko.Objects;
using osu.Game.Rulesets.Taiko.Scoring; using osu.Game.Rulesets.Taiko.Scoring;
using osu.Game.Skinning; using osu.Game.Skinning;
using osuTK;
namespace osu.Game.Rulesets.Taiko.UI namespace osu.Game.Rulesets.Taiko.UI
{ {
@ -44,7 +43,6 @@ namespace osu.Game.Rulesets.Taiko.UI
private JudgementContainer<DrawableTaikoJudgement> judgementContainer = null!; private JudgementContainer<DrawableTaikoJudgement> judgementContainer = null!;
private ScrollingHitObjectContainer drumRollHitContainer = null!; private ScrollingHitObjectContainer drumRollHitContainer = null!;
internal Drawable HitTarget = null!; internal Drawable HitTarget = null!;
private SkinnableDrawable mascot = null!;
private JudgementPooler<DrawableTaikoJudgement> judgementPooler = null!; private JudgementPooler<DrawableTaikoJudgement> judgementPooler = null!;
private readonly IDictionary<HitResult, HitExplosionPool> explosionPools = new Dictionary<HitResult, HitExplosionPool>(); private readonly IDictionary<HitResult, HitExplosionPool> explosionPools = new Dictionary<HitResult, HitExplosionPool>();
@ -59,13 +57,11 @@ namespace osu.Game.Rulesets.Taiko.UI
/// </remarks> /// </remarks>
private BarLinePlayfield barLinePlayfield = null!; private BarLinePlayfield barLinePlayfield = null!;
private Container barLineContent = null!;
private Container hitObjectContent = null!;
private Container overlayContent = null!;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)
{ {
const float hit_target_width = BASE_HEIGHT;
inputDrum = new InputDrum inputDrum = new InputDrum
{ {
Anchor = Anchor.CentreLeft, Anchor = Anchor.CentreLeft,
@ -89,7 +85,7 @@ namespace osu.Game.Rulesets.Taiko.UI
inputDrum.CreateProxy(), inputDrum.CreateProxy(),
} }
}, },
mascot = new SkinnableDrawable(new TaikoSkinComponentLookup(TaikoSkinComponents.Mascot), _ => Empty()) new SkinnableDrawable(new TaikoSkinComponentLookup(TaikoSkinComponents.Mascot), _ => Empty())
{ {
Origin = Anchor.BottomLeft, Origin = Anchor.BottomLeft,
Anchor = Anchor.TopLeft, Anchor = Anchor.TopLeft,
@ -101,14 +97,13 @@ namespace osu.Game.Rulesets.Taiko.UI
{ {
Name = "Right area", Name = "Right area",
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
RelativePositionAxes = Axes.Both,
Children = new Drawable[] Children = new Drawable[]
{ {
new Container new Container
{ {
Name = "Elements before hit objects", Name = "Elements behind hit objects",
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Y,
FillMode = FillMode.Fit, Width = hit_target_width,
Children = new[] Children = new[]
{ {
new SkinnableDrawable(new TaikoSkinComponentLookup(TaikoSkinComponents.KiaiGlow), _ => Empty()) 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", Name = "Bar line content",
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Left = hit_target_width / 2 },
Children = new Drawable[] Children = new Drawable[]
{ {
UnderlayElements = new Container UnderlayElements = new Container
@ -138,17 +134,19 @@ namespace osu.Game.Rulesets.Taiko.UI
barLinePlayfield = new BarLinePlayfield(), barLinePlayfield = new BarLinePlayfield(),
} }
}, },
hitObjectContent = new Container new Container
{ {
Name = "Masked hit objects content", Name = "Masked hit objects content",
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Left = hit_target_width / 2 },
Masking = true, Masking = true,
Child = HitObjectContainer, Child = HitObjectContainer,
}, },
overlayContent = new Container new Container
{ {
Name = "Elements after hit objects", Name = "Overlay content",
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Left = hit_target_width / 2 },
Children = new Drawable[] Children = new Drawable[]
{ {
drumRollHitContainer = new DrumRollHitContainer(), drumRollHitContainer = new DrumRollHitContainer(),
@ -226,14 +224,8 @@ namespace osu.Game.Rulesets.Taiko.UI
{ {
base.Update(); base.Update();
// Padding is required to be updated for elements which are based on "absolute" X sized elements. // todo: input drum width should be constant.
// This is basically allowing for correct alignment as relative pieces move around them. rightArea.Padding = new MarginPadding { Left = inputDrum.DrawWidth };
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);
} }
#region Pooling support #region Pooling support