mirror of
https://github.com/osukey/osukey.git
synced 2025-05-17 03:27:21 +09:00
Merge branch 'master' of https://github.com/ppy/osu into stereo-shifted-playback
This commit is contained in:
commit
22d89dbff7
@ -52,6 +52,6 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.403.0" />
|
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.403.0" />
|
||||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2020.407.1" />
|
<PackageReference Include="ppy.osu.Framework.Android" Version="2020.411.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -45,6 +45,7 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
|||||||
new Container
|
new Container
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Masking = true,
|
||||||
BorderThickness = 1,
|
BorderThickness = 1,
|
||||||
BorderColour = colours.Yellow,
|
BorderColour = colours.Yellow,
|
||||||
Child = new Box
|
Child = new Box
|
||||||
|
412
osu.Game.Rulesets.Osu.Tests/TestSceneOutOfOrderHits.cs
Normal file
412
osu.Game.Rulesets.Osu.Tests/TestSceneOutOfOrderHits.cs
Normal file
@ -0,0 +1,412 @@
|
|||||||
|
// 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 NUnit.Framework;
|
||||||
|
using osu.Framework.Extensions.TypeExtensions;
|
||||||
|
using osu.Framework.Screens;
|
||||||
|
using osu.Framework.Utils;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
|
using osu.Game.Replays;
|
||||||
|
using osu.Game.Rulesets.Judgements;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
|
using osu.Game.Rulesets.Osu.Replays;
|
||||||
|
using osu.Game.Rulesets.Replays;
|
||||||
|
using osu.Game.Rulesets.Scoring;
|
||||||
|
using osu.Game.Scoring;
|
||||||
|
using osu.Game.Screens.Play;
|
||||||
|
using osu.Game.Tests.Visual;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Osu.Tests
|
||||||
|
{
|
||||||
|
public class TestSceneOutOfOrderHits : RateAdjustedBeatmapTestScene
|
||||||
|
{
|
||||||
|
private const double early_miss_window = 1000; // time after -1000 to -500 is considered a miss
|
||||||
|
private const double late_miss_window = 500; // time after +500 is considered a miss
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tests clicking a future circle before the first circle's start time, while the first circle HAS NOT been judged.
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void TestClickSecondCircleBeforeFirstCircleTime()
|
||||||
|
{
|
||||||
|
const double time_first_circle = 1500;
|
||||||
|
const double time_second_circle = 1600;
|
||||||
|
Vector2 positionFirstCircle = Vector2.Zero;
|
||||||
|
Vector2 positionSecondCircle = new Vector2(80);
|
||||||
|
|
||||||
|
var hitObjects = new List<OsuHitObject>
|
||||||
|
{
|
||||||
|
new TestHitCircle
|
||||||
|
{
|
||||||
|
StartTime = time_first_circle,
|
||||||
|
Position = positionFirstCircle
|
||||||
|
},
|
||||||
|
new TestHitCircle
|
||||||
|
{
|
||||||
|
StartTime = time_second_circle,
|
||||||
|
Position = positionSecondCircle
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
performTest(hitObjects, new List<ReplayFrame>
|
||||||
|
{
|
||||||
|
new OsuReplayFrame { Time = time_first_circle - 100, Position = positionSecondCircle, Actions = { OsuAction.LeftButton } }
|
||||||
|
});
|
||||||
|
|
||||||
|
addJudgementAssert(hitObjects[0], HitResult.Miss);
|
||||||
|
addJudgementAssert(hitObjects[1], HitResult.Miss);
|
||||||
|
addJudgementOffsetAssert(hitObjects[0], late_miss_window);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tests clicking a future circle at the first circle's start time, while the first circle HAS NOT been judged.
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void TestClickSecondCircleAtFirstCircleTime()
|
||||||
|
{
|
||||||
|
const double time_first_circle = 1500;
|
||||||
|
const double time_second_circle = 1600;
|
||||||
|
Vector2 positionFirstCircle = Vector2.Zero;
|
||||||
|
Vector2 positionSecondCircle = new Vector2(80);
|
||||||
|
|
||||||
|
var hitObjects = new List<OsuHitObject>
|
||||||
|
{
|
||||||
|
new TestHitCircle
|
||||||
|
{
|
||||||
|
StartTime = time_first_circle,
|
||||||
|
Position = positionFirstCircle
|
||||||
|
},
|
||||||
|
new TestHitCircle
|
||||||
|
{
|
||||||
|
StartTime = time_second_circle,
|
||||||
|
Position = positionSecondCircle
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
performTest(hitObjects, new List<ReplayFrame>
|
||||||
|
{
|
||||||
|
new OsuReplayFrame { Time = time_first_circle, Position = positionSecondCircle, Actions = { OsuAction.LeftButton } }
|
||||||
|
});
|
||||||
|
|
||||||
|
addJudgementAssert(hitObjects[0], HitResult.Miss);
|
||||||
|
addJudgementAssert(hitObjects[1], HitResult.Great);
|
||||||
|
addJudgementOffsetAssert(hitObjects[0], 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tests clicking a future circle after the first circle's start time, while the first circle HAS NOT been judged.
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void TestClickSecondCircleAfterFirstCircleTime()
|
||||||
|
{
|
||||||
|
const double time_first_circle = 1500;
|
||||||
|
const double time_second_circle = 1600;
|
||||||
|
Vector2 positionFirstCircle = Vector2.Zero;
|
||||||
|
Vector2 positionSecondCircle = new Vector2(80);
|
||||||
|
|
||||||
|
var hitObjects = new List<OsuHitObject>
|
||||||
|
{
|
||||||
|
new TestHitCircle
|
||||||
|
{
|
||||||
|
StartTime = time_first_circle,
|
||||||
|
Position = positionFirstCircle
|
||||||
|
},
|
||||||
|
new TestHitCircle
|
||||||
|
{
|
||||||
|
StartTime = time_second_circle,
|
||||||
|
Position = positionSecondCircle
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
performTest(hitObjects, new List<ReplayFrame>
|
||||||
|
{
|
||||||
|
new OsuReplayFrame { Time = time_first_circle + 100, Position = positionSecondCircle, Actions = { OsuAction.LeftButton } }
|
||||||
|
});
|
||||||
|
|
||||||
|
addJudgementAssert(hitObjects[0], HitResult.Miss);
|
||||||
|
addJudgementAssert(hitObjects[1], HitResult.Great);
|
||||||
|
addJudgementOffsetAssert(hitObjects[0], 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tests clicking a future circle before the first circle's start time, while the first circle HAS been judged.
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void TestClickSecondCircleBeforeFirstCircleTimeWithFirstCircleJudged()
|
||||||
|
{
|
||||||
|
const double time_first_circle = 1500;
|
||||||
|
const double time_second_circle = 1600;
|
||||||
|
Vector2 positionFirstCircle = Vector2.Zero;
|
||||||
|
Vector2 positionSecondCircle = new Vector2(80);
|
||||||
|
|
||||||
|
var hitObjects = new List<OsuHitObject>
|
||||||
|
{
|
||||||
|
new TestHitCircle
|
||||||
|
{
|
||||||
|
StartTime = time_first_circle,
|
||||||
|
Position = positionFirstCircle
|
||||||
|
},
|
||||||
|
new TestHitCircle
|
||||||
|
{
|
||||||
|
StartTime = time_second_circle,
|
||||||
|
Position = positionSecondCircle
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
performTest(hitObjects, new List<ReplayFrame>
|
||||||
|
{
|
||||||
|
new OsuReplayFrame { Time = time_first_circle - 200, Position = positionFirstCircle, Actions = { OsuAction.LeftButton } },
|
||||||
|
new OsuReplayFrame { Time = time_first_circle - 100, Position = positionSecondCircle, Actions = { OsuAction.RightButton } }
|
||||||
|
});
|
||||||
|
|
||||||
|
addJudgementAssert(hitObjects[0], HitResult.Great);
|
||||||
|
addJudgementAssert(hitObjects[1], HitResult.Great);
|
||||||
|
addJudgementOffsetAssert(hitObjects[0], -200); // time_first_circle - 200
|
||||||
|
addJudgementOffsetAssert(hitObjects[0], -200); // time_second_circle - first_circle_time - 100
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tests clicking a future circle after a slider's start time, but hitting all slider ticks.
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void TestMissSliderHeadAndHitAllSliderTicks()
|
||||||
|
{
|
||||||
|
const double time_slider = 1500;
|
||||||
|
const double time_circle = 1510;
|
||||||
|
Vector2 positionCircle = Vector2.Zero;
|
||||||
|
Vector2 positionSlider = new Vector2(80);
|
||||||
|
|
||||||
|
var hitObjects = new List<OsuHitObject>
|
||||||
|
{
|
||||||
|
new TestHitCircle
|
||||||
|
{
|
||||||
|
StartTime = time_circle,
|
||||||
|
Position = positionCircle
|
||||||
|
},
|
||||||
|
new TestSlider
|
||||||
|
{
|
||||||
|
StartTime = time_slider,
|
||||||
|
Position = positionSlider,
|
||||||
|
Path = new SliderPath(PathType.Linear, new[]
|
||||||
|
{
|
||||||
|
Vector2.Zero,
|
||||||
|
new Vector2(25, 0),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
performTest(hitObjects, new List<ReplayFrame>
|
||||||
|
{
|
||||||
|
new OsuReplayFrame { Time = time_slider, Position = positionCircle, Actions = { OsuAction.LeftButton } },
|
||||||
|
new OsuReplayFrame { Time = time_slider + 10, Position = positionSlider, Actions = { OsuAction.RightButton } }
|
||||||
|
});
|
||||||
|
|
||||||
|
addJudgementAssert(hitObjects[0], HitResult.Great);
|
||||||
|
addJudgementAssert(hitObjects[1], HitResult.Great);
|
||||||
|
addJudgementAssert("slider head", () => ((Slider)hitObjects[1]).HeadCircle, HitResult.Miss);
|
||||||
|
addJudgementAssert("slider tick", () => ((Slider)hitObjects[1]).NestedHitObjects[1] as SliderTick, HitResult.Great);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tests clicking hitting future slider ticks before a circle.
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void TestHitSliderTicksBeforeCircle()
|
||||||
|
{
|
||||||
|
const double time_slider = 1500;
|
||||||
|
const double time_circle = 1510;
|
||||||
|
Vector2 positionCircle = Vector2.Zero;
|
||||||
|
Vector2 positionSlider = new Vector2(80);
|
||||||
|
|
||||||
|
var hitObjects = new List<OsuHitObject>
|
||||||
|
{
|
||||||
|
new TestHitCircle
|
||||||
|
{
|
||||||
|
StartTime = time_circle,
|
||||||
|
Position = positionCircle
|
||||||
|
},
|
||||||
|
new TestSlider
|
||||||
|
{
|
||||||
|
StartTime = time_slider,
|
||||||
|
Position = positionSlider,
|
||||||
|
Path = new SliderPath(PathType.Linear, new[]
|
||||||
|
{
|
||||||
|
Vector2.Zero,
|
||||||
|
new Vector2(25, 0),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
performTest(hitObjects, new List<ReplayFrame>
|
||||||
|
{
|
||||||
|
new OsuReplayFrame { Time = time_slider, Position = positionSlider, Actions = { OsuAction.LeftButton } },
|
||||||
|
new OsuReplayFrame { Time = time_circle + late_miss_window - 100, Position = positionCircle, Actions = { OsuAction.RightButton } },
|
||||||
|
new OsuReplayFrame { Time = time_circle + late_miss_window - 90, Position = positionSlider, Actions = { OsuAction.LeftButton } },
|
||||||
|
});
|
||||||
|
|
||||||
|
addJudgementAssert(hitObjects[0], HitResult.Great);
|
||||||
|
addJudgementAssert(hitObjects[1], HitResult.Great);
|
||||||
|
addJudgementAssert("slider head", () => ((Slider)hitObjects[1]).HeadCircle, HitResult.Great);
|
||||||
|
addJudgementAssert("slider tick", () => ((Slider)hitObjects[1]).NestedHitObjects[1] as SliderTick, HitResult.Great);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tests clicking a future circle before a spinner.
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void TestHitCircleBeforeSpinner()
|
||||||
|
{
|
||||||
|
const double time_spinner = 1500;
|
||||||
|
const double time_circle = 1800;
|
||||||
|
Vector2 positionCircle = Vector2.Zero;
|
||||||
|
|
||||||
|
var hitObjects = new List<OsuHitObject>
|
||||||
|
{
|
||||||
|
new TestSpinner
|
||||||
|
{
|
||||||
|
StartTime = time_spinner,
|
||||||
|
Position = new Vector2(256, 192),
|
||||||
|
EndTime = time_spinner + 1000,
|
||||||
|
},
|
||||||
|
new TestHitCircle
|
||||||
|
{
|
||||||
|
StartTime = time_circle,
|
||||||
|
Position = positionCircle
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
performTest(hitObjects, new List<ReplayFrame>
|
||||||
|
{
|
||||||
|
new OsuReplayFrame { Time = time_spinner - 100, Position = positionCircle, Actions = { OsuAction.LeftButton } },
|
||||||
|
new OsuReplayFrame { Time = time_spinner + 10, Position = new Vector2(236, 192), Actions = { OsuAction.RightButton } },
|
||||||
|
new OsuReplayFrame { Time = time_spinner + 20, Position = new Vector2(256, 172), Actions = { OsuAction.RightButton } },
|
||||||
|
new OsuReplayFrame { Time = time_spinner + 30, Position = new Vector2(276, 192), Actions = { OsuAction.RightButton } },
|
||||||
|
new OsuReplayFrame { Time = time_spinner + 40, Position = new Vector2(256, 212), Actions = { OsuAction.RightButton } },
|
||||||
|
new OsuReplayFrame { Time = time_spinner + 50, Position = new Vector2(236, 192), Actions = { OsuAction.RightButton } },
|
||||||
|
});
|
||||||
|
|
||||||
|
addJudgementAssert(hitObjects[0], HitResult.Great);
|
||||||
|
addJudgementAssert(hitObjects[1], HitResult.Great);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addJudgementAssert(OsuHitObject hitObject, HitResult result)
|
||||||
|
{
|
||||||
|
AddAssert($"({hitObject.GetType().ReadableName()} @ {hitObject.StartTime}) judgement is {result}",
|
||||||
|
() => judgementResults.Single(r => r.HitObject == hitObject).Type == result);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addJudgementAssert(string name, Func<OsuHitObject> hitObject, HitResult result)
|
||||||
|
{
|
||||||
|
AddAssert($"{name} judgement is {result}",
|
||||||
|
() => judgementResults.Single(r => r.HitObject == hitObject()).Type == result);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addJudgementOffsetAssert(OsuHitObject hitObject, double offset)
|
||||||
|
{
|
||||||
|
AddAssert($"({hitObject.GetType().ReadableName()} @ {hitObject.StartTime}) judged at {offset}",
|
||||||
|
() => Precision.AlmostEquals(judgementResults.Single(r => r.HitObject == hitObject).TimeOffset, offset, 100));
|
||||||
|
}
|
||||||
|
|
||||||
|
private ScoreAccessibleReplayPlayer currentPlayer;
|
||||||
|
private List<JudgementResult> judgementResults;
|
||||||
|
private bool allJudgedFired;
|
||||||
|
|
||||||
|
private void performTest(List<OsuHitObject> hitObjects, List<ReplayFrame> frames)
|
||||||
|
{
|
||||||
|
AddStep("load player", () =>
|
||||||
|
{
|
||||||
|
Beatmap.Value = CreateWorkingBeatmap(new Beatmap<OsuHitObject>
|
||||||
|
{
|
||||||
|
HitObjects = hitObjects,
|
||||||
|
BeatmapInfo =
|
||||||
|
{
|
||||||
|
BaseDifficulty = new BeatmapDifficulty { SliderTickRate = 3 },
|
||||||
|
Ruleset = new OsuRuleset().RulesetInfo
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
Beatmap.Value.Beatmap.ControlPointInfo.Add(0, new DifficultyControlPoint { SpeedMultiplier = 0.1f });
|
||||||
|
|
||||||
|
var p = new ScoreAccessibleReplayPlayer(new Score { Replay = new Replay { Frames = frames } });
|
||||||
|
|
||||||
|
p.OnLoadComplete += _ =>
|
||||||
|
{
|
||||||
|
p.ScoreProcessor.NewJudgement += result =>
|
||||||
|
{
|
||||||
|
if (currentPlayer == p) judgementResults.Add(result);
|
||||||
|
};
|
||||||
|
p.ScoreProcessor.AllJudged += () =>
|
||||||
|
{
|
||||||
|
if (currentPlayer == p) allJudgedFired = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
LoadScreen(currentPlayer = p);
|
||||||
|
allJudgedFired = false;
|
||||||
|
judgementResults = new List<JudgementResult>();
|
||||||
|
});
|
||||||
|
|
||||||
|
AddUntilStep("Beatmap at 0", () => Beatmap.Value.Track.CurrentTime == 0);
|
||||||
|
AddUntilStep("Wait until player is loaded", () => currentPlayer.IsCurrentScreen());
|
||||||
|
AddUntilStep("Wait for all judged", () => allJudgedFired);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class TestHitCircle : HitCircle
|
||||||
|
{
|
||||||
|
protected override HitWindows CreateHitWindows() => new TestHitWindows();
|
||||||
|
}
|
||||||
|
|
||||||
|
private class TestSlider : Slider
|
||||||
|
{
|
||||||
|
public TestSlider()
|
||||||
|
{
|
||||||
|
DefaultsApplied += () =>
|
||||||
|
{
|
||||||
|
HeadCircle.HitWindows = new TestHitWindows();
|
||||||
|
TailCircle.HitWindows = new TestHitWindows();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class TestSpinner : Spinner
|
||||||
|
{
|
||||||
|
protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
||||||
|
{
|
||||||
|
base.ApplyDefaultsToSelf(controlPointInfo, difficulty);
|
||||||
|
SpinsRequired = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class TestHitWindows : HitWindows
|
||||||
|
{
|
||||||
|
private static readonly DifficultyRange[] ranges =
|
||||||
|
{
|
||||||
|
new DifficultyRange(HitResult.Great, 500, 500, 500),
|
||||||
|
new DifficultyRange(HitResult.Miss, early_miss_window, early_miss_window, early_miss_window),
|
||||||
|
};
|
||||||
|
|
||||||
|
public override bool IsHitResultAllowed(HitResult result) => result == HitResult.Great || result == HitResult.Miss;
|
||||||
|
|
||||||
|
protected override DifficultyRange[] GetRanges() => ranges;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ScoreAccessibleReplayPlayer : ReplayPlayer
|
||||||
|
{
|
||||||
|
public new ScoreProcessor ScoreProcessor => base.ScoreProcessor;
|
||||||
|
|
||||||
|
protected override bool PauseOnFocusLost => false;
|
||||||
|
|
||||||
|
public ScoreAccessibleReplayPlayer(Score score)
|
||||||
|
: base(score, false, false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -15,6 +15,7 @@ using osu.Game.Rulesets.Objects;
|
|||||||
using osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components;
|
using osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components;
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||||
|
using osu.Game.Screens.Edit;
|
||||||
using osu.Game.Screens.Edit.Compose;
|
using osu.Game.Screens.Edit.Compose;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Input;
|
using osuTK.Input;
|
||||||
@ -34,6 +35,9 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
|||||||
[Resolved(CanBeNull = true)]
|
[Resolved(CanBeNull = true)]
|
||||||
private IPlacementHandler placementHandler { get; set; }
|
private IPlacementHandler placementHandler { get; set; }
|
||||||
|
|
||||||
|
[Resolved(CanBeNull = true)]
|
||||||
|
private EditorBeatmap editorBeatmap { get; set; }
|
||||||
|
|
||||||
public SliderSelectionBlueprint(DrawableSlider slider)
|
public SliderSelectionBlueprint(DrawableSlider slider)
|
||||||
: base(slider)
|
: base(slider)
|
||||||
{
|
{
|
||||||
@ -162,7 +166,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
|||||||
private void updatePath()
|
private void updatePath()
|
||||||
{
|
{
|
||||||
HitObject.Path.ExpectedDistance.Value = composer?.GetSnappedDistanceFromDistance(HitObject.StartTime, (float)HitObject.Path.CalculatedDistance) ?? (float)HitObject.Path.CalculatedDistance;
|
HitObject.Path.ExpectedDistance.Value = composer?.GetSnappedDistanceFromDistance(HitObject.StartTime, (float)HitObject.Path.CalculatedDistance) ?? (float)HitObject.Path.CalculatedDistance;
|
||||||
UpdateHitObject();
|
editorBeatmap?.UpdateHitObject(HitObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override MenuItem[] ContextMenuItems => new MenuItem[]
|
public override MenuItem[] ContextMenuItems => new MenuItem[]
|
||||||
|
@ -120,7 +120,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
|
|
||||||
var result = HitObject.HitWindows.ResultFor(timeOffset);
|
var result = HitObject.HitWindows.ResultFor(timeOffset);
|
||||||
|
|
||||||
if (result == HitResult.None)
|
if (result == HitResult.None || CheckHittable?.Invoke(this, Time.Current) == false)
|
||||||
{
|
{
|
||||||
Shake(Math.Abs(timeOffset) - HitObject.HitWindows.WindowFor(HitResult.Miss));
|
Shake(Math.Abs(timeOffset) - HitObject.HitWindows.WindowFor(HitResult.Miss));
|
||||||
return;
|
return;
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Rulesets.Judgements;
|
using osu.Game.Rulesets.Judgements;
|
||||||
using osu.Game.Rulesets.Osu.Judgements;
|
using osu.Game.Rulesets.Osu.Judgements;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
|
using osu.Game.Rulesets.Scoring;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||||
{
|
{
|
||||||
@ -18,6 +20,12 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
|
|
||||||
protected override float SamplePlaybackBalance => (HitObject.X / 512f - 0.5f) * 0.8f;
|
protected override float SamplePlaybackBalance => (HitObject.X / 512f - 0.5f) * 0.8f;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether this <see cref="DrawableOsuHitObject"/> can be hit.
|
||||||
|
/// If non-null, judgements will be ignored (resulting in a shake) whilst the function returns false.
|
||||||
|
/// </summary>
|
||||||
|
public Func<DrawableHitObject, double, bool> CheckHittable;
|
||||||
|
|
||||||
protected DrawableOsuHitObject(OsuHitObject hitObject)
|
protected DrawableOsuHitObject(OsuHitObject hitObject)
|
||||||
: base(hitObject)
|
: base(hitObject)
|
||||||
{
|
{
|
||||||
@ -56,6 +64,11 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Causes this <see cref="DrawableOsuHitObject"/> to get missed, disregarding all conditions in implementations of <see cref="DrawableHitObject.CheckForResult"/>.
|
||||||
|
/// </summary>
|
||||||
|
public void MissForcefully() => ApplyResult(r => r.Type = HitResult.Miss);
|
||||||
|
|
||||||
protected override JudgementResult CreateResult(Judgement judgement) => new OsuJudgementResult(HitObject, judgement);
|
protected override JudgementResult CreateResult(Judgement judgement) => new OsuJudgementResult(HitObject, judgement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
case SliderTailCircle tail:
|
case SliderTailCircle tail:
|
||||||
return new DrawableSliderTail(slider, tail);
|
return new DrawableSliderTail(slider, tail);
|
||||||
|
|
||||||
case HitCircle head:
|
case SliderHeadCircle head:
|
||||||
return new DrawableSliderHead(slider, head) { OnShake = Shake };
|
return new DrawableSliderHead(slider, head) { OnShake = Shake };
|
||||||
|
|
||||||
case SliderTick tick:
|
case SliderTick tick:
|
||||||
|
@ -18,7 +18,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
|
|
||||||
private readonly Slider slider;
|
private readonly Slider slider;
|
||||||
|
|
||||||
public DrawableSliderHead(Slider slider, HitCircle h)
|
public DrawableSliderHead(Slider slider, SliderHeadCircle h)
|
||||||
: base(h)
|
: base(h)
|
||||||
{
|
{
|
||||||
this.slider = slider;
|
this.slider = slider;
|
||||||
|
@ -155,7 +155,7 @@ namespace osu.Game.Rulesets.Osu.Objects
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SliderEventType.Head:
|
case SliderEventType.Head:
|
||||||
AddNested(HeadCircle = new SliderCircle
|
AddNested(HeadCircle = new SliderHeadCircle
|
||||||
{
|
{
|
||||||
StartTime = e.Time,
|
StartTime = e.Time,
|
||||||
Position = Position,
|
Position = Position,
|
||||||
|
9
osu.Game.Rulesets.Osu/Objects/SliderHeadCircle.cs
Normal file
9
osu.Game.Rulesets.Osu/Objects/SliderHeadCircle.cs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Osu.Objects
|
||||||
|
{
|
||||||
|
public class SliderHeadCircle : HitCircle
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
127
osu.Game.Rulesets.Osu/UI/OrderedHitPolicy.cs
Normal file
127
osu.Game.Rulesets.Osu/UI/OrderedHitPolicy.cs
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
// 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.Rulesets.Objects;
|
||||||
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||||
|
using osu.Game.Rulesets.UI;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Osu.UI
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Ensures that <see cref="HitObject"/>s are hit in-order.
|
||||||
|
/// If a <see cref="HitObject"/> is hit out of order:
|
||||||
|
/// <list type="number">
|
||||||
|
/// <item><description>The hit is blocked if it occurred earlier than the previous <see cref="HitObject"/>'s start time.</description></item>
|
||||||
|
/// <item><description>The hit causes all previous <see cref="HitObject"/>s to missed otherwise.</description></item>
|
||||||
|
/// </list>
|
||||||
|
/// </summary>
|
||||||
|
public class OrderedHitPolicy
|
||||||
|
{
|
||||||
|
private readonly HitObjectContainer hitObjectContainer;
|
||||||
|
|
||||||
|
public OrderedHitPolicy(HitObjectContainer hitObjectContainer)
|
||||||
|
{
|
||||||
|
this.hitObjectContainer = hitObjectContainer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Determines whether a <see cref="DrawableHitObject"/> can be hit at a point in time.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="hitObject">The <see cref="DrawableHitObject"/> to check.</param>
|
||||||
|
/// <param name="time">The time to check.</param>
|
||||||
|
/// <returns>Whether <paramref name="hitObject"/> can be hit at the given <paramref name="time"/>.</returns>
|
||||||
|
public bool IsHittable(DrawableHitObject hitObject, double time)
|
||||||
|
{
|
||||||
|
DrawableHitObject blockingObject = null;
|
||||||
|
|
||||||
|
// Find the last hitobject which blocks future hits.
|
||||||
|
foreach (var obj in hitObjectContainer.AliveObjects)
|
||||||
|
{
|
||||||
|
if (obj == hitObject)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (drawableCanBlockFutureHits(obj))
|
||||||
|
blockingObject = obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If there is no previous hitobject, allow the hit.
|
||||||
|
if (blockingObject == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// A hit is allowed if:
|
||||||
|
// 1. The last blocking hitobject has been judged.
|
||||||
|
// 2. The current time is after the last hitobject's start time.
|
||||||
|
// Hits at exactly the same time as the blocking hitobject are allowed for maps that contain simultaneous hitobjects (e.g. /b/372245).
|
||||||
|
if (blockingObject.Judged || time >= blockingObject.HitObject.StartTime)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handles a <see cref="HitObject"/> being hit to potentially miss all earlier <see cref="HitObject"/>s.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="hitObject">The <see cref="HitObject"/> that was hit.</param>
|
||||||
|
public void HandleHit(HitObject hitObject)
|
||||||
|
{
|
||||||
|
// Hitobjects which themselves don't block future hitobjects don't cause misses (e.g. slider ticks, spinners).
|
||||||
|
if (!hitObjectCanBlockFutureHits(hitObject))
|
||||||
|
return;
|
||||||
|
|
||||||
|
double maximumTime = hitObject.StartTime;
|
||||||
|
|
||||||
|
// Iterate through and apply miss results to all top-level and nested hitobjects which block future hits.
|
||||||
|
foreach (var obj in hitObjectContainer.AliveObjects)
|
||||||
|
{
|
||||||
|
if (obj.Judged || obj.HitObject.StartTime >= maximumTime)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (hitObjectCanBlockFutureHits(obj.HitObject))
|
||||||
|
applyMiss(obj);
|
||||||
|
|
||||||
|
foreach (var nested in obj.NestedHitObjects)
|
||||||
|
{
|
||||||
|
if (nested.Judged || nested.HitObject.StartTime >= maximumTime)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (hitObjectCanBlockFutureHits(nested.HitObject))
|
||||||
|
applyMiss(nested);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void applyMiss(DrawableHitObject obj) => ((DrawableOsuHitObject)obj).MissForcefully();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether a <see cref="DrawableHitObject"/> blocks hits on future <see cref="DrawableHitObject"/>s until its start time is reached.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// This will ONLY match on top-most <see cref="DrawableHitObject"/>s.
|
||||||
|
/// </remarks>
|
||||||
|
/// <param name="hitObject">The <see cref="DrawableHitObject"/> to test.</param>
|
||||||
|
private static bool drawableCanBlockFutureHits(DrawableHitObject hitObject)
|
||||||
|
{
|
||||||
|
// Special considerations for slider tails aren't required since only top-most drawable hitobjects are being iterated over.
|
||||||
|
return hitObject is DrawableHitCircle || hitObject is DrawableSlider;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether a <see cref="HitObject"/> blocks hits on future <see cref="HitObject"/>s until its start time is reached.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// This is more rigorous and may not match on top-most <see cref="HitObject"/>s as <see cref="drawableCanBlockFutureHits"/> does.
|
||||||
|
/// </remarks>
|
||||||
|
/// <param name="hitObject">The <see cref="HitObject"/> to test.</param>
|
||||||
|
private static bool hitObjectCanBlockFutureHits(HitObject hitObject)
|
||||||
|
{
|
||||||
|
// Unlike the above we will receive slider tails, but they do not block future hits.
|
||||||
|
if (hitObject is SliderTailCircle)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// All other hitcircles continue to block future hits.
|
||||||
|
return hitObject is HitCircle;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -20,6 +20,7 @@ namespace osu.Game.Rulesets.Osu.UI
|
|||||||
private readonly ApproachCircleProxyContainer approachCircles;
|
private readonly ApproachCircleProxyContainer approachCircles;
|
||||||
private readonly JudgementContainer<DrawableOsuJudgement> judgementLayer;
|
private readonly JudgementContainer<DrawableOsuJudgement> judgementLayer;
|
||||||
private readonly FollowPointRenderer followPoints;
|
private readonly FollowPointRenderer followPoints;
|
||||||
|
private readonly OrderedHitPolicy hitPolicy;
|
||||||
|
|
||||||
public static readonly Vector2 BASE_SIZE = new Vector2(512, 384);
|
public static readonly Vector2 BASE_SIZE = new Vector2(512, 384);
|
||||||
|
|
||||||
@ -51,6 +52,8 @@ namespace osu.Game.Rulesets.Osu.UI
|
|||||||
Depth = -1,
|
Depth = -1,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
hitPolicy = new OrderedHitPolicy(HitObjectContainer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Add(DrawableHitObject h)
|
public override void Add(DrawableHitObject h)
|
||||||
@ -64,7 +67,10 @@ namespace osu.Game.Rulesets.Osu.UI
|
|||||||
|
|
||||||
base.Add(h);
|
base.Add(h);
|
||||||
|
|
||||||
followPoints.AddFollowPoints((DrawableOsuHitObject)h);
|
DrawableOsuHitObject osuHitObject = (DrawableOsuHitObject)h;
|
||||||
|
osuHitObject.CheckHittable = hitPolicy.IsHittable;
|
||||||
|
|
||||||
|
followPoints.AddFollowPoints(osuHitObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Remove(DrawableHitObject h)
|
public override bool Remove(DrawableHitObject h)
|
||||||
@ -79,6 +85,9 @@ namespace osu.Game.Rulesets.Osu.UI
|
|||||||
|
|
||||||
private void onNewResult(DrawableHitObject judgedObject, JudgementResult result)
|
private void onNewResult(DrawableHitObject judgedObject, JudgementResult result)
|
||||||
{
|
{
|
||||||
|
// Hitobjects that block future hits should miss previous hitobjects if they're hit out-of-order.
|
||||||
|
hitPolicy.HandleHit(result.HitObject);
|
||||||
|
|
||||||
if (!judgedObject.DisplayResult || !DisplayJudgements.Value)
|
if (!judgedObject.DisplayResult || !DisplayJudgements.Value)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1,18 +1,21 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.EntityFrameworkCore.Internal;
|
using Microsoft.EntityFrameworkCore.Internal;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Testing;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.Osu.Beatmaps;
|
using osu.Game.Rulesets.Osu.Beatmaps;
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
using osu.Game.Screens.Edit;
|
using osu.Game.Screens.Edit;
|
||||||
|
using osu.Game.Tests.Visual;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Beatmaps
|
namespace osu.Game.Tests.Beatmaps
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[HeadlessTest]
|
||||||
public class EditorBeatmapTest
|
public class TestSceneEditorBeatmap : EditorClockTestScene
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests that the addition event is correctly invoked after a hitobject is added.
|
/// Tests that the addition event is correctly invoked after a hitobject is added.
|
||||||
@ -55,13 +58,19 @@ namespace osu.Game.Tests.Beatmaps
|
|||||||
public void TestInitialHitObjectStartTimeChangeEvent()
|
public void TestInitialHitObjectStartTimeChangeEvent()
|
||||||
{
|
{
|
||||||
var hitCircle = new HitCircle();
|
var hitCircle = new HitCircle();
|
||||||
var editorBeatmap = new EditorBeatmap(new OsuBeatmap { HitObjects = { hitCircle } });
|
|
||||||
|
|
||||||
HitObject changedObject = null;
|
HitObject changedObject = null;
|
||||||
editorBeatmap.StartTimeChanged += h => changedObject = h;
|
|
||||||
|
|
||||||
hitCircle.StartTime = 1000;
|
AddStep("add beatmap", () =>
|
||||||
Assert.That(changedObject, Is.EqualTo(hitCircle));
|
{
|
||||||
|
EditorBeatmap editorBeatmap;
|
||||||
|
|
||||||
|
Child = editorBeatmap = new EditorBeatmap(new OsuBeatmap { HitObjects = { hitCircle } });
|
||||||
|
editorBeatmap.HitObjectUpdated += h => changedObject = h;
|
||||||
|
});
|
||||||
|
|
||||||
|
AddStep("change start time", () => hitCircle.StartTime = 1000);
|
||||||
|
AddAssert("received change event", () => changedObject == hitCircle);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -71,18 +80,22 @@ namespace osu.Game.Tests.Beatmaps
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestAddedHitObjectStartTimeChangeEvent()
|
public void TestAddedHitObjectStartTimeChangeEvent()
|
||||||
{
|
{
|
||||||
var editorBeatmap = new EditorBeatmap(new OsuBeatmap());
|
EditorBeatmap editorBeatmap = null;
|
||||||
|
|
||||||
HitObject changedObject = null;
|
HitObject changedObject = null;
|
||||||
editorBeatmap.StartTimeChanged += h => changedObject = h;
|
|
||||||
|
AddStep("add beatmap", () =>
|
||||||
|
{
|
||||||
|
Child = editorBeatmap = new EditorBeatmap(new OsuBeatmap());
|
||||||
|
editorBeatmap.HitObjectUpdated += h => changedObject = h;
|
||||||
|
});
|
||||||
|
|
||||||
var hitCircle = new HitCircle();
|
var hitCircle = new HitCircle();
|
||||||
|
|
||||||
editorBeatmap.Add(hitCircle);
|
AddStep("add object", () => editorBeatmap.Add(hitCircle));
|
||||||
Assert.That(changedObject, Is.Null);
|
AddAssert("event not received", () => changedObject == null);
|
||||||
|
|
||||||
hitCircle.StartTime = 1000;
|
AddStep("change start time", () => hitCircle.StartTime = 1000);
|
||||||
Assert.That(changedObject, Is.EqualTo(hitCircle));
|
AddAssert("event received", () => changedObject == hitCircle);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -95,7 +108,7 @@ namespace osu.Game.Tests.Beatmaps
|
|||||||
var editorBeatmap = new EditorBeatmap(new OsuBeatmap { HitObjects = { hitCircle } });
|
var editorBeatmap = new EditorBeatmap(new OsuBeatmap { HitObjects = { hitCircle } });
|
||||||
|
|
||||||
HitObject changedObject = null;
|
HitObject changedObject = null;
|
||||||
editorBeatmap.StartTimeChanged += h => changedObject = h;
|
editorBeatmap.HitObjectUpdated += h => changedObject = h;
|
||||||
|
|
||||||
editorBeatmap.Remove(hitCircle);
|
editorBeatmap.Remove(hitCircle);
|
||||||
Assert.That(changedObject, Is.Null);
|
Assert.That(changedObject, Is.Null);
|
||||||
@ -150,5 +163,69 @@ namespace osu.Game.Tests.Beatmaps
|
|||||||
Assert.That(editorBeatmap.HitObjects.Count(h => h == hitCircle), Is.EqualTo(1));
|
Assert.That(editorBeatmap.HitObjects.Count(h => h == hitCircle), Is.EqualTo(1));
|
||||||
Assert.That(editorBeatmap.HitObjects.IndexOf(hitCircle), Is.EqualTo(1));
|
Assert.That(editorBeatmap.HitObjects.IndexOf(hitCircle), Is.EqualTo(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tests that multiple hitobjects are updated simultaneously.
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void TestMultipleHitObjectUpdate()
|
||||||
|
{
|
||||||
|
var updatedObjects = new List<HitObject>();
|
||||||
|
var allHitObjects = new List<HitObject>();
|
||||||
|
EditorBeatmap editorBeatmap = null;
|
||||||
|
|
||||||
|
AddStep("add beatmap", () =>
|
||||||
|
{
|
||||||
|
updatedObjects.Clear();
|
||||||
|
|
||||||
|
Child = editorBeatmap = new EditorBeatmap(new OsuBeatmap());
|
||||||
|
|
||||||
|
for (int i = 0; i < 10; i++)
|
||||||
|
{
|
||||||
|
var h = new HitCircle();
|
||||||
|
editorBeatmap.Add(h);
|
||||||
|
allHitObjects.Add(h);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
AddStep("change all start times", () =>
|
||||||
|
{
|
||||||
|
editorBeatmap.HitObjectUpdated += h => updatedObjects.Add(h);
|
||||||
|
|
||||||
|
for (int i = 0; i < 10; i++)
|
||||||
|
allHitObjects[i].StartTime += 10;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Distinct ensures that all hitobjects have been updated once, debounce is tested below.
|
||||||
|
AddAssert("all hitobjects updated", () => updatedObjects.Distinct().Count() == 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tests that hitobject updates are debounced when they happen too soon.
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void TestDebouncedUpdate()
|
||||||
|
{
|
||||||
|
var updatedObjects = new List<HitObject>();
|
||||||
|
EditorBeatmap editorBeatmap = null;
|
||||||
|
|
||||||
|
AddStep("add beatmap", () =>
|
||||||
|
{
|
||||||
|
updatedObjects.Clear();
|
||||||
|
|
||||||
|
Child = editorBeatmap = new EditorBeatmap(new OsuBeatmap());
|
||||||
|
editorBeatmap.Add(new HitCircle());
|
||||||
|
});
|
||||||
|
|
||||||
|
AddStep("change start time twice", () =>
|
||||||
|
{
|
||||||
|
editorBeatmap.HitObjectUpdated += h => updatedObjects.Add(h);
|
||||||
|
|
||||||
|
editorBeatmap.HitObjects[0].StartTime = 10;
|
||||||
|
editorBeatmap.HitObjects[0].StartTime = 20;
|
||||||
|
});
|
||||||
|
|
||||||
|
AddAssert("only updated once", () => updatedObjects.Count == 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -111,7 +111,7 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
writer.WriteLine(FormattableString.Invariant($"Source: {beatmap.Metadata.Source}"));
|
writer.WriteLine(FormattableString.Invariant($"Source: {beatmap.Metadata.Source}"));
|
||||||
writer.WriteLine(FormattableString.Invariant($"Tags: {beatmap.Metadata.Tags}"));
|
writer.WriteLine(FormattableString.Invariant($"Tags: {beatmap.Metadata.Tags}"));
|
||||||
writer.WriteLine(FormattableString.Invariant($"BeatmapID: {beatmap.BeatmapInfo.OnlineBeatmapID ?? 0}"));
|
writer.WriteLine(FormattableString.Invariant($"BeatmapID: {beatmap.BeatmapInfo.OnlineBeatmapID ?? 0}"));
|
||||||
writer.WriteLine(FormattableString.Invariant($"BeatmapSetID: {beatmap.BeatmapInfo.BeatmapSet.OnlineBeatmapSetID ?? -1}"));
|
writer.WriteLine(FormattableString.Invariant($"BeatmapSetID: {beatmap.BeatmapInfo.BeatmapSet?.OnlineBeatmapSetID ?? -1}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleDifficulty(TextWriter writer)
|
private void handleDifficulty(TextWriter writer)
|
||||||
|
@ -29,14 +29,8 @@ namespace osu.Game.Overlays.Music
|
|||||||
{
|
{
|
||||||
public CollectionsMenu()
|
public CollectionsMenu()
|
||||||
{
|
{
|
||||||
|
Masking = true;
|
||||||
CornerRadius = 5;
|
CornerRadius = 5;
|
||||||
EdgeEffect = new EdgeEffectParameters
|
|
||||||
{
|
|
||||||
Type = EdgeEffectType.Shadow,
|
|
||||||
Colour = Color4.Black.Opacity(0.3f),
|
|
||||||
Radius = 3,
|
|
||||||
Offset = new Vector2(0f, 1f),
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
|
@ -69,10 +69,6 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(IFrameBasedClock framedClock)
|
private void load(IFrameBasedClock framedClock)
|
||||||
{
|
{
|
||||||
EditorBeatmap.HitObjectAdded += addHitObject;
|
|
||||||
EditorBeatmap.HitObjectRemoved += removeHitObject;
|
|
||||||
EditorBeatmap.StartTimeChanged += UpdateHitObject;
|
|
||||||
|
|
||||||
Config = Dependencies.Get<RulesetConfigCache>().GetConfigFor(Ruleset);
|
Config = Dependencies.Get<RulesetConfigCache>().GetConfigFor(Ruleset);
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -236,10 +232,6 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
lastGridUpdateTime = EditorClock.CurrentTime;
|
lastGridUpdateTime = EditorClock.CurrentTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addHitObject(HitObject hitObject) => UpdateHitObject(hitObject);
|
|
||||||
|
|
||||||
private void removeHitObject(HitObject hitObject) => UpdateHitObject(null);
|
|
||||||
|
|
||||||
public override IEnumerable<DrawableHitObject> HitObjects => drawableRulesetWrapper.Playfield.AllHitObjects;
|
public override IEnumerable<DrawableHitObject> HitObjects => drawableRulesetWrapper.Playfield.AllHitObjects;
|
||||||
public override bool CursorInPlacementArea => drawableRulesetWrapper.Playfield.ReceivePositionalInputAt(inputManager.CurrentState.Mouse.Position);
|
public override bool CursorInPlacementArea => drawableRulesetWrapper.Playfield.ReceivePositionalInputAt(inputManager.CurrentState.Mouse.Position);
|
||||||
|
|
||||||
@ -302,19 +294,6 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
|
|
||||||
return DurationToDistance(referenceTime, snappedEndTime - referenceTime);
|
return DurationToDistance(referenceTime, snappedEndTime - referenceTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void UpdateHitObject(HitObject hitObject) => EditorBeatmap.UpdateHitObject(hitObject);
|
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
|
||||||
{
|
|
||||||
base.Dispose(isDisposing);
|
|
||||||
|
|
||||||
if (EditorBeatmap != null)
|
|
||||||
{
|
|
||||||
EditorBeatmap.HitObjectAdded -= addHitObject;
|
|
||||||
EditorBeatmap.HitObjectRemoved -= removeHitObject;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Cached(typeof(HitObjectComposer))]
|
[Cached(typeof(HitObjectComposer))]
|
||||||
@ -344,12 +323,6 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
[CanBeNull]
|
[CanBeNull]
|
||||||
protected virtual DistanceSnapGrid CreateDistanceSnapGrid([NotNull] IEnumerable<HitObject> selectedHitObjects) => null;
|
protected virtual DistanceSnapGrid CreateDistanceSnapGrid([NotNull] IEnumerable<HitObject> selectedHitObjects) => null;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Updates a <see cref="HitObject"/>, invoking <see cref="HitObject.ApplyDefaults"/> and re-processing the beatmap.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="hitObject">The <see cref="HitObject"/> to update.</param>
|
|
||||||
public abstract void UpdateHitObject([CanBeNull] HitObject hitObject);
|
|
||||||
|
|
||||||
public abstract (Vector2 position, double time) GetSnappedPosition(Vector2 position, double time);
|
public abstract (Vector2 position, double time) GetSnappedPosition(Vector2 position, double time);
|
||||||
|
|
||||||
public abstract float GetBeatSnapDistanceAt(double referenceTime);
|
public abstract float GetBeatSnapDistanceAt(double referenceTime);
|
||||||
|
@ -108,11 +108,6 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
|
|
||||||
public bool IsSelected => State == SelectionState.Selected;
|
public bool IsSelected => State == SelectionState.Selected;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Updates the <see cref="Objects.HitObject"/>, invoking <see cref="Objects.HitObject.ApplyDefaults"/> and re-processing the beatmap.
|
|
||||||
/// </summary>
|
|
||||||
protected void UpdateHitObject() => composer?.UpdateHitObject(HitObject);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The <see cref="MenuItem"/>s to be displayed in the context menu for this <see cref="OverlaySelectionBlueprint"/>.
|
/// The <see cref="MenuItem"/>s to be displayed in the context menu for this <see cref="OverlaySelectionBlueprint"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -392,7 +392,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool ComputeIsMaskedAway(RectangleF maskingBounds) => AllJudged && base.ComputeIsMaskedAway(maskingBounds);
|
public override bool UpdateSubTreeMasking(Drawable source, RectangleF maskingBounds) => AllJudged && base.UpdateSubTreeMasking(source, maskingBounds);
|
||||||
|
|
||||||
protected override void UpdateAfterChildren()
|
protected override void UpdateAfterChildren()
|
||||||
{
|
{
|
||||||
|
@ -60,8 +60,8 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
waveform.Waveform = b.NewValue.Waveform;
|
waveform.Waveform = b.NewValue.Waveform;
|
||||||
track = b.NewValue.Track;
|
track = b.NewValue.Track;
|
||||||
|
|
||||||
MinZoom = getZoomLevelForVisibleMilliseconds(10000);
|
|
||||||
MaxZoom = getZoomLevelForVisibleMilliseconds(500);
|
MaxZoom = getZoomLevelForVisibleMilliseconds(500);
|
||||||
|
MinZoom = getZoomLevelForVisibleMilliseconds(10000);
|
||||||
Zoom = getZoomLevelForVisibleMilliseconds(2000);
|
Zoom = getZoomLevelForVisibleMilliseconds(2000);
|
||||||
}, true);
|
}, true);
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using JetBrains.Annotations;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
@ -29,9 +30,9 @@ namespace osu.Game.Screens.Edit
|
|||||||
public event Action<HitObject> HitObjectRemoved;
|
public event Action<HitObject> HitObjectRemoved;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Invoked when the start time of a <see cref="HitObject"/> in this <see cref="EditorBeatmap"/> was changed.
|
/// Invoked when a <see cref="HitObject"/> is updated.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public event Action<HitObject> StartTimeChanged;
|
public event Action<HitObject> HitObjectUpdated;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// All currently selected <see cref="HitObject"/>s.
|
/// All currently selected <see cref="HitObject"/>s.
|
||||||
@ -62,21 +63,39 @@ namespace osu.Game.Screens.Edit
|
|||||||
trackStartTime(obj);
|
trackStartTime(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private readonly HashSet<HitObject> pendingUpdates = new HashSet<HitObject>();
|
||||||
private ScheduledDelegate scheduledUpdate;
|
private ScheduledDelegate scheduledUpdate;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Updates a <see cref="HitObject"/>, invoking <see cref="HitObject.ApplyDefaults"/> and re-processing the beatmap.
|
/// Updates a <see cref="HitObject"/>, invoking <see cref="HitObject.ApplyDefaults"/> and re-processing the beatmap.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="hitObject">The <see cref="HitObject"/> to update.</param>
|
/// <param name="hitObject">The <see cref="HitObject"/> to update.</param>
|
||||||
public void UpdateHitObject(HitObject hitObject)
|
public void UpdateHitObject([NotNull] HitObject hitObject) => updateHitObject(hitObject, false);
|
||||||
|
|
||||||
|
private void updateHitObject([CanBeNull] HitObject hitObject, bool silent)
|
||||||
{
|
{
|
||||||
scheduledUpdate?.Cancel();
|
scheduledUpdate?.Cancel();
|
||||||
scheduledUpdate = Scheduler.AddDelayed(() =>
|
|
||||||
|
if (hitObject != null)
|
||||||
|
pendingUpdates.Add(hitObject);
|
||||||
|
|
||||||
|
scheduledUpdate = Schedule(() =>
|
||||||
{
|
{
|
||||||
beatmapProcessor?.PreProcess();
|
beatmapProcessor?.PreProcess();
|
||||||
hitObject?.ApplyDefaults(ControlPointInfo, BeatmapInfo.BaseDifficulty);
|
|
||||||
|
foreach (var obj in pendingUpdates)
|
||||||
|
obj.ApplyDefaults(ControlPointInfo, BeatmapInfo.BaseDifficulty);
|
||||||
|
|
||||||
beatmapProcessor?.PostProcess();
|
beatmapProcessor?.PostProcess();
|
||||||
}, 0);
|
|
||||||
|
if (!silent)
|
||||||
|
{
|
||||||
|
foreach (var obj in pendingUpdates)
|
||||||
|
HitObjectUpdated?.Invoke(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
pendingUpdates.Clear();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public BeatmapInfo BeatmapInfo
|
public BeatmapInfo BeatmapInfo
|
||||||
@ -114,6 +133,8 @@ namespace osu.Game.Screens.Edit
|
|||||||
mutableHitObjects.Insert(insertionIndex + 1, hitObject);
|
mutableHitObjects.Insert(insertionIndex + 1, hitObject);
|
||||||
|
|
||||||
HitObjectAdded?.Invoke(hitObject);
|
HitObjectAdded?.Invoke(hitObject);
|
||||||
|
|
||||||
|
updateHitObject(hitObject, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -132,6 +153,8 @@ namespace osu.Game.Screens.Edit
|
|||||||
|
|
||||||
startTimeBindables.Remove(hitObject);
|
startTimeBindables.Remove(hitObject);
|
||||||
HitObjectRemoved?.Invoke(hitObject);
|
HitObjectRemoved?.Invoke(hitObject);
|
||||||
|
|
||||||
|
updateHitObject(null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void trackStartTime(HitObject hitObject)
|
private void trackStartTime(HitObject hitObject)
|
||||||
@ -145,7 +168,7 @@ namespace osu.Game.Screens.Edit
|
|||||||
var insertionIndex = findInsertionIndex(PlayableBeatmap.HitObjects, hitObject.StartTime);
|
var insertionIndex = findInsertionIndex(PlayableBeatmap.HitObjects, hitObject.StartTime);
|
||||||
mutableHitObjects.Insert(insertionIndex + 1, hitObject);
|
mutableHitObjects.Insert(insertionIndex + 1, hitObject);
|
||||||
|
|
||||||
StartTimeChanged?.Invoke(hitObject);
|
UpdateHitObject(hitObject);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||||
<PackageReference Include="ppy.osu.Framework" Version="2020.407.1" />
|
<PackageReference Include="ppy.osu.Framework" Version="2020.411.0" />
|
||||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.403.0" />
|
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.403.0" />
|
||||||
<PackageReference Include="Sentry" Version="2.1.1" />
|
<PackageReference Include="Sentry" Version="2.1.1" />
|
||||||
<PackageReference Include="SharpCompress" Version="0.25.0" />
|
<PackageReference Include="SharpCompress" Version="0.25.0" />
|
||||||
|
@ -70,7 +70,7 @@
|
|||||||
<Reference Include="System.Net.Http" />
|
<Reference Include="System.Net.Http" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup Label="Package References">
|
<ItemGroup Label="Package References">
|
||||||
<PackageReference Include="ppy.osu.Framework.iOS" Version="2020.407.1" />
|
<PackageReference Include="ppy.osu.Framework.iOS" Version="2020.411.0" />
|
||||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.403.0" />
|
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.403.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<!-- Xamarin.iOS does not automatically handle transitive dependencies from NuGet packages. -->
|
<!-- Xamarin.iOS does not automatically handle transitive dependencies from NuGet packages. -->
|
||||||
@ -79,7 +79,7 @@
|
|||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||||
<PackageReference Include="ppy.osu.Framework" Version="2020.407.1" />
|
<PackageReference Include="ppy.osu.Framework" Version="2020.411.0" />
|
||||||
<PackageReference Include="SharpCompress" Version="0.25.0" />
|
<PackageReference Include="SharpCompress" Version="0.25.0" />
|
||||||
<PackageReference Include="NUnit" Version="3.12.0" />
|
<PackageReference Include="NUnit" Version="3.12.0" />
|
||||||
<PackageReference Include="SharpRaven" Version="2.4.0" />
|
<PackageReference Include="SharpRaven" Version="2.4.0" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user