1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 04:02:57 +08:00

Make hitobject positions adjustable

This commit is contained in:
smoogipoo 2018-03-09 23:12:34 +09:00
parent 3b766b8ec8
commit 4a48136e4f
13 changed files with 108 additions and 11 deletions

View File

@ -22,6 +22,8 @@ namespace osu.Game.Rulesets.Osu.Edit.Layers.Selection.Overlays
Scale = hitCircle.Scale; Scale = hitCircle.Scale;
AddInternal(new RingPiece()); AddInternal(new RingPiece());
hitCircle.HitObject.PositionChanged += _ => Position = hitCircle.Position;
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]

View File

@ -22,18 +22,22 @@ namespace osu.Game.Rulesets.Osu.Edit.Layers.Selection.Overlays
{ {
this.slider = slider; this.slider = slider;
var obj = (Slider)slider.HitObject; Position = slider.Position;
var sliderObject = (Slider)slider.HitObject;
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
{ {
body = new SliderBody(obj) body = new SliderBody(sliderObject)
{ {
AccentColour = Color4.Transparent, AccentColour = Color4.Transparent,
PathWidth = obj.Scale * 64 PathWidth = sliderObject.Scale * 64
}, },
new SliderCircleOverlay(slider.HeadCircle, slider), new SliderCircleOverlay(slider.HeadCircle, slider),
new SliderCircleOverlay(slider.TailCircle, slider), new SliderCircleOverlay(slider.TailCircle, slider),
}; };
sliderObject.PositionChanged += _ => Position = slider.Position;
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
@ -46,7 +50,6 @@ namespace osu.Game.Rulesets.Osu.Edit.Layers.Selection.Overlays
{ {
base.Update(); base.Update();
Position = slider.Position;
Size = slider.Size; Size = slider.Size;
OriginPosition = slider.OriginPosition; OriginPosition = slider.OriginPosition;

View File

@ -66,6 +66,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
//may not be so correct //may not be so correct
Size = circle.DrawSize; Size = circle.DrawSize;
HitObject.PositionChanged += _ => Position = HitObject.StackedPosition;
} }
protected override void CheckForJudgements(bool userTriggered, double timeOffset) protected override void CheckForJudgements(bool userTriggered, double timeOffset)

View File

@ -55,8 +55,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
AlwaysPresent = true, AlwaysPresent = true,
Alpha = 0 Alpha = 0
}, },
HeadCircle = new DrawableHitCircle(s.HeadCircle) { Position = s.TailCircle.Position - s.Position }, HeadCircle = new DrawableSliderHead(s, s.HeadCircle),
TailCircle = new DrawableSliderTail(s.TailCircle) { Position = s.TailCircle.Position - s.Position } TailCircle = new DrawableSliderTail(s, s.TailCircle)
}; };
components.Add(Body); components.Add(Body);
@ -84,6 +84,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
components.Add(drawableRepeatPoint); components.Add(drawableRepeatPoint);
AddNested(drawableRepeatPoint); AddNested(drawableRepeatPoint);
} }
HitObject.PositionChanged += _ => Position = HitObject.StackedPosition;
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]

View File

@ -0,0 +1,14 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
namespace osu.Game.Rulesets.Osu.Objects.Drawables
{
public class DrawableSliderHead : DrawableHitCircle
{
public DrawableSliderHead(Slider slider, HitCircle h)
: base(h)
{
Position = HitObject.Position - slider.Position;
}
}
}

View File

@ -16,7 +16,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
public bool Tracking { get; set; } public bool Tracking { get; set; }
public DrawableSliderTail(HitCircle hitCircle) public DrawableSliderTail(Slider slider, HitCircle hitCircle)
: base(hitCircle) : base(hitCircle)
{ {
Origin = Anchor.Centre; Origin = Anchor.Centre;
@ -25,6 +25,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
FillMode = FillMode.Fit; FillMode = FillMode.Fit;
AlwaysPresent = true; AlwaysPresent = true;
Position = HitObject.Position - slider.Position;
} }
protected override void CheckForJudgements(bool userTriggered, double timeOffset) protected override void CheckForJudgements(bool userTriggered, double timeOffset)

View File

@ -1,23 +1,41 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// 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 osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects;
using OpenTK; using OpenTK;
using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Objects.Types;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Game.Beatmaps.ControlPoints; using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Edit.Types;
namespace osu.Game.Rulesets.Osu.Objects namespace osu.Game.Rulesets.Osu.Objects
{ {
public abstract class OsuHitObject : HitObject, IHasCombo, IHasPosition public abstract class OsuHitObject : HitObject, IHasCombo, IHasPosition, IHasEditablePosition
{ {
public const double OBJECT_RADIUS = 64; public const double OBJECT_RADIUS = 64;
public event Action<Vector2> PositionChanged;
public double TimePreempt = 600; public double TimePreempt = 600;
public double TimeFadein = 400; public double TimeFadein = 400;
public Vector2 Position { get; set; } private Vector2 position;
public Vector2 Position
{
get => position;
set
{
if (position == value)
return;
position = value;
PositionChanged?.Invoke(value);
}
}
public float X => Position.X; public float X => Position.X;
public float Y => Position.Y; public float Y => Position.Y;
@ -48,5 +66,7 @@ namespace osu.Game.Rulesets.Osu.Objects
Scale = (1.0f - 0.7f * (difficulty.CircleSize - 5) / 5) / 2; Scale = (1.0f - 0.7f * (difficulty.CircleSize - 5) / 5) / 2;
} }
public virtual void SetPosition(Vector2 offset) => Position += offset;
} }
} }

View File

@ -95,7 +95,7 @@ namespace osu.Game.Rulesets.Osu.Objects
private void createSliderEnds() private void createSliderEnds()
{ {
HeadCircle = new HitCircle HeadCircle = new SliderCircle(this)
{ {
StartTime = StartTime, StartTime = StartTime,
Position = Position, Position = Position,
@ -105,7 +105,7 @@ namespace osu.Game.Rulesets.Osu.Objects
SampleControlPoint = SampleControlPoint SampleControlPoint = SampleControlPoint
}; };
TailCircle = new HitCircle TailCircle = new SliderCircle(this)
{ {
StartTime = EndTime, StartTime = EndTime,
Position = EndPosition, Position = EndPosition,

View File

@ -0,0 +1,19 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK;
namespace osu.Game.Rulesets.Osu.Objects
{
public class SliderCircle : HitCircle
{
private readonly Slider slider;
public SliderCircle(Slider slider)
{
this.slider = slider;
}
public override void SetPosition(Vector2 offset) => slider.SetPosition(offset);
}
}

View File

@ -87,6 +87,7 @@
<Compile Include="Mods\OsuModSpunOut.cs" /> <Compile Include="Mods\OsuModSpunOut.cs" />
<Compile Include="Mods\OsuModSuddenDeath.cs" /> <Compile Include="Mods\OsuModSuddenDeath.cs" />
<Compile Include="Mods\OsuModTarget.cs" /> <Compile Include="Mods\OsuModTarget.cs" />
<Compile Include="Objects\Drawables\DrawableSliderHead.cs" />
<Compile Include="Objects\Drawables\DrawableOsuHitObject.cs" /> <Compile Include="Objects\Drawables\DrawableOsuHitObject.cs" />
<Compile Include="Objects\Drawables\Connections\ConnectionRenderer.cs" /> <Compile Include="Objects\Drawables\Connections\ConnectionRenderer.cs" />
<Compile Include="Objects\Drawables\Connections\FollowPointRenderer.cs" /> <Compile Include="Objects\Drawables\Connections\FollowPointRenderer.cs" />
@ -117,6 +118,7 @@
<Compile Include="Objects\Drawables\Pieces\SliderBody.cs" /> <Compile Include="Objects\Drawables\Pieces\SliderBody.cs" />
<Compile Include="Objects\ISliderProgress.cs" /> <Compile Include="Objects\ISliderProgress.cs" />
<Compile Include="Objects\RepeatPoint.cs" /> <Compile Include="Objects\RepeatPoint.cs" />
<Compile Include="Objects\SliderCircle.cs" />
<Compile Include="Objects\SliderTick.cs" /> <Compile Include="Objects\SliderTick.cs" />
<Compile Include="OsuDifficulty\OsuDifficultyCalculator.cs" /> <Compile Include="OsuDifficulty\OsuDifficultyCalculator.cs" />
<Compile Include="OsuDifficulty\Preprocessing\OsuDifficultyBeatmap.cs" /> <Compile Include="OsuDifficulty\Preprocessing\OsuDifficultyBeatmap.cs" />

View File

@ -2,6 +2,8 @@
// 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 osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Input;
using osu.Game.Rulesets.Edit.Types;
using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Drawables;
namespace osu.Game.Rulesets.Edit.Layers.Selection namespace osu.Game.Rulesets.Edit.Layers.Selection
@ -19,6 +21,22 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection
State = Visibility.Visible; State = Visibility.Visible;
} }
protected override bool OnDragStart(InputState state) => hitObject.HitObject is IHasEditablePosition;
protected override bool OnDrag(InputState state)
{
switch (hitObject.HitObject)
{
case IHasEditablePosition editablePosition:
editablePosition.SetPosition(state.Mouse.Delta);
break;
}
return true;
}
protected override bool OnDragEnd(InputState state) => true;
protected override void PopIn() => Alpha = 1; protected override void PopIn() => Alpha = 1;
protected override void PopOut() => Alpha = 0; protected override void PopOut() => Alpha = 0;
} }

View File

@ -0,0 +1,12 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK;
namespace osu.Game.Rulesets.Edit.Types
{
public interface IHasEditablePosition
{
void SetPosition(Vector2 offset);
}
}

View File

@ -365,6 +365,7 @@
<Compile Include="Rulesets\Edit\Layers\Selection\CaptureBox.cs" /> <Compile Include="Rulesets\Edit\Layers\Selection\CaptureBox.cs" />
<Compile Include="Rulesets\Edit\Layers\Selection\HitObjectOverlay.cs" /> <Compile Include="Rulesets\Edit\Layers\Selection\HitObjectOverlay.cs" />
<Compile Include="Rulesets\Edit\Layers\Selection\HitObjectOverlayLayer.cs" /> <Compile Include="Rulesets\Edit\Layers\Selection\HitObjectOverlayLayer.cs" />
<Compile Include="Rulesets\Edit\Types\IHasEditablePosition.cs" />
<Compile Include="Rulesets\Mods\IApplicableFailOverride.cs" /> <Compile Include="Rulesets\Mods\IApplicableFailOverride.cs" />
<Compile Include="Rulesets\Mods\IApplicableMod.cs" /> <Compile Include="Rulesets\Mods\IApplicableMod.cs" />
<Compile Include="Rulesets\Mods\IApplicableToBeatmapConverter.cs" /> <Compile Include="Rulesets\Mods\IApplicableToBeatmapConverter.cs" />