1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 04:43:22 +08:00

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

@ -84,5 +84,7 @@ namespace osu.Game.Rulesets.Osu.UI
judgementLayer.Add(explosion);
}
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => HitObjectContainer.ReceivePositionalInputAt(screenSpacePos);
}
}

View File

@ -23,7 +23,7 @@ namespace osu.Game.Rulesets.Edit
{
public abstract class HitObjectComposer : CompositeDrawable
{
public IEnumerable<DrawableHitObject> HitObjects => rulesetContainer.Playfield.AllHitObjects;
public IEnumerable<DrawableHitObject> HitObjects => RulesetContainer.Playfield.AllHitObjects;
protected readonly Ruleset Ruleset;
@ -33,7 +33,7 @@ namespace osu.Game.Rulesets.Edit
private readonly List<Container> layerContainers = new List<Container>();
private EditRulesetContainer rulesetContainer;
public EditRulesetContainer RulesetContainer { get; private set; }
private BlueprintContainer blueprintContainer;
@ -51,8 +51,8 @@ namespace osu.Game.Rulesets.Edit
try
{
rulesetContainer = CreateRulesetContainer();
rulesetContainer.Clock = framedClock;
RulesetContainer = CreateRulesetContainer();
RulesetContainer.Clock = framedClock;
}
catch (Exception e)
{
@ -94,7 +94,7 @@ namespace osu.Game.Rulesets.Edit
Children = new Drawable[]
{
layerBelowRuleset,
rulesetContainer,
RulesetContainer,
layerAboveRuleset
}
}
@ -130,10 +130,10 @@ namespace osu.Game.Rulesets.Edit
layerContainers.ForEach(l =>
{
l.Anchor = rulesetContainer.Playfield.Anchor;
l.Origin = rulesetContainer.Playfield.Origin;
l.Position = rulesetContainer.Playfield.Position;
l.Size = rulesetContainer.Playfield.Size;
l.Anchor = RulesetContainer.Playfield.Anchor;
l.Origin = RulesetContainer.Playfield.Origin;
l.Position = RulesetContainer.Playfield.Position;
l.Size = RulesetContainer.Playfield.Size;
});
}
@ -141,9 +141,9 @@ namespace osu.Game.Rulesets.Edit
/// Adds a <see cref="HitObject"/> to the <see cref="Beatmaps.Beatmap"/> and visualises it.
/// </summary>
/// <param name="hitObject">The <see cref="HitObject"/> to add.</param>
public void Add(HitObject hitObject) => blueprintContainer.AddBlueprintFor(rulesetContainer.Add(hitObject));
public void Add(HitObject hitObject) => blueprintContainer.AddBlueprintFor(RulesetContainer.Add(hitObject));
public void Remove(HitObject hitObject) => blueprintContainer.RemoveBlueprintFor(rulesetContainer.Remove(hitObject));
public void Remove(HitObject hitObject) => blueprintContainer.RemoveBlueprintFor(RulesetContainer.Remove(hitObject));
internal abstract EditRulesetContainer CreateRulesetContainer();

View File

@ -37,6 +37,8 @@ namespace osu.Game.Rulesets.Edit
HitObject = hitObject;
RelativeSizeAxes = Axes.Both;
Alpha = 0;
}
[BackgroundDependencyLoader]
@ -49,7 +51,7 @@ namespace osu.Game.Rulesets.Edit
ApplyDefaultsToHitObject();
}
private bool placementBegun;
public bool PlacementBegun { get; private set; }
/// <summary>
/// Signals that the placement of <see cref="HitObject"/> has started.
@ -57,7 +59,7 @@ namespace osu.Game.Rulesets.Edit
protected void BeginPlacement()
{
placementHandler.BeginPlacement(HitObject);
placementBegun = true;
PlacementBegun = true;
}
/// <summary>
@ -66,7 +68,7 @@ namespace osu.Game.Rulesets.Edit
/// </summary>
protected void EndPlacement()
{
if (!placementBegun)
if (!PlacementBegun)
BeginPlacement();
placementHandler.EndPlacement(HitObject);
}

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;
}