Hide placement when cursor is not in the playfield

This commit is contained in:
smoogipoo
2018-11-13 12:52:04 +09:00
parent 302196e985
commit fbc20d2d4d
4 changed files with 43 additions and 15 deletions

View File

@ -7,6 +7,7 @@ using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Input;
using osu.Framework.Input.Events;
using osu.Framework.Input.States;
using osu.Game.Rulesets.Edit;
@ -18,7 +19,10 @@ namespace osu.Game.Screens.Edit.Compose.Components
public class BlueprintContainer : CompositeDrawable
{
private SelectionBlueprintContainer selectionBlueprints;
private Container<PlacementBlueprint> placementBlueprintContainer;
private PlacementBlueprint currentPlacement;
private SelectionBox selectionBox;
private IEnumerable<SelectionBlueprint> selections => selectionBlueprints.Children.Where(c => c.IsAlive);
@ -26,6 +30,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
[Resolved]
private HitObjectComposer composer { get; set; }
private InputManager inputManager;
public BlueprintContainer()
{
RelativeSizeAxes = Axes.Both;
@ -53,6 +59,13 @@ namespace osu.Game.Screens.Edit.Compose.Components
AddBlueprintFor(obj);
}
protected override void LoadComplete()
{
base.LoadComplete();
inputManager = GetContainingInputManager();
}
private HitObjectCompositionTool currentTool;
/// <summary>
@ -117,16 +130,27 @@ namespace osu.Game.Screens.Edit.Compose.Components
return true;
}
protected override void Update()
{
base.Update();
if (composer.RulesetContainer.Playfield.ReceivePositionalInputAt(inputManager.CurrentState.Mouse.Position))
currentPlacement?.Show();
else if (currentPlacement?.PlacementBegun == false)
currentPlacement?.Hide();
}
/// <summary>
/// Refreshes the current placement tool.
/// </summary>
private void refreshTool()
{
placementBlueprintContainer.Clear();
currentPlacement = null;
var blueprint = CurrentTool?.CreatePlacementBlueprint();
if (blueprint != null)
placementBlueprintContainer.Child = blueprint;
placementBlueprintContainer.Child = currentPlacement = blueprint;
}