1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 22:22:55 +08:00

Update UI components to use new grouping

This commit is contained in:
Dean Herbert 2019-10-25 20:13:22 +09:00
parent 32242f22de
commit b8efc59cdc
3 changed files with 14 additions and 18 deletions

View File

@ -167,7 +167,7 @@ namespace osu.Game.Screens.Edit.Timing
private const float header_height = 20;
[Resolved]
private Bindable<IEnumerable<ControlPoint>> selectedPoints { get; set; }
private Bindable<ControlPointGroup> selectedPoints { get; set; }
[BackgroundDependencyLoader]
private void load(OsuColour colours)
@ -228,7 +228,7 @@ namespace osu.Game.Screens.Edit.Timing
selectedPoints.BindValueChanged(points =>
{
ControlPoint.Value = points.NewValue?.OfType<T>().FirstOrDefault();
ControlPoint.Value = points.NewValue?.ControlPoints.OfType<T>().FirstOrDefault();
checkbox.Current.Value = ControlPoint.Value != null;
}, true);

View File

@ -27,7 +27,7 @@ namespace osu.Game.Screens.Edit.Timing
private readonly FillFlowContainer backgroundFlow;
[Resolved]
private Bindable<IEnumerable<ControlPoint>> selectedPoints { get; set; }
private Bindable<ControlPointGroup> selectedGroup { get; set; }
public ControlPointTable()
{
@ -46,7 +46,7 @@ namespace osu.Game.Screens.Edit.Timing
});
}
public IEnumerable<ControlPoint> ControlPoints
public IEnumerable<ControlPointGroup> ControlGroups
{
set
{
@ -56,15 +56,13 @@ namespace osu.Game.Screens.Edit.Timing
if (value?.Any() != true)
return;
var grouped = value.GroupBy(cp => cp.Time, cp => cp);
foreach (var group in grouped)
foreach (var group in value)
{
backgroundFlow.Add(new RowBackground { Action = () => selectedPoints.Value = group });
backgroundFlow.Add(new RowBackground { Action = () => selectedGroup.Value = group });
}
Columns = createHeaders();
Content = grouped.Select((s, i) => createContent(i, s)).ToArray().ToRectangular();
Content = value.Select((g, i) => createContent(i, g)).ToArray().ToRectangular();
}
}
@ -80,7 +78,7 @@ namespace osu.Game.Screens.Edit.Timing
return columns.ToArray();
}
private Drawable[] createContent(int index, IGrouping<double, ControlPoint> controlPoints) => new Drawable[]
private Drawable[] createContent(int index, ControlPointGroup group) => new Drawable[]
{
new OsuSpriteText
{
@ -90,14 +88,14 @@ namespace osu.Game.Screens.Edit.Timing
},
new OsuSpriteText
{
Text = $"{controlPoints.Key:n0}ms",
Text = $"{group.Time:n0}ms",
Font = OsuFont.GetFont(size: text_size, weight: FontWeight.Bold)
},
new FillFlowContainer
{
RelativeSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
ChildrenEnumerable = controlPoints.Select(createAttribute).Where(c => c != null),
ChildrenEnumerable = group.ControlPoints.Select(createAttribute).Where(c => c != null),
Padding = new MarginPadding(10),
Spacing = new Vector2(10)
},

View File

@ -1,8 +1,6 @@
// 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.Graphics;
@ -21,7 +19,7 @@ namespace osu.Game.Screens.Edit.Timing
public class TimingScreen : EditorScreenWithTimeline
{
[Cached]
private Bindable<IEnumerable<ControlPoint>> selectedPoints = new Bindable<IEnumerable<ControlPoint>>();
private Bindable<ControlPointGroup> selectedPoints = new Bindable<ControlPointGroup>();
[Resolved]
private IAdjustableClock clock { get; set; }
@ -48,7 +46,7 @@ namespace osu.Game.Screens.Edit.Timing
{
base.LoadComplete();
selectedPoints.BindValueChanged(selected => { clock.Seek(selected.NewValue.First().Time); });
selectedPoints.BindValueChanged(selected => { clock.Seek(selected.NewValue.Time); });
}
public class ControlPointList : CompositeDrawable
@ -59,7 +57,7 @@ namespace osu.Game.Screens.Edit.Timing
protected IBindable<WorkingBeatmap> Beatmap { get; private set; }
[Resolved]
private Bindable<IEnumerable<ControlPoint>> selectedPoints { get; set; }
private Bindable<ControlPointGroup> selectedPoints { get; set; }
[BackgroundDependencyLoader]
private void load(OsuColour colours)
@ -78,7 +76,7 @@ namespace osu.Game.Screens.Edit.Timing
RelativeSizeAxes = Axes.Both,
Child = new ControlPointTable
{
ControlPoints = Beatmap.Value.Beatmap.ControlPointInfo.AllControlPoints
ControlGroups = Beatmap.Value.Beatmap.ControlPointInfo.Groups
}
},
new FillFlowContainer