mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 08:02:55 +08:00
Merge branch 'master' into display-sr-changes
This commit is contained in:
commit
2196ae9ca2
@ -27,10 +27,10 @@
|
||||
]
|
||||
},
|
||||
"ppy.localisationanalyser.tools": {
|
||||
"version": "2021.705.0",
|
||||
"version": "2021.725.0",
|
||||
"commands": [
|
||||
"localisation"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -190,3 +190,5 @@ dotnet_diagnostic.CA2225.severity = none
|
||||
|
||||
# Banned APIs
|
||||
dotnet_diagnostic.RS0030.severity = error
|
||||
|
||||
dotnet_diagnostic.OLOC001.license_header = // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.\n// See the LICENCE file in the repository root for full licence text.
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
# osu!
|
||||
|
||||
[![Build status](https://ci.appveyor.com/api/projects/status/u2p01nx7l6og8buh?svg=true)](https://ci.appveyor.com/project/peppy/osu)
|
||||
[![Build status](https://github.com/ppy/osu/actions/workflows/ci.yml/badge.svg?branch=master&event=push)](https://github.com/ppy/osu/actions/workflows/ci.yml)
|
||||
[![GitHub release](https://img.shields.io/github/release/ppy/osu.svg)](https://github.com/ppy/osu/releases/latest)
|
||||
[![CodeFactor](https://www.codefactor.io/repository/github/ppy/osu/badge)](https://www.codefactor.io/repository/github/ppy/osu)
|
||||
[![dev chat](https://discordapp.com/api/guilds/188630481301012481/widget.png?style=shield)](https://discord.gg/ppy)
|
||||
|
@ -51,8 +51,8 @@
|
||||
<Reference Include="Java.Interop" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.722.0" />
|
||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2021.721.0" />
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.810.0" />
|
||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2021.810.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Label="Transitive Dependencies">
|
||||
<!-- Realm needs to be directly referenced in all Xamarin projects, as it will not pull in its transitive dependencies otherwise. -->
|
||||
|
@ -64,7 +64,7 @@
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Xamarin.Essentials" Version="1.6.1" />
|
||||
<PackageReference Include="Xamarin.Essentials" Version="1.7.0" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
|
||||
</Project>
|
@ -32,7 +32,7 @@ namespace osu.Desktop
|
||||
var split = arg.Split('=');
|
||||
|
||||
var key = split[0];
|
||||
var val = split[1];
|
||||
var val = split.Length > 1 ? split[1] : string.Empty;
|
||||
|
||||
switch (key)
|
||||
{
|
||||
|
@ -0,0 +1,155 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. 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 NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.ObjectExtensions;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Rulesets.Catch.Edit.Blueprints;
|
||||
using osu.Game.Rulesets.Catch.Objects;
|
||||
using osu.Game.Rulesets.Catch.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Rulesets.Catch.Tests.Editor
|
||||
{
|
||||
public class TestSceneJuiceStreamPlacementBlueprint : CatchPlacementBlueprintTestScene
|
||||
{
|
||||
private const double velocity = 0.5;
|
||||
|
||||
private JuiceStream lastObject => LastObject?.HitObject as JuiceStream;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
Beatmap.Value.BeatmapInfo.BaseDifficulty.SliderTickRate = 5;
|
||||
Beatmap.Value.BeatmapInfo.BaseDifficulty.SliderMultiplier = velocity * 10;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestBasicPlacement()
|
||||
{
|
||||
double[] times = { 300, 800 };
|
||||
float[] positions = { 100, 200 };
|
||||
addPlacementSteps(times, positions);
|
||||
|
||||
AddAssert("juice stream is placed", () => lastObject != null);
|
||||
AddAssert("start time is correct", () => Precision.AlmostEquals(lastObject.StartTime, times[0]));
|
||||
AddAssert("end time is correct", () => Precision.AlmostEquals(lastObject.EndTime, times[1]));
|
||||
AddAssert("start position is correct", () => Precision.AlmostEquals(lastObject.OriginalX, positions[0]));
|
||||
AddAssert("end position is correct", () => Precision.AlmostEquals(lastObject.EndX, positions[1]));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestEmptyNotCommitted()
|
||||
{
|
||||
addMoveAndClickSteps(100, 100);
|
||||
addMoveAndClickSteps(100, 100);
|
||||
addMoveAndClickSteps(100, 100, true);
|
||||
AddAssert("juice stream not placed", () => lastObject == null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMultipleSegments()
|
||||
{
|
||||
double[] times = { 100, 300, 500, 700 };
|
||||
float[] positions = { 100, 150, 100, 100 };
|
||||
addPlacementSteps(times, positions);
|
||||
|
||||
AddAssert("has 4 vertices", () => lastObject.Path.ControlPoints.Count == 4);
|
||||
addPathCheckStep(times, positions);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestVelocityLimit()
|
||||
{
|
||||
double[] times = { 100, 300 };
|
||||
float[] positions = { 200, 500 };
|
||||
addPlacementSteps(times, positions);
|
||||
addPathCheckStep(times, new float[] { 200, 300 });
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestPreviousVerticesAreFixed()
|
||||
{
|
||||
double[] times = { 100, 300, 500, 700 };
|
||||
float[] positions = { 200, 400, 100, 500 };
|
||||
addPlacementSteps(times, positions);
|
||||
addPathCheckStep(times, new float[] { 200, 300, 200, 300 });
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestClampedPositionIsRestored()
|
||||
{
|
||||
double[] times = { 100, 300, 500 };
|
||||
float[] positions = { 200, 200, 0, 250 };
|
||||
|
||||
addMoveAndClickSteps(times[0], positions[0]);
|
||||
addMoveAndClickSteps(times[1], positions[1]);
|
||||
AddMoveStep(times[2], positions[2]);
|
||||
addMoveAndClickSteps(times[2], positions[3], true);
|
||||
|
||||
addPathCheckStep(times, new float[] { 200, 200, 250 });
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestFirstVertexIsFixed()
|
||||
{
|
||||
double[] times = { 100, 200 };
|
||||
float[] positions = { 100, 300 };
|
||||
addPlacementSteps(times, positions);
|
||||
addPathCheckStep(times, new float[] { 100, 150 });
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestOutOfOrder()
|
||||
{
|
||||
double[] times = { 100, 700, 500, 300 };
|
||||
float[] positions = { 100, 200, 150, 50 };
|
||||
addPlacementSteps(times, positions);
|
||||
addPathCheckStep(times, positions);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMoveBeforeFirstVertex()
|
||||
{
|
||||
double[] times = { 300, 500, 100 };
|
||||
float[] positions = { 100, 100, 100 };
|
||||
addPlacementSteps(times, positions);
|
||||
AddAssert("start time is correct", () => Precision.AlmostEquals(lastObject.StartTime, times[0]));
|
||||
AddAssert("end time is correct", () => Precision.AlmostEquals(lastObject.EndTime, times[1], 1e-3));
|
||||
}
|
||||
|
||||
protected override DrawableHitObject CreateHitObject(HitObject hitObject) => new DrawableJuiceStream((JuiceStream)hitObject);
|
||||
|
||||
protected override PlacementBlueprint CreateBlueprint() => new JuiceStreamPlacementBlueprint();
|
||||
|
||||
private void addMoveAndClickSteps(double time, float position, bool end = false)
|
||||
{
|
||||
AddMoveStep(time, position);
|
||||
AddClickStep(end ? MouseButton.Right : MouseButton.Left);
|
||||
}
|
||||
|
||||
private void addPlacementSteps(double[] times, float[] positions)
|
||||
{
|
||||
for (int i = 0; i < times.Length; i++)
|
||||
addMoveAndClickSteps(times[i], positions[i], i == times.Length - 1);
|
||||
}
|
||||
|
||||
private void addPathCheckStep(double[] times, float[] positions) => AddStep("assert path is correct", () =>
|
||||
Assert.That(getPositions(times), Is.EqualTo(positions).Within(Precision.FLOAT_EPSILON)));
|
||||
|
||||
private float[] getPositions(IEnumerable<double> times)
|
||||
{
|
||||
JuiceStream hitObject = lastObject.AsNonNull();
|
||||
return times
|
||||
.Select(time => (time - hitObject.StartTime) * hitObject.Velocity)
|
||||
.Select(distance => hitObject.EffectiveX + hitObject.Path.PositionAt(distance / hitObject.Distance).X)
|
||||
.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
120
osu.Game.Rulesets.Catch.Tests/Mods/CatchModMirrorTest.cs
Normal file
120
osu.Game.Rulesets.Catch.Tests/Mods/CatchModMirrorTest.cs
Normal file
@ -0,0 +1,120 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Rulesets.Catch.Beatmaps;
|
||||
using osu.Game.Rulesets.Catch.Mods;
|
||||
using osu.Game.Rulesets.Catch.Objects;
|
||||
using osu.Game.Rulesets.Catch.UI;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Catch.Tests.Mods
|
||||
{
|
||||
[TestFixture]
|
||||
public class CatchModMirrorTest
|
||||
{
|
||||
[Test]
|
||||
public void TestModMirror()
|
||||
{
|
||||
IBeatmap original = createBeatmap(false);
|
||||
IBeatmap mirrored = createBeatmap(true);
|
||||
|
||||
assertEffectivePositionsMirrored(original, mirrored);
|
||||
}
|
||||
|
||||
private static IBeatmap createBeatmap(bool withMirrorMod)
|
||||
{
|
||||
var beatmap = createRawBeatmap();
|
||||
var mirrorMod = new CatchModMirror();
|
||||
|
||||
var beatmapProcessor = new CatchBeatmapProcessor(beatmap);
|
||||
beatmapProcessor.PreProcess();
|
||||
|
||||
foreach (var hitObject in beatmap.HitObjects)
|
||||
hitObject.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
||||
|
||||
beatmapProcessor.PostProcess();
|
||||
|
||||
if (withMirrorMod)
|
||||
mirrorMod.ApplyToBeatmap(beatmap);
|
||||
|
||||
return beatmap;
|
||||
}
|
||||
|
||||
private static IBeatmap createRawBeatmap() => new Beatmap
|
||||
{
|
||||
HitObjects = new List<HitObject>
|
||||
{
|
||||
new Fruit
|
||||
{
|
||||
OriginalX = 150,
|
||||
StartTime = 0
|
||||
},
|
||||
new Fruit
|
||||
{
|
||||
OriginalX = 450,
|
||||
StartTime = 500
|
||||
},
|
||||
new JuiceStream
|
||||
{
|
||||
OriginalX = 250,
|
||||
Path = new SliderPath
|
||||
{
|
||||
ControlPoints =
|
||||
{
|
||||
new PathControlPoint(new Vector2(-100, 1)),
|
||||
new PathControlPoint(new Vector2(0, 2)),
|
||||
new PathControlPoint(new Vector2(100, 3)),
|
||||
new PathControlPoint(new Vector2(0, 4))
|
||||
}
|
||||
},
|
||||
StartTime = 1000,
|
||||
},
|
||||
new BananaShower
|
||||
{
|
||||
StartTime = 5000,
|
||||
Duration = 5000
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private static void assertEffectivePositionsMirrored(IBeatmap original, IBeatmap mirrored)
|
||||
{
|
||||
if (original.HitObjects.Count != mirrored.HitObjects.Count)
|
||||
Assert.Fail($"Top-level object count mismatch (original: {original.HitObjects.Count}, mirrored: {mirrored.HitObjects.Count})");
|
||||
|
||||
for (int i = 0; i < original.HitObjects.Count; ++i)
|
||||
{
|
||||
var originalObject = (CatchHitObject)original.HitObjects[i];
|
||||
var mirroredObject = (CatchHitObject)mirrored.HitObjects[i];
|
||||
|
||||
// banana showers themselves are exempt, as we only really care about their nested bananas' positions.
|
||||
if (!effectivePositionMirrored(originalObject, mirroredObject) && !(originalObject is BananaShower))
|
||||
Assert.Fail($"{originalObject.GetType().Name} at time {originalObject.StartTime} is not mirrored ({printEffectivePositions(originalObject, mirroredObject)})");
|
||||
|
||||
if (originalObject.NestedHitObjects.Count != mirroredObject.NestedHitObjects.Count)
|
||||
Assert.Fail($"{originalObject.GetType().Name} nested object count mismatch (original: {originalObject.NestedHitObjects.Count}, mirrored: {mirroredObject.NestedHitObjects.Count})");
|
||||
|
||||
for (int j = 0; j < originalObject.NestedHitObjects.Count; ++j)
|
||||
{
|
||||
var originalNested = (CatchHitObject)originalObject.NestedHitObjects[j];
|
||||
var mirroredNested = (CatchHitObject)mirroredObject.NestedHitObjects[j];
|
||||
|
||||
if (!effectivePositionMirrored(originalNested, mirroredNested))
|
||||
Assert.Fail($"{originalObject.GetType().Name}'s nested {originalNested.GetType().Name} at time {originalObject.StartTime} is not mirrored ({printEffectivePositions(originalNested, mirroredNested)})");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static string printEffectivePositions(CatchHitObject original, CatchHitObject mirrored)
|
||||
=> $"original X: {original.EffectiveX}, mirrored X is: {mirrored.EffectiveX}, mirrored X should be: {CatchPlayfield.WIDTH - original.EffectiveX}";
|
||||
|
||||
private static bool effectivePositionMirrored(CatchHitObject original, CatchHitObject mirrored)
|
||||
=> Precision.AlmostEquals(original.EffectiveX, CatchPlayfield.WIDTH - mirrored.EffectiveX);
|
||||
}
|
||||
}
|
@ -41,7 +41,7 @@ namespace osu.Game.Rulesets.Catch.Tests
|
||||
var skin = new TestSkin { FlipCatcherPlate = flip };
|
||||
container.Child = new SkinProvidingContainer(skin)
|
||||
{
|
||||
Child = catcher = new Catcher(new Container(), new DroppedObjectContainer())
|
||||
Child = catcher = new Catcher(new DroppedObjectContainer())
|
||||
{
|
||||
Anchor = Anchor.Centre
|
||||
}
|
||||
|
@ -31,8 +31,6 @@ namespace osu.Game.Rulesets.Catch.Tests
|
||||
[Resolved]
|
||||
private OsuConfigManager config { get; set; }
|
||||
|
||||
private Container trailContainer;
|
||||
|
||||
private DroppedObjectContainer droppedObjectContainer;
|
||||
|
||||
private TestCatcher catcher;
|
||||
@ -45,7 +43,6 @@ namespace osu.Game.Rulesets.Catch.Tests
|
||||
CircleSize = 0,
|
||||
};
|
||||
|
||||
trailContainer = new Container();
|
||||
droppedObjectContainer = new DroppedObjectContainer();
|
||||
|
||||
Child = new Container
|
||||
@ -54,8 +51,7 @@ namespace osu.Game.Rulesets.Catch.Tests
|
||||
Children = new Drawable[]
|
||||
{
|
||||
droppedObjectContainer,
|
||||
catcher = new TestCatcher(trailContainer, droppedObjectContainer, difficulty),
|
||||
trailContainer,
|
||||
catcher = new TestCatcher(droppedObjectContainer, difficulty),
|
||||
}
|
||||
};
|
||||
});
|
||||
@ -294,8 +290,8 @@ namespace osu.Game.Rulesets.Catch.Tests
|
||||
{
|
||||
public IEnumerable<CaughtObject> CaughtObjects => this.ChildrenOfType<CaughtObject>();
|
||||
|
||||
public TestCatcher(Container trailsTarget, DroppedObjectContainer droppedObjectTarget, BeatmapDifficulty difficulty)
|
||||
: base(trailsTarget, droppedObjectTarget, difficulty)
|
||||
public TestCatcher(DroppedObjectContainer droppedObjectTarget, BeatmapDifficulty difficulty)
|
||||
: base(droppedObjectTarget, difficulty)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -122,10 +122,9 @@ namespace osu.Game.Rulesets.Catch.Tests
|
||||
public TestCatcherArea(BeatmapDifficulty beatmapDifficulty)
|
||||
{
|
||||
var droppedObjectContainer = new DroppedObjectContainer();
|
||||
|
||||
Add(droppedObjectContainer);
|
||||
|
||||
Catcher = new Catcher(this, droppedObjectContainer, beatmapDifficulty)
|
||||
Catcher = new Catcher(droppedObjectContainer, beatmapDifficulty)
|
||||
{
|
||||
X = CatchPlayfield.CENTER_X
|
||||
};
|
||||
|
@ -47,7 +47,7 @@ namespace osu.Game.Rulesets.Catch.Tests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCustomEndGlowColour()
|
||||
public void TestCustomAfterImageColour()
|
||||
{
|
||||
var skin = new TestSkin
|
||||
{
|
||||
@ -58,7 +58,7 @@ namespace osu.Game.Rulesets.Catch.Tests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCustomEndGlowColourPriority()
|
||||
public void TestCustomAfterImageColourPriority()
|
||||
{
|
||||
var skin = new TestSkin
|
||||
{
|
||||
@ -111,39 +111,37 @@ namespace osu.Game.Rulesets.Catch.Tests
|
||||
checkHyperDashFruitColour(skin, skin.HyperDashColour);
|
||||
}
|
||||
|
||||
private void checkHyperDashCatcherColour(ISkin skin, Color4 expectedCatcherColour, Color4? expectedEndGlowColour = null)
|
||||
private void checkHyperDashCatcherColour(ISkin skin, Color4 expectedCatcherColour, Color4? expectedAfterImageColour = null)
|
||||
{
|
||||
Container trailsContainer = null;
|
||||
Catcher catcher = null;
|
||||
CatcherTrailDisplay trails = null;
|
||||
Catcher catcher = null;
|
||||
|
||||
AddStep("create hyper-dashing catcher", () =>
|
||||
{
|
||||
trailsContainer = new Container();
|
||||
CatcherArea catcherArea;
|
||||
Child = setupSkinHierarchy(new Container
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Children = new Drawable[]
|
||||
Child = catcherArea = new CatcherArea
|
||||
{
|
||||
catcher = new Catcher(trailsContainer, new DroppedObjectContainer())
|
||||
Catcher = catcher = new Catcher(new DroppedObjectContainer())
|
||||
{
|
||||
Scale = new Vector2(4)
|
||||
},
|
||||
trailsContainer
|
||||
}
|
||||
}
|
||||
}, skin);
|
||||
trails = catcherArea.ChildrenOfType<CatcherTrailDisplay>().Single();
|
||||
});
|
||||
|
||||
AddStep("get trails container", () =>
|
||||
AddStep("start hyper-dash", () =>
|
||||
{
|
||||
trails = trailsContainer.OfType<CatcherTrailDisplay>().Single();
|
||||
catcher.SetHyperDashState(2);
|
||||
});
|
||||
|
||||
AddUntilStep("catcher colour is correct", () => catcher.Colour == expectedCatcherColour);
|
||||
|
||||
AddAssert("catcher trails colours are correct", () => trails.HyperDashTrailsColour == expectedCatcherColour);
|
||||
AddAssert("catcher end-glow colours are correct", () => trails.EndGlowSpritesColour == (expectedEndGlowColour ?? expectedCatcherColour));
|
||||
AddAssert("catcher after-image colours are correct", () => trails.HyperDashAfterImageColour == (expectedAfterImageColour ?? expectedCatcherColour));
|
||||
|
||||
AddStep("finish hyper-dashing", () =>
|
||||
{
|
||||
|
@ -117,6 +117,7 @@ namespace osu.Game.Rulesets.Catch
|
||||
{
|
||||
new CatchModDifficultyAdjust(),
|
||||
new CatchModClassic(),
|
||||
new CatchModMirror(),
|
||||
};
|
||||
|
||||
case ModType.Automation:
|
||||
@ -130,7 +131,8 @@ namespace osu.Game.Rulesets.Catch
|
||||
return new Mod[]
|
||||
{
|
||||
new MultiMod(new ModWindUp(), new ModWindDown()),
|
||||
new CatchModFloatingFruits()
|
||||
new CatchModFloatingFruits(),
|
||||
new CatchModMuted(),
|
||||
};
|
||||
|
||||
default:
|
||||
|
@ -0,0 +1,49 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using osu.Game.Rulesets.Catch.Objects;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Catch.Edit.Blueprints.Components
|
||||
{
|
||||
public class PlacementEditablePath : EditablePath
|
||||
{
|
||||
/// <summary>
|
||||
/// The original position of the last added vertex.
|
||||
/// This is not same as the last vertex of the current path because the vertex ordering can change.
|
||||
/// </summary>
|
||||
private JuiceStreamPathVertex lastVertex;
|
||||
|
||||
public PlacementEditablePath(Func<float, double> positionToDistance)
|
||||
: base(positionToDistance)
|
||||
{
|
||||
}
|
||||
|
||||
public void AddNewVertex()
|
||||
{
|
||||
var endVertex = Vertices[^1];
|
||||
int index = AddVertex(endVertex.Distance, endVertex.X);
|
||||
|
||||
for (int i = 0; i < VertexCount; i++)
|
||||
{
|
||||
VertexStates[i].IsSelected = i == index;
|
||||
VertexStates[i].IsFixed = i != index;
|
||||
VertexStates[i].VertexBeforeChange = Vertices[i];
|
||||
}
|
||||
|
||||
lastVertex = Vertices[index];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Move the vertex added by <see cref="AddNewVertex"/> in the last time.
|
||||
/// </summary>
|
||||
public void MoveLastVertex(Vector2 screenSpacePosition)
|
||||
{
|
||||
Vector2 position = ToRelativePosition(screenSpacePosition);
|
||||
double distanceDelta = PositionToDistance(position.Y) - lastVertex.Distance;
|
||||
float xDelta = position.X - lastVertex.X;
|
||||
MoveSelectedVertices(distanceDelta, xDelta);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,128 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Rulesets.Catch.Edit.Blueprints.Components;
|
||||
using osu.Game.Rulesets.Catch.Objects;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osuTK;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Rulesets.Catch.Edit.Blueprints
|
||||
{
|
||||
public class JuiceStreamPlacementBlueprint : CatchPlacementBlueprint<JuiceStream>
|
||||
{
|
||||
private readonly ScrollingPath scrollingPath;
|
||||
|
||||
private readonly NestedOutlineContainer nestedOutlineContainer;
|
||||
|
||||
private readonly PlacementEditablePath editablePath;
|
||||
|
||||
private int lastEditablePathId = -1;
|
||||
|
||||
private InputManager inputManager;
|
||||
|
||||
public JuiceStreamPlacementBlueprint()
|
||||
{
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
scrollingPath = new ScrollingPath(),
|
||||
nestedOutlineContainer = new NestedOutlineContainer(),
|
||||
editablePath = new PlacementEditablePath(positionToDistance)
|
||||
};
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
if (PlacementActive == PlacementState.Active)
|
||||
editablePath.UpdateFrom(HitObjectContainer, HitObject);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
inputManager = GetContainingInputManager();
|
||||
}
|
||||
|
||||
protected override bool OnMouseDown(MouseDownEvent e)
|
||||
{
|
||||
switch (PlacementActive)
|
||||
{
|
||||
case PlacementState.Waiting:
|
||||
if (e.Button != MouseButton.Left) break;
|
||||
|
||||
editablePath.AddNewVertex();
|
||||
BeginPlacement(true);
|
||||
return true;
|
||||
|
||||
case PlacementState.Active:
|
||||
switch (e.Button)
|
||||
{
|
||||
case MouseButton.Left:
|
||||
editablePath.AddNewVertex();
|
||||
return true;
|
||||
|
||||
case MouseButton.Right:
|
||||
EndPlacement(HitObject.Duration > 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return base.OnMouseDown(e);
|
||||
}
|
||||
|
||||
public override void UpdateTimeAndPosition(SnapResult result)
|
||||
{
|
||||
switch (PlacementActive)
|
||||
{
|
||||
case PlacementState.Waiting:
|
||||
if (!(result.Time is double snappedTime)) return;
|
||||
|
||||
HitObject.OriginalX = ToLocalSpace(result.ScreenSpacePosition).X;
|
||||
HitObject.StartTime = snappedTime;
|
||||
break;
|
||||
|
||||
case PlacementState.Active:
|
||||
Vector2 unsnappedPosition = inputManager.CurrentState.Mouse.Position;
|
||||
editablePath.MoveLastVertex(unsnappedPosition);
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
// Make sure the up-to-date position is used for outlines.
|
||||
Vector2 startPosition = CatchHitObjectUtils.GetStartPosition(HitObjectContainer, HitObject);
|
||||
editablePath.Position = nestedOutlineContainer.Position = scrollingPath.Position = startPosition;
|
||||
|
||||
updateHitObjectFromPath();
|
||||
}
|
||||
|
||||
private void updateHitObjectFromPath()
|
||||
{
|
||||
if (lastEditablePathId == editablePath.PathId)
|
||||
return;
|
||||
|
||||
editablePath.UpdateHitObjectFromPath(HitObject);
|
||||
ApplyDefaultsToHitObject();
|
||||
|
||||
scrollingPath.UpdatePathFrom(HitObjectContainer, HitObject);
|
||||
nestedOutlineContainer.UpdateNestedObjectsFrom(HitObjectContainer, HitObject);
|
||||
|
||||
lastEditablePathId = editablePath.PathId;
|
||||
}
|
||||
|
||||
private double positionToDistance(float relativeYPosition)
|
||||
{
|
||||
double time = HitObjectContainer.TimeAtPosition(relativeYPosition, HitObject.StartTime);
|
||||
return (time - HitObject.StartTime) * HitObject.Velocity;
|
||||
}
|
||||
}
|
||||
}
|
@ -38,6 +38,7 @@ namespace osu.Game.Rulesets.Catch.Edit
|
||||
protected override IReadOnlyList<HitObjectCompositionTool> CompositionTools => new HitObjectCompositionTool[]
|
||||
{
|
||||
new FruitCompositionTool(),
|
||||
new JuiceStreamCompositionTool(),
|
||||
new BananaShowerCompositionTool()
|
||||
};
|
||||
|
||||
|
24
osu.Game.Rulesets.Catch/Edit/JuiceStreamCompositionTool.cs
Normal file
24
osu.Game.Rulesets.Catch/Edit/JuiceStreamCompositionTool.cs
Normal file
@ -0,0 +1,24 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Catch.Edit.Blueprints;
|
||||
using osu.Game.Rulesets.Catch.Objects;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Rulesets.Edit.Tools;
|
||||
|
||||
namespace osu.Game.Rulesets.Catch.Edit
|
||||
{
|
||||
public class JuiceStreamCompositionTool : HitObjectCompositionTool
|
||||
{
|
||||
public JuiceStreamCompositionTool()
|
||||
: base(nameof(JuiceStream))
|
||||
{
|
||||
}
|
||||
|
||||
public override Drawable CreateIcon() => new BeatmapStatisticIcon(BeatmapStatisticsIconType.Sliders);
|
||||
|
||||
public override PlacementBlueprint CreatePlacementBlueprint() => new JuiceStreamPlacementBlueprint();
|
||||
}
|
||||
}
|
87
osu.Game.Rulesets.Catch/Mods/CatchModMirror.cs
Normal file
87
osu.Game.Rulesets.Catch/Mods/CatchModMirror.cs
Normal file
@ -0,0 +1,87 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Linq;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Catch.Beatmaps;
|
||||
using osu.Game.Rulesets.Catch.Objects;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Catch.UI;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Catch.Mods
|
||||
{
|
||||
public class CatchModMirror : ModMirror, IApplicableToBeatmap
|
||||
{
|
||||
public override string Description => "Fruits are flipped horizontally.";
|
||||
|
||||
/// <remarks>
|
||||
/// <see cref="IApplicableToBeatmap"/> is used instead of <see cref="IApplicableToHitObject"/>,
|
||||
/// as <see cref="CatchBeatmapProcessor"/> applies offsets in <see cref="CatchBeatmapProcessor.PostProcess"/>.
|
||||
/// <see cref="IApplicableToBeatmap"/> runs after post-processing, while <see cref="IApplicableToHitObject"/> runs before it.
|
||||
/// </remarks>
|
||||
public void ApplyToBeatmap(IBeatmap beatmap)
|
||||
{
|
||||
foreach (var hitObject in beatmap.HitObjects)
|
||||
applyToHitObject(hitObject);
|
||||
}
|
||||
|
||||
private void applyToHitObject(HitObject hitObject)
|
||||
{
|
||||
var catchObject = (CatchHitObject)hitObject;
|
||||
|
||||
switch (catchObject)
|
||||
{
|
||||
case Fruit fruit:
|
||||
mirrorEffectiveX(fruit);
|
||||
break;
|
||||
|
||||
case JuiceStream juiceStream:
|
||||
mirrorEffectiveX(juiceStream);
|
||||
mirrorJuiceStreamPath(juiceStream);
|
||||
break;
|
||||
|
||||
case BananaShower bananaShower:
|
||||
mirrorBananaShower(bananaShower);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Mirrors the effective X position of <paramref name="catchObject"/> and its nested hit objects.
|
||||
/// </summary>
|
||||
private static void mirrorEffectiveX(CatchHitObject catchObject)
|
||||
{
|
||||
catchObject.OriginalX = CatchPlayfield.WIDTH - catchObject.OriginalX;
|
||||
catchObject.XOffset = -catchObject.XOffset;
|
||||
|
||||
foreach (var nested in catchObject.NestedHitObjects.Cast<CatchHitObject>())
|
||||
{
|
||||
nested.OriginalX = CatchPlayfield.WIDTH - nested.OriginalX;
|
||||
nested.XOffset = -nested.XOffset;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Mirrors the path of the <paramref name="juiceStream"/>.
|
||||
/// </summary>
|
||||
private static void mirrorJuiceStreamPath(JuiceStream juiceStream)
|
||||
{
|
||||
var controlPoints = juiceStream.Path.ControlPoints.Select(p => new PathControlPoint(p.Position.Value, p.Type.Value)).ToArray();
|
||||
foreach (var point in controlPoints)
|
||||
point.Position.Value = new Vector2(-point.Position.Value.X, point.Position.Value.Y);
|
||||
|
||||
juiceStream.Path = new SliderPath(controlPoints, juiceStream.Path.ExpectedDistance.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Mirrors X positions of all bananas in the <paramref name="bananaShower"/>.
|
||||
/// </summary>
|
||||
private static void mirrorBananaShower(BananaShower bananaShower)
|
||||
{
|
||||
foreach (var banana in bananaShower.NestedHitObjects.OfType<Banana>())
|
||||
banana.XOffset = CatchPlayfield.WIDTH - banana.XOffset;
|
||||
}
|
||||
}
|
||||
}
|
12
osu.Game.Rulesets.Catch/Mods/CatchModMuted.cs
Normal file
12
osu.Game.Rulesets.Catch/Mods/CatchModMuted.cs
Normal file
@ -0,0 +1,12 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Game.Rulesets.Catch.Objects;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
|
||||
namespace osu.Game.Rulesets.Catch.Mods
|
||||
{
|
||||
public class CatchModMuted : ModMuted<CatchHitObject>
|
||||
{
|
||||
}
|
||||
}
|
@ -95,6 +95,14 @@ namespace osu.Game.Rulesets.Catch.Objects
|
||||
set => ComboIndexBindable.Value = value;
|
||||
}
|
||||
|
||||
public Bindable<int> ComboIndexWithOffsetsBindable { get; } = new Bindable<int>();
|
||||
|
||||
public int ComboIndexWithOffsets
|
||||
{
|
||||
get => ComboIndexWithOffsetsBindable.Value;
|
||||
set => ComboIndexWithOffsetsBindable.Value = value;
|
||||
}
|
||||
|
||||
public Bindable<bool> LastInComboBindable { get; } = new Bindable<bool>();
|
||||
|
||||
/// <summary>
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Catch.Objects;
|
||||
using osu.Game.Rulesets.Catch.Objects.Drawables;
|
||||
@ -45,14 +44,9 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
var trailContainer = new Container
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.TopLeft
|
||||
};
|
||||
var droppedObjectContainer = new DroppedObjectContainer();
|
||||
|
||||
Catcher = new Catcher(trailContainer, droppedObjectContainer, difficulty)
|
||||
Catcher = new Catcher(droppedObjectContainer, difficulty)
|
||||
{
|
||||
X = CENTER_X
|
||||
};
|
||||
@ -70,7 +64,6 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
Origin = Anchor.TopLeft,
|
||||
Catcher = Catcher,
|
||||
},
|
||||
trailContainer,
|
||||
HitObjectContainer,
|
||||
});
|
||||
|
||||
|
@ -36,8 +36,7 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
public const float ALLOWED_CATCH_RANGE = 0.8f;
|
||||
|
||||
/// <summary>
|
||||
/// The default colour used to tint hyper-dash fruit, along with the moving catcher, its trail
|
||||
/// and end glow/after-image during a hyper-dash.
|
||||
/// The default colour used to tint hyper-dash fruit, along with the moving catcher, its trail and after-image during a hyper-dash.
|
||||
/// </summary>
|
||||
public static readonly Color4 DEFAULT_HYPER_DASH_COLOUR = Color4.Red;
|
||||
|
||||
@ -71,11 +70,6 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
/// </summary>
|
||||
private const float caught_fruit_scale_adjust = 0.5f;
|
||||
|
||||
[NotNull]
|
||||
private readonly Container trailsTarget;
|
||||
|
||||
private CatcherTrailDisplay trails;
|
||||
|
||||
/// <summary>
|
||||
/// Contains caught objects on the plate.
|
||||
/// </summary>
|
||||
@ -88,30 +82,22 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
|
||||
public CatcherAnimationState CurrentState
|
||||
{
|
||||
get => Body.AnimationState.Value;
|
||||
private set => Body.AnimationState.Value = value;
|
||||
get => body.AnimationState.Value;
|
||||
private set => body.AnimationState.Value = value;
|
||||
}
|
||||
|
||||
private bool dashing;
|
||||
|
||||
public bool Dashing
|
||||
{
|
||||
get => dashing;
|
||||
set
|
||||
{
|
||||
if (value == dashing) return;
|
||||
|
||||
dashing = value;
|
||||
|
||||
updateTrailVisibility();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether the catcher is currently dashing.
|
||||
/// </summary>
|
||||
public bool Dashing { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The currently facing direction.
|
||||
/// </summary>
|
||||
public Direction VisualDirection { get; set; } = Direction.Right;
|
||||
|
||||
public Vector2 BodyScale => Scale * body.Scale;
|
||||
|
||||
/// <summary>
|
||||
/// Whether the contents of the catcher plate should be visually flipped when the catcher direction is changed.
|
||||
/// </summary>
|
||||
@ -122,10 +108,9 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
/// </summary>
|
||||
private readonly float catchWidth;
|
||||
|
||||
internal readonly SkinnableCatcher Body;
|
||||
private readonly SkinnableCatcher body;
|
||||
|
||||
private Color4 hyperDashColour = DEFAULT_HYPER_DASH_COLOUR;
|
||||
private Color4 hyperDashEndGlowColour = DEFAULT_HYPER_DASH_COLOUR;
|
||||
|
||||
private double hyperDashModifier = 1;
|
||||
private int hyperDashDirection;
|
||||
@ -138,9 +123,8 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
private readonly DrawablePool<CaughtBanana> caughtBananaPool;
|
||||
private readonly DrawablePool<CaughtDroplet> caughtDropletPool;
|
||||
|
||||
public Catcher([NotNull] Container trailsTarget, [NotNull] DroppedObjectContainer droppedObjectTarget, BeatmapDifficulty difficulty = null)
|
||||
public Catcher([NotNull] DroppedObjectContainer droppedObjectTarget, BeatmapDifficulty difficulty = null)
|
||||
{
|
||||
this.trailsTarget = trailsTarget;
|
||||
this.droppedObjectTarget = droppedObjectTarget;
|
||||
|
||||
Origin = Anchor.TopCentre;
|
||||
@ -164,7 +148,7 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
// offset fruit vertically to better place "above" the plate.
|
||||
Y = -5
|
||||
},
|
||||
Body = new SkinnableCatcher(),
|
||||
body = new SkinnableCatcher(),
|
||||
hitExplosionContainer = new HitExplosionContainer
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
@ -177,15 +161,6 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
private void load(OsuConfigManager config)
|
||||
{
|
||||
hitLighting = config.GetBindable<bool>(OsuSetting.HitLighting);
|
||||
trails = new CatcherTrailDisplay(this);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
// don't add in above load as we may potentially modify a parent in an unsafe manner.
|
||||
trailsTarget.Add(trails);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -218,14 +193,9 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
if (!(hitObject is PalpableCatchHitObject fruit))
|
||||
return false;
|
||||
|
||||
var halfCatchWidth = catchWidth * 0.5f;
|
||||
|
||||
// this stuff wil disappear once we move fruit to non-relative coordinate space in the future.
|
||||
var catchObjectPosition = fruit.EffectiveX;
|
||||
var catcherPosition = Position.X;
|
||||
|
||||
return catchObjectPosition >= catcherPosition - halfCatchWidth &&
|
||||
catchObjectPosition <= catcherPosition + halfCatchWidth;
|
||||
float halfCatchWidth = catchWidth * 0.5f;
|
||||
return fruit.EffectiveX >= X - halfCatchWidth &&
|
||||
fruit.EffectiveX <= X + halfCatchWidth;
|
||||
}
|
||||
|
||||
public void OnNewResult(DrawableCatchHitObject drawableObject, JudgementResult result)
|
||||
@ -312,10 +282,7 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
hyperDashTargetPosition = targetPosition;
|
||||
|
||||
if (!wasHyperDashing)
|
||||
{
|
||||
trails.DisplayEndGlow();
|
||||
runHyperDashStateTransition(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -331,13 +298,9 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
|
||||
private void runHyperDashStateTransition(bool hyperDashing)
|
||||
{
|
||||
updateTrailVisibility();
|
||||
|
||||
this.FadeColour(hyperDashing ? hyperDashColour : Color4.White, HYPER_DASH_TRANSITION_DURATION, Easing.OutQuint);
|
||||
}
|
||||
|
||||
private void updateTrailVisibility() => trails.DisplayTrail = Dashing || HyperDashing;
|
||||
|
||||
protected override void SkinChanged(ISkinSource skin)
|
||||
{
|
||||
base.SkinChanged(skin);
|
||||
@ -346,13 +309,6 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
skin.GetConfig<CatchSkinColour, Color4>(CatchSkinColour.HyperDash)?.Value ??
|
||||
DEFAULT_HYPER_DASH_COLOUR;
|
||||
|
||||
hyperDashEndGlowColour =
|
||||
skin.GetConfig<CatchSkinColour, Color4>(CatchSkinColour.HyperDashAfterImage)?.Value ??
|
||||
hyperDashColour;
|
||||
|
||||
trails.HyperDashTrailsColour = hyperDashColour;
|
||||
trails.EndGlowSpritesColour = hyperDashEndGlowColour;
|
||||
|
||||
flipCatcherPlate = skin.GetConfig<CatchSkinConfiguration, bool>(CatchSkinConfiguration.FlipCatcherPlate)?.Value ?? true;
|
||||
|
||||
runHyperDashStateTransition(HyperDashing);
|
||||
@ -363,7 +319,7 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
base.Update();
|
||||
|
||||
var scaleFromDirection = new Vector2((int)VisualDirection, 1);
|
||||
Body.Scale = scaleFromDirection;
|
||||
body.Scale = scaleFromDirection;
|
||||
caughtObjectContainer.Scale = hitExplosionContainer.Scale = flipCatcherPlate ? scaleFromDirection : Vector2.One;
|
||||
|
||||
// Correct overshooting.
|
||||
|
@ -25,17 +25,15 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
public Catcher Catcher
|
||||
{
|
||||
get => catcher;
|
||||
set
|
||||
{
|
||||
if (catcher != null)
|
||||
Remove(catcher);
|
||||
|
||||
Add(catcher = value);
|
||||
}
|
||||
set => catcherContainer.Child = catcher = value;
|
||||
}
|
||||
|
||||
private readonly Container<Catcher> catcherContainer;
|
||||
|
||||
private readonly CatchComboDisplay comboDisplay;
|
||||
|
||||
private readonly CatcherTrailDisplay catcherTrails;
|
||||
|
||||
private Catcher catcher;
|
||||
|
||||
/// <summary>
|
||||
@ -45,20 +43,28 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
/// </summary>
|
||||
private int currentDirection;
|
||||
|
||||
// TODO: support replay rewind
|
||||
private bool lastHyperDashState;
|
||||
|
||||
/// <remarks>
|
||||
/// <see cref="Catcher"/> must be set before loading.
|
||||
/// </remarks>
|
||||
public CatcherArea()
|
||||
{
|
||||
Size = new Vector2(CatchPlayfield.WIDTH, Catcher.BASE_SIZE);
|
||||
Child = comboDisplay = new CatchComboDisplay
|
||||
Children = new Drawable[]
|
||||
{
|
||||
RelativeSizeAxes = Axes.None,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.TopLeft,
|
||||
Origin = Anchor.Centre,
|
||||
Margin = new MarginPadding { Bottom = 350f },
|
||||
X = CatchPlayfield.CENTER_X
|
||||
catcherContainer = new Container<Catcher> { RelativeSizeAxes = Axes.Both },
|
||||
catcherTrails = new CatcherTrailDisplay(),
|
||||
comboDisplay = new CatchComboDisplay
|
||||
{
|
||||
RelativeSizeAxes = Axes.None,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.TopLeft,
|
||||
Origin = Anchor.Centre,
|
||||
Margin = new MarginPadding { Bottom = 350f },
|
||||
X = CatchPlayfield.CENTER_X
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -102,6 +108,27 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
base.UpdateAfterChildren();
|
||||
|
||||
comboDisplay.X = Catcher.X;
|
||||
|
||||
if (Time.Elapsed <= 0)
|
||||
{
|
||||
// This is probably a wrong value, but currently the true value is not recorded.
|
||||
// Setting `true` will prevent generation of false-positive after-images (with more false-negatives).
|
||||
lastHyperDashState = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!lastHyperDashState && Catcher.HyperDashing)
|
||||
displayCatcherTrail(CatcherTrailAnimation.HyperDashAfterImage);
|
||||
|
||||
if (Catcher.Dashing || Catcher.HyperDashing)
|
||||
{
|
||||
double generationInterval = Catcher.HyperDashing ? 25 : 50;
|
||||
|
||||
if (Time.Current - catcherTrails.LastDashTrailTime >= generationInterval)
|
||||
displayCatcherTrail(Catcher.HyperDashing ? CatcherTrailAnimation.HyperDashing : CatcherTrailAnimation.Dashing);
|
||||
}
|
||||
|
||||
lastHyperDashState = Catcher.HyperDashing;
|
||||
}
|
||||
|
||||
public void SetCatcherPosition(float X)
|
||||
@ -154,5 +181,7 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void displayCatcherTrail(CatcherTrailAnimation animation) => catcherTrails.Add(new CatcherTrailEntry(Time.Current, Catcher.CurrentState, Catcher.X, Catcher.BodyScale, animation));
|
||||
}
|
||||
}
|
||||
|
@ -2,8 +2,8 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Pooling;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Rulesets.Objects.Pooling;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Catch.UI
|
||||
@ -12,13 +12,8 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
/// A trail of the catcher.
|
||||
/// It also represents a hyper dash afterimage.
|
||||
/// </summary>
|
||||
public class CatcherTrail : PoolableDrawable
|
||||
public class CatcherTrail : PoolableDrawableWithLifetime<CatcherTrailEntry>
|
||||
{
|
||||
public CatcherAnimationState AnimationState
|
||||
{
|
||||
set => body.AnimationState.Value = value;
|
||||
}
|
||||
|
||||
private readonly SkinnableCatcher body;
|
||||
|
||||
public CatcherTrail()
|
||||
@ -34,11 +29,40 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
};
|
||||
}
|
||||
|
||||
protected override void FreeAfterUse()
|
||||
protected override void OnApply(CatcherTrailEntry entry)
|
||||
{
|
||||
Position = new Vector2(entry.Position, 0);
|
||||
Scale = entry.Scale;
|
||||
|
||||
body.AnimationState.Value = entry.CatcherState;
|
||||
|
||||
using (BeginAbsoluteSequence(entry.LifetimeStart, false))
|
||||
applyTransforms(entry.Animation);
|
||||
}
|
||||
|
||||
protected override void OnFree(CatcherTrailEntry entry)
|
||||
{
|
||||
ApplyTransformsAt(double.MinValue);
|
||||
ClearTransforms();
|
||||
Alpha = 1;
|
||||
base.FreeAfterUse();
|
||||
}
|
||||
|
||||
private void applyTransforms(CatcherTrailAnimation animation)
|
||||
{
|
||||
switch (animation)
|
||||
{
|
||||
case CatcherTrailAnimation.Dashing:
|
||||
case CatcherTrailAnimation.HyperDashing:
|
||||
this.FadeTo(0.4f).FadeOut(800, Easing.OutQuint);
|
||||
break;
|
||||
|
||||
case CatcherTrailAnimation.HyperDashAfterImage:
|
||||
this.MoveToOffset(new Vector2(0, -10), 1200, Easing.In);
|
||||
this.ScaleTo(Scale * 0.95f).ScaleTo(Scale * 1.2f, 1200, Easing.In);
|
||||
this.FadeOut(1200);
|
||||
break;
|
||||
}
|
||||
|
||||
Expire();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
12
osu.Game.Rulesets.Catch/UI/CatcherTrailAnimation.cs
Normal file
12
osu.Game.Rulesets.Catch/UI/CatcherTrailAnimation.cs
Normal file
@ -0,0 +1,12 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
namespace osu.Game.Rulesets.Catch.UI
|
||||
{
|
||||
public enum CatcherTrailAnimation
|
||||
{
|
||||
Dashing,
|
||||
HyperDashing,
|
||||
HyperDashAfterImage
|
||||
}
|
||||
}
|
@ -2,11 +2,13 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Pooling;
|
||||
using osuTK;
|
||||
using osu.Game.Rulesets.Catch.Skinning;
|
||||
using osu.Game.Rulesets.Objects.Pooling;
|
||||
using osu.Game.Skinning;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Rulesets.Catch.UI
|
||||
@ -15,70 +17,32 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
/// Represents a component responsible for displaying
|
||||
/// the appropriate catcher trails when requested to.
|
||||
/// </summary>
|
||||
public class CatcherTrailDisplay : CompositeDrawable
|
||||
public class CatcherTrailDisplay : PooledDrawableWithLifetimeContainer<CatcherTrailEntry, CatcherTrail>
|
||||
{
|
||||
private readonly Catcher catcher;
|
||||
/// <summary>
|
||||
/// The most recent time a dash trail was added to this container.
|
||||
/// Only alive (not faded out) trails are considered.
|
||||
/// Returns <see cref="double.NegativeInfinity"/> if no dash trail is alive.
|
||||
/// </summary>
|
||||
public double LastDashTrailTime => getLastDashTrailTime();
|
||||
|
||||
public Color4 HyperDashTrailsColour => hyperDashTrails.Colour;
|
||||
|
||||
public Color4 HyperDashAfterImageColour => hyperDashAfterImages.Colour;
|
||||
|
||||
protected override bool RemoveRewoundEntry => true;
|
||||
|
||||
private readonly DrawablePool<CatcherTrail> trailPool;
|
||||
|
||||
private readonly Container<CatcherTrail> dashTrails;
|
||||
private readonly Container<CatcherTrail> hyperDashTrails;
|
||||
private readonly Container<CatcherTrail> endGlowSprites;
|
||||
private readonly Container<CatcherTrail> hyperDashAfterImages;
|
||||
|
||||
private Color4 hyperDashTrailsColour = Catcher.DEFAULT_HYPER_DASH_COLOUR;
|
||||
[Resolved]
|
||||
private ISkinSource skin { get; set; }
|
||||
|
||||
public Color4 HyperDashTrailsColour
|
||||
public CatcherTrailDisplay()
|
||||
{
|
||||
get => hyperDashTrailsColour;
|
||||
set
|
||||
{
|
||||
if (hyperDashTrailsColour == value)
|
||||
return;
|
||||
|
||||
hyperDashTrailsColour = value;
|
||||
hyperDashTrails.Colour = hyperDashTrailsColour;
|
||||
}
|
||||
}
|
||||
|
||||
private Color4 endGlowSpritesColour = Catcher.DEFAULT_HYPER_DASH_COLOUR;
|
||||
|
||||
public Color4 EndGlowSpritesColour
|
||||
{
|
||||
get => endGlowSpritesColour;
|
||||
set
|
||||
{
|
||||
if (endGlowSpritesColour == value)
|
||||
return;
|
||||
|
||||
endGlowSpritesColour = value;
|
||||
endGlowSprites.Colour = endGlowSpritesColour;
|
||||
}
|
||||
}
|
||||
|
||||
private bool trail;
|
||||
|
||||
/// <summary>
|
||||
/// Whether to start displaying trails following the catcher.
|
||||
/// </summary>
|
||||
public bool DisplayTrail
|
||||
{
|
||||
get => trail;
|
||||
set
|
||||
{
|
||||
if (trail == value)
|
||||
return;
|
||||
|
||||
trail = value;
|
||||
|
||||
if (trail)
|
||||
displayTrail();
|
||||
}
|
||||
}
|
||||
|
||||
public CatcherTrailDisplay([NotNull] Catcher catcher)
|
||||
{
|
||||
this.catcher = catcher ?? throw new ArgumentNullException(nameof(catcher));
|
||||
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
@ -86,47 +50,86 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
trailPool = new DrawablePool<CatcherTrail>(30),
|
||||
dashTrails = new Container<CatcherTrail> { RelativeSizeAxes = Axes.Both },
|
||||
hyperDashTrails = new Container<CatcherTrail> { RelativeSizeAxes = Axes.Both, Colour = Catcher.DEFAULT_HYPER_DASH_COLOUR },
|
||||
endGlowSprites = new Container<CatcherTrail> { RelativeSizeAxes = Axes.Both, Colour = Catcher.DEFAULT_HYPER_DASH_COLOUR },
|
||||
hyperDashAfterImages = new Container<CatcherTrail> { RelativeSizeAxes = Axes.Both, Colour = Catcher.DEFAULT_HYPER_DASH_COLOUR },
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Displays a single end-glow catcher sprite.
|
||||
/// </summary>
|
||||
public void DisplayEndGlow()
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
var endGlow = createTrailSprite(endGlowSprites);
|
||||
base.LoadComplete();
|
||||
|
||||
endGlow.MoveToOffset(new Vector2(0, -10), 1200, Easing.In);
|
||||
endGlow.ScaleTo(endGlow.Scale * 0.95f).ScaleTo(endGlow.Scale * 1.2f, 1200, Easing.In);
|
||||
endGlow.FadeOut(1200);
|
||||
endGlow.Expire(true);
|
||||
skin.SourceChanged += skinSourceChanged;
|
||||
skinSourceChanged();
|
||||
}
|
||||
|
||||
private void displayTrail()
|
||||
private void skinSourceChanged()
|
||||
{
|
||||
if (!DisplayTrail)
|
||||
return;
|
||||
|
||||
var sprite = createTrailSprite(catcher.HyperDashing ? hyperDashTrails : dashTrails);
|
||||
|
||||
sprite.FadeTo(0.4f).FadeOut(800, Easing.OutQuint);
|
||||
sprite.Expire(true);
|
||||
|
||||
Scheduler.AddDelayed(displayTrail, catcher.HyperDashing ? 25 : 50);
|
||||
hyperDashTrails.Colour = skin.GetConfig<CatchSkinColour, Color4>(CatchSkinColour.HyperDash)?.Value ?? Catcher.DEFAULT_HYPER_DASH_COLOUR;
|
||||
hyperDashAfterImages.Colour = skin.GetConfig<CatchSkinColour, Color4>(CatchSkinColour.HyperDashAfterImage)?.Value ?? hyperDashTrails.Colour;
|
||||
}
|
||||
|
||||
private CatcherTrail createTrailSprite(Container<CatcherTrail> target)
|
||||
protected override void AddDrawable(CatcherTrailEntry entry, CatcherTrail drawable)
|
||||
{
|
||||
CatcherTrail sprite = trailPool.Get();
|
||||
switch (entry.Animation)
|
||||
{
|
||||
case CatcherTrailAnimation.Dashing:
|
||||
dashTrails.Add(drawable);
|
||||
break;
|
||||
|
||||
sprite.AnimationState = catcher.CurrentState;
|
||||
sprite.Scale = catcher.Scale * catcher.Body.Scale;
|
||||
sprite.Position = catcher.Position;
|
||||
case CatcherTrailAnimation.HyperDashing:
|
||||
hyperDashTrails.Add(drawable);
|
||||
break;
|
||||
|
||||
target.Add(sprite);
|
||||
case CatcherTrailAnimation.HyperDashAfterImage:
|
||||
hyperDashAfterImages.Add(drawable);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return sprite;
|
||||
protected override void RemoveDrawable(CatcherTrailEntry entry, CatcherTrail drawable)
|
||||
{
|
||||
switch (entry.Animation)
|
||||
{
|
||||
case CatcherTrailAnimation.Dashing:
|
||||
dashTrails.Remove(drawable);
|
||||
break;
|
||||
|
||||
case CatcherTrailAnimation.HyperDashing:
|
||||
hyperDashTrails.Remove(drawable);
|
||||
break;
|
||||
|
||||
case CatcherTrailAnimation.HyperDashAfterImage:
|
||||
hyperDashAfterImages.Remove(drawable);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected override CatcherTrail GetDrawable(CatcherTrailEntry entry)
|
||||
{
|
||||
CatcherTrail trail = trailPool.Get();
|
||||
trail.Apply(entry);
|
||||
return trail;
|
||||
}
|
||||
|
||||
private double getLastDashTrailTime()
|
||||
{
|
||||
double maxTime = double.NegativeInfinity;
|
||||
|
||||
foreach (var trail in dashTrails)
|
||||
maxTime = Math.Max(maxTime, trail.LifetimeStart);
|
||||
|
||||
foreach (var trail in hyperDashTrails)
|
||||
maxTime = Math.Max(maxTime, trail.LifetimeStart);
|
||||
|
||||
return maxTime;
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
|
||||
if (skin != null)
|
||||
skin.SourceChanged -= skinSourceChanged;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
31
osu.Game.Rulesets.Catch/UI/CatcherTrailEntry.cs
Normal file
31
osu.Game.Rulesets.Catch/UI/CatcherTrailEntry.cs
Normal file
@ -0,0 +1,31 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Graphics.Performance;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Catch.UI
|
||||
{
|
||||
public class CatcherTrailEntry : LifetimeEntry
|
||||
{
|
||||
public readonly CatcherAnimationState CatcherState;
|
||||
|
||||
public readonly float Position;
|
||||
|
||||
/// <summary>
|
||||
/// The scaling of the catcher body. It also represents a flipped catcher (negative x component).
|
||||
/// </summary>
|
||||
public readonly Vector2 Scale;
|
||||
|
||||
public readonly CatcherTrailAnimation Animation;
|
||||
|
||||
public CatcherTrailEntry(double startTime, CatcherAnimationState catcherState, float position, Vector2 scale, CatcherTrailAnimation animation)
|
||||
{
|
||||
LifetimeStart = startTime;
|
||||
CatcherState = catcherState;
|
||||
Position = position;
|
||||
Scale = scale;
|
||||
Animation = animation;
|
||||
}
|
||||
}
|
||||
}
|
@ -253,7 +253,8 @@ namespace osu.Game.Rulesets.Mania
|
||||
case ModType.Fun:
|
||||
return new Mod[]
|
||||
{
|
||||
new MultiMod(new ModWindUp(), new ModWindDown())
|
||||
new MultiMod(new ModWindUp(), new ModWindDown()),
|
||||
new ManiaModMuted(),
|
||||
};
|
||||
|
||||
default:
|
||||
|
@ -10,13 +10,9 @@ using osu.Game.Rulesets.Mania.Beatmaps;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Mods
|
||||
{
|
||||
public class ManiaModMirror : Mod, IApplicableToBeatmap
|
||||
public class ManiaModMirror : ModMirror, IApplicableToBeatmap
|
||||
{
|
||||
public override string Name => "Mirror";
|
||||
public override string Acronym => "MR";
|
||||
public override ModType Type => ModType.Conversion;
|
||||
public override string Description => "Notes are flipped horizontally.";
|
||||
public override double ScoreMultiplier => 1;
|
||||
|
||||
public void ApplyToBeatmap(IBeatmap beatmap)
|
||||
{
|
||||
|
12
osu.Game.Rulesets.Mania/Mods/ManiaModMuted.cs
Normal file
12
osu.Game.Rulesets.Mania/Mods/ManiaModMuted.cs
Normal file
@ -0,0 +1,12 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Game.Rulesets.Mania.Objects;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Mods
|
||||
{
|
||||
public class ManiaModMuted : ModMuted<ManiaHitObject>
|
||||
{
|
||||
}
|
||||
}
|
52
osu.Game.Rulesets.Osu.Tests/Mods/TestSceneOsuModMuted.cs
Normal file
52
osu.Game.Rulesets.Osu.Tests/Mods/TestSceneOsuModMuted.cs
Normal file
@ -0,0 +1,52 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. 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.Testing;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Osu.Mods;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Tests.Mods
|
||||
{
|
||||
public class TestSceneOsuModMuted : OsuModTestScene
|
||||
{
|
||||
/// <summary>
|
||||
/// Ensures that a final volume combo of 0 (i.e. "always muted" mode) constantly plays metronome and completely mutes track.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestZeroFinalCombo() => CreateModTest(new ModTestData
|
||||
{
|
||||
Mod = new OsuModMuted
|
||||
{
|
||||
MuteComboCount = { Value = 0 },
|
||||
},
|
||||
PassCondition = () => Beatmap.Value.Track.AggregateVolume.Value == 0.0 &&
|
||||
Player.ChildrenOfType<Metronome>().SingleOrDefault()?.AggregateVolume.Value == 1.0,
|
||||
});
|
||||
|
||||
/// <summary>
|
||||
/// Ensures that copying from a normal mod with 0 final combo while originally inversed does not yield incorrect results.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestModCopy()
|
||||
{
|
||||
OsuModMuted muted = null;
|
||||
|
||||
AddStep("create inversed mod", () => muted = new OsuModMuted
|
||||
{
|
||||
MuteComboCount = { Value = 100 },
|
||||
InverseMuting = { Value = true },
|
||||
});
|
||||
|
||||
AddStep("copy from normal", () => muted.CopyFrom(new OsuModMuted
|
||||
{
|
||||
MuteComboCount = { Value = 0 },
|
||||
InverseMuting = { Value = false },
|
||||
}));
|
||||
|
||||
AddAssert("mute combo count = 0", () => muted.MuteComboCount.Value == 0);
|
||||
AddAssert("inverse muting = false", () => muted.InverseMuting.Value == false);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,16 +1,21 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Skinning;
|
||||
using osu.Game.Tests.Beatmaps;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Tests
|
||||
{
|
||||
@ -77,23 +82,106 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
AddAssert("is custom user skin colours", () => TestPlayer.UsableComboColours.SequenceEqual(TestSkin.Colours));
|
||||
}
|
||||
|
||||
[TestCase(true, true)]
|
||||
[TestCase(true, false)]
|
||||
[TestCase(false, true)]
|
||||
[TestCase(false, false)]
|
||||
public void TestComboOffsetWithBeatmapColours(bool userHasCustomColours, bool useBeatmapSkin)
|
||||
{
|
||||
PrepareBeatmap(() => new OsuCustomSkinWorkingBeatmap(audio, true, getHitCirclesWithLegacyOffsets()));
|
||||
ConfigureTest(useBeatmapSkin, true, userHasCustomColours);
|
||||
assertCorrectObjectComboColours("is beatmap skin colours with combo offsets applied",
|
||||
TestBeatmapSkin.Colours,
|
||||
(i, obj) => i + 1 + obj.ComboOffset);
|
||||
}
|
||||
|
||||
[TestCase(true)]
|
||||
[TestCase(false)]
|
||||
public void TestComboOffsetWithIgnoredBeatmapColours(bool useBeatmapSkin)
|
||||
{
|
||||
PrepareBeatmap(() => new OsuCustomSkinWorkingBeatmap(audio, true, getHitCirclesWithLegacyOffsets()));
|
||||
ConfigureTest(useBeatmapSkin, false, true);
|
||||
assertCorrectObjectComboColours("is user skin colours without combo offsets applied",
|
||||
TestSkin.Colours,
|
||||
(i, _) => i + 1);
|
||||
}
|
||||
|
||||
private void assertCorrectObjectComboColours(string description, Color4[] expectedColours, Func<int, OsuHitObject, int> nextExpectedComboIndex)
|
||||
{
|
||||
AddUntilStep("wait for objects to become alive", () =>
|
||||
TestPlayer.DrawableRuleset.Playfield.AllHitObjects.Count() == TestPlayer.DrawableRuleset.Objects.Count());
|
||||
|
||||
AddAssert(description, () =>
|
||||
{
|
||||
int index = 0;
|
||||
|
||||
return TestPlayer.DrawableRuleset.Playfield.AllHitObjects.All(d =>
|
||||
{
|
||||
index = nextExpectedComboIndex(index, (OsuHitObject)d.HitObject);
|
||||
return checkComboColour(d, expectedColours[index % expectedColours.Length]);
|
||||
});
|
||||
});
|
||||
|
||||
static bool checkComboColour(DrawableHitObject drawableHitObject, Color4 expectedColour)
|
||||
{
|
||||
return drawableHitObject.AccentColour.Value == expectedColour &&
|
||||
drawableHitObject.NestedHitObjects.All(n => checkComboColour(n, expectedColour));
|
||||
}
|
||||
}
|
||||
|
||||
private static IEnumerable<OsuHitObject> getHitCirclesWithLegacyOffsets()
|
||||
{
|
||||
var hitObjects = new List<OsuHitObject>();
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
var hitObject = i % 2 == 0
|
||||
? (OsuHitObject)new HitCircle()
|
||||
: new Slider
|
||||
{
|
||||
Path = new SliderPath(new[]
|
||||
{
|
||||
new PathControlPoint(new Vector2(0, 0)),
|
||||
new PathControlPoint(new Vector2(100, 0)),
|
||||
})
|
||||
};
|
||||
|
||||
hitObject.StartTime = i;
|
||||
hitObject.Position = new Vector2(256, 192);
|
||||
hitObject.NewCombo = true;
|
||||
hitObject.ComboOffset = i;
|
||||
|
||||
hitObjects.Add(hitObject);
|
||||
}
|
||||
|
||||
return hitObjects;
|
||||
}
|
||||
|
||||
private class OsuCustomSkinWorkingBeatmap : CustomSkinWorkingBeatmap
|
||||
{
|
||||
public OsuCustomSkinWorkingBeatmap(AudioManager audio, bool hasColours)
|
||||
: base(createBeatmap(), audio, hasColours)
|
||||
public OsuCustomSkinWorkingBeatmap(AudioManager audio, bool hasColours, IEnumerable<OsuHitObject> hitObjects = null)
|
||||
: base(createBeatmap(hitObjects), audio, hasColours)
|
||||
{
|
||||
}
|
||||
|
||||
private static IBeatmap createBeatmap() =>
|
||||
new Beatmap
|
||||
private static IBeatmap createBeatmap(IEnumerable<OsuHitObject> hitObjects)
|
||||
{
|
||||
var beatmap = new Beatmap
|
||||
{
|
||||
BeatmapInfo =
|
||||
{
|
||||
BeatmapSet = new BeatmapSetInfo(),
|
||||
Ruleset = new OsuRuleset().RulesetInfo,
|
||||
},
|
||||
HitObjects = { new HitCircle { Position = new Vector2(256, 192) } }
|
||||
};
|
||||
|
||||
beatmap.HitObjects.AddRange(hitObjects ?? new[]
|
||||
{
|
||||
new HitCircle { Position = new Vector2(256, 192) }
|
||||
});
|
||||
|
||||
return beatmap;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,12 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Rulesets.Osu.UI;
|
||||
using osuTK;
|
||||
using osu.Game.Rulesets.Osu.Utils;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Mods
|
||||
{
|
||||
@ -15,23 +14,13 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
{
|
||||
public override double ScoreMultiplier => 1.06;
|
||||
|
||||
public override Type[] IncompatibleMods => base.IncompatibleMods.Append(typeof(ModMirror)).ToArray();
|
||||
|
||||
public void ApplyToHitObject(HitObject hitObject)
|
||||
{
|
||||
var osuObject = (OsuHitObject)hitObject;
|
||||
|
||||
osuObject.Position = new Vector2(osuObject.Position.X, OsuPlayfield.BASE_SIZE.Y - osuObject.Y);
|
||||
|
||||
if (!(hitObject is Slider slider))
|
||||
return;
|
||||
|
||||
slider.NestedHitObjects.OfType<SliderTick>().ForEach(h => h.Position = new Vector2(h.Position.X, OsuPlayfield.BASE_SIZE.Y - h.Position.Y));
|
||||
slider.NestedHitObjects.OfType<SliderRepeat>().ForEach(h => h.Position = new Vector2(h.Position.X, OsuPlayfield.BASE_SIZE.Y - h.Position.Y));
|
||||
|
||||
var controlPoints = slider.Path.ControlPoints.Select(p => new PathControlPoint(p.Position.Value, p.Type.Value)).ToArray();
|
||||
foreach (var point in controlPoints)
|
||||
point.Position.Value = new Vector2(point.Position.Value.X, -point.Position.Value.Y);
|
||||
|
||||
slider.Path = new SliderPath(controlPoints, slider.Path.ExpectedDistance.Value);
|
||||
OsuHitObjectGenerationUtils.ReflectVertically(osuObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
50
osu.Game.Rulesets.Osu/Mods/OsuModMirror.cs
Normal file
50
osu.Game.Rulesets.Osu/Mods/OsuModMirror.cs
Normal file
@ -0,0 +1,50 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Rulesets.Osu.Utils;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Mods
|
||||
{
|
||||
public class OsuModMirror : ModMirror, IApplicableToHitObject
|
||||
{
|
||||
public override string Description => "Flip objects on the chosen axes.";
|
||||
public override Type[] IncompatibleMods => new[] { typeof(ModHardRock) };
|
||||
|
||||
[SettingSource("Mirrored axes", "Choose which axes objects are mirrored over.")]
|
||||
public Bindable<MirrorType> Reflection { get; } = new Bindable<MirrorType>();
|
||||
|
||||
public void ApplyToHitObject(HitObject hitObject)
|
||||
{
|
||||
var osuObject = (OsuHitObject)hitObject;
|
||||
|
||||
switch (Reflection.Value)
|
||||
{
|
||||
case MirrorType.Horizontal:
|
||||
OsuHitObjectGenerationUtils.ReflectHorizontally(osuObject);
|
||||
break;
|
||||
|
||||
case MirrorType.Vertical:
|
||||
OsuHitObjectGenerationUtils.ReflectVertically(osuObject);
|
||||
break;
|
||||
|
||||
case MirrorType.Both:
|
||||
OsuHitObjectGenerationUtils.ReflectHorizontally(osuObject);
|
||||
OsuHitObjectGenerationUtils.ReflectVertically(osuObject);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public enum MirrorType
|
||||
{
|
||||
Horizontal,
|
||||
Vertical,
|
||||
Both
|
||||
}
|
||||
}
|
||||
}
|
12
osu.Game.Rulesets.Osu/Mods/OsuModMuted.cs
Normal file
12
osu.Game.Rulesets.Osu/Mods/OsuModMuted.cs
Normal file
@ -0,0 +1,12 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Mods
|
||||
{
|
||||
public class OsuModMuted : ModMuted<OsuHitObject>
|
||||
{
|
||||
}
|
||||
}
|
@ -4,8 +4,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
@ -16,7 +14,6 @@ using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Beatmaps.Timing;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Overlays.Settings;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
@ -29,7 +26,6 @@ using osu.Game.Rulesets.Osu.UI;
|
||||
using osu.Game.Rulesets.Osu.Utils;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Skinning;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
@ -67,11 +63,6 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
/// </summary>
|
||||
private const float distance_cap = 380f;
|
||||
|
||||
// The distances from the hit objects to the borders of the playfield they start to "turn around" and curve towards the middle.
|
||||
// The closer the hit objects draw to the border, the sharper the turn
|
||||
private const byte border_distance_x = 192;
|
||||
private const byte border_distance_y = 144;
|
||||
|
||||
/// <summary>
|
||||
/// The extent of rotation towards playfield centre when a circle is near the edge
|
||||
/// </summary>
|
||||
@ -341,46 +332,7 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
|
||||
public void ApplyToDrawableRuleset(DrawableRuleset<OsuHitObject> drawableRuleset)
|
||||
{
|
||||
drawableRuleset.Overlays.Add(new TargetBeatContainer(drawableRuleset.Beatmap.HitObjects.First().StartTime));
|
||||
}
|
||||
|
||||
public class TargetBeatContainer : BeatSyncedContainer
|
||||
{
|
||||
private readonly double firstHitTime;
|
||||
|
||||
private PausableSkinnableSound sample;
|
||||
|
||||
public TargetBeatContainer(double firstHitTime)
|
||||
{
|
||||
this.firstHitTime = firstHitTime;
|
||||
AllowMistimedEventFiring = false;
|
||||
Divisor = 1;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
sample = new PausableSkinnableSound(new SampleInfo("Gameplay/catch-banana"))
|
||||
};
|
||||
}
|
||||
|
||||
protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, ChannelAmplitudes amplitudes)
|
||||
{
|
||||
base.OnNewBeat(beatIndex, timingPoint, effectPoint, amplitudes);
|
||||
|
||||
if (!IsBeatSyncedWithTrack) return;
|
||||
|
||||
int timeSignature = (int)timingPoint.TimeSignature;
|
||||
|
||||
// play metronome from one measure before the first object.
|
||||
if (BeatSyncClock.CurrentTime < firstHitTime - timingPoint.BeatLength * timeSignature)
|
||||
return;
|
||||
|
||||
sample.Frequency.Value = beatIndex % timeSignature == 0 ? 1 : 0.5f;
|
||||
sample.Play();
|
||||
}
|
||||
drawableRuleset.Overlays.Add(new Metronome(drawableRuleset.Beatmap.HitObjects.First().StartTime));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -97,6 +97,14 @@ namespace osu.Game.Rulesets.Osu.Objects
|
||||
set => ComboIndexBindable.Value = value;
|
||||
}
|
||||
|
||||
public Bindable<int> ComboIndexWithOffsetsBindable { get; } = new Bindable<int>();
|
||||
|
||||
public int ComboIndexWithOffsets
|
||||
{
|
||||
get => ComboIndexWithOffsetsBindable.Value;
|
||||
set => ComboIndexWithOffsetsBindable.Value = value;
|
||||
}
|
||||
|
||||
public Bindable<bool> LastInComboBindable { get; } = new Bindable<bool>();
|
||||
|
||||
public bool LastInCombo
|
||||
|
@ -166,6 +166,7 @@ namespace osu.Game.Rulesets.Osu
|
||||
new OsuModDifficultyAdjust(),
|
||||
new OsuModClassic(),
|
||||
new OsuModRandom(),
|
||||
new OsuModMirror(),
|
||||
};
|
||||
|
||||
case ModType.Automation:
|
||||
@ -188,6 +189,7 @@ namespace osu.Game.Rulesets.Osu
|
||||
new OsuModTraceable(),
|
||||
new OsuModBarrelRoll(),
|
||||
new OsuModApproachDifferent(),
|
||||
new OsuModMuted(),
|
||||
};
|
||||
|
||||
case ModType.System:
|
||||
|
@ -3,9 +3,9 @@
|
||||
|
||||
using System;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Rulesets.Osu.Skinning.Default;
|
||||
using osu.Game.Utils;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Skinning.Legacy
|
||||
@ -22,7 +22,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
|
||||
// Roughly matches osu!stable's slider border portions.
|
||||
=> base.CalculatedBorderPortion * 0.77f;
|
||||
|
||||
public new Color4 AccentColour => new Color4(base.AccentColour.R, base.AccentColour.G, base.AccentColour.B, base.AccentColour.A * 0.70f);
|
||||
public new Color4 AccentColour => new Color4(base.AccentColour.R, base.AccentColour.G, base.AccentColour.B, 0.7f);
|
||||
|
||||
protected override Color4 ColourAt(float position)
|
||||
{
|
||||
@ -40,7 +40,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
|
||||
Color4 outerColour = AccentColour.Darken(0.1f);
|
||||
Color4 innerColour = lighten(AccentColour, 0.5f);
|
||||
|
||||
return Interpolation.ValueAt(position / realGradientPortion, outerColour, innerColour, 0, 1);
|
||||
return LegacyUtils.InterpolateNonLinear(position / realGradientPortion, outerColour, innerColour, 0, 1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -104,7 +104,7 @@ namespace osu.Game.Rulesets.Osu.UI
|
||||
|
||||
private void onJudgementLoaded(DrawableOsuJudgement judgement)
|
||||
{
|
||||
judgementAboveHitObjectLayer.Add(judgement.GetProxyAboveHitObjectsContent());
|
||||
judgementAboveHitObjectLayer.Add(judgement.ProxiedAboveHitObjectsContent);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
@ -150,6 +150,10 @@ namespace osu.Game.Rulesets.Osu.UI
|
||||
DrawableOsuJudgement explosion = poolDictionary[result.Type].Get(doj => doj.Apply(result, judgedObject));
|
||||
|
||||
judgementLayer.Add(explosion);
|
||||
|
||||
// the proxied content is added to judgementAboveHitObjectLayer once, on first load, and never removed from it.
|
||||
// ensure that ordering is consistent with expectations (latest judgement should be front-most).
|
||||
judgementAboveHitObjectLayer.ChangeChildDepth(explosion.ProxiedAboveHitObjectsContent, (float)-result.TimeAbsolute);
|
||||
}
|
||||
|
||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => HitObjectContainer.ReceivePositionalInputAt(screenSpacePos);
|
||||
|
@ -2,7 +2,11 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Game.Rulesets.Osu.UI;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Utils
|
||||
@ -100,5 +104,47 @@ namespace osu.Game.Rulesets.Osu.Utils
|
||||
initial.Length * MathF.Sin(finalAngleRad)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reflects the position of the <see cref="OsuHitObject"/> in the playfield horizontally.
|
||||
/// </summary>
|
||||
/// <param name="osuObject">The object to reflect.</param>
|
||||
public static void ReflectHorizontally(OsuHitObject osuObject)
|
||||
{
|
||||
osuObject.Position = new Vector2(OsuPlayfield.BASE_SIZE.X - osuObject.X, osuObject.Position.Y);
|
||||
|
||||
if (!(osuObject is Slider slider))
|
||||
return;
|
||||
|
||||
slider.NestedHitObjects.OfType<SliderTick>().ForEach(h => h.Position = new Vector2(OsuPlayfield.BASE_SIZE.X - h.Position.X, h.Position.Y));
|
||||
slider.NestedHitObjects.OfType<SliderRepeat>().ForEach(h => h.Position = new Vector2(OsuPlayfield.BASE_SIZE.X - h.Position.X, h.Position.Y));
|
||||
|
||||
var controlPoints = slider.Path.ControlPoints.Select(p => new PathControlPoint(p.Position.Value, p.Type.Value)).ToArray();
|
||||
foreach (var point in controlPoints)
|
||||
point.Position.Value = new Vector2(-point.Position.Value.X, point.Position.Value.Y);
|
||||
|
||||
slider.Path = new SliderPath(controlPoints, slider.Path.ExpectedDistance.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reflects the position of the <see cref="OsuHitObject"/> in the playfield vertically.
|
||||
/// </summary>
|
||||
/// <param name="osuObject">The object to reflect.</param>
|
||||
public static void ReflectVertically(OsuHitObject osuObject)
|
||||
{
|
||||
osuObject.Position = new Vector2(osuObject.Position.X, OsuPlayfield.BASE_SIZE.Y - osuObject.Y);
|
||||
|
||||
if (!(osuObject is Slider slider))
|
||||
return;
|
||||
|
||||
slider.NestedHitObjects.OfType<SliderTick>().ForEach(h => h.Position = new Vector2(h.Position.X, OsuPlayfield.BASE_SIZE.Y - h.Position.Y));
|
||||
slider.NestedHitObjects.OfType<SliderRepeat>().ForEach(h => h.Position = new Vector2(h.Position.X, OsuPlayfield.BASE_SIZE.Y - h.Position.Y));
|
||||
|
||||
var controlPoints = slider.Path.ControlPoints.Select(p => new PathControlPoint(p.Position.Value, p.Type.Value)).ToArray();
|
||||
foreach (var point in controlPoints)
|
||||
point.Position.Value = new Vector2(point.Position.Value.X, -point.Position.Value.Y);
|
||||
|
||||
slider.Path = new SliderPath(controlPoints, slider.Path.ExpectedDistance.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,10 +2,30 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Taiko.Objects;
|
||||
using osu.Game.Rulesets.Taiko.UI;
|
||||
using osu.Game.Rulesets.UI;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Mods
|
||||
{
|
||||
public class TaikoModClassic : ModClassic
|
||||
public class TaikoModClassic : ModClassic, IApplicableToDrawableRuleset<TaikoHitObject>, IUpdatableByPlayfield
|
||||
{
|
||||
private DrawableTaikoRuleset drawableTaikoRuleset;
|
||||
|
||||
public void ApplyToDrawableRuleset(DrawableRuleset<TaikoHitObject> drawableRuleset)
|
||||
{
|
||||
drawableTaikoRuleset = (DrawableTaikoRuleset)drawableRuleset;
|
||||
}
|
||||
|
||||
public void Update(Playfield playfield)
|
||||
{
|
||||
// Classic taiko scrolls at a constant 100px per 1000ms. More notes become visible as the playfield is lengthened.
|
||||
const float scroll_rate = 10;
|
||||
|
||||
// Since the time range will depend on a positional value, it is referenced to the x480 pixel space.
|
||||
float ratio = drawableTaikoRuleset.DrawHeight / 480;
|
||||
|
||||
drawableTaikoRuleset.TimeRange.Value = (playfield.HitObjectContainer.DrawWidth / ratio) * scroll_rate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,23 +12,11 @@ using osu.Game.Rulesets.Taiko.Objects.Drawables;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Mods
|
||||
{
|
||||
public class TaikoModHidden : ModHidden, IApplicableToDifficulty
|
||||
public class TaikoModHidden : ModHidden
|
||||
{
|
||||
public override string Description => @"Beats fade out before you hit them!";
|
||||
public override double ScoreMultiplier => 1.06;
|
||||
|
||||
/// <summary>
|
||||
/// In osu-stable, the hit position is 160, so the active playfield is essentially 160 pixels shorter
|
||||
/// than the actual screen width. The normalized playfield height is 480, so on a 4:3 screen the
|
||||
/// playfield ratio of the active area up to the hit position will actually be (640 - 160) / 480 = 1.
|
||||
/// For custom resolutions/aspect ratios (x:y), the screen width given the normalized height becomes 480 * x / y instead,
|
||||
/// and the playfield ratio becomes (480 * x / y - 160) / 480 = x / y - 1/3.
|
||||
/// This constant is equal to the playfield ratio on 4:3 screens divided by the playfield ratio on 16:9 screens.
|
||||
/// </summary>
|
||||
private const double hd_sv_scale = (4.0 / 3.0 - 1.0 / 3.0) / (16.0 / 9.0 - 1.0 / 3.0);
|
||||
|
||||
private double originalSliderMultiplier;
|
||||
|
||||
private ControlPointInfo controlPointInfo;
|
||||
|
||||
protected override void ApplyIncreasedVisibilityState(DrawableHitObject hitObject, ArmedState state)
|
||||
@ -41,7 +29,7 @@ namespace osu.Game.Rulesets.Taiko.Mods
|
||||
double beatLength = controlPointInfo.TimingPointAt(position).BeatLength;
|
||||
double speedMultiplier = controlPointInfo.DifficultyPointAt(position).SpeedMultiplier;
|
||||
|
||||
return originalSliderMultiplier * speedMultiplier * TimingControlPoint.DEFAULT_BEAT_LENGTH / beatLength;
|
||||
return speedMultiplier * TimingControlPoint.DEFAULT_BEAT_LENGTH / beatLength;
|
||||
}
|
||||
|
||||
protected override void ApplyNormalVisibilityState(DrawableHitObject hitObject, ArmedState state)
|
||||
@ -69,22 +57,6 @@ namespace osu.Game.Rulesets.Taiko.Mods
|
||||
}
|
||||
}
|
||||
|
||||
public void ReadFromDifficulty(BeatmapDifficulty difficulty)
|
||||
{
|
||||
}
|
||||
|
||||
public void ApplyToDifficulty(BeatmapDifficulty difficulty)
|
||||
{
|
||||
// needs to be read after all processing has been run (TaikoBeatmapConverter applies an adjustment which would otherwise be omitted).
|
||||
originalSliderMultiplier = difficulty.SliderMultiplier;
|
||||
|
||||
// osu-stable has an added playfield cover that essentially forces a 4:3 playfield ratio, by cutting off all objects past that size.
|
||||
// This is not yet implemented; instead a playfield adjustment container is present which maintains a 16:9 ratio.
|
||||
// For now, increase the slider multiplier proportionally so that the notes stay on the screen for the same amount of time as on stable.
|
||||
// Note that this means that the notes will scroll faster as they have a longer distance to travel on the screen in that same amount of time.
|
||||
difficulty.SliderMultiplier /= hd_sv_scale;
|
||||
}
|
||||
|
||||
public override void ApplyToBeatmap(IBeatmap beatmap)
|
||||
{
|
||||
controlPointInfo = beatmap.ControlPointInfo;
|
||||
|
12
osu.Game.Rulesets.Taiko/Mods/TaikoModMuted.cs
Normal file
12
osu.Game.Rulesets.Taiko/Mods/TaikoModMuted.cs
Normal file
@ -0,0 +1,12 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Taiko.Objects;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Mods
|
||||
{
|
||||
public class TaikoModMuted : ModMuted<TaikoHitObject>
|
||||
{
|
||||
}
|
||||
}
|
@ -149,7 +149,8 @@ namespace osu.Game.Rulesets.Taiko
|
||||
case ModType.Fun:
|
||||
return new Mod[]
|
||||
{
|
||||
new MultiMod(new ModWindUp(), new ModWindDown())
|
||||
new MultiMod(new ModWindUp(), new ModWindDown()),
|
||||
new TaikoModMuted(),
|
||||
};
|
||||
|
||||
default:
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
@ -24,12 +25,14 @@ namespace osu.Game.Rulesets.Taiko.UI
|
||||
{
|
||||
public class DrawableTaikoRuleset : DrawableScrollingRuleset<TaikoHitObject>
|
||||
{
|
||||
private SkinnableDrawable scroller;
|
||||
public new BindableDouble TimeRange => base.TimeRange;
|
||||
|
||||
protected override ScrollVisualisationMethod VisualisationMethod => ScrollVisualisationMethod.Overlapping;
|
||||
|
||||
protected override bool UserScrollSpeedAdjustment => false;
|
||||
|
||||
private SkinnableDrawable scroller;
|
||||
|
||||
public DrawableTaikoRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods = null)
|
||||
: base(ruleset, beatmap, mods)
|
||||
{
|
||||
|
@ -32,7 +32,7 @@ namespace osu.Game.Rulesets.Taiko.UI
|
||||
/// <summary>
|
||||
/// Default height of a <see cref="TaikoPlayfield"/> when inside a <see cref="DrawableTaikoRuleset"/>.
|
||||
/// </summary>
|
||||
public const float DEFAULT_HEIGHT = 178;
|
||||
public const float DEFAULT_HEIGHT = 212;
|
||||
|
||||
private Container<HitExplosion> hitExplosionContainer;
|
||||
private Container<KiaiHitExplosion> kiaiExplosionContainer;
|
||||
|
@ -323,12 +323,12 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
||||
new OsuBeatmapProcessor(converted).PreProcess();
|
||||
new OsuBeatmapProcessor(converted).PostProcess();
|
||||
|
||||
Assert.AreEqual(4, ((IHasComboInformation)converted.HitObjects.ElementAt(0)).ComboIndex);
|
||||
Assert.AreEqual(5, ((IHasComboInformation)converted.HitObjects.ElementAt(2)).ComboIndex);
|
||||
Assert.AreEqual(5, ((IHasComboInformation)converted.HitObjects.ElementAt(4)).ComboIndex);
|
||||
Assert.AreEqual(6, ((IHasComboInformation)converted.HitObjects.ElementAt(6)).ComboIndex);
|
||||
Assert.AreEqual(11, ((IHasComboInformation)converted.HitObjects.ElementAt(8)).ComboIndex);
|
||||
Assert.AreEqual(14, ((IHasComboInformation)converted.HitObjects.ElementAt(11)).ComboIndex);
|
||||
Assert.AreEqual(4, ((IHasComboInformation)converted.HitObjects.ElementAt(0)).ComboIndexWithOffsets);
|
||||
Assert.AreEqual(5, ((IHasComboInformation)converted.HitObjects.ElementAt(2)).ComboIndexWithOffsets);
|
||||
Assert.AreEqual(5, ((IHasComboInformation)converted.HitObjects.ElementAt(4)).ComboIndexWithOffsets);
|
||||
Assert.AreEqual(6, ((IHasComboInformation)converted.HitObjects.ElementAt(6)).ComboIndexWithOffsets);
|
||||
Assert.AreEqual(11, ((IHasComboInformation)converted.HitObjects.ElementAt(8)).ComboIndexWithOffsets);
|
||||
Assert.AreEqual(14, ((IHasComboInformation)converted.HitObjects.ElementAt(11)).ComboIndexWithOffsets);
|
||||
}
|
||||
}
|
||||
|
||||
@ -346,12 +346,12 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
||||
new CatchBeatmapProcessor(converted).PreProcess();
|
||||
new CatchBeatmapProcessor(converted).PostProcess();
|
||||
|
||||
Assert.AreEqual(4, ((IHasComboInformation)converted.HitObjects.ElementAt(0)).ComboIndex);
|
||||
Assert.AreEqual(5, ((IHasComboInformation)converted.HitObjects.ElementAt(2)).ComboIndex);
|
||||
Assert.AreEqual(5, ((IHasComboInformation)converted.HitObjects.ElementAt(4)).ComboIndex);
|
||||
Assert.AreEqual(6, ((IHasComboInformation)converted.HitObjects.ElementAt(6)).ComboIndex);
|
||||
Assert.AreEqual(11, ((IHasComboInformation)converted.HitObjects.ElementAt(8)).ComboIndex);
|
||||
Assert.AreEqual(14, ((IHasComboInformation)converted.HitObjects.ElementAt(11)).ComboIndex);
|
||||
Assert.AreEqual(4, ((IHasComboInformation)converted.HitObjects.ElementAt(0)).ComboIndexWithOffsets);
|
||||
Assert.AreEqual(5, ((IHasComboInformation)converted.HitObjects.ElementAt(2)).ComboIndexWithOffsets);
|
||||
Assert.AreEqual(5, ((IHasComboInformation)converted.HitObjects.ElementAt(4)).ComboIndexWithOffsets);
|
||||
Assert.AreEqual(6, ((IHasComboInformation)converted.HitObjects.ElementAt(6)).ComboIndexWithOffsets);
|
||||
Assert.AreEqual(11, ((IHasComboInformation)converted.HitObjects.ElementAt(8)).ComboIndexWithOffsets);
|
||||
Assert.AreEqual(14, ((IHasComboInformation)converted.HitObjects.ElementAt(11)).ComboIndexWithOffsets);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,11 +2,13 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Tests.Visual;
|
||||
|
||||
namespace osu.Game.Tests.Gameplay
|
||||
@ -121,6 +123,18 @@ namespace osu.Game.Tests.Gameplay
|
||||
AddAssert("Drawable lifetime is restored", () => dho.LifetimeStart == 666 && dho.LifetimeEnd == 999);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestStateChangeBeforeLoadComplete()
|
||||
{
|
||||
TestDrawableHitObject dho = null;
|
||||
AddStep("Add DHO and apply result", () =>
|
||||
{
|
||||
Child = dho = new TestDrawableHitObject(new HitObject { StartTime = Time.Current });
|
||||
dho.MissForcefully();
|
||||
});
|
||||
AddAssert("DHO state is correct", () => dho.State.Value == ArmedState.Miss);
|
||||
}
|
||||
|
||||
private class TestDrawableHitObject : DrawableHitObject
|
||||
{
|
||||
public const double INITIAL_LIFETIME_OFFSET = 100;
|
||||
@ -141,6 +155,19 @@ namespace osu.Game.Tests.Gameplay
|
||||
if (SetLifetimeStartOnApply)
|
||||
LifetimeStart = LIFETIME_ON_APPLY;
|
||||
}
|
||||
|
||||
public void MissForcefully() => ApplyResult(r => r.Type = HitResult.Miss);
|
||||
|
||||
protected override void UpdateHitStateTransforms(ArmedState state)
|
||||
{
|
||||
if (state != ArmedState.Miss)
|
||||
{
|
||||
base.UpdateHitStateTransforms(state);
|
||||
return;
|
||||
}
|
||||
|
||||
this.FadeOut(1000);
|
||||
}
|
||||
}
|
||||
|
||||
private class TestLifetimeEntry : HitObjectLifetimeEntry
|
||||
|
@ -100,6 +100,14 @@ namespace osu.Game.Tests.Gameplay
|
||||
set => ComboIndexBindable.Value = value;
|
||||
}
|
||||
|
||||
public Bindable<int> ComboIndexWithOffsetsBindable { get; } = new Bindable<int>();
|
||||
|
||||
public int ComboIndexWithOffsets
|
||||
{
|
||||
get => ComboIndexWithOffsetsBindable.Value;
|
||||
set => ComboIndexWithOffsetsBindable.Value = value;
|
||||
}
|
||||
|
||||
public Bindable<bool> LastInComboBindable { get; } = new Bindable<bool>();
|
||||
|
||||
public bool LastInCombo
|
||||
|
@ -1,7 +1,6 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Globalization;
|
||||
using NUnit.Framework;
|
||||
using osu.Game.Utils;
|
||||
|
||||
@ -20,7 +19,7 @@ namespace osu.Game.Tests.NonVisual
|
||||
[TestCase(1, "100.00%")]
|
||||
public void TestAccuracyFormatting(double input, string expectedOutput)
|
||||
{
|
||||
Assert.AreEqual(expectedOutput, input.FormatAccuracy(CultureInfo.InvariantCulture));
|
||||
Assert.AreEqual(expectedOutput, input.FormatAccuracy().ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,8 @@ namespace osu.Game.Tests.NonVisual.Multiplayer
|
||||
AddRepeatStep("add some users", () => Client.AddUser(new User { Id = id++ }), 5);
|
||||
checkPlayingUserCount(0);
|
||||
|
||||
AddAssert("playlist item is available", () => Client.CurrentMatchPlayingItem.Value != null);
|
||||
|
||||
changeState(3, MultiplayerUserState.WaitingForLoad);
|
||||
checkPlayingUserCount(3);
|
||||
|
||||
@ -41,6 +43,8 @@ namespace osu.Game.Tests.NonVisual.Multiplayer
|
||||
|
||||
AddStep("leave room", () => Client.LeaveRoom());
|
||||
checkPlayingUserCount(0);
|
||||
|
||||
AddAssert("playlist item is null", () => Client.CurrentMatchPlayingItem.Value == null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
41
osu.Game.Tests/NonVisual/TimeDisplayExtensionTest.cs
Normal file
41
osu.Game.Tests/NonVisual/TimeDisplayExtensionTest.cs
Normal file
@ -0,0 +1,41 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
using osu.Game.Extensions;
|
||||
|
||||
namespace osu.Game.Tests.NonVisual
|
||||
{
|
||||
[TestFixture]
|
||||
public class TimeDisplayExtensionTest
|
||||
{
|
||||
private static readonly object[][] editor_formatted_duration_tests =
|
||||
{
|
||||
new object[] { new TimeSpan(0, 0, 0, 0, 50), "00:00:050" },
|
||||
new object[] { new TimeSpan(0, 0, 0, 10, 50), "00:10:050" },
|
||||
new object[] { new TimeSpan(0, 0, 5, 10), "05:10:000" },
|
||||
new object[] { new TimeSpan(0, 1, 5, 10), "65:10:000" },
|
||||
};
|
||||
|
||||
[TestCaseSource(nameof(editor_formatted_duration_tests))]
|
||||
public void TestEditorFormat(TimeSpan input, string expectedOutput)
|
||||
{
|
||||
Assert.AreEqual(expectedOutput, input.ToEditorFormattedString());
|
||||
}
|
||||
|
||||
private static readonly object[][] formatted_duration_tests =
|
||||
{
|
||||
new object[] { new TimeSpan(0, 0, 10), "00:10" },
|
||||
new object[] { new TimeSpan(0, 5, 10), "05:10" },
|
||||
new object[] { new TimeSpan(1, 5, 10), "01:05:10" },
|
||||
new object[] { new TimeSpan(1, 1, 5, 10), "01:01:05:10" },
|
||||
};
|
||||
|
||||
[TestCaseSource(nameof(formatted_duration_tests))]
|
||||
public void TestFormattedDuration(TimeSpan input, string expectedOutput)
|
||||
{
|
||||
Assert.AreEqual(expectedOutput, input.ToFormattedDuration().ToString());
|
||||
}
|
||||
}
|
||||
}
|
@ -168,8 +168,8 @@ namespace osu.Game.Tests.Online
|
||||
|
||||
public override async Task<BeatmapSetInfo> Import(BeatmapSetInfo item, ArchiveReader archive = null, bool lowPriority = false, CancellationToken cancellationToken = default)
|
||||
{
|
||||
await AllowImport.Task;
|
||||
return await (CurrentImportTask = base.Import(item, archive, lowPriority, cancellationToken));
|
||||
await AllowImport.Task.ConfigureAwait(false);
|
||||
return await (CurrentImportTask = base.Import(item, archive, lowPriority, cancellationToken)).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,90 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. 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.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Colours
|
||||
{
|
||||
public class TestSceneStarDifficultyColours : OsuTestScene
|
||||
{
|
||||
[Resolved]
|
||||
private OsuColour colours { get; set; }
|
||||
|
||||
[Test]
|
||||
public void TestColours()
|
||||
{
|
||||
AddStep("load colour displays", () =>
|
||||
{
|
||||
Child = new FillFlowContainer
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Spacing = new Vector2(5f),
|
||||
ChildrenEnumerable = Enumerable.Range(0, 10).Select(i => new FillFlowContainer
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(10f),
|
||||
ChildrenEnumerable = Enumerable.Range(0, 10).Select(j =>
|
||||
{
|
||||
var colour = colours.ForStarDifficulty(1f * i + 0.1f * j);
|
||||
|
||||
return new FillFlowContainer
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(0f, 10f),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new CircularContainer
|
||||
{
|
||||
Masking = true,
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
Size = new Vector2(75f, 25f),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = colour,
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Colour = OsuColour.ForegroundTextColourFor(colour),
|
||||
Text = colour.ToHex(),
|
||||
},
|
||||
}
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
Text = $"*{(1f * i + 0.1f * j):0.00}",
|
||||
}
|
||||
}
|
||||
};
|
||||
})
|
||||
})
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -75,7 +75,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
AddAssert("Hitcircle button not clickable", () => !hitObjectComposer.ChildrenOfType<EditorRadioButton>().First(d => d.Button.Label == "HitCircle").Enabled.Value);
|
||||
AddStep("Add timing point", () => editorBeatmap.ControlPointInfo.Add(0, new TimingControlPoint()));
|
||||
AddAssert("Hitcircle button is clickable", () => hitObjectComposer.ChildrenOfType<EditorRadioButton>().First(d => d.Button.Label == "HitCircle").Enabled.Value);
|
||||
AddStep("Change to hitcircle", () => hitObjectComposer.ChildrenOfType<EditorRadioButton>().First(d => d.Button.Label == "HitCircle").Click());
|
||||
AddStep("Change to hitcircle", () => hitObjectComposer.ChildrenOfType<EditorRadioButton>().First(d => d.Button.Label == "HitCircle").TriggerClick());
|
||||
AddAssert("Tool changed", () => hitObjectComposer.ChildrenOfType<ComposeBlueprintContainer>().First().CurrentTool is HitCircleCompositionTool);
|
||||
}
|
||||
|
||||
|
@ -228,7 +228,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
var lastAction = pauseOverlay.OnRetry;
|
||||
pauseOverlay.OnRetry = () => triggered = true;
|
||||
|
||||
getButton(1).Click();
|
||||
getButton(1).TriggerClick();
|
||||
pauseOverlay.OnRetry = lastAction;
|
||||
});
|
||||
|
||||
|
@ -13,6 +13,7 @@ using osu.Game.Online.Spectator;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Osu.Replays;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Screens;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Tests.Beatmaps.IO;
|
||||
using osu.Game.Tests.Visual.Multiplayer;
|
||||
@ -25,41 +26,43 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
private readonly User streamingUser = new User { Id = MultiplayerTestScene.PLAYER_1_ID, Username = "Test user" };
|
||||
|
||||
[Cached(typeof(SpectatorClient))]
|
||||
private TestSpectatorClient testSpectatorClient = new TestSpectatorClient();
|
||||
|
||||
[Cached(typeof(UserLookupCache))]
|
||||
private UserLookupCache lookupCache = new TestUserLookupCache();
|
||||
|
||||
// used just to show beatmap card for the time being.
|
||||
protected override bool UseOnlineAPI => true;
|
||||
|
||||
private SoloSpectator spectatorScreen;
|
||||
|
||||
[Resolved]
|
||||
private OsuGameBase game { get; set; }
|
||||
|
||||
private BeatmapSetInfo importedBeatmap;
|
||||
private TestSpectatorClient spectatorClient;
|
||||
private SoloSpectator spectatorScreen;
|
||||
|
||||
private BeatmapSetInfo importedBeatmap;
|
||||
private int importedBeatmapId;
|
||||
|
||||
public override void SetUpSteps()
|
||||
[SetUpSteps]
|
||||
public void SetupSteps()
|
||||
{
|
||||
base.SetUpSteps();
|
||||
DependenciesScreen dependenciesScreen = null;
|
||||
|
||||
AddStep("load dependencies", () =>
|
||||
{
|
||||
spectatorClient = new TestSpectatorClient();
|
||||
|
||||
// The screen gets suspended so it stops receiving updates.
|
||||
Child = spectatorClient;
|
||||
|
||||
LoadScreen(dependenciesScreen = new DependenciesScreen(spectatorClient));
|
||||
});
|
||||
|
||||
AddUntilStep("wait for dependencies to load", () => dependenciesScreen.IsLoaded);
|
||||
|
||||
AddStep("import beatmap", () =>
|
||||
{
|
||||
importedBeatmap = ImportBeatmapTest.LoadOszIntoOsu(game, virtualTrack: true).Result;
|
||||
importedBeatmapId = importedBeatmap.Beatmaps.First(b => b.RulesetID == 0).OnlineBeatmapID ?? -1;
|
||||
});
|
||||
|
||||
AddStep("add streaming client", () =>
|
||||
{
|
||||
Remove(testSpectatorClient);
|
||||
Add(testSpectatorClient);
|
||||
});
|
||||
|
||||
finish();
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -206,22 +209,36 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
private void waitForPlayer() => AddUntilStep("wait for player", () => (Stack.CurrentScreen as Player)?.IsLoaded == true);
|
||||
|
||||
private void start(int? beatmapId = null) => AddStep("start play", () => testSpectatorClient.StartPlay(streamingUser.Id, beatmapId ?? importedBeatmapId));
|
||||
private void start(int? beatmapId = null) => AddStep("start play", () => spectatorClient.StartPlay(streamingUser.Id, beatmapId ?? importedBeatmapId));
|
||||
|
||||
private void finish() => AddStep("end play", () => testSpectatorClient.EndPlay(streamingUser.Id));
|
||||
private void finish() => AddStep("end play", () => spectatorClient.EndPlay(streamingUser.Id));
|
||||
|
||||
private void checkPaused(bool state) =>
|
||||
AddUntilStep($"game is {(state ? "paused" : "playing")}", () => player.ChildrenOfType<DrawableRuleset>().First().IsPaused.Value == state);
|
||||
|
||||
private void sendFrames(int count = 10)
|
||||
{
|
||||
AddStep("send frames", () => testSpectatorClient.SendFrames(streamingUser.Id, count));
|
||||
AddStep("send frames", () => spectatorClient.SendFrames(streamingUser.Id, count));
|
||||
}
|
||||
|
||||
private void loadSpectatingScreen()
|
||||
{
|
||||
AddStep("load screen", () => LoadScreen(spectatorScreen = new SoloSpectator(streamingUser)));
|
||||
AddStep("load spectator", () => LoadScreen(spectatorScreen = new SoloSpectator(streamingUser)));
|
||||
AddUntilStep("wait for screen load", () => spectatorScreen.LoadState == LoadState.Loaded);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Used for the sole purpose of adding <see cref="TestSpectatorClient"/> as a resolvable dependency.
|
||||
/// </summary>
|
||||
private class DependenciesScreen : OsuScreen
|
||||
{
|
||||
[Cached(typeof(SpectatorClient))]
|
||||
public readonly TestSpectatorClient Client;
|
||||
|
||||
public DependenciesScreen(TestSpectatorClient client)
|
||||
{
|
||||
Client = client;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Drawables;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.BeatmapListing.Panels;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Osu.Mods;
|
||||
@ -215,7 +215,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
assertDownloadButtonVisible(false);
|
||||
|
||||
void assertDownloadButtonVisible(bool visible) => AddUntilStep($"download button {(visible ? "shown" : "hidden")}",
|
||||
() => playlist.ChildrenOfType<BeatmapDownloadTrackingComposite>().Single().Alpha == (visible ? 1 : 0));
|
||||
() => playlist.ChildrenOfType<BeatmapPanelDownloadButton>().Single().Alpha == (visible ? 1 : 0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -229,7 +229,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
|
||||
createPlaylist(byOnlineId, byChecksum);
|
||||
|
||||
AddAssert("download buttons shown", () => playlist.ChildrenOfType<BeatmapDownloadTrackingComposite>().All(d => d.IsPresent));
|
||||
AddAssert("download buttons shown", () => playlist.ChildrenOfType<BeatmapPanelDownloadButton>().All(d => d.IsPresent));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -4,6 +4,8 @@
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osu.Game.Rulesets.Catch;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
@ -40,7 +42,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
AddAssert("has 2 rooms", () => container.Rooms.Count == 2);
|
||||
AddAssert("first room removed", () => container.Rooms.All(r => r.Room.RoomID.Value != 0));
|
||||
|
||||
AddStep("select first room", () => container.Rooms.First().Click());
|
||||
AddStep("select first room", () => container.Rooms.First().TriggerClick());
|
||||
AddAssert("first room selected", () => checkRoomSelected(RoomManager.Rooms.First()));
|
||||
}
|
||||
|
||||
@ -62,6 +64,31 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
AddAssert("last room selected", () => checkRoomSelected(RoomManager.Rooms.Last()));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestKeyboardNavigationAfterOrderChange()
|
||||
{
|
||||
AddStep("add rooms", () => RoomManager.AddRooms(3));
|
||||
|
||||
AddStep("reorder rooms", () =>
|
||||
{
|
||||
var room = RoomManager.Rooms[1];
|
||||
|
||||
RoomManager.RemoveRoom(room);
|
||||
RoomManager.AddRoom(room);
|
||||
});
|
||||
|
||||
AddAssert("no selection", () => checkRoomSelected(null));
|
||||
|
||||
press(Key.Down);
|
||||
AddAssert("first room selected", () => checkRoomSelected(getRoomInFlow(0)));
|
||||
|
||||
press(Key.Down);
|
||||
AddAssert("second room selected", () => checkRoomSelected(getRoomInFlow(1)));
|
||||
|
||||
press(Key.Down);
|
||||
AddAssert("third room selected", () => checkRoomSelected(getRoomInFlow(2)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestClickDeselection()
|
||||
{
|
||||
@ -121,5 +148,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
}
|
||||
|
||||
private bool checkRoomSelected(Room room) => SelectedRoom.Value == room;
|
||||
|
||||
private Room getRoomInFlow(int index) =>
|
||||
(container.ChildrenOfType<FillFlowContainer<DrawableRoom>>().First().FlowingChildren.ElementAt(index) as DrawableRoom)?.Room;
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Screens.OnlinePlay.Multiplayer.Spectate;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Tests.Beatmaps.IO;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Multiplayer
|
||||
{
|
||||
@ -47,8 +48,9 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
{
|
||||
AddStep("start players silently", () =>
|
||||
{
|
||||
Client.CurrentMatchPlayingUserIds.Add(PLAYER_1_ID);
|
||||
Client.CurrentMatchPlayingUserIds.Add(PLAYER_2_ID);
|
||||
OnlinePlayDependencies.Client.AddUser(new User { Id = PLAYER_1_ID }, true);
|
||||
OnlinePlayDependencies.Client.AddUser(new User { Id = PLAYER_2_ID }, true);
|
||||
|
||||
playingUserIds.Add(PLAYER_1_ID);
|
||||
playingUserIds.Add(PLAYER_2_ID);
|
||||
});
|
||||
@ -264,7 +266,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
{
|
||||
foreach (int id in userIds)
|
||||
{
|
||||
Client.CurrentMatchPlayingUserIds.Add(id);
|
||||
OnlinePlayDependencies.Client.AddUser(new User { Id = id }, true);
|
||||
|
||||
SpectatorClient.StartPlay(id, beatmapId ?? importedBeatmapId);
|
||||
playingUserIds.Add(id);
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Framework.Testing;
|
||||
@ -79,6 +80,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
|
||||
AddStep("load multiplayer", () => LoadScreen(multiplayerScreen));
|
||||
AddUntilStep("wait for multiplayer to load", () => multiplayerScreen.IsLoaded);
|
||||
AddUntilStep("wait for lounge to load", () => this.ChildrenOfType<MultiplayerLoungeSubScreen>().FirstOrDefault()?.IsLoaded == true);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -87,6 +89,28 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
// used to test the flow of multiplayer from visual tests.
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCreateRoomViaKeyboard()
|
||||
{
|
||||
// create room dialog
|
||||
AddStep("Press new document", () => InputManager.Keys(PlatformAction.DocumentNew));
|
||||
AddUntilStep("wait for settings", () => InputManager.ChildrenOfType<MultiplayerMatchSettingsOverlay>().FirstOrDefault() != null);
|
||||
|
||||
// edit playlist item
|
||||
AddStep("Press select", () => InputManager.Key(Key.Enter));
|
||||
AddUntilStep("wait for song select", () => InputManager.ChildrenOfType<MultiplayerMatchSongSelect>().FirstOrDefault() != null);
|
||||
|
||||
// select beatmap
|
||||
AddStep("Press select", () => InputManager.Key(Key.Enter));
|
||||
AddUntilStep("wait for return to screen", () => InputManager.ChildrenOfType<MultiplayerMatchSongSelect>().FirstOrDefault() == null);
|
||||
|
||||
// create room
|
||||
AddStep("Press select", () => InputManager.Key(Key.Enter));
|
||||
|
||||
AddUntilStep("wait for room open", () => this.ChildrenOfType<MultiplayerMatchSubScreen>().FirstOrDefault()?.IsLoaded == true);
|
||||
AddUntilStep("wait for join", () => client.Room != null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCreateRoomWithoutPassword()
|
||||
{
|
||||
@ -139,7 +163,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
{
|
||||
AddStep("create room", () =>
|
||||
{
|
||||
API.Queue(new CreateRoomRequest(new Room
|
||||
multiplayerScreen.RoomManager.AddRoom(new Room
|
||||
{
|
||||
Name = { Value = "Test Room" },
|
||||
Playlist =
|
||||
@ -150,7 +174,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
Ruleset = { Value = new OsuRuleset().RulesetInfo },
|
||||
}
|
||||
}
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
AddStep("refresh rooms", () => multiplayerScreen.RoomManager.Filter.Value = new FilterCriteria());
|
||||
@ -186,7 +210,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
{
|
||||
AddStep("create room", () =>
|
||||
{
|
||||
API.Queue(new CreateRoomRequest(new Room
|
||||
multiplayerScreen.RoomManager.AddRoom(new Room
|
||||
{
|
||||
Name = { Value = "Test Room" },
|
||||
Password = { Value = "password" },
|
||||
@ -198,7 +222,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
Ruleset = { Value = new OsuRuleset().RulesetInfo },
|
||||
}
|
||||
}
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
AddStep("refresh rooms", () => multiplayerScreen.RoomManager.Filter.Value = new FilterCriteria());
|
||||
@ -208,7 +232,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
DrawableRoom.PasswordEntryPopover passwordEntryPopover = null;
|
||||
AddUntilStep("password prompt appeared", () => (passwordEntryPopover = InputManager.ChildrenOfType<DrawableRoom.PasswordEntryPopover>().FirstOrDefault()) != null);
|
||||
AddStep("enter password in text box", () => passwordEntryPopover.ChildrenOfType<TextBox>().First().Text = "password");
|
||||
AddStep("press join room button", () => passwordEntryPopover.ChildrenOfType<OsuButton>().First().Click());
|
||||
AddStep("press join room button", () => passwordEntryPopover.ChildrenOfType<OsuButton>().First().TriggerClick());
|
||||
|
||||
AddUntilStep("wait for room open", () => this.ChildrenOfType<MultiplayerMatchSubScreen>().FirstOrDefault()?.IsLoaded == true);
|
||||
AddUntilStep("wait for join", () => client.Room != null);
|
||||
@ -372,7 +396,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
}
|
||||
});
|
||||
|
||||
AddStep("open mod overlay", () => this.ChildrenOfType<PurpleTriangleButton>().ElementAt(2).Click());
|
||||
AddStep("open mod overlay", () => this.ChildrenOfType<PurpleTriangleButton>().ElementAt(2).TriggerClick());
|
||||
|
||||
AddStep("invoke on back button", () => multiplayerScreen.OnBackButton());
|
||||
|
||||
@ -380,7 +404,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
|
||||
AddAssert("dialog overlay is hidden", () => DialogOverlay.State.Value == Visibility.Hidden);
|
||||
|
||||
testLeave("lounge tab item", () => this.ChildrenOfType<BreadcrumbControl<IScreen>.BreadcrumbTabItem>().First().Click());
|
||||
testLeave("lounge tab item", () => this.ChildrenOfType<BreadcrumbControl<IScreen>.BreadcrumbTabItem>().First().TriggerClick());
|
||||
|
||||
testLeave("back button", () => multiplayerScreen.OnBackButton());
|
||||
|
||||
@ -432,9 +456,9 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
|
||||
private class TestMultiplayer : Screens.OnlinePlay.Multiplayer.Multiplayer
|
||||
{
|
||||
public new TestMultiplayerRoomManager RoomManager { get; private set; }
|
||||
public new TestRequestHandlingMultiplayerRoomManager RoomManager { get; private set; }
|
||||
|
||||
protected override RoomManager CreateRoomManager() => RoomManager = new TestMultiplayerRoomManager();
|
||||
protected override RoomManager CreateRoomManager() => RoomManager = new TestRequestHandlingMultiplayerRoomManager();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ using osu.Game.Scoring;
|
||||
using osu.Game.Screens.Play.HUD;
|
||||
using osu.Game.Tests.Visual.OnlinePlay;
|
||||
using osu.Game.Tests.Visual.Spectator;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Multiplayer
|
||||
{
|
||||
@ -53,10 +54,10 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
var playable = Beatmap.Value.GetPlayableBeatmap(Ruleset.Value);
|
||||
|
||||
foreach (var user in users)
|
||||
{
|
||||
SpectatorClient.StartPlay(user, Beatmap.Value.BeatmapInfo.OnlineBeatmapID ?? 0);
|
||||
|
||||
// Todo: This is REALLY bad.
|
||||
Client.CurrentMatchPlayingUserIds.AddRange(users);
|
||||
OnlinePlayDependencies.Client.AddUser(new User { Id = user }, true);
|
||||
}
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
|
@ -74,7 +74,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
AddStep("attempt join room", () => InputManager.Key(Key.Enter));
|
||||
AddUntilStep("password prompt appeared", () => (passwordEntryPopover = InputManager.ChildrenOfType<DrawableRoom.PasswordEntryPopover>().FirstOrDefault()) != null);
|
||||
AddStep("enter password in text box", () => passwordEntryPopover.ChildrenOfType<TextBox>().First().Text = "password");
|
||||
AddStep("press join room button", () => passwordEntryPopover.ChildrenOfType<OsuButton>().First().Click());
|
||||
AddStep("press join room button", () => passwordEntryPopover.ChildrenOfType<OsuButton>().First().TriggerClick());
|
||||
|
||||
AddAssert("room join requested", () => lastJoinedRoom == RoomManager.Rooms.First());
|
||||
AddAssert("room join password correct", () => lastJoinedPassword == "password");
|
||||
|
191
osu.Game.Tests/Visual/Multiplayer/TestSceneTeamVersus.cs
Normal file
191
osu.Game.Tests/Visual/Multiplayer/TestSceneTeamVersus.cs
Normal file
@ -0,0 +1,191 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Online.Multiplayer;
|
||||
using osu.Game.Online.Multiplayer.MatchTypes.TeamVersus;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Screens;
|
||||
using osu.Game.Screens.OnlinePlay.Components;
|
||||
using osu.Game.Screens.OnlinePlay.Multiplayer;
|
||||
using osu.Game.Screens.OnlinePlay.Multiplayer.Match;
|
||||
using osu.Game.Screens.OnlinePlay.Multiplayer.Participants;
|
||||
using osu.Game.Tests.Resources;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Multiplayer
|
||||
{
|
||||
public class TestSceneTeamVersus : ScreenTestScene
|
||||
{
|
||||
private BeatmapManager beatmaps;
|
||||
private RulesetStore rulesets;
|
||||
private BeatmapSetInfo importedSet;
|
||||
|
||||
private DependenciesScreen dependenciesScreen;
|
||||
private TestMultiplayer multiplayerScreen;
|
||||
private TestMultiplayerClient client;
|
||||
|
||||
[Cached(typeof(UserLookupCache))]
|
||||
private UserLookupCache lookupCache = new TestUserLookupCache();
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(GameHost host, AudioManager audio)
|
||||
{
|
||||
Dependencies.Cache(rulesets = new RulesetStore(ContextFactory));
|
||||
Dependencies.Cache(beatmaps = new BeatmapManager(LocalStorage, ContextFactory, rulesets, null, audio, Resources, host, Beatmap.Default));
|
||||
}
|
||||
|
||||
public override void SetUpSteps()
|
||||
{
|
||||
base.SetUpSteps();
|
||||
|
||||
AddStep("import beatmap", () =>
|
||||
{
|
||||
beatmaps.Import(TestResources.GetQuickTestBeatmapForImport()).Wait();
|
||||
importedSet = beatmaps.GetAllUsableBeatmapSetsEnumerable(IncludedDetails.All).First();
|
||||
});
|
||||
|
||||
AddStep("create multiplayer screen", () => multiplayerScreen = new TestMultiplayer());
|
||||
|
||||
AddStep("load dependencies", () =>
|
||||
{
|
||||
client = new TestMultiplayerClient(multiplayerScreen.RoomManager);
|
||||
|
||||
// The screen gets suspended so it stops receiving updates.
|
||||
Child = client;
|
||||
|
||||
LoadScreen(dependenciesScreen = new DependenciesScreen(client));
|
||||
});
|
||||
|
||||
AddUntilStep("wait for dependencies to load", () => dependenciesScreen.IsLoaded);
|
||||
|
||||
AddStep("load multiplayer", () => LoadScreen(multiplayerScreen));
|
||||
AddUntilStep("wait for multiplayer to load", () => multiplayerScreen.IsLoaded);
|
||||
AddUntilStep("wait for lounge to load", () => this.ChildrenOfType<MultiplayerLoungeSubScreen>().FirstOrDefault()?.IsLoaded == true);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCreateWithType()
|
||||
{
|
||||
createRoom(() => new Room
|
||||
{
|
||||
Name = { Value = "Test Room" },
|
||||
Type = { Value = MatchType.TeamVersus },
|
||||
Playlist =
|
||||
{
|
||||
new PlaylistItem
|
||||
{
|
||||
Beatmap = { Value = beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First(b => b.RulesetID == 0)).BeatmapInfo },
|
||||
Ruleset = { Value = new OsuRuleset().RulesetInfo },
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
AddAssert("room type is team vs", () => client.Room?.Settings.MatchType == MatchType.TeamVersus);
|
||||
AddAssert("user state arrived", () => client.Room?.Users.FirstOrDefault()?.MatchState is TeamVersusUserState);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestChangeTeamsViaButton()
|
||||
{
|
||||
createRoom(() => new Room
|
||||
{
|
||||
Name = { Value = "Test Room" },
|
||||
Type = { Value = MatchType.TeamVersus },
|
||||
Playlist =
|
||||
{
|
||||
new PlaylistItem
|
||||
{
|
||||
Beatmap = { Value = beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First(b => b.RulesetID == 0)).BeatmapInfo },
|
||||
Ruleset = { Value = new OsuRuleset().RulesetInfo },
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
AddAssert("user on team 0", () => (client.Room?.Users.FirstOrDefault()?.MatchState as TeamVersusUserState)?.TeamID == 0);
|
||||
|
||||
AddStep("press button", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(multiplayerScreen.ChildrenOfType<TeamDisplay>().First());
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
AddAssert("user on team 1", () => (client.Room?.Users.FirstOrDefault()?.MatchState as TeamVersusUserState)?.TeamID == 1);
|
||||
|
||||
AddStep("press button", () => InputManager.Click(MouseButton.Left));
|
||||
AddAssert("user on team 0", () => (client.Room?.Users.FirstOrDefault()?.MatchState as TeamVersusUserState)?.TeamID == 0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestChangeTypeViaMatchSettings()
|
||||
{
|
||||
createRoom(() => new Room
|
||||
{
|
||||
Name = { Value = "Test Room" },
|
||||
Playlist =
|
||||
{
|
||||
new PlaylistItem
|
||||
{
|
||||
Beatmap = { Value = beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First(b => b.RulesetID == 0)).BeatmapInfo },
|
||||
Ruleset = { Value = new OsuRuleset().RulesetInfo },
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
AddAssert("room type is head to head", () => client.Room?.Settings.MatchType == MatchType.HeadToHead);
|
||||
|
||||
AddStep("change to team vs", () => client.ChangeSettings(matchType: MatchType.TeamVersus));
|
||||
|
||||
AddAssert("room type is team vs", () => client.Room?.Settings.MatchType == MatchType.TeamVersus);
|
||||
}
|
||||
|
||||
private void createRoom(Func<Room> room)
|
||||
{
|
||||
AddStep("open room", () =>
|
||||
{
|
||||
multiplayerScreen.OpenNewRoom(room());
|
||||
});
|
||||
|
||||
AddUntilStep("wait for room open", () => this.ChildrenOfType<MultiplayerMatchSubScreen>().FirstOrDefault()?.IsLoaded == true);
|
||||
AddWaitStep("wait for transition", 2);
|
||||
|
||||
AddStep("create room", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(this.ChildrenOfType<MultiplayerMatchSettingsOverlay.CreateOrUpdateButton>().Single());
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
AddUntilStep("wait for join", () => client.Room != null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Used for the sole purpose of adding <see cref="TestMultiplayerClient"/> as a resolvable dependency.
|
||||
/// </summary>
|
||||
private class DependenciesScreen : OsuScreen
|
||||
{
|
||||
[Cached(typeof(MultiplayerClient))]
|
||||
public readonly TestMultiplayerClient Client;
|
||||
|
||||
public DependenciesScreen(TestMultiplayerClient client)
|
||||
{
|
||||
Client = client;
|
||||
}
|
||||
}
|
||||
|
||||
private class TestMultiplayer : Screens.OnlinePlay.Multiplayer.Multiplayer
|
||||
{
|
||||
public new TestRequestHandlingMultiplayerRoomManager RoomManager { get; private set; }
|
||||
|
||||
protected override RoomManager CreateRoomManager() => RoomManager = new TestRequestHandlingMultiplayerRoomManager();
|
||||
}
|
||||
}
|
||||
}
|
@ -353,10 +353,10 @@ namespace osu.Game.Tests.Visual.Navigation
|
||||
|
||||
public TestMultiplayer()
|
||||
{
|
||||
Client = new TestMultiplayerClient((TestMultiplayerRoomManager)RoomManager);
|
||||
Client = new TestMultiplayerClient((TestRequestHandlingMultiplayerRoomManager)RoomManager);
|
||||
}
|
||||
|
||||
protected override RoomManager CreateRoomManager() => new TestMultiplayerRoomManager();
|
||||
protected override RoomManager CreateRoomManager() => new TestRequestHandlingMultiplayerRoomManager();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
AddStep("show manually", () => accountCreation.Show());
|
||||
AddUntilStep("overlay is visible", () => accountCreation.State.Value == Visibility.Visible);
|
||||
|
||||
AddStep("click button", () => accountCreation.ChildrenOfType<SettingsButton>().Single().Click());
|
||||
AddStep("click button", () => accountCreation.ChildrenOfType<SettingsButton>().Single().TriggerClick());
|
||||
AddUntilStep("warning screen is present", () => accountCreation.ChildrenOfType<ScreenWarning>().SingleOrDefault()?.IsPresent == true);
|
||||
|
||||
AddStep("log back in", () => API.Login("dummy", "password"));
|
||||
|
@ -330,22 +330,11 @@ namespace osu.Game.Tests.Visual.Online
|
||||
InputManager.ReleaseKey(Key.AltLeft);
|
||||
}
|
||||
|
||||
private void pressCloseDocumentKeys() => pressKeysFor(PlatformAction.DocumentClose);
|
||||
private void pressCloseDocumentKeys() => InputManager.Keys(PlatformAction.DocumentClose);
|
||||
|
||||
private void pressNewTabKeys() => pressKeysFor(PlatformAction.TabNew);
|
||||
private void pressNewTabKeys() => InputManager.Keys(PlatformAction.TabNew);
|
||||
|
||||
private void pressRestoreTabKeys() => pressKeysFor(PlatformAction.TabRestore);
|
||||
|
||||
private void pressKeysFor(PlatformAction type)
|
||||
{
|
||||
var binding = host.PlatformKeyBindings.First(b => (PlatformAction)b.Action == type);
|
||||
|
||||
foreach (var k in binding.KeyCombination.Keys)
|
||||
InputManager.PressKey((Key)k);
|
||||
|
||||
foreach (var k in binding.KeyCombination.Keys)
|
||||
InputManager.ReleaseKey((Key)k);
|
||||
}
|
||||
private void pressRestoreTabKeys() => InputManager.Keys(PlatformAction.TabRestore);
|
||||
|
||||
private void clickDrawable(Drawable d)
|
||||
{
|
||||
|
@ -1,13 +1,12 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Online.Spectator;
|
||||
@ -21,51 +20,44 @@ namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
private readonly User streamingUser = new User { Id = 2, Username = "Test user" };
|
||||
|
||||
[Cached(typeof(SpectatorClient))]
|
||||
private TestSpectatorClient testSpectatorClient = new TestSpectatorClient();
|
||||
|
||||
private TestSpectatorClient spectatorClient;
|
||||
private CurrentlyPlayingDisplay currentlyPlaying;
|
||||
|
||||
[Cached(typeof(UserLookupCache))]
|
||||
private UserLookupCache lookupCache = new TestUserLookupCache();
|
||||
|
||||
private Container nestedContainer;
|
||||
|
||||
[SetUpSteps]
|
||||
public void SetUpSteps()
|
||||
{
|
||||
AddStep("add streaming client", () =>
|
||||
{
|
||||
nestedContainer?.Remove(testSpectatorClient);
|
||||
Remove(lookupCache);
|
||||
spectatorClient = new TestSpectatorClient();
|
||||
var lookupCache = new TestUserLookupCache();
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
lookupCache,
|
||||
nestedContainer = new Container
|
||||
spectatorClient,
|
||||
new DependencyProvidingContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
CachedDependencies = new (Type, object)[]
|
||||
{
|
||||
testSpectatorClient,
|
||||
currentlyPlaying = new CurrentlyPlayingDisplay
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
}
|
||||
(typeof(SpectatorClient), spectatorClient),
|
||||
(typeof(UserLookupCache), lookupCache)
|
||||
},
|
||||
Child = currentlyPlaying = new CurrentlyPlayingDisplay
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
}
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
AddStep("Reset players", () => testSpectatorClient.EndPlay(streamingUser.Id));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestBasicDisplay()
|
||||
{
|
||||
AddStep("Add playing user", () => testSpectatorClient.StartPlay(streamingUser.Id, 0));
|
||||
AddStep("Add playing user", () => spectatorClient.StartPlay(streamingUser.Id, 0));
|
||||
AddUntilStep("Panel loaded", () => currentlyPlaying.ChildrenOfType<UserGridPanel>()?.FirstOrDefault()?.User.Id == 2);
|
||||
AddStep("Remove playing user", () => testSpectatorClient.EndPlay(streamingUser.Id));
|
||||
AddStep("Remove playing user", () => spectatorClient.EndPlay(streamingUser.Id));
|
||||
AddUntilStep("Panel no longer present", () => !currentlyPlaying.ChildrenOfType<UserGridPanel>().Any());
|
||||
}
|
||||
|
||||
|
87
osu.Game.Tests/Visual/Online/TestSceneDrawableComment.cs
Normal file
87
osu.Game.Tests/Visual/Online/TestSceneDrawableComment.cs
Normal file
@ -0,0 +1,87 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.Comments;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
public class TestSceneDrawableComment : OsuTestScene
|
||||
{
|
||||
[Cached]
|
||||
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Purple);
|
||||
|
||||
private Container container;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp() => Schedule(() =>
|
||||
{
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = colourProvider.Background4,
|
||||
},
|
||||
container = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
[TestCaseSource(nameof(comments))]
|
||||
public void TestComment(string description, string text)
|
||||
{
|
||||
AddStep(description, () =>
|
||||
{
|
||||
comment.Message = text;
|
||||
container.Add(new DrawableComment(comment));
|
||||
});
|
||||
}
|
||||
|
||||
private static readonly Comment comment = new Comment
|
||||
{
|
||||
Id = 1,
|
||||
LegacyName = "Test User",
|
||||
CreatedAt = DateTimeOffset.Now,
|
||||
VotesCount = 0,
|
||||
};
|
||||
|
||||
private static object[] comments =
|
||||
{
|
||||
new[] { "Plain", "This is plain comment" },
|
||||
new[] { "Link", "Please visit https://osu.ppy.sh" },
|
||||
|
||||
new[]
|
||||
{
|
||||
"Heading", @"# Heading 1
|
||||
## Heading 2
|
||||
### Heading 3
|
||||
#### Heading 4
|
||||
##### Heading 5
|
||||
###### Heading 6"
|
||||
},
|
||||
|
||||
// Taken from https://github.com/ppy/osu/issues/13993#issuecomment-885994077
|
||||
new[]
|
||||
{
|
||||
"Problematic", @"My tablet doesn't work :(
|
||||
It's a Huion 420 and it's apparently incompatible with OpenTablet Driver. The warning I get is: ""DeviceInUseException: Device is currently in use by another kernel module. To fix this issue, please follow the instructions from https://github.com/OpenTabletDriver/OpenTabletDriver/wiki/Linux-FAQ#arg umentoutofrangeexception-value-0-15"" and it repeats 4 times on the notification before logging subsequent warnings.
|
||||
Checking the logs, it looks for other Huion tablets before sending the notification (e.g.
|
||||
""2021-07-23 03:52:33 [verbose]: Detect: Searching for tablet 'Huion WH1409 V2'
|
||||
20 2021-07-23 03:52:33 [error]: DeviceInUseException: Device is currently in use by another kernel module. To fix this issue, please follow the instructions from https://github.com/OpenTabletDriver/OpenTabletDriver/wiki/Linux-FAQ#arg umentoutofrangeexception-value-0-15"")
|
||||
I use an Arch based installation of Linux and the tablet runs perfectly with Digimend kernel driver, with area configuration, pen pressure, etc. On osu!lazer the cursor disappears until I set it to ""Borderless"" instead of ""Fullscreen"" and even after it shows up, it goes to the bottom left corner as soon as a map starts.
|
||||
I have honestly 0 idea of whats going on at this point."
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
@ -29,7 +29,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
[Test]
|
||||
public void TestControl()
|
||||
{
|
||||
AddAssert("Front page selected", () => header.Current.Value == "frontpage");
|
||||
AddAssert("Front page selected", () => header.Current.Value == NewsHeader.FrontPageString);
|
||||
AddAssert("1 tab total", () => header.TabCount == 1);
|
||||
|
||||
AddStep("Set article 1", () => header.SetArticle("1"));
|
||||
@ -41,7 +41,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
AddAssert("2 tabs total", () => header.TabCount == 2);
|
||||
|
||||
AddStep("Set front page", () => header.SetFrontPage());
|
||||
AddAssert("Front page selected", () => header.Current.Value == "frontpage");
|
||||
AddAssert("Front page selected", () => header.Current.Value == NewsHeader.FrontPageString);
|
||||
AddAssert("1 tab total", () => header.TabCount == 1);
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
AddStep("Show", () => overlay.Show());
|
||||
AddUntilStep("Show More button is visible", () => showMoreButton?.Alpha == 1);
|
||||
setUpNewsResponse(responseWithNoCursor, "Set up no cursor response");
|
||||
AddStep("Click Show More", () => showMoreButton?.Click());
|
||||
AddStep("Click Show More", () => showMoreButton?.TriggerClick());
|
||||
AddUntilStep("Show More button is hidden", () => showMoreButton?.Alpha == 0);
|
||||
}
|
||||
|
||||
|
@ -32,19 +32,19 @@ namespace osu.Game.Tests.Visual.Online
|
||||
}
|
||||
});
|
||||
|
||||
AddStep("click button", () => button.Click());
|
||||
AddStep("click button", () => button.TriggerClick());
|
||||
|
||||
AddAssert("action fired once", () => fireCount == 1);
|
||||
AddAssert("is in loading state", () => button.IsLoading);
|
||||
|
||||
AddStep("click button", () => button.Click());
|
||||
AddStep("click button", () => button.TriggerClick());
|
||||
|
||||
AddAssert("action not fired", () => fireCount == 1);
|
||||
AddAssert("is in loading state", () => button.IsLoading);
|
||||
|
||||
AddUntilStep("wait for loaded", () => !button.IsLoading);
|
||||
|
||||
AddStep("click button", () => button.Click());
|
||||
AddStep("click button", () => button.TriggerClick());
|
||||
|
||||
AddAssert("action fired twice", () => fireCount == 2);
|
||||
AddAssert("is in loading state", () => button.IsLoading);
|
||||
|
@ -45,7 +45,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
AddStep("Log in", logIn);
|
||||
AddStep("User comment", () => addVotePill(getUserComment()));
|
||||
AddAssert("Background is transparent", () => votePill.Background.Alpha == 0);
|
||||
AddStep("Click", () => votePill.Click());
|
||||
AddStep("Click", () => votePill.TriggerClick());
|
||||
AddAssert("Not loading", () => !votePill.IsLoading);
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
AddStep("Log in", logIn);
|
||||
AddStep("Random comment", () => addVotePill(getRandomComment()));
|
||||
AddAssert("Background is visible", () => votePill.Background.Alpha == 1);
|
||||
AddStep("Click", () => votePill.Click());
|
||||
AddStep("Click", () => votePill.TriggerClick());
|
||||
AddAssert("Loading", () => votePill.IsLoading);
|
||||
}
|
||||
|
||||
@ -66,7 +66,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
AddStep("Hide login overlay", () => login.Hide());
|
||||
AddStep("Log out", API.Logout);
|
||||
AddStep("Random comment", () => addVotePill(getRandomComment()));
|
||||
AddStep("Click", () => votePill.Click());
|
||||
AddStep("Click", () => votePill.TriggerClick());
|
||||
AddAssert("Login overlay is visible", () => login.State.Value == Visibility.Visible);
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
[Test]
|
||||
public void TestWikiHeader()
|
||||
{
|
||||
AddAssert("Current is index", () => checkCurrent("index"));
|
||||
AddAssert("Current is index", () => checkCurrent(WikiHeader.IndexPageString));
|
||||
|
||||
AddStep("Change wiki page data", () => wikiPageData.Value = new APIWikiPage
|
||||
{
|
||||
@ -54,8 +54,8 @@ namespace osu.Game.Tests.Visual.Online
|
||||
AddAssert("Current is welcome", () => checkCurrent("Welcome"));
|
||||
AddAssert("Check breadcrumb", checkBreadcrumb);
|
||||
|
||||
AddStep("Change current to index", () => header.Current.Value = "index");
|
||||
AddAssert("Current is index", () => checkCurrent("index"));
|
||||
AddStep("Change current to index", () => header.Current.Value = WikiHeader.IndexPageString);
|
||||
AddAssert("Current is index", () => checkCurrent(WikiHeader.IndexPageString));
|
||||
|
||||
AddStep("Change wiki page data", () => wikiPageData.Value = new APIWikiPage
|
||||
{
|
||||
@ -71,7 +71,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
AddAssert("Check breadcrumb", checkBreadcrumb);
|
||||
}
|
||||
|
||||
private bool checkCurrent(string expectedCurrent) => header.Current.Value == expectedCurrent;
|
||||
private bool checkCurrent(LocalisableString expectedCurrent) => header.Current.Value == expectedCurrent;
|
||||
|
||||
private bool checkBreadcrumb()
|
||||
{
|
||||
|
@ -10,6 +10,7 @@ using osu.Game.Screens.OnlinePlay.Lounge;
|
||||
using osu.Game.Screens.OnlinePlay.Lounge.Components;
|
||||
using osu.Game.Screens.OnlinePlay.Playlists;
|
||||
using osu.Game.Tests.Visual.OnlinePlay;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Playlists
|
||||
{
|
||||
@ -30,17 +31,35 @@ namespace osu.Game.Tests.Visual.Playlists
|
||||
|
||||
private RoomsContainer roomsContainer => loungeScreen.ChildrenOfType<RoomsContainer>().First();
|
||||
|
||||
[Test]
|
||||
public void TestScrollByDraggingRooms()
|
||||
{
|
||||
AddStep("reset mouse", () => InputManager.ReleaseButton(MouseButton.Left));
|
||||
|
||||
AddStep("add rooms", () => RoomManager.AddRooms(30));
|
||||
|
||||
AddUntilStep("first room is not masked", () => checkRoomVisible(roomsContainer.Rooms[0]));
|
||||
|
||||
AddStep("move mouse to third room", () => InputManager.MoveMouseTo(roomsContainer.Rooms[2]));
|
||||
AddStep("hold down", () => InputManager.PressButton(MouseButton.Left));
|
||||
AddStep("drag to top", () => InputManager.MoveMouseTo(roomsContainer.Rooms[0]));
|
||||
|
||||
AddAssert("first and second room masked", ()
|
||||
=> !checkRoomVisible(roomsContainer.Rooms[0]) &&
|
||||
!checkRoomVisible(roomsContainer.Rooms[1]));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestScrollSelectedIntoView()
|
||||
{
|
||||
AddStep("add rooms", () => RoomManager.AddRooms(30));
|
||||
|
||||
AddUntilStep("first room is not masked", () => checkRoomVisible(roomsContainer.Rooms.First()));
|
||||
AddUntilStep("first room is not masked", () => checkRoomVisible(roomsContainer.Rooms[0]));
|
||||
|
||||
AddStep("select last room", () => roomsContainer.Rooms.Last().Click());
|
||||
AddStep("select last room", () => roomsContainer.Rooms[^1].TriggerClick());
|
||||
|
||||
AddUntilStep("first room is masked", () => !checkRoomVisible(roomsContainer.Rooms.First()));
|
||||
AddUntilStep("last room is not masked", () => checkRoomVisible(roomsContainer.Rooms.Last()));
|
||||
AddUntilStep("first room is masked", () => !checkRoomVisible(roomsContainer.Rooms[0]));
|
||||
AddUntilStep("last room is not masked", () => checkRoomVisible(roomsContainer.Rooms[^1]));
|
||||
}
|
||||
|
||||
private bool checkRoomVisible(DrawableRoom room) =>
|
||||
|
@ -76,7 +76,7 @@ namespace osu.Game.Tests.Visual.Playlists
|
||||
});
|
||||
});
|
||||
|
||||
AddStep("start match", () => match.ChildrenOfType<PlaylistsReadyButton>().First().Click());
|
||||
AddStep("start match", () => match.ChildrenOfType<PlaylistsReadyButton>().First().TriggerClick());
|
||||
AddUntilStep("player loader loaded", () => Stack.CurrentScreen is PlayerLoader);
|
||||
}
|
||||
|
||||
|
@ -160,7 +160,7 @@ namespace osu.Game.Tests.Visual.Settings
|
||||
{
|
||||
var resetButton = settingsKeyBindingRow.ChildrenOfType<RestoreDefaultValueButton<bool>>().First();
|
||||
|
||||
resetButton.Click();
|
||||
resetButton.TriggerClick();
|
||||
});
|
||||
|
||||
AddUntilStep("restore button hidden", () => settingsKeyBindingRow.ChildrenOfType<RestoreDefaultValueButton<bool>>().First().Alpha == 0);
|
||||
@ -189,7 +189,7 @@ namespace osu.Game.Tests.Visual.Settings
|
||||
{
|
||||
var resetButton = panel.ChildrenOfType<ResetButton>().First();
|
||||
|
||||
resetButton.Click();
|
||||
resetButton.TriggerClick();
|
||||
});
|
||||
|
||||
AddUntilStep("restore button hidden", () => settingsKeyBindingRow.ChildrenOfType<RestoreDefaultValueButton<bool>>().First().Alpha == 0);
|
||||
|
@ -143,9 +143,9 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
public override async Task<StarDifficulty> GetDifficultyAsync(BeatmapInfo beatmapInfo, RulesetInfo rulesetInfo = null, IEnumerable<Mod> mods = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (blockCalculation)
|
||||
await calculationBlocker.Task;
|
||||
await calculationBlocker.Task.ConfigureAwait(false);
|
||||
|
||||
return await base.GetDifficultyAsync(beatmapInfo, rulesetInfo, mods, cancellationToken);
|
||||
return await base.GetDifficultyAsync(beatmapInfo, rulesetInfo, mods, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Configuration;
|
||||
@ -32,6 +33,7 @@ using osuTK.Graphics;
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
[TestFixture]
|
||||
[HeadlessTest]
|
||||
public class TestSceneOsuGame : OsuTestScene
|
||||
{
|
||||
private IReadOnlyList<Type> requiredGameDependencies => new[]
|
||||
@ -83,10 +85,15 @@ namespace osu.Game.Tests.Visual
|
||||
typeof(PreviewTrackManager),
|
||||
};
|
||||
|
||||
private OsuGame game;
|
||||
|
||||
[Resolved]
|
||||
private OsuGameBase gameBase { get; set; }
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(GameHost host, OsuGameBase gameBase)
|
||||
private void load(GameHost host)
|
||||
{
|
||||
OsuGame game = new OsuGame();
|
||||
game = new OsuGame();
|
||||
game.SetHost(host);
|
||||
|
||||
Children = new Drawable[]
|
||||
@ -100,7 +107,39 @@ namespace osu.Game.Tests.Visual
|
||||
};
|
||||
|
||||
AddUntilStep("wait for load", () => game.IsLoaded);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNullRulesetHandled()
|
||||
{
|
||||
RulesetInfo ruleset = null;
|
||||
|
||||
AddStep("store current ruleset", () => ruleset = Ruleset.Value);
|
||||
AddStep("set global ruleset to null value", () => Ruleset.Value = null);
|
||||
|
||||
AddAssert("ruleset still valid", () => Ruleset.Value.Available);
|
||||
AddAssert("ruleset unchanged", () => ReferenceEquals(Ruleset.Value, ruleset));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestUnavailableRulesetHandled()
|
||||
{
|
||||
RulesetInfo ruleset = null;
|
||||
|
||||
AddStep("store current ruleset", () => ruleset = Ruleset.Value);
|
||||
AddStep("set global ruleset to invalid value", () => Ruleset.Value = new RulesetInfo
|
||||
{
|
||||
Name = "unavailable",
|
||||
Available = false,
|
||||
});
|
||||
|
||||
AddAssert("ruleset still valid", () => Ruleset.Value.Available);
|
||||
AddAssert("ruleset unchanged", () => ReferenceEquals(Ruleset.Value, ruleset));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestAvailableDependencies()
|
||||
{
|
||||
AddAssert("check OsuGame DI members", () =>
|
||||
{
|
||||
foreach (var type in requiredGameDependencies)
|
||||
@ -111,6 +150,7 @@ namespace osu.Game.Tests.Visual
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
AddAssert("check OsuGameBase DI members", () =>
|
||||
{
|
||||
foreach (var type in requiredGameBaseDependencies)
|
||||
|
@ -1,16 +1,21 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. 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.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Graphics.Cursor;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Graphics.UserInterfaceV2;
|
||||
using osuTK.Graphics;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
public class TestSceneLabelledColourPalette : OsuTestScene
|
||||
public class TestSceneLabelledColourPalette : OsuManualInputManagerTestScene
|
||||
{
|
||||
private LabelledColourPalette component;
|
||||
|
||||
@ -30,21 +35,41 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
}, 8);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestUserInteractions()
|
||||
{
|
||||
createColourPalette();
|
||||
assertColourCount(4);
|
||||
|
||||
clickAddColour();
|
||||
assertColourCount(5);
|
||||
|
||||
deleteFirstColour();
|
||||
assertColourCount(4);
|
||||
|
||||
clickFirstColour();
|
||||
AddAssert("colour picker spawned", () => this.ChildrenOfType<OsuColourPicker>().Any());
|
||||
}
|
||||
|
||||
private void createColourPalette(bool hasDescription = false)
|
||||
{
|
||||
AddStep("create component", () =>
|
||||
{
|
||||
Child = new Container
|
||||
Child = new OsuContextMenuContainer
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Width = 500,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Child = component = new LabelledColourPalette
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = new Container
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
ColourNamePrefix = "My colour #"
|
||||
Width = 500,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Child = component = new LabelledColourPalette
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
ColourNamePrefix = "My colour #"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -53,18 +78,49 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
|
||||
component.Colours.AddRange(new[]
|
||||
{
|
||||
Color4.DarkRed,
|
||||
Color4.Aquamarine,
|
||||
Color4.Goldenrod,
|
||||
Color4.Gainsboro
|
||||
Colour4.DarkRed,
|
||||
Colour4.Aquamarine,
|
||||
Colour4.Goldenrod,
|
||||
Colour4.Gainsboro
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private Color4 randomColour() => new Color4(
|
||||
private Colour4 randomColour() => new Color4(
|
||||
RNG.NextSingle(),
|
||||
RNG.NextSingle(),
|
||||
RNG.NextSingle(),
|
||||
1);
|
||||
|
||||
private void assertColourCount(int count) => AddAssert($"colour count is {count}", () => component.Colours.Count == count);
|
||||
|
||||
private void clickAddColour() => AddStep("click new colour button", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(this.ChildrenOfType<ColourPalette.AddColourButton>().Single());
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
private void clickFirstColour() => AddStep("click first colour", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(this.ChildrenOfType<ColourDisplay>().First());
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
private void deleteFirstColour()
|
||||
{
|
||||
AddStep("right-click first colour", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(this.ChildrenOfType<ColourDisplay>().First());
|
||||
InputManager.Click(MouseButton.Right);
|
||||
});
|
||||
|
||||
AddUntilStep("wait for menu", () => this.ChildrenOfType<OsuContextMenu>().Any());
|
||||
|
||||
AddStep("click delete", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(this.ChildrenOfType<DrawableOsuMenuItem>().Single());
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -94,10 +94,10 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
|
||||
AddAssert("selected mod matches", () => (SelectedMods.Value.Single() as OsuModDoubleTime)?.SpeedChange.Value == 1.2);
|
||||
|
||||
AddStep("deselect", () => modSelect.DeselectAllButton.Click());
|
||||
AddStep("deselect", () => modSelect.DeselectAllButton.TriggerClick());
|
||||
AddAssert("selected mods empty", () => SelectedMods.Value.Count == 0);
|
||||
|
||||
AddStep("reselect", () => modSelect.GetModButton(osuModDoubleTime).Click());
|
||||
AddStep("reselect", () => modSelect.GetModButton(osuModDoubleTime).TriggerClick());
|
||||
AddAssert("selected mod has default value", () => (SelectedMods.Value.Single() as OsuModDoubleTime)?.SpeedChange.IsDefault == true);
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
AddUntilStep("wait for button load", () => modSelect.ButtonsLoaded);
|
||||
AddStep("select mod", () => modSelect.SelectMod(testCustomisableMod));
|
||||
AddAssert("button enabled", () => modSelect.CustomiseButton.Enabled.Value);
|
||||
AddStep("open Customisation", () => modSelect.CustomiseButton.Click());
|
||||
AddStep("open Customisation", () => modSelect.CustomiseButton.TriggerClick());
|
||||
AddStep("deselect mod", () => modSelect.SelectMod(testCustomisableMod));
|
||||
AddAssert("controls hidden", () => modSelect.ModSettingsContainer.State.Value == Visibility.Hidden);
|
||||
}
|
||||
|
@ -1,21 +1,18 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Game.Tournament.Configuration;
|
||||
using osu.Game.Tests;
|
||||
using osu.Game.Tournament.Configuration;
|
||||
|
||||
namespace osu.Game.Tournament.Tests.NonVisual
|
||||
{
|
||||
[TestFixture]
|
||||
public class CustomTourneyDirectoryTest
|
||||
public class CustomTourneyDirectoryTest : TournamentHostTest
|
||||
{
|
||||
[Test]
|
||||
public void TestDefaultDirectory()
|
||||
@ -24,7 +21,7 @@ namespace osu.Game.Tournament.Tests.NonVisual
|
||||
{
|
||||
try
|
||||
{
|
||||
var osu = loadOsu(host);
|
||||
var osu = LoadTournament(host);
|
||||
var storage = osu.Dependencies.Get<Storage>();
|
||||
|
||||
Assert.That(storage.GetFullPath("."), Is.EqualTo(Path.Combine(host.Storage.GetFullPath("."), "tournaments", "default")));
|
||||
@ -54,7 +51,7 @@ namespace osu.Game.Tournament.Tests.NonVisual
|
||||
|
||||
try
|
||||
{
|
||||
var osu = loadOsu(host);
|
||||
var osu = LoadTournament(host);
|
||||
|
||||
storage = osu.Dependencies.Get<Storage>();
|
||||
|
||||
@ -111,7 +108,7 @@ namespace osu.Game.Tournament.Tests.NonVisual
|
||||
|
||||
try
|
||||
{
|
||||
var osu = loadOsu(host);
|
||||
var osu = LoadTournament(host);
|
||||
|
||||
var storage = osu.Dependencies.Get<Storage>();
|
||||
|
||||
@ -151,25 +148,6 @@ namespace osu.Game.Tournament.Tests.NonVisual
|
||||
}
|
||||
}
|
||||
|
||||
private TournamentGameBase loadOsu(GameHost host)
|
||||
{
|
||||
var osu = new TournamentGameBase();
|
||||
Task.Run(() => host.Run(osu))
|
||||
.ContinueWith(t => Assert.Fail($"Host threw exception {t.Exception}"), TaskContinuationOptions.OnlyOnFaulted);
|
||||
waitForOrAssert(() => osu.IsLoaded, @"osu! failed to start in a reasonable amount of time");
|
||||
return osu;
|
||||
}
|
||||
|
||||
private static void waitForOrAssert(Func<bool> result, string failureMessage, int timeout = 90000)
|
||||
{
|
||||
Task task = Task.Run(() =>
|
||||
{
|
||||
while (!result()) Thread.Sleep(200);
|
||||
});
|
||||
|
||||
Assert.IsTrue(task.Wait(timeout), failureMessage);
|
||||
}
|
||||
|
||||
private string basePath(string testInstance) => Path.Combine(RuntimeInfo.StartupDirectory, "headless", testInstance);
|
||||
}
|
||||
}
|
||||
|
45
osu.Game.Tournament.Tests/NonVisual/DataLoadTest.cs
Normal file
45
osu.Game.Tournament.Tests/NonVisual/DataLoadTest.cs
Normal file
@ -0,0 +1,45 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.IO;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Tests;
|
||||
|
||||
namespace osu.Game.Tournament.Tests.NonVisual
|
||||
{
|
||||
public class DataLoadTest : TournamentHostTest
|
||||
{
|
||||
[Test]
|
||||
public void TestUnavailableRuleset()
|
||||
{
|
||||
using (HeadlessGameHost host = new CleanRunHeadlessGameHost(nameof(TestUnavailableRuleset)))
|
||||
{
|
||||
try
|
||||
{
|
||||
var osu = new TestTournament();
|
||||
|
||||
LoadTournament(host, osu);
|
||||
var storage = osu.Dependencies.Get<Storage>();
|
||||
|
||||
Assert.That(storage.GetFullPath("."), Is.EqualTo(Path.Combine(host.Storage.GetFullPath("."), "tournaments", "default")));
|
||||
}
|
||||
finally
|
||||
{
|
||||
host.Exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class TestTournament : TournamentGameBase
|
||||
{
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
Ruleset.Value = new RulesetInfo(); // not available
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,10 +1,7 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
@ -15,7 +12,7 @@ using osu.Game.Tournament.IPC;
|
||||
namespace osu.Game.Tournament.Tests.NonVisual
|
||||
{
|
||||
[TestFixture]
|
||||
public class IPCLocationTest
|
||||
public class IPCLocationTest : TournamentHostTest
|
||||
{
|
||||
[Test]
|
||||
public void CheckIPCLocation()
|
||||
@ -34,11 +31,11 @@ namespace osu.Game.Tournament.Tests.NonVisual
|
||||
|
||||
try
|
||||
{
|
||||
var osu = loadOsu(host);
|
||||
var osu = LoadTournament(host);
|
||||
TournamentStorage storage = (TournamentStorage)osu.Dependencies.Get<Storage>();
|
||||
FileBasedIPC ipc = null;
|
||||
|
||||
waitForOrAssert(() => (ipc = osu.Dependencies.Get<MatchIPCInfo>() as FileBasedIPC) != null, @"ipc could not be populated in a reasonable amount of time");
|
||||
WaitForOrAssert(() => (ipc = osu.Dependencies.Get<MatchIPCInfo>() as FileBasedIPC) != null, @"ipc could not be populated in a reasonable amount of time");
|
||||
|
||||
Assert.True(ipc.SetIPCLocation(testStableInstallDirectory));
|
||||
Assert.True(storage.AllTournaments.Exists("stable.json"));
|
||||
@ -51,24 +48,5 @@ namespace osu.Game.Tournament.Tests.NonVisual
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private TournamentGameBase loadOsu(GameHost host)
|
||||
{
|
||||
var osu = new TournamentGameBase();
|
||||
Task.Run(() => host.Run(osu))
|
||||
.ContinueWith(t => Assert.Fail($"Host threw exception {t.Exception}"), TaskContinuationOptions.OnlyOnFaulted);
|
||||
waitForOrAssert(() => osu.IsLoaded, @"osu! failed to start in a reasonable amount of time");
|
||||
return osu;
|
||||
}
|
||||
|
||||
private static void waitForOrAssert(Func<bool> result, string failureMessage, int timeout = 90000)
|
||||
{
|
||||
Task task = Task.Run(() =>
|
||||
{
|
||||
while (!result()) Thread.Sleep(200);
|
||||
});
|
||||
|
||||
Assert.IsTrue(task.Wait(timeout), failureMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
33
osu.Game.Tournament.Tests/NonVisual/TournamentHostTest.cs
Normal file
33
osu.Game.Tournament.Tests/NonVisual/TournamentHostTest.cs
Normal file
@ -0,0 +1,33 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Platform;
|
||||
|
||||
namespace osu.Game.Tournament.Tests.NonVisual
|
||||
{
|
||||
public abstract class TournamentHostTest
|
||||
{
|
||||
public static TournamentGameBase LoadTournament(GameHost host, TournamentGameBase tournament = null)
|
||||
{
|
||||
tournament ??= new TournamentGameBase();
|
||||
Task.Run(() => host.Run(tournament))
|
||||
.ContinueWith(t => Assert.Fail($"Host threw exception {t.Exception}"), TaskContinuationOptions.OnlyOnFaulted);
|
||||
WaitForOrAssert(() => tournament.IsLoaded, @"osu! failed to start in a reasonable amount of time");
|
||||
return tournament;
|
||||
}
|
||||
|
||||
public static void WaitForOrAssert(Func<bool> result, string failureMessage, int timeout = 90000)
|
||||
{
|
||||
Task task = Task.Run(() =>
|
||||
{
|
||||
while (!result()) Thread.Sleep(200);
|
||||
});
|
||||
|
||||
Assert.IsTrue(task.Wait(timeout), failureMessage);
|
||||
}
|
||||
}
|
||||
}
|
@ -40,6 +40,6 @@ namespace osu.Game.Tournament.Tests.Screens
|
||||
() => this.ChildrenOfType<TeamScore>().All(score => score.Alpha == (visible ? 1 : 0)));
|
||||
|
||||
private void toggleWarmup()
|
||||
=> AddStep("toggle warmup", () => this.ChildrenOfType<TourneyButton>().First().Click());
|
||||
=> AddStep("toggle warmup", () => this.ChildrenOfType<TourneyButton>().First().TriggerClick());
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. 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;
|
||||
@ -11,6 +10,7 @@ using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Legacy;
|
||||
using osu.Game.Extensions;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Screens.Menu;
|
||||
@ -198,8 +198,8 @@ namespace osu.Game.Tournament.Components
|
||||
Direction = FillDirection.Vertical,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new DiffPiece(("Length", TimeSpan.FromMilliseconds(length).ToString(@"mm\:ss"))),
|
||||
new DiffPiece(("BPM", $"{bpm:0.#}"))
|
||||
new DiffPiece(("Length", length.ToFormattedDuration().ToString())),
|
||||
new DiffPiece(("BPM", $"{bpm:0.#}")),
|
||||
}
|
||||
},
|
||||
new Container
|
||||
|
@ -27,6 +27,9 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
|
||||
{
|
||||
var teams = new List<TournamentTeam>();
|
||||
|
||||
if (!storage.Exists(teams_filename))
|
||||
return teams;
|
||||
|
||||
try
|
||||
{
|
||||
using (Stream stream = storage.GetStream(teams_filename, FileAccess.Read, FileMode.Open))
|
||||
|
@ -9,11 +9,13 @@ using System.Threading.Tasks;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Tournament.Components;
|
||||
using osu.Game.Tournament.Models;
|
||||
using osu.Game.Tournament.Screens.Drawings.Components;
|
||||
@ -51,6 +53,29 @@ namespace osu.Game.Tournament.Screens.Drawings
|
||||
|
||||
if (!TeamList.Teams.Any())
|
||||
{
|
||||
LinkFlowContainer links;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Colour = Color4.Black,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Height = 0.3f,
|
||||
},
|
||||
new WarningBox("No drawings.txt file found. Please create one and restart the client."),
|
||||
links = new LinkFlowContainer
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Y = 60,
|
||||
AutoSizeAxes = Axes.Both
|
||||
}
|
||||
};
|
||||
|
||||
links.AddLink("Click for details on the file format", "https://osu.ppy.sh/wiki/en/Tournament_Drawings", t => t.Colour = Color4.White);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,9 @@ namespace osu.Game.Tournament
|
||||
}
|
||||
|
||||
ladder ??= new LadderInfo();
|
||||
ladder.Ruleset.Value ??= RulesetStore.AvailableRulesets.First();
|
||||
|
||||
ladder.Ruleset.Value = RulesetStore.GetRuleset(ladder.Ruleset.Value?.ShortName)
|
||||
?? RulesetStore.AvailableRulesets.First();
|
||||
|
||||
bool addedInfo = false;
|
||||
|
||||
|
@ -1,2 +1,3 @@
|
||||
[*.cs]
|
||||
dotnet_diagnostic.OLOC001.prefix_namespace = osu.Game.Resources.Localisation
|
||||
dotnet_diagnostic.OLOC001.prefix_namespace = osu.Game.Resources.Localisation
|
||||
dotnet_diagnostic.OLOC001.license_header = // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.\n// See the LICENCE file in the repository root for full licence text.
|
@ -7,6 +7,7 @@ using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Mixing;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
@ -30,11 +31,11 @@ namespace osu.Game.Audio
|
||||
private readonly BindableNumber<double> globalTrackVolumeAdjust = new BindableNumber<double>(OsuGameBase.GLOBAL_TRACK_VOLUME_ADJUST);
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
private void load(AudioManager audioManager)
|
||||
{
|
||||
// this is a temporary solution to get around muting ourselves.
|
||||
// todo: update this once we have a BackgroundTrackManager or similar.
|
||||
trackStore = new PreviewTrackStore(new OnlineStore());
|
||||
trackStore = new PreviewTrackStore(audioManager.Mixer, new OnlineStore());
|
||||
|
||||
audio.AddItem(trackStore);
|
||||
trackStore.AddAdjustment(AdjustableProperty.Volume, globalTrackVolumeAdjust);
|
||||
@ -118,10 +119,12 @@ namespace osu.Game.Audio
|
||||
|
||||
private class PreviewTrackStore : AudioCollectionManager<AdjustableAudioComponent>, ITrackStore
|
||||
{
|
||||
private readonly AudioMixer defaultMixer;
|
||||
private readonly IResourceStore<byte[]> store;
|
||||
|
||||
internal PreviewTrackStore(IResourceStore<byte[]> store)
|
||||
internal PreviewTrackStore(AudioMixer defaultMixer, IResourceStore<byte[]> store)
|
||||
{
|
||||
this.defaultMixer = defaultMixer;
|
||||
this.store = store;
|
||||
}
|
||||
|
||||
@ -145,8 +148,12 @@ namespace osu.Game.Audio
|
||||
if (dataStream == null)
|
||||
return null;
|
||||
|
||||
// Todo: This is quite unsafe. TrackBass shouldn't be exposed as public.
|
||||
Track track = new TrackBass(dataStream);
|
||||
|
||||
defaultMixer.Add(track);
|
||||
AddItem(track);
|
||||
|
||||
return track;
|
||||
}
|
||||
|
||||
|
@ -34,19 +34,19 @@ namespace osu.Game.Beatmaps
|
||||
isFirst = false;
|
||||
}
|
||||
|
||||
obj.ComboIndex = lastObj?.ComboIndex ?? 0;
|
||||
obj.ComboIndexWithOffsets = lastObj?.ComboIndexWithOffsets ?? 0;
|
||||
obj.IndexInCurrentCombo = (lastObj?.IndexInCurrentCombo + 1) ?? 0;
|
||||
|
||||
if (obj.NewCombo)
|
||||
{
|
||||
obj.IndexInCurrentCombo = 0;
|
||||
obj.ComboIndex = (lastObj?.ComboIndex ?? 0) + obj.ComboOffset + 1;
|
||||
obj.ComboIndex++;
|
||||
obj.ComboIndexWithOffsets += obj.ComboOffset + 1;
|
||||
|
||||
if (lastObj != null)
|
||||
lastObj.LastInCombo = true;
|
||||
}
|
||||
else if (lastObj != null)
|
||||
{
|
||||
obj.IndexInCurrentCombo = lastObj.IndexInCurrentCombo + 1;
|
||||
obj.ComboIndex = lastObj.ComboIndex;
|
||||
}
|
||||
|
||||
lastObj = obj;
|
||||
}
|
||||
|
@ -1,22 +1,34 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Resources.Localisation.Web;
|
||||
|
||||
namespace osu.Game.Beatmaps
|
||||
{
|
||||
[LocalisableEnum(typeof(BeatmapSetOnlineStatusEnumLocalisationMapper))]
|
||||
public enum BeatmapSetOnlineStatus
|
||||
{
|
||||
None = -3,
|
||||
|
||||
[LocalisableDescription(typeof(BeatmapsetsStrings), nameof(BeatmapsetsStrings.ShowStatusGraveyard))]
|
||||
Graveyard = -2,
|
||||
|
||||
[LocalisableDescription(typeof(BeatmapsetsStrings), nameof(BeatmapsetsStrings.ShowStatusWip))]
|
||||
WIP = -1,
|
||||
|
||||
[LocalisableDescription(typeof(BeatmapsetsStrings), nameof(BeatmapsetsStrings.ShowStatusPending))]
|
||||
Pending = 0,
|
||||
|
||||
[LocalisableDescription(typeof(BeatmapsetsStrings), nameof(BeatmapsetsStrings.ShowStatusRanked))]
|
||||
Ranked = 1,
|
||||
|
||||
[LocalisableDescription(typeof(BeatmapsetsStrings), nameof(BeatmapsetsStrings.ShowStatusApproved))]
|
||||
Approved = 2,
|
||||
|
||||
[LocalisableDescription(typeof(BeatmapsetsStrings), nameof(BeatmapsetsStrings.ShowStatusQualified))]
|
||||
Qualified = 3,
|
||||
|
||||
[LocalisableDescription(typeof(BeatmapsetsStrings), nameof(BeatmapsetsStrings.ShowStatusLoved))]
|
||||
Loved = 4,
|
||||
}
|
||||
|
||||
@ -25,40 +37,4 @@ namespace osu.Game.Beatmaps
|
||||
public static bool GrantsPerformancePoints(this BeatmapSetOnlineStatus status)
|
||||
=> status == BeatmapSetOnlineStatus.Ranked || status == BeatmapSetOnlineStatus.Approved;
|
||||
}
|
||||
|
||||
public class BeatmapSetOnlineStatusEnumLocalisationMapper : EnumLocalisationMapper<BeatmapSetOnlineStatus>
|
||||
{
|
||||
public override LocalisableString Map(BeatmapSetOnlineStatus value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case BeatmapSetOnlineStatus.None:
|
||||
return string.Empty;
|
||||
|
||||
case BeatmapSetOnlineStatus.Graveyard:
|
||||
return BeatmapsetsStrings.ShowStatusGraveyard;
|
||||
|
||||
case BeatmapSetOnlineStatus.WIP:
|
||||
return BeatmapsetsStrings.ShowStatusWip;
|
||||
|
||||
case BeatmapSetOnlineStatus.Pending:
|
||||
return BeatmapsetsStrings.ShowStatusPending;
|
||||
|
||||
case BeatmapSetOnlineStatus.Ranked:
|
||||
return BeatmapsetsStrings.ShowStatusRanked;
|
||||
|
||||
case BeatmapSetOnlineStatus.Approved:
|
||||
return BeatmapsetsStrings.ShowStatusApproved;
|
||||
|
||||
case BeatmapSetOnlineStatus.Qualified:
|
||||
return BeatmapsetsStrings.ShowStatusQualified;
|
||||
|
||||
case BeatmapSetOnlineStatus.Loved:
|
||||
return BeatmapsetsStrings.ShowStatusLoved;
|
||||
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(value), value, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -93,20 +93,20 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
new CircularContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Scale = new Vector2(0.84f),
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Masking = true,
|
||||
EdgeEffect = new EdgeEffectParameters
|
||||
{
|
||||
Colour = Color4.Black.Opacity(0.08f),
|
||||
Colour = Color4.Black.Opacity(0.06f),
|
||||
|
||||
Type = EdgeEffectType.Shadow,
|
||||
Radius = 5,
|
||||
Radius = 3,
|
||||
},
|
||||
Child = background = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = colours.ForDifficultyRating(beatmap.DifficultyRating) // Default value that will be re-populated once difficulty calculation completes
|
||||
Colour = colours.ForStarDifficulty(beatmap.StarDifficulty) // Default value that will be re-populated once difficulty calculation completes
|
||||
},
|
||||
},
|
||||
new ConstrainedIconContainer
|
||||
@ -124,7 +124,7 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
else
|
||||
difficultyBindable.Value = new StarDifficulty(beatmap.StarDifficulty, 0);
|
||||
|
||||
difficultyBindable.BindValueChanged(difficulty => background.Colour = colours.ForDifficultyRating(difficulty.NewValue.DifficultyRating));
|
||||
difficultyBindable.BindValueChanged(difficulty => background.Colour = colours.ForStarDifficulty(difficulty.NewValue.Stars));
|
||||
}
|
||||
|
||||
public ITooltip GetCustomTooltip() => new DifficultyIconTooltip();
|
||||
@ -271,7 +271,7 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
starDifficulty.BindValueChanged(difficulty =>
|
||||
{
|
||||
starRating.Text = $"{difficulty.NewValue.Stars:0.##}";
|
||||
difficultyFlow.Colour = colours.ForDifficultyRating(difficulty.NewValue.DifficultyRating, true);
|
||||
difficultyFlow.Colour = colours.ForStarDifficulty(difficulty.NewValue.Stars);
|
||||
}, true);
|
||||
|
||||
return true;
|
||||
|
@ -13,8 +13,16 @@ namespace osu.Game.Database
|
||||
public interface IModelManager<TModel>
|
||||
where TModel : class
|
||||
{
|
||||
/// <summary>
|
||||
/// A bindable which contains a weak reference to the last item that was updated.
|
||||
/// This is not thread-safe and should be scheduled locally if consumed from a drawable component.
|
||||
/// </summary>
|
||||
IBindable<WeakReference<TModel>> ItemUpdated { get; }
|
||||
|
||||
/// <summary>
|
||||
/// A bindable which contains a weak reference to the last item that was removed.
|
||||
/// This is not thread-safe and should be scheduled locally if consumed from a drawable component.
|
||||
/// </summary>
|
||||
IBindable<WeakReference<TModel>> ItemRemoved { get; }
|
||||
}
|
||||
}
|
||||
|
@ -1,26 +0,0 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
|
||||
namespace osu.Game.Extensions
|
||||
{
|
||||
public static class EditorDisplayExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Get an editor formatted string (mm:ss:mss)
|
||||
/// </summary>
|
||||
/// <param name="milliseconds">A time value in milliseconds.</param>
|
||||
/// <returns>An editor formatted display string.</returns>
|
||||
public static string ToEditorFormattedString(this double milliseconds) =>
|
||||
ToEditorFormattedString(TimeSpan.FromMilliseconds(milliseconds));
|
||||
|
||||
/// <summary>
|
||||
/// Get an editor formatted string (mm:ss:mss)
|
||||
/// </summary>
|
||||
/// <param name="timeSpan">A time value.</param>
|
||||
/// <returns>An editor formatted display string.</returns>
|
||||
public static string ToEditorFormattedString(this TimeSpan timeSpan) =>
|
||||
$"{(timeSpan < TimeSpan.Zero ? "-" : string.Empty)}{timeSpan:mm\\:ss\\:fff}";
|
||||
}
|
||||
}
|
51
osu.Game/Extensions/TimeDisplayExtensions.cs
Normal file
51
osu.Game/Extensions/TimeDisplayExtensions.cs
Normal file
@ -0,0 +1,51 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using osu.Framework.Localisation;
|
||||
|
||||
namespace osu.Game.Extensions
|
||||
{
|
||||
public static class TimeDisplayExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Get an editor formatted string (mm:ss:mss)
|
||||
/// </summary>
|
||||
/// <param name="milliseconds">A time value in milliseconds.</param>
|
||||
/// <returns>An editor formatted display string.</returns>
|
||||
public static string ToEditorFormattedString(this double milliseconds) =>
|
||||
ToEditorFormattedString(TimeSpan.FromMilliseconds(milliseconds));
|
||||
|
||||
/// <summary>
|
||||
/// Get an editor formatted string (mm:ss:mss)
|
||||
/// </summary>
|
||||
/// <param name="timeSpan">A time value.</param>
|
||||
/// <returns>An editor formatted display string.</returns>
|
||||
public static string ToEditorFormattedString(this TimeSpan timeSpan) =>
|
||||
$"{(timeSpan < TimeSpan.Zero ? "-" : string.Empty)}{(int)timeSpan.TotalMinutes:00}:{timeSpan:ss\\:fff}";
|
||||
|
||||
/// <summary>
|
||||
/// Get a formatted duration (dd:hh:mm:ss with days/hours omitted if zero).
|
||||
/// </summary>
|
||||
/// <param name="milliseconds">A duration in milliseconds.</param>
|
||||
/// <returns>A formatted duration string.</returns>
|
||||
public static LocalisableString ToFormattedDuration(this double milliseconds) =>
|
||||
ToFormattedDuration(TimeSpan.FromMilliseconds(milliseconds));
|
||||
|
||||
/// <summary>
|
||||
/// Get a formatted duration (dd:hh:mm:ss with days/hours omitted if zero).
|
||||
/// </summary>
|
||||
/// <param name="timeSpan">A duration value.</param>
|
||||
/// <returns>A formatted duration string.</returns>
|
||||
public static LocalisableString ToFormattedDuration(this TimeSpan timeSpan)
|
||||
{
|
||||
if (timeSpan.TotalDays >= 1)
|
||||
return new LocalisableFormattableString(timeSpan, @"dd\:hh\:mm\:ss");
|
||||
|
||||
if (timeSpan.TotalHours >= 1)
|
||||
return new LocalisableFormattableString(timeSpan, @"hh\:mm\:ss");
|
||||
|
||||
return new LocalisableFormattableString(timeSpan, @"mm\:ss");
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user