mirror of
https://github.com/osukey/osukey.git
synced 2025-05-25 23:47:30 +09:00
Display difficulty and sample control points associated with hitobjects
This commit is contained in:
parent
a7ae3cc03e
commit
6015b5037a
@ -2,11 +2,12 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
{
|
||||
public class DifficultyPointPiece : TopPointPiece
|
||||
public class DifficultyPointPiece : HitObjectPointPiece
|
||||
{
|
||||
private readonly BindableNumber<double> speedMultiplier;
|
||||
|
||||
@ -14,13 +15,12 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
: base(point)
|
||||
{
|
||||
speedMultiplier = point.SliderVelocityBindable.GetBoundCopy();
|
||||
|
||||
Y = Height;
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
speedMultiplier.BindValueChanged(multiplier => Label.Text = $"{multiplier.NewValue:n2}x", true);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,63 @@
|
||||
// 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.Shapes;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
{
|
||||
public class HitObjectPointPiece : CircularContainer
|
||||
{
|
||||
private readonly ControlPoint point;
|
||||
|
||||
protected OsuSpriteText Label { get; private set; }
|
||||
|
||||
protected HitObjectPointPiece(ControlPoint point)
|
||||
{
|
||||
this.point = point;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
|
||||
Color4 colour = point.GetRepresentingColour(colours);
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new Container
|
||||
{
|
||||
AutoSizeAxes = Axes.X,
|
||||
Height = 16,
|
||||
Masking = true,
|
||||
CornerRadius = 8,
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Origin = Anchor.BottomCentre,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Colour = colour,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
Label = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Padding = new MarginPadding(5),
|
||||
Font = OsuFont.Default.With(size: 12, weight: FontWeight.SemiBold),
|
||||
Colour = colours.B5,
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -3,29 +3,20 @@
|
||||
|
||||
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.Beatmaps.ControlPoints;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
{
|
||||
public class SamplePointPiece : CompositeDrawable
|
||||
public class SamplePointPiece : HitObjectPointPiece
|
||||
{
|
||||
private readonly SampleControlPoint samplePoint;
|
||||
|
||||
private readonly Bindable<string> bank;
|
||||
private readonly BindableNumber<int> volume;
|
||||
|
||||
private OsuSpriteText text;
|
||||
private Container volumeBox;
|
||||
|
||||
private const int max_volume_height = 22;
|
||||
|
||||
public SamplePointPiece(SampleControlPoint samplePoint)
|
||||
: base(samplePoint)
|
||||
{
|
||||
this.samplePoint = samplePoint;
|
||||
volume = samplePoint.SampleVolumeBindable.GetBoundCopy();
|
||||
@ -35,56 +26,13 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
Margin = new MarginPadding { Vertical = 5 };
|
||||
volume.BindValueChanged(volume => updateText());
|
||||
bank.BindValueChanged(bank => updateText(), true);
|
||||
}
|
||||
|
||||
Origin = Anchor.BottomCentre;
|
||||
Anchor = Anchor.BottomCentre;
|
||||
|
||||
AutoSizeAxes = Axes.X;
|
||||
RelativeSizeAxes = Axes.Y;
|
||||
|
||||
Color4 colour = samplePoint.GetRepresentingColour(colours);
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
volumeBox = new Circle
|
||||
{
|
||||
CornerRadius = 5,
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Origin = Anchor.BottomCentre,
|
||||
Y = -20,
|
||||
Width = 10,
|
||||
Colour = colour,
|
||||
},
|
||||
new Container
|
||||
{
|
||||
AutoSizeAxes = Axes.X,
|
||||
Height = 16,
|
||||
Masking = true,
|
||||
CornerRadius = 8,
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Origin = Anchor.BottomCentre,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Colour = colour,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
text = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Padding = new MarginPadding(5),
|
||||
Font = OsuFont.Default.With(size: 12, weight: FontWeight.SemiBold),
|
||||
Colour = colours.B5,
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
volume.BindValueChanged(volume => volumeBox.Height = max_volume_height * volume.NewValue / 100f, true);
|
||||
bank.BindValueChanged(bank => text.Text = bank.NewValue, true);
|
||||
private void updateText()
|
||||
{
|
||||
Label.Text = $"{bank.Value} {volume.Value}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ using osu.Framework.Graphics.Primitives;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
@ -179,6 +180,15 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
colouredComponents.Colour = OsuColour.ForegroundTextColourFor(col);
|
||||
}
|
||||
|
||||
private SamplePointPiece sampleOverrideDisplay;
|
||||
private DifficultyPointPiece difficultyOverrideDisplay;
|
||||
|
||||
[Resolved]
|
||||
private EditorBeatmap beatmap { get; set; }
|
||||
|
||||
private DifficultyControlPoint difficultyControlPoint;
|
||||
private SampleControlPoint sampleControlPoint;
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
@ -194,6 +204,36 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
if (Item is IHasRepeats repeats)
|
||||
updateRepeats(repeats);
|
||||
}
|
||||
|
||||
if (difficultyControlPoint != Item.DifficultyControlPoint)
|
||||
{
|
||||
difficultyControlPoint = Item.DifficultyControlPoint;
|
||||
difficultyOverrideDisplay?.Expire();
|
||||
|
||||
if (Item.DifficultyControlPoint != null && Item is IHasDistance)
|
||||
{
|
||||
AddInternal(difficultyOverrideDisplay = new DifficultyPointPiece(Item.DifficultyControlPoint)
|
||||
{
|
||||
Anchor = Anchor.TopLeft,
|
||||
Origin = Anchor.BottomCentre
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (sampleControlPoint != Item.SampleControlPoint)
|
||||
{
|
||||
sampleControlPoint = Item.SampleControlPoint;
|
||||
sampleOverrideDisplay?.Expire();
|
||||
|
||||
if (Item.SampleControlPoint != null)
|
||||
{
|
||||
AddInternal(sampleOverrideDisplay = new SamplePointPiece(Item.SampleControlPoint)
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.TopCentre
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateRepeats(IHasRepeats repeats)
|
||||
|
Loading…
x
Reference in New Issue
Block a user