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-04-13 17:19:50 +08:00
|
|
|
|
2018-05-11 09:48:07 +08:00
|
|
|
using System;
|
2018-05-22 11:33:41 +08:00
|
|
|
using System.Collections.Generic;
|
2018-05-11 09:48:07 +08:00
|
|
|
using osu.Framework;
|
2018-04-13 17:19:50 +08:00
|
|
|
using osu.Framework.Allocation;
|
2019-02-21 18:04:31 +08:00
|
|
|
using osu.Framework.Bindables;
|
2018-04-13 17:19:50 +08:00
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
|
|
using osu.Framework.Graphics;
|
2021-07-06 19:04:32 +08:00
|
|
|
using osu.Framework.Graphics.Colour;
|
2018-04-13 17:19:50 +08:00
|
|
|
using osu.Framework.Graphics.Containers;
|
2020-12-25 23:50:00 +08:00
|
|
|
using osu.Framework.Graphics.Cursor;
|
2019-04-02 13:51:28 +08:00
|
|
|
using osu.Framework.Graphics.Effects;
|
2018-04-13 17:19:50 +08:00
|
|
|
using osu.Framework.Graphics.Shapes;
|
2020-12-25 23:50:00 +08:00
|
|
|
using osu.Framework.Graphics.UserInterface;
|
2018-04-13 17:19:50 +08:00
|
|
|
using osu.Game.Beatmaps;
|
2019-03-05 14:55:37 +08:00
|
|
|
using osu.Game.Beatmaps.Drawables;
|
2018-04-13 17:19:50 +08:00
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Graphics.Containers;
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2018-05-11 09:48:07 +08:00
|
|
|
using osu.Game.Graphics.UserInterface;
|
2020-12-25 23:50:00 +08:00
|
|
|
using osu.Game.Online.Rooms;
|
|
|
|
using osu.Game.Screens.OnlinePlay.Components;
|
2018-11-20 15:51:59 +08:00
|
|
|
using osuTK;
|
|
|
|
using osuTK.Graphics;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2020-12-25 23:50:00 +08:00
|
|
|
namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2020-08-10 07:16:01 +08:00
|
|
|
public class DrawableRoom : OsuClickableContainer, IStateful<SelectionState>, IFilterable, IHasContextMenu
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2018-05-22 11:07:04 +08:00
|
|
|
public const float SELECTION_BORDER_WIDTH = 4;
|
2021-07-06 19:04:32 +08:00
|
|
|
private const float corner_radius = 10;
|
2018-05-28 12:02:15 +08:00
|
|
|
private const float transition_duration = 60;
|
2021-07-06 19:04:32 +08:00
|
|
|
private const float height = 100;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2018-12-04 14:26:06 +08:00
|
|
|
public event Action<SelectionState> StateChanged;
|
|
|
|
|
2021-07-06 19:04:32 +08:00
|
|
|
private Drawable selectionBox;
|
2018-12-13 17:38:03 +08:00
|
|
|
|
2020-10-19 16:15:35 +08:00
|
|
|
[Resolved(canBeNull: true)]
|
2020-12-26 00:00:00 +08:00
|
|
|
private OnlinePlayScreen parentScreen { get; set; }
|
2020-10-19 16:15:35 +08:00
|
|
|
|
2018-12-06 11:21:30 +08:00
|
|
|
[Resolved]
|
|
|
|
private BeatmapManager beatmaps { get; set; }
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
public readonly Room Room;
|
|
|
|
|
2018-05-11 09:48:07 +08:00
|
|
|
private SelectionState state;
|
2019-02-28 12:31:40 +08:00
|
|
|
|
2018-05-11 09:48:07 +08:00
|
|
|
public SelectionState State
|
|
|
|
{
|
2019-02-28 12:58:19 +08:00
|
|
|
get => state;
|
2018-05-11 09:48:07 +08:00
|
|
|
set
|
|
|
|
{
|
2021-07-06 17:24:06 +08:00
|
|
|
if (value == state)
|
|
|
|
return;
|
2019-02-28 12:31:40 +08:00
|
|
|
|
2018-05-11 09:48:07 +08:00
|
|
|
state = value;
|
|
|
|
|
2021-07-06 17:24:06 +08:00
|
|
|
if (selectionBox != null)
|
|
|
|
{
|
|
|
|
if (state == SelectionState.Selected)
|
|
|
|
selectionBox.FadeIn(transition_duration);
|
|
|
|
else
|
|
|
|
selectionBox.FadeOut(transition_duration);
|
|
|
|
}
|
2018-05-11 09:48:07 +08:00
|
|
|
|
|
|
|
StateChanged?.Invoke(State);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-22 11:33:41 +08:00
|
|
|
public IEnumerable<string> FilterTerms => new[] { Room.Name.Value };
|
|
|
|
|
|
|
|
private bool matchingFilter;
|
2019-02-28 12:31:40 +08:00
|
|
|
|
2018-05-22 11:33:41 +08:00
|
|
|
public bool MatchingFilter
|
|
|
|
{
|
2019-02-28 12:58:19 +08:00
|
|
|
get => matchingFilter;
|
2018-05-22 11:33:41 +08:00
|
|
|
set
|
|
|
|
{
|
|
|
|
matchingFilter = value;
|
2019-11-15 16:49:02 +08:00
|
|
|
|
2020-02-06 10:59:33 +08:00
|
|
|
if (!IsLoaded)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (matchingFilter)
|
|
|
|
this.FadeIn(200);
|
|
|
|
else
|
|
|
|
Hide();
|
2018-05-22 11:33:41 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-13 14:10:44 +08:00
|
|
|
private int numberOfAvatars = 3;
|
|
|
|
|
|
|
|
public int NumberOfAvatars
|
|
|
|
{
|
|
|
|
get => numberOfAvatars;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
numberOfAvatars = value;
|
|
|
|
|
|
|
|
if (recentParticipantsList != null)
|
|
|
|
recentParticipantsList.NumberOfAvatars = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private RecentParticipantsList recentParticipantsList;
|
|
|
|
|
2019-03-28 23:29:07 +08:00
|
|
|
public bool FilteringActive { get; set; }
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
public DrawableRoom(Room room)
|
|
|
|
{
|
|
|
|
Room = room;
|
|
|
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
2021-07-12 13:07:21 +08:00
|
|
|
Height = height;
|
2018-05-22 11:07:04 +08:00
|
|
|
CornerRadius = corner_radius + SELECTION_BORDER_WIDTH / 2;
|
2018-04-13 17:19:50 +08:00
|
|
|
Masking = true;
|
2018-05-11 09:12:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2018-05-29 10:33:13 +08:00
|
|
|
private void load(OsuColour colours)
|
2018-05-11 09:12:25 +08:00
|
|
|
{
|
2018-04-13 17:19:50 +08:00
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new Container
|
|
|
|
{
|
2021-07-06 19:04:32 +08:00
|
|
|
Name = @"Room content",
|
2018-05-11 09:48:07 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Child = new Container
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2018-05-11 09:48:07 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Masking = true,
|
|
|
|
CornerRadius = corner_radius,
|
|
|
|
EdgeEffect = new EdgeEffectParameters
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2018-05-11 09:48:07 +08:00
|
|
|
Type = EdgeEffectType.Shadow,
|
|
|
|
Colour = Color4.Black.Opacity(40),
|
|
|
|
Radius = 5,
|
2018-04-13 17:19:50 +08:00
|
|
|
},
|
2018-05-11 09:48:07 +08:00
|
|
|
Children = new Drawable[]
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2021-07-13 14:50:46 +08:00
|
|
|
// This resolves 1px gaps due to applying the (parenting) corner radius and masking across multiple filling background sprites.
|
|
|
|
new BufferedContainer
|
2021-07-12 15:30:34 +08:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2021-07-13 14:50:46 +08:00
|
|
|
Children = new Drawable[]
|
2021-07-12 13:07:21 +08:00
|
|
|
{
|
2021-07-13 14:50:46 +08:00
|
|
|
new Box
|
2021-07-12 13:07:21 +08:00
|
|
|
{
|
2021-07-13 14:50:46 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = Color4Extensions.FromHex(@"#27302E"),
|
|
|
|
},
|
|
|
|
new Container
|
|
|
|
{
|
|
|
|
Anchor = Anchor.CentreRight,
|
|
|
|
Origin = Anchor.CentreRight,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
FillMode = FillMode.Fill,
|
|
|
|
Child = new OnlinePlayBackgroundSprite(BeatmapSetCoverType.List) { RelativeSizeAxes = Axes.Both }
|
|
|
|
},
|
|
|
|
new GridContainer
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
ColumnDimensions = new[]
|
2021-07-12 13:07:21 +08:00
|
|
|
{
|
2021-07-13 14:50:46 +08:00
|
|
|
new Dimension(GridSizeMode.Relative, 0.2f)
|
2021-07-12 13:07:21 +08:00
|
|
|
},
|
2021-07-13 14:50:46 +08:00
|
|
|
Content = new[]
|
2021-07-12 13:07:21 +08:00
|
|
|
{
|
2021-07-13 14:50:46 +08:00
|
|
|
new Drawable[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = Color4Extensions.FromHex(@"#27302E"),
|
|
|
|
},
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = ColourInfo.GradientHorizontal(Color4Extensions.FromHex(@"#27302E"), Color4Extensions.FromHex(@"#27302E").Opacity(0.3f))
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2021-07-12 13:07:21 +08:00
|
|
|
}
|
2021-07-06 19:04:32 +08:00
|
|
|
},
|
2018-05-11 09:48:07 +08:00
|
|
|
new Container
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2021-07-06 19:04:32 +08:00
|
|
|
Name = @"Left details",
|
2018-05-11 09:48:07 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Padding = new MarginPadding
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2021-07-06 19:04:32 +08:00
|
|
|
Left = 20,
|
|
|
|
Vertical = 5
|
2018-04-13 17:19:50 +08:00
|
|
|
},
|
2018-05-11 09:48:07 +08:00
|
|
|
Children = new Drawable[]
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2021-07-12 14:11:53 +08:00
|
|
|
new FillFlowContainer
|
|
|
|
{
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
Spacing = new Vector2(4),
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new RoomStatusPill
|
|
|
|
{
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
Origin = Anchor.CentreLeft
|
|
|
|
},
|
|
|
|
new EndDateInfo
|
|
|
|
{
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
Origin = Anchor.CentreLeft
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
2021-07-12 15:28:22 +08:00
|
|
|
new FillFlowContainer
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2021-07-06 19:04:32 +08:00
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
Origin = Anchor.CentreLeft,
|
2021-07-12 15:28:22 +08:00
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new RoomNameText(),
|
|
|
|
new RoomHostText()
|
|
|
|
}
|
2018-05-11 09:48:07 +08:00
|
|
|
},
|
|
|
|
new FillFlowContainer
|
|
|
|
{
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
Origin = Anchor.BottomLeft,
|
2021-07-06 19:04:32 +08:00
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
Direction = FillDirection.Horizontal,
|
2021-07-12 14:11:07 +08:00
|
|
|
Spacing = new Vector2(4),
|
2018-05-11 09:48:07 +08:00
|
|
|
Children = new Drawable[]
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2021-07-12 14:11:53 +08:00
|
|
|
new PlaylistCountPill
|
2021-07-12 14:11:07 +08:00
|
|
|
{
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
},
|
|
|
|
new StarRatingRangeDisplay
|
|
|
|
{
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
Scale = new Vector2(0.85f)
|
|
|
|
}
|
2021-07-06 19:04:32 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
},
|
2021-07-13 14:10:44 +08:00
|
|
|
new FillFlowContainer
|
|
|
|
{
|
|
|
|
Name = "Right content",
|
|
|
|
Anchor = Anchor.CentreRight,
|
|
|
|
Origin = Anchor.CentreRight,
|
|
|
|
AutoSizeAxes = Axes.X,
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
Padding = new MarginPadding
|
|
|
|
{
|
|
|
|
Right = 10,
|
|
|
|
Vertical = 5
|
|
|
|
},
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
recentParticipantsList = new RecentParticipantsList
|
|
|
|
{
|
|
|
|
Anchor = Anchor.CentreRight,
|
|
|
|
Origin = Anchor.CentreRight,
|
|
|
|
NumberOfAvatars = NumberOfAvatars
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-06 19:04:32 +08:00
|
|
|
new StatusColouredContainer(transition_duration)
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Child = selectionBox = new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Alpha = state == SelectionState.Selected ? 1 : 0,
|
|
|
|
Masking = true,
|
|
|
|
CornerRadius = corner_radius,
|
|
|
|
BorderThickness = SELECTION_BORDER_WIDTH,
|
|
|
|
BorderColour = Color4.White,
|
|
|
|
Child = new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Alpha = 0,
|
|
|
|
AlwaysPresent = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2018-04-13 17:19:50 +08:00
|
|
|
};
|
|
|
|
}
|
2018-05-22 11:07:04 +08:00
|
|
|
|
2019-02-05 18:00:01 +08:00
|
|
|
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
|
|
|
{
|
2021-06-01 13:33:21 +08:00
|
|
|
return new CachedModelDependencyContainer<Room>(base.CreateChildDependencies(parent))
|
|
|
|
{
|
|
|
|
Model = { Value = Room }
|
|
|
|
};
|
2019-02-05 18:00:01 +08:00
|
|
|
}
|
|
|
|
|
2018-05-27 13:12:20 +08:00
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
2019-11-15 16:49:02 +08:00
|
|
|
|
|
|
|
if (matchingFilter)
|
|
|
|
this.FadeInFromZero(transition_duration);
|
|
|
|
else
|
|
|
|
Alpha = 0;
|
2018-05-27 13:12:20 +08:00
|
|
|
}
|
2019-02-06 12:52:48 +08:00
|
|
|
|
2020-07-13 13:24:11 +08:00
|
|
|
protected override bool ShouldBeConsideredForInput(Drawable child) => state == SelectionState.Selected;
|
|
|
|
|
2021-07-12 15:28:22 +08:00
|
|
|
private class RoomNameText : OsuSpriteText
|
2019-02-06 12:52:48 +08:00
|
|
|
{
|
2020-12-25 12:38:11 +08:00
|
|
|
[Resolved(typeof(Room), nameof(Online.Rooms.Room.Name))]
|
2019-02-06 12:52:48 +08:00
|
|
|
private Bindable<string> name { get; set; }
|
|
|
|
|
2021-07-12 15:28:22 +08:00
|
|
|
public RoomNameText()
|
|
|
|
{
|
|
|
|
Font = OsuFont.GetFont(size: 24);
|
|
|
|
}
|
|
|
|
|
2019-02-06 12:52:48 +08:00
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
|
|
|
Current = name;
|
|
|
|
}
|
|
|
|
}
|
2020-08-10 07:16:01 +08:00
|
|
|
|
2021-07-12 15:28:22 +08:00
|
|
|
private class RoomHostText : OnlinePlayComposite
|
|
|
|
{
|
|
|
|
private LinkFlowContainer hostText;
|
|
|
|
|
|
|
|
public RoomHostText()
|
|
|
|
{
|
|
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
|
|
|
InternalChild = hostText = new LinkFlowContainer(s => s.Font = OsuFont.GetFont(size: 14))
|
|
|
|
{
|
|
|
|
AutoSizeAxes = Axes.Both
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
|
|
Host.BindValueChanged(host =>
|
|
|
|
{
|
|
|
|
hostText.Clear();
|
|
|
|
|
|
|
|
if (host.NewValue != null)
|
|
|
|
{
|
|
|
|
hostText.AddText("hosted by ");
|
|
|
|
hostText.AddUserLink(host.NewValue);
|
|
|
|
}
|
|
|
|
}, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-10 07:16:01 +08:00
|
|
|
public MenuItem[] ContextMenuItems => new MenuItem[]
|
|
|
|
{
|
2020-10-19 16:15:35 +08:00
|
|
|
new OsuMenuItem("Create copy", MenuItemType.Standard, () =>
|
|
|
|
{
|
2020-12-26 00:00:00 +08:00
|
|
|
parentScreen?.OpenNewRoom(Room.CreateCopy());
|
2020-10-19 16:15:35 +08:00
|
|
|
})
|
2020-08-10 07:16:01 +08:00
|
|
|
};
|
2018-04-13 17:19:50 +08:00
|
|
|
}
|
|
|
|
}
|