1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-22 16:32:55 +08:00

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

View File

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

View File

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