mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 11:42:54 +08:00
Remove ScaleContainer and flatten the Drawable tree of catch DHO
This commit is contained in:
parent
56721a6fa9
commit
004c705aa9
@ -11,13 +11,13 @@ namespace osu.Game.Rulesets.Catch.Tests
|
||||
{
|
||||
public class TestSceneFruitRandomness : OsuTestScene
|
||||
{
|
||||
private readonly TestDrawableFruit drawableFruit;
|
||||
private readonly TestDrawableBanana drawableBanana;
|
||||
private readonly DrawableFruit drawableFruit;
|
||||
private readonly DrawableBanana drawableBanana;
|
||||
|
||||
public TestSceneFruitRandomness()
|
||||
{
|
||||
drawableFruit = new TestDrawableFruit(new Fruit());
|
||||
drawableBanana = new TestDrawableBanana(new Banana());
|
||||
drawableFruit = new DrawableFruit(new Fruit());
|
||||
drawableBanana = new DrawableBanana(new Banana());
|
||||
|
||||
Add(new TestDrawableCatchHitObjectSpecimen(drawableFruit) { X = -200 });
|
||||
Add(new TestDrawableCatchHitObjectSpecimen(drawableBanana));
|
||||
@ -44,9 +44,9 @@ namespace osu.Game.Rulesets.Catch.Tests
|
||||
{
|
||||
drawableFruit.HitObject.StartTime = drawableBanana.HitObject.StartTime = initial_start_time;
|
||||
|
||||
fruitRotation = drawableFruit.InnerRotation;
|
||||
bananaRotation = drawableBanana.InnerRotation;
|
||||
bananaScale = drawableBanana.InnerScale;
|
||||
fruitRotation = drawableFruit.Rotation;
|
||||
bananaRotation = drawableBanana.Rotation;
|
||||
bananaScale = drawableBanana.Scale.X;
|
||||
bananaColour = drawableBanana.AccentColour.Value;
|
||||
});
|
||||
|
||||
@ -55,9 +55,9 @@ namespace osu.Game.Rulesets.Catch.Tests
|
||||
drawableFruit.HitObject.StartTime = drawableBanana.HitObject.StartTime = another_start_time;
|
||||
});
|
||||
|
||||
AddAssert("fruit rotation is changed", () => drawableFruit.InnerRotation != fruitRotation);
|
||||
AddAssert("banana rotation is changed", () => drawableBanana.InnerRotation != bananaRotation);
|
||||
AddAssert("banana scale is changed", () => drawableBanana.InnerScale != bananaScale);
|
||||
AddAssert("fruit rotation is changed", () => drawableFruit.Rotation != fruitRotation);
|
||||
AddAssert("banana rotation is changed", () => drawableBanana.Rotation != bananaRotation);
|
||||
AddAssert("banana scale is changed", () => drawableBanana.Scale.X != bananaScale);
|
||||
AddAssert("banana colour is changed", () => drawableBanana.AccentColour.Value != bananaColour);
|
||||
|
||||
AddStep("reset start time", () =>
|
||||
@ -66,31 +66,10 @@ namespace osu.Game.Rulesets.Catch.Tests
|
||||
});
|
||||
|
||||
AddAssert("rotation and scale restored", () =>
|
||||
drawableFruit.InnerRotation == fruitRotation &&
|
||||
drawableBanana.InnerRotation == bananaRotation &&
|
||||
drawableBanana.InnerScale == bananaScale &&
|
||||
drawableFruit.Rotation == fruitRotation &&
|
||||
drawableBanana.Rotation == bananaRotation &&
|
||||
drawableBanana.Scale.X == bananaScale &&
|
||||
drawableBanana.AccentColour.Value == bananaColour);
|
||||
}
|
||||
|
||||
private class TestDrawableFruit : DrawableFruit
|
||||
{
|
||||
public float InnerRotation => ScaleContainer.Rotation;
|
||||
|
||||
public TestDrawableFruit(Fruit h)
|
||||
: base(h)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private class TestDrawableBanana : DrawableBanana
|
||||
{
|
||||
public float InnerRotation => ScaleContainer.Rotation;
|
||||
public float InnerScale => ScaleContainer.Scale.X;
|
||||
|
||||
public TestDrawableBanana(Banana h)
|
||||
: base(h)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,9 +24,9 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
ScaleContainer.Child = new SkinnableDrawable(
|
||||
AddInternal(new SkinnableDrawable(
|
||||
new CatchSkinComponent(CatchSkinComponents.Banana),
|
||||
_ => new BananaPiece());
|
||||
_ => new BananaPiece()));
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
@ -44,12 +44,12 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
||||
const float end_scale = 0.6f;
|
||||
const float random_scale_range = 1.6f;
|
||||
|
||||
ScaleContainer.ScaleTo(HitObject.Scale * (end_scale + random_scale_range * RandomSingle(3)))
|
||||
.Then().ScaleTo(HitObject.Scale * end_scale, HitObject.TimePreempt);
|
||||
this.ScaleTo(HitObject.Scale * (end_scale + random_scale_range * RandomSingle(3)))
|
||||
.Then().ScaleTo(HitObject.Scale * end_scale, HitObject.TimePreempt);
|
||||
|
||||
ScaleContainer.RotateTo(getRandomAngle(1))
|
||||
.Then()
|
||||
.RotateTo(getRandomAngle(2), HitObject.TimePreempt);
|
||||
this.RotateTo(getRandomAngle(1))
|
||||
.Then()
|
||||
.RotateTo(getRandomAngle(2), HitObject.TimePreempt);
|
||||
|
||||
float getRandomAngle(int series) => 180 * (RandomSingle(series) * 2 - 1);
|
||||
}
|
||||
|
@ -26,9 +26,9 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
ScaleContainer.Child = new SkinnableDrawable(
|
||||
AddInternal(new SkinnableDrawable(
|
||||
new CatchSkinComponent(CatchSkinComponents.Droplet),
|
||||
_ => new DropletPiece());
|
||||
_ => new DropletPiece()));
|
||||
}
|
||||
|
||||
protected override void UpdateInitialTransforms()
|
||||
@ -39,7 +39,7 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
||||
float startRotation = RandomSingle(1) * 20;
|
||||
double duration = HitObject.TimePreempt + 2000;
|
||||
|
||||
ScaleContainer.RotateTo(startRotation).RotateTo(startRotation + 720, duration);
|
||||
this.RotateTo(startRotation).RotateTo(startRotation + 720, duration);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -32,16 +32,16 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
||||
VisualRepresentation.Value = (FruitVisualRepresentation)(change.NewValue % 4);
|
||||
}, true);
|
||||
|
||||
ScaleContainer.Child = new SkinnableDrawable(
|
||||
AddInternal(new SkinnableDrawable(
|
||||
new CatchSkinComponent(CatchSkinComponents.Fruit),
|
||||
_ => new FruitPiece());
|
||||
_ => new FruitPiece()));
|
||||
}
|
||||
|
||||
protected override void UpdateInitialTransforms()
|
||||
{
|
||||
base.UpdateInitialTransforms();
|
||||
|
||||
ScaleContainer.RotateTo((RandomSingle(1) - 0.5f) * 40);
|
||||
this.RotateTo((RandomSingle(1) - 0.5f) * 40);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@ using JetBrains.Annotations;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
||||
@ -21,7 +20,7 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
||||
public readonly Bindable<int> IndexInBeatmap = new Bindable<int>();
|
||||
|
||||
/// <summary>
|
||||
/// The multiplicative factor applied to <see cref="ScaleContainer"/> scale relative to <see cref="HitObject"/> scale.
|
||||
/// The multiplicative factor applied to <see cref="Drawable.Scale"/> relative to <see cref="HitObject"/> scale.
|
||||
/// </summary>
|
||||
protected virtual float ScaleFactor => 1;
|
||||
|
||||
@ -32,20 +31,11 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
||||
|
||||
public float DisplayRadius => CatchHitObject.OBJECT_RADIUS * HitObject.Scale * ScaleFactor;
|
||||
|
||||
protected readonly Container ScaleContainer;
|
||||
|
||||
protected DrawablePalpableCatchHitObject([CanBeNull] CatchHitObject h)
|
||||
: base(h)
|
||||
{
|
||||
Origin = Anchor.Centre;
|
||||
Size = new Vector2(CatchHitObject.OBJECT_RADIUS * 2);
|
||||
|
||||
AddInternal(ScaleContainer = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.Centre,
|
||||
});
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -58,7 +48,7 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
||||
|
||||
ScaleBindable.BindValueChanged(scale =>
|
||||
{
|
||||
ScaleContainer.Scale = new Vector2(scale.NewValue * ScaleFactor);
|
||||
Scale = new Vector2(scale.NewValue * ScaleFactor);
|
||||
}, true);
|
||||
|
||||
IndexInBeatmap.BindValueChanged(_ => UpdateComboColour());
|
||||
|
Loading…
Reference in New Issue
Block a user