-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26311 from OliBomby/grids-3
Make editor flip, rotate, and scale tools revolve around the grid center
- Loading branch information
Showing
12 changed files
with
301 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using System; | ||
using System.Linq; | ||
using osu.Framework.Allocation; | ||
using osu.Framework.Bindables; | ||
|
@@ -19,16 +20,19 @@ public partial class PreciseRotationPopover : OsuPopover | |
{ | ||
private readonly SelectionRotationHandler rotationHandler; | ||
|
||
private readonly Bindable<PreciseRotationInfo> rotationInfo = new Bindable<PreciseRotationInfo>(new PreciseRotationInfo(0, RotationOrigin.PlayfieldCentre)); | ||
private readonly OsuGridToolboxGroup gridToolbox; | ||
|
||
private readonly Bindable<PreciseRotationInfo> rotationInfo = new Bindable<PreciseRotationInfo>(new PreciseRotationInfo(0, RotationOrigin.GridCentre)); | ||
|
||
private SliderWithTextBoxInput<float> angleInput = null!; | ||
private EditorRadioButtonCollection rotationOrigin = null!; | ||
|
||
private RadioButton selectionCentreButton = null!; | ||
|
||
public PreciseRotationPopover(SelectionRotationHandler rotationHandler) | ||
public PreciseRotationPopover(SelectionRotationHandler rotationHandler, OsuGridToolboxGroup gridToolbox) | ||
{ | ||
this.rotationHandler = rotationHandler; | ||
this.gridToolbox = gridToolbox; | ||
|
||
AllowableAnchors = new[] { Anchor.CentreLeft, Anchor.CentreRight }; | ||
} | ||
|
@@ -58,6 +62,9 @@ private void load() | |
RelativeSizeAxes = Axes.X, | ||
Items = new[] | ||
{ | ||
new RadioButton("Grid centre", | ||
() => rotationInfo.Value = rotationInfo.Value with { Origin = RotationOrigin.GridCentre }, | ||
() => new SpriteIcon { Icon = FontAwesome.Regular.PlusSquare }), | ||
new RadioButton("Playfield centre", | ||
() => rotationInfo.Value = rotationInfo.Value with { Origin = RotationOrigin.PlayfieldCentre }, | ||
() => new SpriteIcon { Icon = FontAwesome.Regular.Square }), | ||
|
@@ -93,10 +100,19 @@ protected override void LoadComplete() | |
|
||
rotationInfo.BindValueChanged(rotation => | ||
{ | ||
rotationHandler.Update(rotation.NewValue.Degrees, rotation.NewValue.Origin == RotationOrigin.PlayfieldCentre ? OsuPlayfield.BASE_SIZE / 2 : null); | ||
rotationHandler.Update(rotation.NewValue.Degrees, getOriginPosition(rotation.NewValue)); | ||
}); | ||
} | ||
|
||
private Vector2? getOriginPosition(PreciseRotationInfo rotation) => | ||
rotation.Origin switch | ||
{ | ||
RotationOrigin.GridCentre => gridToolbox.StartPosition.Value, | ||
RotationOrigin.PlayfieldCentre => OsuPlayfield.BASE_SIZE / 2, | ||
RotationOrigin.SelectionCentre => null, | ||
_ => throw new ArgumentOutOfRangeException(nameof(rotation)) | ||
}; | ||
|
||
protected override void PopIn() | ||
{ | ||
base.PopIn(); | ||
|
@@ -114,6 +130,7 @@ protected override void PopOut() | |
|
||
public enum RotationOrigin | ||
{ | ||
GridCentre, | ||
PlayfieldCentre, | ||
SelectionCentre | ||
} | ||
|
Oops, something went wrong.