mirror of
https://github.com/ppy/osu.git
synced 2025-02-21 03:02:54 +08:00
Make show/hide only invoked once each
This commit is contained in:
parent
819cba31ce
commit
6d43baf4bf
@ -1,6 +1,8 @@
|
|||||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using osu.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Configuration;
|
using osu.Framework.Configuration;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
@ -18,8 +20,18 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// A blueprint which governs the creation of a new <see cref="HitObject"/> to actualisation.
|
/// A blueprint which governs the creation of a new <see cref="HitObject"/> to actualisation.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class PlacementBlueprint : CompositeDrawable, IRequireHighFrequencyMousePosition
|
public abstract class PlacementBlueprint : CompositeDrawable, IStateful<PlacementState>, IRequireHighFrequencyMousePosition
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Invoked when <see cref="State"/> has changed.
|
||||||
|
/// </summary>
|
||||||
|
public event Action<PlacementState> StateChanged;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether the <see cref="HitObject"/> is currently being placed, but has not necessarily finished being placed.
|
||||||
|
/// </summary>
|
||||||
|
public bool PlacementBegun { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The <see cref="HitObject"/> that is being placed.
|
/// The <see cref="HitObject"/> that is being placed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -51,7 +63,25 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
ApplyDefaultsToHitObject();
|
ApplyDefaultsToHitObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool PlacementBegun { get; private set; }
|
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>
|
/// <summary>
|
||||||
/// Signals that the placement of <see cref="HitObject"/> has started.
|
/// Signals that the placement of <see cref="HitObject"/> has started.
|
||||||
@ -95,4 +125,10 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum PlacementState
|
||||||
|
{
|
||||||
|
Hidden,
|
||||||
|
Shown,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -134,10 +134,15 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
if (composer.RulesetContainer.Playfield.ReceivePositionalInputAt(inputManager.CurrentState.Mouse.Position))
|
if (currentPlacement != null)
|
||||||
currentPlacement?.Show();
|
{
|
||||||
|
bool cursorInPlayfield = composer.RulesetContainer.Playfield.ReceivePositionalInputAt(inputManager.CurrentState.Mouse.Position);
|
||||||
|
|
||||||
|
if (cursorInPlayfield)
|
||||||
|
currentPlacement.State = PlacementState.Shown;
|
||||||
else if (currentPlacement?.PlacementBegun == false)
|
else if (currentPlacement?.PlacementBegun == false)
|
||||||
currentPlacement?.Hide();
|
currentPlacement.State = PlacementState.Hidden;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -153,7 +158,6 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
placementBlueprintContainer.Child = currentPlacement = blueprint;
|
placementBlueprintContainer.Child = currentPlacement = blueprint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Select all masks in a given rectangle selection area.
|
/// Select all masks in a given rectangle selection area.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user