1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 08:02:55 +08:00

Add ability to edit individual ControlPoint attributes from tim… (#6638)

Add ability to edit individual ControlPoint attributes from timing screen
This commit is contained in:
Dean Herbert 2019-11-06 17:24:51 +09:00 committed by GitHub
commit c631a05a44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 101 additions and 34 deletions

View File

@ -128,17 +128,17 @@ namespace osu.Game.Screens.Edit.Timing
switch (controlPoint)
{
case TimingControlPoint timing:
return new RowAttribute("timing", $"{60000 / timing.BeatLength:n1}bpm {timing.TimeSignature}");
return new RowAttribute("timing", () => $"{60000 / timing.BeatLength:n1}bpm {timing.TimeSignature}");
case DifficultyControlPoint difficulty:
return new RowAttribute("difficulty", $"{difficulty.SpeedMultiplier:n2}x");
return new RowAttribute("difficulty", () => $"{difficulty.SpeedMultiplier:n2}x");
case EffectControlPoint effect:
return new RowAttribute("effect", $"{(effect.KiaiMode ? "Kiai " : "")}{(effect.OmitFirstBarLine ? "NoBarLine " : "")}");
return new RowAttribute("effect", () => $"{(effect.KiaiMode ? "Kiai " : "")}{(effect.OmitFirstBarLine ? "NoBarLine " : "")}");
case SampleControlPoint sample:
return new RowAttribute("sample", $"{sample.SampleBank} {sample.SampleVolume}%");
return new RowAttribute("sample", () => $"{sample.SampleBank} {sample.SampleVolume}%");
}
return null;

View File

@ -2,28 +2,37 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Bindables;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Graphics.Sprites;
using osu.Game.Overlays.Settings;
namespace osu.Game.Screens.Edit.Timing
{
internal class DifficultySection : Section<DifficultyControlPoint>
{
private OsuSpriteText multiplier;
private SettingsSlider<double> multiplier;
[BackgroundDependencyLoader]
private void load()
{
Flow.AddRange(new[]
{
multiplier = new OsuSpriteText(),
multiplier = new SettingsSlider<double>
{
LabelText = "Speed Multiplier",
Bindable = new DifficultyControlPoint().SpeedMultiplierBindable,
RelativeSizeAxes = Axes.X,
}
});
}
protected override void OnControlPointChanged(ValueChangedEvent<DifficultyControlPoint> point)
{
multiplier.Text = $"Multiplier: {point.NewValue?.SpeedMultiplier:0.##}x";
if (point.NewValue != null)
{
multiplier.Bindable = point.NewValue.SpeedMultiplierBindable;
}
}
protected override DifficultyControlPoint CreatePoint()

View File

@ -4,29 +4,32 @@
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterfaceV2;
namespace osu.Game.Screens.Edit.Timing
{
internal class EffectSection : Section<EffectControlPoint>
{
private OsuSpriteText kiai;
private OsuSpriteText omitBarLine;
private LabelledSwitchButton kiai;
private LabelledSwitchButton omitBarLine;
[BackgroundDependencyLoader]
private void load()
{
Flow.AddRange(new[]
{
kiai = new OsuSpriteText(),
omitBarLine = new OsuSpriteText(),
kiai = new LabelledSwitchButton { Label = "Kiai Time" },
omitBarLine = new LabelledSwitchButton { Label = "Skip Bar Line" },
});
}
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")}";
if (point.NewValue != null)
{
kiai.Current = point.NewValue.KiaiModeBindable;
omitBarLine.Current = point.NewValue.OmitFirstBarLineBindable;
}
}
protected override EffectControlPoint CreatePoint()

View File

@ -1,6 +1,7 @@
// 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 osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -14,9 +15,9 @@ namespace osu.Game.Screens.Edit.Timing
public class RowAttribute : CompositeDrawable, IHasTooltip
{
private readonly string header;
private readonly string content;
private readonly Func<string> content;
public RowAttribute(string header, string content)
public RowAttribute(string header, Func<string> content)
{
this.header = header;
this.content = content;
@ -54,6 +55,6 @@ namespace osu.Game.Screens.Edit.Timing
};
}
public string TooltipText => content;
public string TooltipText => content();
}
}

View File

@ -2,31 +2,43 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Bindables;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterfaceV2;
using osu.Game.Overlays.Settings;
namespace osu.Game.Screens.Edit.Timing
{
internal class SampleSection : Section<SampleControlPoint>
{
private OsuSpriteText bank;
private OsuSpriteText volume;
private LabelledTextBox bank;
private SettingsSlider<int> volume;
[BackgroundDependencyLoader]
private void load()
{
Flow.AddRange(new[]
Flow.AddRange(new Drawable[]
{
bank = new OsuSpriteText(),
volume = new OsuSpriteText(),
bank = new LabelledTextBox
{
Label = "Bank Name",
},
volume = new SettingsSlider<int>
{
Bindable = new SampleControlPoint().SampleVolumeBindable,
LabelText = "Volume",
}
});
}
protected override void OnControlPointChanged(ValueChangedEvent<SampleControlPoint> point)
{
bank.Text = $"Bank: {point.NewValue?.SampleBank}";
volume.Text = $"Volume: {point.NewValue?.SampleVolume}%";
if (point.NewValue != null)
{
bank.Current = point.NewValue.SampleBankBindable;
volume.Bindable = point.NewValue.SampleVolumeBindable;
}
}
protected override SampleControlPoint CreatePoint()

View File

@ -3,30 +3,42 @@
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Graphics.Sprites;
using osu.Game.Beatmaps.Timing;
using osu.Game.Overlays.Settings;
namespace osu.Game.Screens.Edit.Timing
{
internal class TimingSection : Section<TimingControlPoint>
{
private OsuSpriteText bpm;
private OsuSpriteText timeSignature;
private SettingsSlider<double> bpm;
private SettingsEnumDropdown<TimeSignatures> timeSignature;
[BackgroundDependencyLoader]
private void load()
{
Flow.AddRange(new[]
Flow.AddRange(new Drawable[]
{
bpm = new OsuSpriteText(),
timeSignature = new OsuSpriteText(),
bpm = new BPMSlider
{
Bindable = new TimingControlPoint().BeatLengthBindable,
LabelText = "BPM",
},
timeSignature = new SettingsEnumDropdown<TimeSignatures>
{
LabelText = "Time Signature"
},
});
}
protected override void OnControlPointChanged(ValueChangedEvent<TimingControlPoint> point)
{
bpm.Text = $"BPM: {point.NewValue?.BPM:0.##}";
timeSignature.Text = $"Signature: {point.NewValue?.TimeSignature}";
if (point.NewValue != null)
{
bpm.Bindable = point.NewValue.BeatLengthBindable;
timeSignature.Bindable = point.NewValue.TimeSignatureBindable;
}
}
protected override TimingControlPoint CreatePoint()
@ -39,5 +51,35 @@ namespace osu.Game.Screens.Edit.Timing
TimeSignature = reference.TimeSignature
};
}
private class BPMSlider : SettingsSlider<double>
{
private readonly BindableDouble beatLengthBindable = new BindableDouble();
private BindableDouble bpmBindable;
public override Bindable<double> Bindable
{
get => base.Bindable;
set
{
// incoming will be beatlength
beatLengthBindable.UnbindBindings();
beatLengthBindable.BindTo(value);
base.Bindable = bpmBindable = new BindableDouble(beatLengthToBpm(beatLengthBindable.Value))
{
MinValue = beatLengthToBpm(beatLengthBindable.MaxValue),
MaxValue = beatLengthToBpm(beatLengthBindable.MinValue),
Default = beatLengthToBpm(beatLengthBindable.Default),
};
bpmBindable.BindValueChanged(bpm => beatLengthBindable.Value = beatLengthToBpm(bpm.NewValue));
}
}
private double beatLengthToBpm(double beatLength) => 60000 / beatLength;
}
}
}