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
|
|
|
|
2021-12-07 17:53:08 +08:00
|
|
|
using System.Collections.Generic;
|
2022-02-15 21:44:20 +08:00
|
|
|
using System.Threading;
|
2017-05-22 11:07:15 +08:00
|
|
|
using osu.Framework.Allocation;
|
2019-02-21 18:04:31 +08:00
|
|
|
using osu.Framework.Bindables;
|
2022-02-15 21:44:20 +08:00
|
|
|
using osu.Framework.Extensions;
|
2017-05-22 11:07:15 +08:00
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
|
|
using osu.Framework.Graphics;
|
2021-07-06 19:04:32 +08:00
|
|
|
using osu.Framework.Graphics.Colour;
|
2017-05-22 11:07:15 +08:00
|
|
|
using osu.Framework.Graphics.Containers;
|
2021-07-14 16:46:32 +08:00
|
|
|
using osu.Framework.Graphics.Effects;
|
2017-06-20 13:54:23 +08:00
|
|
|
using osu.Framework.Graphics.Shapes;
|
2021-07-10 13:14:58 +08:00
|
|
|
using osu.Framework.Graphics.Sprites;
|
2017-07-26 12:22:46 +08:00
|
|
|
using osu.Game.Beatmaps;
|
2022-02-15 21:44:20 +08:00
|
|
|
using osu.Game.Database;
|
2017-05-22 11:07:15 +08:00
|
|
|
using osu.Game.Graphics;
|
2017-06-27 20:05:49 +08:00
|
|
|
using osu.Game.Graphics.Containers;
|
2017-05-22 11:07:15 +08:00
|
|
|
using osu.Game.Graphics.Sprites;
|
2021-09-29 19:24:49 +08:00
|
|
|
using osu.Game.Online.Chat;
|
2020-12-25 23:50:00 +08:00
|
|
|
using osu.Game.Online.Rooms;
|
2021-08-12 16:02:55 +08:00
|
|
|
using osu.Game.Overlays;
|
2020-12-25 23:50:00 +08:00
|
|
|
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
|
2017-05-22 11:07:15 +08:00
|
|
|
{
|
2021-08-18 19:53:17 +08:00
|
|
|
public class DrawableRoom : CompositeDrawable
|
2017-05-22 11:07:15 +08:00
|
|
|
{
|
2021-08-18 19:53:17 +08:00
|
|
|
protected const float CORNER_RADIUS = 10;
|
2021-07-06 19:04:32 +08:00
|
|
|
private const float height = 100;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2021-08-18 19:53:17 +08:00
|
|
|
public readonly Room Room;
|
2020-10-19 16:15:35 +08:00
|
|
|
|
2021-08-18 19:53:17 +08:00
|
|
|
protected Container ButtonsContainer { get; private set; }
|
2021-08-18 14:12:16 +08:00
|
|
|
|
2021-08-19 15:09:17 +08:00
|
|
|
private readonly Bindable<MatchType> roomType = new Bindable<MatchType>();
|
2021-07-14 15:48:53 +08:00
|
|
|
private readonly Bindable<RoomCategory> roomCategory = new Bindable<RoomCategory>();
|
2021-08-18 14:12:16 +08:00
|
|
|
private readonly Bindable<bool> hasPassword = new Bindable<bool>();
|
2021-07-14 15:48:53 +08:00
|
|
|
|
2021-09-29 18:15:58 +08:00
|
|
|
private DrawableRoomParticipantsList drawableRoomParticipantsList;
|
2021-07-14 15:48:53 +08:00
|
|
|
private RoomSpecialCategoryPill specialCategoryPill;
|
2021-07-19 21:31:01 +08:00
|
|
|
private PasswordProtectedIcon passwordIcon;
|
2021-08-19 15:09:17 +08:00
|
|
|
private EndDateInfo endDateInfo;
|
2021-07-19 21:31:01 +08:00
|
|
|
|
2021-09-08 16:13:12 +08:00
|
|
|
private DelayedLoadWrapper wrapper;
|
|
|
|
|
2017-05-22 23:44:58 +08:00
|
|
|
public DrawableRoom(Room room)
|
2017-05-22 11:07:15 +08:00
|
|
|
{
|
2017-05-23 00:05:18 +08:00
|
|
|
Room = room;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2017-05-22 11:07:15 +08:00
|
|
|
RelativeSizeAxes = Axes.X;
|
2021-07-12 13:07:21 +08:00
|
|
|
Height = height;
|
2021-07-14 16:46:32 +08:00
|
|
|
|
2017-05-22 11:07:15 +08:00
|
|
|
Masking = true;
|
2021-08-18 19:53:17 +08:00
|
|
|
CornerRadius = CORNER_RADIUS;
|
2021-07-14 16:46:32 +08:00
|
|
|
EdgeEffect = new EdgeEffectParameters
|
|
|
|
{
|
|
|
|
Type = EdgeEffectType.Shadow,
|
|
|
|
Colour = Color4.Black.Opacity(40),
|
|
|
|
Radius = 5,
|
|
|
|
};
|
2018-05-11 09:12:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2021-08-18 19:53:17 +08:00
|
|
|
private void load(OverlayColourProvider colours)
|
2018-05-11 09:12:25 +08:00
|
|
|
{
|
2021-09-08 23:39:54 +08:00
|
|
|
ButtonsContainer = new Container
|
|
|
|
{
|
|
|
|
Anchor = Anchor.CentreRight,
|
|
|
|
Origin = Anchor.CentreRight,
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
AutoSizeAxes = Axes.X
|
|
|
|
};
|
|
|
|
|
2021-08-19 14:52:51 +08:00
|
|
|
InternalChildren = new[]
|
2017-05-22 11:07:15 +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.
|
2021-08-16 10:04:21 +08:00
|
|
|
new Box
|
2017-05-22 12:01:55 +08:00
|
|
|
{
|
2018-05-11 09:48:07 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
2021-08-16 10:04:21 +08:00
|
|
|
Colour = colours.Background5,
|
|
|
|
},
|
2021-08-19 14:52:51 +08:00
|
|
|
CreateBackground().With(d =>
|
2021-08-16 10:04:21 +08:00
|
|
|
{
|
2021-08-19 14:52:51 +08:00
|
|
|
d.RelativeSizeAxes = Axes.Both;
|
|
|
|
}),
|
2021-09-08 16:13:12 +08:00
|
|
|
wrapper = new DelayedLoadWrapper(() =>
|
|
|
|
new Container
|
2021-07-14 15:56:39 +08:00
|
|
|
{
|
2021-09-08 16:13:12 +08:00
|
|
|
Name = @"Room content",
|
2021-07-14 15:56:39 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
2021-09-08 16:13:12 +08:00
|
|
|
// This negative padding resolves 1px gaps between this background and the background above.
|
|
|
|
Padding = new MarginPadding { Left = 20, Vertical = -0.5f },
|
|
|
|
Child = new Container
|
2017-05-22 11:07:15 +08:00
|
|
|
{
|
2021-09-08 16:13:12 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Masking = true,
|
|
|
|
CornerRadius = CORNER_RADIUS,
|
|
|
|
Children = new Drawable[]
|
2021-07-12 15:30:34 +08:00
|
|
|
{
|
2021-09-08 16:13:12 +08:00
|
|
|
new GridContainer
|
2021-07-12 13:07:21 +08:00
|
|
|
{
|
2021-09-08 16:13:12 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
ColumnDimensions = new[]
|
2021-07-14 15:56:39 +08:00
|
|
|
{
|
2021-09-08 16:13:12 +08:00
|
|
|
new Dimension(GridSizeMode.Relative, 0.2f)
|
|
|
|
},
|
|
|
|
Content = new[]
|
|
|
|
{
|
|
|
|
new Drawable[]
|
2021-07-14 15:56:39 +08:00
|
|
|
{
|
2021-09-08 16:13:12 +08:00
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = colours.Background5,
|
|
|
|
},
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = ColourInfo.GradientHorizontal(colours.Background5, colours.Background5.Opacity(0.3f))
|
|
|
|
},
|
|
|
|
}
|
2021-08-16 10:04:21 +08:00
|
|
|
}
|
2021-07-14 15:56:39 +08:00
|
|
|
},
|
2021-09-08 16:13:12 +08:00
|
|
|
new Container
|
2021-07-14 15:56:39 +08:00
|
|
|
{
|
2021-09-08 16:13:12 +08:00
|
|
|
Name = @"Left details",
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Padding = new MarginPadding
|
2021-07-12 14:11:53 +08:00
|
|
|
{
|
2021-09-08 16:13:12 +08:00
|
|
|
Left = 20,
|
|
|
|
Vertical = 5
|
|
|
|
},
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new FillFlowContainer
|
2021-07-12 14:11:53 +08:00
|
|
|
{
|
2021-09-29 19:44:38 +08:00
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
2021-09-08 16:13:12 +08:00
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
Children = new Drawable[]
|
2021-07-12 14:11:53 +08:00
|
|
|
{
|
2021-09-08 16:13:12 +08:00
|
|
|
new FillFlowContainer
|
2021-08-06 17:52:01 +08:00
|
|
|
{
|
2021-09-08 16:13:12 +08:00
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
Spacing = new Vector2(5),
|
|
|
|
Children = new Drawable[]
|
2021-08-06 17:52:01 +08:00
|
|
|
{
|
2021-09-08 16:13:12 +08:00
|
|
|
new RoomStatusPill
|
|
|
|
{
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
Origin = Anchor.CentreLeft
|
|
|
|
},
|
|
|
|
specialCategoryPill = new RoomSpecialCategoryPill
|
|
|
|
{
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
Origin = Anchor.CentreLeft
|
|
|
|
},
|
|
|
|
endDateInfo = new EndDateInfo
|
|
|
|
{
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
new FillFlowContainer
|
|
|
|
{
|
2021-09-29 19:44:38 +08:00
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
2021-09-08 16:13:12 +08:00
|
|
|
Padding = new MarginPadding { Top = 3 },
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
Children = new Drawable[]
|
2021-08-06 17:52:01 +08:00
|
|
|
{
|
2021-09-08 16:13:12 +08:00
|
|
|
new RoomNameText(),
|
2021-09-29 19:24:49 +08:00
|
|
|
new RoomStatusText()
|
2021-09-08 16:13:12 +08:00
|
|
|
}
|
2021-08-06 17:52:01 +08:00
|
|
|
}
|
2021-07-12 14:11:53 +08:00
|
|
|
},
|
2021-08-06 17:52:01 +08:00
|
|
|
},
|
2021-09-08 16:13:12 +08:00
|
|
|
new FillFlowContainer
|
2017-05-22 11:07:15 +08:00
|
|
|
{
|
2021-09-08 16:13:12 +08:00
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
Origin = Anchor.BottomLeft,
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
Spacing = new Vector2(5),
|
2021-12-07 17:53:08 +08:00
|
|
|
ChildrenEnumerable = CreateBottomDetails()
|
2021-07-06 19:04:32 +08:00
|
|
|
}
|
|
|
|
}
|
2021-07-14 15:56:39 +08:00
|
|
|
},
|
2021-09-08 16:13:12 +08:00
|
|
|
new FillFlowContainer
|
2021-07-14 15:56:39 +08:00
|
|
|
{
|
2021-09-08 16:13:12 +08:00
|
|
|
Name = "Right content",
|
|
|
|
Anchor = Anchor.CentreRight,
|
|
|
|
Origin = Anchor.CentreRight,
|
|
|
|
AutoSizeAxes = Axes.X,
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
Spacing = new Vector2(5),
|
|
|
|
Padding = new MarginPadding
|
2021-08-18 19:53:17 +08:00
|
|
|
{
|
2021-09-08 16:13:12 +08:00
|
|
|
Right = 10,
|
|
|
|
Vertical = 20,
|
2021-08-18 19:53:17 +08:00
|
|
|
},
|
2021-09-08 16:13:12 +08:00
|
|
|
Children = new Drawable[]
|
2021-07-14 15:56:39 +08:00
|
|
|
{
|
2021-09-08 23:39:54 +08:00
|
|
|
ButtonsContainer,
|
2021-09-29 18:15:58 +08:00
|
|
|
drawableRoomParticipantsList = new DrawableRoomParticipantsList
|
2021-09-08 16:13:12 +08:00
|
|
|
{
|
|
|
|
Anchor = Anchor.CentreRight,
|
|
|
|
Origin = Anchor.CentreRight,
|
|
|
|
NumberOfCircles = NumberOfAvatars
|
|
|
|
}
|
2021-07-14 15:56:39 +08:00
|
|
|
}
|
2021-09-08 16:13:12 +08:00
|
|
|
},
|
|
|
|
passwordIcon = new PasswordProtectedIcon { Alpha = 0 }
|
2017-05-22 11:07:15 +08:00
|
|
|
},
|
|
|
|
},
|
2021-09-08 16:13:12 +08:00
|
|
|
}, 0)
|
2021-09-08 19:51:16 +08:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
}
|
2021-06-01 13:33:21 +08:00
|
|
|
};
|
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
|
|
|
|
2021-09-08 16:13:12 +08:00
|
|
|
wrapper.DelayedLoadComplete += _ =>
|
2021-07-14 15:48:53 +08:00
|
|
|
{
|
2021-09-08 19:51:16 +08:00
|
|
|
wrapper.FadeInFromZero(200);
|
|
|
|
|
2021-09-08 16:13:12 +08:00
|
|
|
roomCategory.BindTo(Room.Category);
|
|
|
|
roomCategory.BindValueChanged(c =>
|
|
|
|
{
|
|
|
|
if (c.NewValue == RoomCategory.Spotlight)
|
|
|
|
specialCategoryPill.Show();
|
|
|
|
else
|
|
|
|
specialCategoryPill.Hide();
|
|
|
|
}, true);
|
2021-08-19 15:09:17 +08:00
|
|
|
|
2021-09-08 16:13:12 +08:00
|
|
|
roomType.BindTo(Room.Type);
|
|
|
|
roomType.BindValueChanged(t =>
|
|
|
|
{
|
|
|
|
endDateInfo.Alpha = t.NewValue == MatchType.Playlists ? 1 : 0;
|
|
|
|
}, true);
|
|
|
|
|
|
|
|
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-08-18 19:53:17 +08:00
|
|
|
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
2021-07-11 09:13:57 +08:00
|
|
|
{
|
2021-08-18 19:53:17 +08:00
|
|
|
return new CachedModelDependencyContainer<Room>(base.CreateChildDependencies(parent))
|
2021-07-11 09:13:57 +08:00
|
|
|
{
|
2021-08-18 19:53:17 +08:00
|
|
|
Model = { Value = Room }
|
|
|
|
};
|
2018-05-27 13:12:20 +08:00
|
|
|
}
|
2019-02-06 12:52:48 +08:00
|
|
|
|
2021-08-18 19:53:17 +08:00
|
|
|
private int numberOfAvatars = 7;
|
2020-07-13 13:24:11 +08:00
|
|
|
|
2021-08-18 19:53:17 +08:00
|
|
|
public int NumberOfAvatars
|
2021-07-12 13:53:12 +08:00
|
|
|
{
|
2021-08-18 19:53:17 +08:00
|
|
|
get => numberOfAvatars;
|
|
|
|
set
|
2021-07-12 13:53:12 +08:00
|
|
|
{
|
2021-08-18 19:53:17 +08:00
|
|
|
numberOfAvatars = value;
|
2021-07-12 13:53:12 +08:00
|
|
|
|
2021-09-29 18:15:58 +08:00
|
|
|
if (drawableRoomParticipantsList != null)
|
|
|
|
drawableRoomParticipantsList.NumberOfCircles = value;
|
2021-07-12 13:53:12 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-19 14:52:51 +08:00
|
|
|
protected virtual Drawable CreateBackground() => new OnlinePlayBackgroundSprite();
|
|
|
|
|
2021-12-07 19:36:39 +08:00
|
|
|
protected virtual IEnumerable<Drawable> CreateBottomDetails()
|
2021-12-07 17:53:08 +08:00
|
|
|
{
|
2021-12-07 19:36:39 +08:00
|
|
|
var pills = new List<Drawable>();
|
|
|
|
|
|
|
|
if (Room.Type.Value != MatchType.Playlists)
|
2021-12-07 17:53:08 +08:00
|
|
|
{
|
2021-12-07 19:36:39 +08:00
|
|
|
pills.AddRange(new OnlinePlayComposite[]
|
|
|
|
{
|
|
|
|
new MatchTypePill(),
|
|
|
|
new QueueModePill(),
|
|
|
|
});
|
2021-12-07 17:53:08 +08:00
|
|
|
}
|
2021-12-07 19:36:39 +08:00
|
|
|
|
|
|
|
pills.AddRange(new Drawable[]
|
|
|
|
{
|
|
|
|
new PlaylistCountPill
|
|
|
|
{
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
},
|
|
|
|
new StarRatingRangeDisplay
|
|
|
|
{
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
Scale = new Vector2(0.8f)
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return pills;
|
|
|
|
}
|
2021-12-07 17:53:08 +08:00
|
|
|
|
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()
|
|
|
|
{
|
2021-08-06 17:52:01 +08:00
|
|
|
Font = OsuFont.GetFont(size: 28);
|
2021-07-12 15:28:22 +08:00
|
|
|
}
|
|
|
|
|
2019-02-06 12:52:48 +08:00
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
|
|
|
Current = name;
|
|
|
|
}
|
|
|
|
}
|
2020-08-10 07:16:01 +08:00
|
|
|
|
2021-09-29 19:24:49 +08:00
|
|
|
private class RoomStatusText : OnlinePlayComposite
|
2021-07-12 15:28:22 +08:00
|
|
|
{
|
2021-09-29 19:24:49 +08:00
|
|
|
[Resolved]
|
|
|
|
private OsuColour colours { get; set; }
|
2021-07-12 15:28:22 +08:00
|
|
|
|
2022-02-15 21:44:20 +08:00
|
|
|
[Resolved]
|
|
|
|
private BeatmapLookupCache beatmapLookupCache { get; set; }
|
|
|
|
|
2021-09-29 19:44:38 +08:00
|
|
|
private SpriteText statusText;
|
|
|
|
private LinkFlowContainer beatmapText;
|
2021-09-29 19:24:49 +08:00
|
|
|
|
|
|
|
public RoomStatusText()
|
2021-07-12 15:28:22 +08:00
|
|
|
{
|
2021-09-29 19:44:38 +08:00
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
AutoSizeAxes = Axes.Y;
|
|
|
|
Width = 0.5f;
|
2021-07-12 15:28:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
2021-09-29 19:44:38 +08:00
|
|
|
InternalChild = new GridContainer
|
2021-09-29 19:24:49 +08:00
|
|
|
{
|
2021-09-29 19:44:38 +08:00
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
ColumnDimensions = new[]
|
|
|
|
{
|
|
|
|
new Dimension(GridSizeMode.AutoSize),
|
|
|
|
},
|
2021-09-30 11:01:26 +08:00
|
|
|
RowDimensions = new[]
|
|
|
|
{
|
|
|
|
new Dimension(GridSizeMode.AutoSize)
|
|
|
|
},
|
2021-09-29 19:44:38 +08:00
|
|
|
Content = new[]
|
|
|
|
{
|
|
|
|
new Drawable[]
|
|
|
|
{
|
|
|
|
statusText = new OsuSpriteText
|
|
|
|
{
|
|
|
|
Font = OsuFont.Default.With(size: 16),
|
|
|
|
Colour = colours.Lime1
|
|
|
|
},
|
|
|
|
beatmapText = new LinkFlowContainer(s =>
|
|
|
|
{
|
|
|
|
s.Font = OsuFont.Default.With(size: 16);
|
|
|
|
s.Colour = colours.Lime1;
|
|
|
|
})
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
2021-11-04 01:08:12 +08:00
|
|
|
// workaround to ensure only the first line of text shows, emulating truncation (but without ellipsis at the end).
|
|
|
|
// TODO: remove when text/link flow can support truncation with ellipsis natively.
|
|
|
|
Height = 16,
|
|
|
|
Masking = true
|
2021-09-29 19:44:38 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-07-12 15:28:22 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
2022-02-24 15:20:40 +08:00
|
|
|
CurrentPlaylistItem.BindValueChanged(onSelectedItemChanged, true);
|
2021-09-29 19:24:49 +08:00
|
|
|
}
|
2021-07-12 15:28:22 +08:00
|
|
|
|
2022-02-15 21:44:20 +08:00
|
|
|
private CancellationTokenSource beatmapLookupCancellation;
|
|
|
|
|
2021-09-29 19:24:49 +08:00
|
|
|
private void onSelectedItemChanged(ValueChangedEvent<PlaylistItem> item)
|
|
|
|
{
|
2022-02-15 21:44:20 +08:00
|
|
|
beatmapLookupCancellation?.Cancel();
|
2021-09-29 19:44:38 +08:00
|
|
|
beatmapText.Clear();
|
|
|
|
|
2021-09-29 19:24:49 +08:00
|
|
|
if (Type.Value == MatchType.Playlists)
|
2021-07-12 15:28:22 +08:00
|
|
|
{
|
2021-09-30 11:03:44 +08:00
|
|
|
statusText.Text = "Ready to play";
|
2021-09-29 19:24:49 +08:00
|
|
|
return;
|
|
|
|
}
|
2021-07-12 15:28:22 +08:00
|
|
|
|
2022-02-15 21:44:20 +08:00
|
|
|
var beatmap = item.NewValue?.Beatmap;
|
|
|
|
if (beatmap == null)
|
|
|
|
return;
|
|
|
|
|
|
|
|
var cancellationSource = beatmapLookupCancellation = new CancellationTokenSource();
|
2022-02-15 22:33:26 +08:00
|
|
|
beatmapLookupCache.GetBeatmapAsync(beatmap.OnlineID, cancellationSource.Token)
|
2022-02-15 21:44:20 +08:00
|
|
|
.ContinueWith(task => Schedule(() =>
|
|
|
|
{
|
|
|
|
if (cancellationSource.IsCancellationRequested)
|
|
|
|
return;
|
|
|
|
|
|
|
|
var retrievedBeatmap = task.GetResultSafely();
|
|
|
|
|
|
|
|
statusText.Text = "Currently playing ";
|
2022-04-11 12:36:01 +08:00
|
|
|
|
|
|
|
if (retrievedBeatmap != null)
|
|
|
|
{
|
|
|
|
beatmapText.AddLink(retrievedBeatmap.GetDisplayTitleRomanisable(),
|
|
|
|
LinkAction.OpenBeatmap,
|
|
|
|
retrievedBeatmap.OnlineID.ToString(),
|
|
|
|
creationParameters: s => s.Truncate = true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
beatmapText.AddText("unknown beatmap");
|
2022-02-15 21:44:20 +08:00
|
|
|
}), cancellationSource.Token);
|
2021-07-12 15:28:22 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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),
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
2017-05-22 11:07:15 +08:00
|
|
|
}
|
2017-11-23 04:41:50 +08:00
|
|
|
}
|