mirror of
https://github.com/osukey/osukey.git
synced 2025-07-14 22:59:53 +09:00
Add blueprint transferral
This commit is contained in:
@ -276,6 +276,13 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves an item's blueprint.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item">The item to retrieve the blueprint of.</param>
|
||||||
|
/// <returns>The blueprint.</returns>
|
||||||
|
protected SelectionBlueprint<T> GetBlueprintFor(T item) => blueprintMap[item];
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Selection
|
#region Selection
|
||||||
|
@ -16,6 +16,7 @@ using osu.Game.Graphics.UserInterface;
|
|||||||
using osu.Game.Rulesets.Edit;
|
using osu.Game.Rulesets.Edit;
|
||||||
using osu.Game.Rulesets.Edit.Tools;
|
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.Types;
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
using osu.Game.Screens.Edit.Components.TernaryButtons;
|
using osu.Game.Screens.Edit.Components.TernaryButtons;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
@ -73,6 +74,14 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void TransferBlueprintFor(HitObject hitObject, DrawableHitObject drawableObject)
|
||||||
|
{
|
||||||
|
base.TransferBlueprintFor(hitObject, drawableObject);
|
||||||
|
|
||||||
|
var blueprint = (HitObjectSelectionBlueprint)GetBlueprintFor(hitObject);
|
||||||
|
blueprint.DrawableObject = drawableObject;
|
||||||
|
}
|
||||||
|
|
||||||
protected override bool OnKeyDown(KeyDownEvent e)
|
protected override bool OnKeyDown(KeyDownEvent e)
|
||||||
{
|
{
|
||||||
if (e.ControlPressed)
|
if (e.ControlPressed)
|
||||||
|
@ -11,6 +11,7 @@ using osu.Framework.Graphics.Containers;
|
|||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Game.Rulesets.Edit;
|
using osu.Game.Rulesets.Edit;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Edit.Compose.Components
|
namespace osu.Game.Screens.Edit.Compose.Components
|
||||||
{
|
{
|
||||||
@ -65,8 +66,11 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
foreach (var obj in Composer.HitObjects)
|
foreach (var obj in Composer.HitObjects)
|
||||||
AddBlueprintFor(obj.HitObject);
|
AddBlueprintFor(obj.HitObject);
|
||||||
|
|
||||||
Composer.Playfield.HitObjectUsageBegan += AddBlueprintFor;
|
var eventQueue = new HitObjectContainerEventQueue(Composer.Playfield);
|
||||||
Composer.Playfield.HitObjectUsageFinished += RemoveBlueprintFor;
|
eventQueue.HitObjectUsageBegan += AddBlueprintFor;
|
||||||
|
eventQueue.HitObjectUsageFinished += RemoveBlueprintFor;
|
||||||
|
eventQueue.HitObjectUsageTransferred += TransferBlueprintFor;
|
||||||
|
AddInternal(eventQueue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,6 +104,10 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
base.AddBlueprintFor(item);
|
base.AddBlueprintFor(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected virtual void TransferBlueprintFor(HitObject hitObject, DrawableHitObject drawableObject)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
protected override void DragOperationCompleted()
|
protected override void DragOperationCompleted()
|
||||||
{
|
{
|
||||||
base.DragOperationCompleted();
|
base.DragOperationCompleted();
|
||||||
@ -152,12 +160,6 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
Beatmap.HitObjectAdded -= AddBlueprintFor;
|
Beatmap.HitObjectAdded -= AddBlueprintFor;
|
||||||
Beatmap.HitObjectRemoved -= RemoveBlueprintFor;
|
Beatmap.HitObjectRemoved -= RemoveBlueprintFor;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Composer != null)
|
|
||||||
{
|
|
||||||
Composer.Playfield.HitObjectUsageBegan -= AddBlueprintFor;
|
|
||||||
Composer.Playfield.HitObjectUsageFinished -= RemoveBlueprintFor;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using JetBrains.Annotations;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
@ -23,7 +24,7 @@ namespace osu.Game.Screens.Edit.Compose
|
|||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// If the ruleset uses pooled objects, this represents the time when the <see cref="HitObject"/>s become alive.
|
/// If the ruleset uses pooled objects, this represents the time when the <see cref="HitObject"/>s become alive.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public event Action<HitObject, DrawableHitObject> HitObjectUsageBegan;
|
public event Action<HitObject> HitObjectUsageBegan;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Invoked when a <see cref="HitObject"/> becomes unused by a <see cref="DrawableHitObject"/>.
|
/// Invoked when a <see cref="HitObject"/> becomes unused by a <see cref="DrawableHitObject"/>.
|
||||||
@ -44,20 +45,12 @@ namespace osu.Game.Screens.Edit.Compose
|
|||||||
/// Creates a new <see cref="HitObjectContainerEventQueue"/>.
|
/// Creates a new <see cref="HitObjectContainerEventQueue"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="playfield">The most top-level <see cref="Playfield"/>.</param>
|
/// <param name="playfield">The most top-level <see cref="Playfield"/>.</param>
|
||||||
public HitObjectContainerEventQueue(Playfield playfield)
|
public HitObjectContainerEventQueue([NotNull] Playfield playfield)
|
||||||
{
|
{
|
||||||
this.playfield = playfield;
|
this.playfield = playfield;
|
||||||
|
|
||||||
bindPlayfieldRecursive(playfield);
|
playfield.HitObjectUsageBegan += onHitObjectUsageBegan;
|
||||||
}
|
playfield.HitObjectUsageFinished += onHitObjectUsageFinished;
|
||||||
|
|
||||||
private void bindPlayfieldRecursive(Playfield p)
|
|
||||||
{
|
|
||||||
p.HitObjectContainer.HitObjectUsageBegan += onHitObjectUsageBegan;
|
|
||||||
p.HitObjectContainer.HitObjectUsageFinished += onHitObjectUsageFinished;
|
|
||||||
|
|
||||||
foreach (var nested in p.NestedPlayfields)
|
|
||||||
bindPlayfieldRecursive(nested);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly Dictionary<HitObject, int> pendingUsagesBegan = new Dictionary<HitObject, int>();
|
private readonly Dictionary<HitObject, int> pendingUsagesBegan = new Dictionary<HitObject, int>();
|
||||||
@ -87,7 +80,7 @@ namespace osu.Game.Screens.Edit.Compose
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// This is a new usage of the hitobject.
|
// This is a new usage of the hitobject.
|
||||||
HitObjectUsageBegan?.Invoke(hitObject, playfield.AllHitObjects.Single(d => d.HitObject == hitObject));
|
HitObjectUsageBegan?.Invoke(hitObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,5 +91,13 @@ namespace osu.Game.Screens.Edit.Compose
|
|||||||
pendingUsagesBegan.Clear();
|
pendingUsagesBegan.Clear();
|
||||||
pendingUsagesFinished.Clear();
|
pendingUsagesFinished.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Dispose(bool isDisposing)
|
||||||
|
{
|
||||||
|
base.Dispose(isDisposing);
|
||||||
|
|
||||||
|
playfield.HitObjectUsageBegan -= onHitObjectUsageBegan;
|
||||||
|
playfield.HitObjectUsageFinished -= onHitObjectUsageFinished;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user