1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 20:47:28 +08:00

Merge branch 'master' into fix-editor-tap-timing-crash

This commit is contained in:
Bartłomiej Dach 2022-11-23 17:51:50 +01:00 committed by GitHub
commit 60422be9af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 73 additions and 13 deletions

View File

@ -35,6 +35,8 @@ namespace osu.Game.Rulesets.Catch.UI
private void load(CatchInputManager catchInputManager, OsuColour colours)
{
const float width = 0.15f;
// Ratio between normal move area height and total input height
const float normal_area_height_ratio = 0.45f;
keyBindingContainer = catchInputManager.KeyBindingContainer;
@ -54,18 +56,18 @@ namespace osu.Game.Rulesets.Catch.UI
Width = width,
Children = new Drawable[]
{
leftDashBox = new InputArea(TouchCatchAction.DashLeft, trackedActionSources)
{
RelativeSizeAxes = Axes.Both,
Width = 0.5f,
},
leftBox = new InputArea(TouchCatchAction.MoveLeft, trackedActionSources)
{
RelativeSizeAxes = Axes.Both,
Width = 0.5f,
Height = normal_area_height_ratio,
Colour = colours.Gray9,
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight,
},
leftDashBox = new InputArea(TouchCatchAction.DashLeft, trackedActionSources)
{
RelativeSizeAxes = Axes.Both,
Height = 1 - normal_area_height_ratio,
},
}
},
@ -80,15 +82,15 @@ namespace osu.Game.Rulesets.Catch.UI
rightBox = new InputArea(TouchCatchAction.MoveRight, trackedActionSources)
{
RelativeSizeAxes = Axes.Both,
Width = 0.5f,
Height = normal_area_height_ratio,
Colour = colours.Gray9,
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight,
},
rightDashBox = new InputArea(TouchCatchAction.DashRight, trackedActionSources)
{
RelativeSizeAxes = Axes.Both,
Width = 0.5f,
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
Height = 1 - normal_area_height_ratio,
},
}
},

View File

@ -83,5 +83,41 @@ namespace osu.Game.Rulesets.Taiko.Tests
AddAssert("first barline ommited", () => barlines.All(b => b.StartTime != start_time));
AddAssert("second barline generated", () => barlines.Any(b => b.StartTime == start_time + (beat_length * time_signature_numerator)));
}
[Test]
public void TestNegativeStartTimeTimingPoint()
{
const double beat_length = 250;
const int time_signature_numerator = 4;
var beatmap = new Beatmap<TaikoHitObject>
{
HitObjects =
{
new Hit
{
Type = HitType.Centre,
StartTime = 1000
}
},
BeatmapInfo =
{
Difficulty = new BeatmapDifficulty { SliderTickRate = 4 },
Ruleset = new TaikoRuleset().RulesetInfo
},
};
beatmap.ControlPointInfo.Add(-100, new TimingControlPoint
{
BeatLength = beat_length,
TimeSignature = new TimeSignature(time_signature_numerator)
});
var barlines = new BarLineGenerator<BarLine>(beatmap).BarLines;
AddAssert("bar line generated at t=900", () => barlines.Any(line => line.StartTime == 900));
AddAssert("bar line generated at t=1900", () => barlines.Any(line => line.StartTime == 1900));
}
}
}

View File

@ -27,7 +27,10 @@ namespace osu.Game.Rulesets.Objects
if (beatmap.HitObjects.Count == 0)
return;
HitObject firstObject = beatmap.HitObjects.First();
HitObject lastObject = beatmap.HitObjects.Last();
double firstHitTime = firstObject.StartTime;
double lastHitTime = 1 + lastObject.GetEndTime();
var timingPoints = beatmap.ControlPointInfo.TimingPoints;
@ -41,12 +44,31 @@ namespace osu.Game.Rulesets.Objects
EffectControlPoint currentEffectPoint = beatmap.ControlPointInfo.EffectPointAt(currentTimingPoint.Time);
int currentBeat = 0;
// Don't generate barlines before the hit object or t=0 (whichever is earliest). Some beatmaps use very unrealistic values here (although none are ranked).
// I'm not sure we ever want barlines to appear before the first hitobject, but let's keep some degree of compatibility for now.
// Of note, this will still differ from stable if the first timing control point is t<0 and is not near the first hitobject.
double generationStartTime = Math.Min(0, firstHitTime);
// Stop on the next timing point, or if there is no next timing point stop slightly past the last object
double endTime = i < timingPoints.Count - 1 ? timingPoints[i + 1].Time : lastHitTime + currentTimingPoint.BeatLength * currentTimingPoint.TimeSignature.Numerator;
double startTime = currentTimingPoint.Time;
double barLength = currentTimingPoint.BeatLength * currentTimingPoint.TimeSignature.Numerator;
double startTime;
if (currentTimingPoint.Time > generationStartTime)
{
startTime = currentTimingPoint.Time;
}
else
{
// If the timing point starts before the minimum allowable time for bar lines,
// we still need to compute a start time for generation that is actually properly aligned with the timing point.
int barCount = (int)Math.Ceiling((generationStartTime - currentTimingPoint.Time) / barLength);
startTime = currentTimingPoint.Time + barCount * barLength;
}
if (currentEffectPoint.OmitFirstBarLine)
{
startTime += barLength;