mirror of
https://github.com/ppy/osu.git
synced 2025-03-29 19:58:40 +08:00
Rewrite input drum measurements to autosize on X axis
This commit is contained in:
parent
c1693e4387
commit
b84a3b7834
osu.Game.Rulesets.Taiko
@ -20,20 +20,22 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Legacy
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
internal class LegacyInputDrum : Container
|
internal class LegacyInputDrum : Container
|
||||||
{
|
{
|
||||||
|
private Container content;
|
||||||
private LegacyHalfDrum left;
|
private LegacyHalfDrum left;
|
||||||
private LegacyHalfDrum right;
|
private LegacyHalfDrum right;
|
||||||
|
|
||||||
public LegacyInputDrum()
|
public LegacyInputDrum()
|
||||||
{
|
{
|
||||||
Size = new Vector2(180, 200);
|
RelativeSizeAxes = Axes.Y;
|
||||||
|
AutoSizeAxes = Axes.X;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(ISkinSource skin)
|
private void load(ISkinSource skin)
|
||||||
{
|
{
|
||||||
Child = new Container
|
Child = content = new Container
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
Size = new Vector2(180, 200),
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new Sprite
|
new Sprite
|
||||||
@ -66,7 +68,7 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Legacy
|
|||||||
const float ratio = 1.6f;
|
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
|
// 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)
|
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.
|
// 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.
|
// 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>
|
/// <summary>
|
||||||
|
@ -12,6 +12,7 @@ using osu.Framework.Input.Events;
|
|||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Rulesets.Taiko.Objects;
|
using osu.Game.Rulesets.Taiko.Objects;
|
||||||
using osu.Game.Rulesets.UI;
|
using osu.Game.Rulesets.UI;
|
||||||
|
using osu.Game.Screens.Ranking;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
@ -24,8 +25,6 @@ namespace osu.Game.Rulesets.Taiko.UI
|
|||||||
{
|
{
|
||||||
private const float middle_split = 0.025f;
|
private const float middle_split = 0.025f;
|
||||||
|
|
||||||
public SkinnableDrawable Skinnable { get; private set; }
|
|
||||||
|
|
||||||
[Cached]
|
[Cached]
|
||||||
private DrumSampleTriggerSource sampleTriggerSource;
|
private DrumSampleTriggerSource sampleTriggerSource;
|
||||||
|
|
||||||
@ -33,7 +32,8 @@ namespace osu.Game.Rulesets.Taiko.UI
|
|||||||
{
|
{
|
||||||
sampleTriggerSource = new DrumSampleTriggerSource(hitObjectContainer);
|
sampleTriggerSource = new DrumSampleTriggerSource(hitObjectContainer);
|
||||||
|
|
||||||
RelativeSizeAxes = Axes.Both;
|
AutoSizeAxes = Axes.X;
|
||||||
|
RelativeSizeAxes = Axes.Y;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -41,12 +41,32 @@ namespace osu.Game.Rulesets.Taiko.UI
|
|||||||
{
|
{
|
||||||
Children = new Drawable[]
|
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,
|
RelativeSizeAxes = Axes.Both,
|
||||||
FillMode = FillMode.Fit,
|
|
||||||
Scale = new Vector2(0.9f),
|
Scale = new Vector2(0.9f),
|
||||||
Children = new Drawable[]
|
Children = new[]
|
||||||
{
|
{
|
||||||
new TaikoHalfDrum(false)
|
new TaikoHalfDrum(false)
|
||||||
{
|
{
|
||||||
@ -71,134 +91,130 @@ namespace osu.Game.Rulesets.Taiko.UI
|
|||||||
CentreAction = TaikoAction.RightCentre
|
CentreAction = TaikoAction.RightCentre
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
|
||||||
{
|
|
||||||
CentreComponent = false,
|
|
||||||
},
|
|
||||||
sampleTriggerSource
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// A half-drum. Contains one centre and one rim hit.
|
|
||||||
/// </summary>
|
|
||||||
private class TaikoHalfDrum : Container, IKeyBindingHandler<TaikoAction>
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// The key to be used for the rim of the half-drum.
|
|
||||||
/// </summary>
|
|
||||||
public TaikoAction RimAction;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The key to be used for the centre of the half-drum.
|
|
||||||
/// </summary>
|
|
||||||
public TaikoAction CentreAction;
|
|
||||||
|
|
||||||
private readonly Sprite rim;
|
|
||||||
private readonly Sprite rimHit;
|
|
||||||
private readonly Sprite centre;
|
|
||||||
private readonly Sprite centreHit;
|
|
||||||
|
|
||||||
[Resolved]
|
|
||||||
private DrumSampleTriggerSource sampleTriggerSource { get; set; }
|
|
||||||
|
|
||||||
public TaikoHalfDrum(bool flipped)
|
|
||||||
{
|
|
||||||
Masking = true;
|
|
||||||
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
rim = new Sprite
|
|
||||||
{
|
|
||||||
Anchor = flipped ? Anchor.CentreLeft : Anchor.CentreRight,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
RelativeSizeAxes = Axes.Both
|
|
||||||
},
|
|
||||||
rimHit = new Sprite
|
|
||||||
{
|
|
||||||
Anchor = flipped ? Anchor.CentreLeft : Anchor.CentreRight,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Alpha = 0,
|
|
||||||
Blending = BlendingParameters.Additive,
|
|
||||||
},
|
|
||||||
centre = new Sprite
|
|
||||||
{
|
|
||||||
Anchor = flipped ? Anchor.CentreLeft : Anchor.CentreRight,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Size = new Vector2(0.7f)
|
|
||||||
},
|
|
||||||
centreHit = new Sprite
|
|
||||||
{
|
|
||||||
Anchor = flipped ? Anchor.CentreLeft : Anchor.CentreRight,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Size = new Vector2(0.7f),
|
|
||||||
Alpha = 0,
|
|
||||||
Blending = BlendingParameters.Additive
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
/// <summary>
|
||||||
private void load(TextureStore textures, OsuColour colours)
|
/// A half-drum. Contains one centre and one rim hit.
|
||||||
|
/// </summary>
|
||||||
|
private class TaikoHalfDrum : Container, IKeyBindingHandler<TaikoAction>
|
||||||
{
|
{
|
||||||
rim.Texture = textures.Get(@"Gameplay/taiko/taiko-drum-outer");
|
/// <summary>
|
||||||
rimHit.Texture = textures.Get(@"Gameplay/taiko/taiko-drum-outer-hit");
|
/// The key to be used for the rim of the half-drum.
|
||||||
centre.Texture = textures.Get(@"Gameplay/taiko/taiko-drum-inner");
|
/// </summary>
|
||||||
centreHit.Texture = textures.Get(@"Gameplay/taiko/taiko-drum-inner-hit");
|
public TaikoAction RimAction;
|
||||||
|
|
||||||
rimHit.Colour = colours.Blue;
|
/// <summary>
|
||||||
centreHit.Colour = colours.Pink;
|
/// The key to be used for the centre of the half-drum.
|
||||||
}
|
/// </summary>
|
||||||
|
public TaikoAction CentreAction;
|
||||||
|
|
||||||
public bool OnPressed(KeyBindingPressEvent<TaikoAction> e)
|
private readonly Sprite rim;
|
||||||
{
|
private readonly Sprite rimHit;
|
||||||
Drawable target = null;
|
private readonly Sprite centre;
|
||||||
Drawable back = null;
|
private readonly Sprite centreHit;
|
||||||
|
|
||||||
if (e.Action == CentreAction)
|
[Resolved]
|
||||||
|
private DrumSampleTriggerSource sampleTriggerSource { get; set; }
|
||||||
|
|
||||||
|
public TaikoHalfDrum(bool flipped)
|
||||||
{
|
{
|
||||||
target = centreHit;
|
Masking = true;
|
||||||
back = centre;
|
|
||||||
|
|
||||||
sampleTriggerSource.Play(HitType.Centre);
|
Children = new Drawable[]
|
||||||
}
|
{
|
||||||
else if (e.Action == RimAction)
|
rim = new Sprite
|
||||||
{
|
{
|
||||||
target = rimHit;
|
Anchor = flipped ? Anchor.CentreLeft : Anchor.CentreRight,
|
||||||
back = rim;
|
Origin = Anchor.Centre,
|
||||||
|
RelativeSizeAxes = Axes.Both
|
||||||
sampleTriggerSource.Play(HitType.Rim);
|
},
|
||||||
|
rimHit = new Sprite
|
||||||
|
{
|
||||||
|
Anchor = flipped ? Anchor.CentreLeft : Anchor.CentreRight,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Alpha = 0,
|
||||||
|
Blending = BlendingParameters.Additive,
|
||||||
|
},
|
||||||
|
centre = new Sprite
|
||||||
|
{
|
||||||
|
Anchor = flipped ? Anchor.CentreLeft : Anchor.CentreRight,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Size = new Vector2(0.7f)
|
||||||
|
},
|
||||||
|
centreHit = new Sprite
|
||||||
|
{
|
||||||
|
Anchor = flipped ? Anchor.CentreLeft : Anchor.CentreRight,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Size = new Vector2(0.7f),
|
||||||
|
Alpha = 0,
|
||||||
|
Blending = BlendingParameters.Additive
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target != null)
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(TextureStore textures, OsuColour colours)
|
||||||
{
|
{
|
||||||
const float scale_amount = 0.05f;
|
rim.Texture = textures.Get(@"Gameplay/taiko/taiko-drum-outer");
|
||||||
const float alpha_amount = 0.5f;
|
rimHit.Texture = textures.Get(@"Gameplay/taiko/taiko-drum-outer-hit");
|
||||||
|
centre.Texture = textures.Get(@"Gameplay/taiko/taiko-drum-inner");
|
||||||
|
centreHit.Texture = textures.Get(@"Gameplay/taiko/taiko-drum-inner-hit");
|
||||||
|
|
||||||
const float down_time = 40;
|
rimHit.Colour = colours.Blue;
|
||||||
const float up_time = 1000;
|
centreHit.Colour = colours.Pink;
|
||||||
|
|
||||||
back.ScaleTo(target.Scale.X - scale_amount, down_time, Easing.OutQuint)
|
|
||||||
.Then()
|
|
||||||
.ScaleTo(1, up_time, Easing.OutQuint);
|
|
||||||
|
|
||||||
target.Animate(
|
|
||||||
t => t.ScaleTo(target.Scale.X - scale_amount, down_time, Easing.OutQuint),
|
|
||||||
t => t.FadeTo(Math.Min(target.Alpha + alpha_amount, 1), down_time, Easing.OutQuint)
|
|
||||||
).Then(
|
|
||||||
t => t.ScaleTo(1, up_time, Easing.OutQuint),
|
|
||||||
t => t.FadeOut(up_time, Easing.OutQuint)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
public bool OnPressed(KeyBindingPressEvent<TaikoAction> e)
|
||||||
}
|
{
|
||||||
|
Drawable target = null;
|
||||||
|
Drawable back = null;
|
||||||
|
|
||||||
public void OnReleased(KeyBindingReleaseEvent<TaikoAction> e)
|
if (e.Action == CentreAction)
|
||||||
{
|
{
|
||||||
|
target = centreHit;
|
||||||
|
back = centre;
|
||||||
|
|
||||||
|
sampleTriggerSource.Play(HitType.Centre);
|
||||||
|
}
|
||||||
|
else if (e.Action == RimAction)
|
||||||
|
{
|
||||||
|
target = rimHit;
|
||||||
|
back = rim;
|
||||||
|
|
||||||
|
sampleTriggerSource.Play(HitType.Rim);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (target != null)
|
||||||
|
{
|
||||||
|
const float scale_amount = 0.05f;
|
||||||
|
const float alpha_amount = 0.5f;
|
||||||
|
|
||||||
|
const float down_time = 40;
|
||||||
|
const float up_time = 1000;
|
||||||
|
|
||||||
|
back.ScaleTo(target.Scale.X - scale_amount, down_time, Easing.OutQuint)
|
||||||
|
.Then()
|
||||||
|
.ScaleTo(1, up_time, Easing.OutQuint);
|
||||||
|
|
||||||
|
target.Animate(
|
||||||
|
t => t.ScaleTo(target.Scale.X - scale_amount, down_time, Easing.OutQuint),
|
||||||
|
t => t.FadeTo(Math.Min(target.Alpha + alpha_amount, 1), down_time, Easing.OutQuint)
|
||||||
|
).Then(
|
||||||
|
t => t.ScaleTo(1, up_time, Easing.OutQuint),
|
||||||
|
t => t.FadeOut(up_time, Easing.OutQuint)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnReleased(KeyBindingReleaseEvent<TaikoAction> e)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,6 +77,13 @@ namespace osu.Game.Rulesets.Taiko.UI
|
|||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.PlayfieldBackgroundLeft), _ => new PlayfieldBackgroundLeft()),
|
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())
|
mascot = new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.Mascot), _ => Empty())
|
||||||
@ -154,13 +161,13 @@ namespace osu.Game.Rulesets.Taiko.UI
|
|||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
},
|
},
|
||||||
drumRollHitContainer.CreateProxy(),
|
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());
|
leftArea.Add(inputDrum.CreateProxy());
|
||||||
|
|
||||||
RegisterPool<Hit, DrawableHit>(50);
|
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.
|
// 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.
|
// 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 = inputDrum.Width };
|
||||||
rightArea.Padding = new MarginPadding { Left = inputDrumSize.X };
|
|
||||||
playfieldContent.Padding = new MarginPadding { Left = HitTarget.DrawWidth / 2 };
|
playfieldContent.Padding = new MarginPadding { Left = HitTarget.DrawWidth / 2 };
|
||||||
playfieldOverlay.Padding = new MarginPadding { Left = HitTarget.DrawWidth / 2 };
|
playfieldOverlay.Padding = new MarginPadding { Left = HitTarget.DrawWidth / 2 };
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user