mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 15:16:38 +09:00
Merge branch 'master' into fix-editor-clocks
This commit is contained in:
@ -13,10 +13,10 @@ using osu.Framework.Logging;
|
||||
using osu.Framework.MathUtils;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Edit.Layers;
|
||||
using osu.Game.Rulesets.Edit.Layers.Selection;
|
||||
using osu.Game.Rulesets.Edit.Tools;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Screens.Edit.Screens.Compose.Layers;
|
||||
using osu.Game.Screens.Edit.Screens.Compose.RadioButtons;
|
||||
|
||||
namespace osu.Game.Rulesets.Edit
|
||||
@ -60,7 +60,7 @@ namespace osu.Game.Rulesets.Edit
|
||||
return;
|
||||
}
|
||||
|
||||
HitObjectOverlayLayer hitObjectOverlayLayer = CreateHitObjectOverlayLayer();
|
||||
HitObjectMaskLayer hitObjectMaskLayer = new HitObjectMaskLayer(this);
|
||||
SelectionLayer selectionLayer = new SelectionLayer(rulesetContainer.Playfield);
|
||||
|
||||
var layerBelowRuleset = new BorderLayer
|
||||
@ -73,7 +73,7 @@ namespace osu.Game.Rulesets.Edit
|
||||
layerAboveRuleset.Children = new Drawable[]
|
||||
{
|
||||
selectionLayer, // Below object overlays for input
|
||||
hitObjectOverlayLayer,
|
||||
hitObjectMaskLayer,
|
||||
selectionLayer.CreateProxy() // Proxy above object overlays for selections
|
||||
};
|
||||
|
||||
@ -117,8 +117,10 @@ namespace osu.Game.Rulesets.Edit
|
||||
}
|
||||
};
|
||||
|
||||
selectionLayer.ObjectSelected += hitObjectOverlayLayer.AddOverlay;
|
||||
selectionLayer.ObjectDeselected += hitObjectOverlayLayer.RemoveOverlay;
|
||||
selectionLayer.ObjectSelected += hitObjectMaskLayer.AddOverlay;
|
||||
selectionLayer.ObjectDeselected += hitObjectMaskLayer.RemoveOverlay;
|
||||
selectionLayer.SelectionCleared += hitObjectMaskLayer.RemoveSelectionOverlay;
|
||||
selectionLayer.SelectionFinished += hitObjectMaskLayer.AddSelectionOverlay;
|
||||
|
||||
toolboxCollection.Items =
|
||||
new[] { new RadioButton("Select", () => setCompositionTool(null)) }
|
||||
@ -164,36 +166,6 @@ namespace osu.Game.Rulesets.Edit
|
||||
/// <param name="snapped">Whether to snap to the closest beat.</param>
|
||||
public void SeekForward(bool snapped = false) => seek(1, snapped);
|
||||
|
||||
public void SeekTo(double seekTime, bool snapped = false)
|
||||
{
|
||||
// Todo: This should not be a constant, but feels good for now
|
||||
const int beat_snap_divisor = 4;
|
||||
|
||||
if (!snapped)
|
||||
{
|
||||
adjustableClock.Seek(seekTime);
|
||||
return;
|
||||
}
|
||||
|
||||
var timingPoint = beatmap.Value.Beatmap.ControlPointInfo.TimingPointAt(seekTime);
|
||||
double beatSnapLength = timingPoint.BeatLength / beat_snap_divisor;
|
||||
|
||||
// We will be snapping to beats within the timing point
|
||||
seekTime -= timingPoint.Time;
|
||||
|
||||
// Determine the index from the current timing point of the closest beat to seekTime
|
||||
int closestBeat = (int)Math.Round(seekTime / beatSnapLength);
|
||||
seekTime = timingPoint.Time + closestBeat * beatSnapLength;
|
||||
|
||||
// Depending on beatSnapLength, we may snap to a beat that is beyond timingPoint's end time, but we want to instead snap to
|
||||
// the next timing point's start time
|
||||
var nextTimingPoint = beatmap.Value.Beatmap.ControlPointInfo.TimingPoints.FirstOrDefault(t => t.Time > timingPoint.Time);
|
||||
if (seekTime > nextTimingPoint?.Time)
|
||||
seekTime = nextTimingPoint.Time;
|
||||
|
||||
adjustableClock.Seek(seekTime);
|
||||
}
|
||||
|
||||
private void seek(int direction, bool snapped)
|
||||
{
|
||||
// Todo: This should not be a constant, but feels good for now
|
||||
@ -204,7 +176,7 @@ namespace osu.Game.Rulesets.Edit
|
||||
var timingPoint = cpi.TimingPointAt(adjustableClock.CurrentTime);
|
||||
if (direction < 0 && timingPoint.Time == adjustableClock.CurrentTime)
|
||||
{
|
||||
// When going backwards, we care about the timing point that was _previously_ active at the current time
|
||||
// When going backwards and we're at the boundary of two timing points, we compute the seek distance with the timing point which we are seeking into
|
||||
int activeIndex = cpi.TimingPoints.IndexOf(timingPoint);
|
||||
while (activeIndex > 0 && adjustableClock.CurrentTime == timingPoint.Time)
|
||||
timingPoint = cpi.TimingPoints[--activeIndex];
|
||||
@ -239,7 +211,7 @@ namespace osu.Game.Rulesets.Edit
|
||||
seekTime = timingPoint.Time + closestBeat * seekAmount;
|
||||
}
|
||||
|
||||
if (seekTime < timingPoint.Time)
|
||||
if (seekTime < timingPoint.Time && timingPoint != cpi.TimingPoints.First())
|
||||
seekTime = timingPoint.Time;
|
||||
|
||||
var nextTimingPoint = cpi.TimingPoints.FirstOrDefault(t => t.Time > timingPoint.Time);
|
||||
@ -249,20 +221,58 @@ namespace osu.Game.Rulesets.Edit
|
||||
adjustableClock.Seek(seekTime);
|
||||
}
|
||||
|
||||
public void SeekTo(double seekTime, bool snapped = false)
|
||||
{
|
||||
// Todo: This should not be a constant, but feels good for now
|
||||
const int beat_snap_divisor = 4;
|
||||
|
||||
if (!snapped)
|
||||
{
|
||||
adjustableClock.Seek(seekTime);
|
||||
return;
|
||||
}
|
||||
|
||||
var timingPoint = beatmap.Value.Beatmap.ControlPointInfo.TimingPointAt(seekTime);
|
||||
double beatSnapLength = timingPoint.BeatLength / beat_snap_divisor;
|
||||
|
||||
// We will be snapping to beats within the timing point
|
||||
seekTime -= timingPoint.Time;
|
||||
|
||||
// Determine the index from the current timing point of the closest beat to seekTime
|
||||
int closestBeat = (int)Math.Round(seekTime / beatSnapLength);
|
||||
seekTime = timingPoint.Time + closestBeat * beatSnapLength;
|
||||
|
||||
// Depending on beatSnapLength, we may snap to a beat that is beyond timingPoint's end time, but we want to instead snap to
|
||||
// the next timing point's start time
|
||||
var nextTimingPoint = beatmap.Value.Beatmap.ControlPointInfo.TimingPoints.FirstOrDefault(t => t.Time > timingPoint.Time);
|
||||
if (seekTime > nextTimingPoint?.Time)
|
||||
seekTime = nextTimingPoint.Time;
|
||||
|
||||
adjustableClock.Seek(seekTime);
|
||||
}
|
||||
|
||||
private void setCompositionTool(ICompositionTool tool) => CurrentTool = tool;
|
||||
|
||||
protected virtual RulesetContainer CreateRulesetContainer(Ruleset ruleset, WorkingBeatmap beatmap) => ruleset.CreateRulesetContainerWith(beatmap, true);
|
||||
|
||||
protected abstract IReadOnlyList<ICompositionTool> CompositionTools { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Creates a <see cref="HitObjectMask"/> for a specific <see cref="DrawableHitObject"/>.
|
||||
/// </summary>
|
||||
/// <param name="hitObject">The <see cref="DrawableHitObject"/> to create the overlay for.</param>
|
||||
public virtual HitObjectMask CreateMaskFor(DrawableHitObject hitObject) => null;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a <see cref="SelectionBox"/> which outlines <see cref="DrawableHitObject"/>s
|
||||
/// and handles all hitobject movement/pattern adjustments.
|
||||
/// </summary>
|
||||
/// <param name="overlays">The <see cref="DrawableHitObject"/> overlays.</param>
|
||||
public virtual SelectionBox CreateSelectionOverlay(IReadOnlyList<HitObjectMask> overlays) => new SelectionBox(overlays);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a <see cref="ScalableContainer"/> which provides a layer above or below the <see cref="Playfield"/>.
|
||||
/// </summary>
|
||||
protected virtual ScalableContainer CreateLayerContainer() => new ScalableContainer { RelativeSizeAxes = Axes.Both };
|
||||
|
||||
/// <summary>
|
||||
/// Creates the <see cref="HitObjectOverlayLayer"/> which overlays selected <see cref="DrawableHitObject"/>s.
|
||||
/// </summary>
|
||||
protected virtual HitObjectOverlayLayer CreateHitObjectOverlayLayer() => new HitObjectOverlayLayer();
|
||||
}
|
||||
}
|
||||
|
21
osu.Game/Rulesets/Edit/HitObjectMask.cs
Normal file
21
osu.Game/Rulesets/Edit/HitObjectMask.cs
Normal file
@ -0,0 +1,21 @@
|
||||
// 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.Graphics.Containers;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
|
||||
namespace osu.Game.Rulesets.Edit
|
||||
{
|
||||
/// <summary>
|
||||
/// A mask placed above a <see cref="DrawableHitObject"/> adding editing functionality.
|
||||
/// </summary>
|
||||
public class HitObjectMask : Container
|
||||
{
|
||||
public readonly DrawableHitObject HitObject;
|
||||
|
||||
public HitObjectMask(DrawableHitObject hitObject)
|
||||
{
|
||||
HitObject = hitObject;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
// 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.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.Rulesets.Edit.Layers
|
||||
{
|
||||
public class BorderLayer : Container
|
||||
{
|
||||
protected override Container<Drawable> Content => content;
|
||||
private readonly Container content;
|
||||
|
||||
public BorderLayer()
|
||||
{
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new Container
|
||||
{
|
||||
Name = "Border",
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Masking = true,
|
||||
BorderColour = Color4.White,
|
||||
BorderThickness = 2,
|
||||
Child = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Alpha = 0,
|
||||
AlwaysPresent = true
|
||||
}
|
||||
},
|
||||
content = new Container { RelativeSizeAxes = Axes.Both }
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -1,68 +0,0 @@
|
||||
// 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.Collections.Generic;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using OpenTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Edit.Layers.Selection
|
||||
{
|
||||
/// <summary>
|
||||
/// A box which encloses <see cref="DrawableHitObject"/>s.
|
||||
/// </summary>
|
||||
public class CaptureBox : VisibilityContainer
|
||||
{
|
||||
private readonly IDrawable captureArea;
|
||||
private readonly IReadOnlyList<DrawableHitObject> capturedObjects;
|
||||
|
||||
public CaptureBox(IDrawable captureArea, IReadOnlyList<DrawableHitObject> capturedObjects)
|
||||
{
|
||||
this.captureArea = captureArea;
|
||||
this.capturedObjects = capturedObjects;
|
||||
|
||||
Masking = true;
|
||||
BorderThickness = SelectionBox.BORDER_RADIUS;
|
||||
|
||||
InternalChild = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
AlwaysPresent = true,
|
||||
Alpha = 0
|
||||
};
|
||||
|
||||
State = Visibility.Visible;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
BorderColour = colours.Yellow;
|
||||
|
||||
// Move the rectangle to cover the hitobjects
|
||||
var topLeft = new Vector2(float.MaxValue, float.MaxValue);
|
||||
var bottomRight = new Vector2(float.MinValue, float.MinValue);
|
||||
|
||||
foreach (var obj in capturedObjects)
|
||||
{
|
||||
topLeft = Vector2.ComponentMin(topLeft, captureArea.ToLocalSpace(obj.SelectionQuad.TopLeft));
|
||||
bottomRight = Vector2.ComponentMax(bottomRight, captureArea.ToLocalSpace(obj.SelectionQuad.BottomRight));
|
||||
}
|
||||
|
||||
topLeft -= new Vector2(5);
|
||||
bottomRight += new Vector2(5);
|
||||
|
||||
Size = bottomRight - topLeft;
|
||||
Position = topLeft;
|
||||
}
|
||||
|
||||
public override bool DisposeOnDeathRemoval => true;
|
||||
|
||||
protected override void PopIn() => this.FadeIn();
|
||||
protected override void PopOut() => this.FadeOut();
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
// 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.Graphics.Containers;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
|
||||
namespace osu.Game.Rulesets.Edit.Layers.Selection
|
||||
{
|
||||
public class HitObjectOverlay : OverlayContainer
|
||||
{
|
||||
// ReSharper disable once NotAccessedField.Local
|
||||
// This will be used later to handle drag movement, etc
|
||||
private readonly DrawableHitObject hitObject;
|
||||
|
||||
public HitObjectOverlay(DrawableHitObject hitObject)
|
||||
{
|
||||
this.hitObject = hitObject;
|
||||
|
||||
State = Visibility.Visible;
|
||||
}
|
||||
|
||||
protected override void PopIn() => Alpha = 1;
|
||||
protected override void PopOut() => Alpha = 0;
|
||||
}
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
// 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.Collections.Generic;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
|
||||
namespace osu.Game.Rulesets.Edit.Layers.Selection
|
||||
{
|
||||
public class HitObjectOverlayLayer : CompositeDrawable
|
||||
{
|
||||
private readonly Dictionary<DrawableHitObject, HitObjectOverlay> existingOverlays = new Dictionary<DrawableHitObject, HitObjectOverlay>();
|
||||
|
||||
public HitObjectOverlayLayer()
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds an overlay for a <see cref="DrawableHitObject"/> which adds movement support.
|
||||
/// </summary>
|
||||
/// <param name="hitObject">The <see cref="DrawableHitObject"/> to create an overlay for.</param>
|
||||
public void AddOverlay(DrawableHitObject hitObject)
|
||||
{
|
||||
var overlay = CreateOverlayFor(hitObject);
|
||||
if (overlay == null)
|
||||
return;
|
||||
|
||||
existingOverlays[hitObject] = overlay;
|
||||
AddInternal(overlay);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the overlay for a <see cref="DrawableHitObject"/>.
|
||||
/// </summary>
|
||||
/// <param name="hitObject">The <see cref="DrawableHitObject"/> to remove the overlay for.</param>
|
||||
public void RemoveOverlay(DrawableHitObject hitObject)
|
||||
{
|
||||
if (!existingOverlays.TryGetValue(hitObject, out var existing))
|
||||
return;
|
||||
|
||||
existing.Hide();
|
||||
existing.Expire();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a <see cref="HitObjectOverlay"/> for a specific <see cref="DrawableHitObject"/>.
|
||||
/// </summary>
|
||||
/// <param name="hitObject">The <see cref="DrawableHitObject"/> to create the overlay for.</param>
|
||||
protected virtual HitObjectOverlay CreateOverlayFor(DrawableHitObject hitObject) => null;
|
||||
}
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
// 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.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.Rulesets.Edit.Layers.Selection
|
||||
{
|
||||
/// <summary>
|
||||
/// A box that represents a drag selection.
|
||||
/// </summary>
|
||||
public class SelectionBox : VisibilityContainer
|
||||
{
|
||||
public const float BORDER_RADIUS = 2;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="SelectionBox"/>.
|
||||
/// </summary>
|
||||
public SelectionBox()
|
||||
{
|
||||
Masking = true;
|
||||
BorderColour = Color4.White;
|
||||
BorderThickness = BORDER_RADIUS;
|
||||
|
||||
Child = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Alpha = 0.1f
|
||||
};
|
||||
}
|
||||
|
||||
public void SetDragRectangle(RectangleF rectangle)
|
||||
{
|
||||
var topLeft = Parent.ToLocalSpace(rectangle.TopLeft);
|
||||
var bottomRight = Parent.ToLocalSpace(rectangle.BottomRight);
|
||||
|
||||
Position = topLeft;
|
||||
Size = bottomRight - topLeft;
|
||||
}
|
||||
|
||||
public override bool DisposeOnDeathRemoval => true;
|
||||
|
||||
protected override void PopIn() => this.FadeIn(250, Easing.OutQuint);
|
||||
protected override void PopOut() => this.FadeOut(250, Easing.OutQuint);
|
||||
}
|
||||
}
|
@ -1,197 +0,0 @@
|
||||
// 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 System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using OpenTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Edit.Layers.Selection
|
||||
{
|
||||
public class SelectionLayer : CompositeDrawable
|
||||
{
|
||||
/// <summary>
|
||||
/// Invoked when a <see cref="DrawableHitObject"/> is selected.
|
||||
/// </summary>
|
||||
public event Action<DrawableHitObject> ObjectSelected;
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when a <see cref="DrawableHitObject"/> is deselected.
|
||||
/// </summary>
|
||||
public event Action<DrawableHitObject> ObjectDeselected;
|
||||
|
||||
private readonly Playfield playfield;
|
||||
|
||||
public SelectionLayer(Playfield playfield)
|
||||
{
|
||||
this.playfield = playfield;
|
||||
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
private SelectionBox selectionBox;
|
||||
private CaptureBox captureBox;
|
||||
|
||||
private readonly HashSet<DrawableHitObject> selectedHitObjects = new HashSet<DrawableHitObject>();
|
||||
|
||||
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
|
||||
{
|
||||
DeselectAll();
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override bool OnDragStart(InputState state)
|
||||
{
|
||||
AddInternal(selectionBox = new SelectionBox());
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override bool OnDrag(InputState state)
|
||||
{
|
||||
selectionBox.Show();
|
||||
|
||||
var dragPosition = state.Mouse.NativeState.Position;
|
||||
var dragStartPosition = state.Mouse.NativeState.PositionMouseDown ?? dragPosition;
|
||||
|
||||
var screenSpaceDragQuad = new Quad(dragStartPosition.X, dragStartPosition.Y, dragPosition.X - dragStartPosition.X, dragPosition.Y - dragStartPosition.Y);
|
||||
|
||||
selectionBox.SetDragRectangle(screenSpaceDragQuad.AABBFloat);
|
||||
selectQuad(screenSpaceDragQuad);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override bool OnDragEnd(InputState state)
|
||||
{
|
||||
selectionBox.Hide();
|
||||
selectionBox.Expire();
|
||||
|
||||
finishSelection();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override bool OnClick(InputState state)
|
||||
{
|
||||
selectPoint(state.Mouse.NativeState.Position);
|
||||
finishSelection();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Selects a <see cref="DrawableHitObject"/>.
|
||||
/// </summary>
|
||||
/// <param name="hitObject">The <see cref="DrawableHitObject"/> to select.</param>
|
||||
public void Select(DrawableHitObject hitObject)
|
||||
{
|
||||
if (!select(hitObject))
|
||||
return;
|
||||
|
||||
clearCapture();
|
||||
finishSelection();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Selects a <see cref="DrawableHitObject"/> without performing capture updates.
|
||||
/// </summary>
|
||||
/// <param name="hitObject">The <see cref="DrawableHitObject"/> to select.</param>
|
||||
/// <returns>Whether <paramref name="hitObject"/> was selected.</returns>
|
||||
private bool select(DrawableHitObject hitObject)
|
||||
{
|
||||
if (!selectedHitObjects.Add(hitObject))
|
||||
return false;
|
||||
|
||||
ObjectSelected?.Invoke(hitObject);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deselects a <see cref="DrawableHitObject"/>.
|
||||
/// </summary>
|
||||
/// <param name="hitObject">The <see cref="DrawableHitObject"/> to deselect.</param>
|
||||
public void Deselect(DrawableHitObject hitObject)
|
||||
{
|
||||
if (!deselect(hitObject))
|
||||
return;
|
||||
|
||||
clearCapture();
|
||||
finishSelection();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deselects a <see cref="DrawableHitObject"/> without performing capture updates.
|
||||
/// </summary>
|
||||
/// <param name="hitObject">The <see cref="DrawableHitObject"/> to deselect.</param>
|
||||
/// <returns>Whether the <see cref="DrawableHitObject"/> was deselected.</returns>
|
||||
private bool deselect(DrawableHitObject hitObject)
|
||||
{
|
||||
if (!selectedHitObjects.Remove(hitObject))
|
||||
return false;
|
||||
|
||||
ObjectDeselected?.Invoke(hitObject);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deselects all selected <see cref="DrawableHitObject"/>s.
|
||||
/// </summary>
|
||||
public void DeselectAll()
|
||||
{
|
||||
selectedHitObjects.ForEach(h => ObjectDeselected?.Invoke(h));
|
||||
selectedHitObjects.Clear();
|
||||
|
||||
clearCapture();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Selects all hitobjects that are present within the area of a <see cref="Quad"/>.
|
||||
/// </summary>
|
||||
/// <param name="screenSpaceQuad">The selection <see cref="Quad"/>.</param>
|
||||
// Todo: If needed we can severely reduce allocations in this method
|
||||
private void selectQuad(Quad screenSpaceQuad)
|
||||
{
|
||||
var expectedSelection = playfield.HitObjects.Objects.Where(h => h.IsAlive && h.IsPresent && screenSpaceQuad.Contains(h.SelectionPoint)).ToList();
|
||||
|
||||
var toRemove = selectedHitObjects.Except(expectedSelection).ToList();
|
||||
foreach (var obj in toRemove)
|
||||
deselect(obj);
|
||||
|
||||
expectedSelection.ForEach(h => select(h));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Selects the top-most hitobject that is present under a specific point.
|
||||
/// </summary>
|
||||
/// <param name="screenSpacePoint">The <see cref="Vector2"/> to select at.</param>
|
||||
private void selectPoint(Vector2 screenSpacePoint)
|
||||
{
|
||||
var target = playfield.HitObjects.Objects.Reverse().Where(h => h.IsAlive && h.IsPresent).FirstOrDefault(h => h.ReceiveMouseInputAt(screenSpacePoint));
|
||||
if (target == null)
|
||||
return;
|
||||
|
||||
select(target);
|
||||
}
|
||||
|
||||
private void clearCapture()
|
||||
{
|
||||
captureBox?.Hide();
|
||||
captureBox?.Expire();
|
||||
}
|
||||
|
||||
private void finishSelection()
|
||||
{
|
||||
if (selectedHitObjects.Count == 0)
|
||||
return;
|
||||
|
||||
AddInternal(captureBox = new CaptureBox(this, selectedHitObjects.ToList()));
|
||||
}
|
||||
}
|
||||
}
|
13
osu.Game/Rulesets/Edit/Types/IHasEditablePosition.cs
Normal file
13
osu.Game/Rulesets/Edit/Types/IHasEditablePosition.cs
Normal file
@ -0,0 +1,13 @@
|
||||
// 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;
|
||||
using OpenTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Edit.Types
|
||||
{
|
||||
public interface IHasEditablePosition : IHasPosition
|
||||
{
|
||||
void OffsetPosition(Vector2 offset);
|
||||
}
|
||||
}
|
@ -26,7 +26,7 @@ namespace osu.Game.Rulesets.Mods
|
||||
public override string Name => "Autoplay";
|
||||
public override string ShortenedName => "AT";
|
||||
public override FontAwesome Icon => FontAwesome.fa_osu_mod_auto;
|
||||
public override string Description => "Watch a perfect automated play through the song";
|
||||
public override string Description => "Watch a perfect automated play through the song.";
|
||||
public override double ScoreMultiplier => 0;
|
||||
public bool AllowFail => false;
|
||||
public override Type[] IncompatibleMods => new[] { typeof(ModRelax), typeof(ModSuddenDeath), typeof(ModNoFail) };
|
||||
|
@ -11,5 +11,6 @@ namespace osu.Game.Rulesets.Mods
|
||||
public override string ShortenedName => "CN";
|
||||
public override bool HasImplementation => false;
|
||||
public override FontAwesome Icon => FontAwesome.fa_osu_mod_cinema;
|
||||
public override string Description => "Watch the video without visual distractions.";
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ namespace osu.Game.Rulesets.Mods
|
||||
public override string Name => "Daycore";
|
||||
public override string ShortenedName => "DC";
|
||||
public override FontAwesome Icon => FontAwesome.fa_question;
|
||||
public override string Description => "whoaaaaa";
|
||||
public override string Description => "Whoaaaaa...";
|
||||
|
||||
public override void ApplyToClock(IAdjustableClock clock)
|
||||
{
|
||||
|
@ -7,18 +7,16 @@ using osu.Game.Graphics;
|
||||
|
||||
namespace osu.Game.Rulesets.Mods
|
||||
{
|
||||
public class ModDoubleTime : Mod, IApplicableToClock
|
||||
public abstract class ModDoubleTime : Mod, IApplicableToClock
|
||||
{
|
||||
public override string Name => "Double Time";
|
||||
public override string ShortenedName => "DT";
|
||||
public override FontAwesome Icon => FontAwesome.fa_osu_mod_doubletime;
|
||||
public override ModType Type => ModType.DifficultyIncrease;
|
||||
public override string Description => "Zoooooooooom";
|
||||
public override string Description => "Zoooooooooom...";
|
||||
public override bool Ranked => true;
|
||||
public override Type[] IncompatibleMods => new[] { typeof(ModHalfTime) };
|
||||
|
||||
public override double ScoreMultiplier => 1.12;
|
||||
|
||||
public virtual void ApplyToClock(IAdjustableClock clock)
|
||||
{
|
||||
clock.Rate = 1.5;
|
||||
|
@ -13,7 +13,6 @@ namespace osu.Game.Rulesets.Mods
|
||||
public override string ShortenedName => "EZ";
|
||||
public override FontAwesome Icon => FontAwesome.fa_osu_mod_easy;
|
||||
public override ModType Type => ModType.DifficultyReduction;
|
||||
public override string Description => "Reduces overall difficulty - larger circles, more forgiving HP drain, less accuracy required.";
|
||||
public override double ScoreMultiplier => 0.5;
|
||||
public override bool Ranked => true;
|
||||
public override Type[] IncompatibleMods => new[] { typeof(ModHardRock) };
|
||||
|
@ -13,12 +13,10 @@ namespace osu.Game.Rulesets.Mods
|
||||
public override string ShortenedName => "HT";
|
||||
public override FontAwesome Icon => FontAwesome.fa_osu_mod_halftime;
|
||||
public override ModType Type => ModType.DifficultyReduction;
|
||||
public override string Description => "Less zoom";
|
||||
public override string Description => "Less zoom...";
|
||||
public override bool Ranked => true;
|
||||
public override Type[] IncompatibleMods => new[] { typeof(ModDoubleTime) };
|
||||
|
||||
public override double ScoreMultiplier => 1.12;
|
||||
|
||||
public virtual void ApplyToClock(IAdjustableClock clock)
|
||||
{
|
||||
clock.Rate = 0.75;
|
||||
|
@ -14,6 +14,7 @@ namespace osu.Game.Rulesets.Mods
|
||||
public override FontAwesome Icon => FontAwesome.fa_osu_mod_hardrock;
|
||||
public override ModType Type => ModType.DifficultyIncrease;
|
||||
public override string Description => "Everything just got a bit harder...";
|
||||
public override bool Ranked => true;
|
||||
public override Type[] IncompatibleMods => new[] { typeof(ModEasy) };
|
||||
|
||||
public void ApplyToDifficulty(BeatmapDifficulty difficulty)
|
||||
|
@ -12,7 +12,7 @@ namespace osu.Game.Rulesets.Mods
|
||||
public override string Name => "Nightcore";
|
||||
public override string ShortenedName => "NC";
|
||||
public override FontAwesome Icon => FontAwesome.fa_osu_mod_nightcore;
|
||||
public override string Description => "uguuuuuuuu";
|
||||
public override string Description => "Uguuuuuuuu...";
|
||||
|
||||
public override void ApplyToClock(IAdjustableClock clock)
|
||||
{
|
||||
|
@ -8,7 +8,7 @@ namespace osu.Game.Rulesets.Mods
|
||||
{
|
||||
public abstract class ModNoFail : Mod, IApplicableFailOverride
|
||||
{
|
||||
public override string Name => "NoFail";
|
||||
public override string Name => "No Fail";
|
||||
public override string ShortenedName => "NF";
|
||||
public override FontAwesome Icon => FontAwesome.fa_osu_mod_nofail;
|
||||
public override ModType Type => ModType.DifficultyReduction;
|
||||
|
@ -1,6 +1,7 @@
|
||||
// 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.Graphics;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
|
||||
namespace osu.Game.Rulesets.Mods
|
||||
@ -9,6 +10,7 @@ namespace osu.Game.Rulesets.Mods
|
||||
{
|
||||
public override string Name => "Perfect";
|
||||
public override string ShortenedName => "PF";
|
||||
public override FontAwesome Icon => FontAwesome.fa_question;
|
||||
public override string Description => "SS or quit.";
|
||||
|
||||
protected override bool FailCondition(ScoreProcessor scoreProcessor) => scoreProcessor.Accuracy.Value != 1;
|
||||
|
@ -13,7 +13,7 @@ namespace osu.Game.Rulesets.Mods
|
||||
public override string ShortenedName => "SD";
|
||||
public override FontAwesome Icon => FontAwesome.fa_osu_mod_suddendeath;
|
||||
public override ModType Type => ModType.DifficultyIncrease;
|
||||
public override string Description => "Miss a note and fail.";
|
||||
public override string Description => "Miss and fail.";
|
||||
public override double ScoreMultiplier => 1;
|
||||
public override bool Ranked => true;
|
||||
public override Type[] IncompatibleMods => new[] { typeof(ModNoFail), typeof(ModRelax), typeof(ModAutoplay) };
|
||||
|
@ -8,7 +8,7 @@ namespace osu.Game.Rulesets.Mods
|
||||
public override string Name => string.Empty;
|
||||
public override string ShortenedName => string.Empty;
|
||||
public override string Description => string.Empty;
|
||||
public override double ScoreMultiplier => 0.0;
|
||||
public override double ScoreMultiplier => 0;
|
||||
|
||||
public Mod[] Mods;
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.Rulesets.Objects.Drawables
|
||||
{
|
||||
public abstract class DrawableHitObject : Container, IHasAccentColour
|
||||
public abstract class DrawableHitObject : CompositeDrawable, IHasAccentColour
|
||||
{
|
||||
public readonly HitObject HitObject;
|
||||
|
||||
|
Reference in New Issue
Block a user