Skip to content

Define constant input drum width for osu!taiko #26632

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions osu.Game.Rulesets.Taiko.Tests/Skinning/TestSceneInputDrum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@ private void load()
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(200),
Child = new InputDrum()
Size = new Vector2(180f, 200f),
Child = new InputDrum
{
RelativeSizeAxes = Axes.Both,
}
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Taiko/Skinning/Argon/ArgonInputDrum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public partial class ArgonInputDrum : AspectContainer

public ArgonInputDrum()
{
RelativeSizeAxes = Axes.Y;
RelativeSizeAxes = Axes.X;
}

[BackgroundDependencyLoader]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public partial class DefaultInputDrum : AspectContainer
{
public DefaultInputDrum()
{
RelativeSizeAxes = Axes.Y;
RelativeSizeAxes = Axes.X;
}

[BackgroundDependencyLoader]
Expand Down
28 changes: 9 additions & 19 deletions osu.Game.Rulesets.Taiko/Skinning/Legacy/LegacyInputDrum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Game.Rulesets.Taiko.UI;
using osu.Game.Skinning;
using osuTK;

Expand All @@ -17,22 +18,20 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Legacy
/// </summary>
internal partial class LegacyInputDrum : Container
{
private Container content = null!;
private LegacyHalfDrum left = null!;
private LegacyHalfDrum right = null!;

public LegacyInputDrum()
{
RelativeSizeAxes = Axes.Y;
AutoSizeAxes = Axes.X;
RelativeSizeAxes = Axes.Both;
}

[BackgroundDependencyLoader]
private void load(ISkinSource skin)
{
Child = content = new Container
Child = new Container
{
Size = new Vector2(180, 200),
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
new Sprite
Expand Down Expand Up @@ -65,33 +64,24 @@ private void load(ISkinSource skin)
const float ratio = 1.6f;

// because the right half is flipped, we need to position using width - position to get the true "topleft" origin position
float negativeScaleAdjust = content.Width / ratio;
const float negative_scale_adjust = TaikoPlayfield.INPUT_DRUM_WIDTH / ratio;

if (skin.GetConfig<SkinConfiguration.LegacySetting, decimal>(SkinConfiguration.LegacySetting.Version)?.Value >= 2.1m)
{
left.Centre.Position = new Vector2(0, taiko_bar_y) * ratio;
right.Centre.Position = new Vector2(negativeScaleAdjust - 56, taiko_bar_y) * ratio;
right.Centre.Position = new Vector2(negative_scale_adjust - 56, taiko_bar_y) * ratio;
left.Rim.Position = new Vector2(0, taiko_bar_y) * ratio;
right.Rim.Position = new Vector2(negativeScaleAdjust - 56, taiko_bar_y) * ratio;
right.Rim.Position = new Vector2(negative_scale_adjust - 56, taiko_bar_y) * ratio;
}
else
{
left.Centre.Position = new Vector2(18, taiko_bar_y + 31) * ratio;
right.Centre.Position = new Vector2(negativeScaleAdjust - 54, taiko_bar_y + 31) * ratio;
right.Centre.Position = new Vector2(negative_scale_adjust - 54, taiko_bar_y + 31) * ratio;
left.Rim.Position = new Vector2(8, taiko_bar_y + 23) * ratio;
right.Rim.Position = new Vector2(negativeScaleAdjust - 53, taiko_bar_y + 23) * ratio;
right.Rim.Position = new Vector2(negative_scale_adjust - 53, taiko_bar_y + 23) * ratio;
}
}

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 / content.Size.Y);
}

/// <summary>
/// A half-drum. Contains one centre and one rim hit.
/// </summary>
Expand Down
9 changes: 1 addition & 8 deletions osu.Game.Rulesets.Taiko/UI/InputDrum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,14 @@ namespace osu.Game.Rulesets.Taiko.UI
/// </summary>
internal partial class InputDrum : Container
{
public InputDrum()
{
AutoSizeAxes = Axes.X;
RelativeSizeAxes = Axes.Y;
}

[BackgroundDependencyLoader]
private void load()
{
Children = new Drawable[]
{
new SkinnableDrawable(new TaikoSkinComponentLookup(TaikoSkinComponents.InputDrum), _ => new DefaultInputDrum())
{
RelativeSizeAxes = Axes.Y,
AutoSizeAxes = Axes.X,
RelativeSizeAxes = Axes.Both,
},
};
}
Expand Down
20 changes: 7 additions & 13 deletions osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public partial class TaikoPlayfield : ScrollingPlayfield
/// </summary>
public const float BASE_HEIGHT = 200;

public const float INPUT_DRUM_WIDTH = 180f;

/// <summary>
/// Whether the hit target should be nudged further towards the left area, matching the stable "classic" position.
/// </summary>
Expand All @@ -49,7 +51,6 @@ public partial class TaikoPlayfield : ScrollingPlayfield

private ProxyContainer topLevelHitContainer = null!;
private InputDrum inputDrum = null!;
private Container rightArea = null!;

/// <remarks>
/// <see cref="Playfield.AddNested"/> is purposefully not called on this to prevent i.e. being able to interact
Expand All @@ -66,8 +67,8 @@ private void load(OsuColour colours)
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
AutoSizeAxes = Axes.X,
RelativeSizeAxes = Axes.Y,
Width = INPUT_DRUM_WIDTH,
};

InternalChildren = new[]
Expand All @@ -76,8 +77,8 @@ private void load(OsuColour colours)
new Container
{
Name = "Left overlay",
RelativeSizeAxes = Axes.Both,
FillMode = FillMode.Fit,
RelativeSizeAxes = Axes.Y,
Width = INPUT_DRUM_WIDTH,
BorderColour = colours.Gray0,
Children = new[]
{
Expand All @@ -93,10 +94,11 @@ private void load(OsuColour colours)
RelativeSizeAxes = Axes.None,
Y = 0.2f
},
rightArea = new Container
new Container
{
Name = "Right area",
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Left = INPUT_DRUM_WIDTH },
Children = new Drawable[]
{
new Container
Expand Down Expand Up @@ -220,14 +222,6 @@ protected override void OnNewDrawableHitObject(DrawableHitObject drawableHitObje
topLevelHitContainer.Add(taikoObject.CreateProxiedContent());
}

protected override void Update()
{
base.Update();

// todo: input drum width should be constant.
rightArea.Padding = new MarginPadding { Left = inputDrum.DrawWidth };
}

#region Pooling support

public override void Add(HitObject h)
Expand Down