mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 19:22:54 +08:00
Merge pull request #14408 from smoogipoo/remove-current-room
Remove the global "selected room" from online screens
This commit is contained in:
commit
eaa4d479ac
@ -24,12 +24,11 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
{
|
||||
public class TestSceneDrawableRoom : OsuTestScene
|
||||
{
|
||||
[Cached]
|
||||
private readonly Bindable<Room> selectedRoom = new Bindable<Room>();
|
||||
|
||||
[Cached]
|
||||
protected readonly OverlayColourProvider ColourProvider = new OverlayColourProvider(OverlayColourScheme.Plum);
|
||||
|
||||
private readonly Bindable<Room> selectedRoom = new Bindable<Room>();
|
||||
|
||||
[Test]
|
||||
public void TestMultipleStatuses()
|
||||
{
|
||||
@ -153,7 +152,11 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
}));
|
||||
}
|
||||
|
||||
return new DrawableLoungeRoom(room) { MatchingFilter = true };
|
||||
return new DrawableLoungeRoom(room)
|
||||
{
|
||||
MatchingFilter = true,
|
||||
SelectedRoom = { BindTarget = selectedRoom }
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Width = 0.5f,
|
||||
SelectedRoom = { BindTarget = SelectedRoom }
|
||||
};
|
||||
});
|
||||
|
||||
|
@ -3,10 +3,11 @@
|
||||
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Screens.OnlinePlay.Lounge;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osu.Game.Screens.OnlinePlay.Lounge.Components;
|
||||
using osu.Game.Screens.OnlinePlay.Playlists;
|
||||
using osu.Game.Tests.Visual.OnlinePlay;
|
||||
@ -18,13 +19,13 @@ namespace osu.Game.Tests.Visual.Playlists
|
||||
{
|
||||
protected new TestRequestHandlingRoomManager RoomManager => (TestRequestHandlingRoomManager)base.RoomManager;
|
||||
|
||||
private LoungeSubScreen loungeScreen;
|
||||
private TestLoungeSubScreen loungeScreen;
|
||||
|
||||
public override void SetUpSteps()
|
||||
{
|
||||
base.SetUpSteps();
|
||||
|
||||
AddStep("push screen", () => LoadScreen(loungeScreen = new PlaylistsLoungeSubScreen()));
|
||||
AddStep("push screen", () => LoadScreen(loungeScreen = new TestLoungeSubScreen()));
|
||||
|
||||
AddUntilStep("wait for present", () => loungeScreen.IsCurrentScreen());
|
||||
}
|
||||
@ -69,21 +70,26 @@ namespace osu.Game.Tests.Visual.Playlists
|
||||
{
|
||||
AddStep("add rooms", () => RoomManager.AddRooms(1));
|
||||
|
||||
AddAssert("selected room is not disabled", () => !OnlinePlayDependencies.SelectedRoom.Disabled);
|
||||
AddAssert("selected room is not disabled", () => !loungeScreen.SelectedRoom.Disabled);
|
||||
|
||||
AddStep("select room", () => roomsContainer.Rooms[0].TriggerClick());
|
||||
AddAssert("selected room is non-null", () => OnlinePlayDependencies.SelectedRoom.Value != null);
|
||||
AddAssert("selected room is non-null", () => loungeScreen.SelectedRoom.Value != null);
|
||||
|
||||
AddStep("enter room", () => roomsContainer.Rooms[0].TriggerClick());
|
||||
|
||||
AddUntilStep("wait for match load", () => Stack.CurrentScreen is PlaylistsRoomSubScreen);
|
||||
|
||||
AddAssert("selected room is non-null", () => OnlinePlayDependencies.SelectedRoom.Value != null);
|
||||
AddAssert("selected room is disabled", () => OnlinePlayDependencies.SelectedRoom.Disabled);
|
||||
AddAssert("selected room is non-null", () => loungeScreen.SelectedRoom.Value != null);
|
||||
AddAssert("selected room is disabled", () => loungeScreen.SelectedRoom.Disabled);
|
||||
}
|
||||
|
||||
private bool checkRoomVisible(DrawableRoom room) =>
|
||||
loungeScreen.ChildrenOfType<OsuScrollContainer>().First().ScreenSpaceDrawQuad
|
||||
.Contains(room.ScreenSpaceDrawQuad.Centre);
|
||||
|
||||
private class TestLoungeSubScreen : PlaylistsLoungeSubScreen
|
||||
{
|
||||
public new Bindable<Room> SelectedRoom => base.SelectedRoom;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ namespace osu.Game.Tests.Visual.Playlists
|
||||
{
|
||||
SelectedRoom.Value = new Room();
|
||||
|
||||
Child = settings = new TestRoomSettings
|
||||
Child = settings = new TestRoomSettings(SelectedRoom.Value)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
State = { Value = Visibility.Visible }
|
||||
@ -118,6 +118,11 @@ namespace osu.Game.Tests.Visual.Playlists
|
||||
public OsuDropdown<TimeSpan> DurationField => ((MatchSettings)Settings).DurationField;
|
||||
|
||||
public OsuSpriteText ErrorText => ((MatchSettings)Settings).ErrorText;
|
||||
|
||||
public TestRoomSettings(Room room)
|
||||
: base(room)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private class TestDependencies : OnlinePlayTestSceneDependencies
|
||||
|
@ -11,6 +11,9 @@ namespace osu.Game.Screens
|
||||
{
|
||||
public abstract class BackgroundScreen : Screen, IEquatable<BackgroundScreen>
|
||||
{
|
||||
protected const float TRANSITION_LENGTH = 500;
|
||||
private const float x_movement_amount = 50;
|
||||
|
||||
private readonly bool animateOnEnter;
|
||||
|
||||
public override bool IsPresent => base.IsPresent || Scheduler.HasPendingTasks;
|
||||
@ -27,9 +30,6 @@ namespace osu.Game.Screens
|
||||
return other?.GetType() == GetType();
|
||||
}
|
||||
|
||||
private const float transition_length = 500;
|
||||
private const float x_movement_amount = 50;
|
||||
|
||||
protected override bool OnKeyDown(KeyDownEvent e)
|
||||
{
|
||||
// we don't want to handle escape key.
|
||||
@ -55,8 +55,8 @@ namespace osu.Game.Screens
|
||||
this.FadeOut();
|
||||
this.MoveToX(x_movement_amount);
|
||||
|
||||
this.FadeIn(transition_length, Easing.InOutQuart);
|
||||
this.MoveToX(0, transition_length, Easing.InOutQuart);
|
||||
this.FadeIn(TRANSITION_LENGTH, Easing.InOutQuart);
|
||||
this.MoveToX(0, TRANSITION_LENGTH, Easing.InOutQuart);
|
||||
}
|
||||
|
||||
base.OnEntering(last);
|
||||
@ -64,7 +64,7 @@ namespace osu.Game.Screens
|
||||
|
||||
public override void OnSuspending(IScreen next)
|
||||
{
|
||||
this.MoveToX(-x_movement_amount, transition_length, Easing.InOutQuart);
|
||||
this.MoveToX(-x_movement_amount, TRANSITION_LENGTH, Easing.InOutQuart);
|
||||
base.OnSuspending(next);
|
||||
}
|
||||
|
||||
@ -72,8 +72,8 @@ namespace osu.Game.Screens
|
||||
{
|
||||
if (IsLoaded)
|
||||
{
|
||||
this.FadeOut(transition_length, Easing.OutExpo);
|
||||
this.MoveToX(x_movement_amount, transition_length, Easing.OutExpo);
|
||||
this.FadeOut(TRANSITION_LENGTH, Easing.OutExpo);
|
||||
this.MoveToX(x_movement_amount, TRANSITION_LENGTH, Easing.OutExpo);
|
||||
}
|
||||
|
||||
return base.OnExiting(next);
|
||||
@ -82,7 +82,7 @@ namespace osu.Game.Screens
|
||||
public override void OnResuming(IScreen last)
|
||||
{
|
||||
if (IsLoaded)
|
||||
this.MoveToX(0, transition_length, Easing.OutExpo);
|
||||
this.MoveToX(0, TRANSITION_LENGTH, Easing.OutExpo);
|
||||
base.OnResuming(last);
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,6 @@
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Screens;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Screens
|
||||
{
|
||||
@ -13,14 +12,11 @@ namespace osu.Game.Screens
|
||||
public BackgroundScreenStack()
|
||||
: base(false)
|
||||
{
|
||||
Scale = new Vector2(1.06f);
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
Anchor = Anchor.Centre;
|
||||
Origin = Anchor.Centre;
|
||||
}
|
||||
|
||||
//public float ParallaxAmount { set => parallax.ParallaxAmount = ParallaxContainer.DEFAULT_PARALLAX_AMOUNT * value; }
|
||||
|
||||
public void Push(BackgroundScreen screen)
|
||||
{
|
||||
if (screen == null)
|
||||
|
@ -20,9 +20,6 @@ namespace osu.Game.Screens.OnlinePlay.Components
|
||||
|
||||
public readonly Bindable<FilterCriteria> Filter = new Bindable<FilterCriteria>();
|
||||
|
||||
[Resolved]
|
||||
private Bindable<Room> selectedRoom { get; set; }
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
|
@ -0,0 +1,103 @@
|
||||
// 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.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace osu.Game.Screens.OnlinePlay.Components
|
||||
{
|
||||
public abstract class OnlinePlayBackgroundScreen : BackgroundScreen
|
||||
{
|
||||
private CancellationTokenSource? cancellationSource;
|
||||
private PlaylistItemBackground? background;
|
||||
|
||||
protected OnlinePlayBackgroundScreen()
|
||||
: base(false)
|
||||
{
|
||||
AddInternal(new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Depth = float.MinValue,
|
||||
Colour = ColourInfo.GradientVertical(Color4.Black.Opacity(0.9f), Color4.Black.Opacity(0.6f))
|
||||
});
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
switchBackground(new PlaylistItemBackground(playlistItem));
|
||||
}
|
||||
|
||||
private PlaylistItem? playlistItem;
|
||||
|
||||
protected PlaylistItem? PlaylistItem
|
||||
{
|
||||
get => playlistItem;
|
||||
set
|
||||
{
|
||||
if (playlistItem == value)
|
||||
return;
|
||||
|
||||
playlistItem = value;
|
||||
|
||||
if (LoadState > LoadState.Ready)
|
||||
updateBackground();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateBackground()
|
||||
{
|
||||
Schedule(() =>
|
||||
{
|
||||
var beatmap = playlistItem?.Beatmap.Value;
|
||||
|
||||
if (background?.BeatmapInfo?.BeatmapSet?.OnlineInfo?.Covers?.Cover == beatmap?.BeatmapSet?.OnlineInfo?.Covers?.Cover)
|
||||
return;
|
||||
|
||||
cancellationSource?.Cancel();
|
||||
LoadComponentAsync(new PlaylistItemBackground(playlistItem), switchBackground, (cancellationSource = new CancellationTokenSource()).Token);
|
||||
});
|
||||
}
|
||||
|
||||
private void switchBackground(PlaylistItemBackground newBackground)
|
||||
{
|
||||
float newDepth = 0;
|
||||
|
||||
if (background != null)
|
||||
{
|
||||
newDepth = background.Depth + 1;
|
||||
background.FinishTransforms();
|
||||
background.FadeOut(250);
|
||||
background.Expire();
|
||||
}
|
||||
|
||||
newBackground.Depth = newDepth;
|
||||
newBackground.BlurTo(new Vector2(10));
|
||||
|
||||
AddInternal(background = newBackground);
|
||||
}
|
||||
|
||||
public override void OnSuspending(IScreen next)
|
||||
{
|
||||
base.OnSuspending(next);
|
||||
this.MoveToX(0, TRANSITION_LENGTH);
|
||||
}
|
||||
|
||||
public override bool OnExiting(IScreen next)
|
||||
{
|
||||
var result = base.OnExiting(next);
|
||||
this.MoveToX(0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
// 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.
|
||||
|
||||
#nullable enable
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics.Backgrounds;
|
||||
using osu.Game.Online.Rooms;
|
||||
|
||||
namespace osu.Game.Screens.OnlinePlay.Components
|
||||
{
|
||||
public class PlaylistItemBackground : Background
|
||||
{
|
||||
public readonly BeatmapInfo? BeatmapInfo;
|
||||
|
||||
public PlaylistItemBackground(PlaylistItem? playlistItem)
|
||||
{
|
||||
BeatmapInfo = playlistItem?.Beatmap.Value;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(BeatmapManager beatmaps, LargeTextureStore textures)
|
||||
{
|
||||
Texture? texture = null;
|
||||
|
||||
// prefer online cover where available.
|
||||
if (BeatmapInfo?.BeatmapSet?.OnlineInfo?.Covers.Cover != null)
|
||||
texture = textures.Get(BeatmapInfo.BeatmapSet.OnlineInfo.Covers.Cover);
|
||||
|
||||
Sprite.Texture = texture ?? beatmaps.DefaultBeatmap.Background;
|
||||
}
|
||||
|
||||
public override bool Equals(Background? other)
|
||||
{
|
||||
if (ReferenceEquals(null, other)) return false;
|
||||
if (ReferenceEquals(this, other)) return true;
|
||||
|
||||
return other.GetType() == GetType()
|
||||
&& ((PlaylistItemBackground)other).BeatmapInfo == BeatmapInfo;
|
||||
}
|
||||
}
|
||||
}
|
@ -3,7 +3,6 @@
|
||||
|
||||
using System.Threading.Tasks;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Game.Online.Rooms;
|
||||
|
||||
namespace osu.Game.Screens.OnlinePlay.Components
|
||||
@ -13,20 +12,14 @@ namespace osu.Game.Screens.OnlinePlay.Components
|
||||
/// </summary>
|
||||
public class SelectionPollingComponent : RoomPollingComponent
|
||||
{
|
||||
[Resolved]
|
||||
private Bindable<Room> selectedRoom { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private IRoomManager roomManager { get; set; }
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
private readonly Room room;
|
||||
|
||||
public SelectionPollingComponent(Room room)
|
||||
{
|
||||
selectedRoom.BindValueChanged(_ =>
|
||||
{
|
||||
if (IsLoaded)
|
||||
PollImmediately();
|
||||
});
|
||||
this.room = room;
|
||||
}
|
||||
|
||||
private GetRoomRequest pollReq;
|
||||
@ -36,13 +29,13 @@ namespace osu.Game.Screens.OnlinePlay.Components
|
||||
if (!API.IsLoggedIn)
|
||||
return base.Poll();
|
||||
|
||||
if (selectedRoom.Value?.RoomID.Value == null)
|
||||
if (room.RoomID.Value == null)
|
||||
return base.Poll();
|
||||
|
||||
var tcs = new TaskCompletionSource<bool>();
|
||||
|
||||
pollReq?.Cancel();
|
||||
pollReq = new GetRoomRequest(selectedRoom.Value.RoomID.Value.Value);
|
||||
pollReq = new GetRoomRequest(room.RoomID.Value.Value);
|
||||
|
||||
pollReq.Success += result =>
|
||||
{
|
||||
|
@ -23,16 +23,13 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
{
|
||||
public class RoomsContainer : CompositeDrawable, IKeyBindingHandler<GlobalAction>
|
||||
{
|
||||
private readonly IBindableList<Room> rooms = new BindableList<Room>();
|
||||
|
||||
private readonly FillFlowContainer<DrawableLoungeRoom> roomFlow;
|
||||
public readonly Bindable<Room> SelectedRoom = new Bindable<Room>();
|
||||
public readonly Bindable<FilterCriteria> Filter = new Bindable<FilterCriteria>();
|
||||
|
||||
public IReadOnlyList<DrawableRoom> Rooms => roomFlow.FlowingChildren.Cast<DrawableRoom>().ToArray();
|
||||
|
||||
public readonly Bindable<FilterCriteria> Filter = new Bindable<FilterCriteria>();
|
||||
|
||||
[Resolved]
|
||||
private Bindable<Room> selectedRoom { get; set; }
|
||||
private readonly IBindableList<Room> rooms = new BindableList<Room>();
|
||||
private readonly FillFlowContainer<DrawableLoungeRoom> roomFlow;
|
||||
|
||||
[Resolved]
|
||||
private IRoomManager roomManager { get; set; }
|
||||
@ -112,9 +109,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
private void addRooms(IEnumerable<Room> rooms)
|
||||
{
|
||||
foreach (var room in rooms)
|
||||
{
|
||||
roomFlow.Add(new DrawableLoungeRoom(room));
|
||||
}
|
||||
roomFlow.Add(new DrawableLoungeRoom(room) { SelectedRoom = { BindTarget = SelectedRoom } });
|
||||
|
||||
applyFilterCriteria(Filter?.Value);
|
||||
}
|
||||
@ -126,8 +121,8 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
roomFlow.RemoveAll(d => d.Room == r);
|
||||
|
||||
// selection may have a lease due to being in a sub screen.
|
||||
if (!selectedRoom.Disabled)
|
||||
selectedRoom.Value = null;
|
||||
if (!SelectedRoom.Disabled)
|
||||
SelectedRoom.Value = null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -139,8 +134,8 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
|
||||
protected override bool OnClick(ClickEvent e)
|
||||
{
|
||||
if (!selectedRoom.Disabled)
|
||||
selectedRoom.Value = null;
|
||||
if (!SelectedRoom.Disabled)
|
||||
SelectedRoom.Value = null;
|
||||
return base.OnClick(e);
|
||||
}
|
||||
|
||||
@ -202,26 +197,26 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
|
||||
private void selectNext(int direction)
|
||||
{
|
||||
if (selectedRoom.Disabled)
|
||||
if (SelectedRoom.Disabled)
|
||||
return;
|
||||
|
||||
var visibleRooms = Rooms.AsEnumerable().Where(r => r.IsPresent);
|
||||
|
||||
Room room;
|
||||
|
||||
if (selectedRoom.Value == null)
|
||||
if (SelectedRoom.Value == null)
|
||||
room = visibleRooms.FirstOrDefault()?.Room;
|
||||
else
|
||||
{
|
||||
if (direction < 0)
|
||||
visibleRooms = visibleRooms.Reverse();
|
||||
|
||||
room = visibleRooms.SkipWhile(r => r.Room != selectedRoom.Value).Skip(1).FirstOrDefault()?.Room;
|
||||
room = visibleRooms.SkipWhile(r => r.Room != SelectedRoom.Value).Skip(1).FirstOrDefault()?.Room;
|
||||
}
|
||||
|
||||
// we already have a valid selection only change selection if we still have a room to switch to.
|
||||
if (room != null)
|
||||
selectedRoom.Value = room;
|
||||
SelectedRoom.Value = room;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -34,11 +34,10 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
|
||||
private const float transition_duration = 60;
|
||||
private const float selection_border_width = 4;
|
||||
|
||||
[Resolved(canBeNull: true)]
|
||||
private LoungeSubScreen lounge { get; set; }
|
||||
public readonly Bindable<Room> SelectedRoom = new Bindable<Room>();
|
||||
|
||||
[Resolved(canBeNull: true)]
|
||||
private Bindable<Room> selectedRoom { get; set; }
|
||||
private LoungeSubScreen lounge { get; set; }
|
||||
|
||||
private Sample sampleSelect;
|
||||
private Sample sampleJoin;
|
||||
@ -89,7 +88,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
|
||||
else
|
||||
Alpha = 0;
|
||||
|
||||
selectedRoom.BindValueChanged(updateSelectedRoom, true);
|
||||
SelectedRoom.BindValueChanged(updateSelectedRoom, true);
|
||||
}
|
||||
|
||||
private void updateSelectedRoom(ValueChangedEvent<Room> selected)
|
||||
@ -135,7 +134,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
|
||||
|
||||
public bool OnPressed(GlobalAction action)
|
||||
{
|
||||
if (selectedRoom.Value != Room)
|
||||
if (SelectedRoom.Value != Room)
|
||||
return false;
|
||||
|
||||
switch (action)
|
||||
@ -152,14 +151,14 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
|
||||
{
|
||||
}
|
||||
|
||||
protected override bool ShouldBeConsideredForInput(Drawable child) => selectedRoom.Value == Room || child is HoverSounds;
|
||||
protected override bool ShouldBeConsideredForInput(Drawable child) => SelectedRoom.Value == Room || child is HoverSounds;
|
||||
|
||||
protected override bool OnClick(ClickEvent e)
|
||||
{
|
||||
if (Room != selectedRoom.Value)
|
||||
if (Room != SelectedRoom.Value)
|
||||
{
|
||||
sampleSelect?.Play();
|
||||
selectedRoom.Value = Room;
|
||||
SelectedRoom.Value = Room;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
43
osu.Game/Screens/OnlinePlay/Lounge/LoungeBackgroundScreen.cs
Normal file
43
osu.Game/Screens/OnlinePlay/Lounge/LoungeBackgroundScreen.cs
Normal file
@ -0,0 +1,43 @@
|
||||
// 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.
|
||||
|
||||
#nullable enable
|
||||
|
||||
using System.Linq;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osu.Game.Screens.OnlinePlay.Components;
|
||||
using PlaylistItem = osu.Game.Online.Rooms.PlaylistItem;
|
||||
|
||||
namespace osu.Game.Screens.OnlinePlay.Lounge
|
||||
{
|
||||
public class LoungeBackgroundScreen : OnlinePlayBackgroundScreen
|
||||
{
|
||||
public readonly Bindable<Room> SelectedRoom = new Bindable<Room>();
|
||||
private readonly BindableList<PlaylistItem> playlist = new BindableList<PlaylistItem>();
|
||||
|
||||
public LoungeBackgroundScreen()
|
||||
{
|
||||
SelectedRoom.BindValueChanged(onSelectedRoomChanged);
|
||||
playlist.BindCollectionChanged((_, __) => PlaylistItem = playlist.FirstOrDefault());
|
||||
}
|
||||
|
||||
private void onSelectedRoomChanged(ValueChangedEvent<Room> room)
|
||||
{
|
||||
if (room.OldValue != null)
|
||||
playlist.UnbindFrom(room.OldValue.Playlist);
|
||||
|
||||
if (room.NewValue != null)
|
||||
playlist.BindTo(room.NewValue.Playlist);
|
||||
else
|
||||
playlist.Clear();
|
||||
}
|
||||
|
||||
public override bool OnExiting(IScreen next)
|
||||
{
|
||||
// This screen never exits.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@ -36,6 +36,11 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
|
||||
{
|
||||
public override string Title => "Lounge";
|
||||
|
||||
protected override BackgroundScreen CreateBackground() => new LoungeBackgroundScreen
|
||||
{
|
||||
SelectedRoom = { BindTarget = SelectedRoom }
|
||||
};
|
||||
|
||||
protected override UserActivity InitialActivity => new UserActivity.SearchingForLobby();
|
||||
|
||||
protected Container<OsuButton> Buttons { get; } = new Container<OsuButton>
|
||||
@ -47,8 +52,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
|
||||
|
||||
protected ListingPollingComponent ListingPollingComponent { get; private set; }
|
||||
|
||||
[Resolved]
|
||||
private Bindable<Room> selectedRoom { get; set; }
|
||||
protected readonly Bindable<Room> SelectedRoom = new Bindable<Room>();
|
||||
|
||||
[Resolved]
|
||||
private MusicController music { get; set; }
|
||||
@ -101,7 +105,8 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
|
||||
ScrollbarOverlapsContent = false,
|
||||
Child = roomsContainer = new RoomsContainer
|
||||
{
|
||||
Filter = { BindTarget = filter }
|
||||
Filter = { BindTarget = filter },
|
||||
SelectedRoom = { BindTarget = SelectedRoom }
|
||||
}
|
||||
},
|
||||
},
|
||||
@ -160,7 +165,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
|
||||
};
|
||||
|
||||
// scroll selected room into view on selection.
|
||||
selectedRoom.BindValueChanged(val =>
|
||||
SelectedRoom.BindValueChanged(val =>
|
||||
{
|
||||
var drawable = roomsContainer.Rooms.FirstOrDefault(r => r.Room == val.NewValue);
|
||||
if (drawable != null)
|
||||
@ -243,8 +248,8 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
|
||||
selectionLease.Return();
|
||||
selectionLease = null;
|
||||
|
||||
if (selectedRoom.Value?.RoomID.Value == null)
|
||||
selectedRoom.Value = new Room();
|
||||
if (SelectedRoom.Value?.RoomID.Value == null)
|
||||
SelectedRoom.Value = new Room();
|
||||
|
||||
music?.EnsurePlayingSomething();
|
||||
|
||||
@ -317,7 +322,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
|
||||
|
||||
protected virtual void OpenNewRoom(Room room)
|
||||
{
|
||||
selectionLease = selectedRoom.BeginLease(false);
|
||||
selectionLease = SelectedRoom.BeginLease(false);
|
||||
Debug.Assert(selectionLease != null);
|
||||
selectionLease.Value = room;
|
||||
|
||||
|
@ -9,6 +9,7 @@ using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Input.Bindings;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
@ -27,8 +28,12 @@ namespace osu.Game.Screens.OnlinePlay.Match.Components
|
||||
|
||||
protected abstract bool IsLoading { get; }
|
||||
|
||||
protected RoomSettingsOverlay()
|
||||
private readonly Room room;
|
||||
|
||||
protected RoomSettingsOverlay(Room room)
|
||||
{
|
||||
this.room = room;
|
||||
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
Masking = true;
|
||||
CornerRadius = 10;
|
||||
@ -37,12 +42,12 @@ namespace osu.Game.Screens.OnlinePlay.Match.Components
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
Add(Settings = CreateSettings());
|
||||
Add(Settings = CreateSettings(room));
|
||||
}
|
||||
|
||||
protected abstract void SelectBeatmap();
|
||||
|
||||
protected abstract OnlinePlayComposite CreateSettings();
|
||||
protected abstract OnlinePlayComposite CreateSettings(Room room);
|
||||
|
||||
protected override void PopIn()
|
||||
{
|
||||
|
@ -6,6 +6,7 @@ using JetBrains.Annotations;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Beatmaps.Drawables;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osu.Game.Screens.OnlinePlay.Lounge.Components;
|
||||
@ -17,6 +18,7 @@ namespace osu.Game.Screens.OnlinePlay.Match
|
||||
{
|
||||
public class DrawableMatchRoom : DrawableRoom
|
||||
{
|
||||
public readonly IBindable<PlaylistItem> SelectedItem = new Bindable<PlaylistItem>();
|
||||
public Action OnEdit;
|
||||
|
||||
[Resolved]
|
||||
@ -28,6 +30,8 @@ namespace osu.Game.Screens.OnlinePlay.Match
|
||||
[CanBeNull]
|
||||
private Drawable editButton;
|
||||
|
||||
private BackgroundSprite background;
|
||||
|
||||
public DrawableMatchRoom(Room room, bool allowEdit = true)
|
||||
: base(room)
|
||||
{
|
||||
@ -57,8 +61,15 @@ namespace osu.Game.Screens.OnlinePlay.Match
|
||||
|
||||
if (editButton != null)
|
||||
host.BindValueChanged(h => editButton.Alpha = h.NewValue?.Equals(api.LocalUser.Value) == true ? 1 : 0, true);
|
||||
|
||||
SelectedItem.BindValueChanged(item => background.Beatmap.Value = item.NewValue?.Beatmap.Value, true);
|
||||
}
|
||||
|
||||
protected override Drawable CreateBackground() => new RoomBackgroundSprite();
|
||||
protected override Drawable CreateBackground() => background = new BackgroundSprite();
|
||||
|
||||
private class BackgroundSprite : UpdateableBeatmapBackgroundSprite
|
||||
{
|
||||
protected override double LoadDelay => 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
20
osu.Game/Screens/OnlinePlay/Match/RoomBackgroundScreen.cs
Normal file
20
osu.Game/Screens/OnlinePlay/Match/RoomBackgroundScreen.cs
Normal file
@ -0,0 +1,20 @@
|
||||
// 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.Bindables;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osu.Game.Screens.OnlinePlay.Components;
|
||||
|
||||
namespace osu.Game.Screens.OnlinePlay.Match
|
||||
{
|
||||
public class RoomBackgroundScreen : OnlinePlayBackgroundScreen
|
||||
{
|
||||
public readonly Bindable<PlaylistItem> SelectedItem = new Bindable<PlaylistItem>();
|
||||
|
||||
public RoomBackgroundScreen(PlaylistItem initialPlaylistItem)
|
||||
{
|
||||
PlaylistItem = initialPlaylistItem;
|
||||
SelectedItem.BindValueChanged(item => PlaylistItem = item.NewValue);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,33 +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.Graphics;
|
||||
using osu.Game.Beatmaps.Drawables;
|
||||
|
||||
namespace osu.Game.Screens.OnlinePlay.Match
|
||||
{
|
||||
public class RoomBackgroundSprite : RoomSubScreenComposite
|
||||
{
|
||||
protected readonly BeatmapSetCoverType BeatmapSetCoverType;
|
||||
private UpdateableBeatmapBackgroundSprite sprite;
|
||||
|
||||
public RoomBackgroundSprite(BeatmapSetCoverType beatmapSetCoverType = BeatmapSetCoverType.Cover)
|
||||
{
|
||||
BeatmapSetCoverType = beatmapSetCoverType;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
InternalChild = sprite = new UpdateableBeatmapBackgroundSprite(BeatmapSetCoverType) { RelativeSizeAxes = Axes.Both };
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
SelectedItem.BindValueChanged(item => sprite.Beatmap.Value = item.NewValue?.Beatmap.Value, true);
|
||||
}
|
||||
}
|
||||
}
|
@ -29,6 +29,11 @@ namespace osu.Game.Screens.OnlinePlay.Match
|
||||
[Cached(typeof(IBindable<PlaylistItem>))]
|
||||
protected readonly Bindable<PlaylistItem> SelectedItem = new Bindable<PlaylistItem>();
|
||||
|
||||
protected override BackgroundScreen CreateBackground() => new RoomBackgroundScreen(Room.Playlist.FirstOrDefault())
|
||||
{
|
||||
SelectedItem = { BindTarget = SelectedItem }
|
||||
};
|
||||
|
||||
public override bool DisallowExternalBeatmapRulesetChanges => true;
|
||||
|
||||
/// <summary>
|
||||
@ -134,7 +139,8 @@ namespace osu.Game.Screens.OnlinePlay.Match
|
||||
{
|
||||
new DrawableMatchRoom(Room, allowEdit)
|
||||
{
|
||||
OnEdit = () => settingsOverlay.Show()
|
||||
OnEdit = () => settingsOverlay.Show(),
|
||||
SelectedItem = { BindTarget = SelectedItem }
|
||||
}
|
||||
},
|
||||
null,
|
||||
@ -184,7 +190,7 @@ namespace osu.Game.Screens.OnlinePlay.Match
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
// Resolves 1px masking errors between the settings overlay and the room panel.
|
||||
Padding = new MarginPadding(-1),
|
||||
Child = settingsOverlay = CreateRoomSettingsOverlay()
|
||||
Child = settingsOverlay = CreateRoomSettingsOverlay(Room)
|
||||
}
|
||||
},
|
||||
},
|
||||
@ -244,6 +250,14 @@ namespace osu.Game.Screens.OnlinePlay.Match
|
||||
UserMods.BindValueChanged(_ => Scheduler.AddOnce(UpdateMods));
|
||||
}
|
||||
|
||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||
{
|
||||
return new CachedModelDependencyContainer<Room>(base.CreateChildDependencies(parent))
|
||||
{
|
||||
Model = { Value = Room }
|
||||
};
|
||||
}
|
||||
|
||||
public override bool OnBackButton()
|
||||
{
|
||||
if (Room.RoomID.Value == null)
|
||||
@ -412,7 +426,8 @@ namespace osu.Game.Screens.OnlinePlay.Match
|
||||
/// <summary>
|
||||
/// Creates the room settings overlay.
|
||||
/// </summary>
|
||||
protected abstract RoomSettingsOverlay CreateRoomSettingsOverlay();
|
||||
/// <param name="room">The room to change the settings of.</param>
|
||||
protected abstract RoomSettingsOverlay CreateRoomSettingsOverlay(Room room);
|
||||
|
||||
private class UserModSelectOverlay : LocalPlayerModSelectOverlay
|
||||
{
|
||||
|
@ -37,15 +37,19 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
||||
|
||||
protected override bool IsLoading => ongoingOperationTracker.InProgress.Value;
|
||||
|
||||
public MultiplayerMatchSettingsOverlay(Room room)
|
||||
: base(room)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void SelectBeatmap() => settings.SelectBeatmap();
|
||||
|
||||
protected override OnlinePlayComposite CreateSettings()
|
||||
=> settings = new MatchSettings
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
RelativePositionAxes = Axes.Y,
|
||||
SettingsApplied = Hide
|
||||
};
|
||||
protected override OnlinePlayComposite CreateSettings(Room room) => settings = new MatchSettings(room)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
RelativePositionAxes = Axes.Y,
|
||||
SettingsApplied = Hide
|
||||
};
|
||||
|
||||
protected class MatchSettings : OnlinePlayComposite
|
||||
{
|
||||
@ -73,9 +77,6 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
||||
[Resolved]
|
||||
private MultiplayerClient client { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private Bindable<Room> currentRoom { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private Bindable<WorkingBeatmap> beatmap { get; set; }
|
||||
|
||||
@ -90,6 +91,13 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
||||
[CanBeNull]
|
||||
private IDisposable applyingSettingsOperation;
|
||||
|
||||
private readonly Room room;
|
||||
|
||||
public MatchSettings(Room room)
|
||||
{
|
||||
this.room = room;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
@ -321,24 +329,24 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
||||
client.ChangeSettings(name: NameField.Text, password: PasswordTextBox.Text, matchType: TypePicker.Current.Value).ContinueWith(t => Schedule(() =>
|
||||
{
|
||||
if (t.IsCompletedSuccessfully)
|
||||
onSuccess(currentRoom.Value);
|
||||
onSuccess(room);
|
||||
else
|
||||
onError(t.Exception?.AsSingular().Message ?? "Error changing settings.");
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
currentRoom.Value.Name.Value = NameField.Text;
|
||||
currentRoom.Value.Availability.Value = AvailabilityPicker.Current.Value;
|
||||
currentRoom.Value.Type.Value = TypePicker.Current.Value;
|
||||
currentRoom.Value.Password.Value = PasswordTextBox.Current.Value;
|
||||
room.Name.Value = NameField.Text;
|
||||
room.Availability.Value = AvailabilityPicker.Current.Value;
|
||||
room.Type.Value = TypePicker.Current.Value;
|
||||
room.Password.Value = PasswordTextBox.Current.Value;
|
||||
|
||||
if (int.TryParse(MaxParticipantsField.Text, out int max))
|
||||
currentRoom.Value.MaxParticipants.Value = max;
|
||||
room.MaxParticipants.Value = max;
|
||||
else
|
||||
currentRoom.Value.MaxParticipants.Value = null;
|
||||
room.MaxParticipants.Value = null;
|
||||
|
||||
manager?.CreateRoom(currentRoom.Value, onSuccess, onError);
|
||||
manager?.CreateRoom(room, onSuccess, onError);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,9 +48,6 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
||||
[Resolved]
|
||||
private OngoingOperationTracker ongoingOperationTracker { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private Bindable<Room> currentRoom { get; set; } // Todo: This should not exist.
|
||||
|
||||
private readonly IBindable<bool> isConnected = new Bindable<bool>();
|
||||
|
||||
[CanBeNull]
|
||||
@ -81,17 +78,6 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
||||
if (!connected.NewValue)
|
||||
handleRoomLost();
|
||||
}, true);
|
||||
|
||||
currentRoom.BindValueChanged(room =>
|
||||
{
|
||||
if (room.NewValue == null)
|
||||
{
|
||||
// the room has gone away.
|
||||
// this could mean something happened during the join process, or an external connection issue occurred.
|
||||
// one specific scenario is where the underlying room is created, but the signalr server returns an error during the join process. this triggers a PartRoom operation (see https://github.com/ppy/osu/blob/7654df94f6f37b8382be7dfcb4f674e03bd35427/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerRoomManager.cs#L97)
|
||||
handleRoomLost();
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
protected override Drawable CreateMainContent() => new GridContainer
|
||||
@ -212,7 +198,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
||||
OnSpectateClick = onSpectateClick
|
||||
};
|
||||
|
||||
protected override RoomSettingsOverlay CreateRoomSettingsOverlay() => new MultiplayerMatchSettingsOverlay();
|
||||
protected override RoomSettingsOverlay CreateRoomSettingsOverlay(Room room) => new MultiplayerMatchSettingsOverlay(room);
|
||||
|
||||
protected override void UpdateMods()
|
||||
{
|
||||
|
@ -6,23 +6,15 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Drawables;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Screens.Menu;
|
||||
using osu.Game.Screens.OnlinePlay.Components;
|
||||
using osu.Game.Screens.OnlinePlay.Lounge;
|
||||
using osu.Game.Users;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.OnlinePlay
|
||||
{
|
||||
@ -45,9 +37,6 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
[Cached(Type = typeof(IRoomManager))]
|
||||
protected RoomManager RoomManager { get; private set; }
|
||||
|
||||
[Cached]
|
||||
private readonly Bindable<Room> selectedRoom = new Bindable<Room>();
|
||||
|
||||
[Cached]
|
||||
private readonly OngoingOperationTracker ongoingOperationTracker = new OngoingOperationTracker();
|
||||
|
||||
@ -78,38 +67,12 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
var backgroundColour = Color4Extensions.FromHex(@"3e3a44");
|
||||
|
||||
InternalChild = waves = new MultiplayerWaveContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = backgroundColour,
|
||||
},
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new BeatmapBackgroundSprite
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both
|
||||
},
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = ColourInfo.GradientVertical(Color4.Black.Opacity(0.9f), Color4.Black.Opacity(0.6f))
|
||||
},
|
||||
screenStack = new OnlinePlaySubScreenStack
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both
|
||||
}
|
||||
}
|
||||
},
|
||||
screenStack = new OnlinePlaySubScreenStack { RelativeSizeAxes = Axes.Both },
|
||||
new Header(ScreenTitle, screenStack),
|
||||
RoomManager,
|
||||
ongoingOperationTracker
|
||||
@ -139,13 +102,6 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
apiState.BindValueChanged(onlineStateChanged, true);
|
||||
}
|
||||
|
||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||
{
|
||||
var dependencies = new CachedModelDependencyContainer<Room>(base.CreateChildDependencies(parent));
|
||||
dependencies.Model.BindTo(selectedRoom);
|
||||
return dependencies;
|
||||
}
|
||||
|
||||
private void forcefullyExit()
|
||||
{
|
||||
// This is temporary since we don't currently have a way to force screens to be exited
|
||||
@ -276,51 +232,6 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
}
|
||||
}
|
||||
|
||||
private class BeatmapBackgroundSprite : OnlinePlayBackgroundSprite
|
||||
{
|
||||
protected override UpdateableBeatmapBackgroundSprite CreateBackgroundSprite() => new BlurredBackgroundSprite(BeatmapSetCoverType) { RelativeSizeAxes = Axes.Both };
|
||||
|
||||
public class BlurredBackgroundSprite : UpdateableBeatmapBackgroundSprite
|
||||
{
|
||||
public BlurredBackgroundSprite(BeatmapSetCoverType type)
|
||||
: base(type)
|
||||
{
|
||||
}
|
||||
|
||||
protected override double LoadDelay => 200;
|
||||
|
||||
protected override Drawable CreateDrawable(BeatmapInfo model) =>
|
||||
new BufferedLoader(base.CreateDrawable(model));
|
||||
}
|
||||
|
||||
// This class is an unfortunate requirement due to `LongRunningLoad` requiring direct async loading.
|
||||
// It means that if the web request fetching the beatmap background takes too long, it will suddenly appear.
|
||||
internal class BufferedLoader : BufferedContainer
|
||||
{
|
||||
private readonly Drawable drawable;
|
||||
|
||||
public BufferedLoader(Drawable drawable)
|
||||
{
|
||||
this.drawable = drawable;
|
||||
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
BlurSigma = new Vector2(10);
|
||||
FrameBufferScale = new Vector2(0.5f);
|
||||
CacheDrawnFrameBuffer = true;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
LoadComponentAsync(drawable, d =>
|
||||
{
|
||||
Add(d);
|
||||
ForceRedraw();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ScreenStack IHasSubScreenStack.SubScreenStack => screenStack;
|
||||
}
|
||||
}
|
||||
|
@ -29,23 +29,26 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
|
||||
public override void OnEntering(IScreen last)
|
||||
{
|
||||
base.OnEntering(last);
|
||||
this.FadeInFromZero(APPEAR_DURATION, Easing.OutQuint);
|
||||
}
|
||||
|
||||
public override bool OnExiting(IScreen next)
|
||||
{
|
||||
base.OnExiting(next);
|
||||
this.FadeOut(DISAPPEAR_DURATION, Easing.OutQuint);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void OnResuming(IScreen last)
|
||||
{
|
||||
base.OnResuming(last);
|
||||
this.FadeIn(APPEAR_DURATION, Easing.OutQuint);
|
||||
}
|
||||
|
||||
public override void OnSuspending(IScreen next)
|
||||
{
|
||||
base.OnSuspending(next);
|
||||
this.FadeOut(DISAPPEAR_DURATION, Easing.OutQuint);
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@ using System;
|
||||
using System.Collections.Specialized;
|
||||
using Humanizer;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
@ -32,15 +31,19 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
|
||||
|
||||
protected override bool IsLoading => settings.IsLoading; // should probably be replaced with an OngoingOperationTracker.
|
||||
|
||||
public PlaylistsRoomSettingsOverlay(Room room)
|
||||
: base(room)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void SelectBeatmap() => settings.SelectBeatmap();
|
||||
|
||||
protected override OnlinePlayComposite CreateSettings()
|
||||
=> settings = new MatchSettings
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
RelativePositionAxes = Axes.Y,
|
||||
EditPlaylist = () => EditPlaylist?.Invoke()
|
||||
};
|
||||
protected override OnlinePlayComposite CreateSettings(Room room) => settings = new MatchSettings(room)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
RelativePositionAxes = Axes.Y,
|
||||
EditPlaylist = () => EditPlaylist?.Invoke()
|
||||
};
|
||||
|
||||
protected class MatchSettings : OnlinePlayComposite
|
||||
{
|
||||
@ -66,8 +69,12 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
|
||||
[Resolved(CanBeNull = true)]
|
||||
private IRoomManager manager { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private Bindable<Room> currentRoom { get; set; }
|
||||
private readonly Room room;
|
||||
|
||||
public MatchSettings(Room room)
|
||||
{
|
||||
this.room = room;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
@ -333,7 +340,7 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
|
||||
|
||||
Duration.Value = DurationField.Current.Value;
|
||||
|
||||
manager?.CreateRoom(currentRoom.Value, onSuccess, onError);
|
||||
manager?.CreateRoom(room, onSuccess, onError);
|
||||
|
||||
loadingLayer.Show();
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
|
||||
if (idleTracker != null)
|
||||
isIdle.BindTo(idleTracker.IsIdle);
|
||||
|
||||
AddInternal(selectionPollingComponent = new SelectionPollingComponent());
|
||||
AddInternal(selectionPollingComponent = new SelectionPollingComponent(Room));
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
@ -184,7 +184,7 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
|
||||
OnStart = StartPlay
|
||||
};
|
||||
|
||||
protected override RoomSettingsOverlay CreateRoomSettingsOverlay() => new PlaylistsRoomSettingsOverlay
|
||||
protected override RoomSettingsOverlay CreateRoomSettingsOverlay(Room room) => new PlaylistsRoomSettingsOverlay(room)
|
||||
{
|
||||
EditPlaylist = () =>
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user