Merge branch 'master' into concurrent-overlay-limits

This commit is contained in:
Dean Herbert 2017-08-25 14:50:45 +09:00 committed by GitHub
commit c0cf26ed21
5 changed files with 72 additions and 50 deletions

View File

@ -152,14 +152,10 @@ namespace osu.Game
Beatmap.ValueChanged += b => Beatmap.ValueChanged += b =>
{ {
// compare to last baetmap as sometimes the two may share a track representation (optimisation, see WorkingBeatmap.TransferTo) // compare to last beatmap as sometimes the two may share a track representation (optimisation, see WorkingBeatmap.TransferTo)
if (lastBeatmap?.Track != b.Track) if (lastBeatmap?.Track != b.Track)
{ {
// this disposal is done to stop the audio track. lastBeatmap?.Track?.Dispose();
// it may not be exactly what we want for cases beatmaps are reused, as it will
// trigger a fresh load of contained resources.
lastBeatmap?.Dispose();
Audio.Track.AddItem(b.Track); Audio.Track.AddItem(b.Track);
} }

View File

@ -29,7 +29,7 @@ namespace osu.Game.Overlays.Direct
{ {
public abstract class DirectPanel : Container public abstract class DirectPanel : Container
{ {
protected readonly BeatmapSetInfo SetInfo; public readonly BeatmapSetInfo SetInfo;
protected Box BlackBackground; protected Box BlackBackground;
@ -108,10 +108,23 @@ namespace osu.Game.Overlays.Direct
base.OnHoverLost(state); base.OnHoverLost(state);
} }
// this should eventually be moved to a more central place, like BeatmapManager.
private DownloadBeatmapSetRequest downloadRequest;
protected void StartDownload() protected void StartDownload()
{ {
if (api == null) return; if (api == null) return;
// we already have an active download running.
if (downloadRequest != null)
{
content.MoveToX(-5, 50, Easing.OutSine).Then()
.MoveToX(5, 100, Easing.InOutSine).Then()
.MoveToX(-5, 100, Easing.InOutSine).Then()
.MoveToX(0, 50, Easing.InSine).Then();
return;
}
if (!api.LocalUser.Value.IsSupporter) if (!api.LocalUser.Value.IsSupporter)
{ {
notifications.Post(new SimpleNotification notifications.Post(new SimpleNotification
@ -132,16 +145,18 @@ namespace osu.Game.Overlays.Direct
Text = $"Downloading {SetInfo.Metadata.Artist} - {SetInfo.Metadata.Title}", Text = $"Downloading {SetInfo.Metadata.Artist} - {SetInfo.Metadata.Title}",
}; };
var request = new DownloadBeatmapSetRequest(SetInfo); downloadRequest = new DownloadBeatmapSetRequest(SetInfo);
request.Failure += e => downloadRequest.Failure += e =>
{ {
progressBar.Current.Value = 0; progressBar.Current.Value = 0;
progressBar.FadeOut(500); progressBar.FadeOut(500);
downloadNotification.State = ProgressNotificationState.Completed; downloadNotification.State = ProgressNotificationState.Completed;
Logger.Error(e, "Failed to get beatmap download information"); Logger.Error(e, "Failed to get beatmap download information");
downloadRequest = null;
}; };
request.Progress += (current, total) => downloadRequest.Progress += (current, total) =>
{ {
float progress = (float)current / total; float progress = (float)current / total;
@ -151,7 +166,7 @@ namespace osu.Game.Overlays.Direct
downloadNotification.Progress = progress; downloadNotification.Progress = progress;
}; };
request.Success += data => downloadRequest.Success += data =>
{ {
progressBar.Current.Value = 1; progressBar.Current.Value = 1;
progressBar.FadeOut(500); progressBar.FadeOut(500);
@ -165,14 +180,15 @@ namespace osu.Game.Overlays.Direct
downloadNotification.CancelRequested += () => downloadNotification.CancelRequested += () =>
{ {
request.Cancel(); downloadRequest.Cancel();
downloadRequest = null;
return true; return true;
}; };
notifications.Post(downloadNotification); notifications.Post(downloadNotification);
// don't run in the main api queue as this is a long-running task. // don't run in the main api queue as this is a long-running task.
Task.Run(() => request.Perform(api)); Task.Run(() => downloadRequest.Perform(api));
} }
public class DownloadBeatmapSetRequest : APIDownloadRequest public class DownloadBeatmapSetRequest : APIDownloadRequest

View File

@ -30,7 +30,7 @@ namespace osu.Game.Overlays
private readonly FillFlowContainer resultCountsContainer; private readonly FillFlowContainer resultCountsContainer;
private readonly OsuSpriteText resultCountsText; private readonly OsuSpriteText resultCountsText;
private readonly FillFlowContainer<DirectPanel> panels; private FillFlowContainer<DirectPanel> panels;
protected override Color4 BackgroundColour => OsuColour.FromHex(@"485e74"); protected override Color4 BackgroundColour => OsuColour.FromHex(@"485e74");
protected override Color4 TrianglesColourLight => OsuColour.FromHex(@"465b71"); protected override Color4 TrianglesColourLight => OsuColour.FromHex(@"465b71");
@ -48,17 +48,6 @@ namespace osu.Game.Overlays
if (beatmapSets?.Equals(value) ?? false) return; if (beatmapSets?.Equals(value) ?? false) return;
beatmapSets = value; beatmapSets = value;
if (BeatmapSets == null)
{
foreach (var p in panels.Children)
{
p.FadeOut(200);
p.Expire();
}
return;
}
recreatePanels(Filter.DisplayStyleControl.DisplayStyle.Value); recreatePanels(Filter.DisplayStyleControl.DisplayStyle.Value);
} }
} }
@ -108,13 +97,6 @@ namespace osu.Game.Overlays
}, },
} }
}, },
panels = new FillFlowContainer<DirectPanel>
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Spacing = new Vector2(panel_padding),
Margin = new MarginPadding { Top = 10 },
},
}; };
Filter.Search.Current.ValueChanged += text => { if (text != string.Empty) Header.Tabs.Current.Value = DirectTab.Search; }; Filter.Search.Current.ValueChanged += text => { if (text != string.Empty) Header.Tabs.Current.Value = DirectTab.Search; };
@ -161,11 +143,19 @@ namespace osu.Game.Overlays
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours, APIAccess api, RulesetStore rulesets) private void load(OsuColour colours, APIAccess api, RulesetStore rulesets, BeatmapManager beatmaps)
{ {
this.api = api; this.api = api;
this.rulesets = rulesets; this.rulesets = rulesets;
resultCountsContainer.Colour = colours.Yellow; resultCountsContainer.Colour = colours.Yellow;
beatmaps.BeatmapSetAdded += setAdded;
}
private void setAdded(BeatmapSetInfo set)
{
// if a new map was imported, we should remove it from search results (download completed etc.)
panels?.FirstOrDefault(p => p.SetInfo.OnlineBeatmapSetID == set.OnlineBeatmapSetID)?.FadeOut(400).Expire();
} }
private void updateResultCounts() private void updateResultCounts()
@ -185,18 +175,38 @@ namespace osu.Game.Overlays
private void recreatePanels(PanelDisplayStyle displayStyle) private void recreatePanels(PanelDisplayStyle displayStyle)
{ {
if (panels != null)
{
panels.FadeOut(200);
panels.Expire();
panels = null;
}
if (BeatmapSets == null) return; if (BeatmapSets == null) return;
panels.ChildrenEnumerable = BeatmapSets.Select<BeatmapSetInfo, DirectPanel>(b => var newPanels = new FillFlowContainer<DirectPanel>
{ {
switch (displayStyle) RelativeSizeAxes = Axes.X,
{ AutoSizeAxes = Axes.Y,
case PanelDisplayStyle.Grid: Spacing = new Vector2(panel_padding),
return new DirectGridPanel(b) { Width = 400 }; Margin = new MarginPadding { Top = 10 },
default: ChildrenEnumerable = BeatmapSets.Select<BeatmapSetInfo, DirectPanel>(b =>
return new DirectListPanel(b); {
} switch (displayStyle)
}); {
case PanelDisplayStyle.Grid:
return new DirectGridPanel(b) { Width = 400 };
default:
return new DirectListPanel(b);
}
})
};
LoadComponentAsync(newPanels, p =>
{
if (panels != null) ScrollFlow.Remove(panels);
ScrollFlow.Add(panels = newPanels);
});
} }
private GetBeatmapSetsRequest getSetsRequest; private GetBeatmapSetsRequest getSetsRequest;

View File

@ -348,23 +348,23 @@ namespace osu.Game.Overlays
playerContainer.Add(new AsyncLoadWrapper(new Background(beatmap) playerContainer.Add(new AsyncLoadWrapper(new Background(beatmap)
{ {
OnLoadComplete = d => OnLoadComplete = newBackground =>
{ {
switch (direction) switch (direction)
{ {
case TransformDirection.Next: case TransformDirection.Next:
d.Position = new Vector2(400, 0); newBackground.Position = new Vector2(400, 0);
d.MoveToX(0, 500, Easing.OutCubic); newBackground.MoveToX(0, 500, Easing.OutCubic);
currentBackground.MoveToX(-400, 500, Easing.OutCubic); currentBackground.MoveToX(-400, 500, Easing.OutCubic);
break; break;
case TransformDirection.Prev: case TransformDirection.Prev:
d.Position = new Vector2(-400, 0); newBackground.Position = new Vector2(-400, 0);
d.MoveToX(0, 500, Easing.OutCubic); newBackground.MoveToX(0, 500, Easing.OutCubic);
currentBackground.MoveToX(400, 500, Easing.OutCubic); currentBackground.MoveToX(400, 500, Easing.OutCubic);
break; break;
} }
currentBackground.Expire(); currentBackground.Expire();
currentBackground = d; currentBackground = newBackground;
} }
}) })
{ {

View File

@ -10,7 +10,7 @@ namespace osu.Game.Overlays.Toolbar
{ {
public ToolbarDirectButton() public ToolbarDirectButton()
{ {
SetIcon(FontAwesome.fa_download); SetIcon(FontAwesome.fa_osu_chevron_down_o);
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]