mirror of
https://github.com/osukey/osukey.git
synced 2025-05-01 11:47:18 +09:00
Merge pull request #23509 from peppy/editor-slider-placement-tool-change
Force placement of in-progress object when changing tools in the editor
This commit is contained in:
commit
265096bed7
@ -79,5 +79,28 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
AddAssert("no active placement", () => this.ChildrenOfType<ComposeBlueprintContainer>().Single().CurrentPlacement.PlacementActive,
|
AddAssert("no active placement", () => this.ChildrenOfType<ComposeBlueprintContainer>().Single().CurrentPlacement.PlacementActive,
|
||||||
() => Is.EqualTo(PlacementBlueprint.PlacementState.Waiting));
|
() => Is.EqualTo(PlacementBlueprint.PlacementState.Waiting));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestCommitPlacementViaToolChange()
|
||||||
|
{
|
||||||
|
Playfield playfield = null!;
|
||||||
|
|
||||||
|
AddStep("select slider placement tool", () => InputManager.Key(Key.Number3));
|
||||||
|
AddStep("move mouse to top left of playfield", () =>
|
||||||
|
{
|
||||||
|
playfield = this.ChildrenOfType<Playfield>().Single();
|
||||||
|
var location = (3 * playfield.ScreenSpaceDrawQuad.TopLeft + playfield.ScreenSpaceDrawQuad.BottomRight) / 4;
|
||||||
|
InputManager.MoveMouseTo(location);
|
||||||
|
});
|
||||||
|
AddStep("begin placement", () => InputManager.Click(MouseButton.Left));
|
||||||
|
AddStep("move mouse to bottom right of playfield", () =>
|
||||||
|
{
|
||||||
|
var location = (playfield.ScreenSpaceDrawQuad.TopLeft + 3 * playfield.ScreenSpaceDrawQuad.BottomRight) / 4;
|
||||||
|
InputManager.MoveMouseTo(location);
|
||||||
|
});
|
||||||
|
|
||||||
|
AddStep("change tool to circle", () => InputManager.Key(Key.Number2));
|
||||||
|
AddAssert("slider placed", () => EditorBeatmap.HitObjects.Count, () => Is.EqualTo(1));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -317,12 +317,16 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void commitIfPlacementActive()
|
||||||
|
{
|
||||||
|
CurrentPlacement?.EndPlacement(CurrentPlacement.PlacementActive == PlacementBlueprint.PlacementState.Active);
|
||||||
|
removePlacement();
|
||||||
|
}
|
||||||
|
|
||||||
private void removePlacement()
|
private void removePlacement()
|
||||||
{
|
{
|
||||||
if (CurrentPlacement == null) return;
|
CurrentPlacement?.EndPlacement(false);
|
||||||
|
CurrentPlacement?.Expire();
|
||||||
CurrentPlacement.EndPlacement(false);
|
|
||||||
CurrentPlacement.Expire();
|
|
||||||
CurrentPlacement = null;
|
CurrentPlacement = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,7 +346,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
|
|
||||||
currentTool = value;
|
currentTool = value;
|
||||||
|
|
||||||
refreshTool();
|
// As per stable editor, when changing tools, we should forcefully commit any pending placement.
|
||||||
|
commitIfPlacementActive();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user