mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 00:43:21 +08:00
Merge pull request #10007 from Joehuu/fix-replay-download-button-always-being-disabled
Fix replay download button always being disabled when initial score's replay is unavailable
This commit is contained in:
commit
8f02e05dde
@ -13,6 +13,7 @@ using osu.Framework.Screens;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Scoring;
|
||||
@ -212,6 +213,25 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
AddAssert("expanded panel still on screen", () => this.ChildrenOfType<ScorePanel>().Single(p => p.State == PanelState.Expanded).ScreenSpaceDrawQuad.TopLeft.X > 0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDownloadButtonInitiallyDisabled()
|
||||
{
|
||||
TestResultsScreen screen = null;
|
||||
|
||||
AddStep("load results", () => Child = new TestResultsContainer(screen = createResultsScreen()));
|
||||
|
||||
AddAssert("download button is disabled", () => !screen.ChildrenOfType<DownloadButton>().Single().Enabled.Value);
|
||||
|
||||
AddStep("click contracted panel", () =>
|
||||
{
|
||||
var contractedPanel = this.ChildrenOfType<ScorePanel>().First(p => p.State == PanelState.Contracted && p.ScreenSpaceDrawQuad.TopLeft.X > screen.ScreenSpaceDrawQuad.TopLeft.X);
|
||||
InputManager.MoveMouseTo(contractedPanel);
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
AddAssert("download button is enabled", () => screen.ChildrenOfType<DownloadButton>().Single().Enabled.Value);
|
||||
}
|
||||
|
||||
private class TestResultsContainer : Container
|
||||
{
|
||||
[Cached(typeof(Player))]
|
||||
@ -255,6 +275,7 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
{
|
||||
var score = new TestScoreInfo(new OsuRuleset().RulesetInfo);
|
||||
score.TotalScore += 10 - i;
|
||||
score.Hash = $"test{i}";
|
||||
scores.Add(score);
|
||||
}
|
||||
|
||||
|
@ -74,23 +74,33 @@ namespace osu.Game.Screens.Ranking
|
||||
{
|
||||
button.State.Value = state.NewValue;
|
||||
|
||||
switch (replayAvailability)
|
||||
{
|
||||
case ReplayAvailability.Local:
|
||||
button.TooltipText = @"watch replay";
|
||||
break;
|
||||
|
||||
case ReplayAvailability.Online:
|
||||
button.TooltipText = @"download replay";
|
||||
break;
|
||||
|
||||
default:
|
||||
button.TooltipText = @"replay unavailable";
|
||||
break;
|
||||
}
|
||||
updateTooltip();
|
||||
}, true);
|
||||
|
||||
button.Enabled.Value = replayAvailability != ReplayAvailability.NotAvailable;
|
||||
Model.BindValueChanged(_ =>
|
||||
{
|
||||
button.Enabled.Value = replayAvailability != ReplayAvailability.NotAvailable;
|
||||
|
||||
updateTooltip();
|
||||
}, true);
|
||||
}
|
||||
|
||||
private void updateTooltip()
|
||||
{
|
||||
switch (replayAvailability)
|
||||
{
|
||||
case ReplayAvailability.Local:
|
||||
button.TooltipText = @"watch replay";
|
||||
break;
|
||||
|
||||
case ReplayAvailability.Online:
|
||||
button.TooltipText = @"download replay";
|
||||
break;
|
||||
|
||||
default:
|
||||
button.TooltipText = @"replay unavailable";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private enum ReplayAvailability
|
||||
|
Loading…
Reference in New Issue
Block a user