-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/master' into doubleclick
- Loading branch information
Showing
126 changed files
with
2,523 additions
and
1,045 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,17 @@ | ||
// 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 NUnit.Framework; | ||
using osu.Framework.Allocation; | ||
using osu.Framework.Graphics; | ||
using osu.Framework.Graphics.Containers; | ||
using osu.Framework.Testing; | ||
using osu.Game.Rulesets.Judgements; | ||
using osu.Game.Rulesets.Mania.Skinning.Argon; | ||
using osu.Game.Rulesets.Mania.Skinning.Legacy; | ||
using osu.Game.Rulesets.Objects; | ||
using osu.Game.Rulesets.Scoring; | ||
using osu.Game.Rulesets.UI.Scrolling; | ||
using osu.Game.Skinning; | ||
|
||
namespace osu.Game.Rulesets.Mania.Tests.Skinning | ||
|
@@ -17,22 +21,75 @@ public partial class TestSceneComboCounter : ManiaSkinnableTestScene | |
[Cached] | ||
private ScoreProcessor scoreProcessor = new ScoreProcessor(new ManiaRuleset()); | ||
|
||
[SetUpSteps] | ||
public void SetUpSteps() | ||
[Test] | ||
public void TestDisplay() | ||
{ | ||
AddStep("setup", () => SetContents(s => | ||
setup(Anchor.Centre); | ||
AddRepeatStep("perform hit", () => scoreProcessor.ApplyResult(new JudgementResult(new HitObject(), new Judgement()) { Type = HitResult.Great }), 20); | ||
AddStep("perform miss", () => scoreProcessor.ApplyResult(new JudgementResult(new HitObject(), new Judgement()) { Type = HitResult.Miss })); | ||
} | ||
|
||
[Test] | ||
public void TestAnchorOrigin() | ||
{ | ||
AddStep("set direction down", () => ScrollingInfo.Direction.Value = ScrollingDirection.Down); | ||
setup(Anchor.TopCentre, 20); | ||
AddStep("set direction up", () => ScrollingInfo.Direction.Value = ScrollingDirection.Up); | ||
check(Anchor.BottomCentre, -20); | ||
|
||
AddStep("set direction up", () => ScrollingInfo.Direction.Value = ScrollingDirection.Up); | ||
setup(Anchor.BottomCentre, -20); | ||
AddStep("set direction down", () => ScrollingInfo.Direction.Value = ScrollingDirection.Down); | ||
check(Anchor.TopCentre, 20); | ||
|
||
AddStep("set direction down", () => ScrollingInfo.Direction.Value = ScrollingDirection.Down); | ||
setup(Anchor.Centre, 20); | ||
AddStep("set direction up", () => ScrollingInfo.Direction.Value = ScrollingDirection.Up); | ||
check(Anchor.Centre, 20); | ||
|
||
AddStep("set direction up", () => ScrollingInfo.Direction.Value = ScrollingDirection.Up); | ||
setup(Anchor.Centre, -20); | ||
AddStep("set direction down", () => ScrollingInfo.Direction.Value = ScrollingDirection.Down); | ||
check(Anchor.Centre, -20); | ||
} | ||
|
||
private void setup(Anchor anchor, float y = 0) | ||
{ | ||
AddStep($"setup {anchor} {y}", () => SetContents(s => | ||
{ | ||
var container = new Container | ||
{ | ||
RelativeSizeAxes = Axes.Both, | ||
}; | ||
if (s is ArgonSkin) | ||
return new ArgonManiaComboCounter(); | ||
container.Add(new ArgonManiaComboCounter()); | ||
else if (s is LegacySkin) | ||
container.Add(new LegacyManiaComboCounter()); | ||
else | ||
container.Add(new LegacyManiaComboCounter()); | ||
if (s is LegacySkin) | ||
return new LegacyManiaComboCounter(); | ||
container.Child.Anchor = anchor; | ||
container.Child.Origin = Anchor.Centre; | ||
container.Child.Y = y; | ||
return new LegacyManiaComboCounter(); | ||
return container; | ||
})); | ||
} | ||
|
||
AddRepeatStep("perform hit", () => scoreProcessor.ApplyResult(new JudgementResult(new HitObject(), new Judgement()) { Type = HitResult.Great }), 20); | ||
AddStep("perform miss", () => scoreProcessor.ApplyResult(new JudgementResult(new HitObject(), new Judgement()) { Type = HitResult.Miss })); | ||
private void check(Anchor anchor, float y) | ||
{ | ||
AddAssert($"check {anchor} {y}", () => | ||
{ | ||
foreach (var combo in this.ChildrenOfType<ISerialisableDrawable>()) | ||
{ | ||
var drawableCombo = (Drawable)combo; | ||
if (drawableCombo.Anchor != anchor || drawableCombo.Y != y) | ||
return false; | ||
} | ||
return true; | ||
}); | ||
} | ||
} | ||
} |
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
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 System; | ||
using osu.Framework.Allocation; | ||
using osu.Framework.Bindables; | ||
using osu.Framework.Graphics; | ||
|
@@ -44,16 +45,15 @@ protected override void LoadComplete() | |
private void updateAnchor() | ||
{ | ||
// if the anchor isn't a vertical center, set top or bottom anchor based on scroll direction | ||
if (!Anchor.HasFlag(Anchor.y1)) | ||
{ | ||
Anchor &= ~(Anchor.y0 | Anchor.y2); | ||
Anchor |= direction.Value == ScrollingDirection.Up ? Anchor.y2 : Anchor.y0; | ||
} | ||
if (Anchor.HasFlag(Anchor.y1)) | ||
return; | ||
|
||
Anchor &= ~(Anchor.y0 | Anchor.y2); | ||
Anchor |= direction.Value == ScrollingDirection.Up ? Anchor.y2 : Anchor.y0; | ||
|
||
// since we flip the vertical anchor when changing scroll direction, | ||
// we can use the sign of the Y value as an indicator to make the combo counter displayed correctly. | ||
if ((Y < 0 && direction.Value == ScrollingDirection.Down) || (Y > 0 && direction.Value == ScrollingDirection.Up)) | ||
Y = -Y; | ||
// change the sign of the Y coordinate in line with the scrolling direction. | ||
// i.e. if the user changes direction from down to up, the anchor is changed from top to bottom, and the Y is flipped from positive to negative here. | ||
Y = Math.Abs(Y) * (direction.Value == ScrollingDirection.Up ? -1 : 1); | ||
} | ||
|
||
protected override void OnCountIncrement() | ||
|
Oops, something went wrong.