This repository has been archived by the owner on Jun 11, 2023. It is now read-only.
forked from ppy/osu
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
180 changed files
with
2,251 additions
and
2,059 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
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
114 changes: 114 additions & 0 deletions
114
osu.Game.Rulesets.Catch.Tests/TestSceneCatchSkinConfiguration.cs
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 |
---|---|---|
@@ -0,0 +1,114 @@ | ||
// 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.Linq; | ||
using NUnit.Framework; | ||
using osu.Framework.Allocation; | ||
using osu.Framework.Bindables; | ||
using osu.Framework.Graphics; | ||
using osu.Framework.Graphics.Containers; | ||
using osu.Framework.Testing; | ||
using osu.Framework.Utils; | ||
using osu.Game.Beatmaps; | ||
using osu.Game.Beatmaps.ControlPoints; | ||
using osu.Game.Rulesets.Catch.Judgements; | ||
using osu.Game.Rulesets.Catch.Objects; | ||
using osu.Game.Rulesets.Catch.Objects.Drawables; | ||
using osu.Game.Rulesets.Catch.Skinning; | ||
using osu.Game.Rulesets.Catch.UI; | ||
using osu.Game.Skinning; | ||
using osu.Game.Tests.Visual; | ||
using Direction = osu.Game.Rulesets.Catch.UI.Direction; | ||
|
||
namespace osu.Game.Rulesets.Catch.Tests | ||
{ | ||
public class TestSceneCatchSkinConfiguration : OsuTestScene | ||
{ | ||
[Cached] | ||
private readonly DroppedObjectContainer droppedObjectContainer; | ||
|
||
private Catcher catcher; | ||
|
||
private readonly Container container; | ||
|
||
public TestSceneCatchSkinConfiguration() | ||
{ | ||
Add(droppedObjectContainer = new DroppedObjectContainer()); | ||
Add(container = new Container { RelativeSizeAxes = Axes.Both }); | ||
} | ||
|
||
[TestCase(false)] | ||
[TestCase(true)] | ||
public void TestCatcherPlateFlipping(bool flip) | ||
{ | ||
AddStep("setup catcher", () => | ||
{ | ||
var skin = new TestSkin { FlipCatcherPlate = flip }; | ||
container.Child = new SkinProvidingContainer(skin) | ||
{ | ||
Child = catcher = new Catcher(new Container()) | ||
{ | ||
Anchor = Anchor.Centre | ||
} | ||
}; | ||
}); | ||
|
||
Fruit fruit = new Fruit(); | ||
|
||
AddStep("catch fruit", () => catchFruit(fruit, 20)); | ||
|
||
float position = 0; | ||
|
||
AddStep("record fruit position", () => position = getCaughtObjectPosition(fruit)); | ||
|
||
AddStep("face left", () => catcher.VisualDirection = Direction.Left); | ||
|
||
if (flip) | ||
AddAssert("fruit position changed", () => !Precision.AlmostEquals(getCaughtObjectPosition(fruit), position)); | ||
else | ||
AddAssert("fruit position unchanged", () => Precision.AlmostEquals(getCaughtObjectPosition(fruit), position)); | ||
|
||
AddStep("face right", () => catcher.VisualDirection = Direction.Right); | ||
|
||
AddAssert("fruit position restored", () => Precision.AlmostEquals(getCaughtObjectPosition(fruit), position)); | ||
} | ||
|
||
private float getCaughtObjectPosition(Fruit fruit) | ||
{ | ||
var caughtObject = catcher.ChildrenOfType<CaughtObject>().Single(c => c.HitObject == fruit); | ||
return caughtObject.Parent.ToSpaceOfOtherDrawable(caughtObject.Position, catcher).X; | ||
} | ||
|
||
private void catchFruit(Fruit fruit, float x) | ||
{ | ||
fruit.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty()); | ||
var drawableFruit = new DrawableFruit(fruit) { X = x }; | ||
var judgement = fruit.CreateJudgement(); | ||
catcher.OnNewResult(drawableFruit, new CatchJudgementResult(fruit, judgement) | ||
{ | ||
Type = judgement.MaxResult | ||
}); | ||
} | ||
|
||
private class TestSkin : DefaultSkin | ||
{ | ||
public bool FlipCatcherPlate { get; set; } | ||
|
||
public TestSkin() | ||
: base(null) | ||
{ | ||
} | ||
|
||
public override IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) | ||
{ | ||
if (lookup is CatchSkinConfiguration config) | ||
{ | ||
if (config == CatchSkinConfiguration.FlipCatcherPlate) | ||
return SkinUtils.As<TValue>(new Bindable<bool>(FlipCatcherPlate)); | ||
} | ||
|
||
return base.GetConfig<TLookup, TValue>(lookup); | ||
} | ||
} | ||
} | ||
} |
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 JetBrains.Annotations; | ||
using osu.Framework.Allocation; | ||
using osu.Framework.Graphics; | ||
using osu.Framework.Graphics.Containers; | ||
|
@@ -18,7 +19,6 @@ public FruitOutline() | |
{ | ||
Anchor = Anchor.BottomLeft; | ||
Origin = Anchor.Centre; | ||
Size = new Vector2(2 * CatchHitObject.OBJECT_RADIUS); | ||
InternalChild = new BorderPiece(); | ||
} | ||
|
||
|
@@ -28,10 +28,10 @@ private void load(OsuColour osuColour) | |
Colour = osuColour.Yellow; | ||
} | ||
|
||
public void UpdateFrom(ScrollingHitObjectContainer hitObjectContainer, CatchHitObject hitObject) | ||
public void UpdateFrom(ScrollingHitObjectContainer hitObjectContainer, CatchHitObject hitObject, [CanBeNull] CatchHitObject parent = null) | ||
{ | ||
X = hitObject.EffectiveX; | ||
Y = hitObjectContainer.PositionAtTime(hitObject.StartTime); | ||
X = hitObject.EffectiveX - (parent?.OriginalX ?? 0); | ||
Y = hitObjectContainer.PositionAtTime(hitObject.StartTime, parent?.StartTime ?? hitObjectContainer.Time.Current); | ||
Scale = new Vector2(hitObject.Scale); | ||
} | ||
} | ||
|
53 changes: 53 additions & 0 deletions
53
osu.Game.Rulesets.Catch/Edit/Blueprints/Components/NestedOutlineContainer.cs
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// 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.Collections.Generic; | ||
using System.Linq; | ||
using osu.Framework.Graphics; | ||
using osu.Framework.Graphics.Containers; | ||
using osu.Framework.Graphics.Primitives; | ||
using osu.Game.Rulesets.Catch.Objects; | ||
using osu.Game.Rulesets.UI.Scrolling; | ||
|
||
namespace osu.Game.Rulesets.Catch.Edit.Blueprints.Components | ||
{ | ||
public class NestedOutlineContainer : CompositeDrawable | ||
{ | ||
private readonly List<CatchHitObject> nestedHitObjects = new List<CatchHitObject>(); | ||
|
||
public NestedOutlineContainer() | ||
{ | ||
Anchor = Anchor.BottomLeft; | ||
} | ||
|
||
public void UpdatePositionFrom(ScrollingHitObjectContainer hitObjectContainer, CatchHitObject parentHitObject) | ||
{ | ||
X = parentHitObject.OriginalX; | ||
Y = hitObjectContainer.PositionAtTime(parentHitObject.StartTime); | ||
} | ||
|
||
public void UpdateNestedObjectsFrom(ScrollingHitObjectContainer hitObjectContainer, CatchHitObject parentHitObject) | ||
{ | ||
nestedHitObjects.Clear(); | ||
nestedHitObjects.AddRange(parentHitObject.NestedHitObjects | ||
.OfType<CatchHitObject>() | ||
.Where(h => !(h is TinyDroplet))); | ||
|
||
while (nestedHitObjects.Count < InternalChildren.Count) | ||
RemoveInternal(InternalChildren[^1]); | ||
|
||
while (InternalChildren.Count < nestedHitObjects.Count) | ||
AddInternal(new FruitOutline()); | ||
|
||
for (int i = 0; i < nestedHitObjects.Count; i++) | ||
{ | ||
var hitObject = nestedHitObjects[i]; | ||
var outline = (FruitOutline)InternalChildren[i]; | ||
outline.UpdateFrom(hitObjectContainer, hitObject, parentHitObject); | ||
outline.Scale *= hitObject is Droplet ? 0.5f : 1; | ||
} | ||
} | ||
|
||
protected override bool ComputeIsMaskedAway(RectangleF maskingBounds) => false; | ||
} | ||
} |
Oops, something went wrong.