Merge branch 'master' into fix-dragbox-first-frame

This commit is contained in:
Dean Herbert
2019-10-24 23:01:32 +09:00
committed by GitHub
5 changed files with 52 additions and 8 deletions

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System; using System;
using System.Collections.Generic;
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -14,6 +15,7 @@ using osu.Game.Rulesets.Osu.Beatmaps;
using osu.Game.Rulesets.Osu.Edit; using osu.Game.Rulesets.Osu.Edit;
using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Screens.Edit; using osu.Game.Screens.Edit;
using osu.Game.Screens.Edit.Compose.Components;
using osu.Game.Tests.Visual; using osu.Game.Tests.Visual;
using osuTK; using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
@ -25,6 +27,11 @@ namespace osu.Game.Rulesets.Osu.Tests
private const double beat_length = 100; private const double beat_length = 100;
private static readonly Vector2 grid_position = new Vector2(512, 384); private static readonly Vector2 grid_position = new Vector2(512, 384);
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(CircularDistanceSnapGrid)
};
[Cached(typeof(IEditorBeatmap))] [Cached(typeof(IEditorBeatmap))]
private readonly EditorBeatmap<OsuHitObject> editorBeatmap; private readonly EditorBeatmap<OsuHitObject> editorBeatmap;

View File

@ -6,6 +6,7 @@ using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Input;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Edit;
@ -28,6 +29,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
private readonly List<Segment> segments = new List<Segment>(); private readonly List<Segment> segments = new List<Segment>();
private Vector2 cursor; private Vector2 cursor;
private InputManager inputManager;
private PlacementState state; private PlacementState state;
@ -52,6 +54,12 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
setState(PlacementState.Initial); setState(PlacementState.Initial);
} }
protected override void LoadComplete()
{
base.LoadComplete();
inputManager = GetContainingInputManager();
}
public override void UpdatePosition(Vector2 screenSpacePosition) public override void UpdatePosition(Vector2 screenSpacePosition)
{ {
switch (state) switch (state)
@ -61,7 +69,9 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
break; break;
case PlacementState.Body: case PlacementState.Body:
cursor = ToLocalSpace(screenSpacePosition) - HitObject.Position; // The given screen-space position may have been externally snapped, but the unsnapped position from the input manager
// is used instead since snapping control points doesn't make much sense
cursor = ToLocalSpace(inputManager.CurrentState.Mouse.Position) - HitObject.Position;
break; break;
} }
} }

View File

@ -162,11 +162,13 @@ namespace osu.Game.Rulesets.Edit
inputManager = GetContainingInputManager(); inputManager = GetContainingInputManager();
} }
private double lastGridUpdateTime;
protected override void Update() protected override void Update()
{ {
base.Update(); base.Update();
if (EditorClock.ElapsedFrameTime != 0 && blueprintContainer.CurrentTool != null) if (EditorClock.CurrentTime != lastGridUpdateTime && blueprintContainer.CurrentTool != null)
showGridFor(Enumerable.Empty<HitObject>()); showGridFor(Enumerable.Empty<HitObject>());
} }
@ -213,6 +215,8 @@ namespace osu.Game.Rulesets.Edit
distanceSnapGridContainer.Child = distanceSnapGrid; distanceSnapGridContainer.Child = distanceSnapGrid;
distanceSnapGridContainer.Show(); distanceSnapGridContainer.Show();
} }
lastGridUpdateTime = EditorClock.CurrentTime;
} }
private ScheduledDelegate scheduledUpdate; private ScheduledDelegate scheduledUpdate;

View File

@ -3,6 +3,7 @@
using System; using System;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface;
using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects;
using osuTK; using osuTK;
@ -18,10 +19,32 @@ namespace osu.Game.Screens.Edit.Compose.Components
protected override void CreateContent(Vector2 centrePosition) protected override void CreateContent(Vector2 centrePosition)
{ {
const float crosshair_thickness = 1;
const float crosshair_max_size = 10;
AddRangeInternal(new[]
{
new Box
{
Origin = Anchor.Centre,
Position = centrePosition,
Width = crosshair_thickness,
EdgeSmoothness = new Vector2(1),
Height = Math.Min(crosshair_max_size, DistanceSpacing * 2),
},
new Box
{
Origin = Anchor.Centre,
Position = centrePosition,
EdgeSmoothness = new Vector2(1),
Width = Math.Min(crosshair_max_size, DistanceSpacing * 2),
Height = crosshair_thickness,
}
});
float dx = Math.Max(centrePosition.X, DrawWidth - centrePosition.X); float dx = Math.Max(centrePosition.X, DrawWidth - centrePosition.X);
float dy = Math.Max(centrePosition.Y, DrawHeight - centrePosition.Y); float dy = Math.Max(centrePosition.Y, DrawHeight - centrePosition.Y);
float maxDistance = new Vector2(dx, dy).Length; float maxDistance = new Vector2(dx, dy).Length;
int requiredCircles = (int)(maxDistance / DistanceSpacing); int requiredCircles = (int)(maxDistance / DistanceSpacing);
for (int i = 0; i < requiredCircles; i++) for (int i = 0; i < requiredCircles; i++)

View File

@ -36,15 +36,15 @@ namespace osu.Game.Screens.Edit.Compose.Components
/// </summary> /// </summary>
protected readonly Vector2 CentrePosition; protected readonly Vector2 CentrePosition;
[Resolved]
protected OsuColour Colours { get; private set; }
[Resolved] [Resolved]
private IEditorBeatmap beatmap { get; set; } private IEditorBeatmap beatmap { get; set; }
[Resolved] [Resolved]
private BindableBeatDivisor beatDivisor { get; set; } private BindableBeatDivisor beatDivisor { get; set; }
[Resolved]
private OsuColour colours { get; set; }
private readonly Cached gridCache = new Cached(); private readonly Cached gridCache = new Cached();
private readonly HitObject hitObject; private readonly HitObject hitObject;
@ -136,7 +136,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
protected ColourInfo GetColourForBeatIndex(int index) protected ColourInfo GetColourForBeatIndex(int index)
{ {
int beat = (index + 1) % beatDivisor.Value; int beat = (index + 1) % beatDivisor.Value;
ColourInfo colour = colours.Gray5; ColourInfo colour = Colours.Gray5;
for (int i = 0; i < BindableBeatDivisor.VALID_DIVISORS.Length; i++) for (int i = 0; i < BindableBeatDivisor.VALID_DIVISORS.Length; i++)
{ {
@ -144,7 +144,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
if ((beat * divisor) % beatDivisor.Value == 0) if ((beat * divisor) % beatDivisor.Value == 0)
{ {
colour = BindableBeatDivisor.GetColourFor(divisor, colours); colour = BindableBeatDivisor.GetColourFor(divisor, Colours);
break; break;
} }
} }