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;
|
2021-07-12 13:53:12 +08:00
|
|
|
using osu.Framework.Extensions;
|
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;
|
2021-07-14 16:46:32 +08:00
|
|
|
using osu.Framework.Graphics.Effects;
|
2018-04-13 17:19:50 +08:00
|
|
|
using osu.Framework.Graphics.Shapes;
|
2021-07-10 13:14:58 +08:00
|
|
|
using osu.Framework.Graphics.Sprites;
|
2020-12-25 23:50:00 +08:00
|
|
|
using osu.Framework.Graphics.UserInterface;
|
2021-07-11 09:13:57 +08:00
|
|
|
using osu.Framework.Input.Bindings;
|
|
|
|
using osu.Framework.Input.Events;
|
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;
|
2021-07-14 22:55:46 +08:00
|
|
|
using osu.Game.Graphics.UserInterfaceV2;
|
2021-07-11 09:13:57 +08:00
|
|
|
using osu.Game.Input.Bindings;
|
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
|
|
|
{
|
2021-07-11 09:13:57 +08:00
|
|
|
public class DrawableRoom : OsuClickableContainer, IStateful<SelectionState>, IFilterable, IHasContextMenu, IHasPopover, IKeyBindingHandler<GlobalAction>
|
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
|
|
|
|
2021-08-05 20:20:55 +08:00
|
|
|
private static readonly Color4 background_colour = Color4Extensions.FromHex(@"#27302E");
|
|
|
|
|
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)]
|
2021-07-14 17:55:01 +08:00
|
|
|
private LoungeSubScreen loungeScreen { get; set; }
|
2020-10-19 16:15:35 +08:00
|
|
|
|
2018-12-06 11:21:30 +08:00
|
|
|
[Resolved]
|
|
|
|
private BeatmapManager beatmaps { get; set; }
|
|
|
|
|
2021-07-12 13:35:08 +08:00
|
|
|
[Resolved(canBeNull: true)]
|
2021-07-11 09:13:57 +08:00
|
|
|
private Bindable<Room> selectedRoom { get; set; }
|
|
|
|
|
|
|
|
[Resolved(canBeNull: true)]
|
|
|
|
private LoungeSubScreen lounge { 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-08-05 20:02:14 +08:00
|
|
|
private int numberOfAvatars = 7;
|
2021-07-13 14:10:44 +08:00
|
|
|
|
|
|
|
public int NumberOfAvatars
|
|
|
|
{
|
|
|
|
get => numberOfAvatars;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
numberOfAvatars = value;
|
|
|
|
|
|
|
|
if (recentParticipantsList != null)
|
|
|
|
recentParticipantsList.NumberOfAvatars = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-14 15:48:53 +08:00
|
|
|
private readonly Bindable<RoomCategory> roomCategory = new Bindable<RoomCategory>();
|
|
|
|
|
2021-07-13 14:10:44 +08:00
|
|
|
private RecentParticipantsList recentParticipantsList;
|
2021-07-14 15:48:53 +08:00
|
|
|
private RoomSpecialCategoryPill specialCategoryPill;
|
2021-07-13 14:10:44 +08:00
|
|
|
|
2019-03-28 23:29:07 +08:00
|
|
|
public bool FilteringActive { get; set; }
|
|
|
|
|
2021-07-19 21:31:01 +08:00
|
|
|
private PasswordProtectedIcon passwordIcon;
|
|
|
|
|
|
|
|
private readonly Bindable<bool> hasPassword = new Bindable<bool>();
|
|
|
|
|
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;
|
2021-07-14 16:46:32 +08:00
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
Masking = true;
|
2021-07-14 16:46:32 +08:00
|
|
|
CornerRadius = corner_radius + SELECTION_BORDER_WIDTH / 2;
|
|
|
|
EdgeEffect = new EdgeEffectParameters
|
|
|
|
{
|
|
|
|
Type = EdgeEffectType.Shadow,
|
|
|
|
Colour = Color4.Black.Opacity(40),
|
|
|
|
Radius = 5,
|
|
|
|
};
|
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[]
|
|
|
|
{
|
2021-07-14 15:56:39 +08:00
|
|
|
// This resolves internal 1px gaps due to applying the (parenting) corner radius and masking across multiple filling background sprites.
|
|
|
|
new BufferedContainer
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2018-05-11 09:48:07 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
2021-07-14 15:48:53 +08:00
|
|
|
Children = new Drawable[]
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2021-07-14 15:56:39 +08:00
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2021-08-05 20:20:55 +08:00
|
|
|
Colour = background_colour,
|
2021-07-14 15:56:39 +08:00
|
|
|
},
|
2021-08-05 20:01:21 +08:00
|
|
|
new OnlinePlayBackgroundSprite(BeatmapSetCoverType.Cover)
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2021-07-14 15:48:53 +08:00
|
|
|
RelativeSizeAxes = Axes.Both
|
2018-04-13 17:19:50 +08:00
|
|
|
},
|
2021-07-14 15:56:39 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
new Container
|
|
|
|
{
|
|
|
|
Name = @"Room content",
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2021-08-05 20:19:23 +08:00
|
|
|
// This negative padding resolves 1px gaps between this background and the background above.
|
2021-07-14 15:56:39 +08:00
|
|
|
Padding = new MarginPadding { Left = 20, Vertical = -0.5f },
|
|
|
|
Child = new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Masking = true,
|
|
|
|
CornerRadius = corner_radius,
|
|
|
|
Children = new Drawable[]
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2021-07-14 15:56:39 +08:00
|
|
|
// This resolves internal 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-14 15:56:39 +08:00
|
|
|
new Box
|
2021-07-12 13:07:21 +08:00
|
|
|
{
|
2021-07-13 14:50:46 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
2021-08-05 20:20:55 +08:00
|
|
|
Colour = background_colour,
|
2021-07-14 15:56:39 +08:00
|
|
|
},
|
2021-08-04 12:49:13 +08:00
|
|
|
new OnlinePlayBackgroundSprite(BeatmapSetCoverType.Cover)
|
2021-07-14 15:56:39 +08:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both
|
|
|
|
},
|
|
|
|
new GridContainer
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
ColumnDimensions = new[]
|
2021-07-12 13:07:21 +08:00
|
|
|
{
|
2021-07-14 15:56:39 +08:00
|
|
|
new Dimension(GridSizeMode.Relative, 0.2f)
|
|
|
|
},
|
|
|
|
Content = new[]
|
|
|
|
{
|
|
|
|
new Drawable[]
|
2021-07-13 14:50:46 +08:00
|
|
|
{
|
2021-07-14 15:56:39 +08:00
|
|
|
new Box
|
2021-07-13 14:50:46 +08:00
|
|
|
{
|
2021-07-14 15:56:39 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
2021-08-05 20:20:55 +08:00
|
|
|
Colour = background_colour,
|
2021-07-13 14:50:46 +08:00
|
|
|
},
|
2021-07-14 15:56:39 +08:00
|
|
|
new Box
|
2021-07-13 14:50:46 +08:00
|
|
|
{
|
2021-07-14 15:56:39 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
2021-08-05 20:20:55 +08:00
|
|
|
Colour = ColourInfo.GradientHorizontal(background_colour, background_colour.Opacity(0.3f))
|
2021-07-14 15:56:39 +08:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
2021-07-13 14:50:46 +08:00
|
|
|
},
|
2021-07-14 15:56:39 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
new Container
|
|
|
|
{
|
|
|
|
Name = @"Left details",
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Padding = new MarginPadding
|
|
|
|
{
|
|
|
|
Left = 20,
|
|
|
|
Vertical = 5
|
|
|
|
},
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new FillFlowContainer
|
2021-07-12 14:11:53 +08:00
|
|
|
{
|
2021-07-14 15:56:39 +08:00
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
Direction = FillDirection.Horizontal,
|
2021-08-05 19:56:09 +08:00
|
|
|
Spacing = new Vector2(5),
|
2021-07-12 14:11:53 +08:00
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
2021-07-14 15:56:39 +08:00
|
|
|
new RoomStatusPill
|
2021-07-12 14:11:53 +08:00
|
|
|
{
|
2021-07-14 15:56:39 +08:00
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
Origin = Anchor.CentreLeft
|
2021-07-12 14:11:53 +08:00
|
|
|
},
|
2021-07-14 15:56:39 +08:00
|
|
|
specialCategoryPill = new RoomSpecialCategoryPill
|
2021-07-12 14:11:53 +08:00
|
|
|
{
|
|
|
|
Anchor = Anchor.CentreLeft,
|
2021-07-14 15:56:39 +08:00
|
|
|
Origin = Anchor.CentreLeft
|
2021-07-12 14:11:53 +08:00
|
|
|
},
|
2021-07-14 15:56:39 +08:00
|
|
|
new EndDateInfo
|
2021-07-14 15:48:53 +08:00
|
|
|
{
|
2021-07-14 15:56:39 +08:00
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
Origin = Anchor.CentreLeft
|
|
|
|
},
|
2021-07-12 14:11:53 +08:00
|
|
|
}
|
|
|
|
},
|
2021-07-12 15:28:22 +08:00
|
|
|
new FillFlowContainer
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2021-07-14 15:56:39 +08:00
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
Children = new Drawable[]
|
2021-07-12 15:28:22 +08:00
|
|
|
{
|
2021-07-14 15:56:39 +08:00
|
|
|
new RoomNameText(),
|
|
|
|
new RoomHostText()
|
|
|
|
}
|
|
|
|
},
|
|
|
|
new FillFlowContainer
|
|
|
|
{
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
Origin = Anchor.BottomLeft,
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
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-14 15:56:39 +08:00
|
|
|
new PlaylistCountPill
|
|
|
|
{
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
},
|
|
|
|
new StarRatingRangeDisplay
|
2021-07-12 14:11:07 +08:00
|
|
|
{
|
2021-07-14 15:56:39 +08:00
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
Scale = new Vector2(0.85f)
|
2021-07-12 14:11:07 +08:00
|
|
|
}
|
2021-07-06 19:04:32 +08:00
|
|
|
}
|
|
|
|
}
|
2021-07-14 15:56:39 +08:00
|
|
|
}
|
2021-07-14 15:48:53 +08:00
|
|
|
},
|
2021-07-14 15:56:39 +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-19 21:31:01 +08:00
|
|
|
passwordIcon = new PasswordProtectedIcon { Alpha = 0 }
|
2018-04-13 17:19:50 +08:00
|
|
|
},
|
2021-07-14 15:56:39 +08:00
|
|
|
},
|
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;
|
2021-07-14 15:48:53 +08:00
|
|
|
|
|
|
|
roomCategory.BindTo(Room.Category);
|
|
|
|
roomCategory.BindValueChanged(c =>
|
|
|
|
{
|
|
|
|
if (c.NewValue == RoomCategory.Spotlight)
|
|
|
|
specialCategoryPill.Show();
|
|
|
|
else
|
|
|
|
specialCategoryPill.Hide();
|
|
|
|
}, true);
|
2021-08-03 19:02:31 +08:00
|
|
|
|
2021-07-19 21:31:01 +08:00
|
|
|
hasPassword.BindTo(Room.HasPassword);
|
|
|
|
hasPassword.BindValueChanged(v => passwordIcon.Alpha = v.NewValue ? 1 : 0, true);
|
2018-05-27 13:12:20 +08:00
|
|
|
}
|
2019-02-06 12:52:48 +08:00
|
|
|
|
2021-07-17 14:04:18 +08:00
|
|
|
public Popover GetPopover() => new PasswordEntryPopover(Room) { JoinRequested = lounge.Join };
|
2021-07-12 13:53:12 +08:00
|
|
|
|
|
|
|
public MenuItem[] ContextMenuItems => new MenuItem[]
|
|
|
|
{
|
|
|
|
new OsuMenuItem("Create copy", MenuItemType.Standard, () =>
|
|
|
|
{
|
2021-08-03 19:02:31 +08:00
|
|
|
lounge?.Open(Room.DeepClone());
|
2021-07-12 13:53:12 +08:00
|
|
|
})
|
|
|
|
};
|
|
|
|
|
2021-07-11 09:13:57 +08:00
|
|
|
public bool OnPressed(GlobalAction action)
|
|
|
|
{
|
2021-07-12 13:53:12 +08:00
|
|
|
if (selectedRoom.Value != Room)
|
|
|
|
return false;
|
|
|
|
|
2021-07-11 09:13:57 +08:00
|
|
|
switch (action)
|
|
|
|
{
|
|
|
|
case GlobalAction.Select:
|
2021-08-04 16:27:44 +08:00
|
|
|
TriggerClick();
|
2021-07-11 09:13:57 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void OnReleased(GlobalAction action)
|
|
|
|
{
|
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 13:53:12 +08:00
|
|
|
protected override bool OnClick(ClickEvent e)
|
|
|
|
{
|
|
|
|
if (Room != selectedRoom.Value)
|
|
|
|
{
|
|
|
|
selectedRoom.Value = Room;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Room.HasPassword.Value)
|
|
|
|
{
|
|
|
|
this.ShowPopover();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
lounge?.Join(Room, null);
|
|
|
|
|
|
|
|
return base.OnClick(e);
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-19 21:31:01 +08:00
|
|
|
public class PasswordProtectedIcon : CompositeDrawable
|
2020-08-10 07:16:01 +08:00
|
|
|
{
|
2021-07-10 13:14:58 +08:00
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(OsuColour colours)
|
2020-10-19 16:15:35 +08:00
|
|
|
{
|
2021-07-10 13:14:58 +08:00
|
|
|
Anchor = Anchor.TopRight;
|
|
|
|
Origin = Anchor.TopRight;
|
|
|
|
|
|
|
|
Size = new Vector2(32);
|
|
|
|
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
Colour = colours.Gray5,
|
|
|
|
Rotation = 45,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Width = 2,
|
|
|
|
},
|
|
|
|
new SpriteIcon
|
|
|
|
{
|
|
|
|
Icon = FontAwesome.Solid.Lock,
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
Margin = new MarginPadding(6),
|
|
|
|
Size = new Vector2(14),
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
2021-07-11 09:13:57 +08:00
|
|
|
|
2021-07-14 22:55:46 +08:00
|
|
|
public class PasswordEntryPopover : OsuPopover
|
2021-07-11 09:13:57 +08:00
|
|
|
{
|
2021-07-12 17:29:50 +08:00
|
|
|
private readonly Room room;
|
|
|
|
|
2021-07-17 14:04:18 +08:00
|
|
|
public Action<Room, string> JoinRequested;
|
2021-07-11 09:13:57 +08:00
|
|
|
|
|
|
|
public PasswordEntryPopover(Room room)
|
2021-07-12 17:29:50 +08:00
|
|
|
{
|
|
|
|
this.room = room;
|
|
|
|
}
|
|
|
|
|
2021-07-13 15:34:56 +08:00
|
|
|
private OsuPasswordTextBox passwordTextbox;
|
|
|
|
|
2021-07-12 17:29:50 +08:00
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(OsuColour colours)
|
2021-07-11 09:13:57 +08:00
|
|
|
{
|
2021-07-12 17:29:50 +08:00
|
|
|
Child = new FillFlowContainer
|
2021-07-11 09:13:57 +08:00
|
|
|
{
|
2021-07-12 17:29:50 +08:00
|
|
|
Margin = new MarginPadding(10),
|
|
|
|
Spacing = new Vector2(5),
|
2021-07-11 09:13:57 +08:00
|
|
|
AutoSizeAxes = Axes.Both,
|
2021-07-12 17:29:50 +08:00
|
|
|
Direction = FillDirection.Horizontal,
|
2021-07-11 09:13:57 +08:00
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
2021-07-12 17:29:50 +08:00
|
|
|
passwordTextbox = new OsuPasswordTextBox
|
2021-07-11 09:13:57 +08:00
|
|
|
{
|
2021-07-12 17:29:50 +08:00
|
|
|
Width = 200,
|
2021-07-11 09:13:57 +08:00
|
|
|
},
|
2021-07-12 17:29:50 +08:00
|
|
|
new TriangleButton
|
2021-07-11 09:13:57 +08:00
|
|
|
{
|
2021-07-12 17:29:50 +08:00
|
|
|
Width = 80,
|
|
|
|
Text = "Join Room",
|
2021-07-17 14:04:18 +08:00
|
|
|
Action = () => JoinRequested?.Invoke(room, passwordTextbox.Text)
|
2021-07-12 17:29:50 +08:00
|
|
|
}
|
2021-07-11 09:13:57 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2021-07-13 15:34:56 +08:00
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
|
2021-07-14 22:56:52 +08:00
|
|
|
Schedule(() => GetContainingInputManager().ChangeFocus(passwordTextbox));
|
2021-07-21 06:04:51 +08:00
|
|
|
passwordTextbox.OnCommit += (_, __) => JoinRequested?.Invoke(room, passwordTextbox.Text);
|
2021-07-13 15:34:56 +08:00
|
|
|
}
|
2021-07-11 09:13:57 +08:00
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
}
|
|
|
|
}
|