mirror of
https://github.com/ppy/osu.git
synced 2025-01-07 22:22:59 +08:00
Hide placement when cursor is not in the playfield
This commit is contained in:
parent
302196e985
commit
fbc20d2d4d
@ -84,5 +84,7 @@ namespace osu.Game.Rulesets.Osu.UI
|
|||||||
|
|
||||||
judgementLayer.Add(explosion);
|
judgementLayer.Add(explosion);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => HitObjectContainer.ReceivePositionalInputAt(screenSpacePos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
{
|
{
|
||||||
public abstract class HitObjectComposer : CompositeDrawable
|
public abstract class HitObjectComposer : CompositeDrawable
|
||||||
{
|
{
|
||||||
public IEnumerable<DrawableHitObject> HitObjects => rulesetContainer.Playfield.AllHitObjects;
|
public IEnumerable<DrawableHitObject> HitObjects => RulesetContainer.Playfield.AllHitObjects;
|
||||||
|
|
||||||
protected readonly Ruleset Ruleset;
|
protected readonly Ruleset Ruleset;
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
|
|
||||||
private readonly List<Container> layerContainers = new List<Container>();
|
private readonly List<Container> layerContainers = new List<Container>();
|
||||||
|
|
||||||
private EditRulesetContainer rulesetContainer;
|
public EditRulesetContainer RulesetContainer { get; private set; }
|
||||||
|
|
||||||
private BlueprintContainer blueprintContainer;
|
private BlueprintContainer blueprintContainer;
|
||||||
|
|
||||||
@ -51,8 +51,8 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
rulesetContainer = CreateRulesetContainer();
|
RulesetContainer = CreateRulesetContainer();
|
||||||
rulesetContainer.Clock = framedClock;
|
RulesetContainer.Clock = framedClock;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@ -94,7 +94,7 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
layerBelowRuleset,
|
layerBelowRuleset,
|
||||||
rulesetContainer,
|
RulesetContainer,
|
||||||
layerAboveRuleset
|
layerAboveRuleset
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -130,10 +130,10 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
|
|
||||||
layerContainers.ForEach(l =>
|
layerContainers.ForEach(l =>
|
||||||
{
|
{
|
||||||
l.Anchor = rulesetContainer.Playfield.Anchor;
|
l.Anchor = RulesetContainer.Playfield.Anchor;
|
||||||
l.Origin = rulesetContainer.Playfield.Origin;
|
l.Origin = RulesetContainer.Playfield.Origin;
|
||||||
l.Position = rulesetContainer.Playfield.Position;
|
l.Position = RulesetContainer.Playfield.Position;
|
||||||
l.Size = rulesetContainer.Playfield.Size;
|
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.
|
/// Adds a <see cref="HitObject"/> to the <see cref="Beatmaps.Beatmap"/> and visualises it.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="hitObject">The <see cref="HitObject"/> to add.</param>
|
/// <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();
|
internal abstract EditRulesetContainer CreateRulesetContainer();
|
||||||
|
|
||||||
|
@ -37,6 +37,8 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
HitObject = hitObject;
|
HitObject = hitObject;
|
||||||
|
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
|
||||||
|
Alpha = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -49,7 +51,7 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
ApplyDefaultsToHitObject();
|
ApplyDefaultsToHitObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool placementBegun;
|
public bool PlacementBegun { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Signals that the placement of <see cref="HitObject"/> has started.
|
/// Signals that the placement of <see cref="HitObject"/> has started.
|
||||||
@ -57,7 +59,7 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
protected void BeginPlacement()
|
protected void BeginPlacement()
|
||||||
{
|
{
|
||||||
placementHandler.BeginPlacement(HitObject);
|
placementHandler.BeginPlacement(HitObject);
|
||||||
placementBegun = true;
|
PlacementBegun = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -66,7 +68,7 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
protected void EndPlacement()
|
protected void EndPlacement()
|
||||||
{
|
{
|
||||||
if (!placementBegun)
|
if (!PlacementBegun)
|
||||||
BeginPlacement();
|
BeginPlacement();
|
||||||
placementHandler.EndPlacement(HitObject);
|
placementHandler.EndPlacement(HitObject);
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Primitives;
|
using osu.Framework.Graphics.Primitives;
|
||||||
|
using osu.Framework.Input;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Framework.Input.States;
|
using osu.Framework.Input.States;
|
||||||
using osu.Game.Rulesets.Edit;
|
using osu.Game.Rulesets.Edit;
|
||||||
@ -18,7 +19,10 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
public class BlueprintContainer : CompositeDrawable
|
public class BlueprintContainer : CompositeDrawable
|
||||||
{
|
{
|
||||||
private SelectionBlueprintContainer selectionBlueprints;
|
private SelectionBlueprintContainer selectionBlueprints;
|
||||||
|
|
||||||
private Container<PlacementBlueprint> placementBlueprintContainer;
|
private Container<PlacementBlueprint> placementBlueprintContainer;
|
||||||
|
private PlacementBlueprint currentPlacement;
|
||||||
|
|
||||||
private SelectionBox selectionBox;
|
private SelectionBox selectionBox;
|
||||||
|
|
||||||
private IEnumerable<SelectionBlueprint> selections => selectionBlueprints.Children.Where(c => c.IsAlive);
|
private IEnumerable<SelectionBlueprint> selections => selectionBlueprints.Children.Where(c => c.IsAlive);
|
||||||
@ -26,6 +30,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private HitObjectComposer composer { get; set; }
|
private HitObjectComposer composer { get; set; }
|
||||||
|
|
||||||
|
private InputManager inputManager;
|
||||||
|
|
||||||
public BlueprintContainer()
|
public BlueprintContainer()
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
@ -53,6 +59,13 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
AddBlueprintFor(obj);
|
AddBlueprintFor(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
inputManager = GetContainingInputManager();
|
||||||
|
}
|
||||||
|
|
||||||
private HitObjectCompositionTool currentTool;
|
private HitObjectCompositionTool currentTool;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -117,16 +130,27 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
return true;
|
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>
|
/// <summary>
|
||||||
/// Refreshes the current placement tool.
|
/// Refreshes the current placement tool.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void refreshTool()
|
private void refreshTool()
|
||||||
{
|
{
|
||||||
placementBlueprintContainer.Clear();
|
placementBlueprintContainer.Clear();
|
||||||
|
currentPlacement = null;
|
||||||
|
|
||||||
var blueprint = CurrentTool?.CreatePlacementBlueprint();
|
var blueprint = CurrentTool?.CreatePlacementBlueprint();
|
||||||
if (blueprint != null)
|
if (blueprint != null)
|
||||||
placementBlueprintContainer.Child = blueprint;
|
placementBlueprintContainer.Child = currentPlacement = blueprint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user