1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 22:07:25 +08:00

Merge remote-tracking branch 'upstream/master' into dynamic-followpoints

This commit is contained in:
Dean Herbert 2019-11-06 16:33:47 +09:00
commit 7ebd5daf7d
17 changed files with 910 additions and 15 deletions

View File

@ -2,16 +2,20 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Screens.Edit.Compose;
using osuTK;
namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
{
public class PathControlPointVisualiser : CompositeDrawable
public class PathControlPointVisualiser : CompositeDrawable, IKeyBindingHandler<PlatformAction>
{
public Action<Vector2[]> ControlPointsChanged;
@ -21,6 +25,9 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
private InputManager inputManager;
[Resolved(CanBeNull = true)]
private IPlacementHandler placementHandler { get; set; }
public PathControlPointVisualiser(Slider slider, bool allowSelection)
{
this.slider = slider;
@ -76,5 +83,51 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
piece.IsSelected.Value = piece.Index == index;
}
}
public bool OnPressed(PlatformAction action)
{
switch (action.ActionMethod)
{
case PlatformActionMethod.Delete:
var newControlPoints = new List<Vector2>();
foreach (var piece in Pieces)
{
if (!piece.IsSelected.Value)
newControlPoints.Add(slider.Path.ControlPoints[piece.Index]);
}
// Ensure that there are any points to be deleted
if (newControlPoints.Count == slider.Path.ControlPoints.Length)
return false;
// If there are 0 remaining control points, treat the slider as being deleted
if (newControlPoints.Count == 0)
{
placementHandler?.Delete(slider);
return true;
}
// Make control points relative
Vector2 first = newControlPoints[0];
for (int i = 0; i < newControlPoints.Count; i++)
newControlPoints[i] = newControlPoints[i] - first;
// The slider's position defines the position of the first control point, and all further control points are relative to that point
slider.Position = slider.Position + first;
// Since pieces are re-used, they will not point to the deleted control points while remaining selected
foreach (var piece in Pieces)
piece.IsSelected.Value = false;
ControlPointsChanged?.Invoke(newControlPoints.ToArray());
return true;
}
return false;
}
public bool OnReleased(PlatformAction action) => action.ActionMethod == PlatformActionMethod.Delete;
}
}

View File

@ -43,5 +43,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
Size = body.Size;
OriginPosition = body.PathOffset;
}
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => body.ReceivePositionalInputAt(screenSpacePos);
}
}

View File

@ -0,0 +1,35 @@
// 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;
using System.Collections.Generic;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Game.Rulesets.Osu;
using osu.Game.Screens.Edit.Timing;
namespace osu.Game.Tests.Visual.Editor
{
[TestFixture]
public class TestSceneTimingScreen : EditorClockTestScene
{
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(ControlPointTable),
typeof(ControlPointSettings),
typeof(Section<>),
typeof(TimingSection),
typeof(EffectSection),
typeof(SampleSection),
typeof(DifficultySection),
typeof(RowAttribute)
};
[BackgroundDependencyLoader]
private void load()
{
Beatmap.Value = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
Child = new TimingScreen();
}
}
}

View File

@ -215,7 +215,7 @@ namespace osu.Game.Tournament
foreach (var r in ladder.Rounds)
foreach (var b in r.Beatmaps)
if (b.BeatmapInfo == null)
if (b.BeatmapInfo == null && b.ID > 0)
{
var req = new GetBeatmapRequest(new BeatmapInfo { OnlineBeatmapID = b.ID });
req.Perform(API);

View File

@ -43,6 +43,11 @@ namespace osu.Game.Beatmaps.ControlPoints
set => BeatLengthBindable.Value = value;
}
/// <summary>
/// The BPM at this control point.
/// </summary>
public double BPM => 60000 / BeatLength;
public override bool EquivalentTo(ControlPoint other) =>
other is TimingControlPoint otherTyped
&& TimeSignature == otherTyped.TimeSignature && BeatLength.Equals(otherTyped.BeatLength);

View File

@ -82,6 +82,9 @@ namespace osu.Game.Rulesets.Edit
}
}
// When not selected, input is only required for the blueprint itself to receive IsHovering
protected override bool ShouldBeConsideredForInput(Drawable child) => State == SelectionState.Selected;
/// <summary>
/// Selects this <see cref="SelectionBlueprint"/>, causing it to become visible.
/// </summary>

View File

@ -254,6 +254,12 @@ namespace osu.Game.Screens.Edit.Compose.Components
{
Debug.Assert(!clickSelectionBegan);
// If a select blueprint is already hovered, disallow changes in selection.
// Exception is made when holding control, as deselection should still be allowed.
if (!e.CurrentState.Keyboard.ControlPressed &&
selectionHandler.SelectedBlueprints.Any(s => s.IsHovered))
return;
foreach (SelectionBlueprint blueprint in selectionBlueprints.AliveBlueprints)
{
if (blueprint.IsHovered)

View File

@ -8,21 +8,21 @@ using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events;
using osu.Framework.Input;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.States;
using osu.Game.Graphics;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables;
using osuTK;
using osuTK.Input;
namespace osu.Game.Screens.Edit.Compose.Components
{
/// <summary>
/// A component which outlines <see cref="DrawableHitObject"/>s and handles movement of selections.
/// </summary>
public class SelectionHandler : CompositeDrawable
public class SelectionHandler : CompositeDrawable, IKeyBindingHandler<PlatformAction>
{
public const float BORDER_RADIUS = 2;
@ -72,22 +72,21 @@ namespace osu.Game.Screens.Edit.Compose.Components
{
}
protected override bool OnKeyDown(KeyDownEvent e)
public bool OnPressed(PlatformAction action)
{
if (e.Repeat)
return base.OnKeyDown(e);
switch (e.Key)
switch (action.ActionMethod)
{
case Key.Delete:
case PlatformActionMethod.Delete:
foreach (var h in selectedBlueprints.ToList())
placementHandler.Delete(h.DrawableObject.HitObject);
return true;
}
return base.OnKeyDown(e);
return false;
}
public bool OnReleased(PlatformAction action) => action.ActionMethod == PlatformActionMethod.Delete;
#endregion
#region Selection Handling

View File

@ -0,0 +1,50 @@
// 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 osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
namespace osu.Game.Screens.Edit.Timing
{
public class ControlPointSettings : CompositeDrawable
{
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
RelativeSizeAxes = Axes.Both;
InternalChildren = new Drawable[]
{
new Box
{
Colour = colours.Gray3,
RelativeSizeAxes = Axes.Both,
},
new OsuScrollContainer
{
RelativeSizeAxes = Axes.Both,
Child = new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Children = createSections()
},
}
};
}
private IReadOnlyList<Drawable> createSections() => new Drawable[]
{
new TimingSection(),
new DifficultySection(),
new SampleSection(),
new EffectSection(),
};
}
}

View File

@ -0,0 +1,247 @@
// 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.Framework.Graphics.Shapes;
using osu.Framework.Input.Events;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osuTK;
using osuTK.Graphics;
namespace osu.Game.Screens.Edit.Timing
{
public class ControlPointTable : TableContainer
{
private const float horizontal_inset = 20;
private const float row_height = 25;
private const int text_size = 14;
private readonly FillFlowContainer backgroundFlow;
[Resolved]
private Bindable<ControlPointGroup> selectedGroup { get; set; }
public ControlPointTable()
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
Padding = new MarginPadding { Horizontal = horizontal_inset };
RowSize = new Dimension(GridSizeMode.Absolute, row_height);
AddInternal(backgroundFlow = new FillFlowContainer
{
RelativeSizeAxes = Axes.Both,
Depth = 1f,
Padding = new MarginPadding { Horizontal = -horizontal_inset },
Margin = new MarginPadding { Top = row_height }
});
}
public IEnumerable<ControlPointGroup> ControlGroups
{
set
{
Content = null;
backgroundFlow.Clear();
if (value?.Any() != true)
return;
foreach (var group in value)
{
backgroundFlow.Add(new RowBackground(group));
}
Columns = createHeaders();
Content = value.Select((g, i) => createContent(i, g)).ToArray().ToRectangular();
}
}
private TableColumn[] createHeaders()
{
var columns = new List<TableColumn>
{
new TableColumn(string.Empty, Anchor.Centre, new Dimension(GridSizeMode.AutoSize)),
new TableColumn("Time", Anchor.Centre, new Dimension(GridSizeMode.AutoSize)),
new TableColumn("Attributes", Anchor.Centre),
};
return columns.ToArray();
}
private Drawable[] createContent(int index, ControlPointGroup group) => new Drawable[]
{
new OsuSpriteText
{
Text = $"#{index + 1}",
Font = OsuFont.GetFont(size: text_size, weight: FontWeight.Bold),
Margin = new MarginPadding(10)
},
new OsuSpriteText
{
Text = $"{group.Time:n0}ms",
Font = OsuFont.GetFont(size: text_size, weight: FontWeight.Bold)
},
new ControlGroupAttributes(group),
};
private class ControlGroupAttributes : CompositeDrawable
{
private readonly IBindableList<ControlPoint> controlPoints;
private readonly FillFlowContainer fill;
public ControlGroupAttributes(ControlPointGroup group)
{
InternalChild = fill = new FillFlowContainer
{
RelativeSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Padding = new MarginPadding(10),
Spacing = new Vector2(2)
};
controlPoints = group.ControlPoints.GetBoundCopy();
controlPoints.ItemsAdded += _ => createChildren();
controlPoints.ItemsRemoved += _ => createChildren();
createChildren();
}
private void createChildren()
{
fill.ChildrenEnumerable = controlPoints.Select(createAttribute).Where(c => c != null);
}
private Drawable createAttribute(ControlPoint controlPoint)
{
switch (controlPoint)
{
case TimingControlPoint timing:
return new RowAttribute("timing", $"{60000 / timing.BeatLength:n1}bpm {timing.TimeSignature}");
case DifficultyControlPoint difficulty:
return new RowAttribute("difficulty", $"{difficulty.SpeedMultiplier:n2}x");
case EffectControlPoint effect:
return new RowAttribute("effect", $"{(effect.KiaiMode ? "Kiai " : "")}{(effect.OmitFirstBarLine ? "NoBarLine " : "")}");
case SampleControlPoint sample:
return new RowAttribute("sample", $"{sample.SampleBank} {sample.SampleVolume}%");
}
return null;
}
}
protected override Drawable CreateHeader(int index, TableColumn column) => new HeaderText(column?.Header ?? string.Empty);
private class HeaderText : OsuSpriteText
{
public HeaderText(string text)
{
Text = text.ToUpper();
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Black);
}
}
public class RowBackground : OsuClickableContainer
{
private readonly ControlPointGroup controlGroup;
private const int fade_duration = 100;
private readonly Box hoveredBackground;
[Resolved]
private Bindable<ControlPointGroup> selectedGroup { get; set; }
public RowBackground(ControlPointGroup controlGroup)
{
this.controlGroup = controlGroup;
RelativeSizeAxes = Axes.X;
Height = 25;
AlwaysPresent = true;
CornerRadius = 3;
Masking = true;
Children = new Drawable[]
{
hoveredBackground = new Box
{
RelativeSizeAxes = Axes.Both,
Alpha = 0,
},
};
Action = () => selectedGroup.Value = controlGroup;
}
private Color4 colourHover;
private Color4 colourSelected;
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
hoveredBackground.Colour = colourHover = colours.BlueDarker;
colourSelected = colours.YellowDarker;
}
protected override void LoadComplete()
{
base.LoadComplete();
selectedGroup.BindValueChanged(group => { Selected = controlGroup == group.NewValue; }, true);
}
private bool selected;
protected bool Selected
{
get => selected;
set
{
if (value == selected)
return;
selected = value;
updateState();
}
}
protected override bool OnHover(HoverEvent e)
{
updateState();
return base.OnHover(e);
}
protected override void OnHoverLost(HoverLostEvent e)
{
updateState();
base.OnHoverLost(e);
}
private void updateState()
{
hoveredBackground.FadeColour(selected ? colourSelected : colourHover, 450, Easing.OutQuint);
if (selected || IsHovered)
hoveredBackground.FadeIn(fade_duration, Easing.OutQuint);
else
hoveredBackground.FadeOut(fade_duration, Easing.OutQuint);
}
}
}
}

View File

@ -0,0 +1,39 @@
// 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 osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Graphics.Sprites;
namespace osu.Game.Screens.Edit.Timing
{
internal class DifficultySection : Section<DifficultyControlPoint>
{
private OsuSpriteText multiplier;
[BackgroundDependencyLoader]
private void load()
{
Flow.AddRange(new[]
{
multiplier = new OsuSpriteText(),
});
}
protected override void OnControlPointChanged(ValueChangedEvent<DifficultyControlPoint> point)
{
multiplier.Text = $"Multiplier: {point.NewValue?.SpeedMultiplier:0.##}x";
}
protected override DifficultyControlPoint CreatePoint()
{
var reference = Beatmap.Value.Beatmap.ControlPointInfo.DifficultyPointAt(SelectedGroup.Value.Time);
return new DifficultyControlPoint
{
SpeedMultiplier = reference.SpeedMultiplier,
};
}
}
}

View File

@ -0,0 +1,43 @@
// 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 osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Graphics.Sprites;
namespace osu.Game.Screens.Edit.Timing
{
internal 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 OnControlPointChanged(ValueChangedEvent<EffectControlPoint> point)
{
kiai.Text = $"Kiai: {(point.NewValue?.KiaiMode == true ? "on" : "off")}";
omitBarLine.Text = $"Skip Bar Line: {(point.NewValue?.OmitFirstBarLine == true ? "on" : "off")}";
}
protected override EffectControlPoint CreatePoint()
{
var reference = Beatmap.Value.Beatmap.ControlPointInfo.EffectPointAt(SelectedGroup.Value.Time);
return new EffectControlPoint
{
KiaiMode = reference.KiaiMode,
OmitFirstBarLine = reference.OmitFirstBarLine
};
}
}
}

View File

@ -0,0 +1,59 @@
// 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 osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
namespace osu.Game.Screens.Edit.Timing
{
public class RowAttribute : CompositeDrawable, IHasTooltip
{
private readonly string header;
private readonly string content;
public RowAttribute(string header, string content)
{
this.header = header;
this.content = content;
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
AutoSizeAxes = Axes.X;
Height = 20;
Anchor = Anchor.CentreLeft;
Origin = Anchor.CentreLeft;
Masking = true;
CornerRadius = 5;
InternalChildren = new Drawable[]
{
new Box
{
Colour = colours.Yellow,
RelativeSizeAxes = Axes.Both,
},
new OsuSpriteText
{
Padding = new MarginPadding(2),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Font = OsuFont.Default.With(weight: FontWeight.SemiBold, size: 12),
Text = header,
Colour = colours.Gray3
},
};
}
public string TooltipText => content;
}
}

View File

@ -0,0 +1,43 @@
// 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 osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Graphics.Sprites;
namespace osu.Game.Screens.Edit.Timing
{
internal 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 OnControlPointChanged(ValueChangedEvent<SampleControlPoint> point)
{
bank.Text = $"Bank: {point.NewValue?.SampleBank}";
volume.Text = $"Volume: {point.NewValue?.SampleVolume}%";
}
protected override SampleControlPoint CreatePoint()
{
var reference = Beatmap.Value.Beatmap.ControlPointInfo.SamplePointAt(SelectedGroup.Value.Time);
return new SampleControlPoint
{
SampleBank = reference.SampleBank,
SampleVolume = reference.SampleVolume,
};
}
}
}

View File

@ -0,0 +1,130 @@
// 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.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Screens.Edit.Timing
{
internal abstract class Section<T> : CompositeDrawable
where T : ControlPoint
{
private OsuCheckbox checkbox;
private Container content;
protected FillFlowContainer Flow { get; private set; }
protected Bindable<T> ControlPoint { get; } = new Bindable<T>();
private const float header_height = 20;
[Resolved]
protected IBindable<WorkingBeatmap> Beatmap { get; private set; }
[Resolved]
protected Bindable<ControlPointGroup> SelectedGroup { get; private set; }
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
RelativeSizeAxes = Axes.X;
AutoSizeDuration = 200;
AutoSizeEasing = Easing.OutQuint;
AutoSizeAxes = Axes.Y;
Masking = true;
InternalChildren = new Drawable[]
{
new Box
{
Colour = colours.Gray1,
RelativeSizeAxes = Axes.Both,
},
new Container
{
RelativeSizeAxes = Axes.X,
Height = header_height,
Children = new Drawable[]
{
checkbox = new OsuCheckbox
{
LabelText = 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 = colours.Gray2,
RelativeSizeAxes = Axes.Both,
},
Flow = new FillFlowContainer
{
Padding = new MarginPadding(10),
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
},
}
}
};
}
protected override void LoadComplete()
{
base.LoadComplete();
checkbox.Current.BindValueChanged(selected =>
{
if (selected.NewValue)
{
if (SelectedGroup.Value == null)
{
checkbox.Current.Value = false;
return;
}
if (ControlPoint.Value == null)
SelectedGroup.Value.Add(ControlPoint.Value = CreatePoint());
}
else
{
if (ControlPoint.Value != null)
{
SelectedGroup.Value.Remove(ControlPoint.Value);
ControlPoint.Value = null;
}
}
content.BypassAutoSizeAxes = selected.NewValue ? Axes.None : Axes.Y;
}, true);
SelectedGroup.BindValueChanged(points =>
{
ControlPoint.Value = points.NewValue?.ControlPoints.OfType<T>().FirstOrDefault();
checkbox.Current.Value = ControlPoint.Value != null;
}, true);
ControlPoint.BindValueChanged(OnControlPointChanged, true);
}
protected abstract void OnControlPointChanged(ValueChangedEvent<T> point);
protected abstract T CreatePoint();
}
}

View File

@ -1,13 +1,151 @@
// 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.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Timing;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface;
using osuTK;
namespace osu.Game.Screens.Edit.Timing
{
public class TimingScreen : EditorScreen
public class TimingScreen : EditorScreenWithTimeline
{
public TimingScreen()
[Cached]
private Bindable<ControlPointGroup> selectedGroup = new Bindable<ControlPointGroup>();
[Resolved]
private IAdjustableClock clock { get; set; }
protected override Drawable CreateMainContent() => new GridContainer
{
Child = new ScreenWhiteBox.UnderConstructionMessage("Timing mode");
RelativeSizeAxes = Axes.Both,
ColumnDimensions = new[]
{
new Dimension(),
new Dimension(GridSizeMode.Absolute, 200),
},
Content = new[]
{
new Drawable[]
{
new ControlPointList(),
new ControlPointSettings(),
},
}
};
protected override void LoadComplete()
{
base.LoadComplete();
selectedGroup.BindValueChanged(selected =>
{
if (selected.NewValue != null)
clock.Seek(selected.NewValue.Time);
});
}
public class ControlPointList : CompositeDrawable
{
private OsuButton deleteButton;
private ControlPointTable table;
private IBindableList<ControlPointGroup> controlGroups;
[Resolved]
private IFrameBasedClock clock { get; set; }
[Resolved]
protected IBindable<WorkingBeatmap> Beatmap { get; private set; }
[Resolved]
private Bindable<ControlPointGroup> selectedGroup { get; set; }
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
RelativeSizeAxes = Axes.Both;
InternalChildren = new Drawable[]
{
new Box
{
Colour = colours.Gray0,
RelativeSizeAxes = Axes.Both,
},
new OsuScrollContainer
{
RelativeSizeAxes = Axes.Both,
Child = table = new ControlPointTable(),
},
new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight,
Direction = FillDirection.Horizontal,
Margin = new MarginPadding(10),
Spacing = new Vector2(5),
Children = new Drawable[]
{
deleteButton = new OsuButton
{
Text = "-",
Size = new Vector2(30, 30),
Action = delete,
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight,
},
new OsuButton
{
Text = "+",
Action = addNew,
Size = new Vector2(30, 30),
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight,
},
}
},
};
}
protected override void LoadComplete()
{
base.LoadComplete();
selectedGroup.BindValueChanged(selected => { deleteButton.Enabled.Value = selected.NewValue != null; }, true);
controlGroups = Beatmap.Value.Beatmap.ControlPointInfo.Groups.GetBoundCopy();
controlGroups.ItemsAdded += _ => createContent();
controlGroups.ItemsRemoved += _ => createContent();
createContent();
}
private void createContent() => table.ControlGroups = controlGroups;
private void delete()
{
if (selectedGroup.Value == null)
return;
Beatmap.Value.Beatmap.ControlPointInfo.RemoveGroup(selectedGroup.Value);
selectedGroup.Value = Beatmap.Value.Beatmap.ControlPointInfo.Groups.FirstOrDefault(g => g.Time >= clock.CurrentTime);
}
private void addNew()
{
selectedGroup.Value = Beatmap.Value.Beatmap.ControlPointInfo.GroupAt(clock.CurrentTime, true);
}
}
}
}

View File

@ -0,0 +1,43 @@
// 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 osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Graphics.Sprites;
namespace osu.Game.Screens.Edit.Timing
{
internal 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 OnControlPointChanged(ValueChangedEvent<TimingControlPoint> point)
{
bpm.Text = $"BPM: {point.NewValue?.BPM:0.##}";
timeSignature.Text = $"Signature: {point.NewValue?.TimeSignature}";
}
protected override TimingControlPoint CreatePoint()
{
var reference = Beatmap.Value.Beatmap.ControlPointInfo.TimingPointAt(SelectedGroup.Value.Time);
return new TimingControlPoint
{
BeatLength = reference.BeatLength,
TimeSignature = reference.TimeSignature
};
}
}
}