mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 19:22:54 +08:00
6d4f94756e
The general idea here is that we need the masks to handle mouse down events, as they need to handle the drag (mousedown -> drag immediately). I've rewritten the editor selections to use events, as there are some 3 different components that handle/trigger selections in different ways. 1. All selections/deselections now propagate through `HitObjectMask.Select()`/`HitObjectMask.Deselect()`. 2. Components that react to changes in the selection bind to the masks' `Selected`/`Deselected` events, and track them/change their states locally. 3. Masks provide a `SingleSelectionRequested` event which is invoked on the mouse-down event. Various components bind to this event to perform state changes locally in this scenario. 4. `DragBox` now handles all drag input locally. It triggers `Select`/`Deselect` on the masks it needs to. 5. `SelectionBox` handles the display of itself locally. 6. `SelectionBox` handles movement of groups of masks locally. 7. `HitObjectMasks` handles movement of itself locally.
77 lines
2.7 KiB
C#
77 lines
2.7 KiB
C#
// 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 JetBrains.Annotations;
|
|
using NUnit.Framework;
|
|
using osu.Framework.Allocation;
|
|
using osu.Framework.Timing;
|
|
using OpenTK;
|
|
using osu.Game.Beatmaps;
|
|
using osu.Game.Rulesets.Edit;
|
|
using osu.Game.Rulesets.Objects;
|
|
using osu.Game.Rulesets.Osu;
|
|
using osu.Game.Rulesets.Osu.Edit;
|
|
using osu.Game.Rulesets.Osu.Edit.Layers.Selection.Overlays;
|
|
using osu.Game.Rulesets.Osu.Objects;
|
|
using osu.Game.Screens.Edit.Screens.Compose.Layers;
|
|
using osu.Game.Tests.Beatmaps;
|
|
|
|
namespace osu.Game.Tests.Visual
|
|
{
|
|
[TestFixture]
|
|
public class TestCaseEditorSelectionLayer : OsuTestCase
|
|
{
|
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
|
{
|
|
typeof(SelectionBox),
|
|
typeof(HitObjectComposer),
|
|
typeof(OsuHitObjectComposer),
|
|
typeof(HitObjectMaskLayer),
|
|
typeof(HitObjectMask),
|
|
typeof(HitCircleMask),
|
|
typeof(SliderMask),
|
|
typeof(SliderCircleMask),
|
|
typeof(NotNullAttribute)
|
|
};
|
|
|
|
private DependencyContainer dependencies;
|
|
|
|
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent)
|
|
=> dependencies = new DependencyContainer(parent);
|
|
|
|
[BackgroundDependencyLoader]
|
|
private void load(OsuGameBase osuGame)
|
|
{
|
|
osuGame.Beatmap.Value = new TestWorkingBeatmap(new Beatmap
|
|
{
|
|
HitObjects = new List<HitObject>
|
|
{
|
|
new HitCircle { Position = new Vector2(256, 192), Scale = 0.5f },
|
|
new HitCircle { Position = new Vector2(344, 148), Scale = 0.5f },
|
|
new Slider
|
|
{
|
|
Position = new Vector2(128, 256),
|
|
ControlPoints = new List<Vector2>
|
|
{
|
|
Vector2.Zero,
|
|
new Vector2(216, 0),
|
|
},
|
|
Distance = 400,
|
|
Velocity = 1,
|
|
TickDistance = 100,
|
|
Scale = 0.5f,
|
|
}
|
|
},
|
|
});
|
|
|
|
var clock = new DecoupleableInterpolatingFramedClock { IsCoupled = false };
|
|
dependencies.CacheAs<IAdjustableClock>(clock);
|
|
dependencies.CacheAs<IFrameBasedClock>(clock);
|
|
|
|
Child = new OsuHitObjectComposer(new OsuRuleset());
|
|
}
|
|
}
|
|
}
|