mirror of
https://github.com/ppy/osu
synced 2025-01-24 23:03:14 +00:00
Remember origin for editor rotation popover
This commit is contained in:
parent
b03963ac84
commit
3a3471c202
@ -10,6 +10,7 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Graphics.UserInterfaceV2;
|
using osu.Game.Graphics.UserInterfaceV2;
|
||||||
using osu.Game.Input.Bindings;
|
using osu.Game.Input.Bindings;
|
||||||
using osu.Game.Rulesets.Osu.UI;
|
using osu.Game.Rulesets.Osu.UI;
|
||||||
@ -30,8 +31,12 @@ namespace osu.Game.Rulesets.Osu.Edit
|
|||||||
private SliderWithTextBoxInput<float> angleInput = null!;
|
private SliderWithTextBoxInput<float> angleInput = null!;
|
||||||
private EditorRadioButtonCollection rotationOrigin = null!;
|
private EditorRadioButtonCollection rotationOrigin = null!;
|
||||||
|
|
||||||
|
private RadioButton gridCentreButton = null!;
|
||||||
|
private RadioButton playfieldCentreButton = null!;
|
||||||
private RadioButton selectionCentreButton = null!;
|
private RadioButton selectionCentreButton = null!;
|
||||||
|
|
||||||
|
private Bindable<EditorOrigin> configRotationOrigin = null!;
|
||||||
|
|
||||||
public PreciseRotationPopover(SelectionRotationHandler rotationHandler, OsuGridToolboxGroup gridToolbox)
|
public PreciseRotationPopover(SelectionRotationHandler rotationHandler, OsuGridToolboxGroup gridToolbox)
|
||||||
{
|
{
|
||||||
this.rotationHandler = rotationHandler;
|
this.rotationHandler = rotationHandler;
|
||||||
@ -41,8 +46,10 @@ namespace osu.Game.Rulesets.Osu.Edit
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load(OsuConfigManager config)
|
||||||
{
|
{
|
||||||
|
configRotationOrigin = config.GetBindable<EditorOrigin>(OsuSetting.EditorRotationOrigin);
|
||||||
|
|
||||||
Child = new FillFlowContainer
|
Child = new FillFlowContainer
|
||||||
{
|
{
|
||||||
Width = 220,
|
Width = 220,
|
||||||
@ -66,10 +73,10 @@ namespace osu.Game.Rulesets.Osu.Edit
|
|||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Items = new[]
|
Items = new[]
|
||||||
{
|
{
|
||||||
new RadioButton("Grid centre",
|
gridCentreButton = new RadioButton("Grid centre",
|
||||||
() => rotationInfo.Value = rotationInfo.Value with { Origin = EditorOrigin.GridCentre },
|
() => rotationInfo.Value = rotationInfo.Value with { Origin = EditorOrigin.GridCentre },
|
||||||
() => new SpriteIcon { Icon = FontAwesome.Regular.PlusSquare }),
|
() => new SpriteIcon { Icon = FontAwesome.Regular.PlusSquare }),
|
||||||
new RadioButton("Playfield centre",
|
playfieldCentreButton = new RadioButton("Playfield centre",
|
||||||
() => rotationInfo.Value = rotationInfo.Value with { Origin = EditorOrigin.PlayfieldCentre },
|
() => rotationInfo.Value = rotationInfo.Value with { Origin = EditorOrigin.PlayfieldCentre },
|
||||||
() => new SpriteIcon { Icon = FontAwesome.Regular.Square }),
|
() => new SpriteIcon { Icon = FontAwesome.Regular.Square }),
|
||||||
selectionCentreButton = new RadioButton("Selection centre",
|
selectionCentreButton = new RadioButton("Selection centre",
|
||||||
@ -95,7 +102,57 @@ namespace osu.Game.Rulesets.Osu.Edit
|
|||||||
angleInput.SelectAll();
|
angleInput.SelectAll();
|
||||||
});
|
});
|
||||||
angleInput.Current.BindValueChanged(angle => rotationInfo.Value = rotationInfo.Value with { Degrees = angle.NewValue });
|
angleInput.Current.BindValueChanged(angle => rotationInfo.Value = rotationInfo.Value with { Degrees = angle.NewValue });
|
||||||
rotationOrigin.Items.First().Select();
|
|
||||||
|
bool didSelect = false;
|
||||||
|
|
||||||
|
configRotationOrigin.BindValueChanged(val =>
|
||||||
|
{
|
||||||
|
switch (configRotationOrigin.Value)
|
||||||
|
{
|
||||||
|
case EditorOrigin.GridCentre:
|
||||||
|
if (!gridCentreButton.Selected.Disabled)
|
||||||
|
{
|
||||||
|
gridCentreButton.Select();
|
||||||
|
didSelect = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EditorOrigin.PlayfieldCentre:
|
||||||
|
if (!playfieldCentreButton.Selected.Disabled)
|
||||||
|
{
|
||||||
|
playfieldCentreButton.Select();
|
||||||
|
didSelect = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EditorOrigin.SelectionCentre:
|
||||||
|
if (!selectionCentreButton.Selected.Disabled)
|
||||||
|
{
|
||||||
|
selectionCentreButton.Select();
|
||||||
|
didSelect = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}, true);
|
||||||
|
|
||||||
|
if (!didSelect)
|
||||||
|
rotationOrigin.Items.First(b => !b.Selected.Disabled).Select();
|
||||||
|
|
||||||
|
gridCentreButton.Selected.BindValueChanged(b =>
|
||||||
|
{
|
||||||
|
if (b.NewValue) configRotationOrigin.Value = EditorOrigin.GridCentre;
|
||||||
|
});
|
||||||
|
playfieldCentreButton.Selected.BindValueChanged(b =>
|
||||||
|
{
|
||||||
|
if (b.NewValue) configRotationOrigin.Value = EditorOrigin.PlayfieldCentre;
|
||||||
|
});
|
||||||
|
selectionCentreButton.Selected.BindValueChanged(b =>
|
||||||
|
{
|
||||||
|
if (b.NewValue) configRotationOrigin.Value = EditorOrigin.SelectionCentre;
|
||||||
|
});
|
||||||
|
|
||||||
rotationHandler.CanRotateAroundSelectionOrigin.BindValueChanged(e =>
|
rotationHandler.CanRotateAroundSelectionOrigin.BindValueChanged(e =>
|
||||||
{
|
{
|
||||||
|
@ -195,7 +195,7 @@ namespace osu.Game.Configuration
|
|||||||
SetDefault(OsuSetting.EditorLimitedDistanceSnap, false);
|
SetDefault(OsuSetting.EditorLimitedDistanceSnap, false);
|
||||||
SetDefault(OsuSetting.EditorShowSpeedChanges, false);
|
SetDefault(OsuSetting.EditorShowSpeedChanges, false);
|
||||||
SetDefault(OsuSetting.EditorScaleOrigin, EditorOrigin.GridCentre);
|
SetDefault(OsuSetting.EditorScaleOrigin, EditorOrigin.GridCentre);
|
||||||
SetDefault(OsuSetting.EditorRotateOrigin, EditorOrigin.GridCentre);
|
SetDefault(OsuSetting.EditorRotationOrigin, EditorOrigin.GridCentre);
|
||||||
|
|
||||||
SetDefault(OsuSetting.HideCountryFlags, false);
|
SetDefault(OsuSetting.HideCountryFlags, false);
|
||||||
|
|
||||||
@ -438,6 +438,7 @@ namespace osu.Game.Configuration
|
|||||||
EditorTimelineShowTicks,
|
EditorTimelineShowTicks,
|
||||||
AlwaysShowHoldForMenuButton,
|
AlwaysShowHoldForMenuButton,
|
||||||
EditorContractSidebars,
|
EditorContractSidebars,
|
||||||
EditorScaleOrigin
|
EditorScaleOrigin,
|
||||||
|
EditorRotationOrigin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user