mirror of
https://github.com/osukey/osukey.git
synced 2025-05-28 17:07:35 +09:00
54 lines
1.4 KiB
C#
54 lines
1.4 KiB
C#
using osu.Framework.Allocation;
|
|
using osu.Framework.Graphics.Sprites;
|
|
using osu.Game.Graphics;
|
|
using osu.Game.Graphics.UserInterface;
|
|
using osu.Game.Online;
|
|
using osu.Game.Scoring;
|
|
|
|
namespace osu.Game.Screens.Play
|
|
{
|
|
public class ReplayDownloadButton : DownloadTrackingComposite<ScoreInfo, ScoreManager>
|
|
{
|
|
[Resolved]
|
|
private OsuGame game { get; set; }
|
|
|
|
[Resolved]
|
|
private ScoreManager scores { get; set; }
|
|
|
|
public ReplayDownloadButton(ScoreInfo score)
|
|
: base(score)
|
|
{
|
|
}
|
|
|
|
[BackgroundDependencyLoader]
|
|
private void load(OsuColour colours)
|
|
{
|
|
AddInternal(new TwoLayerButton
|
|
{
|
|
BackgroundColour = colours.Yellow,
|
|
Icon = FontAwesome.Solid.PlayCircle,
|
|
Text = @"Replay",
|
|
HoverColour = colours.YellowDark,
|
|
Action = onReplay,
|
|
});
|
|
}
|
|
|
|
private void onReplay()
|
|
{
|
|
if (scores.IsAvailableLocally(ModelInfo.Value))
|
|
{
|
|
game.PresentScore(ModelInfo.Value);
|
|
return;
|
|
}
|
|
|
|
scores.Download(ModelInfo.Value);
|
|
|
|
scores.ItemAdded += (score, _) =>
|
|
{
|
|
if (score.Equals(ModelInfo.Value))
|
|
game.PresentScore(ModelInfo.Value);
|
|
};
|
|
}
|
|
}
|
|
}
|