Merge branch 'master' into merge-global-to-legacy
@ -51,7 +51,7 @@
|
||||
<Reference Include="Java.Interop" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.727.1" />
|
||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2020.723.0" />
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.731.0" />
|
||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2020.730.1" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
@ -1,6 +1,8 @@
|
||||
// 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 osu.Game.Audio;
|
||||
using osu.Game.Rulesets.Catch.Judgements;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
|
||||
@ -8,8 +10,27 @@ namespace osu.Game.Rulesets.Catch.Objects
|
||||
{
|
||||
public class Banana : Fruit
|
||||
{
|
||||
/// <summary>
|
||||
/// Index of banana in current shower.
|
||||
/// </summary>
|
||||
public int BananaIndex;
|
||||
|
||||
public override FruitVisualRepresentation VisualRepresentation => FruitVisualRepresentation.Banana;
|
||||
|
||||
public override Judgement CreateJudgement() => new CatchBananaJudgement();
|
||||
|
||||
private static readonly List<HitSampleInfo> samples = new List<HitSampleInfo> { new BananaHitSampleInfo() };
|
||||
|
||||
public Banana()
|
||||
{
|
||||
Samples = samples;
|
||||
}
|
||||
|
||||
private class BananaHitSampleInfo : HitSampleInfo
|
||||
{
|
||||
private static string[] lookupNames { get; } = { "metronomelow", "catch-banana" };
|
||||
|
||||
public override IEnumerable<string> LookupNames => lookupNames;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,15 +30,21 @@ namespace osu.Game.Rulesets.Catch.Objects
|
||||
if (spacing <= 0)
|
||||
return;
|
||||
|
||||
for (double i = StartTime; i <= EndTime; i += spacing)
|
||||
double time = StartTime;
|
||||
int i = 0;
|
||||
|
||||
while (time <= EndTime)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
AddNested(new Banana
|
||||
{
|
||||
Samples = Samples,
|
||||
StartTime = i
|
||||
StartTime = time,
|
||||
BananaIndex = i,
|
||||
});
|
||||
|
||||
time += spacing;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,6 +40,13 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
||||
float getRandomAngle() => 180 * (RNG.NextSingle() * 2 - 1);
|
||||
}
|
||||
|
||||
public override void PlaySamples()
|
||||
{
|
||||
base.PlaySamples();
|
||||
if (Samples != null)
|
||||
Samples.Frequency.Value = 0.77f + ((Banana)HitObject).BananaIndex * 0.006f;
|
||||
}
|
||||
|
||||
private Color4 getBananaColour()
|
||||
{
|
||||
switch (RNG.Next(0, 3))
|
||||
|
@ -1,23 +1,27 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Pooling;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Mania.Judgements;
|
||||
using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces;
|
||||
using osu.Game.Rulesets.Mania.UI;
|
||||
using osu.Game.Skinning;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Tests.Skinning
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestSceneHitExplosion : ManiaSkinnableTestScene
|
||||
{
|
||||
private readonly List<DrawablePool<PoolableHitExplosion>> hitExplosionPools = new List<DrawablePool<PoolableHitExplosion>>();
|
||||
|
||||
public TestSceneHitExplosion()
|
||||
{
|
||||
int runcount = 0;
|
||||
@ -29,28 +33,40 @@ namespace osu.Game.Rulesets.Mania.Tests.Skinning
|
||||
if (runcount % 15 > 12)
|
||||
return;
|
||||
|
||||
CreatedDrawables.OfType<Container>().ForEach(c =>
|
||||
int poolIndex = 0;
|
||||
|
||||
foreach (var c in CreatedDrawables.OfType<Container>())
|
||||
{
|
||||
c.Add(new SkinnableDrawable(new ManiaSkinComponent(ManiaSkinComponents.HitExplosion, 0),
|
||||
_ => new DefaultHitExplosion((runcount / 15) % 2 == 0 ? new Color4(94, 0, 57, 255) : new Color4(6, 84, 0, 255), runcount % 6 != 0)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
}));
|
||||
});
|
||||
c.Add(hitExplosionPools[poolIndex].Get(e =>
|
||||
{
|
||||
e.Apply(new JudgementResult(new HitObject(), runcount % 6 == 0 ? new HoldNoteTickJudgement() : new ManiaJudgement()));
|
||||
|
||||
e.Anchor = Anchor.Centre;
|
||||
e.Origin = Anchor.Centre;
|
||||
}));
|
||||
|
||||
poolIndex++;
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
SetContents(() => new ColumnTestContainer(0, ManiaAction.Key1)
|
||||
SetContents(() =>
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativePositionAxes = Axes.Y,
|
||||
Y = -0.25f,
|
||||
Size = new Vector2(Column.COLUMN_WIDTH, DefaultNotePiece.NOTE_HEIGHT),
|
||||
var pool = new DrawablePool<PoolableHitExplosion>(5);
|
||||
hitExplosionPools.Add(pool);
|
||||
|
||||
return new ColumnTestContainer(0, ManiaAction.Key1)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativePositionAxes = Axes.Y,
|
||||
Y = -0.25f,
|
||||
Size = new Vector2(Column.COLUMN_WIDTH, DefaultNotePiece.NOTE_HEIGHT),
|
||||
Child = pool
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -6,13 +6,15 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Animations;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Mania.UI;
|
||||
using osu.Game.Rulesets.UI.Scrolling;
|
||||
using osu.Game.Skinning;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Skinning
|
||||
{
|
||||
public class LegacyHitExplosion : LegacyManiaColumnElement
|
||||
public class LegacyHitExplosion : LegacyManiaColumnElement, IHitExplosion
|
||||
{
|
||||
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
|
||||
|
||||
@ -62,9 +64,9 @@ namespace osu.Game.Rulesets.Mania.Skinning
|
||||
explosion.Anchor = direction.NewValue == ScrollingDirection.Up ? Anchor.TopCentre : Anchor.BottomCentre;
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
public void Animate(JudgementResult result)
|
||||
{
|
||||
base.LoadComplete();
|
||||
(explosion as IFramedAnimation)?.GotoFrame(0);
|
||||
|
||||
explosion?.FadeInFromZero(80)
|
||||
.Then().FadeOut(120);
|
||||
|
@ -9,9 +9,9 @@ using osu.Game.Graphics;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics.Pooling;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Mania.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Mania.UI.Components;
|
||||
using osu.Game.Rulesets.UI.Scrolling;
|
||||
using osu.Game.Skinning;
|
||||
@ -34,8 +34,8 @@ namespace osu.Game.Rulesets.Mania.UI
|
||||
public readonly Bindable<ManiaAction> Action = new Bindable<ManiaAction>();
|
||||
|
||||
public readonly ColumnHitObjectArea HitObjectArea;
|
||||
|
||||
internal readonly Container TopLevelContainer;
|
||||
private readonly DrawablePool<PoolableHitExplosion> hitExplosionPool;
|
||||
|
||||
public Container UnderlayElements => HitObjectArea.UnderlayElements;
|
||||
|
||||
@ -53,6 +53,7 @@ namespace osu.Game.Rulesets.Mania.UI
|
||||
|
||||
InternalChildren = new[]
|
||||
{
|
||||
hitExplosionPool = new DrawablePool<PoolableHitExplosion>(5),
|
||||
// For input purposes, the background is added at the highest depth, but is then proxied back below all other elements
|
||||
background.CreateProxy(),
|
||||
HitObjectArea = new ColumnHitObjectArea(Index, HitObjectContainer) { RelativeSizeAxes = Axes.Both },
|
||||
@ -108,15 +109,7 @@ namespace osu.Game.Rulesets.Mania.UI
|
||||
if (!result.IsHit || !judgedObject.DisplayResult || !DisplayJudgements.Value)
|
||||
return;
|
||||
|
||||
var explosion = new SkinnableDrawable(new ManiaSkinComponent(ManiaSkinComponents.HitExplosion, Index), _ =>
|
||||
new DefaultHitExplosion(judgedObject.AccentColour.Value, judgedObject is DrawableHoldNoteTick))
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both
|
||||
};
|
||||
|
||||
HitObjectArea.Explosions.Add(explosion);
|
||||
|
||||
explosion.Delay(200).Expire(true);
|
||||
HitObjectArea.Explosions.Add(hitExplosionPool.Get(e => e.Apply(result)));
|
||||
}
|
||||
|
||||
public bool OnPressed(ManiaAction action)
|
||||
|
@ -8,6 +8,8 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Effects;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Mania.Judgements;
|
||||
using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces;
|
||||
using osu.Game.Rulesets.UI.Scrolling;
|
||||
using osuTK;
|
||||
@ -15,35 +17,36 @@ using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.UI
|
||||
{
|
||||
public class DefaultHitExplosion : CompositeDrawable
|
||||
public class DefaultHitExplosion : CompositeDrawable, IHitExplosion
|
||||
{
|
||||
private const float default_large_faint_size = 0.8f;
|
||||
|
||||
public override bool RemoveWhenNotAlive => true;
|
||||
|
||||
[Resolved]
|
||||
private Column column { get; set; }
|
||||
|
||||
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
|
||||
|
||||
private readonly CircularContainer largeFaint;
|
||||
private readonly CircularContainer mainGlow1;
|
||||
private CircularContainer largeFaint;
|
||||
private CircularContainer mainGlow1;
|
||||
|
||||
public DefaultHitExplosion(Color4 objectColour, bool isSmall = false)
|
||||
public DefaultHitExplosion()
|
||||
{
|
||||
Origin = Anchor.Centre;
|
||||
|
||||
RelativeSizeAxes = Axes.X;
|
||||
Height = DefaultNotePiece.NOTE_HEIGHT;
|
||||
}
|
||||
|
||||
// scale roughly in-line with visual appearance of notes
|
||||
Scale = new Vector2(1f, 0.6f);
|
||||
|
||||
if (isSmall)
|
||||
Scale *= 0.5f;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(IScrollingInfo scrollingInfo)
|
||||
{
|
||||
const float angle_variangle = 15; // should be less than 45
|
||||
|
||||
const float roundness = 80;
|
||||
|
||||
const float initial_height = 10;
|
||||
|
||||
var colour = Interpolation.ValueAt(0.4f, objectColour, Color4.White, 0, 1);
|
||||
var colour = Interpolation.ValueAt(0.4f, column.AccentColour, Color4.White, 0, 1);
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
@ -54,12 +57,12 @@ namespace osu.Game.Rulesets.Mania.UI
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Masking = true,
|
||||
// we want our size to be very small so the glow dominates it.
|
||||
Size = new Vector2(0.8f),
|
||||
Size = new Vector2(default_large_faint_size),
|
||||
Blending = BlendingParameters.Additive,
|
||||
EdgeEffect = new EdgeEffectParameters
|
||||
{
|
||||
Type = EdgeEffectType.Glow,
|
||||
Colour = Interpolation.ValueAt(0.1f, objectColour, Color4.White, 0, 1).Opacity(0.3f),
|
||||
Colour = Interpolation.ValueAt(0.1f, column.AccentColour, Color4.White, 0, 1).Opacity(0.3f),
|
||||
Roundness = 160,
|
||||
Radius = 200,
|
||||
},
|
||||
@ -74,7 +77,7 @@ namespace osu.Game.Rulesets.Mania.UI
|
||||
EdgeEffect = new EdgeEffectParameters
|
||||
{
|
||||
Type = EdgeEffectType.Glow,
|
||||
Colour = Interpolation.ValueAt(0.6f, objectColour, Color4.White, 0, 1),
|
||||
Colour = Interpolation.ValueAt(0.6f, column.AccentColour, Color4.White, 0, 1),
|
||||
Roundness = 20,
|
||||
Radius = 50,
|
||||
},
|
||||
@ -114,30 +117,11 @@ namespace osu.Game.Rulesets.Mania.UI
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(IScrollingInfo scrollingInfo)
|
||||
{
|
||||
direction.BindTo(scrollingInfo.Direction);
|
||||
direction.BindValueChanged(onDirectionChanged, true);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
const double duration = 200;
|
||||
|
||||
base.LoadComplete();
|
||||
|
||||
largeFaint
|
||||
.ResizeTo(largeFaint.Size * new Vector2(5, 1), duration, Easing.OutQuint)
|
||||
.FadeOut(duration * 2);
|
||||
|
||||
mainGlow1.ScaleTo(1.4f, duration, Easing.OutQuint);
|
||||
|
||||
this.FadeOut(duration, Easing.Out);
|
||||
}
|
||||
|
||||
private void onDirectionChanged(ValueChangedEvent<ScrollingDirection> direction)
|
||||
{
|
||||
if (direction.NewValue == ScrollingDirection.Up)
|
||||
@ -151,5 +135,29 @@ namespace osu.Game.Rulesets.Mania.UI
|
||||
Y = -DefaultNotePiece.NOTE_HEIGHT / 2;
|
||||
}
|
||||
}
|
||||
|
||||
public void Animate(JudgementResult result)
|
||||
{
|
||||
// scale roughly in-line with visual appearance of notes
|
||||
Vector2 scale = new Vector2(1, 0.6f);
|
||||
|
||||
if (result.Judgement is HoldNoteTickJudgement)
|
||||
scale *= 0.5f;
|
||||
|
||||
this.ScaleTo(scale);
|
||||
|
||||
largeFaint
|
||||
.ResizeTo(default_large_faint_size)
|
||||
.Then()
|
||||
.ResizeTo(default_large_faint_size * new Vector2(5, 1), PoolableHitExplosion.DURATION, Easing.OutQuint)
|
||||
.FadeOut(PoolableHitExplosion.DURATION * 2);
|
||||
|
||||
mainGlow1
|
||||
.ScaleTo(1)
|
||||
.Then()
|
||||
.ScaleTo(1.4f, PoolableHitExplosion.DURATION, Easing.OutQuint);
|
||||
|
||||
this.FadeOutFromOne(PoolableHitExplosion.DURATION, Easing.Out);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
19
osu.Game.Rulesets.Mania/UI/IHitExplosion.cs
Normal file
@ -0,0 +1,19 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.UI
|
||||
{
|
||||
/// <summary>
|
||||
/// Common interface for all hit explosion bodies.
|
||||
/// </summary>
|
||||
public interface IHitExplosion
|
||||
{
|
||||
/// <summary>
|
||||
/// Begins animating this <see cref="IHitExplosion"/>.
|
||||
/// </summary>
|
||||
/// <param name="result">The type of <see cref="JudgementResult"/> that caused this explosion.</param>
|
||||
void Animate(JudgementResult result);
|
||||
}
|
||||
}
|
51
osu.Game.Rulesets.Mania/UI/PoolableHitExplosion.cs
Normal file
@ -0,0 +1,51 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Pooling;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Skinning;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.UI
|
||||
{
|
||||
public class PoolableHitExplosion : PoolableDrawable
|
||||
{
|
||||
public const double DURATION = 200;
|
||||
|
||||
public JudgementResult Result { get; private set; }
|
||||
|
||||
[Resolved]
|
||||
private Column column { get; set; }
|
||||
|
||||
private SkinnableDrawable skinnableExplosion;
|
||||
|
||||
public PoolableHitExplosion()
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
InternalChild = skinnableExplosion = new SkinnableDrawable(new ManiaSkinComponent(ManiaSkinComponents.HitExplosion, column.Index), _ => new DefaultHitExplosion())
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both
|
||||
};
|
||||
}
|
||||
|
||||
public void Apply(JudgementResult result)
|
||||
{
|
||||
Result = result;
|
||||
}
|
||||
|
||||
protected override void PrepareForUse()
|
||||
{
|
||||
base.PrepareForUse();
|
||||
|
||||
(skinnableExplosion?.Drawable as IHitExplosion)?.Animate(Result);
|
||||
|
||||
this.Delay(DURATION).Then().Expire();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,12 +1,27 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Tests.Visual;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Tests
|
||||
{
|
||||
public abstract class OsuSkinnableTestScene : SkinnableTestScene
|
||||
{
|
||||
private Container content;
|
||||
|
||||
protected override Container<Drawable> Content
|
||||
{
|
||||
get
|
||||
{
|
||||
if (content == null)
|
||||
base.Content.Add(content = new OsuInputManager(new RulesetInfo { ID = 0 }));
|
||||
|
||||
return content;
|
||||
}
|
||||
}
|
||||
|
||||
protected override Ruleset CreateRulesetForSkinProvider() => new OsuRuleset();
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 45 KiB |
After Width: | Height: | Size: 162 KiB |
BIN
osu.Game.Rulesets.Osu.Tests/Resources/old-skin/spinner-clear.png
Normal file
After Width: | Height: | Size: 38 KiB |
BIN
osu.Game.Rulesets.Osu.Tests/Resources/old-skin/spinner-metre.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
osu.Game.Rulesets.Osu.Tests/Resources/old-skin/spinner-osu.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
osu.Game.Rulesets.Osu.Tests/Resources/old-skin/spinner-spin.png
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
osu.Game.Rulesets.Osu.Tests/Resources/old-skin/spinnerbonus.wav
Normal file
BIN
osu.Game.Rulesets.Osu.Tests/Resources/old-skin/spinnerspin.wav
Normal file
@ -3,7 +3,6 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
@ -26,19 +25,6 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
[TestFixture]
|
||||
public class TestSceneSlider : OsuSkinnableTestScene
|
||||
{
|
||||
private Container content;
|
||||
|
||||
protected override Container<Drawable> Content
|
||||
{
|
||||
get
|
||||
{
|
||||
if (content == null)
|
||||
base.Content.Add(content = new OsuInputManager(new RulesetInfo { ID = 0 }));
|
||||
|
||||
return content;
|
||||
}
|
||||
}
|
||||
|
||||
private int depthIndex;
|
||||
|
||||
public TestSceneSlider()
|
||||
|
@ -4,37 +4,30 @@
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||
using osu.Game.Tests.Visual;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestSceneSpinner : OsuTestScene
|
||||
public class TestSceneSpinner : OsuSkinnableTestScene
|
||||
{
|
||||
private readonly Container content;
|
||||
protected override Container<Drawable> Content => content;
|
||||
|
||||
private int depthIndex;
|
||||
|
||||
public TestSceneSpinner()
|
||||
{
|
||||
base.Content.Add(content = new OsuInputManager(new RulesetInfo { ID = 0 }));
|
||||
|
||||
AddStep("Miss Big", () => testSingle(2));
|
||||
AddStep("Miss Medium", () => testSingle(5));
|
||||
AddStep("Miss Small", () => testSingle(7));
|
||||
AddStep("Hit Big", () => testSingle(2, true));
|
||||
AddStep("Hit Medium", () => testSingle(5, true));
|
||||
AddStep("Hit Small", () => testSingle(7, true));
|
||||
AddStep("Miss Big", () => SetContents(() => testSingle(2)));
|
||||
AddStep("Miss Medium", () => SetContents(() => testSingle(5)));
|
||||
AddStep("Miss Small", () => SetContents(() => testSingle(7)));
|
||||
AddStep("Hit Big", () => SetContents(() => testSingle(2, true)));
|
||||
AddStep("Hit Medium", () => SetContents(() => testSingle(5, true)));
|
||||
AddStep("Hit Small", () => SetContents(() => testSingle(7, true)));
|
||||
}
|
||||
|
||||
private void testSingle(float circleSize, bool auto = false)
|
||||
private Drawable testSingle(float circleSize, bool auto = false)
|
||||
{
|
||||
var spinner = new Spinner { StartTime = Time.Current + 2000, EndTime = Time.Current + 5000 };
|
||||
|
||||
@ -49,12 +42,12 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
foreach (var mod in SelectedMods.Value.OfType<IApplicableToDrawableHitObjects>())
|
||||
mod.ApplyToDrawableHitObjects(new[] { drawable });
|
||||
|
||||
Add(drawable);
|
||||
return drawable;
|
||||
}
|
||||
|
||||
private class TestDrawableSpinner : DrawableSpinner
|
||||
{
|
||||
private bool auto;
|
||||
private readonly bool auto;
|
||||
|
||||
public TestDrawableSpinner(Spinner s, bool auto)
|
||||
: base(s)
|
||||
@ -62,16 +55,11 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
this.auto = auto;
|
||||
}
|
||||
|
||||
protected override void CheckForResult(bool userTriggered, double timeOffset)
|
||||
protected override void Update()
|
||||
{
|
||||
if (auto && !userTriggered && Time.Current > Spinner.StartTime + Spinner.Duration / 2 && Progress < 1)
|
||||
{
|
||||
// force completion only once to not break human interaction
|
||||
Disc.CumulativeRotation = Spinner.SpinsRequired * 360;
|
||||
auto = false;
|
||||
}
|
||||
|
||||
base.CheckForResult(userTriggered, timeOffset);
|
||||
base.Update();
|
||||
if (auto)
|
||||
RotationTracker.AddRotation((float)(Clock.ElapsedFrameTime * 3));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
@ -60,39 +61,60 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
[Test]
|
||||
public void TestSpinnerRewindingRotation()
|
||||
{
|
||||
double trackerRotationTolerance = 0;
|
||||
|
||||
addSeekStep(5000);
|
||||
AddAssert("is disc rotation not almost 0", () => !Precision.AlmostEquals(drawableSpinner.Disc.Rotation, 0, 100));
|
||||
AddAssert("is disc rotation absolute not almost 0", () => !Precision.AlmostEquals(drawableSpinner.Disc.CumulativeRotation, 0, 100));
|
||||
AddStep("calculate rotation tolerance", () =>
|
||||
{
|
||||
trackerRotationTolerance = Math.Abs(drawableSpinner.RotationTracker.Rotation * 0.1f);
|
||||
});
|
||||
AddAssert("is disc rotation not almost 0", () => !Precision.AlmostEquals(drawableSpinner.RotationTracker.Rotation, 0, 100));
|
||||
AddAssert("is disc rotation absolute not almost 0", () => !Precision.AlmostEquals(drawableSpinner.RotationTracker.CumulativeRotation, 0, 100));
|
||||
|
||||
addSeekStep(0);
|
||||
AddAssert("is disc rotation almost 0", () => Precision.AlmostEquals(drawableSpinner.Disc.Rotation, 0, 100));
|
||||
AddAssert("is disc rotation absolute almost 0", () => Precision.AlmostEquals(drawableSpinner.Disc.CumulativeRotation, 0, 100));
|
||||
AddAssert("is disc rotation almost 0", () => Precision.AlmostEquals(drawableSpinner.RotationTracker.Rotation, 0, trackerRotationTolerance));
|
||||
AddAssert("is disc rotation absolute almost 0", () => Precision.AlmostEquals(drawableSpinner.RotationTracker.CumulativeRotation, 0, 100));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSpinnerMiddleRewindingRotation()
|
||||
{
|
||||
double finalAbsoluteDiscRotation = 0, finalRelativeDiscRotation = 0, finalSpinnerSymbolRotation = 0;
|
||||
double finalCumulativeTrackerRotation = 0;
|
||||
double finalTrackerRotation = 0, trackerRotationTolerance = 0;
|
||||
double finalSpinnerSymbolRotation = 0, spinnerSymbolRotationTolerance = 0;
|
||||
|
||||
addSeekStep(5000);
|
||||
AddStep("retrieve disc relative rotation", () => finalRelativeDiscRotation = drawableSpinner.Disc.Rotation);
|
||||
AddStep("retrieve disc absolute rotation", () => finalAbsoluteDiscRotation = drawableSpinner.Disc.CumulativeRotation);
|
||||
AddStep("retrieve spinner symbol rotation", () => finalSpinnerSymbolRotation = spinnerSymbol.Rotation);
|
||||
AddStep("retrieve disc rotation", () =>
|
||||
{
|
||||
finalTrackerRotation = drawableSpinner.RotationTracker.Rotation;
|
||||
trackerRotationTolerance = Math.Abs(finalTrackerRotation * 0.05f);
|
||||
});
|
||||
AddStep("retrieve spinner symbol rotation", () =>
|
||||
{
|
||||
finalSpinnerSymbolRotation = spinnerSymbol.Rotation;
|
||||
spinnerSymbolRotationTolerance = Math.Abs(finalSpinnerSymbolRotation * 0.05f);
|
||||
});
|
||||
AddStep("retrieve cumulative disc rotation", () => finalCumulativeTrackerRotation = drawableSpinner.RotationTracker.CumulativeRotation);
|
||||
|
||||
addSeekStep(2500);
|
||||
AddUntilStep("disc rotation rewound",
|
||||
AddAssert("disc rotation rewound",
|
||||
// we want to make sure that the rotation at time 2500 is in the same direction as at time 5000, but about half-way in.
|
||||
() => Precision.AlmostEquals(drawableSpinner.Disc.Rotation, finalRelativeDiscRotation / 2, 100));
|
||||
AddUntilStep("symbol rotation rewound",
|
||||
() => Precision.AlmostEquals(spinnerSymbol.Rotation, finalSpinnerSymbolRotation / 2, 100));
|
||||
// due to the exponential damping applied we're allowing a larger margin of error of about 10%
|
||||
// (5% relative to the final rotation value, but we're half-way through the spin).
|
||||
() => Precision.AlmostEquals(drawableSpinner.RotationTracker.Rotation, finalTrackerRotation / 2, trackerRotationTolerance));
|
||||
AddAssert("symbol rotation rewound",
|
||||
() => Precision.AlmostEquals(spinnerSymbol.Rotation, finalSpinnerSymbolRotation / 2, spinnerSymbolRotationTolerance));
|
||||
AddAssert("is cumulative rotation rewound",
|
||||
// cumulative rotation is not damped, so we're treating it as the "ground truth" and allowing a comparatively smaller margin of error.
|
||||
() => Precision.AlmostEquals(drawableSpinner.RotationTracker.CumulativeRotation, finalCumulativeTrackerRotation / 2, 100));
|
||||
|
||||
addSeekStep(5000);
|
||||
AddAssert("is disc rotation almost same",
|
||||
() => Precision.AlmostEquals(drawableSpinner.Disc.Rotation, finalRelativeDiscRotation, 100));
|
||||
() => Precision.AlmostEquals(drawableSpinner.RotationTracker.Rotation, finalTrackerRotation, trackerRotationTolerance));
|
||||
AddAssert("is symbol rotation almost same",
|
||||
() => Precision.AlmostEquals(spinnerSymbol.Rotation, finalSpinnerSymbolRotation, 100));
|
||||
AddAssert("is disc rotation absolute almost same",
|
||||
() => Precision.AlmostEquals(drawableSpinner.Disc.CumulativeRotation, finalAbsoluteDiscRotation, 100));
|
||||
() => Precision.AlmostEquals(spinnerSymbol.Rotation, finalSpinnerSymbolRotation, spinnerSymbolRotationTolerance));
|
||||
AddAssert("is cumulative rotation almost same",
|
||||
() => Precision.AlmostEquals(drawableSpinner.RotationTracker.CumulativeRotation, finalCumulativeTrackerRotation, 100));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -115,7 +137,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
|
||||
addSeekStep(5000);
|
||||
|
||||
AddAssert("disc spin direction correct", () => clockwise ? drawableSpinner.Disc.Rotation > 0 : drawableSpinner.Disc.Rotation < 0);
|
||||
AddAssert("disc spin direction correct", () => clockwise ? drawableSpinner.RotationTracker.Rotation > 0 : drawableSpinner.RotationTracker.Rotation < 0);
|
||||
AddAssert("spinner symbol direction correct", () => clockwise ? spinnerSymbol.Rotation > 0 : spinnerSymbol.Rotation < 0);
|
||||
}
|
||||
|
||||
@ -142,7 +164,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
{
|
||||
// multipled by 2 to nullify the score multiplier. (autoplay mod selected)
|
||||
var totalScore = ((ScoreExposedPlayer)Player).ScoreProcessor.TotalScore.Value * 2;
|
||||
return totalScore == (int)(drawableSpinner.Disc.CumulativeRotation / 360) * SpinnerTick.SCORE_PER_TICK;
|
||||
return totalScore == (int)(drawableSpinner.RotationTracker.CumulativeRotation / 360) * SpinnerTick.SCORE_PER_TICK;
|
||||
});
|
||||
|
||||
addSeekStep(0);
|
||||
|
@ -82,9 +82,7 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
|
||||
case DrawableSpinner spinner:
|
||||
// hide elements we don't care about.
|
||||
spinner.Disc.Hide();
|
||||
spinner.Ticks.Hide();
|
||||
spinner.Background.Hide();
|
||||
// todo: hide background
|
||||
|
||||
using (spinner.BeginAbsoluteSequence(fadeOutStartTime + longFadeDuration, true))
|
||||
spinner.FadeOut(fadeOutDuration);
|
||||
|
@ -40,8 +40,8 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
{
|
||||
var spinner = (DrawableSpinner)drawable;
|
||||
|
||||
spinner.Disc.Tracking = true;
|
||||
spinner.Disc.Rotate(MathUtils.RadiansToDegrees((float)spinner.Clock.ElapsedFrameTime * 0.03f));
|
||||
spinner.RotationTracker.Tracking = true;
|
||||
spinner.RotationTracker.AddRotation(MathUtils.RadiansToDegrees((float)spinner.Clock.ElapsedFrameTime * 0.03f));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -43,6 +43,8 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
|
||||
var h = drawableOsu.HitObject;
|
||||
|
||||
//todo: expose and hide spinner background somehow
|
||||
|
||||
switch (drawable)
|
||||
{
|
||||
case DrawableHitCircle circle:
|
||||
@ -56,11 +58,6 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
slider.Body.OnSkinChanged += () => applySliderState(slider);
|
||||
applySliderState(slider);
|
||||
break;
|
||||
|
||||
case DrawableSpinner spinner:
|
||||
spinner.Disc.Hide();
|
||||
spinner.Background.Hide();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,21 +3,18 @@
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Screens.Ranking;
|
||||
using osu.Game.Skinning;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
{
|
||||
@ -27,28 +24,12 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
|
||||
private readonly Container<DrawableSpinnerTick> ticks;
|
||||
|
||||
public readonly SpinnerDisc Disc;
|
||||
public readonly SpinnerTicks Ticks;
|
||||
public readonly SpinnerRotationTracker RotationTracker;
|
||||
public readonly SpinnerSpmCounter SpmCounter;
|
||||
private readonly SpinnerBonusDisplay bonusDisplay;
|
||||
|
||||
private readonly Container mainContainer;
|
||||
|
||||
public readonly SpinnerBackground Background;
|
||||
private readonly Container circleContainer;
|
||||
private readonly CirclePiece circle;
|
||||
private readonly GlowPiece glow;
|
||||
|
||||
private readonly SpriteIcon symbol;
|
||||
|
||||
private readonly Color4 baseColour = Color4Extensions.FromHex(@"002c3c");
|
||||
private readonly Color4 fillColour = Color4Extensions.FromHex(@"005b7c");
|
||||
|
||||
private readonly IBindable<Vector2> positionBindable = new Bindable<Vector2>();
|
||||
|
||||
private Color4 normalColour;
|
||||
private Color4 completeColour;
|
||||
|
||||
public DrawableSpinner(Spinner s)
|
||||
: base(s)
|
||||
{
|
||||
@ -57,66 +38,20 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
// we are slightly bigger than our parent, to clip the top and bottom of the circle
|
||||
Height = 1.3f;
|
||||
|
||||
Spinner = s;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
ticks = new Container<DrawableSpinnerTick>(),
|
||||
circleContainer = new Container
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
glow = new GlowPiece(),
|
||||
circle = new CirclePiece
|
||||
{
|
||||
Position = Vector2.Zero,
|
||||
Anchor = Anchor.Centre,
|
||||
},
|
||||
new RingPiece(),
|
||||
symbol = new SpriteIcon
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(48),
|
||||
Icon = FontAwesome.Solid.Asterisk,
|
||||
Shadow = false,
|
||||
},
|
||||
}
|
||||
},
|
||||
mainContainer = new AspectContainer
|
||||
new AspectContainer
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Children = new[]
|
||||
Children = new Drawable[]
|
||||
{
|
||||
Background = new SpinnerBackground
|
||||
{
|
||||
Disc =
|
||||
{
|
||||
Alpha = 0f,
|
||||
},
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
},
|
||||
Disc = new SpinnerDisc(Spinner)
|
||||
{
|
||||
Scale = Vector2.Zero,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
},
|
||||
circleContainer.CreateProxy(),
|
||||
Ticks = new SpinnerTicks
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
},
|
||||
new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.SpinnerBody), _ => new DefaultSpinnerDisc()),
|
||||
RotationTracker = new SpinnerRotationTracker(Spinner)
|
||||
}
|
||||
},
|
||||
SpmCounter = new SpinnerSpmCounter
|
||||
@ -135,6 +70,58 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
};
|
||||
}
|
||||
|
||||
private Bindable<bool> isSpinning;
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
isSpinning = RotationTracker.IsSpinning.GetBoundCopy();
|
||||
isSpinning.BindValueChanged(updateSpinningSample);
|
||||
}
|
||||
|
||||
private SkinnableSound spinningSample;
|
||||
|
||||
private const float minimum_volume = 0.0001f;
|
||||
|
||||
protected override void LoadSamples()
|
||||
{
|
||||
base.LoadSamples();
|
||||
|
||||
spinningSample?.Expire();
|
||||
spinningSample = null;
|
||||
|
||||
var firstSample = HitObject.Samples.FirstOrDefault();
|
||||
|
||||
if (firstSample != null)
|
||||
{
|
||||
var clone = HitObject.SampleControlPoint.ApplyTo(firstSample);
|
||||
clone.Name = "spinnerspin";
|
||||
|
||||
AddInternal(spinningSample = new SkinnableSound(clone)
|
||||
{
|
||||
Volume = { Value = minimum_volume },
|
||||
Looping = true,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void updateSpinningSample(ValueChangedEvent<bool> tracking)
|
||||
{
|
||||
// note that samples will not start playing if exiting a seek operation in the middle of a spinner.
|
||||
// may be something we want to address at a later point, but not so easy to make happen right now
|
||||
// (SkinnableSound would need to expose whether the sample is already playing and this logic would need to run in Update).
|
||||
if (tracking.NewValue && ShouldPlaySamples)
|
||||
{
|
||||
spinningSample?.Play();
|
||||
spinningSample?.VolumeTo(1, 200);
|
||||
}
|
||||
else
|
||||
{
|
||||
spinningSample?.VolumeTo(minimum_volume, 200).Finally(_ => spinningSample.Stop());
|
||||
}
|
||||
}
|
||||
|
||||
protected override void AddNestedHitObject(DrawableHitObject hitObject)
|
||||
{
|
||||
base.AddNestedHitObject(hitObject);
|
||||
@ -147,6 +134,17 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
}
|
||||
}
|
||||
|
||||
protected override void UpdateStateTransforms(ArmedState state)
|
||||
{
|
||||
base.UpdateStateTransforms(state);
|
||||
|
||||
using (BeginDelayedSequence(Spinner.Duration, true))
|
||||
this.FadeOut(160);
|
||||
|
||||
// skin change does a rewind of transforms, which will stop the spinning sound from playing if it's currently in playback.
|
||||
isSpinning?.TriggerChange();
|
||||
}
|
||||
|
||||
protected override void ClearNestedHitObjects()
|
||||
{
|
||||
base.ClearNestedHitObjects();
|
||||
@ -170,31 +168,20 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
normalColour = baseColour;
|
||||
completeColour = colours.YellowLight;
|
||||
|
||||
Background.AccentColour = normalColour;
|
||||
Ticks.AccentColour = normalColour;
|
||||
|
||||
Disc.AccentColour = fillColour;
|
||||
circle.Colour = colours.BlueDark;
|
||||
glow.Colour = colours.BlueDark;
|
||||
|
||||
positionBindable.BindValueChanged(pos => Position = pos.NewValue);
|
||||
positionBindable.BindTo(HitObject.PositionBindable);
|
||||
}
|
||||
|
||||
public float Progress => Math.Clamp(Disc.CumulativeRotation / 360 / Spinner.SpinsRequired, 0, 1);
|
||||
/// <summary>
|
||||
/// The completion progress of this spinner from 0..1 (clamped).
|
||||
/// </summary>
|
||||
public float Progress => Math.Clamp(RotationTracker.CumulativeRotation / 360 / Spinner.SpinsRequired, 0, 1);
|
||||
|
||||
protected override void CheckForResult(bool userTriggered, double timeOffset)
|
||||
{
|
||||
if (Time.Current < HitObject.StartTime) return;
|
||||
|
||||
if (Progress >= 1 && !Disc.Complete)
|
||||
{
|
||||
Disc.Complete = true;
|
||||
transformFillColour(completeColour, 200);
|
||||
}
|
||||
RotationTracker.Complete.Value = Progress >= 1;
|
||||
|
||||
if (userTriggered || Time.Current < Spinner.EndTime)
|
||||
return;
|
||||
@ -219,29 +206,24 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
if (HandleUserInput)
|
||||
Disc.Tracking = OsuActionInputManager?.PressedActions.Any(x => x == OsuAction.LeftButton || x == OsuAction.RightButton) ?? false;
|
||||
RotationTracker.Tracking = !Result.HasResult && (OsuActionInputManager?.PressedActions.Any(x => x == OsuAction.LeftButton || x == OsuAction.RightButton) ?? false);
|
||||
|
||||
if (spinningSample != null)
|
||||
// todo: implement SpinnerFrequencyModulate
|
||||
spinningSample.Frequency.Value = 0.5f + Progress;
|
||||
}
|
||||
|
||||
protected override void UpdateAfterChildren()
|
||||
{
|
||||
base.UpdateAfterChildren();
|
||||
|
||||
if (!SpmCounter.IsPresent && Disc.Tracking)
|
||||
if (!SpmCounter.IsPresent && RotationTracker.Tracking)
|
||||
SpmCounter.FadeIn(HitObject.TimeFadeIn);
|
||||
|
||||
circle.Rotation = Disc.Rotation;
|
||||
Ticks.Rotation = Disc.Rotation;
|
||||
|
||||
SpmCounter.SetRotation(Disc.CumulativeRotation);
|
||||
SpmCounter.SetRotation(RotationTracker.CumulativeRotation);
|
||||
|
||||
updateBonusScore();
|
||||
|
||||
float relativeCircleScale = Spinner.Scale * circle.DrawHeight / mainContainer.DrawHeight;
|
||||
float targetScale = relativeCircleScale + (1 - relativeCircleScale) * Progress;
|
||||
Disc.Scale = new Vector2((float)Interpolation.Lerp(Disc.Scale.X, targetScale, Math.Clamp(Math.Abs(Time.Elapsed) / 100, 0, 1)));
|
||||
|
||||
symbol.Rotation = (float)Interpolation.Lerp(symbol.Rotation, Disc.Rotation / 2, Math.Clamp(Math.Abs(Time.Elapsed) / 40, 0, 1));
|
||||
}
|
||||
|
||||
private int wholeSpins;
|
||||
@ -251,7 +233,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
if (ticks.Count == 0)
|
||||
return;
|
||||
|
||||
int spins = (int)(Disc.CumulativeRotation / 360);
|
||||
int spins = (int)(RotationTracker.CumulativeRotation / 360);
|
||||
|
||||
if (spins < wholeSpins)
|
||||
{
|
||||
@ -275,64 +257,5 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
wholeSpins++;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void UpdateInitialTransforms()
|
||||
{
|
||||
base.UpdateInitialTransforms();
|
||||
|
||||
circleContainer.ScaleTo(0);
|
||||
mainContainer.ScaleTo(0);
|
||||
|
||||
using (BeginDelayedSequence(HitObject.TimePreempt / 2, true))
|
||||
{
|
||||
float phaseOneScale = Spinner.Scale * 0.7f;
|
||||
|
||||
circleContainer.ScaleTo(phaseOneScale, HitObject.TimePreempt / 4, Easing.OutQuint);
|
||||
|
||||
mainContainer
|
||||
.ScaleTo(phaseOneScale * circle.DrawHeight / DrawHeight * 1.6f, HitObject.TimePreempt / 4, Easing.OutQuint)
|
||||
.RotateTo((float)(25 * Spinner.Duration / 2000), HitObject.TimePreempt + Spinner.Duration);
|
||||
|
||||
using (BeginDelayedSequence(HitObject.TimePreempt / 2, true))
|
||||
{
|
||||
circleContainer.ScaleTo(Spinner.Scale, 400, Easing.OutQuint);
|
||||
mainContainer.ScaleTo(1, 400, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void UpdateStateTransforms(ArmedState state)
|
||||
{
|
||||
base.UpdateStateTransforms(state);
|
||||
|
||||
using (BeginDelayedSequence(Spinner.Duration, true))
|
||||
{
|
||||
this.FadeOut(160);
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case ArmedState.Hit:
|
||||
transformFillColour(completeColour, 0);
|
||||
this.ScaleTo(Scale * 1.2f, 320, Easing.Out);
|
||||
mainContainer.RotateTo(mainContainer.Rotation + 180, 320);
|
||||
break;
|
||||
|
||||
case ArmedState.Miss:
|
||||
this.ScaleTo(Scale * 0.8f, 320, Easing.In);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void transformFillColour(Colour4 colour, double duration)
|
||||
{
|
||||
Disc.FadeAccent(colour, duration);
|
||||
|
||||
Background.FadeAccent(colour.Darken(1), duration);
|
||||
Ticks.FadeAccent(colour, duration);
|
||||
|
||||
circle.FadeColour(colour, duration);
|
||||
glow.FadeColour(colour, duration);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,189 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
||||
{
|
||||
public class DefaultSpinnerDisc : CompositeDrawable
|
||||
{
|
||||
private DrawableSpinner drawableSpinner;
|
||||
|
||||
private Spinner spinner;
|
||||
|
||||
private const float idle_alpha = 0.2f;
|
||||
private const float tracking_alpha = 0.4f;
|
||||
|
||||
private Color4 normalColour;
|
||||
private Color4 completeColour;
|
||||
|
||||
private SpinnerTicks ticks;
|
||||
|
||||
private int wholeRotationCount;
|
||||
|
||||
private SpinnerFill fill;
|
||||
private Container mainContainer;
|
||||
private SpinnerCentreLayer centre;
|
||||
private SpinnerBackgroundLayer background;
|
||||
|
||||
public DefaultSpinnerDisc()
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
// we are slightly bigger than our parent, to clip the top and bottom of the circle
|
||||
// this should probably be revisited when scaled spinners are a thing.
|
||||
Scale = new Vector2(1.3f);
|
||||
|
||||
Anchor = Anchor.Centre;
|
||||
Origin = Anchor.Centre;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours, DrawableHitObject drawableHitObject)
|
||||
{
|
||||
drawableSpinner = (DrawableSpinner)drawableHitObject;
|
||||
spinner = (Spinner)drawableSpinner.HitObject;
|
||||
|
||||
normalColour = colours.BlueDark;
|
||||
completeColour = colours.YellowLight;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
mainContainer = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
background = new SpinnerBackgroundLayer(),
|
||||
fill = new SpinnerFill
|
||||
{
|
||||
Alpha = idle_alpha,
|
||||
AccentColour = normalColour
|
||||
},
|
||||
ticks = new SpinnerTicks
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
AccentColour = normalColour
|
||||
},
|
||||
}
|
||||
},
|
||||
centre = new SpinnerCentreLayer
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
drawableSpinner.RotationTracker.Complete.BindValueChanged(complete => updateComplete(complete.NewValue, 200));
|
||||
drawableSpinner.State.BindValueChanged(updateStateTransforms, true);
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
if (drawableSpinner.RotationTracker.Complete.Value)
|
||||
{
|
||||
if (checkNewRotationCount)
|
||||
{
|
||||
fill.FinishTransforms(false, nameof(Alpha));
|
||||
fill
|
||||
.FadeTo(tracking_alpha + 0.2f, 60, Easing.OutExpo)
|
||||
.Then()
|
||||
.FadeTo(tracking_alpha, 250, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fill.Alpha = (float)Interpolation.Damp(fill.Alpha, drawableSpinner.RotationTracker.Tracking ? tracking_alpha : idle_alpha, 0.98f, (float)Math.Abs(Clock.ElapsedFrameTime));
|
||||
}
|
||||
|
||||
const float initial_scale = 0.2f;
|
||||
float targetScale = initial_scale + (1 - initial_scale) * drawableSpinner.Progress;
|
||||
|
||||
fill.Scale = new Vector2((float)Interpolation.Lerp(fill.Scale.X, targetScale, Math.Clamp(Math.Abs(Time.Elapsed) / 100, 0, 1)));
|
||||
mainContainer.Rotation = drawableSpinner.RotationTracker.Rotation;
|
||||
}
|
||||
|
||||
private void updateStateTransforms(ValueChangedEvent<ArmedState> state)
|
||||
{
|
||||
centre.ScaleTo(0);
|
||||
mainContainer.ScaleTo(0);
|
||||
|
||||
using (BeginAbsoluteSequence(spinner.StartTime - spinner.TimePreempt / 2, true))
|
||||
{
|
||||
// constant ambient rotation to give the spinner "spinning" character.
|
||||
this.RotateTo((float)(25 * spinner.Duration / 2000), spinner.TimePreempt + spinner.Duration);
|
||||
|
||||
centre.ScaleTo(0.3f, spinner.TimePreempt / 4, Easing.OutQuint);
|
||||
mainContainer.ScaleTo(0.2f, spinner.TimePreempt / 4, Easing.OutQuint);
|
||||
|
||||
using (BeginDelayedSequence(spinner.TimePreempt / 2, true))
|
||||
{
|
||||
centre.ScaleTo(0.5f, spinner.TimePreempt / 2, Easing.OutQuint);
|
||||
mainContainer.ScaleTo(1, spinner.TimePreempt / 2, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
|
||||
// transforms we have from completing the spinner will be rolled back, so reapply immediately.
|
||||
updateComplete(state.NewValue == ArmedState.Hit, 0);
|
||||
|
||||
using (BeginDelayedSequence(spinner.Duration, true))
|
||||
{
|
||||
switch (state.NewValue)
|
||||
{
|
||||
case ArmedState.Hit:
|
||||
this.ScaleTo(Scale * 1.2f, 320, Easing.Out);
|
||||
this.RotateTo(mainContainer.Rotation + 180, 320);
|
||||
break;
|
||||
|
||||
case ArmedState.Miss:
|
||||
this.ScaleTo(Scale * 0.8f, 320, Easing.In);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateComplete(bool complete, double duration)
|
||||
{
|
||||
var colour = complete ? completeColour : normalColour;
|
||||
|
||||
ticks.FadeAccent(colour.Darken(1), duration);
|
||||
fill.FadeAccent(colour.Darken(1), duration);
|
||||
|
||||
background.FadeAccent(colour, duration);
|
||||
centre.FadeAccent(colour, duration);
|
||||
}
|
||||
|
||||
private bool checkNewRotationCount
|
||||
{
|
||||
get
|
||||
{
|
||||
int rotations = (int)(drawableSpinner.RotationTracker.CumulativeRotation / 360);
|
||||
|
||||
if (wholeRotationCount == rotations) return false;
|
||||
|
||||
wholeRotationCount = rotations;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -10,7 +10,7 @@ using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
||||
{
|
||||
public class SpinnerBackground : CircularContainer, IHasAccentColour
|
||||
public class SpinnerFill : CircularContainer, IHasAccentColour
|
||||
{
|
||||
public readonly Box Disc;
|
||||
|
||||
@ -31,11 +31,14 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
||||
}
|
||||
}
|
||||
|
||||
public SpinnerBackground()
|
||||
public SpinnerFill()
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
Masking = true;
|
||||
|
||||
Anchor = Anchor.Centre;
|
||||
Origin = Anchor.Centre;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
Disc = new Box
|
@ -2,76 +2,33 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Graphics;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
using osu.Framework.Utils;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
||||
{
|
||||
public class SpinnerDisc : CircularContainer, IHasAccentColour
|
||||
public class SpinnerRotationTracker : CircularContainer
|
||||
{
|
||||
private readonly Spinner spinner;
|
||||
|
||||
public Color4 AccentColour
|
||||
{
|
||||
get => background.AccentColour;
|
||||
set => background.AccentColour = value;
|
||||
}
|
||||
|
||||
private readonly SpinnerBackground background;
|
||||
|
||||
private const float idle_alpha = 0.2f;
|
||||
private const float tracking_alpha = 0.4f;
|
||||
|
||||
public override bool IsPresent => true; // handle input when hidden
|
||||
|
||||
public SpinnerDisc(Spinner s)
|
||||
public SpinnerRotationTracker(Spinner s)
|
||||
{
|
||||
spinner = s;
|
||||
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
background = new SpinnerBackground { Alpha = idle_alpha },
|
||||
};
|
||||
}
|
||||
|
||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
|
||||
|
||||
private bool tracking;
|
||||
public bool Tracking { get; set; }
|
||||
|
||||
public bool Tracking
|
||||
{
|
||||
get => tracking;
|
||||
set
|
||||
{
|
||||
if (value == tracking) return;
|
||||
|
||||
tracking = value;
|
||||
|
||||
background.FadeTo(tracking ? tracking_alpha : idle_alpha, 100);
|
||||
}
|
||||
}
|
||||
|
||||
private bool complete;
|
||||
|
||||
public bool Complete
|
||||
{
|
||||
get => complete;
|
||||
set
|
||||
{
|
||||
if (value == complete) return;
|
||||
|
||||
complete = value;
|
||||
|
||||
updateCompleteTick();
|
||||
}
|
||||
}
|
||||
public readonly BindableBool Complete = new BindableBool();
|
||||
|
||||
/// <summary>
|
||||
/// The total rotation performed on the spinner disc, disregarding the spin direction.
|
||||
@ -84,7 +41,12 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
||||
/// If the spinner is spun 360 degrees clockwise and then 360 degrees counter-clockwise,
|
||||
/// this property will return the value of 720 (as opposed to 0 for <see cref="Drawable.Rotation"/>).
|
||||
/// </example>
|
||||
public float CumulativeRotation;
|
||||
public float CumulativeRotation { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the spinning is spinning at a reasonable speed to be considered visually spinning.
|
||||
/// </summary>
|
||||
public readonly BindableBool IsSpinning = new BindableBool();
|
||||
|
||||
/// <summary>
|
||||
/// Whether currently in the correct time range to allow spinning.
|
||||
@ -101,9 +63,6 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
||||
|
||||
private float lastAngle;
|
||||
private float currentRotation;
|
||||
private int completeTick;
|
||||
|
||||
private bool updateCompleteTick() => completeTick != (completeTick = (int)(CumulativeRotation / 360));
|
||||
|
||||
private bool rotationTransferred;
|
||||
|
||||
@ -114,21 +73,14 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
||||
|
||||
var delta = thisAngle - lastAngle;
|
||||
|
||||
if (tracking)
|
||||
Rotate(delta);
|
||||
if (Tracking)
|
||||
AddRotation(delta);
|
||||
|
||||
lastAngle = thisAngle;
|
||||
|
||||
if (Complete && updateCompleteTick())
|
||||
{
|
||||
background.FinishTransforms(false, nameof(Alpha));
|
||||
background
|
||||
.FadeTo(tracking_alpha + 0.2f, 60, Easing.OutExpo)
|
||||
.Then()
|
||||
.FadeTo(tracking_alpha, 250, Easing.OutQuint);
|
||||
}
|
||||
IsSpinning.Value = isSpinnableTime && Math.Abs(currentRotation / 2 - Rotation) > 5f;
|
||||
|
||||
Rotation = (float)Interpolation.Lerp(Rotation, currentRotation / 2, Math.Clamp(Math.Abs(Time.Elapsed) / 40, 0, 1));
|
||||
Rotation = (float)Interpolation.Damp(Rotation, currentRotation / 2, 0.99, Math.Abs(Time.Elapsed));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -138,7 +90,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
||||
/// Will be a no-op if not a valid time to spin.
|
||||
/// </remarks>
|
||||
/// <param name="angle">The delta angle.</param>
|
||||
public void Rotate(float angle)
|
||||
public void AddRotation(float angle)
|
||||
{
|
||||
if (!isSpinnableTime)
|
||||
return;
|
@ -0,0 +1,22 @@
|
||||
// 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.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
{
|
||||
public class SpinnerBackgroundLayer : SpinnerFill
|
||||
{
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours, DrawableHitObject drawableHitObject)
|
||||
{
|
||||
Disc.Alpha = 0;
|
||||
Anchor = Anchor.Centre;
|
||||
Origin = Anchor.Centre;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
// 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.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
{
|
||||
public class SpinnerCentreLayer : CompositeDrawable, IHasAccentColour
|
||||
{
|
||||
private DrawableSpinner spinner;
|
||||
|
||||
private CirclePiece circle;
|
||||
private GlowPiece glow;
|
||||
private SpriteIcon symbol;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(DrawableHitObject drawableHitObject)
|
||||
{
|
||||
spinner = (DrawableSpinner)drawableHitObject;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
glow = new GlowPiece(),
|
||||
circle = new CirclePiece
|
||||
{
|
||||
Position = Vector2.Zero,
|
||||
Anchor = Anchor.Centre,
|
||||
},
|
||||
new RingPiece(),
|
||||
symbol = new SpriteIcon
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(48),
|
||||
Icon = FontAwesome.Solid.Asterisk,
|
||||
Shadow = false,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
symbol.Rotation = (float)Interpolation.Lerp(symbol.Rotation, spinner.RotationTracker.Rotation / 2, Math.Clamp(Math.Abs(Time.Elapsed) / 40, 0, 1));
|
||||
}
|
||||
|
||||
private Color4 accentColour;
|
||||
|
||||
public Color4 AccentColour
|
||||
{
|
||||
get => accentColour;
|
||||
set
|
||||
{
|
||||
accentColour = value;
|
||||
|
||||
circle.Colour = accentColour;
|
||||
glow.Colour = accentColour;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -17,5 +17,6 @@ namespace osu.Game.Rulesets.Osu
|
||||
SliderFollowCircle,
|
||||
SliderBall,
|
||||
SliderBody,
|
||||
SpinnerBody
|
||||
}
|
||||
}
|
||||
|
99
osu.Game.Rulesets.Osu/Skinning/LegacyNewStyleSpinner.cs
Normal file
@ -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 osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||
using osu.Game.Skinning;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Skinning
|
||||
{
|
||||
/// <summary>
|
||||
/// Legacy skinned spinner with two main spinning layers, one fixed overlay and one final spinning overlay.
|
||||
/// No background layer.
|
||||
/// </summary>
|
||||
public class LegacyNewStyleSpinner : CompositeDrawable
|
||||
{
|
||||
private Sprite discBottom;
|
||||
private Sprite discTop;
|
||||
private Sprite spinningMiddle;
|
||||
private Sprite fixedMiddle;
|
||||
|
||||
private DrawableSpinner drawableSpinner;
|
||||
|
||||
private const float final_scale = 0.625f;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(ISkinSource source, DrawableHitObject drawableObject)
|
||||
{
|
||||
drawableSpinner = (DrawableSpinner)drawableObject;
|
||||
|
||||
Scale = new Vector2(final_scale);
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
discBottom = new Sprite
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Texture = source.GetTexture("spinner-bottom")
|
||||
},
|
||||
discTop = new Sprite
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Texture = source.GetTexture("spinner-top")
|
||||
},
|
||||
fixedMiddle = new Sprite
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Texture = source.GetTexture("spinner-middle")
|
||||
},
|
||||
spinningMiddle = new Sprite
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Texture = source.GetTexture("spinner-middle2")
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
this.FadeOut();
|
||||
drawableSpinner.State.BindValueChanged(updateStateTransforms, true);
|
||||
}
|
||||
|
||||
private void updateStateTransforms(ValueChangedEvent<ArmedState> state)
|
||||
{
|
||||
var spinner = (Spinner)drawableSpinner.HitObject;
|
||||
|
||||
using (BeginAbsoluteSequence(spinner.StartTime - spinner.TimePreempt / 2, true))
|
||||
this.FadeInFromZero(spinner.TimePreempt / 2);
|
||||
|
||||
fixedMiddle.FadeColour(Color4.White);
|
||||
using (BeginAbsoluteSequence(spinner.StartTime, true))
|
||||
fixedMiddle.FadeColour(Color4.Red, spinner.Duration);
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
spinningMiddle.Rotation = discTop.Rotation = drawableSpinner.RotationTracker.Rotation;
|
||||
discBottom.Rotation = discTop.Rotation / 3;
|
||||
|
||||
Scale = new Vector2(final_scale * (0.8f + (float)Interpolation.ApplyEasing(Easing.Out, drawableSpinner.Progress) * 0.2f));
|
||||
}
|
||||
}
|
||||
}
|
114
osu.Game.Rulesets.Osu/Skinning/LegacyOldStyleSpinner.cs
Normal file
@ -0,0 +1,114 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||
using osu.Game.Skinning;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Skinning
|
||||
{
|
||||
/// <summary>
|
||||
/// Legacy skinned spinner with one main spinning layer and a background layer.
|
||||
/// </summary>
|
||||
public class LegacyOldStyleSpinner : CompositeDrawable
|
||||
{
|
||||
private DrawableSpinner drawableSpinner;
|
||||
private Sprite disc;
|
||||
private Container metre;
|
||||
|
||||
private const float background_y_offset = 20;
|
||||
|
||||
private const float sprite_scale = 1 / 1.6f;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(ISkinSource source, DrawableHitObject drawableObject)
|
||||
{
|
||||
drawableSpinner = (DrawableSpinner)drawableObject;
|
||||
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new Sprite
|
||||
{
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Origin = Anchor.BottomCentre,
|
||||
Texture = source.GetTexture("spinner-background"),
|
||||
Y = background_y_offset,
|
||||
Scale = new Vector2(sprite_scale)
|
||||
},
|
||||
disc = new Sprite
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Texture = source.GetTexture("spinner-circle"),
|
||||
Scale = new Vector2(sprite_scale)
|
||||
},
|
||||
metre = new Container
|
||||
{
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Origin = Anchor.BottomCentre,
|
||||
Y = background_y_offset,
|
||||
Masking = true,
|
||||
Child = new Sprite
|
||||
{
|
||||
Texture = source.GetTexture("spinner-metre"),
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Origin = Anchor.BottomCentre,
|
||||
},
|
||||
Scale = new Vector2(0.625f)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private Vector2 metreFinalSize;
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
this.FadeOut();
|
||||
drawableSpinner.State.BindValueChanged(updateStateTransforms, true);
|
||||
|
||||
metreFinalSize = metre.Size = metre.Child.Size;
|
||||
}
|
||||
|
||||
private void updateStateTransforms(ValueChangedEvent<ArmedState> state)
|
||||
{
|
||||
var spinner = drawableSpinner.HitObject;
|
||||
|
||||
using (BeginAbsoluteSequence(spinner.StartTime - spinner.TimePreempt / 2, true))
|
||||
this.FadeInFromZero(spinner.TimePreempt / 2);
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
disc.Rotation = drawableSpinner.RotationTracker.Rotation;
|
||||
metre.Height = getMetreHeight(drawableSpinner.Progress);
|
||||
}
|
||||
|
||||
private const int total_bars = 10;
|
||||
|
||||
private float getMetreHeight(float progress)
|
||||
{
|
||||
progress = Math.Min(99, progress * 100);
|
||||
|
||||
int barCount = (int)progress / 10;
|
||||
|
||||
// todo: add SpinnerNoBlink support
|
||||
if (RNG.NextBool(((int)progress % 10) / 10f))
|
||||
barCount++;
|
||||
|
||||
return (float)barCount / total_bars * metreFinalSize.Y;
|
||||
}
|
||||
}
|
||||
}
|
@ -102,6 +102,16 @@ namespace osu.Game.Rulesets.Osu.Skinning
|
||||
Scale = new Vector2(0.8f),
|
||||
Spacing = new Vector2(-overlap, 0)
|
||||
};
|
||||
|
||||
case OsuSkinComponents.SpinnerBody:
|
||||
bool hasBackground = Source.GetTexture("spinner-background") != null;
|
||||
|
||||
if (Source.GetTexture("spinner-top") != null && !hasBackground)
|
||||
return new LegacyNewStyleSpinner();
|
||||
else if (hasBackground)
|
||||
return new LegacyOldStyleSpinner();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -0,0 +1,10 @@
|
||||
osu file format v14
|
||||
|
||||
[General]
|
||||
Mode: 1
|
||||
|
||||
[TimingPoints]
|
||||
0,300,4,1,2,100,1,0
|
||||
|
||||
[HitObjects]
|
||||
444,320,1000,5,0,0:0:0:0:
|
@ -0,0 +1,52 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Reflection;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.IO.Stores;
|
||||
using osu.Game.Tests.Beatmaps;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Tests
|
||||
{
|
||||
public class TestSceneTaikoHitObjectSamples : HitObjectSampleTest
|
||||
{
|
||||
protected override Ruleset CreatePlayerRuleset() => new TaikoRuleset();
|
||||
|
||||
protected override IResourceStore<byte[]> Resources => new DllResourceStore(Assembly.GetAssembly(typeof(TestSceneTaikoHitObjectSamples)));
|
||||
|
||||
[TestCase("taiko-normal-hitnormal")]
|
||||
[TestCase("normal-hitnormal")]
|
||||
[TestCase("hitnormal")]
|
||||
public void TestDefaultCustomSampleFromBeatmap(string expectedSample)
|
||||
{
|
||||
SetupSkins(expectedSample, expectedSample);
|
||||
|
||||
CreateTestWithBeatmap("taiko-hitobject-beatmap-custom-sample-bank.osu");
|
||||
|
||||
AssertBeatmapLookup(expectedSample);
|
||||
}
|
||||
|
||||
[TestCase("taiko-normal-hitnormal")]
|
||||
[TestCase("normal-hitnormal")]
|
||||
[TestCase("hitnormal")]
|
||||
public void TestDefaultCustomSampleFromUserSkinFallback(string expectedSample)
|
||||
{
|
||||
SetupSkins(string.Empty, expectedSample);
|
||||
|
||||
CreateTestWithBeatmap("taiko-hitobject-beatmap-custom-sample-bank.osu");
|
||||
|
||||
AssertUserLookup(expectedSample);
|
||||
}
|
||||
|
||||
[TestCase("taiko-normal-hitnormal2")]
|
||||
[TestCase("normal-hitnormal2")]
|
||||
public void TestUserSkinLookupIgnoresSampleBank(string unwantedSample)
|
||||
{
|
||||
SetupSkins(string.Empty, unwantedSample);
|
||||
|
||||
CreateTestWithBeatmap("taiko-hitobject-beatmap-custom-sample-bank.osu");
|
||||
|
||||
AssertNoLookup(unwantedSample);
|
||||
}
|
||||
}
|
||||
}
|
@ -67,9 +67,11 @@ namespace osu.Game.Tests.Gameplay
|
||||
/// Tests that a hitobject which provides a custom sample set of 2 retrieves the following samples from the beatmap skin:
|
||||
/// normal-hitnormal2
|
||||
/// normal-hitnormal
|
||||
/// hitnormal
|
||||
/// </summary>
|
||||
[TestCase("normal-hitnormal2")]
|
||||
[TestCase("normal-hitnormal")]
|
||||
[TestCase("hitnormal")]
|
||||
public void TestDefaultCustomSampleFromBeatmap(string expectedSample)
|
||||
{
|
||||
SetupSkins(expectedSample, expectedSample);
|
||||
@ -80,12 +82,13 @@ namespace osu.Game.Tests.Gameplay
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests that a hitobject which provides a custom sample set of 2 retrieves the following samples from the user skin when the beatmap does not contain the sample:
|
||||
/// normal-hitnormal2
|
||||
/// Tests that a hitobject which provides a custom sample set of 2 retrieves the following samples from the user skin
|
||||
/// (ignoring the custom sample set index) when the beatmap skin does not contain the sample:
|
||||
/// normal-hitnormal
|
||||
/// hitnormal
|
||||
/// </summary>
|
||||
[TestCase("normal-hitnormal2")]
|
||||
[TestCase("normal-hitnormal")]
|
||||
[TestCase("hitnormal")]
|
||||
public void TestDefaultCustomSampleFromUserSkinFallback(string expectedSample)
|
||||
{
|
||||
SetupSkins(string.Empty, expectedSample);
|
||||
@ -95,6 +98,23 @@ namespace osu.Game.Tests.Gameplay
|
||||
AssertUserLookup(expectedSample);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests that a hitobject which provides a custom sample set of 2 does not retrieve a normal-hitnormal2 sample from the user skin
|
||||
/// if the beatmap skin does not contain the sample.
|
||||
/// User skins in stable ignore the custom sample set index when performing lookups.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestUserSkinLookupIgnoresSampleBank()
|
||||
{
|
||||
const string unwanted_sample = "normal-hitnormal2";
|
||||
|
||||
SetupSkins(string.Empty, unwanted_sample);
|
||||
|
||||
CreateTestWithBeatmap("hitobject-beatmap-custom-sample.osu");
|
||||
|
||||
AssertNoLookup(unwanted_sample);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests that a hitobject which provides a sample file retrieves the sample file from the beatmap skin.
|
||||
/// </summary>
|
||||
@ -145,6 +165,7 @@ namespace osu.Game.Tests.Gameplay
|
||||
/// </summary>
|
||||
[TestCase("normal-hitnormal2")]
|
||||
[TestCase("normal-hitnormal")]
|
||||
[TestCase("hitnormal")]
|
||||
public void TestControlPointCustomSampleFromBeatmap(string sampleName)
|
||||
{
|
||||
SetupSkins(sampleName, sampleName);
|
||||
@ -178,7 +199,7 @@ namespace osu.Game.Tests.Gameplay
|
||||
string[] expectedSamples =
|
||||
{
|
||||
"normal-hitnormal2",
|
||||
"normal-hitwhistle2"
|
||||
"normal-hitwhistle" // user skin lookups ignore custom sample set index
|
||||
};
|
||||
|
||||
SetupSkins(expectedSamples[0], expectedSamples[1]);
|
||||
|
@ -3,14 +3,24 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using JetBrains.Annotations;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests;
|
||||
using osu.Game.Online.Multiplayer;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens.Multi.Ranking;
|
||||
using osu.Game.Screens.Ranking;
|
||||
using osu.Game.Tests.Beatmaps;
|
||||
using osu.Game.Users;
|
||||
|
||||
@ -18,43 +28,134 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
{
|
||||
public class TestSceneTimeshiftResultsScreen : ScreenTestScene
|
||||
{
|
||||
private bool roomsReceived;
|
||||
private const int scores_per_result = 10;
|
||||
|
||||
private TestResultsScreen resultsScreen;
|
||||
private int currentScoreId;
|
||||
private bool requestComplete;
|
||||
|
||||
[SetUp]
|
||||
public void Setup() => Schedule(() =>
|
||||
{
|
||||
roomsReceived = false;
|
||||
currentScoreId = 0;
|
||||
requestComplete = false;
|
||||
bindHandler();
|
||||
});
|
||||
|
||||
[Test]
|
||||
public void TestShowResultsWithScore()
|
||||
public void TestShowWithUserScore()
|
||||
{
|
||||
createResults(new TestScoreInfo(new OsuRuleset().RulesetInfo));
|
||||
AddWaitStep("wait for display", 5);
|
||||
ScoreInfo userScore = null;
|
||||
|
||||
AddStep("bind user score info handler", () =>
|
||||
{
|
||||
userScore = new TestScoreInfo(new OsuRuleset().RulesetInfo) { OnlineScoreID = currentScoreId++ };
|
||||
bindHandler(userScore: userScore);
|
||||
});
|
||||
|
||||
createResults(() => userScore);
|
||||
waitForDisplay();
|
||||
|
||||
AddAssert("user score selected", () => this.ChildrenOfType<ScorePanel>().Single(p => p.Score.OnlineScoreID == userScore.OnlineScoreID).State == PanelState.Expanded);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestShowResultsNullScore()
|
||||
public void TestShowNullUserScore()
|
||||
{
|
||||
createResults(null);
|
||||
AddWaitStep("wait for display", 5);
|
||||
createResults();
|
||||
waitForDisplay();
|
||||
|
||||
AddAssert("top score selected", () => this.ChildrenOfType<ScorePanel>().OrderByDescending(p => p.Score.TotalScore).First().State == PanelState.Expanded);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestShowResultsNullScoreWithDelay()
|
||||
public void TestShowUserScoreWithDelay()
|
||||
{
|
||||
ScoreInfo userScore = null;
|
||||
|
||||
AddStep("bind user score info handler", () =>
|
||||
{
|
||||
userScore = new TestScoreInfo(new OsuRuleset().RulesetInfo) { OnlineScoreID = currentScoreId++ };
|
||||
bindHandler(3000, userScore);
|
||||
});
|
||||
|
||||
createResults(() => userScore);
|
||||
waitForDisplay();
|
||||
|
||||
AddAssert("more than 1 panel displayed", () => this.ChildrenOfType<ScorePanel>().Count() > 1);
|
||||
AddAssert("user score selected", () => this.ChildrenOfType<ScorePanel>().Single(p => p.Score.OnlineScoreID == userScore.OnlineScoreID).State == PanelState.Expanded);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestShowNullUserScoreWithDelay()
|
||||
{
|
||||
AddStep("bind delayed handler", () => bindHandler(3000));
|
||||
createResults(null);
|
||||
AddUntilStep("wait for rooms to be received", () => roomsReceived);
|
||||
AddWaitStep("wait for display", 5);
|
||||
|
||||
createResults();
|
||||
waitForDisplay();
|
||||
|
||||
AddAssert("top score selected", () => this.ChildrenOfType<ScorePanel>().OrderByDescending(p => p.Score.TotalScore).First().State == PanelState.Expanded);
|
||||
}
|
||||
|
||||
private void createResults(ScoreInfo score)
|
||||
[Test]
|
||||
public void TestFetchWhenScrolledToTheRight()
|
||||
{
|
||||
createResults();
|
||||
waitForDisplay();
|
||||
|
||||
AddStep("bind delayed handler", () => bindHandler(3000));
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
int beforePanelCount = 0;
|
||||
|
||||
AddStep("get panel count", () => beforePanelCount = this.ChildrenOfType<ScorePanel>().Count());
|
||||
AddStep("scroll to right", () => resultsScreen.ScorePanelList.ChildrenOfType<OsuScrollContainer>().Single().ScrollToEnd(false));
|
||||
|
||||
AddAssert("right loading spinner shown", () => resultsScreen.RightSpinner.State.Value == Visibility.Visible);
|
||||
waitForDisplay();
|
||||
|
||||
AddAssert($"count increased by {scores_per_result}", () => this.ChildrenOfType<ScorePanel>().Count() == beforePanelCount + scores_per_result);
|
||||
AddAssert("right loading spinner hidden", () => resultsScreen.RightSpinner.State.Value == Visibility.Hidden);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestFetchWhenScrolledToTheLeft()
|
||||
{
|
||||
ScoreInfo userScore = null;
|
||||
|
||||
AddStep("bind user score info handler", () =>
|
||||
{
|
||||
userScore = new TestScoreInfo(new OsuRuleset().RulesetInfo) { OnlineScoreID = currentScoreId++ };
|
||||
bindHandler(userScore: userScore);
|
||||
});
|
||||
|
||||
createResults(() => userScore);
|
||||
waitForDisplay();
|
||||
|
||||
AddStep("bind delayed handler", () => bindHandler(3000));
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
int beforePanelCount = 0;
|
||||
|
||||
AddStep("get panel count", () => beforePanelCount = this.ChildrenOfType<ScorePanel>().Count());
|
||||
AddStep("scroll to left", () => resultsScreen.ScorePanelList.ChildrenOfType<OsuScrollContainer>().Single().ScrollToStart(false));
|
||||
|
||||
AddAssert("left loading spinner shown", () => resultsScreen.LeftSpinner.State.Value == Visibility.Visible);
|
||||
waitForDisplay();
|
||||
|
||||
AddAssert($"count increased by {scores_per_result}", () => this.ChildrenOfType<ScorePanel>().Count() == beforePanelCount + scores_per_result);
|
||||
AddAssert("left loading spinner hidden", () => resultsScreen.LeftSpinner.State.Value == Visibility.Hidden);
|
||||
}
|
||||
}
|
||||
|
||||
private void createResults(Func<ScoreInfo> getScore = null)
|
||||
{
|
||||
AddStep("load results", () =>
|
||||
{
|
||||
LoadScreen(new TimeshiftResultsScreen(score, 1, new PlaylistItem
|
||||
LoadScreen(resultsScreen = new TestResultsScreen(getScore?.Invoke(), 1, new PlaylistItem
|
||||
{
|
||||
Beatmap = { Value = new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo },
|
||||
Ruleset = { Value = new OsuRuleset().RulesetInfo }
|
||||
@ -62,62 +163,214 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
});
|
||||
}
|
||||
|
||||
private void bindHandler(double delay = 0)
|
||||
private void waitForDisplay()
|
||||
{
|
||||
var roomScores = new List<MultiplayerScore>();
|
||||
AddUntilStep("wait for request to complete", () => requestComplete);
|
||||
AddWaitStep("wait for display", 5);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
private void bindHandler(double delay = 0, ScoreInfo userScore = null, bool failRequests = false) => ((DummyAPIAccess)API).HandleRequest = request =>
|
||||
{
|
||||
requestComplete = false;
|
||||
|
||||
if (failRequests)
|
||||
{
|
||||
roomScores.Add(new MultiplayerScore
|
||||
triggerFail(request, delay);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (request)
|
||||
{
|
||||
case ShowPlaylistUserScoreRequest s:
|
||||
if (userScore == null)
|
||||
triggerFail(s, delay);
|
||||
else
|
||||
triggerSuccess(s, createUserResponse(userScore), delay);
|
||||
break;
|
||||
|
||||
case IndexPlaylistScoresRequest i:
|
||||
triggerSuccess(i, createIndexResponse(i), delay);
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
private void triggerSuccess<T>(APIRequest<T> req, T result, double delay)
|
||||
where T : class
|
||||
{
|
||||
if (delay == 0)
|
||||
success();
|
||||
else
|
||||
{
|
||||
Task.Run(async () =>
|
||||
{
|
||||
ID = i,
|
||||
Accuracy = 0.9 - 0.01 * i,
|
||||
EndedAt = DateTimeOffset.Now.Subtract(TimeSpan.FromHours(i)),
|
||||
await Task.Delay(TimeSpan.FromMilliseconds(delay));
|
||||
Schedule(success);
|
||||
});
|
||||
}
|
||||
|
||||
void success()
|
||||
{
|
||||
requestComplete = true;
|
||||
req.TriggerSuccess(result);
|
||||
}
|
||||
}
|
||||
|
||||
private void triggerFail(APIRequest req, double delay)
|
||||
{
|
||||
if (delay == 0)
|
||||
fail();
|
||||
else
|
||||
{
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await Task.Delay(TimeSpan.FromMilliseconds(delay));
|
||||
Schedule(fail);
|
||||
});
|
||||
}
|
||||
|
||||
void fail()
|
||||
{
|
||||
requestComplete = true;
|
||||
req.TriggerFailure(new WebException("Failed."));
|
||||
}
|
||||
}
|
||||
|
||||
private MultiplayerScore createUserResponse([NotNull] ScoreInfo userScore)
|
||||
{
|
||||
var multiplayerUserScore = new MultiplayerScore
|
||||
{
|
||||
ID = (int)(userScore.OnlineScoreID ?? currentScoreId++),
|
||||
Accuracy = userScore.Accuracy,
|
||||
EndedAt = userScore.Date,
|
||||
Passed = userScore.Passed,
|
||||
Rank = userScore.Rank,
|
||||
Position = 200,
|
||||
MaxCombo = userScore.MaxCombo,
|
||||
TotalScore = userScore.TotalScore,
|
||||
User = userScore.User,
|
||||
Statistics = userScore.Statistics,
|
||||
ScoresAround = new MultiplayerScoresAround
|
||||
{
|
||||
Higher = new MultiplayerScores(),
|
||||
Lower = new MultiplayerScores()
|
||||
}
|
||||
};
|
||||
|
||||
for (int i = 1; i <= scores_per_result; i++)
|
||||
{
|
||||
multiplayerUserScore.ScoresAround.Lower.Scores.Add(new MultiplayerScore
|
||||
{
|
||||
ID = currentScoreId++,
|
||||
Accuracy = userScore.Accuracy,
|
||||
EndedAt = userScore.Date,
|
||||
Passed = true,
|
||||
Rank = ScoreRank.B,
|
||||
MaxCombo = 999,
|
||||
TotalScore = 999999 - i * 1000,
|
||||
Rank = userScore.Rank,
|
||||
MaxCombo = userScore.MaxCombo,
|
||||
TotalScore = userScore.TotalScore - i,
|
||||
User = new User
|
||||
{
|
||||
Id = 2,
|
||||
Username = $"peppy{i}",
|
||||
CoverUrl = "https://osu.ppy.sh/images/headers/profile-covers/c3.jpg",
|
||||
},
|
||||
Statistics =
|
||||
Statistics = userScore.Statistics
|
||||
});
|
||||
|
||||
multiplayerUserScore.ScoresAround.Higher.Scores.Add(new MultiplayerScore
|
||||
{
|
||||
ID = currentScoreId++,
|
||||
Accuracy = userScore.Accuracy,
|
||||
EndedAt = userScore.Date,
|
||||
Passed = true,
|
||||
Rank = userScore.Rank,
|
||||
MaxCombo = userScore.MaxCombo,
|
||||
TotalScore = userScore.TotalScore + i,
|
||||
User = new User
|
||||
{
|
||||
Id = 2,
|
||||
Username = $"peppy{i}",
|
||||
CoverUrl = "https://osu.ppy.sh/images/headers/profile-covers/c3.jpg",
|
||||
},
|
||||
Statistics = userScore.Statistics
|
||||
});
|
||||
}
|
||||
|
||||
addCursor(multiplayerUserScore.ScoresAround.Lower);
|
||||
addCursor(multiplayerUserScore.ScoresAround.Higher);
|
||||
|
||||
return multiplayerUserScore;
|
||||
}
|
||||
|
||||
private IndexedMultiplayerScores createIndexResponse(IndexPlaylistScoresRequest req)
|
||||
{
|
||||
var result = new IndexedMultiplayerScores();
|
||||
|
||||
long startTotalScore = req.Cursor?.Properties["total_score"].ToObject<long>() ?? 1000000;
|
||||
string sort = req.IndexParams?.Properties["sort"].ToObject<string>() ?? "score_desc";
|
||||
|
||||
for (int i = 1; i <= scores_per_result; i++)
|
||||
{
|
||||
result.Scores.Add(new MultiplayerScore
|
||||
{
|
||||
ID = currentScoreId++,
|
||||
Accuracy = 1,
|
||||
EndedAt = DateTimeOffset.Now,
|
||||
Passed = true,
|
||||
Rank = ScoreRank.X,
|
||||
MaxCombo = 1000,
|
||||
TotalScore = startTotalScore + (sort == "score_asc" ? i : -i),
|
||||
User = new User
|
||||
{
|
||||
Id = 2,
|
||||
Username = $"peppy{i}",
|
||||
CoverUrl = "https://osu.ppy.sh/images/headers/profile-covers/c3.jpg",
|
||||
},
|
||||
Statistics = new Dictionary<HitResult, int>
|
||||
{
|
||||
{ HitResult.Miss, 1 },
|
||||
{ HitResult.Meh, 50 },
|
||||
{ HitResult.Good, 100 },
|
||||
{ HitResult.Great, 300 },
|
||||
{ HitResult.Great, 300 }
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
((DummyAPIAccess)API).HandleRequest = request =>
|
||||
addCursor(result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private void addCursor(MultiplayerScores scores)
|
||||
{
|
||||
scores.Cursor = new Cursor
|
||||
{
|
||||
switch (request)
|
||||
Properties = new Dictionary<string, JToken>
|
||||
{
|
||||
case GetRoomPlaylistScoresRequest r:
|
||||
if (delay == 0)
|
||||
success();
|
||||
else
|
||||
{
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await Task.Delay(TimeSpan.FromMilliseconds(delay));
|
||||
Schedule(success);
|
||||
});
|
||||
}
|
||||
{ "total_score", JToken.FromObject(scores.Scores[^1].TotalScore) },
|
||||
{ "score_id", JToken.FromObject(scores.Scores[^1].ID) },
|
||||
}
|
||||
};
|
||||
|
||||
void success()
|
||||
{
|
||||
r.TriggerSuccess(new RoomPlaylistScores { Scores = roomScores });
|
||||
roomsReceived = true;
|
||||
}
|
||||
|
||||
break;
|
||||
scores.Params = new IndexScoresParams
|
||||
{
|
||||
Properties = new Dictionary<string, JToken>
|
||||
{
|
||||
{ "sort", JToken.FromObject(scores.Scores[^1].TotalScore > scores.Scores[^2].TotalScore ? "score_asc" : "score_desc") }
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private class TestResultsScreen : TimeshiftResultsScreen
|
||||
{
|
||||
public new LoadingSpinner LeftSpinner => base.LeftSpinner;
|
||||
public new LoadingSpinner CentreSpinner => base.CentreSpinner;
|
||||
public new LoadingSpinner RightSpinner => base.RightSpinner;
|
||||
public new ScorePanelList ScorePanelList => base.ScorePanelList;
|
||||
|
||||
public TestResultsScreen(ScoreInfo score, int roomId, PlaylistItem playlistItem, bool allowRetry = true)
|
||||
: base(score, roomId, playlistItem, allowRetry)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,15 +31,16 @@ namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
new NewsCard(new APINewsPost
|
||||
{
|
||||
Title = "This post has an image which starts with \"/\" and has many authors!",
|
||||
Title = "This post has an image which starts with \"/\" and has many authors! (clickable)",
|
||||
Preview = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
|
||||
Author = "someone, someone1, someone2, someone3, someone4",
|
||||
FirstImage = "/help/wiki/shared/news/banners/monthly-beatmapping-contest.png",
|
||||
PublishedAt = DateTimeOffset.Now
|
||||
PublishedAt = DateTimeOffset.Now,
|
||||
Slug = "2020-07-16-summer-theme-park-2020-voting-open"
|
||||
}),
|
||||
new NewsCard(new APINewsPost
|
||||
{
|
||||
Title = "This post has a full-url image! (HTML entity: &)",
|
||||
Title = "This post has a full-url image! (HTML entity: &) (non-clickable)",
|
||||
Preview = "boom (HTML entity: &)",
|
||||
Author = "user (HTML entity: &)",
|
||||
FirstImage = "https://assets.ppy.sh/artists/88/header.jpg",
|
||||
|
53
osu.Game.Tests/Visual/Online/TestSceneNewsHeader.cs
Normal file
@ -0,0 +1,53 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using NUnit.Framework;
|
||||
using osu.Game.Overlays.News;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Framework.Allocation;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
public class TestSceneNewsHeader : OsuTestScene
|
||||
{
|
||||
[Cached]
|
||||
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Purple);
|
||||
|
||||
private TestHeader header;
|
||||
|
||||
[SetUp]
|
||||
public void Setup() => Schedule(() =>
|
||||
{
|
||||
Child = header = new TestHeader
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre
|
||||
};
|
||||
});
|
||||
|
||||
[Test]
|
||||
public void TestControl()
|
||||
{
|
||||
AddAssert("Front page selected", () => header.Current.Value == "frontpage");
|
||||
AddAssert("1 tab total", () => header.TabCount == 1);
|
||||
|
||||
AddStep("Set article 1", () => header.SetArticle("1"));
|
||||
AddAssert("Article 1 selected", () => header.Current.Value == "1");
|
||||
AddAssert("2 tabs total", () => header.TabCount == 2);
|
||||
|
||||
AddStep("Set article 2", () => header.SetArticle("2"));
|
||||
AddAssert("Article 2 selected", () => header.Current.Value == "2");
|
||||
AddAssert("2 tabs total", () => header.TabCount == 2);
|
||||
|
||||
AddStep("Set front page", () => header.SetFrontPage());
|
||||
AddAssert("Front page selected", () => header.Current.Value == "frontpage");
|
||||
AddAssert("1 tab total", () => header.TabCount == 1);
|
||||
}
|
||||
|
||||
private class TestHeader : NewsHeader
|
||||
{
|
||||
public int TabCount => TabControl.Items.Count;
|
||||
}
|
||||
}
|
||||
}
|
@ -2,65 +2,64 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using osu.Framework.Graphics;
|
||||
using NUnit.Framework;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.News;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
public class TestSceneNewsOverlay : OsuTestScene
|
||||
{
|
||||
private TestNewsOverlay news;
|
||||
private DummyAPIAccess dummyAPI => (DummyAPIAccess)API;
|
||||
|
||||
protected override void LoadComplete()
|
||||
private NewsOverlay news;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp() => Schedule(() => Child = news = new NewsOverlay());
|
||||
|
||||
[Test]
|
||||
public void TestRequest()
|
||||
{
|
||||
base.LoadComplete();
|
||||
Add(news = new TestNewsOverlay());
|
||||
AddStep(@"Show", news.Show);
|
||||
AddStep(@"Hide", news.Hide);
|
||||
|
||||
AddStep(@"Show front page", () => news.ShowFrontPage());
|
||||
AddStep(@"Custom article", () => news.Current.Value = "Test Article 101");
|
||||
|
||||
AddStep(@"Article covers", () => news.LoadAndShowContent(new NewsCoverTest()));
|
||||
setUpNewsResponse(responseExample);
|
||||
AddStep("Show", () => news.Show());
|
||||
AddStep("Show article", () => news.ShowArticle("article"));
|
||||
}
|
||||
|
||||
private class TestNewsOverlay : NewsOverlay
|
||||
{
|
||||
public new void LoadAndShowContent(NewsContent content) => base.LoadAndShowContent(content);
|
||||
}
|
||||
|
||||
private class NewsCoverTest : NewsContent
|
||||
{
|
||||
public NewsCoverTest()
|
||||
private void setUpNewsResponse(GetNewsResponse r)
|
||||
=> AddStep("set up response", () =>
|
||||
{
|
||||
Spacing = new osuTK.Vector2(0, 10);
|
||||
|
||||
var article = new NewsArticleCover.ArticleInfo
|
||||
dummyAPI.HandleRequest = request =>
|
||||
{
|
||||
Author = "Ephemeral",
|
||||
CoverUrl = "https://assets.ppy.sh/artists/58/header.jpg",
|
||||
Time = new DateTime(2019, 12, 4),
|
||||
Title = "New Featured Artist: Kurokotei"
|
||||
};
|
||||
if (!(request is GetNewsRequest getNewsRequest))
|
||||
return;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new NewsArticleCover(article)
|
||||
{
|
||||
Height = 200
|
||||
},
|
||||
new NewsArticleCover(article)
|
||||
{
|
||||
Height = 120
|
||||
},
|
||||
new NewsArticleCover(article)
|
||||
{
|
||||
RelativeSizeAxes = Axes.None,
|
||||
Size = new osuTK.Vector2(400, 200),
|
||||
}
|
||||
getNewsRequest.TriggerSuccess(r);
|
||||
};
|
||||
});
|
||||
|
||||
private GetNewsResponse responseExample => new GetNewsResponse
|
||||
{
|
||||
NewsPosts = new[]
|
||||
{
|
||||
new APINewsPost
|
||||
{
|
||||
Title = "This post has an image which starts with \"/\" and has many authors!",
|
||||
Preview = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
|
||||
Author = "someone, someone1, someone2, someone3, someone4",
|
||||
FirstImage = "/help/wiki/shared/news/banners/monthly-beatmapping-contest.png",
|
||||
PublishedAt = DateTimeOffset.Now
|
||||
},
|
||||
new APINewsPost
|
||||
{
|
||||
Title = "This post has a full-url image! (HTML entity: &)",
|
||||
Preview = "boom (HTML entity: &)",
|
||||
Author = "user (HTML entity: &)",
|
||||
FirstImage = "https://assets.ppy.sh/artists/88/header.jpg",
|
||||
PublishedAt = DateTimeOffset.Now
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -4,19 +4,22 @@
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Overlays;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
public class TestSceneShowMoreButton : OsuTestScene
|
||||
{
|
||||
[Cached]
|
||||
private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Green);
|
||||
|
||||
public TestSceneShowMoreButton()
|
||||
{
|
||||
TestButton button = null;
|
||||
ShowMoreButton button = null;
|
||||
|
||||
int fireCount = 0;
|
||||
|
||||
Add(button = new TestButton
|
||||
Add(button = new ShowMoreButton
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
@ -46,16 +49,5 @@ namespace osu.Game.Tests.Visual.Online
|
||||
AddAssert("action fired twice", () => fireCount == 2);
|
||||
AddAssert("is in loading state", () => button.IsLoading);
|
||||
}
|
||||
|
||||
private class TestButton : ShowMoreButton
|
||||
{
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colors)
|
||||
{
|
||||
IdleColour = colors.YellowDark;
|
||||
HoverColour = colors.Yellow;
|
||||
ChevronIconColour = colors.Red;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ namespace osu.Game.Tests.Visual
|
||||
typeof(NotificationOverlay),
|
||||
typeof(BeatmapListingOverlay),
|
||||
typeof(DashboardOverlay),
|
||||
typeof(NewsOverlay),
|
||||
typeof(ChannelManager),
|
||||
typeof(ChatOverlay),
|
||||
typeof(SettingsOverlay),
|
||||
|
@ -81,7 +81,7 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
||||
{
|
||||
}
|
||||
|
||||
private class SettingsRoundDropdown : LadderSettingsDropdown<TournamentRound>
|
||||
private class SettingsRoundDropdown : SettingsDropdown<TournamentRound>
|
||||
{
|
||||
public SettingsRoundDropdown(BindableList<TournamentRound> rounds)
|
||||
{
|
||||
|
@ -1,26 +0,0 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Overlays.Settings;
|
||||
|
||||
namespace osu.Game.Tournament.Screens.Ladder.Components
|
||||
{
|
||||
public class LadderSettingsDropdown<T> : SettingsDropdown<T>
|
||||
{
|
||||
protected override OsuDropdown<T> CreateDropdown() => new DropdownControl();
|
||||
|
||||
private new class DropdownControl : SettingsDropdown<T>.DropdownControl
|
||||
{
|
||||
protected override DropdownMenu CreateMenu() => new Menu();
|
||||
|
||||
private new class Menu : OsuDropdownMenu
|
||||
{
|
||||
public Menu()
|
||||
{
|
||||
MaxHeight = 200;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -6,11 +6,12 @@ using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Game.Overlays.Settings;
|
||||
using osu.Game.Tournament.Models;
|
||||
|
||||
namespace osu.Game.Tournament.Screens.Ladder.Components
|
||||
{
|
||||
public class SettingsTeamDropdown : LadderSettingsDropdown<TournamentTeam>
|
||||
public class SettingsTeamDropdown : SettingsDropdown<TournamentTeam>
|
||||
{
|
||||
public SettingsTeamDropdown(BindableList<TournamentTeam> teams)
|
||||
{
|
||||
|
@ -1,13 +1,15 @@
|
||||
// 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.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Overlays;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
@ -16,14 +18,6 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
private const int duration = 200;
|
||||
|
||||
private Color4 chevronIconColour;
|
||||
|
||||
protected Color4 ChevronIconColour
|
||||
{
|
||||
get => chevronIconColour;
|
||||
set => chevronIconColour = leftChevron.Colour = rightChevron.Colour = value;
|
||||
}
|
||||
|
||||
public string Text
|
||||
{
|
||||
get => text.Text;
|
||||
@ -32,22 +26,28 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
protected override IEnumerable<Drawable> EffectTargets => new[] { background };
|
||||
|
||||
private ChevronIcon leftChevron;
|
||||
private ChevronIcon rightChevron;
|
||||
private ChevronIcon leftIcon;
|
||||
private ChevronIcon rightIcon;
|
||||
private SpriteText text;
|
||||
private Box background;
|
||||
private FillFlowContainer textContainer;
|
||||
|
||||
public ShowMoreButton()
|
||||
{
|
||||
Height = 30;
|
||||
Width = 140;
|
||||
AutoSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OverlayColourProvider colourProvider)
|
||||
{
|
||||
IdleColour = colourProvider.Background2;
|
||||
HoverColour = colourProvider.Background1;
|
||||
}
|
||||
|
||||
protected override Drawable CreateContent() => new CircularContainer
|
||||
{
|
||||
Masking = true,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
background = new Box
|
||||
@ -56,22 +56,36 @@ namespace osu.Game.Graphics.UserInterface
|
||||
},
|
||||
textContainer = new FillFlowContainer
|
||||
{
|
||||
AlwaysPresent = true,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Spacing = new Vector2(7),
|
||||
Spacing = new Vector2(10),
|
||||
Margin = new MarginPadding
|
||||
{
|
||||
Horizontal = 20,
|
||||
Vertical = 5
|
||||
},
|
||||
Children = new Drawable[]
|
||||
{
|
||||
leftChevron = new ChevronIcon(),
|
||||
leftIcon = new ChevronIcon
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
},
|
||||
text = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold),
|
||||
Font = OsuFont.GetFont(size: 12, weight: FontWeight.SemiBold),
|
||||
Text = "show more".ToUpper(),
|
||||
},
|
||||
rightChevron = new ChevronIcon(),
|
||||
rightIcon = new ChevronIcon
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -81,17 +95,40 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
protected override void OnLoadFinished() => textContainer.FadeIn(duration, Easing.OutQuint);
|
||||
|
||||
private class ChevronIcon : SpriteIcon
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
{
|
||||
private const int icon_size = 8;
|
||||
base.OnHover(e);
|
||||
leftIcon.SetHoveredState(true);
|
||||
rightIcon.SetHoveredState(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(HoverLostEvent e)
|
||||
{
|
||||
base.OnHoverLost(e);
|
||||
leftIcon.SetHoveredState(false);
|
||||
rightIcon.SetHoveredState(false);
|
||||
}
|
||||
|
||||
public class ChevronIcon : SpriteIcon
|
||||
{
|
||||
[Resolved]
|
||||
private OverlayColourProvider colourProvider { get; set; }
|
||||
|
||||
public ChevronIcon()
|
||||
{
|
||||
Anchor = Anchor.Centre;
|
||||
Origin = Anchor.Centre;
|
||||
Size = new Vector2(icon_size);
|
||||
Size = new Vector2(7.5f);
|
||||
Icon = FontAwesome.Solid.ChevronDown;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
Colour = colourProvider.Foreground1;
|
||||
}
|
||||
|
||||
public void SetHoveredState(bool hovered) =>
|
||||
this.FadeColour(hovered ? colourProvider.Light1 : colourProvider.Foreground1, 200, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -136,6 +136,11 @@ namespace osu.Game.Online.API
|
||||
Success?.Invoke();
|
||||
}
|
||||
|
||||
internal void TriggerFailure(Exception e)
|
||||
{
|
||||
Failure?.Invoke(e);
|
||||
}
|
||||
|
||||
public void Cancel() => Fail(new OperationCanceledException(@"Request cancelled"));
|
||||
|
||||
public void Fail(Exception e)
|
||||
@ -166,7 +171,7 @@ namespace osu.Game.Online.API
|
||||
}
|
||||
|
||||
Logger.Log($@"Failing request {this} ({e})", LoggingTarget.Network);
|
||||
pendingFailure = () => Failure?.Invoke(e);
|
||||
pendingFailure = () => TriggerFailure(e);
|
||||
checkAndScheduleFailure();
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,6 @@ namespace osu.Game.Online.API.Requests
|
||||
{
|
||||
[UsedImplicitly]
|
||||
[JsonExtensionData]
|
||||
public IDictionary<string, JToken> Properties;
|
||||
public IDictionary<string, JToken> Properties { get; set; } = new Dictionary<string, JToken>();
|
||||
}
|
||||
}
|
||||
|
27
osu.Game/Online/API/Requests/GetNewsRequest.cs
Normal file
@ -0,0 +1,27 @@
|
||||
// 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.IO.Network;
|
||||
using osu.Game.Extensions;
|
||||
|
||||
namespace osu.Game.Online.API.Requests
|
||||
{
|
||||
public class GetNewsRequest : APIRequest<GetNewsResponse>
|
||||
{
|
||||
private readonly Cursor cursor;
|
||||
|
||||
public GetNewsRequest(Cursor cursor = null)
|
||||
{
|
||||
this.cursor = cursor;
|
||||
}
|
||||
|
||||
protected override WebRequest CreateWebRequest()
|
||||
{
|
||||
var req = base.CreateWebRequest();
|
||||
req.AddCursor(cursor);
|
||||
return req;
|
||||
}
|
||||
|
||||
protected override string Target => "news";
|
||||
}
|
||||
}
|
15
osu.Game/Online/API/Requests/GetNewsResponse.cs
Normal file
@ -0,0 +1,15 @@
|
||||
// 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 Newtonsoft.Json;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
|
||||
namespace osu.Game.Online.API.Requests
|
||||
{
|
||||
public class GetNewsResponse : ResponseWithCursor
|
||||
{
|
||||
[JsonProperty("news_posts")]
|
||||
public IEnumerable<APINewsPost> NewsPosts;
|
||||
}
|
||||
}
|
@ -11,17 +11,20 @@ namespace osu.Game.Online.Multiplayer
|
||||
{
|
||||
private readonly int roomId;
|
||||
private readonly int playlistItemId;
|
||||
private readonly string versionHash;
|
||||
|
||||
public CreateRoomScoreRequest(int roomId, int playlistItemId)
|
||||
public CreateRoomScoreRequest(int roomId, int playlistItemId, string versionHash)
|
||||
{
|
||||
this.roomId = roomId;
|
||||
this.playlistItemId = playlistItemId;
|
||||
this.versionHash = versionHash;
|
||||
}
|
||||
|
||||
protected override WebRequest CreateWebRequest()
|
||||
{
|
||||
var req = base.CreateWebRequest();
|
||||
req.Method = HttpMethod.Post;
|
||||
req.AddParameter("version_hash", versionHash);
|
||||
return req;
|
||||
}
|
||||
|
||||
|
@ -1,29 +0,0 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using osu.Game.Online.API;
|
||||
|
||||
namespace osu.Game.Online.Multiplayer
|
||||
{
|
||||
public class GetRoomPlaylistScoresRequest : APIRequest<RoomPlaylistScores>
|
||||
{
|
||||
private readonly int roomId;
|
||||
private readonly int playlistItemId;
|
||||
|
||||
public GetRoomPlaylistScoresRequest(int roomId, int playlistItemId)
|
||||
{
|
||||
this.roomId = roomId;
|
||||
this.playlistItemId = playlistItemId;
|
||||
}
|
||||
|
||||
protected override string Target => $@"rooms/{roomId}/playlist/{playlistItemId}/scores";
|
||||
}
|
||||
|
||||
public class RoomPlaylistScores
|
||||
{
|
||||
[JsonProperty("scores")]
|
||||
public List<MultiplayerScore> Scores { get; set; }
|
||||
}
|
||||
}
|
59
osu.Game/Online/Multiplayer/IndexPlaylistScoresRequest.cs
Normal file
@ -0,0 +1,59 @@
|
||||
// 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.Diagnostics;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.IO.Network;
|
||||
using osu.Game.Extensions;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests;
|
||||
|
||||
namespace osu.Game.Online.Multiplayer
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns a list of scores for the specified playlist item.
|
||||
/// </summary>
|
||||
public class IndexPlaylistScoresRequest : APIRequest<IndexedMultiplayerScores>
|
||||
{
|
||||
public readonly int RoomId;
|
||||
public readonly int PlaylistItemId;
|
||||
|
||||
[CanBeNull]
|
||||
public readonly Cursor Cursor;
|
||||
|
||||
[CanBeNull]
|
||||
public readonly IndexScoresParams IndexParams;
|
||||
|
||||
public IndexPlaylistScoresRequest(int roomId, int playlistItemId)
|
||||
{
|
||||
RoomId = roomId;
|
||||
PlaylistItemId = playlistItemId;
|
||||
}
|
||||
|
||||
public IndexPlaylistScoresRequest(int roomId, int playlistItemId, [NotNull] Cursor cursor, [NotNull] IndexScoresParams indexParams)
|
||||
: this(roomId, playlistItemId)
|
||||
{
|
||||
Cursor = cursor;
|
||||
IndexParams = indexParams;
|
||||
}
|
||||
|
||||
protected override WebRequest CreateWebRequest()
|
||||
{
|
||||
var req = base.CreateWebRequest();
|
||||
|
||||
if (Cursor != null)
|
||||
{
|
||||
Debug.Assert(IndexParams != null);
|
||||
|
||||
req.AddCursor(Cursor);
|
||||
|
||||
foreach (var (key, value) in IndexParams.Properties)
|
||||
req.AddParameter(key, value.ToString());
|
||||
}
|
||||
|
||||
return req;
|
||||
}
|
||||
|
||||
protected override string Target => $@"rooms/{RoomId}/playlist/{PlaylistItemId}/scores";
|
||||
}
|
||||
}
|
20
osu.Game/Online/Multiplayer/IndexScoresParams.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.Collections.Generic;
|
||||
using JetBrains.Annotations;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace osu.Game.Online.Multiplayer
|
||||
{
|
||||
/// <summary>
|
||||
/// A collection of parameters which should be passed to the index endpoint to fetch the next page.
|
||||
/// </summary>
|
||||
public class IndexScoresParams
|
||||
{
|
||||
[UsedImplicitly]
|
||||
[JsonExtensionData]
|
||||
public IDictionary<string, JToken> Properties { get; set; } = new Dictionary<string, JToken>();
|
||||
}
|
||||
}
|
27
osu.Game/Online/Multiplayer/IndexedMultiplayerScores.cs
Normal file
@ -0,0 +1,27 @@
|
||||
// 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 JetBrains.Annotations;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace osu.Game.Online.Multiplayer
|
||||
{
|
||||
/// <summary>
|
||||
/// A <see cref="MultiplayerScores"/> object returned via a <see cref="IndexPlaylistScoresRequest"/>.
|
||||
/// </summary>
|
||||
public class IndexedMultiplayerScores : MultiplayerScores
|
||||
{
|
||||
/// <summary>
|
||||
/// The total scores in the playlist item.
|
||||
/// </summary>
|
||||
[JsonProperty("total")]
|
||||
public int? TotalScores { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The user's score, if any.
|
||||
/// </summary>
|
||||
[JsonProperty("user_score")]
|
||||
[CanBeNull]
|
||||
public MultiplayerScore UserScore { get; set; }
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using osu.Game.Online.API;
|
||||
@ -47,6 +48,19 @@ namespace osu.Game.Online.Multiplayer
|
||||
[JsonProperty("ended_at")]
|
||||
public DateTimeOffset EndedAt { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The position of this score, starting at 1.
|
||||
/// </summary>
|
||||
[JsonProperty("position")]
|
||||
public int? Position { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Any scores in the room around this score.
|
||||
/// </summary>
|
||||
[JsonProperty("scores_around")]
|
||||
[CanBeNull]
|
||||
public MultiplayerScoresAround ScoresAround { get; set; }
|
||||
|
||||
public ScoreInfo CreateScoreInfo(PlaylistItem playlistItem)
|
||||
{
|
||||
var rulesetInstance = playlistItem.Ruleset.Value.CreateInstance();
|
||||
@ -66,7 +80,8 @@ namespace osu.Game.Online.Multiplayer
|
||||
Date = EndedAt,
|
||||
Hash = string.Empty, // todo: temporary?
|
||||
Rank = Rank,
|
||||
Mods = Mods?.Select(m => m.ToMod(rulesetInstance)).ToArray() ?? Array.Empty<Mod>()
|
||||
Mods = Mods?.Select(m => m.ToMod(rulesetInstance)).ToArray() ?? Array.Empty<Mod>(),
|
||||
Position = Position,
|
||||
};
|
||||
|
||||
return scoreInfo;
|
||||
|
27
osu.Game/Online/Multiplayer/MultiplayerScores.cs
Normal file
@ -0,0 +1,27 @@
|
||||
// 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 Newtonsoft.Json;
|
||||
using osu.Game.Online.API.Requests;
|
||||
|
||||
namespace osu.Game.Online.Multiplayer
|
||||
{
|
||||
/// <summary>
|
||||
/// An object which contains scores and related data for fetching next pages.
|
||||
/// </summary>
|
||||
public class MultiplayerScores : ResponseWithCursor
|
||||
{
|
||||
/// <summary>
|
||||
/// The scores.
|
||||
/// </summary>
|
||||
[JsonProperty("scores")]
|
||||
public List<MultiplayerScore> Scores { get; set; } = new List<MultiplayerScore>();
|
||||
|
||||
/// <summary>
|
||||
/// The parameters to be used to fetch the next page.
|
||||
/// </summary>
|
||||
[JsonProperty("params")]
|
||||
public IndexScoresParams Params { get; set; } = new IndexScoresParams();
|
||||
}
|
||||
}
|
28
osu.Game/Online/Multiplayer/MultiplayerScoresAround.cs
Normal file
@ -0,0 +1,28 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using JetBrains.Annotations;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace osu.Game.Online.Multiplayer
|
||||
{
|
||||
/// <summary>
|
||||
/// An object which stores scores higher and lower than the user's score.
|
||||
/// </summary>
|
||||
public class MultiplayerScoresAround
|
||||
{
|
||||
/// <summary>
|
||||
/// Scores sorted "higher" than the user's score, depending on the sorting order.
|
||||
/// </summary>
|
||||
[JsonProperty("higher")]
|
||||
[CanBeNull]
|
||||
public MultiplayerScores Higher { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Scores sorted "lower" than the user's score, depending on the sorting order.
|
||||
/// </summary>
|
||||
[JsonProperty("lower")]
|
||||
[CanBeNull]
|
||||
public MultiplayerScores Lower { get; set; }
|
||||
}
|
||||
}
|
23
osu.Game/Online/Multiplayer/ShowPlaylistUserScoreRequest.cs
Normal file
@ -0,0 +1,23 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Game.Online.API;
|
||||
|
||||
namespace osu.Game.Online.Multiplayer
|
||||
{
|
||||
public class ShowPlaylistUserScoreRequest : APIRequest<MultiplayerScore>
|
||||
{
|
||||
private readonly int roomId;
|
||||
private readonly int playlistItemId;
|
||||
private readonly long userId;
|
||||
|
||||
public ShowPlaylistUserScoreRequest(int roomId, int playlistItemId, long userId)
|
||||
{
|
||||
this.roomId = roomId;
|
||||
this.playlistItemId = playlistItemId;
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
protected override string Target => $"rooms/{roomId}/playlist/{playlistItemId}/scores/users/{userId}";
|
||||
}
|
||||
}
|
@ -73,6 +73,8 @@ namespace osu.Game
|
||||
|
||||
private DashboardOverlay dashboard;
|
||||
|
||||
private NewsOverlay news;
|
||||
|
||||
private UserProfileOverlay userProfile;
|
||||
|
||||
private BeatmapSetOverlay beatmapSetOverlay;
|
||||
@ -632,6 +634,7 @@ namespace osu.Game
|
||||
// overlay elements
|
||||
loadComponentSingleFile(beatmapListing = new BeatmapListingOverlay(), overlayContent.Add, true);
|
||||
loadComponentSingleFile(dashboard = new DashboardOverlay(), overlayContent.Add, true);
|
||||
loadComponentSingleFile(news = new NewsOverlay(), overlayContent.Add, true);
|
||||
var rankingsOverlay = loadComponentSingleFile(new RankingsOverlay(), overlayContent.Add, true);
|
||||
loadComponentSingleFile(channelManager = new ChannelManager(), AddInternal, true);
|
||||
loadComponentSingleFile(chatOverlay = new ChatOverlay(), overlayContent.Add, true);
|
||||
@ -689,7 +692,7 @@ namespace osu.Game
|
||||
}
|
||||
|
||||
// ensure only one of these overlays are open at once.
|
||||
var singleDisplayOverlays = new OverlayContainer[] { chatOverlay, dashboard, beatmapListing, changelogOverlay, rankingsOverlay };
|
||||
var singleDisplayOverlays = new OverlayContainer[] { chatOverlay, news, dashboard, beatmapListing, changelogOverlay, rankingsOverlay };
|
||||
|
||||
foreach (var overlay in singleDisplayOverlays)
|
||||
{
|
||||
|
@ -11,6 +11,7 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Development;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.IO.Stores;
|
||||
@ -97,6 +98,11 @@ namespace osu.Game
|
||||
|
||||
public virtual Version AssemblyVersion => Assembly.GetEntryAssembly()?.GetName().Version ?? new Version();
|
||||
|
||||
/// <summary>
|
||||
/// MD5 representation of the game executable.
|
||||
/// </summary>
|
||||
public string VersionHash { get; private set; }
|
||||
|
||||
public bool IsDeployedBuild => AssemblyVersion.Major > 0;
|
||||
|
||||
public virtual string Version
|
||||
@ -128,6 +134,9 @@ namespace osu.Game
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
using (var str = File.OpenRead(typeof(OsuGameBase).Assembly.Location))
|
||||
VersionHash = str.ComputeMD5Hash();
|
||||
|
||||
Resources.AddStore(new DllResourceStore(OsuResources.ResourceAssembly));
|
||||
|
||||
dependencies.Cache(contextFactory = new DatabaseContextFactory(Storage));
|
||||
|
@ -5,12 +5,12 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osuTK;
|
||||
using static osu.Game.Graphics.UserInterface.ShowMoreButton;
|
||||
|
||||
namespace osu.Game.Overlays.Comments.Buttons
|
||||
{
|
||||
@ -25,7 +25,7 @@ namespace osu.Game.Overlays.Comments.Buttons
|
||||
[Resolved]
|
||||
private OverlayColourProvider colourProvider { get; set; }
|
||||
|
||||
private readonly SpriteIcon icon;
|
||||
private readonly ChevronIcon icon;
|
||||
private readonly Box background;
|
||||
private readonly OsuSpriteText text;
|
||||
|
||||
@ -68,12 +68,10 @@ namespace osu.Game.Overlays.Comments.Buttons
|
||||
AlwaysPresent = true,
|
||||
Font = OsuFont.GetFont(size: 12, weight: FontWeight.SemiBold)
|
||||
},
|
||||
icon = new SpriteIcon
|
||||
icon = new ChevronIcon
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Size = new Vector2(7.5f),
|
||||
Icon = FontAwesome.Solid.ChevronDown
|
||||
Origin = Anchor.CentreLeft
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -88,7 +86,6 @@ namespace osu.Game.Overlays.Comments.Buttons
|
||||
private void load()
|
||||
{
|
||||
background.Colour = colourProvider.Background2;
|
||||
icon.Colour = colourProvider.Foreground1;
|
||||
}
|
||||
|
||||
protected void SetIconDirection(bool upwards) => icon.ScaleTo(new Vector2(1, upwards ? -1 : 1));
|
||||
@ -99,7 +96,7 @@ namespace osu.Game.Overlays.Comments.Buttons
|
||||
{
|
||||
base.OnHover(e);
|
||||
background.FadeColour(colourProvider.Background1, 200, Easing.OutQuint);
|
||||
icon.FadeColour(colourProvider.Light1, 200, Easing.OutQuint);
|
||||
icon.SetHoveredState(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -107,7 +104,7 @@ namespace osu.Game.Overlays.Comments.Buttons
|
||||
{
|
||||
base.OnHoverLost(e);
|
||||
background.FadeColour(colourProvider.Background2, 200, Easing.OutQuint);
|
||||
icon.FadeColour(colourProvider.Foreground1, 200, Easing.OutQuint);
|
||||
icon.SetHoveredState(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,13 +12,13 @@ using osu.Framework.Allocation;
|
||||
|
||||
namespace osu.Game.Overlays.Comments.Buttons
|
||||
{
|
||||
public class ShowMoreButton : LoadingButton
|
||||
public class ShowMoreRepliesButton : LoadingButton
|
||||
{
|
||||
protected override IEnumerable<Drawable> EffectTargets => new[] { text };
|
||||
|
||||
private OsuSpriteText text;
|
||||
|
||||
public ShowMoreButton()
|
||||
public ShowMoreRepliesButton()
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
LoadingAnimationSize = new Vector2(8);
|
@ -1,7 +1,6 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
|
||||
@ -11,16 +10,6 @@ namespace osu.Game.Overlays.Comments
|
||||
{
|
||||
public readonly BindableInt Current = new BindableInt();
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OverlayColourProvider colourProvider)
|
||||
{
|
||||
Height = 20;
|
||||
|
||||
IdleColour = colourProvider.Background2;
|
||||
HoverColour = colourProvider.Background1;
|
||||
ChevronIconColour = colourProvider.Foreground1;
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
Current.BindValueChanged(onCurrentChanged, true);
|
||||
|
@ -46,7 +46,7 @@ namespace osu.Game.Overlays.Comments
|
||||
private FillFlowContainer childCommentsVisibilityContainer;
|
||||
private FillFlowContainer childCommentsContainer;
|
||||
private LoadRepliesButton loadRepliesButton;
|
||||
private ShowMoreButton showMoreButton;
|
||||
private ShowMoreRepliesButton showMoreButton;
|
||||
private ShowRepliesButton showRepliesButton;
|
||||
private ChevronButton chevronButton;
|
||||
private DeletedCommentsCounter deletedCommentsCounter;
|
||||
@ -213,7 +213,7 @@ namespace osu.Game.Overlays.Comments
|
||||
Top = 10
|
||||
}
|
||||
},
|
||||
showMoreButton = new ShowMoreButton
|
||||
showMoreButton = new ShowMoreRepliesButton
|
||||
{
|
||||
Action = () => RepliesRequested(this, ++currentPage)
|
||||
}
|
||||
|
@ -19,7 +19,6 @@ namespace osu.Game.Overlays
|
||||
{
|
||||
private CancellationTokenSource cancellationToken;
|
||||
|
||||
private Box background;
|
||||
private Container content;
|
||||
private DashboardOverlayHeader header;
|
||||
private LoadingLayer loading;
|
||||
@ -35,9 +34,10 @@ namespace osu.Game.Overlays
|
||||
{
|
||||
Children = new Drawable[]
|
||||
{
|
||||
background = new Box
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = ColourProvider.Background5
|
||||
},
|
||||
scrollFlow = new OverlayScrollContainer
|
||||
{
|
||||
@ -66,8 +66,6 @@ namespace osu.Game.Overlays
|
||||
},
|
||||
loading = new LoadingLayer(content),
|
||||
};
|
||||
|
||||
background.Colour = ColourProvider.Background5;
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
|
@ -236,8 +236,8 @@ namespace osu.Game.Overlays
|
||||
{
|
||||
if (beatmap is Bindable<WorkingBeatmap> working)
|
||||
working.Value = beatmaps.GetWorkingBeatmap(playable.Beatmaps.First(), beatmap.Value);
|
||||
beatmap.Value.Track.Restart();
|
||||
|
||||
restartTrack();
|
||||
return PreviousTrackResult.Previous;
|
||||
}
|
||||
|
||||
@ -262,13 +262,21 @@ namespace osu.Game.Overlays
|
||||
{
|
||||
if (beatmap is Bindable<WorkingBeatmap> working)
|
||||
working.Value = beatmaps.GetWorkingBeatmap(playable.Beatmaps.First(), beatmap.Value);
|
||||
beatmap.Value.Track.Restart();
|
||||
|
||||
restartTrack();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void restartTrack()
|
||||
{
|
||||
// if not scheduled, the previously track will be stopped one frame later (see ScheduleAfterChildren logic in GameBase).
|
||||
// we probably want to move this to a central method for switching to a new working beatmap in the future.
|
||||
Schedule(() => beatmap.Value.Track.Restart());
|
||||
}
|
||||
|
||||
private WorkingBeatmap current;
|
||||
|
||||
private TrackChangeDirection? queuedDirection;
|
||||
|
114
osu.Game/Overlays/News/Displays/FrontPageDisplay.cs
Normal file
@ -0,0 +1,114 @@
|
||||
// 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 System.Threading;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Overlays.News.Displays
|
||||
{
|
||||
public class FrontPageDisplay : CompositeDrawable
|
||||
{
|
||||
[Resolved]
|
||||
private IAPIProvider api { get; set; }
|
||||
|
||||
private FillFlowContainer content;
|
||||
private ShowMoreButton showMore;
|
||||
|
||||
private GetNewsRequest request;
|
||||
private Cursor lastCursor;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
Padding = new MarginPadding
|
||||
{
|
||||
Vertical = 20,
|
||||
Left = 30,
|
||||
Right = 50
|
||||
};
|
||||
|
||||
InternalChild = new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(0, 10),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
content = new FillFlowContainer
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(0, 10)
|
||||
},
|
||||
showMore = new ShowMoreButton
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
Margin = new MarginPadding
|
||||
{
|
||||
Top = 15
|
||||
},
|
||||
Action = performFetch,
|
||||
Alpha = 0
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
performFetch();
|
||||
}
|
||||
|
||||
private void performFetch()
|
||||
{
|
||||
request?.Cancel();
|
||||
|
||||
request = new GetNewsRequest(lastCursor);
|
||||
request.Success += response => Schedule(() => onSuccess(response));
|
||||
api.PerformAsync(request);
|
||||
}
|
||||
|
||||
private CancellationTokenSource cancellationToken;
|
||||
|
||||
private void onSuccess(GetNewsResponse response)
|
||||
{
|
||||
cancellationToken?.Cancel();
|
||||
|
||||
lastCursor = response.Cursor;
|
||||
|
||||
var flow = new FillFlowContainer<NewsCard>
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(0, 10),
|
||||
Children = response.NewsPosts.Select(p => new NewsCard(p)).ToList()
|
||||
};
|
||||
|
||||
LoadComponentAsync(flow, loaded =>
|
||||
{
|
||||
content.Add(loaded);
|
||||
showMore.IsLoading = false;
|
||||
showMore.Show();
|
||||
}, (cancellationToken = new CancellationTokenSource()).Token);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
request?.Cancel();
|
||||
cancellationToken?.Cancel();
|
||||
base.Dispose(isDisposing);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,174 +0,0 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Overlays.News
|
||||
{
|
||||
public class NewsArticleCover : Container
|
||||
{
|
||||
private const int hover_duration = 300;
|
||||
|
||||
private readonly Box gradient;
|
||||
|
||||
public NewsArticleCover(ArticleInfo info)
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
Masking = true;
|
||||
CornerRadius = 4;
|
||||
|
||||
NewsBackground bg;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = ColourInfo.GradientVertical(OsuColour.Gray(0.2f), OsuColour.Gray(0.1f))
|
||||
},
|
||||
new DelayedLoadWrapper(bg = new NewsBackground(info.CoverUrl)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
FillMode = FillMode.Fill,
|
||||
Alpha = 0
|
||||
})
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
gradient = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = ColourInfo.GradientVertical(Color4.Black.Opacity(0.1f), Color4.Black.Opacity(0.7f)),
|
||||
Alpha = 0
|
||||
},
|
||||
new DateContainer(info.Time)
|
||||
{
|
||||
Margin = new MarginPadding
|
||||
{
|
||||
Right = 20,
|
||||
Top = 20,
|
||||
}
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
Margin = new MarginPadding
|
||||
{
|
||||
Left = 25,
|
||||
Bottom = 50,
|
||||
},
|
||||
Font = OsuFont.GetFont(Typeface.Torus, 24, FontWeight.Bold),
|
||||
Text = info.Title,
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
Margin = new MarginPadding
|
||||
{
|
||||
Left = 25,
|
||||
Bottom = 30,
|
||||
},
|
||||
Font = OsuFont.GetFont(Typeface.Torus, 16, FontWeight.Bold),
|
||||
Text = "by " + info.Author
|
||||
}
|
||||
};
|
||||
|
||||
bg.OnLoadComplete += d => d.FadeIn(250, Easing.In);
|
||||
}
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
{
|
||||
gradient.FadeIn(hover_duration, Easing.OutQuint);
|
||||
return base.OnHover(e);
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(HoverLostEvent e)
|
||||
{
|
||||
base.OnHoverLost(e);
|
||||
gradient.FadeOut(hover_duration, Easing.OutQuint);
|
||||
}
|
||||
|
||||
[LongRunningLoad]
|
||||
private class NewsBackground : Sprite
|
||||
{
|
||||
private readonly string url;
|
||||
|
||||
public NewsBackground(string coverUrl)
|
||||
{
|
||||
url = coverUrl ?? "Headers/news";
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(LargeTextureStore store)
|
||||
{
|
||||
Texture = store.Get(url);
|
||||
}
|
||||
}
|
||||
|
||||
private class DateContainer : Container, IHasTooltip
|
||||
{
|
||||
private readonly DateTime date;
|
||||
|
||||
public DateContainer(DateTime date)
|
||||
{
|
||||
this.date = date;
|
||||
|
||||
Anchor = Anchor.TopRight;
|
||||
Origin = Anchor.TopRight;
|
||||
Masking = true;
|
||||
CornerRadius = 4;
|
||||
AutoSizeAxes = Axes.Both;
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Black.Opacity(0.5f),
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Font = OsuFont.GetFont(Typeface.Torus, 12, FontWeight.Bold, false, false),
|
||||
Text = date.ToString("d MMM yyy").ToUpper(),
|
||||
Margin = new MarginPadding
|
||||
{
|
||||
Vertical = 4,
|
||||
Horizontal = 8,
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public string TooltipText => date.ToString("dddd dd MMMM yyyy hh:mm:ss UTCz").ToUpper();
|
||||
}
|
||||
|
||||
// fake API data struct to use for now as a skeleton for data, as there is no API struct for news article info for now
|
||||
public class ArticleInfo
|
||||
{
|
||||
public string Title { get; set; }
|
||||
public string CoverUrl { get; set; }
|
||||
public DateTime Time { get; set; }
|
||||
public string Author { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
@ -11,17 +12,17 @@ using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
|
||||
namespace osu.Game.Overlays.News
|
||||
{
|
||||
public class NewsCard : CompositeDrawable
|
||||
public class NewsCard : OsuHoverContainer
|
||||
{
|
||||
[Resolved]
|
||||
private OverlayColourProvider colourProvider { get; set; }
|
||||
protected override IEnumerable<Drawable> EffectTargets => new[] { background };
|
||||
|
||||
private readonly APINewsPost post;
|
||||
|
||||
@ -31,24 +32,28 @@ namespace osu.Game.Overlays.News
|
||||
public NewsCard(APINewsPost post)
|
||||
{
|
||||
this.post = post;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
Masking = true;
|
||||
CornerRadius = 6;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OverlayColourProvider colourProvider, GameHost host)
|
||||
{
|
||||
if (post.Slug != null)
|
||||
{
|
||||
TooltipText = "view in browser";
|
||||
Action = () => host.OpenUrlExternally("https://osu.ppy.sh/home/news/" + post.Slug);
|
||||
}
|
||||
|
||||
NewsBackground bg;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
AddRange(new Drawable[]
|
||||
{
|
||||
background = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = colourProvider.Background4
|
||||
RelativeSizeAxes = Axes.Both
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
@ -104,9 +109,11 @@ namespace osu.Game.Overlays.News
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
new HoverClickSounds()
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
IdleColour = colourProvider.Background4;
|
||||
HoverColour = colourProvider.Background3;
|
||||
|
||||
bg.OnLoadComplete += d => d.FadeIn(250, Easing.In);
|
||||
|
||||
@ -116,18 +123,6 @@ namespace osu.Game.Overlays.News
|
||||
main.AddText(post.Author, t => t.Font = OsuFont.GetFont(size: 12, weight: FontWeight.SemiBold));
|
||||
}
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
{
|
||||
background.FadeColour(colourProvider.Background3, 200, Easing.OutQuint);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(HoverLostEvent e)
|
||||
{
|
||||
background.FadeColour(colourProvider.Background4, 200, Easing.OutQuint);
|
||||
base.OnHoverLost(e);
|
||||
}
|
||||
|
||||
[LongRunningLoad]
|
||||
private class NewsBackground : Sprite
|
||||
{
|
||||
@ -193,6 +188,8 @@ namespace osu.Game.Overlays.News
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override bool OnClick(ClickEvent e) => true; // Protects the NewsCard from clicks while hovering DateContainer
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,19 +0,0 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
|
||||
namespace osu.Game.Overlays.News
|
||||
{
|
||||
public abstract class NewsContent : FillFlowContainer
|
||||
{
|
||||
protected NewsContent()
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
Direction = FillDirection.Vertical;
|
||||
Padding = new MarginPadding { Bottom = 100, Top = 20, Horizontal = 50 };
|
||||
}
|
||||
}
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using System;
|
||||
|
||||
namespace osu.Game.Overlays.News
|
||||
{
|
||||
@ -11,24 +11,28 @@ namespace osu.Game.Overlays.News
|
||||
{
|
||||
private const string front_page_string = "frontpage";
|
||||
|
||||
public readonly Bindable<string> Post = new Bindable<string>(null);
|
||||
|
||||
public Action ShowFrontPage;
|
||||
|
||||
private readonly Bindable<string> article = new Bindable<string>(null);
|
||||
|
||||
public NewsHeader()
|
||||
{
|
||||
TabControl.AddItem(front_page_string);
|
||||
|
||||
Current.ValueChanged += e =>
|
||||
Current.BindValueChanged(e =>
|
||||
{
|
||||
if (e.NewValue == front_page_string)
|
||||
ShowFrontPage?.Invoke();
|
||||
};
|
||||
});
|
||||
|
||||
Post.ValueChanged += showPost;
|
||||
article.BindValueChanged(onArticleChanged, true);
|
||||
}
|
||||
|
||||
private void showPost(ValueChangedEvent<string> e)
|
||||
public void SetFrontPage() => article.Value = null;
|
||||
|
||||
public void SetArticle(string slug) => article.Value = slug;
|
||||
|
||||
private void onArticleChanged(ValueChangedEvent<string> e)
|
||||
{
|
||||
if (e.OldValue != null)
|
||||
TabControl.RemoveItem(e.OldValue);
|
||||
|
@ -7,18 +7,20 @@ using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Overlays.News;
|
||||
using osu.Game.Overlays.News.Displays;
|
||||
|
||||
namespace osu.Game.Overlays
|
||||
{
|
||||
public class NewsOverlay : FullscreenOverlay
|
||||
{
|
||||
private readonly Bindable<string> article = new Bindable<string>(null);
|
||||
|
||||
private Container content;
|
||||
private LoadingLayer loading;
|
||||
private NewsHeader header;
|
||||
|
||||
private Container<NewsContent> content;
|
||||
|
||||
public readonly Bindable<string> Current = new Bindable<string>(null);
|
||||
private OverlayScrollContainer scrollFlow;
|
||||
|
||||
public NewsOverlay()
|
||||
: base(OverlayColourScheme.Purple)
|
||||
@ -26,18 +28,19 @@ namespace osu.Game.Overlays
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
private void load()
|
||||
{
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = colours.PurpleDarkAlternative
|
||||
Colour = ColourProvider.Background5,
|
||||
},
|
||||
new OverlayScrollContainer
|
||||
scrollFlow = new OverlayScrollContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
ScrollbarVisible = false,
|
||||
Child = new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
@ -49,7 +52,7 @@ namespace osu.Game.Overlays
|
||||
{
|
||||
ShowFrontPage = ShowFrontPage
|
||||
},
|
||||
content = new Container<NewsContent>
|
||||
content = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
@ -57,31 +60,60 @@ namespace osu.Game.Overlays
|
||||
},
|
||||
},
|
||||
},
|
||||
loading = new LoadingLayer(content),
|
||||
};
|
||||
|
||||
header.Post.BindTo(Current);
|
||||
Current.TriggerChange();
|
||||
}
|
||||
|
||||
private CancellationTokenSource loadContentCancellation;
|
||||
|
||||
protected void LoadAndShowContent(NewsContent newContent)
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
content.FadeTo(0.2f, 300, Easing.OutQuint);
|
||||
|
||||
loadContentCancellation?.Cancel();
|
||||
|
||||
LoadComponentAsync(newContent, c =>
|
||||
{
|
||||
content.Child = c;
|
||||
content.FadeIn(300, Easing.OutQuint);
|
||||
}, (loadContentCancellation = new CancellationTokenSource()).Token);
|
||||
base.LoadComplete();
|
||||
article.BindValueChanged(onArticleChanged, true);
|
||||
}
|
||||
|
||||
public void ShowFrontPage()
|
||||
{
|
||||
Current.Value = null;
|
||||
article.Value = null;
|
||||
Show();
|
||||
}
|
||||
|
||||
public void ShowArticle(string slug)
|
||||
{
|
||||
article.Value = slug;
|
||||
Show();
|
||||
}
|
||||
|
||||
private CancellationTokenSource cancellationToken;
|
||||
|
||||
private void onArticleChanged(ValueChangedEvent<string> e)
|
||||
{
|
||||
cancellationToken?.Cancel();
|
||||
loading.Show();
|
||||
|
||||
if (e.NewValue == null)
|
||||
{
|
||||
header.SetFrontPage();
|
||||
LoadDisplay(new FrontPageDisplay());
|
||||
return;
|
||||
}
|
||||
|
||||
header.SetArticle(e.NewValue);
|
||||
LoadDisplay(Empty());
|
||||
}
|
||||
|
||||
protected void LoadDisplay(Drawable display)
|
||||
{
|
||||
scrollFlow.ScrollToStart();
|
||||
LoadComponentAsync(display, loaded =>
|
||||
{
|
||||
content.Child = loaded;
|
||||
loading.Hide();
|
||||
}, (cancellationToken = new CancellationTokenSource()).Token);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
cancellationToken?.Cancel();
|
||||
base.Dispose(isDisposing);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ namespace osu.Game.Overlays.Profile
|
||||
Masking = true,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
coverContainer = new UserCoverBackground
|
||||
coverContainer = new ProfileCoverBackground
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
@ -100,5 +100,10 @@ namespace osu.Game.Overlays.Profile
|
||||
IconTexture = "Icons/profile";
|
||||
}
|
||||
}
|
||||
|
||||
private class ProfileCoverBackground : UserCoverBackground
|
||||
{
|
||||
protected override double LoadDelay => 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,12 +14,13 @@ using osu.Game.Users;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Sections
|
||||
{
|
||||
public abstract class PaginatedContainer<TModel> : FillFlowContainer
|
||||
{
|
||||
private readonly ProfileShowMoreButton moreButton;
|
||||
private readonly ShowMoreButton moreButton;
|
||||
private readonly OsuSpriteText missingText;
|
||||
private APIRequest<List<TModel>> retrievalRequest;
|
||||
private CancellationTokenSource loadCancellation;
|
||||
@ -74,7 +75,7 @@ namespace osu.Game.Overlays.Profile.Sections
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Spacing = new Vector2(0, 2),
|
||||
},
|
||||
moreButton = new ProfileShowMoreButton
|
||||
moreButton = new ShowMoreButton
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
|
@ -1,19 +0,0 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Sections
|
||||
{
|
||||
public class ProfileShowMoreButton : ShowMoreButton
|
||||
{
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OverlayColourProvider colourProvider)
|
||||
{
|
||||
IdleColour = colourProvider.Background2;
|
||||
HoverColour = colourProvider.Background1;
|
||||
ChevronIconColour = colourProvider.Foreground1;
|
||||
}
|
||||
}
|
||||
}
|
@ -116,8 +116,6 @@ namespace osu.Game.Overlays.Settings.Sections
|
||||
private class SkinDropdownControl : DropdownControl
|
||||
{
|
||||
protected override string GenerateItemText(SkinInfo item) => item.ToString();
|
||||
|
||||
protected override DropdownMenu CreateMenu() => base.CreateMenu().With(m => m.MaxHeight = 200);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,8 @@ namespace osu.Game.Overlays.Settings
|
||||
Margin = new MarginPadding { Top = 5 };
|
||||
RelativeSizeAxes = Axes.X;
|
||||
}
|
||||
|
||||
protected override DropdownMenu CreateMenu() => base.CreateMenu().With(m => m.MaxHeight = 200);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -69,6 +69,7 @@ namespace osu.Game.Overlays.Toolbar
|
||||
AutoSizeAxes = Axes.X,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new ToolbarNewsButton(),
|
||||
new ToolbarChangelogButton(),
|
||||
new ToolbarRankingsButton(),
|
||||
new ToolbarBeatmapListingButton(),
|
||||
|
22
osu.Game/Overlays/Toolbar/ToolbarNewsButton.cs
Normal file
@ -0,0 +1,22 @@
|
||||
// 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.Allocation;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
|
||||
namespace osu.Game.Overlays.Toolbar
|
||||
{
|
||||
public class ToolbarNewsButton : ToolbarOverlayToggleButton
|
||||
{
|
||||
public ToolbarNewsButton()
|
||||
{
|
||||
Icon = FontAwesome.Solid.Newspaper;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(NewsOverlay news)
|
||||
{
|
||||
StateContainer = news;
|
||||
}
|
||||
}
|
||||
}
|
@ -65,11 +65,15 @@ namespace osu.Game.Rulesets
|
||||
// the requesting assembly may be located out of the executable's base directory, thus requiring manual resolving of its dependencies.
|
||||
// this attempts resolving the ruleset dependencies on game core and framework assemblies by returning assemblies with the same assembly name
|
||||
// already loaded in the AppDomain.
|
||||
foreach (var curAsm in AppDomain.CurrentDomain.GetAssemblies())
|
||||
{
|
||||
if (asm.Name.Equals(curAsm.GetName().Name, StringComparison.Ordinal))
|
||||
return curAsm;
|
||||
}
|
||||
var domainAssembly = AppDomain.CurrentDomain.GetAssemblies()
|
||||
// Given name is always going to be equally-or-more qualified than the assembly name.
|
||||
.Where(a => args.Name.Contains(a.GetName().Name, StringComparison.Ordinal))
|
||||
// Pick the greatest assembly version.
|
||||
.OrderByDescending(a => a.GetName().Version)
|
||||
.FirstOrDefault();
|
||||
|
||||
if (domainAssembly != null)
|
||||
return domainAssembly;
|
||||
|
||||
return loadedAssemblies.Keys.FirstOrDefault(a => a.FullName == asm.FullName);
|
||||
}
|
||||
|
@ -179,6 +179,13 @@ namespace osu.Game.Scoring
|
||||
[JsonIgnore]
|
||||
public bool DeletePending { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The position of this score, starting at 1.
|
||||
/// </summary>
|
||||
[NotMapped]
|
||||
[JsonProperty("position")]
|
||||
public int? Position { get; set; }
|
||||
|
||||
[Serializable]
|
||||
protected class DeserializedMod : IMod
|
||||
{
|
||||
|
@ -58,7 +58,7 @@ namespace osu.Game.Screens.Multi.Play
|
||||
if (!playlistItem.RequiredMods.All(m => Mods.Value.Any(m.Equals)))
|
||||
throw new InvalidOperationException("Current Mods do not match PlaylistItem's RequiredMods");
|
||||
|
||||
var req = new CreateRoomScoreRequest(roomId.Value ?? 0, playlistItem.ID);
|
||||
var req = new CreateRoomScoreRequest(roomId.Value ?? 0, playlistItem.ID, Game.VersionHash);
|
||||
req.Success += r => token = r.ID;
|
||||
req.Failure += e =>
|
||||
{
|
||||
|
@ -3,7 +3,9 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
@ -20,7 +22,15 @@ namespace osu.Game.Screens.Multi.Ranking
|
||||
private readonly int roomId;
|
||||
private readonly PlaylistItem playlistItem;
|
||||
|
||||
private LoadingSpinner loadingLayer;
|
||||
protected LoadingSpinner LeftSpinner { get; private set; }
|
||||
protected LoadingSpinner CentreSpinner { get; private set; }
|
||||
protected LoadingSpinner RightSpinner { get; private set; }
|
||||
|
||||
private MultiplayerScores higherScores;
|
||||
private MultiplayerScores lowerScores;
|
||||
|
||||
[Resolved]
|
||||
private IAPIProvider api { get; set; }
|
||||
|
||||
public TimeshiftResultsScreen(ScoreInfo score, int roomId, PlaylistItem playlistItem, bool allowRetry = true)
|
||||
: base(score, allowRetry)
|
||||
@ -32,29 +42,209 @@ namespace osu.Game.Screens.Multi.Ranking
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
AddInternal(loadingLayer = new LoadingLayer
|
||||
AddInternal(new Container
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
X = -10,
|
||||
State = { Value = Score == null ? Visibility.Visible : Visibility.Hidden },
|
||||
Padding = new MarginPadding { Bottom = TwoLayerButton.SIZE_EXTENDED.Y }
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding { Bottom = TwoLayerButton.SIZE_EXTENDED.Y },
|
||||
Children = new Drawable[]
|
||||
{
|
||||
LeftSpinner = new PanelListLoadingSpinner(ScorePanelList)
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.Centre,
|
||||
},
|
||||
CentreSpinner = new PanelListLoadingSpinner(ScorePanelList)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
State = { Value = Score == null ? Visibility.Visible : Visibility.Hidden },
|
||||
},
|
||||
RightSpinner = new PanelListLoadingSpinner(ScorePanelList)
|
||||
{
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.Centre,
|
||||
},
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected override APIRequest FetchScores(Action<IEnumerable<ScoreInfo>> scoresCallback)
|
||||
{
|
||||
var req = new GetRoomPlaylistScoresRequest(roomId, playlistItem.ID);
|
||||
// This performs two requests:
|
||||
// 1. A request to show the user's score (and scores around).
|
||||
// 2. If that fails, a request to index the room starting from the highest score.
|
||||
|
||||
req.Success += r =>
|
||||
var userScoreReq = new ShowPlaylistUserScoreRequest(roomId, playlistItem.ID, api.LocalUser.Value.Id);
|
||||
|
||||
userScoreReq.Success += userScore =>
|
||||
{
|
||||
scoresCallback?.Invoke(r.Scores.Where(s => s.ID != Score?.OnlineScoreID).Select(s => s.CreateScoreInfo(playlistItem)));
|
||||
loadingLayer.Hide();
|
||||
var allScores = new List<MultiplayerScore> { userScore };
|
||||
|
||||
if (userScore.ScoresAround?.Higher != null)
|
||||
{
|
||||
allScores.AddRange(userScore.ScoresAround.Higher.Scores);
|
||||
higherScores = userScore.ScoresAround.Higher;
|
||||
|
||||
Debug.Assert(userScore.Position != null);
|
||||
setPositions(higherScores, userScore.Position.Value, -1);
|
||||
}
|
||||
|
||||
if (userScore.ScoresAround?.Lower != null)
|
||||
{
|
||||
allScores.AddRange(userScore.ScoresAround.Lower.Scores);
|
||||
lowerScores = userScore.ScoresAround.Lower;
|
||||
|
||||
Debug.Assert(userScore.Position != null);
|
||||
setPositions(lowerScores, userScore.Position.Value, 1);
|
||||
}
|
||||
|
||||
performSuccessCallback(scoresCallback, allScores);
|
||||
};
|
||||
|
||||
req.Failure += _ => loadingLayer.Hide();
|
||||
// On failure, fallback to a normal index.
|
||||
userScoreReq.Failure += _ => api.Queue(createIndexRequest(scoresCallback));
|
||||
|
||||
return req;
|
||||
return userScoreReq;
|
||||
}
|
||||
|
||||
protected override APIRequest FetchNextPage(int direction, Action<IEnumerable<ScoreInfo>> scoresCallback)
|
||||
{
|
||||
Debug.Assert(direction == 1 || direction == -1);
|
||||
|
||||
MultiplayerScores pivot = direction == -1 ? higherScores : lowerScores;
|
||||
|
||||
if (pivot?.Cursor == null)
|
||||
return null;
|
||||
|
||||
if (pivot == higherScores)
|
||||
LeftSpinner.Show();
|
||||
else
|
||||
RightSpinner.Show();
|
||||
|
||||
return createIndexRequest(scoresCallback, pivot);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a <see cref="IndexPlaylistScoresRequest"/> with an optional score pivot.
|
||||
/// </summary>
|
||||
/// <remarks>Does not queue the request.</remarks>
|
||||
/// <param name="scoresCallback">The callback to perform with the resulting scores.</param>
|
||||
/// <param name="pivot">An optional score pivot to retrieve scores around. Can be null to retrieve scores from the highest score.</param>
|
||||
/// <returns>The indexing <see cref="APIRequest"/>.</returns>
|
||||
private APIRequest createIndexRequest(Action<IEnumerable<ScoreInfo>> scoresCallback, [CanBeNull] MultiplayerScores pivot = null)
|
||||
{
|
||||
var indexReq = pivot != null
|
||||
? new IndexPlaylistScoresRequest(roomId, playlistItem.ID, pivot.Cursor, pivot.Params)
|
||||
: new IndexPlaylistScoresRequest(roomId, playlistItem.ID);
|
||||
|
||||
indexReq.Success += r =>
|
||||
{
|
||||
if (pivot == lowerScores)
|
||||
{
|
||||
lowerScores = r;
|
||||
setPositions(r, pivot, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
higherScores = r;
|
||||
setPositions(r, pivot, -1);
|
||||
}
|
||||
|
||||
performSuccessCallback(scoresCallback, r.Scores, r);
|
||||
};
|
||||
|
||||
indexReq.Failure += _ => hideLoadingSpinners(pivot);
|
||||
|
||||
return indexReq;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Transforms returned <see cref="MultiplayerScores"/> into <see cref="ScoreInfo"/>s, ensure the <see cref="ScorePanelList"/> is put into a sane state, and invokes a given success callback.
|
||||
/// </summary>
|
||||
/// <param name="callback">The callback to invoke with the final <see cref="ScoreInfo"/>s.</param>
|
||||
/// <param name="scores">The <see cref="MultiplayerScore"/>s that were retrieved from <see cref="APIRequest"/>s.</param>
|
||||
/// <param name="pivot">An optional pivot around which the scores were retrieved.</param>
|
||||
private void performSuccessCallback([NotNull] Action<IEnumerable<ScoreInfo>> callback, [NotNull] List<MultiplayerScore> scores, [CanBeNull] MultiplayerScores pivot = null)
|
||||
{
|
||||
var scoreInfos = new List<ScoreInfo>(scores.Select(s => s.CreateScoreInfo(playlistItem)));
|
||||
|
||||
// Select a score if we don't already have one selected.
|
||||
// Note: This is done before the callback so that the panel list centres on the selected score before panels are added (eliminating initial scroll).
|
||||
if (SelectedScore.Value == null)
|
||||
{
|
||||
Schedule(() =>
|
||||
{
|
||||
// Prefer selecting the local user's score, or otherwise default to the first visible score.
|
||||
SelectedScore.Value = scoreInfos.FirstOrDefault(s => s.User.Id == api.LocalUser.Value.Id) ?? scoreInfos.FirstOrDefault();
|
||||
});
|
||||
}
|
||||
|
||||
// Invoke callback to add the scores. Exclude the user's current score which was added previously.
|
||||
callback.Invoke(scoreInfos.Where(s => s.OnlineScoreID != Score?.OnlineScoreID));
|
||||
|
||||
hideLoadingSpinners(pivot);
|
||||
}
|
||||
|
||||
private void hideLoadingSpinners([CanBeNull] MultiplayerScores pivot = null)
|
||||
{
|
||||
CentreSpinner.Hide();
|
||||
|
||||
if (pivot == lowerScores)
|
||||
RightSpinner.Hide();
|
||||
else if (pivot == higherScores)
|
||||
LeftSpinner.Hide();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Applies positions to all <see cref="MultiplayerScore"/>s referenced to a given pivot.
|
||||
/// </summary>
|
||||
/// <param name="scores">The <see cref="MultiplayerScores"/> to set positions on.</param>
|
||||
/// <param name="pivot">The pivot.</param>
|
||||
/// <param name="increment">The amount to increment the pivot position by for each <see cref="MultiplayerScore"/> in <paramref name="scores"/>.</param>
|
||||
private void setPositions([NotNull] MultiplayerScores scores, [CanBeNull] MultiplayerScores pivot, int increment)
|
||||
=> setPositions(scores, pivot?.Scores[^1].Position ?? 0, increment);
|
||||
|
||||
/// <summary>
|
||||
/// Applies positions to all <see cref="MultiplayerScore"/>s referenced to a given pivot.
|
||||
/// </summary>
|
||||
/// <param name="scores">The <see cref="MultiplayerScores"/> to set positions on.</param>
|
||||
/// <param name="pivotPosition">The pivot position.</param>
|
||||
/// <param name="increment">The amount to increment the pivot position by for each <see cref="MultiplayerScore"/> in <paramref name="scores"/>.</param>
|
||||
private void setPositions([NotNull] MultiplayerScores scores, int pivotPosition, int increment)
|
||||
{
|
||||
foreach (var s in scores.Scores)
|
||||
{
|
||||
pivotPosition += increment;
|
||||
s.Position = pivotPosition;
|
||||
}
|
||||
}
|
||||
|
||||
private class PanelListLoadingSpinner : LoadingSpinner
|
||||
{
|
||||
private readonly ScorePanelList list;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="PanelListLoadingSpinner"/>.
|
||||
/// </summary>
|
||||
/// <param name="list">The list to track.</param>
|
||||
/// <param name="withBox">Whether the spinner should have a surrounding black box for visibility.</param>
|
||||
public PanelListLoadingSpinner(ScorePanelList list, bool withBox = true)
|
||||
: base(withBox)
|
||||
{
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
float panelOffset = list.DrawWidth / 2 - ScorePanel.EXPANDED_WIDTH;
|
||||
|
||||
if ((Anchor & Anchor.x0) > 0)
|
||||
X = (float)(panelOffset - list.Current);
|
||||
else if ((Anchor & Anchor.x2) > 0)
|
||||
X = (float)(list.ScrollableExtent - list.Current - panelOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Scoring;
|
||||
|
||||
namespace osu.Game.Screens.Ranking.Contracted
|
||||
{
|
||||
public class ContractedPanelTopContent : CompositeDrawable
|
||||
{
|
||||
private readonly ScoreInfo score;
|
||||
|
||||
public ContractedPanelTopContent(ScoreInfo score)
|
||||
{
|
||||
this.score = score;
|
||||
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
InternalChild = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
Y = 6,
|
||||
Text = score.Position != null ? $"#{score.Position}" : string.Empty,
|
||||
Font = OsuFont.GetFont(size: 18, weight: FontWeight.Bold)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -37,7 +37,8 @@ namespace osu.Game.Screens.Ranking
|
||||
public readonly Bindable<ScoreInfo> SelectedScore = new Bindable<ScoreInfo>();
|
||||
|
||||
public readonly ScoreInfo Score;
|
||||
private readonly bool allowRetry;
|
||||
|
||||
protected ScorePanelList ScorePanelList { get; private set; }
|
||||
|
||||
[Resolved(CanBeNull = true)]
|
||||
private Player player { get; set; }
|
||||
@ -47,9 +48,13 @@ namespace osu.Game.Screens.Ranking
|
||||
|
||||
private StatisticsPanel statisticsPanel;
|
||||
private Drawable bottomPanel;
|
||||
private ScorePanelList scorePanelList;
|
||||
private Container<ScorePanel> detachedPanelContainer;
|
||||
|
||||
private bool fetchedInitialScores;
|
||||
private APIRequest nextPageRequest;
|
||||
|
||||
private readonly bool allowRetry;
|
||||
|
||||
protected ResultsScreen(ScoreInfo score, bool allowRetry = true)
|
||||
{
|
||||
Score = score;
|
||||
@ -84,7 +89,7 @@ namespace osu.Game.Screens.Ranking
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Score = { BindTarget = SelectedScore }
|
||||
},
|
||||
scorePanelList = new ScorePanelList
|
||||
ScorePanelList = new ScorePanelList
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
SelectedScore = { BindTarget = SelectedScore },
|
||||
@ -142,7 +147,7 @@ namespace osu.Game.Screens.Ranking
|
||||
};
|
||||
|
||||
if (Score != null)
|
||||
scorePanelList.AddScore(Score);
|
||||
ScorePanelList.AddScore(Score);
|
||||
|
||||
if (player != null && allowRetry)
|
||||
{
|
||||
@ -164,11 +169,7 @@ namespace osu.Game.Screens.Ranking
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
var req = FetchScores(scores => Schedule(() =>
|
||||
{
|
||||
foreach (var s in scores)
|
||||
addScore(s);
|
||||
}));
|
||||
var req = FetchScores(fetchScoresCallback);
|
||||
|
||||
if (req != null)
|
||||
api.Queue(req);
|
||||
@ -176,6 +177,28 @@ namespace osu.Game.Screens.Ranking
|
||||
statisticsPanel.State.BindValueChanged(onStatisticsStateChanged, true);
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
if (fetchedInitialScores && nextPageRequest == null)
|
||||
{
|
||||
if (ScorePanelList.IsScrolledToStart)
|
||||
nextPageRequest = FetchNextPage(-1, fetchScoresCallback);
|
||||
else if (ScorePanelList.IsScrolledToEnd)
|
||||
nextPageRequest = FetchNextPage(1, fetchScoresCallback);
|
||||
|
||||
if (nextPageRequest != null)
|
||||
{
|
||||
// Scheduled after children to give the list a chance to update its scroll position and not potentially trigger a second request too early.
|
||||
nextPageRequest.Success += () => ScheduleAfterChildren(() => nextPageRequest = null);
|
||||
nextPageRequest.Failure += _ => ScheduleAfterChildren(() => nextPageRequest = null);
|
||||
|
||||
api.Queue(nextPageRequest);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs a fetch/refresh of scores to be displayed.
|
||||
/// </summary>
|
||||
@ -183,6 +206,22 @@ namespace osu.Game.Screens.Ranking
|
||||
/// <returns>An <see cref="APIRequest"/> responsible for the fetch operation. This will be queued and performed automatically.</returns>
|
||||
protected virtual APIRequest FetchScores(Action<IEnumerable<ScoreInfo>> scoresCallback) => null;
|
||||
|
||||
/// <summary>
|
||||
/// Performs a fetch of the next page of scores. This is invoked every frame until a non-null <see cref="APIRequest"/> is returned.
|
||||
/// </summary>
|
||||
/// <param name="direction">The fetch direction. -1 to fetch scores greater than the current start of the list, and 1 to fetch scores lower than the current end of the list.</param>
|
||||
/// <param name="scoresCallback">A callback which should be called when fetching is completed. Scheduling is not required.</param>
|
||||
/// <returns>An <see cref="APIRequest"/> responsible for the fetch operation. This will be queued and performed automatically.</returns>
|
||||
protected virtual APIRequest FetchNextPage(int direction, Action<IEnumerable<ScoreInfo>> scoresCallback) => null;
|
||||
|
||||
private void fetchScoresCallback(IEnumerable<ScoreInfo> scores) => Schedule(() =>
|
||||
{
|
||||
foreach (var s in scores)
|
||||
addScore(s);
|
||||
|
||||
fetchedInitialScores = true;
|
||||
});
|
||||
|
||||
public override void OnEntering(IScreen last)
|
||||
{
|
||||
base.OnEntering(last);
|
||||
@ -213,7 +252,7 @@ namespace osu.Game.Screens.Ranking
|
||||
|
||||
private void addScore(ScoreInfo score)
|
||||
{
|
||||
var panel = scorePanelList.AddScore(score);
|
||||
var panel = ScorePanelList.AddScore(score);
|
||||
|
||||
if (detachedPanel != null)
|
||||
panel.Alpha = 0;
|
||||
@ -226,11 +265,11 @@ namespace osu.Game.Screens.Ranking
|
||||
if (state.NewValue == Visibility.Visible)
|
||||
{
|
||||
// Detach the panel in its original location, and move into the desired location in the local container.
|
||||
var expandedPanel = scorePanelList.GetPanelForScore(SelectedScore.Value);
|
||||
var expandedPanel = ScorePanelList.GetPanelForScore(SelectedScore.Value);
|
||||
var screenSpacePos = expandedPanel.ScreenSpaceDrawQuad.TopLeft;
|
||||
|
||||
// Detach and move into the local container.
|
||||
scorePanelList.Detach(expandedPanel);
|
||||
ScorePanelList.Detach(expandedPanel);
|
||||
detachedPanelContainer.Add(expandedPanel);
|
||||
|
||||
// Move into its original location in the local container first, then to the final location.
|
||||
@ -240,9 +279,9 @@ namespace osu.Game.Screens.Ranking
|
||||
.MoveTo(new Vector2(StatisticsPanel.SIDE_PADDING, origLocation.Y), 150, Easing.OutQuint);
|
||||
|
||||
// Hide contracted panels.
|
||||
foreach (var contracted in scorePanelList.GetScorePanels().Where(p => p.State == PanelState.Contracted))
|
||||
foreach (var contracted in ScorePanelList.GetScorePanels().Where(p => p.State == PanelState.Contracted))
|
||||
contracted.FadeOut(150, Easing.OutQuint);
|
||||
scorePanelList.HandleInput = false;
|
||||
ScorePanelList.HandleInput = false;
|
||||
|
||||
// Dim background.
|
||||
Background.FadeTo(0.1f, 150);
|
||||
@ -255,7 +294,7 @@ namespace osu.Game.Screens.Ranking
|
||||
|
||||
// Remove from the local container and re-attach.
|
||||
detachedPanelContainer.Remove(detachedPanel);
|
||||
scorePanelList.Attach(detachedPanel);
|
||||
ScorePanelList.Attach(detachedPanel);
|
||||
|
||||
// Move into its original location in the attached container first, then to the final location.
|
||||
var origLocation = detachedPanel.Parent.ToLocalSpace(screenSpacePos);
|
||||
@ -264,9 +303,9 @@ namespace osu.Game.Screens.Ranking
|
||||
.MoveTo(new Vector2(0, origLocation.Y), 150, Easing.OutQuint);
|
||||
|
||||
// Show contracted panels.
|
||||
foreach (var contracted in scorePanelList.GetScorePanels().Where(p => p.State == PanelState.Contracted))
|
||||
foreach (var contracted in ScorePanelList.GetScorePanels().Where(p => p.State == PanelState.Contracted))
|
||||
contracted.FadeIn(150, Easing.OutQuint);
|
||||
scorePanelList.HandleInput = true;
|
||||
ScorePanelList.HandleInput = true;
|
||||
|
||||
// Un-dim background.
|
||||
Background.FadeTo(0.5f, 150);
|
||||
|
@ -151,7 +151,7 @@ namespace osu.Game.Screens.Ranking
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
User = Score.User,
|
||||
Colour = ColourInfo.GradientVertical(Color4.White.Opacity(0.5f), Color4Extensions.FromHex("#444").Opacity(0))
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
middleLayerContentContainer = new Container { RelativeSizeAxes = Axes.Both }
|
||||
@ -203,8 +203,8 @@ namespace osu.Game.Screens.Ranking
|
||||
topLayerBackground.FadeColour(expanded_top_layer_colour, resize_duration, Easing.OutQuint);
|
||||
middleLayerBackground.FadeColour(expanded_middle_layer_colour, resize_duration, Easing.OutQuint);
|
||||
|
||||
topLayerContentContainer.Add(middleLayerContent = new ExpandedPanelTopContent(Score.User).With(d => d.Alpha = 0));
|
||||
middleLayerContentContainer.Add(topLayerContent = new ExpandedPanelMiddleContent(Score).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));
|
||||
break;
|
||||
|
||||
case PanelState.Contracted:
|
||||
@ -213,7 +213,8 @@ namespace osu.Game.Screens.Ranking
|
||||
topLayerBackground.FadeColour(contracted_top_layer_colour, resize_duration, Easing.OutQuint);
|
||||
middleLayerBackground.FadeColour(contracted_middle_layer_colour, resize_duration, Easing.OutQuint);
|
||||
|
||||
middleLayerContentContainer.Add(topLayerContent = new ContractedPanelMiddleContent(Score).With(d => d.Alpha = 0));
|
||||
topLayerContentContainer.Add(topLayerContent = new ContractedPanelTopContent(Score).With(d => d.Alpha = 0));
|
||||
middleLayerContentContainer.Add(middleLayerContent = new ContractedPanelMiddleContent(Score).With(d => d.Alpha = 0));
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,31 @@ namespace osu.Game.Screens.Ranking
|
||||
/// </summary>
|
||||
private const float expanded_panel_spacing = 15;
|
||||
|
||||
/// <summary>
|
||||
/// Minimum distance from either end point of the list that the list can be considered scrolled to the end point.
|
||||
/// </summary>
|
||||
private const float scroll_endpoint_distance = 100;
|
||||
|
||||
/// <summary>
|
||||
/// Whether this <see cref="ScorePanelList"/> can be scrolled and is currently scrolled to the start.
|
||||
/// </summary>
|
||||
public bool IsScrolledToStart => flow.Count > 0 && scroll.ScrollableExtent > 0 && scroll.Current <= scroll_endpoint_distance;
|
||||
|
||||
/// <summary>
|
||||
/// Whether this <see cref="ScorePanelList"/> can be scrolled and is currently scrolled to the end.
|
||||
/// </summary>
|
||||
public bool IsScrolledToEnd => flow.Count > 0 && scroll.ScrollableExtent > 0 && scroll.IsScrolledToEnd(scroll_endpoint_distance);
|
||||
|
||||
/// <summary>
|
||||
/// The current scroll position.
|
||||
/// </summary>
|
||||
public double Current => scroll.Current;
|
||||
|
||||
/// <summary>
|
||||
/// The scrollable extent.
|
||||
/// </summary>
|
||||
public double ScrollableExtent => scroll.ScrollableExtent;
|
||||
|
||||
/// <summary>
|
||||
/// An action to be invoked if a <see cref="ScorePanel"/> is clicked while in an expanded state.
|
||||
/// </summary>
|
||||
|
@ -14,6 +14,7 @@ namespace osu.Game.Skinning
|
||||
public class LegacyBeatmapSkin : LegacySkin
|
||||
{
|
||||
protected override bool AllowManiaSkin => false;
|
||||
protected override bool UseCustomSampleBanks => true;
|
||||
|
||||
public LegacyBeatmapSkin(BeatmapInfo beatmap, IResourceStore<byte[]> storage, AudioManager audioManager)
|
||||
: base(createSkinInfo(beatmap), new LegacySkinResourceStore<BeatmapSetFileInfo>(beatmap.BeatmapSet, storage), audioManager, beatmap.Path)
|
||||
|
@ -38,6 +38,12 @@ namespace osu.Game.Skinning
|
||||
|
||||
protected virtual bool AllowManiaSkin => hasKeyTexture.Value;
|
||||
|
||||
/// <summary>
|
||||
/// Whether this skin can use samples with a custom bank (custom sample set in stable terminology).
|
||||
/// Added in order to match sample lookup logic from stable (in stable, only the beatmap skin could use samples with a custom sample bank).
|
||||
/// </summary>
|
||||
protected virtual bool UseCustomSampleBanks => false;
|
||||
|
||||
public new LegacySkinConfiguration Configuration
|
||||
{
|
||||
get => base.Configuration as LegacySkinConfiguration;
|
||||
@ -348,7 +354,12 @@ namespace osu.Game.Skinning
|
||||
|
||||
public override SampleChannel GetSample(ISampleInfo sampleInfo)
|
||||
{
|
||||
foreach (var lookup in sampleInfo.LookupNames)
|
||||
var lookupNames = sampleInfo.LookupNames;
|
||||
|
||||
if (sampleInfo is HitSampleInfo hitSample)
|
||||
lookupNames = getLegacyLookupNames(hitSample);
|
||||
|
||||
foreach (var lookup in lookupNames)
|
||||
{
|
||||
var sample = Samples?.Get(lookup);
|
||||
|
||||
@ -356,10 +367,6 @@ namespace osu.Game.Skinning
|
||||
return sample;
|
||||
}
|
||||
|
||||
if (sampleInfo is HitSampleInfo hsi)
|
||||
// Try fallback to non-bank samples.
|
||||
return Samples?.Get(hsi.Name);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -372,5 +379,23 @@ namespace osu.Game.Skinning
|
||||
string lastPiece = componentName.Split('/').Last();
|
||||
yield return componentName.StartsWith("Gameplay/taiko/") ? "taiko-" + lastPiece : lastPiece;
|
||||
}
|
||||
|
||||
private IEnumerable<string> getLegacyLookupNames(HitSampleInfo hitSample)
|
||||
{
|
||||
var lookupNames = hitSample.LookupNames;
|
||||
|
||||
if (!UseCustomSampleBanks && !string.IsNullOrEmpty(hitSample.Suffix))
|
||||
// for compatibility with stable, exclude the lookup names with the custom sample bank suffix, if they are not valid for use in this skin.
|
||||
// using .EndsWith() is intentional as it ensures parity in all edge cases
|
||||
// (see LegacyTaikoSampleInfo for an example of one - prioritising the taiko prefix should still apply, but the sample bank should not).
|
||||
lookupNames = hitSample.LookupNames.Where(name => !name.EndsWith(hitSample.Suffix));
|
||||
|
||||
// also for compatibility, try falling back to non-bank samples (so-called "universal" samples) as the last resort.
|
||||
// going forward specifying banks shall always be required, even for elements that wouldn't require it on stable,
|
||||
// which is why this is done locally here.
|
||||
lookupNames = lookupNames.Append(hitSample.Name);
|
||||
|
||||
return lookupNames;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -37,6 +37,8 @@ namespace osu.Game.Tests
|
||||
Statistics[HitResult.Meh] = 50;
|
||||
Statistics[HitResult.Good] = 100;
|
||||
Statistics[HitResult.Great] = 300;
|
||||
|
||||
Position = 1;
|
||||
}
|
||||
|
||||
private class TestModHardRock : ModHardRock
|
||||
|
@ -1,6 +1,7 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
@ -23,6 +24,16 @@ namespace osu.Game.Users
|
||||
|
||||
protected override Drawable CreateDrawable(User user) => new Cover(user);
|
||||
|
||||
protected override double LoadDelay => 300;
|
||||
|
||||
/// <summary>
|
||||
/// Delay before the background is unloaded while off-screen.
|
||||
/// </summary>
|
||||
protected virtual double UnloadDelay => 5000;
|
||||
|
||||
protected override DelayedLoadWrapper CreateDelayedLoadWrapper(Func<Drawable> createContentFunc, double timeBeforeLoad)
|
||||
=> new DelayedLoadUnloadWrapper(createContentFunc, timeBeforeLoad, UnloadDelay);
|
||||
|
||||
[LongRunningLoad]
|
||||
private class Cover : CompositeDrawable
|
||||
{
|
||||
|
@ -4,7 +4,6 @@
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
@ -25,7 +24,7 @@ namespace osu.Game.Users
|
||||
|
||||
protected Action ViewProfile { get; private set; }
|
||||
|
||||
protected DelayedLoadUnloadWrapper Background { get; private set; }
|
||||
protected Drawable Background { get; private set; }
|
||||
|
||||
protected UserPanel(User user)
|
||||
{
|
||||
@ -56,17 +55,12 @@ namespace osu.Game.Users
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = ColourProvider?.Background5 ?? Colours.Gray1
|
||||
},
|
||||
Background = new DelayedLoadUnloadWrapper(() => new UserCoverBackground
|
||||
Background = new UserCoverBackground
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
User = User,
|
||||
}, 300, 5000)
|
||||
{
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
CreateLayout()
|
||||
});
|
||||
|
@ -24,8 +24,8 @@
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2020.723.0" />
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.727.1" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2020.730.1" />
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.731.0" />
|
||||
<PackageReference Include="Sentry" Version="2.1.5" />
|
||||
<PackageReference Include="SharpCompress" Version="0.26.0" />
|
||||
<PackageReference Include="NUnit" Version="3.12.0" />
|
||||
|
@ -70,8 +70,8 @@
|
||||
<Reference Include="System.Net.Http" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Label="Package References">
|
||||
<PackageReference Include="ppy.osu.Framework.iOS" Version="2020.723.0" />
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.727.1" />
|
||||
<PackageReference Include="ppy.osu.Framework.iOS" Version="2020.730.1" />
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.731.0" />
|
||||
</ItemGroup>
|
||||
<!-- Xamarin.iOS does not automatically handle transitive dependencies from NuGet packages. -->
|
||||
<ItemGroup Label="Transitive Dependencies">
|
||||
@ -80,7 +80,7 @@
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2020.723.0" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2020.730.1" />
|
||||
<PackageReference Include="SharpCompress" Version="0.26.0" />
|
||||
<PackageReference Include="NUnit" Version="3.12.0" />
|
||||
<PackageReference Include="SharpRaven" Version="2.4.0" />
|
||||
|