mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 06:12:56 +08:00
Merge pull request #3656 from smoogipoo/spinner-selection
Implement spinner selections
This commit is contained in:
commit
16d9ab2a0e
50
osu.Game.Rulesets.Osu.Tests/TestCaseSpinnerSelectionMask.cs
Normal file
50
osu.Game.Rulesets.Osu.Tests/TestCaseSpinnerSelectionMask.cs
Normal file
@ -0,0 +1,50 @@
|
||||
// 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 osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Rulesets.Osu.Edit.Masks.SpinnerMasks;
|
||||
using osu.Game.Rulesets.Osu.Edit.Masks.SpinnerMasks.Components;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||
using osu.Game.Tests.Visual;
|
||||
using OpenTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Tests
|
||||
{
|
||||
public class TestCaseSpinnerSelectionMask : HitObjectSelectionMaskTestCase
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(SpinnerSelectionMask),
|
||||
typeof(SpinnerPiece)
|
||||
};
|
||||
|
||||
private readonly DrawableSpinner drawableSpinner;
|
||||
|
||||
public TestCaseSpinnerSelectionMask()
|
||||
{
|
||||
var spinner = new Spinner
|
||||
{
|
||||
Position = new Vector2(256, 256),
|
||||
StartTime = -1000,
|
||||
EndTime = 2000
|
||||
};
|
||||
spinner.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty { CircleSize = 2 });
|
||||
|
||||
Add(new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Size = new Vector2(0.5f),
|
||||
Child = drawableSpinner = new DrawableSpinner(spinner)
|
||||
});
|
||||
}
|
||||
|
||||
protected override SelectionMask CreateMask() => new SpinnerSelectionMask(drawableSpinner) { Size = new Vector2(0.5f) };
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
// 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.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces;
|
||||
using OpenTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Edit.Masks.SpinnerMasks.Components
|
||||
{
|
||||
public class SpinnerPiece : CompositeDrawable
|
||||
{
|
||||
private readonly Spinner spinner;
|
||||
private readonly CircularContainer circle;
|
||||
|
||||
public SpinnerPiece(Spinner spinner)
|
||||
{
|
||||
this.spinner = spinner;
|
||||
|
||||
Origin = Anchor.Centre;
|
||||
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
FillMode = FillMode.Fit;
|
||||
Size = new Vector2(1.3f);
|
||||
|
||||
RingPiece ring;
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
circle = new CircularContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Masking = true,
|
||||
Alpha = 0.5f,
|
||||
Child = new Box { RelativeSizeAxes = Axes.Both }
|
||||
},
|
||||
ring = new RingPiece
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre
|
||||
}
|
||||
};
|
||||
|
||||
ring.Scale = new Vector2(spinner.Scale);
|
||||
|
||||
spinner.PositionChanged += _ => updatePosition();
|
||||
spinner.StackHeightChanged += _ => updatePosition();
|
||||
spinner.ScaleChanged += _ => ring.Scale = new Vector2(spinner.Scale);
|
||||
|
||||
updatePosition();
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
Colour = colours.Yellow;
|
||||
}
|
||||
|
||||
private void updatePosition() => Position = spinner.Position;
|
||||
|
||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => circle.ReceivePositionalInputAt(screenSpacePos);
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
// 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.Edit;
|
||||
using osu.Game.Rulesets.Osu.Edit.Masks.SpinnerMasks.Components;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||
using OpenTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Edit.Masks.SpinnerMasks
|
||||
{
|
||||
public class SpinnerSelectionMask : SelectionMask
|
||||
{
|
||||
private readonly SpinnerPiece piece;
|
||||
|
||||
public SpinnerSelectionMask(DrawableSpinner spinner)
|
||||
: base(spinner)
|
||||
{
|
||||
InternalChild = piece = new SpinnerPiece((Spinner)spinner.HitObject);
|
||||
}
|
||||
|
||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => piece.ReceivePositionalInputAt(screenSpacePos);
|
||||
}
|
||||
}
|
@ -10,6 +10,7 @@ using osu.Game.Rulesets.Edit.Tools;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Osu.Edit.Masks.HitCircleMasks;
|
||||
using osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks;
|
||||
using osu.Game.Rulesets.Osu.Edit.Masks.SpinnerMasks;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Osu.UI;
|
||||
@ -42,6 +43,8 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
return new HitCircleSelectionMask(circle);
|
||||
case DrawableSlider slider:
|
||||
return new SliderSelectionMask(slider);
|
||||
case DrawableSpinner spinner:
|
||||
return new SpinnerSelectionMask(spinner);
|
||||
}
|
||||
|
||||
return base.CreateMaskFor(hitObject);
|
||||
|
@ -112,6 +112,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
Alpha = 0
|
||||
}
|
||||
};
|
||||
|
||||
s.PositionChanged += _ => Position = s.Position;
|
||||
}
|
||||
|
||||
public float Progress => MathHelper.Clamp(Disc.RotationAbsolute / 360 / Spinner.SpinsRequired, 0, 1);
|
||||
@ -167,7 +169,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
Disc.Tracking = OsuActionInputManager.PressedActions.Any(x => x == OsuAction.LeftButton || x == OsuAction.RightButton);
|
||||
Disc.Tracking = OsuActionInputManager?.PressedActions.Any(x => x == OsuAction.LeftButton || x == OsuAction.RightButton) ?? false;
|
||||
if (!spmCounter.IsPresent && Disc.Tracking)
|
||||
spmCounter.FadeIn(HitObject.TimeFadeIn);
|
||||
|
||||
|
@ -7,6 +7,7 @@ using osu.Game.Rulesets.Objects.Types;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Osu.Judgements;
|
||||
using OpenTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Objects
|
||||
{
|
||||
@ -31,5 +32,10 @@ namespace osu.Game.Rulesets.Osu.Objects
|
||||
}
|
||||
|
||||
public override Judgement CreateJudgement() => new OsuJudgement();
|
||||
|
||||
public override void OffsetPosition(Vector2 offset)
|
||||
{
|
||||
// for now we don't want to allow spinners to be moved around.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user