mirror of
https://github.com/ppy/osu.git
synced 2025-02-22 21:33:00 +08:00
Move major barline portion to default implementation to allow for further customisation
Of note, this removes the "major" barline triangles from legacy skins. I think this is more correct, as they did not display in stable.
This commit is contained in:
parent
cb6b9898c1
commit
c69a4f9333
@ -1,17 +1,12 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
using JetBrains.Annotations;
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
|
||||||
using osu.Framework.Graphics.Shapes;
|
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
using osuTK;
|
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
|
using osu.Game.Rulesets.Taiko.Skinning.Default;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
||||||
@ -28,35 +23,15 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private const float tracker_width = 2f;
|
private const float tracker_width = 2f;
|
||||||
|
|
||||||
/// <summary>
|
public readonly Bindable<bool> Major = new Bindable<bool>();
|
||||||
/// The vertical offset of the triangles from the line tracker.
|
|
||||||
/// </summary>
|
|
||||||
private const float triangle_offset = 10f;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The size of the triangles.
|
|
||||||
/// </summary>
|
|
||||||
private const float triangle_size = 20f;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The visual line tracker.
|
|
||||||
/// </summary>
|
|
||||||
private SkinnableDrawable line;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Container with triangles. Only visible for major lines.
|
|
||||||
/// </summary>
|
|
||||||
private Container triangleContainer;
|
|
||||||
|
|
||||||
private readonly Bindable<bool> major = new Bindable<bool>();
|
|
||||||
|
|
||||||
public DrawableBarLine()
|
public DrawableBarLine()
|
||||||
: this(null)
|
: this(null)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public DrawableBarLine([CanBeNull] BarLine barLine)
|
public DrawableBarLine(BarLine? barLine)
|
||||||
: base(barLine)
|
: base(barLine!)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,69 +44,23 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
|||||||
RelativeSizeAxes = Axes.Y;
|
RelativeSizeAxes = Axes.Y;
|
||||||
Width = tracker_width;
|
Width = tracker_width;
|
||||||
|
|
||||||
AddRangeInternal(new Drawable[]
|
AddInternal(new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.BarLine), _ => new DefaultBarLine())
|
||||||
{
|
{
|
||||||
line = new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.BarLine), _ => new Box
|
Anchor = Anchor.Centre,
|
||||||
{
|
Origin = Anchor.Centre,
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
EdgeSmoothness = new Vector2(0.5f, 0),
|
|
||||||
})
|
|
||||||
{
|
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
},
|
|
||||||
triangleContainer = new Container
|
|
||||||
{
|
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Children = new[]
|
|
||||||
{
|
|
||||||
new EquilateralTriangle
|
|
||||||
{
|
|
||||||
Name = "Top",
|
|
||||||
Anchor = Anchor.TopCentre,
|
|
||||||
Origin = Anchor.TopCentre,
|
|
||||||
Position = new Vector2(0, -triangle_offset),
|
|
||||||
Size = new Vector2(-triangle_size),
|
|
||||||
EdgeSmoothness = new Vector2(1),
|
|
||||||
},
|
|
||||||
new EquilateralTriangle
|
|
||||||
{
|
|
||||||
Name = "Bottom",
|
|
||||||
Anchor = Anchor.BottomCentre,
|
|
||||||
Origin = Anchor.TopCentre,
|
|
||||||
Position = new Vector2(0, triangle_offset),
|
|
||||||
Size = new Vector2(triangle_size),
|
|
||||||
EdgeSmoothness = new Vector2(1),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
|
||||||
{
|
|
||||||
base.LoadComplete();
|
|
||||||
major.BindValueChanged(updateMajor, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateMajor(ValueChangedEvent<bool> major)
|
|
||||||
{
|
|
||||||
line.Alpha = major.NewValue ? 1f : 0.75f;
|
|
||||||
triangleContainer.Alpha = major.NewValue ? 1 : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnApply()
|
protected override void OnApply()
|
||||||
{
|
{
|
||||||
base.OnApply();
|
base.OnApply();
|
||||||
major.BindTo(HitObject.MajorBindable);
|
Major.BindTo(HitObject.MajorBindable);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnFree()
|
protected override void OnFree()
|
||||||
{
|
{
|
||||||
base.OnFree();
|
base.OnFree();
|
||||||
major.UnbindFrom(HitObject.MajorBindable);
|
Major.UnbindFrom(HitObject.MajorBindable);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void UpdateHitStateTransforms(ArmedState state)
|
protected override void UpdateHitStateTransforms(ArmedState state)
|
||||||
|
94
osu.Game.Rulesets.Taiko/Skinning/Default/DefaultBarLine.cs
Normal file
94
osu.Game.Rulesets.Taiko/Skinning/Default/DefaultBarLine.cs
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
// 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.Bindables;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
|
using osu.Game.Rulesets.Taiko.Objects.Drawables;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Taiko.Skinning.Default
|
||||||
|
{
|
||||||
|
public class DefaultBarLine : CompositeDrawable
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The vertical offset of the triangles from the line tracker.
|
||||||
|
/// </summary>
|
||||||
|
private const float triangle_offset = 10f;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The size of the triangles.
|
||||||
|
/// </summary>
|
||||||
|
private const float triangle_size = 20f;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Container with triangles. Only visible for major lines.
|
||||||
|
/// </summary>
|
||||||
|
private Container triangleContainer = null!;
|
||||||
|
|
||||||
|
private Bindable<bool> major = null!;
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(DrawableHitObject drawableHitObject)
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
|
||||||
|
InternalChildren = new Drawable[]
|
||||||
|
{
|
||||||
|
line = new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
EdgeSmoothness = new Vector2(0.5f, 0),
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
},
|
||||||
|
triangleContainer = new Container
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Children = new[]
|
||||||
|
{
|
||||||
|
new EquilateralTriangle
|
||||||
|
{
|
||||||
|
Name = "Top",
|
||||||
|
Anchor = Anchor.TopCentre,
|
||||||
|
Origin = Anchor.TopCentre,
|
||||||
|
Position = new Vector2(0, -triangle_offset),
|
||||||
|
Size = new Vector2(-triangle_size),
|
||||||
|
EdgeSmoothness = new Vector2(1),
|
||||||
|
},
|
||||||
|
new EquilateralTriangle
|
||||||
|
{
|
||||||
|
Name = "Bottom",
|
||||||
|
Anchor = Anchor.BottomCentre,
|
||||||
|
Origin = Anchor.TopCentre,
|
||||||
|
Position = new Vector2(0, triangle_offset),
|
||||||
|
Size = new Vector2(triangle_size),
|
||||||
|
EdgeSmoothness = new Vector2(1),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
major = ((DrawableBarLine)drawableHitObject).Major.GetBoundCopy();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
major.BindValueChanged(updateMajor, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Box line = null!;
|
||||||
|
|
||||||
|
private void updateMajor(ValueChangedEvent<bool> major)
|
||||||
|
{
|
||||||
|
line.Alpha = major.NewValue ? 1f : 0.75f;
|
||||||
|
triangleContainer.Alpha = major.NewValue ? 1 : 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -736,7 +736,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
|||||||
{
|
{
|
||||||
public new TObject HitObject => (TObject)base.HitObject;
|
public new TObject HitObject => (TObject)base.HitObject;
|
||||||
|
|
||||||
protected DrawableHitObject(TObject hitObject)
|
protected DrawableHitObject([CanBeNull] TObject hitObject)
|
||||||
: base(hitObject)
|
: base(hitObject)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user