mirror of
https://github.com/ppy/osu.git
synced 2024-09-21 18:47:27 +08:00
Combine DisplayRadius and Scale to DisplaySize
This commit is contained in:
parent
e097b6e61c
commit
2634c6b8d9
@ -5,6 +5,7 @@ using NUnit.Framework;
|
|||||||
using osu.Game.Rulesets.Catch.Objects;
|
using osu.Game.Rulesets.Catch.Objects;
|
||||||
using osu.Game.Rulesets.Catch.Objects.Drawables;
|
using osu.Game.Rulesets.Catch.Objects.Drawables;
|
||||||
using osu.Game.Tests.Visual;
|
using osu.Game.Tests.Visual;
|
||||||
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Catch.Tests
|
namespace osu.Game.Rulesets.Catch.Tests
|
||||||
@ -37,16 +38,16 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
|
|
||||||
float fruitRotation = 0;
|
float fruitRotation = 0;
|
||||||
float bananaRotation = 0;
|
float bananaRotation = 0;
|
||||||
float bananaScale = 0;
|
Vector2 bananaSize = new Vector2();
|
||||||
Color4 bananaColour = new Color4();
|
Color4 bananaColour = new Color4();
|
||||||
|
|
||||||
AddStep("Initialize start time", () =>
|
AddStep("Initialize start time", () =>
|
||||||
{
|
{
|
||||||
drawableFruit.HitObject.StartTime = drawableBanana.HitObject.StartTime = initial_start_time;
|
drawableFruit.HitObject.StartTime = drawableBanana.HitObject.StartTime = initial_start_time;
|
||||||
|
|
||||||
fruitRotation = drawableFruit.Rotation;
|
fruitRotation = drawableFruit.DisplayRotation;
|
||||||
bananaRotation = drawableBanana.Rotation;
|
bananaRotation = drawableBanana.DisplayRotation;
|
||||||
bananaScale = drawableBanana.Scale.X;
|
bananaSize = drawableBanana.DisplaySize;
|
||||||
bananaColour = drawableBanana.AccentColour.Value;
|
bananaColour = drawableBanana.AccentColour.Value;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -55,9 +56,9 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
drawableFruit.HitObject.StartTime = drawableBanana.HitObject.StartTime = another_start_time;
|
drawableFruit.HitObject.StartTime = drawableBanana.HitObject.StartTime = another_start_time;
|
||||||
});
|
});
|
||||||
|
|
||||||
AddAssert("fruit rotation is changed", () => drawableFruit.Rotation != fruitRotation);
|
AddAssert("fruit rotation is changed", () => drawableFruit.DisplayRotation != fruitRotation);
|
||||||
AddAssert("banana rotation is changed", () => drawableBanana.Rotation != bananaRotation);
|
AddAssert("banana rotation is changed", () => drawableBanana.DisplayRotation != bananaRotation);
|
||||||
AddAssert("banana scale is changed", () => drawableBanana.Scale.X != bananaScale);
|
AddAssert("banana size is changed", () => drawableBanana.DisplaySize != bananaSize);
|
||||||
AddAssert("banana colour is changed", () => drawableBanana.AccentColour.Value != bananaColour);
|
AddAssert("banana colour is changed", () => drawableBanana.AccentColour.Value != bananaColour);
|
||||||
|
|
||||||
AddStep("reset start time", () =>
|
AddStep("reset start time", () =>
|
||||||
@ -65,10 +66,10 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
drawableFruit.HitObject.StartTime = drawableBanana.HitObject.StartTime = initial_start_time;
|
drawableFruit.HitObject.StartTime = drawableBanana.HitObject.StartTime = initial_start_time;
|
||||||
});
|
});
|
||||||
|
|
||||||
AddAssert("rotation and scale restored", () =>
|
AddAssert("rotation and size restored", () =>
|
||||||
drawableFruit.Rotation == fruitRotation &&
|
drawableFruit.DisplayRotation == fruitRotation &&
|
||||||
drawableBanana.Rotation == bananaRotation &&
|
drawableBanana.DisplayRotation == bananaRotation &&
|
||||||
drawableBanana.Scale.X == bananaScale &&
|
drawableBanana.DisplaySize == bananaSize &&
|
||||||
drawableBanana.AccentColour.Value == bananaColour);
|
drawableBanana.AccentColour.Value == bananaColour);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,9 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
|||||||
public Bindable<Color4> AccentColour { get; } = new Bindable<Color4>();
|
public Bindable<Color4> AccentColour { get; } = new Bindable<Color4>();
|
||||||
public Bindable<bool> HyperDash { get; } = new Bindable<bool>();
|
public Bindable<bool> HyperDash { get; } = new Bindable<bool>();
|
||||||
|
|
||||||
float IHasCatchObjectState.Scale => Scale.X;
|
public Vector2 DisplaySize => Size * Scale;
|
||||||
|
|
||||||
|
public float DisplayRotation => Rotation;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether this hit object should stay on the catcher plate when the object is caught by the catcher.
|
/// Whether this hit object should stay on the catcher plate when the object is caught by the catcher.
|
||||||
@ -45,8 +47,8 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
|||||||
public virtual void CopyStateFrom(IHasCatchObjectState objectState)
|
public virtual void CopyStateFrom(IHasCatchObjectState objectState)
|
||||||
{
|
{
|
||||||
HitObject = objectState.HitObject;
|
HitObject = objectState.HitObject;
|
||||||
Scale = new Vector2(objectState.Scale);
|
Scale = Vector2.Divide(objectState.DisplaySize, Size);
|
||||||
Rotation = objectState.Rotation;
|
Rotation = objectState.DisplayRotation;
|
||||||
AccentColour.Value = objectState.AccentColour.Value;
|
AccentColour.Value = objectState.AccentColour.Value;
|
||||||
HyperDash.Value = objectState.HyperDash.Value;
|
HyperDash.Value = objectState.HyperDash.Value;
|
||||||
}
|
}
|
||||||
|
@ -29,16 +29,14 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
protected virtual float ScaleFactor => 1;
|
protected virtual float ScaleFactor => 1;
|
||||||
|
|
||||||
public float DisplayRadius => CatchHitObject.OBJECT_RADIUS * HitObject.Scale * ScaleFactor;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The container internal transforms (such as scaling based on the circle size) are applied to.
|
/// The container internal transforms (such as scaling based on the circle size) are applied to.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected readonly Container ScalingContainer;
|
protected readonly Container ScalingContainer;
|
||||||
|
|
||||||
float IHasCatchObjectState.Scale => HitObject.Scale * ScaleFactor;
|
public Vector2 DisplaySize => ScalingContainer.Size * ScalingContainer.Scale;
|
||||||
|
|
||||||
float IHasCatchObjectState.Rotation => ScalingContainer.Rotation;
|
public float DisplayRotation => ScalingContainer.Rotation;
|
||||||
|
|
||||||
protected DrawablePalpableCatchHitObject([CanBeNull] CatchHitObject h)
|
protected DrawablePalpableCatchHitObject([CanBeNull] CatchHitObject h)
|
||||||
: base(h)
|
: base(h)
|
||||||
@ -65,7 +63,7 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
|||||||
ScaleBindable.BindValueChanged(scale =>
|
ScaleBindable.BindValueChanged(scale =>
|
||||||
{
|
{
|
||||||
ScalingContainer.Scale = new Vector2(scale.NewValue * ScaleFactor);
|
ScalingContainer.Scale = new Vector2(scale.NewValue * ScaleFactor);
|
||||||
Size = ScalingContainer.Size * ScalingContainer.Scale;
|
Size = DisplaySize;
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
IndexInBeatmap.BindValueChanged(_ => UpdateComboColour());
|
IndexInBeatmap.BindValueChanged(_ => UpdateComboColour());
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
||||||
@ -15,7 +16,7 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
|||||||
Bindable<Color4> AccentColour { get; }
|
Bindable<Color4> AccentColour { get; }
|
||||||
Bindable<bool> HyperDash { get; }
|
Bindable<bool> HyperDash { get; }
|
||||||
|
|
||||||
float Rotation { get; }
|
Vector2 DisplaySize { get; }
|
||||||
float Scale { get; }
|
float DisplayRotation { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -235,7 +235,7 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
|
|
||||||
if (result.IsHit)
|
if (result.IsHit)
|
||||||
{
|
{
|
||||||
var positionInStack = computePositionInStack(new Vector2(palpableObject.X - X, 0), palpableObject.DisplayRadius);
|
var positionInStack = computePositionInStack(new Vector2(palpableObject.X - X, 0), palpableObject.DisplaySize.X / 2);
|
||||||
|
|
||||||
placeCaughtObject(palpableObject, positionInStack);
|
placeCaughtObject(palpableObject, positionInStack);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user