Implement mask layering (incomplete)

This commit is contained in:
AlFasGD
2018-05-20 13:22:42 +03:00
parent 9b307f0e12
commit d504a44dfb
20 changed files with 426 additions and 47 deletions

View File

@ -25,7 +25,7 @@ namespace osu.Game.Rulesets.Edit
protected ICompositionTool CurrentTool { get; private set; }
private RulesetContainer rulesetContainer;
protected RulesetContainer RulesetContainer;
private readonly List<Container> layerContainers = new List<Container>();
private readonly Bindable<WorkingBeatmap> beatmap = new Bindable<WorkingBeatmap>();
@ -44,8 +44,8 @@ namespace osu.Game.Rulesets.Edit
try
{
rulesetContainer = CreateRulesetContainer(ruleset, beatmap.Value);
rulesetContainer.Clock = framedClock;
RulesetContainer = CreateRulesetContainer(ruleset, beatmap.Value);
RulesetContainer.Clock = framedClock;
}
catch (Exception e)
{
@ -60,7 +60,7 @@ namespace osu.Game.Rulesets.Edit
};
var layerAboveRuleset = CreateLayerContainer();
layerAboveRuleset.Child = new HitObjectMaskLayer(rulesetContainer.Playfield, this);
layerAboveRuleset.Child = CreateHitObjectMaskLayer();
layerContainers.Add(layerBelowRuleset);
layerContainers.Add(layerAboveRuleset);
@ -90,7 +90,7 @@ namespace osu.Game.Rulesets.Edit
Children = new Drawable[]
{
layerBelowRuleset,
rulesetContainer,
RulesetContainer,
layerAboveRuleset
}
}
@ -116,13 +116,14 @@ namespace osu.Game.Rulesets.Edit
layerContainers.ForEach(l =>
{
l.Anchor = rulesetContainer.Playfield.Anchor;
l.Origin = rulesetContainer.Playfield.Origin;
l.Position = rulesetContainer.Playfield.Position;
l.Size = rulesetContainer.Playfield.Size;
l.Anchor = RulesetContainer.Playfield.Anchor;
l.Origin = RulesetContainer.Playfield.Origin;
l.Position = RulesetContainer.Playfield.Position;
l.Size = RulesetContainer.Playfield.Size;
});
}
private void setCompositionTool(ICompositionTool tool) => CurrentTool = tool;
protected virtual RulesetContainer CreateRulesetContainer(Ruleset ruleset, WorkingBeatmap beatmap) => ruleset.CreateRulesetContainerWith(beatmap);
@ -141,6 +142,11 @@ namespace osu.Game.Rulesets.Edit
/// </summary>
public virtual MaskSelection CreateMaskSelection() => new MaskSelection();
/// <summary>
/// Creates a <see cref="HitObjectMaskLayer"/> depending on the ruleset.
/// </summary>
protected virtual HitObjectMaskLayer CreateHitObjectMaskLayer() => new HitObjectMaskLayer(RulesetContainer.Playfield, this);
/// <summary>
/// Creates a <see cref="ScalableContainer"/> which provides a layer above or below the <see cref="Playfield"/>.
/// </summary>

View File

@ -33,11 +33,21 @@ namespace osu.Game.Rulesets.Edit
/// </summary>
public event Action<HitObjectMask, InputState> SelectionRequested;
/// <summary>
/// Invoked when this <see cref="HitObjectMask"/> has started drag.
/// </summary>
public event Action<HitObjectMask, InputState> DragStarted;
/// <summary>
/// Invoked when this <see cref="HitObjectMask"/> has requested drag.
/// </summary>
public event Action<HitObjectMask, InputState> DragRequested;
/// <summary>
/// Invoked when this <see cref="HitObjectMask"/> has ended drag.
/// </summary>
public event Action<HitObjectMask, InputState> DragEnded;
/// <summary>
/// The <see cref="DrawableHitObject"/> which this <see cref="HitObjectMask"/> applies to.
/// </summary>
@ -120,7 +130,11 @@ namespace osu.Game.Rulesets.Edit
return base.OnClick(state);
}
protected override bool OnDragStart(InputState state) => true;
protected override bool OnDragStart(InputState state)
{
DragStarted?.Invoke(this, state);
return true;
}
protected override bool OnDrag(InputState state)
{
@ -128,6 +142,12 @@ namespace osu.Game.Rulesets.Edit
return true;
}
protected override bool OnDragEnd(InputState state)
{
DragEnded?.Invoke(this, state);
return true;
}
/// <summary>
/// The screen-space point that causes this <see cref="HitObjectMask"/> to be selected.
/// </summary>

View File

@ -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.Input;
using osu.Game.Rulesets.Objects;
namespace osu.Game.Rulesets.Edit.Tools
@ -8,6 +10,18 @@ namespace osu.Game.Rulesets.Edit.Tools
public class HitObjectCompositionTool<T> : ICompositionTool
where T : HitObject
{
public string Name => typeof(T).Name;
public string Name { get; } = typeof(T).Name;
public Action<InputState, MouseDownEventArgs, bool> OnMouseDown { get; }
public Action<InputState, MouseDownEventArgs, bool> OnMouseUp { get; }
public HitObjectCompositionTool()
{
}
public HitObjectCompositionTool(string name)
{
Name = name;
}
}
}

View File

@ -1,10 +1,16 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Input;
using System;
namespace osu.Game.Rulesets.Edit.Tools
{
public interface ICompositionTool
{
string Name { get; }
Action<InputState, MouseDownEventArgs, bool> OnMouseDown { get; }
Action<InputState, MouseDownEventArgs, bool> OnMouseUp { get; }
}
}

View File

@ -0,0 +1,12 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Game.Rulesets.Objects.Types;
namespace osu.Game.Rulesets.Edit.Types
{
public interface IHasEditableColumn : IHasColumn
{
void OffsetColumn(int offset);
}
}

View File

@ -0,0 +1,12 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Game.Rulesets.Objects.Types;
namespace osu.Game.Rulesets.Edit.Types
{
public interface IHasEditableLayer : IHasLayer
{
void OffsetLayer(int offset);
}
}