1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-13 15:03:13 +08:00

Merge pull request #17698 from Joehuu/fix-replay-button-local-being-disabled

Fix replay button being disabled when available locally but not online
This commit is contained in:
Dean Herbert 2022-04-07 14:18:02 +09:00 committed by GitHub
commit eb0653fa7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View File

@ -150,10 +150,12 @@ namespace osu.Game.Tests.Visual.Gameplay
AddStep("import score", () => imported = scoreManager.Import(getScoreInfo(true)));
AddUntilStep("state is available", () => downloadButton.State.Value == DownloadState.LocallyAvailable);
AddAssert("button is enabled", () => downloadButton.ChildrenOfType<DownloadButton>().First().Enabled.Value);
AddStep("delete score", () => scoreManager.Delete(imported.Value));
AddUntilStep("state is not downloaded", () => downloadButton.State.Value == DownloadState.NotDownloaded);
AddAssert("button is not enabled", () => !downloadButton.ChildrenOfType<DownloadButton>().First().Enabled.Value);
}
[Test]

View File

@ -87,31 +87,33 @@ namespace osu.Game.Screens.Ranking
});
}
button.Enabled.Value = replayAvailability != ReplayAvailability.NotAvailable;
updateTooltip();
updateState();
}, true);
State.BindValueChanged(state =>
{
button.State.Value = state.NewValue;
updateTooltip();
updateState();
}, true);
}
private void updateTooltip()
private void updateState()
{
switch (replayAvailability)
{
case ReplayAvailability.Local:
button.TooltipText = @"watch replay";
button.Enabled.Value = true;
break;
case ReplayAvailability.Online:
button.TooltipText = @"download replay";
button.Enabled.Value = true;
break;
default:
button.TooltipText = @"replay unavailable";
button.Enabled.Value = false;
break;
}
}