mirror of
https://github.com/ppy/osu
synced 2025-01-02 04:12:13 +00:00
Simplify blueprints by removing visible state
This commit is contained in:
parent
0fe41fd50a
commit
b65e839bd2
@ -1,8 +1,6 @@
|
||||
// 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 osu.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
@ -20,13 +18,8 @@ namespace osu.Game.Rulesets.Edit
|
||||
/// <summary>
|
||||
/// A blueprint which governs the creation of a new <see cref="HitObject"/> to actualisation.
|
||||
/// </summary>
|
||||
public abstract class PlacementBlueprint : CompositeDrawable, IStateful<PlacementState>
|
||||
public abstract class PlacementBlueprint : CompositeDrawable
|
||||
{
|
||||
/// <summary>
|
||||
/// Invoked when <see cref="State"/> has changed.
|
||||
/// </summary>
|
||||
public event Action<PlacementState> StateChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Whether the <see cref="HitObject"/> is currently mid-placement, but has not necessarily finished being placed.
|
||||
/// </summary>
|
||||
@ -53,8 +46,6 @@ namespace osu.Game.Rulesets.Edit
|
||||
// This is required to allow the blueprint's position to be updated via OnMouseMove/Handle
|
||||
// on the same frame it is made visible via a PlacementState change.
|
||||
AlwaysPresent = true;
|
||||
|
||||
Alpha = 0;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -67,27 +58,6 @@ namespace osu.Game.Rulesets.Edit
|
||||
ApplyDefaultsToHitObject();
|
||||
}
|
||||
|
||||
private PlacementState state;
|
||||
|
||||
public PlacementState State
|
||||
{
|
||||
get => state;
|
||||
set
|
||||
{
|
||||
if (state == value)
|
||||
return;
|
||||
|
||||
state = value;
|
||||
|
||||
if (state == PlacementState.Shown)
|
||||
Show();
|
||||
else
|
||||
Hide();
|
||||
|
||||
StateChanged?.Invoke(value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Signals that the placement of <see cref="HitObject"/> has started.
|
||||
/// </summary>
|
||||
@ -144,10 +114,4 @@ namespace osu.Game.Rulesets.Edit
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum PlacementState
|
||||
{
|
||||
Hidden,
|
||||
Shown,
|
||||
}
|
||||
}
|
||||
|
@ -64,8 +64,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
{
|
||||
placementBlueprintContainer.Clear();
|
||||
|
||||
currentPlacement?.EndPlacement(false);
|
||||
currentPlacement = null;
|
||||
removePlacement();
|
||||
|
||||
var blueprint = CurrentTool?.CreatePlacementBlueprint();
|
||||
|
||||
@ -103,18 +102,14 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
{
|
||||
base.Update();
|
||||
|
||||
if (currentPlacement != null)
|
||||
{
|
||||
if (composer.CursorInPlacementArea)
|
||||
currentPlacement.State = PlacementState.Shown;
|
||||
else if (currentPlacement?.PlacementActive == false)
|
||||
currentPlacement.State = PlacementState.Hidden;
|
||||
}
|
||||
if (currentPlacement?.PlacementActive == false && !composer.CursorInPlacementArea)
|
||||
removePlacement();
|
||||
}
|
||||
|
||||
protected sealed override SelectionBlueprint CreateBlueprintFor(HitObject hitObject)
|
||||
{
|
||||
var drawable = drawableHitObjects.FirstOrDefault(d => d.HitObject == hitObject);
|
||||
|
||||
if (drawable == null)
|
||||
return null;
|
||||
|
||||
@ -129,6 +124,14 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
base.AddBlueprintFor(hitObject);
|
||||
}
|
||||
|
||||
private void removePlacement()
|
||||
{
|
||||
if (currentPlacement == null) return;
|
||||
|
||||
currentPlacement.EndPlacement(false);
|
||||
currentPlacement = null;
|
||||
}
|
||||
|
||||
private HitObjectCompositionTool currentTool;
|
||||
|
||||
/// <summary>
|
||||
@ -137,6 +140,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
public HitObjectCompositionTool CurrentTool
|
||||
{
|
||||
get => currentTool;
|
||||
|
||||
set
|
||||
{
|
||||
if (currentTool == value)
|
||||
|
Loading…
Reference in New Issue
Block a user