1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 16:52: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);
});
downloadAssert(true);
AddStep(@"show second", () =>
{
overlay.ShowBeatmapSet(new BeatmapSetInfo
@ -408,6 +410,8 @@ namespace osu.Game.Tests.Visual.Online
},
}, false);
});
downloadAssert(true);
}
[Test]
@ -559,6 +563,8 @@ namespace osu.Game.Tests.Visual.Online
}, false);
});
downloadAssert(true);
AddStep(@"show undownloadable", () =>
{
overlay.ShowBeatmapSet(new BeatmapSetInfo
@ -705,7 +711,12 @@ namespace osu.Game.Tests.Visual.Online
}, 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]

View File

@ -22,16 +22,12 @@ namespace osu.Game.Overlays.BeatmapSet
get => beatmapSet;
set
{
if (value == beatmapSet) return;
if (value == beatmapSet)
return;
beatmapSet = value;
link?.Clear();
if (beatmapSet?.OnlineInfo.Availability != null)
Show();
else
Hide();
updateText();
}
}
@ -81,16 +77,17 @@ namespace osu.Game.Overlays.BeatmapSet
};
}
public override void Show()
private void updateText()
{
if (availability == null)
return;
text.Text = availability.DownloadDisabled
? "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.";
if (!string.IsNullOrEmpty(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)
{
DownloadButtonsContainer.RemoveAll(x => true);
DownloadButtonsContainer.Clear();
return;
}
@ -228,7 +228,7 @@ namespace osu.Game.Overlays.BeatmapSet
{
case DownloadState.LocallyAvailable:
// 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,
RelativeSizeAxes = Axes.Y