2020-04-03 09:23:03 +00:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
using osu.Framework.Input.Bindings;
|
2021-09-16 09:26:12 +00:00
|
|
|
using osu.Framework.Input.Events;
|
2024-01-19 20:26:35 +00:00
|
|
|
using osu.Game.Rulesets.Taiko.UI;
|
2020-04-03 09:23:03 +00:00
|
|
|
using osu.Game.Skinning;
|
|
|
|
using osuTK;
|
|
|
|
|
2020-12-07 03:30:25 +00:00
|
|
|
namespace osu.Game.Rulesets.Taiko.Skinning.Legacy
|
2020-04-03 09:23:03 +00:00
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// A component of the playfield that captures input and displays input as a drum.
|
|
|
|
/// </summary>
|
|
|
|
internal partial class LegacyInputDrum : Container
|
|
|
|
{
|
2022-11-02 08:07:19 +00:00
|
|
|
private LegacyHalfDrum left = null!;
|
|
|
|
private LegacyHalfDrum right = null!;
|
2020-04-07 10:14:31 +00:00
|
|
|
|
2020-04-03 09:23:03 +00:00
|
|
|
public LegacyInputDrum()
|
|
|
|
{
|
2024-01-19 20:26:35 +00:00
|
|
|
RelativeSizeAxes = Axes.Both;
|
2020-04-03 09:23:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(ISkinSource skin)
|
|
|
|
{
|
2024-01-19 20:26:35 +00:00
|
|
|
Child = new Container
|
2020-04-03 09:23:03 +00:00
|
|
|
{
|
2024-01-19 20:26:35 +00:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
2020-04-23 04:07:30 +00:00
|
|
|
Children = new Drawable[]
|
2020-04-03 09:23:03 +00:00
|
|
|
{
|
2020-04-23 04:07:30 +00:00
|
|
|
new Sprite
|
|
|
|
{
|
|
|
|
Texture = skin.GetTexture("taiko-bar-left")
|
|
|
|
},
|
|
|
|
left = new LegacyHalfDrum(false)
|
|
|
|
{
|
|
|
|
Name = "Left Half",
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
RimAction = TaikoAction.LeftRim,
|
|
|
|
CentreAction = TaikoAction.LeftCentre
|
|
|
|
},
|
|
|
|
right = new LegacyHalfDrum(true)
|
|
|
|
{
|
|
|
|
Name = "Right Half",
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
Scale = new Vector2(-1, 1),
|
|
|
|
RimAction = TaikoAction.RightRim,
|
|
|
|
CentreAction = TaikoAction.RightCentre
|
|
|
|
}
|
2020-04-03 09:23:03 +00:00
|
|
|
}
|
|
|
|
};
|
2020-04-07 10:14:31 +00:00
|
|
|
|
|
|
|
// this will be used in the future for stable skin alignment. keeping here for reference.
|
|
|
|
const float taiko_bar_y = 0;
|
|
|
|
|
|
|
|
// stable things
|
|
|
|
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
|
2024-01-19 20:26:35 +00:00
|
|
|
const float negative_scale_adjust = TaikoPlayfield.INPUT_DRUM_WIDTH / ratio;
|
2020-04-07 10:14:31 +00:00
|
|
|
|
2021-10-22 05:41:59 +00:00
|
|
|
if (skin.GetConfig<SkinConfiguration.LegacySetting, decimal>(SkinConfiguration.LegacySetting.Version)?.Value >= 2.1m)
|
2020-04-07 10:14:31 +00:00
|
|
|
{
|
|
|
|
left.Centre.Position = new Vector2(0, taiko_bar_y) * ratio;
|
2024-01-19 20:26:35 +00:00
|
|
|
right.Centre.Position = new Vector2(negative_scale_adjust - 56, taiko_bar_y) * ratio;
|
2020-04-07 10:14:31 +00:00
|
|
|
left.Rim.Position = new Vector2(0, taiko_bar_y) * ratio;
|
2024-01-19 20:26:35 +00:00
|
|
|
right.Rim.Position = new Vector2(negative_scale_adjust - 56, taiko_bar_y) * ratio;
|
2020-04-07 10:14:31 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
left.Centre.Position = new Vector2(18, taiko_bar_y + 31) * ratio;
|
2024-01-19 20:26:35 +00:00
|
|
|
right.Centre.Position = new Vector2(negative_scale_adjust - 54, taiko_bar_y + 31) * ratio;
|
2020-04-07 10:14:31 +00:00
|
|
|
left.Rim.Position = new Vector2(8, taiko_bar_y + 23) * ratio;
|
2024-01-19 20:26:35 +00:00
|
|
|
right.Rim.Position = new Vector2(negative_scale_adjust - 53, taiko_bar_y + 23) * ratio;
|
2020-04-07 10:14:31 +00:00
|
|
|
}
|
2020-04-03 09:23:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// A half-drum. Contains one centre and one rim hit.
|
|
|
|
/// </summary>
|
|
|
|
private partial class LegacyHalfDrum : 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;
|
|
|
|
|
2020-04-07 10:14:31 +00:00
|
|
|
public readonly Sprite Rim;
|
|
|
|
public readonly Sprite Centre;
|
2020-04-03 09:23:03 +00:00
|
|
|
|
|
|
|
public LegacyHalfDrum(bool flipped)
|
|
|
|
{
|
|
|
|
Masking = true;
|
|
|
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
2020-04-07 10:14:31 +00:00
|
|
|
Rim = new Sprite
|
2020-04-03 09:23:03 +00:00
|
|
|
{
|
|
|
|
Scale = new Vector2(-1, 1),
|
2020-04-07 10:14:31 +00:00
|
|
|
Origin = flipped ? Anchor.TopLeft : Anchor.TopRight,
|
2020-04-03 09:23:03 +00:00
|
|
|
Alpha = 0,
|
|
|
|
},
|
2020-04-07 10:14:31 +00:00
|
|
|
Centre = new Sprite
|
2020-04-03 09:23:03 +00:00
|
|
|
{
|
|
|
|
Alpha = 0,
|
2020-04-07 10:14:31 +00:00
|
|
|
Origin = flipped ? Anchor.TopRight : Anchor.TopLeft,
|
2020-04-03 09:23:03 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(ISkinSource skin)
|
|
|
|
{
|
2020-04-07 10:14:31 +00:00
|
|
|
Rim.Texture = skin.GetTexture(@"taiko-drum-outer");
|
|
|
|
Centre.Texture = skin.GetTexture(@"taiko-drum-inner");
|
2020-04-03 09:23:03 +00:00
|
|
|
}
|
|
|
|
|
2021-09-16 09:26:12 +00:00
|
|
|
public bool OnPressed(KeyBindingPressEvent<TaikoAction> e)
|
2020-04-03 09:23:03 +00:00
|
|
|
{
|
2022-11-02 08:07:19 +00:00
|
|
|
Drawable? target = null;
|
2020-04-03 09:23:03 +00:00
|
|
|
|
2021-09-16 09:26:12 +00:00
|
|
|
if (e.Action == CentreAction)
|
2020-04-03 09:23:03 +00:00
|
|
|
{
|
2020-04-07 10:14:31 +00:00
|
|
|
target = Centre;
|
2020-04-03 09:23:03 +00:00
|
|
|
}
|
2021-09-16 09:26:12 +00:00
|
|
|
else if (e.Action == RimAction)
|
2020-04-03 09:23:03 +00:00
|
|
|
{
|
2020-04-07 10:14:31 +00:00
|
|
|
target = Rim;
|
2020-04-03 09:23:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (target != null)
|
|
|
|
{
|
|
|
|
const float down_time = 80;
|
|
|
|
const float up_time = 50;
|
|
|
|
|
2024-01-18 07:22:26 +00:00
|
|
|
target
|
|
|
|
.FadeTo(1, down_time * (1 - target.Alpha), Easing.Out)
|
|
|
|
.Delay(100).FadeOut(up_time);
|
2020-04-03 09:23:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-09-16 09:26:12 +00:00
|
|
|
public void OnReleased(KeyBindingReleaseEvent<TaikoAction> e)
|
2020-04-03 09:23:03 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|