1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-27 00:22:57 +08:00
osu-lazer/osu.Game/Screens/Edit/Timing/EffectSection.cs

78 lines
2.5 KiB
C#
Raw Normal View History

2019-10-28 11:42:17 +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;
using osu.Framework.Graphics;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Configuration;
using osu.Game.Graphics.UserInterfaceV2;
using osu.Game.Rulesets.UI.Scrolling;
namespace osu.Game.Screens.Edit.Timing
{
2022-11-24 13:32:20 +08:00
internal partial class EffectSection : Section<EffectControlPoint>
{
2023-01-14 07:23:21 +08:00
private LabelledSwitchButton kiai = null!;
2023-01-14 07:23:21 +08:00
private SliderWithTextBoxInput<double> scrollSpeedSlider = null!;
[BackgroundDependencyLoader]
private void load()
{
Flow.AddRange(new Drawable[]
{
kiai = new LabelledSwitchButton { Label = "Kiai Time" },
scrollSpeedSlider = new SliderWithTextBoxInput<double>("Scroll Speed")
{
Current = new EffectControlPoint().ScrollSpeedBindable,
KeyboardStep = 0.1f
}
});
}
protected override void LoadComplete()
{
base.LoadComplete();
kiai.Current.BindValueChanged(_ => saveChanges());
scrollSpeedSlider.Current.BindValueChanged(_ => saveChanges());
var drawableRuleset = Beatmap.BeatmapInfo.Ruleset.CreateInstance().CreateDrawableRulesetWith(Beatmap.PlayableBeatmap);
if (drawableRuleset is not IDrawableScrollingRuleset scrollingRuleset || scrollingRuleset.VisualisationMethod == ScrollVisualisationMethod.Constant)
scrollSpeedSlider.Hide();
void saveChanges()
{
if (!isRebinding) ChangeHandler?.SaveState();
}
}
private bool isRebinding;
2023-01-14 07:23:21 +08:00
protected override void OnControlPointChanged(ValueChangedEvent<EffectControlPoint?> point)
{
if (point.NewValue != null)
{
isRebinding = true;
kiai.Current = point.NewValue.KiaiModeBindable;
scrollSpeedSlider.Current = point.NewValue.ScrollSpeedBindable;
isRebinding = false;
}
}
protected override EffectControlPoint CreatePoint()
{
var reference = Beatmap.ControlPointInfo.EffectPointAt(SelectedGroup.Value.Time);
return new EffectControlPoint
{
KiaiMode = reference.KiaiMode,
ScrollSpeed = reference.ScrollSpeed,
};
}
}
}