1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 17:32:54 +08:00

More simplifies + fix test

This commit is contained in:
KingLuigi4932 2019-06-19 03:37:08 +03:00
parent a0609f28d7
commit 3876442143
3 changed files with 21 additions and 13 deletions

View File

@ -242,6 +242,8 @@ namespace osu.Game.Tests.Visual.Online
}, false); }, false);
}); });
downloadAssert(true);
AddStep(@"show second", () => AddStep(@"show second", () =>
{ {
overlay.ShowBeatmapSet(new BeatmapSetInfo overlay.ShowBeatmapSet(new BeatmapSetInfo
@ -408,6 +410,8 @@ namespace osu.Game.Tests.Visual.Online
}, },
}, false); }, false);
}); });
downloadAssert(true);
} }
[Test] [Test]
@ -559,6 +563,8 @@ namespace osu.Game.Tests.Visual.Online
}, false); }, false);
}); });
downloadAssert(true);
AddStep(@"show undownloadable", () => AddStep(@"show undownloadable", () =>
{ {
overlay.ShowBeatmapSet(new BeatmapSetInfo overlay.ShowBeatmapSet(new BeatmapSetInfo
@ -705,7 +711,12 @@ namespace osu.Game.Tests.Visual.Online
}, false); }, false);
}); });
AddAssert(@"is download button removed", () => overlay.Header.DownloadButtonsContainer.Any()); downloadAssert(false);
}
private void downloadAssert(bool shown)
{
AddAssert($"is download button {(shown ? "shown" : "hidden")}", () => overlay.Header.DownloadButtonsContainer.Any() == shown);
} }
[Test] [Test]

View File

@ -22,16 +22,12 @@ namespace osu.Game.Overlays.BeatmapSet
get => beatmapSet; get => beatmapSet;
set set
{ {
if (value == beatmapSet) return; if (value == beatmapSet)
return;
beatmapSet = value; beatmapSet = value;
link?.Clear(); updateText();
if (beatmapSet?.OnlineInfo.Availability != null)
Show();
else
Hide();
} }
} }
@ -81,16 +77,17 @@ namespace osu.Game.Overlays.BeatmapSet
}; };
} }
public override void Show() private void updateText()
{ {
if (availability == null)
return;
text.Text = availability.DownloadDisabled text.Text = availability.DownloadDisabled
? "This beatmap is currently not available for download." ? "This beatmap is currently not available for download."
: "Portions of this beatmap have been removed at the request of the creator or a third-party rights holder."; : "Portions of this beatmap have been removed at the request of the creator or a third-party rights holder.";
if (!string.IsNullOrEmpty(availability.ExternalLink)) if (!string.IsNullOrEmpty(availability.ExternalLink))
link.AddLink("Check here for more information.", availability.ExternalLink); link.AddLink("Check here for more information.", availability.ExternalLink);
base.Show();
} }
} }
} }

View File

@ -220,7 +220,7 @@ namespace osu.Game.Overlays.BeatmapSet
if (BeatmapSet.Value.OnlineInfo.Availability?.DownloadDisabled ?? false) if (BeatmapSet.Value.OnlineInfo.Availability?.DownloadDisabled ?? false)
{ {
DownloadButtonsContainer.RemoveAll(x => true); DownloadButtonsContainer.Clear();
return; return;
} }
@ -228,7 +228,7 @@ namespace osu.Game.Overlays.BeatmapSet
{ {
case DownloadState.LocallyAvailable: case DownloadState.LocallyAvailable:
// temporary for UX until new design is implemented. // temporary for UX until new design is implemented.
DownloadButtonsContainer.Child = new osu.Game.Overlays.Direct.DownloadButton(BeatmapSet.Value) DownloadButtonsContainer.Child = new Direct.DownloadButton(BeatmapSet.Value)
{ {
Width = 50, Width = 50,
RelativeSizeAxes = Axes.Y RelativeSizeAxes = Axes.Y