Tidy up fetch methods

Anonymise some test data further
This commit is contained in:
Dean Herbert 2019-06-27 12:00:31 +09:00
parent 375a6f406d
commit d6da21b0f0
3 changed files with 26 additions and 25 deletions

View File

@ -76,21 +76,22 @@ namespace osu.Game.Tests.Visual.Online
{
overlay.ShowBeatmapSet(new BeatmapSetInfo
{
OnlineBeatmapSetID = 1235,
Metadata = new BeatmapMetadata
{
Title = @"Lachryma <Re:QueenM>",
Artist = @"Kaneko Chiharu",
Source = @"SOUND VOLTEX III GRAVITY WARS",
Tags = @"sdvx grace the 5th kac original song contest konami bemani",
Title = @"an awesome beatmap",
Artist = @"naru narusegawa",
Source = @"hinata sou",
Tags = @"test tag tag more tag",
Author = new User
{
Username = @"Fresh Chicken",
Id = 3984370,
Username = @"BanchoBot",
Id = 3,
},
},
OnlineInfo = new BeatmapSetOnlineInfo
{
Preview = @"https://b.ppy.sh/preview/415886.mp3",
Preview = @"https://b.ppy.sh/preview/12345.mp3",
PlayCount = 681380,
FavouriteCount = 356,
Submitted = new DateTime(2016, 2, 10),
@ -237,7 +238,7 @@ namespace osu.Game.Tests.Visual.Online
},
},
},
}, false);
});
});
downloadAssert(true);
@ -250,6 +251,7 @@ namespace osu.Game.Tests.Visual.Online
{
overlay.ShowBeatmapSet(new BeatmapSetInfo
{
OnlineBeatmapSetID = 1234,
Metadata = new BeatmapMetadata
{
Title = @"Soumatou Labyrinth",
@ -415,7 +417,7 @@ namespace osu.Game.Tests.Visual.Online
},
},
},
}, false);
});
});
downloadAssert(false);

View File

@ -31,8 +31,6 @@ namespace osu.Game.Overlays
private RulesetStore rulesets;
private readonly OsuScrollContainer scroll;
private readonly Bindable<BeatmapSetInfo> beatmapSet = new Bindable<BeatmapSetInfo>();
// receive input outside our bounds so we can trigger a close event on ourselves.
@ -40,6 +38,7 @@ namespace osu.Game.Overlays
public BeatmapSetOverlay()
{
OsuScrollContainer scroll;
Info info;
ScoresContainer scores;
@ -76,6 +75,8 @@ namespace osu.Game.Overlays
{
info.Beatmap = b.NewValue;
scores.Beatmap = b.NewValue;
scroll.ScrollToStart();
};
}
@ -119,18 +120,14 @@ namespace osu.Game.Overlays
Show();
}
public void ShowBeatmapSet(BeatmapSetInfo set, bool refetch = true)
/// <summary>
/// Show an already fully-populated beatmap set.
/// </summary>
/// <param name="set">The set to show.</param>
public void ShowBeatmapSet(BeatmapSetInfo set)
{
// Re-fetching is the correct way forward.
if (refetch)
FetchAndShowBeatmapSet(set?.OnlineBeatmapSetID ?? 0);
else
{
beatmapSet.Value = set;
Show();
}
scroll.ScrollTo(0);
beatmapSet.Value = set;
Show();
}
}
}

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
@ -45,6 +46,8 @@ namespace osu.Game.Overlays.Direct
protected DirectPanel(BeatmapSetInfo setInfo)
{
Debug.Assert(setInfo.OnlineBeatmapSetID != null);
SetInfo = setInfo;
}
@ -119,12 +122,11 @@ namespace osu.Game.Overlays.Direct
protected override bool OnClick(ClickEvent e)
{
ShowInformation();
Debug.Assert(SetInfo.OnlineBeatmapSetID != null);
beatmapSetOverlay?.FetchAndShowBeatmapSet(SetInfo.OnlineBeatmapSetID.Value);
return true;
}
protected void ShowInformation() => beatmapSetOverlay?.ShowBeatmapSet(SetInfo);
protected override void LoadComplete()
{
base.LoadComplete();