2020-10-01 17:49:48 +08:00
|
|
|
// 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;
|
2021-09-14 17:51:22 +08:00
|
|
|
using osu.Framework.Extensions;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Cursor;
|
|
|
|
using osu.Framework.Graphics.UserInterface;
|
|
|
|
using osu.Framework.Input.Events;
|
2020-10-01 17:49:48 +08:00
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
|
|
|
using osu.Game.Graphics;
|
2021-09-14 17:51:22 +08:00
|
|
|
using osu.Game.Graphics.UserInterfaceV2;
|
2021-09-14 18:21:23 +08:00
|
|
|
using osu.Game.Rulesets.Objects;
|
2021-09-14 17:51:22 +08:00
|
|
|
using osu.Game.Screens.Edit.Timing;
|
2020-10-01 17:49:48 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|
|
|
{
|
2021-09-14 17:51:22 +08:00
|
|
|
public class SamplePointPiece : HitObjectPointPiece, IHasPopover
|
2020-10-01 17:49:48 +08:00
|
|
|
{
|
2021-11-13 23:58:24 +08:00
|
|
|
public readonly HitObject HitObject;
|
2020-10-01 18:29:34 +08:00
|
|
|
|
2020-10-01 17:49:48 +08:00
|
|
|
private readonly Bindable<string> bank;
|
|
|
|
private readonly BindableNumber<int> volume;
|
|
|
|
|
2021-09-14 18:21:23 +08:00
|
|
|
public SamplePointPiece(HitObject hitObject)
|
|
|
|
: base(hitObject.SampleControlPoint)
|
2020-10-01 17:49:48 +08:00
|
|
|
{
|
2021-11-13 23:58:24 +08:00
|
|
|
HitObject = hitObject;
|
2021-09-14 18:21:23 +08:00
|
|
|
volume = hitObject.SampleControlPoint.SampleVolumeBindable.GetBoundCopy();
|
|
|
|
bank = hitObject.SampleControlPoint.SampleBankBindable.GetBoundCopy();
|
2020-10-01 17:49:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
{
|
2021-09-10 12:44:39 +08:00
|
|
|
volume.BindValueChanged(volume => updateText());
|
|
|
|
bank.BindValueChanged(bank => updateText(), true);
|
|
|
|
}
|
2020-10-01 17:49:48 +08:00
|
|
|
|
2021-09-14 17:51:22 +08:00
|
|
|
protected override bool OnClick(ClickEvent e)
|
|
|
|
{
|
|
|
|
this.ShowPopover();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-09-10 12:44:39 +08:00
|
|
|
private void updateText()
|
|
|
|
{
|
|
|
|
Label.Text = $"{bank.Value} {volume.Value}";
|
2020-10-01 17:49:48 +08:00
|
|
|
}
|
2021-09-14 17:51:22 +08:00
|
|
|
|
2021-11-13 23:58:24 +08:00
|
|
|
public Popover GetPopover() => new SampleEditPopover(HitObject);
|
2021-09-14 17:51:22 +08:00
|
|
|
|
|
|
|
public class SampleEditPopover : OsuPopover
|
|
|
|
{
|
2021-09-14 18:21:23 +08:00
|
|
|
private readonly HitObject hitObject;
|
2021-09-14 17:51:22 +08:00
|
|
|
private readonly SampleControlPoint point;
|
|
|
|
|
|
|
|
private LabelledTextBox bank;
|
|
|
|
private SliderWithTextBoxInput<int> volume;
|
|
|
|
|
|
|
|
[Resolved(canBeNull: true)]
|
2021-09-14 18:21:23 +08:00
|
|
|
private EditorBeatmap beatmap { get; set; }
|
2021-09-14 17:51:22 +08:00
|
|
|
|
2021-09-14 18:21:23 +08:00
|
|
|
public SampleEditPopover(HitObject hitObject)
|
2021-09-14 17:51:22 +08:00
|
|
|
{
|
2021-09-14 18:21:23 +08:00
|
|
|
this.hitObject = hitObject;
|
|
|
|
point = hitObject.SampleControlPoint;
|
2021-09-14 17:51:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new FillFlowContainer
|
|
|
|
{
|
|
|
|
Width = 200,
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
bank = new LabelledTextBox
|
|
|
|
{
|
|
|
|
Label = "Bank Name",
|
|
|
|
},
|
|
|
|
volume = new SliderWithTextBoxInput<int>("Volume")
|
|
|
|
{
|
|
|
|
Current = new SampleControlPoint().SampleVolumeBindable,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
bank.Current = point.SampleBankBindable;
|
2021-09-14 18:21:23 +08:00
|
|
|
bank.Current.BindValueChanged(_ => beatmap.Update(hitObject));
|
2021-09-14 17:51:22 +08:00
|
|
|
|
|
|
|
volume.Current = point.SampleVolumeBindable;
|
2021-09-14 18:21:23 +08:00
|
|
|
volume.Current.BindValueChanged(_ => beatmap.Update(hitObject));
|
2021-09-14 17:51:22 +08:00
|
|
|
}
|
|
|
|
}
|
2020-10-01 17:49:48 +08:00
|
|
|
}
|
|
|
|
}
|