mirror of
https://github.com/ppy/osu
synced 2025-03-05 10:58:34 +00:00
Merge pull request #29055 from peppy/event-feed-improvements
Improve daily challenge event feed
This commit is contained in:
commit
e489ae8f72
@ -6,6 +6,7 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Framework.Extensions.ObjectExtensions;
|
using osu.Framework.Extensions.ObjectExtensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Framework.Testing;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
@ -17,14 +18,14 @@ namespace osu.Game.Tests.Visual.DailyChallenge
|
|||||||
{
|
{
|
||||||
public partial class TestSceneDailyChallengeEventFeed : OsuTestScene
|
public partial class TestSceneDailyChallengeEventFeed : OsuTestScene
|
||||||
{
|
{
|
||||||
|
private DailyChallengeEventFeed feed = null!;
|
||||||
|
|
||||||
[Cached]
|
[Cached]
|
||||||
private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Plum);
|
private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Plum);
|
||||||
|
|
||||||
[Test]
|
[SetUpSteps]
|
||||||
public void TestBasicAppearance()
|
public void SetUpSteps()
|
||||||
{
|
{
|
||||||
DailyChallengeEventFeed feed = null!;
|
|
||||||
|
|
||||||
AddStep("create content", () => Children = new Drawable[]
|
AddStep("create content", () => Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new Box
|
new Box
|
||||||
@ -35,22 +36,28 @@ namespace osu.Game.Tests.Visual.DailyChallenge
|
|||||||
feed = new DailyChallengeEventFeed
|
feed = new DailyChallengeEventFeed
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Height = 0.3f,
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
AddSliderStep("adjust width", 0.1f, 1, 1, width =>
|
AddSliderStep("adjust width", 0.1f, 1, 1, width =>
|
||||||
{
|
{
|
||||||
if (feed.IsNotNull())
|
if (feed.IsNotNull())
|
||||||
feed.Width = width;
|
feed.Width = width;
|
||||||
});
|
});
|
||||||
AddSliderStep("adjust height", 0.1f, 1, 1, height =>
|
AddSliderStep("adjust height", 0.1f, 1, 0.3f, height =>
|
||||||
{
|
{
|
||||||
if (feed.IsNotNull())
|
if (feed.IsNotNull())
|
||||||
feed.Height = height;
|
feed.Height = height;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
AddStep("add normal score", () =>
|
[Test]
|
||||||
|
public void TestBasicAppearance()
|
||||||
|
{
|
||||||
|
AddRepeatStep("add normal score", () =>
|
||||||
{
|
{
|
||||||
var ev = new NewScoreEvent(1, new APIUser
|
var ev = new NewScoreEvent(1, new APIUser
|
||||||
{
|
{
|
||||||
@ -60,9 +67,9 @@ namespace osu.Game.Tests.Visual.DailyChallenge
|
|||||||
}, RNG.Next(1_000_000), null);
|
}, RNG.Next(1_000_000), null);
|
||||||
|
|
||||||
feed.AddNewScore(ev);
|
feed.AddNewScore(ev);
|
||||||
});
|
}, 50);
|
||||||
|
|
||||||
AddStep("add new user best", () =>
|
AddRepeatStep("add new user best", () =>
|
||||||
{
|
{
|
||||||
var ev = new NewScoreEvent(1, new APIUser
|
var ev = new NewScoreEvent(1, new APIUser
|
||||||
{
|
{
|
||||||
@ -75,9 +82,9 @@ namespace osu.Game.Tests.Visual.DailyChallenge
|
|||||||
testScore.TotalScore = RNG.Next(1_000_000);
|
testScore.TotalScore = RNG.Next(1_000_000);
|
||||||
|
|
||||||
feed.AddNewScore(ev);
|
feed.AddNewScore(ev);
|
||||||
});
|
}, 50);
|
||||||
|
|
||||||
AddStep("add top 10 score", () =>
|
AddRepeatStep("add top 10 score", () =>
|
||||||
{
|
{
|
||||||
var ev = new NewScoreEvent(1, new APIUser
|
var ev = new NewScoreEvent(1, new APIUser
|
||||||
{
|
{
|
||||||
@ -87,6 +94,25 @@ namespace osu.Game.Tests.Visual.DailyChallenge
|
|||||||
}, RNG.Next(1_000_000), RNG.Next(1, 10));
|
}, RNG.Next(1_000_000), RNG.Next(1, 10));
|
||||||
|
|
||||||
feed.AddNewScore(ev);
|
feed.AddNewScore(ev);
|
||||||
|
}, 50);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestMassAdd()
|
||||||
|
{
|
||||||
|
AddStep("add 1000 scores at once", () =>
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 1000; i++)
|
||||||
|
{
|
||||||
|
var ev = new NewScoreEvent(1, new APIUser
|
||||||
|
{
|
||||||
|
Id = 2,
|
||||||
|
Username = "peppy",
|
||||||
|
CoverUrl = "https://osu.ppy.sh/images/headers/profile-covers/c3.jpg",
|
||||||
|
}, RNG.Next(1_000_000), null);
|
||||||
|
|
||||||
|
feed.AddNewScore(ev);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ using System.Linq;
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
@ -22,6 +23,8 @@ namespace osu.Game.Screens.OnlinePlay.DailyChallenge
|
|||||||
|
|
||||||
public Action<long>? PresentScore { get; init; }
|
public Action<long>? PresentScore { get; init; }
|
||||||
|
|
||||||
|
private readonly Queue<NewScoreEvent> newScores = new Queue<NewScoreEvent>();
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
@ -47,24 +50,33 @@ namespace osu.Game.Screens.OnlinePlay.DailyChallenge
|
|||||||
|
|
||||||
public void AddNewScore(NewScoreEvent newScoreEvent)
|
public void AddNewScore(NewScoreEvent newScoreEvent)
|
||||||
{
|
{
|
||||||
var row = new NewScoreEventRow(newScoreEvent)
|
newScores.Enqueue(newScoreEvent);
|
||||||
{
|
|
||||||
Anchor = Anchor.BottomCentre,
|
// ensure things don't get too out-of-hand.
|
||||||
Origin = Anchor.BottomCentre,
|
if (newScores.Count > 25)
|
||||||
PresentScore = PresentScore,
|
newScores.Dequeue();
|
||||||
};
|
|
||||||
flow.Add(row);
|
|
||||||
row.Delay(15000).Then().FadeOut(300, Easing.OutQuint).Expire();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
|
while (newScores.TryDequeue(out var newScore))
|
||||||
|
{
|
||||||
|
flow.Add(new NewScoreEventRow(newScore)
|
||||||
|
{
|
||||||
|
Anchor = Anchor.BottomCentre,
|
||||||
|
Origin = Anchor.BottomCentre,
|
||||||
|
PresentScore = PresentScore,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < flow.Count; ++i)
|
for (int i = 0; i < flow.Count; ++i)
|
||||||
{
|
{
|
||||||
var row = flow[i];
|
var row = flow[i];
|
||||||
|
|
||||||
|
row.Alpha = Interpolation.ValueAt(Math.Clamp(row.Y + flow.DrawHeight, 0, flow.DrawHeight), 0f, 1f, 0, flow.DrawHeight, Easing.Out);
|
||||||
|
|
||||||
if (row.Y < -flow.DrawHeight)
|
if (row.Y < -flow.DrawHeight)
|
||||||
{
|
{
|
||||||
row.RemoveAndDisposeImmediately();
|
row.RemoveAndDisposeImmediately();
|
||||||
|
Loading…
Reference in New Issue
Block a user