1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 18:12:56 +08:00

Add support for x/y position and scale back in

This commit is contained in:
Dean Herbert 2021-04-28 15:28:32 +09:00
parent 1cb8fc9a24
commit 59339aa4fd
2 changed files with 29 additions and 10 deletions

View File

@ -16,11 +16,17 @@ namespace osu.Game.Screens.Play.HUD
/// </summary> /// </summary>
public abstract class SkinnableHUDComponent : SkinnableDrawable public abstract class SkinnableHUDComponent : SkinnableDrawable
{ {
[SettingSource("Scale", "The scale at which this component should be displayed.")] [SettingSource("ScaleX", "The horizontal scale at which this component should be displayed.")]
public BindableNumber<float> SkinScale { get; } = new BindableFloat(1); public BindableNumber<float> SkinScaleX { get; } = new BindableFloat(1);
[SettingSource("Position", "The position at which this component should be displayed.")] [SettingSource("ScaleY", "The vertical scale at which this component should be displayed.")]
public BindableNumber<float> SkinPosition { get; } = new BindableFloat(); public BindableNumber<float> SkinScaleY { get; } = new BindableFloat(1);
[SettingSource("PositionX", "The horizontal position at which this component should be displayed.")]
public BindableNumber<float> SkinPositionX { get; } = new BindableFloat();
[SettingSource("PositionY", "The vertical position at which this component should be displayed.")]
public BindableNumber<float> SkinPositionY { get; } = new BindableFloat();
[SettingSource("Rotation", "The rotation at which this component should be displayed.")] [SettingSource("Rotation", "The rotation at which this component should be displayed.")]
public BindableNumber<float> SkinRotation { get; } = new BindableFloat(); public BindableNumber<float> SkinRotation { get; } = new BindableFloat();
@ -31,8 +37,12 @@ namespace osu.Game.Screens.Play.HUD
protected SkinnableHUDComponent(ISkinComponent component, Func<ISkinComponent, Drawable> defaultImplementation, Func<ISkinSource, bool> allowFallback = null, ConfineMode confineMode = ConfineMode.NoScaling) protected SkinnableHUDComponent(ISkinComponent component, Func<ISkinComponent, Drawable> defaultImplementation, Func<ISkinSource, bool> allowFallback = null, ConfineMode confineMode = ConfineMode.NoScaling)
: base(component, defaultImplementation, allowFallback, confineMode) : base(component, defaultImplementation, allowFallback, confineMode)
{ {
SkinScale.BindValueChanged(scale => Drawable.Scale = new Vector2(scale.NewValue)); SkinScaleX.BindValueChanged(x => Drawable.Scale = new Vector2(x.NewValue, Drawable.Scale.Y));
SkinPosition.BindValueChanged(position => Position = new Vector2(position.NewValue)); SkinScaleY.BindValueChanged(y => Drawable.Scale = new Vector2(Drawable.Scale.X, y.NewValue));
SkinPositionX.BindValueChanged(x => Position = new Vector2(x.NewValue, Position.Y));
SkinPositionY.BindValueChanged(y => Position = new Vector2(Position.X, y.NewValue));
SkinRotation.BindValueChanged(rotation => Drawable.Rotation = rotation.NewValue); SkinRotation.BindValueChanged(rotation => Drawable.Rotation = rotation.NewValue);
SkinAnchor.BindValueChanged(anchor => SkinAnchor.BindValueChanged(anchor =>
{ {
@ -42,8 +52,10 @@ namespace osu.Game.Screens.Play.HUD
protected override bool OnInvalidate(Invalidation invalidation, InvalidationSource source) protected override bool OnInvalidate(Invalidation invalidation, InvalidationSource source)
{ {
SkinScale.Value = Drawable.Scale.X; SkinScaleX.Value = Drawable.Scale.X;
SkinPosition.Value = Position.X; SkinScaleY.Value = Drawable.Scale.Y;
SkinPositionX.Value = Position.X;
SkinPositionY.Value = Position.Y;
SkinRotation.Value = Drawable.Rotation; SkinRotation.Value = Drawable.Rotation;
SkinAnchor.Value = Anchor; SkinAnchor.Value = Anchor;
return base.OnInvalidate(invalidation, source); return base.OnInvalidate(invalidation, source);

View File

@ -98,7 +98,10 @@ namespace osu.Game.Skinning.Editor
adjustScaleFromAnchor(ref scale, anchor); adjustScaleFromAnchor(ref scale, anchor);
foreach (var c in SelectedBlueprints) foreach (var c in SelectedBlueprints)
c.Item.SkinScale.Value += scale.X * 0.01f; {
c.Item.SkinScaleX.Value += scale.X * 0.01f;
c.Item.SkinScaleY.Value += scale.Y * 0.01f;
}
return true; return true;
} }
@ -106,7 +109,11 @@ namespace osu.Game.Skinning.Editor
public override bool HandleMovement(MoveSelectionEvent<SkinnableHUDComponent> moveEvent) public override bool HandleMovement(MoveSelectionEvent<SkinnableHUDComponent> moveEvent)
{ {
foreach (var c in SelectedBlueprints) foreach (var c in SelectedBlueprints)
c.Item.SkinPosition.Value += moveEvent.InstantDelta.X; {
c.Item.SkinPositionX.Value += moveEvent.InstantDelta.X;
c.Item.SkinPositionY.Value += moveEvent.InstantDelta.Y;
}
return true; return true;
} }