mirror of
https://github.com/ppy/osu.git
synced 2024-12-17 03:02:56 +08:00
Add control sections and hook up bindable control groups
This commit is contained in:
parent
0fbba9a5e5
commit
80bf68c108
@ -1,11 +1,20 @@
|
|||||||
// 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.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.Containers;
|
||||||
|
using osu.Game.Graphics.Sprites;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
using osuTK;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Edit.Timing
|
namespace osu.Game.Screens.Edit.Timing
|
||||||
{
|
{
|
||||||
@ -16,11 +25,126 @@ namespace osu.Game.Screens.Edit.Timing
|
|||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
|
||||||
InternalChild = new Box
|
InternalChildren = new Drawable[]
|
||||||
|
{
|
||||||
|
new Box
|
||||||
{
|
{
|
||||||
Colour = colours.Gray3,
|
Colour = colours.Gray3,
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
},
|
||||||
|
new OsuScrollContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Child = new FillFlowContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Direction = FillDirection.Vertical,
|
||||||
|
Spacing = new Vector2(30),
|
||||||
|
Children = createSections()
|
||||||
|
},
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IReadOnlyList<Drawable> createSections() => new Drawable[]
|
||||||
|
{
|
||||||
|
new TimingSection(),
|
||||||
|
new DifficultySection(),
|
||||||
|
new SampleSection(),
|
||||||
|
new EffectSection(),
|
||||||
|
};
|
||||||
|
|
||||||
|
private class TimingSection : Section<TimingControlPoint>
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private class DifficultySection : Section<DifficultyControlPoint>
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private class SampleSection : Section<SampleControlPoint>
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private class EffectSection : Section<EffectControlPoint>
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private class Section<T> : Container
|
||||||
|
where T : ControlPoint
|
||||||
|
{
|
||||||
|
private const float header_height = 20;
|
||||||
|
|
||||||
|
protected override Container<Drawable> Content { get; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private Bindable<IEnumerable<ControlPoint>> selectedPoints { get; set; }
|
||||||
|
|
||||||
|
protected Section()
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X;
|
||||||
|
AutoSizeDuration = 200;
|
||||||
|
AutoSizeEasing = Easing.OutQuint;
|
||||||
|
AutoSizeAxes = Axes.Y;
|
||||||
|
|
||||||
|
Masking = true;
|
||||||
|
|
||||||
|
InternalChildren = new Drawable[]
|
||||||
|
{
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
Colour = Color4.Gray,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
},
|
||||||
|
new Container
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Height = header_height,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new OsuSpriteText
|
||||||
|
{
|
||||||
|
Text = typeof(T).Name.Replace(typeof(ControlPoint).Name, string.Empty)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Content = new Container()
|
||||||
|
{
|
||||||
|
Y = header_height,
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
Colour = Color4.DarkGray,
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Height = 100,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
selectedPoints.BindValueChanged(points =>
|
||||||
|
{
|
||||||
|
var matching = points.NewValue?.OfType<T>().Where(p => !p.AutoGenerated).FirstOrDefault();
|
||||||
|
|
||||||
|
if (matching != null)
|
||||||
|
{
|
||||||
|
Content.BypassAutoSizeAxes = Axes.None;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Content.BypassAutoSizeAxes = Axes.Y;
|
||||||
|
}
|
||||||
|
}, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ namespace osu.Game.Screens.Edit.Timing
|
|||||||
private readonly FillFlowContainer backgroundFlow;
|
private readonly FillFlowContainer backgroundFlow;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private Bindable<ControlPoint> controlPoint { get; set; }
|
private Bindable<IEnumerable<ControlPoint>> selectedPoints { get; set; }
|
||||||
|
|
||||||
public ControlPointTable()
|
public ControlPointTable()
|
||||||
{
|
{
|
||||||
@ -60,7 +60,7 @@ namespace osu.Game.Screens.Edit.Timing
|
|||||||
|
|
||||||
foreach (var group in grouped)
|
foreach (var group in grouped)
|
||||||
{
|
{
|
||||||
backgroundFlow.Add(new RowBackground { Action = () => controlPoint.Value = group.First() });
|
backgroundFlow.Add(new RowBackground { Action = () => selectedPoints.Value = group });
|
||||||
}
|
}
|
||||||
|
|
||||||
Columns = createHeaders();
|
Columns = createHeaders();
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// 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 osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
@ -16,7 +17,7 @@ namespace osu.Game.Screens.Edit.Timing
|
|||||||
public class TimingScreen : EditorScreenWithTimeline
|
public class TimingScreen : EditorScreenWithTimeline
|
||||||
{
|
{
|
||||||
[Cached]
|
[Cached]
|
||||||
private readonly Bindable<ControlPoint> controlPoint = new Bindable<ControlPoint>();
|
private Bindable<IEnumerable<ControlPoint>> selectedPoints = new Bindable<IEnumerable<ControlPoint>>();
|
||||||
|
|
||||||
protected override Drawable CreateMainContent() => new GridContainer
|
protected override Drawable CreateMainContent() => new GridContainer
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user