1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 09:47:52 +08:00

Clean up some more leftover code

This commit is contained in:
naoey 2019-06-30 10:56:20 +05:30
parent 04c467fd81
commit bfcbb47b77
No known key found for this signature in database
GPG Key ID: 670DA9BE3DF7EE60

View File

@ -21,17 +21,9 @@ namespace osu.Game.Screens.Play
{
public class ReplayDownloadButton : DownloadTrackingComposite<ScoreInfo, ScoreManager>, IHasTooltip
{
private const int size = 40;
[Resolved(canBeNull: true)]
private OsuGame game { get; set; }
[Resolved]
private ScoreManager scores { get; set; }
[Resolved]
private OsuColour colours { get; set; }
private OsuClickableContainer button;
private SpriteIcon downloadIcon;
private SpriteIcon playIcon;
@ -42,7 +34,7 @@ namespace osu.Game.Screens.Play
{
get
{
switch (getReplayAvailability())
switch (replayAvailability)
{
case ReplayAvailability.Local:
return @"Watch replay";
@ -56,6 +48,20 @@ namespace osu.Game.Screens.Play
}
}
private ReplayAvailability replayAvailability
{
get
{
if (scores.IsAvailableLocally(Model.Value))
return ReplayAvailability.Local;
if (Model.Value is APILegacyScoreInfo apiScore && apiScore.Replay)
return ReplayAvailability.Online;
return ReplayAvailability.NotAvailable;
}
}
public ReplayDownloadButton(ScoreInfo score)
: base(score)
{
@ -63,7 +69,7 @@ namespace osu.Game.Screens.Play
}
[BackgroundDependencyLoader(true)]
private void load()
private void load(OsuGame game, OsuColour colours)
{
InternalChild = shakeContainer = new ShakeContainer
{
@ -71,7 +77,7 @@ namespace osu.Game.Screens.Play
Child = circle = new CircularContainer
{
Masking = true,
Size = new Vector2(size),
Size = new Vector2(40),
EdgeEffect = new EdgeEffectParameters
{
Colour = Color4.Black.Opacity(0.4f),
@ -132,41 +138,32 @@ namespace osu.Game.Screens.Play
switch (state.NewValue)
{
case DownloadState.Downloading:
playIcon.ResizeTo(Vector2.Zero, 400, Easing.OutQuint);
downloadIcon.ResizeTo(13, 400, Easing.OutQuint);
circle.FadeEdgeEffectTo(colours.Yellow, 400, Easing.OutQuint);
break;
case DownloadState.LocallyAvailable:
playIcon.ResizeTo(13, 300, Easing.OutQuint);
downloadIcon.ResizeTo(Vector2.Zero, 300, Easing.OutExpo);
playIcon.ResizeTo(13, 400, Easing.OutQuint);
downloadIcon.ResizeTo(Vector2.Zero, 400, Easing.OutQuint);
circle.FadeEdgeEffectTo(Color4.Black.Opacity(0.4f), 400, Easing.OutQuint);
break;
case DownloadState.NotDownloaded:
playIcon.ResizeTo(Vector2.Zero, 300, Easing.OutQuint);
downloadIcon.ResizeTo(13, 300, Easing.OutExpo);
playIcon.ResizeTo(Vector2.Zero, 400, Easing.OutQuint);
downloadIcon.ResizeTo(13, 400, Easing.OutQuint);
circle.FadeEdgeEffectTo(Color4.Black.Opacity(0.4f), 400, Easing.OutQuint);
break;
}
}, true);
if (getReplayAvailability() == ReplayAvailability.NotAvailable)
if (replayAvailability == ReplayAvailability.NotAvailable)
{
button.Enabled.Value = false;
button.Alpha = 0.6f;
}
}
private ReplayAvailability getReplayAvailability()
{
if (scores.IsAvailableLocally(Model.Value))
return ReplayAvailability.Local;
if (Model.Value is APILegacyScoreInfo apiScore && apiScore.Replay)
return ReplayAvailability.Online;
return ReplayAvailability.NotAvailable;
}
private enum ReplayAvailability
{
Local,