mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 06:42:54 +08:00
Merge branch 'master' into hold-for-menu-back
This commit is contained in:
commit
81a3170e3b
@ -37,6 +37,8 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Spinners
|
||||
|
||||
isPlacingEnd = true;
|
||||
piece.FadeTo(1f, 150, Easing.OutQuint);
|
||||
|
||||
BeginPlacement();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -84,5 +84,7 @@ namespace osu.Game.Rulesets.Osu.UI
|
||||
|
||||
judgementLayer.Add(explosion);
|
||||
}
|
||||
|
||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => HitObjectContainer.ReceivePositionalInputAt(screenSpacePos);
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Beatmaps;
|
||||
@ -37,6 +38,8 @@ namespace osu.Game.Rulesets.Edit
|
||||
|
||||
private BlueprintContainer blueprintContainer;
|
||||
|
||||
private InputManager inputManager;
|
||||
|
||||
internal HitObjectComposer(Ruleset ruleset)
|
||||
{
|
||||
Ruleset = ruleset;
|
||||
@ -114,6 +117,13 @@ namespace osu.Game.Rulesets.Edit
|
||||
toolboxCollection.Items[0].Select();
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
inputManager = GetContainingInputManager();
|
||||
}
|
||||
|
||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||
{
|
||||
var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
||||
@ -137,6 +147,11 @@ namespace osu.Game.Rulesets.Edit
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether the user's cursor is currently in an area of the <see cref="HitObjectComposer"/> that is valid for placement.
|
||||
/// </summary>
|
||||
public virtual bool CursorInPlacementArea => rulesetContainer.Playfield.ReceivePositionalInputAt(inputManager.CurrentState.Mouse.Position);
|
||||
|
||||
/// <summary>
|
||||
/// Adds a <see cref="HitObject"/> to the <see cref="Beatmaps.Beatmap"/> and visualises it.
|
||||
/// </summary>
|
||||
|
@ -1,6 +1,8 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// 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.Configuration;
|
||||
using osu.Framework.Graphics;
|
||||
@ -18,8 +20,18 @@ 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, 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>
|
||||
/// The <see cref="HitObject"/> that is being placed.
|
||||
/// </summary>
|
||||
@ -37,6 +49,8 @@ namespace osu.Game.Rulesets.Edit
|
||||
HitObject = hitObject;
|
||||
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
Alpha = 0;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -49,7 +63,25 @@ namespace osu.Game.Rulesets.Edit
|
||||
ApplyDefaultsToHitObject();
|
||||
}
|
||||
|
||||
private bool placementBegun;
|
||||
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.
|
||||
@ -57,7 +89,7 @@ namespace osu.Game.Rulesets.Edit
|
||||
protected void BeginPlacement()
|
||||
{
|
||||
placementHandler.BeginPlacement(HitObject);
|
||||
placementBegun = true;
|
||||
PlacementBegun = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -66,7 +98,7 @@ namespace osu.Game.Rulesets.Edit
|
||||
/// </summary>
|
||||
protected void EndPlacement()
|
||||
{
|
||||
if (!placementBegun)
|
||||
if (!PlacementBegun)
|
||||
BeginPlacement();
|
||||
placementHandler.EndPlacement(HitObject);
|
||||
}
|
||||
@ -93,4 +125,10 @@ namespace osu.Game.Rulesets.Edit
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum PlacementState
|
||||
{
|
||||
Hidden,
|
||||
Shown,
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,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);
|
||||
@ -117,19 +120,32 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
if (currentPlacement != null)
|
||||
{
|
||||
if (composer.CursorInPlacementArea)
|
||||
currentPlacement.State = PlacementState.Shown;
|
||||
else if (currentPlacement?.PlacementBegun == false)
|
||||
currentPlacement.State = PlacementState.Hidden;
|
||||
}
|
||||
}
|
||||
|
||||
/// <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;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Select all masks in a given rectangle selection area.
|
||||
/// </summary>
|
||||
|
Loading…
Reference in New Issue
Block a user