1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-15 09:13:21 +08:00

Add basic information display for all types of control points

This commit is contained in:
Dean Herbert 2019-10-22 20:57:56 +09:00
parent 81e8b678d3
commit 4883844c4c

View File

@ -14,7 +14,6 @@ using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osuTK; using osuTK;
using osuTK.Graphics;
namespace osu.Game.Screens.Edit.Timing namespace osu.Game.Screens.Edit.Timing
{ {
@ -40,7 +39,7 @@ namespace osu.Game.Screens.Edit.Timing
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical, Direction = FillDirection.Vertical,
Spacing = new Vector2(30), Spacing = new Vector2(2),
Children = createSections() Children = createSections()
}, },
} }
@ -57,31 +56,123 @@ namespace osu.Game.Screens.Edit.Timing
private class TimingSection : Section<TimingControlPoint> private class TimingSection : Section<TimingControlPoint>
{ {
private OsuSpriteText bpm;
private OsuSpriteText timeSignature;
[BackgroundDependencyLoader]
private void load()
{
Flow.AddRange(new[]
{
bpm = new OsuSpriteText(),
timeSignature = new OsuSpriteText(),
});
}
protected override void LoadComplete()
{
base.LoadComplete();
ControlPoint.BindValueChanged(point =>
{
bpm.Text = $"BPM: {point.NewValue?.BeatLength}";
timeSignature.Text = $"Signature: {point.NewValue?.TimeSignature}";
});
}
} }
private class DifficultySection : Section<DifficultyControlPoint> private class DifficultySection : Section<DifficultyControlPoint>
{ {
private OsuSpriteText multiplier;
[BackgroundDependencyLoader]
private void load()
{
Flow.AddRange(new[]
{
multiplier = new OsuSpriteText(),
});
}
protected override void LoadComplete()
{
base.LoadComplete();
ControlPoint.BindValueChanged(point => { multiplier.Text = $"Multiplier: {point.NewValue?.SpeedMultiplier}"; });
}
} }
private class SampleSection : Section<SampleControlPoint> private class SampleSection : Section<SampleControlPoint>
{ {
private OsuSpriteText bank;
private OsuSpriteText volume;
[BackgroundDependencyLoader]
private void load()
{
Flow.AddRange(new[]
{
bank = new OsuSpriteText(),
volume = new OsuSpriteText(),
});
}
protected override void LoadComplete()
{
base.LoadComplete();
ControlPoint.BindValueChanged(point =>
{
bank.Text = $"Bank: {point.NewValue?.SampleBank}";
volume.Text = $"Volume: {point.NewValue?.SampleVolume}";
});
}
} }
private class EffectSection : Section<EffectControlPoint> private class EffectSection : Section<EffectControlPoint>
{ {
private OsuSpriteText kiai;
private OsuSpriteText omitBarLine;
[BackgroundDependencyLoader]
private void load()
{
Flow.AddRange(new[]
{
kiai = new OsuSpriteText(),
omitBarLine = new OsuSpriteText(),
});
}
protected override void LoadComplete()
{
base.LoadComplete();
ControlPoint.BindValueChanged(point =>
{
kiai.Text = $"Kiai: {point.NewValue?.KiaiMode}";
omitBarLine.Text = $"Skip Bar Line: {point.NewValue?.OmitFirstBarLine}";
});
}
} }
private class Section<T> : Container private class Section<T> : CompositeDrawable
where T : ControlPoint where T : ControlPoint
{ {
private const float header_height = 20; private OsuCheckbox checkbox;
private Container content;
protected override Container<Drawable> Content { get; } protected FillFlowContainer Flow { get; private set; }
protected Bindable<T> ControlPoint { get; } = new Bindable<T>();
private const float header_height = 20;
[Resolved] [Resolved]
private Bindable<IEnumerable<ControlPoint>> selectedPoints { get; set; } private Bindable<IEnumerable<ControlPoint>> selectedPoints { get; set; }
protected Section() [BackgroundDependencyLoader]
private void load(OsuColour colours)
{ {
RelativeSizeAxes = Axes.X; RelativeSizeAxes = Axes.X;
AutoSizeDuration = 200; AutoSizeDuration = 200;
@ -94,7 +185,7 @@ namespace osu.Game.Screens.Edit.Timing
{ {
new Box new Box
{ {
Colour = Color4.Gray, Colour = colours.Gray1,
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
}, },
new Container new Container
@ -103,13 +194,13 @@ namespace osu.Game.Screens.Edit.Timing
Height = header_height, Height = header_height,
Children = new Drawable[] Children = new Drawable[]
{ {
new OsuSpriteText checkbox = new OsuCheckbox
{ {
Text = typeof(T).Name.Replace(typeof(ControlPoint).Name, string.Empty) LabelText = typeof(T).Name.Replace(typeof(ControlPoint).Name, string.Empty)
}, }
} }
}, },
Content = new Container() content = new Container
{ {
Y = header_height, Y = header_height,
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
@ -118,9 +209,15 @@ namespace osu.Game.Screens.Edit.Timing
{ {
new Box new Box
{ {
Colour = Color4.DarkGray, Colour = colours.Gray2,
RelativeSizeAxes = Axes.Both,
},
Flow = new FillFlowContainer
{
Padding = new MarginPadding(10),
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Height = 100, AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
}, },
} }
} }
@ -133,17 +230,12 @@ namespace osu.Game.Screens.Edit.Timing
selectedPoints.BindValueChanged(points => selectedPoints.BindValueChanged(points =>
{ {
var matching = points.NewValue?.OfType<T>().Where(p => !p.AutoGenerated).FirstOrDefault(); ControlPoint.Value = points.NewValue?.OfType<T>().Where(p => !p.AutoGenerated).FirstOrDefault();
if (matching != null) checkbox.Current.Value = ControlPoint.Value != null;
{
Content.BypassAutoSizeAxes = Axes.None;
}
else
{
Content.BypassAutoSizeAxes = Axes.Y;
}
}, true); }, true);
checkbox.Current.BindValueChanged(selected => { content.BypassAutoSizeAxes = selected.NewValue ? Axes.None : Axes.Y; }, true);
} }
} }
} }