mirror of
https://github.com/ppy/osu.git
synced 2025-02-15 19:45:43 +08:00
Apply remaining changes required to restore previous functionality
This commit is contained in:
parent
d8d12cbbdd
commit
d57f55f053
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
using osu.Game.Rulesets.Edit;
|
using osu.Game.Rulesets.Edit;
|
||||||
using osu.Game.Rulesets.Mania.Edit.Blueprints;
|
using osu.Game.Rulesets.Mania.Edit.Blueprints;
|
||||||
using osu.Game.Rulesets.Mania.Objects.Drawables;
|
using osu.Game.Rulesets.Mania.Objects.Drawables;
|
||||||
@ -11,6 +12,11 @@ namespace osu.Game.Rulesets.Mania.Edit
|
|||||||
{
|
{
|
||||||
public class ManiaBlueprintContainer : ComposeBlueprintContainer
|
public class ManiaBlueprintContainer : ComposeBlueprintContainer
|
||||||
{
|
{
|
||||||
|
public ManiaBlueprintContainer(IEnumerable<DrawableHitObject> drawableHitObjects)
|
||||||
|
: base(drawableHitObjects)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public override SelectionBlueprint CreateBlueprintFor(DrawableHitObject hitObject)
|
public override SelectionBlueprint CreateBlueprintFor(DrawableHitObject hitObject)
|
||||||
{
|
{
|
||||||
switch (hitObject)
|
switch (hitObject)
|
||||||
|
@ -49,7 +49,7 @@ namespace osu.Game.Rulesets.Mania.Edit
|
|||||||
return drawableRuleset;
|
return drawableRuleset;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override ComposeBlueprintContainer CreateBlueprintContainer() => new ManiaBlueprintContainer();
|
protected override ComposeBlueprintContainer CreateBlueprintContainer() => new ManiaBlueprintContainer(drawableRuleset.Playfield.AllHitObjects);
|
||||||
|
|
||||||
protected override IReadOnlyList<HitObjectCompositionTool> CompositionTools => new HitObjectCompositionTool[]
|
protected override IReadOnlyList<HitObjectCompositionTool> CompositionTools => new HitObjectCompositionTool[]
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
using osu.Game.Rulesets.Edit;
|
using osu.Game.Rulesets.Edit;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
using osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles;
|
using osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles;
|
||||||
@ -13,7 +14,7 @@ namespace osu.Game.Rulesets.Osu.Edit
|
|||||||
{
|
{
|
||||||
public class OsuBlueprintContainer : ComposeBlueprintContainer
|
public class OsuBlueprintContainer : ComposeBlueprintContainer
|
||||||
{
|
{
|
||||||
public override SelectionHandler CreateSelectionHandler() => new OsuSelectionHandler();
|
protected override SelectionHandler CreateSelectionHandler() => new OsuSelectionHandler();
|
||||||
|
|
||||||
public override SelectionBlueprint CreateBlueprintFor(DrawableHitObject hitObject)
|
public override SelectionBlueprint CreateBlueprintFor(DrawableHitObject hitObject)
|
||||||
{
|
{
|
||||||
@ -31,5 +32,10 @@ namespace osu.Game.Rulesets.Osu.Edit
|
|||||||
|
|
||||||
return base.CreateBlueprintFor(hitObject);
|
return base.CreateBlueprintFor(hitObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public OsuBlueprintContainer(IEnumerable<DrawableHitObject> drawableHitObjects)
|
||||||
|
: base(drawableHitObjects)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ namespace osu.Game.Rulesets.Osu.Edit
|
|||||||
new SpinnerCompositionTool()
|
new SpinnerCompositionTool()
|
||||||
};
|
};
|
||||||
|
|
||||||
protected override ComposeBlueprintContainer CreateBlueprintContainer() => new OsuBlueprintContainer();
|
protected override ComposeBlueprintContainer CreateBlueprintContainer() => new OsuBlueprintContainer(HitObjects);
|
||||||
|
|
||||||
protected override DistanceSnapGrid CreateDistanceSnapGrid(IEnumerable<HitObject> selectedHitObjects)
|
protected override DistanceSnapGrid CreateDistanceSnapGrid(IEnumerable<HitObject> selectedHitObjects)
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
using osu.Game.Screens.Edit.Compose.Components;
|
using osu.Game.Screens.Edit.Compose.Components;
|
||||||
using osu.Game.Tests.Visual;
|
using osu.Game.Tests.Visual;
|
||||||
|
|
||||||
@ -12,7 +14,7 @@ namespace osu.Game.Tests.Editor
|
|||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup() => Schedule(() =>
|
public void Setup() => Schedule(() =>
|
||||||
{
|
{
|
||||||
Child = new ComposeBlueprintContainer();
|
Child = new ComposeBlueprintContainer(new List<DrawableHitObject>());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
private IBeatmapProcessor beatmapProcessor;
|
private IBeatmapProcessor beatmapProcessor;
|
||||||
|
|
||||||
private DrawableEditRulesetWrapper<TObject> drawableRulesetWrapper;
|
private DrawableEditRulesetWrapper<TObject> drawableRulesetWrapper;
|
||||||
private BlueprintContainer blueprintContainer;
|
private ComposeBlueprintContainer blueprintContainer;
|
||||||
private Container distanceSnapGridContainer;
|
private Container distanceSnapGridContainer;
|
||||||
private DistanceSnapGrid distanceSnapGrid;
|
private DistanceSnapGrid distanceSnapGrid;
|
||||||
private readonly List<Container> layerContainers = new List<Container>();
|
private readonly List<Container> layerContainers = new List<Container>();
|
||||||
|
@ -14,7 +14,6 @@ using osu.Framework.Input.Bindings;
|
|||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Framework.Timing;
|
using osu.Framework.Timing;
|
||||||
using osu.Game.Rulesets.Edit;
|
using osu.Game.Rulesets.Edit;
|
||||||
using osu.Game.Rulesets.Edit.Tools;
|
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
@ -30,12 +29,11 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
{
|
{
|
||||||
public event Action<IEnumerable<HitObject>> SelectionChanged;
|
public event Action<IEnumerable<HitObject>> SelectionChanged;
|
||||||
|
|
||||||
private DragBox dragBox;
|
protected DragBox DragBox;
|
||||||
|
|
||||||
private SelectionBlueprintContainer selectionBlueprints;
|
private SelectionBlueprintContainer selectionBlueprints;
|
||||||
private Container<PlacementBlueprint> placementBlueprintContainer;
|
|
||||||
private PlacementBlueprint currentPlacement;
|
|
||||||
private SelectionHandler selectionHandler;
|
private SelectionHandler selectionHandler;
|
||||||
private InputManager inputManager;
|
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private IAdjustableClock adjustableClock { get; set; }
|
private IAdjustableClock adjustableClock { get; set; }
|
||||||
@ -43,6 +41,9 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private EditorBeatmap beatmap { get; set; }
|
private EditorBeatmap beatmap { get; set; }
|
||||||
|
|
||||||
|
[Resolved(canBeNull: true)]
|
||||||
|
private IDistanceSnapProvider snapProvider { get; set; }
|
||||||
|
|
||||||
protected BlueprintContainer()
|
protected BlueprintContainer()
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
@ -51,13 +52,15 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a <see cref="SelectionHandler"/> which outlines <see cref="DrawableHitObject"/>s and handles movement of selections.
|
/// Creates a <see cref="SelectionHandler"/> which outlines <see cref="DrawableHitObject"/>s and handles movement of selections.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual SelectionHandler CreateSelectionHandler() => new SelectionHandler();
|
protected virtual SelectionHandler CreateSelectionHandler() => new SelectionHandler();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a <see cref="SelectionBlueprint"/> for a specific <see cref="DrawableHitObject"/>.
|
/// Creates a <see cref="SelectionBlueprint"/> for a specific <see cref="DrawableHitObject"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="hitObject">The <see cref="DrawableHitObject"/> to create the overlay for.</param>
|
/// <param name="hitObject">The <see cref="DrawableHitObject"/> to create the overlay for.</param>
|
||||||
public virtual SelectionBlueprint CreateBlueprintFor(DrawableHitObject hitObject) => null;
|
protected virtual SelectionBlueprint CreateBlueprintFor(HitObject hitObject) => null;
|
||||||
|
|
||||||
|
protected virtual DragBox CreateDragBox(Action<RectangleF> performSelect) => new DragBox(performSelect);
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
@ -65,46 +68,24 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
selectionHandler = CreateSelectionHandler();
|
selectionHandler = CreateSelectionHandler();
|
||||||
selectionHandler.DeselectAll = deselectAll;
|
selectionHandler.DeselectAll = deselectAll;
|
||||||
|
|
||||||
InternalChildren = new[]
|
AddRangeInternal(new[]
|
||||||
{
|
{
|
||||||
dragBox = new DragBox(select),
|
DragBox = CreateDragBox(select),
|
||||||
selectionHandler,
|
selectionHandler,
|
||||||
selectionBlueprints = new SelectionBlueprintContainer { RelativeSizeAxes = Axes.Both },
|
selectionBlueprints = new SelectionBlueprintContainer { RelativeSizeAxes = Axes.Both },
|
||||||
placementBlueprintContainer = new Container<PlacementBlueprint> { RelativeSizeAxes = Axes.Both },
|
DragBox.CreateProxy().With(p => p.Depth = int.MinValue)
|
||||||
dragBox.CreateProxy()
|
});
|
||||||
};
|
|
||||||
|
|
||||||
foreach (var obj in beatmap.HitObjects)
|
foreach (var obj in beatmap.HitObjects)
|
||||||
addBlueprintFor(obj);
|
AddBlueprintFor(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
beatmap.HitObjectAdded += addBlueprintFor;
|
beatmap.HitObjectAdded += AddBlueprintFor;
|
||||||
beatmap.HitObjectRemoved += removeBlueprintFor;
|
beatmap.HitObjectRemoved += removeBlueprintFor;
|
||||||
|
|
||||||
inputManager = GetContainingInputManager();
|
|
||||||
}
|
|
||||||
|
|
||||||
private HitObjectCompositionTool currentTool;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The current placement tool.
|
|
||||||
/// </summary>
|
|
||||||
public HitObjectCompositionTool CurrentTool
|
|
||||||
{
|
|
||||||
get => currentTool;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (currentTool == value)
|
|
||||||
return;
|
|
||||||
|
|
||||||
currentTool = value;
|
|
||||||
|
|
||||||
refreshTool();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnMouseDown(MouseDownEvent e)
|
protected override bool OnMouseDown(MouseDownEvent e)
|
||||||
@ -148,17 +129,6 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
return e.Button == MouseButton.Left;
|
return e.Button == MouseButton.Left;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnMouseMove(MouseMoveEvent e)
|
|
||||||
{
|
|
||||||
if (currentPlacement != null)
|
|
||||||
{
|
|
||||||
updatePlacementPosition(e.ScreenSpaceMousePosition);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return base.OnMouseMove(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override bool OnDragStart(DragStartEvent e)
|
protected override bool OnDragStart(DragStartEvent e)
|
||||||
{
|
{
|
||||||
if (e.Button == MouseButton.Right)
|
if (e.Button == MouseButton.Right)
|
||||||
@ -166,8 +136,10 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
|
|
||||||
if (!beginSelectionMovement())
|
if (!beginSelectionMovement())
|
||||||
{
|
{
|
||||||
dragBox.UpdateDrag(e);
|
if (!DragBox.UpdateDrag(e))
|
||||||
dragBox.FadeIn(250, Easing.OutQuint);
|
return false;
|
||||||
|
|
||||||
|
DragBox.FadeIn(250, Easing.OutQuint);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -179,7 +151,10 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!moveCurrentSelection(e))
|
if (!moveCurrentSelection(e))
|
||||||
dragBox.UpdateDrag(e);
|
{
|
||||||
|
if (!DragBox.UpdateDrag(e))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -191,7 +166,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
|
|
||||||
if (!finishSelectionMovement())
|
if (!finishSelectionMovement())
|
||||||
{
|
{
|
||||||
dragBox.FadeOut(250, Easing.OutQuint);
|
DragBox.FadeOut(250, Easing.OutQuint);
|
||||||
selectionHandler.UpdateVisibility();
|
selectionHandler.UpdateVisibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,30 +204,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
|
|
||||||
public bool OnReleased(PlatformAction action) => false;
|
public bool OnReleased(PlatformAction action) => false;
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Blueprint Addition/Removal
|
#region Blueprint Addition/Removal
|
||||||
|
|
||||||
private void addBlueprintFor(HitObject hitObject)
|
|
||||||
{
|
|
||||||
var drawable = composer.HitObjects.FirstOrDefault(d => d.HitObject == hitObject);
|
|
||||||
if (drawable == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
addBlueprintFor(drawable);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void removeBlueprintFor(HitObject hitObject)
|
private void removeBlueprintFor(HitObject hitObject)
|
||||||
{
|
{
|
||||||
var blueprint = selectionBlueprints.Single(m => m.DrawableObject.HitObject == hitObject);
|
var blueprint = selectionBlueprints.Single(m => m.DrawableObject.HitObject == hitObject);
|
||||||
@ -267,10 +220,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
selectionBlueprints.Remove(blueprint);
|
selectionBlueprints.Remove(blueprint);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addBlueprintFor(DrawableHitObject hitObject)
|
protected virtual void AddBlueprintFor(HitObject hitObject)
|
||||||
{
|
{
|
||||||
refreshTool();
|
|
||||||
|
|
||||||
var blueprint = CreateBlueprintFor(hitObject);
|
var blueprint = CreateBlueprintFor(hitObject);
|
||||||
if (blueprint == null)
|
if (blueprint == null)
|
||||||
return;
|
return;
|
||||||
@ -283,37 +234,6 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Placement
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Refreshes the current placement tool.
|
|
||||||
/// </summary>
|
|
||||||
private void refreshTool()
|
|
||||||
{
|
|
||||||
placementBlueprintContainer.Clear();
|
|
||||||
currentPlacement = null;
|
|
||||||
|
|
||||||
var blueprint = CurrentTool?.CreatePlacementBlueprint();
|
|
||||||
|
|
||||||
if (blueprint != null)
|
|
||||||
{
|
|
||||||
placementBlueprintContainer.Child = currentPlacement = blueprint;
|
|
||||||
|
|
||||||
// Fixes a 1-frame position discrepancy due to the first mouse move event happening in the next frame
|
|
||||||
updatePlacementPosition(inputManager.CurrentState.Mouse.Position);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updatePlacementPosition(Vector2 screenSpacePosition)
|
|
||||||
{
|
|
||||||
Vector2 snappedGridPosition = composer.GetSnappedPosition(ToLocalSpace(screenSpacePosition), 0).position;
|
|
||||||
Vector2 snappedScreenSpacePosition = ToScreenSpace(snappedGridPosition);
|
|
||||||
|
|
||||||
currentPlacement.UpdatePosition(snappedScreenSpacePosition);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Selection
|
#region Selection
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -449,7 +369,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
|
|
||||||
// The final movement position, relative to screenSpaceMovementStartPosition
|
// The final movement position, relative to screenSpaceMovementStartPosition
|
||||||
Vector2 movePosition = startPosition + e.ScreenSpaceMousePosition - e.ScreenSpaceMouseDownPosition;
|
Vector2 movePosition = startPosition + e.ScreenSpaceMousePosition - e.ScreenSpaceMouseDownPosition;
|
||||||
(Vector2 snappedPosition, double snappedTime) = composer.GetSnappedPosition(ToLocalSpace(movePosition), draggedObject.StartTime);
|
(Vector2 snappedPosition, double snappedTime) = snapProvider.GetSnappedPosition(ToLocalSpace(movePosition), draggedObject.StartTime);
|
||||||
|
|
||||||
// Move the hitobjects
|
// Move the hitobjects
|
||||||
if (!selectionHandler.HandleMovement(new MoveSelectionEvent(movementBlueprint, startPosition, ToScreenSpace(snappedPosition))))
|
if (!selectionHandler.HandleMovement(new MoveSelectionEvent(movementBlueprint, startPosition, ToScreenSpace(snappedPosition))))
|
||||||
@ -486,7 +406,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
|
|
||||||
if (beatmap != null)
|
if (beatmap != null)
|
||||||
{
|
{
|
||||||
beatmap.HitObjectAdded -= addBlueprintFor;
|
beatmap.HitObjectAdded -= AddBlueprintFor;
|
||||||
beatmap.HitObjectRemoved -= removeBlueprintFor;
|
beatmap.HitObjectRemoved -= removeBlueprintFor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,19 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Input;
|
||||||
|
using osu.Framework.Input.Events;
|
||||||
|
using osu.Game.Rulesets.Edit;
|
||||||
|
using osu.Game.Rulesets.Edit.Tools;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Edit.Compose.Components
|
namespace osu.Game.Screens.Edit.Compose.Components
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -8,5 +21,129 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class ComposeBlueprintContainer : BlueprintContainer
|
public class ComposeBlueprintContainer : BlueprintContainer
|
||||||
{
|
{
|
||||||
|
[Resolved]
|
||||||
|
private HitObjectComposer composer { get; set; }
|
||||||
|
|
||||||
|
private PlacementBlueprint currentPlacement;
|
||||||
|
|
||||||
|
private readonly Container<PlacementBlueprint> placementBlueprintContainer;
|
||||||
|
|
||||||
|
private InputManager inputManager;
|
||||||
|
|
||||||
|
private readonly IEnumerable<DrawableHitObject> drawableHitObjects;
|
||||||
|
|
||||||
|
public ComposeBlueprintContainer(IEnumerable<DrawableHitObject> drawableHitObjects)
|
||||||
|
{
|
||||||
|
this.drawableHitObjects = drawableHitObjects;
|
||||||
|
|
||||||
|
placementBlueprintContainer = new Container<PlacementBlueprint>
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
AddInternal(placementBlueprintContainer);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
inputManager = GetContainingInputManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Placement
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Refreshes the current placement tool.
|
||||||
|
/// </summary>
|
||||||
|
private void refreshTool()
|
||||||
|
{
|
||||||
|
placementBlueprintContainer.Clear();
|
||||||
|
currentPlacement = null;
|
||||||
|
|
||||||
|
var blueprint = CurrentTool?.CreatePlacementBlueprint();
|
||||||
|
|
||||||
|
if (blueprint != null)
|
||||||
|
{
|
||||||
|
placementBlueprintContainer.Child = currentPlacement = blueprint;
|
||||||
|
|
||||||
|
// Fixes a 1-frame position discrepancy due to the first mouse move event happening in the next frame
|
||||||
|
updatePlacementPosition(inputManager.CurrentState.Mouse.Position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updatePlacementPosition(Vector2 screenSpacePosition)
|
||||||
|
{
|
||||||
|
Vector2 snappedGridPosition = composer.GetSnappedPosition(ToLocalSpace(screenSpacePosition), 0).position;
|
||||||
|
Vector2 snappedScreenSpacePosition = ToScreenSpace(snappedGridPosition);
|
||||||
|
|
||||||
|
currentPlacement.UpdatePosition(snappedScreenSpacePosition);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
protected override bool OnMouseMove(MouseMoveEvent e)
|
||||||
|
{
|
||||||
|
if (currentPlacement != null)
|
||||||
|
{
|
||||||
|
updatePlacementPosition(e.ScreenSpaceMousePosition);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return base.OnMouseMove(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected sealed override SelectionBlueprint CreateBlueprintFor(HitObject hitObject)
|
||||||
|
{
|
||||||
|
var drawable = drawableHitObjects.FirstOrDefault(d => d.HitObject == hitObject);
|
||||||
|
if (drawable == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return CreateBlueprintFor(drawable);
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual SelectionBlueprint CreateBlueprintFor(DrawableHitObject hitObject) => null;
|
||||||
|
|
||||||
|
protected override void AddBlueprintFor(HitObject hitObject)
|
||||||
|
{
|
||||||
|
refreshTool();
|
||||||
|
base.AddBlueprintFor(hitObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
private HitObjectCompositionTool currentTool;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The current placement tool.
|
||||||
|
/// </summary>
|
||||||
|
public HitObjectCompositionTool CurrentTool
|
||||||
|
{
|
||||||
|
get => currentTool;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (currentTool == value)
|
||||||
|
return;
|
||||||
|
|
||||||
|
currentTool = value;
|
||||||
|
|
||||||
|
refreshTool();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,12 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateDrag(MouseButtonEvent e)
|
/// <summary>
|
||||||
|
/// Handle a forwarded mouse event.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="e">The mouse event.</param>
|
||||||
|
/// <returns>Whether the event should be handled and blocking.</returns>
|
||||||
|
public virtual bool UpdateDrag(MouseButtonEvent e)
|
||||||
{
|
{
|
||||||
var dragPosition = e.ScreenSpaceMousePosition;
|
var dragPosition = e.ScreenSpaceMousePosition;
|
||||||
var dragStartPosition = e.ScreenSpaceMouseDownPosition;
|
var dragStartPosition = e.ScreenSpaceMouseDownPosition;
|
||||||
@ -67,6 +72,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
box.Size = bottomRight - topLeft;
|
box.Size = bottomRight - topLeft;
|
||||||
|
|
||||||
performSelection?.Invoke(dragRectangle);
|
performSelection?.Invoke(dragRectangle);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
|
|
||||||
private Drawable outline;
|
private Drawable outline;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved(CanBeNull = true)]
|
||||||
private IPlacementHandler placementHandler { get; set; }
|
private IPlacementHandler placementHandler { get; set; }
|
||||||
|
|
||||||
public SelectionHandler()
|
public SelectionHandler()
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
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.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Framework.Input.Events;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.Objects.Types;
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
using osu.Game.Screens.Edit.Components.Timelines.Summary.Parts;
|
using osu.Game.Screens.Edit.Components.Timelines.Summary.Parts;
|
||||||
@ -26,7 +29,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
|
|
||||||
this.beatmap = beatmap;
|
this.beatmap = beatmap;
|
||||||
|
|
||||||
AddInternal(content = new TimelinePart());
|
AddInternal(content = new TimelinePart { RelativeSizeAxes = Axes.Both });
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -44,6 +47,12 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
DragBox.Alpha = 0;
|
||||||
|
}
|
||||||
|
|
||||||
private void remove(HitObject h)
|
private void remove(HitObject h)
|
||||||
{
|
{
|
||||||
foreach (var d in content.OfType<TimelineHitObjectRepresentation>().Where(c => c.HitObject == h))
|
foreach (var d in content.OfType<TimelineHitObjectRepresentation>().Where(c => c.HitObject == h))
|
||||||
@ -57,6 +66,25 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
content.Add(new TimelineHitObjectRepresentation(h) { Y = -yOffset * TimelineHitObjectRepresentation.THICKNESS });
|
content.Add(new TimelineHitObjectRepresentation(h) { Y = -yOffset * TimelineHitObjectRepresentation.THICKNESS });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override bool OnMouseDown(MouseDownEvent e)
|
||||||
|
{
|
||||||
|
base.OnMouseDown(e);
|
||||||
|
|
||||||
|
return false; // tempoerary until we correctly handle selections.
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override DragBox CreateDragBox(Action<RectangleF> performSelect) => new NoDragDragBox(performSelect);
|
||||||
|
|
||||||
|
internal class NoDragDragBox : DragBox
|
||||||
|
{
|
||||||
|
public NoDragDragBox(Action<RectangleF> performSelect)
|
||||||
|
: base(performSelect)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool UpdateDrag(MouseButtonEvent e) => false;
|
||||||
|
}
|
||||||
|
|
||||||
private class TimelineHitObjectRepresentation : CompositeDrawable
|
private class TimelineHitObjectRepresentation : CompositeDrawable
|
||||||
{
|
{
|
||||||
public const float THICKNESS = 3;
|
public const float THICKNESS = 3;
|
||||||
|
Loading…
Reference in New Issue
Block a user