mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 15:12:57 +08:00
Update DirectPanel to use BeatmapSetDownloadButton.
This commit is contained in:
parent
7b7236929a
commit
b332c22fe5
@ -166,14 +166,13 @@ namespace osu.Game.Overlays.Direct
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
new DownloadButton
|
new DownloadButton(SetInfo)
|
||||||
{
|
{
|
||||||
Size = new Vector2(30),
|
Size = new Vector2(30),
|
||||||
Margin = new MarginPadding(horizontal_padding),
|
Margin = new MarginPadding(horizontal_padding),
|
||||||
Anchor = Anchor.CentreRight,
|
Anchor = Anchor.CentreRight,
|
||||||
Origin = Anchor.CentreRight,
|
Origin = Anchor.CentreRight,
|
||||||
Colour = colours.Gray5,
|
Colour = colours.Gray5,
|
||||||
Action = StartDownload
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -144,12 +144,11 @@ namespace osu.Game.Overlays.Direct
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
new DownloadButton
|
new DownloadButton(SetInfo)
|
||||||
{
|
{
|
||||||
Anchor = Anchor.TopRight,
|
Anchor = Anchor.TopRight,
|
||||||
Origin = Anchor.TopRight,
|
Origin = Anchor.TopRight,
|
||||||
Size = new Vector2(height - vertical_padding * 2),
|
Size = new Vector2(height - vertical_padding * 2),
|
||||||
Action = StartDownload
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -147,22 +147,6 @@ namespace osu.Game.Overlays.Direct
|
|||||||
|
|
||||||
protected void ShowInformation() => beatmapSetOverlay?.ShowBeatmapSet(SetInfo);
|
protected void ShowInformation() => beatmapSetOverlay?.ShowBeatmapSet(SetInfo);
|
||||||
|
|
||||||
protected void StartDownload()
|
|
||||||
{
|
|
||||||
if (beatmaps.GetExistingDownload(SetInfo) != null)
|
|
||||||
{
|
|
||||||
// we already have an active download running.
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
beatmaps.Download(SetInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void attachDownload(DownloadBeatmapSetRequest request)
|
private void attachDownload(DownloadBeatmapSetRequest request)
|
||||||
{
|
{
|
||||||
if (request.BeatmapSet.OnlineBeatmapSetID != SetInfo.OnlineBeatmapSetID)
|
if (request.BeatmapSet.OnlineBeatmapSetID != SetInfo.OnlineBeatmapSetID)
|
||||||
|
@ -3,17 +3,18 @@
|
|||||||
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Direct
|
namespace osu.Game.Overlays.Direct
|
||||||
{
|
{
|
||||||
public class DownloadButton : OsuClickableContainer
|
public class DownloadButton : BeatmapSetDownloadButton
|
||||||
{
|
{
|
||||||
private readonly SpriteIcon icon;
|
private readonly SpriteIcon icon;
|
||||||
|
|
||||||
public DownloadButton()
|
public DownloadButton(BeatmapSetInfo set, bool noVideo = false) : base(set, noVideo)
|
||||||
{
|
{
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
@ -49,5 +50,19 @@ namespace osu.Game.Overlays.Direct
|
|||||||
{
|
{
|
||||||
icon.ScaleTo(1f, 500, Easing.OutElastic);
|
icon.ScaleTo(1f, 500, Easing.OutElastic);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Enable()
|
||||||
|
{
|
||||||
|
this.FadeIn(200);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Disable()
|
||||||
|
{
|
||||||
|
this.FadeOut(200);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void AlreadyDownloading()
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,6 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
private APIAccess api;
|
private APIAccess api;
|
||||||
private RulesetStore rulesets;
|
private RulesetStore rulesets;
|
||||||
private BeatmapManager beatmaps;
|
|
||||||
|
|
||||||
private readonly FillFlowContainer resultCountsContainer;
|
private readonly FillFlowContainer resultCountsContainer;
|
||||||
private readonly OsuSpriteText resultCountsText;
|
private readonly OsuSpriteText resultCountsText;
|
||||||
@ -181,20 +180,10 @@ namespace osu.Game.Overlays
|
|||||||
{
|
{
|
||||||
this.api = api;
|
this.api = api;
|
||||||
this.rulesets = rulesets;
|
this.rulesets = rulesets;
|
||||||
this.beatmaps = beatmaps;
|
|
||||||
|
|
||||||
resultCountsContainer.Colour = colours.Yellow;
|
resultCountsContainer.Colour = colours.Yellow;
|
||||||
|
|
||||||
beatmaps.ItemAdded += setAdded;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setAdded(BeatmapSetInfo set) => Schedule(() =>
|
|
||||||
{
|
|
||||||
// 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();
|
|
||||||
BeatmapSets = BeatmapSets?.Where(b => b.OnlineBeatmapSetID != set.OnlineBeatmapSetID);
|
|
||||||
});
|
|
||||||
|
|
||||||
private void updateResultCounts()
|
private void updateResultCounts()
|
||||||
{
|
{
|
||||||
resultCountsContainer.FadeTo(ResultAmounts == null ? 0f : 1f, 200, Easing.OutQuint);
|
resultCountsContainer.FadeTo(ResultAmounts == null ? 0f : 1f, 200, Easing.OutQuint);
|
||||||
@ -297,9 +286,7 @@ namespace osu.Game.Overlays
|
|||||||
{
|
{
|
||||||
Task.Run(() =>
|
Task.Run(() =>
|
||||||
{
|
{
|
||||||
var onlineIds = response.Select(r => r.OnlineBeatmapSetID).ToList();
|
var sets = response.Select(r => r.ToBeatmapSet(rulesets)).ToList();
|
||||||
var presentOnlineIds = beatmaps.QueryBeatmapSets(s => onlineIds.Contains(s.OnlineBeatmapSetID) && !s.DeletePending).Select(r => r.OnlineBeatmapSetID).ToList();
|
|
||||||
var sets = response.Select(r => r.ToBeatmapSet(rulesets)).Where(b => !presentOnlineIds.Contains(b.OnlineBeatmapSetID)).ToList();
|
|
||||||
|
|
||||||
// may not need scheduling; loads async internally.
|
// may not need scheduling; loads async internally.
|
||||||
Schedule(() =>
|
Schedule(() =>
|
||||||
@ -323,14 +310,6 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
private int distinctCount(List<string> list) => list.Distinct().ToArray().Length;
|
private int distinctCount(List<string> list) => list.Distinct().ToArray().Length;
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
|
||||||
{
|
|
||||||
base.Dispose(isDisposing);
|
|
||||||
|
|
||||||
if (beatmaps != null)
|
|
||||||
beatmaps.ItemAdded -= setAdded;
|
|
||||||
}
|
|
||||||
|
|
||||||
public class ResultCounts
|
public class ResultCounts
|
||||||
{
|
{
|
||||||
public readonly int Artists;
|
public readonly int Artists;
|
||||||
|
Loading…
Reference in New Issue
Block a user