1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-30 21:32:57 +08:00

Merge branch 'master' into hold-for-menu-back

This commit is contained in:
Dan Balasescu 2018-11-14 19:13:07 +09:00 committed by GitHub
commit 81a3170e3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 79 additions and 6 deletions

View File

@ -37,6 +37,8 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Spinners
isPlacingEnd = true; isPlacingEnd = true;
piece.FadeTo(1f, 150, Easing.OutQuint); piece.FadeTo(1f, 150, Easing.OutQuint);
BeginPlacement();
} }
return true; return true;

View File

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

View File

@ -8,6 +8,7 @@ using osu.Framework.Allocation;
using osu.Framework.Configuration; using osu.Framework.Configuration;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Input;
using osu.Framework.Logging; using osu.Framework.Logging;
using osu.Framework.Timing; using osu.Framework.Timing;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
@ -37,6 +38,8 @@ namespace osu.Game.Rulesets.Edit
private BlueprintContainer blueprintContainer; private BlueprintContainer blueprintContainer;
private InputManager inputManager;
internal HitObjectComposer(Ruleset ruleset) internal HitObjectComposer(Ruleset ruleset)
{ {
Ruleset = ruleset; Ruleset = ruleset;
@ -114,6 +117,13 @@ namespace osu.Game.Rulesets.Edit
toolboxCollection.Items[0].Select(); toolboxCollection.Items[0].Select();
} }
protected override void LoadComplete()
{
base.LoadComplete();
inputManager = GetContainingInputManager();
}
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
{ {
var dependencies = new DependencyContainer(base.CreateChildDependencies(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> /// <summary>
/// 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>

View File

@ -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>
@ -37,6 +49,8 @@ namespace osu.Game.Rulesets.Edit
HitObject = hitObject; HitObject = hitObject;
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
Alpha = 0;
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
@ -49,7 +63,25 @@ namespace osu.Game.Rulesets.Edit
ApplyDefaultsToHitObject(); 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> /// <summary>
/// Signals that the placement of <see cref="HitObject"/> has started. /// Signals that the placement of <see cref="HitObject"/> has started.
@ -57,7 +89,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 +98,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);
} }
@ -93,4 +125,10 @@ namespace osu.Game.Rulesets.Edit
} }
} }
} }
public enum PlacementState
{
Hidden,
Shown,
}
} }

View File

@ -18,7 +18,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);
@ -117,19 +120,32 @@ namespace osu.Game.Screens.Edit.Compose.Components
return true; 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> /// <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;
} }
/// <summary> /// <summary>
/// Select all masks in a given rectangle selection area. /// Select all masks in a given rectangle selection area.
/// </summary> /// </summary>