mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 13:32:54 +08:00
Merge branch 'master' into slider-anchor-type-switching
This commit is contained in:
commit
57774ae767
@ -10,7 +10,7 @@
|
||||
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2024.528.1" />
|
||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2024.618.0" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<!-- Fody does not handle Android build well, and warns when unchanged.
|
||||
|
@ -74,7 +74,7 @@ namespace osu.Game.Rulesets.Catch.Tests.Mods
|
||||
StartTime = 5000,
|
||||
}
|
||||
},
|
||||
Breaks = new List<BreakPeriod>
|
||||
Breaks =
|
||||
{
|
||||
new BreakPeriod(2000, 4000),
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ namespace osu.Game.Rulesets.Catch.Edit.Blueprints
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
inputManager = GetContainingInputManager();
|
||||
inputManager = GetContainingInputManager()!;
|
||||
|
||||
BeginPlacement();
|
||||
}
|
||||
|
@ -76,6 +76,8 @@ namespace osu.Game.Rulesets.Catch.Objects
|
||||
{
|
||||
base.CreateNestedHitObjects(cancellationToken);
|
||||
|
||||
this.PopulateNodeSamples();
|
||||
|
||||
var dropletSamples = Samples.Select(s => s.With(@"slidertick")).ToList();
|
||||
|
||||
int nodeIndex = 0;
|
||||
|
@ -84,7 +84,7 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
{
|
||||
base.Update();
|
||||
|
||||
var replayState = (GetContainingInputManager().CurrentState as RulesetInputManagerInputState<CatchAction>)?.LastReplayState as CatchFramedReplayInputHandler.CatchReplayState;
|
||||
var replayState = (GetContainingInputManager()!.CurrentState as RulesetInputManagerInputState<CatchAction>)?.LastReplayState as CatchFramedReplayInputHandler.CatchReplayState;
|
||||
|
||||
SetCatcherPosition(
|
||||
replayState?.CatcherX ??
|
||||
|
@ -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 System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
@ -17,6 +18,7 @@ using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Rulesets.UI.Scrolling;
|
||||
using osu.Game.Screens.Edit;
|
||||
using osu.Game.Screens.Edit.Compose.Components;
|
||||
using osu.Game.Tests.Visual;
|
||||
using osuTK;
|
||||
|
||||
@ -84,6 +86,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor
|
||||
public partial class TestHitObjectComposer : HitObjectComposer
|
||||
{
|
||||
public override Playfield Playfield { get; }
|
||||
public override ComposeBlueprintContainer BlueprintContainer => throw new NotImplementedException();
|
||||
public override IEnumerable<DrawableHitObject> HitObjects => Enumerable.Empty<DrawableHitObject>();
|
||||
public override bool CursorInPlacementArea => false;
|
||||
|
||||
@ -100,7 +103,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor
|
||||
|
||||
public override SnapResult FindSnappedPositionAndTime(Vector2 screenSpacePosition, SnapType snapType = SnapType.All)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ namespace osu.Game.Rulesets.Mania.Tests
|
||||
AddStep("Hold key", () =>
|
||||
{
|
||||
clock.CurrentTime = 0;
|
||||
note.OnPressed(new KeyBindingPressEvent<ManiaAction>(GetContainingInputManager().CurrentState, ManiaAction.Key1));
|
||||
note.OnPressed(new KeyBindingPressEvent<ManiaAction>(GetContainingInputManager()!.CurrentState, ManiaAction.Key1));
|
||||
});
|
||||
AddStep("progress time", () => clock.CurrentTime = 500);
|
||||
AddAssert("head is visible", () => note.Head.Alpha == 1);
|
||||
|
@ -65,11 +65,8 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
|
||||
if (tmp is IFramedAnimation tmpAnimation && tmpAnimation.FrameCount > 0)
|
||||
frameLength = Math.Max(1000 / 60.0, 170.0 / tmpAnimation.FrameCount);
|
||||
|
||||
light = skin.GetAnimation(lightImage, true, true, frameLength: frameLength).With(d =>
|
||||
light = skin.GetAnimation(lightImage, true, true, frameLength: frameLength)?.With(d =>
|
||||
{
|
||||
if (d == null)
|
||||
return;
|
||||
|
||||
d.Origin = Anchor.Centre;
|
||||
d.Blending = BlendingParameters.Additive;
|
||||
d.Scale = new Vector2(lightScale);
|
||||
@ -91,11 +88,8 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
|
||||
direction.BindTo(scrollingInfo.Direction);
|
||||
isHitting.BindTo(holdNote.IsHitting);
|
||||
|
||||
bodySprite = skin.GetAnimation(imageName, wrapMode, wrapMode, true, true, frameLength: 30).With(d =>
|
||||
bodySprite = skin.GetAnimation(imageName, wrapMode, wrapMode, true, true, frameLength: 30)?.With(d =>
|
||||
{
|
||||
if (d == null)
|
||||
return;
|
||||
|
||||
if (d is TextureAnimation animation)
|
||||
animation.IsPlaying = false;
|
||||
|
||||
|
@ -43,11 +43,8 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
|
||||
if (tmp is IFramedAnimation tmpAnimation && tmpAnimation.FrameCount > 0)
|
||||
frameLength = Math.Max(1000 / 60.0, 170.0 / tmpAnimation.FrameCount);
|
||||
|
||||
explosion = skin.GetAnimation(imageName, true, false, frameLength: frameLength).With(d =>
|
||||
explosion = skin.GetAnimation(imageName, true, false, frameLength: frameLength)?.With(d =>
|
||||
{
|
||||
if (d == null)
|
||||
return;
|
||||
|
||||
d.Origin = Anchor.Centre;
|
||||
d.Blending = BlendingParameters.Additive;
|
||||
d.Scale = new Vector2(explosionScale);
|
||||
|
@ -28,13 +28,7 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
|
||||
string bottomImage = skin.GetManiaSkinConfig<string>(LegacyManiaSkinConfigurationLookups.BottomStageImage)?.Value
|
||||
?? "mania-stage-bottom";
|
||||
|
||||
sprite = skin.GetAnimation(bottomImage, true, true)?.With(d =>
|
||||
{
|
||||
if (d == null)
|
||||
return;
|
||||
|
||||
d.Scale = new Vector2(1.6f);
|
||||
});
|
||||
sprite = skin.GetAnimation(bottomImage, true, true)?.With(d => d.Scale = new Vector2(1.6f));
|
||||
|
||||
if (sprite != null)
|
||||
InternalChild = sprite;
|
||||
|
@ -133,7 +133,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods
|
||||
Autoplay = false,
|
||||
Beatmap = new Beatmap
|
||||
{
|
||||
Breaks = new List<BreakPeriod>
|
||||
Breaks =
|
||||
{
|
||||
new BreakPeriod(500, 2000),
|
||||
},
|
||||
|
@ -46,7 +46,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods
|
||||
StartTime = 5000,
|
||||
}
|
||||
},
|
||||
Breaks = new List<BreakPeriod>
|
||||
Breaks =
|
||||
{
|
||||
new BreakPeriod(2000, 4000),
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods
|
||||
Autoplay = false,
|
||||
Beatmap = new Beatmap
|
||||
{
|
||||
Breaks = new List<BreakPeriod>
|
||||
Breaks =
|
||||
{
|
||||
new BreakPeriod(500, 2000),
|
||||
},
|
||||
|
@ -161,9 +161,9 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
|
||||
pressed = value;
|
||||
if (value)
|
||||
OnPressed(new KeyBindingPressEvent<OsuAction>(GetContainingInputManager().CurrentState, OsuAction.LeftButton));
|
||||
OnPressed(new KeyBindingPressEvent<OsuAction>(GetContainingInputManager()!.CurrentState, OsuAction.LeftButton));
|
||||
else
|
||||
OnReleased(new KeyBindingReleaseEvent<OsuAction>(GetContainingInputManager().CurrentState, OsuAction.LeftButton));
|
||||
OnReleased(new KeyBindingReleaseEvent<OsuAction>(GetContainingInputManager()!.CurrentState, OsuAction.LeftButton));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
private void scheduleHit() => AddStep("schedule action", () =>
|
||||
{
|
||||
double delay = hitCircle.StartTime - hitCircle.HitWindows.WindowFor(HitResult.Great) - Time.Current;
|
||||
Scheduler.AddDelayed(() => hitAreaReceptor.OnPressed(new KeyBindingPressEvent<OsuAction>(GetContainingInputManager().CurrentState, OsuAction.LeftButton)), delay);
|
||||
Scheduler.AddDelayed(() => hitAreaReceptor.OnPressed(new KeyBindingPressEvent<OsuAction>(GetContainingInputManager()!.CurrentState, OsuAction.LeftButton)), delay);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -156,6 +156,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
{
|
||||
slider = (DrawableSlider)createSlider(repeats: 1);
|
||||
Add(slider);
|
||||
slider.HitObject.NodeSamples.Clear();
|
||||
});
|
||||
|
||||
AddStep("change samples", () => slider.HitObject.Samples = new[]
|
||||
|
@ -252,6 +252,8 @@ namespace osu.Game.Rulesets.Osu.Objects
|
||||
|
||||
protected void UpdateNestedSamples()
|
||||
{
|
||||
this.PopulateNodeSamples();
|
||||
|
||||
// TODO: remove this when guaranteed sort is present for samples (https://github.com/ppy/osu/issues/1933)
|
||||
HitSampleInfo tickSample = (Samples.FirstOrDefault(s => s.Name == HitSampleInfo.HIT_NORMAL) ?? Samples.FirstOrDefault())?.With("slidertick");
|
||||
|
||||
|
@ -177,7 +177,7 @@ namespace osu.Game.Rulesets.Taiko.Tests.Mods
|
||||
Autoplay = false,
|
||||
Beatmap = new Beatmap
|
||||
{
|
||||
Breaks = new List<BreakPeriod>
|
||||
Breaks =
|
||||
{
|
||||
new BreakPeriod(100, 1600),
|
||||
},
|
||||
|
@ -1,7 +1,6 @@
|
||||
// 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 NUnit.Framework;
|
||||
using osu.Game.Beatmaps;
|
||||
@ -29,7 +28,7 @@ namespace osu.Game.Tests.Editing.Checks
|
||||
{
|
||||
var beatmap = new Beatmap<HitObject>
|
||||
{
|
||||
Breaks = new List<BreakPeriod>
|
||||
Breaks =
|
||||
{
|
||||
new BreakPeriod(0, 649)
|
||||
}
|
||||
@ -52,7 +51,7 @@ namespace osu.Game.Tests.Editing.Checks
|
||||
new HitCircle { StartTime = 0 },
|
||||
new HitCircle { StartTime = 1_200 }
|
||||
},
|
||||
Breaks = new List<BreakPeriod>
|
||||
Breaks =
|
||||
{
|
||||
new BreakPeriod(100, 751)
|
||||
}
|
||||
@ -75,7 +74,7 @@ namespace osu.Game.Tests.Editing.Checks
|
||||
new HitCircle { StartTime = 0 },
|
||||
new HitCircle { StartTime = 1_298 }
|
||||
},
|
||||
Breaks = new List<BreakPeriod>
|
||||
Breaks =
|
||||
{
|
||||
new BreakPeriod(200, 850)
|
||||
}
|
||||
@ -98,7 +97,7 @@ namespace osu.Game.Tests.Editing.Checks
|
||||
new HitCircle { StartTime = 0 },
|
||||
new HitCircle { StartTime = 1200 }
|
||||
},
|
||||
Breaks = new List<BreakPeriod>
|
||||
Breaks =
|
||||
{
|
||||
new BreakPeriod(1398, 2300)
|
||||
}
|
||||
@ -121,7 +120,7 @@ namespace osu.Game.Tests.Editing.Checks
|
||||
new HitCircle { StartTime = 1100 },
|
||||
new HitCircle { StartTime = 1500 }
|
||||
},
|
||||
Breaks = new List<BreakPeriod>
|
||||
Breaks =
|
||||
{
|
||||
new BreakPeriod(0, 652)
|
||||
}
|
||||
@ -145,7 +144,7 @@ namespace osu.Game.Tests.Editing.Checks
|
||||
new HitCircle { StartTime = 1_297 },
|
||||
new HitCircle { StartTime = 1_298 }
|
||||
},
|
||||
Breaks = new List<BreakPeriod>
|
||||
Breaks =
|
||||
{
|
||||
new BreakPeriod(200, 850)
|
||||
}
|
||||
@ -168,7 +167,7 @@ namespace osu.Game.Tests.Editing.Checks
|
||||
new HitCircle { StartTime = 0 },
|
||||
new HitCircle { StartTime = 1_300 }
|
||||
},
|
||||
Breaks = new List<BreakPeriod>
|
||||
Breaks =
|
||||
{
|
||||
new BreakPeriod(200, 850)
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ namespace osu.Game.Tests.Editing.Checks
|
||||
new HitCircle { StartTime = 0 },
|
||||
new HitCircle { StartTime = 40_000 }
|
||||
},
|
||||
Breaks = new List<BreakPeriod>
|
||||
Breaks =
|
||||
{
|
||||
new BreakPeriod(10_000, 21_000)
|
||||
}
|
||||
|
300
osu.Game.Tests/Editing/TestSceneEditorBeatmapProcessor.cs
Normal file
300
osu.Game.Tests/Editing/TestSceneEditorBeatmapProcessor.cs
Normal file
@ -0,0 +1,300 @@
|
||||
// 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 NUnit.Framework;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Beatmaps.Timing;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Screens.Edit;
|
||||
|
||||
namespace osu.Game.Tests.Editing
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestSceneEditorBeatmapProcessor
|
||||
{
|
||||
[Test]
|
||||
public void TestEmptyBeatmap()
|
||||
{
|
||||
var controlPoints = new ControlPointInfo();
|
||||
controlPoints.Add(0, new TimingControlPoint { BeatLength = 500 });
|
||||
var beatmap = new Beatmap
|
||||
{
|
||||
ControlPointInfo = controlPoints,
|
||||
};
|
||||
|
||||
var beatmapProcessor = new EditorBeatmapProcessor(beatmap, new OsuRuleset());
|
||||
beatmapProcessor.PreProcess();
|
||||
beatmapProcessor.PostProcess();
|
||||
|
||||
Assert.That(beatmap.Breaks, Is.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSingleObjectBeatmap()
|
||||
{
|
||||
var controlPoints = new ControlPointInfo();
|
||||
controlPoints.Add(0, new TimingControlPoint { BeatLength = 500 });
|
||||
var beatmap = new Beatmap
|
||||
{
|
||||
ControlPointInfo = controlPoints,
|
||||
HitObjects =
|
||||
{
|
||||
new HitCircle { StartTime = 1000 },
|
||||
}
|
||||
};
|
||||
|
||||
var beatmapProcessor = new EditorBeatmapProcessor(beatmap, new OsuRuleset());
|
||||
beatmapProcessor.PreProcess();
|
||||
beatmapProcessor.PostProcess();
|
||||
|
||||
Assert.That(beatmap.Breaks, Is.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestTwoObjectsCloseTogether()
|
||||
{
|
||||
var controlPoints = new ControlPointInfo();
|
||||
controlPoints.Add(0, new TimingControlPoint { BeatLength = 500 });
|
||||
var beatmap = new Beatmap
|
||||
{
|
||||
ControlPointInfo = controlPoints,
|
||||
HitObjects =
|
||||
{
|
||||
new HitCircle { StartTime = 1000 },
|
||||
new HitCircle { StartTime = 2000 },
|
||||
}
|
||||
};
|
||||
|
||||
var beatmapProcessor = new EditorBeatmapProcessor(beatmap, new OsuRuleset());
|
||||
beatmapProcessor.PreProcess();
|
||||
beatmapProcessor.PostProcess();
|
||||
|
||||
Assert.That(beatmap.Breaks, Is.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestTwoObjectsFarApart()
|
||||
{
|
||||
var controlPoints = new ControlPointInfo();
|
||||
controlPoints.Add(0, new TimingControlPoint { BeatLength = 500 });
|
||||
var beatmap = new Beatmap
|
||||
{
|
||||
ControlPointInfo = controlPoints,
|
||||
HitObjects =
|
||||
{
|
||||
new HitCircle { StartTime = 1000 },
|
||||
new HitCircle { StartTime = 5000 },
|
||||
}
|
||||
};
|
||||
|
||||
var beatmapProcessor = new EditorBeatmapProcessor(beatmap, new OsuRuleset());
|
||||
beatmapProcessor.PreProcess();
|
||||
beatmapProcessor.PostProcess();
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(beatmap.Breaks, Has.Count.EqualTo(1));
|
||||
Assert.That(beatmap.Breaks[0].StartTime, Is.EqualTo(1200));
|
||||
Assert.That(beatmap.Breaks[0].EndTime, Is.EqualTo(4000));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestBreaksAreFused()
|
||||
{
|
||||
var controlPoints = new ControlPointInfo();
|
||||
controlPoints.Add(0, new TimingControlPoint { BeatLength = 500 });
|
||||
var beatmap = new Beatmap
|
||||
{
|
||||
ControlPointInfo = controlPoints,
|
||||
HitObjects =
|
||||
{
|
||||
new HitCircle { StartTime = 1000 },
|
||||
new HitCircle { StartTime = 9000 },
|
||||
},
|
||||
Breaks =
|
||||
{
|
||||
new BreakPeriod(1200, 4000),
|
||||
new BreakPeriod(5200, 8000),
|
||||
}
|
||||
};
|
||||
|
||||
var beatmapProcessor = new EditorBeatmapProcessor(beatmap, new OsuRuleset());
|
||||
beatmapProcessor.PreProcess();
|
||||
beatmapProcessor.PostProcess();
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(beatmap.Breaks, Has.Count.EqualTo(1));
|
||||
Assert.That(beatmap.Breaks[0].StartTime, Is.EqualTo(1200));
|
||||
Assert.That(beatmap.Breaks[0].EndTime, Is.EqualTo(8000));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestBreaksAreSplit()
|
||||
{
|
||||
var controlPoints = new ControlPointInfo();
|
||||
controlPoints.Add(0, new TimingControlPoint { BeatLength = 500 });
|
||||
var beatmap = new Beatmap
|
||||
{
|
||||
ControlPointInfo = controlPoints,
|
||||
HitObjects =
|
||||
{
|
||||
new HitCircle { StartTime = 1000 },
|
||||
new HitCircle { StartTime = 5000 },
|
||||
new HitCircle { StartTime = 9000 },
|
||||
},
|
||||
Breaks =
|
||||
{
|
||||
new BreakPeriod(1200, 8000),
|
||||
}
|
||||
};
|
||||
|
||||
var beatmapProcessor = new EditorBeatmapProcessor(beatmap, new OsuRuleset());
|
||||
beatmapProcessor.PreProcess();
|
||||
beatmapProcessor.PostProcess();
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(beatmap.Breaks, Has.Count.EqualTo(2));
|
||||
Assert.That(beatmap.Breaks[0].StartTime, Is.EqualTo(1200));
|
||||
Assert.That(beatmap.Breaks[0].EndTime, Is.EqualTo(4000));
|
||||
Assert.That(beatmap.Breaks[1].StartTime, Is.EqualTo(5200));
|
||||
Assert.That(beatmap.Breaks[1].EndTime, Is.EqualTo(8000));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestBreaksAreNudged()
|
||||
{
|
||||
var controlPoints = new ControlPointInfo();
|
||||
controlPoints.Add(0, new TimingControlPoint { BeatLength = 500 });
|
||||
var beatmap = new Beatmap
|
||||
{
|
||||
ControlPointInfo = controlPoints,
|
||||
HitObjects =
|
||||
{
|
||||
new HitCircle { StartTime = 1100 },
|
||||
new HitCircle { StartTime = 9000 },
|
||||
},
|
||||
Breaks =
|
||||
{
|
||||
new BreakPeriod(1200, 8000),
|
||||
}
|
||||
};
|
||||
|
||||
var beatmapProcessor = new EditorBeatmapProcessor(beatmap, new OsuRuleset());
|
||||
beatmapProcessor.PreProcess();
|
||||
beatmapProcessor.PostProcess();
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(beatmap.Breaks, Has.Count.EqualTo(1));
|
||||
Assert.That(beatmap.Breaks[0].StartTime, Is.EqualTo(1300));
|
||||
Assert.That(beatmap.Breaks[0].EndTime, Is.EqualTo(8000));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestManualBreaksAreNotFused()
|
||||
{
|
||||
var controlPoints = new ControlPointInfo();
|
||||
controlPoints.Add(0, new TimingControlPoint { BeatLength = 500 });
|
||||
var beatmap = new Beatmap
|
||||
{
|
||||
ControlPointInfo = controlPoints,
|
||||
HitObjects =
|
||||
{
|
||||
new HitCircle { StartTime = 1000 },
|
||||
new HitCircle { StartTime = 9000 },
|
||||
},
|
||||
Breaks =
|
||||
{
|
||||
new ManualBreakPeriod(1200, 4000),
|
||||
new ManualBreakPeriod(5200, 8000),
|
||||
}
|
||||
};
|
||||
|
||||
var beatmapProcessor = new EditorBeatmapProcessor(beatmap, new OsuRuleset());
|
||||
beatmapProcessor.PreProcess();
|
||||
beatmapProcessor.PostProcess();
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(beatmap.Breaks, Has.Count.EqualTo(2));
|
||||
Assert.That(beatmap.Breaks[0].StartTime, Is.EqualTo(1200));
|
||||
Assert.That(beatmap.Breaks[0].EndTime, Is.EqualTo(4000));
|
||||
Assert.That(beatmap.Breaks[1].StartTime, Is.EqualTo(5200));
|
||||
Assert.That(beatmap.Breaks[1].EndTime, Is.EqualTo(8000));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestManualBreaksAreSplit()
|
||||
{
|
||||
var controlPoints = new ControlPointInfo();
|
||||
controlPoints.Add(0, new TimingControlPoint { BeatLength = 500 });
|
||||
var beatmap = new Beatmap
|
||||
{
|
||||
ControlPointInfo = controlPoints,
|
||||
HitObjects =
|
||||
{
|
||||
new HitCircle { StartTime = 1000 },
|
||||
new HitCircle { StartTime = 5000 },
|
||||
new HitCircle { StartTime = 9000 },
|
||||
},
|
||||
Breaks =
|
||||
{
|
||||
new ManualBreakPeriod(1200, 8000),
|
||||
}
|
||||
};
|
||||
|
||||
var beatmapProcessor = new EditorBeatmapProcessor(beatmap, new OsuRuleset());
|
||||
beatmapProcessor.PreProcess();
|
||||
beatmapProcessor.PostProcess();
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(beatmap.Breaks, Has.Count.EqualTo(2));
|
||||
Assert.That(beatmap.Breaks[0].StartTime, Is.EqualTo(1200));
|
||||
Assert.That(beatmap.Breaks[0].EndTime, Is.EqualTo(4000));
|
||||
Assert.That(beatmap.Breaks[1].StartTime, Is.EqualTo(5200));
|
||||
Assert.That(beatmap.Breaks[1].EndTime, Is.EqualTo(8000));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestManualBreaksAreNotNudged()
|
||||
{
|
||||
var controlPoints = new ControlPointInfo();
|
||||
controlPoints.Add(0, new TimingControlPoint { BeatLength = 500 });
|
||||
var beatmap = new Beatmap
|
||||
{
|
||||
ControlPointInfo = controlPoints,
|
||||
HitObjects =
|
||||
{
|
||||
new HitCircle { StartTime = 1000 },
|
||||
new HitCircle { StartTime = 9000 },
|
||||
},
|
||||
Breaks =
|
||||
{
|
||||
new ManualBreakPeriod(1200, 8800),
|
||||
}
|
||||
};
|
||||
|
||||
var beatmapProcessor = new EditorBeatmapProcessor(beatmap, new OsuRuleset());
|
||||
beatmapProcessor.PreProcess();
|
||||
beatmapProcessor.PostProcess();
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(beatmap.Breaks, Has.Count.EqualTo(1));
|
||||
Assert.That(beatmap.Breaks[0].StartTime, Is.EqualTo(1200));
|
||||
Assert.That(beatmap.Breaks[0].EndTime, Is.EqualTo(8800));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -4,10 +4,12 @@
|
||||
#nullable disable
|
||||
|
||||
using NUnit.Framework;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Tests.Beatmaps;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Editing
|
||||
{
|
||||
@ -15,6 +17,8 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
{
|
||||
protected override Ruleset CreateEditorRuleset() => new OsuRuleset();
|
||||
|
||||
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset) => new TestBeatmap(ruleset, false);
|
||||
|
||||
[Test]
|
||||
public void TestSelectedObjects()
|
||||
{
|
||||
|
@ -13,9 +13,12 @@ using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Graphics.UserInterfaceV2;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Rulesets.Osu.UI;
|
||||
using osu.Game.Screens.Edit.Components.TernaryButtons;
|
||||
using osu.Game.Screens.Edit.Compose.Components.Timeline;
|
||||
using osu.Game.Screens.Edit.Timing;
|
||||
using osu.Game.Tests.Beatmaps;
|
||||
@ -79,10 +82,10 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestPopoverHasFocus()
|
||||
public void TestPopoverHasNoFocus()
|
||||
{
|
||||
clickSamplePiece(0);
|
||||
samplePopoverHasFocus();
|
||||
samplePopoverHasNoFocus();
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -226,6 +229,84 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
samplePopoverHasSingleBank(HitSampleInfo.BANK_NORMAL);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestPopoverAddSampleAddition()
|
||||
{
|
||||
clickSamplePiece(0);
|
||||
|
||||
setBankViaPopover(HitSampleInfo.BANK_SOFT);
|
||||
hitObjectHasSampleBank(0, HitSampleInfo.BANK_SOFT);
|
||||
|
||||
toggleAdditionViaPopover(0);
|
||||
|
||||
hitObjectHasSampleBank(0, HitSampleInfo.BANK_SOFT);
|
||||
hitObjectHasSamples(0, HitSampleInfo.HIT_NORMAL, HitSampleInfo.HIT_WHISTLE);
|
||||
|
||||
setAdditionBankViaPopover(HitSampleInfo.BANK_DRUM);
|
||||
|
||||
hitObjectHasSampleNormalBank(0, HitSampleInfo.BANK_SOFT);
|
||||
hitObjectHasSampleAdditionBank(0, HitSampleInfo.BANK_DRUM);
|
||||
|
||||
toggleAdditionViaPopover(0);
|
||||
|
||||
hitObjectHasSampleBank(0, HitSampleInfo.BANK_SOFT);
|
||||
hitObjectHasSamples(0, HitSampleInfo.HIT_NORMAL);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNodeSamplePopover()
|
||||
{
|
||||
AddStep("add slider", () =>
|
||||
{
|
||||
EditorBeatmap.Clear();
|
||||
EditorBeatmap.Add(new Slider
|
||||
{
|
||||
Position = new Vector2(256, 256),
|
||||
StartTime = 0,
|
||||
Path = new SliderPath(new[] { new PathControlPoint(Vector2.Zero), new PathControlPoint(new Vector2(250, 0)) }),
|
||||
Samples =
|
||||
{
|
||||
new HitSampleInfo(HitSampleInfo.HIT_NORMAL)
|
||||
},
|
||||
NodeSamples =
|
||||
{
|
||||
new List<HitSampleInfo> { new HitSampleInfo(HitSampleInfo.HIT_NORMAL) },
|
||||
new List<HitSampleInfo> { new HitSampleInfo(HitSampleInfo.HIT_NORMAL) },
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
clickNodeSamplePiece(0, 1);
|
||||
|
||||
setBankViaPopover(HitSampleInfo.BANK_SOFT);
|
||||
hitObjectNodeHasSampleBank(0, 0, HitSampleInfo.BANK_NORMAL);
|
||||
hitObjectNodeHasSampleBank(0, 1, HitSampleInfo.BANK_SOFT);
|
||||
|
||||
toggleAdditionViaPopover(0);
|
||||
|
||||
hitObjectNodeHasSampleBank(0, 0, HitSampleInfo.BANK_NORMAL);
|
||||
hitObjectNodeHasSampleBank(0, 1, HitSampleInfo.BANK_SOFT);
|
||||
hitObjectNodeHasSamples(0, 0, HitSampleInfo.HIT_NORMAL);
|
||||
hitObjectNodeHasSamples(0, 1, HitSampleInfo.HIT_NORMAL, HitSampleInfo.HIT_WHISTLE);
|
||||
|
||||
setAdditionBankViaPopover(HitSampleInfo.BANK_DRUM);
|
||||
|
||||
hitObjectNodeHasSampleBank(0, 0, HitSampleInfo.BANK_NORMAL);
|
||||
hitObjectNodeHasSampleNormalBank(0, 1, HitSampleInfo.BANK_SOFT);
|
||||
hitObjectNodeHasSampleAdditionBank(0, 1, HitSampleInfo.BANK_DRUM);
|
||||
|
||||
toggleAdditionViaPopover(0);
|
||||
|
||||
hitObjectNodeHasSampleBank(0, 1, HitSampleInfo.BANK_SOFT);
|
||||
hitObjectNodeHasSamples(0, 0, HitSampleInfo.HIT_NORMAL);
|
||||
hitObjectNodeHasSamples(0, 1, HitSampleInfo.HIT_NORMAL);
|
||||
|
||||
setVolumeViaPopover(10);
|
||||
|
||||
hitObjectNodeHasSampleVolume(0, 0, 100);
|
||||
hitObjectNodeHasSampleVolume(0, 1, 10);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestHotkeysMultipleSelectionWithSameSampleBank()
|
||||
{
|
||||
@ -329,13 +410,21 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
private void samplePopoverHasFocus() => AddUntilStep("sample popover textbox focused", () =>
|
||||
private void clickNodeSamplePiece(int objectIndex, int nodeIndex) => AddStep($"click {objectIndex.ToOrdinalWords()} object {nodeIndex.ToOrdinalWords()} node sample piece", () =>
|
||||
{
|
||||
var samplePiece = this.ChildrenOfType<NodeSamplePointPiece>().Where(piece => piece.HitObject == EditorBeatmap.HitObjects.ElementAt(objectIndex)).ToArray()[nodeIndex];
|
||||
|
||||
InputManager.MoveMouseTo(samplePiece);
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
private void samplePopoverHasNoFocus() => AddUntilStep("sample popover textbox not focused", () =>
|
||||
{
|
||||
var popover = this.ChildrenOfType<SamplePointPiece.SampleEditPopover>().SingleOrDefault();
|
||||
var slider = popover?.ChildrenOfType<IndeterminateSliderWithTextBoxInput<int>>().Single();
|
||||
var textbox = slider?.ChildrenOfType<OsuTextBox>().Single();
|
||||
|
||||
return textbox?.HasFocus == true;
|
||||
return textbox?.HasFocus == false;
|
||||
});
|
||||
|
||||
private void samplePopoverHasSingleVolume(int volume) => AddUntilStep($"sample popover has volume {volume}", () =>
|
||||
@ -372,7 +461,6 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
|
||||
private void dismissPopover()
|
||||
{
|
||||
AddStep("unfocus textbox", () => InputManager.Key(Key.Escape));
|
||||
AddStep("dismiss popover", () => InputManager.Key(Key.Escape));
|
||||
AddUntilStep("wait for dismiss", () => !this.ChildrenOfType<SamplePointPiece.SampleEditPopover>().Any(popover => popover.IsPresent));
|
||||
}
|
||||
@ -390,6 +478,12 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
return h.Samples.All(o => o.Volume == volume);
|
||||
});
|
||||
|
||||
private void hitObjectNodeHasSampleVolume(int objectIndex, int nodeIndex, int volume) => AddAssert($"{objectIndex.ToOrdinalWords()} object {nodeIndex.ToOrdinalWords()} node has volume {volume}", () =>
|
||||
{
|
||||
var h = EditorBeatmap.HitObjects.ElementAt(objectIndex) as IHasRepeats;
|
||||
return h is not null && h.NodeSamples[nodeIndex].All(o => o.Volume == volume);
|
||||
});
|
||||
|
||||
private void setBankViaPopover(string bank) => AddStep($"set bank {bank} via popover", () =>
|
||||
{
|
||||
var popover = this.ChildrenOfType<SamplePointPiece.SampleEditPopover>().Single();
|
||||
@ -401,6 +495,26 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
InputManager.Key(Key.Enter);
|
||||
});
|
||||
|
||||
private void setAdditionBankViaPopover(string bank) => AddStep($"set addition bank {bank} via popover", () =>
|
||||
{
|
||||
var popover = this.ChildrenOfType<SamplePointPiece.SampleEditPopover>().Single();
|
||||
var textBox = popover.ChildrenOfType<LabelledTextBox>().ToArray()[1];
|
||||
textBox.Current.Value = bank;
|
||||
// force a commit via keyboard.
|
||||
// this is needed when testing attempting to set empty bank - which should revert to the previous value, but only on commit.
|
||||
((IFocusManager)InputManager).ChangeFocus(textBox);
|
||||
InputManager.Key(Key.Enter);
|
||||
});
|
||||
|
||||
private void toggleAdditionViaPopover(int index) => AddStep($"toggle addition {index} via popover", () =>
|
||||
{
|
||||
var popover = this.ChildrenOfType<SamplePointPiece.SampleEditPopover>().First();
|
||||
var ternaryButton = popover.ChildrenOfType<DrawableTernaryButton>().ToArray()[index];
|
||||
InputManager.MoveMouseTo(ternaryButton);
|
||||
InputManager.PressButton(MouseButton.Left);
|
||||
InputManager.ReleaseButton(MouseButton.Left);
|
||||
});
|
||||
|
||||
private void hitObjectHasSamples(int objectIndex, params string[] samples) => AddAssert($"{objectIndex.ToOrdinalWords()} has samples {string.Join(',', samples)}", () =>
|
||||
{
|
||||
var h = EditorBeatmap.HitObjects.ElementAt(objectIndex);
|
||||
@ -412,5 +526,41 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
var h = EditorBeatmap.HitObjects.ElementAt(objectIndex);
|
||||
return h.Samples.All(o => o.Bank == bank);
|
||||
});
|
||||
|
||||
private void hitObjectHasSampleNormalBank(int objectIndex, string bank) => AddAssert($"{objectIndex.ToOrdinalWords()} has normal bank {bank}", () =>
|
||||
{
|
||||
var h = EditorBeatmap.HitObjects.ElementAt(objectIndex);
|
||||
return h.Samples.Where(o => o.Name == HitSampleInfo.HIT_NORMAL).All(o => o.Bank == bank);
|
||||
});
|
||||
|
||||
private void hitObjectHasSampleAdditionBank(int objectIndex, string bank) => AddAssert($"{objectIndex.ToOrdinalWords()} has addition bank {bank}", () =>
|
||||
{
|
||||
var h = EditorBeatmap.HitObjects.ElementAt(objectIndex);
|
||||
return h.Samples.Where(o => o.Name != HitSampleInfo.HIT_NORMAL).All(o => o.Bank == bank);
|
||||
});
|
||||
|
||||
private void hitObjectNodeHasSamples(int objectIndex, int nodeIndex, params string[] samples) => AddAssert($"{objectIndex.ToOrdinalWords()} object {nodeIndex.ToOrdinalWords()} node has samples {string.Join(',', samples)}", () =>
|
||||
{
|
||||
var h = EditorBeatmap.HitObjects.ElementAt(objectIndex) as IHasRepeats;
|
||||
return h is not null && h.NodeSamples[nodeIndex].Select(s => s.Name).SequenceEqual(samples);
|
||||
});
|
||||
|
||||
private void hitObjectNodeHasSampleBank(int objectIndex, int nodeIndex, string bank) => AddAssert($"{objectIndex.ToOrdinalWords()} object {nodeIndex.ToOrdinalWords()} node has bank {bank}", () =>
|
||||
{
|
||||
var h = EditorBeatmap.HitObjects.ElementAt(objectIndex) as IHasRepeats;
|
||||
return h is not null && h.NodeSamples[nodeIndex].All(o => o.Bank == bank);
|
||||
});
|
||||
|
||||
private void hitObjectNodeHasSampleNormalBank(int objectIndex, int nodeIndex, string bank) => AddAssert($"{objectIndex.ToOrdinalWords()} object {nodeIndex.ToOrdinalWords()} node has normal bank {bank}", () =>
|
||||
{
|
||||
var h = EditorBeatmap.HitObjects.ElementAt(objectIndex) as IHasRepeats;
|
||||
return h is not null && h.NodeSamples[nodeIndex].Where(o => o.Name == HitSampleInfo.HIT_NORMAL).All(o => o.Bank == bank);
|
||||
});
|
||||
|
||||
private void hitObjectNodeHasSampleAdditionBank(int objectIndex, int nodeIndex, string bank) => AddAssert($"{objectIndex.ToOrdinalWords()} object {nodeIndex.ToOrdinalWords()} node has addition bank {bank}", () =>
|
||||
{
|
||||
var h = EditorBeatmap.HitObjects.ElementAt(objectIndex) as IHasRepeats;
|
||||
return h is not null && h.NodeSamples[nodeIndex].Where(o => o.Name != HitSampleInfo.HIT_NORMAL).All(o => o.Bank == bank);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
updatePosition(GetContainingInputManager().CurrentState.Mouse.Position);
|
||||
updatePosition(GetContainingInputManager()!.CurrentState.Mouse.Position);
|
||||
}
|
||||
|
||||
protected override bool OnMouseMove(MouseMoveEvent e)
|
||||
|
@ -14,6 +14,7 @@ using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Osu.Edit;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Screens.Edit.Compose.Components.Timeline;
|
||||
using osu.Game.Tests.Beatmaps;
|
||||
@ -357,6 +358,51 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
AddAssert("all blueprints are present", () => blueprintContainer.SelectionBlueprints.Count == EditorBeatmap.SelectedHitObjects.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDragSelectionDuringPlacement()
|
||||
{
|
||||
var addedObjects = new[]
|
||||
{
|
||||
new Slider
|
||||
{
|
||||
StartTime = 300,
|
||||
Path = new SliderPath([
|
||||
new PathControlPoint(),
|
||||
new PathControlPoint(new Vector2(200)),
|
||||
])
|
||||
},
|
||||
};
|
||||
AddStep("add hitobjects", () => EditorBeatmap.AddRange(addedObjects));
|
||||
|
||||
AddStep("seek to 700", () => EditorClock.Seek(700));
|
||||
AddStep("select spinner placement tool", () =>
|
||||
{
|
||||
InputManager.Key(Key.Number4);
|
||||
InputManager.MoveMouseTo(this.ChildrenOfType<OsuHitObjectComposer>().Single());
|
||||
});
|
||||
AddStep("begin spinner placement", () => InputManager.Click(MouseButton.Left));
|
||||
AddStep("seek to 1500", () => EditorClock.Seek(1500));
|
||||
|
||||
AddStep("start dragging", () =>
|
||||
{
|
||||
var blueprintQuad = blueprintContainer.SelectionBlueprints[1].ScreenSpaceDrawQuad;
|
||||
var dragStartPos = (blueprintQuad.TopLeft + blueprintQuad.BottomLeft) / 2 - new Vector2(30, 0);
|
||||
InputManager.MoveMouseTo(dragStartPos);
|
||||
InputManager.PressButton(MouseButton.Left);
|
||||
});
|
||||
|
||||
AddStep("select entire object", () =>
|
||||
{
|
||||
var blueprintQuad = blueprintContainer.SelectionBlueprints[1].ScreenSpaceDrawQuad;
|
||||
var dragStartPos = (blueprintQuad.TopRight + blueprintQuad.BottomRight) / 2 + new Vector2(30, 0);
|
||||
InputManager.MoveMouseTo(dragStartPos);
|
||||
});
|
||||
AddStep("end drag", () => InputManager.ReleaseButton(MouseButton.Left));
|
||||
|
||||
AddUntilStep("hitobject selected", () => EditorBeatmap.SelectedHitObjects, () => NUnit.Framework.Contains.Item(addedObjects[0]));
|
||||
AddAssert("placement committed", () => EditorBeatmap.HitObjects, () => Has.Count.EqualTo(2));
|
||||
}
|
||||
|
||||
private void assertSelectionIs(IEnumerable<HitObject> hitObjects)
|
||||
=> AddAssert("correct hitobjects selected", () => EditorBeatmap.SelectedHitObjects.OrderBy(h => h.StartTime).SequenceEqual(hitObjects));
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
||||
editorInfo.Selected.ValueChanged += selection =>
|
||||
{
|
||||
// ensure any ongoing edits are committed out to the *current* selection before changing to a new one.
|
||||
GetContainingFocusManager().TriggerFocusContention(null);
|
||||
GetContainingFocusManager()?.TriggerFocusContention(null);
|
||||
|
||||
// Required to avoid cyclic failure in BindableWithCurrent (TriggerChange called during the Current_Set process).
|
||||
// Arguable a framework issue but since we haven't hit it anywhere else a local workaround seems best.
|
||||
|
@ -1,10 +1,8 @@
|
||||
// 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.Diagnostics;
|
||||
using ManagedBass.Fx;
|
||||
using osu.Framework.Audio.Mixing;
|
||||
using osu.Framework.Caching;
|
||||
using osu.Framework.Graphics;
|
||||
|
||||
namespace osu.Game.Audio.Effects
|
||||
@ -26,8 +24,6 @@ namespace osu.Game.Audio.Effects
|
||||
private readonly BQFParameters filter;
|
||||
private readonly BQFType type;
|
||||
|
||||
private readonly Cached filterApplication = new Cached();
|
||||
|
||||
private int cutoff;
|
||||
|
||||
/// <summary>
|
||||
@ -42,7 +38,7 @@ namespace osu.Game.Audio.Effects
|
||||
return;
|
||||
|
||||
cutoff = value;
|
||||
filterApplication.Invalidate();
|
||||
updateFilter();
|
||||
}
|
||||
}
|
||||
|
||||
@ -64,18 +60,9 @@ namespace osu.Game.Audio.Effects
|
||||
fQ = 0.7f
|
||||
};
|
||||
|
||||
Cutoff = getInitialCutoff(type);
|
||||
}
|
||||
cutoff = getInitialCutoff(type);
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
if (!filterApplication.IsValid)
|
||||
{
|
||||
updateFilter(cutoff);
|
||||
filterApplication.Validate();
|
||||
}
|
||||
updateFilter();
|
||||
}
|
||||
|
||||
private int getInitialCutoff(BQFType type)
|
||||
@ -93,13 +80,13 @@ namespace osu.Game.Audio.Effects
|
||||
}
|
||||
}
|
||||
|
||||
private void updateFilter(int newValue)
|
||||
private void updateFilter()
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case BQFType.LowPass:
|
||||
// Workaround for weird behaviour when rapidly setting fCenter of a low-pass filter to nyquist - 1hz.
|
||||
if (newValue >= MAX_LOWPASS_CUTOFF)
|
||||
if (Cutoff >= MAX_LOWPASS_CUTOFF)
|
||||
{
|
||||
ensureDetached();
|
||||
return;
|
||||
@ -109,7 +96,7 @@ namespace osu.Game.Audio.Effects
|
||||
|
||||
// Workaround for weird behaviour when rapidly setting fCenter of a high-pass filter to 1hz.
|
||||
case BQFType.HighPass:
|
||||
if (newValue <= 1)
|
||||
if (Cutoff <= 1)
|
||||
{
|
||||
ensureDetached();
|
||||
return;
|
||||
@ -120,17 +107,8 @@ namespace osu.Game.Audio.Effects
|
||||
|
||||
ensureAttached();
|
||||
|
||||
int filterIndex = mixer.Effects.IndexOf(filter);
|
||||
|
||||
if (filterIndex < 0) return;
|
||||
|
||||
if (mixer.Effects[filterIndex] is BQFParameters existingFilter)
|
||||
{
|
||||
existingFilter.fCenter = newValue;
|
||||
|
||||
// required to update effect with new parameters.
|
||||
mixer.Effects[filterIndex] = existingFilter;
|
||||
}
|
||||
filter.fCenter = Cutoff;
|
||||
mixer.UpdateEffect(filter);
|
||||
}
|
||||
|
||||
private void ensureAttached()
|
||||
@ -138,8 +116,7 @@ namespace osu.Game.Audio.Effects
|
||||
if (IsAttached)
|
||||
return;
|
||||
|
||||
Debug.Assert(!mixer.Effects.Contains(filter));
|
||||
mixer.Effects.Add(filter);
|
||||
mixer.AddEffect(filter);
|
||||
IsAttached = true;
|
||||
}
|
||||
|
||||
@ -148,8 +125,7 @@ namespace osu.Game.Audio.Effects
|
||||
if (!IsAttached)
|
||||
return;
|
||||
|
||||
Debug.Assert(mixer.Effects.Contains(filter));
|
||||
mixer.Effects.Remove(filter);
|
||||
mixer.RemoveEffect(filter);
|
||||
IsAttached = false;
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using Newtonsoft.Json;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Game.IO.Serialization.Converters;
|
||||
|
||||
namespace osu.Game.Beatmaps
|
||||
@ -61,7 +62,7 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
public ControlPointInfo ControlPointInfo { get; set; } = new ControlPointInfo();
|
||||
|
||||
public List<BreakPeriod> Breaks { get; set; } = new List<BreakPeriod>();
|
||||
public BindableList<BreakPeriod> Breaks { get; set; } = new BindableList<BreakPeriod>();
|
||||
|
||||
public List<string> UnhandledEventLines { get; set; } = new List<string>();
|
||||
|
||||
|
@ -13,8 +13,28 @@ namespace osu.Game.Beatmaps.ControlPoints
|
||||
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
|
||||
public abstract class ControlPoint : IComparable<ControlPoint>, IDeepCloneable<ControlPoint>, IEquatable<ControlPoint>, IControlPoint
|
||||
{
|
||||
/// <summary>
|
||||
/// Invoked when any of this <see cref="ControlPoint"/>'s properties have changed.
|
||||
/// </summary>
|
||||
public event Action<ControlPoint>? Changed;
|
||||
|
||||
protected void RaiseChanged() => Changed?.Invoke(this);
|
||||
|
||||
private double time;
|
||||
|
||||
[JsonIgnore]
|
||||
public double Time { get; set; }
|
||||
public double Time
|
||||
{
|
||||
get => time;
|
||||
set
|
||||
{
|
||||
if (time == value)
|
||||
return;
|
||||
|
||||
time = value;
|
||||
RaiseChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public void AttachGroup(ControlPointGroup pointGroup) => Time = pointGroup.Time;
|
||||
|
||||
|
@ -10,8 +10,11 @@ namespace osu.Game.Beatmaps.ControlPoints
|
||||
public class ControlPointGroup : IComparable<ControlPointGroup>, IEquatable<ControlPointGroup>
|
||||
{
|
||||
public event Action<ControlPoint>? ItemAdded;
|
||||
public event Action<ControlPoint>? ItemChanged;
|
||||
public event Action<ControlPoint>? ItemRemoved;
|
||||
|
||||
private void raiseItemChanged(ControlPoint controlPoint) => ItemChanged?.Invoke(controlPoint);
|
||||
|
||||
/// <summary>
|
||||
/// The time at which the control point takes effect.
|
||||
/// </summary>
|
||||
@ -39,12 +42,14 @@ namespace osu.Game.Beatmaps.ControlPoints
|
||||
|
||||
controlPoints.Add(point);
|
||||
ItemAdded?.Invoke(point);
|
||||
point.Changed += raiseItemChanged;
|
||||
}
|
||||
|
||||
public void Remove(ControlPoint point)
|
||||
{
|
||||
controlPoints.Remove(point);
|
||||
ItemRemoved?.Invoke(point);
|
||||
point.Changed -= raiseItemChanged;
|
||||
}
|
||||
|
||||
public sealed override bool Equals(object? obj)
|
||||
|
@ -20,6 +20,14 @@ namespace osu.Game.Beatmaps.ControlPoints
|
||||
[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
|
||||
public class ControlPointInfo : IDeepCloneable<ControlPointInfo>
|
||||
{
|
||||
/// <summary>
|
||||
/// Invoked on any change to the set of control points.
|
||||
/// </summary>
|
||||
[CanBeNull]
|
||||
public event Action ControlPointsChanged;
|
||||
|
||||
private void raiseControlPointsChanged([CanBeNull] ControlPoint _ = null) => ControlPointsChanged?.Invoke();
|
||||
|
||||
/// <summary>
|
||||
/// All control points grouped by time.
|
||||
/// </summary>
|
||||
@ -117,6 +125,7 @@ namespace osu.Game.Beatmaps.ControlPoints
|
||||
if (addIfNotExisting)
|
||||
{
|
||||
newGroup.ItemAdded += GroupItemAdded;
|
||||
newGroup.ItemChanged += raiseControlPointsChanged;
|
||||
newGroup.ItemRemoved += GroupItemRemoved;
|
||||
|
||||
groups.Insert(~i, newGroup);
|
||||
@ -132,6 +141,7 @@ namespace osu.Game.Beatmaps.ControlPoints
|
||||
group.Remove(item);
|
||||
|
||||
group.ItemAdded -= GroupItemAdded;
|
||||
group.ItemChanged -= raiseControlPointsChanged;
|
||||
group.ItemRemoved -= GroupItemRemoved;
|
||||
|
||||
groups.Remove(group);
|
||||
@ -288,6 +298,8 @@ namespace osu.Game.Beatmaps.ControlPoints
|
||||
default:
|
||||
throw new ArgumentException($"A control point of unexpected type {controlPoint.GetType()} was added to this {nameof(ControlPointInfo)}");
|
||||
}
|
||||
|
||||
raiseControlPointsChanged();
|
||||
}
|
||||
|
||||
protected virtual void GroupItemRemoved(ControlPoint controlPoint)
|
||||
@ -302,6 +314,8 @@ namespace osu.Game.Beatmaps.ControlPoints
|
||||
effectPoints.Remove(typed);
|
||||
break;
|
||||
}
|
||||
|
||||
raiseControlPointsChanged();
|
||||
}
|
||||
|
||||
public ControlPointInfo DeepClone()
|
||||
|
@ -44,6 +44,11 @@ namespace osu.Game.Beatmaps.ControlPoints
|
||||
set => SliderVelocityBindable.Value = value;
|
||||
}
|
||||
|
||||
public DifficultyControlPoint()
|
||||
{
|
||||
SliderVelocityBindable.BindValueChanged(_ => RaiseChanged());
|
||||
}
|
||||
|
||||
public override bool IsRedundant(ControlPoint? existing)
|
||||
=> existing is DifficultyControlPoint existingDifficulty
|
||||
&& GenerateTicks == existingDifficulty.GenerateTicks
|
||||
|
@ -50,6 +50,12 @@ namespace osu.Game.Beatmaps.ControlPoints
|
||||
set => KiaiModeBindable.Value = value;
|
||||
}
|
||||
|
||||
public EffectControlPoint()
|
||||
{
|
||||
KiaiModeBindable.BindValueChanged(_ => RaiseChanged());
|
||||
ScrollSpeedBindable.BindValueChanged(_ => RaiseChanged());
|
||||
}
|
||||
|
||||
public override bool IsRedundant(ControlPoint? existing)
|
||||
=> existing is EffectControlPoint existingEffect
|
||||
&& KiaiMode == existingEffect.KiaiMode
|
||||
|
@ -56,6 +56,12 @@ namespace osu.Game.Beatmaps.ControlPoints
|
||||
set => SampleVolumeBindable.Value = value;
|
||||
}
|
||||
|
||||
public SampleControlPoint()
|
||||
{
|
||||
SampleBankBindable.BindValueChanged(_ => RaiseChanged());
|
||||
SampleVolumeBindable.BindValueChanged(_ => RaiseChanged());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a SampleInfo based on the sample settings in this control point.
|
||||
/// </summary>
|
||||
|
@ -82,6 +82,13 @@ namespace osu.Game.Beatmaps.ControlPoints
|
||||
/// </summary>
|
||||
public double BPM => 60000 / BeatLength;
|
||||
|
||||
public TimingControlPoint()
|
||||
{
|
||||
TimeSignatureBindable.BindValueChanged(_ => RaiseChanged());
|
||||
OmitFirstBarLineBindable.BindValueChanged(_ => RaiseChanged());
|
||||
BeatLengthBindable.BindValueChanged(_ => RaiseChanged());
|
||||
}
|
||||
|
||||
// Timing points are never redundant as they can change the time signature.
|
||||
public override bool IsRedundant(ControlPoint? existing) => false;
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Beatmaps.Timing;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
@ -40,7 +41,7 @@ namespace osu.Game.Beatmaps
|
||||
/// <summary>
|
||||
/// The breaks in this beatmap.
|
||||
/// </summary>
|
||||
List<BreakPeriod> Breaks { get; }
|
||||
BindableList<BreakPeriod> Breaks { get; }
|
||||
|
||||
/// <summary>
|
||||
/// All lines from the [Events] section which aren't handled in the encoding process yet.
|
||||
|
@ -1,26 +1,44 @@
|
||||
// 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.Game.Screens.Play;
|
||||
|
||||
namespace osu.Game.Beatmaps.Timing
|
||||
{
|
||||
public class BreakPeriod
|
||||
public class BreakPeriod : IEquatable<BreakPeriod>
|
||||
{
|
||||
/// <summary>
|
||||
/// The minimum gap between the start of the break and the previous object.
|
||||
/// </summary>
|
||||
public const double GAP_BEFORE_BREAK = 200;
|
||||
|
||||
/// <summary>
|
||||
/// The minimum gap between the end of the break and the next object.
|
||||
/// Based on osu! preempt time at AR=10.
|
||||
/// See also: https://github.com/ppy/osu/issues/14330#issuecomment-1002158551
|
||||
/// </summary>
|
||||
public const double GAP_AFTER_BREAK = 450;
|
||||
|
||||
/// <summary>
|
||||
/// The minimum duration required for a break to have any effect.
|
||||
/// </summary>
|
||||
public const double MIN_BREAK_DURATION = 650;
|
||||
|
||||
/// <summary>
|
||||
/// The minimum required duration of a gap between two objects such that a break can be placed between them.
|
||||
/// </summary>
|
||||
public const double MIN_GAP_DURATION = GAP_BEFORE_BREAK + MIN_BREAK_DURATION + GAP_AFTER_BREAK;
|
||||
|
||||
/// <summary>
|
||||
/// The break start time.
|
||||
/// </summary>
|
||||
public double StartTime;
|
||||
public double StartTime { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The break end time.
|
||||
/// </summary>
|
||||
public double EndTime;
|
||||
public double EndTime { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The break duration.
|
||||
@ -49,5 +67,14 @@ namespace osu.Game.Beatmaps.Timing
|
||||
/// <param name="time">The time to check in milliseconds.</param>
|
||||
/// <returns>Whether the time falls within this <see cref="BreakPeriod"/>.</returns>
|
||||
public bool Contains(double time) => time >= StartTime && time <= EndTime - BreakOverlay.BREAK_FADE_DURATION;
|
||||
|
||||
public bool Intersects(BreakPeriod other) => StartTime <= other.EndTime && EndTime >= other.StartTime;
|
||||
|
||||
public virtual bool Equals(BreakPeriod? other) =>
|
||||
other != null
|
||||
&& StartTime == other.StartTime
|
||||
&& EndTime == other.EndTime;
|
||||
|
||||
public override int GetHashCode() => HashCode.Combine(StartTime, EndTime);
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ namespace osu.Game.Graphics.Cursor
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
inputManager = GetContainingInputManager();
|
||||
inputManager = GetContainingInputManager()!;
|
||||
showDuringTouch = config.GetBindable<bool>(OsuSetting.GameplayCursorDuringTouch);
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
if (!allowImmediateFocus)
|
||||
return;
|
||||
|
||||
Scheduler.Add(() => GetContainingFocusManager().ChangeFocus(this));
|
||||
Scheduler.Add(() => GetContainingFocusManager()!.ChangeFocus(this));
|
||||
}
|
||||
|
||||
public new void KillFocus() => base.KillFocus();
|
||||
|
@ -59,7 +59,7 @@ namespace osu.Game.Graphics.UserInterfaceV2
|
||||
protected override void OnFocus(FocusEvent e)
|
||||
{
|
||||
base.OnFocus(e);
|
||||
GetContainingFocusManager().ChangeFocus(Component);
|
||||
GetContainingFocusManager()!.ChangeFocus(Component);
|
||||
}
|
||||
|
||||
protected override OsuTextBox CreateComponent() => CreateTextBox().With(t =>
|
||||
|
@ -85,7 +85,7 @@ namespace osu.Game.Graphics.UserInterfaceV2
|
||||
Current.BindValueChanged(updateTextBoxFromSlider, true);
|
||||
}
|
||||
|
||||
public bool TakeFocus() => GetContainingFocusManager().ChangeFocus(textBox);
|
||||
public bool TakeFocus() => GetContainingFocusManager()?.ChangeFocus(textBox) == true;
|
||||
|
||||
public bool SelectAll() => textBox.SelectAll();
|
||||
|
||||
|
@ -243,7 +243,7 @@ namespace osu.Game.Overlays.AccountCreation
|
||||
|
||||
if (nextTextBox != null)
|
||||
{
|
||||
Schedule(() => GetContainingFocusManager().ChangeFocus(nextTextBox));
|
||||
Schedule(() => GetContainingFocusManager()!.ChangeFocus(nextTextBox));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ namespace osu.Game.Overlays.Comments
|
||||
base.LoadComplete();
|
||||
|
||||
if (!TextBox.ReadOnly)
|
||||
GetContainingFocusManager().ChangeFocus(TextBox);
|
||||
GetContainingFocusManager()!.ChangeFocus(TextBox);
|
||||
}
|
||||
|
||||
protected override void OnCommit(string text)
|
||||
|
@ -150,7 +150,7 @@ namespace osu.Game.Overlays.Login
|
||||
|
||||
protected override void OnFocus(FocusEvent e)
|
||||
{
|
||||
Schedule(() => { GetContainingFocusManager().ChangeFocus(string.IsNullOrEmpty(username.Text) ? username : password); });
|
||||
Schedule(() => { GetContainingFocusManager()!.ChangeFocus(string.IsNullOrEmpty(username.Text) ? username : password); });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -216,7 +216,7 @@ namespace osu.Game.Overlays.Login
|
||||
|
||||
protected override void OnFocus(FocusEvent e)
|
||||
{
|
||||
if (form != null) GetContainingFocusManager().ChangeFocus(form);
|
||||
if (form != null) GetContainingFocusManager()!.ChangeFocus(form);
|
||||
base.OnFocus(e);
|
||||
}
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ namespace osu.Game.Overlays.Login
|
||||
|
||||
protected override void OnFocus(FocusEvent e)
|
||||
{
|
||||
Schedule(() => { GetContainingFocusManager().ChangeFocus(codeTextBox); });
|
||||
Schedule(() => { GetContainingFocusManager()!.ChangeFocus(codeTextBox); });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ namespace osu.Game.Overlays
|
||||
this.FadeIn(transition_time, Easing.OutQuint);
|
||||
FadeEdgeEffectTo(WaveContainer.SHADOW_OPACITY, WaveContainer.APPEAR_DURATION, Easing.Out);
|
||||
|
||||
ScheduleAfterChildren(() => GetContainingFocusManager().ChangeFocus(panel));
|
||||
ScheduleAfterChildren(() => GetContainingFocusManager()!.ChangeFocus(panel));
|
||||
}
|
||||
|
||||
protected override void PopOut()
|
||||
|
@ -89,7 +89,7 @@ namespace osu.Game.Overlays.Mods
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
ScheduleAfterChildren(() => GetContainingFocusManager().ChangeFocus(nameTextBox));
|
||||
ScheduleAfterChildren(() => GetContainingFocusManager()!.ChangeFocus(nameTextBox));
|
||||
|
||||
nameTextBox.Current.BindValueChanged(s =>
|
||||
{
|
||||
|
@ -136,7 +136,7 @@ namespace osu.Game.Overlays.Mods
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
ScheduleAfterChildren(() => GetContainingFocusManager().ChangeFocus(nameTextBox));
|
||||
ScheduleAfterChildren(() => GetContainingFocusManager()!.ChangeFocus(nameTextBox));
|
||||
}
|
||||
|
||||
public override bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
|
||||
|
@ -949,7 +949,7 @@ namespace osu.Game.Overlays.Mods
|
||||
RequestScroll?.Invoke(this);
|
||||
|
||||
// Killing focus is done here because it's the only feasible place on ModSelectOverlay you can click on without triggering any action.
|
||||
Scheduler.Add(() => GetContainingFocusManager().ChangeFocus(null));
|
||||
Scheduler.Add(() => GetContainingFocusManager()!.ChangeFocus(null));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -465,7 +465,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
}
|
||||
|
||||
if (HasFocus)
|
||||
GetContainingFocusManager().ChangeFocus(null);
|
||||
GetContainingFocusManager()!.ChangeFocus(null);
|
||||
|
||||
cancelAndClearButtons.FadeOut(300, Easing.OutQuint);
|
||||
cancelAndClearButtons.BypassAutoSizeAxes |= Axes.Y;
|
||||
|
@ -106,7 +106,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
{
|
||||
var next = Children.SkipWhile(c => c != sender).Skip(1).FirstOrDefault();
|
||||
if (next != null)
|
||||
GetContainingFocusManager().ChangeFocus(next);
|
||||
GetContainingFocusManager()?.ChangeFocus(next);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -201,7 +201,7 @@ namespace osu.Game.Overlays
|
||||
|
||||
searchTextBox.HoldFocus = false;
|
||||
if (searchTextBox.HasFocus)
|
||||
GetContainingFocusManager().ChangeFocus(null);
|
||||
GetContainingFocusManager()!.ChangeFocus(null);
|
||||
}
|
||||
|
||||
public override bool AcceptsFocus => true;
|
||||
|
@ -669,7 +669,7 @@ namespace osu.Game.Overlays.SkinEditor
|
||||
{
|
||||
SpriteName = { Value = file.Name },
|
||||
Origin = Anchor.Centre,
|
||||
Position = skinnableTarget.ToLocalSpace(GetContainingInputManager().CurrentState.Mouse.Position),
|
||||
Position = skinnableTarget.ToLocalSpace(GetContainingInputManager()!.CurrentState.Mouse.Position),
|
||||
};
|
||||
|
||||
SelectedComponents.Clear();
|
||||
|
@ -9,6 +9,7 @@ using System.Linq;
|
||||
using System.Threading;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
@ -329,7 +330,7 @@ namespace osu.Game.Rulesets.Difficulty
|
||||
set => baseBeatmap.Difficulty = value;
|
||||
}
|
||||
|
||||
public List<BreakPeriod> Breaks => baseBeatmap.Breaks;
|
||||
public BindableList<BreakPeriod> Breaks => baseBeatmap.Breaks;
|
||||
public List<string> UnhandledEventLines => baseBeatmap.UnhandledEventLines;
|
||||
|
||||
public double TotalBreakTime => baseBeatmap.TotalBreakTime;
|
||||
|
@ -13,13 +13,7 @@ namespace osu.Game.Rulesets.Edit.Checks
|
||||
{
|
||||
// Breaks may be off by 1 ms.
|
||||
private const int leniency_threshold = 1;
|
||||
private const double minimum_gap_before_break = 200;
|
||||
|
||||
// Break end time depends on the upcoming object's pre-empt time.
|
||||
// As things stand, "pre-empt time" is only defined for osu! standard
|
||||
// This is a generic value representing AR=10
|
||||
// Relevant: https://github.com/ppy/osu/issues/14330#issuecomment-1002158551
|
||||
private const double min_end_threshold = 450;
|
||||
public CheckMetadata Metadata => new CheckMetadata(CheckCategory.Events, "Breaks not achievable using the editor");
|
||||
|
||||
public IEnumerable<IssueTemplate> PossibleTemplates => new IssueTemplate[]
|
||||
@ -45,8 +39,8 @@ namespace osu.Game.Rulesets.Edit.Checks
|
||||
if (previousObjectEndTimeIndex >= 0)
|
||||
{
|
||||
double gapBeforeBreak = breakPeriod.StartTime - endTimes[previousObjectEndTimeIndex];
|
||||
if (gapBeforeBreak < minimum_gap_before_break - leniency_threshold)
|
||||
yield return new IssueTemplateEarlyStart(this).Create(breakPeriod.StartTime, minimum_gap_before_break - gapBeforeBreak);
|
||||
if (gapBeforeBreak < BreakPeriod.GAP_BEFORE_BREAK - leniency_threshold)
|
||||
yield return new IssueTemplateEarlyStart(this).Create(breakPeriod.StartTime, BreakPeriod.GAP_BEFORE_BREAK - gapBeforeBreak);
|
||||
}
|
||||
|
||||
int nextObjectStartTimeIndex = startTimes.BinarySearch(breakPeriod.EndTime);
|
||||
@ -55,8 +49,8 @@ namespace osu.Game.Rulesets.Edit.Checks
|
||||
if (nextObjectStartTimeIndex < startTimes.Count)
|
||||
{
|
||||
double gapAfterBreak = startTimes[nextObjectStartTimeIndex] - breakPeriod.EndTime;
|
||||
if (gapAfterBreak < min_end_threshold - leniency_threshold)
|
||||
yield return new IssueTemplateLateEnd(this).Create(breakPeriod.StartTime, min_end_threshold - gapAfterBreak);
|
||||
if (gapAfterBreak < BreakPeriod.GAP_AFTER_BREAK - leniency_threshold)
|
||||
yield return new IssueTemplateLateEnd(this).Create(breakPeriod.StartTime, BreakPeriod.GAP_AFTER_BREAK - gapAfterBreak);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -67,7 +67,8 @@ namespace osu.Game.Rulesets.Edit
|
||||
[Resolved]
|
||||
private OverlayColourProvider colourProvider { get; set; }
|
||||
|
||||
protected ComposeBlueprintContainer BlueprintContainer { get; private set; }
|
||||
public override ComposeBlueprintContainer BlueprintContainer => blueprintContainer;
|
||||
private ComposeBlueprintContainer blueprintContainer;
|
||||
|
||||
protected ExpandingToolboxContainer LeftToolbox { get; private set; }
|
||||
|
||||
@ -143,7 +144,7 @@ namespace osu.Game.Rulesets.Edit
|
||||
drawableRulesetWrapper,
|
||||
// layers above playfield
|
||||
drawableRulesetWrapper.CreatePlayfieldAdjustmentContainer()
|
||||
.WithChild(BlueprintContainer = CreateBlueprintContainer())
|
||||
.WithChild(blueprintContainer = CreateBlueprintContainer())
|
||||
}
|
||||
},
|
||||
new Container
|
||||
@ -570,6 +571,8 @@ namespace osu.Game.Rulesets.Edit
|
||||
/// </summary>
|
||||
public abstract Playfield Playfield { get; }
|
||||
|
||||
public abstract ComposeBlueprintContainer BlueprintContainer { get; }
|
||||
|
||||
/// <summary>
|
||||
/// All <see cref="DrawableHitObject"/>s in currently loaded beatmap.
|
||||
/// </summary>
|
||||
|
@ -4,6 +4,7 @@
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.ObjectExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
@ -12,6 +13,7 @@ using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Rulesets.Edit.Tools;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.UI.Scrolling;
|
||||
using osu.Game.Screens.Edit;
|
||||
using osu.Game.Screens.Edit.Components.TernaryButtons;
|
||||
using osu.Game.Screens.Edit.Compose.Components;
|
||||
using osuTK;
|
||||
@ -21,6 +23,9 @@ namespace osu.Game.Rulesets.Edit
|
||||
public abstract partial class ScrollingHitObjectComposer<TObject> : HitObjectComposer<TObject>
|
||||
where TObject : HitObject
|
||||
{
|
||||
[Resolved]
|
||||
private Editor? editor { get; set; }
|
||||
|
||||
private readonly Bindable<TernaryState> showSpeedChanges = new Bindable<TernaryState>();
|
||||
private Bindable<bool> configShowSpeedChanges = null!;
|
||||
|
||||
@ -72,6 +77,8 @@ namespace osu.Game.Rulesets.Edit
|
||||
|
||||
if (beatSnapGrid != null)
|
||||
AddInternal(beatSnapGrid);
|
||||
|
||||
EditorBeatmap.ControlPointInfo.ControlPointsChanged += expireComposeScreenOnControlPointChange;
|
||||
}
|
||||
|
||||
protected override void UpdateAfterChildren()
|
||||
@ -104,5 +111,15 @@ namespace osu.Game.Rulesets.Edit
|
||||
beatSnapGrid.SelectionTimeRange = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
|
||||
if (EditorBeatmap.IsNotNull())
|
||||
EditorBeatmap.ControlPointInfo.ControlPointsChanged -= expireComposeScreenOnControlPointChange;
|
||||
}
|
||||
|
||||
private void expireComposeScreenOnControlPointChange() => editor?.ReloadComposeScreen();
|
||||
}
|
||||
}
|
||||
|
@ -224,8 +224,16 @@ namespace osu.Game.Rulesets.Objects
|
||||
/// <returns>A populated <see cref="HitSampleInfo"/>.</returns>
|
||||
public HitSampleInfo CreateHitSampleInfo(string sampleName = HitSampleInfo.HIT_NORMAL)
|
||||
{
|
||||
if (Samples.FirstOrDefault(s => s.Name == HitSampleInfo.HIT_NORMAL) is HitSampleInfo existingSample)
|
||||
return existingSample.With(newName: sampleName);
|
||||
// As per stable, all non-normal "addition" samples should use the same bank.
|
||||
if (sampleName != HitSampleInfo.HIT_NORMAL)
|
||||
{
|
||||
if (Samples.FirstOrDefault(s => s.Name != HitSampleInfo.HIT_NORMAL) is HitSampleInfo existingAddition)
|
||||
return existingAddition.With(newName: sampleName);
|
||||
}
|
||||
|
||||
// Fall back to using the normal sample bank otherwise.
|
||||
if (Samples.FirstOrDefault(s => s.Name == HitSampleInfo.HIT_NORMAL) is HitSampleInfo existingNormal)
|
||||
return existingNormal.With(newName: sampleName);
|
||||
|
||||
return new HitSampleInfo(sampleName);
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
using osu.Game.Audio;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace osu.Game.Rulesets.Objects.Types
|
||||
{
|
||||
@ -45,5 +46,19 @@ namespace osu.Game.Rulesets.Objects.Types
|
||||
public static IList<HitSampleInfo> GetNodeSamples<T>(this T obj, int nodeIndex)
|
||||
where T : HitObject, IHasRepeats
|
||||
=> nodeIndex < obj.NodeSamples.Count ? obj.NodeSamples[nodeIndex] : obj.Samples;
|
||||
|
||||
/// <summary>
|
||||
/// Ensures that the list of node samples is at least as long as the number of nodes.
|
||||
/// </summary>
|
||||
/// <param name="obj">The <see cref="HitObject"/>.</param>
|
||||
public static void PopulateNodeSamples<T>(this T obj)
|
||||
where T : HitObject, IHasRepeats
|
||||
{
|
||||
if (obj.NodeSamples.Count >= obj.RepeatCount + 2)
|
||||
return;
|
||||
|
||||
while (obj.NodeSamples.Count < obj.RepeatCount + 2)
|
||||
obj.NodeSamples.Add(obj.Samples.Select(o => o.With()).ToList());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,9 +2,11 @@
|
||||
// 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.Framework.Graphics.Shapes;
|
||||
using osu.Game.Beatmaps.Timing;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Screens.Edit.Components.Timelines.Summary.Visualisations;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
|
||||
{
|
||||
@ -13,22 +15,33 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
|
||||
/// </summary>
|
||||
public partial class BreakPart : TimelinePart
|
||||
{
|
||||
private readonly BindableList<BreakPeriod> breaks = new BindableList<BreakPeriod>();
|
||||
|
||||
protected override void LoadBeatmap(EditorBeatmap beatmap)
|
||||
{
|
||||
base.LoadBeatmap(beatmap);
|
||||
foreach (var breakPeriod in beatmap.Breaks)
|
||||
Add(new BreakVisualisation(breakPeriod));
|
||||
|
||||
breaks.UnbindAll();
|
||||
breaks.BindTo(beatmap.Breaks);
|
||||
breaks.BindCollectionChanged((_, _) =>
|
||||
{
|
||||
foreach (var breakPeriod in beatmap.Breaks)
|
||||
Add(new BreakVisualisation(breakPeriod));
|
||||
}, true);
|
||||
}
|
||||
|
||||
private partial class BreakVisualisation : DurationVisualisation
|
||||
private partial class BreakVisualisation : Circle
|
||||
{
|
||||
public BreakVisualisation(BreakPeriod breakPeriod)
|
||||
: base(breakPeriod.StartTime, breakPeriod.EndTime)
|
||||
{
|
||||
RelativePositionAxes = Axes.X;
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
X = (float)breakPeriod.StartTime;
|
||||
Width = (float)breakPeriod.Duration;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours) => Colour = colours.GreyCarmineLight;
|
||||
private void load(OsuColour colours) => Colour = colours.Gray7;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,23 +0,0 @@
|
||||
// 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.Graphics;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Visualisations
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a spanning point on a timeline part.
|
||||
/// </summary>
|
||||
public partial class DurationVisualisation : Circle
|
||||
{
|
||||
protected DurationVisualisation(double startTime, double endTime)
|
||||
{
|
||||
RelativePositionAxes = Axes.X;
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
X = (float)startTime;
|
||||
Width = (float)(endTime - startTime);
|
||||
}
|
||||
}
|
||||
}
|
@ -580,7 +580,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
GetContainingFocusManager().ChangeFocus(this);
|
||||
GetContainingFocusManager()!.ChangeFocus(this);
|
||||
SelectAll();
|
||||
}
|
||||
}
|
||||
|
@ -228,7 +228,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
yield return new TernaryButton(NewCombo, "New combo", () => new SpriteIcon { Icon = OsuIcon.EditorNewComboA });
|
||||
|
||||
foreach (var kvp in SelectionHandler.SelectionSampleStates)
|
||||
yield return new TernaryButton(kvp.Value, kvp.Key.Replace("hit", string.Empty).Titleize(), () => getIconForSample(kvp.Key));
|
||||
yield return new TernaryButton(kvp.Value, kvp.Key.Replace("hit", string.Empty).Titleize(), () => GetIconForSample(kvp.Key));
|
||||
}
|
||||
|
||||
private IEnumerable<TernaryButton> createSampleBankTernaryButtons()
|
||||
@ -264,7 +264,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
};
|
||||
}
|
||||
|
||||
private Drawable getIconForSample(string sampleName)
|
||||
public static Drawable GetIconForSample(string sampleName)
|
||||
{
|
||||
switch (sampleName)
|
||||
{
|
||||
@ -372,7 +372,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
}
|
||||
}
|
||||
|
||||
private void commitIfPlacementActive()
|
||||
public void CommitIfPlacementActive()
|
||||
{
|
||||
CurrentPlacement?.EndPlacement(CurrentPlacement.PlacementActive == PlacementBlueprint.PlacementState.Active);
|
||||
removePlacement();
|
||||
@ -402,7 +402,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
currentTool = value;
|
||||
|
||||
// As per stable editor, when changing tools, we should forcefully commit any pending placement.
|
||||
commitIfPlacementActive();
|
||||
CommitIfPlacementActive();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -227,6 +227,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
return;
|
||||
|
||||
h.Samples.Add(h.CreateHitSampleInfo(sampleName));
|
||||
|
||||
EditorBeatmap.Update(h);
|
||||
});
|
||||
}
|
||||
|
@ -313,7 +313,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
/// <summary>
|
||||
/// Given a selection target and a function of truth, retrieve the correct ternary state for display.
|
||||
/// </summary>
|
||||
protected static TernaryState GetStateFromSelection<TObject>(IEnumerable<TObject> selection, Func<TObject, bool> func)
|
||||
public static TernaryState GetStateFromSelection<TObject>(IEnumerable<TObject> selection, Func<TObject, bool> func)
|
||||
{
|
||||
if (selection.Any(func))
|
||||
return selection.All(func) ? TernaryState.True : TernaryState.Indeterminate;
|
||||
|
@ -138,7 +138,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
ScheduleAfterChildren(() => GetContainingFocusManager().ChangeFocus(sliderVelocitySlider));
|
||||
ScheduleAfterChildren(() => GetContainingFocusManager()!.ChangeFocus(sliderVelocitySlider));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,52 @@
|
||||
// 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.Graphics.UserInterface;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
{
|
||||
public partial class NodeSamplePointPiece : SamplePointPiece
|
||||
{
|
||||
public readonly int NodeIndex;
|
||||
|
||||
public NodeSamplePointPiece(HitObject hitObject, int nodeIndex)
|
||||
: base(hitObject)
|
||||
{
|
||||
if (hitObject is not IHasRepeats)
|
||||
throw new System.ArgumentException($"HitObject must implement {nameof(IHasRepeats)}", nameof(hitObject));
|
||||
|
||||
NodeIndex = nodeIndex;
|
||||
}
|
||||
|
||||
protected override IList<HitSampleInfo> GetSamples()
|
||||
{
|
||||
var hasRepeats = (IHasRepeats)HitObject;
|
||||
return NodeIndex < hasRepeats.NodeSamples.Count ? hasRepeats.NodeSamples[NodeIndex] : HitObject.Samples;
|
||||
}
|
||||
|
||||
public override Popover GetPopover() => new NodeSampleEditPopover(HitObject, NodeIndex);
|
||||
|
||||
public partial class NodeSampleEditPopover : SampleEditPopover
|
||||
{
|
||||
private readonly int nodeIndex;
|
||||
|
||||
protected override IList<HitSampleInfo> GetRelevantSamples(HitObject ho)
|
||||
{
|
||||
if (ho is not IHasRepeats hasRepeats)
|
||||
return ho.Samples;
|
||||
|
||||
return nodeIndex < hasRepeats.NodeSamples.Count ? hasRepeats.NodeSamples[nodeIndex] : ho.Samples;
|
||||
}
|
||||
|
||||
public NodeSampleEditPopover(HitObject hitObject, int nodeIndex)
|
||||
: base(hitObject)
|
||||
{
|
||||
this.nodeIndex = nodeIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,8 +1,10 @@
|
||||
// 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 System.Linq;
|
||||
using Humanizer;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions;
|
||||
@ -14,12 +16,15 @@ using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Graphics.UserInterfaceV2;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Screens.Edit.Components.TernaryButtons;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Screens.Edit.Timing;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
{
|
||||
@ -27,20 +32,20 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
{
|
||||
public readonly HitObject HitObject;
|
||||
|
||||
private readonly BindableList<HitSampleInfo> samplesBindable;
|
||||
|
||||
public SamplePointPiece(HitObject hitObject)
|
||||
{
|
||||
HitObject = hitObject;
|
||||
samplesBindable = hitObject.SamplesBindable.GetBoundCopy();
|
||||
}
|
||||
|
||||
protected override Color4 GetRepresentingColour(OsuColour colours) => colours.Pink;
|
||||
public bool AlternativeColor { get; init; }
|
||||
|
||||
protected override Color4 GetRepresentingColour(OsuColour colours) => AlternativeColor ? colours.Pink2 : colours.Pink1;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
samplesBindable.BindCollectionChanged((_, _) => updateText(), true);
|
||||
HitObject.DefaultsApplied += _ => updateText();
|
||||
updateText();
|
||||
}
|
||||
|
||||
protected override bool OnClick(ClickEvent e)
|
||||
@ -51,12 +56,28 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
|
||||
private void updateText()
|
||||
{
|
||||
Label.Text = $"{GetBankValue(samplesBindable)} {GetVolumeValue(samplesBindable)}";
|
||||
Label.Text = $"{abbreviateBank(GetBankValue(GetSamples()))} {GetVolumeValue(GetSamples())}";
|
||||
}
|
||||
|
||||
private static string? abbreviateBank(string? bank)
|
||||
{
|
||||
return bank switch
|
||||
{
|
||||
HitSampleInfo.BANK_NORMAL => @"N",
|
||||
HitSampleInfo.BANK_SOFT => @"S",
|
||||
HitSampleInfo.BANK_DRUM => @"D",
|
||||
_ => bank
|
||||
};
|
||||
}
|
||||
|
||||
public static string? GetBankValue(IEnumerable<HitSampleInfo> samples)
|
||||
{
|
||||
return samples.FirstOrDefault()?.Bank;
|
||||
return samples.FirstOrDefault(o => o.Name == HitSampleInfo.HIT_NORMAL)?.Bank;
|
||||
}
|
||||
|
||||
public static string? GetAdditionBankValue(IEnumerable<HitSampleInfo> samples)
|
||||
{
|
||||
return samples.FirstOrDefault(o => o.Name != HitSampleInfo.HIT_NORMAL)?.Bank;
|
||||
}
|
||||
|
||||
public static int GetVolumeValue(ICollection<HitSampleInfo> samples)
|
||||
@ -64,15 +85,36 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
return samples.Count == 0 ? 0 : samples.Max(o => o.Volume);
|
||||
}
|
||||
|
||||
public Popover GetPopover() => new SampleEditPopover(HitObject);
|
||||
/// <summary>
|
||||
/// Gets the samples to be edited by this sample point piece.
|
||||
/// This could be the samples of the hit object itself, or of one of the nested hit objects. For example a slider repeat.
|
||||
/// </summary>
|
||||
/// <returns>The samples to be edited.</returns>
|
||||
protected virtual IList<HitSampleInfo> GetSamples() => HitObject.Samples;
|
||||
|
||||
public virtual Popover GetPopover() => new SampleEditPopover(HitObject);
|
||||
|
||||
public partial class SampleEditPopover : OsuPopover
|
||||
{
|
||||
private readonly HitObject hitObject;
|
||||
|
||||
private LabelledTextBox bank = null!;
|
||||
private LabelledTextBox additionBank = null!;
|
||||
private IndeterminateSliderWithTextBoxInput<int> volume = null!;
|
||||
|
||||
private FillFlowContainer togglesCollection = null!;
|
||||
|
||||
private HitObject[] relevantObjects = null!;
|
||||
private IList<HitSampleInfo>[] allRelevantSamples = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the sub-set of samples relevant to this sample point piece.
|
||||
/// For example, to edit node samples this should return the samples at the index of the node.
|
||||
/// </summary>
|
||||
/// <param name="ho">The hit object to get the relevant samples from.</param>
|
||||
/// <returns>The relevant list of samples.</returns>
|
||||
protected virtual IList<HitSampleInfo> GetRelevantSamples(HitObject ho) => ho.Samples;
|
||||
|
||||
[Resolved(canBeNull: true)]
|
||||
private EditorBeatmap beatmap { get; set; } = null!;
|
||||
|
||||
@ -96,10 +138,21 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
Spacing = new Vector2(0, 10),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
togglesCollection = new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Spacing = new Vector2(5, 5),
|
||||
},
|
||||
bank = new LabelledTextBox
|
||||
{
|
||||
Label = "Bank Name",
|
||||
},
|
||||
additionBank = new LabelledTextBox
|
||||
{
|
||||
Label = "Addition Bank",
|
||||
},
|
||||
volume = new IndeterminateSliderWithTextBoxInput<int>("Volume", new BindableInt(100)
|
||||
{
|
||||
MinValue = DrawableHitObject.MINIMUM_SAMPLE_VOLUME,
|
||||
@ -110,89 +163,273 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
};
|
||||
|
||||
bank.TabbableContentContainer = flow;
|
||||
additionBank.TabbableContentContainer = flow;
|
||||
volume.TabbableContentContainer = flow;
|
||||
|
||||
// if the piece belongs to a currently selected object, assume that the user wants to change all selected objects.
|
||||
// if the piece belongs to an unselected object, operate on that object alone, independently of the selection.
|
||||
var relevantObjects = (beatmap.SelectedHitObjects.Contains(hitObject) ? beatmap.SelectedHitObjects : hitObject.Yield()).ToArray();
|
||||
var relevantSamples = relevantObjects.Select(h => h.Samples).ToArray();
|
||||
relevantObjects = (beatmap.SelectedHitObjects.Contains(hitObject) ? beatmap.SelectedHitObjects : hitObject.Yield()).ToArray();
|
||||
allRelevantSamples = relevantObjects.Select(GetRelevantSamples).ToArray();
|
||||
|
||||
// even if there are multiple objects selected, we can still display sample volume or bank if they all have the same value.
|
||||
string? commonBank = getCommonBank(relevantSamples);
|
||||
if (!string.IsNullOrEmpty(commonBank))
|
||||
bank.Current.Value = commonBank;
|
||||
|
||||
int? commonVolume = getCommonVolume(relevantSamples);
|
||||
int? commonVolume = getCommonVolume();
|
||||
if (commonVolume != null)
|
||||
volume.Current.Value = commonVolume.Value;
|
||||
|
||||
updateBankPlaceholderText(relevantObjects);
|
||||
updatePrimaryBankState();
|
||||
bank.Current.BindValueChanged(val =>
|
||||
{
|
||||
updateBankFor(relevantObjects, val.NewValue);
|
||||
updateBankPlaceholderText(relevantObjects);
|
||||
if (string.IsNullOrEmpty(val.NewValue))
|
||||
return;
|
||||
|
||||
setBank(val.NewValue);
|
||||
updatePrimaryBankState();
|
||||
});
|
||||
// on commit, ensure that the value is correct by sourcing it from the objects' samples again.
|
||||
// this ensures that committing empty text causes a revert to the previous value.
|
||||
bank.OnCommit += (_, _) => bank.Current.Value = getCommonBank(relevantSamples);
|
||||
bank.OnCommit += (_, _) => updatePrimaryBankState();
|
||||
|
||||
volume.Current.BindValueChanged(val => updateVolumeFor(relevantObjects, val.NewValue));
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
ScheduleAfterChildren(() => GetContainingFocusManager().ChangeFocus(volume));
|
||||
}
|
||||
|
||||
private static string? getCommonBank(IList<HitSampleInfo>[] relevantSamples) => relevantSamples.Select(GetBankValue).Distinct().Count() == 1 ? GetBankValue(relevantSamples.First()) : null;
|
||||
private static int? getCommonVolume(IList<HitSampleInfo>[] relevantSamples) => relevantSamples.Select(GetVolumeValue).Distinct().Count() == 1 ? GetVolumeValue(relevantSamples.First()) : null;
|
||||
|
||||
private void updateBankFor(IEnumerable<HitObject> objects, string? newBank)
|
||||
{
|
||||
if (string.IsNullOrEmpty(newBank))
|
||||
return;
|
||||
|
||||
beatmap.BeginChange();
|
||||
|
||||
foreach (var h in objects)
|
||||
updateAdditionBankState();
|
||||
additionBank.Current.BindValueChanged(val =>
|
||||
{
|
||||
for (int i = 0; i < h.Samples.Count; i++)
|
||||
{
|
||||
h.Samples[i] = h.Samples[i].With(newBank: newBank);
|
||||
}
|
||||
if (string.IsNullOrEmpty(val.NewValue))
|
||||
return;
|
||||
|
||||
beatmap.Update(h);
|
||||
}
|
||||
setAdditionBank(val.NewValue);
|
||||
updateAdditionBankState();
|
||||
});
|
||||
additionBank.OnCommit += (_, _) => updateAdditionBankState();
|
||||
|
||||
beatmap.EndChange();
|
||||
volume.Current.BindValueChanged(val =>
|
||||
{
|
||||
if (val.NewValue != null)
|
||||
setVolume(val.NewValue.Value);
|
||||
});
|
||||
|
||||
createStateBindables();
|
||||
updateTernaryStates();
|
||||
togglesCollection.AddRange(createTernaryButtons().Select(b => new DrawableTernaryButton(b) { RelativeSizeAxes = Axes.None, Size = new Vector2(40, 40) }));
|
||||
}
|
||||
|
||||
private void updateBankPlaceholderText(IEnumerable<HitObject> objects)
|
||||
private string? getCommonBank() => allRelevantSamples.Select(GetBankValue).Distinct().Count() == 1 ? GetBankValue(allRelevantSamples.First()) : null;
|
||||
private string? getCommonAdditionBank() => allRelevantSamples.Select(GetAdditionBankValue).Where(o => o is not null).Distinct().Count() == 1 ? GetAdditionBankValue(allRelevantSamples.First()) : null;
|
||||
private int? getCommonVolume() => allRelevantSamples.Select(GetVolumeValue).Distinct().Count() == 1 ? GetVolumeValue(allRelevantSamples.First()) : null;
|
||||
|
||||
private void updatePrimaryBankState()
|
||||
{
|
||||
string? commonBank = getCommonBank(objects.Select(h => h.Samples).ToArray());
|
||||
string? commonBank = getCommonBank();
|
||||
bank.Current.Value = commonBank;
|
||||
bank.PlaceholderText = string.IsNullOrEmpty(commonBank) ? "(multiple)" : string.Empty;
|
||||
}
|
||||
|
||||
private void updateVolumeFor(IEnumerable<HitObject> objects, int? newVolume)
|
||||
private void updateAdditionBankState()
|
||||
{
|
||||
if (newVolume == null)
|
||||
return;
|
||||
string? commonAdditionBank = getCommonAdditionBank();
|
||||
additionBank.PlaceholderText = string.IsNullOrEmpty(commonAdditionBank) ? "(multiple)" : string.Empty;
|
||||
additionBank.Current.Value = commonAdditionBank;
|
||||
|
||||
bool anyAdditions = allRelevantSamples.Any(o => o.Any(s => s.Name != HitSampleInfo.HIT_NORMAL));
|
||||
if (anyAdditions)
|
||||
additionBank.Show();
|
||||
else
|
||||
additionBank.Hide();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Applies the given update action on all samples of <see cref="allRelevantSamples"/>
|
||||
/// and invokes the necessary update notifiers for the beatmap and hit objects.
|
||||
/// </summary>
|
||||
/// <param name="updateAction">The action to perform on each element of <see cref="allRelevantSamples"/>.</param>
|
||||
private void updateAllRelevantSamples(Action<HitObject, IList<HitSampleInfo>> updateAction)
|
||||
{
|
||||
beatmap.BeginChange();
|
||||
|
||||
foreach (var h in objects)
|
||||
foreach (var relevantHitObject in relevantObjects)
|
||||
{
|
||||
for (int i = 0; i < h.Samples.Count; i++)
|
||||
{
|
||||
h.Samples[i] = h.Samples[i].With(newVolume: newVolume.Value);
|
||||
}
|
||||
|
||||
beatmap.Update(h);
|
||||
var relevantSamples = GetRelevantSamples(relevantHitObject);
|
||||
updateAction(relevantHitObject, relevantSamples);
|
||||
beatmap.Update(relevantHitObject);
|
||||
}
|
||||
|
||||
beatmap.EndChange();
|
||||
}
|
||||
|
||||
private void setBank(string newBank)
|
||||
{
|
||||
updateAllRelevantSamples((_, relevantSamples) =>
|
||||
{
|
||||
for (int i = 0; i < relevantSamples.Count; i++)
|
||||
{
|
||||
if (relevantSamples[i].Name != HitSampleInfo.HIT_NORMAL) continue;
|
||||
|
||||
relevantSamples[i] = relevantSamples[i].With(newBank: newBank);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setAdditionBank(string newBank)
|
||||
{
|
||||
updateAllRelevantSamples((_, relevantSamples) =>
|
||||
{
|
||||
for (int i = 0; i < relevantSamples.Count; i++)
|
||||
{
|
||||
if (relevantSamples[i].Name == HitSampleInfo.HIT_NORMAL) continue;
|
||||
|
||||
relevantSamples[i] = relevantSamples[i].With(newBank: newBank);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setVolume(int newVolume)
|
||||
{
|
||||
updateAllRelevantSamples((_, relevantSamples) =>
|
||||
{
|
||||
for (int i = 0; i < relevantSamples.Count; i++)
|
||||
{
|
||||
relevantSamples[i] = relevantSamples[i].With(newVolume: newVolume);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
#region hitsound toggles
|
||||
|
||||
private readonly Dictionary<string, Bindable<TernaryState>> selectionSampleStates = new Dictionary<string, Bindable<TernaryState>>();
|
||||
|
||||
private readonly List<string> banks = new List<string>();
|
||||
|
||||
private void createStateBindables()
|
||||
{
|
||||
foreach (string sampleName in HitSampleInfo.AllAdditions)
|
||||
{
|
||||
var bindable = new Bindable<TernaryState>
|
||||
{
|
||||
Description = sampleName.Replace("hit", string.Empty).Titleize()
|
||||
};
|
||||
|
||||
bindable.ValueChanged += state =>
|
||||
{
|
||||
switch (state.NewValue)
|
||||
{
|
||||
case TernaryState.False:
|
||||
removeHitSample(sampleName);
|
||||
break;
|
||||
|
||||
case TernaryState.True:
|
||||
addHitSample(sampleName);
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
selectionSampleStates[sampleName] = bindable;
|
||||
}
|
||||
|
||||
banks.AddRange(HitSampleInfo.AllBanks);
|
||||
}
|
||||
|
||||
private void updateTernaryStates()
|
||||
{
|
||||
foreach ((string sampleName, var bindable) in selectionSampleStates)
|
||||
{
|
||||
bindable.Value = SelectionHandler<HitObject>.GetStateFromSelection(relevantObjects, h => GetRelevantSamples(h).Any(s => s.Name == sampleName));
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerable<TernaryButton> createTernaryButtons()
|
||||
{
|
||||
foreach ((string sampleName, var bindable) in selectionSampleStates)
|
||||
yield return new TernaryButton(bindable, string.Empty, () => ComposeBlueprintContainer.GetIconForSample(sampleName));
|
||||
}
|
||||
|
||||
private void addHitSample(string sampleName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(sampleName))
|
||||
return;
|
||||
|
||||
updateAllRelevantSamples((h, relevantSamples) =>
|
||||
{
|
||||
// Make sure there isn't already an existing sample
|
||||
if (relevantSamples.Any(s => s.Name == sampleName))
|
||||
return;
|
||||
|
||||
// First try inheriting the sample info from the node samples instead of the samples of the hitobject
|
||||
var relevantSample = relevantSamples.FirstOrDefault(s => s.Name != HitSampleInfo.HIT_NORMAL) ?? relevantSamples.FirstOrDefault();
|
||||
relevantSamples.Add(relevantSample?.With(sampleName) ?? h.CreateHitSampleInfo(sampleName));
|
||||
});
|
||||
|
||||
updateAdditionBankState();
|
||||
}
|
||||
|
||||
private void removeHitSample(string sampleName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(sampleName))
|
||||
return;
|
||||
|
||||
updateAllRelevantSamples((_, relevantSamples) =>
|
||||
{
|
||||
for (int i = 0; i < relevantSamples.Count; i++)
|
||||
{
|
||||
if (relevantSamples[i].Name == sampleName)
|
||||
relevantSamples.RemoveAt(i--);
|
||||
}
|
||||
});
|
||||
|
||||
updateAdditionBankState();
|
||||
}
|
||||
|
||||
protected override bool OnKeyDown(KeyDownEvent e)
|
||||
{
|
||||
if (e.ControlPressed || e.AltPressed || e.SuperPressed || !checkRightToggleFromKey(e.Key, out int rightIndex))
|
||||
return base.OnKeyDown(e);
|
||||
|
||||
if (e.ShiftPressed)
|
||||
{
|
||||
string? newBank = banks.ElementAtOrDefault(rightIndex);
|
||||
|
||||
if (string.IsNullOrEmpty(newBank))
|
||||
return true;
|
||||
|
||||
setBank(newBank);
|
||||
updatePrimaryBankState();
|
||||
setAdditionBank(newBank);
|
||||
updateAdditionBankState();
|
||||
}
|
||||
else
|
||||
{
|
||||
var item = togglesCollection.ElementAtOrDefault(rightIndex);
|
||||
|
||||
if (item is not DrawableTernaryButton button) return base.OnKeyDown(e);
|
||||
|
||||
button.Button.Toggle();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool checkRightToggleFromKey(Key key, out int index)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case Key.W:
|
||||
index = 0;
|
||||
break;
|
||||
|
||||
case Key.E:
|
||||
index = 1;
|
||||
break;
|
||||
|
||||
case Key.R:
|
||||
index = 2;
|
||||
break;
|
||||
|
||||
default:
|
||||
index = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
return index >= 0;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -170,6 +170,8 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
|
||||
protected override void UpdateSelectionFromDragBox()
|
||||
{
|
||||
Composer.BlueprintContainer.CommitIfPlacementActive();
|
||||
|
||||
var dragBox = (TimelineDragBox)DragBox;
|
||||
double minTime = dragBox.MinTime;
|
||||
double maxTime = dragBox.MaxTime;
|
||||
|
@ -0,0 +1,224 @@
|
||||
// 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.Diagnostics;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Beatmaps.Timing;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
{
|
||||
public partial class TimelineBreak : CompositeDrawable
|
||||
{
|
||||
public Bindable<BreakPeriod> Break { get; } = new Bindable<BreakPeriod>();
|
||||
|
||||
public TimelineBreak(BreakPeriod b)
|
||||
{
|
||||
Break.Value = b;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
RelativePositionAxes = Axes.X;
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
Origin = Anchor.TopLeft;
|
||||
Padding = new MarginPadding { Horizontal = -5 };
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding { Horizontal = 5 },
|
||||
Child = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = colours.Gray5,
|
||||
Alpha = 0.7f,
|
||||
},
|
||||
},
|
||||
new DragHandle(isStartHandle: true)
|
||||
{
|
||||
Break = { BindTarget = Break },
|
||||
Anchor = Anchor.TopLeft,
|
||||
Origin = Anchor.TopLeft,
|
||||
Action = (time, breakPeriod) => new ManualBreakPeriod(time, breakPeriod.EndTime),
|
||||
},
|
||||
new DragHandle(isStartHandle: false)
|
||||
{
|
||||
Break = { BindTarget = Break },
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
Action = (time, breakPeriod) => new ManualBreakPeriod(breakPeriod.StartTime, time),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
Break.BindValueChanged(_ =>
|
||||
{
|
||||
X = (float)Break.Value.StartTime;
|
||||
Width = (float)Break.Value.Duration;
|
||||
}, true);
|
||||
}
|
||||
|
||||
private partial class DragHandle : FillFlowContainer
|
||||
{
|
||||
public Bindable<BreakPeriod> Break { get; } = new Bindable<BreakPeriod>();
|
||||
|
||||
public new Anchor Anchor
|
||||
{
|
||||
get => base.Anchor;
|
||||
init => base.Anchor = value;
|
||||
}
|
||||
|
||||
public Func<double, BreakPeriod, BreakPeriod>? Action { get; init; }
|
||||
|
||||
private readonly bool isStartHandle;
|
||||
|
||||
private Container handle = null!;
|
||||
private (double min, double max)? allowedDragRange;
|
||||
|
||||
[Resolved]
|
||||
private EditorBeatmap beatmap { get; set; } = null!;
|
||||
|
||||
[Resolved]
|
||||
private Timeline timeline { get; set; } = null!;
|
||||
|
||||
[Resolved]
|
||||
private IEditorChangeHandler? changeHandler { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private OsuColour colours { get; set; } = null!;
|
||||
|
||||
public DragHandle(bool isStartHandle)
|
||||
{
|
||||
this.isStartHandle = isStartHandle;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
AutoSizeAxes = Axes.X;
|
||||
RelativeSizeAxes = Axes.Y;
|
||||
Direction = FillDirection.Horizontal;
|
||||
Spacing = new Vector2(5);
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
handle = new Container
|
||||
{
|
||||
Anchor = Anchor,
|
||||
Origin = Anchor,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
CornerRadius = 5,
|
||||
Masking = true,
|
||||
Child = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Colour4.White,
|
||||
},
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
BypassAutoSizeAxes = Axes.X,
|
||||
Anchor = Anchor,
|
||||
Origin = Anchor,
|
||||
Text = "Break",
|
||||
Margin = new MarginPadding { Top = 2, },
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
updateState();
|
||||
FinishTransforms(true);
|
||||
}
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
{
|
||||
updateState();
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(HoverLostEvent e)
|
||||
{
|
||||
updateState();
|
||||
base.OnHoverLost(e);
|
||||
}
|
||||
|
||||
protected override bool OnDragStart(DragStartEvent e)
|
||||
{
|
||||
changeHandler?.BeginChange();
|
||||
updateState();
|
||||
|
||||
double min = beatmap.HitObjects.Last(ho => ho.GetEndTime() <= Break.Value.StartTime).GetEndTime();
|
||||
double max = beatmap.HitObjects.First(ho => ho.StartTime >= Break.Value.EndTime).StartTime;
|
||||
|
||||
if (isStartHandle)
|
||||
max = Math.Min(max, Break.Value.EndTime - BreakPeriod.MIN_BREAK_DURATION);
|
||||
else
|
||||
min = Math.Max(min, Break.Value.StartTime + BreakPeriod.MIN_BREAK_DURATION);
|
||||
|
||||
allowedDragRange = (min, max);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void OnDrag(DragEvent e)
|
||||
{
|
||||
base.OnDrag(e);
|
||||
|
||||
Debug.Assert(allowedDragRange != null);
|
||||
|
||||
if (Action != null
|
||||
&& timeline.FindSnappedPositionAndTime(e.ScreenSpaceMousePosition).Time is double time
|
||||
&& time > allowedDragRange.Value.min
|
||||
&& time < allowedDragRange.Value.max)
|
||||
{
|
||||
int index = beatmap.Breaks.IndexOf(Break.Value);
|
||||
beatmap.Breaks[index] = Break.Value = Action.Invoke(time, Break.Value);
|
||||
}
|
||||
|
||||
updateState();
|
||||
}
|
||||
|
||||
protected override void OnDragEnd(DragEndEvent e)
|
||||
{
|
||||
changeHandler?.EndChange();
|
||||
updateState();
|
||||
base.OnDragEnd(e);
|
||||
}
|
||||
|
||||
private void updateState()
|
||||
{
|
||||
bool active = IsHovered || IsDragged;
|
||||
|
||||
var colour = colours.Gray8;
|
||||
if (active)
|
||||
colour = colour.Lighten(0.3f);
|
||||
|
||||
this.FadeColour(colour, 400, Easing.OutQuint);
|
||||
handle.ResizeWidthTo(active ? 20 : 10, 400, Easing.OutElasticHalf);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
// 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.Specialized;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Caching;
|
||||
using osu.Game.Beatmaps.Timing;
|
||||
using osu.Game.Screens.Edit.Components.Timelines.Summary.Parts;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
{
|
||||
public partial class TimelineBreakDisplay : TimelinePart<TimelineBreak>
|
||||
{
|
||||
[Resolved]
|
||||
private Timeline timeline { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// The visible time/position range of the timeline.
|
||||
/// </summary>
|
||||
private (float min, float max) visibleRange = (float.MinValue, float.MaxValue);
|
||||
|
||||
private readonly Cached breakCache = new Cached();
|
||||
|
||||
private readonly BindableList<BreakPeriod> breaks = new BindableList<BreakPeriod>();
|
||||
|
||||
protected override void LoadBeatmap(EditorBeatmap beatmap)
|
||||
{
|
||||
base.LoadBeatmap(beatmap);
|
||||
|
||||
breaks.UnbindAll();
|
||||
breaks.BindTo(beatmap.Breaks);
|
||||
breaks.BindCollectionChanged((_, e) =>
|
||||
{
|
||||
if (e.Action != NotifyCollectionChangedAction.Replace)
|
||||
breakCache.Invalidate();
|
||||
});
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
if (DrawWidth <= 0) return;
|
||||
|
||||
(float, float) newRange = (
|
||||
(ToLocalSpace(timeline.ScreenSpaceDrawQuad.TopLeft).X) / DrawWidth * Content.RelativeChildSize.X,
|
||||
(ToLocalSpace(timeline.ScreenSpaceDrawQuad.TopRight).X) / DrawWidth * Content.RelativeChildSize.X);
|
||||
|
||||
if (visibleRange != newRange)
|
||||
{
|
||||
visibleRange = newRange;
|
||||
breakCache.Invalidate();
|
||||
}
|
||||
|
||||
if (!breakCache.IsValid)
|
||||
{
|
||||
recreateBreaks();
|
||||
breakCache.Validate();
|
||||
}
|
||||
}
|
||||
|
||||
private void recreateBreaks()
|
||||
{
|
||||
Clear();
|
||||
|
||||
for (int i = 0; i < breaks.Count; i++)
|
||||
{
|
||||
var breakPeriod = breaks[i];
|
||||
|
||||
if (!shouldBeVisible(breakPeriod))
|
||||
continue;
|
||||
|
||||
Add(new TimelineBreak(breakPeriod));
|
||||
}
|
||||
}
|
||||
|
||||
private bool shouldBeVisible(BreakPeriod breakPeriod) => breakPeriod.EndTime >= visibleRange.min && breakPeriod.StartTime <= visibleRange.max;
|
||||
}
|
||||
}
|
@ -50,6 +50,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
private readonly Border border;
|
||||
|
||||
private readonly Container colouredComponents;
|
||||
private readonly Container sampleComponents;
|
||||
private readonly OsuSpriteText comboIndexText;
|
||||
private readonly SamplePointPiece samplePointPiece;
|
||||
private readonly DifficultyPointPiece? difficultyPointPiece;
|
||||
@ -107,7 +108,13 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
samplePointPiece = new SamplePointPiece(Item)
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.TopCentre
|
||||
Origin = Anchor.TopCentre,
|
||||
RelativePositionAxes = Axes.X,
|
||||
AlternativeColor = Item is IHasRepeats
|
||||
},
|
||||
sampleComponents = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
});
|
||||
|
||||
@ -236,6 +243,22 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
X = (float)(i + 1) / (repeats.RepeatCount + 1)
|
||||
});
|
||||
}
|
||||
|
||||
// Add node sample pieces
|
||||
sampleComponents.Clear();
|
||||
|
||||
for (int i = 0; i < repeats.RepeatCount + 2; i++)
|
||||
{
|
||||
sampleComponents.Add(new NodeSamplePointPiece(Item, i)
|
||||
{
|
||||
X = (float)i / (repeats.RepeatCount + 1),
|
||||
RelativePositionAxes = Axes.X,
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.TopCentre
|
||||
});
|
||||
}
|
||||
|
||||
samplePointPiece.X = 1f / (repeats.RepeatCount + 1) / 2;
|
||||
}
|
||||
|
||||
protected override bool ShouldBeConsideredForInput(Drawable child) => true;
|
||||
|
@ -69,7 +69,15 @@ namespace osu.Game.Screens.Edit.Compose
|
||||
if (ruleset == null || composer == null)
|
||||
return base.CreateTimelineContent();
|
||||
|
||||
return wrapSkinnableContent(new TimelineBlueprintContainer(composer));
|
||||
return wrapSkinnableContent(new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new TimelineBlueprintContainer(composer),
|
||||
new TimelineBreakDisplay { RelativeSizeAxes = Axes.Both, },
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private Drawable wrapSkinnableContent(Drawable content)
|
||||
|
@ -1019,6 +1019,15 @@ namespace osu.Game.Screens.Edit
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Forces a reload of the compose screen after significant configuration changes.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This can be necessary for scrolling rulesets, as they do not easily support control points changing under them.
|
||||
/// The reason that this works is that <see cref="onModeChanged"/> will re-instantiate the screen whenever it is requested next.
|
||||
/// </remarks>
|
||||
public void ReloadComposeScreen() => screenContainer.SingleOrDefault(s => s.Type == EditorScreenMode.Compose)?.RemoveAndDisposeImmediately();
|
||||
|
||||
[CanBeNull]
|
||||
private ScheduledDelegate playbackDisabledDebounce;
|
||||
|
||||
|
@ -105,7 +105,7 @@ namespace osu.Game.Screens.Edit
|
||||
BeatmapSkin.BeatmapSkinChanged += SaveState;
|
||||
}
|
||||
|
||||
beatmapProcessor = playableBeatmap.BeatmapInfo.Ruleset.CreateInstance().CreateBeatmapProcessor(this);
|
||||
beatmapProcessor = new EditorBeatmapProcessor(this, playableBeatmap.BeatmapInfo.Ruleset.CreateInstance());
|
||||
|
||||
foreach (var obj in HitObjects)
|
||||
trackStartTime(obj);
|
||||
@ -172,7 +172,7 @@ namespace osu.Game.Screens.Edit
|
||||
set => PlayableBeatmap.ControlPointInfo = value;
|
||||
}
|
||||
|
||||
public List<BreakPeriod> Breaks => PlayableBeatmap.Breaks;
|
||||
public BindableList<BreakPeriod> Breaks => PlayableBeatmap.Breaks;
|
||||
|
||||
public List<string> UnhandledEventLines => PlayableBeatmap.UnhandledEventLines;
|
||||
|
||||
@ -349,13 +349,13 @@ namespace osu.Game.Screens.Edit
|
||||
if (batchPendingUpdates.Count == 0 && batchPendingDeletes.Count == 0 && batchPendingInserts.Count == 0)
|
||||
return;
|
||||
|
||||
beatmapProcessor?.PreProcess();
|
||||
beatmapProcessor.PreProcess();
|
||||
|
||||
foreach (var h in batchPendingDeletes) processHitObject(h);
|
||||
foreach (var h in batchPendingInserts) processHitObject(h);
|
||||
foreach (var h in batchPendingUpdates) processHitObject(h);
|
||||
|
||||
beatmapProcessor?.PostProcess();
|
||||
beatmapProcessor.PostProcess();
|
||||
|
||||
BeatmapReprocessed?.Invoke();
|
||||
|
||||
|
70
osu.Game/Screens/Edit/EditorBeatmapProcessor.cs
Normal file
70
osu.Game/Screens/Edit/EditorBeatmapProcessor.cs
Normal file
@ -0,0 +1,70 @@
|
||||
// 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.Linq;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Timing;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
|
||||
namespace osu.Game.Screens.Edit
|
||||
{
|
||||
public class EditorBeatmapProcessor : IBeatmapProcessor
|
||||
{
|
||||
public IBeatmap Beatmap { get; }
|
||||
|
||||
private readonly IBeatmapProcessor? rulesetBeatmapProcessor;
|
||||
|
||||
public EditorBeatmapProcessor(IBeatmap beatmap, Ruleset ruleset)
|
||||
{
|
||||
Beatmap = beatmap;
|
||||
rulesetBeatmapProcessor = ruleset.CreateBeatmapProcessor(beatmap);
|
||||
}
|
||||
|
||||
public void PreProcess()
|
||||
{
|
||||
rulesetBeatmapProcessor?.PreProcess();
|
||||
}
|
||||
|
||||
public void PostProcess()
|
||||
{
|
||||
rulesetBeatmapProcessor?.PostProcess();
|
||||
|
||||
autoGenerateBreaks();
|
||||
}
|
||||
|
||||
private void autoGenerateBreaks()
|
||||
{
|
||||
Beatmap.Breaks.RemoveAll(b => b is not ManualBreakPeriod);
|
||||
|
||||
foreach (var manualBreak in Beatmap.Breaks.ToList())
|
||||
{
|
||||
if (Beatmap.HitObjects.Any(ho => ho.StartTime <= manualBreak.EndTime && ho.GetEndTime() >= manualBreak.StartTime))
|
||||
Beatmap.Breaks.Remove(manualBreak);
|
||||
}
|
||||
|
||||
for (int i = 1; i < Beatmap.HitObjects.Count; ++i)
|
||||
{
|
||||
double previousObjectEndTime = Beatmap.HitObjects[i - 1].GetEndTime();
|
||||
double nextObjectStartTime = Beatmap.HitObjects[i].StartTime;
|
||||
|
||||
if (nextObjectStartTime - previousObjectEndTime < BreakPeriod.MIN_GAP_DURATION)
|
||||
continue;
|
||||
|
||||
double breakStartTime = previousObjectEndTime + BreakPeriod.GAP_BEFORE_BREAK;
|
||||
double breakEndTime = nextObjectStartTime - Math.Max(BreakPeriod.GAP_AFTER_BREAK, Beatmap.ControlPointInfo.TimingPointAt(nextObjectStartTime).BeatLength * 2);
|
||||
|
||||
if (breakEndTime - breakStartTime < BreakPeriod.MIN_BREAK_DURATION)
|
||||
continue;
|
||||
|
||||
var breakPeriod = new BreakPeriod(breakStartTime, breakEndTime);
|
||||
|
||||
if (Beatmap.Breaks.Any(b => b.Intersects(breakPeriod)))
|
||||
continue;
|
||||
|
||||
Beatmap.Breaks.Add(breakPeriod);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -45,6 +45,7 @@ namespace osu.Game.Screens.Edit
|
||||
editorBeatmap.BeginChange();
|
||||
processHitObjects(result, () => newBeatmap ??= readBeatmap(newState));
|
||||
processTimingPoints(() => newBeatmap ??= readBeatmap(newState));
|
||||
processBreaks(() => newBeatmap ??= readBeatmap(newState));
|
||||
processHitObjectLocalData(() => newBeatmap ??= readBeatmap(newState));
|
||||
editorBeatmap.EndChange();
|
||||
}
|
||||
@ -75,6 +76,27 @@ namespace osu.Game.Screens.Edit
|
||||
}
|
||||
}
|
||||
|
||||
private void processBreaks(Func<IBeatmap> getNewBeatmap)
|
||||
{
|
||||
var newBreaks = getNewBeatmap().Breaks.ToArray();
|
||||
|
||||
foreach (var oldBreak in editorBeatmap.Breaks.ToArray())
|
||||
{
|
||||
if (newBreaks.Any(b => b.Equals(oldBreak)))
|
||||
continue;
|
||||
|
||||
editorBeatmap.Breaks.Remove(oldBreak);
|
||||
}
|
||||
|
||||
foreach (var newBreak in newBreaks)
|
||||
{
|
||||
if (editorBeatmap.Breaks.Any(b => b.Equals(newBreak)))
|
||||
continue;
|
||||
|
||||
editorBeatmap.Breaks.Add(newBreak);
|
||||
}
|
||||
}
|
||||
|
||||
private void processHitObjects(DiffResult result, Func<IBeatmap> getNewBeatmap)
|
||||
{
|
||||
findChangedIndices(result, LegacyDecoder<Beatmap>.Section.HitObjects, out var removedIndices, out var addedIndices);
|
||||
|
15
osu.Game/Screens/Edit/ManualBreakPeriod.cs
Normal file
15
osu.Game/Screens/Edit/ManualBreakPeriod.cs
Normal file
@ -0,0 +1,15 @@
|
||||
// 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.Game.Beatmaps.Timing;
|
||||
|
||||
namespace osu.Game.Screens.Edit
|
||||
{
|
||||
public class ManualBreakPeriod : BreakPeriod
|
||||
{
|
||||
public ManualBreakPeriod(double startTime, double endTime)
|
||||
: base(startTime, endTime)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -45,7 +45,7 @@ namespace osu.Game.Screens.Edit.Setup
|
||||
OnFocused?.Invoke();
|
||||
base.OnFocus(e);
|
||||
|
||||
GetContainingFocusManager().TriggerFocusContention(this);
|
||||
GetContainingFocusManager()!.TriggerFocusContention(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ namespace osu.Game.Screens.Edit.Setup
|
||||
base.LoadComplete();
|
||||
|
||||
if (string.IsNullOrEmpty(ArtistTextBox.Current.Value))
|
||||
ScheduleAfterChildren(() => GetContainingFocusManager().ChangeFocus(ArtistTextBox));
|
||||
ScheduleAfterChildren(() => GetContainingFocusManager()!.ChangeFocus(ArtistTextBox));
|
||||
|
||||
ArtistTextBox.Current.BindValueChanged(artist => transferIfRomanised(artist.NewValue, RomanisedArtistTextBox));
|
||||
TitleTextBox.Current.BindValueChanged(title => transferIfRomanised(title.NewValue, RomanisedTitleTextBox));
|
||||
|
@ -126,7 +126,7 @@ namespace osu.Game.Screens.Edit.Timing
|
||||
protected override void OnFocus(FocusEvent e)
|
||||
{
|
||||
base.OnFocus(e);
|
||||
GetContainingFocusManager().ChangeFocus(textBox);
|
||||
GetContainingFocusManager()!.ChangeFocus(textBox);
|
||||
}
|
||||
|
||||
private void updateState()
|
||||
|
@ -53,7 +53,7 @@ namespace osu.Game.Screens.Edit.Verify
|
||||
if (issue.Time != null)
|
||||
{
|
||||
clock.Seek(issue.Time.Value);
|
||||
editor.OnPressed(new KeyBindingPressEvent<GlobalAction>(GetContainingInputManager().CurrentState, GlobalAction.EditorComposeMode));
|
||||
editor.OnPressed(new KeyBindingPressEvent<GlobalAction>(GetContainingInputManager()!.CurrentState, GlobalAction.EditorComposeMode));
|
||||
}
|
||||
|
||||
if (!issue.HitObjects.Any())
|
||||
|
@ -248,21 +248,21 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
ScheduleAfterChildren(() => GetContainingFocusManager().ChangeFocus(passwordTextBox));
|
||||
ScheduleAfterChildren(() => GetContainingFocusManager()!.ChangeFocus(passwordTextBox));
|
||||
passwordTextBox.OnCommit += (_, _) => performJoin();
|
||||
}
|
||||
|
||||
private void performJoin()
|
||||
{
|
||||
lounge?.Join(room, passwordTextBox.Text, null, joinFailed);
|
||||
GetContainingFocusManager().TriggerFocusContention(passwordTextBox);
|
||||
GetContainingFocusManager()?.TriggerFocusContention(passwordTextBox);
|
||||
}
|
||||
|
||||
private void joinFailed(string error) => Schedule(() =>
|
||||
{
|
||||
passwordTextBox.Text = string.Empty;
|
||||
|
||||
GetContainingFocusManager().ChangeFocus(passwordTextBox);
|
||||
GetContainingFocusManager()!.ChangeFocus(passwordTextBox);
|
||||
|
||||
errorText.Text = error;
|
||||
errorText
|
||||
|
@ -249,7 +249,7 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
inputManager = GetContainingInputManager();
|
||||
inputManager = GetContainingInputManager()!;
|
||||
|
||||
showStoryboards.BindValueChanged(val => epilepsyWarning?.FadeTo(val.NewValue ? 1 : 0, 250, Easing.OutQuint), true);
|
||||
epilepsyWarning?.FinishTransforms(true);
|
||||
|
@ -1279,7 +1279,7 @@ namespace osu.Game.Screens.Select
|
||||
{
|
||||
// we need to block right click absolute scrolling when hovering a carousel item so context menus can display.
|
||||
// this can be reconsidered when we have an alternative to right click scrolling.
|
||||
if (GetContainingInputManager().HoveredDrawables.OfType<DrawableCarouselItem>().Any())
|
||||
if (GetContainingInputManager()!.HoveredDrawables.OfType<DrawableCarouselItem>().Any())
|
||||
{
|
||||
rightMouseScrollBlocked = true;
|
||||
return false;
|
||||
|
@ -245,7 +245,7 @@ namespace osu.Game.Screens.Select
|
||||
searchTextBox.ReadOnly = true;
|
||||
searchTextBox.HoldFocus = false;
|
||||
if (searchTextBox.HasFocus)
|
||||
GetContainingFocusManager().ChangeFocus(searchTextBox);
|
||||
GetContainingFocusManager()!.ChangeFocus(searchTextBox);
|
||||
}
|
||||
|
||||
public void Activate()
|
||||
|
@ -95,7 +95,7 @@ namespace osu.Game.Screens.Select
|
||||
modsAtGameplayStart = Mods.Value;
|
||||
|
||||
// Ctrl+Enter should start map with autoplay enabled.
|
||||
if (GetContainingInputManager().CurrentState?.Keyboard.ControlPressed == true)
|
||||
if (GetContainingInputManager()?.CurrentState?.Keyboard.ControlPressed == true)
|
||||
{
|
||||
var autoInstance = getAutoplayMod();
|
||||
|
||||
|
@ -81,7 +81,7 @@ namespace osu.Game.Screens.SelectV2.Footer
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
ScheduleAfterChildren(() => GetContainingFocusManager().ChangeFocus(this));
|
||||
ScheduleAfterChildren(() => GetContainingFocusManager()!.ChangeFocus(this));
|
||||
|
||||
beatmap.BindValueChanged(_ => Hide());
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ namespace osu.Game.Screens.Utility.SampleComponents
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
inputManager = GetContainingInputManager();
|
||||
inputManager = GetContainingInputManager()!;
|
||||
IsActive.BindTo(latencyArea.IsActiveArea);
|
||||
}
|
||||
|
||||
|
@ -26,11 +26,13 @@ namespace osu.Game.Tests.Beatmaps
|
||||
|
||||
BeatmapInfo = baseBeatmap.BeatmapInfo;
|
||||
ControlPointInfo = baseBeatmap.ControlPointInfo;
|
||||
Breaks = baseBeatmap.Breaks;
|
||||
UnhandledEventLines = baseBeatmap.UnhandledEventLines;
|
||||
|
||||
if (withHitObjects)
|
||||
{
|
||||
HitObjects = baseBeatmap.HitObjects;
|
||||
Breaks = baseBeatmap.Breaks;
|
||||
}
|
||||
|
||||
BeatmapInfo.Ruleset = ruleset;
|
||||
BeatmapInfo.Length = 75000;
|
||||
|
@ -35,7 +35,7 @@
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Realm" Version="11.5.0" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2024.528.1" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2024.618.0" />
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2024.517.0" />
|
||||
<PackageReference Include="Sentry" Version="4.3.0" />
|
||||
<!-- Held back due to 0.34.0 failing AOT compilation on ZstdSharp.dll dependency. -->
|
||||
|
@ -23,6 +23,6 @@
|
||||
<RuntimeIdentifier>iossimulator-x64</RuntimeIdentifier>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ppy.osu.Framework.iOS" Version="2024.528.1" />
|
||||
<PackageReference Include="ppy.osu.Framework.iOS" Version="2024.618.0" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
Loading…
Reference in New Issue
Block a user