mirror of
https://github.com/ppy/osu.git
synced 2025-01-27 01:02:54 +08:00
Add beatmap panel to multiplayer match screen (#5643)
Add beatmap panel to multiplayer match screen Co-authored-by: Dean Herbert <pe@ppy.sh> Co-authored-by: Dan Balasescu <smoogipoo@smgi.me>
This commit is contained in:
commit
42464acd7e
@ -0,0 +1,53 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Online.Multiplayer;
|
||||||
|
using osu.Game.Screens.Multi.Match.Components;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.MathUtils;
|
||||||
|
using osu.Game.Audio;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual.Multiplayer
|
||||||
|
{
|
||||||
|
[Cached(typeof(IPreviewTrackOwner))]
|
||||||
|
public class TestSceneMatchBeatmapPanel : MultiplayerTestScene, IPreviewTrackOwner
|
||||||
|
{
|
||||||
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||||
|
{
|
||||||
|
typeof(MatchBeatmapPanel)
|
||||||
|
};
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private PreviewTrackManager previewTrackManager { get; set; }
|
||||||
|
|
||||||
|
public TestSceneMatchBeatmapPanel()
|
||||||
|
{
|
||||||
|
Add(new MatchBeatmapPanel
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
});
|
||||||
|
|
||||||
|
Room.Playlist.Add(new PlaylistItem { Beatmap = new BeatmapInfo { OnlineBeatmapID = 1763072 } });
|
||||||
|
Room.Playlist.Add(new PlaylistItem { Beatmap = new BeatmapInfo { OnlineBeatmapID = 2101557 } });
|
||||||
|
Room.Playlist.Add(new PlaylistItem { Beatmap = new BeatmapInfo { OnlineBeatmapID = 1973466 } });
|
||||||
|
Room.Playlist.Add(new PlaylistItem { Beatmap = new BeatmapInfo { OnlineBeatmapID = 2109801 } });
|
||||||
|
Room.Playlist.Add(new PlaylistItem { Beatmap = new BeatmapInfo { OnlineBeatmapID = 1922035 } });
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
AddStep("Select random beatmap", () =>
|
||||||
|
{
|
||||||
|
Room.CurrentItem.Value = Room.Playlist[RNG.Next(Room.Playlist.Count)];
|
||||||
|
previewTrackManager.StopAnyPlaying(this);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -21,7 +21,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
typeof(Info),
|
typeof(Info),
|
||||||
typeof(HeaderButton),
|
typeof(HeaderButton),
|
||||||
typeof(ReadyButton),
|
typeof(ReadyButton),
|
||||||
typeof(ViewBeatmapButton)
|
typeof(MatchBeatmapPanel)
|
||||||
};
|
};
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
|
@ -25,10 +25,14 @@ namespace osu.Game.Screens.Multi.Match.Components
|
|||||||
{
|
{
|
||||||
public const float HEIGHT = 200;
|
public const float HEIGHT = 200;
|
||||||
|
|
||||||
public MatchTabControl Tabs;
|
public readonly BindableBool ShowBeatmapPanel = new BindableBool();
|
||||||
|
|
||||||
|
public MatchTabControl Tabs { get; private set; }
|
||||||
|
|
||||||
public Action RequestBeatmapSelection;
|
public Action RequestBeatmapSelection;
|
||||||
|
|
||||||
|
private MatchBeatmapPanel beatmapPanel;
|
||||||
|
|
||||||
public Header()
|
public Header()
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
@ -53,8 +57,14 @@ namespace osu.Game.Screens.Multi.Match.Components
|
|||||||
new Box
|
new Box
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Colour = ColourInfo.GradientVertical(Color4.Black.Opacity(0.4f), Color4.Black.Opacity(0.6f)),
|
Colour = ColourInfo.GradientVertical(Color4.Black.Opacity(0.7f), Color4.Black.Opacity(0.8f)),
|
||||||
},
|
},
|
||||||
|
beatmapPanel = new MatchBeatmapPanel
|
||||||
|
{
|
||||||
|
Anchor = Anchor.CentreRight,
|
||||||
|
Origin = Anchor.CentreRight,
|
||||||
|
Margin = new MarginPadding { Right = 100 },
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new Box
|
new Box
|
||||||
@ -114,6 +124,12 @@ namespace osu.Game.Screens.Multi.Match.Components
|
|||||||
beatmapButton.Action = () => RequestBeatmapSelection?.Invoke();
|
beatmapButton.Action = () => RequestBeatmapSelection?.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
ShowBeatmapPanel.BindValueChanged(value => beatmapPanel.FadeTo(value.NewValue ? 1 : 0, 200, Easing.OutQuint), true);
|
||||||
|
}
|
||||||
|
|
||||||
private class BeatmapSelectButton : HeaderButton
|
private class BeatmapSelectButton : HeaderButton
|
||||||
{
|
{
|
||||||
[Resolved(typeof(Room), nameof(Room.RoomID))]
|
[Resolved(typeof(Room), nameof(Room.RoomID))]
|
||||||
|
@ -28,7 +28,6 @@ namespace osu.Game.Screens.Multi.Match.Components
|
|||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
ReadyButton readyButton;
|
ReadyButton readyButton;
|
||||||
ViewBeatmapButton viewBeatmapButton;
|
|
||||||
HostInfo hostInfo;
|
HostInfo hostInfo;
|
||||||
|
|
||||||
InternalChildren = new Drawable[]
|
InternalChildren = new Drawable[]
|
||||||
@ -80,7 +79,6 @@ namespace osu.Game.Screens.Multi.Match.Components
|
|||||||
Direction = FillDirection.Horizontal,
|
Direction = FillDirection.Horizontal,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
viewBeatmapButton = new ViewBeatmapButton(),
|
|
||||||
readyButton = new ReadyButton
|
readyButton = new ReadyButton
|
||||||
{
|
{
|
||||||
Action = () => OnStart?.Invoke()
|
Action = () => OnStart?.Invoke()
|
||||||
@ -91,11 +89,7 @@ namespace osu.Game.Screens.Multi.Match.Components
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
CurrentItem.BindValueChanged(item =>
|
CurrentItem.BindValueChanged(item => readyButton.Beatmap.Value = item.NewValue?.Beatmap, true);
|
||||||
{
|
|
||||||
viewBeatmapButton.Beatmap.Value = item.NewValue?.Beatmap;
|
|
||||||
readyButton.Beatmap.Value = item.NewValue?.Beatmap;
|
|
||||||
}, true);
|
|
||||||
|
|
||||||
hostInfo.Host.BindTo(Host);
|
hostInfo.Host.BindTo(Host);
|
||||||
}
|
}
|
||||||
|
62
osu.Game/Screens/Multi/Match/Components/MatchBeatmapPanel.cs
Normal file
62
osu.Game/Screens/Multi/Match/Components/MatchBeatmapPanel.cs
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Threading;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Online.API;
|
||||||
|
using osu.Game.Online.API.Requests;
|
||||||
|
using osu.Game.Overlays.Direct;
|
||||||
|
using osu.Game.Rulesets;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Multi.Match.Components
|
||||||
|
{
|
||||||
|
public class MatchBeatmapPanel : MultiplayerComposite
|
||||||
|
{
|
||||||
|
[Resolved]
|
||||||
|
private IAPIProvider api { get; set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private RulesetStore rulesets { get; set; }
|
||||||
|
|
||||||
|
private CancellationTokenSource loadCancellation;
|
||||||
|
private GetBeatmapSetRequest request;
|
||||||
|
private DirectGridPanel panel;
|
||||||
|
|
||||||
|
public MatchBeatmapPanel()
|
||||||
|
{
|
||||||
|
AutoSizeAxes = Axes.Both;
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
CurrentItem.BindValueChanged(item => loadNewPanel(item.NewValue?.Beatmap), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadNewPanel(BeatmapInfo beatmap)
|
||||||
|
{
|
||||||
|
loadCancellation?.Cancel();
|
||||||
|
request?.Cancel();
|
||||||
|
|
||||||
|
panel?.FadeOut(200);
|
||||||
|
panel?.Expire();
|
||||||
|
panel = null;
|
||||||
|
|
||||||
|
if (beatmap?.OnlineBeatmapID == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
loadCancellation = new CancellationTokenSource();
|
||||||
|
|
||||||
|
request = new GetBeatmapSetRequest(beatmap.OnlineBeatmapID.Value, BeatmapSetLookupType.BeatmapId);
|
||||||
|
request.Success += res => Schedule(() =>
|
||||||
|
{
|
||||||
|
panel = new DirectGridPanel(res.ToBeatmapSet(rulesets));
|
||||||
|
LoadComponentAsync(panel, AddInternal, loadCancellation.Token);
|
||||||
|
});
|
||||||
|
|
||||||
|
api.Queue(request);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,46 +0,0 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
|
||||||
|
|
||||||
using osu.Framework.Allocation;
|
|
||||||
using osu.Framework.Bindables;
|
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Game.Beatmaps;
|
|
||||||
using osuTK;
|
|
||||||
|
|
||||||
namespace osu.Game.Screens.Multi.Match.Components
|
|
||||||
{
|
|
||||||
public class ViewBeatmapButton : HeaderButton
|
|
||||||
{
|
|
||||||
public readonly Bindable<BeatmapInfo> Beatmap = new Bindable<BeatmapInfo>();
|
|
||||||
|
|
||||||
[Resolved(CanBeNull = true)]
|
|
||||||
private OsuGame osuGame { get; set; }
|
|
||||||
|
|
||||||
public ViewBeatmapButton()
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Y;
|
|
||||||
Size = new Vector2(200, 1);
|
|
||||||
|
|
||||||
Text = "View beatmap";
|
|
||||||
}
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load()
|
|
||||||
{
|
|
||||||
if (osuGame != null)
|
|
||||||
Beatmap.BindValueChanged(beatmap => updateAction(beatmap.NewValue), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateAction(BeatmapInfo beatmap)
|
|
||||||
{
|
|
||||||
if (beatmap == null)
|
|
||||||
{
|
|
||||||
Enabled.Value = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Action = () => osuGame.ShowBeatmap(beatmap.OnlineBeatmapID ?? 0);
|
|
||||||
Enabled.Value = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -7,6 +7,7 @@ using osu.Framework.Bindables;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
|
using osu.Game.Audio;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Online.Multiplayer;
|
using osu.Game.Online.Multiplayer;
|
||||||
using osu.Game.Online.Multiplayer.GameTypes;
|
using osu.Game.Online.Multiplayer.GameTypes;
|
||||||
@ -18,7 +19,8 @@ using PlaylistItem = osu.Game.Online.Multiplayer.PlaylistItem;
|
|||||||
|
|
||||||
namespace osu.Game.Screens.Multi.Match
|
namespace osu.Game.Screens.Multi.Match
|
||||||
{
|
{
|
||||||
public class MatchSubScreen : MultiplayerSubScreen
|
[Cached(typeof(IPreviewTrackOwner))]
|
||||||
|
public class MatchSubScreen : MultiplayerSubScreen, IPreviewTrackOwner
|
||||||
{
|
{
|
||||||
public override bool DisallowExternalBeatmapRulesetChanges => true;
|
public override bool DisallowExternalBeatmapRulesetChanges => true;
|
||||||
|
|
||||||
@ -44,6 +46,9 @@ namespace osu.Game.Screens.Multi.Match
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private BeatmapManager beatmapManager { get; set; }
|
private BeatmapManager beatmapManager { get; set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private PreviewTrackManager previewTrackManager { get; set; }
|
||||||
|
|
||||||
[Resolved(CanBeNull = true)]
|
[Resolved(CanBeNull = true)]
|
||||||
private OsuGame game { get; set; }
|
private OsuGame game { get; set; }
|
||||||
|
|
||||||
@ -146,18 +151,12 @@ namespace osu.Game.Screens.Multi.Match
|
|||||||
{
|
{
|
||||||
const float fade_duration = 500;
|
const float fade_duration = 500;
|
||||||
|
|
||||||
if (tab.NewValue is SettingsMatchPage)
|
var settingsDisplayed = tab.NewValue is SettingsMatchPage;
|
||||||
{
|
|
||||||
settings.Show();
|
header.ShowBeatmapPanel.Value = !settingsDisplayed;
|
||||||
info.FadeOut(fade_duration, Easing.OutQuint);
|
settings.State.Value = settingsDisplayed ? Visibility.Visible : Visibility.Hidden;
|
||||||
bottomRow.FadeOut(fade_duration, Easing.OutQuint);
|
info.FadeTo(settingsDisplayed ? 0 : 1, fade_duration, Easing.OutQuint);
|
||||||
}
|
bottomRow.FadeTo(settingsDisplayed ? 0 : 1, fade_duration, Easing.OutQuint);
|
||||||
else
|
|
||||||
{
|
|
||||||
settings.Hide();
|
|
||||||
info.FadeIn(fade_duration, Easing.OutQuint);
|
|
||||||
bottomRow.FadeIn(fade_duration, Easing.OutQuint);
|
|
||||||
}
|
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
chat.Exit += () =>
|
chat.Exit += () =>
|
||||||
@ -179,8 +178,8 @@ namespace osu.Game.Screens.Multi.Match
|
|||||||
public override bool OnExiting(IScreen next)
|
public override bool OnExiting(IScreen next)
|
||||||
{
|
{
|
||||||
RoomManager?.PartRoom();
|
RoomManager?.PartRoom();
|
||||||
|
|
||||||
Mods.Value = Array.Empty<Mod>();
|
Mods.Value = Array.Empty<Mod>();
|
||||||
|
previewTrackManager.StopAnyPlaying(this);
|
||||||
|
|
||||||
return base.OnExiting(next);
|
return base.OnExiting(next);
|
||||||
}
|
}
|
||||||
@ -198,6 +197,8 @@ namespace osu.Game.Screens.Multi.Match
|
|||||||
|
|
||||||
if (e.NewValue?.Ruleset != null)
|
if (e.NewValue?.Ruleset != null)
|
||||||
Ruleset.Value = e.NewValue.Ruleset;
|
Ruleset.Value = e.NewValue.Ruleset;
|
||||||
|
|
||||||
|
previewTrackManager.StopAnyPlaying(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -223,6 +224,8 @@ namespace osu.Game.Screens.Multi.Match
|
|||||||
|
|
||||||
private void onStart()
|
private void onStart()
|
||||||
{
|
{
|
||||||
|
previewTrackManager.StopAnyPlaying(this);
|
||||||
|
|
||||||
switch (type.Value)
|
switch (type.Value)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user