2018-05-22 03:07:04 +00:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
2018-12-10 09:35:08 +00:00
|
|
|
|
using osu.Framework.Configuration;
|
2018-05-22 03:07:04 +00:00
|
|
|
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2018-10-02 03:02:47 +00:00
|
|
|
|
using osu.Framework.Input.Events;
|
2018-05-22 03:24:39 +00:00
|
|
|
|
using osu.Framework.Screens;
|
2018-05-22 03:07:04 +00:00
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
|
|
|
|
using osu.Game.Online.Multiplayer;
|
|
|
|
|
using osu.Game.Overlays.SearchableList;
|
2018-12-10 10:20:41 +00:00
|
|
|
|
using osu.Game.Screens.Multi.Lounge.Components;
|
|
|
|
|
using osu.Game.Screens.Multi.Match;
|
2018-11-20 07:51:59 +00:00
|
|
|
|
using osuTK;
|
2018-05-22 03:07:04 +00:00
|
|
|
|
|
2018-12-10 10:20:41 +00:00
|
|
|
|
namespace osu.Game.Screens.Multi.Lounge
|
2018-05-22 03:07:04 +00:00
|
|
|
|
{
|
2018-12-10 10:20:41 +00:00
|
|
|
|
public class LoungeScreen : MultiplayerScreen
|
2018-05-22 03:07:04 +00:00
|
|
|
|
{
|
|
|
|
|
private readonly Container content;
|
2018-05-22 03:33:41 +00:00
|
|
|
|
private readonly SearchContainer search;
|
2018-05-22 03:07:04 +00:00
|
|
|
|
|
2018-05-22 04:22:23 +00:00
|
|
|
|
protected readonly FilterControl Filter;
|
|
|
|
|
protected readonly FillFlowContainer<DrawableRoom> RoomsContainer;
|
|
|
|
|
protected readonly RoomInspector Inspector;
|
2018-05-22 03:07:04 +00:00
|
|
|
|
|
2018-05-29 07:23:29 +00:00
|
|
|
|
public override string Title => "Lounge";
|
2018-05-28 04:02:06 +00:00
|
|
|
|
|
2018-12-10 09:35:08 +00:00
|
|
|
|
private Room roomBeingCreated;
|
|
|
|
|
private readonly IBindable<bool> roomCreated = new Bindable<bool>();
|
|
|
|
|
|
2018-12-07 07:20:05 +00:00
|
|
|
|
protected override Drawable TransitionContent => content;
|
2018-05-22 03:07:04 +00:00
|
|
|
|
|
2018-12-10 10:20:41 +00:00
|
|
|
|
public LoungeScreen()
|
2018-05-22 03:07:04 +00:00
|
|
|
|
{
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2018-12-03 09:30:26 +00:00
|
|
|
|
Filter = new FilterControl { Depth = -1 },
|
2018-05-22 03:07:04 +00:00
|
|
|
|
content = new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new ScrollContainer
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Width = 0.55f,
|
|
|
|
|
Padding = new MarginPadding
|
|
|
|
|
{
|
|
|
|
|
Vertical = 35 - DrawableRoom.SELECTION_BORDER_WIDTH,
|
|
|
|
|
Right = 20 - DrawableRoom.SELECTION_BORDER_WIDTH
|
|
|
|
|
},
|
2018-05-22 03:33:41 +00:00
|
|
|
|
Child = search = new SearchContainer
|
2018-05-22 03:07:04 +00:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
2018-05-22 04:22:23 +00:00
|
|
|
|
Child = RoomsContainer = new RoomsFilterContainer
|
2018-05-22 03:33:41 +00:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
|
Spacing = new Vector2(10 - DrawableRoom.SELECTION_BORDER_WIDTH * 2),
|
|
|
|
|
},
|
2018-05-22 03:07:04 +00:00
|
|
|
|
},
|
|
|
|
|
},
|
2018-05-22 04:22:23 +00:00
|
|
|
|
Inspector = new RoomInspector
|
2018-05-22 03:07:04 +00:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Width = 0.45f,
|
|
|
|
|
},
|
|
|
|
|
},
|
2018-12-03 09:30:26 +00:00
|
|
|
|
}
|
2018-05-22 03:07:04 +00:00
|
|
|
|
};
|
2018-05-22 03:24:39 +00:00
|
|
|
|
|
2018-05-22 04:22:23 +00:00
|
|
|
|
Filter.Search.Current.ValueChanged += s => filterRooms();
|
|
|
|
|
Filter.Tabs.Current.ValueChanged += t => filterRooms();
|
|
|
|
|
Filter.Search.Exit += Exit;
|
2018-12-10 09:35:08 +00:00
|
|
|
|
|
|
|
|
|
roomCreated.BindValueChanged(v =>
|
|
|
|
|
{
|
|
|
|
|
if (v)
|
|
|
|
|
addRoom(roomBeingCreated);
|
|
|
|
|
});
|
2018-05-22 03:07:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void UpdateAfterChildren()
|
|
|
|
|
{
|
|
|
|
|
base.UpdateAfterChildren();
|
|
|
|
|
|
|
|
|
|
content.Padding = new MarginPadding
|
|
|
|
|
{
|
2018-05-22 04:22:23 +00:00
|
|
|
|
Top = Filter.DrawHeight,
|
2018-05-22 03:07:04 +00:00
|
|
|
|
Left = SearchableListOverlay.WIDTH_PADDING - DrawableRoom.SELECTION_BORDER_WIDTH,
|
|
|
|
|
Right = SearchableListOverlay.WIDTH_PADDING,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-03 11:50:40 +00:00
|
|
|
|
public IEnumerable<Room> Rooms
|
|
|
|
|
{
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
RoomsContainer.ForEach(r => r.Action = null);
|
|
|
|
|
RoomsContainer.Clear();
|
|
|
|
|
|
|
|
|
|
foreach (var room in value)
|
|
|
|
|
addRoom(room);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private DrawableRoom addRoom(Room room)
|
|
|
|
|
{
|
|
|
|
|
var drawableRoom = new DrawableRoom(room);
|
|
|
|
|
|
2018-12-07 05:28:43 +00:00
|
|
|
|
drawableRoom.Action = () => selectionRequested(drawableRoom);
|
2018-12-03 11:50:40 +00:00
|
|
|
|
|
|
|
|
|
RoomsContainer.Add(drawableRoom);
|
|
|
|
|
|
|
|
|
|
filterRooms();
|
|
|
|
|
|
|
|
|
|
return drawableRoom;
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-02 03:02:47 +00:00
|
|
|
|
protected override void OnFocus(FocusEvent e)
|
2018-05-22 03:24:39 +00:00
|
|
|
|
{
|
2018-05-22 04:22:23 +00:00
|
|
|
|
GetContainingInputManager().ChangeFocus(Filter.Search);
|
2018-05-22 03:24:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnEntering(Screen last)
|
|
|
|
|
{
|
|
|
|
|
base.OnEntering(last);
|
2018-05-22 04:22:23 +00:00
|
|
|
|
Filter.Search.HoldFocus = true;
|
2018-05-22 03:24:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override bool OnExiting(Screen next)
|
|
|
|
|
{
|
2018-05-22 04:22:23 +00:00
|
|
|
|
Filter.Search.HoldFocus = false;
|
2018-05-22 03:24:39 +00:00
|
|
|
|
return base.OnExiting(next);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnResuming(Screen last)
|
|
|
|
|
{
|
|
|
|
|
base.OnResuming(last);
|
2018-12-04 06:25:41 +00:00
|
|
|
|
|
2018-05-22 04:22:23 +00:00
|
|
|
|
Filter.Search.HoldFocus = true;
|
2018-05-22 03:24:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnSuspending(Screen next)
|
|
|
|
|
{
|
|
|
|
|
base.OnSuspending(next);
|
2018-05-22 04:22:23 +00:00
|
|
|
|
Filter.Search.HoldFocus = false;
|
2018-05-22 03:24:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-05-22 03:33:41 +00:00
|
|
|
|
private void filterRooms()
|
|
|
|
|
{
|
2018-12-03 09:30:26 +00:00
|
|
|
|
if (Filter.Tabs.Current.Value == LoungeTab.Create)
|
2018-12-10 09:00:57 +00:00
|
|
|
|
{
|
2018-12-10 09:35:08 +00:00
|
|
|
|
roomBeingCreated = new Room();
|
|
|
|
|
|
|
|
|
|
roomCreated.UnbindBindings();
|
|
|
|
|
roomCreated.BindTo(roomBeingCreated.Created);
|
|
|
|
|
|
2018-12-10 09:00:57 +00:00
|
|
|
|
Filter.Tabs.Current.Value = LoungeTab.Public;
|
2018-12-10 09:35:08 +00:00
|
|
|
|
|
2018-12-10 10:20:41 +00:00
|
|
|
|
Push(new MatchScreen(roomBeingCreated));
|
2018-12-10 09:00:57 +00:00
|
|
|
|
}
|
2018-12-03 09:30:26 +00:00
|
|
|
|
|
2018-05-22 04:22:23 +00:00
|
|
|
|
search.SearchTerm = Filter.Search.Current.Value ?? string.Empty;
|
2018-05-22 03:33:41 +00:00
|
|
|
|
|
2018-05-22 04:22:23 +00:00
|
|
|
|
foreach (DrawableRoom r in RoomsContainer.Children)
|
2018-05-22 03:33:41 +00:00
|
|
|
|
{
|
2018-12-03 08:50:39 +00:00
|
|
|
|
r.MatchingFilter = r.MatchingFilter && r.Room.Availability.Value == Filter.Availability;
|
2018-05-22 03:33:41 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-04 06:26:06 +00:00
|
|
|
|
private void selectionRequested(DrawableRoom room)
|
2018-05-22 03:07:04 +00:00
|
|
|
|
{
|
2018-12-04 06:26:06 +00:00
|
|
|
|
if (room.State == SelectionState.Selected)
|
|
|
|
|
openRoom(room);
|
|
|
|
|
else
|
2018-05-22 03:07:04 +00:00
|
|
|
|
{
|
2018-12-04 06:26:06 +00:00
|
|
|
|
RoomsContainer.ForEach(c => c.State = c == room ? SelectionState.Selected : SelectionState.NotSelected);
|
|
|
|
|
Inspector.Room = room.Room;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-05-22 03:07:04 +00:00
|
|
|
|
|
2018-12-04 06:26:06 +00:00
|
|
|
|
private void openRoom(DrawableRoom room)
|
|
|
|
|
{
|
|
|
|
|
if (!IsCurrentScreen)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
RoomsContainer.ForEach(c => c.State = c == room ? SelectionState.Selected : SelectionState.NotSelected);
|
2018-05-22 04:22:23 +00:00
|
|
|
|
Inspector.Room = room.Room;
|
2018-05-22 03:07:04 +00:00
|
|
|
|
|
2018-12-10 10:20:41 +00:00
|
|
|
|
Push(new MatchScreen(room.Room));
|
2018-12-04 06:26:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-05-22 03:33:41 +00:00
|
|
|
|
private class RoomsFilterContainer : FillFlowContainer<DrawableRoom>, IHasFilterableChildren
|
|
|
|
|
{
|
|
|
|
|
public IEnumerable<string> FilterTerms => new string[] { };
|
|
|
|
|
public IEnumerable<IFilterable> FilterableChildren => Children;
|
|
|
|
|
|
|
|
|
|
public bool MatchingFilter
|
|
|
|
|
{
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value)
|
|
|
|
|
InvalidateLayout();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public RoomsFilterContainer()
|
|
|
|
|
{
|
|
|
|
|
LayoutDuration = 200;
|
|
|
|
|
LayoutEasing = Easing.OutQuint;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-05-22 03:07:04 +00:00
|
|
|
|
}
|
|
|
|
|
}
|