mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 14:12:54 +08:00
Add a loading state to BeatmapSetOverlay.
- Handle null value in header and info sections - Add item to context menu for carousel beatmaps to show details
This commit is contained in:
parent
c304c1eecf
commit
7482d5986a
@ -374,6 +374,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
AddStep(@"hide", overlay.Hide);
|
AddStep(@"hide", overlay.Hide);
|
||||||
AddStep(@"show without reload", overlay.Show);
|
AddStep(@"show without reload", overlay.Show);
|
||||||
|
AddStep(@"show loading", () => overlay.BeatmapSet = null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -150,7 +150,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
|||||||
Beatmap.TriggerChange();
|
Beatmap.TriggerChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showBeatmap(BeatmapInfo beatmap) => version.Text = beatmap.Version;
|
private void showBeatmap(BeatmapInfo beatmap) => version.Text = beatmap?.Version;
|
||||||
|
|
||||||
private void updateDifficultyButtons()
|
private void updateDifficultyButtons()
|
||||||
{
|
{
|
||||||
|
@ -48,6 +48,9 @@ namespace osu.Game.Overlays.BeatmapSet
|
|||||||
if (value == beatmapSet) return;
|
if (value == beatmapSet) return;
|
||||||
beatmapSet = value;
|
beatmapSet = value;
|
||||||
|
|
||||||
|
if (beatmapSet == null)
|
||||||
|
return;
|
||||||
|
|
||||||
Picker.BeatmapSet = author.BeatmapSet = Details.BeatmapSet = BeatmapSet;
|
Picker.BeatmapSet = author.BeatmapSet = Details.BeatmapSet = BeatmapSet;
|
||||||
title.Text = BeatmapSet.Metadata.Title;
|
title.Text = BeatmapSet.Metadata.Title;
|
||||||
artist.Text = BeatmapSet.Metadata.Artist;
|
artist.Text = BeatmapSet.Metadata.Artist;
|
||||||
|
@ -34,6 +34,9 @@ namespace osu.Game.Overlays.BeatmapSet
|
|||||||
if (value == beatmapSet) return;
|
if (value == beatmapSet) return;
|
||||||
beatmapSet = value;
|
beatmapSet = value;
|
||||||
|
|
||||||
|
if (beatmapSet == null)
|
||||||
|
return;
|
||||||
|
|
||||||
source.Text = BeatmapSet.Metadata.Source;
|
source.Text = BeatmapSet.Metadata.Source;
|
||||||
tags.Text = BeatmapSet.Metadata.Tags;
|
tags.Text = BeatmapSet.Metadata.Tags;
|
||||||
}
|
}
|
||||||
|
@ -18,17 +18,22 @@ using osu.Game.Overlays.BeatmapSet;
|
|||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Overlays.BeatmapSet.Scores;
|
using osu.Game.Overlays.BeatmapSet.Scores;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using osu.Framework.Configuration;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
|
||||||
namespace osu.Game.Overlays
|
namespace osu.Game.Overlays
|
||||||
{
|
{
|
||||||
public class BeatmapSetOverlay : WaveOverlayContainer
|
public class BeatmapSetOverlay : WaveOverlayContainer
|
||||||
{
|
{
|
||||||
|
private const int fade_duration = 300;
|
||||||
|
|
||||||
public const float X_PADDING = 40;
|
public const float X_PADDING = 40;
|
||||||
public const float RIGHT_WIDTH = 275;
|
public const float RIGHT_WIDTH = 275;
|
||||||
|
|
||||||
private readonly Header header;
|
private readonly Header header;
|
||||||
private readonly Info info;
|
private readonly Info info;
|
||||||
private readonly ScoresContainer scores;
|
private readonly ScoresContainer scores;
|
||||||
|
private readonly LoadingAnimation loading;
|
||||||
|
|
||||||
private APIAccess api;
|
private APIAccess api;
|
||||||
private RulesetStore rulesets;
|
private RulesetStore rulesets;
|
||||||
@ -36,6 +41,31 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
private readonly ScrollContainer scroll;
|
private readonly ScrollContainer scroll;
|
||||||
|
|
||||||
|
private BeatmapSetInfo beatmapSet;
|
||||||
|
|
||||||
|
public BeatmapSetInfo BeatmapSet
|
||||||
|
{
|
||||||
|
get => beatmapSet;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value == beatmapSet)
|
||||||
|
return;
|
||||||
|
|
||||||
|
beatmapSet = value;
|
||||||
|
|
||||||
|
if (beatmapSet == null)
|
||||||
|
{
|
||||||
|
scroll.FadeOut(fade_duration);
|
||||||
|
loading.FadeIn(fade_duration);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
header.BeatmapSet = info.BeatmapSet = beatmapSet;
|
||||||
|
loading.FadeOut(fade_duration);
|
||||||
|
scroll.FadeIn(fade_duration);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 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.
|
||||||
public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => true;
|
public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => true;
|
||||||
|
|
||||||
@ -67,10 +97,17 @@ namespace osu.Game.Overlays
|
|||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Colour = OsuColour.Gray(0.2f)
|
Colour = OsuColour.Gray(0.2f)
|
||||||
},
|
},
|
||||||
|
loading = new LoadingAnimation
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Alpha = 1,
|
||||||
|
},
|
||||||
scroll = new ScrollContainer
|
scroll = new ScrollContainer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
ScrollbarVisible = false,
|
ScrollbarVisible = false,
|
||||||
|
Alpha = 0,
|
||||||
Child = new ReverseChildIDFillFlowContainer<Drawable>
|
Child = new ReverseChildIDFillFlowContainer<Drawable>
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
@ -89,6 +126,8 @@ namespace osu.Game.Overlays
|
|||||||
header.Picker.Beatmap.ValueChanged += b =>
|
header.Picker.Beatmap.ValueChanged += b =>
|
||||||
{
|
{
|
||||||
info.Beatmap = b;
|
info.Beatmap = b;
|
||||||
|
|
||||||
|
if (b != null)
|
||||||
updateScores(b);
|
updateScores(b);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -132,6 +171,7 @@ namespace osu.Game.Overlays
|
|||||||
base.PopOut();
|
base.PopOut();
|
||||||
header.Details.StopPreview();
|
header.Details.StopPreview();
|
||||||
FadeEdgeEffectTo(0, DISAPPEAR_DURATION, Easing.Out);
|
FadeEdgeEffectTo(0, DISAPPEAR_DURATION, Easing.Out);
|
||||||
|
BeatmapSet = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnClick(InputState state)
|
protected override bool OnClick(InputState state)
|
||||||
@ -142,6 +182,7 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
public void ShowBeatmap(int beatmapId)
|
public void ShowBeatmap(int beatmapId)
|
||||||
{
|
{
|
||||||
|
BeatmapSet = null;
|
||||||
var req = new GetBeatmapSetRequest(beatmapId, BeatmapSetLookupType.BeatmapId);
|
var req = new GetBeatmapSetRequest(beatmapId, BeatmapSetLookupType.BeatmapId);
|
||||||
req.Success += res =>
|
req.Success += res =>
|
||||||
{
|
{
|
||||||
@ -149,25 +190,21 @@ namespace osu.Game.Overlays
|
|||||||
header.Picker.Beatmap.Value = header.BeatmapSet.Beatmaps.First(b => b.OnlineBeatmapID == beatmapId);
|
header.Picker.Beatmap.Value = header.BeatmapSet.Beatmaps.First(b => b.OnlineBeatmapID == beatmapId);
|
||||||
};
|
};
|
||||||
api.Queue(req);
|
api.Queue(req);
|
||||||
}
|
Show();
|
||||||
|
|
||||||
public void ShowBeatmap(BeatmapInfo beatmap)
|
|
||||||
{
|
|
||||||
ShowBeatmapSet(beatmap.BeatmapSet);
|
|
||||||
header.Picker.Beatmap.Value = beatmap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowBeatmapSet(int beatmapSetId)
|
public void ShowBeatmapSet(int beatmapSetId)
|
||||||
{
|
{
|
||||||
// todo: display the overlay while we are loading here. we need to support setting BeatmapSet to null for this to work.
|
BeatmapSet = null;
|
||||||
var req = new GetBeatmapSetRequest(beatmapSetId);
|
var req = new GetBeatmapSetRequest(beatmapSetId);
|
||||||
req.Success += res => ShowBeatmapSet(res.ToBeatmapSet(rulesets));
|
req.Success += res => ShowBeatmapSet(res.ToBeatmapSet(rulesets));
|
||||||
api.Queue(req);
|
api.Queue(req);
|
||||||
|
Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowBeatmapSet(BeatmapSetInfo set)
|
public void ShowBeatmapSet(BeatmapSetInfo set)
|
||||||
{
|
{
|
||||||
header.BeatmapSet = info.BeatmapSet = set;
|
BeatmapSet = set;
|
||||||
Show();
|
Show();
|
||||||
scroll.ScrollTo(0);
|
scroll.ScrollTo(0);
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ using osu.Game.Graphics;
|
|||||||
using osu.Game.Graphics.Backgrounds;
|
using osu.Game.Graphics.Backgrounds;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
using osu.Game.Overlays;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
|
|
||||||
@ -35,6 +36,8 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
private Triangles triangles;
|
private Triangles triangles;
|
||||||
private StarCounter starCounter;
|
private StarCounter starCounter;
|
||||||
|
|
||||||
|
private BeatmapSetOverlay beatmapOverlay;
|
||||||
|
|
||||||
public DrawableCarouselBeatmap(CarouselBeatmap panel) : base(panel)
|
public DrawableCarouselBeatmap(CarouselBeatmap panel) : base(panel)
|
||||||
{
|
{
|
||||||
beatmap = panel.Beatmap;
|
beatmap = panel.Beatmap;
|
||||||
@ -42,8 +45,10 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader(true)]
|
[BackgroundDependencyLoader(true)]
|
||||||
private void load(SongSelect songSelect, BeatmapManager manager)
|
private void load(SongSelect songSelect, BeatmapManager manager, BeatmapSetOverlay beatmapOverlay)
|
||||||
{
|
{
|
||||||
|
this.beatmapOverlay = beatmapOverlay;
|
||||||
|
|
||||||
if (songSelect != null)
|
if (songSelect != null)
|
||||||
{
|
{
|
||||||
startRequested = songSelect.FinaliseSelection;
|
startRequested = songSelect.FinaliseSelection;
|
||||||
@ -171,6 +176,10 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
new OsuMenuItem("Play", MenuItemType.Highlighted, () => startRequested?.Invoke(beatmap)),
|
new OsuMenuItem("Play", MenuItemType.Highlighted, () => startRequested?.Invoke(beatmap)),
|
||||||
new OsuMenuItem("Edit", MenuItemType.Standard, () => editRequested?.Invoke(beatmap)),
|
new OsuMenuItem("Edit", MenuItemType.Standard, () => editRequested?.Invoke(beatmap)),
|
||||||
new OsuMenuItem("Hide", MenuItemType.Destructive, () => hideRequested?.Invoke(beatmap)),
|
new OsuMenuItem("Hide", MenuItemType.Destructive, () => hideRequested?.Invoke(beatmap)),
|
||||||
|
new OsuMenuItem("Details", MenuItemType.Standard, () =>
|
||||||
|
{
|
||||||
|
if (beatmap.OnlineBeatmapID.HasValue) beatmapOverlay?.ShowBeatmap(beatmap.OnlineBeatmapID.Value);
|
||||||
|
}),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user