mirror of
https://github.com/ppy/osu.git
synced 2025-01-21 08:52:54 +08:00
Disable replay button when replay is unavailable
This commit is contained in:
parent
7d9e215744
commit
d8f6bbc90e
@ -26,29 +26,33 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
public TestSceneReplayDownloadButton()
|
public TestSceneReplayDownloadButton()
|
||||||
{
|
{
|
||||||
createButton();
|
createButton(true);
|
||||||
AddStep(@"downloading state", () => downloadButton.SetDownloadState(DownloadState.Downloading));
|
AddStep(@"downloading state", () => downloadButton.SetDownloadState(DownloadState.Downloading));
|
||||||
AddStep(@"locally available state", () => downloadButton.SetDownloadState(DownloadState.LocallyAvailable));
|
AddStep(@"locally available state", () => downloadButton.SetDownloadState(DownloadState.LocallyAvailable));
|
||||||
AddStep(@"not downloaded state", () => downloadButton.SetDownloadState(DownloadState.NotDownloaded));
|
AddStep(@"not downloaded state", () => downloadButton.SetDownloadState(DownloadState.NotDownloaded));
|
||||||
|
createButton(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createButton()
|
private void createButton(bool withReplay)
|
||||||
{
|
{
|
||||||
AddStep(@"create button", () => Child = downloadButton = new TestReplayDownloadButton(getScoreInfo())
|
AddStep(withReplay ? @"create button with replay" : "create button without replay", () =>
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Child = downloadButton = new TestReplayDownloadButton(getScoreInfo(withReplay))
|
||||||
Origin = Anchor.Centre,
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private ScoreInfo getScoreInfo()
|
private ScoreInfo getScoreInfo(bool replayAvailable)
|
||||||
{
|
{
|
||||||
return new APILegacyScoreInfo
|
return new APILegacyScoreInfo
|
||||||
{
|
{
|
||||||
ID = 1,
|
ID = 1,
|
||||||
OnlineScoreID = 2553163309,
|
OnlineScoreID = 2553163309,
|
||||||
Ruleset = new OsuRuleset().RulesetInfo,
|
Ruleset = new OsuRuleset().RulesetInfo,
|
||||||
Replay = true,
|
Replay = replayAvailable,
|
||||||
User = new User
|
User = new User
|
||||||
{
|
{
|
||||||
Id = 39828,
|
Id = 39828,
|
||||||
|
@ -42,13 +42,17 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (scores.IsAvailableLocally(Model.Value))
|
switch (getReplayAvailability())
|
||||||
return @"Watch replay";
|
{
|
||||||
|
case ReplayAvailability.Local:
|
||||||
|
return @"Watch replay";
|
||||||
|
|
||||||
if (Model.Value is APILegacyScoreInfo apiScore && apiScore.Replay)
|
case ReplayAvailability.Online:
|
||||||
return @"Download replay";
|
return @"Download replay";
|
||||||
|
|
||||||
return @"Replay unavailable";
|
default:
|
||||||
|
return @"Replay unavailable";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,8 +62,6 @@ namespace osu.Game.Screens.Play
|
|||||||
AutoSizeAxes = Axes.Both;
|
AutoSizeAxes = Axes.Both;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool hasReplay => (Model.Value is APILegacyScoreInfo apiScore && apiScore.Replay) || scores.IsAvailableLocally(Model.Value);
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader(true)]
|
[BackgroundDependencyLoader(true)]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
@ -146,6 +148,30 @@ namespace osu.Game.Screens.Play
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
|
if (getReplayAvailability() == 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,
|
||||||
|
Online,
|
||||||
|
NotAvailable,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user