mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Make the dragger attach to objects it surrounds
Plus a lot more implementation.
This commit is contained in:
Submodule osu-framework updated: 4fc866eee3...d231ca9f79
@ -9,6 +9,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Game.Rulesets.Osu.Judgements;
|
using osu.Game.Rulesets.Osu.Judgements;
|
||||||
|
using osu.Framework.Graphics.Primitives;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||||
{
|
{
|
||||||
@ -165,6 +166,9 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Drawable ProxiedLayer => initialCircle.ApproachCircle;
|
public Drawable ProxiedLayer => initialCircle.ApproachCircle;
|
||||||
|
|
||||||
|
public override Vector2 SelectionPoint => body.Position;
|
||||||
|
public override Quad SelectionQuad => body.PathDrawQuad;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal interface ISliderProgress
|
internal interface ISliderProgress
|
||||||
|
@ -14,6 +14,7 @@ using osu.Game.Configuration;
|
|||||||
using OpenTK;
|
using OpenTK;
|
||||||
using OpenTK.Graphics.ES30;
|
using OpenTK.Graphics.ES30;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
|
using osu.Framework.Graphics.Primitives;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
||||||
{
|
{
|
||||||
@ -49,6 +50,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Quad PathDrawQuad => container.ScreenSpaceDrawQuad;
|
||||||
|
|
||||||
private int textureWidth => (int)PathWidth * 2;
|
private int textureWidth => (int)PathWidth * 2;
|
||||||
|
|
||||||
private readonly Slider slider;
|
private readonly Slider slider;
|
||||||
@ -182,4 +185,4 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
|||||||
SetRange(start, end);
|
SetRange(start, end);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,10 @@
|
|||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Rulesets.Edit;
|
||||||
using osu.Game.Screens.Edit.Screens.Compose;
|
using osu.Game.Screens.Edit.Screens.Compose;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual
|
namespace osu.Game.Tests.Visual
|
||||||
|
54
osu.Game.Tests/Visual/TestCaseEditorPlayfieldOverlay.cs
Normal file
54
osu.Game.Tests/Visual/TestCaseEditorPlayfieldOverlay.cs
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
// Copyright (c) 2007-2017 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 OpenTK;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Timing;
|
||||||
|
using osu.Game.Rulesets.Edit;
|
||||||
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
|
using osu.Game.Rulesets.Osu.Edit;
|
||||||
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||||
|
using osu.Game.Rulesets.Osu.UI;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual
|
||||||
|
{
|
||||||
|
public class TestCaseEditorPlayfieldOverlay : OsuTestCase
|
||||||
|
{
|
||||||
|
public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(PlayfieldOverlay) };
|
||||||
|
|
||||||
|
public TestCaseEditorPlayfieldOverlay()
|
||||||
|
{
|
||||||
|
var playfield = new OsuEditPlayfield();
|
||||||
|
playfield.Add(new DrawableHitCircle(new HitCircle { Position = new Vector2(256, 192), Scale = 0.5f }));
|
||||||
|
playfield.Add(new DrawableHitCircle(new HitCircle { Position = new Vector2(344, 148), Scale = 0.5f }));
|
||||||
|
playfield.Add(new DrawableSlider(new Slider
|
||||||
|
{
|
||||||
|
ControlPoints = new List<Vector2>
|
||||||
|
{
|
||||||
|
new Vector2(128, 256),
|
||||||
|
new Vector2(344, 256),
|
||||||
|
},
|
||||||
|
Distance = 400,
|
||||||
|
Position = new Vector2(128, 256),
|
||||||
|
Velocity = 1,
|
||||||
|
TickDistance = 100,
|
||||||
|
Scale = 0.5f
|
||||||
|
}));
|
||||||
|
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new Container
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Clock = new FramedClock(new StopwatchClock()),
|
||||||
|
Child = playfield
|
||||||
|
},
|
||||||
|
new PlayfieldOverlay(playfield)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -110,6 +110,7 @@
|
|||||||
<Compile Include="Visual\TestCaseEditorComposeTimeline.cs" />
|
<Compile Include="Visual\TestCaseEditorComposeTimeline.cs" />
|
||||||
<Compile Include="Visual\TestCaseEditorMenuBar.cs" />
|
<Compile Include="Visual\TestCaseEditorMenuBar.cs" />
|
||||||
<Compile Include="Visual\TestCaseEditorSummaryTimeline.cs" />
|
<Compile Include="Visual\TestCaseEditorSummaryTimeline.cs" />
|
||||||
|
<Compile Include="Visual\TestCaseEditorPlayfieldOverlay.cs" />
|
||||||
<Compile Include="Visual\TestCaseGamefield.cs" />
|
<Compile Include="Visual\TestCaseGamefield.cs" />
|
||||||
<Compile Include="Visual\TestCaseGraph.cs" />
|
<Compile Include="Visual\TestCaseGraph.cs" />
|
||||||
<Compile Include="Visual\TestCaseIconButton.cs" />
|
<Compile Include="Visual\TestCaseIconButton.cs" />
|
||||||
|
@ -77,7 +77,7 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
Alpha = 0,
|
Alpha = 0,
|
||||||
AlwaysPresent = true,
|
AlwaysPresent = true,
|
||||||
},
|
},
|
||||||
CreateUnderlay(rulesetContainer.Playfield),
|
CreateUnderlay(),
|
||||||
rulesetContainer,
|
rulesetContainer,
|
||||||
CreateOverlay(rulesetContainer.Playfield)
|
CreateOverlay(rulesetContainer.Playfield)
|
||||||
}
|
}
|
||||||
@ -106,9 +106,9 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
|
|
||||||
protected virtual RulesetContainer CreateRulesetContainer(Ruleset ruleset, WorkingBeatmap beatmap) => ruleset.CreateRulesetContainerWith(beatmap, true);
|
protected virtual RulesetContainer CreateRulesetContainer(Ruleset ruleset, WorkingBeatmap beatmap) => ruleset.CreateRulesetContainerWith(beatmap, true);
|
||||||
|
|
||||||
protected virtual PlayfieldUnderlay CreateUnderlay(Playfield playfield) => new PlayfieldUnderlay();
|
protected virtual PlayfieldUnderlay CreateUnderlay() => new PlayfieldUnderlay();
|
||||||
|
|
||||||
protected virtual PlayfieldOverlay CreateOverlay(Playfield playfield) => new PlayfieldOverlay();
|
protected virtual PlayfieldOverlay CreateOverlay(Playfield playfield) => new PlayfieldOverlay(playfield);
|
||||||
|
|
||||||
protected abstract IReadOnlyList<ICompositionTool> CompositionTools { get; }
|
protected abstract IReadOnlyList<ICompositionTool> CompositionTools { get; }
|
||||||
}
|
}
|
||||||
|
@ -9,15 +9,27 @@ using osu.Framework.Graphics.Shapes;
|
|||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
|
using osu.Game.Rulesets.UI;
|
||||||
|
using System.Linq;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Edit
|
namespace osu.Game.Rulesets.Edit
|
||||||
{
|
{
|
||||||
public class PlayfieldOverlay : CompositeDrawable
|
public class PlayfieldOverlay : CompositeDrawable
|
||||||
{
|
{
|
||||||
private readonly Drawable dragBox;
|
private readonly static Color4 selection_normal_colour = Color4.White;
|
||||||
|
private readonly static Color4 selection_attached_colour = OsuColour.FromHex("eeaa00");
|
||||||
|
|
||||||
public PlayfieldOverlay()
|
private readonly Container dragBox;
|
||||||
|
|
||||||
|
private readonly Playfield playfield;
|
||||||
|
|
||||||
|
public PlayfieldOverlay(Playfield playfield)
|
||||||
{
|
{
|
||||||
|
this.playfield = playfield;
|
||||||
|
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
|
||||||
InternalChildren = new[]
|
InternalChildren = new[]
|
||||||
@ -31,25 +43,31 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
Child = new Box
|
Child = new Box
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Alpha = 0,
|
Alpha = 0.1f
|
||||||
AlwaysPresent = true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private Vector2 dragStartPos;
|
private Vector2 dragStartPos;
|
||||||
|
private RectangleF dragRectangle;
|
||||||
|
private List<DrawableHitObject> capturedHitObjects = new List<DrawableHitObject>();
|
||||||
|
|
||||||
protected override bool OnDragStart(InputState state)
|
protected override bool OnDragStart(InputState state)
|
||||||
{
|
{
|
||||||
dragStartPos = ToLocalSpace(state.Mouse.NativeState.Position);
|
dragStartPos = ToLocalSpace(state.Mouse.NativeState.Position);
|
||||||
|
dragBox.Position = dragStartPos;
|
||||||
|
dragBox.Size = Vector2.Zero;
|
||||||
|
dragBox.FadeTo(1);
|
||||||
|
dragBox.FadeColour(selection_normal_colour);
|
||||||
|
dragBox.BorderThickness = 2;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnDrag(InputState state)
|
protected override bool OnDrag(InputState state)
|
||||||
{
|
{
|
||||||
var dragPos = ToLocalSpace(state.Mouse.NativeState.Position);
|
var dragPos = ToLocalSpace(state.Mouse.NativeState.Position);
|
||||||
var dragRectangle = RectangleF.FromLTRB(
|
dragRectangle = RectangleF.FromLTRB(
|
||||||
Math.Min(dragStartPos.X, dragPos.X),
|
Math.Min(dragStartPos.X, dragPos.X),
|
||||||
Math.Min(dragStartPos.Y, dragPos.Y),
|
Math.Min(dragStartPos.Y, dragPos.Y),
|
||||||
Math.Max(dragStartPos.X, dragPos.X),
|
Math.Max(dragStartPos.X, dragPos.X),
|
||||||
@ -58,11 +76,51 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
dragBox.Position = dragRectangle.Location;
|
dragBox.Position = dragRectangle.Location;
|
||||||
dragBox.Size = dragRectangle.Size;
|
dragBox.Size = dragRectangle.Size;
|
||||||
|
|
||||||
|
updateCapturedHitObjects();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateCapturedHitObjects()
|
||||||
|
{
|
||||||
|
capturedHitObjects.Clear();
|
||||||
|
|
||||||
|
foreach (var obj in playfield.HitObjects.Objects)
|
||||||
|
{
|
||||||
|
if (!obj.IsAlive || !obj.IsPresent)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var objectPosition = obj.Parent.ToScreenSpace(obj.SelectionPoint);
|
||||||
|
if (dragRectangle.Contains(ToLocalSpace(objectPosition)))
|
||||||
|
capturedHitObjects.Add(obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected override bool OnDragEnd(InputState state)
|
protected override bool OnDragEnd(InputState state)
|
||||||
{
|
{
|
||||||
|
if (capturedHitObjects.Count == 0)
|
||||||
|
dragBox.FadeOut(400, Easing.OutQuint);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 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 capturedHitObjects)
|
||||||
|
{
|
||||||
|
topLeft = Vector2.ComponentMin(topLeft, ToLocalSpace(obj.SelectionQuad.TopLeft));
|
||||||
|
bottomRight = Vector2.ComponentMax(bottomRight, ToLocalSpace(obj.SelectionQuad.BottomRight));
|
||||||
|
}
|
||||||
|
|
||||||
|
topLeft -= new Vector2(5);
|
||||||
|
bottomRight += new Vector2(5);
|
||||||
|
|
||||||
|
dragBox.MoveTo(topLeft, 200, Easing.OutQuint)
|
||||||
|
.ResizeTo(bottomRight - topLeft, 200, Easing.OutQuint)
|
||||||
|
.FadeColour(selection_attached_colour, 200, Easing.OutQuint);
|
||||||
|
dragBox.BorderThickness = 3;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
12
osu.Game/Rulesets/Edit/SelectionDragger.cs
Normal file
12
osu.Game/Rulesets/Edit/SelectionDragger.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Edit
|
||||||
|
{
|
||||||
|
public class SelectionDragger : CompositeDrawable
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -14,6 +14,8 @@ using osu.Game.Audio;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Framework.Configuration;
|
using osu.Framework.Configuration;
|
||||||
|
using OpenTK;
|
||||||
|
using osu.Framework.Graphics.Primitives;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Objects.Drawables
|
namespace osu.Game.Rulesets.Objects.Drawables
|
||||||
{
|
{
|
||||||
@ -38,6 +40,16 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
|||||||
{
|
{
|
||||||
HitObject = hitObject;
|
HitObject = hitObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The local point that causes this <see cref="DrawableHitObject"/> to be selected in the Editor.
|
||||||
|
/// </summary>
|
||||||
|
public virtual Vector2 SelectionPoint => DrawPosition;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The local rectangle that outlines this <see cref="DrawableHitObject"/> for selections in the Editor.
|
||||||
|
/// </summary>
|
||||||
|
public virtual Quad SelectionQuad => ScreenSpaceDrawQuad;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract class DrawableHitObject<TObject> : DrawableHitObject
|
public abstract class DrawableHitObject<TObject> : DrawableHitObject
|
||||||
|
@ -55,10 +55,11 @@ namespace osu.Game.Rulesets.UI
|
|||||||
|
|
||||||
public abstract IEnumerable<HitObject> Objects { get; }
|
public abstract IEnumerable<HitObject> Objects { get; }
|
||||||
|
|
||||||
|
private Playfield playfield;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The playfield.
|
/// The playfield.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Playfield Playfield { get; protected set; }
|
public Playfield Playfield => playfield ?? (playfield = CreatePlayfield());
|
||||||
|
|
||||||
protected readonly Ruleset Ruleset;
|
protected readonly Ruleset Ruleset;
|
||||||
|
|
||||||
@ -95,6 +96,12 @@ namespace osu.Game.Rulesets.UI
|
|||||||
Replay = replay;
|
Replay = replay;
|
||||||
ReplayInputManager.ReplayInputHandler = replay != null ? CreateReplayInputHandler(replay) : null;
|
ReplayInputManager.ReplayInputHandler = replay != null ? CreateReplayInputHandler(replay) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a Playfield.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The Playfield.</returns>
|
||||||
|
protected abstract Playfield CreatePlayfield();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -198,7 +205,7 @@ namespace osu.Game.Rulesets.UI
|
|||||||
});
|
});
|
||||||
|
|
||||||
AddInternal(KeyBindingInputManager);
|
AddInternal(KeyBindingInputManager);
|
||||||
KeyBindingInputManager.Add(Playfield = CreatePlayfield());
|
KeyBindingInputManager.Add(Playfield);
|
||||||
|
|
||||||
loadObjects();
|
loadObjects();
|
||||||
}
|
}
|
||||||
@ -286,12 +293,6 @@ namespace osu.Game.Rulesets.UI
|
|||||||
/// <param name="h">The HitObject to make drawable.</param>
|
/// <param name="h">The HitObject to make drawable.</param>
|
||||||
/// <returns>The DrawableHitObject.</returns>
|
/// <returns>The DrawableHitObject.</returns>
|
||||||
protected abstract DrawableHitObject<TObject> GetVisualRepresentation(TObject h);
|
protected abstract DrawableHitObject<TObject> GetVisualRepresentation(TObject h);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Creates a Playfield.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>The Playfield.</returns>
|
|
||||||
protected abstract Playfield CreatePlayfield();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -304,6 +304,7 @@
|
|||||||
<Compile Include="Overlays\Settings\SettingsButton.cs" />
|
<Compile Include="Overlays\Settings\SettingsButton.cs" />
|
||||||
<Compile Include="Rulesets\Edit\PlayfieldOverlay.cs" />
|
<Compile Include="Rulesets\Edit\PlayfieldOverlay.cs" />
|
||||||
<Compile Include="Rulesets\Edit\PlayfieldUnderlay.cs" />
|
<Compile Include="Rulesets\Edit\PlayfieldUnderlay.cs" />
|
||||||
|
<Compile Include="Rulesets\Edit\PlayfieldUnderlay.cs" />
|
||||||
<Compile Include="Screens\Edit\Components\BottomBarContainer.cs" />
|
<Compile Include="Screens\Edit\Components\BottomBarContainer.cs" />
|
||||||
<Compile Include="Screens\Edit\Components\PlaybackControl.cs" />
|
<Compile Include="Screens\Edit\Components\PlaybackControl.cs" />
|
||||||
<Compile Include="Screens\Edit\Components\TimeInfoContainer.cs" />
|
<Compile Include="Screens\Edit\Components\TimeInfoContainer.cs" />
|
||||||
@ -567,6 +568,7 @@
|
|||||||
<Compile Include="Rulesets\Edit\Tools\HitObjectCompositionTool.cs" />
|
<Compile Include="Rulesets\Edit\Tools\HitObjectCompositionTool.cs" />
|
||||||
<Compile Include="Rulesets\Edit\Tools\ICompositionTool.cs" />
|
<Compile Include="Rulesets\Edit\Tools\ICompositionTool.cs" />
|
||||||
<Compile Include="Rulesets\Edit\HitObjectComposer.cs" />
|
<Compile Include="Rulesets\Edit\HitObjectComposer.cs" />
|
||||||
|
<Compile Include="Rulesets\Edit\SelectionDragger.cs" />
|
||||||
<Compile Include="Rulesets\Edit\ToolboxGroup.cs" />
|
<Compile Include="Rulesets\Edit\ToolboxGroup.cs" />
|
||||||
<Compile Include="Rulesets\Judgements\DrawableJudgement.cs" />
|
<Compile Include="Rulesets\Judgements\DrawableJudgement.cs" />
|
||||||
<Compile Include="Rulesets\Judgements\Judgement.cs" />
|
<Compile Include="Rulesets\Judgements\Judgement.cs" />
|
||||||
|
Reference in New Issue
Block a user