mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 15:12:57 +08:00
Standardise placement blueprint creation and destruction
This commit is contained in:
parent
b65e839bd2
commit
2b6f99d404
@ -62,19 +62,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void refreshTool()
|
private void refreshTool()
|
||||||
{
|
{
|
||||||
placementBlueprintContainer.Clear();
|
|
||||||
|
|
||||||
removePlacement();
|
removePlacement();
|
||||||
|
createPlacement();
|
||||||
var blueprint = CurrentTool?.CreatePlacementBlueprint();
|
|
||||||
|
|
||||||
if (blueprint != null)
|
|
||||||
{
|
|
||||||
placementBlueprintContainer.Child = currentPlacement = blueprint;
|
|
||||||
|
|
||||||
// Fixes a 1-frame position discrepancy due to the first mouse move event happening in the next frame
|
|
||||||
updatePlacementPosition(inputManager.CurrentState.Mouse.Position);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updatePlacementPosition(Vector2 screenSpacePosition)
|
private void updatePlacementPosition(Vector2 screenSpacePosition)
|
||||||
@ -102,7 +91,9 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
if (currentPlacement?.PlacementActive == false && !composer.CursorInPlacementArea)
|
if (composer.CursorInPlacementArea)
|
||||||
|
createPlacement();
|
||||||
|
else if (currentPlacement?.PlacementActive == false)
|
||||||
removePlacement();
|
removePlacement();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,11 +115,27 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
base.AddBlueprintFor(hitObject);
|
base.AddBlueprintFor(hitObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void createPlacement()
|
||||||
|
{
|
||||||
|
if (currentPlacement != null) return;
|
||||||
|
|
||||||
|
var blueprint = CurrentTool?.CreatePlacementBlueprint();
|
||||||
|
|
||||||
|
if (blueprint != null)
|
||||||
|
{
|
||||||
|
placementBlueprintContainer.Child = currentPlacement = blueprint;
|
||||||
|
|
||||||
|
// Fixes a 1-frame position discrepancy due to the first mouse move event happening in the next frame
|
||||||
|
updatePlacementPosition(inputManager.CurrentState.Mouse.Position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void removePlacement()
|
private void removePlacement()
|
||||||
{
|
{
|
||||||
if (currentPlacement == null) return;
|
if (currentPlacement == null) return;
|
||||||
|
|
||||||
currentPlacement.EndPlacement(false);
|
currentPlacement.EndPlacement(false);
|
||||||
|
currentPlacement.Expire();
|
||||||
currentPlacement = null;
|
currentPlacement = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user