mirror of
https://github.com/osukey/osukey.git
synced 2025-06-09 05:19:11 +09: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.Testing;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Rulesets.Osu;
|
using osu.Game.Rulesets.Osu;
|
||||||
using osu.Game.Scoring;
|
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);
|
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
|
private class TestResultsContainer : Container
|
||||||
{
|
{
|
||||||
[Cached(typeof(Player))]
|
[Cached(typeof(Player))]
|
||||||
@ -255,6 +275,7 @@ namespace osu.Game.Tests.Visual.Ranking
|
|||||||
{
|
{
|
||||||
var score = new TestScoreInfo(new OsuRuleset().RulesetInfo);
|
var score = new TestScoreInfo(new OsuRuleset().RulesetInfo);
|
||||||
score.TotalScore += 10 - i;
|
score.TotalScore += 10 - i;
|
||||||
|
score.Hash = $"test{i}";
|
||||||
scores.Add(score);
|
scores.Add(score);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,23 +74,33 @@ namespace osu.Game.Screens.Ranking
|
|||||||
{
|
{
|
||||||
button.State.Value = state.NewValue;
|
button.State.Value = state.NewValue;
|
||||||
|
|
||||||
switch (replayAvailability)
|
updateTooltip();
|
||||||
{
|
|
||||||
case ReplayAvailability.Local:
|
|
||||||
button.TooltipText = @"watch replay";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ReplayAvailability.Online:
|
|
||||||
button.TooltipText = @"download replay";
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
button.TooltipText = @"replay unavailable";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}, true);
|
}, 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
|
private enum ReplayAvailability
|
||||||
|
Loading…
x
Reference in New Issue
Block a user