mirror of
https://github.com/ppy/osu.git
synced 2024-12-05 10:33:22 +08:00
Add MoveXCommand
and MoveYCommand
This commit is contained in:
parent
c50adc80b0
commit
1d953e0e6f
@ -8,7 +8,7 @@ namespace osu.Game.Rulesets.Objects.Types
|
||||
/// <summary>
|
||||
/// A HitObject that has a starting position that can be mutated.
|
||||
/// </summary>
|
||||
public interface IHasMutablePosition : IHasPosition
|
||||
public interface IHasMutablePosition : IHasPosition, IHasMutableXPosition, IHasMutableYPosition
|
||||
{
|
||||
/// <summary>
|
||||
/// The starting position of the HitObject.
|
||||
|
16
osu.Game/Rulesets/Objects/Types/IHasMutableXPosition.cs
Normal file
16
osu.Game/Rulesets/Objects/Types/IHasMutableXPosition.cs
Normal file
@ -0,0 +1,16 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
namespace osu.Game.Rulesets.Objects.Types
|
||||
{
|
||||
/// <summary>
|
||||
/// A HitObject that has a starting X-position that can be mutated.
|
||||
/// </summary>
|
||||
public interface IHasMutableXPosition : IHasXPosition
|
||||
{
|
||||
/// <summary>
|
||||
/// The starting X-position of this HitObject.
|
||||
/// </summary>
|
||||
new float X { get; set; }
|
||||
}
|
||||
}
|
16
osu.Game/Rulesets/Objects/Types/IHasMutableYPosition.cs
Normal file
16
osu.Game/Rulesets/Objects/Types/IHasMutableYPosition.cs
Normal file
@ -0,0 +1,16 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
namespace osu.Game.Rulesets.Objects.Types
|
||||
{
|
||||
/// <summary>
|
||||
/// A HitObject that has a starting Y-position that can be mutated.
|
||||
/// </summary>
|
||||
public interface IHasMutableYPosition : IHasYPosition
|
||||
{
|
||||
/// <summary>
|
||||
/// The starting Y-position of this HitObject.
|
||||
/// </summary>
|
||||
new float Y { get; set; }
|
||||
}
|
||||
}
|
27
osu.Game/Screens/Edit/Commands/MoveXCommand.cs
Normal file
27
osu.Game/Screens/Edit/Commands/MoveXCommand.cs
Normal file
@ -0,0 +1,27 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Commands
|
||||
{
|
||||
public class MoveXCommand : IEditorCommand
|
||||
{
|
||||
public readonly IHasMutablePosition Target;
|
||||
|
||||
public readonly float X;
|
||||
|
||||
public MoveXCommand(IHasMutablePosition target, float x)
|
||||
{
|
||||
Target = target;
|
||||
X = x;
|
||||
}
|
||||
|
||||
public void Apply() => Target.X = X;
|
||||
|
||||
public IEditorCommand CreateUndo() => new MoveXCommand(Target, Target.X);
|
||||
|
||||
public bool IsRedundant => Precision.AlmostEquals(X, Target.X);
|
||||
}
|
||||
}
|
27
osu.Game/Screens/Edit/Commands/MoveYCommand.cs
Normal file
27
osu.Game/Screens/Edit/Commands/MoveYCommand.cs
Normal file
@ -0,0 +1,27 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Commands
|
||||
{
|
||||
public class MoveYCommand : IEditorCommand
|
||||
{
|
||||
public readonly IHasMutablePosition Target;
|
||||
|
||||
public readonly float Y;
|
||||
|
||||
public MoveYCommand(IHasMutablePosition target, float y)
|
||||
{
|
||||
Target = target;
|
||||
Y = y;
|
||||
}
|
||||
|
||||
public void Apply() => Target.Y = Y;
|
||||
|
||||
public IEditorCommand CreateUndo() => new MoveXCommand(Target, Target.Y);
|
||||
|
||||
public bool IsRedundant => Precision.AlmostEquals(Y, Target.Y);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user