diff --git a/README.md b/README.md
index 7c749f3422..86c42dae12 100644
--- a/README.md
+++ b/README.md
@@ -34,6 +34,8 @@ If you are looking to install or test osu! without setting up a development envi
| [Windows (x64)](https://github.com/ppy/osu/releases/latest/download/install.exe) | [macOS 10.12+](https://github.com/ppy/osu/releases/latest/download/osu.app.zip) | [Linux (x64)](https://github.com/ppy/osu/releases/latest/download/osu.AppImage) | [iOS(iOS 10+)](https://osu.ppy.sh/home/testflight) | [Android (5+)](https://github.com/ppy/osu/releases/latest/download/sh.ppy.osulazer.apk)
| ------------- | ------------- | ------------- | ------------- | ------------- |
+- The iOS testflight link may fill up (Apple has a hard limit of 10,000 users). We reset it occasionally when this happens. Please do not ask about this. Check back regularly for link resets or follow [peppy](https://twitter.com/ppy) on twitter for announcements of link resets.
+
- When running on Windows 7 or 8.1, **[additional prerequisites](https://docs.microsoft.com/en-us/dotnet/core/install/dependencies?tabs=netcore31&pivots=os-windows)** may be required to correctly run .NET Core applications if your operating system is not up-to-date with the latest service packs.
If your platform is not listed above, there is still a chance you can manually build it by following the instructions below.
diff --git a/osu.Android.props b/osu.Android.props
index 2d531cf01e..a4bcbd289d 100644
--- a/osu.Android.props
+++ b/osu.Android.props
@@ -52,6 +52,6 @@
-
+
diff --git a/osu.Game.Rulesets.Mania.Tests/TestSceneOutOfOrderHits.cs b/osu.Game.Rulesets.Mania.Tests/TestSceneOutOfOrderHits.cs
index ab840e1c46..e8c2472c3b 100644
--- a/osu.Game.Rulesets.Mania.Tests/TestSceneOutOfOrderHits.cs
+++ b/osu.Game.Rulesets.Mania.Tests/TestSceneOutOfOrderHits.cs
@@ -35,6 +35,7 @@ namespace osu.Game.Rulesets.Mania.Tests
objects.Add(new Note { StartTime = time });
+ // don't hit the first note
if (i > 0)
{
frames.Add(new ManiaReplayFrame(time + 10, ManiaAction.Key1));
diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModAutopilot.cs b/osu.Game.Rulesets.Osu/Mods/OsuModAutopilot.cs
index 2263e2b2f4..8c819c4773 100644
--- a/osu.Game.Rulesets.Osu/Mods/OsuModAutopilot.cs
+++ b/osu.Game.Rulesets.Osu/Mods/OsuModAutopilot.cs
@@ -11,7 +11,6 @@ using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Replays;
using osu.Game.Rulesets.UI;
-using osu.Game.Screens.Play;
namespace osu.Game.Rulesets.Osu.Mods
{
@@ -31,7 +30,7 @@ namespace osu.Game.Rulesets.Osu.Mods
private OsuInputManager inputManager;
- private GameplayClock gameplayClock;
+ private IFrameStableClock gameplayClock;
private List replayFrames;
diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModTraceable.cs b/osu.Game.Rulesets.Osu/Mods/OsuModTraceable.cs
index d7582f3196..bb2213aa31 100644
--- a/osu.Game.Rulesets.Osu/Mods/OsuModTraceable.cs
+++ b/osu.Game.Rulesets.Osu/Mods/OsuModTraceable.cs
@@ -6,6 +6,7 @@ using System.Linq;
using osu.Framework.Bindables;
using System.Collections.Generic;
using osu.Framework.Extensions.Color4Extensions;
+using osu.Framework.Graphics;
using osu.Game.Configuration;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Objects.Drawables;
@@ -38,20 +39,25 @@ namespace osu.Game.Rulesets.Osu.Mods
protected void ApplyTraceableState(DrawableHitObject drawable, ArmedState state)
{
- if (!(drawable is DrawableOsuHitObject drawableOsu))
+ if (!(drawable is DrawableOsuHitObject))
return;
- var h = drawableOsu.HitObject;
-
//todo: expose and hide spinner background somehow
switch (drawable)
{
case DrawableHitCircle circle:
// we only want to see the approach circle
- using (circle.BeginAbsoluteSequence(h.StartTime - h.TimePreempt, true))
- circle.CirclePiece.Hide();
+ applyCirclePieceState(circle, circle.CirclePiece);
+ break;
+ case DrawableSliderTail sliderTail:
+ applyCirclePieceState(sliderTail);
+ break;
+
+ case DrawableSliderRepeat sliderRepeat:
+ // show only the repeat arrow
+ applyCirclePieceState(sliderRepeat, sliderRepeat.CirclePiece);
break;
case DrawableSlider slider:
@@ -61,6 +67,13 @@ namespace osu.Game.Rulesets.Osu.Mods
}
}
+ private void applyCirclePieceState(DrawableOsuHitObject hitObject, IDrawable hitCircle = null)
+ {
+ var h = hitObject.HitObject;
+ using (hitObject.BeginAbsoluteSequence(h.StartTime - h.TimePreempt, true))
+ (hitCircle ?? hitObject).Hide();
+ }
+
private void applySliderState(DrawableSlider slider)
{
((PlaySliderBody)slider.Body.Drawable).AccentColour = slider.AccentColour.Value.Opacity(0);
diff --git a/osu.Game.Rulesets.Taiko/UI/DrumRollHitContainer.cs b/osu.Game.Rulesets.Taiko/UI/DrumRollHitContainer.cs
index fde42bec04..9bfb6aa839 100644
--- a/osu.Game.Rulesets.Taiko/UI/DrumRollHitContainer.cs
+++ b/osu.Game.Rulesets.Taiko/UI/DrumRollHitContainer.cs
@@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Graphics.Containers;
+using osu.Framework.Graphics.Performance;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Taiko.Objects.Drawables;
using osu.Game.Rulesets.UI.Scrolling;
diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneDrawableStoryboardSprite.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneDrawableStoryboardSprite.cs
new file mode 100644
index 0000000000..9501026edc
--- /dev/null
+++ b/osu.Game.Tests/Visual/Gameplay/TestSceneDrawableStoryboardSprite.cs
@@ -0,0 +1,65 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System.Linq;
+using NUnit.Framework;
+using osu.Framework.Allocation;
+using osu.Framework.Graphics;
+using osu.Framework.Testing;
+using osu.Game.Rulesets;
+using osu.Game.Rulesets.Osu;
+using osu.Game.Skinning;
+using osu.Game.Storyboards;
+using osu.Game.Storyboards.Drawables;
+using osuTK;
+
+namespace osu.Game.Tests.Visual.Gameplay
+{
+ public class TestSceneDrawableStoryboardSprite : SkinnableTestScene
+ {
+ protected override Ruleset CreateRulesetForSkinProvider() => new OsuRuleset();
+
+ [Cached]
+ private Storyboard storyboard { get; set; } = new Storyboard();
+
+ [Test]
+ public void TestSkinSpriteDisallowedByDefault()
+ {
+ const string lookup_name = "hitcircleoverlay";
+
+ AddStep("allow skin lookup", () => storyboard.UseSkinSprites = false);
+
+ AddStep("create sprites", () => SetContents(
+ () => createSprite(lookup_name, Anchor.TopLeft, Vector2.Zero)));
+
+ assertSpritesFromSkin(false);
+ }
+
+ [Test]
+ public void TestAllowLookupFromSkin()
+ {
+ const string lookup_name = "hitcircleoverlay";
+
+ AddStep("allow skin lookup", () => storyboard.UseSkinSprites = true);
+
+ AddStep("create sprites", () => SetContents(
+ () => createSprite(lookup_name, Anchor.Centre, Vector2.Zero)));
+
+ assertSpritesFromSkin(true);
+ }
+
+ private DrawableStoryboardSprite createSprite(string lookupName, Anchor origin, Vector2 initialPosition)
+ => new DrawableStoryboardSprite(
+ new StoryboardSprite(lookupName, origin, initialPosition)
+ ).With(s =>
+ {
+ s.LifetimeStart = double.MinValue;
+ s.LifetimeEnd = double.MaxValue;
+ });
+
+ private void assertSpritesFromSkin(bool fromSkin) =>
+ AddAssert($"sprites are {(fromSkin ? "from skin" : "from storyboard")}",
+ () => this.ChildrenOfType()
+ .All(sprite => sprite.ChildrenOfType().Any() == fromSkin));
+ }
+}
diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneGameplaySamplePlayback.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneGameplaySamplePlayback.cs
index 6e505b16c2..b86cb69eb4 100644
--- a/osu.Game.Tests/Visual/Gameplay/TestSceneGameplaySamplePlayback.cs
+++ b/osu.Game.Tests/Visual/Gameplay/TestSceneGameplaySamplePlayback.cs
@@ -9,7 +9,6 @@ using osu.Framework.Testing;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Osu.Objects.Drawables;
-using osu.Game.Rulesets.UI;
using osu.Game.Screens.Play;
using osu.Game.Skinning;
@@ -22,11 +21,11 @@ namespace osu.Game.Tests.Visual.Gameplay
{
DrawableSlider slider = null;
DrawableSample[] samples = null;
- ISamplePlaybackDisabler gameplayClock = null;
+ ISamplePlaybackDisabler sampleDisabler = null;
AddStep("get variables", () =>
{
- gameplayClock = Player.ChildrenOfType().First();
+ sampleDisabler = Player;
slider = Player.ChildrenOfType().OrderBy(s => s.HitObject.StartTime).First();
samples = slider.ChildrenOfType().ToArray();
});
@@ -43,16 +42,16 @@ namespace osu.Game.Tests.Visual.Gameplay
return true;
});
- AddAssert("sample playback disabled", () => gameplayClock.SamplePlaybackDisabled.Value);
+ AddAssert("sample playback disabled", () => sampleDisabler.SamplePlaybackDisabled.Value);
// because we are in frame stable context, it's quite likely that not all samples are "played" at this point.
// the important thing is that at least one started, and that sample has since stopped.
AddAssert("all looping samples stopped immediately", () => allStopped(allLoopingSounds));
AddUntilStep("all samples stopped eventually", () => allStopped(allSounds));
- AddAssert("sample playback still disabled", () => gameplayClock.SamplePlaybackDisabled.Value);
+ AddAssert("sample playback still disabled", () => sampleDisabler.SamplePlaybackDisabled.Value);
- AddUntilStep("seek finished, sample playback enabled", () => !gameplayClock.SamplePlaybackDisabled.Value);
+ AddUntilStep("seek finished, sample playback enabled", () => !sampleDisabler.SamplePlaybackDisabled.Value);
AddUntilStep("any sample is playing", () => Player.ChildrenOfType().Any(s => s.IsPlaying));
}
diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneHUDOverlay.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneHUDOverlay.cs
index 6ec673704c..f9914e0193 100644
--- a/osu.Game.Tests/Visual/Gameplay/TestSceneHUDOverlay.cs
+++ b/osu.Game.Tests/Visual/Gameplay/TestSceneHUDOverlay.cs
@@ -2,29 +2,23 @@
// See the LICENCE file in the repository root for full licence text.
using System;
-using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
-using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Testing;
using osu.Game.Configuration;
-using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
-using osu.Game.Rulesets.Osu;
using osu.Game.Screens.Play;
using osuTK.Input;
namespace osu.Game.Tests.Visual.Gameplay
{
- public class TestSceneHUDOverlay : SkinnableTestScene
+ public class TestSceneHUDOverlay : OsuManualInputManagerTestScene
{
private HUDOverlay hudOverlay;
- private IEnumerable hudOverlays => CreatedDrawables.OfType();
-
// best way to check without exposing.
private Drawable hideTarget => hudOverlay.KeyCounter;
private FillFlowContainer keyCounterFlow => hudOverlay.KeyCounter.ChildrenOfType>().First();
@@ -37,17 +31,9 @@ namespace osu.Game.Tests.Visual.Gameplay
{
createNew();
- AddRepeatStep("increase combo", () =>
- {
- foreach (var hud in hudOverlays)
- hud.ComboCounter.Current.Value++;
- }, 10);
+ AddRepeatStep("increase combo", () => { hudOverlay.ComboCounter.Current.Value++; }, 10);
- AddStep("reset combo", () =>
- {
- foreach (var hud in hudOverlays)
- hud.ComboCounter.Current.Value = 0;
- });
+ AddStep("reset combo", () => { hudOverlay.ComboCounter.Current.Value = 0; });
}
[Test]
@@ -77,7 +63,7 @@ namespace osu.Game.Tests.Visual.Gameplay
{
createNew();
- AddStep("set showhud false", () => hudOverlays.ForEach(h => h.ShowHud.Value = false));
+ AddStep("set showhud false", () => hudOverlay.ShowHud.Value = false);
AddUntilStep("hidetarget is hidden", () => !hideTarget.IsPresent);
AddAssert("pause button is still visible", () => hudOverlay.HoldToQuit.IsPresent);
@@ -86,10 +72,32 @@ namespace osu.Game.Tests.Visual.Gameplay
AddAssert("key counter flow not affected", () => keyCounterFlow.IsPresent);
}
+ [Test]
+ public void TestMomentaryShowHUD()
+ {
+ createNew();
+
+ HUDVisibilityMode originalConfigValue = HUDVisibilityMode.HideDuringGameplay;
+
+ AddStep("get original config value", () => originalConfigValue = config.Get(OsuSetting.HUDVisibilityMode));
+
+ AddStep("set hud to never show", () => config.Set(OsuSetting.HUDVisibilityMode, HUDVisibilityMode.Never));
+
+ AddUntilStep("wait for fade", () => !hideTarget.IsPresent);
+
+ AddStep("trigger momentary show", () => InputManager.PressKey(Key.ControlLeft));
+ AddUntilStep("wait for visible", () => hideTarget.IsPresent);
+
+ AddStep("stop trigering", () => InputManager.ReleaseKey(Key.ControlLeft));
+ AddUntilStep("wait for fade", () => !hideTarget.IsPresent);
+
+ AddStep("set original config value", () => config.Set(OsuSetting.HUDVisibilityMode, originalConfigValue));
+ }
+
[Test]
public void TestExternalHideDoesntAffectConfig()
{
- HUDVisibilityMode originalConfigValue = HUDVisibilityMode.HideDuringBreaks;
+ HUDVisibilityMode originalConfigValue = HUDVisibilityMode.HideDuringGameplay;
createNew();
@@ -113,14 +121,14 @@ namespace osu.Game.Tests.Visual.Gameplay
AddStep("set keycounter visible false", () =>
{
config.Set(OsuSetting.KeyOverlay, false);
- hudOverlays.ForEach(h => h.KeyCounter.AlwaysVisible.Value = false);
+ hudOverlay.KeyCounter.AlwaysVisible.Value = false;
});
- AddStep("set showhud false", () => hudOverlays.ForEach(h => h.ShowHud.Value = false));
+ AddStep("set showhud false", () => hudOverlay.ShowHud.Value = false);
AddUntilStep("hidetarget is hidden", () => !hideTarget.IsPresent);
AddAssert("key counters hidden", () => !keyCounterFlow.IsPresent);
- AddStep("set showhud true", () => hudOverlays.ForEach(h => h.ShowHud.Value = true));
+ AddStep("set showhud true", () => hudOverlay.ShowHud.Value = true);
AddUntilStep("hidetarget is visible", () => hideTarget.IsPresent);
AddAssert("key counters still hidden", () => !keyCounterFlow.IsPresent);
@@ -131,22 +139,17 @@ namespace osu.Game.Tests.Visual.Gameplay
{
AddStep("create overlay", () =>
{
- SetContents(() =>
- {
- hudOverlay = new HUDOverlay(null, null, null, Array.Empty());
+ hudOverlay = new HUDOverlay(null, null, null, Array.Empty());
- // Add any key just to display the key counter visually.
- hudOverlay.KeyCounter.Add(new KeyCounterKeyboard(Key.Space));
+ // Add any key just to display the key counter visually.
+ hudOverlay.KeyCounter.Add(new KeyCounterKeyboard(Key.Space));
- hudOverlay.ComboCounter.Current.Value = 1;
+ hudOverlay.ComboCounter.Current.Value = 1;
- action?.Invoke(hudOverlay);
+ action?.Invoke(hudOverlay);
- return hudOverlay;
- });
+ Child = hudOverlay;
});
}
-
- protected override Ruleset CreateRulesetForSkinProvider() => new OsuRuleset();
}
}
diff --git a/osu.Game.Tests/Visual/Gameplay/TestScenePlayerLoader.cs b/osu.Game.Tests/Visual/Gameplay/TestScenePlayerLoader.cs
index 888a2f2197..9b31dd045a 100644
--- a/osu.Game.Tests/Visual/Gameplay/TestScenePlayerLoader.cs
+++ b/osu.Game.Tests/Visual/Gameplay/TestScenePlayerLoader.cs
@@ -265,6 +265,26 @@ namespace osu.Game.Tests.Visual.Gameplay
AddUntilStep("wait for current", () => loader.IsCurrentScreen());
AddAssert($"epilepsy warning {(warning ? "present" : "absent")}", () => this.ChildrenOfType().Any() == warning);
+
+ if (warning)
+ {
+ AddUntilStep("sound volume decreased", () => Beatmap.Value.Track.AggregateVolume.Value == 0.25);
+ AddUntilStep("sound volume restored", () => Beatmap.Value.Track.AggregateVolume.Value == 1);
+ }
+ }
+
+ [Test]
+ public void TestEpilepsyWarningEarlyExit()
+ {
+ AddStep("set epilepsy warning", () => epilepsyWarning = true);
+ AddStep("load dummy beatmap", () => ResetPlayer(false));
+
+ AddUntilStep("wait for current", () => loader.IsCurrentScreen());
+
+ AddUntilStep("wait for epilepsy warning", () => loader.ChildrenOfType().Single().Alpha > 0);
+ AddStep("exit early", () => loader.Exit());
+
+ AddUntilStep("sound volume restored", () => Beatmap.Value.Track.AggregateVolume.Value == 1);
}
private class TestPlayerLoaderContainer : Container
diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneReplayRecorder.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneReplayRecorder.cs
index bc1c10e59d..47dd47959d 100644
--- a/osu.Game.Tests/Visual/Gameplay/TestSceneReplayRecorder.cs
+++ b/osu.Game.Tests/Visual/Gameplay/TestSceneReplayRecorder.cs
@@ -4,6 +4,7 @@
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
+using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
@@ -12,11 +13,13 @@ using osu.Framework.Input.Events;
using osu.Framework.Input.StateChanges;
using osu.Framework.Testing;
using osu.Framework.Threading;
+using osu.Game.Beatmaps;
using osu.Game.Graphics.Sprites;
using osu.Game.Replays;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Replays;
using osu.Game.Rulesets.UI;
+using osu.Game.Screens.Play;
using osu.Game.Tests.Visual.UserInterface;
using osuTK;
using osuTK.Graphics;
@@ -33,6 +36,9 @@ namespace osu.Game.Tests.Visual.Gameplay
private TestReplayRecorder recorder;
+ [Cached]
+ private GameplayBeatmap gameplayBeatmap = new GameplayBeatmap(new Beatmap());
+
[SetUp]
public void SetUp() => Schedule(() =>
{
@@ -166,6 +172,12 @@ namespace osu.Game.Tests.Visual.Gameplay
playbackManager?.ReplayInputHandler.SetFrameFromTime(Time.Current - 100);
}
+ [TearDownSteps]
+ public void TearDown()
+ {
+ AddStep("stop recorder", () => recorder.Expire());
+ }
+
public class TestFramedReplayInputHandler : FramedReplayInputHandler
{
public TestFramedReplayInputHandler(Replay replay)
diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneReplayRecording.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneReplayRecording.cs
index c0f99db85d..6872b6a669 100644
--- a/osu.Game.Tests/Visual/Gameplay/TestSceneReplayRecording.cs
+++ b/osu.Game.Tests/Visual/Gameplay/TestSceneReplayRecording.cs
@@ -2,17 +2,20 @@
// See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
+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.Framework.Input.StateChanges;
+using osu.Game.Beatmaps;
using osu.Game.Graphics.Sprites;
using osu.Game.Replays;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Replays;
using osu.Game.Rulesets.UI;
+using osu.Game.Screens.Play;
using osu.Game.Tests.Visual.UserInterface;
using osuTK;
using osuTK.Graphics;
@@ -25,6 +28,9 @@ namespace osu.Game.Tests.Visual.Gameplay
private readonly TestRulesetInputManager recordingManager;
+ [Cached]
+ private GameplayBeatmap gameplayBeatmap = new GameplayBeatmap(new Beatmap());
+
public TestSceneReplayRecording()
{
Replay replay = new Replay();
diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableHUDOverlay.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableHUDOverlay.cs
new file mode 100644
index 0000000000..fec1610160
--- /dev/null
+++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableHUDOverlay.cs
@@ -0,0 +1,99 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using NUnit.Framework;
+using osu.Framework.Allocation;
+using osu.Framework.Extensions.IEnumerableExtensions;
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.Containers;
+using osu.Framework.Testing;
+using osu.Game.Configuration;
+using osu.Game.Rulesets;
+using osu.Game.Rulesets.Mods;
+using osu.Game.Rulesets.Osu;
+using osu.Game.Screens.Play;
+using osuTK.Input;
+
+namespace osu.Game.Tests.Visual.Gameplay
+{
+ public class TestSceneSkinnableHUDOverlay : SkinnableTestScene
+ {
+ private HUDOverlay hudOverlay;
+
+ private IEnumerable hudOverlays => CreatedDrawables.OfType();
+
+ // best way to check without exposing.
+ private Drawable hideTarget => hudOverlay.KeyCounter;
+ private FillFlowContainer keyCounterFlow => hudOverlay.KeyCounter.ChildrenOfType>().First();
+
+ [Resolved]
+ private OsuConfigManager config { get; set; }
+
+ [Test]
+ public void TestComboCounterIncrementing()
+ {
+ createNew();
+
+ AddRepeatStep("increase combo", () =>
+ {
+ foreach (var hud in hudOverlays)
+ hud.ComboCounter.Current.Value++;
+ }, 10);
+
+ AddStep("reset combo", () =>
+ {
+ foreach (var hud in hudOverlays)
+ hud.ComboCounter.Current.Value = 0;
+ });
+ }
+
+ [Test]
+ public void TestFadesInOnLoadComplete()
+ {
+ float? initialAlpha = null;
+
+ createNew(h => h.OnLoadComplete += _ => initialAlpha = hideTarget.Alpha);
+ AddUntilStep("wait for load", () => hudOverlay.IsAlive);
+ AddAssert("initial alpha was less than 1", () => initialAlpha < 1);
+ }
+
+ [Test]
+ public void TestHideExternally()
+ {
+ createNew();
+
+ AddStep("set showhud false", () => hudOverlays.ForEach(h => h.ShowHud.Value = false));
+
+ AddUntilStep("hidetarget is hidden", () => !hideTarget.IsPresent);
+ AddAssert("pause button is still visible", () => hudOverlay.HoldToQuit.IsPresent);
+
+ // Key counter flow container should not be affected by this, only the key counter display will be hidden as checked above.
+ AddAssert("key counter flow not affected", () => keyCounterFlow.IsPresent);
+ }
+
+ private void createNew(Action action = null)
+ {
+ AddStep("create overlay", () =>
+ {
+ SetContents(() =>
+ {
+ hudOverlay = new HUDOverlay(null, null, null, Array.Empty());
+
+ // Add any key just to display the key counter visually.
+ hudOverlay.KeyCounter.Add(new KeyCounterKeyboard(Key.Space));
+
+ hudOverlay.ComboCounter.Current.Value = 1;
+
+ action?.Invoke(hudOverlay);
+
+ return hudOverlay;
+ });
+ });
+ }
+
+ protected override Ruleset CreateRulesetForSkinProvider() => new OsuRuleset();
+ }
+}
diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSpectatorPlayback.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSpectatorPlayback.cs
new file mode 100644
index 0000000000..1d8231cce7
--- /dev/null
+++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSpectatorPlayback.cs
@@ -0,0 +1,361 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System;
+using System.Collections.Generic;
+using System.Collections.Specialized;
+using System.Linq;
+using NUnit.Framework;
+using osu.Framework.Allocation;
+using osu.Framework.Bindables;
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.Containers;
+using osu.Framework.Graphics.Shapes;
+using osu.Framework.Input.Bindings;
+using osu.Framework.Input.Events;
+using osu.Framework.Input.StateChanges;
+using osu.Framework.Logging;
+using osu.Framework.Testing;
+using osu.Framework.Timing;
+using osu.Game.Beatmaps;
+using osu.Game.Graphics.Sprites;
+using osu.Game.Online.API;
+using osu.Game.Online.Spectator;
+using osu.Game.Replays;
+using osu.Game.Replays.Legacy;
+using osu.Game.Rulesets;
+using osu.Game.Rulesets.Replays;
+using osu.Game.Rulesets.Replays.Types;
+using osu.Game.Rulesets.UI;
+using osu.Game.Screens.Play;
+using osu.Game.Tests.Visual.UserInterface;
+using osuTK;
+using osuTK.Graphics;
+
+namespace osu.Game.Tests.Visual.Gameplay
+{
+ public class TestSceneSpectatorPlayback : OsuManualInputManagerTestScene
+ {
+ protected override bool UseOnlineAPI => true;
+
+ private TestRulesetInputManager playbackManager;
+ private TestRulesetInputManager recordingManager;
+
+ private Replay replay;
+
+ private IBindableList users;
+
+ private TestReplayRecorder recorder;
+
+ private readonly ManualClock manualClock = new ManualClock();
+
+ private OsuSpriteText latencyDisplay;
+
+ private TestFramedReplayInputHandler replayHandler;
+
+ [Resolved]
+ private IAPIProvider api { get; set; }
+
+ [Resolved]
+ private SpectatorStreamingClient streamingClient { get; set; }
+
+ [Cached]
+ private GameplayBeatmap gameplayBeatmap = new GameplayBeatmap(new Beatmap());
+
+ [SetUp]
+ public void SetUp() => Schedule(() =>
+ {
+ replay = new Replay();
+
+ users = streamingClient.PlayingUsers.GetBoundCopy();
+ users.BindCollectionChanged((obj, args) =>
+ {
+ switch (args.Action)
+ {
+ case NotifyCollectionChangedAction.Add:
+ foreach (int user in args.NewItems)
+ {
+ if (user == api.LocalUser.Value.Id)
+ streamingClient.WatchUser(user);
+ }
+
+ break;
+
+ case NotifyCollectionChangedAction.Remove:
+ foreach (int user in args.OldItems)
+ {
+ if (user == api.LocalUser.Value.Id)
+ streamingClient.StopWatchingUser(user);
+ }
+
+ break;
+ }
+ }, true);
+
+ streamingClient.OnNewFrames += onNewFrames;
+
+ Add(new GridContainer
+ {
+ RelativeSizeAxes = Axes.Both,
+ Content = new[]
+ {
+ new Drawable[]
+ {
+ recordingManager = new TestRulesetInputManager(new TestSceneModSettings.TestRulesetInfo(), 0, SimultaneousBindingMode.Unique)
+ {
+ Recorder = recorder = new TestReplayRecorder
+ {
+ ScreenSpaceToGamefield = pos => recordingManager.ToLocalSpace(pos),
+ },
+ Child = new Container
+ {
+ RelativeSizeAxes = Axes.Both,
+ Children = new Drawable[]
+ {
+ new Box
+ {
+ Colour = Color4.Brown,
+ RelativeSizeAxes = Axes.Both,
+ },
+ new OsuSpriteText
+ {
+ Text = "Sending",
+ Scale = new Vector2(3),
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ },
+ new TestInputConsumer()
+ }
+ },
+ }
+ },
+ new Drawable[]
+ {
+ playbackManager = new TestRulesetInputManager(new TestSceneModSettings.TestRulesetInfo(), 0, SimultaneousBindingMode.Unique)
+ {
+ Clock = new FramedClock(manualClock),
+ ReplayInputHandler = replayHandler = new TestFramedReplayInputHandler(replay)
+ {
+ GamefieldToScreenSpace = pos => playbackManager.ToScreenSpace(pos),
+ },
+ Child = new Container
+ {
+ RelativeSizeAxes = Axes.Both,
+ Children = new Drawable[]
+ {
+ new Box
+ {
+ Colour = Color4.DarkBlue,
+ RelativeSizeAxes = Axes.Both,
+ },
+ new OsuSpriteText
+ {
+ Text = "Receiving",
+ Scale = new Vector2(3),
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ },
+ new TestInputConsumer()
+ }
+ },
+ }
+ }
+ }
+ });
+
+ Add(latencyDisplay = new OsuSpriteText());
+ });
+
+ private void onNewFrames(int userId, FrameDataBundle frames)
+ {
+ Logger.Log($"Received {frames.Frames.Count()} new frames ({string.Join(',', frames.Frames.Select(f => ((int)f.Time).ToString()))})");
+
+ foreach (var legacyFrame in frames.Frames)
+ {
+ var frame = new TestReplayFrame();
+ frame.FromLegacy(legacyFrame, null, null);
+ replay.Frames.Add(frame);
+ }
+ }
+
+ [Test]
+ public void TestBasic()
+ {
+ }
+
+ private double latency = SpectatorStreamingClient.TIME_BETWEEN_SENDS;
+
+ protected override void Update()
+ {
+ base.Update();
+
+ if (latencyDisplay == null) return;
+
+ // propagate initial time value
+ if (manualClock.CurrentTime == 0)
+ {
+ manualClock.CurrentTime = Time.Current;
+ return;
+ }
+
+ if (replayHandler.NextFrame != null)
+ {
+ var lastFrame = replay.Frames.LastOrDefault();
+
+ // this isn't perfect as we basically can't be aware of the rate-of-send here (the streamer is not sending data when not being moved).
+ // in gameplay playback, the case where NextFrame is null would pause gameplay and handle this correctly; it's strictly a test limitation / best effort implementation.
+ if (lastFrame != null)
+ latency = Math.Max(latency, Time.Current - lastFrame.Time);
+
+ latencyDisplay.Text = $"latency: {latency:N1}";
+
+ double proposedTime = Time.Current - latency + Time.Elapsed;
+
+ // this will either advance by one or zero frames.
+ double? time = replayHandler.SetFrameFromTime(proposedTime);
+
+ if (time == null)
+ return;
+
+ manualClock.CurrentTime = time.Value;
+ }
+ }
+
+ [TearDownSteps]
+ public void TearDown()
+ {
+ AddStep("stop recorder", () =>
+ {
+ recorder.Expire();
+ streamingClient.OnNewFrames -= onNewFrames;
+ });
+ }
+
+ public class TestFramedReplayInputHandler : FramedReplayInputHandler
+ {
+ public TestFramedReplayInputHandler(Replay replay)
+ : base(replay)
+ {
+ }
+
+ public override void CollectPendingInputs(List inputs)
+ {
+ inputs.Add(new MousePositionAbsoluteInput { Position = GamefieldToScreenSpace(CurrentFrame?.Position ?? Vector2.Zero) });
+ inputs.Add(new ReplayState { PressedActions = CurrentFrame?.Actions ?? new List() });
+ }
+ }
+
+ public class TestInputConsumer : CompositeDrawable, IKeyBindingHandler
+ {
+ public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => Parent.ReceivePositionalInputAt(screenSpacePos);
+
+ private readonly Box box;
+
+ public TestInputConsumer()
+ {
+ Size = new Vector2(30);
+
+ Origin = Anchor.Centre;
+
+ InternalChildren = new Drawable[]
+ {
+ box = new Box
+ {
+ Colour = Color4.Black,
+ RelativeSizeAxes = Axes.Both,
+ },
+ };
+ }
+
+ protected override bool OnMouseMove(MouseMoveEvent e)
+ {
+ Position = e.MousePosition;
+ return base.OnMouseMove(e);
+ }
+
+ public bool OnPressed(TestAction action)
+ {
+ box.Colour = Color4.White;
+ return true;
+ }
+
+ public void OnReleased(TestAction action)
+ {
+ box.Colour = Color4.Black;
+ }
+ }
+
+ public class TestRulesetInputManager : RulesetInputManager
+ {
+ public TestRulesetInputManager(RulesetInfo ruleset, int variant, SimultaneousBindingMode unique)
+ : base(ruleset, variant, unique)
+ {
+ }
+
+ protected override KeyBindingContainer CreateKeyBindingContainer(RulesetInfo ruleset, int variant, SimultaneousBindingMode unique)
+ => new TestKeyBindingContainer();
+
+ internal class TestKeyBindingContainer : KeyBindingContainer
+ {
+ public override IEnumerable DefaultKeyBindings => new[]
+ {
+ new KeyBinding(InputKey.MouseLeft, TestAction.Down),
+ };
+ }
+ }
+
+ public class TestReplayFrame : ReplayFrame, IConvertibleReplayFrame
+ {
+ public Vector2 Position;
+
+ public List Actions = new List();
+
+ public TestReplayFrame(double time, Vector2 position, params TestAction[] actions)
+ : base(time)
+ {
+ Position = position;
+ Actions.AddRange(actions);
+ }
+
+ public TestReplayFrame()
+ {
+ }
+
+ public void FromLegacy(LegacyReplayFrame currentFrame, IBeatmap beatmap, ReplayFrame lastFrame = null)
+ {
+ Position = currentFrame.Position;
+ Time = currentFrame.Time;
+ if (currentFrame.MouseLeft)
+ Actions.Add(TestAction.Down);
+ }
+
+ public LegacyReplayFrame ToLegacy(IBeatmap beatmap)
+ {
+ ReplayButtonState state = ReplayButtonState.None;
+
+ if (Actions.Contains(TestAction.Down))
+ state |= ReplayButtonState.Left1;
+
+ return new LegacyReplayFrame(Time, Position.X, Position.Y, state);
+ }
+ }
+
+ public enum TestAction
+ {
+ Down,
+ }
+
+ internal class TestReplayRecorder : ReplayRecorder
+ {
+ public TestReplayRecorder()
+ : base(new Replay())
+ {
+ }
+
+ protected override ReplayFrame HandleFrame(Vector2 mousePosition, List actions, ReplayFrame previousFrame)
+ {
+ return new TestReplayFrame(Time.Current, mousePosition, actions.ToArray());
+ }
+ }
+ }
+}
diff --git a/osu.Game.Tests/Visual/Ranking/TestSceneScorePanel.cs b/osu.Game.Tests/Visual/Ranking/TestSceneScorePanel.cs
index 250fdc5ebd..5af55e99f8 100644
--- a/osu.Game.Tests/Visual/Ranking/TestSceneScorePanel.cs
+++ b/osu.Game.Tests/Visual/Ranking/TestSceneScorePanel.cs
@@ -103,7 +103,7 @@ namespace osu.Game.Tests.Visual.Ranking
private void addPanelStep(ScoreInfo score, PanelState state = PanelState.Expanded) => AddStep("add panel", () =>
{
- Child = panel = new ScorePanel(score)
+ Child = panel = new ScorePanel(score, true)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
diff --git a/osu.Game.Tests/Visual/Ranking/TestSceneStarRatingDisplay.cs b/osu.Game.Tests/Visual/Ranking/TestSceneStarRatingDisplay.cs
index d12f32e470..d0067c3396 100644
--- a/osu.Game.Tests/Visual/Ranking/TestSceneStarRatingDisplay.cs
+++ b/osu.Game.Tests/Visual/Ranking/TestSceneStarRatingDisplay.cs
@@ -18,13 +18,13 @@ namespace osu.Game.Tests.Visual.Ranking
Origin = Anchor.Centre,
Children = new Drawable[]
{
- new StarRatingDisplay(new BeatmapInfo { StarDifficulty = 1.23 }),
- new StarRatingDisplay(new BeatmapInfo { StarDifficulty = 2.34 }),
- new StarRatingDisplay(new BeatmapInfo { StarDifficulty = 3.45 }),
- new StarRatingDisplay(new BeatmapInfo { StarDifficulty = 4.56 }),
- new StarRatingDisplay(new BeatmapInfo { StarDifficulty = 5.67 }),
- new StarRatingDisplay(new BeatmapInfo { StarDifficulty = 6.78 }),
- new StarRatingDisplay(new BeatmapInfo { StarDifficulty = 10.11 }),
+ new StarRatingDisplay(new StarDifficulty(1.23, 0)),
+ new StarRatingDisplay(new StarDifficulty(2.34, 0)),
+ new StarRatingDisplay(new StarDifficulty(3.45, 0)),
+ new StarRatingDisplay(new StarDifficulty(4.56, 0)),
+ new StarRatingDisplay(new StarDifficulty(5.67, 0)),
+ new StarRatingDisplay(new StarDifficulty(6.78, 0)),
+ new StarRatingDisplay(new StarDifficulty(10.11, 0)),
}
};
}
diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapListingSearchControl.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapListingSearchControl.cs
index a4698a9a32..3f757031f8 100644
--- a/osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapListingSearchControl.cs
+++ b/osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapListingSearchControl.cs
@@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
+using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
@@ -27,6 +28,9 @@ namespace osu.Game.Tests.Visual.UserInterface
OsuSpriteText category;
OsuSpriteText genre;
OsuSpriteText language;
+ OsuSpriteText extra;
+ OsuSpriteText ranks;
+ OsuSpriteText played;
Add(control = new BeatmapListingSearchControl
{
@@ -46,6 +50,9 @@ namespace osu.Game.Tests.Visual.UserInterface
category = new OsuSpriteText(),
genre = new OsuSpriteText(),
language = new OsuSpriteText(),
+ extra = new OsuSpriteText(),
+ ranks = new OsuSpriteText(),
+ played = new OsuSpriteText()
}
});
@@ -54,6 +61,9 @@ namespace osu.Game.Tests.Visual.UserInterface
control.Category.BindValueChanged(c => category.Text = $"Category: {c.NewValue}", true);
control.Genre.BindValueChanged(g => genre.Text = $"Genre: {g.NewValue}", true);
control.Language.BindValueChanged(l => language.Text = $"Language: {l.NewValue}", true);
+ control.Extra.BindCollectionChanged((u, v) => extra.Text = $"Extra: {(control.Extra.Any() ? string.Join('.', control.Extra.Select(i => i.ToString().ToLowerInvariant())) : "")}", true);
+ control.Ranks.BindCollectionChanged((u, v) => ranks.Text = $"Ranks: {(control.Ranks.Any() ? string.Join('.', control.Ranks.Select(i => i.ToString())) : "")}", true);
+ control.Played.BindValueChanged(p => played.Text = $"Played: {p.NewValue}", true);
}
[Test]
diff --git a/osu.Game.Tournament/Components/DrawableTeamFlag.cs b/osu.Game.Tournament/Components/DrawableTeamFlag.cs
index 8c85c9a46f..75991a1ab8 100644
--- a/osu.Game.Tournament/Components/DrawableTeamFlag.cs
+++ b/osu.Game.Tournament/Components/DrawableTeamFlag.cs
@@ -4,19 +4,24 @@
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Game.Tournament.Models;
+using osuTK;
namespace osu.Game.Tournament.Components
{
- public class DrawableTeamFlag : Sprite
+ public class DrawableTeamFlag : Container
{
private readonly TournamentTeam team;
[UsedImplicitly]
private Bindable flag;
+ private Sprite flagSprite;
+
public DrawableTeamFlag(TournamentTeam team)
{
this.team = team;
@@ -27,7 +32,18 @@ namespace osu.Game.Tournament.Components
{
if (team == null) return;
- (flag = team.FlagName.GetBoundCopy()).BindValueChanged(acronym => Texture = textures.Get($@"Flags/{team.FlagName}"), true);
+ Size = new Vector2(75, 50);
+ Masking = true;
+ CornerRadius = 5;
+ Child = flagSprite = new Sprite
+ {
+ RelativeSizeAxes = Axes.Both,
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ FillMode = FillMode.Fill
+ };
+
+ (flag = team.FlagName.GetBoundCopy()).BindValueChanged(acronym => flagSprite.Texture = textures.Get($@"Flags/{team.FlagName}"), true);
}
}
}
diff --git a/osu.Game.Tournament/Components/DrawableTournamentTeam.cs b/osu.Game.Tournament/Components/DrawableTournamentTeam.cs
index f8aed26ce1..b9442a67f5 100644
--- a/osu.Game.Tournament/Components/DrawableTournamentTeam.cs
+++ b/osu.Game.Tournament/Components/DrawableTournamentTeam.cs
@@ -4,9 +4,7 @@
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
-using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
-using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Game.Graphics;
using osu.Game.Tournament.Models;
@@ -17,7 +15,7 @@ namespace osu.Game.Tournament.Components
{
public readonly TournamentTeam Team;
- protected readonly Sprite Flag;
+ protected readonly Container Flag;
protected readonly TournamentSpriteText AcronymText;
[UsedImplicitly]
@@ -27,12 +25,7 @@ namespace osu.Game.Tournament.Components
{
Team = team;
- Flag = new DrawableTeamFlag(team)
- {
- RelativeSizeAxes = Axes.Both,
- FillMode = FillMode.Fit
- };
-
+ Flag = new DrawableTeamFlag(team);
AcronymText = new TournamentSpriteText
{
Font = OsuFont.Torus.With(weight: FontWeight.Regular),
diff --git a/osu.Game.Tournament/Screens/Drawings/Components/GroupTeam.cs b/osu.Game.Tournament/Screens/Drawings/Components/GroupTeam.cs
index 4f0ce0bbe7..cd252392ba 100644
--- a/osu.Game.Tournament/Screens/Drawings/Components/GroupTeam.cs
+++ b/osu.Game.Tournament/Screens/Drawings/Components/GroupTeam.cs
@@ -27,6 +27,7 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
AcronymText.Origin = Anchor.TopCentre;
AcronymText.Text = team.Acronym.Value.ToUpperInvariant();
AcronymText.Font = OsuFont.Torus.With(weight: FontWeight.Bold, size: 10);
+ Flag.Scale = new Vector2(0.48f);
InternalChildren = new Drawable[]
{
diff --git a/osu.Game.Tournament/Screens/Gameplay/Components/TeamDisplay.cs b/osu.Game.Tournament/Screens/Gameplay/Components/TeamDisplay.cs
index 1b4a769b84..4ba86dcefc 100644
--- a/osu.Game.Tournament/Screens/Gameplay/Components/TeamDisplay.cs
+++ b/osu.Game.Tournament/Screens/Gameplay/Components/TeamDisplay.cs
@@ -29,7 +29,7 @@ namespace osu.Game.Tournament.Screens.Gameplay.Components
var anchor = flip ? Anchor.TopLeft : Anchor.TopRight;
Flag.RelativeSizeAxes = Axes.None;
- Flag.Size = new Vector2(60, 40);
+ Flag.Scale = new Vector2(0.8f);
Flag.Origin = anchor;
Flag.Anchor = anchor;
diff --git a/osu.Game.Tournament/Screens/Ladder/Components/DrawableMatchTeam.cs b/osu.Game.Tournament/Screens/Ladder/Components/DrawableMatchTeam.cs
index 15cb7e44cb..bb1e4d2eff 100644
--- a/osu.Game.Tournament/Screens/Ladder/Components/DrawableMatchTeam.cs
+++ b/osu.Game.Tournament/Screens/Ladder/Components/DrawableMatchTeam.cs
@@ -63,7 +63,7 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
this.losers = losers;
Size = new Vector2(150, 40);
- Flag.Scale = new Vector2(0.9f);
+ Flag.Scale = new Vector2(0.54f);
Flag.Anchor = Flag.Origin = Anchor.CentreLeft;
AcronymText.Anchor = AcronymText.Origin = Anchor.CentreLeft;
diff --git a/osu.Game.Tournament/Screens/TeamIntro/SeedingScreen.cs b/osu.Game.Tournament/Screens/TeamIntro/SeedingScreen.cs
index b343608e69..55fc80dba2 100644
--- a/osu.Game.Tournament/Screens/TeamIntro/SeedingScreen.cs
+++ b/osu.Game.Tournament/Screens/TeamIntro/SeedingScreen.cs
@@ -288,8 +288,7 @@ namespace osu.Game.Tournament.Screens.TeamIntro
AutoSizeAxes = Axes.Both;
Flag.RelativeSizeAxes = Axes.None;
- Flag.Size = new Vector2(300, 200);
- Flag.Scale = new Vector2(0.3f);
+ Flag.Scale = new Vector2(1.2f);
InternalChild = new FillFlowContainer
{
diff --git a/osu.Game.Tournament/Screens/TeamWin/TeamWinScreen.cs b/osu.Game.Tournament/Screens/TeamWin/TeamWinScreen.cs
index 3870f486e1..7ca262a2e8 100644
--- a/osu.Game.Tournament/Screens/TeamWin/TeamWinScreen.cs
+++ b/osu.Game.Tournament/Screens/TeamWin/TeamWinScreen.cs
@@ -90,11 +90,10 @@ namespace osu.Game.Tournament.Screens.TeamWin
{
new DrawableTeamFlag(match.Winner)
{
- Size = new Vector2(300, 200),
- Scale = new Vector2(0.5f),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Position = new Vector2(-300, 10),
+ Scale = new Vector2(2f)
},
new FillFlowContainer
{
diff --git a/osu.Game/Beatmaps/Formats/LegacyStoryboardDecoder.cs b/osu.Game/Beatmaps/Formats/LegacyStoryboardDecoder.cs
index 269449ef80..e2550d1ca4 100644
--- a/osu.Game/Beatmaps/Formats/LegacyStoryboardDecoder.cs
+++ b/osu.Game/Beatmaps/Formats/LegacyStoryboardDecoder.cs
@@ -48,6 +48,10 @@ namespace osu.Game.Beatmaps.Formats
switch (section)
{
+ case Section.General:
+ handleGeneral(storyboard, line);
+ return;
+
case Section.Events:
handleEvents(line);
return;
@@ -60,6 +64,18 @@ namespace osu.Game.Beatmaps.Formats
base.ParseLine(storyboard, section, line);
}
+ private void handleGeneral(Storyboard storyboard, string line)
+ {
+ var pair = SplitKeyVal(line);
+
+ switch (pair.Key)
+ {
+ case "UseSkinSprites":
+ storyboard.UseSkinSprites = pair.Value == "1";
+ break;
+ }
+ }
+
private void handleEvents(string line)
{
var depth = 0;
diff --git a/osu.Game/Configuration/HUDVisibilityMode.cs b/osu.Game/Configuration/HUDVisibilityMode.cs
index b0b55dd811..10f3f65355 100644
--- a/osu.Game/Configuration/HUDVisibilityMode.cs
+++ b/osu.Game/Configuration/HUDVisibilityMode.cs
@@ -12,9 +12,6 @@ namespace osu.Game.Configuration
[Description("Hide during gameplay")]
HideDuringGameplay,
- [Description("Hide during breaks")]
- HideDuringBreaks,
-
Always
}
}
diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs
index 9f7280eef4..e579898c05 100644
--- a/osu.Game/Configuration/OsuConfigManager.cs
+++ b/osu.Game/Configuration/OsuConfigManager.cs
@@ -171,6 +171,7 @@ namespace osu.Game.Configuration
public override TrackedSettings CreateTrackedSettings() => new TrackedSettings
{
new TrackedSetting(OsuSetting.MouseDisableButtons, v => new SettingDescription(!v, "gameplay mouse buttons", v ? "disabled" : "enabled")),
+ new TrackedSetting(OsuSetting.HUDVisibilityMode, m => new SettingDescription(m, "HUD Visibility", m.GetDescription())),
new TrackedSetting(OsuSetting.Scaling, m => new SettingDescription(m, "scaling", m.GetDescription())),
};
}
diff --git a/osu.Game/Input/Bindings/GlobalActionContainer.cs b/osu.Game/Input/Bindings/GlobalActionContainer.cs
index 41be4cfcc3..3de4bb1f9d 100644
--- a/osu.Game/Input/Bindings/GlobalActionContainer.cs
+++ b/osu.Game/Input/Bindings/GlobalActionContainer.cs
@@ -67,6 +67,7 @@ namespace osu.Game.Input.Bindings
new KeyBinding(new[] { InputKey.Control, InputKey.Plus }, GlobalAction.IncreaseScrollSpeed),
new KeyBinding(new[] { InputKey.Control, InputKey.Minus }, GlobalAction.DecreaseScrollSpeed),
new KeyBinding(InputKey.MouseMiddle, GlobalAction.PauseGameplay),
+ new KeyBinding(InputKey.Control, GlobalAction.HoldForHUD),
};
public IEnumerable AudioControlKeyBindings => new[]
@@ -187,5 +188,8 @@ namespace osu.Game.Input.Bindings
[Description("Timing Mode")]
EditorTimingMode,
+
+ [Description("Hold for HUD")]
+ HoldForHUD,
}
}
diff --git a/osu.Game/Online/API/APIMod.cs b/osu.Game/Online/API/APIMod.cs
index 46a8db31b7..780e5daa16 100644
--- a/osu.Game/Online/API/APIMod.cs
+++ b/osu.Game/Online/API/APIMod.cs
@@ -53,5 +53,13 @@ namespace osu.Game.Online.API
}
public bool Equals(IMod other) => Acronym == other?.Acronym;
+
+ public override string ToString()
+ {
+ if (Settings.Count > 0)
+ return $"{Acronym} ({string.Join(',', Settings.Select(kvp => $"{kvp.Key}:{kvp.Value}"))})";
+
+ return $"{Acronym}";
+ }
}
}
diff --git a/osu.Game/Online/API/DummyAPIAccess.cs b/osu.Game/Online/API/DummyAPIAccess.cs
index da22a70bf8..e275676cea 100644
--- a/osu.Game/Online/API/DummyAPIAccess.cs
+++ b/osu.Game/Online/API/DummyAPIAccess.cs
@@ -20,6 +20,8 @@ namespace osu.Game.Online.API
public Bindable Activity { get; } = new Bindable();
+ public string AccessToken => "token";
+
public bool IsLoggedIn => State.Value == APIState.Online;
public string ProvidedUsername => LocalUser.Value.Username;
diff --git a/osu.Game/Online/API/IAPIProvider.cs b/osu.Game/Online/API/IAPIProvider.cs
index fc675639bf..cadc806f4f 100644
--- a/osu.Game/Online/API/IAPIProvider.cs
+++ b/osu.Game/Online/API/IAPIProvider.cs
@@ -21,6 +21,11 @@ namespace osu.Game.Online.API
///
Bindable Activity { get; }
+ ///
+ /// Retrieve the OAuth access token.
+ ///
+ string AccessToken { get; }
+
///
/// Returns whether the local user is logged in.
///
diff --git a/osu.Game/Online/API/Requests/SearchBeatmapSetsRequest.cs b/osu.Game/Online/API/Requests/SearchBeatmapSetsRequest.cs
index dde45b5aeb..bbaa7e745f 100644
--- a/osu.Game/Online/API/Requests/SearchBeatmapSetsRequest.cs
+++ b/osu.Game/Online/API/Requests/SearchBeatmapSetsRequest.cs
@@ -1,11 +1,15 @@
// Copyright (c) ppy Pty Ltd . 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 JetBrains.Annotations;
using osu.Framework.IO.Network;
using osu.Game.Extensions;
using osu.Game.Overlays;
using osu.Game.Overlays.BeatmapListing;
using osu.Game.Rulesets;
+using osu.Game.Scoring;
namespace osu.Game.Online.API.Requests
{
@@ -21,6 +25,14 @@ namespace osu.Game.Online.API.Requests
public SearchLanguage Language { get; }
+ [CanBeNull]
+ public IReadOnlyCollection Extra { get; }
+
+ public SearchPlayed Played { get; }
+
+ [CanBeNull]
+ public IReadOnlyCollection Ranks { get; }
+
private readonly string query;
private readonly RulesetInfo ruleset;
private readonly Cursor cursor;
@@ -35,7 +47,10 @@ namespace osu.Game.Online.API.Requests
SortCriteria sortCriteria = SortCriteria.Ranked,
SortDirection sortDirection = SortDirection.Descending,
SearchGenre genre = SearchGenre.Any,
- SearchLanguage language = SearchLanguage.Any)
+ SearchLanguage language = SearchLanguage.Any,
+ IReadOnlyCollection extra = null,
+ IReadOnlyCollection ranks = null,
+ SearchPlayed played = SearchPlayed.Any)
{
this.query = string.IsNullOrEmpty(query) ? string.Empty : System.Uri.EscapeDataString(query);
this.ruleset = ruleset;
@@ -46,6 +61,9 @@ namespace osu.Game.Online.API.Requests
SortDirection = sortDirection;
Genre = genre;
Language = language;
+ Extra = extra;
+ Ranks = ranks;
+ Played = played;
}
protected override WebRequest CreateWebRequest()
@@ -66,6 +84,15 @@ namespace osu.Game.Online.API.Requests
req.AddParameter("sort", $"{SortCriteria.ToString().ToLowerInvariant()}_{directionString}");
+ if (Extra != null && Extra.Any())
+ req.AddParameter("e", string.Join('.', Extra.Select(e => e.ToString().ToLowerInvariant())));
+
+ if (Ranks != null && Ranks.Any())
+ req.AddParameter("r", string.Join('.', Ranks.Select(r => r.ToString())));
+
+ if (Played != SearchPlayed.Any)
+ req.AddParameter("played", Played.ToString().ToLowerInvariant());
+
req.AddCursor(cursor);
return req;
diff --git a/osu.Game/Online/Spectator/FrameDataBundle.cs b/osu.Game/Online/Spectator/FrameDataBundle.cs
new file mode 100644
index 0000000000..5281e61f9c
--- /dev/null
+++ b/osu.Game/Online/Spectator/FrameDataBundle.cs
@@ -0,0 +1,20 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System;
+using System.Collections.Generic;
+using osu.Game.Replays.Legacy;
+
+namespace osu.Game.Online.Spectator
+{
+ [Serializable]
+ public class FrameDataBundle
+ {
+ public IEnumerable Frames { get; set; }
+
+ public FrameDataBundle(IEnumerable frames)
+ {
+ Frames = frames;
+ }
+ }
+}
diff --git a/osu.Game/Online/Spectator/ISpectatorClient.cs b/osu.Game/Online/Spectator/ISpectatorClient.cs
new file mode 100644
index 0000000000..3acc9b2282
--- /dev/null
+++ b/osu.Game/Online/Spectator/ISpectatorClient.cs
@@ -0,0 +1,34 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System.Threading.Tasks;
+
+namespace osu.Game.Online.Spectator
+{
+ ///
+ /// An interface defining a spectator client instance.
+ ///
+ public interface ISpectatorClient
+ {
+ ///
+ /// Signals that a user has begun a new play session.
+ ///
+ /// The user.
+ /// The state of gameplay.
+ Task UserBeganPlaying(int userId, SpectatorState state);
+
+ ///
+ /// Signals that a user has finished a play session.
+ ///
+ /// The user.
+ /// The state of gameplay.
+ Task UserFinishedPlaying(int userId, SpectatorState state);
+
+ ///
+ /// Called when new frames are available for a subscribed user's play session.
+ ///
+ /// The user.
+ /// The frame data.
+ Task UserSentFrames(int userId, FrameDataBundle data);
+ }
+}
diff --git a/osu.Game/Online/Spectator/ISpectatorServer.cs b/osu.Game/Online/Spectator/ISpectatorServer.cs
new file mode 100644
index 0000000000..af0196862a
--- /dev/null
+++ b/osu.Game/Online/Spectator/ISpectatorServer.cs
@@ -0,0 +1,44 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System.Threading.Tasks;
+
+namespace osu.Game.Online.Spectator
+{
+ ///
+ /// An interface defining the spectator server instance.
+ ///
+ public interface ISpectatorServer
+ {
+ ///
+ /// Signal the start of a new play session.
+ ///
+ /// The state of gameplay.
+ Task BeginPlaySession(SpectatorState state);
+
+ ///
+ /// Send a bundle of frame data for the current play session.
+ ///
+ /// The frame data.
+ Task SendFrameData(FrameDataBundle data);
+
+ ///
+ /// Signal the end of a play session.
+ ///
+ /// The state of gameplay.
+ Task EndPlaySession(SpectatorState state);
+
+ ///
+ /// Request spectating data for the specified user. May be called on multiple users and offline users.
+ /// For offline users, a subscription will be created and data will begin streaming on next play.
+ ///
+ /// The user to subscribe to.
+ Task StartWatchingUser(int userId);
+
+ ///
+ /// Stop requesting spectating data for the specified user. Unsubscribes from receiving further data.
+ ///
+ /// The user to unsubscribe from.
+ Task EndWatchingUser(int userId);
+ }
+}
diff --git a/osu.Game/Online/Spectator/SpectatorState.cs b/osu.Game/Online/Spectator/SpectatorState.cs
new file mode 100644
index 0000000000..101ce3d5d5
--- /dev/null
+++ b/osu.Game/Online/Spectator/SpectatorState.cs
@@ -0,0 +1,26 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+using osu.Game.Online.API;
+
+namespace osu.Game.Online.Spectator
+{
+ [Serializable]
+ public class SpectatorState : IEquatable
+ {
+ public int? BeatmapID { get; set; }
+
+ public int? RulesetID { get; set; }
+
+ [NotNull]
+ public IEnumerable Mods { get; set; } = Enumerable.Empty();
+
+ public bool Equals(SpectatorState other) => BeatmapID == other?.BeatmapID && Mods.SequenceEqual(other?.Mods) && RulesetID == other?.RulesetID;
+
+ public override string ToString() => $"Beatmap:{BeatmapID} Mods:{string.Join(',', Mods)} Ruleset:{RulesetID}";
+ }
+}
diff --git a/osu.Game/Online/Spectator/SpectatorStreamingClient.cs b/osu.Game/Online/Spectator/SpectatorStreamingClient.cs
new file mode 100644
index 0000000000..5a41316f31
--- /dev/null
+++ b/osu.Game/Online/Spectator/SpectatorStreamingClient.cs
@@ -0,0 +1,274 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Threading.Tasks;
+using JetBrains.Annotations;
+using Microsoft.AspNetCore.SignalR.Client;
+using Microsoft.Extensions.DependencyInjection;
+using Newtonsoft.Json;
+using osu.Framework.Allocation;
+using osu.Framework.Bindables;
+using osu.Framework.Graphics;
+using osu.Game.Beatmaps;
+using osu.Game.Online.API;
+using osu.Game.Replays.Legacy;
+using osu.Game.Rulesets;
+using osu.Game.Rulesets.Mods;
+using osu.Game.Rulesets.Replays;
+using osu.Game.Rulesets.Replays.Types;
+using osu.Game.Screens.Play;
+
+namespace osu.Game.Online.Spectator
+{
+ public class SpectatorStreamingClient : Component, ISpectatorClient
+ {
+ ///
+ /// The maximum milliseconds between frame bundle sends.
+ ///
+ public const double TIME_BETWEEN_SENDS = 200;
+
+ private HubConnection connection;
+
+ private readonly List watchingUsers = new List();
+
+ public IBindableList PlayingUsers => playingUsers;
+
+ private readonly BindableList playingUsers = new BindableList();
+
+ private readonly IBindable apiState = new Bindable();
+
+ private bool isConnected;
+
+ [Resolved]
+ private IAPIProvider api { get; set; }
+
+ [CanBeNull]
+ private IBeatmap currentBeatmap;
+
+ [Resolved]
+ private IBindable currentRuleset { get; set; }
+
+ [Resolved]
+ private IBindable> currentMods { get; set; }
+
+ private readonly SpectatorState currentState = new SpectatorState();
+
+ private bool isPlaying;
+
+ ///
+ /// Called whenever new frames arrive from the server.
+ ///
+ public event Action OnNewFrames;
+
+ [BackgroundDependencyLoader]
+ private void load()
+ {
+ apiState.BindTo(api.State);
+ apiState.BindValueChanged(apiStateChanged, true);
+ }
+
+ private void apiStateChanged(ValueChangedEvent state)
+ {
+ switch (state.NewValue)
+ {
+ case APIState.Failing:
+ case APIState.Offline:
+ connection?.StopAsync();
+ connection = null;
+ break;
+
+ case APIState.Online:
+ Task.Run(connect);
+ break;
+ }
+ }
+
+ private const string endpoint = "https://spectator.ppy.sh/spectator";
+
+ private async Task connect()
+ {
+ if (connection != null)
+ return;
+
+ connection = new HubConnectionBuilder()
+ .WithUrl(endpoint, options =>
+ {
+ options.Headers.Add("Authorization", $"Bearer {api.AccessToken}");
+ })
+ .AddNewtonsoftJsonProtocol(options => { options.PayloadSerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; })
+ .Build();
+
+ // until strong typed client support is added, each method must be manually bound (see https://github.com/dotnet/aspnetcore/issues/15198)
+ connection.On(nameof(ISpectatorClient.UserBeganPlaying), ((ISpectatorClient)this).UserBeganPlaying);
+ connection.On(nameof(ISpectatorClient.UserSentFrames), ((ISpectatorClient)this).UserSentFrames);
+ connection.On(nameof(ISpectatorClient.UserFinishedPlaying), ((ISpectatorClient)this).UserFinishedPlaying);
+
+ connection.Closed += async ex =>
+ {
+ isConnected = false;
+ playingUsers.Clear();
+
+ if (ex != null) await tryUntilConnected();
+ };
+
+ await tryUntilConnected();
+
+ async Task tryUntilConnected()
+ {
+ while (api.State.Value == APIState.Online)
+ {
+ try
+ {
+ // reconnect on any failure
+ await connection.StartAsync();
+
+ // success
+ isConnected = true;
+
+ // resubscribe to watched users
+ var users = watchingUsers.ToArray();
+ watchingUsers.Clear();
+ foreach (var userId in users)
+ WatchUser(userId);
+
+ // re-send state in case it wasn't received
+ if (isPlaying)
+ beginPlaying();
+
+ break;
+ }
+ catch
+ {
+ await Task.Delay(5000);
+ }
+ }
+ }
+ }
+
+ Task ISpectatorClient.UserBeganPlaying(int userId, SpectatorState state)
+ {
+ if (!playingUsers.Contains(userId))
+ playingUsers.Add(userId);
+
+ return Task.CompletedTask;
+ }
+
+ Task ISpectatorClient.UserFinishedPlaying(int userId, SpectatorState state)
+ {
+ playingUsers.Remove(userId);
+ return Task.CompletedTask;
+ }
+
+ Task ISpectatorClient.UserSentFrames(int userId, FrameDataBundle data)
+ {
+ OnNewFrames?.Invoke(userId, data);
+ return Task.CompletedTask;
+ }
+
+ public void BeginPlaying(GameplayBeatmap beatmap)
+ {
+ if (isPlaying)
+ throw new InvalidOperationException($"Cannot invoke {nameof(BeginPlaying)} when already playing");
+
+ isPlaying = true;
+
+ // transfer state at point of beginning play
+ currentState.BeatmapID = beatmap.BeatmapInfo.OnlineBeatmapID;
+ currentState.RulesetID = currentRuleset.Value.ID;
+ currentState.Mods = currentMods.Value.Select(m => new APIMod(m));
+
+ currentBeatmap = beatmap.PlayableBeatmap;
+ beginPlaying();
+ }
+
+ private void beginPlaying()
+ {
+ Debug.Assert(isPlaying);
+
+ if (!isConnected) return;
+
+ connection.SendAsync(nameof(ISpectatorServer.BeginPlaySession), currentState);
+ }
+
+ public void SendFrames(FrameDataBundle data)
+ {
+ if (!isConnected) return;
+
+ lastSend = connection.SendAsync(nameof(ISpectatorServer.SendFrameData), data);
+ }
+
+ public void EndPlaying()
+ {
+ isPlaying = false;
+ currentBeatmap = null;
+
+ if (!isConnected) return;
+
+ connection.SendAsync(nameof(ISpectatorServer.EndPlaySession), currentState);
+ }
+
+ public void WatchUser(int userId)
+ {
+ if (watchingUsers.Contains(userId))
+ return;
+
+ watchingUsers.Add(userId);
+
+ if (!isConnected) return;
+
+ connection.SendAsync(nameof(ISpectatorServer.StartWatchingUser), userId);
+ }
+
+ public void StopWatchingUser(int userId)
+ {
+ watchingUsers.Remove(userId);
+
+ if (!isConnected) return;
+
+ connection.SendAsync(nameof(ISpectatorServer.EndWatchingUser), userId);
+ }
+
+ private readonly Queue pendingFrames = new Queue();
+
+ private double lastSendTime;
+
+ private Task lastSend;
+
+ private const int max_pending_frames = 30;
+
+ protected override void Update()
+ {
+ base.Update();
+
+ if (pendingFrames.Count > 0 && Time.Current - lastSendTime > TIME_BETWEEN_SENDS)
+ purgePendingFrames();
+ }
+
+ public void HandleFrame(ReplayFrame frame)
+ {
+ if (frame is IConvertibleReplayFrame convertible)
+ pendingFrames.Enqueue(convertible.ToLegacy(currentBeatmap));
+
+ if (pendingFrames.Count > max_pending_frames)
+ purgePendingFrames();
+ }
+
+ private void purgePendingFrames()
+ {
+ if (lastSend?.IsCompleted == false)
+ return;
+
+ var frames = pendingFrames.ToArray();
+
+ pendingFrames.Clear();
+
+ SendFrames(new FrameDataBundle(frames));
+
+ lastSendTime = Time.Current;
+ }
+ }
+}
diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs
index 2d609668af..7364cf04b0 100644
--- a/osu.Game/OsuGameBase.cs
+++ b/osu.Game/OsuGameBase.cs
@@ -30,6 +30,7 @@ using osu.Game.Database;
using osu.Game.Input;
using osu.Game.Input.Bindings;
using osu.Game.IO;
+using osu.Game.Online.Spectator;
using osu.Game.Overlays;
using osu.Game.Resources;
using osu.Game.Rulesets;
@@ -74,6 +75,8 @@ namespace osu.Game
protected IAPIProvider API;
+ private SpectatorStreamingClient spectatorStreaming;
+
protected MenuCursorContainer MenuCursorContainer;
protected MusicController MusicController;
@@ -189,9 +192,9 @@ namespace osu.Game
dependencies.Cache(SkinManager = new SkinManager(Storage, contextFactory, Host, Audio, new NamespacedResourceStore(Resources, "Skins/Legacy")));
dependencies.CacheAs(SkinManager);
- API ??= new APIAccess(LocalConfig);
+ dependencies.CacheAs(API ??= new APIAccess(LocalConfig));
- dependencies.CacheAs(API);
+ dependencies.CacheAs(spectatorStreaming = new SpectatorStreamingClient());
var defaultBeatmap = new DummyWorkingBeatmap(Audio, Textures);
@@ -247,8 +250,11 @@ namespace osu.Game
FileStore.Cleanup();
+ // add api components to hierarchy.
if (API is APIAccess apiAccess)
AddInternal(apiAccess);
+ AddInternal(spectatorStreaming);
+
AddInternal(RulesetConfigCache);
MenuCursorContainer = new MenuCursorContainer { RelativeSizeAxes = Axes.Both };
diff --git a/osu.Game/Overlays/BeatmapListing/BeatmapListingFilterControl.cs b/osu.Game/Overlays/BeatmapListing/BeatmapListingFilterControl.cs
index 494a0df8f8..3be38e3c1d 100644
--- a/osu.Game/Overlays/BeatmapListing/BeatmapListingFilterControl.cs
+++ b/osu.Game/Overlays/BeatmapListing/BeatmapListingFilterControl.cs
@@ -130,6 +130,9 @@ namespace osu.Game.Overlays.BeatmapListing
searchControl.Category.BindValueChanged(_ => queueUpdateSearch());
searchControl.Genre.BindValueChanged(_ => queueUpdateSearch());
searchControl.Language.BindValueChanged(_ => queueUpdateSearch());
+ searchControl.Extra.CollectionChanged += (_, __) => queueUpdateSearch();
+ searchControl.Ranks.CollectionChanged += (_, __) => queueUpdateSearch();
+ searchControl.Played.BindValueChanged(_ => queueUpdateSearch());
sortCriteria.BindValueChanged(_ => queueUpdateSearch());
sortDirection.BindValueChanged(_ => queueUpdateSearch());
@@ -179,7 +182,10 @@ namespace osu.Game.Overlays.BeatmapListing
sortControl.Current.Value,
sortControl.SortDirection.Value,
searchControl.Genre.Value,
- searchControl.Language.Value);
+ searchControl.Language.Value,
+ searchControl.Extra,
+ searchControl.Ranks,
+ searchControl.Played.Value);
getSetsRequest.Success += response =>
{
diff --git a/osu.Game/Overlays/BeatmapListing/BeatmapListingSearchControl.cs b/osu.Game/Overlays/BeatmapListing/BeatmapListingSearchControl.cs
index 29c4fe0d2e..3694c9855e 100644
--- a/osu.Game/Overlays/BeatmapListing/BeatmapListingSearchControl.cs
+++ b/osu.Game/Overlays/BeatmapListing/BeatmapListingSearchControl.cs
@@ -13,6 +13,7 @@ using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface;
using osuTK.Graphics;
using osu.Game.Rulesets;
+using osu.Game.Scoring;
namespace osu.Game.Overlays.BeatmapListing
{
@@ -28,6 +29,12 @@ namespace osu.Game.Overlays.BeatmapListing
public Bindable Language => languageFilter.Current;
+ public BindableList Extra => extraFilter.Current;
+
+ public BindableList Ranks => ranksFilter.Current;
+
+ public Bindable Played => playedFilter.Current;
+
public BeatmapSetInfo BeatmapSet
{
set
@@ -48,6 +55,9 @@ namespace osu.Game.Overlays.BeatmapListing
private readonly BeatmapSearchFilterRow categoryFilter;
private readonly BeatmapSearchFilterRow genreFilter;
private readonly BeatmapSearchFilterRow languageFilter;
+ private readonly BeatmapSearchMultipleSelectionFilterRow extraFilter;
+ private readonly BeatmapSearchScoreFilterRow ranksFilter;
+ private readonly BeatmapSearchFilterRow playedFilter;
private readonly Box background;
private readonly UpdateableBeatmapSetCover beatmapCover;
@@ -105,6 +115,9 @@ namespace osu.Game.Overlays.BeatmapListing
categoryFilter = new BeatmapSearchFilterRow(@"Categories"),
genreFilter = new BeatmapSearchFilterRow(@"Genre"),
languageFilter = new BeatmapSearchFilterRow(@"Language"),
+ extraFilter = new BeatmapSearchMultipleSelectionFilterRow(@"Extra"),
+ ranksFilter = new BeatmapSearchScoreFilterRow(),
+ playedFilter = new BeatmapSearchFilterRow(@"Played")
}
}
}
diff --git a/osu.Game/Overlays/BeatmapListing/BeatmapSearchFilterRow.cs b/osu.Game/Overlays/BeatmapListing/BeatmapSearchFilterRow.cs
index 45ef793deb..b429a5277b 100644
--- a/osu.Game/Overlays/BeatmapListing/BeatmapSearchFilterRow.cs
+++ b/osu.Game/Overlays/BeatmapListing/BeatmapSearchFilterRow.cs
@@ -1,20 +1,16 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-using System;
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
-using osu.Framework.Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.UserInterface;
-using osu.Framework.Input.Events;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osuTK;
-using osuTK.Graphics;
using Humanizer;
using osu.Game.Utils;
@@ -32,6 +28,7 @@ namespace osu.Game.Overlays.BeatmapListing
public BeatmapSearchFilterRow(string headerName)
{
+ Drawable filter;
AutoSizeAxes = Axes.Y;
RelativeSizeAxes = Axes.X;
AddInternal(new GridContainer
@@ -49,7 +46,7 @@ namespace osu.Game.Overlays.BeatmapListing
},
Content = new[]
{
- new Drawable[]
+ new[]
{
new OsuSpriteText
{
@@ -58,17 +55,17 @@ namespace osu.Game.Overlays.BeatmapListing
Font = OsuFont.GetFont(size: 13),
Text = headerName.Titleize()
},
- CreateFilter().With(f =>
- {
- f.Current = current;
- })
+ filter = CreateFilter()
}
}
});
+
+ if (filter is IHasCurrentValue filterWithValue)
+ Current = filterWithValue.Current;
}
[NotNull]
- protected virtual BeatmapSearchFilter CreateFilter() => new BeatmapSearchFilter();
+ protected virtual Drawable CreateFilter() => new BeatmapSearchFilter();
protected class BeatmapSearchFilter : TabControl
{
@@ -97,63 +94,7 @@ namespace osu.Game.Overlays.BeatmapListing
protected override Dropdown CreateDropdown() => new FilterDropdown();
- protected override TabItem CreateTabItem(T value) => new FilterTabItem(value);
-
- protected class FilterTabItem : TabItem
- {
- protected virtual float TextSize => 13;
-
- [Resolved]
- private OverlayColourProvider colourProvider { get; set; }
-
- private readonly OsuSpriteText text;
-
- public FilterTabItem(T value)
- : base(value)
- {
- AutoSizeAxes = Axes.Both;
- Anchor = Anchor.BottomLeft;
- Origin = Anchor.BottomLeft;
- AddRangeInternal(new Drawable[]
- {
- text = new OsuSpriteText
- {
- Font = OsuFont.GetFont(size: TextSize, weight: FontWeight.Regular),
- Text = (value as Enum)?.GetDescription() ?? value.ToString()
- },
- new HoverClickSounds()
- });
-
- Enabled.Value = true;
- }
-
- [BackgroundDependencyLoader]
- private void load()
- {
- updateState();
- }
-
- protected override bool OnHover(HoverEvent e)
- {
- base.OnHover(e);
- updateState();
- return true;
- }
-
- protected override void OnHoverLost(HoverLostEvent e)
- {
- base.OnHoverLost(e);
- updateState();
- }
-
- protected override void OnActivated() => updateState();
-
- protected override void OnDeactivated() => updateState();
-
- private void updateState() => text.FadeColour(Active.Value ? Color4.White : getStateColour(), 200, Easing.OutQuint);
-
- private Color4 getStateColour() => IsHovered ? colourProvider.Light1 : colourProvider.Light3;
- }
+ protected override TabItem CreateTabItem(T value) => new FilterTabItem(value);
private class FilterDropdown : OsuTabDropdown
{
diff --git a/osu.Game/Overlays/BeatmapListing/BeatmapSearchMultipleSelectionFilterRow.cs b/osu.Game/Overlays/BeatmapListing/BeatmapSearchMultipleSelectionFilterRow.cs
new file mode 100644
index 0000000000..5dfa8e6109
--- /dev/null
+++ b/osu.Game/Overlays/BeatmapListing/BeatmapSearchMultipleSelectionFilterRow.cs
@@ -0,0 +1,93 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using osu.Framework.Allocation;
+using osu.Framework.Bindables;
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.Containers;
+using osu.Framework.Input.Events;
+using osuTK;
+
+namespace osu.Game.Overlays.BeatmapListing
+{
+ public class BeatmapSearchMultipleSelectionFilterRow : BeatmapSearchFilterRow>
+ {
+ public new readonly BindableList Current = new BindableList();
+
+ private MultipleSelectionFilter filter;
+
+ public BeatmapSearchMultipleSelectionFilterRow(string headerName)
+ : base(headerName)
+ {
+ Current.BindTo(filter.Current);
+ }
+
+ protected sealed override Drawable CreateFilter() => filter = CreateMultipleSelectionFilter();
+
+ ///
+ /// Creates a filter control that can be used to simultaneously select multiple values of type .
+ ///
+ protected virtual MultipleSelectionFilter CreateMultipleSelectionFilter() => new MultipleSelectionFilter();
+
+ protected class MultipleSelectionFilter : FillFlowContainer
+ {
+ public readonly BindableList Current = new BindableList();
+
+ [BackgroundDependencyLoader]
+ private void load()
+ {
+ Anchor = Anchor.BottomLeft;
+ Origin = Anchor.BottomLeft;
+ RelativeSizeAxes = Axes.X;
+ Height = 15;
+ Spacing = new Vector2(10, 0);
+
+ AddRange(GetValues().Select(CreateTabItem));
+ }
+
+ protected override void LoadComplete()
+ {
+ base.LoadComplete();
+
+ foreach (var item in Children)
+ item.Active.BindValueChanged(active => toggleItem(item.Value, active.NewValue));
+ }
+
+ ///
+ /// Returns all values to be displayed in this filter row.
+ ///
+ protected virtual IEnumerable GetValues() => Enum.GetValues(typeof(T)).Cast();
+
+ ///
+ /// Creates a representing the supplied .
+ ///
+ protected virtual MultipleSelectionFilterTabItem CreateTabItem(T value) => new MultipleSelectionFilterTabItem(value);
+
+ private void toggleItem(T value, bool active)
+ {
+ if (active)
+ Current.Add(value);
+ else
+ Current.Remove(value);
+ }
+ }
+
+ protected class MultipleSelectionFilterTabItem : FilterTabItem
+ {
+ public MultipleSelectionFilterTabItem(T value)
+ : base(value)
+ {
+ }
+
+ protected override bool OnClick(ClickEvent e)
+ {
+ base.OnClick(e);
+ Active.Toggle();
+ return true;
+ }
+ }
+ }
+}
diff --git a/osu.Game/Overlays/BeatmapListing/BeatmapSearchRulesetFilterRow.cs b/osu.Game/Overlays/BeatmapListing/BeatmapSearchRulesetFilterRow.cs
index eebd896cf9..a8dc088e52 100644
--- a/osu.Game/Overlays/BeatmapListing/BeatmapSearchRulesetFilterRow.cs
+++ b/osu.Game/Overlays/BeatmapListing/BeatmapSearchRulesetFilterRow.cs
@@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
+using osu.Framework.Graphics;
using osu.Game.Rulesets;
namespace osu.Game.Overlays.BeatmapListing
@@ -13,7 +14,7 @@ namespace osu.Game.Overlays.BeatmapListing
{
}
- protected override BeatmapSearchFilter CreateFilter() => new RulesetFilter();
+ protected override Drawable CreateFilter() => new RulesetFilter();
private class RulesetFilter : BeatmapSearchFilter
{
diff --git a/osu.Game/Overlays/BeatmapListing/BeatmapSearchScoreFilterRow.cs b/osu.Game/Overlays/BeatmapListing/BeatmapSearchScoreFilterRow.cs
new file mode 100644
index 0000000000..804962adfb
--- /dev/null
+++ b/osu.Game/Overlays/BeatmapListing/BeatmapSearchScoreFilterRow.cs
@@ -0,0 +1,50 @@
+// Copyright (c) ppy Pty Ltd . 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.Extensions;
+using osu.Game.Scoring;
+
+namespace osu.Game.Overlays.BeatmapListing
+{
+ public class BeatmapSearchScoreFilterRow : BeatmapSearchMultipleSelectionFilterRow
+ {
+ public BeatmapSearchScoreFilterRow()
+ : base(@"Rank Achieved")
+ {
+ }
+
+ protected override MultipleSelectionFilter CreateMultipleSelectionFilter() => new RankFilter();
+
+ private class RankFilter : MultipleSelectionFilter
+ {
+ protected override MultipleSelectionFilterTabItem CreateTabItem(ScoreRank value) => new RankItem(value);
+
+ protected override IEnumerable GetValues() => base.GetValues().Reverse();
+ }
+
+ private class RankItem : MultipleSelectionFilterTabItem
+ {
+ public RankItem(ScoreRank value)
+ : base(value)
+ {
+ }
+
+ protected override string LabelFor(ScoreRank value)
+ {
+ switch (value)
+ {
+ case ScoreRank.XH:
+ return @"Silver SS";
+
+ case ScoreRank.SH:
+ return @"Silver S";
+
+ default:
+ return value.GetDescription();
+ }
+ }
+ }
+ }
+}
diff --git a/osu.Game/Overlays/BeatmapListing/FilterTabItem.cs b/osu.Game/Overlays/BeatmapListing/FilterTabItem.cs
new file mode 100644
index 0000000000..f02b515755
--- /dev/null
+++ b/osu.Game/Overlays/BeatmapListing/FilterTabItem.cs
@@ -0,0 +1,79 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System;
+using osu.Framework.Allocation;
+using osu.Framework.Extensions;
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.UserInterface;
+using osu.Framework.Input.Events;
+using osu.Game.Graphics;
+using osu.Game.Graphics.Sprites;
+using osu.Game.Graphics.UserInterface;
+using osuTK.Graphics;
+
+namespace osu.Game.Overlays.BeatmapListing
+{
+ public class FilterTabItem : TabItem
+ {
+ [Resolved]
+ private OverlayColourProvider colourProvider { get; set; }
+
+ private OsuSpriteText text;
+
+ public FilterTabItem(T value)
+ : base(value)
+ {
+ }
+
+ [BackgroundDependencyLoader]
+ private void load()
+ {
+ AutoSizeAxes = Axes.Both;
+ Anchor = Anchor.BottomLeft;
+ Origin = Anchor.BottomLeft;
+ AddRangeInternal(new Drawable[]
+ {
+ text = new OsuSpriteText
+ {
+ Font = OsuFont.GetFont(size: 13, weight: FontWeight.Regular),
+ Text = LabelFor(Value)
+ },
+ new HoverClickSounds()
+ });
+
+ Enabled.Value = true;
+ updateState();
+ }
+
+ protected override bool OnHover(HoverEvent e)
+ {
+ base.OnHover(e);
+ updateState();
+ return true;
+ }
+
+ protected override void OnHoverLost(HoverLostEvent e)
+ {
+ base.OnHoverLost(e);
+ updateState();
+ }
+
+ protected override void OnActivated() => updateState();
+
+ protected override void OnDeactivated() => updateState();
+
+ ///
+ /// Returns the label text to be used for the supplied .
+ ///
+ protected virtual string LabelFor(T value) => (value as Enum)?.GetDescription() ?? value.ToString();
+
+ private void updateState()
+ {
+ text.FadeColour(IsHovered ? colourProvider.Light1 : getStateColour(), 200, Easing.OutQuint);
+ text.Font = text.Font.With(weight: Active.Value ? FontWeight.SemiBold : FontWeight.Regular);
+ }
+
+ private Color4 getStateColour() => Active.Value ? colourProvider.Content1 : colourProvider.Light2;
+ }
+}
diff --git a/osu.Game/Overlays/BeatmapListing/SearchExtra.cs b/osu.Game/Overlays/BeatmapListing/SearchExtra.cs
new file mode 100644
index 0000000000..af37e3264f
--- /dev/null
+++ b/osu.Game/Overlays/BeatmapListing/SearchExtra.cs
@@ -0,0 +1,16 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System.ComponentModel;
+
+namespace osu.Game.Overlays.BeatmapListing
+{
+ public enum SearchExtra
+ {
+ [Description("Has Video")]
+ Video,
+
+ [Description("Has Storyboard")]
+ Storyboard
+ }
+}
diff --git a/osu.Game/Overlays/BeatmapListing/SearchPlayed.cs b/osu.Game/Overlays/BeatmapListing/SearchPlayed.cs
new file mode 100644
index 0000000000..eb7fb46158
--- /dev/null
+++ b/osu.Game/Overlays/BeatmapListing/SearchPlayed.cs
@@ -0,0 +1,12 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+namespace osu.Game.Overlays.BeatmapListing
+{
+ public enum SearchPlayed
+ {
+ Any,
+ Played,
+ Unplayed
+ }
+}
diff --git a/osu.Game/Replays/Legacy/LegacyReplayFrame.cs b/osu.Game/Replays/Legacy/LegacyReplayFrame.cs
index c3cffa8699..74bacae9e1 100644
--- a/osu.Game/Replays/Legacy/LegacyReplayFrame.cs
+++ b/osu.Game/Replays/Legacy/LegacyReplayFrame.cs
@@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
+using Newtonsoft.Json;
using osu.Game.Rulesets.Replays;
using osuTK;
@@ -8,17 +9,28 @@ namespace osu.Game.Replays.Legacy
{
public class LegacyReplayFrame : ReplayFrame
{
+ [JsonIgnore]
public Vector2 Position => new Vector2(MouseX ?? 0, MouseY ?? 0);
public float? MouseX;
public float? MouseY;
+ [JsonIgnore]
public bool MouseLeft => MouseLeft1 || MouseLeft2;
+
+ [JsonIgnore]
public bool MouseRight => MouseRight1 || MouseRight2;
+ [JsonIgnore]
public bool MouseLeft1 => ButtonState.HasFlag(ReplayButtonState.Left1);
+
+ [JsonIgnore]
public bool MouseRight1 => ButtonState.HasFlag(ReplayButtonState.Right1);
+
+ [JsonIgnore]
public bool MouseLeft2 => ButtonState.HasFlag(ReplayButtonState.Left2);
+
+ [JsonIgnore]
public bool MouseRight2 => ButtonState.HasFlag(ReplayButtonState.Right2);
public ReplayButtonState ButtonState;
diff --git a/osu.Game/Rulesets/Edit/SelectionBlueprint.cs b/osu.Game/Rulesets/Edit/SelectionBlueprint.cs
index 4abdbfc244..f3816f6218 100644
--- a/osu.Game/Rulesets/Edit/SelectionBlueprint.cs
+++ b/osu.Game/Rulesets/Edit/SelectionBlueprint.cs
@@ -120,6 +120,11 @@ namespace osu.Game.Rulesets.Edit
///
public void Deselect() => State = SelectionState.NotSelected;
+ ///
+ /// Toggles the selection state of this .
+ ///
+ public void ToggleSelection() => State = IsSelected ? SelectionState.NotSelected : SelectionState.Selected;
+
public bool IsSelected => State == SelectionState.Selected;
///
diff --git a/osu.Game/Rulesets/UI/DrawableRuleset.cs b/osu.Game/Rulesets/UI/DrawableRuleset.cs
index 50e9a93e22..f6cf836fe7 100644
--- a/osu.Game/Rulesets/UI/DrawableRuleset.cs
+++ b/osu.Game/Rulesets/UI/DrawableRuleset.cs
@@ -65,7 +65,7 @@ namespace osu.Game.Rulesets.UI
public override Container FrameStableComponents { get; } = new Container { RelativeSizeAxes = Axes.Both };
- public override GameplayClock FrameStableClock => frameStabilityContainer.GameplayClock;
+ public override IFrameStableClock FrameStableClock => frameStabilityContainer.FrameStableClock;
private bool frameStablePlayback = true;
@@ -404,7 +404,7 @@ namespace osu.Game.Rulesets.UI
///
/// The frame-stable clock which is being used for playfield display.
///
- public abstract GameplayClock FrameStableClock { get; }
+ public abstract IFrameStableClock FrameStableClock { get; }
/// ~
/// The associated ruleset.
diff --git a/osu.Game/Rulesets/UI/FrameStabilityContainer.cs b/osu.Game/Rulesets/UI/FrameStabilityContainer.cs
index e4a3a2fe3d..595574115c 100644
--- a/osu.Game/Rulesets/UI/FrameStabilityContainer.cs
+++ b/osu.Game/Rulesets/UI/FrameStabilityContainer.cs
@@ -18,11 +18,8 @@ namespace osu.Game.Rulesets.UI
/// A container which consumes a parent gameplay clock and standardises frame counts for children.
/// Will ensure a minimum of 50 frames per clock second is maintained, regardless of any system lag or seeks.
///
- [Cached(typeof(ISamplePlaybackDisabler))]
- public class FrameStabilityContainer : Container, IHasReplayHandler, ISamplePlaybackDisabler
+ public class FrameStabilityContainer : Container, IHasReplayHandler
{
- private readonly Bindable samplePlaybackDisabled = new Bindable();
-
private readonly double gameplayStartTime;
///
@@ -35,16 +32,16 @@ namespace osu.Game.Rulesets.UI
///
internal bool FrameStablePlayback = true;
- public GameplayClock GameplayClock => stabilityGameplayClock;
+ public IFrameStableClock FrameStableClock => frameStableClock;
[Cached(typeof(GameplayClock))]
- private readonly StabilityGameplayClock stabilityGameplayClock;
+ private readonly FrameStabilityClock frameStableClock;
public FrameStabilityContainer(double gameplayStartTime = double.MinValue)
{
RelativeSizeAxes = Axes.Both;
- stabilityGameplayClock = new StabilityGameplayClock(framedClock = new FramedClock(manualClock = new ManualClock()));
+ frameStableClock = new FrameStabilityClock(framedClock = new FramedClock(manualClock = new ManualClock()));
this.gameplayStartTime = gameplayStartTime;
}
@@ -65,12 +62,9 @@ namespace osu.Game.Rulesets.UI
{
if (clock != null)
{
- parentGameplayClock = stabilityGameplayClock.ParentGameplayClock = clock;
- GameplayClock.IsPaused.BindTo(clock.IsPaused);
+ parentGameplayClock = frameStableClock.ParentGameplayClock = clock;
+ frameStableClock.IsPaused.BindTo(clock.IsPaused);
}
-
- // this is a bit temporary. should really be done inside of GameplayClock (but requires large structural changes).
- stabilityGameplayClock.ParentSampleDisabler = sampleDisabler;
}
protected override void LoadComplete()
@@ -79,21 +73,11 @@ namespace osu.Game.Rulesets.UI
setClock();
}
- ///
- /// Whether we are running up-to-date with our parent clock.
- /// If not, we will need to keep processing children until we catch up.
- ///
- private bool requireMoreUpdateLoops;
+ private PlaybackState state;
- ///
- /// Whether we are in a valid state (ie. should we keep processing children frames).
- /// This should be set to false when the replay is, for instance, waiting for future frames to arrive.
- ///
- private bool validState;
+ protected override bool RequiresChildrenUpdate => base.RequiresChildrenUpdate && state != PlaybackState.NotValid;
- protected override bool RequiresChildrenUpdate => base.RequiresChildrenUpdate && validState;
-
- private bool isAttached => ReplayInputHandler != null;
+ private bool hasReplayAttached => ReplayInputHandler != null;
private const double sixty_frame_time = 1000.0 / 60;
@@ -101,22 +85,19 @@ namespace osu.Game.Rulesets.UI
public override bool UpdateSubTree()
{
- requireMoreUpdateLoops = true;
- validState = !GameplayClock.IsPaused.Value;
+ state = frameStableClock.IsPaused.Value ? PlaybackState.NotValid : PlaybackState.Valid;
- samplePlaybackDisabled.Value = stabilityGameplayClock.ShouldDisableSamplePlayback;
+ int loops = MaxCatchUpFrames;
- int loops = 0;
-
- while (validState && requireMoreUpdateLoops && loops++ < MaxCatchUpFrames)
+ while (state != PlaybackState.NotValid && loops-- > 0)
{
updateClock();
- if (validState)
- {
- base.UpdateSubTree();
- UpdateSubTreeMasking(this, ScreenSpaceDrawQuad.AABBFloat);
- }
+ if (state == PlaybackState.NotValid)
+ break;
+
+ base.UpdateSubTree();
+ UpdateSubTreeMasking(this, ScreenSpaceDrawQuad.AABBFloat);
}
return true;
@@ -127,89 +108,108 @@ namespace osu.Game.Rulesets.UI
if (parentGameplayClock == null)
setClock(); // LoadComplete may not be run yet, but we still want the clock.
- validState = true;
- requireMoreUpdateLoops = false;
+ // each update start with considering things in valid state.
+ state = PlaybackState.Valid;
- var newProposedTime = parentGameplayClock.CurrentTime;
+ // our goal is to catch up to the time provided by the parent clock.
+ var proposedTime = parentGameplayClock.CurrentTime;
- try
+ if (FrameStablePlayback)
+ // if we require frame stability, the proposed time will be adjusted to move at most one known
+ // frame interval in the current direction.
+ applyFrameStability(ref proposedTime);
+
+ if (hasReplayAttached)
{
- if (FrameStablePlayback)
+ bool valid = updateReplay(ref proposedTime);
+
+ if (!valid)
+ state = PlaybackState.NotValid;
+ }
+
+ if (proposedTime != manualClock.CurrentTime)
+ direction = proposedTime > manualClock.CurrentTime ? 1 : -1;
+
+ manualClock.CurrentTime = proposedTime;
+ manualClock.Rate = Math.Abs(parentGameplayClock.Rate) * direction;
+ manualClock.IsRunning = parentGameplayClock.IsRunning;
+
+ double timeBehind = Math.Abs(manualClock.CurrentTime - parentGameplayClock.CurrentTime);
+
+ // determine whether catch-up is required.
+ if (state == PlaybackState.Valid && timeBehind > 0)
+ state = PlaybackState.RequiresCatchUp;
+
+ frameStableClock.IsCatchingUp.Value = timeBehind > 200;
+
+ // The manual clock time has changed in the above code. The framed clock now needs to be updated
+ // to ensure that the its time is valid for our children before input is processed
+ framedClock.ProcessFrame();
+ }
+
+ ///
+ /// Attempt to advance replay playback for a given time.
+ ///
+ /// The time which is to be displayed.
+ /// Whether playback is still valid.
+ private bool updateReplay(ref double proposedTime)
+ {
+ double? newTime;
+
+ if (FrameStablePlayback)
+ {
+ // when stability is turned on, we shouldn't execute for time values the replay is unable to satisfy.
+ newTime = ReplayInputHandler.SetFrameFromTime(proposedTime);
+ }
+ else
+ {
+ // when stability is disabled, we don't really care about accuracy.
+ // looping over the replay will allow it to catch up and feed out the required values
+ // for the current time.
+ while ((newTime = ReplayInputHandler.SetFrameFromTime(proposedTime)) != proposedTime)
{
- if (firstConsumption)
+ if (newTime == null)
{
- // On the first update, frame-stability seeking would result in unexpected/unwanted behaviour.
- // Instead we perform an initial seek to the proposed time.
-
- // process frame (in addition to finally clause) to clear out ElapsedTime
- manualClock.CurrentTime = newProposedTime;
- framedClock.ProcessFrame();
-
- firstConsumption = false;
+ // special case for when the replay actually can't arrive at the required time.
+ // protects from potential endless loop.
+ break;
}
- else if (manualClock.CurrentTime < gameplayStartTime)
- manualClock.CurrentTime = newProposedTime = Math.Min(gameplayStartTime, newProposedTime);
- else if (Math.Abs(manualClock.CurrentTime - newProposedTime) > sixty_frame_time * 1.2f)
- {
- newProposedTime = newProposedTime > manualClock.CurrentTime
- ? Math.Min(newProposedTime, manualClock.CurrentTime + sixty_frame_time)
- : Math.Max(newProposedTime, manualClock.CurrentTime - sixty_frame_time);
- }
- }
-
- if (isAttached)
- {
- double? newTime;
-
- if (FrameStablePlayback)
- {
- // when stability is turned on, we shouldn't execute for time values the replay is unable to satisfy.
- if ((newTime = ReplayInputHandler.SetFrameFromTime(newProposedTime)) == null)
- {
- // setting invalid state here ensures that gameplay will not continue (ie. our child
- // hierarchy won't be updated).
- validState = false;
-
- // potentially loop to catch-up playback.
- requireMoreUpdateLoops = true;
-
- return;
- }
- }
- else
- {
- // when stability is disabled, we don't really care about accuracy.
- // looping over the replay will allow it to catch up and feed out the required values
- // for the current time.
- while ((newTime = ReplayInputHandler.SetFrameFromTime(newProposedTime)) != newProposedTime)
- {
- if (newTime == null)
- {
- // special case for when the replay actually can't arrive at the required time.
- // protects from potential endless loop.
- validState = false;
- return;
- }
- }
- }
-
- newProposedTime = newTime.Value;
}
}
- finally
+
+ if (newTime == null)
+ return false;
+
+ proposedTime = newTime.Value;
+ return true;
+ }
+
+ ///
+ /// Apply frame stability modifier to a time.
+ ///
+ /// The time which is to be displayed.
+ private void applyFrameStability(ref double proposedTime)
+ {
+ if (firstConsumption)
{
- if (newProposedTime != manualClock.CurrentTime)
- direction = newProposedTime > manualClock.CurrentTime ? 1 : -1;
+ // On the first update, frame-stability seeking would result in unexpected/unwanted behaviour.
+ // Instead we perform an initial seek to the proposed time.
- manualClock.CurrentTime = newProposedTime;
- manualClock.Rate = Math.Abs(parentGameplayClock.Rate) * direction;
- manualClock.IsRunning = parentGameplayClock.IsRunning;
-
- requireMoreUpdateLoops |= manualClock.CurrentTime != parentGameplayClock.CurrentTime;
-
- // The manual clock time has changed in the above code. The framed clock now needs to be updated
- // to ensure that the its time is valid for our children before input is processed
+ // process frame (in addition to finally clause) to clear out ElapsedTime
+ manualClock.CurrentTime = proposedTime;
framedClock.ProcessFrame();
+
+ firstConsumption = false;
+ return;
+ }
+
+ if (manualClock.CurrentTime < gameplayStartTime)
+ manualClock.CurrentTime = proposedTime = Math.Min(gameplayStartTime, proposedTime);
+ else if (Math.Abs(manualClock.CurrentTime - proposedTime) > sixty_frame_time * 1.2f)
+ {
+ proposedTime = proposedTime > manualClock.CurrentTime
+ ? Math.Min(proposedTime, manualClock.CurrentTime + sixty_frame_time)
+ : Math.Max(proposedTime, manualClock.CurrentTime - sixty_frame_time);
}
}
@@ -222,32 +222,45 @@ namespace osu.Game.Rulesets.UI
}
else
{
- Clock = GameplayClock;
+ Clock = frameStableClock;
}
}
public ReplayInputHandler ReplayInputHandler { get; set; }
- IBindable ISamplePlaybackDisabler.SamplePlaybackDisabled => samplePlaybackDisabled;
+ private enum PlaybackState
+ {
+ ///
+ /// Playback is not possible. Child hierarchy should not be processed.
+ ///
+ NotValid,
- private class StabilityGameplayClock : GameplayClock
+ ///
+ /// Playback is running behind real-time. Catch-up will be attempted by processing more than once per
+ /// game loop (limited to a sane maximum to avoid frame drops).
+ ///
+ RequiresCatchUp,
+
+ ///
+ /// In a valid state, progressing one child hierarchy loop per game loop.
+ ///
+ Valid
+ }
+
+ private class FrameStabilityClock : GameplayClock, IFrameStableClock
{
public GameplayClock ParentGameplayClock;
- public ISamplePlaybackDisabler ParentSampleDisabler;
+ public readonly Bindable IsCatchingUp = new Bindable();
public override IEnumerable> NonGameplayAdjustments => ParentGameplayClock?.NonGameplayAdjustments ?? Enumerable.Empty>();
- public StabilityGameplayClock(FramedClock underlyingClock)
+ public FrameStabilityClock(FramedClock underlyingClock)
: base(underlyingClock)
{
}
- public override bool ShouldDisableSamplePlayback =>
- // handle the case where playback is catching up to real-time.
- base.ShouldDisableSamplePlayback
- || ParentSampleDisabler?.SamplePlaybackDisabled.Value == true
- || (ParentGameplayClock != null && Math.Abs(CurrentTime - ParentGameplayClock.CurrentTime) > 200);
+ IBindable IFrameStableClock.IsCatchingUp => IsCatchingUp;
}
}
}
diff --git a/osu.Game/Rulesets/UI/HitObjectContainer.cs b/osu.Game/Rulesets/UI/HitObjectContainer.cs
index 9a0217a1eb..4cadfa9ad4 100644
--- a/osu.Game/Rulesets/UI/HitObjectContainer.cs
+++ b/osu.Game/Rulesets/UI/HitObjectContainer.cs
@@ -6,6 +6,7 @@ using System.Linq;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
+using osu.Framework.Graphics.Performance;
using osu.Game.Rulesets.Objects.Drawables;
namespace osu.Game.Rulesets.UI
diff --git a/osu.Game/Rulesets/UI/IFrameStableClock.cs b/osu.Game/Rulesets/UI/IFrameStableClock.cs
new file mode 100644
index 0000000000..d888eefdc6
--- /dev/null
+++ b/osu.Game/Rulesets/UI/IFrameStableClock.cs
@@ -0,0 +1,13 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osu.Framework.Bindables;
+using osu.Framework.Timing;
+
+namespace osu.Game.Rulesets.UI
+{
+ public interface IFrameStableClock : IFrameBasedClock
+ {
+ IBindable IsCatchingUp { get; }
+ }
+}
diff --git a/osu.Game/Rulesets/UI/ReplayRecorder.cs b/osu.Game/Rulesets/UI/ReplayRecorder.cs
index c977639584..1438ebd37a 100644
--- a/osu.Game/Rulesets/UI/ReplayRecorder.cs
+++ b/osu.Game/Rulesets/UI/ReplayRecorder.cs
@@ -4,12 +4,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Input;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
+using osu.Game.Online.Spectator;
using osu.Game.Replays;
using osu.Game.Rulesets.Replays;
+using osu.Game.Screens.Play;
using osuTK;
namespace osu.Game.Rulesets.UI
@@ -25,6 +28,12 @@ namespace osu.Game.Rulesets.UI
public int RecordFrameRate = 60;
+ [Resolved(canBeNull: true)]
+ private SpectatorStreamingClient spectatorStreaming { get; set; }
+
+ [Resolved]
+ private GameplayBeatmap gameplayBeatmap { get; set; }
+
protected ReplayRecorder(Replay target)
{
this.target = target;
@@ -39,6 +48,14 @@ namespace osu.Game.Rulesets.UI
base.LoadComplete();
inputManager = GetContainingInputManager();
+
+ spectatorStreaming?.BeginPlaying(gameplayBeatmap);
+ }
+
+ protected override void Dispose(bool isDisposing)
+ {
+ base.Dispose(isDisposing);
+ spectatorStreaming?.EndPlaying();
}
protected override bool OnMouseMove(MouseMoveEvent e)
@@ -72,7 +89,11 @@ namespace osu.Game.Rulesets.UI
var frame = HandleFrame(position, pressedActions, last);
if (frame != null)
+ {
target.Frames.Add(frame);
+
+ spectatorStreaming?.HandleFrame(frame);
+ }
}
protected abstract ReplayFrame HandleFrame(Vector2 mousePosition, List actions, ReplayFrame previousFrame);
diff --git a/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs b/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs
index 7751df29cf..5ac360d029 100644
--- a/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs
+++ b/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs
@@ -298,13 +298,6 @@ namespace osu.Game.Screens.Edit.Compose.Components
{
Debug.Assert(!clickSelectionBegan);
- // Deselections are only allowed for control + left clicks
- bool allowDeselection = e.ControlPressed && e.Button == MouseButton.Left;
-
- // Todo: This is probably incorrectly disallowing multiple selections on stacked objects
- if (!allowDeselection && SelectionHandler.SelectedBlueprints.Any(s => s.IsHovered))
- return;
-
foreach (SelectionBlueprint blueprint in SelectionBlueprints.AliveChildren)
{
if (blueprint.IsHovered)
diff --git a/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs b/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs
index 4caceedc5a..01e23bafc5 100644
--- a/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs
+++ b/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs
@@ -24,6 +24,7 @@ using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Objects.Types;
using osuTK;
+using osuTK.Input;
namespace osu.Game.Screens.Edit.Compose.Components
{
@@ -224,21 +225,21 @@ namespace osu.Game.Screens.Edit.Compose.Components
/// The input state at the point of selection.
internal void HandleSelectionRequested(SelectionBlueprint blueprint, InputState state)
{
- if (state.Keyboard.ControlPressed)
- {
- if (blueprint.IsSelected)
- blueprint.Deselect();
- else
- blueprint.Select();
- }
+ if (state.Keyboard.ShiftPressed && state.Mouse.IsPressed(MouseButton.Right))
+ EditorBeatmap.Remove(blueprint.HitObject);
+ else if (state.Keyboard.ControlPressed && state.Mouse.IsPressed(MouseButton.Left))
+ blueprint.ToggleSelection();
else
- {
- if (blueprint.IsSelected)
- return;
+ ensureSelected(blueprint);
+ }
- DeselectAll?.Invoke();
- blueprint.Select();
- }
+ private void ensureSelected(SelectionBlueprint blueprint)
+ {
+ if (blueprint.IsSelected)
+ return;
+
+ DeselectAll?.Invoke();
+ blueprint.Select();
}
private void deleteSelected()
diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs
index c3560dff38..f95c7fe7a6 100644
--- a/osu.Game/Screens/Edit/Editor.cs
+++ b/osu.Game/Screens/Edit/Editor.cs
@@ -43,8 +43,9 @@ using osuTK.Input;
namespace osu.Game.Screens.Edit
{
[Cached(typeof(IBeatSnapProvider))]
+ [Cached(typeof(ISamplePlaybackDisabler))]
[Cached]
- public class Editor : ScreenWithBeatmapBackground, IKeyBindingHandler, IKeyBindingHandler, IBeatSnapProvider
+ public class Editor : ScreenWithBeatmapBackground, IKeyBindingHandler, IKeyBindingHandler, IBeatSnapProvider, ISamplePlaybackDisabler
{
public override float BackgroundParallaxAmount => 0.1f;
@@ -64,6 +65,10 @@ namespace osu.Game.Screens.Edit
[Resolved(canBeNull: true)]
private DialogOverlay dialogOverlay { get; set; }
+ public IBindable SamplePlaybackDisabled => samplePlaybackDisabled;
+
+ private readonly Bindable samplePlaybackDisabled = new Bindable();
+
private bool exitConfirmed;
private string lastSavedHash;
@@ -109,9 +114,10 @@ namespace osu.Game.Screens.Edit
UpdateClockSource();
dependencies.CacheAs(clock);
- dependencies.CacheAs(clock);
AddInternal(clock);
+ clock.SeekingOrStopped.BindValueChanged(_ => updateSampleDisabledState());
+
// todo: remove caching of this and consume via editorBeatmap?
dependencies.Cache(beatDivisor);
@@ -444,12 +450,21 @@ namespace osu.Game.Screens.Edit
if (dialogOverlay == null || dialogOverlay.CurrentDialog is PromptForSaveDialog)
{
confirmExit();
- return true;
+ return false;
}
if (isNewBeatmap || HasUnsavedChanges)
{
- dialogOverlay?.Push(new PromptForSaveDialog(confirmExit, confirmExitWithSave));
+ dialogOverlay?.Push(new PromptForSaveDialog(() =>
+ {
+ confirmExit();
+ this.Exit();
+ }, () =>
+ {
+ confirmExitWithSave();
+ this.Exit();
+ }));
+
return true;
}
}
@@ -464,7 +479,6 @@ namespace osu.Game.Screens.Edit
{
exitConfirmed = true;
Save();
- this.Exit();
}
private void confirmExit()
@@ -483,7 +497,6 @@ namespace osu.Game.Screens.Edit
}
exitConfirmed = true;
- this.Exit();
}
private readonly Bindable clipboard = new Bindable();
@@ -557,40 +570,52 @@ namespace osu.Game.Screens.Edit
.ScaleTo(0.98f, 200, Easing.OutQuint)
.FadeOut(200, Easing.OutQuint);
- if ((currentScreen = screenContainer.SingleOrDefault(s => s.Type == e.NewValue)) != null)
+ try
{
- screenContainer.ChangeChildDepth(currentScreen, lastScreen?.Depth + 1 ?? 0);
+ if ((currentScreen = screenContainer.SingleOrDefault(s => s.Type == e.NewValue)) != null)
+ {
+ screenContainer.ChangeChildDepth(currentScreen, lastScreen?.Depth + 1 ?? 0);
- currentScreen
- .ScaleTo(1, 200, Easing.OutQuint)
- .FadeIn(200, Easing.OutQuint);
- return;
+ currentScreen
+ .ScaleTo(1, 200, Easing.OutQuint)
+ .FadeIn(200, Easing.OutQuint);
+ return;
+ }
+
+ switch (e.NewValue)
+ {
+ case EditorScreenMode.SongSetup:
+ currentScreen = new SetupScreen();
+ break;
+
+ case EditorScreenMode.Compose:
+ currentScreen = new ComposeScreen();
+ break;
+
+ case EditorScreenMode.Design:
+ currentScreen = new DesignScreen();
+ break;
+
+ case EditorScreenMode.Timing:
+ currentScreen = new TimingScreen();
+ break;
+ }
+
+ LoadComponentAsync(currentScreen, newScreen =>
+ {
+ if (newScreen == currentScreen)
+ screenContainer.Add(newScreen);
+ });
}
-
- switch (e.NewValue)
+ finally
{
- case EditorScreenMode.SongSetup:
- currentScreen = new SetupScreen();
- break;
-
- case EditorScreenMode.Compose:
- currentScreen = new ComposeScreen();
- break;
-
- case EditorScreenMode.Design:
- currentScreen = new DesignScreen();
- break;
-
- case EditorScreenMode.Timing:
- currentScreen = new TimingScreen();
- break;
+ updateSampleDisabledState();
}
+ }
- LoadComponentAsync(currentScreen, newScreen =>
- {
- if (newScreen == currentScreen)
- screenContainer.Add(newScreen);
- });
+ private void updateSampleDisabledState()
+ {
+ samplePlaybackDisabled.Value = clock.SeekingOrStopped.Value || !(currentScreen is ComposeScreen);
}
private void seek(UIEvent e, int direction)
diff --git a/osu.Game/Screens/Edit/EditorClock.cs b/osu.Game/Screens/Edit/EditorClock.cs
index 64ed34f5ec..949636f695 100644
--- a/osu.Game/Screens/Edit/EditorClock.cs
+++ b/osu.Game/Screens/Edit/EditorClock.cs
@@ -11,14 +11,13 @@ using osu.Framework.Timing;
using osu.Framework.Utils;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
-using osu.Game.Screens.Play;
namespace osu.Game.Screens.Edit
{
///
/// A decoupled clock which adds editor-specific functionality, such as snapping to a user-defined beat divisor.
///
- public class EditorClock : Component, IFrameBasedClock, IAdjustableClock, ISourceChangeableClock, ISamplePlaybackDisabler
+ public class EditorClock : Component, IFrameBasedClock, IAdjustableClock, ISourceChangeableClock
{
public IBindable
/// The score to display.
- public ExpandedPanelMiddleContent(ScoreInfo score)
+ /// Whether to add flair for a new score being set.
+ public ExpandedPanelMiddleContent(ScoreInfo score, bool withFlair = false)
{
this.score = score;
+ this.withFlair = withFlair;
RelativeSizeAxes = Axes.Both;
Masking = true;
@@ -51,7 +56,7 @@ namespace osu.Game.Screens.Ranking.Expanded
}
[BackgroundDependencyLoader]
- private void load()
+ private void load(BeatmapDifficultyManager beatmapDifficultyManager)
{
var beatmap = score.Beatmap;
var metadata = beatmap.BeatmapSet?.Metadata ?? beatmap.Metadata;
@@ -138,7 +143,7 @@ namespace osu.Game.Screens.Ranking.Expanded
Spacing = new Vector2(5, 0),
Children = new Drawable[]
{
- new StarRatingDisplay(beatmap)
+ new StarRatingDisplay(beatmapDifficultyManager.GetDifficulty(beatmap, score.Ruleset, score.Mods))
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft
@@ -265,6 +270,9 @@ namespace osu.Game.Screens.Ranking.Expanded
delay += 200;
}
}
+
+ if (!withFlair)
+ FinishTransforms(true);
});
}
}
diff --git a/osu.Game/Screens/Ranking/Expanded/StarRatingDisplay.cs b/osu.Game/Screens/Ranking/Expanded/StarRatingDisplay.cs
index 4b38b298f1..ffb12d474b 100644
--- a/osu.Game/Screens/Ranking/Expanded/StarRatingDisplay.cs
+++ b/osu.Game/Screens/Ranking/Expanded/StarRatingDisplay.cs
@@ -22,29 +22,30 @@ namespace osu.Game.Screens.Ranking.Expanded
///
public class StarRatingDisplay : CompositeDrawable
{
- private readonly BeatmapInfo beatmap;
+ private readonly StarDifficulty difficulty;
///
- /// Creates a new .
+ /// Creates a new using an already computed .
///
- /// The to display the star difficulty of.
- public StarRatingDisplay(BeatmapInfo beatmap)
+ /// The already computed to display the star difficulty of.
+ public StarRatingDisplay(StarDifficulty starDifficulty)
{
- this.beatmap = beatmap;
- AutoSizeAxes = Axes.Both;
+ difficulty = starDifficulty;
}
[BackgroundDependencyLoader]
- private void load(OsuColour colours)
+ private void load(OsuColour colours, BeatmapDifficultyManager difficultyManager)
{
- var starRatingParts = beatmap.StarDifficulty.ToString("0.00", CultureInfo.InvariantCulture).Split('.');
+ AutoSizeAxes = Axes.Both;
+
+ var starRatingParts = difficulty.Stars.ToString("0.00", CultureInfo.InvariantCulture).Split('.');
string wholePart = starRatingParts[0];
string fractionPart = starRatingParts[1];
string separator = CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator;
- ColourInfo backgroundColour = beatmap.DifficultyRating == DifficultyRating.ExpertPlus
+ ColourInfo backgroundColour = difficulty.DifficultyRating == DifficultyRating.ExpertPlus
? ColourInfo.GradientVertical(Color4Extensions.FromHex("#C1C1C1"), Color4Extensions.FromHex("#595959"))
- : (ColourInfo)colours.ForDifficultyRating(beatmap.DifficultyRating);
+ : (ColourInfo)colours.ForDifficultyRating(difficulty.DifficultyRating);
InternalChildren = new Drawable[]
{
diff --git a/osu.Game/Screens/Ranking/ResultsScreen.cs b/osu.Game/Screens/Ranking/ResultsScreen.cs
index 026ce01857..f8bdf0140c 100644
--- a/osu.Game/Screens/Ranking/ResultsScreen.cs
+++ b/osu.Game/Screens/Ranking/ResultsScreen.cs
@@ -149,7 +149,7 @@ namespace osu.Game.Screens.Ranking
};
if (Score != null)
- ScorePanelList.AddScore(Score);
+ ScorePanelList.AddScore(Score, true);
if (player != null && allowRetry)
{
diff --git a/osu.Game/Screens/Ranking/ScorePanel.cs b/osu.Game/Screens/Ranking/ScorePanel.cs
index ee97ee55eb..df710e4eb8 100644
--- a/osu.Game/Screens/Ranking/ScorePanel.cs
+++ b/osu.Game/Screens/Ranking/ScorePanel.cs
@@ -85,6 +85,8 @@ namespace osu.Game.Screens.Ranking
public readonly ScoreInfo Score;
+ private bool displayWithFlair;
+
private Container content;
private Container topLayerContainer;
@@ -97,9 +99,10 @@ namespace osu.Game.Screens.Ranking
private Container middleLayerContentContainer;
private Drawable middleLayerContent;
- public ScorePanel(ScoreInfo score)
+ public ScorePanel(ScoreInfo score, bool isNewLocalScore = false)
{
Score = score;
+ displayWithFlair = isNewLocalScore;
}
[BackgroundDependencyLoader]
@@ -188,7 +191,7 @@ namespace osu.Game.Screens.Ranking
state = value;
- if (LoadState >= LoadState.Ready)
+ if (IsLoaded)
updateState();
StateChanged?.Invoke(value);
@@ -209,7 +212,10 @@ namespace osu.Game.Screens.Ranking
middleLayerBackground.FadeColour(expanded_middle_layer_colour, resize_duration, Easing.OutQuint);
topLayerContentContainer.Add(topLayerContent = new ExpandedPanelTopContent(Score.User).With(d => d.Alpha = 0));
- middleLayerContentContainer.Add(middleLayerContent = new ExpandedPanelMiddleContent(Score).With(d => d.Alpha = 0));
+ middleLayerContentContainer.Add(middleLayerContent = new ExpandedPanelMiddleContent(Score, displayWithFlair).With(d => d.Alpha = 0));
+
+ // only the first expanded display should happen with flair.
+ displayWithFlair = false;
break;
case PanelState.Contracted:
diff --git a/osu.Game/Screens/Ranking/ScorePanelList.cs b/osu.Game/Screens/Ranking/ScorePanelList.cs
index 0d7d339df0..77b3d8fc3b 100644
--- a/osu.Game/Screens/Ranking/ScorePanelList.cs
+++ b/osu.Game/Screens/Ranking/ScorePanelList.cs
@@ -95,9 +95,10 @@ namespace osu.Game.Screens.Ranking
/// Adds a to this list.
///
/// The to add.
- public ScorePanel AddScore(ScoreInfo score)
+ /// Whether this is a score that has just been achieved locally. Controls whether flair is added to the display or not.
+ public ScorePanel AddScore(ScoreInfo score, bool isNewLocalScore = false)
{
- var panel = new ScorePanel(score)
+ var panel = new ScorePanel(score, isNewLocalScore)
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
@@ -117,19 +118,24 @@ namespace osu.Game.Screens.Ranking
d.Origin = Anchor.Centre;
}));
- if (SelectedScore.Value == score)
- selectedScoreChanged(new ValueChangedEvent(SelectedScore.Value, SelectedScore.Value));
- else
+ if (IsLoaded)
{
- // We want the scroll position to remain relative to the expanded panel. When a new panel is added after the expanded panel, nothing needs to be done.
- // But when a panel is added before the expanded panel, we need to offset the scroll position by the width of the new panel.
- if (expandedPanel != null && flow.GetPanelIndex(score) < flow.GetPanelIndex(expandedPanel.Score))
+ if (SelectedScore.Value == score)
{
- // A somewhat hacky property is used here because we need to:
- // 1) Scroll after the scroll container's visible range is updated.
- // 2) Scroll before the scroll container's scroll position is updated.
- // Without this, we would have a 1-frame positioning error which looks very jarring.
- scroll.InstantScrollTarget = (scroll.InstantScrollTarget ?? scroll.Target) + ScorePanel.CONTRACTED_WIDTH + panel_spacing;
+ SelectedScore.TriggerChange();
+ }
+ else
+ {
+ // We want the scroll position to remain relative to the expanded panel. When a new panel is added after the expanded panel, nothing needs to be done.
+ // But when a panel is added before the expanded panel, we need to offset the scroll position by the width of the new panel.
+ if (expandedPanel != null && flow.GetPanelIndex(score) < flow.GetPanelIndex(expandedPanel.Score))
+ {
+ // A somewhat hacky property is used here because we need to:
+ // 1) Scroll after the scroll container's visible range is updated.
+ // 2) Scroll before the scroll container's scroll position is updated.
+ // Without this, we would have a 1-frame positioning error which looks very jarring.
+ scroll.InstantScrollTarget = (scroll.InstantScrollTarget ?? scroll.Target) + ScorePanel.CONTRACTED_WIDTH + panel_spacing;
+ }
}
}
@@ -142,11 +148,15 @@ namespace osu.Game.Screens.Ranking
/// The to present.
private void selectedScoreChanged(ValueChangedEvent score)
{
- // Contract the old panel.
- foreach (var t in flow.Where(t => t.Panel.Score == score.OldValue))
+ // avoid contracting panels unnecessarily when TriggerChange is fired manually.
+ if (score.OldValue != score.NewValue)
{
- t.Panel.State = PanelState.Contracted;
- t.Margin = new MarginPadding();
+ // Contract the old panel.
+ foreach (var t in flow.Where(t => t.Panel.Score == score.OldValue))
+ {
+ t.Panel.State = PanelState.Contracted;
+ t.Margin = new MarginPadding();
+ }
}
// Find the panel corresponding to the new score.
@@ -162,12 +172,16 @@ namespace osu.Game.Screens.Ranking
expandedTrackingComponent.Margin = new MarginPadding { Horizontal = expanded_panel_spacing };
expandedPanel.State = PanelState.Expanded;
- // Scroll to the new panel. This is done manually since we need:
- // 1) To scroll after the scroll container's visible range is updated.
- // 2) To account for the centre anchor/origins of panels.
- // In the end, it's easier to compute the scroll position manually.
- float scrollOffset = flow.GetPanelIndex(expandedPanel.Score) * (ScorePanel.CONTRACTED_WIDTH + panel_spacing);
- scroll.ScrollTo(scrollOffset);
+ // requires schedule after children to ensure the flow (and thus ScrollContainer's ScrollableExtent) has been updated.
+ ScheduleAfterChildren(() =>
+ {
+ // Scroll to the new panel. This is done manually since we need:
+ // 1) To scroll after the scroll container's visible range is updated.
+ // 2) To account for the centre anchor/origins of panels.
+ // In the end, it's easier to compute the scroll position manually.
+ float scrollOffset = flow.GetPanelIndex(expandedPanel.Score) * (ScorePanel.CONTRACTED_WIDTH + panel_spacing);
+ scroll.ScrollTo(scrollOffset);
+ });
}
protected override void Update()
diff --git a/osu.Game/Screens/Select/BeatmapInfoWedge.cs b/osu.Game/Screens/Select/BeatmapInfoWedge.cs
index 2a3eb8c67a..bdfcc2fd96 100644
--- a/osu.Game/Screens/Select/BeatmapInfoWedge.cs
+++ b/osu.Game/Screens/Select/BeatmapInfoWedge.cs
@@ -39,6 +39,11 @@ namespace osu.Game.Screens.Select
private readonly IBindable ruleset = new Bindable();
+ [Resolved]
+ private BeatmapDifficultyManager difficultyManager { get; set; }
+
+ private IBindable beatmapDifficulty;
+
protected BufferedWedgeInfo Info;
public BeatmapInfoWedge()
@@ -88,6 +93,11 @@ namespace osu.Game.Screens.Select
if (beatmap == value) return;
beatmap = value;
+
+ beatmapDifficulty?.UnbindAll();
+ beatmapDifficulty = difficultyManager.GetBindableDifficulty(beatmap.BeatmapInfo);
+ beatmapDifficulty.BindValueChanged(_ => updateDisplay());
+
updateDisplay();
}
}
@@ -113,7 +123,7 @@ namespace osu.Game.Screens.Select
return;
}
- LoadComponentAsync(loadingInfo = new BufferedWedgeInfo(beatmap, ruleset.Value)
+ LoadComponentAsync(loadingInfo = new BufferedWedgeInfo(beatmap, ruleset.Value, beatmapDifficulty.Value)
{
Shear = -Shear,
Depth = Info?.Depth + 1 ?? 0
@@ -141,12 +151,14 @@ namespace osu.Game.Screens.Select
private readonly WorkingBeatmap beatmap;
private readonly RulesetInfo ruleset;
+ private readonly StarDifficulty starDifficulty;
- public BufferedWedgeInfo(WorkingBeatmap beatmap, RulesetInfo userRuleset)
+ public BufferedWedgeInfo(WorkingBeatmap beatmap, RulesetInfo userRuleset, StarDifficulty difficulty)
: base(pixelSnapping: true)
{
this.beatmap = beatmap;
ruleset = userRuleset ?? beatmap.BeatmapInfo.Ruleset;
+ starDifficulty = difficulty;
}
[BackgroundDependencyLoader]
@@ -190,7 +202,7 @@ namespace osu.Game.Screens.Select
},
},
},
- new DifficultyColourBar(beatmapInfo)
+ new DifficultyColourBar(starDifficulty)
{
RelativeSizeAxes = Axes.Y,
Width = 20,
@@ -226,7 +238,7 @@ namespace osu.Game.Screens.Select
Shear = wedged_container_shear,
Children = new[]
{
- createStarRatingDisplay(beatmapInfo).With(display =>
+ createStarRatingDisplay(starDifficulty).With(display =>
{
display.Anchor = Anchor.TopRight;
display.Origin = Anchor.TopRight;
@@ -293,8 +305,8 @@ namespace osu.Game.Screens.Select
StatusPill.Hide();
}
- private static Drawable createStarRatingDisplay(BeatmapInfo beatmapInfo) => beatmapInfo.StarDifficulty > 0
- ? new StarRatingDisplay(beatmapInfo)
+ private static Drawable createStarRatingDisplay(StarDifficulty difficulty) => difficulty.Stars > 0
+ ? new StarRatingDisplay(difficulty)
{
Margin = new MarginPadding { Bottom = 5 }
}
@@ -447,11 +459,11 @@ namespace osu.Game.Screens.Select
private class DifficultyColourBar : Container
{
- private readonly BeatmapInfo beatmap;
+ private readonly StarDifficulty difficulty;
- public DifficultyColourBar(BeatmapInfo beatmap)
+ public DifficultyColourBar(StarDifficulty difficulty)
{
- this.beatmap = beatmap;
+ this.difficulty = difficulty;
}
[BackgroundDependencyLoader]
@@ -459,7 +471,7 @@ namespace osu.Game.Screens.Select
{
const float full_opacity_ratio = 0.7f;
- var difficultyColour = colours.ForDifficultyRating(beatmap.DifficultyRating);
+ var difficultyColour = colours.ForDifficultyRating(difficulty.DifficultyRating);
Children = new Drawable[]
{
diff --git a/osu.Game/Screens/Select/Carousel/DrawableCarouselBeatmapSet.cs b/osu.Game/Screens/Select/Carousel/DrawableCarouselBeatmapSet.cs
index 703b91c517..93f95e76cc 100644
--- a/osu.Game/Screens/Select/Carousel/DrawableCarouselBeatmapSet.cs
+++ b/osu.Game/Screens/Select/Carousel/DrawableCarouselBeatmapSet.cs
@@ -140,7 +140,7 @@ namespace osu.Game.Screens.Select.Carousel
LoadComponentAsync(beatmapContainer, loaded =>
{
// make sure the pooled target hasn't changed.
- if (carouselBeatmapSet != Item)
+ if (beatmapContainer != loaded)
return;
Content.Child = loaded;
diff --git a/osu.Game/Storyboards/Drawables/DrawableStoryboard.cs b/osu.Game/Storyboards/Drawables/DrawableStoryboard.cs
index ec461fa095..4bc28e6cef 100644
--- a/osu.Game/Storyboards/Drawables/DrawableStoryboard.cs
+++ b/osu.Game/Storyboards/Drawables/DrawableStoryboard.cs
@@ -15,6 +15,7 @@ namespace osu.Game.Storyboards.Drawables
{
public class DrawableStoryboard : Container
{
+ [Cached]
public Storyboard Storyboard { get; }
protected override Container Content { get; }
diff --git a/osu.Game/Storyboards/Drawables/DrawableStoryboardAnimation.cs b/osu.Game/Storyboards/Drawables/DrawableStoryboardAnimation.cs
index 72e52f6106..97de239e4a 100644
--- a/osu.Game/Storyboards/Drawables/DrawableStoryboardAnimation.cs
+++ b/osu.Game/Storyboards/Drawables/DrawableStoryboardAnimation.cs
@@ -2,18 +2,16 @@
// See the LICENCE file in the repository root for full licence text.
using System;
-using osuTK;
using osu.Framework.Allocation;
-using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Animations;
using osu.Framework.Graphics.Textures;
using osu.Framework.Utils;
-using osu.Game.Beatmaps;
+using osuTK;
namespace osu.Game.Storyboards.Drawables
{
- public class DrawableStoryboardAnimation : TextureAnimation, IFlippable, IVectorScalable
+ public class DrawableStoryboardAnimation : DrawableAnimation, IFlippable, IVectorScalable
{
public StoryboardAnimation Animation { get; }
@@ -115,18 +113,13 @@ namespace osu.Game.Storyboards.Drawables
}
[BackgroundDependencyLoader]
- private void load(IBindable beatmap, TextureStore textureStore)
+ private void load(TextureStore textureStore, Storyboard storyboard)
{
- for (var frame = 0; frame < Animation.FrameCount; frame++)
+ for (int frame = 0; frame < Animation.FrameCount; frame++)
{
- var framePath = Animation.Path.Replace(".", frame + ".");
+ string framePath = Animation.Path.Replace(".", frame + ".");
- var path = beatmap.Value.BeatmapSetInfo.Files.Find(f => f.Filename.Equals(framePath, StringComparison.OrdinalIgnoreCase))?.FileInfo.StoragePath;
- if (path == null)
- continue;
-
- var texture = textureStore.Get(path);
- AddFrame(texture, Animation.FrameDelay);
+ AddFrame(storyboard.CreateSpriteFromResourcePath(framePath, textureStore), Animation.FrameDelay);
}
Animation.ApplyTransforms(this);
diff --git a/osu.Game/Storyboards/Drawables/DrawableStoryboardSprite.cs b/osu.Game/Storyboards/Drawables/DrawableStoryboardSprite.cs
index d8d3248659..7b1a6d54da 100644
--- a/osu.Game/Storyboards/Drawables/DrawableStoryboardSprite.cs
+++ b/osu.Game/Storyboards/Drawables/DrawableStoryboardSprite.cs
@@ -2,18 +2,16 @@
// See the LICENCE file in the repository root for full licence text.
using System;
-using osuTK;
using osu.Framework.Allocation;
-using osu.Framework.Bindables;
using osu.Framework.Graphics;
-using osu.Framework.Graphics.Sprites;
+using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Textures;
using osu.Framework.Utils;
-using osu.Game.Beatmaps;
+using osuTK;
namespace osu.Game.Storyboards.Drawables
{
- public class DrawableStoryboardSprite : Sprite, IFlippable, IVectorScalable
+ public class DrawableStoryboardSprite : CompositeDrawable, IFlippable, IVectorScalable
{
public StoryboardSprite Sprite { get; }
@@ -111,16 +109,18 @@ namespace osu.Game.Storyboards.Drawables
LifetimeStart = sprite.StartTime;
LifetimeEnd = sprite.EndTime;
+
+ AutoSizeAxes = Axes.Both;
}
[BackgroundDependencyLoader]
- private void load(IBindable beatmap, TextureStore textureStore)
+ private void load(TextureStore textureStore, Storyboard storyboard)
{
- var path = beatmap.Value.BeatmapSetInfo?.Files?.Find(f => f.Filename.Equals(Sprite.Path, StringComparison.OrdinalIgnoreCase))?.FileInfo.StoragePath;
- if (path == null)
- return;
+ var drawable = storyboard.CreateSpriteFromResourcePath(Sprite.Path, textureStore);
+
+ if (drawable != null)
+ InternalChild = drawable;
- Texture = textureStore.Get(path);
Sprite.ApplyTransforms(this);
}
}
diff --git a/osu.Game/Storyboards/Storyboard.cs b/osu.Game/Storyboards/Storyboard.cs
index b0fb583d62..e0d18eab00 100644
--- a/osu.Game/Storyboards/Storyboard.cs
+++ b/osu.Game/Storyboards/Storyboard.cs
@@ -1,9 +1,14 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
+using System;
using System.Collections.Generic;
using System.Linq;
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.Sprites;
+using osu.Framework.Graphics.Textures;
using osu.Game.Beatmaps;
+using osu.Game.Skinning;
using osu.Game.Storyboards.Drawables;
namespace osu.Game.Storyboards
@@ -15,6 +20,11 @@ namespace osu.Game.Storyboards
public BeatmapInfo BeatmapInfo = new BeatmapInfo();
+ ///
+ /// Whether the storyboard can fall back to skin sprites in case no matching storyboard sprites are found.
+ ///
+ public bool UseSkinSprites { get; set; }
+
public bool HasDrawable => Layers.Any(l => l.Elements.Any(e => e.IsDrawable));
public double FirstEventTime => Layers.Min(l => l.Elements.FirstOrDefault()?.StartTime ?? 0);
@@ -64,5 +74,19 @@ namespace osu.Game.Storyboards
drawable.Width = drawable.Height * (BeatmapInfo.WidescreenStoryboard ? 16 / 9f : 4 / 3f);
return drawable;
}
+
+ public Drawable CreateSpriteFromResourcePath(string path, TextureStore textureStore)
+ {
+ Drawable drawable = null;
+ var storyboardPath = BeatmapInfo.BeatmapSet?.Files?.Find(f => f.Filename.Equals(path, StringComparison.OrdinalIgnoreCase))?.FileInfo.StoragePath;
+
+ if (storyboardPath != null)
+ drawable = new Sprite { Texture = textureStore.Get(storyboardPath) };
+ // if the texture isn't available locally in the beatmap, some storyboards choose to source from the underlying skin lookup hierarchy.
+ else if (UseSkinSprites)
+ drawable = new SkinnableSprite(path);
+
+ return drawable;
+ }
}
}
diff --git a/osu.Game/Tests/Beatmaps/HitObjectSampleTest.cs b/osu.Game/Tests/Beatmaps/HitObjectSampleTest.cs
index ab4fb38657..1e43e5d148 100644
--- a/osu.Game/Tests/Beatmaps/HitObjectSampleTest.cs
+++ b/osu.Game/Tests/Beatmaps/HitObjectSampleTest.cs
@@ -180,9 +180,8 @@ namespace osu.Game.Tests.Beatmaps
private readonly BeatmapInfo skinBeatmapInfo;
private readonly IResourceStore resourceStore;
- public TestWorkingBeatmap(BeatmapInfo skinBeatmapInfo, IResourceStore resourceStore, IBeatmap beatmap, Storyboard storyboard, IFrameBasedClock referenceClock, AudioManager audio,
- double length = 60000)
- : base(beatmap, storyboard, referenceClock, audio, length)
+ public TestWorkingBeatmap(BeatmapInfo skinBeatmapInfo, IResourceStore resourceStore, IBeatmap beatmap, Storyboard storyboard, IFrameBasedClock referenceClock, AudioManager audio)
+ : base(beatmap, storyboard, referenceClock, audio)
{
this.skinBeatmapInfo = skinBeatmapInfo;
this.resourceStore = resourceStore;
diff --git a/osu.Game/Tests/Visual/OsuTestScene.cs b/osu.Game/Tests/Visual/OsuTestScene.cs
index b59a1db403..e32ed07863 100644
--- a/osu.Game/Tests/Visual/OsuTestScene.cs
+++ b/osu.Game/Tests/Visual/OsuTestScene.cs
@@ -23,6 +23,7 @@ using osu.Game.Online.API;
using osu.Game.Overlays;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
+using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.UI;
using osu.Game.Screens;
using osu.Game.Storyboards;
@@ -222,18 +223,23 @@ namespace osu.Game.Tests.Visual
/// The storyboard.
/// An optional clock which should be used instead of a stopwatch for virtual time progression.
/// Audio manager. Required if a reference clock isn't provided.
- /// The length of the returned virtual track.
- public ClockBackedTestWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard, IFrameBasedClock referenceClock, AudioManager audio, double length = 60000)
+ public ClockBackedTestWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard, IFrameBasedClock referenceClock, AudioManager audio)
: base(beatmap, storyboard, audio)
{
+ double trackLength = 60000;
+
+ if (beatmap.HitObjects.Count > 0)
+ // add buffer after last hitobject to allow for final replay frames etc.
+ trackLength = Math.Max(trackLength, beatmap.HitObjects.Max(h => h.GetEndTime()) + 2000);
+
if (referenceClock != null)
{
store = new TrackVirtualStore(referenceClock);
audio.AddItem(store);
- track = store.GetVirtual(length);
+ track = store.GetVirtual(trackLength);
}
else
- track = audio?.Tracks.GetVirtual(length);
+ track = audio?.Tracks.GetVirtual(trackLength);
}
~ClockBackedTestWorkingBeatmap()
diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj
index de7bde824f..9be933c74a 100644
--- a/osu.Game/osu.Game.csproj
+++ b/osu.Game/osu.Game.csproj
@@ -21,10 +21,12 @@
+
+
-
+
diff --git a/osu.iOS.props b/osu.iOS.props
index 9c22dec330..e26f8cc8b4 100644
--- a/osu.iOS.props
+++ b/osu.iOS.props
@@ -70,7 +70,7 @@
-
+
@@ -80,7 +80,7 @@
-
+