mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 16:02:55 +08:00
Merge branch 'master' into seasonal-backgrounds
This commit is contained in:
commit
1db8dfd03e
@ -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)
|
| [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.
|
- 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.
|
If your platform is not listed above, there is still a chance you can manually build it by following the instructions below.
|
||||||
|
@ -52,6 +52,6 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.1016.0" />
|
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.1016.0" />
|
||||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2020.1019.0" />
|
<PackageReference Include="ppy.osu.Framework.Android" Version="2020.1029.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -35,6 +35,7 @@ namespace osu.Game.Rulesets.Mania.Tests
|
|||||||
|
|
||||||
objects.Add(new Note { StartTime = time });
|
objects.Add(new Note { StartTime = time });
|
||||||
|
|
||||||
|
// don't hit the first note
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
{
|
{
|
||||||
frames.Add(new ManiaReplayFrame(time + 10, ManiaAction.Key1));
|
frames.Add(new ManiaReplayFrame(time + 10, ManiaAction.Key1));
|
||||||
|
@ -11,7 +11,6 @@ using osu.Game.Rulesets.Mods;
|
|||||||
using osu.Game.Rulesets.Osu.Objects;
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
using osu.Game.Rulesets.Osu.Replays;
|
using osu.Game.Rulesets.Osu.Replays;
|
||||||
using osu.Game.Rulesets.UI;
|
using osu.Game.Rulesets.UI;
|
||||||
using osu.Game.Screens.Play;
|
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Mods
|
namespace osu.Game.Rulesets.Osu.Mods
|
||||||
{
|
{
|
||||||
@ -31,7 +30,7 @@ namespace osu.Game.Rulesets.Osu.Mods
|
|||||||
|
|
||||||
private OsuInputManager inputManager;
|
private OsuInputManager inputManager;
|
||||||
|
|
||||||
private GameplayClock gameplayClock;
|
private IFrameStableClock gameplayClock;
|
||||||
|
|
||||||
private List<OsuReplayFrame> replayFrames;
|
private List<OsuReplayFrame> replayFrames;
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ using System.Linq;
|
|||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
@ -38,20 +39,25 @@ namespace osu.Game.Rulesets.Osu.Mods
|
|||||||
|
|
||||||
protected void ApplyTraceableState(DrawableHitObject drawable, ArmedState state)
|
protected void ApplyTraceableState(DrawableHitObject drawable, ArmedState state)
|
||||||
{
|
{
|
||||||
if (!(drawable is DrawableOsuHitObject drawableOsu))
|
if (!(drawable is DrawableOsuHitObject))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var h = drawableOsu.HitObject;
|
|
||||||
|
|
||||||
//todo: expose and hide spinner background somehow
|
//todo: expose and hide spinner background somehow
|
||||||
|
|
||||||
switch (drawable)
|
switch (drawable)
|
||||||
{
|
{
|
||||||
case DrawableHitCircle circle:
|
case DrawableHitCircle circle:
|
||||||
// we only want to see the approach circle
|
// we only want to see the approach circle
|
||||||
using (circle.BeginAbsoluteSequence(h.StartTime - h.TimePreempt, true))
|
applyCirclePieceState(circle, circle.CirclePiece);
|
||||||
circle.CirclePiece.Hide();
|
break;
|
||||||
|
|
||||||
|
case DrawableSliderTail sliderTail:
|
||||||
|
applyCirclePieceState(sliderTail);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DrawableSliderRepeat sliderRepeat:
|
||||||
|
// show only the repeat arrow
|
||||||
|
applyCirclePieceState(sliderRepeat, sliderRepeat.CirclePiece);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DrawableSlider slider:
|
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)
|
private void applySliderState(DrawableSlider slider)
|
||||||
{
|
{
|
||||||
((PlaySliderBody)slider.Body.Drawable).AccentColour = slider.AccentColour.Value.Opacity(0);
|
((PlaySliderBody)slider.Body.Drawable).AccentColour = slider.AccentColour.Value.Opacity(0);
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Performance;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
using osu.Game.Rulesets.Taiko.Objects.Drawables;
|
using osu.Game.Rulesets.Taiko.Objects.Drawables;
|
||||||
using osu.Game.Rulesets.UI.Scrolling;
|
using osu.Game.Rulesets.UI.Scrolling;
|
||||||
|
@ -0,0 +1,65 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Linq;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.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<DrawableStoryboardSprite>()
|
||||||
|
.All(sprite => sprite.ChildrenOfType<SkinnableSprite>().Any() == fromSkin));
|
||||||
|
}
|
||||||
|
}
|
@ -9,7 +9,6 @@ using osu.Framework.Testing;
|
|||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Rulesets.Osu;
|
using osu.Game.Rulesets.Osu;
|
||||||
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||||
using osu.Game.Rulesets.UI;
|
|
||||||
using osu.Game.Screens.Play;
|
using osu.Game.Screens.Play;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
|
|
||||||
@ -22,11 +21,11 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
{
|
{
|
||||||
DrawableSlider slider = null;
|
DrawableSlider slider = null;
|
||||||
DrawableSample[] samples = null;
|
DrawableSample[] samples = null;
|
||||||
ISamplePlaybackDisabler gameplayClock = null;
|
ISamplePlaybackDisabler sampleDisabler = null;
|
||||||
|
|
||||||
AddStep("get variables", () =>
|
AddStep("get variables", () =>
|
||||||
{
|
{
|
||||||
gameplayClock = Player.ChildrenOfType<FrameStabilityContainer>().First();
|
sampleDisabler = Player;
|
||||||
slider = Player.ChildrenOfType<DrawableSlider>().OrderBy(s => s.HitObject.StartTime).First();
|
slider = Player.ChildrenOfType<DrawableSlider>().OrderBy(s => s.HitObject.StartTime).First();
|
||||||
samples = slider.ChildrenOfType<DrawableSample>().ToArray();
|
samples = slider.ChildrenOfType<DrawableSample>().ToArray();
|
||||||
});
|
});
|
||||||
@ -43,16 +42,16 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
return true;
|
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.
|
// 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.
|
// the important thing is that at least one started, and that sample has since stopped.
|
||||||
AddAssert("all looping samples stopped immediately", () => allStopped(allLoopingSounds));
|
AddAssert("all looping samples stopped immediately", () => allStopped(allLoopingSounds));
|
||||||
AddUntilStep("all samples stopped eventually", () => allStopped(allSounds));
|
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<PausableSkinnableSound>().Any(s => s.IsPlaying));
|
AddUntilStep("any sample is playing", () => Player.ChildrenOfType<PausableSkinnableSound>().Any(s => s.IsPlaying));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,29 +2,23 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Rulesets;
|
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Rulesets.Osu;
|
|
||||||
using osu.Game.Screens.Play;
|
using osu.Game.Screens.Play;
|
||||||
using osuTK.Input;
|
using osuTK.Input;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Gameplay
|
namespace osu.Game.Tests.Visual.Gameplay
|
||||||
{
|
{
|
||||||
public class TestSceneHUDOverlay : SkinnableTestScene
|
public class TestSceneHUDOverlay : OsuManualInputManagerTestScene
|
||||||
{
|
{
|
||||||
private HUDOverlay hudOverlay;
|
private HUDOverlay hudOverlay;
|
||||||
|
|
||||||
private IEnumerable<HUDOverlay> hudOverlays => CreatedDrawables.OfType<HUDOverlay>();
|
|
||||||
|
|
||||||
// best way to check without exposing.
|
// best way to check without exposing.
|
||||||
private Drawable hideTarget => hudOverlay.KeyCounter;
|
private Drawable hideTarget => hudOverlay.KeyCounter;
|
||||||
private FillFlowContainer<KeyCounter> keyCounterFlow => hudOverlay.KeyCounter.ChildrenOfType<FillFlowContainer<KeyCounter>>().First();
|
private FillFlowContainer<KeyCounter> keyCounterFlow => hudOverlay.KeyCounter.ChildrenOfType<FillFlowContainer<KeyCounter>>().First();
|
||||||
@ -37,17 +31,9 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
{
|
{
|
||||||
createNew();
|
createNew();
|
||||||
|
|
||||||
AddRepeatStep("increase combo", () =>
|
AddRepeatStep("increase combo", () => { hudOverlay.ComboCounter.Current.Value++; }, 10);
|
||||||
{
|
|
||||||
foreach (var hud in hudOverlays)
|
|
||||||
hud.ComboCounter.Current.Value++;
|
|
||||||
}, 10);
|
|
||||||
|
|
||||||
AddStep("reset combo", () =>
|
AddStep("reset combo", () => { hudOverlay.ComboCounter.Current.Value = 0; });
|
||||||
{
|
|
||||||
foreach (var hud in hudOverlays)
|
|
||||||
hud.ComboCounter.Current.Value = 0;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -77,7 +63,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
{
|
{
|
||||||
createNew();
|
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);
|
AddUntilStep("hidetarget is hidden", () => !hideTarget.IsPresent);
|
||||||
AddAssert("pause button is still visible", () => hudOverlay.HoldToQuit.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);
|
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<HUDVisibilityMode>(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]
|
[Test]
|
||||||
public void TestExternalHideDoesntAffectConfig()
|
public void TestExternalHideDoesntAffectConfig()
|
||||||
{
|
{
|
||||||
HUDVisibilityMode originalConfigValue = HUDVisibilityMode.HideDuringBreaks;
|
HUDVisibilityMode originalConfigValue = HUDVisibilityMode.HideDuringGameplay;
|
||||||
|
|
||||||
createNew();
|
createNew();
|
||||||
|
|
||||||
@ -113,14 +121,14 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
AddStep("set keycounter visible false", () =>
|
AddStep("set keycounter visible false", () =>
|
||||||
{
|
{
|
||||||
config.Set<bool>(OsuSetting.KeyOverlay, false);
|
config.Set<bool>(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);
|
AddUntilStep("hidetarget is hidden", () => !hideTarget.IsPresent);
|
||||||
AddAssert("key counters hidden", () => !keyCounterFlow.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);
|
AddUntilStep("hidetarget is visible", () => hideTarget.IsPresent);
|
||||||
AddAssert("key counters still hidden", () => !keyCounterFlow.IsPresent);
|
AddAssert("key counters still hidden", () => !keyCounterFlow.IsPresent);
|
||||||
|
|
||||||
@ -131,22 +139,17 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
{
|
{
|
||||||
AddStep("create overlay", () =>
|
AddStep("create overlay", () =>
|
||||||
{
|
{
|
||||||
SetContents(() =>
|
hudOverlay = new HUDOverlay(null, null, null, Array.Empty<Mod>());
|
||||||
{
|
|
||||||
hudOverlay = new HUDOverlay(null, null, null, Array.Empty<Mod>());
|
|
||||||
|
|
||||||
// Add any key just to display the key counter visually.
|
// Add any key just to display the key counter visually.
|
||||||
hudOverlay.KeyCounter.Add(new KeyCounterKeyboard(Key.Space));
|
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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -265,6 +265,26 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
AddUntilStep("wait for current", () => loader.IsCurrentScreen());
|
AddUntilStep("wait for current", () => loader.IsCurrentScreen());
|
||||||
|
|
||||||
AddAssert($"epilepsy warning {(warning ? "present" : "absent")}", () => this.ChildrenOfType<EpilepsyWarning>().Any() == warning);
|
AddAssert($"epilepsy warning {(warning ? "present" : "absent")}", () => this.ChildrenOfType<EpilepsyWarning>().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<EpilepsyWarning>().Single().Alpha > 0);
|
||||||
|
AddStep("exit early", () => loader.Exit());
|
||||||
|
|
||||||
|
AddUntilStep("sound volume restored", () => Beatmap.Value.Track.AggregateVolume.Value == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TestPlayerLoaderContainer : Container
|
private class TestPlayerLoaderContainer : Container
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
@ -12,11 +13,13 @@ using osu.Framework.Input.Events;
|
|||||||
using osu.Framework.Input.StateChanges;
|
using osu.Framework.Input.StateChanges;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Framework.Threading;
|
using osu.Framework.Threading;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Replays;
|
using osu.Game.Replays;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Rulesets.Replays;
|
using osu.Game.Rulesets.Replays;
|
||||||
using osu.Game.Rulesets.UI;
|
using osu.Game.Rulesets.UI;
|
||||||
|
using osu.Game.Screens.Play;
|
||||||
using osu.Game.Tests.Visual.UserInterface;
|
using osu.Game.Tests.Visual.UserInterface;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
@ -33,6 +36,9 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
private TestReplayRecorder recorder;
|
private TestReplayRecorder recorder;
|
||||||
|
|
||||||
|
[Cached]
|
||||||
|
private GameplayBeatmap gameplayBeatmap = new GameplayBeatmap(new Beatmap());
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void SetUp() => Schedule(() =>
|
public void SetUp() => Schedule(() =>
|
||||||
{
|
{
|
||||||
@ -166,6 +172,12 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
playbackManager?.ReplayInputHandler.SetFrameFromTime(Time.Current - 100);
|
playbackManager?.ReplayInputHandler.SetFrameFromTime(Time.Current - 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TearDownSteps]
|
||||||
|
public void TearDown()
|
||||||
|
{
|
||||||
|
AddStep("stop recorder", () => recorder.Expire());
|
||||||
|
}
|
||||||
|
|
||||||
public class TestFramedReplayInputHandler : FramedReplayInputHandler<TestReplayFrame>
|
public class TestFramedReplayInputHandler : FramedReplayInputHandler<TestReplayFrame>
|
||||||
{
|
{
|
||||||
public TestFramedReplayInputHandler(Replay replay)
|
public TestFramedReplayInputHandler(Replay replay)
|
||||||
|
@ -2,17 +2,20 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Framework.Input.StateChanges;
|
using osu.Framework.Input.StateChanges;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Replays;
|
using osu.Game.Replays;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Rulesets.Replays;
|
using osu.Game.Rulesets.Replays;
|
||||||
using osu.Game.Rulesets.UI;
|
using osu.Game.Rulesets.UI;
|
||||||
|
using osu.Game.Screens.Play;
|
||||||
using osu.Game.Tests.Visual.UserInterface;
|
using osu.Game.Tests.Visual.UserInterface;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
@ -25,6 +28,9 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
private readonly TestRulesetInputManager recordingManager;
|
private readonly TestRulesetInputManager recordingManager;
|
||||||
|
|
||||||
|
[Cached]
|
||||||
|
private GameplayBeatmap gameplayBeatmap = new GameplayBeatmap(new Beatmap());
|
||||||
|
|
||||||
public TestSceneReplayRecording()
|
public TestSceneReplayRecording()
|
||||||
{
|
{
|
||||||
Replay replay = new Replay();
|
Replay replay = new Replay();
|
||||||
|
@ -0,0 +1,99 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.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<HUDOverlay> hudOverlays => CreatedDrawables.OfType<HUDOverlay>();
|
||||||
|
|
||||||
|
// best way to check without exposing.
|
||||||
|
private Drawable hideTarget => hudOverlay.KeyCounter;
|
||||||
|
private FillFlowContainer<KeyCounter> keyCounterFlow => hudOverlay.KeyCounter.ChildrenOfType<FillFlowContainer<KeyCounter>>().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<HUDOverlay> action = null)
|
||||||
|
{
|
||||||
|
AddStep("create overlay", () =>
|
||||||
|
{
|
||||||
|
SetContents(() =>
|
||||||
|
{
|
||||||
|
hudOverlay = new HUDOverlay(null, null, null, Array.Empty<Mod>());
|
||||||
|
|
||||||
|
// 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();
|
||||||
|
}
|
||||||
|
}
|
361
osu.Game.Tests/Visual/Gameplay/TestSceneSpectatorPlayback.cs
Normal file
361
osu.Game.Tests/Visual/Gameplay/TestSceneSpectatorPlayback.cs
Normal file
@ -0,0 +1,361 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.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<int> 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<TestReplayFrame>
|
||||||
|
{
|
||||||
|
public TestFramedReplayInputHandler(Replay replay)
|
||||||
|
: base(replay)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void CollectPendingInputs(List<IInput> inputs)
|
||||||
|
{
|
||||||
|
inputs.Add(new MousePositionAbsoluteInput { Position = GamefieldToScreenSpace(CurrentFrame?.Position ?? Vector2.Zero) });
|
||||||
|
inputs.Add(new ReplayState<TestAction> { PressedActions = CurrentFrame?.Actions ?? new List<TestAction>() });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class TestInputConsumer : CompositeDrawable, IKeyBindingHandler<TestAction>
|
||||||
|
{
|
||||||
|
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<TestAction>
|
||||||
|
{
|
||||||
|
public TestRulesetInputManager(RulesetInfo ruleset, int variant, SimultaneousBindingMode unique)
|
||||||
|
: base(ruleset, variant, unique)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override KeyBindingContainer<TestAction> CreateKeyBindingContainer(RulesetInfo ruleset, int variant, SimultaneousBindingMode unique)
|
||||||
|
=> new TestKeyBindingContainer();
|
||||||
|
|
||||||
|
internal class TestKeyBindingContainer : KeyBindingContainer<TestAction>
|
||||||
|
{
|
||||||
|
public override IEnumerable<KeyBinding> DefaultKeyBindings => new[]
|
||||||
|
{
|
||||||
|
new KeyBinding(InputKey.MouseLeft, TestAction.Down),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class TestReplayFrame : ReplayFrame, IConvertibleReplayFrame
|
||||||
|
{
|
||||||
|
public Vector2 Position;
|
||||||
|
|
||||||
|
public List<TestAction> Actions = new List<TestAction>();
|
||||||
|
|
||||||
|
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<TestAction>
|
||||||
|
{
|
||||||
|
public TestReplayRecorder()
|
||||||
|
: base(new Replay())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override ReplayFrame HandleFrame(Vector2 mousePosition, List<TestAction> actions, ReplayFrame previousFrame)
|
||||||
|
{
|
||||||
|
return new TestReplayFrame(Time.Current, mousePosition, actions.ToArray());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -103,7 +103,7 @@ namespace osu.Game.Tests.Visual.Ranking
|
|||||||
|
|
||||||
private void addPanelStep(ScoreInfo score, PanelState state = PanelState.Expanded) => AddStep("add panel", () =>
|
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,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
|
@ -18,13 +18,13 @@ namespace osu.Game.Tests.Visual.Ranking
|
|||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new StarRatingDisplay(new BeatmapInfo { StarDifficulty = 1.23 }),
|
new StarRatingDisplay(new StarDifficulty(1.23, 0)),
|
||||||
new StarRatingDisplay(new BeatmapInfo { StarDifficulty = 2.34 }),
|
new StarRatingDisplay(new StarDifficulty(2.34, 0)),
|
||||||
new StarRatingDisplay(new BeatmapInfo { StarDifficulty = 3.45 }),
|
new StarRatingDisplay(new StarDifficulty(3.45, 0)),
|
||||||
new StarRatingDisplay(new BeatmapInfo { StarDifficulty = 4.56 }),
|
new StarRatingDisplay(new StarDifficulty(4.56, 0)),
|
||||||
new StarRatingDisplay(new BeatmapInfo { StarDifficulty = 5.67 }),
|
new StarRatingDisplay(new StarDifficulty(5.67, 0)),
|
||||||
new StarRatingDisplay(new BeatmapInfo { StarDifficulty = 6.78 }),
|
new StarRatingDisplay(new StarDifficulty(6.78, 0)),
|
||||||
new StarRatingDisplay(new BeatmapInfo { StarDifficulty = 10.11 }),
|
new StarRatingDisplay(new StarDifficulty(10.11, 0)),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
@ -27,6 +28,9 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
OsuSpriteText category;
|
OsuSpriteText category;
|
||||||
OsuSpriteText genre;
|
OsuSpriteText genre;
|
||||||
OsuSpriteText language;
|
OsuSpriteText language;
|
||||||
|
OsuSpriteText extra;
|
||||||
|
OsuSpriteText ranks;
|
||||||
|
OsuSpriteText played;
|
||||||
|
|
||||||
Add(control = new BeatmapListingSearchControl
|
Add(control = new BeatmapListingSearchControl
|
||||||
{
|
{
|
||||||
@ -46,6 +50,9 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
category = new OsuSpriteText(),
|
category = new OsuSpriteText(),
|
||||||
genre = new OsuSpriteText(),
|
genre = new OsuSpriteText(),
|
||||||
language = 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.Category.BindValueChanged(c => category.Text = $"Category: {c.NewValue}", true);
|
||||||
control.Genre.BindValueChanged(g => genre.Text = $"Genre: {g.NewValue}", true);
|
control.Genre.BindValueChanged(g => genre.Text = $"Genre: {g.NewValue}", true);
|
||||||
control.Language.BindValueChanged(l => language.Text = $"Language: {l.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]
|
[Test]
|
||||||
|
@ -4,19 +4,24 @@
|
|||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
using osu.Game.Tournament.Models;
|
using osu.Game.Tournament.Models;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Tournament.Components
|
namespace osu.Game.Tournament.Components
|
||||||
{
|
{
|
||||||
public class DrawableTeamFlag : Sprite
|
public class DrawableTeamFlag : Container
|
||||||
{
|
{
|
||||||
private readonly TournamentTeam team;
|
private readonly TournamentTeam team;
|
||||||
|
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
private Bindable<string> flag;
|
private Bindable<string> flag;
|
||||||
|
|
||||||
|
private Sprite flagSprite;
|
||||||
|
|
||||||
public DrawableTeamFlag(TournamentTeam team)
|
public DrawableTeamFlag(TournamentTeam team)
|
||||||
{
|
{
|
||||||
this.team = team;
|
this.team = team;
|
||||||
@ -27,7 +32,18 @@ namespace osu.Game.Tournament.Components
|
|||||||
{
|
{
|
||||||
if (team == null) return;
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,7 @@
|
|||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Sprites;
|
|
||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Tournament.Models;
|
using osu.Game.Tournament.Models;
|
||||||
@ -17,7 +15,7 @@ namespace osu.Game.Tournament.Components
|
|||||||
{
|
{
|
||||||
public readonly TournamentTeam Team;
|
public readonly TournamentTeam Team;
|
||||||
|
|
||||||
protected readonly Sprite Flag;
|
protected readonly Container Flag;
|
||||||
protected readonly TournamentSpriteText AcronymText;
|
protected readonly TournamentSpriteText AcronymText;
|
||||||
|
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
@ -27,12 +25,7 @@ namespace osu.Game.Tournament.Components
|
|||||||
{
|
{
|
||||||
Team = team;
|
Team = team;
|
||||||
|
|
||||||
Flag = new DrawableTeamFlag(team)
|
Flag = new DrawableTeamFlag(team);
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
FillMode = FillMode.Fit
|
|
||||||
};
|
|
||||||
|
|
||||||
AcronymText = new TournamentSpriteText
|
AcronymText = new TournamentSpriteText
|
||||||
{
|
{
|
||||||
Font = OsuFont.Torus.With(weight: FontWeight.Regular),
|
Font = OsuFont.Torus.With(weight: FontWeight.Regular),
|
||||||
|
@ -27,6 +27,7 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
|
|||||||
AcronymText.Origin = Anchor.TopCentre;
|
AcronymText.Origin = Anchor.TopCentre;
|
||||||
AcronymText.Text = team.Acronym.Value.ToUpperInvariant();
|
AcronymText.Text = team.Acronym.Value.ToUpperInvariant();
|
||||||
AcronymText.Font = OsuFont.Torus.With(weight: FontWeight.Bold, size: 10);
|
AcronymText.Font = OsuFont.Torus.With(weight: FontWeight.Bold, size: 10);
|
||||||
|
Flag.Scale = new Vector2(0.48f);
|
||||||
|
|
||||||
InternalChildren = new Drawable[]
|
InternalChildren = new Drawable[]
|
||||||
{
|
{
|
||||||
|
@ -29,7 +29,7 @@ namespace osu.Game.Tournament.Screens.Gameplay.Components
|
|||||||
var anchor = flip ? Anchor.TopLeft : Anchor.TopRight;
|
var anchor = flip ? Anchor.TopLeft : Anchor.TopRight;
|
||||||
|
|
||||||
Flag.RelativeSizeAxes = Axes.None;
|
Flag.RelativeSizeAxes = Axes.None;
|
||||||
Flag.Size = new Vector2(60, 40);
|
Flag.Scale = new Vector2(0.8f);
|
||||||
Flag.Origin = anchor;
|
Flag.Origin = anchor;
|
||||||
Flag.Anchor = anchor;
|
Flag.Anchor = anchor;
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
|||||||
this.losers = losers;
|
this.losers = losers;
|
||||||
Size = new Vector2(150, 40);
|
Size = new Vector2(150, 40);
|
||||||
|
|
||||||
Flag.Scale = new Vector2(0.9f);
|
Flag.Scale = new Vector2(0.54f);
|
||||||
Flag.Anchor = Flag.Origin = Anchor.CentreLeft;
|
Flag.Anchor = Flag.Origin = Anchor.CentreLeft;
|
||||||
|
|
||||||
AcronymText.Anchor = AcronymText.Origin = Anchor.CentreLeft;
|
AcronymText.Anchor = AcronymText.Origin = Anchor.CentreLeft;
|
||||||
|
@ -288,8 +288,7 @@ namespace osu.Game.Tournament.Screens.TeamIntro
|
|||||||
AutoSizeAxes = Axes.Both;
|
AutoSizeAxes = Axes.Both;
|
||||||
|
|
||||||
Flag.RelativeSizeAxes = Axes.None;
|
Flag.RelativeSizeAxes = Axes.None;
|
||||||
Flag.Size = new Vector2(300, 200);
|
Flag.Scale = new Vector2(1.2f);
|
||||||
Flag.Scale = new Vector2(0.3f);
|
|
||||||
|
|
||||||
InternalChild = new FillFlowContainer
|
InternalChild = new FillFlowContainer
|
||||||
{
|
{
|
||||||
|
@ -90,11 +90,10 @@ namespace osu.Game.Tournament.Screens.TeamWin
|
|||||||
{
|
{
|
||||||
new DrawableTeamFlag(match.Winner)
|
new DrawableTeamFlag(match.Winner)
|
||||||
{
|
{
|
||||||
Size = new Vector2(300, 200),
|
|
||||||
Scale = new Vector2(0.5f),
|
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Position = new Vector2(-300, 10),
|
Position = new Vector2(-300, 10),
|
||||||
|
Scale = new Vector2(2f)
|
||||||
},
|
},
|
||||||
new FillFlowContainer
|
new FillFlowContainer
|
||||||
{
|
{
|
||||||
|
@ -48,6 +48,10 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
|
|
||||||
switch (section)
|
switch (section)
|
||||||
{
|
{
|
||||||
|
case Section.General:
|
||||||
|
handleGeneral(storyboard, line);
|
||||||
|
return;
|
||||||
|
|
||||||
case Section.Events:
|
case Section.Events:
|
||||||
handleEvents(line);
|
handleEvents(line);
|
||||||
return;
|
return;
|
||||||
@ -60,6 +64,18 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
base.ParseLine(storyboard, section, line);
|
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)
|
private void handleEvents(string line)
|
||||||
{
|
{
|
||||||
var depth = 0;
|
var depth = 0;
|
||||||
|
@ -12,9 +12,6 @@ namespace osu.Game.Configuration
|
|||||||
[Description("Hide during gameplay")]
|
[Description("Hide during gameplay")]
|
||||||
HideDuringGameplay,
|
HideDuringGameplay,
|
||||||
|
|
||||||
[Description("Hide during breaks")]
|
|
||||||
HideDuringBreaks,
|
|
||||||
|
|
||||||
Always
|
Always
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -171,6 +171,7 @@ namespace osu.Game.Configuration
|
|||||||
public override TrackedSettings CreateTrackedSettings() => new TrackedSettings
|
public override TrackedSettings CreateTrackedSettings() => new TrackedSettings
|
||||||
{
|
{
|
||||||
new TrackedSetting<bool>(OsuSetting.MouseDisableButtons, v => new SettingDescription(!v, "gameplay mouse buttons", v ? "disabled" : "enabled")),
|
new TrackedSetting<bool>(OsuSetting.MouseDisableButtons, v => new SettingDescription(!v, "gameplay mouse buttons", v ? "disabled" : "enabled")),
|
||||||
|
new TrackedSetting<HUDVisibilityMode>(OsuSetting.HUDVisibilityMode, m => new SettingDescription(m, "HUD Visibility", m.GetDescription())),
|
||||||
new TrackedSetting<ScalingMode>(OsuSetting.Scaling, m => new SettingDescription(m, "scaling", m.GetDescription())),
|
new TrackedSetting<ScalingMode>(OsuSetting.Scaling, m => new SettingDescription(m, "scaling", m.GetDescription())),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -67,6 +67,7 @@ namespace osu.Game.Input.Bindings
|
|||||||
new KeyBinding(new[] { InputKey.Control, InputKey.Plus }, GlobalAction.IncreaseScrollSpeed),
|
new KeyBinding(new[] { InputKey.Control, InputKey.Plus }, GlobalAction.IncreaseScrollSpeed),
|
||||||
new KeyBinding(new[] { InputKey.Control, InputKey.Minus }, GlobalAction.DecreaseScrollSpeed),
|
new KeyBinding(new[] { InputKey.Control, InputKey.Minus }, GlobalAction.DecreaseScrollSpeed),
|
||||||
new KeyBinding(InputKey.MouseMiddle, GlobalAction.PauseGameplay),
|
new KeyBinding(InputKey.MouseMiddle, GlobalAction.PauseGameplay),
|
||||||
|
new KeyBinding(InputKey.Control, GlobalAction.HoldForHUD),
|
||||||
};
|
};
|
||||||
|
|
||||||
public IEnumerable<KeyBinding> AudioControlKeyBindings => new[]
|
public IEnumerable<KeyBinding> AudioControlKeyBindings => new[]
|
||||||
@ -187,5 +188,8 @@ namespace osu.Game.Input.Bindings
|
|||||||
|
|
||||||
[Description("Timing Mode")]
|
[Description("Timing Mode")]
|
||||||
EditorTimingMode,
|
EditorTimingMode,
|
||||||
|
|
||||||
|
[Description("Hold for HUD")]
|
||||||
|
HoldForHUD,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,5 +53,13 @@ namespace osu.Game.Online.API
|
|||||||
}
|
}
|
||||||
|
|
||||||
public bool Equals(IMod other) => Acronym == other?.Acronym;
|
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}";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,8 @@ namespace osu.Game.Online.API
|
|||||||
|
|
||||||
public Bindable<UserActivity> Activity { get; } = new Bindable<UserActivity>();
|
public Bindable<UserActivity> Activity { get; } = new Bindable<UserActivity>();
|
||||||
|
|
||||||
|
public string AccessToken => "token";
|
||||||
|
|
||||||
public bool IsLoggedIn => State.Value == APIState.Online;
|
public bool IsLoggedIn => State.Value == APIState.Online;
|
||||||
|
|
||||||
public string ProvidedUsername => LocalUser.Value.Username;
|
public string ProvidedUsername => LocalUser.Value.Username;
|
||||||
|
@ -21,6 +21,11 @@ namespace osu.Game.Online.API
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
Bindable<UserActivity> Activity { get; }
|
Bindable<UserActivity> Activity { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieve the OAuth access token.
|
||||||
|
/// </summary>
|
||||||
|
string AccessToken { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns whether the local user is logged in.
|
/// Returns whether the local user is logged in.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using JetBrains.Annotations;
|
||||||
using osu.Framework.IO.Network;
|
using osu.Framework.IO.Network;
|
||||||
using osu.Game.Extensions;
|
using osu.Game.Extensions;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Overlays.BeatmapListing;
|
using osu.Game.Overlays.BeatmapListing;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
|
using osu.Game.Scoring;
|
||||||
|
|
||||||
namespace osu.Game.Online.API.Requests
|
namespace osu.Game.Online.API.Requests
|
||||||
{
|
{
|
||||||
@ -21,6 +25,14 @@ namespace osu.Game.Online.API.Requests
|
|||||||
|
|
||||||
public SearchLanguage Language { get; }
|
public SearchLanguage Language { get; }
|
||||||
|
|
||||||
|
[CanBeNull]
|
||||||
|
public IReadOnlyCollection<SearchExtra> Extra { get; }
|
||||||
|
|
||||||
|
public SearchPlayed Played { get; }
|
||||||
|
|
||||||
|
[CanBeNull]
|
||||||
|
public IReadOnlyCollection<ScoreRank> Ranks { get; }
|
||||||
|
|
||||||
private readonly string query;
|
private readonly string query;
|
||||||
private readonly RulesetInfo ruleset;
|
private readonly RulesetInfo ruleset;
|
||||||
private readonly Cursor cursor;
|
private readonly Cursor cursor;
|
||||||
@ -35,7 +47,10 @@ namespace osu.Game.Online.API.Requests
|
|||||||
SortCriteria sortCriteria = SortCriteria.Ranked,
|
SortCriteria sortCriteria = SortCriteria.Ranked,
|
||||||
SortDirection sortDirection = SortDirection.Descending,
|
SortDirection sortDirection = SortDirection.Descending,
|
||||||
SearchGenre genre = SearchGenre.Any,
|
SearchGenre genre = SearchGenre.Any,
|
||||||
SearchLanguage language = SearchLanguage.Any)
|
SearchLanguage language = SearchLanguage.Any,
|
||||||
|
IReadOnlyCollection<SearchExtra> extra = null,
|
||||||
|
IReadOnlyCollection<ScoreRank> ranks = null,
|
||||||
|
SearchPlayed played = SearchPlayed.Any)
|
||||||
{
|
{
|
||||||
this.query = string.IsNullOrEmpty(query) ? string.Empty : System.Uri.EscapeDataString(query);
|
this.query = string.IsNullOrEmpty(query) ? string.Empty : System.Uri.EscapeDataString(query);
|
||||||
this.ruleset = ruleset;
|
this.ruleset = ruleset;
|
||||||
@ -46,6 +61,9 @@ namespace osu.Game.Online.API.Requests
|
|||||||
SortDirection = sortDirection;
|
SortDirection = sortDirection;
|
||||||
Genre = genre;
|
Genre = genre;
|
||||||
Language = language;
|
Language = language;
|
||||||
|
Extra = extra;
|
||||||
|
Ranks = ranks;
|
||||||
|
Played = played;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override WebRequest CreateWebRequest()
|
protected override WebRequest CreateWebRequest()
|
||||||
@ -66,6 +84,15 @@ namespace osu.Game.Online.API.Requests
|
|||||||
|
|
||||||
req.AddParameter("sort", $"{SortCriteria.ToString().ToLowerInvariant()}_{directionString}");
|
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);
|
req.AddCursor(cursor);
|
||||||
|
|
||||||
return req;
|
return req;
|
||||||
|
20
osu.Game/Online/Spectator/FrameDataBundle.cs
Normal file
20
osu.Game/Online/Spectator/FrameDataBundle.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using osu.Game.Replays.Legacy;
|
||||||
|
|
||||||
|
namespace osu.Game.Online.Spectator
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
public class FrameDataBundle
|
||||||
|
{
|
||||||
|
public IEnumerable<LegacyReplayFrame> Frames { get; set; }
|
||||||
|
|
||||||
|
public FrameDataBundle(IEnumerable<LegacyReplayFrame> frames)
|
||||||
|
{
|
||||||
|
Frames = frames;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
34
osu.Game/Online/Spectator/ISpectatorClient.cs
Normal file
34
osu.Game/Online/Spectator/ISpectatorClient.cs
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace osu.Game.Online.Spectator
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// An interface defining a spectator client instance.
|
||||||
|
/// </summary>
|
||||||
|
public interface ISpectatorClient
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Signals that a user has begun a new play session.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userId">The user.</param>
|
||||||
|
/// <param name="state">The state of gameplay.</param>
|
||||||
|
Task UserBeganPlaying(int userId, SpectatorState state);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Signals that a user has finished a play session.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userId">The user.</param>
|
||||||
|
/// <param name="state">The state of gameplay.</param>
|
||||||
|
Task UserFinishedPlaying(int userId, SpectatorState state);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Called when new frames are available for a subscribed user's play session.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userId">The user.</param>
|
||||||
|
/// <param name="data">The frame data.</param>
|
||||||
|
Task UserSentFrames(int userId, FrameDataBundle data);
|
||||||
|
}
|
||||||
|
}
|
44
osu.Game/Online/Spectator/ISpectatorServer.cs
Normal file
44
osu.Game/Online/Spectator/ISpectatorServer.cs
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace osu.Game.Online.Spectator
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// An interface defining the spectator server instance.
|
||||||
|
/// </summary>
|
||||||
|
public interface ISpectatorServer
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Signal the start of a new play session.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="state">The state of gameplay.</param>
|
||||||
|
Task BeginPlaySession(SpectatorState state);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Send a bundle of frame data for the current play session.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="data">The frame data.</param>
|
||||||
|
Task SendFrameData(FrameDataBundle data);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Signal the end of a play session.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="state">The state of gameplay.</param>
|
||||||
|
Task EndPlaySession(SpectatorState state);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userId">The user to subscribe to.</param>
|
||||||
|
Task StartWatchingUser(int userId);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Stop requesting spectating data for the specified user. Unsubscribes from receiving further data.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userId">The user to unsubscribe from.</param>
|
||||||
|
Task EndWatchingUser(int userId);
|
||||||
|
}
|
||||||
|
}
|
26
osu.Game/Online/Spectator/SpectatorState.cs
Normal file
26
osu.Game/Online/Spectator/SpectatorState.cs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
using System.Linq;
|
||||||
|
using osu.Game.Online.API;
|
||||||
|
|
||||||
|
namespace osu.Game.Online.Spectator
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
public class SpectatorState : IEquatable<SpectatorState>
|
||||||
|
{
|
||||||
|
public int? BeatmapID { get; set; }
|
||||||
|
|
||||||
|
public int? RulesetID { get; set; }
|
||||||
|
|
||||||
|
[NotNull]
|
||||||
|
public IEnumerable<APIMod> Mods { get; set; } = Enumerable.Empty<APIMod>();
|
||||||
|
|
||||||
|
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}";
|
||||||
|
}
|
||||||
|
}
|
274
osu.Game/Online/Spectator/SpectatorStreamingClient.cs
Normal file
274
osu.Game/Online/Spectator/SpectatorStreamingClient.cs
Normal file
@ -0,0 +1,274 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The maximum milliseconds between frame bundle sends.
|
||||||
|
/// </summary>
|
||||||
|
public const double TIME_BETWEEN_SENDS = 200;
|
||||||
|
|
||||||
|
private HubConnection connection;
|
||||||
|
|
||||||
|
private readonly List<int> watchingUsers = new List<int>();
|
||||||
|
|
||||||
|
public IBindableList<int> PlayingUsers => playingUsers;
|
||||||
|
|
||||||
|
private readonly BindableList<int> playingUsers = new BindableList<int>();
|
||||||
|
|
||||||
|
private readonly IBindable<APIState> apiState = new Bindable<APIState>();
|
||||||
|
|
||||||
|
private bool isConnected;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private IAPIProvider api { get; set; }
|
||||||
|
|
||||||
|
[CanBeNull]
|
||||||
|
private IBeatmap currentBeatmap;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private IBindable<RulesetInfo> currentRuleset { get; set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private IBindable<IReadOnlyList<Mod>> currentMods { get; set; }
|
||||||
|
|
||||||
|
private readonly SpectatorState currentState = new SpectatorState();
|
||||||
|
|
||||||
|
private bool isPlaying;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Called whenever new frames arrive from the server.
|
||||||
|
/// </summary>
|
||||||
|
public event Action<int, FrameDataBundle> OnNewFrames;
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
apiState.BindTo(api.State);
|
||||||
|
apiState.BindValueChanged(apiStateChanged, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void apiStateChanged(ValueChangedEvent<APIState> 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<int, SpectatorState>(nameof(ISpectatorClient.UserBeganPlaying), ((ISpectatorClient)this).UserBeganPlaying);
|
||||||
|
connection.On<int, FrameDataBundle>(nameof(ISpectatorClient.UserSentFrames), ((ISpectatorClient)this).UserSentFrames);
|
||||||
|
connection.On<int, SpectatorState>(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<LegacyReplayFrame> pendingFrames = new Queue<LegacyReplayFrame>();
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -30,6 +30,7 @@ using osu.Game.Database;
|
|||||||
using osu.Game.Input;
|
using osu.Game.Input;
|
||||||
using osu.Game.Input.Bindings;
|
using osu.Game.Input.Bindings;
|
||||||
using osu.Game.IO;
|
using osu.Game.IO;
|
||||||
|
using osu.Game.Online.Spectator;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Resources;
|
using osu.Game.Resources;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
@ -74,6 +75,8 @@ namespace osu.Game
|
|||||||
|
|
||||||
protected IAPIProvider API;
|
protected IAPIProvider API;
|
||||||
|
|
||||||
|
private SpectatorStreamingClient spectatorStreaming;
|
||||||
|
|
||||||
protected MenuCursorContainer MenuCursorContainer;
|
protected MenuCursorContainer MenuCursorContainer;
|
||||||
|
|
||||||
protected MusicController MusicController;
|
protected MusicController MusicController;
|
||||||
@ -189,9 +192,9 @@ namespace osu.Game
|
|||||||
dependencies.Cache(SkinManager = new SkinManager(Storage, contextFactory, Host, Audio, new NamespacedResourceStore<byte[]>(Resources, "Skins/Legacy")));
|
dependencies.Cache(SkinManager = new SkinManager(Storage, contextFactory, Host, Audio, new NamespacedResourceStore<byte[]>(Resources, "Skins/Legacy")));
|
||||||
dependencies.CacheAs<ISkinSource>(SkinManager);
|
dependencies.CacheAs<ISkinSource>(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);
|
var defaultBeatmap = new DummyWorkingBeatmap(Audio, Textures);
|
||||||
|
|
||||||
@ -247,8 +250,11 @@ namespace osu.Game
|
|||||||
|
|
||||||
FileStore.Cleanup();
|
FileStore.Cleanup();
|
||||||
|
|
||||||
|
// add api components to hierarchy.
|
||||||
if (API is APIAccess apiAccess)
|
if (API is APIAccess apiAccess)
|
||||||
AddInternal(apiAccess);
|
AddInternal(apiAccess);
|
||||||
|
AddInternal(spectatorStreaming);
|
||||||
|
|
||||||
AddInternal(RulesetConfigCache);
|
AddInternal(RulesetConfigCache);
|
||||||
|
|
||||||
MenuCursorContainer = new MenuCursorContainer { RelativeSizeAxes = Axes.Both };
|
MenuCursorContainer = new MenuCursorContainer { RelativeSizeAxes = Axes.Both };
|
||||||
|
@ -130,6 +130,9 @@ namespace osu.Game.Overlays.BeatmapListing
|
|||||||
searchControl.Category.BindValueChanged(_ => queueUpdateSearch());
|
searchControl.Category.BindValueChanged(_ => queueUpdateSearch());
|
||||||
searchControl.Genre.BindValueChanged(_ => queueUpdateSearch());
|
searchControl.Genre.BindValueChanged(_ => queueUpdateSearch());
|
||||||
searchControl.Language.BindValueChanged(_ => queueUpdateSearch());
|
searchControl.Language.BindValueChanged(_ => queueUpdateSearch());
|
||||||
|
searchControl.Extra.CollectionChanged += (_, __) => queueUpdateSearch();
|
||||||
|
searchControl.Ranks.CollectionChanged += (_, __) => queueUpdateSearch();
|
||||||
|
searchControl.Played.BindValueChanged(_ => queueUpdateSearch());
|
||||||
|
|
||||||
sortCriteria.BindValueChanged(_ => queueUpdateSearch());
|
sortCriteria.BindValueChanged(_ => queueUpdateSearch());
|
||||||
sortDirection.BindValueChanged(_ => queueUpdateSearch());
|
sortDirection.BindValueChanged(_ => queueUpdateSearch());
|
||||||
@ -179,7 +182,10 @@ namespace osu.Game.Overlays.BeatmapListing
|
|||||||
sortControl.Current.Value,
|
sortControl.Current.Value,
|
||||||
sortControl.SortDirection.Value,
|
sortControl.SortDirection.Value,
|
||||||
searchControl.Genre.Value,
|
searchControl.Genre.Value,
|
||||||
searchControl.Language.Value);
|
searchControl.Language.Value,
|
||||||
|
searchControl.Extra,
|
||||||
|
searchControl.Ranks,
|
||||||
|
searchControl.Played.Value);
|
||||||
|
|
||||||
getSetsRequest.Success += response =>
|
getSetsRequest.Success += response =>
|
||||||
{
|
{
|
||||||
|
@ -13,6 +13,7 @@ using osu.Game.Graphics.Containers;
|
|||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
|
using osu.Game.Scoring;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.BeatmapListing
|
namespace osu.Game.Overlays.BeatmapListing
|
||||||
{
|
{
|
||||||
@ -28,6 +29,12 @@ namespace osu.Game.Overlays.BeatmapListing
|
|||||||
|
|
||||||
public Bindable<SearchLanguage> Language => languageFilter.Current;
|
public Bindable<SearchLanguage> Language => languageFilter.Current;
|
||||||
|
|
||||||
|
public BindableList<SearchExtra> Extra => extraFilter.Current;
|
||||||
|
|
||||||
|
public BindableList<ScoreRank> Ranks => ranksFilter.Current;
|
||||||
|
|
||||||
|
public Bindable<SearchPlayed> Played => playedFilter.Current;
|
||||||
|
|
||||||
public BeatmapSetInfo BeatmapSet
|
public BeatmapSetInfo BeatmapSet
|
||||||
{
|
{
|
||||||
set
|
set
|
||||||
@ -48,6 +55,9 @@ namespace osu.Game.Overlays.BeatmapListing
|
|||||||
private readonly BeatmapSearchFilterRow<SearchCategory> categoryFilter;
|
private readonly BeatmapSearchFilterRow<SearchCategory> categoryFilter;
|
||||||
private readonly BeatmapSearchFilterRow<SearchGenre> genreFilter;
|
private readonly BeatmapSearchFilterRow<SearchGenre> genreFilter;
|
||||||
private readonly BeatmapSearchFilterRow<SearchLanguage> languageFilter;
|
private readonly BeatmapSearchFilterRow<SearchLanguage> languageFilter;
|
||||||
|
private readonly BeatmapSearchMultipleSelectionFilterRow<SearchExtra> extraFilter;
|
||||||
|
private readonly BeatmapSearchScoreFilterRow ranksFilter;
|
||||||
|
private readonly BeatmapSearchFilterRow<SearchPlayed> playedFilter;
|
||||||
|
|
||||||
private readonly Box background;
|
private readonly Box background;
|
||||||
private readonly UpdateableBeatmapSetCover beatmapCover;
|
private readonly UpdateableBeatmapSetCover beatmapCover;
|
||||||
@ -105,6 +115,9 @@ namespace osu.Game.Overlays.BeatmapListing
|
|||||||
categoryFilter = new BeatmapSearchFilterRow<SearchCategory>(@"Categories"),
|
categoryFilter = new BeatmapSearchFilterRow<SearchCategory>(@"Categories"),
|
||||||
genreFilter = new BeatmapSearchFilterRow<SearchGenre>(@"Genre"),
|
genreFilter = new BeatmapSearchFilterRow<SearchGenre>(@"Genre"),
|
||||||
languageFilter = new BeatmapSearchFilterRow<SearchLanguage>(@"Language"),
|
languageFilter = new BeatmapSearchFilterRow<SearchLanguage>(@"Language"),
|
||||||
|
extraFilter = new BeatmapSearchMultipleSelectionFilterRow<SearchExtra>(@"Extra"),
|
||||||
|
ranksFilter = new BeatmapSearchScoreFilterRow(),
|
||||||
|
playedFilter = new BeatmapSearchFilterRow<SearchPlayed>(@"Played")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,20 +1,16 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Extensions;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.UserInterface;
|
using osu.Framework.Graphics.UserInterface;
|
||||||
using osu.Framework.Input.Events;
|
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
|
||||||
using Humanizer;
|
using Humanizer;
|
||||||
using osu.Game.Utils;
|
using osu.Game.Utils;
|
||||||
|
|
||||||
@ -32,6 +28,7 @@ namespace osu.Game.Overlays.BeatmapListing
|
|||||||
|
|
||||||
public BeatmapSearchFilterRow(string headerName)
|
public BeatmapSearchFilterRow(string headerName)
|
||||||
{
|
{
|
||||||
|
Drawable filter;
|
||||||
AutoSizeAxes = Axes.Y;
|
AutoSizeAxes = Axes.Y;
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
AddInternal(new GridContainer
|
AddInternal(new GridContainer
|
||||||
@ -49,7 +46,7 @@ namespace osu.Game.Overlays.BeatmapListing
|
|||||||
},
|
},
|
||||||
Content = new[]
|
Content = new[]
|
||||||
{
|
{
|
||||||
new Drawable[]
|
new[]
|
||||||
{
|
{
|
||||||
new OsuSpriteText
|
new OsuSpriteText
|
||||||
{
|
{
|
||||||
@ -58,17 +55,17 @@ namespace osu.Game.Overlays.BeatmapListing
|
|||||||
Font = OsuFont.GetFont(size: 13),
|
Font = OsuFont.GetFont(size: 13),
|
||||||
Text = headerName.Titleize()
|
Text = headerName.Titleize()
|
||||||
},
|
},
|
||||||
CreateFilter().With(f =>
|
filter = CreateFilter()
|
||||||
{
|
|
||||||
f.Current = current;
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (filter is IHasCurrentValue<T> filterWithValue)
|
||||||
|
Current = filterWithValue.Current;
|
||||||
}
|
}
|
||||||
|
|
||||||
[NotNull]
|
[NotNull]
|
||||||
protected virtual BeatmapSearchFilter CreateFilter() => new BeatmapSearchFilter();
|
protected virtual Drawable CreateFilter() => new BeatmapSearchFilter();
|
||||||
|
|
||||||
protected class BeatmapSearchFilter : TabControl<T>
|
protected class BeatmapSearchFilter : TabControl<T>
|
||||||
{
|
{
|
||||||
@ -97,63 +94,7 @@ namespace osu.Game.Overlays.BeatmapListing
|
|||||||
|
|
||||||
protected override Dropdown<T> CreateDropdown() => new FilterDropdown();
|
protected override Dropdown<T> CreateDropdown() => new FilterDropdown();
|
||||||
|
|
||||||
protected override TabItem<T> CreateTabItem(T value) => new FilterTabItem(value);
|
protected override TabItem<T> CreateTabItem(T value) => new FilterTabItem<T>(value);
|
||||||
|
|
||||||
protected class FilterTabItem : TabItem<T>
|
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
private class FilterDropdown : OsuTabDropdown<T>
|
private class FilterDropdown : OsuTabDropdown<T>
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,93 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using 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<T> : BeatmapSearchFilterRow<List<T>>
|
||||||
|
{
|
||||||
|
public new readonly BindableList<T> Current = new BindableList<T>();
|
||||||
|
|
||||||
|
private MultipleSelectionFilter filter;
|
||||||
|
|
||||||
|
public BeatmapSearchMultipleSelectionFilterRow(string headerName)
|
||||||
|
: base(headerName)
|
||||||
|
{
|
||||||
|
Current.BindTo(filter.Current);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected sealed override Drawable CreateFilter() => filter = CreateMultipleSelectionFilter();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a filter control that can be used to simultaneously select multiple values of type <typeparamref name="T"/>.
|
||||||
|
/// </summary>
|
||||||
|
protected virtual MultipleSelectionFilter CreateMultipleSelectionFilter() => new MultipleSelectionFilter();
|
||||||
|
|
||||||
|
protected class MultipleSelectionFilter : FillFlowContainer<MultipleSelectionFilterTabItem>
|
||||||
|
{
|
||||||
|
public readonly BindableList<T> Current = new BindableList<T>();
|
||||||
|
|
||||||
|
[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));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns all values to be displayed in this filter row.
|
||||||
|
/// </summary>
|
||||||
|
protected virtual IEnumerable<T> GetValues() => Enum.GetValues(typeof(T)).Cast<T>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a <see cref="MultipleSelectionFilterTabItem"/> representing the supplied <paramref name="value"/>.
|
||||||
|
/// </summary>
|
||||||
|
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<T>
|
||||||
|
{
|
||||||
|
public MultipleSelectionFilterTabItem(T value)
|
||||||
|
: base(value)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool OnClick(ClickEvent e)
|
||||||
|
{
|
||||||
|
base.OnClick(e);
|
||||||
|
Active.Toggle();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -2,6 +2,7 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.BeatmapListing
|
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
|
private class RulesetFilter : BeatmapSearchFilter
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,50 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using osu.Framework.Extensions;
|
||||||
|
using osu.Game.Scoring;
|
||||||
|
|
||||||
|
namespace osu.Game.Overlays.BeatmapListing
|
||||||
|
{
|
||||||
|
public class BeatmapSearchScoreFilterRow : BeatmapSearchMultipleSelectionFilterRow<ScoreRank>
|
||||||
|
{
|
||||||
|
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<ScoreRank> 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
79
osu.Game/Overlays/BeatmapListing/FilterTabItem.cs
Normal file
79
osu.Game/Overlays/BeatmapListing/FilterTabItem.cs
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.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<T> : TabItem<T>
|
||||||
|
{
|
||||||
|
[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();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the label text to be used for the supplied <paramref name="value"/>.
|
||||||
|
/// </summary>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
16
osu.Game/Overlays/BeatmapListing/SearchExtra.cs
Normal file
16
osu.Game/Overlays/BeatmapListing/SearchExtra.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace osu.Game.Overlays.BeatmapListing
|
||||||
|
{
|
||||||
|
public enum SearchExtra
|
||||||
|
{
|
||||||
|
[Description("Has Video")]
|
||||||
|
Video,
|
||||||
|
|
||||||
|
[Description("Has Storyboard")]
|
||||||
|
Storyboard
|
||||||
|
}
|
||||||
|
}
|
12
osu.Game/Overlays/BeatmapListing/SearchPlayed.cs
Normal file
12
osu.Game/Overlays/BeatmapListing/SearchPlayed.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
namespace osu.Game.Overlays.BeatmapListing
|
||||||
|
{
|
||||||
|
public enum SearchPlayed
|
||||||
|
{
|
||||||
|
Any,
|
||||||
|
Played,
|
||||||
|
Unplayed
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using Newtonsoft.Json;
|
||||||
using osu.Game.Rulesets.Replays;
|
using osu.Game.Rulesets.Replays;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
@ -8,17 +9,28 @@ namespace osu.Game.Replays.Legacy
|
|||||||
{
|
{
|
||||||
public class LegacyReplayFrame : ReplayFrame
|
public class LegacyReplayFrame : ReplayFrame
|
||||||
{
|
{
|
||||||
|
[JsonIgnore]
|
||||||
public Vector2 Position => new Vector2(MouseX ?? 0, MouseY ?? 0);
|
public Vector2 Position => new Vector2(MouseX ?? 0, MouseY ?? 0);
|
||||||
|
|
||||||
public float? MouseX;
|
public float? MouseX;
|
||||||
public float? MouseY;
|
public float? MouseY;
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
public bool MouseLeft => MouseLeft1 || MouseLeft2;
|
public bool MouseLeft => MouseLeft1 || MouseLeft2;
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
public bool MouseRight => MouseRight1 || MouseRight2;
|
public bool MouseRight => MouseRight1 || MouseRight2;
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
public bool MouseLeft1 => ButtonState.HasFlag(ReplayButtonState.Left1);
|
public bool MouseLeft1 => ButtonState.HasFlag(ReplayButtonState.Left1);
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
public bool MouseRight1 => ButtonState.HasFlag(ReplayButtonState.Right1);
|
public bool MouseRight1 => ButtonState.HasFlag(ReplayButtonState.Right1);
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
public bool MouseLeft2 => ButtonState.HasFlag(ReplayButtonState.Left2);
|
public bool MouseLeft2 => ButtonState.HasFlag(ReplayButtonState.Left2);
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
public bool MouseRight2 => ButtonState.HasFlag(ReplayButtonState.Right2);
|
public bool MouseRight2 => ButtonState.HasFlag(ReplayButtonState.Right2);
|
||||||
|
|
||||||
public ReplayButtonState ButtonState;
|
public ReplayButtonState ButtonState;
|
||||||
|
@ -120,6 +120,11 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void Deselect() => State = SelectionState.NotSelected;
|
public void Deselect() => State = SelectionState.NotSelected;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Toggles the selection state of this <see cref="OverlaySelectionBlueprint"/>.
|
||||||
|
/// </summary>
|
||||||
|
public void ToggleSelection() => State = IsSelected ? SelectionState.NotSelected : SelectionState.Selected;
|
||||||
|
|
||||||
public bool IsSelected => State == SelectionState.Selected;
|
public bool IsSelected => State == SelectionState.Selected;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -65,7 +65,7 @@ namespace osu.Game.Rulesets.UI
|
|||||||
|
|
||||||
public override Container FrameStableComponents { get; } = new Container { RelativeSizeAxes = Axes.Both };
|
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;
|
private bool frameStablePlayback = true;
|
||||||
|
|
||||||
@ -404,7 +404,7 @@ namespace osu.Game.Rulesets.UI
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The frame-stable clock which is being used for playfield display.
|
/// The frame-stable clock which is being used for playfield display.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract GameplayClock FrameStableClock { get; }
|
public abstract IFrameStableClock FrameStableClock { get; }
|
||||||
|
|
||||||
/// <summary>~
|
/// <summary>~
|
||||||
/// The associated ruleset.
|
/// The associated ruleset.
|
||||||
|
@ -18,11 +18,8 @@ namespace osu.Game.Rulesets.UI
|
|||||||
/// A container which consumes a parent gameplay clock and standardises frame counts for children.
|
/// 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.
|
/// Will ensure a minimum of 50 frames per clock second is maintained, regardless of any system lag or seeks.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Cached(typeof(ISamplePlaybackDisabler))]
|
public class FrameStabilityContainer : Container, IHasReplayHandler
|
||||||
public class FrameStabilityContainer : Container, IHasReplayHandler, ISamplePlaybackDisabler
|
|
||||||
{
|
{
|
||||||
private readonly Bindable<bool> samplePlaybackDisabled = new Bindable<bool>();
|
|
||||||
|
|
||||||
private readonly double gameplayStartTime;
|
private readonly double gameplayStartTime;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -35,16 +32,16 @@ namespace osu.Game.Rulesets.UI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
internal bool FrameStablePlayback = true;
|
internal bool FrameStablePlayback = true;
|
||||||
|
|
||||||
public GameplayClock GameplayClock => stabilityGameplayClock;
|
public IFrameStableClock FrameStableClock => frameStableClock;
|
||||||
|
|
||||||
[Cached(typeof(GameplayClock))]
|
[Cached(typeof(GameplayClock))]
|
||||||
private readonly StabilityGameplayClock stabilityGameplayClock;
|
private readonly FrameStabilityClock frameStableClock;
|
||||||
|
|
||||||
public FrameStabilityContainer(double gameplayStartTime = double.MinValue)
|
public FrameStabilityContainer(double gameplayStartTime = double.MinValue)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
|
||||||
stabilityGameplayClock = new StabilityGameplayClock(framedClock = new FramedClock(manualClock = new ManualClock()));
|
frameStableClock = new FrameStabilityClock(framedClock = new FramedClock(manualClock = new ManualClock()));
|
||||||
|
|
||||||
this.gameplayStartTime = gameplayStartTime;
|
this.gameplayStartTime = gameplayStartTime;
|
||||||
}
|
}
|
||||||
@ -65,12 +62,9 @@ namespace osu.Game.Rulesets.UI
|
|||||||
{
|
{
|
||||||
if (clock != null)
|
if (clock != null)
|
||||||
{
|
{
|
||||||
parentGameplayClock = stabilityGameplayClock.ParentGameplayClock = clock;
|
parentGameplayClock = frameStableClock.ParentGameplayClock = clock;
|
||||||
GameplayClock.IsPaused.BindTo(clock.IsPaused);
|
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()
|
protected override void LoadComplete()
|
||||||
@ -79,21 +73,11 @@ namespace osu.Game.Rulesets.UI
|
|||||||
setClock();
|
setClock();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
private PlaybackState state;
|
||||||
/// Whether we are running up-to-date with our parent clock.
|
|
||||||
/// If not, we will need to keep processing children until we catch up.
|
|
||||||
/// </summary>
|
|
||||||
private bool requireMoreUpdateLoops;
|
|
||||||
|
|
||||||
/// <summary>
|
protected override bool RequiresChildrenUpdate => base.RequiresChildrenUpdate && state != PlaybackState.NotValid;
|
||||||
/// 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.
|
|
||||||
/// </summary>
|
|
||||||
private bool validState;
|
|
||||||
|
|
||||||
protected override bool RequiresChildrenUpdate => base.RequiresChildrenUpdate && validState;
|
private bool hasReplayAttached => ReplayInputHandler != null;
|
||||||
|
|
||||||
private bool isAttached => ReplayInputHandler != null;
|
|
||||||
|
|
||||||
private const double sixty_frame_time = 1000.0 / 60;
|
private const double sixty_frame_time = 1000.0 / 60;
|
||||||
|
|
||||||
@ -101,22 +85,19 @@ namespace osu.Game.Rulesets.UI
|
|||||||
|
|
||||||
public override bool UpdateSubTree()
|
public override bool UpdateSubTree()
|
||||||
{
|
{
|
||||||
requireMoreUpdateLoops = true;
|
state = frameStableClock.IsPaused.Value ? PlaybackState.NotValid : PlaybackState.Valid;
|
||||||
validState = !GameplayClock.IsPaused.Value;
|
|
||||||
|
|
||||||
samplePlaybackDisabled.Value = stabilityGameplayClock.ShouldDisableSamplePlayback;
|
int loops = MaxCatchUpFrames;
|
||||||
|
|
||||||
int loops = 0;
|
while (state != PlaybackState.NotValid && loops-- > 0)
|
||||||
|
|
||||||
while (validState && requireMoreUpdateLoops && loops++ < MaxCatchUpFrames)
|
|
||||||
{
|
{
|
||||||
updateClock();
|
updateClock();
|
||||||
|
|
||||||
if (validState)
|
if (state == PlaybackState.NotValid)
|
||||||
{
|
break;
|
||||||
base.UpdateSubTree();
|
|
||||||
UpdateSubTreeMasking(this, ScreenSpaceDrawQuad.AABBFloat);
|
base.UpdateSubTree();
|
||||||
}
|
UpdateSubTreeMasking(this, ScreenSpaceDrawQuad.AABBFloat);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -127,89 +108,108 @@ namespace osu.Game.Rulesets.UI
|
|||||||
if (parentGameplayClock == null)
|
if (parentGameplayClock == null)
|
||||||
setClock(); // LoadComplete may not be run yet, but we still want the clock.
|
setClock(); // LoadComplete may not be run yet, but we still want the clock.
|
||||||
|
|
||||||
validState = true;
|
// each update start with considering things in valid state.
|
||||||
requireMoreUpdateLoops = false;
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Attempt to advance replay playback for a given time.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="proposedTime">The time which is to be displayed.</param>
|
||||||
|
/// <returns>Whether playback is still valid.</returns>
|
||||||
|
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.
|
// special case for when the replay actually can't arrive at the required time.
|
||||||
// Instead we perform an initial seek to the proposed time.
|
// protects from potential endless loop.
|
||||||
|
break;
|
||||||
// process frame (in addition to finally clause) to clear out ElapsedTime
|
|
||||||
manualClock.CurrentTime = newProposedTime;
|
|
||||||
framedClock.ProcessFrame();
|
|
||||||
|
|
||||||
firstConsumption = false;
|
|
||||||
}
|
}
|
||||||
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Apply frame stability modifier to a time.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="proposedTime">The time which is to be displayed.</param>
|
||||||
|
private void applyFrameStability(ref double proposedTime)
|
||||||
|
{
|
||||||
|
if (firstConsumption)
|
||||||
{
|
{
|
||||||
if (newProposedTime != manualClock.CurrentTime)
|
// On the first update, frame-stability seeking would result in unexpected/unwanted behaviour.
|
||||||
direction = newProposedTime > manualClock.CurrentTime ? 1 : -1;
|
// Instead we perform an initial seek to the proposed time.
|
||||||
|
|
||||||
manualClock.CurrentTime = newProposedTime;
|
// process frame (in addition to finally clause) to clear out ElapsedTime
|
||||||
manualClock.Rate = Math.Abs(parentGameplayClock.Rate) * direction;
|
manualClock.CurrentTime = proposedTime;
|
||||||
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
|
|
||||||
framedClock.ProcessFrame();
|
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
|
else
|
||||||
{
|
{
|
||||||
Clock = GameplayClock;
|
Clock = frameStableClock;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReplayInputHandler ReplayInputHandler { get; set; }
|
public ReplayInputHandler ReplayInputHandler { get; set; }
|
||||||
|
|
||||||
IBindable<bool> ISamplePlaybackDisabler.SamplePlaybackDisabled => samplePlaybackDisabled;
|
private enum PlaybackState
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Playback is not possible. Child hierarchy should not be processed.
|
||||||
|
/// </summary>
|
||||||
|
NotValid,
|
||||||
|
|
||||||
private class StabilityGameplayClock : GameplayClock
|
/// <summary>
|
||||||
|
/// 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).
|
||||||
|
/// </summary>
|
||||||
|
RequiresCatchUp,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// In a valid state, progressing one child hierarchy loop per game loop.
|
||||||
|
/// </summary>
|
||||||
|
Valid
|
||||||
|
}
|
||||||
|
|
||||||
|
private class FrameStabilityClock : GameplayClock, IFrameStableClock
|
||||||
{
|
{
|
||||||
public GameplayClock ParentGameplayClock;
|
public GameplayClock ParentGameplayClock;
|
||||||
|
|
||||||
public ISamplePlaybackDisabler ParentSampleDisabler;
|
public readonly Bindable<bool> IsCatchingUp = new Bindable<bool>();
|
||||||
|
|
||||||
public override IEnumerable<Bindable<double>> NonGameplayAdjustments => ParentGameplayClock?.NonGameplayAdjustments ?? Enumerable.Empty<Bindable<double>>();
|
public override IEnumerable<Bindable<double>> NonGameplayAdjustments => ParentGameplayClock?.NonGameplayAdjustments ?? Enumerable.Empty<Bindable<double>>();
|
||||||
|
|
||||||
public StabilityGameplayClock(FramedClock underlyingClock)
|
public FrameStabilityClock(FramedClock underlyingClock)
|
||||||
: base(underlyingClock)
|
: base(underlyingClock)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool ShouldDisableSamplePlayback =>
|
IBindable<bool> IFrameStableClock.IsCatchingUp => IsCatchingUp;
|
||||||
// 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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ using System.Linq;
|
|||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Performance;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.UI
|
namespace osu.Game.Rulesets.UI
|
||||||
|
13
osu.Game/Rulesets/UI/IFrameStableClock.cs
Normal file
13
osu.Game/Rulesets/UI/IFrameStableClock.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Timing;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.UI
|
||||||
|
{
|
||||||
|
public interface IFrameStableClock : IFrameBasedClock
|
||||||
|
{
|
||||||
|
IBindable<bool> IsCatchingUp { get; }
|
||||||
|
}
|
||||||
|
}
|
@ -4,12 +4,15 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
|
using osu.Game.Online.Spectator;
|
||||||
using osu.Game.Replays;
|
using osu.Game.Replays;
|
||||||
using osu.Game.Rulesets.Replays;
|
using osu.Game.Rulesets.Replays;
|
||||||
|
using osu.Game.Screens.Play;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.UI
|
namespace osu.Game.Rulesets.UI
|
||||||
@ -25,6 +28,12 @@ namespace osu.Game.Rulesets.UI
|
|||||||
|
|
||||||
public int RecordFrameRate = 60;
|
public int RecordFrameRate = 60;
|
||||||
|
|
||||||
|
[Resolved(canBeNull: true)]
|
||||||
|
private SpectatorStreamingClient spectatorStreaming { get; set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private GameplayBeatmap gameplayBeatmap { get; set; }
|
||||||
|
|
||||||
protected ReplayRecorder(Replay target)
|
protected ReplayRecorder(Replay target)
|
||||||
{
|
{
|
||||||
this.target = target;
|
this.target = target;
|
||||||
@ -39,6 +48,14 @@ namespace osu.Game.Rulesets.UI
|
|||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
inputManager = GetContainingInputManager();
|
inputManager = GetContainingInputManager();
|
||||||
|
|
||||||
|
spectatorStreaming?.BeginPlaying(gameplayBeatmap);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Dispose(bool isDisposing)
|
||||||
|
{
|
||||||
|
base.Dispose(isDisposing);
|
||||||
|
spectatorStreaming?.EndPlaying();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnMouseMove(MouseMoveEvent e)
|
protected override bool OnMouseMove(MouseMoveEvent e)
|
||||||
@ -72,7 +89,11 @@ namespace osu.Game.Rulesets.UI
|
|||||||
var frame = HandleFrame(position, pressedActions, last);
|
var frame = HandleFrame(position, pressedActions, last);
|
||||||
|
|
||||||
if (frame != null)
|
if (frame != null)
|
||||||
|
{
|
||||||
target.Frames.Add(frame);
|
target.Frames.Add(frame);
|
||||||
|
|
||||||
|
spectatorStreaming?.HandleFrame(frame);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract ReplayFrame HandleFrame(Vector2 mousePosition, List<T> actions, ReplayFrame previousFrame);
|
protected abstract ReplayFrame HandleFrame(Vector2 mousePosition, List<T> actions, ReplayFrame previousFrame);
|
||||||
|
@ -298,13 +298,6 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
{
|
{
|
||||||
Debug.Assert(!clickSelectionBegan);
|
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)
|
foreach (SelectionBlueprint blueprint in SelectionBlueprints.AliveChildren)
|
||||||
{
|
{
|
||||||
if (blueprint.IsHovered)
|
if (blueprint.IsHovered)
|
||||||
|
@ -24,6 +24,7 @@ using osu.Game.Rulesets.Objects;
|
|||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
using osu.Game.Rulesets.Objects.Types;
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
using osuTK.Input;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Edit.Compose.Components
|
namespace osu.Game.Screens.Edit.Compose.Components
|
||||||
{
|
{
|
||||||
@ -224,21 +225,21 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
/// <param name="state">The input state at the point of selection.</param>
|
/// <param name="state">The input state at the point of selection.</param>
|
||||||
internal void HandleSelectionRequested(SelectionBlueprint blueprint, InputState state)
|
internal void HandleSelectionRequested(SelectionBlueprint blueprint, InputState state)
|
||||||
{
|
{
|
||||||
if (state.Keyboard.ControlPressed)
|
if (state.Keyboard.ShiftPressed && state.Mouse.IsPressed(MouseButton.Right))
|
||||||
{
|
EditorBeatmap.Remove(blueprint.HitObject);
|
||||||
if (blueprint.IsSelected)
|
else if (state.Keyboard.ControlPressed && state.Mouse.IsPressed(MouseButton.Left))
|
||||||
blueprint.Deselect();
|
blueprint.ToggleSelection();
|
||||||
else
|
|
||||||
blueprint.Select();
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
ensureSelected(blueprint);
|
||||||
if (blueprint.IsSelected)
|
}
|
||||||
return;
|
|
||||||
|
|
||||||
DeselectAll?.Invoke();
|
private void ensureSelected(SelectionBlueprint blueprint)
|
||||||
blueprint.Select();
|
{
|
||||||
}
|
if (blueprint.IsSelected)
|
||||||
|
return;
|
||||||
|
|
||||||
|
DeselectAll?.Invoke();
|
||||||
|
blueprint.Select();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteSelected()
|
private void deleteSelected()
|
||||||
|
@ -43,8 +43,9 @@ using osuTK.Input;
|
|||||||
namespace osu.Game.Screens.Edit
|
namespace osu.Game.Screens.Edit
|
||||||
{
|
{
|
||||||
[Cached(typeof(IBeatSnapProvider))]
|
[Cached(typeof(IBeatSnapProvider))]
|
||||||
|
[Cached(typeof(ISamplePlaybackDisabler))]
|
||||||
[Cached]
|
[Cached]
|
||||||
public class Editor : ScreenWithBeatmapBackground, IKeyBindingHandler<GlobalAction>, IKeyBindingHandler<PlatformAction>, IBeatSnapProvider
|
public class Editor : ScreenWithBeatmapBackground, IKeyBindingHandler<GlobalAction>, IKeyBindingHandler<PlatformAction>, IBeatSnapProvider, ISamplePlaybackDisabler
|
||||||
{
|
{
|
||||||
public override float BackgroundParallaxAmount => 0.1f;
|
public override float BackgroundParallaxAmount => 0.1f;
|
||||||
|
|
||||||
@ -64,6 +65,10 @@ namespace osu.Game.Screens.Edit
|
|||||||
[Resolved(canBeNull: true)]
|
[Resolved(canBeNull: true)]
|
||||||
private DialogOverlay dialogOverlay { get; set; }
|
private DialogOverlay dialogOverlay { get; set; }
|
||||||
|
|
||||||
|
public IBindable<bool> SamplePlaybackDisabled => samplePlaybackDisabled;
|
||||||
|
|
||||||
|
private readonly Bindable<bool> samplePlaybackDisabled = new Bindable<bool>();
|
||||||
|
|
||||||
private bool exitConfirmed;
|
private bool exitConfirmed;
|
||||||
|
|
||||||
private string lastSavedHash;
|
private string lastSavedHash;
|
||||||
@ -109,9 +114,10 @@ namespace osu.Game.Screens.Edit
|
|||||||
UpdateClockSource();
|
UpdateClockSource();
|
||||||
|
|
||||||
dependencies.CacheAs(clock);
|
dependencies.CacheAs(clock);
|
||||||
dependencies.CacheAs<ISamplePlaybackDisabler>(clock);
|
|
||||||
AddInternal(clock);
|
AddInternal(clock);
|
||||||
|
|
||||||
|
clock.SeekingOrStopped.BindValueChanged(_ => updateSampleDisabledState());
|
||||||
|
|
||||||
// todo: remove caching of this and consume via editorBeatmap?
|
// todo: remove caching of this and consume via editorBeatmap?
|
||||||
dependencies.Cache(beatDivisor);
|
dependencies.Cache(beatDivisor);
|
||||||
|
|
||||||
@ -444,12 +450,21 @@ namespace osu.Game.Screens.Edit
|
|||||||
if (dialogOverlay == null || dialogOverlay.CurrentDialog is PromptForSaveDialog)
|
if (dialogOverlay == null || dialogOverlay.CurrentDialog is PromptForSaveDialog)
|
||||||
{
|
{
|
||||||
confirmExit();
|
confirmExit();
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isNewBeatmap || HasUnsavedChanges)
|
if (isNewBeatmap || HasUnsavedChanges)
|
||||||
{
|
{
|
||||||
dialogOverlay?.Push(new PromptForSaveDialog(confirmExit, confirmExitWithSave));
|
dialogOverlay?.Push(new PromptForSaveDialog(() =>
|
||||||
|
{
|
||||||
|
confirmExit();
|
||||||
|
this.Exit();
|
||||||
|
}, () =>
|
||||||
|
{
|
||||||
|
confirmExitWithSave();
|
||||||
|
this.Exit();
|
||||||
|
}));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -464,7 +479,6 @@ namespace osu.Game.Screens.Edit
|
|||||||
{
|
{
|
||||||
exitConfirmed = true;
|
exitConfirmed = true;
|
||||||
Save();
|
Save();
|
||||||
this.Exit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void confirmExit()
|
private void confirmExit()
|
||||||
@ -483,7 +497,6 @@ namespace osu.Game.Screens.Edit
|
|||||||
}
|
}
|
||||||
|
|
||||||
exitConfirmed = true;
|
exitConfirmed = true;
|
||||||
this.Exit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly Bindable<string> clipboard = new Bindable<string>();
|
private readonly Bindable<string> clipboard = new Bindable<string>();
|
||||||
@ -557,40 +570,52 @@ namespace osu.Game.Screens.Edit
|
|||||||
.ScaleTo(0.98f, 200, Easing.OutQuint)
|
.ScaleTo(0.98f, 200, Easing.OutQuint)
|
||||||
.FadeOut(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
|
currentScreen
|
||||||
.ScaleTo(1, 200, Easing.OutQuint)
|
.ScaleTo(1, 200, Easing.OutQuint)
|
||||||
.FadeIn(200, Easing.OutQuint);
|
.FadeIn(200, Easing.OutQuint);
|
||||||
return;
|
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);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
switch (e.NewValue)
|
|
||||||
{
|
{
|
||||||
case EditorScreenMode.SongSetup:
|
updateSampleDisabledState();
|
||||||
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 =>
|
private void updateSampleDisabledState()
|
||||||
{
|
{
|
||||||
if (newScreen == currentScreen)
|
samplePlaybackDisabled.Value = clock.SeekingOrStopped.Value || !(currentScreen is ComposeScreen);
|
||||||
screenContainer.Add(newScreen);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void seek(UIEvent e, int direction)
|
private void seek(UIEvent e, int direction)
|
||||||
|
@ -11,14 +11,13 @@ using osu.Framework.Timing;
|
|||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Beatmaps.ControlPoints;
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
using osu.Game.Screens.Play;
|
|
||||||
|
|
||||||
namespace osu.Game.Screens.Edit
|
namespace osu.Game.Screens.Edit
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A decoupled clock which adds editor-specific functionality, such as snapping to a user-defined beat divisor.
|
/// A decoupled clock which adds editor-specific functionality, such as snapping to a user-defined beat divisor.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class EditorClock : Component, IFrameBasedClock, IAdjustableClock, ISourceChangeableClock, ISamplePlaybackDisabler
|
public class EditorClock : Component, IFrameBasedClock, IAdjustableClock, ISourceChangeableClock
|
||||||
{
|
{
|
||||||
public IBindable<Track> Track => track;
|
public IBindable<Track> Track => track;
|
||||||
|
|
||||||
@ -32,9 +31,9 @@ namespace osu.Game.Screens.Edit
|
|||||||
|
|
||||||
private readonly DecoupleableInterpolatingFramedClock underlyingClock;
|
private readonly DecoupleableInterpolatingFramedClock underlyingClock;
|
||||||
|
|
||||||
public IBindable<bool> SamplePlaybackDisabled => samplePlaybackDisabled;
|
public IBindable<bool> SeekingOrStopped => seekingOrStopped;
|
||||||
|
|
||||||
private readonly Bindable<bool> samplePlaybackDisabled = new Bindable<bool>();
|
private readonly Bindable<bool> seekingOrStopped = new Bindable<bool>(true);
|
||||||
|
|
||||||
public EditorClock(WorkingBeatmap beatmap, BindableBeatDivisor beatDivisor)
|
public EditorClock(WorkingBeatmap beatmap, BindableBeatDivisor beatDivisor)
|
||||||
: this(beatmap.Beatmap.ControlPointInfo, beatmap.Track.Length, beatDivisor)
|
: this(beatmap.Beatmap.ControlPointInfo, beatmap.Track.Length, beatDivisor)
|
||||||
@ -171,13 +170,13 @@ namespace osu.Game.Screens.Edit
|
|||||||
|
|
||||||
public void Stop()
|
public void Stop()
|
||||||
{
|
{
|
||||||
samplePlaybackDisabled.Value = true;
|
seekingOrStopped.Value = true;
|
||||||
underlyingClock.Stop();
|
underlyingClock.Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Seek(double position)
|
public bool Seek(double position)
|
||||||
{
|
{
|
||||||
samplePlaybackDisabled.Value = true;
|
seekingOrStopped.Value = true;
|
||||||
|
|
||||||
ClearTransforms();
|
ClearTransforms();
|
||||||
return underlyingClock.Seek(position);
|
return underlyingClock.Seek(position);
|
||||||
@ -228,7 +227,7 @@ namespace osu.Game.Screens.Edit
|
|||||||
|
|
||||||
private void updateSeekingState()
|
private void updateSeekingState()
|
||||||
{
|
{
|
||||||
if (samplePlaybackDisabled.Value)
|
if (seekingOrStopped.Value)
|
||||||
{
|
{
|
||||||
if (track.Value?.IsRunning != true)
|
if (track.Value?.IsRunning != true)
|
||||||
{
|
{
|
||||||
@ -240,13 +239,13 @@ namespace osu.Game.Screens.Edit
|
|||||||
// we are either running a seek tween or doing an immediate seek.
|
// we are either running a seek tween or doing an immediate seek.
|
||||||
// in the case of an immediate seek the seeking bool will be set to false after one update.
|
// in the case of an immediate seek the seeking bool will be set to false after one update.
|
||||||
// this allows for silencing hit sounds and the likes.
|
// this allows for silencing hit sounds and the likes.
|
||||||
samplePlaybackDisabled.Value = Transforms.Any();
|
seekingOrStopped.Value = Transforms.Any();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SeekTo(double seekDestination)
|
public void SeekTo(double seekDestination)
|
||||||
{
|
{
|
||||||
samplePlaybackDisabled.Value = true;
|
seekingOrStopped.Value = true;
|
||||||
|
|
||||||
if (IsRunning)
|
if (IsRunning)
|
||||||
Seek(seekDestination);
|
Seek(seekDestination);
|
||||||
|
@ -177,6 +177,9 @@ namespace osu.Game.Screens.Edit.Timing
|
|||||||
|
|
||||||
private readonly Box hoveredBackground;
|
private readonly Box hoveredBackground;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private EditorClock clock { get; set; }
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private Bindable<ControlPointGroup> selectedGroup { get; set; }
|
private Bindable<ControlPointGroup> selectedGroup { get; set; }
|
||||||
|
|
||||||
@ -200,7 +203,11 @@ namespace osu.Game.Screens.Edit.Timing
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
Action = () => selectedGroup.Value = controlGroup;
|
Action = () =>
|
||||||
|
{
|
||||||
|
selectedGroup.Value = controlGroup;
|
||||||
|
clock.SeekTo(controlGroup.Time);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private Color4 colourHover;
|
private Color4 colourHover;
|
||||||
|
@ -22,9 +22,6 @@ namespace osu.Game.Screens.Edit.Timing
|
|||||||
[Cached]
|
[Cached]
|
||||||
private Bindable<ControlPointGroup> selectedGroup = new Bindable<ControlPointGroup>();
|
private Bindable<ControlPointGroup> selectedGroup = new Bindable<ControlPointGroup>();
|
||||||
|
|
||||||
[Resolved]
|
|
||||||
private EditorClock clock { get; set; }
|
|
||||||
|
|
||||||
public TimingScreen()
|
public TimingScreen()
|
||||||
: base(EditorScreenMode.Timing)
|
: base(EditorScreenMode.Timing)
|
||||||
{
|
{
|
||||||
@ -48,17 +45,6 @@ namespace osu.Game.Screens.Edit.Timing
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
protected override void LoadComplete()
|
|
||||||
{
|
|
||||||
base.LoadComplete();
|
|
||||||
|
|
||||||
selectedGroup.BindValueChanged(selected =>
|
|
||||||
{
|
|
||||||
if (selected.NewValue != null)
|
|
||||||
clock.SeekTo(selected.NewValue.Time);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnTimelineLoaded(TimelineArea timelineArea)
|
protected override void OnTimelineLoaded(TimelineArea timelineArea)
|
||||||
{
|
{
|
||||||
base.OnTimelineLoaded(timelineArea);
|
base.OnTimelineLoaded(timelineArea);
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Audio;
|
|
||||||
using osu.Framework.Audio.Track;
|
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
@ -18,11 +16,7 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
public class EpilepsyWarning : VisibilityContainer
|
public class EpilepsyWarning : VisibilityContainer
|
||||||
{
|
{
|
||||||
public const double FADE_DURATION = 500;
|
public const double FADE_DURATION = 250;
|
||||||
|
|
||||||
private readonly BindableDouble trackVolumeOnEpilepsyWarning = new BindableDouble(1f);
|
|
||||||
|
|
||||||
private Track track;
|
|
||||||
|
|
||||||
public EpilepsyWarning()
|
public EpilepsyWarning()
|
||||||
{
|
{
|
||||||
@ -77,26 +71,15 @@ namespace osu.Game.Screens.Play
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
track = beatmap.Value.Track;
|
|
||||||
track.AddAdjustment(AdjustableProperty.Volume, trackVolumeOnEpilepsyWarning);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void PopIn()
|
protected override void PopIn()
|
||||||
{
|
{
|
||||||
this.TransformBindableTo(trackVolumeOnEpilepsyWarning, 0.25, FADE_DURATION);
|
|
||||||
|
|
||||||
DimmableBackground?.FadeColour(OsuColour.Gray(0.5f), FADE_DURATION, Easing.OutQuint);
|
DimmableBackground?.FadeColour(OsuColour.Gray(0.5f), FADE_DURATION, Easing.OutQuint);
|
||||||
|
|
||||||
this.FadeIn(FADE_DURATION, Easing.OutQuint);
|
this.FadeIn(FADE_DURATION, Easing.OutQuint);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void PopOut() => this.FadeOut(FADE_DURATION);
|
protected override void PopOut() => this.FadeOut(FADE_DURATION);
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
|
||||||
{
|
|
||||||
base.Dispose(isDisposing);
|
|
||||||
track?.RemoveAdjustment(AdjustableProperty.Volume, trackVolumeOnEpilepsyWarning);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,11 +61,6 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
public bool IsRunning => underlyingClock.IsRunning;
|
public bool IsRunning => underlyingClock.IsRunning;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Whether nested samples supporting the <see cref="ISamplePlaybackDisabler"/> interface should be paused.
|
|
||||||
/// </summary>
|
|
||||||
public virtual bool ShouldDisableSamplePlayback => IsPaused.Value;
|
|
||||||
|
|
||||||
public void ProcessFrame()
|
public void ProcessFrame()
|
||||||
{
|
{
|
||||||
// intentionally not updating the underlying clock (handled externally).
|
// intentionally not updating the underlying clock (handled externally).
|
||||||
|
@ -8,8 +8,10 @@ using osu.Framework.Bindables;
|
|||||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Input.Bindings;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
|
using osu.Game.Input.Bindings;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Overlays.Notifications;
|
using osu.Game.Overlays.Notifications;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
@ -22,7 +24,7 @@ using osuTK.Input;
|
|||||||
namespace osu.Game.Screens.Play
|
namespace osu.Game.Screens.Play
|
||||||
{
|
{
|
||||||
[Cached]
|
[Cached]
|
||||||
public class HUDOverlay : Container
|
public class HUDOverlay : Container, IKeyBindingHandler<GlobalAction>
|
||||||
{
|
{
|
||||||
public const float FADE_DURATION = 400;
|
public const float FADE_DURATION = 400;
|
||||||
|
|
||||||
@ -67,6 +69,8 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
internal readonly IBindable<bool> IsBreakTime = new Bindable<bool>();
|
internal readonly IBindable<bool> IsBreakTime = new Bindable<bool>();
|
||||||
|
|
||||||
|
private bool holdingForHUD;
|
||||||
|
|
||||||
private IEnumerable<Drawable> hideTargets => new Drawable[] { visibilityContainer, KeyCounter };
|
private IEnumerable<Drawable> hideTargets => new Drawable[] { visibilityContainer, KeyCounter };
|
||||||
|
|
||||||
public HUDOverlay(ScoreProcessor scoreProcessor, HealthProcessor healthProcessor, DrawableRuleset drawableRuleset, IReadOnlyList<Mod> mods)
|
public HUDOverlay(ScoreProcessor scoreProcessor, HealthProcessor healthProcessor, DrawableRuleset drawableRuleset, IReadOnlyList<Mod> mods)
|
||||||
@ -217,17 +221,18 @@ namespace osu.Game.Screens.Play
|
|||||||
if (ShowHud.Disabled)
|
if (ShowHud.Disabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (holdingForHUD)
|
||||||
|
{
|
||||||
|
ShowHud.Value = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switch (configVisibilityMode.Value)
|
switch (configVisibilityMode.Value)
|
||||||
{
|
{
|
||||||
case HUDVisibilityMode.Never:
|
case HUDVisibilityMode.Never:
|
||||||
ShowHud.Value = false;
|
ShowHud.Value = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HUDVisibilityMode.HideDuringBreaks:
|
|
||||||
// always show during replay as we want the seek bar to be visible.
|
|
||||||
ShowHud.Value = replayLoaded.Value || !IsBreakTime.Value;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case HUDVisibilityMode.HideDuringGameplay:
|
case HUDVisibilityMode.HideDuringGameplay:
|
||||||
// always show during replay as we want the seek bar to be visible.
|
// always show during replay as we want the seek bar to be visible.
|
||||||
ShowHud.Value = replayLoaded.Value || IsBreakTime.Value;
|
ShowHud.Value = replayLoaded.Value || IsBreakTime.Value;
|
||||||
@ -277,9 +282,21 @@ namespace osu.Game.Screens.Play
|
|||||||
switch (e.Key)
|
switch (e.Key)
|
||||||
{
|
{
|
||||||
case Key.Tab:
|
case Key.Tab:
|
||||||
configVisibilityMode.Value = configVisibilityMode.Value != HUDVisibilityMode.Never
|
switch (configVisibilityMode.Value)
|
||||||
? HUDVisibilityMode.Never
|
{
|
||||||
: HUDVisibilityMode.HideDuringGameplay;
|
case HUDVisibilityMode.Never:
|
||||||
|
configVisibilityMode.Value = HUDVisibilityMode.HideDuringGameplay;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HUDVisibilityMode.HideDuringGameplay:
|
||||||
|
configVisibilityMode.Value = HUDVisibilityMode.Always;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HUDVisibilityMode.Always:
|
||||||
|
configVisibilityMode.Value = HUDVisibilityMode.Never;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -351,5 +368,29 @@ namespace osu.Game.Screens.Play
|
|||||||
HealthDisplay?.BindHealthProcessor(processor);
|
HealthDisplay?.BindHealthProcessor(processor);
|
||||||
FailingLayer?.BindHealthProcessor(processor);
|
FailingLayer?.BindHealthProcessor(processor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool OnPressed(GlobalAction action)
|
||||||
|
{
|
||||||
|
switch (action)
|
||||||
|
{
|
||||||
|
case GlobalAction.HoldForHUD:
|
||||||
|
holdingForHUD = true;
|
||||||
|
updateVisibility();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnReleased(GlobalAction action)
|
||||||
|
{
|
||||||
|
switch (action)
|
||||||
|
{
|
||||||
|
case GlobalAction.HoldForHUD:
|
||||||
|
holdingForHUD = false;
|
||||||
|
updateVisibility();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -152,7 +152,9 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
PrepareReplay();
|
// replays should never be recorded or played back when autoplay is enabled
|
||||||
|
if (!Mods.Value.Any(m => m is ModAutoplay))
|
||||||
|
PrepareReplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Replay recordingReplay;
|
private Replay recordingReplay;
|
||||||
@ -239,8 +241,11 @@ namespace osu.Game.Screens.Play
|
|||||||
DrawableRuleset.IsPaused.BindValueChanged(paused =>
|
DrawableRuleset.IsPaused.BindValueChanged(paused =>
|
||||||
{
|
{
|
||||||
updateGameplayState();
|
updateGameplayState();
|
||||||
samplePlaybackDisabled.Value = paused.NewValue;
|
updateSampleDisabledState();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
DrawableRuleset.FrameStableClock.IsCatchingUp.BindValueChanged(_ => updateSampleDisabledState());
|
||||||
|
|
||||||
DrawableRuleset.HasReplayLoaded.BindValueChanged(_ => updateGameplayState());
|
DrawableRuleset.HasReplayLoaded.BindValueChanged(_ => updateGameplayState());
|
||||||
|
|
||||||
DrawableRuleset.HasReplayLoaded.BindValueChanged(_ => updatePauseOnFocusLostState(), true);
|
DrawableRuleset.HasReplayLoaded.BindValueChanged(_ => updatePauseOnFocusLostState(), true);
|
||||||
@ -382,6 +387,11 @@ namespace osu.Game.Screens.Play
|
|||||||
LocalUserPlaying.Value = inGameplay;
|
LocalUserPlaying.Value = inGameplay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateSampleDisabledState()
|
||||||
|
{
|
||||||
|
samplePlaybackDisabled.Value = DrawableRuleset.FrameStableClock.IsCatchingUp.Value || GameplayClockContainer.GameplayClock.IsPaused.Value;
|
||||||
|
}
|
||||||
|
|
||||||
private void updatePauseOnFocusLostState() =>
|
private void updatePauseOnFocusLostState() =>
|
||||||
HUDOverlay.HoldToQuit.PauseOnFocusLost = PauseOnFocusLost
|
HUDOverlay.HoldToQuit.PauseOnFocusLost = PauseOnFocusLost
|
||||||
&& !DrawableRuleset.HasReplayLoaded.Value
|
&& !DrawableRuleset.HasReplayLoaded.Value
|
||||||
|
@ -55,6 +55,8 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
private bool backgroundBrightnessReduction;
|
private bool backgroundBrightnessReduction;
|
||||||
|
|
||||||
|
private readonly BindableDouble volumeAdjustment = new BindableDouble(1);
|
||||||
|
|
||||||
protected bool BackgroundBrightnessReduction
|
protected bool BackgroundBrightnessReduction
|
||||||
{
|
{
|
||||||
set
|
set
|
||||||
@ -169,6 +171,7 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
if (epilepsyWarning != null)
|
if (epilepsyWarning != null)
|
||||||
epilepsyWarning.DimmableBackground = Background;
|
epilepsyWarning.DimmableBackground = Background;
|
||||||
|
Beatmap.Value.Track.AddAdjustment(AdjustableProperty.Volume, volumeAdjustment);
|
||||||
|
|
||||||
content.ScaleTo(0.7f);
|
content.ScaleTo(0.7f);
|
||||||
Background?.FadeColour(Color4.White, 800, Easing.OutQuint);
|
Background?.FadeColour(Color4.White, 800, Easing.OutQuint);
|
||||||
@ -197,6 +200,11 @@ namespace osu.Game.Screens.Play
|
|||||||
cancelLoad();
|
cancelLoad();
|
||||||
|
|
||||||
BackgroundBrightnessReduction = false;
|
BackgroundBrightnessReduction = false;
|
||||||
|
|
||||||
|
// we're moving to player, so a period of silence is upcoming.
|
||||||
|
// stop the track before removing adjustment to avoid a volume spike.
|
||||||
|
Beatmap.Value.Track.Stop();
|
||||||
|
Beatmap.Value.Track.RemoveAdjustment(AdjustableProperty.Volume, volumeAdjustment);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool OnExiting(IScreen next)
|
public override bool OnExiting(IScreen next)
|
||||||
@ -208,6 +216,7 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
Background.EnableUserDim.Value = false;
|
Background.EnableUserDim.Value = false;
|
||||||
BackgroundBrightnessReduction = false;
|
BackgroundBrightnessReduction = false;
|
||||||
|
Beatmap.Value.Track.RemoveAdjustment(AdjustableProperty.Volume, volumeAdjustment);
|
||||||
|
|
||||||
return base.OnExiting(next);
|
return base.OnExiting(next);
|
||||||
}
|
}
|
||||||
@ -331,18 +340,16 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
const double epilepsy_display_length = 3000;
|
const double epilepsy_display_length = 3000;
|
||||||
|
|
||||||
pushSequence.Schedule(() =>
|
pushSequence
|
||||||
{
|
.Schedule(() => epilepsyWarning.State.Value = Visibility.Visible)
|
||||||
epilepsyWarning.State.Value = Visibility.Visible;
|
.TransformBindableTo(volumeAdjustment, 0.25, EpilepsyWarning.FADE_DURATION, Easing.OutQuint)
|
||||||
|
.Delay(epilepsy_display_length)
|
||||||
this.Delay(epilepsy_display_length).Schedule(() =>
|
.Schedule(() =>
|
||||||
{
|
{
|
||||||
epilepsyWarning.Hide();
|
epilepsyWarning.Hide();
|
||||||
epilepsyWarning.Expire();
|
epilepsyWarning.Expire();
|
||||||
});
|
})
|
||||||
});
|
.Delay(EpilepsyWarning.FADE_DURATION);
|
||||||
|
|
||||||
pushSequence.Delay(epilepsy_display_length);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pushSequence.Schedule(() =>
|
pushSequence.Schedule(() =>
|
||||||
|
@ -7,6 +7,7 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
@ -28,6 +29,8 @@ namespace osu.Game.Screens.Ranking.Expanded
|
|||||||
private const float padding = 10;
|
private const float padding = 10;
|
||||||
|
|
||||||
private readonly ScoreInfo score;
|
private readonly ScoreInfo score;
|
||||||
|
private readonly bool withFlair;
|
||||||
|
|
||||||
private readonly List<StatisticDisplay> statisticDisplays = new List<StatisticDisplay>();
|
private readonly List<StatisticDisplay> statisticDisplays = new List<StatisticDisplay>();
|
||||||
|
|
||||||
private FillFlowContainer starAndModDisplay;
|
private FillFlowContainer starAndModDisplay;
|
||||||
@ -40,9 +43,11 @@ namespace osu.Game.Screens.Ranking.Expanded
|
|||||||
/// Creates a new <see cref="ExpandedPanelMiddleContent"/>.
|
/// Creates a new <see cref="ExpandedPanelMiddleContent"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="score">The score to display.</param>
|
/// <param name="score">The score to display.</param>
|
||||||
public ExpandedPanelMiddleContent(ScoreInfo score)
|
/// <param name="withFlair">Whether to add flair for a new score being set.</param>
|
||||||
|
public ExpandedPanelMiddleContent(ScoreInfo score, bool withFlair = false)
|
||||||
{
|
{
|
||||||
this.score = score;
|
this.score = score;
|
||||||
|
this.withFlair = withFlair;
|
||||||
|
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
Masking = true;
|
Masking = true;
|
||||||
@ -51,7 +56,7 @@ namespace osu.Game.Screens.Ranking.Expanded
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load(BeatmapDifficultyManager beatmapDifficultyManager)
|
||||||
{
|
{
|
||||||
var beatmap = score.Beatmap;
|
var beatmap = score.Beatmap;
|
||||||
var metadata = beatmap.BeatmapSet?.Metadata ?? beatmap.Metadata;
|
var metadata = beatmap.BeatmapSet?.Metadata ?? beatmap.Metadata;
|
||||||
@ -138,7 +143,7 @@ namespace osu.Game.Screens.Ranking.Expanded
|
|||||||
Spacing = new Vector2(5, 0),
|
Spacing = new Vector2(5, 0),
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new StarRatingDisplay(beatmap)
|
new StarRatingDisplay(beatmapDifficultyManager.GetDifficulty(beatmap, score.Ruleset, score.Mods))
|
||||||
{
|
{
|
||||||
Anchor = Anchor.CentreLeft,
|
Anchor = Anchor.CentreLeft,
|
||||||
Origin = Anchor.CentreLeft
|
Origin = Anchor.CentreLeft
|
||||||
@ -265,6 +270,9 @@ namespace osu.Game.Screens.Ranking.Expanded
|
|||||||
delay += 200;
|
delay += 200;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!withFlair)
|
||||||
|
FinishTransforms(true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,29 +22,30 @@ namespace osu.Game.Screens.Ranking.Expanded
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class StarRatingDisplay : CompositeDrawable
|
public class StarRatingDisplay : CompositeDrawable
|
||||||
{
|
{
|
||||||
private readonly BeatmapInfo beatmap;
|
private readonly StarDifficulty difficulty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new <see cref="StarRatingDisplay"/>.
|
/// Creates a new <see cref="StarRatingDisplay"/> using an already computed <see cref="StarDifficulty"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="beatmap">The <see cref="BeatmapInfo"/> to display the star difficulty of.</param>
|
/// <param name="starDifficulty">The already computed <see cref="StarDifficulty"/> to display the star difficulty of.</param>
|
||||||
public StarRatingDisplay(BeatmapInfo beatmap)
|
public StarRatingDisplay(StarDifficulty starDifficulty)
|
||||||
{
|
{
|
||||||
this.beatmap = beatmap;
|
difficulty = starDifficulty;
|
||||||
AutoSizeAxes = Axes.Both;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[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 wholePart = starRatingParts[0];
|
||||||
string fractionPart = starRatingParts[1];
|
string fractionPart = starRatingParts[1];
|
||||||
string separator = CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator;
|
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.GradientVertical(Color4Extensions.FromHex("#C1C1C1"), Color4Extensions.FromHex("#595959"))
|
||||||
: (ColourInfo)colours.ForDifficultyRating(beatmap.DifficultyRating);
|
: (ColourInfo)colours.ForDifficultyRating(difficulty.DifficultyRating);
|
||||||
|
|
||||||
InternalChildren = new Drawable[]
|
InternalChildren = new Drawable[]
|
||||||
{
|
{
|
||||||
|
@ -149,7 +149,7 @@ namespace osu.Game.Screens.Ranking
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (Score != null)
|
if (Score != null)
|
||||||
ScorePanelList.AddScore(Score);
|
ScorePanelList.AddScore(Score, true);
|
||||||
|
|
||||||
if (player != null && allowRetry)
|
if (player != null && allowRetry)
|
||||||
{
|
{
|
||||||
|
@ -85,6 +85,8 @@ namespace osu.Game.Screens.Ranking
|
|||||||
|
|
||||||
public readonly ScoreInfo Score;
|
public readonly ScoreInfo Score;
|
||||||
|
|
||||||
|
private bool displayWithFlair;
|
||||||
|
|
||||||
private Container content;
|
private Container content;
|
||||||
|
|
||||||
private Container topLayerContainer;
|
private Container topLayerContainer;
|
||||||
@ -97,9 +99,10 @@ namespace osu.Game.Screens.Ranking
|
|||||||
private Container middleLayerContentContainer;
|
private Container middleLayerContentContainer;
|
||||||
private Drawable middleLayerContent;
|
private Drawable middleLayerContent;
|
||||||
|
|
||||||
public ScorePanel(ScoreInfo score)
|
public ScorePanel(ScoreInfo score, bool isNewLocalScore = false)
|
||||||
{
|
{
|
||||||
Score = score;
|
Score = score;
|
||||||
|
displayWithFlair = isNewLocalScore;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -188,7 +191,7 @@ namespace osu.Game.Screens.Ranking
|
|||||||
|
|
||||||
state = value;
|
state = value;
|
||||||
|
|
||||||
if (LoadState >= LoadState.Ready)
|
if (IsLoaded)
|
||||||
updateState();
|
updateState();
|
||||||
|
|
||||||
StateChanged?.Invoke(value);
|
StateChanged?.Invoke(value);
|
||||||
@ -209,7 +212,10 @@ namespace osu.Game.Screens.Ranking
|
|||||||
middleLayerBackground.FadeColour(expanded_middle_layer_colour, resize_duration, Easing.OutQuint);
|
middleLayerBackground.FadeColour(expanded_middle_layer_colour, resize_duration, Easing.OutQuint);
|
||||||
|
|
||||||
topLayerContentContainer.Add(topLayerContent = new ExpandedPanelTopContent(Score.User).With(d => d.Alpha = 0));
|
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;
|
break;
|
||||||
|
|
||||||
case PanelState.Contracted:
|
case PanelState.Contracted:
|
||||||
|
@ -95,9 +95,10 @@ namespace osu.Game.Screens.Ranking
|
|||||||
/// Adds a <see cref="ScoreInfo"/> to this list.
|
/// Adds a <see cref="ScoreInfo"/> to this list.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="score">The <see cref="ScoreInfo"/> to add.</param>
|
/// <param name="score">The <see cref="ScoreInfo"/> to add.</param>
|
||||||
public ScorePanel AddScore(ScoreInfo score)
|
/// <param name="isNewLocalScore">Whether this is a score that has just been achieved locally. Controls whether flair is added to the display or not.</param>
|
||||||
|
public ScorePanel AddScore(ScoreInfo score, bool isNewLocalScore = false)
|
||||||
{
|
{
|
||||||
var panel = new ScorePanel(score)
|
var panel = new ScorePanel(score, isNewLocalScore)
|
||||||
{
|
{
|
||||||
Anchor = Anchor.CentreLeft,
|
Anchor = Anchor.CentreLeft,
|
||||||
Origin = Anchor.CentreLeft,
|
Origin = Anchor.CentreLeft,
|
||||||
@ -117,19 +118,24 @@ namespace osu.Game.Screens.Ranking
|
|||||||
d.Origin = Anchor.Centre;
|
d.Origin = Anchor.Centre;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
if (SelectedScore.Value == score)
|
if (IsLoaded)
|
||||||
selectedScoreChanged(new ValueChangedEvent<ScoreInfo>(SelectedScore.Value, SelectedScore.Value));
|
|
||||||
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.
|
if (SelectedScore.Value == score)
|
||||||
// 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:
|
SelectedScore.TriggerChange();
|
||||||
// 1) Scroll after the scroll container's visible range is updated.
|
}
|
||||||
// 2) Scroll before the scroll container's scroll position is updated.
|
else
|
||||||
// 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;
|
// 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
|
|||||||
/// <param name="score">The <see cref="ScoreInfo"/> to present.</param>
|
/// <param name="score">The <see cref="ScoreInfo"/> to present.</param>
|
||||||
private void selectedScoreChanged(ValueChangedEvent<ScoreInfo> score)
|
private void selectedScoreChanged(ValueChangedEvent<ScoreInfo> score)
|
||||||
{
|
{
|
||||||
// Contract the old panel.
|
// avoid contracting panels unnecessarily when TriggerChange is fired manually.
|
||||||
foreach (var t in flow.Where(t => t.Panel.Score == score.OldValue))
|
if (score.OldValue != score.NewValue)
|
||||||
{
|
{
|
||||||
t.Panel.State = PanelState.Contracted;
|
// Contract the old panel.
|
||||||
t.Margin = new MarginPadding();
|
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.
|
// 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 };
|
expandedTrackingComponent.Margin = new MarginPadding { Horizontal = expanded_panel_spacing };
|
||||||
expandedPanel.State = PanelState.Expanded;
|
expandedPanel.State = PanelState.Expanded;
|
||||||
|
|
||||||
// Scroll to the new panel. This is done manually since we need:
|
// requires schedule after children to ensure the flow (and thus ScrollContainer's ScrollableExtent) has been updated.
|
||||||
// 1) To scroll after the scroll container's visible range is updated.
|
ScheduleAfterChildren(() =>
|
||||||
// 2) To account for the centre anchor/origins of panels.
|
{
|
||||||
// In the end, it's easier to compute the scroll position manually.
|
// Scroll to the new panel. This is done manually since we need:
|
||||||
float scrollOffset = flow.GetPanelIndex(expandedPanel.Score) * (ScorePanel.CONTRACTED_WIDTH + panel_spacing);
|
// 1) To scroll after the scroll container's visible range is updated.
|
||||||
scroll.ScrollTo(scrollOffset);
|
// 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()
|
protected override void Update()
|
||||||
|
@ -39,6 +39,11 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
private readonly IBindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
|
private readonly IBindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private BeatmapDifficultyManager difficultyManager { get; set; }
|
||||||
|
|
||||||
|
private IBindable<StarDifficulty> beatmapDifficulty;
|
||||||
|
|
||||||
protected BufferedWedgeInfo Info;
|
protected BufferedWedgeInfo Info;
|
||||||
|
|
||||||
public BeatmapInfoWedge()
|
public BeatmapInfoWedge()
|
||||||
@ -88,6 +93,11 @@ namespace osu.Game.Screens.Select
|
|||||||
if (beatmap == value) return;
|
if (beatmap == value) return;
|
||||||
|
|
||||||
beatmap = value;
|
beatmap = value;
|
||||||
|
|
||||||
|
beatmapDifficulty?.UnbindAll();
|
||||||
|
beatmapDifficulty = difficultyManager.GetBindableDifficulty(beatmap.BeatmapInfo);
|
||||||
|
beatmapDifficulty.BindValueChanged(_ => updateDisplay());
|
||||||
|
|
||||||
updateDisplay();
|
updateDisplay();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -113,7 +123,7 @@ namespace osu.Game.Screens.Select
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadComponentAsync(loadingInfo = new BufferedWedgeInfo(beatmap, ruleset.Value)
|
LoadComponentAsync(loadingInfo = new BufferedWedgeInfo(beatmap, ruleset.Value, beatmapDifficulty.Value)
|
||||||
{
|
{
|
||||||
Shear = -Shear,
|
Shear = -Shear,
|
||||||
Depth = Info?.Depth + 1 ?? 0
|
Depth = Info?.Depth + 1 ?? 0
|
||||||
@ -141,12 +151,14 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
private readonly WorkingBeatmap beatmap;
|
private readonly WorkingBeatmap beatmap;
|
||||||
private readonly RulesetInfo ruleset;
|
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)
|
: base(pixelSnapping: true)
|
||||||
{
|
{
|
||||||
this.beatmap = beatmap;
|
this.beatmap = beatmap;
|
||||||
ruleset = userRuleset ?? beatmap.BeatmapInfo.Ruleset;
|
ruleset = userRuleset ?? beatmap.BeatmapInfo.Ruleset;
|
||||||
|
starDifficulty = difficulty;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -190,7 +202,7 @@ namespace osu.Game.Screens.Select
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
new DifficultyColourBar(beatmapInfo)
|
new DifficultyColourBar(starDifficulty)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Y,
|
RelativeSizeAxes = Axes.Y,
|
||||||
Width = 20,
|
Width = 20,
|
||||||
@ -226,7 +238,7 @@ namespace osu.Game.Screens.Select
|
|||||||
Shear = wedged_container_shear,
|
Shear = wedged_container_shear,
|
||||||
Children = new[]
|
Children = new[]
|
||||||
{
|
{
|
||||||
createStarRatingDisplay(beatmapInfo).With(display =>
|
createStarRatingDisplay(starDifficulty).With(display =>
|
||||||
{
|
{
|
||||||
display.Anchor = Anchor.TopRight;
|
display.Anchor = Anchor.TopRight;
|
||||||
display.Origin = Anchor.TopRight;
|
display.Origin = Anchor.TopRight;
|
||||||
@ -293,8 +305,8 @@ namespace osu.Game.Screens.Select
|
|||||||
StatusPill.Hide();
|
StatusPill.Hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Drawable createStarRatingDisplay(BeatmapInfo beatmapInfo) => beatmapInfo.StarDifficulty > 0
|
private static Drawable createStarRatingDisplay(StarDifficulty difficulty) => difficulty.Stars > 0
|
||||||
? new StarRatingDisplay(beatmapInfo)
|
? new StarRatingDisplay(difficulty)
|
||||||
{
|
{
|
||||||
Margin = new MarginPadding { Bottom = 5 }
|
Margin = new MarginPadding { Bottom = 5 }
|
||||||
}
|
}
|
||||||
@ -447,11 +459,11 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
private class DifficultyColourBar : Container
|
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]
|
[BackgroundDependencyLoader]
|
||||||
@ -459,7 +471,7 @@ namespace osu.Game.Screens.Select
|
|||||||
{
|
{
|
||||||
const float full_opacity_ratio = 0.7f;
|
const float full_opacity_ratio = 0.7f;
|
||||||
|
|
||||||
var difficultyColour = colours.ForDifficultyRating(beatmap.DifficultyRating);
|
var difficultyColour = colours.ForDifficultyRating(difficulty.DifficultyRating);
|
||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
|
@ -140,7 +140,7 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
LoadComponentAsync(beatmapContainer, loaded =>
|
LoadComponentAsync(beatmapContainer, loaded =>
|
||||||
{
|
{
|
||||||
// make sure the pooled target hasn't changed.
|
// make sure the pooled target hasn't changed.
|
||||||
if (carouselBeatmapSet != Item)
|
if (beatmapContainer != loaded)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Content.Child = loaded;
|
Content.Child = loaded;
|
||||||
|
@ -15,6 +15,7 @@ namespace osu.Game.Storyboards.Drawables
|
|||||||
{
|
{
|
||||||
public class DrawableStoryboard : Container<DrawableStoryboardLayer>
|
public class DrawableStoryboard : Container<DrawableStoryboardLayer>
|
||||||
{
|
{
|
||||||
|
[Cached]
|
||||||
public Storyboard Storyboard { get; }
|
public Storyboard Storyboard { get; }
|
||||||
|
|
||||||
protected override Container<DrawableStoryboardLayer> Content { get; }
|
protected override Container<DrawableStoryboardLayer> Content { get; }
|
||||||
|
@ -2,18 +2,16 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using osuTK;
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Animations;
|
using osu.Framework.Graphics.Animations;
|
||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Beatmaps;
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Storyboards.Drawables
|
namespace osu.Game.Storyboards.Drawables
|
||||||
{
|
{
|
||||||
public class DrawableStoryboardAnimation : TextureAnimation, IFlippable, IVectorScalable
|
public class DrawableStoryboardAnimation : DrawableAnimation, IFlippable, IVectorScalable
|
||||||
{
|
{
|
||||||
public StoryboardAnimation Animation { get; }
|
public StoryboardAnimation Animation { get; }
|
||||||
|
|
||||||
@ -115,18 +113,13 @@ namespace osu.Game.Storyboards.Drawables
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(IBindable<WorkingBeatmap> 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;
|
AddFrame(storyboard.CreateSpriteFromResourcePath(framePath, textureStore), Animation.FrameDelay);
|
||||||
if (path == null)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
var texture = textureStore.Get(path);
|
|
||||||
AddFrame(texture, Animation.FrameDelay);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Animation.ApplyTransforms(this);
|
Animation.ApplyTransforms(this);
|
||||||
|
@ -2,18 +2,16 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using osuTK;
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Beatmaps;
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Storyboards.Drawables
|
namespace osu.Game.Storyboards.Drawables
|
||||||
{
|
{
|
||||||
public class DrawableStoryboardSprite : Sprite, IFlippable, IVectorScalable
|
public class DrawableStoryboardSprite : CompositeDrawable, IFlippable, IVectorScalable
|
||||||
{
|
{
|
||||||
public StoryboardSprite Sprite { get; }
|
public StoryboardSprite Sprite { get; }
|
||||||
|
|
||||||
@ -111,16 +109,18 @@ namespace osu.Game.Storyboards.Drawables
|
|||||||
|
|
||||||
LifetimeStart = sprite.StartTime;
|
LifetimeStart = sprite.StartTime;
|
||||||
LifetimeEnd = sprite.EndTime;
|
LifetimeEnd = sprite.EndTime;
|
||||||
|
|
||||||
|
AutoSizeAxes = Axes.Both;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(IBindable<WorkingBeatmap> 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;
|
var drawable = storyboard.CreateSpriteFromResourcePath(Sprite.Path, textureStore);
|
||||||
if (path == null)
|
|
||||||
return;
|
if (drawable != null)
|
||||||
|
InternalChild = drawable;
|
||||||
|
|
||||||
Texture = textureStore.Get(path);
|
|
||||||
Sprite.ApplyTransforms(this);
|
Sprite.ApplyTransforms(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,14 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Framework.Graphics.Textures;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Skinning;
|
||||||
using osu.Game.Storyboards.Drawables;
|
using osu.Game.Storyboards.Drawables;
|
||||||
|
|
||||||
namespace osu.Game.Storyboards
|
namespace osu.Game.Storyboards
|
||||||
@ -15,6 +20,11 @@ namespace osu.Game.Storyboards
|
|||||||
|
|
||||||
public BeatmapInfo BeatmapInfo = new BeatmapInfo();
|
public BeatmapInfo BeatmapInfo = new BeatmapInfo();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether the storyboard can fall back to skin sprites in case no matching storyboard sprites are found.
|
||||||
|
/// </summary>
|
||||||
|
public bool UseSkinSprites { get; set; }
|
||||||
|
|
||||||
public bool HasDrawable => Layers.Any(l => l.Elements.Any(e => e.IsDrawable));
|
public bool HasDrawable => Layers.Any(l => l.Elements.Any(e => e.IsDrawable));
|
||||||
|
|
||||||
public double FirstEventTime => Layers.Min(l => l.Elements.FirstOrDefault()?.StartTime ?? 0);
|
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);
|
drawable.Width = drawable.Height * (BeatmapInfo.WidescreenStoryboard ? 16 / 9f : 4 / 3f);
|
||||||
return drawable;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -180,9 +180,8 @@ namespace osu.Game.Tests.Beatmaps
|
|||||||
private readonly BeatmapInfo skinBeatmapInfo;
|
private readonly BeatmapInfo skinBeatmapInfo;
|
||||||
private readonly IResourceStore<byte[]> resourceStore;
|
private readonly IResourceStore<byte[]> resourceStore;
|
||||||
|
|
||||||
public TestWorkingBeatmap(BeatmapInfo skinBeatmapInfo, IResourceStore<byte[]> resourceStore, IBeatmap beatmap, Storyboard storyboard, IFrameBasedClock referenceClock, AudioManager audio,
|
public TestWorkingBeatmap(BeatmapInfo skinBeatmapInfo, IResourceStore<byte[]> resourceStore, IBeatmap beatmap, Storyboard storyboard, IFrameBasedClock referenceClock, AudioManager audio)
|
||||||
double length = 60000)
|
: base(beatmap, storyboard, referenceClock, audio)
|
||||||
: base(beatmap, storyboard, referenceClock, audio, length)
|
|
||||||
{
|
{
|
||||||
this.skinBeatmapInfo = skinBeatmapInfo;
|
this.skinBeatmapInfo = skinBeatmapInfo;
|
||||||
this.resourceStore = resourceStore;
|
this.resourceStore = resourceStore;
|
||||||
|
@ -23,6 +23,7 @@ using osu.Game.Online.API;
|
|||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.UI;
|
using osu.Game.Rulesets.UI;
|
||||||
using osu.Game.Screens;
|
using osu.Game.Screens;
|
||||||
using osu.Game.Storyboards;
|
using osu.Game.Storyboards;
|
||||||
@ -222,18 +223,23 @@ namespace osu.Game.Tests.Visual
|
|||||||
/// <param name="storyboard">The storyboard.</param>
|
/// <param name="storyboard">The storyboard.</param>
|
||||||
/// <param name="referenceClock">An optional clock which should be used instead of a stopwatch for virtual time progression.</param>
|
/// <param name="referenceClock">An optional clock which should be used instead of a stopwatch for virtual time progression.</param>
|
||||||
/// <param name="audio">Audio manager. Required if a reference clock isn't provided.</param>
|
/// <param name="audio">Audio manager. Required if a reference clock isn't provided.</param>
|
||||||
/// <param name="length">The length of the returned virtual track.</param>
|
public ClockBackedTestWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard, IFrameBasedClock referenceClock, AudioManager audio)
|
||||||
public ClockBackedTestWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard, IFrameBasedClock referenceClock, AudioManager audio, double length = 60000)
|
|
||||||
: base(beatmap, storyboard, 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)
|
if (referenceClock != null)
|
||||||
{
|
{
|
||||||
store = new TrackVirtualStore(referenceClock);
|
store = new TrackVirtualStore(referenceClock);
|
||||||
audio.AddItem(store);
|
audio.AddItem(store);
|
||||||
track = store.GetVirtual(length);
|
track = store.GetVirtual(trackLength);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
track = audio?.Tracks.GetVirtual(length);
|
track = audio?.Tracks.GetVirtual(trackLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
~ClockBackedTestWorkingBeatmap()
|
~ClockBackedTestWorkingBeatmap()
|
||||||
|
@ -21,10 +21,12 @@
|
|||||||
<PackageReference Include="Dapper" Version="2.0.35" />
|
<PackageReference Include="Dapper" Version="2.0.35" />
|
||||||
<PackageReference Include="DiffPlex" Version="1.6.3" />
|
<PackageReference Include="DiffPlex" Version="1.6.3" />
|
||||||
<PackageReference Include="Humanizer" Version="2.8.26" />
|
<PackageReference Include="Humanizer" Version="2.8.26" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="3.1.9" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson" Version="3.1.9" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||||
<PackageReference Include="ppy.osu.Framework" Version="2020.1019.0" />
|
<PackageReference Include="ppy.osu.Framework" Version="2020.1029.1" />
|
||||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.1016.0" />
|
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.1016.0" />
|
||||||
<PackageReference Include="Sentry" Version="2.1.6" />
|
<PackageReference Include="Sentry" Version="2.1.6" />
|
||||||
<PackageReference Include="SharpCompress" Version="0.26.0" />
|
<PackageReference Include="SharpCompress" Version="0.26.0" />
|
||||||
|
@ -70,7 +70,7 @@
|
|||||||
<Reference Include="System.Net.Http" />
|
<Reference Include="System.Net.Http" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup Label="Package References">
|
<ItemGroup Label="Package References">
|
||||||
<PackageReference Include="ppy.osu.Framework.iOS" Version="2020.1019.0" />
|
<PackageReference Include="ppy.osu.Framework.iOS" Version="2020.1029.1" />
|
||||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.1016.0" />
|
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.1016.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<!-- Xamarin.iOS does not automatically handle transitive dependencies from NuGet packages. -->
|
<!-- Xamarin.iOS does not automatically handle transitive dependencies from NuGet packages. -->
|
||||||
@ -80,7 +80,7 @@
|
|||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||||
<PackageReference Include="ppy.osu.Framework" Version="2020.1019.0" />
|
<PackageReference Include="ppy.osu.Framework" Version="2020.1029.1" />
|
||||||
<PackageReference Include="SharpCompress" Version="0.26.0" />
|
<PackageReference Include="SharpCompress" Version="0.26.0" />
|
||||||
<PackageReference Include="NUnit" Version="3.12.0" />
|
<PackageReference Include="NUnit" Version="3.12.0" />
|
||||||
<PackageReference Include="SharpRaven" Version="2.4.0" />
|
<PackageReference Include="SharpRaven" Version="2.4.0" />
|
||||||
|
Loading…
Reference in New Issue
Block a user