2019-01-24 16:43:03 +08:00
|
|
|
|
// 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.
|
2018-05-22 11:07:04 +08:00
|
|
|
|
|
2019-02-08 14:20:11 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2019-02-21 18:04:31 +08:00
|
|
|
|
using osu.Framework.Bindables;
|
2018-05-22 11:07:04 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2018-10-02 11:02:47 +08:00
|
|
|
|
using osu.Framework.Input.Events;
|
2018-05-22 11:24:39 +08:00
|
|
|
|
using osu.Framework.Screens;
|
2019-06-14 14:55:32 +08:00
|
|
|
|
using osu.Game.Graphics.Containers;
|
2018-12-26 20:10:31 +08:00
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2018-05-22 11:07:04 +08:00
|
|
|
|
using osu.Game.Online.Multiplayer;
|
|
|
|
|
using osu.Game.Overlays.SearchableList;
|
2018-12-10 18:20:41 +08:00
|
|
|
|
using osu.Game.Screens.Multi.Lounge.Components;
|
|
|
|
|
using osu.Game.Screens.Multi.Match;
|
2018-05-22 11:07:04 +08:00
|
|
|
|
|
2018-12-10 18:20:41 +08:00
|
|
|
|
namespace osu.Game.Screens.Multi.Lounge
|
2018-05-22 11:07:04 +08:00
|
|
|
|
{
|
2019-01-25 18:32:37 +08:00
|
|
|
|
public class LoungeSubScreen : MultiplayerSubScreen
|
2018-05-22 11:07:04 +08:00
|
|
|
|
{
|
2019-01-25 18:32:37 +08:00
|
|
|
|
public override string Title => "Lounge";
|
2019-01-25 16:44:33 +08:00
|
|
|
|
|
2018-12-11 18:07:40 +08:00
|
|
|
|
protected readonly FilterControl Filter;
|
|
|
|
|
|
2018-05-22 11:07:04 +08:00
|
|
|
|
private readonly Container content;
|
2018-12-26 20:10:31 +08:00
|
|
|
|
private readonly ProcessingOverlay processingOverlay;
|
2018-05-22 11:07:04 +08:00
|
|
|
|
|
2019-02-08 14:20:11 +08:00
|
|
|
|
[Resolved]
|
|
|
|
|
private Bindable<Room> currentRoom { get; set; }
|
|
|
|
|
|
2019-02-11 18:11:34 +08:00
|
|
|
|
public LoungeSubScreen()
|
2018-05-22 11:07:04 +08:00
|
|
|
|
{
|
2019-01-23 19:52:00 +08:00
|
|
|
|
InternalChildren = new Drawable[]
|
2018-05-22 11:07:04 +08:00
|
|
|
|
{
|
2018-12-03 17:30:26 +08:00
|
|
|
|
Filter = new FilterControl { Depth = -1 },
|
2018-05-22 11:07:04 +08:00
|
|
|
|
content = new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2018-12-26 20:10:31 +08:00
|
|
|
|
new Container
|
2018-05-22 11:07:04 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Width = 0.55f,
|
2018-12-26 20:10:31 +08:00
|
|
|
|
Children = new Drawable[]
|
2018-05-22 11:07:04 +08:00
|
|
|
|
{
|
2019-06-14 14:55:32 +08:00
|
|
|
|
new OsuScrollContainer
|
2018-12-26 20:10:31 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
ScrollbarOverlapsContent = false,
|
|
|
|
|
Padding = new MarginPadding(10),
|
|
|
|
|
Child = new SearchContainer
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
2019-02-05 18:00:01 +08:00
|
|
|
|
Child = new RoomsContainer { JoinRequested = joinRequested }
|
2018-12-26 20:10:31 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
processingOverlay = new ProcessingOverlay { Alpha = 0 }
|
|
|
|
|
}
|
2018-05-22 11:07:04 +08:00
|
|
|
|
},
|
2019-02-05 18:00:01 +08:00
|
|
|
|
new RoomInspector
|
2018-05-22 11:07:04 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Width = 0.45f,
|
|
|
|
|
},
|
|
|
|
|
},
|
2018-12-11 18:07:40 +08:00
|
|
|
|
},
|
2018-05-22 11:07:04 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void UpdateAfterChildren()
|
|
|
|
|
{
|
|
|
|
|
base.UpdateAfterChildren();
|
|
|
|
|
|
|
|
|
|
content.Padding = new MarginPadding
|
|
|
|
|
{
|
2018-05-22 12:22:23 +08:00
|
|
|
|
Top = Filter.DrawHeight,
|
2019-02-11 18:11:34 +08:00
|
|
|
|
Left = SearchableListOverlay.WIDTH_PADDING - DrawableRoom.SELECTION_BORDER_WIDTH + HORIZONTAL_OVERFLOW_PADDING,
|
|
|
|
|
Right = SearchableListOverlay.WIDTH_PADDING + HORIZONTAL_OVERFLOW_PADDING,
|
2018-05-22 11:07:04 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-02 11:02:47 +08:00
|
|
|
|
protected override void OnFocus(FocusEvent e)
|
2018-05-22 11:24:39 +08:00
|
|
|
|
{
|
2019-01-25 18:20:08 +08:00
|
|
|
|
Filter.Search.TakeFocus();
|
2018-05-22 11:24:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-01-25 18:32:37 +08:00
|
|
|
|
public override void OnEntering(IScreen last)
|
2018-05-22 11:24:39 +08:00
|
|
|
|
{
|
2019-01-25 18:32:37 +08:00
|
|
|
|
base.OnEntering(last);
|
2018-05-22 12:22:23 +08:00
|
|
|
|
Filter.Search.HoldFocus = true;
|
2018-05-22 11:24:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-01-25 18:32:37 +08:00
|
|
|
|
public override bool OnExiting(IScreen next)
|
2018-05-22 11:24:39 +08:00
|
|
|
|
{
|
2018-05-22 12:22:23 +08:00
|
|
|
|
Filter.Search.HoldFocus = false;
|
2019-01-25 18:32:37 +08:00
|
|
|
|
return base.OnExiting(next);
|
2019-01-25 16:44:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-01-25 18:32:37 +08:00
|
|
|
|
public override void OnSuspending(IScreen next)
|
2019-01-25 16:44:33 +08:00
|
|
|
|
{
|
2019-01-25 18:32:37 +08:00
|
|
|
|
base.OnSuspending(next);
|
2018-05-22 12:22:23 +08:00
|
|
|
|
Filter.Search.HoldFocus = false;
|
2018-05-22 11:24:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-03-07 15:49:48 +08:00
|
|
|
|
public override void OnResuming(IScreen last)
|
|
|
|
|
{
|
|
|
|
|
base.OnResuming(last);
|
|
|
|
|
|
|
|
|
|
if (currentRoom.Value?.RoomID.Value == null)
|
|
|
|
|
currentRoom.Value = new Room();
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-26 20:10:31 +08:00
|
|
|
|
private void joinRequested(Room room)
|
|
|
|
|
{
|
|
|
|
|
processingOverlay.Show();
|
2019-02-11 18:11:34 +08:00
|
|
|
|
RoomManager?.JoinRoom(room, r =>
|
2018-12-26 20:10:31 +08:00
|
|
|
|
{
|
2019-02-05 18:00:01 +08:00
|
|
|
|
Open(room);
|
2018-12-26 20:10:31 +08:00
|
|
|
|
processingOverlay.Hide();
|
|
|
|
|
}, _ => processingOverlay.Hide());
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-26 19:21:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Push a room as a new subscreen.
|
|
|
|
|
/// </summary>
|
2019-02-05 18:00:01 +08:00
|
|
|
|
public void Open(Room room)
|
2018-12-04 14:26:06 +08:00
|
|
|
|
{
|
2018-12-11 18:07:40 +08:00
|
|
|
|
// Handles the case where a room is clicked 3 times in quick succession
|
2019-01-23 19:52:00 +08:00
|
|
|
|
if (!this.IsCurrentScreen())
|
2018-12-04 14:26:06 +08:00
|
|
|
|
return;
|
|
|
|
|
|
2019-02-08 14:20:11 +08:00
|
|
|
|
currentRoom.Value = room;
|
|
|
|
|
|
2019-02-11 18:11:34 +08:00
|
|
|
|
this.Push(new MatchSubScreen(room));
|
2018-05-22 11:33:41 +08:00
|
|
|
|
}
|
2018-05-22 11:07:04 +08:00
|
|
|
|
}
|
|
|
|
|
}
|