Merge pull request #18158 from ekrctb/fix-banana-shower-placement-negative-duration

Fix duration is negative while placing banana shower in catch editor
This commit is contained in:
Dan Balasescu
2022-05-09 11:26:06 +09:00
committed by GitHub
2 changed files with 12 additions and 9 deletions

View File

@ -55,7 +55,10 @@ namespace osu.Game.Rulesets.Catch.Tests.Editor
AddMoveStep(end_time, 0); AddMoveStep(end_time, 0);
AddClickStep(MouseButton.Left); AddClickStep(MouseButton.Left);
AddMoveStep(start_time, 0); AddMoveStep(start_time, 0);
AddAssert("duration is positive", () => ((BananaShower)CurrentBlueprint.HitObject).Duration > 0);
AddClickStep(MouseButton.Right); AddClickStep(MouseButton.Right);
AddAssert("start time is correct", () => Precision.AlmostEquals(LastObject.HitObject.StartTime, start_time)); AddAssert("start time is correct", () => Precision.AlmostEquals(LastObject.HitObject.StartTime, start_time));
AddAssert("end time is correct", () => Precision.AlmostEquals(LastObject.HitObject.GetEndTime(), end_time)); AddAssert("end time is correct", () => Precision.AlmostEquals(LastObject.HitObject.GetEndTime(), end_time));

View File

@ -1,6 +1,7 @@
// 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.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Game.Rulesets.Catch.Edit.Blueprints.Components; using osu.Game.Rulesets.Catch.Edit.Blueprints.Components;
using osu.Game.Rulesets.Catch.Objects; using osu.Game.Rulesets.Catch.Objects;
@ -13,6 +14,9 @@ namespace osu.Game.Rulesets.Catch.Edit.Blueprints
{ {
private readonly TimeSpanOutline outline; private readonly TimeSpanOutline outline;
private double placementStartTime;
private double placementEndTime;
public BananaShowerPlacementBlueprint() public BananaShowerPlacementBlueprint()
{ {
InternalChild = outline = new TimeSpanOutline(); InternalChild = outline = new TimeSpanOutline();
@ -45,13 +49,6 @@ namespace osu.Game.Rulesets.Catch.Edit.Blueprints
case PlacementState.Active: case PlacementState.Active:
if (e.Button != MouseButton.Right) break; if (e.Button != MouseButton.Right) break;
// If the duration is negative, swap the start and the end time to make the duration positive.
if (HitObject.Duration < 0)
{
HitObject.StartTime = HitObject.EndTime;
HitObject.Duration = -HitObject.Duration;
}
EndPlacement(HitObject.Duration > 0); EndPlacement(HitObject.Duration > 0);
return true; return true;
} }
@ -68,13 +65,16 @@ namespace osu.Game.Rulesets.Catch.Edit.Blueprints
switch (PlacementActive) switch (PlacementActive)
{ {
case PlacementState.Waiting: case PlacementState.Waiting:
HitObject.StartTime = time; placementStartTime = placementEndTime = time;
break; break;
case PlacementState.Active: case PlacementState.Active:
HitObject.EndTime = time; placementEndTime = time;
break; break;
} }
HitObject.StartTime = Math.Min(placementStartTime, placementEndTime);
HitObject.EndTime = Math.Max(placementStartTime, placementEndTime);
} }
} }
} }