1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-16 00:52:59 +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; private const float header_height = 20;
[Resolved] [Resolved]
private Bindable<IEnumerable<ControlPoint>> selectedPoints { get; set; } private Bindable<ControlPointGroup> selectedPoints { get; set; }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)
@ -228,7 +228,7 @@ namespace osu.Game.Screens.Edit.Timing
selectedPoints.BindValueChanged(points => selectedPoints.BindValueChanged(points =>
{ {
ControlPoint.Value = points.NewValue?.OfType<T>().FirstOrDefault(); ControlPoint.Value = points.NewValue?.ControlPoints.OfType<T>().FirstOrDefault();
checkbox.Current.Value = ControlPoint.Value != null; checkbox.Current.Value = ControlPoint.Value != null;
}, true); }, true);

View File

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

View File

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