2019-10-18 16:59:54 +08: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 System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Extensions;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
2020-09-30 11:45:43 +08:00
|
|
|
using osu.Game.Extensions;
|
2019-10-18 16:59:54 +08:00
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
using osuTK;
|
2019-10-27 12:31:23 +08:00
|
|
|
using osuTK.Graphics;
|
2019-10-18 16:59:54 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Screens.Edit.Timing
|
|
|
|
{
|
2021-04-13 22:05:58 +08:00
|
|
|
public class ControlPointTable : EditorTable
|
2019-10-18 16:59:54 +08:00
|
|
|
{
|
|
|
|
[Resolved]
|
2019-10-25 19:13:22 +08:00
|
|
|
private Bindable<ControlPointGroup> selectedGroup { get; set; }
|
2019-10-18 16:59:54 +08:00
|
|
|
|
2021-04-13 22:26:19 +08:00
|
|
|
[Resolved]
|
|
|
|
private EditorClock clock { get; set; }
|
|
|
|
|
2019-10-25 19:13:22 +08:00
|
|
|
public IEnumerable<ControlPointGroup> ControlGroups
|
2019-10-18 16:59:54 +08:00
|
|
|
{
|
|
|
|
set
|
|
|
|
{
|
|
|
|
Content = null;
|
2021-04-13 22:05:58 +08:00
|
|
|
BackgroundFlow.Clear();
|
2019-10-18 16:59:54 +08:00
|
|
|
|
|
|
|
if (value?.Any() != true)
|
|
|
|
return;
|
|
|
|
|
2019-10-25 19:13:22 +08:00
|
|
|
foreach (var group in value)
|
2019-10-18 16:59:54 +08:00
|
|
|
{
|
2021-04-13 22:26:19 +08:00
|
|
|
BackgroundFlow.Add(new RowBackground(group)
|
|
|
|
{
|
|
|
|
Action = () =>
|
|
|
|
{
|
|
|
|
selectedGroup.Value = group;
|
|
|
|
clock.SeekSmoothlyTo(group.Time);
|
|
|
|
}
|
|
|
|
});
|
2019-10-18 16:59:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
Columns = createHeaders();
|
2019-10-25 19:13:22 +08:00
|
|
|
Content = value.Select((g, i) => createContent(i, g)).ToArray().ToRectangular();
|
2019-10-18 16:59:54 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-13 22:26:19 +08:00
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
|
|
selectedGroup.BindValueChanged(group =>
|
|
|
|
{
|
|
|
|
foreach (var b in BackgroundFlow) b.Selected = b.Item == group.NewValue;
|
|
|
|
}, true);
|
|
|
|
}
|
|
|
|
|
2019-10-18 16:59:54 +08:00
|
|
|
private TableColumn[] createHeaders()
|
|
|
|
{
|
|
|
|
var columns = new List<TableColumn>
|
|
|
|
{
|
|
|
|
new TableColumn(string.Empty, Anchor.Centre, new Dimension(GridSizeMode.AutoSize)),
|
2019-10-23 10:22:55 +08:00
|
|
|
new TableColumn("Time", Anchor.Centre, new Dimension(GridSizeMode.AutoSize)),
|
2021-02-08 17:34:32 +08:00
|
|
|
new TableColumn(),
|
|
|
|
new TableColumn("Attributes", Anchor.CentreLeft),
|
2019-10-18 16:59:54 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
return columns.ToArray();
|
|
|
|
}
|
|
|
|
|
2019-10-25 19:13:22 +08:00
|
|
|
private Drawable[] createContent(int index, ControlPointGroup group) => new Drawable[]
|
2019-10-18 16:59:54 +08:00
|
|
|
{
|
|
|
|
new OsuSpriteText
|
|
|
|
{
|
|
|
|
Text = $"#{index + 1}",
|
2021-04-13 22:05:58 +08:00
|
|
|
Font = OsuFont.GetFont(size: TEXT_SIZE, weight: FontWeight.Bold),
|
2019-10-18 16:59:54 +08:00
|
|
|
Margin = new MarginPadding(10)
|
|
|
|
},
|
|
|
|
new OsuSpriteText
|
|
|
|
{
|
2020-09-30 11:45:43 +08:00
|
|
|
Text = group.Time.ToEditorFormattedString(),
|
2021-04-13 22:05:58 +08:00
|
|
|
Font = OsuFont.GetFont(size: TEXT_SIZE, weight: FontWeight.Bold)
|
2019-10-18 16:59:54 +08:00
|
|
|
},
|
2021-02-08 17:34:32 +08:00
|
|
|
null,
|
2019-10-27 14:19:36 +08:00
|
|
|
new ControlGroupAttributes(group),
|
2019-10-18 16:59:54 +08:00
|
|
|
};
|
|
|
|
|
2019-10-27 14:19:36 +08:00
|
|
|
private class ControlGroupAttributes : CompositeDrawable
|
2019-10-18 16:59:54 +08:00
|
|
|
{
|
2020-11-04 14:29:14 +08:00
|
|
|
private readonly IBindableList<ControlPoint> controlPoints = new BindableList<ControlPoint>();
|
2019-10-18 16:59:54 +08:00
|
|
|
|
2019-10-27 14:19:36 +08:00
|
|
|
private readonly FillFlowContainer fill;
|
2019-10-18 16:59:54 +08:00
|
|
|
|
2019-10-27 14:19:36 +08:00
|
|
|
public ControlGroupAttributes(ControlPointGroup group)
|
|
|
|
{
|
2021-02-08 17:37:34 +08:00
|
|
|
RelativeSizeAxes = Axes.Both;
|
2019-10-27 14:19:36 +08:00
|
|
|
InternalChild = fill = new FillFlowContainer
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
Spacing = new Vector2(2)
|
|
|
|
};
|
|
|
|
|
2020-11-04 14:29:14 +08:00
|
|
|
controlPoints.BindTo(group.ControlPoints);
|
2020-10-01 18:29:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[Resolved]
|
|
|
|
private OsuColour colours { get; set; }
|
2019-10-18 16:59:54 +08:00
|
|
|
|
2020-10-01 18:29:34 +08:00
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
2019-10-27 14:19:36 +08:00
|
|
|
createChildren();
|
|
|
|
}
|
2019-10-18 16:59:54 +08:00
|
|
|
|
2020-10-08 04:57:20 +08:00
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
controlPoints.CollectionChanged += (_, __) => createChildren();
|
|
|
|
}
|
|
|
|
|
2019-10-27 14:19:36 +08:00
|
|
|
private void createChildren()
|
|
|
|
{
|
|
|
|
fill.ChildrenEnumerable = controlPoints.Select(createAttribute).Where(c => c != null);
|
2019-10-18 16:59:54 +08:00
|
|
|
}
|
|
|
|
|
2019-10-27 14:19:36 +08:00
|
|
|
private Drawable createAttribute(ControlPoint controlPoint)
|
|
|
|
{
|
2020-10-01 18:29:34 +08:00
|
|
|
Color4 colour = controlPoint.GetRepresentingColour(colours);
|
|
|
|
|
2019-10-27 14:19:36 +08:00
|
|
|
switch (controlPoint)
|
|
|
|
{
|
|
|
|
case TimingControlPoint timing:
|
2020-10-01 18:29:34 +08:00
|
|
|
return new RowAttribute("timing", () => $"{60000 / timing.BeatLength:n1}bpm {timing.TimeSignature}", colour);
|
2019-10-27 14:19:36 +08:00
|
|
|
|
|
|
|
case DifficultyControlPoint difficulty:
|
|
|
|
|
2020-10-01 18:29:34 +08:00
|
|
|
return new RowAttribute("difficulty", () => $"{difficulty.SpeedMultiplier:n2}x", colour);
|
2019-10-27 14:19:36 +08:00
|
|
|
|
|
|
|
case EffectControlPoint effect:
|
2021-02-09 11:00:03 +08:00
|
|
|
return new RowAttribute("effect", () => string.Join(" ",
|
2021-02-08 18:41:07 +08:00
|
|
|
effect.KiaiMode ? "Kiai" : string.Empty,
|
|
|
|
effect.OmitFirstBarLine ? "NoBarLine" : string.Empty
|
2021-02-09 11:00:03 +08:00
|
|
|
).Trim(), colour);
|
2019-10-27 14:19:36 +08:00
|
|
|
|
|
|
|
case SampleControlPoint sample:
|
2020-10-01 18:29:34 +08:00
|
|
|
return new RowAttribute("sample", () => $"{sample.SampleBank} {sample.SampleVolume}%", colour);
|
2019-10-27 14:19:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
2019-10-18 16:59:54 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|