mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 08:49:59 +09:00
Separate out timeline control point display from summary timeline display
This commit is contained in:
@ -0,0 +1,66 @@
|
|||||||
|
// 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.Beatmaps.ControlPoints;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.Sprites;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||||
|
{
|
||||||
|
public class DifficultyPointPiece : CompositeDrawable
|
||||||
|
{
|
||||||
|
private OsuSpriteText speedMultiplierText;
|
||||||
|
private readonly BindableNumber<double> speedMultiplier;
|
||||||
|
|
||||||
|
public DifficultyPointPiece(DifficultyControlPoint point)
|
||||||
|
{
|
||||||
|
speedMultiplier = point.SpeedMultiplierBindable.GetBoundCopy();
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuColour colours)
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Y;
|
||||||
|
AutoSizeAxes = Axes.X;
|
||||||
|
|
||||||
|
Color4 colour = colours.GreenDark;
|
||||||
|
|
||||||
|
InternalChildren = new Drawable[]
|
||||||
|
{
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
Colour = colour,
|
||||||
|
Width = 2,
|
||||||
|
RelativeSizeAxes = Axes.Y,
|
||||||
|
},
|
||||||
|
new Container
|
||||||
|
{
|
||||||
|
Anchor = Anchor.BottomLeft,
|
||||||
|
Origin = Anchor.BottomLeft,
|
||||||
|
AutoSizeAxes = Axes.Both,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
Colour = colour,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
},
|
||||||
|
speedMultiplierText = new OsuSpriteText
|
||||||
|
{
|
||||||
|
Font = OsuFont.Default.With(weight: FontWeight.Bold),
|
||||||
|
Colour = Color4.White,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
speedMultiplier.BindValueChanged(multiplier => speedMultiplierText.Text = $"{multiplier.NewValue:n2}x", true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -13,7 +13,6 @@ using osu.Framework.Input.Events;
|
|||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Rulesets.Edit;
|
using osu.Game.Rulesets.Edit;
|
||||||
using osu.Game.Screens.Edit.Components.Timelines.Summary.Parts;
|
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||||
@ -63,9 +62,11 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
}
|
}
|
||||||
|
|
||||||
private WaveformGraph waveform;
|
private WaveformGraph waveform;
|
||||||
private ControlPointPart controlPoints;
|
|
||||||
private TimelineTickDisplay ticks;
|
private TimelineTickDisplay ticks;
|
||||||
|
|
||||||
|
private TimelineControlPointDisplay controlPoints;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(IBindable<WorkingBeatmap> beatmap, OsuColour colours)
|
private void load(IBindable<WorkingBeatmap> beatmap, OsuColour colours)
|
||||||
{
|
{
|
||||||
@ -85,10 +86,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
MidColour = colours.BlueDark,
|
MidColour = colours.BlueDark,
|
||||||
HighColour = colours.BlueDarker,
|
HighColour = colours.BlueDarker,
|
||||||
},
|
},
|
||||||
controlPoints = new ControlPointPart
|
controlPoints = new TimelineControlPointDisplay(),
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both
|
|
||||||
},
|
|
||||||
ticks = new TimelineTickDisplay(),
|
ticks = new TimelineTickDisplay(),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -0,0 +1,57 @@
|
|||||||
|
// 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 System.Collections.Specialized;
|
||||||
|
using System.Linq;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
|
using osu.Game.Screens.Edit.Components.Timelines.Summary.Parts;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The part of the timeline that displays the control points.
|
||||||
|
/// </summary>
|
||||||
|
public class TimelineControlPointDisplay : TimelinePart<TimelineControlPointGroup>
|
||||||
|
{
|
||||||
|
private IBindableList<ControlPointGroup> controlPointGroups;
|
||||||
|
|
||||||
|
public TimelineControlPointDisplay()
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadBeatmap(WorkingBeatmap beatmap)
|
||||||
|
{
|
||||||
|
base.LoadBeatmap(beatmap);
|
||||||
|
|
||||||
|
controlPointGroups = beatmap.Beatmap.ControlPointInfo.Groups.GetBoundCopy();
|
||||||
|
controlPointGroups.BindCollectionChanged((sender, args) =>
|
||||||
|
{
|
||||||
|
switch (args.Action)
|
||||||
|
{
|
||||||
|
case NotifyCollectionChangedAction.Reset:
|
||||||
|
Clear();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case NotifyCollectionChangedAction.Add:
|
||||||
|
foreach (var group in args.NewItems.OfType<ControlPointGroup>())
|
||||||
|
Add(new TimelineControlPointGroup(group));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case NotifyCollectionChangedAction.Remove:
|
||||||
|
foreach (var group in args.OldItems.OfType<ControlPointGroup>())
|
||||||
|
{
|
||||||
|
var matching = Children.SingleOrDefault(gv => gv.Group == group);
|
||||||
|
|
||||||
|
matching?.Expire();
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,55 @@
|
|||||||
|
// 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.Game.Beatmaps.ControlPoints;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||||
|
{
|
||||||
|
public class TimelineControlPointGroup : CompositeDrawable
|
||||||
|
{
|
||||||
|
public readonly ControlPointGroup Group;
|
||||||
|
|
||||||
|
private BindableList<ControlPoint> controlPoints;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private OsuColour colours { get; set; }
|
||||||
|
|
||||||
|
public TimelineControlPointGroup(ControlPointGroup group)
|
||||||
|
{
|
||||||
|
Origin = Anchor.TopCentre;
|
||||||
|
|
||||||
|
Group = group;
|
||||||
|
|
||||||
|
RelativePositionAxes = Axes.X;
|
||||||
|
RelativeSizeAxes = Axes.Y;
|
||||||
|
|
||||||
|
Width = 1;
|
||||||
|
|
||||||
|
X = (float)group.Time;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
controlPoints = (BindableList<ControlPoint>)Group.ControlPoints.GetBoundCopy();
|
||||||
|
controlPoints.BindCollectionChanged((_, __) =>
|
||||||
|
{
|
||||||
|
foreach (var point in controlPoints)
|
||||||
|
{
|
||||||
|
switch (point)
|
||||||
|
{
|
||||||
|
case DifficultyControlPoint difficultyPoint:
|
||||||
|
AddInternal(new DifficultyPointPiece(difficultyPoint));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user