mirror of
https://github.com/ppy/osu
synced 2024-12-27 17:32:56 +00:00
Rewrite input drum measurements to autosize on X axis
This commit is contained in:
parent
c1693e4387
commit
b84a3b7834
@ -20,20 +20,22 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Legacy
|
||||
/// </summary>
|
||||
internal class LegacyInputDrum : Container
|
||||
{
|
||||
private Container content;
|
||||
private LegacyHalfDrum left;
|
||||
private LegacyHalfDrum right;
|
||||
|
||||
public LegacyInputDrum()
|
||||
{
|
||||
Size = new Vector2(180, 200);
|
||||
RelativeSizeAxes = Axes.Y;
|
||||
AutoSizeAxes = Axes.X;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(ISkinSource skin)
|
||||
{
|
||||
Child = new Container
|
||||
Child = content = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Size = new Vector2(180, 200),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Sprite
|
||||
@ -66,7 +68,7 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Legacy
|
||||
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 = Width / ratio;
|
||||
float negativeScaleAdjust = content.Width / ratio;
|
||||
|
||||
if (skin.GetConfig<SkinConfiguration.LegacySetting, decimal>(SkinConfiguration.LegacySetting.Version)?.Value >= 2.1m)
|
||||
{
|
||||
@ -90,7 +92,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.
|
||||
Scale = new Vector2(Parent.DrawHeight / Size.Y);
|
||||
content.Scale = new Vector2(DrawHeight / content.Size.Y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -12,6 +12,7 @@ using osu.Framework.Input.Events;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Rulesets.Taiko.Objects;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Screens.Ranking;
|
||||
using osu.Game.Skinning;
|
||||
using osuTK;
|
||||
|
||||
@ -24,8 +25,6 @@ namespace osu.Game.Rulesets.Taiko.UI
|
||||
{
|
||||
private const float middle_split = 0.025f;
|
||||
|
||||
public SkinnableDrawable Skinnable { get; private set; }
|
||||
|
||||
[Cached]
|
||||
private DrumSampleTriggerSource sampleTriggerSource;
|
||||
|
||||
@ -33,7 +32,8 @@ namespace osu.Game.Rulesets.Taiko.UI
|
||||
{
|
||||
sampleTriggerSource = new DrumSampleTriggerSource(hitObjectContainer);
|
||||
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
AutoSizeAxes = Axes.X;
|
||||
RelativeSizeAxes = Axes.Y;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -41,12 +41,32 @@ namespace osu.Game.Rulesets.Taiko.UI
|
||||
{
|
||||
Children = new Drawable[]
|
||||
{
|
||||
Skinnable = new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.InputDrum), _ => new Container
|
||||
new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.InputDrum), _ => new DefaultInputDrum())
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
AutoSizeAxes = Axes.X,
|
||||
},
|
||||
sampleTriggerSource
|
||||
};
|
||||
}
|
||||
|
||||
private class DefaultInputDrum : AspectContainer
|
||||
{
|
||||
public DefaultInputDrum()
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
InternalChild = new Container
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
FillMode = FillMode.Fit,
|
||||
Scale = new Vector2(0.9f),
|
||||
Children = new Drawable[]
|
||||
Children = new[]
|
||||
{
|
||||
new TaikoHalfDrum(false)
|
||||
{
|
||||
@ -71,11 +91,6 @@ namespace osu.Game.Rulesets.Taiko.UI
|
||||
CentreAction = TaikoAction.RightCentre
|
||||
}
|
||||
}
|
||||
})
|
||||
{
|
||||
CentreComponent = false,
|
||||
},
|
||||
sampleTriggerSource
|
||||
};
|
||||
}
|
||||
|
||||
@ -202,4 +217,5 @@ namespace osu.Game.Rulesets.Taiko.UI
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -77,6 +77,13 @@ namespace osu.Game.Rulesets.Taiko.UI
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.PlayfieldBackgroundLeft), _ => new PlayfieldBackgroundLeft()),
|
||||
inputDrum = new InputDrum(HitObjectContainer)
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
AutoSizeAxes = Axes.X,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
},
|
||||
}
|
||||
},
|
||||
mascot = new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.Mascot), _ => Empty())
|
||||
@ -154,13 +161,13 @@ namespace osu.Game.Rulesets.Taiko.UI
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
drumRollHitContainer.CreateProxy(),
|
||||
inputDrum = new InputDrum(HitObjectContainer)
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
},
|
||||
};
|
||||
|
||||
// to prioritise receiving key presses on input drum before objects, move input drum to the end of the hierarchy...
|
||||
leftArea.Remove(inputDrum);
|
||||
AddInternal(inputDrum);
|
||||
|
||||
// ...and create a proxy to keep the input drum displayed behind the playfield elements.
|
||||
leftArea.Add(inputDrum.CreateProxy());
|
||||
|
||||
RegisterPool<Hit, DrawableHit>(50);
|
||||
@ -207,8 +214,7 @@ namespace osu.Game.Rulesets.Taiko.UI
|
||||
|
||||
// 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.
|
||||
var inputDrumSize = inputDrum.Skinnable.Drawable.ToSpaceOfOtherDrawable(inputDrum.Skinnable.Drawable.DrawSize, this);
|
||||
rightArea.Padding = new MarginPadding { Left = inputDrumSize.X };
|
||||
rightArea.Padding = new MarginPadding { Left = inputDrum.Width };
|
||||
playfieldContent.Padding = new MarginPadding { Left = HitTarget.DrawWidth / 2 };
|
||||
playfieldOverlay.Padding = new MarginPadding { Left = HitTarget.DrawWidth / 2 };
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user