mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 23:24:04 +09:00
Merge branch 'master' into beatmap-cancellation-token
This commit is contained in:
@ -13,7 +13,6 @@ using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Threading;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Drawables;
|
||||
using osu.Game.Graphics;
|
||||
@ -45,6 +44,8 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
private ExplicitContentBeatmapPill explicitContentPill;
|
||||
private ModDisplay modDisplay;
|
||||
|
||||
private readonly IBindable<bool> valid = new Bindable<bool>();
|
||||
|
||||
private readonly Bindable<IBeatmapInfo> beatmap = new Bindable<IBeatmapInfo>();
|
||||
private readonly Bindable<IRulesetInfo> ruleset = new Bindable<IRulesetInfo>();
|
||||
private readonly BindableList<Mod> requiredMods = new BindableList<Mod>();
|
||||
@ -66,14 +67,18 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
this.allowSelection = allowSelection;
|
||||
|
||||
beatmap.BindTo(item.Beatmap);
|
||||
valid.BindTo(item.Valid);
|
||||
ruleset.BindTo(item.Ruleset);
|
||||
requiredMods.BindTo(item.RequiredMods);
|
||||
|
||||
ShowDragHandle.Value = allowEdit;
|
||||
}
|
||||
|
||||
[Resolved]
|
||||
private OsuColour colours { get; set; }
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
private void load()
|
||||
{
|
||||
if (!allowEdit)
|
||||
HandleColour = HandleColour.Opacity(0);
|
||||
@ -85,27 +90,43 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
SelectedItem.BindValueChanged(selected => maskingContainer.BorderThickness = selected.NewValue == Model ? 5 : 0, true);
|
||||
SelectedItem.BindValueChanged(selected =>
|
||||
{
|
||||
bool isCurrent = selected.NewValue == Model;
|
||||
|
||||
beatmap.BindValueChanged(_ => scheduleRefresh());
|
||||
ruleset.BindValueChanged(_ => scheduleRefresh());
|
||||
if (!valid.Value)
|
||||
{
|
||||
// Don't allow selection when not valid.
|
||||
if (isCurrent)
|
||||
{
|
||||
SelectedItem.Value = selected.OldValue;
|
||||
}
|
||||
|
||||
requiredMods.CollectionChanged += (_, __) => scheduleRefresh();
|
||||
// Don't update border when not valid (the border is displaying this fact).
|
||||
return;
|
||||
}
|
||||
|
||||
maskingContainer.BorderThickness = isCurrent ? 5 : 0;
|
||||
}, true);
|
||||
|
||||
beatmap.BindValueChanged(_ => Scheduler.AddOnce(refresh));
|
||||
ruleset.BindValueChanged(_ => Scheduler.AddOnce(refresh));
|
||||
valid.BindValueChanged(_ => Scheduler.AddOnce(refresh));
|
||||
requiredMods.CollectionChanged += (_, __) => Scheduler.AddOnce(refresh);
|
||||
|
||||
refresh();
|
||||
}
|
||||
|
||||
private ScheduledDelegate scheduledRefresh;
|
||||
private PanelBackground panelBackground;
|
||||
|
||||
private void scheduleRefresh()
|
||||
{
|
||||
scheduledRefresh?.Cancel();
|
||||
scheduledRefresh = Schedule(refresh);
|
||||
}
|
||||
|
||||
private void refresh()
|
||||
{
|
||||
if (!valid.Value)
|
||||
{
|
||||
maskingContainer.BorderThickness = 5;
|
||||
maskingContainer.BorderColour = colours.Red;
|
||||
}
|
||||
|
||||
difficultyIconContainer.Child = new DifficultyIcon(Item.Beatmap.Value, ruleset.Value, requiredMods, performBackgroundDifficultyLookup: false) { Size = new Vector2(32) };
|
||||
|
||||
panelBackground.Beatmap.Value = Item.Beatmap.Value;
|
||||
@ -278,7 +299,7 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
|
||||
protected override bool OnClick(ClickEvent e)
|
||||
{
|
||||
if (allowSelection)
|
||||
if (allowSelection && valid.Value)
|
||||
SelectedItem.Value = Model;
|
||||
return true;
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using Humanizer;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
@ -204,7 +205,7 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
|
||||
{
|
||||
new Drawable[]
|
||||
{
|
||||
playlist = new DrawableRoomPlaylist(true, true) { RelativeSizeAxes = Axes.Both }
|
||||
playlist = new DrawableRoomPlaylist(true, false) { RelativeSizeAxes = Axes.Both }
|
||||
},
|
||||
new Drawable[]
|
||||
{
|
||||
@ -339,9 +340,8 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
|
||||
|
||||
Duration.Value = DurationField.Current.Value;
|
||||
|
||||
manager?.CreateRoom(room, onSuccess, onError);
|
||||
|
||||
loadingLayer.Show();
|
||||
manager?.CreateRoom(room, onSuccess, onError);
|
||||
}
|
||||
|
||||
private void hideError() => ErrorText.FadeOut(50);
|
||||
@ -350,9 +350,31 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
|
||||
|
||||
private void onError(string text)
|
||||
{
|
||||
ErrorText.Text = text;
|
||||
ErrorText.FadeIn(50);
|
||||
// see https://github.com/ppy/osu-web/blob/2c97aaeb64fb4ed97c747d8383a35b30f57428c7/app/Models/Multiplayer/PlaylistItem.php#L48.
|
||||
const string not_found_prefix = "beatmaps not found:";
|
||||
|
||||
if (text.StartsWith(not_found_prefix, StringComparison.Ordinal))
|
||||
{
|
||||
ErrorText.Text = "One or more beatmaps were not available online. Please remove or replace the highlighted items.";
|
||||
|
||||
int[] invalidBeatmapIDs = text
|
||||
.Substring(not_found_prefix.Length + 1)
|
||||
.Split(", ")
|
||||
.Select(int.Parse)
|
||||
.ToArray();
|
||||
|
||||
foreach (var item in Playlist)
|
||||
{
|
||||
if (invalidBeatmapIDs.Contains(item.BeatmapID))
|
||||
item.MarkInvalid();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorText.Text = text;
|
||||
}
|
||||
|
||||
ErrorText.FadeIn(50);
|
||||
loadingLayer.Hide();
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ namespace osu.Game.Screens.Play
|
||||
/// </summary>
|
||||
public class BeatmapMetadataDisplay : Container
|
||||
{
|
||||
private readonly WorkingBeatmap beatmap;
|
||||
private readonly IWorkingBeatmap beatmap;
|
||||
private readonly Bindable<IReadOnlyList<Mod>> mods;
|
||||
private readonly Drawable logoFacade;
|
||||
private LoadingSpinner loading;
|
||||
@ -43,7 +43,7 @@ namespace osu.Game.Screens.Play
|
||||
}
|
||||
}
|
||||
|
||||
public BeatmapMetadataDisplay(WorkingBeatmap beatmap, Bindable<IReadOnlyList<Mod>> mods, Drawable logoFacade)
|
||||
public BeatmapMetadataDisplay(IWorkingBeatmap beatmap, Bindable<IReadOnlyList<Mod>> mods, Drawable logoFacade)
|
||||
{
|
||||
this.beatmap = beatmap;
|
||||
this.logoFacade = logoFacade;
|
||||
|
@ -354,7 +354,7 @@ namespace osu.Game.Screens.Play
|
||||
private Drawable createUnderlayComponents() =>
|
||||
DimmableStoryboard = new DimmableStoryboard(Beatmap.Value.Storyboard) { RelativeSizeAxes = Axes.Both };
|
||||
|
||||
private Drawable createGameplayComponents(WorkingBeatmap working, IBeatmap playableBeatmap) => new ScalingContainer(ScalingMode.Gameplay)
|
||||
private Drawable createGameplayComponents(IWorkingBeatmap working, IBeatmap playableBeatmap) => new ScalingContainer(ScalingMode.Gameplay)
|
||||
{
|
||||
Children = new Drawable[]
|
||||
{
|
||||
@ -372,7 +372,7 @@ namespace osu.Game.Screens.Play
|
||||
}
|
||||
};
|
||||
|
||||
private Drawable createOverlayComponents(WorkingBeatmap working)
|
||||
private Drawable createOverlayComponents(IWorkingBeatmap working)
|
||||
{
|
||||
var container = new Container
|
||||
{
|
||||
|
@ -15,9 +15,9 @@ namespace osu.Game.Screens.Select
|
||||
{
|
||||
internal class BeatmapInfoWedgeBackground : CompositeDrawable
|
||||
{
|
||||
private readonly WorkingBeatmap beatmap;
|
||||
private readonly IWorkingBeatmap beatmap;
|
||||
|
||||
public BeatmapInfoWedgeBackground(WorkingBeatmap beatmap)
|
||||
public BeatmapInfoWedgeBackground(IWorkingBeatmap beatmap)
|
||||
{
|
||||
this.beatmap = beatmap;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
{
|
||||
public class SetPanelBackground : BufferedContainer
|
||||
{
|
||||
public SetPanelBackground(WorkingBeatmap working)
|
||||
public SetPanelBackground(IWorkingBeatmap working)
|
||||
: base(cachedFrameBuffer: true)
|
||||
{
|
||||
RedrawOnScale = false;
|
||||
|
@ -671,7 +671,7 @@ namespace osu.Game.Screens.Select
|
||||
music.TrackChanged -= ensureTrackLooping;
|
||||
}
|
||||
|
||||
private void ensureTrackLooping(WorkingBeatmap beatmap, TrackChangeDirection changeDirection)
|
||||
private void ensureTrackLooping(IWorkingBeatmap beatmap, TrackChangeDirection changeDirection)
|
||||
=> beatmap.PrepareTrackForPreviewLooping();
|
||||
|
||||
public override bool OnBackButton()
|
||||
|
Reference in New Issue
Block a user