Basic Lounge functionality.

This commit is contained in:
DrabWeb
2018-05-22 00:07:04 -03:00
parent 1210368e29
commit cae09492c3
7 changed files with 312 additions and 29 deletions

View File

@ -9,6 +9,7 @@ using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input;
using osu.Framework.Localisation;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Drawables;
@ -25,8 +26,8 @@ namespace osu.Game.Screens.Multi.Components
{
public class DrawableRoom : OsuClickableContainer, IStateful<SelectionState>
{
public const float SELECTION_BORDER_WIDTH = 4;
private const float corner_radius = 5;
private const float selection_border_width = 4;
private const float transition_duration = 100;
private const float content_padding = 10;
private const float height = 100;
@ -62,6 +63,17 @@ namespace osu.Game.Screens.Multi.Components
}
}
private Action<DrawableRoom> action;
public new Action<DrawableRoom> Action
{
get { return action; }
set
{
action = value;
Enabled.Value = action != null;
}
}
public event Action<SelectionState> StateChanged;
public DrawableRoom(Room room)
@ -69,8 +81,8 @@ namespace osu.Game.Screens.Multi.Components
Room = room;
RelativeSizeAxes = Axes.X;
Height = height + selection_border_width * 2;
CornerRadius = corner_radius + selection_border_width / 2;
Height = height + SELECTION_BORDER_WIDTH * 2;
CornerRadius = corner_radius + SELECTION_BORDER_WIDTH / 2;
Masking = true;
// create selectionBox here so State can be set before being loaded
@ -79,8 +91,6 @@ namespace osu.Game.Screens.Multi.Components
RelativeSizeAxes = Axes.Both,
Alpha = 0f,
};
Action += () => State = SelectionState.Selected;
}
[BackgroundDependencyLoader]
@ -98,7 +108,7 @@ namespace osu.Game.Screens.Multi.Components
new Container
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding(selection_border_width),
Padding = new MarginPadding(SELECTION_BORDER_WIDTH),
Child = new Container
{
RelativeSizeAxes = Axes.Both,
@ -272,5 +282,16 @@ namespace osu.Game.Screens.Multi.Components
beatmapBind.BindTo(Room.Beatmap);
participantsBind.BindTo(Room.Participants);
}
protected override bool OnClick(InputState state)
{
if (Enabled.Value)
{
Action?.Invoke(this);
State = SelectionState.Selected;
}
return true;
}
}
}

View File

@ -25,7 +25,7 @@ namespace osu.Game.Screens.Multi
RelativeSizeAxes = Axes.Both,
};
Lobby lobby;
Lounge lounge;
Children = new Drawable[]
{
new Container
@ -52,12 +52,12 @@ namespace osu.Game.Screens.Multi
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Top = Header.HEIGHT },
Child = lobby = new Lobby(),
Child = lounge = new Lounge(),
},
new Header(lobby),
new Header(lounge),
};
lobby.Exited += s => Exit();
lounge.Exited += s => Exit();
}
protected override void OnEntering(Screen last)

View File

@ -1,16 +0,0 @@
// 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;
using System.Collections.Generic;
namespace osu.Game.Screens.Multi.Screens
{
public class Lobby : ScreenWhiteBox
{
protected override IEnumerable<Type> PossibleChildren => new[] {
typeof(MatchCreate),
typeof(Match)
};
}
}

View File

@ -0,0 +1,115 @@
// 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.Linq;
using System.Collections.Generic;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.Multiplayer;
using osu.Game.Overlays.SearchableList;
using osu.Game.Screens.Multi.Components;
using OpenTK;
namespace osu.Game.Screens.Multi.Screens
{
public class Lounge : MultiplayerScreen
{
private readonly Container content;
private readonly FillFlowContainer<DrawableRoom> roomsFlow;
private readonly RoomInspector roomInspector;
protected override Container<Drawable> TransitionContent => content;
public override string Title => "lounge";
public override string Name => "Lounge";
private IEnumerable<Room> rooms;
public IEnumerable<Room> Rooms
{
get { return rooms; }
set
{
if (Equals(value, rooms)) return;
rooms = value;
var enumerable = rooms.ToList();
roomsFlow.Children = enumerable.Select(r => new DrawableRoom(r)
{
Action = didSelect,
}).ToList();
if (!enumerable.Contains(roomInspector.Room))
roomInspector.Room = null;
}
}
public Lounge()
{
Children = new Drawable[]
{
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
},
Child = roomsFlow = new FillFlowContainer<DrawableRoom>
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
LayoutEasing = Easing.OutQuint,
LayoutDuration = 200,
Spacing = new Vector2(10 - DrawableRoom.SELECTION_BORDER_WIDTH * 2),
},
},
roomInspector = new RoomInspector
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
RelativeSizeAxes = Axes.Both,
Width = 0.45f,
},
},
},
};
}
protected override void UpdateAfterChildren()
{
base.UpdateAfterChildren();
content.Padding = new MarginPadding
{
Left = SearchableListOverlay.WIDTH_PADDING - DrawableRoom.SELECTION_BORDER_WIDTH,
Right = SearchableListOverlay.WIDTH_PADDING,
};
}
private void didSelect(DrawableRoom room)
{
roomsFlow.Children.ForEach(c =>
{
if (c != room)
c.State = SelectionState.NotSelected;
});
roomInspector.Room = room.Room;
// open the room if its selected and is clicked again
if (room.State == SelectionState.Selected)
Push(new Match(room.Room));
}
}
}

View File

@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using osu.Framework.Graphics;
using osu.Framework.Screens;
using osu.Game.Online.Multiplayer;
using osu.Game.Screens.Backgrounds;
using osu.Game.Screens.Play;
using osu.Game.Screens.Select;
@ -21,6 +22,10 @@ namespace osu.Game.Screens.Multi.Screens
protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg4");
public Match(Room room)
{
}
protected override void OnEntering(Screen last)
{
base.OnEntering(last);