1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-06 07:42:55 +08:00

Merge branch 'master' into fix_progress_bar_info

This commit is contained in:
Dean Herbert 2022-09-09 17:34:13 +09:00 committed by GitHub
commit 27f745b980
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
183 changed files with 2708 additions and 1041 deletions

View File

@ -52,7 +52,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.831.0" /> <PackageReference Include="ppy.osu.Game.Resources" Version="2022.831.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2022.825.0" /> <PackageReference Include="ppy.osu.Framework.Android" Version="2022.908.0" />
</ItemGroup> </ItemGroup>
<ItemGroup Label="Transitive Dependencies"> <ItemGroup Label="Transitive Dependencies">
<!-- Realm needs to be directly referenced in all Xamarin projects, as it will not pull in its transitive dependencies otherwise. --> <!-- Realm needs to be directly referenced in all Xamarin projects, as it will not pull in its transitive dependencies otherwise. -->

View File

@ -0,0 +1,43 @@
// 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 NUnit.Framework;
using osu.Framework.Graphics;
using osu.Framework.Testing;
using osu.Game.Rulesets.Catch.UI;
using osu.Game.Tests.Visual;
namespace osu.Game.Rulesets.Catch.Tests
{
[TestFixture]
public class TestSceneCatchTouchInput : OsuTestScene
{
private CatchTouchInputMapper catchTouchInputMapper = null!;
[SetUpSteps]
public void SetUpSteps()
{
AddStep("create input overlay", () =>
{
Child = new CatchInputManager(new CatchRuleset().RulesetInfo)
{
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
catchTouchInputMapper = new CatchTouchInputMapper
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre
}
}
};
});
}
[Test]
public void TestBasic()
{
AddStep("show overlay", () => catchTouchInputMapper.Show());
}
}
}

View File

@ -4,11 +4,13 @@
#nullable disable #nullable disable
using System.ComponentModel; using System.ComponentModel;
using osu.Framework.Allocation;
using osu.Framework.Input.Bindings; using osu.Framework.Input.Bindings;
using osu.Game.Rulesets.UI; using osu.Game.Rulesets.UI;
namespace osu.Game.Rulesets.Catch namespace osu.Game.Rulesets.Catch
{ {
[Cached]
public class CatchInputManager : RulesetInputManager<CatchAction> public class CatchInputManager : RulesetInputManager<CatchAction>
{ {
public CatchInputManager(RulesetInfo ruleset) public CatchInputManager(RulesetInfo ruleset)

View File

@ -56,7 +56,7 @@ namespace osu.Game.Rulesets.Catch.Edit.Blueprints.Components
public void UpdateFrom(ScrollingHitObjectContainer hitObjectContainer, JuiceStream hitObject) public void UpdateFrom(ScrollingHitObjectContainer hitObjectContainer, JuiceStream hitObject)
{ {
while (path.Vertices.Count < InternalChildren.Count) while (path.Vertices.Count < InternalChildren.Count)
RemoveInternal(InternalChildren[^1]); RemoveInternal(InternalChildren[^1], true);
while (InternalChildren.Count < path.Vertices.Count) while (InternalChildren.Count < path.Vertices.Count)
AddInternal(new VertexPiece()); AddInternal(new VertexPiece());

View File

@ -30,7 +30,7 @@ namespace osu.Game.Rulesets.Catch.Edit.Blueprints.Components
.Where(h => !(h is TinyDroplet))); .Where(h => !(h is TinyDroplet)));
while (nestedHitObjects.Count < InternalChildren.Count) while (nestedHitObjects.Count < InternalChildren.Count)
RemoveInternal(InternalChildren[^1]); RemoveInternal(InternalChildren[^1], true);
while (InternalChildren.Count < nestedHitObjects.Count) while (InternalChildren.Count < nestedHitObjects.Count)
AddInternal(new FruitOutline()); AddInternal(new FruitOutline());

View File

@ -0,0 +1,277 @@
// 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 osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Game.Graphics;
using osuTK;
using osuTK.Input;
namespace osu.Game.Rulesets.Catch.UI
{
public class CatchTouchInputMapper : VisibilityContainer
{
public override bool PropagatePositionalInputSubTree => true;
public override bool PropagateNonPositionalInputSubTree => true;
private readonly Dictionary<object, TouchCatchAction> trackedActionSources = new Dictionary<object, TouchCatchAction>();
private KeyBindingContainer<CatchAction> keyBindingContainer = null!;
private Container mainContent = null!;
private InputArea leftBox = null!;
private InputArea rightBox = null!;
private InputArea leftDashBox = null!;
private InputArea rightDashBox = null!;
[BackgroundDependencyLoader]
private void load(CatchInputManager catchInputManager, OsuColour colours)
{
const float width = 0.15f;
keyBindingContainer = catchInputManager.KeyBindingContainer;
RelativeSizeAxes = Axes.Both;
Children = new Drawable[]
{
mainContent = new Container
{
RelativeSizeAxes = Axes.Both,
Alpha = 0,
Children = new Drawable[]
{
new Container
{
RelativeSizeAxes = Axes.Both,
Width = width,
Children = new Drawable[]
{
leftDashBox = new InputArea(TouchCatchAction.DashLeft, trackedActionSources)
{
RelativeSizeAxes = Axes.Both,
Width = 0.5f,
},
leftBox = new InputArea(TouchCatchAction.MoveLeft, trackedActionSources)
{
RelativeSizeAxes = Axes.Both,
Width = 0.5f,
Colour = colours.Gray9,
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
},
}
},
new Container
{
RelativeSizeAxes = Axes.Both,
Width = width,
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
Children = new Drawable[]
{
rightBox = new InputArea(TouchCatchAction.MoveRight, trackedActionSources)
{
RelativeSizeAxes = Axes.Both,
Width = 0.5f,
Colour = colours.Gray9,
},
rightDashBox = new InputArea(TouchCatchAction.DashRight, trackedActionSources)
{
RelativeSizeAxes = Axes.Both,
Width = 0.5f,
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
},
}
},
},
},
};
}
protected override bool OnKeyDown(KeyDownEvent e)
{
// Hide whenever the keyboard is used.
Hide();
return false;
}
protected override bool OnMouseDown(MouseDownEvent e)
{
return updateAction(e.Button, getTouchCatchActionFromInput(e.ScreenSpaceMousePosition));
}
protected override bool OnTouchDown(TouchDownEvent e)
{
return updateAction(e.Touch.Source, getTouchCatchActionFromInput(e.ScreenSpaceTouch.Position));
}
protected override bool OnMouseMove(MouseMoveEvent e)
{
Show();
TouchCatchAction? action = getTouchCatchActionFromInput(e.ScreenSpaceMousePosition);
// multiple mouse buttons may be pressed and handling the same action.
foreach (MouseButton button in e.PressedButtons)
updateAction(button, action);
return false;
}
protected override void OnTouchMove(TouchMoveEvent e)
{
updateAction(e.Touch.Source, getTouchCatchActionFromInput(e.ScreenSpaceTouch.Position));
base.OnTouchMove(e);
}
protected override void OnMouseUp(MouseUpEvent e)
{
updateAction(e.Button, null);
base.OnMouseUp(e);
}
protected override void OnTouchUp(TouchUpEvent e)
{
updateAction(e.Touch.Source, null);
base.OnTouchUp(e);
}
private bool updateAction(object source, TouchCatchAction? newAction)
{
TouchCatchAction? actionBefore = null;
if (trackedActionSources.TryGetValue(source, out TouchCatchAction found))
actionBefore = found;
if (actionBefore != newAction)
{
if (newAction != null)
trackedActionSources[source] = newAction.Value;
else
trackedActionSources.Remove(source);
updatePressedActions();
}
return newAction != null;
}
private void updatePressedActions()
{
Show();
if (trackedActionSources.ContainsValue(TouchCatchAction.DashLeft) || trackedActionSources.ContainsValue(TouchCatchAction.MoveLeft))
keyBindingContainer.TriggerPressed(CatchAction.MoveLeft);
else
keyBindingContainer.TriggerReleased(CatchAction.MoveLeft);
if (trackedActionSources.ContainsValue(TouchCatchAction.DashRight) || trackedActionSources.ContainsValue(TouchCatchAction.MoveRight))
keyBindingContainer.TriggerPressed(CatchAction.MoveRight);
else
keyBindingContainer.TriggerReleased(CatchAction.MoveRight);
if (trackedActionSources.ContainsValue(TouchCatchAction.DashLeft) || trackedActionSources.ContainsValue(TouchCatchAction.DashRight))
keyBindingContainer.TriggerPressed(CatchAction.Dash);
else
keyBindingContainer.TriggerReleased(CatchAction.Dash);
}
private TouchCatchAction? getTouchCatchActionFromInput(Vector2 screenSpaceInputPosition)
{
if (leftDashBox.Contains(screenSpaceInputPosition))
return TouchCatchAction.DashLeft;
if (rightDashBox.Contains(screenSpaceInputPosition))
return TouchCatchAction.DashRight;
if (leftBox.Contains(screenSpaceInputPosition))
return TouchCatchAction.MoveLeft;
if (rightBox.Contains(screenSpaceInputPosition))
return TouchCatchAction.MoveRight;
return null;
}
protected override void PopIn() => mainContent.FadeIn(300, Easing.OutQuint);
protected override void PopOut() => mainContent.FadeOut(300, Easing.OutQuint);
private class InputArea : CompositeDrawable, IKeyBindingHandler<CatchAction>
{
private readonly TouchCatchAction handledAction;
private readonly Box highlightOverlay;
private readonly IEnumerable<KeyValuePair<object, TouchCatchAction>> trackedActions;
private bool isHighlighted;
public InputArea(TouchCatchAction handledAction, IEnumerable<KeyValuePair<object, TouchCatchAction>> trackedActions)
{
this.handledAction = handledAction;
this.trackedActions = trackedActions;
InternalChildren = new Drawable[]
{
new Container
{
RelativeSizeAxes = Axes.Both,
Masking = true,
CornerRadius = 10,
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Alpha = 0.15f,
},
highlightOverlay = new Box
{
RelativeSizeAxes = Axes.Both,
Alpha = 0,
Blending = BlendingParameters.Additive,
}
}
}
};
}
public bool OnPressed(KeyBindingPressEvent<CatchAction> _)
{
updateHighlight();
return false;
}
public void OnReleased(KeyBindingReleaseEvent<CatchAction> _)
{
updateHighlight();
}
private void updateHighlight()
{
bool isHandling = trackedActions.Any(a => a.Value == handledAction);
if (isHandling == isHighlighted)
return;
isHighlighted = isHandling;
highlightOverlay.FadeTo(isHighlighted ? 0.1f : 0, isHighlighted ? 80 : 400, Easing.OutQuint);
}
}
public enum TouchCatchAction
{
MoveLeft,
MoveRight,
DashLeft,
DashRight,
}
}
}

View File

@ -271,8 +271,8 @@ namespace osu.Game.Rulesets.Catch.UI
SetHyperDashState(); SetHyperDashState();
} }
caughtObjectContainer.RemoveAll(d => d.HitObject == drawableObject.HitObject); caughtObjectContainer.RemoveAll(d => d.HitObject == drawableObject.HitObject, false);
droppedObjectTarget.RemoveAll(d => d.HitObject == drawableObject.HitObject); droppedObjectTarget.RemoveAll(d => d.HitObject == drawableObject.HitObject, false);
} }
/// <summary> /// <summary>
@ -430,7 +430,7 @@ namespace osu.Game.Rulesets.Catch.UI
{ {
var droppedObject = getDroppedObject(caughtObject); var droppedObject = getDroppedObject(caughtObject);
caughtObjectContainer.Remove(caughtObject); caughtObjectContainer.Remove(caughtObject, false);
droppedObjectTarget.Add(droppedObject); droppedObjectTarget.Add(droppedObject);

View File

@ -93,15 +93,15 @@ namespace osu.Game.Rulesets.Catch.UI
switch (entry.Animation) switch (entry.Animation)
{ {
case CatcherTrailAnimation.Dashing: case CatcherTrailAnimation.Dashing:
dashTrails.Remove(drawable); dashTrails.Remove(drawable, false);
break; break;
case CatcherTrailAnimation.HyperDashing: case CatcherTrailAnimation.HyperDashing:
hyperDashTrails.Remove(drawable); hyperDashTrails.Remove(drawable, false);
break; break;
case CatcherTrailAnimation.HyperDashAfterImage: case CatcherTrailAnimation.HyperDashAfterImage:
hyperDashAfterImages.Remove(drawable); hyperDashAfterImages.Remove(drawable, false);
break; break;
} }
} }

View File

@ -4,6 +4,7 @@
#nullable disable #nullable disable
using System.Collections.Generic; using System.Collections.Generic;
using osu.Framework.Allocation;
using osu.Framework.Input; using osu.Framework.Input;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Configuration; using osu.Game.Configuration;
@ -32,6 +33,12 @@ namespace osu.Game.Rulesets.Catch.UI
TimeRange.Value = IBeatmapDifficultyInfo.DifficultyRange(beatmap.Difficulty.ApproachRate, 1800, 1200, 450); TimeRange.Value = IBeatmapDifficultyInfo.DifficultyRange(beatmap.Difficulty.ApproachRate, 1800, 1200, 450);
} }
[BackgroundDependencyLoader]
private void load()
{
KeyBindingInputManager.Add(new CatchTouchInputMapper());
}
protected override ReplayInputHandler CreateReplayInputHandler(Replay replay) => new CatchFramedReplayInputHandler(replay); protected override ReplayInputHandler CreateReplayInputHandler(Replay replay) => new CatchFramedReplayInputHandler(replay);
protected override ReplayRecorder CreateReplayRecorder(Score score) => new CatchReplayRecorder(score, (CatchPlayfield)Playfield); protected override ReplayRecorder CreateReplayRecorder(Score score) => new CatchReplayRecorder(score, (CatchPlayfield)Playfield);

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System; using System;
using osu.Framework.Configuration.Tracking; using osu.Framework.Configuration.Tracking;
using osu.Game.Configuration; using osu.Game.Configuration;
@ -33,7 +31,7 @@ namespace osu.Game.Rulesets.Mania.Configuration
scrollTime => new SettingDescription( scrollTime => new SettingDescription(
rawValue: scrollTime, rawValue: scrollTime,
name: "Scroll Speed", name: "Scroll Speed",
value: $"{(int)Math.Round(DrawableManiaRuleset.MAX_TIME_RANGE / scrollTime)} ({scrollTime}ms)" value: $"{scrollTime}ms (speed {(int)Math.Round(DrawableManiaRuleset.MAX_TIME_RANGE / scrollTime)})"
) )
) )
}; };

View File

@ -1,8 +1,7 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable using System;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Localisation; using osu.Framework.Localisation;
@ -34,7 +33,7 @@ namespace osu.Game.Rulesets.Mania
LabelText = "Scrolling direction", LabelText = "Scrolling direction",
Current = config.GetBindable<ManiaScrollingDirection>(ManiaRulesetSetting.ScrollDirection) Current = config.GetBindable<ManiaScrollingDirection>(ManiaRulesetSetting.ScrollDirection)
}, },
new SettingsSlider<double, TimeSlider> new SettingsSlider<double, ManiaScrollSlider>
{ {
LabelText = "Scroll speed", LabelText = "Scroll speed",
Current = config.GetBindable<double>(ManiaRulesetSetting.ScrollTime), Current = config.GetBindable<double>(ManiaRulesetSetting.ScrollTime),
@ -47,5 +46,10 @@ namespace osu.Game.Rulesets.Mania
} }
}; };
} }
private class ManiaScrollSlider : OsuSliderBar<double>
{
public override LocalisableString TooltipText => $"{Current.Value}ms (speed {(int)Math.Round(DrawableManiaRuleset.MAX_TIME_RANGE / Current.Value)})";
}
} }
} }

View File

@ -31,7 +31,7 @@ namespace osu.Game.Rulesets.Mania.Mods
HitObjectContainer hoc = column.HitObjectArea.HitObjectContainer; HitObjectContainer hoc = column.HitObjectArea.HitObjectContainer;
Container hocParent = (Container)hoc.Parent; Container hocParent = (Container)hoc.Parent;
hocParent.Remove(hoc); hocParent.Remove(hoc, false);
hocParent.Add(new PlayfieldCoveringWrapper(hoc).With(c => hocParent.Add(new PlayfieldCoveringWrapper(hoc).With(c =>
{ {
c.RelativeSizeAxes = Axes.Both; c.RelativeSizeAxes = Axes.Both;

View File

@ -155,7 +155,7 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
else else
{ {
lightContainer.FadeOut(120) lightContainer.FadeOut(120)
.OnComplete(d => Column.TopLevelContainer.Remove(d)); .OnComplete(d => Column.TopLevelContainer.Remove(d, false));
} }
} }

View File

@ -195,7 +195,7 @@ namespace osu.Game.Rulesets.Osu.Tests
{ {
var drawableObject = getFunc.Invoke(); var drawableObject = getFunc.Invoke();
hitObjectContainer.Remove(drawableObject); hitObjectContainer.Remove(drawableObject, false);
followPointRenderer.RemoveFollowPoints(drawableObject.HitObject); followPointRenderer.RemoveFollowPoints(drawableObject.HitObject);
}); });
} }
@ -212,7 +212,7 @@ namespace osu.Game.Rulesets.Osu.Tests
else else
targetTime = getObject(hitObjectContainer.Count - 1).HitObject.StartTime + 1; targetTime = getObject(hitObjectContainer.Count - 1).HitObject.StartTime + 1;
hitObjectContainer.Remove(toReorder); hitObjectContainer.Remove(toReorder, false);
toReorder.HitObject.StartTime = targetTime; toReorder.HitObject.StartTime = targetTime;
hitObjectContainer.Add(toReorder); hitObjectContainer.Add(toReorder);
}); });

View File

@ -89,6 +89,10 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
HitObject.DifficultyControlPoint = nearestDifficultyPoint ?? new DifficultyControlPoint(); HitObject.DifficultyControlPoint = nearestDifficultyPoint ?? new DifficultyControlPoint();
HitObject.Position = ToLocalSpace(result.ScreenSpacePosition); HitObject.Position = ToLocalSpace(result.ScreenSpacePosition);
// Replacing the DifficultyControlPoint above doesn't trigger any kind of invalidation.
// Without re-applying defaults, velocity won't be updated.
ApplyDefaultsToHitObject();
break; break;
case SliderPlacementState.Body: case SliderPlacementState.Body:

View File

@ -362,10 +362,12 @@ namespace osu.Game.Rulesets.Osu.Mods
{ {
return breaks.Any(breakPeriod => return breaks.Any(breakPeriod =>
{ {
var firstObjAfterBreak = originalHitObjects.First(obj => almostBigger(obj.StartTime, breakPeriod.EndTime)); OsuHitObject? firstObjAfterBreak = originalHitObjects.FirstOrDefault(obj => almostBigger(obj.StartTime, breakPeriod.EndTime));
return almostBigger(time, breakPeriod.StartTime) return almostBigger(time, breakPeriod.StartTime)
&& definitelyBigger(firstObjAfterBreak.StartTime, time); // There should never really be a break section with no objects after it, but we've seen crashes from users with malformed beatmaps,
// so it's best to guard against this.
&& (firstObjAfterBreak == null || definitelyBigger(firstObjAfterBreak.StartTime, time));
}); });
} }

View File

@ -77,7 +77,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
// This is a bit ugly but we don't have the concept of InternalContent so it'll have to do for now. (https://github.com/ppy/osu-framework/issues/1690) // This is a bit ugly but we don't have the concept of InternalContent so it'll have to do for now. (https://github.com/ppy/osu-framework/issues/1690)
protected override void AddInternal(Drawable drawable) => shakeContainer.Add(drawable); protected override void AddInternal(Drawable drawable) => shakeContainer.Add(drawable);
protected override void ClearInternal(bool disposeChildren = true) => shakeContainer.Clear(disposeChildren); protected override void ClearInternal(bool disposeChildren = true) => shakeContainer.Clear(disposeChildren);
protected override bool RemoveInternal(Drawable drawable) => shakeContainer.Remove(drawable); protected override bool RemoveInternal(Drawable drawable, bool disposeImmediately) => shakeContainer.Remove(drawable, disposeImmediately);
protected sealed override double InitialLifetimeOffset => HitObject.TimePreempt; protected sealed override double InitialLifetimeOffset => HitObject.TimePreempt;

View File

@ -110,7 +110,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default
currentRotation += angle; currentRotation += angle;
// rate has to be applied each frame, because it's not guaranteed to be constant throughout playback // rate has to be applied each frame, because it's not guaranteed to be constant throughout playback
// (see: ModTimeRamp) // (see: ModTimeRamp)
drawableSpinner.Result.RateAdjustedRotation += (float)(Math.Abs(angle) * (gameplayClock?.TrueGameplayRate ?? Clock.Rate)); drawableSpinner.Result.RateAdjustedRotation += (float)(Math.Abs(angle) * (gameplayClock?.GetTrueGameplayRate() ?? Clock.Rate));
} }
private void resetState(DrawableHitObject obj) private void resetState(DrawableHitObject obj)

View File

@ -0,0 +1,96 @@
// 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.Extensions.TypeExtensions;
using osu.Framework.Screens;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Replays;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Replays;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Taiko.Objects;
using osu.Game.Scoring;
using osu.Game.Screens.Play;
using osu.Game.Tests.Visual;
namespace osu.Game.Rulesets.Taiko.Tests.Judgements
{
public class JudgementTest : RateAdjustedBeatmapTestScene
{
private ScoreAccessibleReplayPlayer currentPlayer = null!;
protected List<JudgementResult> JudgementResults { get; private set; } = null!;
protected void AssertJudgementCount(int count)
{
AddAssert($"{count} judgement{(count > 0 ? "s" : "")}", () => JudgementResults, () => Has.Count.EqualTo(count));
}
protected void AssertResult<T>(int index, HitResult expectedResult)
{
AddAssert($"{typeof(T).ReadableName()} ({index}) judged as {expectedResult}",
() => JudgementResults.Where(j => j.HitObject is T).OrderBy(j => j.HitObject.StartTime).ElementAt(index).Type,
() => Is.EqualTo(expectedResult));
}
protected void PerformTest(List<ReplayFrame> frames, Beatmap<TaikoHitObject>? beatmap = null)
{
AddStep("load player", () =>
{
Beatmap.Value = CreateWorkingBeatmap(beatmap);
var p = new ScoreAccessibleReplayPlayer(new Score { Replay = new Replay { Frames = frames } });
p.OnLoadComplete += _ =>
{
p.ScoreProcessor.NewJudgement += result =>
{
if (currentPlayer == p) JudgementResults.Add(result);
};
};
LoadScreen(currentPlayer = p);
JudgementResults = new List<JudgementResult>();
});
AddUntilStep("Beatmap at 0", () => Beatmap.Value.Track.CurrentTime == 0);
AddUntilStep("Wait until player is loaded", () => currentPlayer.IsCurrentScreen());
AddUntilStep("Wait for completion", () => currentPlayer.ScoreProcessor.HasCompleted.Value);
}
protected Beatmap<TaikoHitObject> CreateBeatmap(params TaikoHitObject[] hitObjects)
{
var beatmap = new Beatmap<TaikoHitObject>
{
HitObjects = hitObjects.ToList(),
BeatmapInfo =
{
Difficulty = new BeatmapDifficulty { SliderTickRate = 4 },
Ruleset = new TaikoRuleset().RulesetInfo
},
};
beatmap.ControlPointInfo.Add(0, new EffectControlPoint { ScrollSpeed = 0.1f });
return beatmap;
}
private class ScoreAccessibleReplayPlayer : ReplayPlayer
{
public new ScoreProcessor ScoreProcessor => base.ScoreProcessor;
protected override bool PauseOnFocusLost => false;
public ScoreAccessibleReplayPlayer(Score score)
: base(score, new PlayerConfiguration
{
AllowPause = false,
ShowResults = false,
})
{
}
}
}
}

View File

@ -0,0 +1,201 @@
// 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.Game.Rulesets.Replays;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Taiko.Objects;
using osu.Game.Rulesets.Taiko.Replays;
namespace osu.Game.Rulesets.Taiko.Tests.Judgements
{
public class TestSceneDrumRollJudgements : JudgementTest
{
[Test]
public void TestHitAllDrumRoll()
{
const double hit_time = 1000;
PerformTest(new List<ReplayFrame>
{
new TaikoReplayFrame(0),
new TaikoReplayFrame(1000, TaikoAction.LeftCentre),
new TaikoReplayFrame(1001),
new TaikoReplayFrame(2000, TaikoAction.LeftCentre),
new TaikoReplayFrame(2001),
}, CreateBeatmap(new DrumRoll
{
StartTime = hit_time,
Duration = 1000
}));
AssertJudgementCount(3);
AssertResult<DrumRollTick>(0, HitResult.SmallBonus);
AssertResult<DrumRollTick>(1, HitResult.SmallBonus);
AssertResult<DrumRoll>(0, HitResult.IgnoreHit);
}
[Test]
public void TestHitSomeDrumRoll()
{
const double hit_time = 1000;
PerformTest(new List<ReplayFrame>
{
new TaikoReplayFrame(0),
new TaikoReplayFrame(2000, TaikoAction.LeftCentre),
new TaikoReplayFrame(2001),
}, CreateBeatmap(new DrumRoll
{
StartTime = hit_time,
Duration = 1000
}));
AssertJudgementCount(3);
AssertResult<DrumRollTick>(0, HitResult.IgnoreMiss);
AssertResult<DrumRollTick>(1, HitResult.SmallBonus);
AssertResult<DrumRoll>(0, HitResult.IgnoreHit);
}
[Test]
public void TestHitNoneDrumRoll()
{
const double hit_time = 1000;
PerformTest(new List<ReplayFrame>
{
new TaikoReplayFrame(0),
}, CreateBeatmap(new DrumRoll
{
StartTime = hit_time,
Duration = 1000
}));
AssertJudgementCount(3);
AssertResult<DrumRollTick>(0, HitResult.IgnoreMiss);
AssertResult<DrumRollTick>(1, HitResult.IgnoreMiss);
AssertResult<DrumRoll>(0, HitResult.IgnoreHit);
}
[Test]
public void TestHitAllStrongDrumRollWithOneKey()
{
const double hit_time = 1000;
PerformTest(new List<ReplayFrame>
{
new TaikoReplayFrame(0),
new TaikoReplayFrame(1000, TaikoAction.LeftCentre),
new TaikoReplayFrame(1001),
new TaikoReplayFrame(2000, TaikoAction.LeftCentre),
new TaikoReplayFrame(2001),
}, CreateBeatmap(new DrumRoll
{
StartTime = hit_time,
Duration = 1000,
IsStrong = true
}));
AssertJudgementCount(6);
AssertResult<DrumRollTick>(0, HitResult.SmallBonus);
AssertResult<StrongNestedHitObject>(0, HitResult.LargeBonus);
AssertResult<DrumRollTick>(1, HitResult.SmallBonus);
AssertResult<StrongNestedHitObject>(1, HitResult.LargeBonus);
AssertResult<DrumRoll>(0, HitResult.IgnoreHit);
AssertResult<StrongNestedHitObject>(2, HitResult.IgnoreHit);
}
[Test]
public void TestHitSomeStrongDrumRollWithOneKey()
{
const double hit_time = 1000;
PerformTest(new List<ReplayFrame>
{
new TaikoReplayFrame(0),
new TaikoReplayFrame(2000, TaikoAction.LeftCentre),
new TaikoReplayFrame(2001),
}, CreateBeatmap(new DrumRoll
{
StartTime = hit_time,
Duration = 1000,
IsStrong = true
}));
AssertJudgementCount(6);
AssertResult<DrumRollTick>(0, HitResult.IgnoreMiss);
AssertResult<StrongNestedHitObject>(0, HitResult.IgnoreMiss);
AssertResult<DrumRollTick>(1, HitResult.SmallBonus);
AssertResult<StrongNestedHitObject>(1, HitResult.LargeBonus);
AssertResult<DrumRoll>(0, HitResult.IgnoreHit);
AssertResult<StrongNestedHitObject>(2, HitResult.IgnoreHit);
}
[Test]
public void TestHitAllStrongDrumRollWithBothKeys()
{
const double hit_time = 1000;
PerformTest(new List<ReplayFrame>
{
new TaikoReplayFrame(0),
new TaikoReplayFrame(1000, TaikoAction.LeftCentre, TaikoAction.RightCentre),
new TaikoReplayFrame(1001),
new TaikoReplayFrame(2000, TaikoAction.LeftCentre, TaikoAction.RightCentre),
new TaikoReplayFrame(2001),
}, CreateBeatmap(new DrumRoll
{
StartTime = hit_time,
Duration = 1000,
IsStrong = true
}));
AssertJudgementCount(6);
AssertResult<DrumRollTick>(0, HitResult.SmallBonus);
AssertResult<StrongNestedHitObject>(0, HitResult.LargeBonus);
AssertResult<DrumRollTick>(1, HitResult.SmallBonus);
AssertResult<StrongNestedHitObject>(1, HitResult.LargeBonus);
AssertResult<DrumRoll>(0, HitResult.IgnoreHit);
AssertResult<StrongNestedHitObject>(2, HitResult.IgnoreHit);
}
[Test]
public void TestHitSomeStrongDrumRollWithBothKeys()
{
const double hit_time = 1000;
PerformTest(new List<ReplayFrame>
{
new TaikoReplayFrame(0),
new TaikoReplayFrame(2000, TaikoAction.LeftCentre, TaikoAction.RightCentre),
new TaikoReplayFrame(2001),
}, CreateBeatmap(new DrumRoll
{
StartTime = hit_time,
Duration = 1000,
IsStrong = true
}));
AssertJudgementCount(6);
AssertResult<DrumRollTick>(0, HitResult.IgnoreMiss);
AssertResult<StrongNestedHitObject>(0, HitResult.IgnoreMiss);
AssertResult<DrumRollTick>(1, HitResult.SmallBonus);
AssertResult<StrongNestedHitObject>(1, HitResult.LargeBonus);
AssertResult<DrumRoll>(0, HitResult.IgnoreHit);
AssertResult<StrongNestedHitObject>(2, HitResult.IgnoreHit);
}
}
}

View File

@ -0,0 +1,133 @@
// 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.Game.Rulesets.Replays;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Taiko.Objects;
using osu.Game.Rulesets.Taiko.Replays;
namespace osu.Game.Rulesets.Taiko.Tests.Judgements
{
public class TestSceneHitJudgements : JudgementTest
{
[Test]
public void TestHitCentreHit()
{
const double hit_time = 1000;
PerformTest(new List<ReplayFrame>
{
new TaikoReplayFrame(0),
new TaikoReplayFrame(hit_time, TaikoAction.LeftCentre),
}, CreateBeatmap(new Hit
{
Type = HitType.Centre,
StartTime = hit_time
}));
AssertJudgementCount(1);
AssertResult<Hit>(0, HitResult.Great);
}
[Test]
public void TestHitRimHit()
{
const double hit_time = 1000;
PerformTest(new List<ReplayFrame>
{
new TaikoReplayFrame(0),
new TaikoReplayFrame(hit_time, TaikoAction.LeftRim),
}, CreateBeatmap(new Hit
{
Type = HitType.Rim,
StartTime = hit_time
}));
AssertJudgementCount(1);
AssertResult<Hit>(0, HitResult.Great);
}
[Test]
public void TestMissHit()
{
const double hit_time = 1000;
PerformTest(new List<ReplayFrame>
{
new TaikoReplayFrame(0)
}, CreateBeatmap(new Hit
{
Type = HitType.Centre,
StartTime = hit_time
}));
AssertJudgementCount(1);
AssertResult<Hit>(0, HitResult.Miss);
}
[Test]
public void TestHitStrongHitWithOneKey()
{
const double hit_time = 1000;
PerformTest(new List<ReplayFrame>
{
new TaikoReplayFrame(0),
new TaikoReplayFrame(hit_time, TaikoAction.LeftCentre),
}, CreateBeatmap(new Hit
{
Type = HitType.Centre,
StartTime = hit_time,
IsStrong = true
}));
AssertJudgementCount(2);
AssertResult<Hit>(0, HitResult.Great);
AssertResult<StrongNestedHitObject>(0, HitResult.IgnoreMiss);
}
[Test]
public void TestHitStrongHitWithBothKeys()
{
const double hit_time = 1000;
PerformTest(new List<ReplayFrame>
{
new TaikoReplayFrame(0),
new TaikoReplayFrame(hit_time, TaikoAction.LeftCentre, TaikoAction.RightCentre),
}, CreateBeatmap(new Hit
{
Type = HitType.Centre,
StartTime = hit_time,
IsStrong = true
}));
AssertJudgementCount(2);
AssertResult<Hit>(0, HitResult.Great);
AssertResult<StrongNestedHitObject>(0, HitResult.LargeBonus);
}
[Test]
public void TestMissStrongHit()
{
const double hit_time = 1000;
PerformTest(new List<ReplayFrame>
{
new TaikoReplayFrame(0),
}, CreateBeatmap(new Hit
{
Type = HitType.Centre,
StartTime = hit_time,
IsStrong = true
}));
AssertJudgementCount(2);
AssertResult<Hit>(0, HitResult.Miss);
AssertResult<StrongNestedHitObject>(0, HitResult.IgnoreMiss);
}
}
}

View File

@ -0,0 +1,118 @@
// 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.Game.Rulesets.Replays;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Taiko.Objects;
using osu.Game.Rulesets.Taiko.Replays;
namespace osu.Game.Rulesets.Taiko.Tests.Judgements
{
public class TestSceneSwellJudgements : JudgementTest
{
[Test]
public void TestHitAllSwell()
{
const double hit_time = 1000;
Swell swell = new Swell
{
StartTime = hit_time,
Duration = 1000,
RequiredHits = 10
};
List<ReplayFrame> frames = new List<ReplayFrame>
{
new TaikoReplayFrame(0),
new TaikoReplayFrame(2001),
};
for (int i = 0; i < swell.RequiredHits; i++)
{
double frameTime = 1000 + i * 50;
frames.Add(new TaikoReplayFrame(frameTime, i % 2 == 0 ? TaikoAction.LeftCentre : TaikoAction.LeftRim));
frames.Add(new TaikoReplayFrame(frameTime + 10));
}
PerformTest(frames, CreateBeatmap(swell));
AssertJudgementCount(11);
for (int i = 0; i < swell.RequiredHits; i++)
AssertResult<SwellTick>(i, HitResult.IgnoreHit);
AssertResult<Swell>(0, HitResult.LargeBonus);
}
[Test]
public void TestHitSomeSwell()
{
const double hit_time = 1000;
Swell swell = new Swell
{
StartTime = hit_time,
Duration = 1000,
RequiredHits = 10
};
List<ReplayFrame> frames = new List<ReplayFrame>
{
new TaikoReplayFrame(0),
new TaikoReplayFrame(2001),
};
for (int i = 0; i < swell.RequiredHits / 2; i++)
{
double frameTime = 1000 + i * 50;
frames.Add(new TaikoReplayFrame(frameTime, i % 2 == 0 ? TaikoAction.LeftCentre : TaikoAction.LeftRim));
frames.Add(new TaikoReplayFrame(frameTime + 10));
}
PerformTest(frames, CreateBeatmap(swell));
AssertJudgementCount(11);
for (int i = 0; i < swell.RequiredHits / 2; i++)
AssertResult<SwellTick>(i, HitResult.IgnoreHit);
for (int i = swell.RequiredHits / 2; i < swell.RequiredHits; i++)
AssertResult<SwellTick>(i, HitResult.IgnoreMiss);
AssertResult<Swell>(0, HitResult.IgnoreMiss);
}
[Test]
public void TestHitNoneSwell()
{
const double hit_time = 1000;
Swell swell = new Swell
{
StartTime = hit_time,
Duration = 1000,
RequiredHits = 10
};
List<ReplayFrame> frames = new List<ReplayFrame>
{
new TaikoReplayFrame(0),
new TaikoReplayFrame(2001),
};
PerformTest(frames, CreateBeatmap(swell));
AssertJudgementCount(11);
for (int i = 0; i < swell.RequiredHits; i++)
AssertResult<SwellTick>(i, HitResult.IgnoreMiss);
AssertResult<Swell>(0, HitResult.IgnoreMiss);
AddAssert("all tick offsets are 0", () => JudgementResults.Where(r => r.HitObject is SwellTick).All(r => r.TimeOffset == 0));
}
}
}

View File

@ -25,11 +25,11 @@ namespace osu.Game.Rulesets.Taiko.Tests.Mods
[TestCase(false)] [TestCase(false)]
[TestCase(true)] [TestCase(true)]
public void TestDrumRoll(bool shouldMiss) => CreateHitObjectTest(new HitObjectTestData(new DrumRoll { StartTime = 1000, EndTime = 3000 }), shouldMiss); public void TestDrumRoll(bool shouldMiss) => CreateHitObjectTest(new HitObjectTestData(new DrumRoll { StartTime = 1000, EndTime = 3000 }, false), shouldMiss);
[TestCase(false)] [TestCase(false)]
[TestCase(true)] [TestCase(true)]
public void TestSwell(bool shouldMiss) => CreateHitObjectTest(new HitObjectTestData(new Swell { StartTime = 1000, EndTime = 3000 }), shouldMiss); public void TestSwell(bool shouldMiss) => CreateHitObjectTest(new HitObjectTestData(new Swell { StartTime = 1000, EndTime = 3000 }, false), shouldMiss);
private class TestTaikoRuleset : TaikoRuleset private class TestTaikoRuleset : TaikoRuleset
{ {

View File

@ -112,7 +112,6 @@ namespace osu.Game.Rulesets.Taiko.Tests.Skinning
assertStateAfterResult(new JudgementResult(new Hit(), new TaikoJudgement()) { Type = HitResult.Great }, TaikoMascotAnimationState.Idle); assertStateAfterResult(new JudgementResult(new Hit(), new TaikoJudgement()) { Type = HitResult.Great }, TaikoMascotAnimationState.Idle);
assertStateAfterResult(new JudgementResult(new Hit(), new TaikoJudgement()) { Type = HitResult.Miss }, TaikoMascotAnimationState.Fail); assertStateAfterResult(new JudgementResult(new Hit(), new TaikoJudgement()) { Type = HitResult.Miss }, TaikoMascotAnimationState.Fail);
assertStateAfterResult(new JudgementResult(new DrumRoll(), new TaikoDrumRollJudgement()) { Type = HitResult.Great }, TaikoMascotAnimationState.Idle);
assertStateAfterResult(new JudgementResult(new Hit(), new TaikoJudgement()) { Type = HitResult.Ok }, TaikoMascotAnimationState.Idle); assertStateAfterResult(new JudgementResult(new Hit(), new TaikoJudgement()) { Type = HitResult.Ok }, TaikoMascotAnimationState.Idle);
} }

View File

@ -1,38 +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.
#nullable disable
using System.Linq;
using NUnit.Framework;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Taiko.Objects;
namespace osu.Game.Rulesets.Taiko.Tests
{
public class TestSceneDrumRollJudgements : TestSceneTaikoPlayer
{
[Test]
public void TestStrongDrumRollFullyJudgedOnKilled()
{
AddUntilStep("gameplay finished", () => Player.ScoreProcessor.HasCompleted.Value);
AddAssert("all judgements are misses", () => Player.Results.All(r => r.Type == r.Judgement.MinResult));
}
protected override bool Autoplay => false;
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset) => new Beatmap<TaikoHitObject>
{
BeatmapInfo = { Ruleset = new TaikoRuleset().RulesetInfo },
HitObjects =
{
new DrumRoll
{
StartTime = 1000,
Duration = 1000,
IsStrong = true
}
}
};
}
}

View File

@ -1,42 +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.
#nullable disable
using System.Linq;
using NUnit.Framework;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Taiko.Objects;
namespace osu.Game.Rulesets.Taiko.Tests
{
public class TestSceneSwellJudgements : TestSceneTaikoPlayer
{
[Test]
public void TestZeroTickTimeOffsets()
{
AddUntilStep("gameplay finished", () => Player.ScoreProcessor.HasCompleted.Value);
AddAssert("all tick offsets are 0", () => Player.Results.Where(r => r.HitObject is SwellTick).All(r => r.TimeOffset == 0));
}
protected override bool Autoplay => true;
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset)
{
var beatmap = new Beatmap<TaikoHitObject>
{
BeatmapInfo = { Ruleset = new TaikoRuleset().RulesetInfo },
HitObjects =
{
new Swell
{
StartTime = 1000,
Duration = 1000,
}
}
};
return beatmap;
}
}
}

View File

@ -38,7 +38,7 @@ namespace osu.Game.Rulesets.Taiko.Tests
}; };
[Test] [Test]
public void TestSpinnerDoesFail() public void TestSwellDoesNotFail()
{ {
bool judged = false; bool judged = false;
AddStep("Setup judgements", () => AddStep("Setup judgements", () =>
@ -47,7 +47,7 @@ namespace osu.Game.Rulesets.Taiko.Tests
Player.ScoreProcessor.NewJudgement += _ => judged = true; Player.ScoreProcessor.NewJudgement += _ => judged = true;
}); });
AddUntilStep("swell judged", () => judged); AddUntilStep("swell judged", () => judged);
AddAssert("failed", () => Player.GameplayState.HasFailed); AddAssert("not failed", () => !Player.GameplayState.HasFailed);
} }
} }
} }

View File

@ -1,25 +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.
#nullable disable
using osu.Game.Rulesets.Scoring;
namespace osu.Game.Rulesets.Taiko.Judgements
{
public class TaikoDrumRollJudgement : TaikoJudgement
{
protected override double HealthIncreaseFor(HitResult result)
{
// Drum rolls can be ignored with no health penalty
switch (result)
{
case HitResult.Miss:
return 0;
default:
return base.HealthIncreaseFor(result);
}
}
}
}

View File

@ -9,18 +9,8 @@ namespace osu.Game.Rulesets.Taiko.Judgements
{ {
public class TaikoDrumRollTickJudgement : TaikoJudgement public class TaikoDrumRollTickJudgement : TaikoJudgement
{ {
public override HitResult MaxResult => HitResult.SmallTickHit; public override HitResult MaxResult => HitResult.SmallBonus;
protected override double HealthIncreaseFor(HitResult result) protected override double HealthIncreaseFor(HitResult result) => 0;
{
switch (result)
{
case HitResult.SmallTickHit:
return 0.15;
default:
return 0;
}
}
} }
} }

View File

@ -9,7 +9,7 @@ namespace osu.Game.Rulesets.Taiko.Judgements
{ {
public class TaikoStrongJudgement : TaikoJudgement public class TaikoStrongJudgement : TaikoJudgement
{ {
public override HitResult MaxResult => HitResult.SmallBonus; public override HitResult MaxResult => HitResult.LargeBonus;
// MainObject already changes the HP // MainObject already changes the HP
protected override double HealthIncreaseFor(HitResult result) => 0; protected override double HealthIncreaseFor(HitResult result) => 0;

View File

@ -9,11 +9,13 @@ namespace osu.Game.Rulesets.Taiko.Judgements
{ {
public class TaikoSwellJudgement : TaikoJudgement public class TaikoSwellJudgement : TaikoJudgement
{ {
public override HitResult MaxResult => HitResult.LargeBonus;
protected override double HealthIncreaseFor(HitResult result) protected override double HealthIncreaseFor(HitResult result)
{ {
switch (result) switch (result)
{ {
case HitResult.Miss: case HitResult.IgnoreMiss:
return -0.65; return -0.65;
default: default:

View File

@ -4,7 +4,6 @@
#nullable disable #nullable disable
using System; using System;
using System.Linq;
using JetBrains.Annotations; using JetBrains.Annotations;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Utils; using osu.Framework.Utils;
@ -17,7 +16,6 @@ using osu.Framework.Graphics.Primitives;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Taiko.Skinning.Default; using osu.Game.Rulesets.Taiko.Skinning.Default;
using osu.Game.Skinning; using osu.Game.Skinning;
using osuTK; using osuTK;
@ -43,6 +41,8 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
private Color4 colourIdle; private Color4 colourIdle;
private Color4 colourEngaged; private Color4 colourEngaged;
public override bool DisplayResult => false;
public DrawableDrumRoll() public DrawableDrumRoll()
: this(null) : this(null)
{ {
@ -143,14 +143,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
if (timeOffset < 0) if (timeOffset < 0)
return; return;
int countHit = NestedHitObjects.Count(o => o.IsHit); ApplyResult(r => r.Type = r.Judgement.MaxResult);
if (countHit >= HitObject.RequiredGoodHits)
{
ApplyResult(r => r.Type = countHit >= HitObject.RequiredGreatHits ? HitResult.Great : HitResult.Ok);
}
else
ApplyResult(r => r.Type = r.Judgement.MinResult);
} }
protected override void UpdateHitStateTransforms(ArmedState state) protected override void UpdateHitStateTransforms(ArmedState state)

View File

@ -16,7 +16,6 @@ using osuTK.Graphics;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Taiko.Skinning.Default; using osu.Game.Rulesets.Taiko.Skinning.Default;
using osu.Game.Skinning; using osu.Game.Skinning;
@ -39,6 +38,8 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
private readonly CircularContainer targetRing; private readonly CircularContainer targetRing;
private readonly CircularContainer expandingRing; private readonly CircularContainer expandingRing;
public override bool DisplayResult => false;
public DrawableSwell() public DrawableSwell()
: this(null) : this(null)
{ {
@ -201,7 +202,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
expandingRing.ScaleTo(1f + Math.Min(target_ring_scale - 1f, (target_ring_scale - 1f) * completion * 1.3f), 260, Easing.OutQuint); expandingRing.ScaleTo(1f + Math.Min(target_ring_scale - 1f, (target_ring_scale - 1f) * completion * 1.3f), 260, Easing.OutQuint);
if (numHits == HitObject.RequiredHits) if (numHits == HitObject.RequiredHits)
ApplyResult(r => r.Type = HitResult.Great); ApplyResult(r => r.Type = r.Judgement.MaxResult);
} }
else else
{ {
@ -222,7 +223,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
tick.TriggerResult(false); tick.TriggerResult(false);
} }
ApplyResult(r => r.Type = numHits > HitObject.RequiredHits / 2 ? HitResult.Ok : r.Judgement.MinResult); ApplyResult(r => r.Type = numHits == HitObject.RequiredHits ? r.Judgement.MaxResult : r.Judgement.MinResult);
} }
} }

View File

@ -56,7 +56,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
isProxied = true; isProxied = true;
nonProxiedContent.Remove(Content); nonProxiedContent.Remove(Content, false);
proxiedContent.Add(Content); proxiedContent.Add(Content);
} }
@ -70,7 +70,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
isProxied = false; isProxied = false;
proxiedContent.Remove(Content); proxiedContent.Remove(Content, false);
nonProxiedContent.Add(Content); nonProxiedContent.Add(Content);
} }
@ -141,7 +141,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
Size = BaseSize = new Vector2(TaikoHitObject.DEFAULT_SIZE); Size = BaseSize = new Vector2(TaikoHitObject.DEFAULT_SIZE);
if (MainPiece != null) if (MainPiece != null)
Content.Remove(MainPiece); Content.Remove(MainPiece, true);
Content.Add(MainPiece = CreateMainPiece()); Content.Add(MainPiece = CreateMainPiece());
} }

View File

@ -4,7 +4,6 @@
#nullable disable #nullable disable
using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Objects.Types;
using System;
using System.Threading; using System.Threading;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints; using osu.Game.Beatmaps.ControlPoints;
@ -12,7 +11,6 @@ using osu.Game.Beatmaps.Formats;
using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Taiko.Judgements;
using osuTK; using osuTK;
namespace osu.Game.Rulesets.Taiko.Objects namespace osu.Game.Rulesets.Taiko.Objects
@ -42,24 +40,12 @@ namespace osu.Game.Rulesets.Taiko.Objects
/// </summary> /// </summary>
public int TickRate = 1; public int TickRate = 1;
/// <summary>
/// Number of drum roll ticks required for a "Good" hit.
/// </summary>
public double RequiredGoodHits { get; protected set; }
/// <summary>
/// Number of drum roll ticks required for a "Great" hit.
/// </summary>
public double RequiredGreatHits { get; protected set; }
/// <summary> /// <summary>
/// The length (in milliseconds) between ticks of this drumroll. /// The length (in milliseconds) between ticks of this drumroll.
/// <para>Half of this value is the hit window of the ticks.</para> /// <para>Half of this value is the hit window of the ticks.</para>
/// </summary> /// </summary>
private double tickSpacing = 100; private double tickSpacing = 100;
private float overallDifficulty = BeatmapDifficulty.DEFAULT_DIFFICULTY;
protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, IBeatmapDifficultyInfo difficulty) protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, IBeatmapDifficultyInfo difficulty)
{ {
base.ApplyDefaultsToSelf(controlPointInfo, difficulty); base.ApplyDefaultsToSelf(controlPointInfo, difficulty);
@ -70,16 +56,12 @@ namespace osu.Game.Rulesets.Taiko.Objects
Velocity = scoringDistance / timingPoint.BeatLength; Velocity = scoringDistance / timingPoint.BeatLength;
tickSpacing = timingPoint.BeatLength / TickRate; tickSpacing = timingPoint.BeatLength / TickRate;
overallDifficulty = difficulty.OverallDifficulty;
} }
protected override void CreateNestedHitObjects(CancellationToken cancellationToken) protected override void CreateNestedHitObjects(CancellationToken cancellationToken)
{ {
createTicks(cancellationToken); createTicks(cancellationToken);
RequiredGoodHits = NestedHitObjects.Count * Math.Min(0.15, 0.05 + 0.10 / 6 * overallDifficulty);
RequiredGreatHits = NestedHitObjects.Count * Math.Min(0.30, 0.10 + 0.20 / 6 * overallDifficulty);
base.CreateNestedHitObjects(cancellationToken); base.CreateNestedHitObjects(cancellationToken);
} }
@ -106,7 +88,7 @@ namespace osu.Game.Rulesets.Taiko.Objects
} }
} }
public override Judgement CreateJudgement() => new TaikoDrumRollJudgement(); public override Judgement CreateJudgement() => new IgnoreJudgement();
protected override HitWindows CreateHitWindows() => HitWindows.Empty; protected override HitWindows CreateHitWindows() => HitWindows.Empty;
@ -114,6 +96,8 @@ namespace osu.Game.Rulesets.Taiko.Objects
public class StrongNestedHit : StrongNestedHitObject public class StrongNestedHit : StrongNestedHitObject
{ {
// The strong hit of the drum roll doesn't actually provide any score.
public override Judgement CreateJudgement() => new IgnoreJudgement();
} }
#region LegacyBeatmapEncoder #region LegacyBeatmapEncoder

View File

@ -199,11 +199,8 @@ namespace osu.Game.Rulesets.Taiko
{ {
switch (result) switch (result)
{ {
case HitResult.SmallTickHit:
return "drum tick";
case HitResult.SmallBonus: case HitResult.SmallBonus:
return "strong bonus"; return "bonus";
} }
return base.GetDisplayNameForHitResult(result); return base.GetDisplayNameForHitResult(result);

View File

@ -317,6 +317,9 @@ namespace osu.Game.Rulesets.Taiko.UI
break; break;
default: default:
if (!result.Type.IsScorable())
break;
judgementContainer.Add(judgementPools[result.Type].Get(j => judgementContainer.Add(judgementPools[result.Type].Get(j =>
{ {
j.Apply(result, judgedObject); j.Apply(result, judgedObject);

View File

@ -67,6 +67,24 @@ namespace osu.Game.Tests.Beatmaps.Formats
} }
} }
[Test]
public void TestDecodeTaikoReplay()
{
var decoder = new TestLegacyScoreDecoder();
using (var resourceStream = TestResources.OpenResource("Replays/taiko-replay.osr"))
{
var score = decoder.Parse(resourceStream);
Assert.AreEqual(1, score.ScoreInfo.Ruleset.OnlineID);
Assert.AreEqual(4, score.ScoreInfo.Statistics[HitResult.Great]);
Assert.AreEqual(2, score.ScoreInfo.Statistics[HitResult.LargeBonus]);
Assert.AreEqual(4, score.ScoreInfo.MaxCombo);
Assert.That(score.Replay.Frames, Is.Not.Empty);
}
}
[TestCase(3, true)] [TestCase(3, true)]
[TestCase(6, false)] [TestCase(6, false)]
[TestCase(LegacyBeatmapDecoder.LATEST_VERSION, false)] [TestCase(LegacyBeatmapDecoder.LATEST_VERSION, false)]

View File

@ -117,6 +117,26 @@ namespace osu.Game.Tests.Beatmaps.Formats
} }
} }
[Test]
public void TestEarliestStartTimeWithLoopAlphas()
{
var decoder = new LegacyStoryboardDecoder();
using (var resStream = TestResources.OpenResource("loop-containing-earlier-non-zero-fade.osb"))
using (var stream = new LineBufferedReader(resStream))
{
var storyboard = decoder.Decode(stream);
StoryboardLayer background = storyboard.Layers.Single(l => l.Depth == 3);
Assert.AreEqual(2, background.Elements.Count);
Assert.AreEqual(1000, background.Elements[0].StartTime);
Assert.AreEqual(1000, background.Elements[1].StartTime);
Assert.AreEqual(1000, storyboard.EarliestEventTime);
}
}
[Test] [Test]
public void TestDecodeVariableWithSuffix() public void TestDecodeVariableWithSuffix()
{ {

View File

@ -7,10 +7,12 @@ using System.Linq;
using Moq; using Moq;
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Audio.Track; using osu.Framework.Audio.Track;
using osu.Framework.Timing;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Edit.Checks; using osu.Game.Rulesets.Edit.Checks;
using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects;
using osu.Game.Tests.Visual;
namespace osu.Game.Tests.Editing.Checks namespace osu.Game.Tests.Editing.Checks
{ {
@ -109,7 +111,7 @@ namespace osu.Game.Tests.Editing.Checks
/// <param name="audioBitrate">The bitrate of the audio file the beatmap uses.</param> /// <param name="audioBitrate">The bitrate of the audio file the beatmap uses.</param>
private Mock<IWorkingBeatmap> getMockWorkingBeatmap(int? audioBitrate) private Mock<IWorkingBeatmap> getMockWorkingBeatmap(int? audioBitrate)
{ {
var mockTrack = new Mock<Track>(); var mockTrack = new Mock<OsuTestScene.ClockBackedTestWorkingBeatmap.TrackVirtualManual>(new FramedClock(), "virtual");
mockTrack.SetupGet(t => t.Bitrate).Returns(audioBitrate); mockTrack.SetupGet(t => t.Bitrate).Returns(audioBitrate);
var mockWorkingBeatmap = new Mock<IWorkingBeatmap>(); var mockWorkingBeatmap = new Mock<IWorkingBeatmap>();

View File

@ -1,8 +1,9 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Audio;
using osu.Framework.Bindables;
using osu.Framework.Timing; using osu.Framework.Timing;
using osu.Game.Screens.Play; using osu.Game.Screens.Play;
@ -13,21 +14,20 @@ namespace osu.Game.Tests.NonVisual
{ {
[TestCase(0)] [TestCase(0)]
[TestCase(1)] [TestCase(1)]
public void TestTrueGameplayRateWithZeroAdjustment(double underlyingClockRate) public void TestTrueGameplayRateWithGameplayAdjustment(double underlyingClockRate)
{ {
var framedClock = new FramedClock(new ManualClock { Rate = underlyingClockRate }); var framedClock = new FramedClock(new ManualClock { Rate = underlyingClockRate });
var gameplayClock = new TestGameplayClockContainer(framedClock); var gameplayClock = new TestGameplayClockContainer(framedClock);
Assert.That(gameplayClock.TrueGameplayRate, Is.EqualTo(0)); Assert.That(gameplayClock.GetTrueGameplayRate(), Is.EqualTo(2));
} }
private class TestGameplayClockContainer : GameplayClockContainer private class TestGameplayClockContainer : GameplayClockContainer
{ {
public override IEnumerable<double> NonGameplayAdjustments => new[] { 0.0 };
public TestGameplayClockContainer(IFrameBasedClock underlyingClock) public TestGameplayClockContainer(IFrameBasedClock underlyingClock)
: base(underlyingClock) : base(underlyingClock)
{ {
AdjustmentsFromMods.AddAdjustment(AdjustableProperty.Frequency, new BindableDouble(2.0));
} }
} }
} }

Binary file not shown.

View File

@ -0,0 +1,14 @@
osu file format v14
[Events]
//Storyboard Layer 0 (Background)
Sprite,Background,TopCentre,"img.jpg",320,240
L,1000,1
F,0,0,,1 // fade inside a loop with non-zero alpha and an earlier start time should be the true start time..
F,0,2000,,0 // ..not a zero alpha fade with a later start time
Sprite,Background,TopCentre,"img.jpg",320,240
L,2000,1
F,0,0,24,0 // fade inside a loop with zero alpha but later start time than the top-level zero alpha start time.
F,0,24,48,1
F,0,1000,,1 // ..so this should be the true start time

View File

@ -36,7 +36,9 @@ namespace osu.Game.Tests.Skins
"Archives/modified-default-20220723.osk", "Archives/modified-default-20220723.osk",
"Archives/modified-classic-20220723.osk", "Archives/modified-classic-20220723.osk",
// Covers legacy song progress, UR counter, colour hit error metre. // Covers legacy song progress, UR counter, colour hit error metre.
"Archives/modified-classic-20220801.osk" "Archives/modified-classic-20220801.osk",
// Covers clicks/s counter
"Archives/modified-default-20220818.osk"
}; };
/// <summary> /// <summary>

View File

@ -171,7 +171,7 @@ namespace osu.Game.Tests.Visual.Background
=> AddStep("create loader", () => => AddStep("create loader", () =>
{ {
if (backgroundLoader != null) if (backgroundLoader != null)
Remove(backgroundLoader); Remove(backgroundLoader, true);
Add(backgroundLoader = new SeasonalBackgroundLoader()); Add(backgroundLoader = new SeasonalBackgroundLoader());
}); });

View File

@ -9,6 +9,7 @@ using osu.Framework.Graphics;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Drawables.Cards.Buttons; using osu.Game.Beatmaps.Drawables.Cards.Buttons;
using osu.Game.Configuration; using osu.Game.Configuration;
using osu.Game.Online;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays; using osu.Game.Overlays;
using osu.Game.Resources.Localisation.Web; using osu.Game.Resources.Localisation.Web;
@ -58,6 +59,7 @@ namespace osu.Game.Tests.Visual.Beatmaps
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
State = { Value = DownloadState.NotDownloaded },
Scale = new Vector2(2) Scale = new Vector2(2)
}; };
}); });

View File

@ -0,0 +1,85 @@
// 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.Extensions;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Testing;
using osu.Game.Beatmaps;
using osu.Game.Graphics.UserInterface;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Osu;
using osu.Game.Storyboards;
using osu.Game.Tests.Beatmaps.IO;
using osuTK.Input;
namespace osu.Game.Tests.Visual.Editing
{
public class TestSceneDifficultyDelete : EditorTestScene
{
protected override Ruleset CreateEditorRuleset() => new OsuRuleset();
protected override bool IsolateSavingFromDatabase => false;
[Resolved]
private OsuGameBase game { get; set; } = null!;
[Resolved]
private BeatmapManager beatmaps { get; set; } = null!;
private BeatmapSetInfo importedBeatmapSet = null!;
protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null!)
=> beatmaps.GetWorkingBeatmap(importedBeatmapSet.Beatmaps.First());
public override void SetUpSteps()
{
AddStep("import test beatmap", () => importedBeatmapSet = BeatmapImportHelper.LoadOszIntoOsu(game, virtualTrack: true).GetResultSafely());
base.SetUpSteps();
}
[Test]
public void TestDeleteDifficulties()
{
Guid deletedDifficultyID = Guid.Empty;
int countBeforeDeletion = 0;
string beatmapSetHashBefore = string.Empty;
for (int i = 0; i < 12; i++)
{
// Will be reloaded after each deletion.
AddUntilStep("wait for editor to load", () => Editor?.ReadyForUse == true);
AddStep("store selected difficulty", () =>
{
deletedDifficultyID = EditorBeatmap.BeatmapInfo.ID;
countBeforeDeletion = Beatmap.Value.BeatmapSetInfo.Beatmaps.Count;
beatmapSetHashBefore = Beatmap.Value.BeatmapSetInfo.Hash;
});
AddStep("click File", () => this.ChildrenOfType<DrawableOsuMenuItem>().First().TriggerClick());
if (i == 11)
{
// last difficulty shouldn't be able to be deleted.
AddAssert("Delete menu item disabled", () => getDeleteMenuItem().Item.Action.Disabled);
}
else
{
AddStep("click delete", () => getDeleteMenuItem().TriggerClick());
AddUntilStep("wait for dialog", () => DialogOverlay.CurrentDialog != null);
AddStep("confirm", () => InputManager.Key(Key.Number1));
AddAssert($"difficulty {i} is deleted", () => Beatmap.Value.BeatmapSetInfo.Beatmaps.Select(b => b.ID), () => Does.Not.Contain(deletedDifficultyID));
AddAssert("count decreased by one", () => Beatmap.Value.BeatmapSetInfo.Beatmaps.Count, () => Is.EqualTo(countBeforeDeletion - 1));
AddAssert("set hash changed", () => Beatmap.Value.BeatmapSetInfo.Hash, () => Is.Not.EqualTo(beatmapSetHashBefore));
}
}
}
private DrawableOsuMenuItem getDeleteMenuItem() => this.ChildrenOfType<DrawableOsuMenuItem>()
.Single(item => item.ChildrenOfType<SpriteText>().Any(text => text.Text.ToString().StartsWith("Delete", StringComparison.Ordinal)));
}
}

View File

@ -87,7 +87,7 @@ namespace osu.Game.Tests.Visual.Gameplay
Add(expectedComponentsAdjustmentContainer); Add(expectedComponentsAdjustmentContainer);
expectedComponentsAdjustmentContainer.UpdateSubTree(); expectedComponentsAdjustmentContainer.UpdateSubTree();
var expectedInfo = expectedComponentsContainer.CreateSkinnableInfo(); var expectedInfo = expectedComponentsContainer.CreateSkinnableInfo();
Remove(expectedComponentsAdjustmentContainer); Remove(expectedComponentsAdjustmentContainer, true);
return almostEqual(actualInfo, expectedInfo); return almostEqual(actualInfo, expectedInfo);
} }

View File

@ -0,0 +1,130 @@
// 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 NUnit.Framework;
using osu.Framework.Audio;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Testing;
using osu.Framework.Timing;
using osu.Game.Screens.Play;
using osu.Game.Screens.Play.HUD.ClicksPerSecond;
using osuTK;
namespace osu.Game.Tests.Visual.Gameplay
{
public class TestSceneClicksPerSecondCalculator : OsuTestScene
{
private ClicksPerSecondCalculator calculator = null!;
private TestGameplayClock manualGameplayClock = null!;
[SetUpSteps]
public void SetUpSteps()
{
AddStep("create components", () =>
{
manualGameplayClock = new TestGameplayClock();
Child = new DependencyProvidingContainer
{
RelativeSizeAxes = Axes.Both,
CachedDependencies = new (Type, object)[] { (typeof(IGameplayClock), manualGameplayClock) },
Children = new Drawable[]
{
calculator = new ClicksPerSecondCalculator(),
new DependencyProvidingContainer
{
RelativeSizeAxes = Axes.Both,
CachedDependencies = new (Type, object)[] { (typeof(ClicksPerSecondCalculator), calculator) },
Child = new ClicksPerSecondCounter
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Scale = new Vector2(5),
}
}
},
};
});
}
[Test]
public void TestBasicConsistency()
{
seek(1000);
AddStep("add inputs in past", () => addInputs(new double[] { 0, 100, 200, 300, 400, 500, 600, 700, 800, 900 }));
checkClicksPerSecondValue(10);
}
[Test]
public void TestRateAdjustConsistency()
{
seek(1000);
AddStep("add inputs in past", () => addInputs(new double[] { 0, 100, 200, 300, 400, 500, 600, 700, 800, 900 }));
checkClicksPerSecondValue(10);
AddStep("set rate 0.5x", () => manualGameplayClock.TrueGameplayRate = 0.5);
checkClicksPerSecondValue(5);
}
[Test]
public void TestInputsDiscardedOnRewind()
{
seek(1000);
AddStep("add inputs in past", () => addInputs(new double[] { 0, 100, 200, 300, 400, 500, 600, 700, 800, 900 }));
checkClicksPerSecondValue(10);
seek(500);
checkClicksPerSecondValue(6);
seek(1000);
checkClicksPerSecondValue(6);
}
private void checkClicksPerSecondValue(int i) => AddAssert("clicks/s is correct", () => calculator.Value, () => Is.EqualTo(i));
private void seekClockImmediately(double time) => manualGameplayClock.CurrentTime = time;
private void seek(double time) => AddStep($"Seek to {time}ms", () => seekClockImmediately(time));
private void addInputs(IEnumerable<double> inputs)
{
double baseTime = manualGameplayClock.CurrentTime;
foreach (double timestamp in inputs)
{
seekClockImmediately(timestamp);
calculator.AddInputTimestamp();
}
seekClockImmediately(baseTime);
}
private class TestGameplayClock : IGameplayClock
{
public double CurrentTime { get; set; }
public double Rate => 1;
public bool IsRunning => true;
public double TrueGameplayRate { set => adjustableAudioComponent.Tempo.Value = value; }
private readonly AudioAdjustments adjustableAudioComponent = new AudioAdjustments();
public void ProcessFrame()
{
}
public double ElapsedFrameTime => throw new NotImplementedException();
public double FramesPerSecond => throw new NotImplementedException();
public FrameTimeInfo TimeInfo => throw new NotImplementedException();
public double StartTime => throw new NotImplementedException();
public IAdjustableAudioComponent AdjustmentsFromMods => adjustableAudioComponent;
public IEnumerable<double> NonGameplayAdjustments => throw new NotImplementedException();
public IBindable<bool> IsPaused => throw new NotImplementedException();
}
}
}

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using NUnit.Framework; using NUnit.Framework;
@ -73,6 +71,18 @@ namespace osu.Game.Tests.Visual.Gameplay
AddAssert("origin flipped", () => sprites.All(s => s.Origin == Anchor.BottomRight)); AddAssert("origin flipped", () => sprites.All(s => s.Origin == Anchor.BottomRight));
} }
[Test]
public void TestZeroScale()
{
const string lookup_name = "hitcircleoverlay";
AddStep("allow skin lookup", () => storyboard.UseSkinSprites = true);
AddStep("create sprites", () => SetContents(_ => createSprite(lookup_name, Anchor.TopLeft, Vector2.Zero)));
AddAssert("sprites present", () => sprites.All(s => s.IsPresent));
AddStep("scale sprite", () => sprites.ForEach(s => s.VectorScale = new Vector2(0, 1)));
AddAssert("sprites not present", () => sprites.All(s => !s.IsPresent));
}
[Test] [Test]
public void TestNegativeScale() public void TestNegativeScale()
{ {

View File

@ -66,18 +66,20 @@ namespace osu.Game.Tests.Visual.Gameplay
[TestCase(-10000, -10000, true)] [TestCase(-10000, -10000, true)]
public void TestStoryboardProducesCorrectStartTimeFadeInAfterOtherEvents(double firstStoryboardEvent, double expectedStartTime, bool addEventToLoop) public void TestStoryboardProducesCorrectStartTimeFadeInAfterOtherEvents(double firstStoryboardEvent, double expectedStartTime, bool addEventToLoop)
{ {
const double loop_start_time = -20000;
var storyboard = new Storyboard(); var storyboard = new Storyboard();
var sprite = new StoryboardSprite("unknown", Anchor.TopLeft, Vector2.Zero); var sprite = new StoryboardSprite("unknown", Anchor.TopLeft, Vector2.Zero);
// these should be ignored as we have an alpha visibility blocker proceeding this command. // these should be ignored as we have an alpha visibility blocker proceeding this command.
sprite.TimelineGroup.Scale.Add(Easing.None, -20000, -18000, 0, 1); sprite.TimelineGroup.Scale.Add(Easing.None, loop_start_time, -18000, 0, 1);
var loopGroup = sprite.AddLoop(-20000, 50); var loopGroup = sprite.AddLoop(loop_start_time, 50);
loopGroup.Scale.Add(Easing.None, -20000, -18000, 0, 1); loopGroup.Scale.Add(Easing.None, loop_start_time, -18000, 0, 1);
var target = addEventToLoop ? loopGroup : sprite.TimelineGroup; var target = addEventToLoop ? loopGroup : sprite.TimelineGroup;
double targetTime = addEventToLoop ? 20000 : 0; double loopRelativeOffset = addEventToLoop ? -loop_start_time : 0;
target.Alpha.Add(Easing.None, targetTime + firstStoryboardEvent, targetTime + firstStoryboardEvent + 500, 0, 1); target.Alpha.Add(Easing.None, loopRelativeOffset + firstStoryboardEvent, loopRelativeOffset + firstStoryboardEvent + 500, 0, 1);
// these should be ignored due to being in the future. // these should be ignored due to being in the future.
sprite.TimelineGroup.Alpha.Add(Easing.None, 18000, 20000, 0, 1); sprite.TimelineGroup.Alpha.Add(Easing.None, 18000, 20000, 0, 1);

View File

@ -370,7 +370,7 @@ namespace osu.Game.Tests.Visual.Gameplay
private void confirmNoTrackAdjustments() private void confirmNoTrackAdjustments()
{ {
AddAssert("track has no adjustments", () => Beatmap.Value.Track.AggregateFrequency.Value == 1); AddUntilStep("track has no adjustments", () => Beatmap.Value.Track.AggregateFrequency.Value, () => Is.EqualTo(1));
} }
private void restart() => AddStep("restart", () => Player.Restart()); private void restart() => AddStep("restart", () => Player.Restart());

View File

@ -301,7 +301,7 @@ namespace osu.Game.Tests.Visual.Gameplay
AddAssert("check for notification", () => notificationOverlay.UnreadCount.Value, () => Is.EqualTo(1)); AddAssert("check for notification", () => notificationOverlay.UnreadCount.Value, () => Is.EqualTo(1));
clickNotificationIfAny(); clickNotification();
AddAssert("check " + volumeName, assert); AddAssert("check " + volumeName, assert);
@ -370,8 +370,12 @@ namespace osu.Game.Tests.Visual.Gameplay
batteryInfo.SetChargeLevel(chargeLevel); batteryInfo.SetChargeLevel(chargeLevel);
})); }));
AddUntilStep("wait for player", () => player?.LoadState == LoadState.Ready); AddUntilStep("wait for player", () => player?.LoadState == LoadState.Ready);
AddAssert($"notification {(shouldWarn ? "triggered" : "not triggered")}", () => notificationOverlay.UnreadCount.Value == (shouldWarn ? 1 : 0));
clickNotificationIfAny(); if (shouldWarn)
clickNotification();
else
AddAssert("notification not triggered", () => notificationOverlay.UnreadCount.Value == 0);
AddUntilStep("wait for player load", () => player.IsLoaded); AddUntilStep("wait for player load", () => player.IsLoaded);
} }
@ -436,9 +440,13 @@ namespace osu.Game.Tests.Visual.Gameplay
AddUntilStep("skip button not visible", () => !checkSkipButtonVisible()); AddUntilStep("skip button not visible", () => !checkSkipButtonVisible());
} }
private void clickNotificationIfAny() private void clickNotification()
{ {
AddStep("click notification", () => notificationOverlay.ChildrenOfType<Notification>().FirstOrDefault()?.TriggerClick()); Notification notification = null;
AddUntilStep("wait for notification", () => (notification = notificationOverlay.ChildrenOfType<Notification>().FirstOrDefault()) != null);
AddStep("open notification overlay", () => notificationOverlay.Show());
AddStep("click notification", () => notification.TriggerClick());
} }
private EpilepsyWarning getWarning() => loader.ChildrenOfType<EpilepsyWarning>().SingleOrDefault(); private EpilepsyWarning getWarning() => loader.ChildrenOfType<EpilepsyWarning>().SingleOrDefault();

View File

@ -81,9 +81,11 @@ namespace osu.Game.Tests.Visual.Gameplay
CreateTest(); CreateTest();
AddUntilStep("fail screen displayed", () => Player.ChildrenOfType<FailOverlay>().First().State.Value == Visibility.Visible); AddUntilStep("fail screen displayed", () => Player.ChildrenOfType<FailOverlay>().First().State.Value == Visibility.Visible);
AddUntilStep("wait for button clickable", () => Player.ChildrenOfType<SaveFailedScoreButton>().First().ChildrenOfType<OsuClickableContainer>().First().Enabled.Value);
AddUntilStep("score not in database", () => Realm.Run(r => r.Find<ScoreInfo>(Player.Score.ScoreInfo.ID) == null)); AddUntilStep("score not in database", () => Realm.Run(r => r.Find<ScoreInfo>(Player.Score.ScoreInfo.ID) == null));
AddStep("click save button", () => Player.ChildrenOfType<SaveFailedScoreButton>().First().ChildrenOfType<OsuClickableContainer>().First().TriggerClick()); AddStep("click save button", () => Player.ChildrenOfType<SaveFailedScoreButton>().First().ChildrenOfType<OsuClickableContainer>().First().TriggerClick());
AddUntilStep("score not in database", () => Realm.Run(r => r.Find<ScoreInfo>(Player.Score.ScoreInfo.ID) != null)); AddUntilStep("score in database", () => Realm.Run(r => r.Find<ScoreInfo>(Player.Score.ScoreInfo.ID) != null));
} }
[Test] [Test]

View File

@ -202,7 +202,7 @@ namespace osu.Game.Tests.Visual.Gameplay
AddUntilStep("wait for load", () => downloadButton.IsLoaded); AddUntilStep("wait for load", () => downloadButton.IsLoaded);
AddAssert("state is not downloaded", () => downloadButton.State.Value == DownloadState.NotDownloaded); AddAssert("state is unknown", () => downloadButton.State.Value == DownloadState.Unknown);
AddAssert("button is not enabled", () => !downloadButton.ChildrenOfType<DownloadButton>().First().Enabled.Value); AddAssert("button is not enabled", () => !downloadButton.ChildrenOfType<DownloadButton>().First().Enabled.Value);
} }

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System.Linq; using System.Linq;
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Allocation; using osu.Framework.Allocation;
@ -22,7 +20,7 @@ namespace osu.Game.Tests.Visual.Gameplay
{ {
public class TestSceneSkinEditor : PlayerTestScene public class TestSceneSkinEditor : PlayerTestScene
{ {
private SkinEditor skinEditor; private SkinEditor? skinEditor;
protected override bool Autoplay => true; protected override bool Autoplay => true;
@ -42,29 +40,33 @@ namespace osu.Game.Tests.Visual.Gameplay
Player.ScaleTo(0.4f); Player.ScaleTo(0.4f);
LoadComponentAsync(skinEditor = new SkinEditor(Player), Add); LoadComponentAsync(skinEditor = new SkinEditor(Player), Add);
}); });
AddUntilStep("wait for loaded", () => skinEditor.IsLoaded); AddUntilStep("wait for loaded", () => skinEditor!.IsLoaded);
} }
[Test] [Test]
public void TestToggleEditor() public void TestToggleEditor()
{ {
AddToggleStep("toggle editor visibility", _ => skinEditor.ToggleVisibility()); AddToggleStep("toggle editor visibility", _ => skinEditor!.ToggleVisibility());
} }
[Test] [Test]
public void TestEditComponent() public void TestEditComponent()
{ {
BarHitErrorMeter hitErrorMeter = null; BarHitErrorMeter hitErrorMeter = null!;
AddStep("select bar hit error blueprint", () => AddStep("select bar hit error blueprint", () =>
{ {
var blueprint = skinEditor.ChildrenOfType<SkinBlueprint>().First(b => b.Item is BarHitErrorMeter); var blueprint = skinEditor.ChildrenOfType<SkinBlueprint>().First(b => b.Item is BarHitErrorMeter);
hitErrorMeter = (BarHitErrorMeter)blueprint.Item; hitErrorMeter = (BarHitErrorMeter)blueprint.Item;
skinEditor.SelectedComponents.Clear(); skinEditor!.SelectedComponents.Clear();
skinEditor.SelectedComponents.Add(blueprint.Item); skinEditor.SelectedComponents.Add(blueprint.Item);
}); });
AddStep("move by keyboard", () => InputManager.Key(Key.Right));
AddAssert("hitErrorMeter moved", () => hitErrorMeter.X != 0);
AddAssert("value is default", () => hitErrorMeter.JudgementLineThickness.IsDefault); AddAssert("value is default", () => hitErrorMeter.JudgementLineThickness.IsDefault);
AddStep("hover first slider", () => AddStep("hover first slider", () =>

View File

@ -63,7 +63,7 @@ namespace osu.Game.Tests.Visual.Gameplay
{ {
base.TearDownSteps(); base.TearDownSteps();
AddStep("stop watching user", () => spectatorClient.StopWatchingUser(dummy_user_id)); AddStep("stop watching user", () => spectatorClient.StopWatchingUser(dummy_user_id));
AddStep("remove test spectator client", () => Remove(spectatorClient)); AddStep("remove test spectator client", () => Remove(spectatorClient, false));
} }
} }
} }

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
@ -24,8 +22,9 @@ namespace osu.Game.Tests.Visual.Gameplay
[TestFixture] [TestFixture]
public class TestSceneStoryboard : OsuTestScene public class TestSceneStoryboard : OsuTestScene
{ {
private Container<DrawableStoryboard> storyboardContainer; private Container<DrawableStoryboard> storyboardContainer = null!;
private DrawableStoryboard storyboard;
private DrawableStoryboard? storyboard;
[Test] [Test]
public void TestStoryboard() public void TestStoryboard()
@ -40,7 +39,7 @@ namespace osu.Game.Tests.Visual.Gameplay
[Test] [Test]
public void TestStoryboardMissingVideo() public void TestStoryboardMissingVideo()
{ {
AddStep("Load storyboard with missing video", loadStoryboardNoVideo); AddStep("Load storyboard with missing video", () => loadStoryboard("storyboard_no_video.osu"));
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
@ -77,53 +76,44 @@ namespace osu.Game.Tests.Visual.Gameplay
Beatmap.BindValueChanged(beatmapChanged, true); Beatmap.BindValueChanged(beatmapChanged, true);
} }
private void beatmapChanged(ValueChangedEvent<WorkingBeatmap> e) => loadStoryboard(e.NewValue); private void beatmapChanged(ValueChangedEvent<WorkingBeatmap> e) => loadStoryboard(e.NewValue.Storyboard);
private void restart() private void restart()
{ {
var track = Beatmap.Value.Track; var track = Beatmap.Value.Track;
track.Reset(); track.Reset();
loadStoryboard(Beatmap.Value); loadStoryboard(Beatmap.Value.Storyboard);
track.Start(); track.Start();
} }
private void loadStoryboard(IWorkingBeatmap working) private void loadStoryboard(Storyboard toLoad)
{ {
if (storyboard != null) if (storyboard != null)
storyboardContainer.Remove(storyboard); storyboardContainer.Remove(storyboard, true);
var decoupledClock = new DecoupleableInterpolatingFramedClock { IsCoupled = true }; var decoupledClock = new DecoupleableInterpolatingFramedClock { IsCoupled = true };
storyboardContainer.Clock = decoupledClock; storyboardContainer.Clock = decoupledClock;
storyboard = working.Storyboard.CreateDrawable(SelectedMods.Value); storyboard = toLoad.CreateDrawable(SelectedMods.Value);
storyboard.Passing = false; storyboard.Passing = false;
storyboardContainer.Add(storyboard);
decoupledClock.ChangeSource(working.Track);
}
private void loadStoryboardNoVideo()
{
if (storyboard != null)
storyboardContainer.Remove(storyboard);
var decoupledClock = new DecoupleableInterpolatingFramedClock { IsCoupled = true };
storyboardContainer.Clock = decoupledClock;
Storyboard sb;
using (var str = TestResources.OpenResource("storyboard_no_video.osu"))
using (var bfr = new LineBufferedReader(str))
{
var decoder = new LegacyStoryboardDecoder();
sb = decoder.Decode(bfr);
}
storyboard = sb.CreateDrawable(SelectedMods.Value);
storyboardContainer.Add(storyboard); storyboardContainer.Add(storyboard);
decoupledClock.ChangeSource(Beatmap.Value.Track); decoupledClock.ChangeSource(Beatmap.Value.Track);
} }
private void loadStoryboard(string filename)
{
Storyboard loaded;
using (var str = TestResources.OpenResource(filename))
using (var bfr = new LineBufferedReader(str))
{
var decoder = new LegacyStoryboardDecoder();
loaded = decoder.Decode(bfr);
}
loadStoryboard(loaded);
}
} }
} }

View File

@ -62,8 +62,8 @@ namespace osu.Game.Tests.Visual.Menus
[SetUp] [SetUp]
public void SetUp() => Schedule(() => public void SetUp() => Schedule(() =>
{ {
Remove(nowPlayingOverlay); Remove(nowPlayingOverlay, false);
Remove(volumeOverlay); Remove(volumeOverlay, false);
Children = new Drawable[] Children = new Drawable[]
{ {

View File

@ -91,8 +91,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
break; break;
case StopCountdownRequest: case StopCountdownRequest:
multiplayerRoom.Countdown = null; clearRoomCountdown();
raiseRoomUpdated();
break; break;
} }
}); });
@ -244,14 +243,14 @@ namespace osu.Game.Tests.Visual.Multiplayer
}); });
AddStep("start countdown", () => multiplayerClient.Object.SendMatchRequest(new StartMatchCountdownRequest { Duration = TimeSpan.FromMinutes(1) }).WaitSafely()); AddStep("start countdown", () => multiplayerClient.Object.SendMatchRequest(new StartMatchCountdownRequest { Duration = TimeSpan.FromMinutes(1) }).WaitSafely());
AddUntilStep("countdown started", () => multiplayerRoom.Countdown != null); AddUntilStep("countdown started", () => multiplayerRoom.ActiveCountdowns.Any());
AddStep("transfer host to local user", () => transferHost(localUser)); AddStep("transfer host to local user", () => transferHost(localUser));
AddUntilStep("local user is host", () => multiplayerRoom.Host?.Equals(multiplayerClient.Object.LocalUser) == true); AddUntilStep("local user is host", () => multiplayerRoom.Host?.Equals(multiplayerClient.Object.LocalUser) == true);
ClickButtonWhenEnabled<MultiplayerReadyButton>(); ClickButtonWhenEnabled<MultiplayerReadyButton>();
checkLocalUserState(MultiplayerUserState.Ready); checkLocalUserState(MultiplayerUserState.Ready);
AddAssert("countdown still active", () => multiplayerRoom.Countdown != null); AddAssert("countdown still active", () => multiplayerRoom.ActiveCountdowns.Any());
} }
[Test] [Test]
@ -392,7 +391,13 @@ namespace osu.Game.Tests.Visual.Multiplayer
private void setRoomCountdown(TimeSpan duration) private void setRoomCountdown(TimeSpan duration)
{ {
multiplayerRoom.Countdown = new MatchStartCountdown { TimeRemaining = duration }; multiplayerRoom.ActiveCountdowns.Add(new MatchStartCountdown { TimeRemaining = duration });
raiseRoomUpdated();
}
private void clearRoomCountdown()
{
multiplayerRoom.ActiveCountdowns.Clear();
raiseRoomUpdated(); raiseRoomUpdated();
} }

View File

@ -13,9 +13,11 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Testing; using osu.Framework.Testing;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Configuration; using osu.Game.Configuration;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
using osu.Game.Online.Multiplayer; using osu.Game.Online.Multiplayer;
using osu.Game.Online.Multiplayer.MatchTypes.TeamVersus; using osu.Game.Online.Multiplayer.MatchTypes.TeamVersus;
using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Rulesets.UI; using osu.Game.Rulesets.UI;
using osu.Game.Screens.OnlinePlay.Multiplayer.Spectate; using osu.Game.Screens.OnlinePlay.Multiplayer.Spectate;
using osu.Game.Screens.Play; using osu.Game.Screens.Play;
@ -332,6 +334,18 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddUntilStep("player 2 playing from correct point in time", () => getPlayer(PLAYER_2_ID).ChildrenOfType<DrawableRuleset>().Single().FrameStableClock.CurrentTime > 30000); AddUntilStep("player 2 playing from correct point in time", () => getPlayer(PLAYER_2_ID).ChildrenOfType<DrawableRuleset>().Single().FrameStableClock.CurrentTime > 30000);
} }
[Test]
public void TestGameplayRateAdjust()
{
start(getPlayerIds(4), mods: new[] { new APIMod(new OsuModDoubleTime()) });
loadSpectateScreen();
sendFrames(getPlayerIds(4), 300);
AddUntilStep("wait for correct track speed", () => Beatmap.Value.Track.Rate, () => Is.EqualTo(1.5));
}
[Test] [Test]
public void TestPlayersLeaveWhileSpectating() public void TestPlayersLeaveWhileSpectating()
{ {
@ -420,7 +434,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
private void start(int userId, int? beatmapId = null) => start(new[] { userId }, beatmapId); private void start(int userId, int? beatmapId = null) => start(new[] { userId }, beatmapId);
private void start(int[] userIds, int? beatmapId = null) private void start(int[] userIds, int? beatmapId = null, APIMod[]? mods = null)
{ {
AddStep("start play", () => AddStep("start play", () =>
{ {
@ -429,10 +443,11 @@ namespace osu.Game.Tests.Visual.Multiplayer
var user = new MultiplayerRoomUser(id) var user = new MultiplayerRoomUser(id)
{ {
User = new APIUser { Id = id }, User = new APIUser { Id = id },
Mods = mods ?? Array.Empty<APIMod>(),
}; };
OnlinePlayDependencies.MultiplayerClient.AddUser(user.User, true); OnlinePlayDependencies.MultiplayerClient.AddUser(user, true);
SpectatorClient.SendStartPlay(id, beatmapId ?? importedBeatmapId); SpectatorClient.SendStartPlay(id, beatmapId ?? importedBeatmapId, mods);
playingUsers.Add(user); playingUsers.Add(user);
} }

View File

@ -19,7 +19,6 @@ using osu.Game.Database;
using osu.Game.Online.Rooms; using osu.Game.Online.Rooms;
using osu.Game.Overlays.Mods; using osu.Game.Overlays.Mods;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Rulesets.Catch;
using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Osu.Mods; using osu.Game.Rulesets.Osu.Mods;
@ -68,37 +67,6 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddUntilStep("wait for present", () => songSelect.IsCurrentScreen() && songSelect.BeatmapSetsLoaded); AddUntilStep("wait for present", () => songSelect.IsCurrentScreen() && songSelect.BeatmapSetsLoaded);
} }
[Test]
public void TestBeatmapRevertedOnExitIfNoSelection()
{
BeatmapInfo selectedBeatmap = null;
AddStep("select beatmap",
() => songSelect.Carousel.SelectBeatmap(selectedBeatmap = beatmaps.Where(beatmap => beatmap.Ruleset.OnlineID == new OsuRuleset().LegacyID).ElementAt(1)));
AddUntilStep("wait for selection", () => Beatmap.Value.BeatmapInfo.Equals(selectedBeatmap));
AddStep("exit song select", () => songSelect.Exit());
AddAssert("beatmap reverted", () => Beatmap.IsDefault);
}
[Test]
public void TestModsRevertedOnExitIfNoSelection()
{
AddStep("change mods", () => SelectedMods.Value = new[] { new OsuModDoubleTime() });
AddStep("exit song select", () => songSelect.Exit());
AddAssert("mods reverted", () => SelectedMods.Value.Count == 0);
}
[Test]
public void TestRulesetRevertedOnExitIfNoSelection()
{
AddStep("change ruleset", () => Ruleset.Value = new CatchRuleset().RulesetInfo);
AddStep("exit song select", () => songSelect.Exit());
AddAssert("ruleset reverted", () => Ruleset.Value.Equals(new OsuRuleset().RulesetInfo));
}
[Test] [Test]
public void TestBeatmapConfirmed() public void TestBeatmapConfirmed()
{ {
@ -152,8 +120,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
public new BeatmapCarousel Carousel => base.Carousel; public new BeatmapCarousel Carousel => base.Carousel;
public TestMultiplayerMatchSongSelect(Room room, WorkingBeatmap beatmap = null, RulesetInfo ruleset = null) public TestMultiplayerMatchSongSelect(Room room)
: base(room, null, beatmap, ruleset) : base(room)
{ {
} }
} }

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System.Linq; using System.Linq;
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Testing; using osu.Framework.Testing;
@ -13,7 +11,7 @@ namespace osu.Game.Tests.Visual.Navigation
{ {
public class TestSceneStartupImport : OsuGameTestScene public class TestSceneStartupImport : OsuGameTestScene
{ {
private string importFilename; private string? importFilename;
protected override TestOsuGame CreateTestGame() => new TestOsuGame(LocalStorage, API, new[] { importFilename }); protected override TestOsuGame CreateTestGame() => new TestOsuGame(LocalStorage, API, new[] { importFilename });

View File

@ -34,7 +34,7 @@ namespace osu.Game.Tests.Visual.Navigation
AddStep("force save config", () => Game.LocalConfig.Save()); AddStep("force save config", () => Game.LocalConfig.Save());
AddStep("remove game", () => Remove(Game)); AddStep("remove game", () => Remove(Game, true));
AddStep("create game again", CreateGame); AddStep("create game again", CreateGame);

View File

@ -60,7 +60,7 @@ namespace osu.Game.Tests.Visual.Online
{ {
if (selected.Text == mod.Acronym) if (selected.Text == mod.Acronym)
{ {
selectedMods.Remove(selected); selectedMods.Remove(selected, true);
break; break;
} }
} }

View File

@ -154,7 +154,7 @@ namespace osu.Game.Tests.Visual.Online
}); });
} }
private int onlineID = 1; private ulong onlineID = 1;
private APIScoresCollection createScores() private APIScoresCollection createScores()
{ {

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -20,7 +18,7 @@ namespace osu.Game.Tests.Visual.Ranking
{ {
public class TestSceneHitEventTimingDistributionGraph : OsuTestScene public class TestSceneHitEventTimingDistributionGraph : OsuTestScene
{ {
private HitEventTimingDistributionGraph graph; private HitEventTimingDistributionGraph graph = null!;
private static readonly HitObject placeholder_object = new HitCircle(); private static readonly HitObject placeholder_object = new HitCircle();
@ -43,6 +41,65 @@ namespace osu.Game.Tests.Visual.Ranking
createTest(Enumerable.Range(-150, 300).Select(i => new HitEvent(i / 50f, HitResult.Perfect, placeholder_object, placeholder_object, null)).ToList()); createTest(Enumerable.Range(-150, 300).Select(i => new HitEvent(i / 50f, HitResult.Perfect, placeholder_object, placeholder_object, null)).ToList());
} }
[Test]
public void TestSparse()
{
createTest(new List<HitEvent>
{
new HitEvent(-7, HitResult.Perfect, placeholder_object, placeholder_object, null),
new HitEvent(-6, HitResult.Perfect, placeholder_object, placeholder_object, null),
new HitEvent(-5, HitResult.Perfect, placeholder_object, placeholder_object, null),
new HitEvent(5, HitResult.Perfect, placeholder_object, placeholder_object, null),
new HitEvent(6, HitResult.Perfect, placeholder_object, placeholder_object, null),
new HitEvent(7, HitResult.Perfect, placeholder_object, placeholder_object, null),
});
}
[Test]
public void TestVariousTypesOfHitResult()
{
createTest(CreateDistributedHitEvents(0, 50).Select(h =>
{
double offset = Math.Abs(h.TimeOffset);
HitResult result = offset > 36 ? HitResult.Miss
: offset > 32 ? HitResult.Meh
: offset > 24 ? HitResult.Ok
: offset > 16 ? HitResult.Good
: offset > 8 ? HitResult.Great
: HitResult.Perfect;
return new HitEvent(h.TimeOffset, result, placeholder_object, placeholder_object, null);
}).ToList());
}
[Test]
public void TestMultipleWindowsOfHitResult()
{
var wide = CreateDistributedHitEvents(0, 50).Select(h =>
{
double offset = Math.Abs(h.TimeOffset);
HitResult result = offset > 36 ? HitResult.Miss
: offset > 32 ? HitResult.Meh
: offset > 24 ? HitResult.Ok
: offset > 16 ? HitResult.Good
: offset > 8 ? HitResult.Great
: HitResult.Perfect;
return new HitEvent(h.TimeOffset, result, placeholder_object, placeholder_object, null);
});
var narrow = CreateDistributedHitEvents(0, 50).Select(h =>
{
double offset = Math.Abs(h.TimeOffset);
HitResult result = offset > 25 ? HitResult.Miss
: offset > 20 ? HitResult.Meh
: offset > 15 ? HitResult.Ok
: offset > 10 ? HitResult.Good
: offset > 5 ? HitResult.Great
: HitResult.Perfect;
return new HitEvent(h.TimeOffset, result, placeholder_object, placeholder_object, null);
});
createTest(wide.Concat(narrow).ToList());
}
[Test] [Test]
public void TestZeroTimeOffset() public void TestZeroTimeOffset()
{ {

View File

@ -173,7 +173,7 @@ namespace osu.Game.Tests.Visual.SongSelect
if (isIterating) if (isIterating)
AddUntilStep("selection changed", () => !carousel.SelectedBeatmapInfo?.Equals(selection) == true); AddUntilStep("selection changed", () => !carousel.SelectedBeatmapInfo?.Equals(selection) == true);
else else
AddUntilStep("selection not changed", () => carousel.SelectedBeatmapInfo.Equals(selection)); AddUntilStep("selection not changed", () => carousel.SelectedBeatmapInfo?.Equals(selection) == true);
} }
} }
} }
@ -382,7 +382,7 @@ namespace osu.Game.Tests.Visual.SongSelect
// buffer the selection // buffer the selection
setSelected(3, 2); setSelected(3, 2);
AddStep("get search text", () => searchText = carousel.SelectedBeatmapSet.Metadata.Title); AddStep("get search text", () => searchText = carousel.SelectedBeatmapSet!.Metadata.Title);
setSelected(1, 3); setSelected(1, 3);
@ -701,7 +701,7 @@ namespace osu.Game.Tests.Visual.SongSelect
setSelected(2, 1); setSelected(2, 1);
AddAssert("Selection is non-null", () => currentSelection != null); AddAssert("Selection is non-null", () => currentSelection != null);
AddStep("Remove selected", () => carousel.RemoveBeatmapSet(carousel.SelectedBeatmapSet)); AddStep("Remove selected", () => carousel.RemoveBeatmapSet(carousel.SelectedBeatmapSet!));
waitForSelection(2); waitForSelection(2);
AddStep("Remove first", () => carousel.RemoveBeatmapSet(carousel.BeatmapSets.First())); AddStep("Remove first", () => carousel.RemoveBeatmapSet(carousel.BeatmapSets.First()));
@ -804,7 +804,7 @@ namespace osu.Game.Tests.Visual.SongSelect
AddStep("filter to ruleset 0", () => AddStep("filter to ruleset 0", () =>
carousel.Filter(new FilterCriteria { Ruleset = rulesets.AvailableRulesets.ElementAt(0) }, false)); carousel.Filter(new FilterCriteria { Ruleset = rulesets.AvailableRulesets.ElementAt(0) }, false));
AddStep("select filtered map skipping filtered", () => carousel.SelectBeatmap(testMixed.Beatmaps[1], false)); AddStep("select filtered map skipping filtered", () => carousel.SelectBeatmap(testMixed.Beatmaps[1], false));
AddAssert("unfiltered beatmap not selected", () => carousel.SelectedBeatmapInfo.Ruleset.OnlineID == 0); AddAssert("unfiltered beatmap not selected", () => carousel.SelectedBeatmapInfo?.Ruleset.OnlineID == 0);
AddStep("remove mixed set", () => AddStep("remove mixed set", () =>
{ {
@ -854,7 +854,7 @@ namespace osu.Game.Tests.Visual.SongSelect
AddStep("Restore no filter", () => AddStep("Restore no filter", () =>
{ {
carousel.Filter(new FilterCriteria(), false); carousel.Filter(new FilterCriteria(), false);
eagerSelectedIDs.Add(carousel.SelectedBeatmapSet.ID); eagerSelectedIDs.Add(carousel.SelectedBeatmapSet!.ID);
}); });
} }
@ -899,10 +899,10 @@ namespace osu.Game.Tests.Visual.SongSelect
AddStep("Restore different ruleset filter", () => AddStep("Restore different ruleset filter", () =>
{ {
carousel.Filter(new FilterCriteria { Ruleset = rulesets.GetRuleset(1) }, false); carousel.Filter(new FilterCriteria { Ruleset = rulesets.GetRuleset(1) }, false);
eagerSelectedIDs.Add(carousel.SelectedBeatmapSet.ID); eagerSelectedIDs.Add(carousel.SelectedBeatmapSet!.ID);
}); });
AddAssert("selection changed", () => !carousel.SelectedBeatmapInfo.Equals(manySets.First().Beatmaps.First())); AddAssert("selection changed", () => !carousel.SelectedBeatmapInfo!.Equals(manySets.First().Beatmaps.First()));
} }
AddAssert("Selection was random", () => eagerSelectedIDs.Count > 2); AddAssert("Selection was random", () => eagerSelectedIDs.Count > 2);

View File

@ -98,7 +98,7 @@ namespace osu.Game.Tests.Visual.SongSelect
OsuLogo logo = new OsuLogo { Scale = new Vector2(0.15f) }; OsuLogo logo = new OsuLogo { Scale = new Vector2(0.15f) };
Remove(testDifficultyCache); Remove(testDifficultyCache, false);
Children = new Drawable[] Children = new Drawable[]
{ {

View File

@ -1,10 +1,9 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using NUnit.Framework; using NUnit.Framework;
@ -13,6 +12,7 @@ using osu.Framework.Audio;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Extensions; using osu.Framework.Extensions;
using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Platform; using osu.Framework.Platform;
using osu.Framework.Screens; using osu.Framework.Screens;
@ -46,11 +46,12 @@ namespace osu.Game.Tests.Visual.SongSelect
[TestFixture] [TestFixture]
public class TestScenePlaySongSelect : ScreenTestScene public class TestScenePlaySongSelect : ScreenTestScene
{ {
private BeatmapManager manager; private BeatmapManager manager = null!;
private RulesetStore rulesets; private RulesetStore rulesets = null!;
private MusicController music; private MusicController music = null!;
private WorkingBeatmap defaultBeatmap; private WorkingBeatmap defaultBeatmap = null!;
private TestSongSelect songSelect; private OsuConfigManager config = null!;
private TestSongSelect? songSelect;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(GameHost host, AudioManager audio) private void load(GameHost host, AudioManager audio)
@ -69,8 +70,6 @@ namespace osu.Game.Tests.Visual.SongSelect
Dependencies.Cache(config = new OsuConfigManager(LocalStorage)); Dependencies.Cache(config = new OsuConfigManager(LocalStorage));
} }
private OsuConfigManager config;
public override void SetUpSteps() public override void SetUpSteps()
{ {
base.SetUpSteps(); base.SetUpSteps();
@ -85,7 +84,7 @@ namespace osu.Game.Tests.Visual.SongSelect
songSelect = null; songSelect = null;
}); });
AddStep("delete all beatmaps", () => manager?.Delete()); AddStep("delete all beatmaps", () => manager.Delete());
} }
[Test] [Test]
@ -98,7 +97,7 @@ namespace osu.Game.Tests.Visual.SongSelect
addRulesetImportStep(0); addRulesetImportStep(0);
AddUntilStep("wait for placeholder hidden", () => getPlaceholder()?.State.Value == Visibility.Hidden); AddUntilStep("wait for placeholder hidden", () => getPlaceholder()?.State.Value == Visibility.Hidden);
AddStep("delete all beatmaps", () => manager?.Delete()); AddStep("delete all beatmaps", () => manager.Delete());
AddUntilStep("wait for placeholder visible", () => getPlaceholder()?.State.Value == Visibility.Visible); AddUntilStep("wait for placeholder visible", () => getPlaceholder()?.State.Value == Visibility.Visible);
} }
@ -144,7 +143,7 @@ namespace osu.Game.Tests.Visual.SongSelect
createSongSelect(); createSongSelect();
AddAssert("filter count is 1", () => songSelect.FilterCount == 1); AddAssert("filter count is 1", () => songSelect?.FilterCount == 1);
} }
[Test] [Test]
@ -156,7 +155,7 @@ namespace osu.Game.Tests.Visual.SongSelect
waitForInitialSelection(); waitForInitialSelection();
WorkingBeatmap selected = null; WorkingBeatmap? selected = null;
AddStep("store selected beatmap", () => selected = Beatmap.Value); AddStep("store selected beatmap", () => selected = Beatmap.Value);
@ -166,7 +165,7 @@ namespace osu.Game.Tests.Visual.SongSelect
InputManager.Key(Key.Enter); InputManager.Key(Key.Enter);
}); });
AddUntilStep("wait for not current", () => !songSelect.IsCurrentScreen()); AddUntilStep("wait for not current", () => !songSelect!.IsCurrentScreen());
AddAssert("ensure selection changed", () => selected != Beatmap.Value); AddAssert("ensure selection changed", () => selected != Beatmap.Value);
} }
@ -179,7 +178,7 @@ namespace osu.Game.Tests.Visual.SongSelect
waitForInitialSelection(); waitForInitialSelection();
WorkingBeatmap selected = null; WorkingBeatmap? selected = null;
AddStep("store selected beatmap", () => selected = Beatmap.Value); AddStep("store selected beatmap", () => selected = Beatmap.Value);
@ -189,7 +188,7 @@ namespace osu.Game.Tests.Visual.SongSelect
InputManager.Key(Key.Down); InputManager.Key(Key.Down);
}); });
AddUntilStep("wait for not current", () => !songSelect.IsCurrentScreen()); AddUntilStep("wait for not current", () => !songSelect!.IsCurrentScreen());
AddAssert("ensure selection didn't change", () => selected == Beatmap.Value); AddAssert("ensure selection didn't change", () => selected == Beatmap.Value);
} }
@ -202,23 +201,23 @@ namespace osu.Game.Tests.Visual.SongSelect
AddUntilStep("wait for initial selection", () => !Beatmap.IsDefault); AddUntilStep("wait for initial selection", () => !Beatmap.IsDefault);
WorkingBeatmap selected = null; WorkingBeatmap? selected = null;
AddStep("store selected beatmap", () => selected = Beatmap.Value); AddStep("store selected beatmap", () => selected = Beatmap.Value);
AddUntilStep("wait for beatmaps to load", () => songSelect.Carousel.ChildrenOfType<DrawableCarouselBeatmap>().Any()); AddUntilStep("wait for beatmaps to load", () => songSelect!.Carousel.ChildrenOfType<DrawableCarouselBeatmap>().Any());
AddStep("select next and enter", () => AddStep("select next and enter", () =>
{ {
InputManager.MoveMouseTo(songSelect.Carousel.ChildrenOfType<DrawableCarouselBeatmap>() InputManager.MoveMouseTo(songSelect!.Carousel.ChildrenOfType<DrawableCarouselBeatmap>()
.First(b => !((CarouselBeatmap)b.Item).BeatmapInfo.Equals(songSelect.Carousel.SelectedBeatmapInfo))); .First(b => !((CarouselBeatmap)b.Item).BeatmapInfo.Equals(songSelect!.Carousel.SelectedBeatmapInfo)));
InputManager.Click(MouseButton.Left); InputManager.Click(MouseButton.Left);
InputManager.Key(Key.Enter); InputManager.Key(Key.Enter);
}); });
AddUntilStep("wait for not current", () => !songSelect.IsCurrentScreen()); AddUntilStep("wait for not current", () => !songSelect!.IsCurrentScreen());
AddAssert("ensure selection changed", () => selected != Beatmap.Value); AddAssert("ensure selection changed", () => selected != Beatmap.Value);
} }
@ -231,14 +230,14 @@ namespace osu.Game.Tests.Visual.SongSelect
waitForInitialSelection(); waitForInitialSelection();
WorkingBeatmap selected = null; WorkingBeatmap? selected = null;
AddStep("store selected beatmap", () => selected = Beatmap.Value); AddStep("store selected beatmap", () => selected = Beatmap.Value);
AddStep("select next and enter", () => AddStep("select next and enter", () =>
{ {
InputManager.MoveMouseTo(songSelect.Carousel.ChildrenOfType<DrawableCarouselBeatmap>() InputManager.MoveMouseTo(songSelect!.Carousel.ChildrenOfType<DrawableCarouselBeatmap>()
.First(b => !((CarouselBeatmap)b.Item).BeatmapInfo.Equals(songSelect.Carousel.SelectedBeatmapInfo))); .First(b => !((CarouselBeatmap)b.Item).BeatmapInfo.Equals(songSelect!.Carousel.SelectedBeatmapInfo)));
InputManager.PressButton(MouseButton.Left); InputManager.PressButton(MouseButton.Left);
@ -247,7 +246,7 @@ namespace osu.Game.Tests.Visual.SongSelect
InputManager.ReleaseButton(MouseButton.Left); InputManager.ReleaseButton(MouseButton.Left);
}); });
AddUntilStep("wait for not current", () => !songSelect.IsCurrentScreen()); AddUntilStep("wait for not current", () => !songSelect!.IsCurrentScreen());
AddAssert("ensure selection didn't change", () => selected == Beatmap.Value); AddAssert("ensure selection didn't change", () => selected == Beatmap.Value);
} }
@ -260,11 +259,11 @@ namespace osu.Game.Tests.Visual.SongSelect
createSongSelect(); createSongSelect();
AddStep("push child screen", () => Stack.Push(new TestSceneOsuScreenStack.TestScreen("test child"))); AddStep("push child screen", () => Stack.Push(new TestSceneOsuScreenStack.TestScreen("test child")));
AddUntilStep("wait for not current", () => !songSelect.IsCurrentScreen()); AddUntilStep("wait for not current", () => !songSelect!.IsCurrentScreen());
AddStep("return", () => songSelect.MakeCurrent()); AddStep("return", () => songSelect!.MakeCurrent());
AddUntilStep("wait for current", () => songSelect.IsCurrentScreen()); AddUntilStep("wait for current", () => songSelect!.IsCurrentScreen());
AddAssert("filter count is 1", () => songSelect.FilterCount == 1); AddAssert("filter count is 1", () => songSelect!.FilterCount == 1);
} }
[Test] [Test]
@ -278,13 +277,13 @@ namespace osu.Game.Tests.Visual.SongSelect
createSongSelect(); createSongSelect();
AddStep("push child screen", () => Stack.Push(new TestSceneOsuScreenStack.TestScreen("test child"))); AddStep("push child screen", () => Stack.Push(new TestSceneOsuScreenStack.TestScreen("test child")));
AddUntilStep("wait for not current", () => !songSelect.IsCurrentScreen()); AddUntilStep("wait for not current", () => !songSelect!.IsCurrentScreen());
AddStep("change convert setting", () => config.SetValue(OsuSetting.ShowConvertedBeatmaps, true)); AddStep("change convert setting", () => config.SetValue(OsuSetting.ShowConvertedBeatmaps, true));
AddStep("return", () => songSelect.MakeCurrent()); AddStep("return", () => songSelect!.MakeCurrent());
AddUntilStep("wait for current", () => songSelect.IsCurrentScreen()); AddUntilStep("wait for current", () => songSelect!.IsCurrentScreen());
AddAssert("filter count is 2", () => songSelect.FilterCount == 2); AddAssert("filter count is 2", () => songSelect!.FilterCount == 2);
} }
[Test] [Test]
@ -295,7 +294,7 @@ namespace osu.Game.Tests.Visual.SongSelect
createSongSelect(); createSongSelect();
AddStep("push child screen", () => Stack.Push(new TestSceneOsuScreenStack.TestScreen("test child"))); AddStep("push child screen", () => Stack.Push(new TestSceneOsuScreenStack.TestScreen("test child")));
AddUntilStep("wait for not current", () => !songSelect.IsCurrentScreen()); AddUntilStep("wait for not current", () => !songSelect!.IsCurrentScreen());
AddStep("update beatmap", () => AddStep("update beatmap", () =>
{ {
@ -304,9 +303,9 @@ namespace osu.Game.Tests.Visual.SongSelect
Beatmap.Value = manager.GetWorkingBeatmap(anotherBeatmap); Beatmap.Value = manager.GetWorkingBeatmap(anotherBeatmap);
}); });
AddStep("return", () => songSelect.MakeCurrent()); AddStep("return", () => songSelect!.MakeCurrent());
AddUntilStep("wait for current", () => songSelect.IsCurrentScreen()); AddUntilStep("wait for current", () => songSelect!.IsCurrentScreen());
AddAssert("carousel updated", () => songSelect.Carousel.SelectedBeatmapInfo.Equals(Beatmap.Value.BeatmapInfo)); AddAssert("carousel updated", () => songSelect!.Carousel.SelectedBeatmapInfo?.Equals(Beatmap.Value.BeatmapInfo) == true);
} }
[Test] [Test]
@ -318,15 +317,15 @@ namespace osu.Game.Tests.Visual.SongSelect
addRulesetImportStep(0); addRulesetImportStep(0);
checkMusicPlaying(true); checkMusicPlaying(true);
AddStep("select first", () => songSelect.Carousel.SelectBeatmap(songSelect.Carousel.BeatmapSets.First().Beatmaps.First())); AddStep("select first", () => songSelect!.Carousel.SelectBeatmap(songSelect!.Carousel.BeatmapSets.First().Beatmaps.First()));
checkMusicPlaying(true); checkMusicPlaying(true);
AddStep("manual pause", () => music.TogglePause()); AddStep("manual pause", () => music.TogglePause());
checkMusicPlaying(false); checkMusicPlaying(false);
AddStep("select next difficulty", () => songSelect.Carousel.SelectNext(skipDifficulties: false)); AddStep("select next difficulty", () => songSelect!.Carousel.SelectNext(skipDifficulties: false));
checkMusicPlaying(false); checkMusicPlaying(false);
AddStep("select next set", () => songSelect.Carousel.SelectNext()); AddStep("select next set", () => songSelect!.Carousel.SelectNext());
checkMusicPlaying(true); checkMusicPlaying(true);
} }
@ -366,13 +365,13 @@ namespace osu.Game.Tests.Visual.SongSelect
public void TestDummy() public void TestDummy()
{ {
createSongSelect(); createSongSelect();
AddUntilStep("dummy selected", () => songSelect.CurrentBeatmap == defaultBeatmap); AddUntilStep("dummy selected", () => songSelect!.CurrentBeatmap == defaultBeatmap);
AddUntilStep("dummy shown on wedge", () => songSelect.CurrentBeatmapDetailsBeatmap == defaultBeatmap); AddUntilStep("dummy shown on wedge", () => songSelect!.CurrentBeatmapDetailsBeatmap == defaultBeatmap);
addManyTestMaps(); addManyTestMaps();
AddUntilStep("random map selected", () => songSelect.CurrentBeatmap != defaultBeatmap); AddUntilStep("random map selected", () => songSelect!.CurrentBeatmap != defaultBeatmap);
} }
[Test] [Test]
@ -381,7 +380,7 @@ namespace osu.Game.Tests.Visual.SongSelect
createSongSelect(); createSongSelect();
addManyTestMaps(); addManyTestMaps();
AddUntilStep("random map selected", () => songSelect.CurrentBeatmap != defaultBeatmap); AddUntilStep("random map selected", () => songSelect!.CurrentBeatmap != defaultBeatmap);
AddStep(@"Sort by Artist", () => config.SetValue(OsuSetting.SongSelectSortingMode, SortMode.Artist)); AddStep(@"Sort by Artist", () => config.SetValue(OsuSetting.SongSelectSortingMode, SortMode.Artist));
AddStep(@"Sort by Title", () => config.SetValue(OsuSetting.SongSelectSortingMode, SortMode.Title)); AddStep(@"Sort by Title", () => config.SetValue(OsuSetting.SongSelectSortingMode, SortMode.Title));
@ -398,7 +397,7 @@ namespace osu.Game.Tests.Visual.SongSelect
{ {
createSongSelect(); createSongSelect();
addRulesetImportStep(2); addRulesetImportStep(2);
AddUntilStep("no selection", () => songSelect.Carousel.SelectedBeatmapInfo == null); AddUntilStep("no selection", () => songSelect!.Carousel.SelectedBeatmapInfo == null);
} }
[Test] [Test]
@ -408,13 +407,13 @@ namespace osu.Game.Tests.Visual.SongSelect
changeRuleset(2); changeRuleset(2);
addRulesetImportStep(2); addRulesetImportStep(2);
addRulesetImportStep(1); addRulesetImportStep(1);
AddUntilStep("has selection", () => songSelect.Carousel.SelectedBeatmapInfo.Ruleset.OnlineID == 2); AddUntilStep("has selection", () => songSelect!.Carousel.SelectedBeatmapInfo?.Ruleset.OnlineID == 2);
changeRuleset(1); changeRuleset(1);
AddUntilStep("has selection", () => songSelect.Carousel.SelectedBeatmapInfo.Ruleset.OnlineID == 1); AddUntilStep("has selection", () => songSelect!.Carousel.SelectedBeatmapInfo?.Ruleset.OnlineID == 1);
changeRuleset(0); changeRuleset(0);
AddUntilStep("no selection", () => songSelect.Carousel.SelectedBeatmapInfo == null); AddUntilStep("no selection", () => songSelect!.Carousel.SelectedBeatmapInfo == null);
} }
[Test] [Test]
@ -423,7 +422,7 @@ namespace osu.Game.Tests.Visual.SongSelect
createSongSelect(); createSongSelect();
changeRuleset(0); changeRuleset(0);
Live<BeatmapSetInfo> original = null!; Live<BeatmapSetInfo>? original = null;
int originalOnlineSetID = 0; int originalOnlineSetID = 0;
AddStep(@"Sort by artist", () => config.SetValue(OsuSetting.SongSelectSortingMode, SortMode.Artist)); AddStep(@"Sort by artist", () => config.SetValue(OsuSetting.SongSelectSortingMode, SortMode.Artist));
@ -431,12 +430,17 @@ namespace osu.Game.Tests.Visual.SongSelect
AddStep("import original", () => AddStep("import original", () =>
{ {
original = manager.Import(new ImportTask(TestResources.GetQuickTestBeatmapForImport())).GetResultSafely(); original = manager.Import(new ImportTask(TestResources.GetQuickTestBeatmapForImport())).GetResultSafely();
originalOnlineSetID = original!.Value.OnlineID;
Debug.Assert(original != null);
originalOnlineSetID = original.Value.OnlineID;
}); });
// This will move the beatmap set to a different location in the carousel. // This will move the beatmap set to a different location in the carousel.
AddStep("Update original with bogus info", () => AddStep("Update original with bogus info", () =>
{ {
Debug.Assert(original != null);
original.PerformWrite(set => original.PerformWrite(set =>
{ {
foreach (var beatmap in set.Beatmaps) foreach (var beatmap in set.Beatmaps)
@ -457,13 +461,19 @@ namespace osu.Game.Tests.Visual.SongSelect
manager.Import(testBeatmapSetInfo); manager.Import(testBeatmapSetInfo);
}, 10); }, 10);
AddUntilStep("has selection", () => songSelect.Carousel.SelectedBeatmapInfo?.BeatmapSet?.OnlineID == originalOnlineSetID); AddUntilStep("has selection", () => songSelect!.Carousel.SelectedBeatmapInfo?.BeatmapSet?.OnlineID == originalOnlineSetID);
Task<Live<BeatmapSetInfo>> updateTask = null!; Task<Live<BeatmapSetInfo>?> updateTask = null!;
AddStep("update beatmap", () => updateTask = manager.ImportAsUpdate(new ProgressNotification(), new ImportTask(TestResources.GetQuickTestBeatmapForImport()), original.Value));
AddStep("update beatmap", () =>
{
Debug.Assert(original != null);
updateTask = manager.ImportAsUpdate(new ProgressNotification(), new ImportTask(TestResources.GetQuickTestBeatmapForImport()), original.Value);
});
AddUntilStep("wait for update completion", () => updateTask.IsCompleted); AddUntilStep("wait for update completion", () => updateTask.IsCompleted);
AddUntilStep("retained selection", () => songSelect.Carousel.SelectedBeatmapInfo?.BeatmapSet?.OnlineID == originalOnlineSetID); AddUntilStep("retained selection", () => songSelect!.Carousel.SelectedBeatmapInfo?.BeatmapSet?.OnlineID == originalOnlineSetID);
} }
[Test] [Test]
@ -473,13 +483,13 @@ namespace osu.Game.Tests.Visual.SongSelect
changeRuleset(2); changeRuleset(2);
addRulesetImportStep(2); addRulesetImportStep(2);
AddUntilStep("has selection", () => songSelect.Carousel.SelectedBeatmapInfo.Ruleset.OnlineID == 2); AddUntilStep("has selection", () => songSelect!.Carousel.SelectedBeatmapInfo?.Ruleset.OnlineID == 2);
addRulesetImportStep(0); addRulesetImportStep(0);
addRulesetImportStep(0); addRulesetImportStep(0);
addRulesetImportStep(0); addRulesetImportStep(0);
BeatmapInfo target = null; BeatmapInfo? target = null;
AddStep("select beatmap/ruleset externally", () => AddStep("select beatmap/ruleset externally", () =>
{ {
@ -490,10 +500,10 @@ namespace osu.Game.Tests.Visual.SongSelect
Beatmap.Value = manager.GetWorkingBeatmap(target); Beatmap.Value = manager.GetWorkingBeatmap(target);
}); });
AddUntilStep("has selection", () => songSelect.Carousel.SelectedBeatmapInfo.Equals(target)); AddUntilStep("has selection", () => songSelect!.Carousel.SelectedBeatmapInfo?.Equals(target) == true);
// this is an important check, to make sure updateComponentFromBeatmap() was actually run // this is an important check, to make sure updateComponentFromBeatmap() was actually run
AddUntilStep("selection shown on wedge", () => songSelect.CurrentBeatmapDetailsBeatmap.BeatmapInfo.MatchesOnlineID(target)); AddUntilStep("selection shown on wedge", () => songSelect!.CurrentBeatmapDetailsBeatmap.BeatmapInfo.MatchesOnlineID(target));
} }
[Test] [Test]
@ -503,13 +513,13 @@ namespace osu.Game.Tests.Visual.SongSelect
changeRuleset(2); changeRuleset(2);
addRulesetImportStep(2); addRulesetImportStep(2);
AddUntilStep("has selection", () => songSelect.Carousel.SelectedBeatmapInfo.Ruleset.OnlineID == 2); AddUntilStep("has selection", () => songSelect!.Carousel.SelectedBeatmapInfo?.Ruleset.OnlineID == 2);
addRulesetImportStep(0); addRulesetImportStep(0);
addRulesetImportStep(0); addRulesetImportStep(0);
addRulesetImportStep(0); addRulesetImportStep(0);
BeatmapInfo target = null; BeatmapInfo? target = null;
AddStep("select beatmap/ruleset externally", () => AddStep("select beatmap/ruleset externally", () =>
{ {
@ -520,12 +530,12 @@ namespace osu.Game.Tests.Visual.SongSelect
Ruleset.Value = rulesets.AvailableRulesets.First(r => r.OnlineID == 0); Ruleset.Value = rulesets.AvailableRulesets.First(r => r.OnlineID == 0);
}); });
AddUntilStep("has selection", () => songSelect.Carousel.SelectedBeatmapInfo.Equals(target)); AddUntilStep("has selection", () => songSelect!.Carousel.SelectedBeatmapInfo?.Equals(target) == true);
AddUntilStep("has correct ruleset", () => Ruleset.Value.OnlineID == 0); AddUntilStep("has correct ruleset", () => Ruleset.Value.OnlineID == 0);
// this is an important check, to make sure updateComponentFromBeatmap() was actually run // this is an important check, to make sure updateComponentFromBeatmap() was actually run
AddUntilStep("selection shown on wedge", () => songSelect.CurrentBeatmapDetailsBeatmap.BeatmapInfo.MatchesOnlineID(target)); AddUntilStep("selection shown on wedge", () => songSelect!.CurrentBeatmapDetailsBeatmap.BeatmapInfo.MatchesOnlineID(target));
} }
[Test] [Test]
@ -543,12 +553,12 @@ namespace osu.Game.Tests.Visual.SongSelect
AddStep("change ruleset", () => AddStep("change ruleset", () =>
{ {
SelectedMods.ValueChanged += onModChange; SelectedMods.ValueChanged += onModChange;
songSelect.Ruleset.ValueChanged += onRulesetChange; songSelect!.Ruleset.ValueChanged += onRulesetChange;
Ruleset.Value = new TaikoRuleset().RulesetInfo; Ruleset.Value = new TaikoRuleset().RulesetInfo;
SelectedMods.ValueChanged -= onModChange; SelectedMods.ValueChanged -= onModChange;
songSelect.Ruleset.ValueChanged -= onRulesetChange; songSelect!.Ruleset.ValueChanged -= onRulesetChange;
}); });
AddAssert("mods changed before ruleset", () => modChangeIndex < rulesetChangeIndex); AddAssert("mods changed before ruleset", () => modChangeIndex < rulesetChangeIndex);
@ -579,18 +589,18 @@ namespace osu.Game.Tests.Visual.SongSelect
{ {
createSongSelect(); createSongSelect();
addManyTestMaps(); addManyTestMaps();
AddUntilStep("has selection", () => songSelect.Carousel.SelectedBeatmapInfo != null); AddUntilStep("has selection", () => songSelect!.Carousel.SelectedBeatmapInfo != null);
bool startRequested = false; bool startRequested = false;
AddStep("set filter and finalize", () => AddStep("set filter and finalize", () =>
{ {
songSelect.StartRequested = () => startRequested = true; songSelect!.StartRequested = () => startRequested = true;
songSelect.Carousel.Filter(new FilterCriteria { SearchText = "somestringthatshouldn'tbematchable" }); songSelect!.Carousel.Filter(new FilterCriteria { SearchText = "somestringthatshouldn'tbematchable" });
songSelect.FinaliseSelection(); songSelect!.FinaliseSelection();
songSelect.StartRequested = null; songSelect!.StartRequested = null;
}); });
AddAssert("start not requested", () => !startRequested); AddAssert("start not requested", () => !startRequested);
@ -610,15 +620,15 @@ namespace osu.Game.Tests.Visual.SongSelect
// used for filter check below // used for filter check below
AddStep("allow convert display", () => config.SetValue(OsuSetting.ShowConvertedBeatmaps, true)); AddStep("allow convert display", () => config.SetValue(OsuSetting.ShowConvertedBeatmaps, true));
AddUntilStep("has selection", () => songSelect.Carousel.SelectedBeatmapInfo != null); AddUntilStep("has selection", () => songSelect!.Carousel.SelectedBeatmapInfo != null);
AddStep("set filter text", () => songSelect.FilterControl.ChildrenOfType<SearchTextBox>().First().Text = "nonono"); AddStep("set filter text", () => songSelect!.FilterControl.ChildrenOfType<SearchTextBox>().First().Text = "nonono");
AddUntilStep("dummy selected", () => Beatmap.Value is DummyWorkingBeatmap); AddUntilStep("dummy selected", () => Beatmap.Value is DummyWorkingBeatmap);
AddUntilStep("has no selection", () => songSelect.Carousel.SelectedBeatmapInfo == null); AddUntilStep("has no selection", () => songSelect!.Carousel.SelectedBeatmapInfo == null);
BeatmapInfo target = null; BeatmapInfo? target = null;
int targetRuleset = differentRuleset ? 1 : 0; int targetRuleset = differentRuleset ? 1 : 0;
@ -632,24 +642,24 @@ namespace osu.Game.Tests.Visual.SongSelect
Beatmap.Value = manager.GetWorkingBeatmap(target); Beatmap.Value = manager.GetWorkingBeatmap(target);
}); });
AddUntilStep("has selection", () => songSelect.Carousel.SelectedBeatmapInfo != null); AddUntilStep("has selection", () => songSelect!.Carousel.SelectedBeatmapInfo != null);
AddAssert("selected only shows expected ruleset (plus converts)", () => AddAssert("selected only shows expected ruleset (plus converts)", () =>
{ {
var selectedPanel = songSelect.Carousel.ChildrenOfType<DrawableCarouselBeatmapSet>().First(s => s.Item.State.Value == CarouselItemState.Selected); var selectedPanel = songSelect!.Carousel.ChildrenOfType<DrawableCarouselBeatmapSet>().First(s => s.Item.State.Value == CarouselItemState.Selected);
// special case for converts checked here. // special case for converts checked here.
return selectedPanel.ChildrenOfType<FilterableDifficultyIcon>().All(i => return selectedPanel.ChildrenOfType<FilterableDifficultyIcon>().All(i =>
i.IsFiltered || i.Item.BeatmapInfo.Ruleset.OnlineID == targetRuleset || i.Item.BeatmapInfo.Ruleset.OnlineID == 0); i.IsFiltered || i.Item.BeatmapInfo.Ruleset.OnlineID == targetRuleset || i.Item.BeatmapInfo.Ruleset.OnlineID == 0);
}); });
AddUntilStep("carousel has correct", () => songSelect.Carousel.SelectedBeatmapInfo?.MatchesOnlineID(target) == true); AddUntilStep("carousel has correct", () => songSelect!.Carousel.SelectedBeatmapInfo?.MatchesOnlineID(target) == true);
AddUntilStep("game has correct", () => Beatmap.Value.BeatmapInfo.MatchesOnlineID(target)); AddUntilStep("game has correct", () => Beatmap.Value.BeatmapInfo.MatchesOnlineID(target));
AddStep("reset filter text", () => songSelect.FilterControl.ChildrenOfType<SearchTextBox>().First().Text = string.Empty); AddStep("reset filter text", () => songSelect!.FilterControl.ChildrenOfType<SearchTextBox>().First().Text = string.Empty);
AddAssert("game still correct", () => Beatmap.Value?.BeatmapInfo.MatchesOnlineID(target) == true); AddAssert("game still correct", () => Beatmap.Value?.BeatmapInfo.MatchesOnlineID(target) == true);
AddAssert("carousel still correct", () => songSelect.Carousel.SelectedBeatmapInfo.MatchesOnlineID(target)); AddAssert("carousel still correct", () => songSelect!.Carousel.SelectedBeatmapInfo.MatchesOnlineID(target));
} }
[Test] [Test]
@ -662,15 +672,15 @@ namespace osu.Game.Tests.Visual.SongSelect
changeRuleset(0); changeRuleset(0);
AddUntilStep("has selection", () => songSelect.Carousel.SelectedBeatmapInfo != null); AddUntilStep("has selection", () => songSelect!.Carousel.SelectedBeatmapInfo != null);
AddStep("set filter text", () => songSelect.FilterControl.ChildrenOfType<SearchTextBox>().First().Text = "nonono"); AddStep("set filter text", () => songSelect!.FilterControl.ChildrenOfType<SearchTextBox>().First().Text = "nonono");
AddUntilStep("dummy selected", () => Beatmap.Value is DummyWorkingBeatmap); AddUntilStep("dummy selected", () => Beatmap.Value is DummyWorkingBeatmap);
AddUntilStep("has no selection", () => songSelect.Carousel.SelectedBeatmapInfo == null); AddUntilStep("has no selection", () => songSelect!.Carousel.SelectedBeatmapInfo == null);
BeatmapInfo target = null; BeatmapInfo? target = null;
AddStep("select beatmap externally", () => AddStep("select beatmap externally", () =>
{ {
@ -682,15 +692,15 @@ namespace osu.Game.Tests.Visual.SongSelect
Beatmap.Value = manager.GetWorkingBeatmap(target); Beatmap.Value = manager.GetWorkingBeatmap(target);
}); });
AddUntilStep("has selection", () => songSelect.Carousel.SelectedBeatmapInfo != null); AddUntilStep("has selection", () => songSelect!.Carousel.SelectedBeatmapInfo != null);
AddUntilStep("carousel has correct", () => songSelect.Carousel.SelectedBeatmapInfo?.MatchesOnlineID(target) == true); AddUntilStep("carousel has correct", () => songSelect!.Carousel.SelectedBeatmapInfo?.MatchesOnlineID(target) == true);
AddUntilStep("game has correct", () => Beatmap.Value.BeatmapInfo.MatchesOnlineID(target)); AddUntilStep("game has correct", () => Beatmap.Value.BeatmapInfo.MatchesOnlineID(target));
AddStep("set filter text", () => songSelect.FilterControl.ChildrenOfType<SearchTextBox>().First().Text = "nononoo"); AddStep("set filter text", () => songSelect!.FilterControl.ChildrenOfType<SearchTextBox>().First().Text = "nononoo");
AddUntilStep("game lost selection", () => Beatmap.Value is DummyWorkingBeatmap); AddUntilStep("game lost selection", () => Beatmap.Value is DummyWorkingBeatmap);
AddAssert("carousel lost selection", () => songSelect.Carousel.SelectedBeatmapInfo == null); AddAssert("carousel lost selection", () => songSelect!.Carousel.SelectedBeatmapInfo == null);
} }
[Test] [Test]
@ -711,11 +721,11 @@ namespace osu.Game.Tests.Visual.SongSelect
AddUntilStep("wait for player", () => Stack.CurrentScreen is PlayerLoader); AddUntilStep("wait for player", () => Stack.CurrentScreen is PlayerLoader);
AddAssert("autoplay selected", () => songSelect.Mods.Value.Single() is ModAutoplay); AddAssert("autoplay selected", () => songSelect!.Mods.Value.Single() is ModAutoplay);
AddUntilStep("wait for return to ss", () => songSelect.IsCurrentScreen()); AddUntilStep("wait for return to ss", () => songSelect!.IsCurrentScreen());
AddAssert("no mods selected", () => songSelect.Mods.Value.Count == 0); AddAssert("no mods selected", () => songSelect!.Mods.Value.Count == 0);
} }
[Test] [Test]
@ -738,11 +748,11 @@ namespace osu.Game.Tests.Visual.SongSelect
AddUntilStep("wait for player", () => Stack.CurrentScreen is PlayerLoader); AddUntilStep("wait for player", () => Stack.CurrentScreen is PlayerLoader);
AddAssert("autoplay selected", () => songSelect.Mods.Value.Single() is ModAutoplay); AddAssert("autoplay selected", () => songSelect!.Mods.Value.Single() is ModAutoplay);
AddUntilStep("wait for return to ss", () => songSelect.IsCurrentScreen()); AddUntilStep("wait for return to ss", () => songSelect!.IsCurrentScreen());
AddAssert("autoplay still selected", () => songSelect.Mods.Value.Single() is ModAutoplay); AddAssert("autoplay still selected", () => songSelect!.Mods.Value.Single() is ModAutoplay);
} }
[Test] [Test]
@ -765,11 +775,11 @@ namespace osu.Game.Tests.Visual.SongSelect
AddUntilStep("wait for player", () => Stack.CurrentScreen is PlayerLoader); AddUntilStep("wait for player", () => Stack.CurrentScreen is PlayerLoader);
AddAssert("only autoplay selected", () => songSelect.Mods.Value.Single() is ModAutoplay); AddAssert("only autoplay selected", () => songSelect!.Mods.Value.Single() is ModAutoplay);
AddUntilStep("wait for return to ss", () => songSelect.IsCurrentScreen()); AddUntilStep("wait for return to ss", () => songSelect!.IsCurrentScreen());
AddAssert("relax returned", () => songSelect.Mods.Value.Single() is ModRelax); AddAssert("relax returned", () => songSelect!.Mods.Value.Single() is ModRelax);
} }
[Test] [Test]
@ -778,10 +788,10 @@ namespace osu.Game.Tests.Visual.SongSelect
Guid? previousID = null; Guid? previousID = null;
createSongSelect(); createSongSelect();
addRulesetImportStep(0); addRulesetImportStep(0);
AddStep("Move to last difficulty", () => songSelect.Carousel.SelectBeatmap(songSelect.Carousel.BeatmapSets.First().Beatmaps.Last())); AddStep("Move to last difficulty", () => songSelect!.Carousel.SelectBeatmap(songSelect!.Carousel.BeatmapSets.First().Beatmaps.Last()));
AddStep("Store current ID", () => previousID = songSelect.Carousel.SelectedBeatmapInfo.ID); AddStep("Store current ID", () => previousID = songSelect!.Carousel.SelectedBeatmapInfo!.ID);
AddStep("Hide first beatmap", () => manager.Hide(songSelect.Carousel.SelectedBeatmapSet.Beatmaps.First())); AddStep("Hide first beatmap", () => manager.Hide(songSelect!.Carousel.SelectedBeatmapSet!.Beatmaps.First()));
AddAssert("Selected beatmap has not changed", () => songSelect.Carousel.SelectedBeatmapInfo.ID == previousID); AddAssert("Selected beatmap has not changed", () => songSelect!.Carousel.SelectedBeatmapInfo?.ID == previousID);
} }
[Test] [Test]
@ -792,17 +802,24 @@ namespace osu.Game.Tests.Visual.SongSelect
AddUntilStep("wait for selection", () => !Beatmap.IsDefault); AddUntilStep("wait for selection", () => !Beatmap.IsDefault);
DrawableCarouselBeatmapSet set = null; DrawableCarouselBeatmapSet set = null!;
AddStep("Find the DrawableCarouselBeatmapSet", () => AddStep("Find the DrawableCarouselBeatmapSet", () =>
{ {
set = songSelect.Carousel.ChildrenOfType<DrawableCarouselBeatmapSet>().First(); set = songSelect!.Carousel.ChildrenOfType<DrawableCarouselBeatmapSet>().First();
}); });
FilterableDifficultyIcon difficultyIcon = null; FilterableDifficultyIcon difficultyIcon = null!;
AddUntilStep("Find an icon", () => AddUntilStep("Find an icon", () =>
{ {
return (difficultyIcon = set.ChildrenOfType<FilterableDifficultyIcon>() var foundIcon = set.ChildrenOfType<FilterableDifficultyIcon>()
.FirstOrDefault(icon => getDifficultyIconIndex(set, icon) != getCurrentBeatmapIndex())) != null; .FirstOrDefault(icon => getDifficultyIconIndex(set, icon) != getCurrentBeatmapIndex());
if (foundIcon == null)
return false;
difficultyIcon = foundIcon;
return true;
}); });
AddStep("Click on a difficulty", () => AddStep("Click on a difficulty", () =>
@ -815,21 +832,24 @@ namespace osu.Game.Tests.Visual.SongSelect
AddAssert("Selected beatmap correct", () => getCurrentBeatmapIndex() == getDifficultyIconIndex(set, difficultyIcon)); AddAssert("Selected beatmap correct", () => getCurrentBeatmapIndex() == getDifficultyIconIndex(set, difficultyIcon));
double? maxBPM = null; double? maxBPM = null;
AddStep("Filter some difficulties", () => songSelect.Carousel.Filter(new FilterCriteria AddStep("Filter some difficulties", () => songSelect!.Carousel.Filter(new FilterCriteria
{ {
BPM = new FilterCriteria.OptionalRange<double> BPM = new FilterCriteria.OptionalRange<double>
{ {
Min = maxBPM = songSelect.Carousel.SelectedBeatmapSet.MaxBPM, Min = maxBPM = songSelect!.Carousel.SelectedBeatmapSet!.MaxBPM,
IsLowerInclusive = true IsLowerInclusive = true
} }
})); }));
BeatmapInfo filteredBeatmap = null; BeatmapInfo? filteredBeatmap = null;
FilterableDifficultyIcon filteredIcon = null; FilterableDifficultyIcon? filteredIcon = null;
AddStep("Get filtered icon", () => AddStep("Get filtered icon", () =>
{ {
var selectedSet = songSelect.Carousel.SelectedBeatmapSet; var selectedSet = songSelect!.Carousel.SelectedBeatmapSet;
Debug.Assert(selectedSet != null);
filteredBeatmap = selectedSet.Beatmaps.First(b => b.BPM < maxBPM); filteredBeatmap = selectedSet.Beatmaps.First(b => b.BPM < maxBPM);
int filteredBeatmapIndex = getBeatmapIndex(selectedSet, filteredBeatmap); int filteredBeatmapIndex = getBeatmapIndex(selectedSet, filteredBeatmap);
filteredIcon = set.ChildrenOfType<FilterableDifficultyIcon>().ElementAt(filteredBeatmapIndex); filteredIcon = set.ChildrenOfType<FilterableDifficultyIcon>().ElementAt(filteredBeatmapIndex);
@ -842,7 +862,7 @@ namespace osu.Game.Tests.Visual.SongSelect
InputManager.Click(MouseButton.Left); InputManager.Click(MouseButton.Left);
}); });
AddAssert("Selected beatmap correct", () => songSelect.Carousel.SelectedBeatmapInfo.Equals(filteredBeatmap)); AddAssert("Selected beatmap correct", () => songSelect!.Carousel.SelectedBeatmapInfo?.Equals(filteredBeatmap) == true);
} }
[Test] [Test]
@ -907,14 +927,14 @@ namespace osu.Game.Tests.Visual.SongSelect
manager.Import(TestResources.CreateTestBeatmapSetInfo(3, usableRulesets)); manager.Import(TestResources.CreateTestBeatmapSetInfo(3, usableRulesets));
}); });
DrawableCarouselBeatmapSet set = null; DrawableCarouselBeatmapSet? set = null;
AddUntilStep("Find the DrawableCarouselBeatmapSet", () => AddUntilStep("Find the DrawableCarouselBeatmapSet", () =>
{ {
set = songSelect.Carousel.ChildrenOfType<DrawableCarouselBeatmapSet>().FirstOrDefault(); set = songSelect!.Carousel.ChildrenOfType<DrawableCarouselBeatmapSet>().FirstOrDefault();
return set != null; return set != null;
}); });
FilterableDifficultyIcon difficultyIcon = null; FilterableDifficultyIcon? difficultyIcon = null;
AddUntilStep("Find an icon for different ruleset", () => AddUntilStep("Find an icon for different ruleset", () =>
{ {
difficultyIcon = set.ChildrenOfType<FilterableDifficultyIcon>() difficultyIcon = set.ChildrenOfType<FilterableDifficultyIcon>()
@ -937,7 +957,7 @@ namespace osu.Game.Tests.Visual.SongSelect
AddUntilStep("Check ruleset changed to mania", () => Ruleset.Value.OnlineID == 3); AddUntilStep("Check ruleset changed to mania", () => Ruleset.Value.OnlineID == 3);
AddAssert("Selected beatmap still same set", () => songSelect.Carousel.SelectedBeatmapInfo.BeatmapSet?.OnlineID == previousSetID); AddAssert("Selected beatmap still same set", () => songSelect!.Carousel.SelectedBeatmapInfo?.BeatmapSet?.OnlineID == previousSetID);
AddAssert("Selected beatmap is mania", () => Beatmap.Value.BeatmapInfo.Ruleset.OnlineID == 3); AddAssert("Selected beatmap is mania", () => Beatmap.Value.BeatmapInfo.Ruleset.OnlineID == 3);
} }
@ -948,7 +968,7 @@ namespace osu.Game.Tests.Visual.SongSelect
createSongSelect(); createSongSelect();
BeatmapSetInfo imported = null; BeatmapSetInfo? imported = null;
AddStep("import huge difficulty count map", () => AddStep("import huge difficulty count map", () =>
{ {
@ -956,20 +976,27 @@ namespace osu.Game.Tests.Visual.SongSelect
imported = manager.Import(TestResources.CreateTestBeatmapSetInfo(50, usableRulesets))?.Value; imported = manager.Import(TestResources.CreateTestBeatmapSetInfo(50, usableRulesets))?.Value;
}); });
AddStep("select the first beatmap of import", () => Beatmap.Value = manager.GetWorkingBeatmap(imported.Beatmaps.First())); AddStep("select the first beatmap of import", () => Beatmap.Value = manager.GetWorkingBeatmap(imported?.Beatmaps.First()));
DrawableCarouselBeatmapSet set = null; DrawableCarouselBeatmapSet? set = null;
AddUntilStep("Find the DrawableCarouselBeatmapSet", () => AddUntilStep("Find the DrawableCarouselBeatmapSet", () =>
{ {
set = songSelect.Carousel.ChildrenOfType<DrawableCarouselBeatmapSet>().FirstOrDefault(); set = songSelect!.Carousel.ChildrenOfType<DrawableCarouselBeatmapSet>().FirstOrDefault();
return set != null; return set != null;
}); });
GroupedDifficultyIcon groupIcon = null; GroupedDifficultyIcon groupIcon = null!;
AddUntilStep("Find group icon for different ruleset", () => AddUntilStep("Find group icon for different ruleset", () =>
{ {
return (groupIcon = set.ChildrenOfType<GroupedDifficultyIcon>() var foundIcon = set.ChildrenOfType<GroupedDifficultyIcon>()
.FirstOrDefault(icon => icon.Items.First().BeatmapInfo.Ruleset.OnlineID == 3)) != null; .FirstOrDefault(icon => icon.Items.First().BeatmapInfo.Ruleset.OnlineID == 3);
if (foundIcon == null)
return false;
groupIcon = foundIcon;
return true;
}); });
AddAssert("Check ruleset is osu!", () => Ruleset.Value.OnlineID == 0); AddAssert("Check ruleset is osu!", () => Ruleset.Value.OnlineID == 0);
@ -1004,7 +1031,7 @@ namespace osu.Game.Tests.Visual.SongSelect
// this ruleset change should be overridden by the present. // this ruleset change should be overridden by the present.
Ruleset.Value = getSwitchBeatmap().Ruleset; Ruleset.Value = getSwitchBeatmap().Ruleset;
songSelect.PresentScore(new ScoreInfo songSelect!.PresentScore(new ScoreInfo
{ {
User = new APIUser { Username = "woo" }, User = new APIUser { Username = "woo" },
BeatmapInfo = getPresentBeatmap(), BeatmapInfo = getPresentBeatmap(),
@ -1012,7 +1039,7 @@ namespace osu.Game.Tests.Visual.SongSelect
}); });
}); });
AddUntilStep("wait for results screen presented", () => !songSelect.IsCurrentScreen()); AddUntilStep("wait for results screen presented", () => !songSelect!.IsCurrentScreen());
AddAssert("check beatmap is correct for score", () => Beatmap.Value.BeatmapInfo.MatchesOnlineID(getPresentBeatmap())); AddAssert("check beatmap is correct for score", () => Beatmap.Value.BeatmapInfo.MatchesOnlineID(getPresentBeatmap()));
AddAssert("check ruleset is correct for score", () => Ruleset.Value.OnlineID == 0); AddAssert("check ruleset is correct for score", () => Ruleset.Value.OnlineID == 0);
@ -1038,10 +1065,10 @@ namespace osu.Game.Tests.Visual.SongSelect
// this beatmap change should be overridden by the present. // this beatmap change should be overridden by the present.
Beatmap.Value = manager.GetWorkingBeatmap(getSwitchBeatmap()); Beatmap.Value = manager.GetWorkingBeatmap(getSwitchBeatmap());
songSelect.PresentScore(TestResources.CreateTestScoreInfo(getPresentBeatmap())); songSelect!.PresentScore(TestResources.CreateTestScoreInfo(getPresentBeatmap()));
}); });
AddUntilStep("wait for results screen presented", () => !songSelect.IsCurrentScreen()); AddUntilStep("wait for results screen presented", () => !songSelect!.IsCurrentScreen());
AddAssert("check beatmap is correct for score", () => Beatmap.Value.BeatmapInfo.MatchesOnlineID(getPresentBeatmap())); AddAssert("check beatmap is correct for score", () => Beatmap.Value.BeatmapInfo.MatchesOnlineID(getPresentBeatmap()));
AddAssert("check ruleset is correct for score", () => Ruleset.Value.OnlineID == 0); AddAssert("check ruleset is correct for score", () => Ruleset.Value.OnlineID == 0);
@ -1054,23 +1081,29 @@ namespace osu.Game.Tests.Visual.SongSelect
createSongSelect(); createSongSelect();
AddStep("toggle mod overlay on", () => InputManager.Key(Key.F1)); AddStep("toggle mod overlay on", () => InputManager.Key(Key.F1));
AddUntilStep("mod overlay shown", () => songSelect.ModSelect.State.Value == Visibility.Visible); AddUntilStep("mod overlay shown", () => songSelect!.ModSelect.State.Value == Visibility.Visible);
AddStep("toggle mod overlay off", () => InputManager.Key(Key.F1)); AddStep("toggle mod overlay off", () => InputManager.Key(Key.F1));
AddUntilStep("mod overlay hidden", () => songSelect.ModSelect.State.Value == Visibility.Hidden); AddUntilStep("mod overlay hidden", () => songSelect!.ModSelect.State.Value == Visibility.Hidden);
} }
private void waitForInitialSelection() private void waitForInitialSelection()
{ {
AddUntilStep("wait for initial selection", () => !Beatmap.IsDefault); AddUntilStep("wait for initial selection", () => !Beatmap.IsDefault);
AddUntilStep("wait for difficulty panels visible", () => songSelect.Carousel.ChildrenOfType<DrawableCarouselBeatmap>().Any()); AddUntilStep("wait for difficulty panels visible", () => songSelect!.Carousel.ChildrenOfType<DrawableCarouselBeatmap>().Any());
} }
private int getBeatmapIndex(BeatmapSetInfo set, BeatmapInfo info) => set.Beatmaps.IndexOf(info); private int getBeatmapIndex(BeatmapSetInfo set, BeatmapInfo info) => set.Beatmaps.IndexOf(info);
private NoResultsPlaceholder getPlaceholder() => songSelect.ChildrenOfType<NoResultsPlaceholder>().FirstOrDefault(); private NoResultsPlaceholder? getPlaceholder() => songSelect!.ChildrenOfType<NoResultsPlaceholder>().FirstOrDefault();
private int getCurrentBeatmapIndex() => getBeatmapIndex(songSelect.Carousel.SelectedBeatmapSet, songSelect.Carousel.SelectedBeatmapInfo); private int getCurrentBeatmapIndex()
{
Debug.Assert(songSelect!.Carousel.SelectedBeatmapSet != null);
Debug.Assert(songSelect!.Carousel.SelectedBeatmapInfo != null);
return getBeatmapIndex(songSelect!.Carousel.SelectedBeatmapSet, songSelect!.Carousel.SelectedBeatmapInfo);
}
private int getDifficultyIconIndex(DrawableCarouselBeatmapSet set, FilterableDifficultyIcon icon) private int getDifficultyIconIndex(DrawableCarouselBeatmapSet set, FilterableDifficultyIcon icon)
{ {
@ -1079,14 +1112,14 @@ namespace osu.Game.Tests.Visual.SongSelect
private void addRulesetImportStep(int id) private void addRulesetImportStep(int id)
{ {
Live<BeatmapSetInfo> imported = null; Live<BeatmapSetInfo>? imported = null;
AddStep($"import test map for ruleset {id}", () => imported = importForRuleset(id)); AddStep($"import test map for ruleset {id}", () => imported = importForRuleset(id));
// This is specifically for cases where the add is happening post song select load. // This is specifically for cases where the add is happening post song select load.
// For cases where song select is null, the assertions are provided by the load checks. // For cases where song select is null, the assertions are provided by the load checks.
AddUntilStep("wait for imported to arrive in carousel", () => songSelect == null || songSelect.Carousel.BeatmapSets.Any(s => s.ID == imported?.ID)); AddUntilStep("wait for imported to arrive in carousel", () => songSelect == null || songSelect!.Carousel.BeatmapSets.Any(s => s.ID == imported?.ID));
} }
private Live<BeatmapSetInfo> importForRuleset(int id) => manager.Import(TestResources.CreateTestBeatmapSetInfo(3, rulesets.AvailableRulesets.Where(r => r.OnlineID == id).ToArray())); private Live<BeatmapSetInfo>? importForRuleset(int id) => manager.Import(TestResources.CreateTestBeatmapSetInfo(3, rulesets.AvailableRulesets.Where(r => r.OnlineID == id).ToArray()));
private void checkMusicPlaying(bool playing) => private void checkMusicPlaying(bool playing) =>
AddUntilStep($"music {(playing ? "" : "not ")}playing", () => music.IsPlaying == playing); AddUntilStep($"music {(playing ? "" : "not ")}playing", () => music.IsPlaying == playing);
@ -1098,8 +1131,8 @@ namespace osu.Game.Tests.Visual.SongSelect
private void createSongSelect() private void createSongSelect()
{ {
AddStep("create song select", () => LoadScreen(songSelect = new TestSongSelect())); AddStep("create song select", () => LoadScreen(songSelect = new TestSongSelect()));
AddUntilStep("wait for present", () => songSelect.IsCurrentScreen()); AddUntilStep("wait for present", () => songSelect!.IsCurrentScreen());
AddUntilStep("wait for carousel loaded", () => songSelect.Carousel.IsAlive); AddUntilStep("wait for carousel loaded", () => songSelect!.Carousel.IsAlive);
} }
/// <summary> /// <summary>
@ -1123,12 +1156,14 @@ namespace osu.Game.Tests.Visual.SongSelect
protected override void Dispose(bool isDisposing) protected override void Dispose(bool isDisposing)
{ {
base.Dispose(isDisposing); base.Dispose(isDisposing);
rulesets?.Dispose();
if (rulesets.IsNotNull())
rulesets.Dispose();
} }
private class TestSongSelect : PlaySongSelect private class TestSongSelect : PlaySongSelect
{ {
public Action StartRequested; public Action? StartRequested;
public new Bindable<RulesetInfo> Ruleset => base.Ruleset; public new Bindable<RulesetInfo> Ruleset => base.Ruleset;

View File

@ -259,7 +259,7 @@ namespace osu.Game.Tests.Visual.UserInterface
private void removeFacade() private void removeFacade()
{ {
trackingContainer.Remove(logoFacade); trackingContainer.Remove(logoFacade, false);
visualBox.Colour = Color4.White; visualBox.Colour = Color4.White;
moveLogoFacade(); moveLogoFacade();
} }

View File

@ -7,6 +7,7 @@ using NUnit.Framework;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Testing;
using osu.Framework.Utils; using osu.Framework.Utils;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Overlays; using osu.Game.Overlays;
@ -23,9 +24,12 @@ namespace osu.Game.Tests.Visual.UserInterface
private SpriteText displayedCount = null!; private SpriteText displayedCount = null!;
public double TimeToCompleteProgress { get; set; } = 2000;
[SetUp] [SetUp]
public void SetUp() => Schedule(() => public void SetUp() => Schedule(() =>
{ {
TimeToCompleteProgress = 2000;
progressingNotifications.Clear(); progressingNotifications.Clear();
Content.Children = new Drawable[] Content.Children = new Drawable[]
@ -41,10 +45,36 @@ namespace osu.Game.Tests.Visual.UserInterface
notificationOverlay.UnreadCount.ValueChanged += count => { displayedCount.Text = $"displayed count: {count.NewValue}"; }; notificationOverlay.UnreadCount.ValueChanged += count => { displayedCount.Text = $"displayed count: {count.NewValue}"; };
}); });
[Test]
public void TestPresence()
{
AddAssert("tray not present", () => !notificationOverlay.ChildrenOfType<NotificationOverlayToastTray>().Single().IsPresent);
AddAssert("overlay not present", () => !notificationOverlay.IsPresent);
AddStep(@"post notification", sendBackgroundNotification);
AddUntilStep("wait tray not present", () => !notificationOverlay.ChildrenOfType<NotificationOverlayToastTray>().Single().IsPresent);
AddUntilStep("wait overlay not present", () => !notificationOverlay.IsPresent);
}
[Test]
public void TestPresenceWithManualDismiss()
{
AddAssert("tray not present", () => !notificationOverlay.ChildrenOfType<NotificationOverlayToastTray>().Single().IsPresent);
AddAssert("overlay not present", () => !notificationOverlay.IsPresent);
AddStep(@"post notification", sendBackgroundNotification);
AddStep("click notification", () => notificationOverlay.ChildrenOfType<Notification>().Single().TriggerClick());
AddUntilStep("wait tray not present", () => !notificationOverlay.ChildrenOfType<NotificationOverlayToastTray>().Single().IsPresent);
AddUntilStep("wait overlay not present", () => !notificationOverlay.IsPresent);
}
[Test] [Test]
public void TestCompleteProgress() public void TestCompleteProgress()
{ {
ProgressNotification notification = null!; ProgressNotification notification = null!;
AddStep("add progress notification", () => AddStep("add progress notification", () =>
{ {
notification = new ProgressNotification notification = new ProgressNotification
@ -57,6 +87,31 @@ namespace osu.Game.Tests.Visual.UserInterface
}); });
AddUntilStep("wait completion", () => notification.State == ProgressNotificationState.Completed); AddUntilStep("wait completion", () => notification.State == ProgressNotificationState.Completed);
AddAssert("Completion toast shown", () => notificationOverlay.ToastCount == 1);
AddUntilStep("wait forwarded", () => notificationOverlay.ToastCount == 0);
}
[Test]
public void TestCompleteProgressSlow()
{
ProgressNotification notification = null!;
AddStep("Set progress slow", () => TimeToCompleteProgress *= 2);
AddStep("add progress notification", () =>
{
notification = new ProgressNotification
{
Text = @"Uploading to BSS...",
CompletionText = "Uploaded to BSS!",
};
notificationOverlay.Post(notification);
progressingNotifications.Add(notification);
});
AddUntilStep("wait completion", () => notification.State == ProgressNotificationState.Completed);
AddAssert("Completion toast shown", () => notificationOverlay.ToastCount == 1);
} }
[Test] [Test]
@ -177,7 +232,7 @@ namespace osu.Game.Tests.Visual.UserInterface
foreach (var n in progressingNotifications.FindAll(n => n.State == ProgressNotificationState.Active)) foreach (var n in progressingNotifications.FindAll(n => n.State == ProgressNotificationState.Active))
{ {
if (n.Progress < 1) if (n.Progress < 1)
n.Progress += (float)(Time.Elapsed / 2000); n.Progress += (float)(Time.Elapsed / TimeToCompleteProgress);
else else
n.State = ProgressNotificationState.Completed; n.State = ProgressNotificationState.Completed;
} }

View File

@ -53,7 +53,7 @@ namespace osu.Game.Tournament.Tests.Screens
{ {
AddStep("setup screen", () => AddStep("setup screen", () =>
{ {
Remove(chat); Remove(chat, false);
Children = new Drawable[] Children = new Drawable[]
{ {

View File

@ -106,13 +106,16 @@ namespace osu.Game.Tournament.Models
} }
/// <summary> /// <summary>
/// Initialise this match with zeroed scores. Will be a noop if either team is not present. /// Initialise this match with zeroed scores. Will be a noop if either team is not present or if either of the scores are non-zero.
/// </summary> /// </summary>
public void StartMatch() public void StartMatch()
{ {
if (Team1.Value == null || Team2.Value == null) if (Team1.Value == null || Team2.Value == null)
return; return;
if (Team1Score.Value > 0 || Team2Score.Value > 0)
return;
Team1Score.Value = 0; Team1Score.Value = 0;
Team2Score.Value = 0; Team2Score.Value = 0;
} }

View File

@ -93,7 +93,7 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
{ {
allTeams.RemoveAll(gt => gt.Team == team); allTeams.RemoveAll(gt => gt.Team == team);
if (teams.RemoveAll(gt => gt.Team == team) > 0) if (teams.RemoveAll(gt => gt.Team == team, true) > 0)
{ {
TeamsCount--; TeamsCount--;
return true; return true;

View File

@ -170,7 +170,7 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
availableTeams.Add(team); availableTeams.Add(team);
RemoveAll(c => c is ScrollingTeam); RemoveAll(c => c is ScrollingTeam, true);
setScrollState(ScrollState.Idle); setScrollState(ScrollState.Idle);
} }
@ -186,7 +186,7 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
public void ClearTeams() public void ClearTeams()
{ {
availableTeams.Clear(); availableTeams.Clear();
RemoveAll(c => c is ScrollingTeam); RemoveAll(c => c is ScrollingTeam, true);
setScrollState(ScrollState.Idle); setScrollState(ScrollState.Idle);
} }

View File

@ -57,7 +57,7 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
if (allLines.Count == 0) if (allLines.Count == 0)
return; return;
Remove(allLines.First()); Remove(allLines.First(), true);
allLines.Remove(allLines.First()); allLines.Remove(allLines.First());
} }

View File

@ -106,7 +106,7 @@ namespace osu.Game.Tournament.Screens.Editors
break; break;
case NotifyCollectionChangedAction.Remove: case NotifyCollectionChangedAction.Remove:
args.OldItems.Cast<TModel>().ForEach(i => flow.RemoveAll(d => d.Model == i)); args.OldItems.Cast<TModel>().ForEach(i => flow.RemoveAll(d => d.Model == i, true));
break; break;
} }
}; };

View File

@ -25,6 +25,7 @@ namespace osu.Game.Tournament.Screens.Gameplay.Components
public bool ShowScore public bool ShowScore
{ {
get => teamDisplay.ShowScore;
set => teamDisplay.ShowScore = value; set => teamDisplay.ShowScore = value;
} }
@ -92,10 +93,14 @@ namespace osu.Game.Tournament.Screens.Gameplay.Components
private void teamChanged(ValueChangedEvent<TournamentTeam> team) private void teamChanged(ValueChangedEvent<TournamentTeam> team)
{ {
bool wasShowingScores = teamDisplay?.ShowScore ?? false;
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
{ {
teamDisplay = new TeamDisplay(team.NewValue, teamColour, currentTeamScore, currentMatch.Value?.PointsToWin ?? 0), teamDisplay = new TeamDisplay(team.NewValue, teamColour, currentTeamScore, currentMatch.Value?.PointsToWin ?? 0),
}; };
teamDisplay.ShowScore = wasShowingScores;
} }
} }
} }

View File

@ -280,7 +280,7 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
protected override bool OnClick(ClickEvent e) protected override bool OnClick(ClickEvent e)
{ {
if (editorInfo == null || Match is ConditionalTournamentMatch) if (editorInfo == null || Match is ConditionalTournamentMatch || e.Button != MouseButton.Left)
return false; return false;
Selected = true; Selected = true;

View File

@ -46,7 +46,10 @@ namespace osu.Game.Tournament.Screens.MapPool
Loop = true, Loop = true,
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
}, },
new MatchHeader(), new MatchHeader
{
ShowScores = true,
},
mapFlows = new FillFlowContainer<FillFlowContainer<TournamentBeatmapPanel>> mapFlows = new FillFlowContainer<FillFlowContainer<TournamentBeatmapPanel>>
{ {
Y = 160, Y = 160,

View File

@ -319,8 +319,7 @@ namespace osu.Game.Beatmaps
AddFile(setInfo, stream, createBeatmapFilenameFromMetadata(beatmapInfo)); AddFile(setInfo, stream, createBeatmapFilenameFromMetadata(beatmapInfo));
setInfo.Hash = beatmapImporter.ComputeHash(setInfo); updateHashAndMarkDirty(setInfo);
setInfo.Status = BeatmapOnlineStatus.LocallyModified;
Realm.Write(r => Realm.Write(r =>
{ {
@ -363,6 +362,33 @@ namespace osu.Game.Beatmaps
}); });
} }
/// <summary>
/// Delete a beatmap difficulty immediately.
/// </summary>
/// <remarks>
/// There's no undoing this operation, as we don't have a soft-deletion flag on <see cref="BeatmapInfo"/>.
/// This may be a future consideration if there's a user requirement for undeleting support.
/// </remarks>
public void DeleteDifficultyImmediately(BeatmapInfo beatmapInfo)
{
Realm.Write(r =>
{
if (!beatmapInfo.IsManaged)
beatmapInfo = r.Find<BeatmapInfo>(beatmapInfo.ID);
Debug.Assert(beatmapInfo.BeatmapSet != null);
Debug.Assert(beatmapInfo.File != null);
var setInfo = beatmapInfo.BeatmapSet;
DeleteFile(setInfo, beatmapInfo.File);
setInfo.Beatmaps.Remove(beatmapInfo);
updateHashAndMarkDirty(setInfo);
workingBeatmapCache.Invalidate(setInfo);
});
}
/// <summary> /// <summary>
/// Delete videos from a list of beatmaps. /// Delete videos from a list of beatmaps.
/// This will post notifications tracking progress. /// This will post notifications tracking progress.
@ -416,6 +442,12 @@ namespace osu.Game.Beatmaps
public Task<Live<BeatmapSetInfo>?> ImportAsUpdate(ProgressNotification notification, ImportTask importTask, BeatmapSetInfo original) => public Task<Live<BeatmapSetInfo>?> ImportAsUpdate(ProgressNotification notification, ImportTask importTask, BeatmapSetInfo original) =>
beatmapImporter.ImportAsUpdate(notification, importTask, original); beatmapImporter.ImportAsUpdate(notification, importTask, original);
private void updateHashAndMarkDirty(BeatmapSetInfo setInfo)
{
setInfo.Hash = beatmapImporter.ComputeHash(setInfo);
setInfo.Status = BeatmapOnlineStatus.LocallyModified;
}
#region Implementation of ICanAcceptFiles #region Implementation of ICanAcceptFiles
public Task Import(params string[] paths) => beatmapImporter.Import(paths); public Task Import(params string[] paths) => beatmapImporter.Import(paths);

View File

@ -17,8 +17,7 @@ namespace osu.Game.Beatmaps.Drawables.Cards.Buttons
{ {
public class DownloadButton : BeatmapCardIconButton public class DownloadButton : BeatmapCardIconButton
{ {
public IBindable<DownloadState> State => state; public Bindable<DownloadState> State { get; } = new Bindable<DownloadState>();
private readonly Bindable<DownloadState> state = new Bindable<DownloadState>();
private readonly APIBeatmapSet beatmapSet; private readonly APIBeatmapSet beatmapSet;
@ -48,14 +47,19 @@ namespace osu.Game.Beatmaps.Drawables.Cards.Buttons
{ {
base.LoadComplete(); base.LoadComplete();
preferNoVideo.BindValueChanged(_ => updateState()); preferNoVideo.BindValueChanged(_ => updateState());
state.BindValueChanged(_ => updateState(), true); State.BindValueChanged(_ => updateState(), true);
FinishTransforms(true); FinishTransforms(true);
} }
private void updateState() private void updateState()
{ {
switch (state.Value) switch (State.Value)
{ {
case DownloadState.Unknown:
Action = null;
TooltipText = string.Empty;
break;
case DownloadState.Downloading: case DownloadState.Downloading:
case DownloadState.Importing: case DownloadState.Importing:
Action = null; Action = null;

View File

@ -121,7 +121,18 @@ namespace osu.Game.Beatmaps
protected override void Update() protected override void Update()
{ {
base.Update(); base.Update();
finalClockSource.ProcessFrame();
if (Source != null && Source is not IAdjustableClock && Source.CurrentTime < decoupledClock.CurrentTime)
{
// InterpolatingFramedClock won't interpolate backwards unless its source has an ElapsedFrameTime.
// See https://github.com/ppy/osu-framework/blob/ba1385330cc501f34937e08257e586c84e35d772/osu.Framework/Timing/InterpolatingFramedClock.cs#L91-L93
// This is not always the case here when doing large seeks.
// (Of note, this is not an issue if the source is adjustable, as the source is seeked to be in time by DecoupleableInterpolatingFramedClock).
// Rather than trying to get around this by fixing the framework clock stack, let's work around it for now.
Seek(Source.CurrentTime);
}
else
finalClockSource.ProcessFrame();
} }
public double TotalAppliedOffset public double TotalAppliedOffset

View File

@ -108,47 +108,42 @@ namespace osu.Game.Database
bool isBatchImport = tasks.Length >= minimum_items_considered_batch_import; bool isBatchImport = tasks.Length >= minimum_items_considered_batch_import;
try await Task.WhenAll(tasks.Select(async task =>
{ {
await Task.WhenAll(tasks.Select(async task => if (notification.CancellationToken.IsCancellationRequested)
return;
try
{ {
notification.CancellationToken.ThrowIfCancellationRequested(); var model = await Import(task, isBatchImport, notification.CancellationToken).ConfigureAwait(false);
try lock (imported)
{ {
var model = await Import(task, isBatchImport, notification.CancellationToken).ConfigureAwait(false); if (model != null)
imported.Add(model);
current++;
lock (imported) notification.Text = $"Imported {current} of {tasks.Length} {HumanisedModelName}s";
{ notification.Progress = (float)current / tasks.Length;
if (model != null) }
imported.Add(model); }
current++; catch (OperationCanceledException)
{
}
catch (Exception e)
{
Logger.Error(e, $@"Could not import ({task})", LoggingTarget.Database);
}
})).ConfigureAwait(false);
notification.Text = $"Imported {current} of {tasks.Length} {HumanisedModelName}s"; if (imported.Count == 0)
notification.Progress = (float)current / tasks.Length;
}
}
catch (TaskCanceledException)
{
throw;
}
catch (Exception e)
{
Logger.Error(e, $@"Could not import ({task})", LoggingTarget.Database);
}
})).ConfigureAwait(false);
}
catch (OperationCanceledException)
{ {
if (imported.Count == 0) if (notification.CancellationToken.IsCancellationRequested)
{ {
notification.State = ProgressNotificationState.Cancelled; notification.State = ProgressNotificationState.Cancelled;
return imported; return imported;
} }
}
if (imported.Count == 0)
{
notification.Text = $"{HumanisedModelName.Humanize(LetterCasing.Title)} import failed!"; notification.Text = $"{HumanisedModelName.Humanize(LetterCasing.Title)} import failed!";
notification.State = ProgressNotificationState.Cancelled; notification.State = ProgressNotificationState.Cancelled;
} }

View File

@ -57,7 +57,7 @@ namespace osu.Game.Graphics.Backgrounds
{ {
if (bufferedContainer == null && newBlurSigma != Vector2.Zero) if (bufferedContainer == null && newBlurSigma != Vector2.Zero)
{ {
RemoveInternal(Sprite); RemoveInternal(Sprite, false);
AddInternal(bufferedContainer = new BufferedContainer(cachedFrameBuffer: true) AddInternal(bufferedContainer = new BufferedContainer(cachedFrameBuffer: true)
{ {

View File

@ -35,7 +35,7 @@ namespace osu.Game.Graphics.Containers
if (value == expandableHeader) return; if (value == expandableHeader) return;
if (expandableHeader != null) if (expandableHeader != null)
RemoveInternal(expandableHeader); RemoveInternal(expandableHeader, false);
expandableHeader = value; expandableHeader = value;
@ -55,6 +55,7 @@ namespace osu.Game.Graphics.Containers
fixedHeader?.Expire(); fixedHeader?.Expire();
fixedHeader = value; fixedHeader = value;
if (value == null) return; if (value == null) return;
AddInternal(fixedHeader); AddInternal(fixedHeader);
@ -70,8 +71,10 @@ namespace osu.Game.Graphics.Containers
if (value == footer) return; if (value == footer) return;
if (footer != null) if (footer != null)
scrollContainer.Remove(footer); scrollContainer.Remove(footer, false);
footer = value; footer = value;
if (value == null) return; if (value == null) return;
footer.Anchor |= Anchor.y2; footer.Anchor |= Anchor.y2;

View File

@ -59,7 +59,7 @@ namespace osu.Game.Graphics.Containers
drawable.StateChanged += state => selectionChanged(drawable, state); drawable.StateChanged += state => selectionChanged(drawable, state);
} }
public override bool Remove(T drawable) public override bool Remove(T drawable, bool disposeImmediately)
=> throw new NotSupportedException($"Cannot remove drawables from {nameof(SelectionCycleFillFlowContainer<T>)}"); => throw new NotSupportedException($"Cannot remove drawables from {nameof(SelectionCycleFillFlowContainer<T>)}");
private void setSelected(int? value) private void setSelected(int? value)

View File

@ -102,26 +102,31 @@ namespace osu.Game.Graphics
/// <summary> /// <summary>
/// Retrieves the colour for a <see cref="HitResult"/>. /// Retrieves the colour for a <see cref="HitResult"/>.
/// </summary> /// </summary>
public Color4 ForHitResult(HitResult judgement) public Color4 ForHitResult(HitResult result)
{ {
switch (judgement) switch (result)
{ {
case HitResult.Perfect: case HitResult.SmallTickMiss:
case HitResult.Great: case HitResult.LargeTickMiss:
return Blue; case HitResult.Miss:
return Red;
case HitResult.Ok:
case HitResult.Good:
return Green;
case HitResult.Meh: case HitResult.Meh:
return Yellow; return Yellow;
case HitResult.Miss: case HitResult.Ok:
return Red; return Green;
case HitResult.Good:
return GreenLight;
case HitResult.SmallTickHit:
case HitResult.LargeTickHit:
case HitResult.Great:
return Blue;
default: default:
return Color4.White; return BlueLight;
} }
} }

View File

@ -74,7 +74,7 @@ namespace osu.Game.Graphics.UserInterface
} }
//I'm using ToList() here because Where() returns an Enumerable which can change it's elements afterwards //I'm using ToList() here because Where() returns an Enumerable which can change it's elements afterwards
RemoveRange(Children.Where((_, index) => index >= value.Count()).ToList()); RemoveRange(Children.Where((_, index) => index >= value.Count()).ToList(), true);
} }
} }
} }

View File

@ -88,6 +88,7 @@ namespace osu.Game.Graphics.UserInterface
if (Text.Length > 0) if (Text.Length > 0)
{ {
Text = string.Empty; Text = string.Empty;
PlayFeedbackSample(FeedbackSampleType.TextRemove);
return true; return true;
} }
} }

View File

@ -47,7 +47,7 @@ namespace osu.Game.Graphics.UserInterface
private bool selectionStarted; private bool selectionStarted;
private double sampleLastPlaybackTime; private double sampleLastPlaybackTime;
private enum FeedbackSampleType protected enum FeedbackSampleType
{ {
TextAdd, TextAdd,
TextAddCaps, TextAddCaps,
@ -117,30 +117,30 @@ namespace osu.Game.Graphics.UserInterface
return; return;
if (added.Any(char.IsUpper) && AllowUniqueCharacterSamples) if (added.Any(char.IsUpper) && AllowUniqueCharacterSamples)
playSample(FeedbackSampleType.TextAddCaps); PlayFeedbackSample(FeedbackSampleType.TextAddCaps);
else else
playSample(FeedbackSampleType.TextAdd); PlayFeedbackSample(FeedbackSampleType.TextAdd);
} }
protected override void OnUserTextRemoved(string removed) protected override void OnUserTextRemoved(string removed)
{ {
base.OnUserTextRemoved(removed); base.OnUserTextRemoved(removed);
playSample(FeedbackSampleType.TextRemove); PlayFeedbackSample(FeedbackSampleType.TextRemove);
} }
protected override void NotifyInputError() protected override void NotifyInputError()
{ {
base.NotifyInputError(); base.NotifyInputError();
playSample(FeedbackSampleType.TextInvalid); PlayFeedbackSample(FeedbackSampleType.TextInvalid);
} }
protected override void OnTextCommitted(bool textChanged) protected override void OnTextCommitted(bool textChanged)
{ {
base.OnTextCommitted(textChanged); base.OnTextCommitted(textChanged);
playSample(FeedbackSampleType.TextConfirm); PlayFeedbackSample(FeedbackSampleType.TextConfirm);
} }
protected override void OnCaretMoved(bool selecting) protected override void OnCaretMoved(bool selecting)
@ -148,7 +148,7 @@ namespace osu.Game.Graphics.UserInterface
base.OnCaretMoved(selecting); base.OnCaretMoved(selecting);
if (!selecting) if (!selecting)
playSample(FeedbackSampleType.CaretMove); PlayFeedbackSample(FeedbackSampleType.CaretMove);
} }
protected override void OnTextSelectionChanged(TextSelectionType selectionType) protected override void OnTextSelectionChanged(TextSelectionType selectionType)
@ -158,15 +158,15 @@ namespace osu.Game.Graphics.UserInterface
switch (selectionType) switch (selectionType)
{ {
case TextSelectionType.Character: case TextSelectionType.Character:
playSample(FeedbackSampleType.SelectCharacter); PlayFeedbackSample(FeedbackSampleType.SelectCharacter);
break; break;
case TextSelectionType.Word: case TextSelectionType.Word:
playSample(selectionStarted ? FeedbackSampleType.SelectCharacter : FeedbackSampleType.SelectWord); PlayFeedbackSample(selectionStarted ? FeedbackSampleType.SelectCharacter : FeedbackSampleType.SelectWord);
break; break;
case TextSelectionType.All: case TextSelectionType.All:
playSample(FeedbackSampleType.SelectAll); PlayFeedbackSample(FeedbackSampleType.SelectAll);
break; break;
} }
@ -179,7 +179,7 @@ namespace osu.Game.Graphics.UserInterface
if (!selectionStarted) return; if (!selectionStarted) return;
playSample(FeedbackSampleType.Deselect); PlayFeedbackSample(FeedbackSampleType.Deselect);
selectionStarted = false; selectionStarted = false;
} }
@ -198,13 +198,13 @@ namespace osu.Game.Graphics.UserInterface
case 1: case 1:
// composition probably ended by pressing backspace, or was cancelled. // composition probably ended by pressing backspace, or was cancelled.
playSample(FeedbackSampleType.TextRemove); PlayFeedbackSample(FeedbackSampleType.TextRemove);
return; return;
default: default:
// longer text removed, composition ended because it was cancelled. // longer text removed, composition ended because it was cancelled.
// could be a different sample if desired. // could be a different sample if desired.
playSample(FeedbackSampleType.TextRemove); PlayFeedbackSample(FeedbackSampleType.TextRemove);
return; return;
} }
} }
@ -212,7 +212,7 @@ namespace osu.Game.Graphics.UserInterface
if (addedTextLength > 0) if (addedTextLength > 0)
{ {
// some text was added, probably due to typing new text or by changing the candidate. // some text was added, probably due to typing new text or by changing the candidate.
playSample(FeedbackSampleType.TextAdd); PlayFeedbackSample(FeedbackSampleType.TextAdd);
return; return;
} }
@ -220,14 +220,14 @@ namespace osu.Game.Graphics.UserInterface
{ {
// text was probably removed by backspacing. // text was probably removed by backspacing.
// it's also possible that a candidate that only removed text was changed to. // it's also possible that a candidate that only removed text was changed to.
playSample(FeedbackSampleType.TextRemove); PlayFeedbackSample(FeedbackSampleType.TextRemove);
return; return;
} }
if (caretMoved) if (caretMoved)
{ {
// only the caret/selection was moved. // only the caret/selection was moved.
playSample(FeedbackSampleType.CaretMove); PlayFeedbackSample(FeedbackSampleType.CaretMove);
} }
} }
@ -238,13 +238,13 @@ namespace osu.Game.Graphics.UserInterface
if (successful) if (successful)
{ {
// composition was successfully completed, usually by pressing the enter key. // composition was successfully completed, usually by pressing the enter key.
playSample(FeedbackSampleType.TextConfirm); PlayFeedbackSample(FeedbackSampleType.TextConfirm);
} }
else else
{ {
// composition was prematurely ended, eg. by clicking inside the textbox. // composition was prematurely ended, eg. by clicking inside the textbox.
// could be a different sample if desired. // could be a different sample if desired.
playSample(FeedbackSampleType.TextConfirm); PlayFeedbackSample(FeedbackSampleType.TextConfirm);
} }
} }
@ -283,7 +283,7 @@ namespace osu.Game.Graphics.UserInterface
return samples[RNG.Next(0, samples.Length)]?.GetChannel(); return samples[RNG.Next(0, samples.Length)]?.GetChannel();
} }
private void playSample(FeedbackSampleType feedbackSample) protected void PlayFeedbackSample(FeedbackSampleType feedbackSample) => Schedule(() =>
{ {
if (Time.Current < sampleLastPlaybackTime + 15) return; if (Time.Current < sampleLastPlaybackTime + 15) return;
@ -300,7 +300,7 @@ namespace osu.Game.Graphics.UserInterface
channel.Play(); channel.Play();
sampleLastPlaybackTime = Time.Current; sampleLastPlaybackTime = Time.Current;
} });
private class OsuCaret : Caret private class OsuCaret : Caret
{ {

View File

@ -64,8 +64,8 @@ namespace osu.Game.Graphics.UserInterface
X = value.HasFlagFast(Anchor.x2) ? SIZE_RETRACTED.X * shear.X * 0.5f : 0; X = value.HasFlagFast(Anchor.x2) ? SIZE_RETRACTED.X * shear.X * 0.5f : 0;
Remove(c1); Remove(c1, false);
Remove(c2); Remove(c2, false);
c1.Depth = value.HasFlagFast(Anchor.x2) ? 0 : 1; c1.Depth = value.HasFlagFast(Anchor.x2) ? 0 : 1;
c2.Depth = value.HasFlagFast(Anchor.x2) ? 1 : 0; c2.Depth = value.HasFlagFast(Anchor.x2) ? 1 : 0;
Add(c1); Add(c1);

View File

@ -81,12 +81,12 @@ namespace osu.Game.Online.API.Requests.Responses
public int? LegacyTotalScore { get; set; } public int? LegacyTotalScore { get; set; }
[JsonProperty("legacy_score_id")] [JsonProperty("legacy_score_id")]
public uint? LegacyScoreId { get; set; } public ulong? LegacyScoreId { get; set; }
#region osu-web API additions (not stored to database). #region osu-web API additions (not stored to database).
[JsonProperty("id")] [JsonProperty("id")]
public long? ID { get; set; } public ulong? ID { get; set; }
[JsonProperty("user")] [JsonProperty("user")]
public APIUser? User { get; set; } public APIUser? User { get; set; }
@ -190,6 +190,6 @@ namespace osu.Game.Online.API.Requests.Responses
MaximumStatistics = score.MaximumStatistics.Where(kvp => kvp.Value != 0).ToDictionary(kvp => kvp.Key, kvp => kvp.Value), MaximumStatistics = score.MaximumStatistics.Where(kvp => kvp.Value != 0).ToDictionary(kvp => kvp.Key, kvp => kvp.Value),
}; };
public long OnlineID => ID ?? -1; public long OnlineID => (long?)ID ?? -1;
} }
} }

View File

@ -5,6 +5,7 @@ namespace osu.Game.Online
{ {
public enum DownloadState public enum DownloadState
{ {
Unknown,
NotDownloaded, NotDownloaded,
Downloading, Downloading,
Importing, Importing,

View File

@ -1,20 +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 MessagePack;
namespace osu.Game.Online.Multiplayer.Countdown
{
/// <summary>
/// Indicates a change to the <see cref="MultiplayerRoom"/>'s countdown.
/// </summary>
[MessagePackObject]
public class CountdownChangedEvent : MatchServerEvent
{
/// <summary>
/// The new countdown.
/// </summary>
[Key(0)]
public MultiplayerCountdown? Countdown { get; set; }
}
}

View File

@ -0,0 +1,28 @@
// 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 MessagePack;
using Newtonsoft.Json;
namespace osu.Game.Online.Multiplayer.Countdown
{
/// <summary>
/// Indicates that a countdown started in the <see cref="MultiplayerRoom"/>.
/// </summary>
[MessagePackObject]
public class CountdownStartedEvent : MatchServerEvent
{
/// <summary>
/// The countdown that was started.
/// </summary>
[Key(0)]
public readonly MultiplayerCountdown Countdown;
[JsonConstructor]
[SerializationConstructor]
public CountdownStartedEvent(MultiplayerCountdown countdown)
{
Countdown = countdown;
}
}
}

View File

@ -0,0 +1,28 @@
// 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 MessagePack;
using Newtonsoft.Json;
namespace osu.Game.Online.Multiplayer.Countdown
{
/// <summary>
/// Indicates that a countdown was stopped in the <see cref="MultiplayerRoom"/>.
/// </summary>
[MessagePackObject]
public class CountdownStoppedEvent : MatchServerEvent
{
/// <summary>
/// The identifier of the countdown that was stopped.
/// </summary>
[Key(0)]
public readonly int ID;
[JsonConstructor]
[SerializationConstructor]
public CountdownStoppedEvent(int id)
{
ID = id;
}
}
}

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using MessagePack; using MessagePack;
using Newtonsoft.Json;
namespace osu.Game.Online.Multiplayer.Countdown namespace osu.Game.Online.Multiplayer.Countdown
{ {
@ -11,5 +12,14 @@ namespace osu.Game.Online.Multiplayer.Countdown
[MessagePackObject] [MessagePackObject]
public class StopCountdownRequest : MatchUserRequest public class StopCountdownRequest : MatchUserRequest
{ {
[Key(0)]
public readonly int ID;
[JsonConstructor]
[SerializationConstructor]
public StopCountdownRequest(int id)
{
ID = id;
}
} }
} }

Some files were not shown because too many files have changed in this diff Show More