1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 03:25:11 +08:00

Merge remote-tracking branch 'upstream/master' into humanizer-fallback

This commit is contained in:
Dean Herbert 2019-08-28 20:15:32 +09:00
commit dfdf3f5e96
72 changed files with 690 additions and 459 deletions

View File

@ -60,7 +60,7 @@
<Reference Include="Java.Interop" /> <Reference Include="Java.Interop" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.809.0" /> <PackageReference Include="ppy.osu.Game.Resources" Version="2019.823.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2019.821.0" /> <PackageReference Include="ppy.osu.Framework.Android" Version="2019.828.0" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -15,6 +15,7 @@ using osu.Framework.Graphics.Sprites;
using osuTK.Graphics; using osuTK.Graphics;
using osu.Framework.Audio.Sample; using osu.Framework.Audio.Sample;
using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Textures;
using osu.Game.Audio;
namespace osu.Game.Rulesets.Catch.Tests namespace osu.Game.Rulesets.Catch.Tests
{ {
@ -92,7 +93,7 @@ namespace osu.Game.Rulesets.Catch.Tests
return null; return null;
} }
public SampleChannel GetSample(string sampleName) => public SampleChannel GetSample(ISampleInfo sampleInfo) =>
throw new NotImplementedException(); throw new NotImplementedException();
public Texture GetTexture(string componentName) => public Texture GetTexture(string componentName) =>

View File

@ -4,7 +4,7 @@
<PackageReference Include="Appveyor.TestLogger" Version="2.0.0" /> <PackageReference Include="Appveyor.TestLogger" Version="2.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="NUnit" Version="3.12.0" /> <PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.14.0" /> <PackageReference Include="NUnit3TestAdapter" Version="3.15.0" />
<PackageReference Update="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" /> <PackageReference Update="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" />
</ItemGroup> </ItemGroup>
<PropertyGroup Label="Project"> <PropertyGroup Label="Project">

View File

@ -58,14 +58,12 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable
ApplyResult(r => r.Type = CheckPosition.Invoke(HitObject) ? HitResult.Perfect : HitResult.Miss); ApplyResult(r => r.Type = CheckPosition.Invoke(HitObject) ? HitResult.Perfect : HitResult.Miss);
} }
protected override bool UseTransformStateManagement => false; protected sealed override double InitialLifetimeOffset => HitObject.TimePreempt;
protected override void UpdateState(ArmedState state) protected override void UpdateInitialTransforms() => this.FadeIn(200);
protected override void UpdateStateTransforms(ArmedState state)
{ {
// TODO: update to use new state management.
using (BeginAbsoluteSequence(HitObject.StartTime - HitObject.TimePreempt))
this.FadeIn(200);
var endTime = (HitObject as IHasEndTime)?.EndTime ?? HitObject.StartTime; var endTime = (HitObject as IHasEndTime)?.EndTime ?? HitObject.StartTime;
using (BeginAbsoluteSequence(endTime, true)) using (BeginAbsoluteSequence(endTime, true))

View File

@ -53,7 +53,7 @@ namespace osu.Game.Rulesets.Catch.UI
if (lastPlateableFruit == null) if (lastPlateableFruit == null)
return; return;
// this is required to make this run after the last caught fruit runs UpdateState at least once. // this is required to make this run after the last caught fruit runs updateState() at least once.
// TODO: find a better alternative // TODO: find a better alternative
if (lastPlateableFruit.IsLoaded) if (lastPlateableFruit.IsLoaded)
action(); action();

View File

@ -4,7 +4,7 @@
<PackageReference Include="Appveyor.TestLogger" Version="2.0.0" /> <PackageReference Include="Appveyor.TestLogger" Version="2.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="NUnit" Version="3.12.0" /> <PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.14.0" /> <PackageReference Include="NUnit3TestAdapter" Version="3.15.0" />
<PackageReference Update="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" /> <PackageReference Update="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" />
</ItemGroup> </ItemGroup>
<PropertyGroup Label="Project"> <PropertyGroup Label="Project">

View File

@ -69,7 +69,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
Alpha = 0.2f; Alpha = 0.2f;
} }
protected override void UpdateState(ArmedState state) protected override void UpdateStateTransforms(ArmedState state)
{ {
} }
} }

View File

@ -8,6 +8,7 @@ using osu.Framework.Graphics;
using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces; using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Input.Bindings; using osu.Framework.Input.Bindings;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.UI.Scrolling; using osu.Game.Rulesets.UI.Scrolling;
@ -104,6 +105,12 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
bodyPiece.Height = DrawHeight - Head.Height / 2 + Tail.Height / 2; bodyPiece.Height = DrawHeight - Head.Height / 2 + Tail.Height / 2;
} }
protected override void UpdateStateTransforms(ArmedState state)
{
using (BeginDelayedSequence(HitObject.Duration, true))
base.UpdateStateTransforms(state);
}
protected void BeginHold() protected void BeginHold()
{ {
holdStartTime = Time.Current; holdStartTime = Time.Current;

View File

@ -45,24 +45,11 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
{ {
Anchor = Origin = e.NewValue == ScrollingDirection.Up ? Anchor.TopCentre : Anchor.BottomCentre; Anchor = Origin = e.NewValue == ScrollingDirection.Up ? Anchor.TopCentre : Anchor.BottomCentre;
} }
}
public abstract class DrawableManiaHitObject<TObject> : DrawableManiaHitObject protected override void UpdateInitialTransforms() => this.FadeIn();
where TObject : ManiaHitObject
{
public new readonly TObject HitObject;
protected DrawableManiaHitObject(TObject hitObject) protected override void UpdateStateTransforms(ArmedState state)
: base(hitObject)
{ {
HitObject = hitObject;
}
protected override bool UseTransformStateManagement => false;
protected override void UpdateState(ArmedState state)
{
// TODO: update to use new state management.
switch (state) switch (state)
{ {
case ArmedState.Miss: case ArmedState.Miss:
@ -75,4 +62,16 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
} }
} }
} }
public abstract class DrawableManiaHitObject<TObject> : DrawableManiaHitObject
where TObject : ManiaHitObject
{
public new readonly TObject HitObject;
protected DrawableManiaHitObject(TObject hitObject)
: base(hitObject)
{
HitObject = hitObject;
}
}
} }

View File

@ -5,6 +5,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using osu.Game.Replays; using osu.Game.Replays;
using osu.Game.Rulesets.Mania.Beatmaps; using osu.Game.Rulesets.Mania.Beatmaps;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.Replays; using osu.Game.Rulesets.Replays;
@ -77,13 +78,37 @@ namespace osu.Game.Rulesets.Mania.Replays
private IEnumerable<IActionPoint> generateActionPoints() private IEnumerable<IActionPoint> generateActionPoints()
{ {
foreach (var obj in Beatmap.HitObjects) for (int i = 0; i < Beatmap.HitObjects.Count; i++)
{ {
yield return new HitPoint { Time = obj.StartTime, Column = obj.Column }; var currentObject = Beatmap.HitObjects[i];
yield return new ReleasePoint { Time = ((obj as IHasEndTime)?.EndTime ?? obj.StartTime) + RELEASE_DELAY, Column = obj.Column }; var nextObjectInColumn = GetNextObject(i); // Get the next object that requires pressing the same button
double endTime = (currentObject as IHasEndTime)?.EndTime ?? currentObject.StartTime;
bool canDelayKeyUp = nextObjectInColumn == null ||
nextObjectInColumn.StartTime > endTime + RELEASE_DELAY;
double calculatedDelay = canDelayKeyUp ? RELEASE_DELAY : (nextObjectInColumn.StartTime - endTime) * 0.9;
yield return new HitPoint { Time = currentObject.StartTime, Column = currentObject.Column };
yield return new ReleasePoint { Time = endTime + calculatedDelay, Column = currentObject.Column };
} }
} }
protected override HitObject GetNextObject(int currentIndex)
{
int desiredColumn = Beatmap.HitObjects[currentIndex].Column;
for (int i = currentIndex + 1; i < Beatmap.HitObjects.Count; i++)
{
if (Beatmap.HitObjects[i].Column == desiredColumn)
return Beatmap.HitObjects[i];
}
return null;
}
private interface IActionPoint private interface IActionPoint
{ {
double Time { get; set; } double Time { get; set; }

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -4,7 +4,7 @@
<PackageReference Include="Appveyor.TestLogger" Version="2.0.0" /> <PackageReference Include="Appveyor.TestLogger" Version="2.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="NUnit" Version="3.12.0" /> <PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.14.0" /> <PackageReference Include="NUnit3TestAdapter" Version="3.15.0" />
<PackageReference Update="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" /> <PackageReference Update="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" />
</ItemGroup> </ItemGroup>
<PropertyGroup Label="Project"> <PropertyGroup Label="Project">

View File

@ -247,10 +247,6 @@ namespace osu.Game.Rulesets.Taiko.Tests
: base(hitObject) : base(hitObject)
{ {
} }
protected override void UpdateState(ArmedState state)
{
}
} }
} }
} }

View File

@ -4,7 +4,7 @@
<PackageReference Include="Appveyor.TestLogger" Version="2.0.0" /> <PackageReference Include="Appveyor.TestLogger" Version="2.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="NUnit" Version="3.12.0" /> <PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.14.0" /> <PackageReference Include="NUnit3TestAdapter" Version="3.15.0" />
<PackageReference Update="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" /> <PackageReference Update="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" />
</ItemGroup> </ItemGroup>
<PropertyGroup Label="Project"> <PropertyGroup Label="Project">

View File

@ -53,9 +53,5 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
Alpha = 0.75f Alpha = 0.75f
}); });
} }
protected override void UpdateState(ArmedState state)
{
}
} }
} }

View File

@ -88,13 +88,13 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
ApplyResult(r => r.Type = HitResult.Miss); ApplyResult(r => r.Type = HitResult.Miss);
} }
protected override void UpdateState(ArmedState state) protected override void UpdateStateTransforms(ArmedState state)
{ {
switch (state) switch (state)
{ {
case ArmedState.Hit: case ArmedState.Hit:
case ArmedState.Miss: case ArmedState.Miss:
this.FadeOut(100).Expire(); this.Delay(HitObject.Duration).FadeOut(100).Expire();
break; break;
} }
} }

View File

@ -39,7 +39,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
ApplyResult(r => r.Type = HitResult.Great); ApplyResult(r => r.Type = HitResult.Great);
} }
protected override void UpdateState(ArmedState state) protected override void UpdateStateTransforms(ArmedState state)
{ {
switch (state) switch (state)
{ {

View File

@ -92,56 +92,42 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
Size = BaseSize * Parent.RelativeChildSize; Size = BaseSize * Parent.RelativeChildSize;
} }
protected override void UpdateState(ArmedState state) protected override void UpdateStateTransforms(ArmedState state)
{ {
// TODO: update to use new state management. switch (state)
var circlePiece = MainPiece as CirclePiece;
circlePiece?.FlashBox.FinishTransforms();
var offset = !AllJudged ? 0 : Time.Current - HitObject.StartTime;
using (BeginDelayedSequence(HitObject.StartTime - Time.Current + offset, true))
{ {
switch (State.Value) case ArmedState.Idle:
{ validActionPressed = false;
case ArmedState.Idle:
validActionPressed = false;
UnproxyContent(); UnproxyContent();
this.Delay(HitObject.HitWindows.HalfWindowFor(HitResult.Miss)).Expire(); this.Delay(HitObject.HitWindows.HalfWindowFor(HitResult.Miss)).Expire();
break; break;
case ArmedState.Miss: case ArmedState.Miss:
this.FadeOut(100) this.FadeOut(100)
.Expire(); .Expire();
break; break;
case ArmedState.Hit: case ArmedState.Hit:
// If we're far enough away from the left stage, we should bring outselves in front of it // If we're far enough away from the left stage, we should bring outselves in front of it
ProxyContent(); ProxyContent();
var flash = circlePiece?.FlashBox; var flash = (MainPiece as CirclePiece)?.FlashBox;
flash?.FadeTo(0.9f).FadeOut(300);
if (flash != null) const float gravity_time = 300;
{ const float gravity_travel_height = 200;
flash.FadeTo(0.9f);
flash.FadeOut(300);
}
const float gravity_time = 300; this.ScaleTo(0.8f, gravity_time * 2, Easing.OutQuad);
const float gravity_travel_height = 200;
this.ScaleTo(0.8f, gravity_time * 2, Easing.OutQuad); this.MoveToY(-gravity_travel_height, gravity_time, Easing.Out)
.Then()
.MoveToY(gravity_travel_height * 2, gravity_time * 2, Easing.In);
this.MoveToY(-gravity_travel_height, gravity_time, Easing.Out) this.FadeOut(800)
.Then() .Expire();
.MoveToY(gravity_travel_height * 2, gravity_time * 2, Easing.In);
this.FadeOut(800) break;
.Expire();
break;
}
} }
} }

View File

@ -18,9 +18,5 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
{ {
MainObject = mainObject; MainObject = mainObject;
} }
protected override void UpdateState(ArmedState state)
{
}
} }
} }

View File

@ -25,6 +25,11 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
private const float target_ring_scale = 5f; private const float target_ring_scale = 5f;
private const float inner_ring_alpha = 0.65f; private const float inner_ring_alpha = 0.65f;
/// <summary>
/// Offset away from the start time of the swell at which the ring starts appearing.
/// </summary>
private const double ring_appear_offset = 100;
private readonly List<DrawableSwellTick> ticks = new List<DrawableSwellTick>(); private readonly List<DrawableSwellTick> ticks = new List<DrawableSwellTick>();
private readonly Container bodyContainer; private readonly Container bodyContainer;
@ -179,26 +184,34 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
} }
} }
protected override void UpdateState(ArmedState state) protected override void UpdateInitialTransforms()
{ {
const float preempt = 100; base.UpdateInitialTransforms();
const float out_transition_time = 300;
using (BeginAbsoluteSequence(HitObject.StartTime - ring_appear_offset, true))
targetRing.ScaleTo(target_ring_scale, 400, Easing.OutQuint);
}
protected override void UpdateStateTransforms(ArmedState state)
{
const double transition_duration = 300;
switch (state) switch (state)
{ {
case ArmedState.Idle: case ArmedState.Idle:
UnproxyContent();
expandingRing.FadeTo(0); expandingRing.FadeTo(0);
using (BeginAbsoluteSequence(HitObject.StartTime - preempt, true))
targetRing.ScaleTo(target_ring_scale, preempt * 4, Easing.OutQuint);
break; break;
case ArmedState.Miss: case ArmedState.Miss:
case ArmedState.Hit: case ArmedState.Hit:
this.FadeOut(out_transition_time, Easing.Out); using (BeginAbsoluteSequence(Time.Current, true))
bodyContainer.ScaleTo(1.4f, out_transition_time); {
this.FadeOut(transition_duration, Easing.Out);
bodyContainer.ScaleTo(1.4f, transition_duration);
Expire();
}
Expire();
break; break;
} }
} }
@ -212,9 +225,10 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
// Make the swell stop at the hit target // Make the swell stop at the hit target
X = Math.Max(0, X); X = Math.Max(0, X);
double t = Math.Min(HitObject.StartTime, Time.Current); if (Time.Current >= HitObject.StartTime - ring_appear_offset)
if (t == HitObject.StartTime)
ProxyContent(); ProxyContent();
else
UnproxyContent();
} }
private bool? lastWasCentre; private bool? lastWasCentre;

View File

@ -1,7 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
namespace osu.Game.Rulesets.Taiko.Objects.Drawables namespace osu.Game.Rulesets.Taiko.Objects.Drawables
@ -21,10 +20,6 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
{ {
} }
protected override void UpdateState(ArmedState state)
{
}
public override bool OnPressed(TaikoAction action) => false; public override bool OnPressed(TaikoAction action) => false;
} }
} }

View File

@ -78,10 +78,31 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
public abstract bool OnPressed(TaikoAction action); public abstract bool OnPressed(TaikoAction action);
public virtual bool OnReleased(TaikoAction action) => false; public virtual bool OnReleased(TaikoAction action) => false;
protected override void UpdateInitialTransforms() => this.FadeIn();
public override double LifetimeStart
{
get => base.LifetimeStart;
set
{
base.LifetimeStart = value;
proxiedContent.LifetimeStart = value;
}
}
public override double LifetimeEnd
{
get => base.LifetimeEnd;
set
{
base.LifetimeEnd = value;
proxiedContent.LifetimeEnd = value;
}
}
private class ProxiedContentContainer : Container private class ProxiedContentContainer : Container
{ {
public override double LifetimeStart => Parent?.LifetimeStart ?? base.LifetimeStart; public override bool RemoveWhenNotAlive => false;
public override double LifetimeEnd => Parent?.LifetimeEnd ?? base.LifetimeEnd;
} }
} }
@ -121,8 +142,6 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
} }
} }
protected override bool UseTransformStateManagement => false;
// Normal and clap samples are handled by the drum // Normal and clap samples are handled by the drum
protected override IEnumerable<HitSampleInfo> GetSamples() => HitObject.Samples.Where(s => s.Name != HitSampleInfo.HIT_NORMAL && s.Name != HitSampleInfo.HIT_CLAP); protected override IEnumerable<HitSampleInfo> GetSamples() => HitObject.Samples.Where(s => s.Name != HitSampleInfo.HIT_NORMAL && s.Name != HitSampleInfo.HIT_CLAP);

View File

@ -10,6 +10,7 @@ using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.Taiko.Objects; using osu.Game.Rulesets.Taiko.Objects;
using osu.Game.Rulesets.Replays; using osu.Game.Rulesets.Replays;
using osu.Game.Rulesets.Taiko.Beatmaps; using osu.Game.Rulesets.Taiko.Beatmaps;
using osu.Game.Rulesets.Objects;
namespace osu.Game.Rulesets.Taiko.Replays namespace osu.Game.Rulesets.Taiko.Replays
{ {
@ -113,7 +114,13 @@ namespace osu.Game.Rulesets.Taiko.Replays
else else
throw new InvalidOperationException("Unknown hit object type."); throw new InvalidOperationException("Unknown hit object type.");
Frames.Add(new TaikoReplayFrame(endTime + KEY_UP_DELAY)); var nextHitObject = GetNextObject(i); // Get the next object that requires pressing the same button
bool canDelayKeyUp = nextHitObject == null || nextHitObject.StartTime > endTime + KEY_UP_DELAY;
double calculatedDelay = canDelayKeyUp ? KEY_UP_DELAY : (nextHitObject.StartTime - endTime) * 0.9;
Frames.Add(new TaikoReplayFrame(endTime + calculatedDelay));
if (i < Beatmap.HitObjects.Count - 1) if (i < Beatmap.HitObjects.Count - 1)
{ {
@ -127,5 +134,24 @@ namespace osu.Game.Rulesets.Taiko.Replays
return Replay; return Replay;
} }
protected override HitObject GetNextObject(int currentIndex)
{
Type desiredType = Beatmap.HitObjects[currentIndex].GetType();
for (int i = currentIndex + 1; i < Beatmap.HitObjects.Count; i++)
{
var currentObj = Beatmap.HitObjects[i];
if (currentObj.GetType() == desiredType ||
// Un-press all keys before a DrumRoll or Swell
currentObj is DrumRoll || currentObj is Swell)
{
return Beatmap.HitObjects[i];
}
}
return null;
}
} }
} }

View File

@ -44,9 +44,8 @@ namespace osu.Game.Rulesets.Taiko.UI
private readonly JudgementContainer<DrawableTaikoJudgement> judgementContainer; private readonly JudgementContainer<DrawableTaikoJudgement> judgementContainer;
internal readonly HitTarget HitTarget; internal readonly HitTarget HitTarget;
private readonly Container topLevelHitContainer; private readonly ProxyContainer topLevelHitContainer;
private readonly ProxyContainer barlineContainer;
private readonly Container barlineContainer;
private readonly Container overlayBackgroundContainer; private readonly Container overlayBackgroundContainer;
private readonly Container backgroundContainer; private readonly Container backgroundContainer;
@ -108,7 +107,7 @@ namespace osu.Game.Rulesets.Taiko.UI
} }
} }
}, },
barlineContainer = new Container barlineContainer = new ProxyContainer
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Left = HIT_TARGET_OFFSET } Padding = new MarginPadding { Left = HIT_TARGET_OFFSET }
@ -183,7 +182,7 @@ namespace osu.Game.Rulesets.Taiko.UI
} }
} }
}, },
topLevelHitContainer = new Container topLevelHitContainer = new ProxyContainer
{ {
Name = "Top level hit objects", Name = "Top level hit objects",
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
@ -256,5 +255,15 @@ namespace osu.Game.Rulesets.Taiko.UI
break; break;
} }
} }
private class ProxyContainer : LifetimeManagementContainer
{
public new MarginPadding Padding
{
set => base.Padding = value;
}
public void Add(Drawable proxy) => AddInternal(proxy);
}
} }
} }

View File

@ -58,7 +58,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
int spriteCount = background.Elements.Count(x => x.GetType() == typeof(StoryboardSprite)); int spriteCount = background.Elements.Count(x => x.GetType() == typeof(StoryboardSprite));
int animationCount = background.Elements.Count(x => x.GetType() == typeof(StoryboardAnimation)); int animationCount = background.Elements.Count(x => x.GetType() == typeof(StoryboardAnimation));
int sampleCount = background.Elements.Count(x => x.GetType() == typeof(StoryboardSample)); int sampleCount = background.Elements.Count(x => x.GetType() == typeof(StoryboardSampleInfo));
Assert.AreEqual(15, spriteCount); Assert.AreEqual(15, spriteCount);
Assert.AreEqual(1, animationCount); Assert.AreEqual(1, animationCount);

View File

@ -200,10 +200,6 @@ namespace osu.Game.Tests.Visual.Gameplay
break; break;
} }
} }
protected override void UpdateState(ArmedState state)
{
}
} }
private class TestDrawableHitObject : DrawableHitObject<HitObject> private class TestDrawableHitObject : DrawableHitObject<HitObject>
@ -216,10 +212,6 @@ namespace osu.Game.Tests.Visual.Gameplay
AddInternal(new Box { Size = new Vector2(75) }); AddInternal(new Box { Size = new Vector2(75) });
} }
protected override void UpdateState(ArmedState state)
{
}
} }
} }
} }

View File

@ -10,6 +10,7 @@ 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.Graphics.Textures; using osu.Framework.Graphics.Textures;
using osu.Game.Audio;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Skinning; using osu.Game.Skinning;
@ -253,7 +254,7 @@ namespace osu.Game.Tests.Visual.Gameplay
public Texture GetTexture(string componentName) => throw new NotImplementedException(); public Texture GetTexture(string componentName) => throw new NotImplementedException();
public SampleChannel GetSample(string sampleName) => throw new NotImplementedException(); public SampleChannel GetSample(ISampleInfo sampleInfo) => throw new NotImplementedException();
public TValue GetValue<TConfiguration, TValue>(Func<TConfiguration, TValue> query) where TConfiguration : SkinConfiguration => throw new NotImplementedException(); public TValue GetValue<TConfiguration, TValue>(Func<TConfiguration, TValue> query) where TConfiguration : SkinConfiguration => throw new NotImplementedException();
} }
@ -264,7 +265,7 @@ namespace osu.Game.Tests.Visual.Gameplay
public Texture GetTexture(string componentName) => throw new NotImplementedException(); public Texture GetTexture(string componentName) => throw new NotImplementedException();
public SampleChannel GetSample(string sampleName) => throw new NotImplementedException(); public SampleChannel GetSample(ISampleInfo sampleInfo) => throw new NotImplementedException();
public TValue GetValue<TConfiguration, TValue>(Func<TConfiguration, TValue> query) where TConfiguration : SkinConfiguration => throw new NotImplementedException(); public TValue GetValue<TConfiguration, TValue>(Func<TConfiguration, TValue> query) where TConfiguration : SkinConfiguration => throw new NotImplementedException();
} }
@ -275,7 +276,7 @@ namespace osu.Game.Tests.Visual.Gameplay
public Texture GetTexture(string componentName) => throw new NotImplementedException(); public Texture GetTexture(string componentName) => throw new NotImplementedException();
public SampleChannel GetSample(string sampleName) => throw new NotImplementedException(); public SampleChannel GetSample(ISampleInfo sampleInfo) => throw new NotImplementedException();
public TValue GetValue<TConfiguration, TValue>(Func<TConfiguration, TValue> query) where TConfiguration : SkinConfiguration => throw new NotImplementedException(); public TValue GetValue<TConfiguration, TValue>(Func<TConfiguration, TValue> query) where TConfiguration : SkinConfiguration => throw new NotImplementedException();
} }

View File

@ -135,6 +135,9 @@ namespace osu.Game.Tests.Visual.Online
}); });
downloadAssert(true); downloadAssert(true);
AddStep("show many difficulties", () => overlay.ShowBeatmapSet(createManyDifficultiesBeatmapSet()));
downloadAssert(true);
} }
[Test] [Test]
@ -222,6 +225,56 @@ namespace osu.Game.Tests.Visual.Online
AddStep(@"show without reload", overlay.Show); AddStep(@"show without reload", overlay.Show);
} }
private BeatmapSetInfo createManyDifficultiesBeatmapSet()
{
var beatmaps = new List<BeatmapInfo>();
for (int i = 1; i < 41; i++)
{
beatmaps.Add(new BeatmapInfo
{
OnlineBeatmapID = i * 10,
Version = $"Test #{i}",
Ruleset = Ruleset.Value,
StarDifficulty = 2 + i * 0.1,
BaseDifficulty = new BeatmapDifficulty
{
OverallDifficulty = 3.5f,
},
OnlineInfo = new BeatmapOnlineInfo(),
Metrics = new BeatmapMetrics
{
Fails = Enumerable.Range(1, 100).Select(j => j % 12 - 6).ToArray(),
Retries = Enumerable.Range(-2, 100).Select(j => j % 12 - 6).ToArray(),
},
});
}
return new BeatmapSetInfo
{
OnlineBeatmapSetID = 123,
Metadata = new BeatmapMetadata
{
Title = @"many difficulties beatmap",
Artist = @"none",
Author = new User
{
Username = @"BanchoBot",
Id = 3,
},
},
OnlineInfo = new BeatmapSetOnlineInfo
{
Preview = @"https://b.ppy.sh/preview/123.mp3",
HasVideo = true,
HasStoryboard = true,
Covers = new BeatmapSetOnlineCovers(),
},
Metrics = new BeatmapSetMetrics { Ratings = Enumerable.Range(0, 11).ToArray() },
Beatmaps = beatmaps,
};
}
private void downloadAssert(bool shown) private void downloadAssert(bool shown)
{ {
AddAssert($"is download button {(shown ? "shown" : "hidden")}", () => overlay.DownloadButtonsVisible == shown); AddAssert($"is download button {(shown ? "shown" : "hidden")}", () => overlay.DownloadButtonsVisible == shown);

View File

@ -9,7 +9,6 @@ using osu.Framework.Graphics.Containers;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Overlays.Direct; using osu.Game.Overlays.Direct;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Rulesets.Osu;
using osu.Game.Users; using osu.Game.Users;
using osuTK; using osuTK;
@ -24,7 +23,7 @@ namespace osu.Game.Tests.Visual.Online
typeof(IconPill) typeof(IconPill)
}; };
private BeatmapSetInfo getUndownloadableBeatmapSet(RulesetInfo ruleset) => new BeatmapSetInfo private BeatmapSetInfo getUndownloadableBeatmapSet() => new BeatmapSetInfo
{ {
OnlineBeatmapSetID = 123, OnlineBeatmapSetID = 123,
Metadata = new BeatmapMetadata Metadata = new BeatmapMetadata
@ -56,23 +55,62 @@ namespace osu.Game.Tests.Visual.Online
{ {
new BeatmapInfo new BeatmapInfo
{ {
Ruleset = ruleset, Ruleset = Ruleset.Value,
Version = "Test", Version = "Test",
StarDifficulty = 6.42, StarDifficulty = 6.42,
} }
} }
}; };
[BackgroundDependencyLoader] private BeatmapSetInfo getManyDifficultiesBeatmapSet(RulesetStore rulesets)
private void load()
{ {
var ruleset = new OsuRuleset().RulesetInfo; var beatmaps = new List<BeatmapInfo>();
var normal = CreateWorkingBeatmap(ruleset).BeatmapSetInfo; for (int i = 0; i < 100; i++)
{
beatmaps.Add(new BeatmapInfo
{
Ruleset = rulesets.GetRuleset(i % 4),
StarDifficulty = 2 + i % 4 * 2,
BaseDifficulty = new BeatmapDifficulty
{
OverallDifficulty = 3.5f,
}
});
}
return new BeatmapSetInfo
{
OnlineBeatmapSetID = 1,
Metadata = new BeatmapMetadata
{
Title = "many difficulties beatmap",
Artist = "test",
Author = new User
{
Username = "BanchoBot",
Id = 3,
}
},
OnlineInfo = new BeatmapSetOnlineInfo
{
HasVideo = true,
HasStoryboard = true,
Covers = new BeatmapSetOnlineCovers(),
},
Beatmaps = beatmaps,
};
}
[BackgroundDependencyLoader]
private void load(RulesetStore rulesets)
{
var normal = CreateWorkingBeatmap(Ruleset.Value).BeatmapSetInfo;
normal.OnlineInfo.HasVideo = true; normal.OnlineInfo.HasVideo = true;
normal.OnlineInfo.HasStoryboard = true; normal.OnlineInfo.HasStoryboard = true;
var undownloadable = getUndownloadableBeatmapSet(ruleset); var undownloadable = getUndownloadableBeatmapSet();
var manyDifficulties = getManyDifficultiesBeatmapSet(rulesets);
Child = new BasicScrollContainer Child = new BasicScrollContainer
{ {
@ -81,15 +119,17 @@ namespace osu.Game.Tests.Visual.Online
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical, Direction = FillDirection.Full,
Padding = new MarginPadding(20), Padding = new MarginPadding(20),
Spacing = new Vector2(0, 20), Spacing = new Vector2(5, 20),
Children = new Drawable[] Children = new Drawable[]
{ {
new DirectGridPanel(normal), new DirectGridPanel(normal),
new DirectListPanel(normal),
new DirectGridPanel(undownloadable), new DirectGridPanel(undownloadable),
new DirectGridPanel(manyDifficulties),
new DirectListPanel(normal),
new DirectListPanel(undownloadable), new DirectListPanel(undownloadable),
new DirectListPanel(manyDifficulties),
}, },
}, },
}; };

View File

@ -516,6 +516,7 @@ namespace osu.Game.Tests.Visual.SongSelect
OnlineBeatmapID = b * 10, OnlineBeatmapID = b * 10,
Path = $"extra{b}.osu", Path = $"extra{b}.osu",
Version = $"Extra {b}", Version = $"Extra {b}",
Ruleset = rulesets.GetRuleset((b - 1) % 4),
StarDifficulty = 2, StarDifficulty = 2,
BaseDifficulty = new BeatmapDifficulty BaseDifficulty = new BeatmapDifficulty
{ {

View File

@ -15,6 +15,7 @@ using osu.Framework.MathUtils;
using osu.Framework.Platform; using osu.Framework.Platform;
using osu.Framework.Screens; using osu.Framework.Screens;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Osu;
@ -79,8 +80,12 @@ namespace osu.Game.Tests.Visual.SongSelect
Dependencies.Cache(manager = new BeatmapManager(LocalStorage, ContextFactory, rulesets, null, audio, host, defaultBeatmap = Beatmap.Default)); Dependencies.Cache(manager = new BeatmapManager(LocalStorage, ContextFactory, rulesets, null, audio, host, defaultBeatmap = Beatmap.Default));
Beatmap.SetDefault(); Beatmap.SetDefault();
Dependencies.Cache(config = new OsuConfigManager(LocalStorage));
} }
private OsuConfigManager config;
[SetUp] [SetUp]
public virtual void SetUp() => Schedule(() => public virtual void SetUp() => Schedule(() =>
{ {
@ -111,13 +116,15 @@ namespace osu.Game.Tests.Visual.SongSelect
AddAssert("random map selected", () => songSelect.CurrentBeatmap != defaultBeatmap); AddAssert("random map selected", () => songSelect.CurrentBeatmap != defaultBeatmap);
AddStep(@"Sort by Artist", delegate { songSelect.FilterControl.Sort = SortMode.Artist; }); var sortMode = config.GetBindable<SortMode>(OsuSetting.SongSelectSortingMode);
AddStep(@"Sort by Title", delegate { songSelect.FilterControl.Sort = SortMode.Title; });
AddStep(@"Sort by Author", delegate { songSelect.FilterControl.Sort = SortMode.Author; }); AddStep(@"Sort by Artist", delegate { sortMode.Value = SortMode.Artist; });
AddStep(@"Sort by DateAdded", delegate { songSelect.FilterControl.Sort = SortMode.DateAdded; }); AddStep(@"Sort by Title", delegate { sortMode.Value = SortMode.Title; });
AddStep(@"Sort by BPM", delegate { songSelect.FilterControl.Sort = SortMode.BPM; }); AddStep(@"Sort by Author", delegate { sortMode.Value = SortMode.Author; });
AddStep(@"Sort by Length", delegate { songSelect.FilterControl.Sort = SortMode.Length; }); AddStep(@"Sort by DateAdded", delegate { sortMode.Value = SortMode.DateAdded; });
AddStep(@"Sort by Difficulty", delegate { songSelect.FilterControl.Sort = SortMode.Difficulty; }); AddStep(@"Sort by BPM", delegate { sortMode.Value = SortMode.BPM; });
AddStep(@"Sort by Length", delegate { sortMode.Value = SortMode.Length; });
AddStep(@"Sort by Difficulty", delegate { sortMode.Value = SortMode.Difficulty; });
} }
[Test] [Test]

View File

@ -5,7 +5,7 @@
<PackageReference Include="DeepEqual" Version="2.0.0" /> <PackageReference Include="DeepEqual" Version="2.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="NUnit" Version="3.12.0" /> <PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.14.0" /> <PackageReference Include="NUnit3TestAdapter" Version="3.15.0" />
<PackageReference Update="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" /> <PackageReference Update="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" />
</ItemGroup> </ItemGroup>
<PropertyGroup Label="Project"> <PropertyGroup Label="Project">

View File

@ -7,7 +7,7 @@
<PackageReference Include="Appveyor.TestLogger" Version="2.0.0" /> <PackageReference Include="Appveyor.TestLogger" Version="2.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="NUnit" Version="3.12.0" /> <PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.14.0" /> <PackageReference Include="NUnit3TestAdapter" Version="3.15.0" />
</ItemGroup> </ItemGroup>
<PropertyGroup Label="Project"> <PropertyGroup Label="Project">
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>

View File

@ -138,19 +138,15 @@ namespace osu.Game.Beatmaps
protected override Skin GetSkin() protected override Skin GetSkin()
{ {
Skin skin;
try try
{ {
skin = new LegacyBeatmapSkin(BeatmapInfo, store, AudioManager); return new LegacyBeatmapSkin(BeatmapInfo, store, AudioManager);
} }
catch (Exception e) catch (Exception e)
{ {
Logger.Error(e, "Skin failed to load"); Logger.Error(e, "Skin failed to load");
skin = new DefaultSkin(); return null;
} }
return skin;
} }
} }
} }

View File

@ -19,23 +19,33 @@ using osuTK.Graphics;
namespace osu.Game.Beatmaps.Drawables namespace osu.Game.Beatmaps.Drawables
{ {
public class DifficultyIcon : Container, IHasCustomTooltip public class DifficultyIcon : CompositeDrawable, IHasCustomTooltip
{ {
private readonly BeatmapInfo beatmap; private readonly BeatmapInfo beatmap;
private readonly RulesetInfo ruleset; private readonly RulesetInfo ruleset;
private readonly Container iconContainer;
/// <summary>
/// Size of this difficulty icon.
/// </summary>
public new Vector2 Size
{
get => iconContainer.Size;
set => iconContainer.Size = value;
}
public DifficultyIcon(BeatmapInfo beatmap, RulesetInfo ruleset = null, bool shouldShowTooltip = true) public DifficultyIcon(BeatmapInfo beatmap, RulesetInfo ruleset = null, bool shouldShowTooltip = true)
{ {
if (beatmap == null) this.beatmap = beatmap ?? throw new ArgumentNullException(nameof(beatmap));
throw new ArgumentNullException(nameof(beatmap));
this.beatmap = beatmap;
this.ruleset = ruleset ?? beatmap.Ruleset; this.ruleset = ruleset ?? beatmap.Ruleset;
if (shouldShowTooltip) if (shouldShowTooltip)
TooltipContent = beatmap; TooltipContent = beatmap;
Size = new Vector2(20); AutoSizeAxes = Axes.Both;
InternalChild = iconContainer = new Container { Size = new Vector2(20f) };
} }
public string TooltipText { get; set; } public string TooltipText { get; set; }
@ -47,7 +57,7 @@ namespace osu.Game.Beatmaps.Drawables
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)
{ {
Children = new Drawable[] iconContainer.Children = new Drawable[]
{ {
new CircularContainer new CircularContainer
{ {

View File

@ -0,0 +1,37 @@
// 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.Graphics;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Rulesets;
using osuTK.Graphics;
namespace osu.Game.Beatmaps.Drawables
{
/// <summary>
/// A difficulty icon that contains a counter on the right-side of it.
/// </summary>
/// <remarks>
/// Used in cases when there are too many difficulty icons to show.
/// </remarks>
public class GroupedDifficultyIcon : DifficultyIcon
{
public GroupedDifficultyIcon(List<BeatmapInfo> beatmaps, RulesetInfo ruleset, Color4 counterColour)
: base(beatmaps.OrderBy(b => b.StarDifficulty).Last(), ruleset, false)
{
AddInternal(new OsuSpriteText
{
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
Padding = new MarginPadding { Left = Size.X },
Margin = new MarginPadding { Left = 2, Right = 5 },
Font = OsuFont.GetFont(size: 14, weight: FontWeight.SemiBold),
Text = beatmaps.Count.ToString(),
Colour = counterColour,
});
}
}
}

View File

@ -121,7 +121,7 @@ namespace osu.Game.Beatmaps.Formats
var layer = parseLayer(split[2]); var layer = parseLayer(split[2]);
var path = cleanFilename(split[3]); var path = cleanFilename(split[3]);
var volume = split.Length > 4 ? float.Parse(split[4], CultureInfo.InvariantCulture) : 100; var volume = split.Length > 4 ? float.Parse(split[4], CultureInfo.InvariantCulture) : 100;
storyboard.GetLayer(layer).Add(new StoryboardSample(path, time, volume)); storyboard.GetLayer(layer).Add(new StoryboardSampleInfo(path, time, (int)volume));
break; break;
} }
} }

View File

@ -8,6 +8,7 @@ using osu.Framework.Platform;
using osu.Game.Overlays; using osu.Game.Overlays;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
using osu.Game.Screens.Select; using osu.Game.Screens.Select;
using osu.Game.Screens.Select.Filter;
namespace osu.Game.Configuration namespace osu.Game.Configuration
{ {
@ -25,6 +26,9 @@ namespace osu.Game.Configuration
Set(OsuSetting.DisplayStarsMinimum, 0.0, 0, 10, 0.1); Set(OsuSetting.DisplayStarsMinimum, 0.0, 0, 10, 0.1);
Set(OsuSetting.DisplayStarsMaximum, 10.0, 0, 10, 0.1); Set(OsuSetting.DisplayStarsMaximum, 10.0, 0, 10, 0.1);
Set(OsuSetting.SongSelectGroupingMode, GroupMode.All);
Set(OsuSetting.SongSelectSortingMode, SortMode.Title);
Set(OsuSetting.RandomSelectAlgorithm, RandomSelectAlgorithm.RandomPermutation); Set(OsuSetting.RandomSelectAlgorithm, RandomSelectAlgorithm.RandomPermutation);
Set(OsuSetting.ChatDisplayHeight, ChatOverlay.DEFAULT_HEIGHT, 0.2, 1); Set(OsuSetting.ChatDisplayHeight, ChatOverlay.DEFAULT_HEIGHT, 0.2, 1);
@ -150,6 +154,8 @@ namespace osu.Game.Configuration
SaveUsername, SaveUsername,
DisplayStarsMinimum, DisplayStarsMinimum,
DisplayStarsMaximum, DisplayStarsMaximum,
SongSelectGroupingMode,
SongSelectSortingMode,
RandomSelectAlgorithm, RandomSelectAlgorithm,
ShowFpsDisplay, ShowFpsDisplay,
ChatDisplayHeight, ChatDisplayHeight,

View File

@ -22,7 +22,7 @@ using SixLabors.ImageSharp;
namespace osu.Game.Graphics namespace osu.Game.Graphics
{ {
public class ScreenshotManager : Container, IKeyBindingHandler<GlobalAction>, IHandleGlobalInput public class ScreenshotManager : Container, IKeyBindingHandler<GlobalAction>, IHandleGlobalKeyboardInput
{ {
private readonly BindableBool cursorVisibility = new BindableBool(true); private readonly BindableBool cursorVisibility = new BindableBool(true);

View File

@ -10,7 +10,7 @@ using osu.Framework.Input.Bindings;
namespace osu.Game.Input.Bindings namespace osu.Game.Input.Bindings
{ {
public class GlobalActionContainer : DatabasedKeyBindingContainer<GlobalAction>, IHandleGlobalInput public class GlobalActionContainer : DatabasedKeyBindingContainer<GlobalAction>, IHandleGlobalKeyboardInput
{ {
private readonly Drawable handler; private readonly Drawable handler;

View File

@ -12,7 +12,7 @@ namespace osu.Game.Input
/// <summary> /// <summary>
/// Track whether the end-user is in an idle state, based on their last interaction with the game. /// Track whether the end-user is in an idle state, based on their last interaction with the game.
/// </summary> /// </summary>
public class IdleTracker : Component, IKeyBindingHandler<PlatformAction>, IHandleGlobalInput public class IdleTracker : Component, IKeyBindingHandler<PlatformAction>, IHandleGlobalKeyboardInput
{ {
private readonly double timeToIdle; private readonly double timeToIdle;

View File

@ -91,7 +91,8 @@ namespace osu.Game.Overlays.BeatmapSet
{ {
difficulties = new DifficultiesContainer difficulties = new DifficultiesContainer
{ {
AutoSizeAxes = Axes.Both, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Margin = new MarginPadding { Left = -(tile_icon_padding + tile_spacing / 2) }, Margin = new MarginPadding { Left = -(tile_icon_padding + tile_spacing / 2) },
OnLostHover = () => OnLostHover = () =>
{ {

View File

@ -151,7 +151,7 @@ namespace osu.Game.Overlays.Direct
AutoSizeAxes = Axes.X, AutoSizeAxes = Axes.X,
Height = 20, Height = 20,
Margin = new MarginPadding { Top = vertical_padding, Bottom = vertical_padding }, Margin = new MarginPadding { Top = vertical_padding, Bottom = vertical_padding },
Children = GetDifficultyIcons(), Children = GetDifficultyIcons(colours),
}, },
}, },
}, },

View File

@ -129,7 +129,7 @@ namespace osu.Game.Overlays.Direct
AutoSizeAxes = Axes.X, AutoSizeAxes = Axes.X,
Height = 20, Height = 20,
Margin = new MarginPadding { Top = vertical_padding, Bottom = vertical_padding }, Margin = new MarginPadding { Top = vertical_padding, Bottom = vertical_padding },
Children = GetDifficultyIcons(), Children = GetDifficultyIcons(colours),
}, },
}, },
}, },

View File

@ -28,6 +28,7 @@ namespace osu.Game.Overlays.Direct
public readonly BeatmapSetInfo SetInfo; public readonly BeatmapSetInfo SetInfo;
private const double hover_transition_time = 400; private const double hover_transition_time = 400;
private const int maximum_difficulty_icons = 15;
private Container content; private Container content;
@ -138,12 +139,18 @@ namespace osu.Game.Overlays.Direct
}; };
} }
protected List<DifficultyIcon> GetDifficultyIcons() protected List<DifficultyIcon> GetDifficultyIcons(OsuColour colours)
{ {
var icons = new List<DifficultyIcon>(); var icons = new List<DifficultyIcon>();
foreach (var b in SetInfo.Beatmaps.OrderBy(beatmap => beatmap.StarDifficulty)) if (SetInfo.Beatmaps.Count > maximum_difficulty_icons)
icons.Add(new DifficultyIcon(b)); {
foreach (var ruleset in SetInfo.Beatmaps.Select(b => b.Ruleset).Distinct())
icons.Add(new GroupedDifficultyIcon(SetInfo.Beatmaps.FindAll(b => b.Ruleset.Equals(ruleset)), ruleset, this is DirectListPanel ? Color4.White : colours.Gray5));
}
else
foreach (var b in SetInfo.Beatmaps.OrderBy(beatmap => beatmap.StarDifficulty))
icons.Add(new DifficultyIcon(b));
return icons; return icons;
} }

View File

@ -1,21 +1,22 @@
// 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 System.Collections.Generic;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests; using osu.Game.Online.API.Requests;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays.Direct; using osu.Game.Overlays.Direct;
using osu.Game.Users; using osu.Game.Users;
using osuTK; using osuTK;
namespace osu.Game.Overlays.Profile.Sections.Beatmaps namespace osu.Game.Overlays.Profile.Sections.Beatmaps
{ {
public class PaginatedBeatmapContainer : PaginatedContainer public class PaginatedBeatmapContainer : PaginatedContainer<APIBeatmapSet>
{ {
private const float panel_padding = 10f; private const float panel_padding = 10f;
private readonly BeatmapSetType type; private readonly BeatmapSetType type;
private GetUserBeatmapsRequest request;
public PaginatedBeatmapContainer(BeatmapSetType type, Bindable<User> user, string header, string missing = "None... yet.") public PaginatedBeatmapContainer(BeatmapSetType type, Bindable<User> user, string header, string missing = "None... yet.")
: base(user, header, missing) : base(user, header, missing)
@ -27,40 +28,15 @@ namespace osu.Game.Overlays.Profile.Sections.Beatmaps
ItemsContainer.Spacing = new Vector2(panel_padding); ItemsContainer.Spacing = new Vector2(panel_padding);
} }
protected override void ShowMore() protected override APIRequest<List<APIBeatmapSet>> CreateRequest() =>
{ new GetUserBeatmapsRequest(User.Value.Id, type, VisiblePages++, ItemsPerPage);
request = new GetUserBeatmapsRequest(User.Value.Id, type, VisiblePages++, ItemsPerPage);
request.Success += sets => Schedule(() => protected override Drawable CreateDrawableItem(APIBeatmapSet model) => !model.OnlineBeatmapSetID.HasValue
? null
: new DirectGridPanel(model.ToBeatmapSet(Rulesets))
{ {
MoreButton.FadeTo(sets.Count == ItemsPerPage ? 1 : 0); Anchor = Anchor.TopCentre,
MoreButton.IsLoading = false; Origin = Anchor.TopCentre,
};
if (!sets.Any() && VisiblePages == 1)
{
MissingText.Show();
return;
}
foreach (var s in sets)
{
if (!s.OnlineBeatmapSetID.HasValue)
continue;
ItemsContainer.Add(new DirectGridPanel(s.ToBeatmapSet(Rulesets))
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
});
}
});
Api.Queue(request);
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
request?.Cancel();
}
} }
} }

View File

@ -1,19 +1,19 @@
// 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 System.Collections.Generic;
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.Game.Online.API;
using osu.Game.Online.API.Requests; using osu.Game.Online.API.Requests;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Users; using osu.Game.Users;
namespace osu.Game.Overlays.Profile.Sections.Historical namespace osu.Game.Overlays.Profile.Sections.Historical
{ {
public class PaginatedMostPlayedBeatmapContainer : PaginatedContainer public class PaginatedMostPlayedBeatmapContainer : PaginatedContainer<APIUserMostPlayedBeatmap>
{ {
private GetUserMostPlayedBeatmapsRequest request;
public PaginatedMostPlayedBeatmapContainer(Bindable<User> user) public PaginatedMostPlayedBeatmapContainer(Bindable<User> user)
: base(user, "Most Played Beatmaps", "No records. :(") : base(user, "Most Played Beatmaps", "No records. :(")
{ {
@ -22,35 +22,10 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
ItemsContainer.Direction = FillDirection.Vertical; ItemsContainer.Direction = FillDirection.Vertical;
} }
protected override void ShowMore() protected override APIRequest<List<APIUserMostPlayedBeatmap>> CreateRequest() =>
{ new GetUserMostPlayedBeatmapsRequest(User.Value.Id, VisiblePages++, ItemsPerPage);
request = new GetUserMostPlayedBeatmapsRequest(User.Value.Id, VisiblePages++, ItemsPerPage);
request.Success += beatmaps => Schedule(() =>
{
MoreButton.FadeTo(beatmaps.Count == ItemsPerPage ? 1 : 0);
MoreButton.IsLoading = false;
if (!beatmaps.Any() && VisiblePages == 1) protected override Drawable CreateDrawableItem(APIUserMostPlayedBeatmap model) =>
{ new DrawableMostPlayedBeatmap(model.GetBeatmapInfo(Rulesets), model.PlayCount);
MissingText.Show();
return;
}
MissingText.Hide();
foreach (var beatmap in beatmaps)
{
ItemsContainer.Add(new DrawableMostPlayedBeatmap(beatmap.GetBeatmapInfo(Rulesets), beatmap.PlayCount));
}
});
Api.Queue(request);
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
request?.Cancel();
}
} }
} }

View File

@ -11,22 +11,27 @@ using osu.Game.Graphics.Sprites;
using osu.Game.Online.API; using osu.Game.Online.API;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Users; using osu.Game.Users;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
namespace osu.Game.Overlays.Profile.Sections namespace osu.Game.Overlays.Profile.Sections
{ {
public abstract class PaginatedContainer : FillFlowContainer public abstract class PaginatedContainer<TModel> : FillFlowContainer
{ {
protected readonly FillFlowContainer ItemsContainer; private readonly ShowMoreButton moreButton;
protected readonly ShowMoreButton MoreButton; private readonly OsuSpriteText missingText;
protected readonly OsuSpriteText MissingText; private APIRequest<List<TModel>> retrievalRequest;
private CancellationTokenSource loadCancellation;
[Resolved]
private IAPIProvider api { get; set; }
protected int VisiblePages; protected int VisiblePages;
protected int ItemsPerPage; protected int ItemsPerPage;
protected readonly Bindable<User> User = new Bindable<User>(); protected readonly Bindable<User> User = new Bindable<User>();
protected readonly FillFlowContainer ItemsContainer;
protected IAPIProvider Api;
protected APIRequest RetrievalRequest;
protected RulesetStore Rulesets; protected RulesetStore Rulesets;
protected PaginatedContainer(Bindable<User> user, string header, string missing) protected PaginatedContainer(Bindable<User> user, string header, string missing)
@ -51,15 +56,15 @@ namespace osu.Game.Overlays.Profile.Sections
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Spacing = new Vector2(0, 2), Spacing = new Vector2(0, 2),
}, },
MoreButton = new ShowMoreButton moreButton = new ShowMoreButton
{ {
Anchor = Anchor.TopCentre, Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre, Origin = Anchor.TopCentre,
Alpha = 0, Alpha = 0,
Margin = new MarginPadding { Top = 10 }, Margin = new MarginPadding { Top = 10 },
Action = ShowMore, Action = showMore,
}, },
MissingText = new OsuSpriteText missingText = new OsuSpriteText
{ {
Font = OsuFont.GetFont(size: 15), Font = OsuFont.GetFont(size: 15),
Text = missing, Text = missing,
@ -69,9 +74,8 @@ namespace osu.Game.Overlays.Profile.Sections
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(IAPIProvider api, RulesetStore rulesets) private void load(RulesetStore rulesets)
{ {
Api = api;
Rulesets = rulesets; Rulesets = rulesets;
User.ValueChanged += onUserChanged; User.ValueChanged += onUserChanged;
@ -80,13 +84,54 @@ namespace osu.Game.Overlays.Profile.Sections
private void onUserChanged(ValueChangedEvent<User> e) private void onUserChanged(ValueChangedEvent<User> e)
{ {
loadCancellation?.Cancel();
retrievalRequest?.Cancel();
VisiblePages = 0; VisiblePages = 0;
ItemsContainer.Clear(); ItemsContainer.Clear();
if (e.NewValue != null) if (e.NewValue != null)
ShowMore(); showMore();
} }
protected abstract void ShowMore(); private void showMore()
{
loadCancellation = new CancellationTokenSource();
retrievalRequest = CreateRequest();
retrievalRequest.Success += UpdateItems;
api.Queue(retrievalRequest);
}
protected virtual void UpdateItems(List<TModel> items) => Schedule(() =>
{
if (!items.Any() && VisiblePages == 1)
{
moreButton.Hide();
moreButton.IsLoading = false;
missingText.Show();
return;
}
LoadComponentsAsync(items.Select(CreateDrawableItem).Where(d => d != null), drawables =>
{
missingText.Hide();
moreButton.FadeTo(items.Count == ItemsPerPage ? 1 : 0);
moreButton.IsLoading = false;
ItemsContainer.AddRange(drawables);
}, loadCancellation.Token);
});
protected abstract APIRequest<List<TModel>> CreateRequest();
protected abstract Drawable CreateDrawableItem(TModel model);
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
retrievalRequest?.Cancel();
}
} }
} }

View File

@ -5,18 +5,18 @@ using osu.Framework.Graphics.Containers;
using osu.Game.Online.API.Requests; using osu.Game.Online.API.Requests;
using osu.Game.Users; using osu.Game.Users;
using System; using System;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Online.API.Requests.Responses;
using System.Collections.Generic;
using osu.Game.Online.API;
namespace osu.Game.Overlays.Profile.Sections.Ranks namespace osu.Game.Overlays.Profile.Sections.Ranks
{ {
public class PaginatedScoreContainer : PaginatedContainer public class PaginatedScoreContainer : PaginatedContainer<APILegacyScoreInfo>
{ {
private readonly bool includeWeight; private readonly bool includeWeight;
private readonly ScoreType type; private readonly ScoreType type;
private GetUserScoresRequest request;
public PaginatedScoreContainer(ScoreType type, Bindable<User> user, string header, string missing, bool includeWeight = false) public PaginatedScoreContainer(ScoreType type, Bindable<User> user, string header, string missing, bool includeWeight = false)
: base(user, header, missing) : base(user, header, missing)
@ -29,52 +29,27 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
ItemsContainer.Direction = FillDirection.Vertical; ItemsContainer.Direction = FillDirection.Vertical;
} }
protected override void ShowMore() protected override void UpdateItems(List<APILegacyScoreInfo> items)
{ {
request = new GetUserScoresRequest(User.Value.Id, type, VisiblePages++, ItemsPerPage); foreach (var item in items)
request.Success += scores => Schedule(() => item.Ruleset = Rulesets.GetRuleset(item.RulesetID);
{
foreach (var s in scores)
s.Ruleset = Rulesets.GetRuleset(s.RulesetID);
if (!scores.Any() && VisiblePages == 1) base.UpdateItems(items);
{
MoreButton.Hide();
MoreButton.IsLoading = false;
MissingText.Show();
return;
}
IEnumerable<DrawableProfileScore> drawableScores;
switch (type)
{
default:
drawableScores = scores.Select(score => new DrawablePerformanceScore(score, includeWeight ? Math.Pow(0.95, ItemsContainer.Count) : (double?)null));
break;
case ScoreType.Recent:
drawableScores = scores.Select(score => new DrawableTotalScore(score));
break;
}
LoadComponentsAsync(drawableScores, s =>
{
MissingText.Hide();
MoreButton.FadeTo(scores.Count == ItemsPerPage ? 1 : 0);
MoreButton.IsLoading = false;
ItemsContainer.AddRange(s);
});
});
Api.Queue(request);
} }
protected override void Dispose(bool isDisposing) protected override APIRequest<List<APILegacyScoreInfo>> CreateRequest() =>
new GetUserScoresRequest(User.Value.Id, type, VisiblePages++, ItemsPerPage);
protected override Drawable CreateDrawableItem(APILegacyScoreInfo model)
{ {
base.Dispose(isDisposing); switch (type)
request?.Cancel(); {
default:
return new DrawablePerformanceScore(model, includeWeight ? Math.Pow(0.95, ItemsContainer.Count) : (double?)null);
case ScoreType.Recent:
return new DrawableTotalScore(model);
}
} }
} }
} }

View File

@ -4,51 +4,24 @@
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Online.API.Requests; using osu.Game.Online.API.Requests;
using osu.Game.Users; using osu.Game.Users;
using System.Linq;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
using osu.Game.Online.API;
using System.Collections.Generic;
namespace osu.Game.Overlays.Profile.Sections.Recent namespace osu.Game.Overlays.Profile.Sections.Recent
{ {
public class PaginatedRecentActivityContainer : PaginatedContainer public class PaginatedRecentActivityContainer : PaginatedContainer<APIRecentActivity>
{ {
private GetUserRecentActivitiesRequest request;
public PaginatedRecentActivityContainer(Bindable<User> user, string header, string missing) public PaginatedRecentActivityContainer(Bindable<User> user, string header, string missing)
: base(user, header, missing) : base(user, header, missing)
{ {
ItemsPerPage = 5; ItemsPerPage = 5;
} }
protected override void ShowMore() protected override APIRequest<List<APIRecentActivity>> CreateRequest() =>
{ new GetUserRecentActivitiesRequest(User.Value.Id, VisiblePages++, ItemsPerPage);
request = new GetUserRecentActivitiesRequest(User.Value.Id, VisiblePages++, ItemsPerPage);
request.Success += activities => Schedule(() =>
{
MoreButton.FadeTo(activities.Count == ItemsPerPage ? 1 : 0);
MoreButton.IsLoading = false;
if (!activities.Any() && VisiblePages == 1) protected override Drawable CreateDrawableItem(APIRecentActivity model) => new DrawableRecentActivity(model);
{
MissingText.Show();
return;
}
MissingText.Hide();
foreach (APIRecentActivity activity in activities)
{
ItemsContainer.Add(new DrawableRecentActivity(activity));
}
});
Api.Queue(request);
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
request?.Cancel();
}
} }
} }

View File

@ -124,14 +124,12 @@ namespace osu.Game.Overlays.Profile.Sections
private class ChevronIcon : SpriteIcon private class ChevronIcon : SpriteIcon
{ {
private const int bottom_margin = 2;
private const int icon_size = 8; private const int icon_size = 8;
public ChevronIcon() public ChevronIcon()
{ {
Anchor = Anchor.Centre; Anchor = Anchor.Centre;
Origin = Anchor.Centre; Origin = Anchor.Centre;
Margin = new MarginPadding { Bottom = bottom_margin };
Size = new Vector2(icon_size); Size = new Vector2(icon_size);
Icon = FontAwesome.Solid.ChevronDown; Icon = FontAwesome.Solid.ChevronDown;
} }

View File

@ -65,16 +65,15 @@ namespace osu.Game.Overlays.Volume
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Size = new Vector2(20),
} }
}); });
Current.ValueChanged += muted => Current.BindValueChanged(muted =>
{ {
icon.Icon = muted.NewValue ? FontAwesome.Solid.VolumeMute : FontAwesome.Solid.VolumeUp; icon.Icon = muted.NewValue ? FontAwesome.Solid.VolumeMute : FontAwesome.Solid.VolumeUp;
}; icon.Size = new Vector2(muted.NewValue ? 18 : 20);
icon.Margin = new MarginPadding { Right = muted.NewValue ? 2 : 0 };
Current.TriggerChange(); }, true);
} }
protected override bool OnHover(HoverEvent e) protected override bool OnHover(HoverEvent e)

View File

@ -9,7 +9,7 @@ using osu.Game.Input.Bindings;
namespace osu.Game.Overlays.Volume namespace osu.Game.Overlays.Volume
{ {
public class VolumeControlReceptor : Container, IScrollBindingHandler<GlobalAction>, IHandleGlobalInput public class VolumeControlReceptor : Container, IScrollBindingHandler<GlobalAction>, IHandleGlobalKeyboardInput
{ {
public Func<GlobalAction, bool> ActionRequested; public Func<GlobalAction, bool> ActionRequested;
public Func<GlobalAction, float, bool, bool> ScrollActionRequested; public Func<GlobalAction, float, bool, bool> ScrollActionRequested;

View File

@ -132,6 +132,8 @@ namespace osu.Game.Rulesets.Objects.Drawables
/// </summary> /// </summary>
public event Action<DrawableHitObject, ArmedState> ApplyCustomUpdateState; public event Action<DrawableHitObject, ArmedState> ApplyCustomUpdateState;
#pragma warning disable 618 // (legacy state management) - can be removed 20200227
/// <summary> /// <summary>
/// Enables automatic transform management of this hitobject. Implementation of transforms should be done in <see cref="UpdateInitialTransforms"/> and <see cref="UpdateStateTransforms"/> only. Rewinding and removing previous states is done automatically. /// Enables automatic transform management of this hitobject. Implementation of transforms should be done in <see cref="UpdateInitialTransforms"/> and <see cref="UpdateStateTransforms"/> only. Rewinding and removing previous states is done automatically.
/// </summary> /// </summary>
@ -139,6 +141,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
/// Going forward, this is the preferred way of implementing <see cref="DrawableHitObject"/>s. Previous functionality /// Going forward, this is the preferred way of implementing <see cref="DrawableHitObject"/>s. Previous functionality
/// is offered as a compatibility layer until all rulesets have been migrated across. /// is offered as a compatibility layer until all rulesets have been migrated across.
/// </remarks> /// </remarks>
[Obsolete("Use UpdateInitialTransforms()/UpdateStateTransforms() instead")] // can be removed 20200227
protected virtual bool UseTransformStateManagement => true; protected virtual bool UseTransformStateManagement => true;
protected override void ClearInternal(bool disposeChildren = true) => throw new InvalidOperationException($"Should never clear a {nameof(DrawableHitObject)}"); protected override void ClearInternal(bool disposeChildren = true) => throw new InvalidOperationException($"Should never clear a {nameof(DrawableHitObject)}");
@ -219,10 +222,13 @@ namespace osu.Game.Rulesets.Objects.Drawables
/// Should generally not be used when <see cref="UseTransformStateManagement"/> is true; use <see cref="UpdateStateTransforms"/> instead. /// Should generally not be used when <see cref="UseTransformStateManagement"/> is true; use <see cref="UpdateStateTransforms"/> instead.
/// </summary> /// </summary>
/// <param name="state">The new armed state.</param> /// <param name="state">The new armed state.</param>
[Obsolete("Use UpdateInitialTransforms()/UpdateStateTransforms() instead")] // can be removed 20200227
protected virtual void UpdateState(ArmedState state) protected virtual void UpdateState(ArmedState state)
{ {
} }
#pragma warning restore 618
#endregion #endregion
protected override void SkinChanged(ISkinSource skin, bool allowFallback) protected override void SkinChanged(ISkinSource skin, bool allowFallback)

View File

@ -3,6 +3,7 @@
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Replays; using osu.Game.Replays;
using osu.Game.Rulesets.Objects;
namespace osu.Game.Rulesets.Replays namespace osu.Game.Rulesets.Replays
{ {
@ -34,5 +35,13 @@ namespace osu.Game.Rulesets.Replays
protected const double KEY_UP_DELAY = 50; protected const double KEY_UP_DELAY = 50;
#endregion #endregion
protected virtual HitObject GetNextObject(int currentIndex)
{
if (currentIndex >= Beatmap.HitObjects.Count - 1)
return null;
return Beatmap.HitObjects[currentIndex + 1];
}
} }
} }

View File

@ -32,7 +32,7 @@ namespace osu.Game.Rulesets
public IRulesetConfigManager GetConfigFor(Ruleset ruleset) public IRulesetConfigManager GetConfigFor(Ruleset ruleset)
{ {
if (ruleset.RulesetInfo.ID == null) if (ruleset.RulesetInfo.ID == null)
throw new InvalidOperationException("The provided ruleset doesn't have a valid id."); return null;
return configCache.GetOrAdd(ruleset.RulesetInfo.ID.Value, _ => ruleset.CreateConfig(settingsStore)); return configCache.GetOrAdd(ruleset.RulesetInfo.ID.Value, _ => ruleset.CreateConfig(settingsStore));
} }

View File

@ -62,13 +62,20 @@ namespace osu.Game.Rulesets.UI
public override GameplayClock FrameStableClock => frameStabilityContainer.GameplayClock; public override GameplayClock FrameStableClock => frameStabilityContainer.GameplayClock;
private bool frameStablePlayback = true;
/// <summary> /// <summary>
/// Whether to enable frame-stable playback. /// Whether to enable frame-stable playback.
/// </summary> /// </summary>
internal bool FrameStablePlayback internal bool FrameStablePlayback
{ {
get => frameStabilityContainer.FrameStablePlayback; get => frameStablePlayback;
set => frameStabilityContainer.FrameStablePlayback = value; set
{
frameStablePlayback = false;
if (frameStabilityContainer != null)
frameStabilityContainer.FrameStablePlayback = value;
}
} }
/// <summary> /// <summary>
@ -156,6 +163,7 @@ namespace osu.Game.Rulesets.UI
{ {
frameStabilityContainer = new FrameStabilityContainer(GameplayStartTime) frameStabilityContainer = new FrameStabilityContainer(GameplayStartTime)
{ {
FrameStablePlayback = FrameStablePlayback,
Child = KeyBindingInputManager Child = KeyBindingInputManager
.WithChild(CreatePlayfieldAdjustmentContainer() .WithChild(CreatePlayfieldAdjustmentContainer()
.WithChild(Playfield) .WithChild(Playfield)

View File

@ -12,8 +12,13 @@ namespace osu.Game.Rulesets.UI.Scrolling
{ {
public class ScrollingHitObjectContainer : HitObjectContainer public class ScrollingHitObjectContainer : HitObjectContainer
{ {
private readonly IBindable<double> timeRange = new BindableDouble(); /// <summary>
/// A multiplier applied to the length of the scrolling area to determine a safe default lifetime end for hitobjects.
/// This is only used to limit the lifetime end within reason, as proper lifetime management should be implemented on hitobjects themselves.
/// </summary>
private const float safe_lifetime_end_multiplier = 2;
private readonly IBindable<double> timeRange = new BindableDouble();
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>(); private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
[Resolved] [Resolved]
@ -88,24 +93,29 @@ namespace osu.Game.Rulesets.UI.Scrolling
private void computeInitialStateRecursive(DrawableHitObject hitObject) private void computeInitialStateRecursive(DrawableHitObject hitObject)
{ {
hitObject.LifetimeStart = scrollingInfo.Algorithm.GetDisplayStartTime(hitObject.HitObject.StartTime, timeRange.Value); double endTime = hitObject.HitObject.StartTime;
if (hitObject.HitObject is IHasEndTime endTime) if (hitObject.HitObject is IHasEndTime e)
{ {
endTime = e.EndTime;
switch (direction.Value) switch (direction.Value)
{ {
case ScrollingDirection.Up: case ScrollingDirection.Up:
case ScrollingDirection.Down: case ScrollingDirection.Down:
hitObject.Height = scrollingInfo.Algorithm.GetLength(hitObject.HitObject.StartTime, endTime.EndTime, timeRange.Value, scrollLength); hitObject.Height = scrollingInfo.Algorithm.GetLength(hitObject.HitObject.StartTime, endTime, timeRange.Value, scrollLength);
break; break;
case ScrollingDirection.Left: case ScrollingDirection.Left:
case ScrollingDirection.Right: case ScrollingDirection.Right:
hitObject.Width = scrollingInfo.Algorithm.GetLength(hitObject.HitObject.StartTime, endTime.EndTime, timeRange.Value, scrollLength); hitObject.Width = scrollingInfo.Algorithm.GetLength(hitObject.HitObject.StartTime, endTime, timeRange.Value, scrollLength);
break; break;
} }
} }
hitObject.LifetimeStart = scrollingInfo.Algorithm.GetDisplayStartTime(hitObject.HitObject.StartTime, timeRange.Value);
hitObject.LifetimeEnd = scrollingInfo.Algorithm.TimeAt(scrollLength * safe_lifetime_end_multiplier, endTime, timeRange.Value, scrollLength);
foreach (var obj in hitObject.NestedHitObjects) foreach (var obj in hitObject.NestedHitObjects)
{ {
computeInitialStateRecursive(obj); computeInitialStateRecursive(obj);

View File

@ -138,7 +138,7 @@ namespace osu.Game.Screens.Menu
private RulesetFlow rulesets; private RulesetFlow rulesets;
private Container rulesetsScale; private Container rulesetsScale;
private Drawable logoContainerSecondary; private Container logoContainerSecondary;
private Drawable lazerLogo; private Drawable lazerLogo;
private GlitchingTriangles triangles; private GlitchingTriangles triangles;
@ -158,7 +158,7 @@ namespace osu.Game.Screens.Menu
{ {
this.game = game; this.game = game;
InternalChildren = new[] InternalChildren = new Drawable[]
{ {
triangles = new GlitchingTriangles triangles = new GlitchingTriangles
{ {
@ -277,7 +277,7 @@ namespace osu.Game.Screens.Menu
{ {
lazerLogo.FadeOut().OnComplete(_ => lazerLogo.FadeOut().OnComplete(_ =>
{ {
lazerLogo.Expire(); logoContainerSecondary.Remove(lazerLogo);
lazerLogo.Dispose(); // explicit disposal as we are pushing a new screen and the expire may not get run. lazerLogo.Dispose(); // explicit disposal as we are pushing a new screen and the expire may not get run.
logo.FadeIn(); logo.FadeIn();

View File

@ -19,6 +19,7 @@ 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 osu.Game.Overlays; using osu.Game.Overlays;
using osu.Game.Rulesets;
using osuTK; using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
@ -95,11 +96,11 @@ namespace osu.Game.Screens.Select.Carousel
TextPadding = new MarginPadding { Horizontal = 8, Vertical = 2 }, TextPadding = new MarginPadding { Horizontal = 8, Vertical = 2 },
Status = beatmapSet.Status Status = beatmapSet.Status
}, },
new FillFlowContainer<FilterableDifficultyIcon> new FillFlowContainer<DifficultyIcon>
{ {
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Spacing = new Vector2(3), Spacing = new Vector2(3),
Children = ((CarouselBeatmapSet)Item).Beatmaps.Select(b => new FilterableDifficultyIcon(b)).ToList() ChildrenEnumerable = getDifficultyIcons(),
}, },
} }
} }
@ -108,6 +109,17 @@ namespace osu.Game.Screens.Select.Carousel
}; };
} }
private const int maximum_difficulty_icons = 18;
private IEnumerable<DifficultyIcon> getDifficultyIcons()
{
var beatmaps = ((CarouselBeatmapSet)Item).Beatmaps.ToList();
return beatmaps.Count > maximum_difficulty_icons
? (IEnumerable<DifficultyIcon>)beatmaps.GroupBy(b => b.Beatmap.Ruleset).Select(group => new FilterableGroupedDifficultyIcon(group.ToList(), group.Key))
: beatmaps.Select(b => new FilterableDifficultyIcon(b));
}
public MenuItem[] ContextMenuItems public MenuItem[] ContextMenuItems
{ {
get get
@ -205,5 +217,27 @@ namespace osu.Game.Screens.Select.Carousel
filtered.TriggerChange(); filtered.TriggerChange();
} }
} }
public class FilterableGroupedDifficultyIcon : GroupedDifficultyIcon
{
private readonly List<CarouselBeatmap> items;
public FilterableGroupedDifficultyIcon(List<CarouselBeatmap> items, RulesetInfo ruleset)
: base(items.Select(i => i.Beatmap).ToList(), ruleset, Color4.White)
{
this.items = items;
foreach (var item in items)
item.Filtered.BindValueChanged(_ => Scheduler.AddOnce(updateFilteredDisplay));
updateFilteredDisplay();
}
private void updateFilteredDisplay()
{
// for now, fade the whole group based on the ratio of hidden items.
this.FadeTo(1 - 0.9f * ((float)items.Count(i => i.Filtered.Value) / items.Count), 100);
}
}
} }
} }

View File

@ -29,40 +29,14 @@ namespace osu.Game.Screens.Select
private readonly TabControl<GroupMode> groupTabs; private readonly TabControl<GroupMode> groupTabs;
private SortMode sort = SortMode.Title; private Bindable<SortMode> sortMode;
public SortMode Sort private Bindable<GroupMode> groupMode;
{
get => sort;
set
{
if (sort != value)
{
sort = value;
FilterChanged?.Invoke(CreateCriteria());
}
}
}
private GroupMode group = GroupMode.All;
public GroupMode Group
{
get => group;
set
{
if (group != value)
{
group = value;
FilterChanged?.Invoke(CreateCriteria());
}
}
}
public FilterCriteria CreateCriteria() => new FilterCriteria public FilterCriteria CreateCriteria() => new FilterCriteria
{ {
Group = group, Group = groupMode.Value,
Sort = sort, Sort = sortMode.Value,
SearchText = searchTextBox.Text, SearchText = searchTextBox.Text,
AllowConvertedBeatmaps = showConverted.Value, AllowConvertedBeatmaps = showConverted.Value,
Ruleset = ruleset.Value Ruleset = ruleset.Value
@ -122,7 +96,6 @@ namespace osu.Game.Screens.Select
Height = 24, Height = 24,
Width = 0.5f, Width = 0.5f,
AutoSort = true, AutoSort = true,
Current = { Value = GroupMode.Title }
}, },
//spriteText = new OsuSpriteText //spriteText = new OsuSpriteText
//{ //{
@ -141,7 +114,6 @@ namespace osu.Game.Screens.Select
Width = 0.5f, Width = 0.5f,
Height = 24, Height = 24,
AutoSort = true, AutoSort = true,
Current = { Value = SortMode.Title }
} }
} }
}, },
@ -153,8 +125,6 @@ namespace osu.Game.Screens.Select
groupTabs.PinItem(GroupMode.All); groupTabs.PinItem(GroupMode.All);
groupTabs.PinItem(GroupMode.RecentlyPlayed); groupTabs.PinItem(GroupMode.RecentlyPlayed);
groupTabs.Current.ValueChanged += group => Group = group.NewValue;
sortTabs.Current.ValueChanged += sort => Sort = sort.NewValue;
} }
public void Deactivate() public void Deactivate()
@ -184,7 +154,18 @@ namespace osu.Game.Screens.Select
showConverted.ValueChanged += _ => updateCriteria(); showConverted.ValueChanged += _ => updateCriteria();
ruleset.BindTo(parentRuleset); ruleset.BindTo(parentRuleset);
ruleset.BindValueChanged(_ => updateCriteria(), true); ruleset.BindValueChanged(_ => updateCriteria());
sortMode = config.GetBindable<SortMode>(OsuSetting.SongSelectSortingMode);
groupMode = config.GetBindable<GroupMode>(OsuSetting.SongSelectGroupingMode);
sortTabs.Current.BindTo(sortMode);
groupTabs.Current.BindTo(groupMode);
groupMode.BindValueChanged(_ => updateCriteria());
sortMode.BindValueChanged(_ => updateCriteria());
updateCriteria();
} }
private void updateCriteria() => FilterChanged?.Invoke(CreateCriteria()); private void updateCriteria() => FilterChanged?.Invoke(CreateCriteria());

View File

@ -4,6 +4,7 @@
using osu.Framework.Audio.Sample; using osu.Framework.Audio.Sample;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Textures;
using osu.Game.Audio;
namespace osu.Game.Skinning namespace osu.Game.Skinning
{ {
@ -19,6 +20,6 @@ namespace osu.Game.Skinning
public override Texture GetTexture(string componentName) => null; public override Texture GetTexture(string componentName) => null;
public override SampleChannel GetSample(string sampleName) => null; public override SampleChannel GetSample(ISampleInfo sampleInfo) => null;
} }
} }

View File

@ -5,6 +5,7 @@ using System;
using osu.Framework.Audio.Sample; using osu.Framework.Audio.Sample;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Textures;
using osu.Game.Audio;
namespace osu.Game.Skinning namespace osu.Game.Skinning
{ {
@ -17,7 +18,7 @@ namespace osu.Game.Skinning
Texture GetTexture(string componentName); Texture GetTexture(string componentName);
SampleChannel GetSample(string sampleName); SampleChannel GetSample(ISampleInfo sampleInfo);
TValue GetValue<TConfiguration, TValue>(Func<TConfiguration, TValue> query) where TConfiguration : SkinConfiguration; TValue GetValue<TConfiguration, TValue>(Func<TConfiguration, TValue> query) where TConfiguration : SkinConfiguration;
} }

View File

@ -17,6 +17,7 @@ using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Textures;
using osu.Framework.IO.Stores; using osu.Framework.IO.Stores;
using osu.Framework.Text; using osu.Framework.Text;
using osu.Game.Audio;
using osu.Game.Database; using osu.Game.Database;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
@ -160,6 +161,50 @@ namespace osu.Game.Skinning
return getAnimation(componentName, animatable, looping); return getAnimation(componentName, animatable, looping);
} }
public override Texture GetTexture(string componentName)
{
componentName = getFallbackName(componentName);
float ratio = 2;
var texture = Textures.Get($"{componentName}@2x");
if (texture == null)
{
ratio = 1;
texture = Textures.Get(componentName);
}
if (texture != null)
texture.ScaleAdjust = ratio;
return texture;
}
public override SampleChannel GetSample(ISampleInfo sampleInfo)
{
foreach (var lookup in sampleInfo.LookupNames)
{
var sample = Samples.Get(getFallbackName(lookup));
if (sample != null)
return sample;
}
if (sampleInfo is HitSampleInfo hsi)
// Try fallback to non-bank samples.
return Samples.Get(hsi.Name);
return null;
}
private bool hasFont(string fontName) => GetTexture($"{fontName}-0") != null;
private string getFallbackName(string componentName)
{
string lastPiece = componentName.Split('/').Last();
return componentName.StartsWith("Gameplay/taiko/") ? "taiko-" + lastPiece : lastPiece;
}
private Drawable getAnimation(string componentName, bool animatable, bool looping, string animationSeparator = "-") private Drawable getAnimation(string componentName, bool animatable, bool looping, string animationSeparator = "-")
{ {
Texture texture; Texture texture;
@ -195,27 +240,6 @@ namespace osu.Game.Skinning
return null; return null;
} }
public override Texture GetTexture(string componentName)
{
float ratio = 2;
var texture = Textures.Get($"{componentName}@2x");
if (texture == null)
{
ratio = 1;
texture = Textures.Get(componentName);
}
if (texture != null)
texture.ScaleAdjust = ratio;
return texture;
}
public override SampleChannel GetSample(string sampleName) => Samples.Get(sampleName);
private bool hasFont(string fontName) => GetTexture($"{fontName}-0") != null;
protected class LegacySkinResourceStore<T> : IResourceStore<byte[]> protected class LegacySkinResourceStore<T> : IResourceStore<byte[]>
where T : INamedFileInfo where T : INamedFileInfo
{ {
@ -226,11 +250,8 @@ namespace osu.Game.Skinning
{ {
bool hasExtension = filename.Contains('.'); bool hasExtension = filename.Contains('.');
string lastPiece = filename.Split('/').Last();
var legacyName = filename.StartsWith("Gameplay/taiko/") ? "taiko-" + lastPiece : lastPiece;
var file = source.Files.Find(f => var file = source.Files.Find(f =>
string.Equals(hasExtension ? f.Filename : Path.ChangeExtension(f.Filename, null), legacyName, StringComparison.InvariantCultureIgnoreCase)); string.Equals(hasExtension ? f.Filename : Path.ChangeExtension(f.Filename, null), filename, StringComparison.InvariantCultureIgnoreCase));
return file?.FileInfo.StoragePath; return file?.FileInfo.StoragePath;
} }

View File

@ -8,6 +8,7 @@ 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.Textures; using osu.Framework.Graphics.Textures;
using osu.Game.Audio;
using osu.Game.Configuration; using osu.Game.Configuration;
namespace osu.Game.Skinning namespace osu.Game.Skinning
@ -49,13 +50,13 @@ namespace osu.Game.Skinning
return fallbackSource.GetTexture(componentName); return fallbackSource.GetTexture(componentName);
} }
public SampleChannel GetSample(string sampleName) public SampleChannel GetSample(ISampleInfo sampleInfo)
{ {
SampleChannel sourceChannel; SampleChannel sourceChannel;
if (beatmapHitsounds.Value && (sourceChannel = skin?.GetSample(sampleName)) != null) if (beatmapHitsounds.Value && (sourceChannel = skin?.GetSample(sampleInfo)) != null)
return sourceChannel; return sourceChannel;
return fallbackSource?.GetSample(sampleName); return fallbackSource?.GetSample(sampleInfo);
} }
public TValue GetValue<TConfiguration, TValue>(Func<TConfiguration, TValue> query) where TConfiguration : SkinConfiguration public TValue GetValue<TConfiguration, TValue>(Func<TConfiguration, TValue> query) where TConfiguration : SkinConfiguration

View File

@ -5,6 +5,7 @@ using System;
using osu.Framework.Audio.Sample; using osu.Framework.Audio.Sample;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Textures;
using osu.Game.Audio;
namespace osu.Game.Skinning namespace osu.Game.Skinning
{ {
@ -16,7 +17,7 @@ namespace osu.Game.Skinning
public abstract Drawable GetDrawableComponent(string componentName); public abstract Drawable GetDrawableComponent(string componentName);
public abstract SampleChannel GetSample(string sampleName); public abstract SampleChannel GetSample(ISampleInfo sampleInfo);
public abstract Texture GetTexture(string componentName); public abstract Texture GetTexture(string componentName);

View File

@ -15,6 +15,7 @@ using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Textures;
using osu.Framework.Platform; using osu.Framework.Platform;
using osu.Game.Audio;
using osu.Game.Database; using osu.Game.Database;
using osu.Game.IO.Archives; using osu.Game.IO.Archives;
@ -120,7 +121,7 @@ namespace osu.Game.Skinning
public Texture GetTexture(string componentName) => CurrentSkin.Value.GetTexture(componentName); public Texture GetTexture(string componentName) => CurrentSkin.Value.GetTexture(componentName);
public SampleChannel GetSample(string sampleName) => CurrentSkin.Value.GetSample(sampleName); public SampleChannel GetSample(ISampleInfo sampleInfo) => CurrentSkin.Value.GetSample(sampleInfo);
public TValue GetValue<TConfiguration, TValue>(Func<TConfiguration, TValue> query) where TConfiguration : SkinConfiguration => CurrentSkin.Value.GetValue(query); public TValue GetValue<TConfiguration, TValue>(Func<TConfiguration, TValue> query) where TConfiguration : SkinConfiguration => CurrentSkin.Value.GetValue(query);
} }

View File

@ -1,7 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
@ -37,34 +36,26 @@ namespace osu.Game.Skinning
public void Play() => channels?.ForEach(c => c.Play()); public void Play() => channels?.ForEach(c => c.Play());
public override bool IsPresent => false; // We don't need to receive updates. public override bool IsPresent => Scheduler.HasPendingTasks;
protected override void SkinChanged(ISkinSource skin, bool allowFallback) protected override void SkinChanged(ISkinSource skin, bool allowFallback)
{ {
channels = hitSamples.Select(s => channels = hitSamples.Select(s =>
{ {
var ch = loadChannel(s, skin.GetSample); var ch = skin.GetSample(s);
if (ch == null && allowFallback) if (ch == null && allowFallback)
ch = loadChannel(s, audio.Samples.Get); foreach (var lookup in s.LookupNames)
if ((ch = audio.Samples.Get($"Gameplay/{lookup}")) != null)
break;
if (ch != null)
ch.Volume.Value = s.Volume / 100.0;
return ch; return ch;
}).Where(c => c != null).ToArray(); }).Where(c => c != null).ToArray();
} }
private SampleChannel loadChannel(ISampleInfo info, Func<string, SampleChannel> getSampleFunction)
{
foreach (var lookup in info.LookupNames)
{
var ch = getSampleFunction($"Gameplay/{lookup}");
if (ch == null)
continue;
ch.Volume.Value = info.Volume / 100.0;
return ch;
}
return null;
}
protected override void Dispose(bool isDisposing) protected override void Dispose(bool isDisposing)
{ {
base.Dispose(isDisposing); base.Dispose(isDisposing);

View File

@ -1,7 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System.IO;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Audio.Sample; using osu.Framework.Audio.Sample;
using osu.Framework.Bindables; using osu.Framework.Bindables;
@ -17,25 +16,24 @@ namespace osu.Game.Storyboards.Drawables
/// </summary> /// </summary>
private const double allowable_late_start = 100; private const double allowable_late_start = 100;
private readonly StoryboardSample sample; private readonly StoryboardSampleInfo sampleInfo;
private SampleChannel channel; private SampleChannel channel;
public override bool RemoveWhenNotAlive => false; public override bool RemoveWhenNotAlive => false;
public DrawableStoryboardSample(StoryboardSample sample) public DrawableStoryboardSample(StoryboardSampleInfo sampleInfo)
{ {
this.sample = sample; this.sampleInfo = sampleInfo;
LifetimeStart = sample.StartTime; LifetimeStart = sampleInfo.StartTime;
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(IBindable<WorkingBeatmap> beatmap) private void load(IBindable<WorkingBeatmap> beatmap)
{ {
// Try first with the full name, then attempt with no path channel = beatmap.Value.Skin.GetSample(sampleInfo);
channel = beatmap.Value.Skin.GetSample(sample.Path) ?? beatmap.Value.Skin.GetSample(Path.ChangeExtension(sample.Path, null));
if (channel != null) if (channel != null)
channel.Volume.Value = sample.Volume / 100; channel.Volume.Value = sampleInfo.Volume / 100.0;
} }
protected override void Update() protected override void Update()
@ -43,27 +41,27 @@ namespace osu.Game.Storyboards.Drawables
base.Update(); base.Update();
// TODO: this logic will need to be consolidated with other game samples like hit sounds. // TODO: this logic will need to be consolidated with other game samples like hit sounds.
if (Time.Current < sample.StartTime) if (Time.Current < sampleInfo.StartTime)
{ {
// We've rewound before the start time of the sample // We've rewound before the start time of the sample
channel?.Stop(); channel?.Stop();
// In the case that the user fast-forwards to a point far beyond the start time of the sample, // In the case that the user fast-forwards to a point far beyond the start time of the sample,
// we want to be able to fall into the if-conditional below (therefore we must not have a life time end) // we want to be able to fall into the if-conditional below (therefore we must not have a life time end)
LifetimeStart = sample.StartTime; LifetimeStart = sampleInfo.StartTime;
LifetimeEnd = double.MaxValue; LifetimeEnd = double.MaxValue;
} }
else if (Time.Current - Time.Elapsed < sample.StartTime) else if (Time.Current - Time.Elapsed < sampleInfo.StartTime)
{ {
// We've passed the start time of the sample. We only play the sample if we're within an allowable range // We've passed the start time of the sample. We only play the sample if we're within an allowable range
// from the sample's start, to reduce layering if we've been fast-forwarded far into the future // from the sample's start, to reduce layering if we've been fast-forwarded far into the future
if (Time.Current - sample.StartTime < allowable_late_start) if (Time.Current - sampleInfo.StartTime < allowable_late_start)
channel?.Play(); channel?.Play();
// In the case that the user rewinds to a point far behind the start time of the sample, // In the case that the user rewinds to a point far behind the start time of the sample,
// we want to be able to fall into the if-conditional above (therefore we must not have a life time start) // we want to be able to fall into the if-conditional above (therefore we must not have a life time start)
LifetimeStart = double.MinValue; LifetimeStart = double.MinValue;
LifetimeEnd = sample.StartTime; LifetimeEnd = sampleInfo.StartTime;
} }
} }
} }

View File

@ -1,21 +1,30 @@
// 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 osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Audio;
using osu.Game.Storyboards.Drawables; using osu.Game.Storyboards.Drawables;
namespace osu.Game.Storyboards namespace osu.Game.Storyboards
{ {
public class StoryboardSample : IStoryboardElement public class StoryboardSampleInfo : IStoryboardElement, ISampleInfo
{ {
public string Path { get; set; } public string Path { get; }
public bool IsDrawable => true; public bool IsDrawable => true;
public double StartTime { get; } public double StartTime { get; }
public float Volume; public int Volume { get; }
public StoryboardSample(string path, double time, float volume) public IEnumerable<string> LookupNames => new[]
{
// Try first with the full name, then attempt with no path
Path,
System.IO.Path.ChangeExtension(Path, null),
};
public StoryboardSampleInfo(string path, double time, int volume)
{ {
Path = path; Path = path;
StartTime = time; StartTime = time;

View File

@ -14,8 +14,8 @@
<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.2" /> <PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.809.0" /> <PackageReference Include="ppy.osu.Game.Resources" Version="2019.823.0" />
<PackageReference Include="ppy.osu.Framework" Version="2019.821.0" /> <PackageReference Include="ppy.osu.Framework" Version="2019.828.0" />
<PackageReference Include="SharpCompress" Version="0.24.0" /> <PackageReference Include="SharpCompress" Version="0.24.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" />

View File

@ -117,9 +117,9 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.1" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.1" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.1" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" /> <PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.809.0" /> <PackageReference Include="ppy.osu.Game.Resources" Version="2019.823.0" />
<PackageReference Include="ppy.osu.Framework" Version="2019.821.0" /> <PackageReference Include="ppy.osu.Framework" Version="2019.828.0" />
<PackageReference Include="ppy.osu.Framework.iOS" Version="2019.821.0" /> <PackageReference Include="ppy.osu.Framework.iOS" Version="2019.828.0" />
<PackageReference Include="SharpCompress" Version="0.24.0" /> <PackageReference Include="SharpCompress" Version="0.24.0" />
<PackageReference Include="NUnit" Version="3.11.0" /> <PackageReference Include="NUnit" Version="3.11.0" />
<PackageReference Include="SharpRaven" Version="2.4.0" /> <PackageReference Include="SharpRaven" Version="2.4.0" />