2019-06-12 04:01:57 +08:00
|
|
|
|
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()
|
|
|
|
|
{
|
2019-06-26 23:40:21 +08:00
|
|
|
|
if (scores.IsAvailableLocally(Model.Value))
|
2019-06-12 04:01:57 +08:00
|
|
|
|
{
|
2019-06-26 23:40:21 +08:00
|
|
|
|
game.PresentScore(Model.Value);
|
2019-06-12 04:01:57 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-26 23:40:21 +08:00
|
|
|
|
scores.Download(Model.Value);
|
2019-06-12 04:01:57 +08:00
|
|
|
|
|
2019-06-26 23:40:21 +08:00
|
|
|
|
scores.ItemAdded += score =>
|
2019-06-12 04:01:57 +08:00
|
|
|
|
{
|
2019-06-26 23:40:21 +08:00
|
|
|
|
if (score.Equals(Model.Value))
|
|
|
|
|
// use the newly added score instead of ModelInfo.Score because that won't have the Files property populated
|
|
|
|
|
game.PresentScore(score);
|
|
|
|
|
//ReplayLoaded?.Invoke(scores.GetScore(score));
|
2019-06-12 04:01:57 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|