2018-05-22 11:07:04 +08:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
2018-12-18 11:56:16 +08:00
|
|
|
|
using System;
|
2018-12-11 18:07:40 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
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;
|
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
|
|
|
|
{
|
2018-12-26 19:05:57 +08:00
|
|
|
|
public class LoungeSubScreen : MultiplayerSubScreen
|
2018-05-22 11:07:04 +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-11 18:07:40 +08:00
|
|
|
|
private readonly RoomsContainer rooms;
|
2018-12-18 11:56:16 +08:00
|
|
|
|
private readonly Action<Screen> pushGameplayScreen;
|
2018-12-26 20:10:31 +08:00
|
|
|
|
private readonly ProcessingOverlay processingOverlay;
|
2018-05-22 11:07:04 +08:00
|
|
|
|
|
2018-12-22 13:14:14 +08:00
|
|
|
|
[Resolved(CanBeNull = true)]
|
2018-12-25 10:45:50 +08:00
|
|
|
|
private IRoomManager roomManager { get; set; }
|
2018-05-22 11:07:04 +08:00
|
|
|
|
|
2018-05-29 15:23:29 +08:00
|
|
|
|
public override string Title => "Lounge";
|
2018-05-28 12:02:06 +08:00
|
|
|
|
|
2018-12-07 15:20:05 +08:00
|
|
|
|
protected override Drawable TransitionContent => content;
|
2018-05-22 11:07:04 +08:00
|
|
|
|
|
2018-12-26 19:05:57 +08:00
|
|
|
|
public LoungeSubScreen(Action<Screen> pushGameplayScreen)
|
2018-05-22 11:07:04 +08:00
|
|
|
|
{
|
2018-12-18 11:56:16 +08:00
|
|
|
|
this.pushGameplayScreen = pushGameplayScreen;
|
|
|
|
|
|
2018-12-11 18:07:40 +08:00
|
|
|
|
RoomInspector inspector;
|
|
|
|
|
|
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
|
|
|
|
{
|
2018-12-26 20:10:31 +08:00
|
|
|
|
new ScrollContainer
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
ScrollbarOverlapsContent = false,
|
|
|
|
|
Padding = new MarginPadding(10),
|
|
|
|
|
Child = new SearchContainer
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
Child = rooms = new RoomsContainer { JoinRequested = joinRequested }
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
processingOverlay = new ProcessingOverlay { Alpha = 0 }
|
|
|
|
|
}
|
2018-05-22 11:07:04 +08:00
|
|
|
|
},
|
2018-12-11 18:07:40 +08:00
|
|
|
|
inspector = 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
|
|
|
|
};
|
2018-05-22 11:24:39 +08:00
|
|
|
|
|
2018-12-20 19:58:34 +08:00
|
|
|
|
inspector.Room.BindTo(rooms.SelectedRoom);
|
2018-12-11 18:07:40 +08:00
|
|
|
|
|
2018-05-22 12:22:23 +08:00
|
|
|
|
Filter.Search.Current.ValueChanged += s => filterRooms();
|
|
|
|
|
Filter.Tabs.Current.ValueChanged += t => filterRooms();
|
2019-01-23 19:52:00 +08:00
|
|
|
|
Filter.Search.Exit += this.Exit;
|
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,
|
2018-05-22 11:07:04 +08:00
|
|
|
|
Left = SearchableListOverlay.WIDTH_PADDING - DrawableRoom.SELECTION_BORDER_WIDTH,
|
|
|
|
|
Right = SearchableListOverlay.WIDTH_PADDING,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-02 11:02:47 +08:00
|
|
|
|
protected override void OnFocus(FocusEvent e)
|
2018-05-22 11:24:39 +08:00
|
|
|
|
{
|
2018-05-22 12:22:23 +08:00
|
|
|
|
GetContainingInputManager().ChangeFocus(Filter.Search);
|
2018-05-22 11:24:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-01-23 19:52:00 +08:00
|
|
|
|
public override void OnEntering(IScreen last)
|
2018-05-22 11:24:39 +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-23 19:52:00 +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;
|
2018-12-26 19:05:57 +08:00
|
|
|
|
// no base call; don't animate
|
|
|
|
|
return false;
|
2018-05-22 11:24:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-01-23 19:52:00 +08:00
|
|
|
|
public override void OnSuspending(IScreen next)
|
2018-05-22 11:24:39 +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
|
|
|
|
}
|
|
|
|
|
|
2018-12-19 17:02:05 +08:00
|
|
|
|
private void filterRooms()
|
|
|
|
|
{
|
|
|
|
|
rooms.Filter(Filter.CreateCriteria());
|
2018-12-22 13:14:14 +08:00
|
|
|
|
roomManager?.Filter(Filter.CreateCriteria());
|
2018-12-19 17:02:05 +08:00
|
|
|
|
}
|
2018-05-22 11:33:41 +08:00
|
|
|
|
|
2018-12-26 20:10:31 +08:00
|
|
|
|
private void joinRequested(Room room)
|
|
|
|
|
{
|
|
|
|
|
processingOverlay.Show();
|
|
|
|
|
roomManager?.JoinRoom(room, r =>
|
|
|
|
|
{
|
2018-12-26 20:21:26 +08:00
|
|
|
|
Push(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>
|
|
|
|
|
public void Push(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-01-23 19:52:00 +08:00
|
|
|
|
this.Push(new MatchSubScreen(room, s => pushGameplayScreen?.Invoke(s)));
|
2018-05-22 11:33:41 +08:00
|
|
|
|
}
|
2018-05-22 11:07:04 +08:00
|
|
|
|
}
|
|
|
|
|
}
|