mirror of
https://github.com/osukey/osukey.git
synced 2025-08-05 15:44:04 +09:00
Merge branch 'master' into multiplayer-team-vs-results
This commit is contained in:
@ -1,117 +0,0 @@
|
||||
// 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.
|
||||
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osu.Game.Online.Rooms.RoomStatuses;
|
||||
|
||||
namespace osu.Game.Screens.OnlinePlay.Components
|
||||
{
|
||||
public class RoomStatusInfo : OnlinePlayComposite
|
||||
{
|
||||
public RoomStatusInfo()
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
StatusPart statusPart;
|
||||
EndDatePart endDatePart;
|
||||
|
||||
InternalChild = new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Vertical,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
statusPart = new StatusPart
|
||||
{
|
||||
Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 14)
|
||||
},
|
||||
endDatePart = new EndDatePart { Font = OsuFont.GetFont(size: 14) }
|
||||
}
|
||||
};
|
||||
|
||||
statusPart.EndDate.BindTo(EndDate);
|
||||
statusPart.Status.BindTo(Status);
|
||||
statusPart.Availability.BindTo(Availability);
|
||||
endDatePart.EndDate.BindTo(EndDate);
|
||||
}
|
||||
|
||||
private class EndDatePart : DrawableDate
|
||||
{
|
||||
public readonly IBindable<DateTimeOffset?> EndDate = new Bindable<DateTimeOffset?>();
|
||||
|
||||
public EndDatePart()
|
||||
: base(DateTimeOffset.UtcNow)
|
||||
{
|
||||
EndDate.BindValueChanged(date =>
|
||||
{
|
||||
// If null, set a very large future date to prevent unnecessary schedules.
|
||||
Date = date.NewValue ?? DateTimeOffset.Now.AddYears(1);
|
||||
}, true);
|
||||
}
|
||||
|
||||
protected override string Format()
|
||||
{
|
||||
if (EndDate.Value == null)
|
||||
return string.Empty;
|
||||
|
||||
var diffToNow = Date.Subtract(DateTimeOffset.Now);
|
||||
|
||||
if (diffToNow.TotalSeconds < -5)
|
||||
return $"Closed {base.Format()}";
|
||||
|
||||
if (diffToNow.TotalSeconds < 0)
|
||||
return "Closed";
|
||||
|
||||
if (diffToNow.TotalSeconds < 5)
|
||||
return "Closing soon";
|
||||
|
||||
return $"Closing {base.Format()}";
|
||||
}
|
||||
}
|
||||
|
||||
private class StatusPart : EndDatePart
|
||||
{
|
||||
public readonly IBindable<RoomStatus> Status = new Bindable<RoomStatus>();
|
||||
public readonly IBindable<RoomAvailability> Availability = new Bindable<RoomAvailability>();
|
||||
|
||||
[Resolved]
|
||||
private OsuColour colours { get; set; }
|
||||
|
||||
public StatusPart()
|
||||
{
|
||||
EndDate.BindValueChanged(_ => Format());
|
||||
Status.BindValueChanged(_ => Format());
|
||||
Availability.BindValueChanged(_ => Format());
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
Text = Format();
|
||||
}
|
||||
|
||||
protected override string Format()
|
||||
{
|
||||
if (!IsLoaded)
|
||||
return string.Empty;
|
||||
|
||||
RoomStatus status = Date < DateTimeOffset.Now ? new RoomStatusEnded() : Status.Value ?? new RoomStatusOpen();
|
||||
|
||||
this.FadeColour(status.GetAppropriateColour(colours), 100);
|
||||
return $"{Availability.Value.GetDescription()}, {status.Message}";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,12 +1,14 @@
|
||||
// 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.
|
||||
|
||||
using System;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Screens.Ranking.Expanded;
|
||||
@ -85,6 +87,7 @@ namespace osu.Game.Screens.OnlinePlay.Components
|
||||
|
||||
minDisplay.Current.Value = minDifficulty;
|
||||
maxDisplay.Current.Value = maxDifficulty;
|
||||
maxDisplay.Alpha = Precision.AlmostEquals(Math.Round(minDifficulty.Stars, 2), Math.Round(maxDifficulty.Stars, 2)) ? 0 : 1;
|
||||
|
||||
minBackground.Colour = colours.ForStarDifficulty(minDifficulty.Stars);
|
||||
maxBackground.Colour = colours.ForStarDifficulty(maxDifficulty.Stars);
|
||||
|
@ -11,6 +11,7 @@ using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Graphics.Effects;
|
||||
@ -20,7 +21,6 @@ using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Drawables;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
@ -28,6 +28,7 @@ using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Graphics.UserInterfaceV2;
|
||||
using osu.Game.Input.Bindings;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Screens.OnlinePlay.Components;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
@ -37,21 +38,18 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
public class DrawableRoom : OsuClickableContainer, IStateful<SelectionState>, IFilterable, IHasContextMenu, IHasPopover, IKeyBindingHandler<GlobalAction>
|
||||
{
|
||||
public const float SELECTION_BORDER_WIDTH = 4;
|
||||
private const float corner_radius = 5;
|
||||
private const float corner_radius = 10;
|
||||
private const float transition_duration = 60;
|
||||
private const float content_padding = 10;
|
||||
private const float height = 110;
|
||||
private const float side_strip_width = 5;
|
||||
private const float cover_width = 145;
|
||||
private const float height = 100;
|
||||
|
||||
public event Action<SelectionState> StateChanged;
|
||||
|
||||
protected override HoverSounds CreateHoverSounds(HoverSampleSet sampleSet) => new HoverSounds();
|
||||
|
||||
private readonly Box selectionBox;
|
||||
private Drawable selectionBox;
|
||||
|
||||
[Resolved(canBeNull: true)]
|
||||
private OnlinePlayScreen parentScreen { get; set; }
|
||||
private LoungeSubScreen loungeScreen { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private BeatmapManager beatmaps { get; set; }
|
||||
@ -74,14 +72,18 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
get => state;
|
||||
set
|
||||
{
|
||||
if (value == state) return;
|
||||
if (value == state)
|
||||
return;
|
||||
|
||||
state = value;
|
||||
|
||||
if (state == SelectionState.Selected)
|
||||
selectionBox.FadeIn(transition_duration);
|
||||
else
|
||||
selectionBox.FadeOut(transition_duration);
|
||||
if (selectionBox != null)
|
||||
{
|
||||
if (state == SelectionState.Selected)
|
||||
selectionBox.FadeIn(transition_duration);
|
||||
else
|
||||
selectionBox.FadeOut(transition_duration);
|
||||
}
|
||||
|
||||
StateChanged?.Invoke(State);
|
||||
}
|
||||
@ -108,6 +110,25 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
}
|
||||
}
|
||||
|
||||
private int numberOfAvatars = 7;
|
||||
|
||||
public int NumberOfAvatars
|
||||
{
|
||||
get => numberOfAvatars;
|
||||
set
|
||||
{
|
||||
numberOfAvatars = value;
|
||||
|
||||
if (recentParticipantsList != null)
|
||||
recentParticipantsList.NumberOfCircles = value;
|
||||
}
|
||||
}
|
||||
|
||||
private readonly Bindable<RoomCategory> roomCategory = new Bindable<RoomCategory>();
|
||||
|
||||
private RecentParticipantsList recentParticipantsList;
|
||||
private RoomSpecialCategoryPill specialCategoryPill;
|
||||
|
||||
public bool FilteringActive { get; set; }
|
||||
|
||||
private PasswordProtectedIcon passwordIcon;
|
||||
@ -119,114 +140,208 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
Room = room;
|
||||
|
||||
RelativeSizeAxes = Axes.X;
|
||||
Height = height + SELECTION_BORDER_WIDTH * 2;
|
||||
CornerRadius = corner_radius + SELECTION_BORDER_WIDTH / 2;
|
||||
Masking = true;
|
||||
Height = height;
|
||||
|
||||
// create selectionBox here so State can be set before being loaded
|
||||
selectionBox = new Box
|
||||
Masking = true;
|
||||
CornerRadius = corner_radius + SELECTION_BORDER_WIDTH / 2;
|
||||
EdgeEffect = new EdgeEffectParameters
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Alpha = 0f,
|
||||
Type = EdgeEffectType.Shadow,
|
||||
Colour = Color4.Black.Opacity(40),
|
||||
Radius = 5,
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours, AudioManager audio)
|
||||
private void load(OverlayColourProvider colours, AudioManager audio)
|
||||
{
|
||||
float stripWidth = side_strip_width * (Room.Category.Value == RoomCategory.Spotlight ? 2 : 1);
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new StatusColouredContainer(transition_duration)
|
||||
// This resolves internal 1px gaps due to applying the (parenting) corner radius and masking across multiple filling background sprites.
|
||||
new BufferedContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = selectionBox
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = colours.Background5,
|
||||
},
|
||||
new OnlinePlayBackgroundSprite
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both
|
||||
},
|
||||
}
|
||||
},
|
||||
new Container
|
||||
{
|
||||
Name = @"Room content",
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding(SELECTION_BORDER_WIDTH),
|
||||
// This negative padding resolves 1px gaps between this background and the background above.
|
||||
Padding = new MarginPadding { Left = 20, Vertical = -0.5f },
|
||||
Child = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Masking = true,
|
||||
CornerRadius = corner_radius,
|
||||
EdgeEffect = new EdgeEffectParameters
|
||||
{
|
||||
Type = EdgeEffectType.Shadow,
|
||||
Colour = Color4.Black.Opacity(40),
|
||||
Radius = 5,
|
||||
},
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
// This resolves internal 1px gaps due to applying the (parenting) corner radius and masking across multiple filling background sprites.
|
||||
new BufferedContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4Extensions.FromHex(@"212121"),
|
||||
},
|
||||
new StatusColouredContainer(transition_duration)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Width = stripWidth,
|
||||
Child = new Box { RelativeSizeAxes = Axes.Both }
|
||||
},
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Width = cover_width,
|
||||
Masking = true,
|
||||
Margin = new MarginPadding { Left = stripWidth },
|
||||
Child = new OnlinePlayBackgroundSprite(BeatmapSetCoverType.List) { RelativeSizeAxes = Axes.Both }
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new GridContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
ColumnDimensions = new[]
|
||||
{
|
||||
new Dimension(GridSizeMode.Relative, 0.2f)
|
||||
},
|
||||
Content = new[]
|
||||
{
|
||||
new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = colours.Background5,
|
||||
},
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = ColourInfo.GradientHorizontal(colours.Background5, colours.Background5.Opacity(0.3f))
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
new Container
|
||||
{
|
||||
Name = @"Left details",
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding
|
||||
{
|
||||
Vertical = content_padding,
|
||||
Left = stripWidth + cover_width + content_padding,
|
||||
Right = content_padding,
|
||||
Left = 20,
|
||||
Vertical = 5
|
||||
},
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(5f),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new RoomName { Font = OsuFont.GetFont(size: 18) },
|
||||
new ParticipantInfo(),
|
||||
new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Spacing = new Vector2(5),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new RoomStatusPill
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft
|
||||
},
|
||||
specialCategoryPill = new RoomSpecialCategoryPill
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft
|
||||
},
|
||||
new EndDateInfo
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft
|
||||
},
|
||||
}
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding { Top = 3 },
|
||||
Direction = FillDirection.Vertical,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new RoomNameText(),
|
||||
new RoomHostText(),
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(0, 5),
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Spacing = new Vector2(5),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new RoomStatusInfo(),
|
||||
new BeatmapTitle { TextSize = 14 },
|
||||
},
|
||||
},
|
||||
new ModeTypeInfo
|
||||
{
|
||||
Anchor = Anchor.BottomRight,
|
||||
Origin = Anchor.BottomRight,
|
||||
},
|
||||
new PlaylistCountPill
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
},
|
||||
new StarRatingRangeDisplay
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Scale = new Vector2(0.8f)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
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,
|
||||
NumberOfCircles = NumberOfAvatars
|
||||
}
|
||||
}
|
||||
},
|
||||
passwordIcon = new PasswordProtectedIcon { Alpha = 0 }
|
||||
},
|
||||
},
|
||||
},
|
||||
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
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
sampleSelect = audio.Samples.Get($@"UI/{HoverSampleSet.Default.GetDescription()}-select");
|
||||
@ -250,6 +365,15 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
else
|
||||
Alpha = 0;
|
||||
|
||||
roomCategory.BindTo(Room.Category);
|
||||
roomCategory.BindValueChanged(c =>
|
||||
{
|
||||
if (c.NewValue == RoomCategory.Spotlight)
|
||||
specialCategoryPill.Show();
|
||||
else
|
||||
specialCategoryPill.Hide();
|
||||
}, true);
|
||||
|
||||
hasPassword.BindTo(Room.HasPassword);
|
||||
hasPassword.BindValueChanged(v => passwordIcon.Alpha = v.NewValue ? 1 : 0, true);
|
||||
}
|
||||
@ -260,7 +384,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
{
|
||||
new OsuMenuItem("Create copy", MenuItemType.Standard, () =>
|
||||
{
|
||||
parentScreen?.OpenNewRoom(Room.DeepClone());
|
||||
lounge?.Open(Room.DeepClone());
|
||||
})
|
||||
};
|
||||
|
||||
@ -307,11 +431,16 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
return base.OnClick(e);
|
||||
}
|
||||
|
||||
private class RoomName : OsuSpriteText
|
||||
private class RoomNameText : OsuSpriteText
|
||||
{
|
||||
[Resolved(typeof(Room), nameof(Online.Rooms.Room.Name))]
|
||||
private Bindable<string> name { get; set; }
|
||||
|
||||
public RoomNameText()
|
||||
{
|
||||
Font = OsuFont.GetFont(size: 28);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
@ -319,6 +448,41 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
}
|
||||
}
|
||||
|
||||
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: 16))
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
public class PasswordProtectedIcon : CompositeDrawable
|
||||
{
|
||||
[BackgroundDependencyLoader]
|
||||
@ -366,7 +530,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
private OsuPasswordTextBox passwordTextbox;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
private void load()
|
||||
{
|
||||
Child = new FillFlowContainer
|
||||
{
|
||||
|
65
osu.Game/Screens/OnlinePlay/Lounge/Components/EndDateInfo.cs
Normal file
65
osu.Game/Screens/OnlinePlay/Lounge/Components/EndDateInfo.cs
Normal file
@ -0,0 +1,65 @@
|
||||
// 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.
|
||||
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
{
|
||||
public class EndDateInfo : OnlinePlayComposite
|
||||
{
|
||||
public EndDateInfo()
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
InternalChild = new EndDatePart
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Font = OsuFont.GetFont(weight: FontWeight.SemiBold, size: 12),
|
||||
EndDate = { BindTarget = EndDate }
|
||||
};
|
||||
}
|
||||
|
||||
private class EndDatePart : DrawableDate
|
||||
{
|
||||
public readonly IBindable<DateTimeOffset?> EndDate = new Bindable<DateTimeOffset?>();
|
||||
|
||||
public EndDatePart()
|
||||
: base(DateTimeOffset.UtcNow)
|
||||
{
|
||||
EndDate.BindValueChanged(date =>
|
||||
{
|
||||
// If null, set a very large future date to prevent unnecessary schedules.
|
||||
Date = date.NewValue ?? DateTimeOffset.Now.AddYears(1);
|
||||
}, true);
|
||||
}
|
||||
|
||||
protected override string Format()
|
||||
{
|
||||
if (EndDate.Value == null)
|
||||
return string.Empty;
|
||||
|
||||
var diffToNow = Date.Subtract(DateTimeOffset.Now);
|
||||
|
||||
if (diffToNow.TotalSeconds < -5)
|
||||
return $"Closed {base.Format()}";
|
||||
|
||||
if (diffToNow.TotalSeconds < 0)
|
||||
return "Closed";
|
||||
|
||||
if (diffToNow.TotalSeconds < 5)
|
||||
return "Closing soon";
|
||||
|
||||
return $"Closing {base.Format()}";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -5,19 +5,18 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Threading;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Rulesets;
|
||||
using osuTK.Graphics;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
{
|
||||
public abstract class FilterControl : CompositeDrawable
|
||||
{
|
||||
protected const float VERTICAL_PADDING = 10;
|
||||
protected const float HORIZONTAL_PADDING = 80;
|
||||
protected readonly FillFlowContainer Filters;
|
||||
|
||||
[Resolved(CanBeNull = true)]
|
||||
private Bindable<FilterCriteria> filter { get; set; }
|
||||
@ -25,60 +24,51 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
[Resolved]
|
||||
private IBindable<RulesetInfo> ruleset { get; set; }
|
||||
|
||||
private readonly Box tabStrip;
|
||||
private readonly SearchTextBox search;
|
||||
private readonly PageTabControl<RoomStatusFilter> tabs;
|
||||
private readonly Dropdown<RoomStatusFilter> statusDropdown;
|
||||
|
||||
protected FilterControl()
|
||||
{
|
||||
InternalChildren = new Drawable[]
|
||||
RelativeSizeAxes = Axes.X;
|
||||
Height = 70;
|
||||
|
||||
InternalChild = new FillFlowContainer
|
||||
{
|
||||
new Box
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(10),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Black,
|
||||
Alpha = 0.25f,
|
||||
},
|
||||
tabStrip = new Box
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 1,
|
||||
},
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding
|
||||
search = new FilterSearchTextBox
|
||||
{
|
||||
Top = VERTICAL_PADDING,
|
||||
Horizontal = HORIZONTAL_PADDING
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Width = 0.6f,
|
||||
},
|
||||
Children = new Drawable[]
|
||||
Filters = new FillFlowContainer
|
||||
{
|
||||
search = new FilterSearchTextBox
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Spacing = new Vector2(10),
|
||||
Child = statusDropdown = new SlimEnumDropdown<RoomStatusFilter>
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
},
|
||||
tabs = new PageTabControl<RoomStatusFilter>
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
},
|
||||
}
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
RelativeSizeAxes = Axes.None,
|
||||
Width = 160,
|
||||
}
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
tabs.Current.Value = RoomStatusFilter.Open;
|
||||
tabs.Current.TriggerChange();
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
filter ??= new Bindable<FilterCriteria>();
|
||||
tabStrip.Colour = colours.Yellow;
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
@ -87,7 +77,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
|
||||
search.Current.BindValueChanged(_ => updateFilterDebounced());
|
||||
ruleset.BindValueChanged(_ => UpdateFilter());
|
||||
tabs.Current.BindValueChanged(_ => UpdateFilter(), true);
|
||||
statusDropdown.Current.BindValueChanged(_ => UpdateFilter(), true);
|
||||
}
|
||||
|
||||
private ScheduledDelegate scheduledFilterUpdate;
|
||||
@ -106,7 +96,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
|
||||
var criteria = CreateCriteria();
|
||||
criteria.SearchString = search.Current.Value;
|
||||
criteria.Status = tabs.Current.Value;
|
||||
criteria.Status = statusDropdown.Current.Value;
|
||||
criteria.Ruleset = ruleset.Value;
|
||||
|
||||
filter.Value = criteria;
|
||||
|
@ -1,88 +0,0 @@
|
||||
// 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.
|
||||
|
||||
using Humanizer;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Users.Drawables;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
{
|
||||
public class ParticipantInfo : OnlinePlayComposite
|
||||
{
|
||||
public ParticipantInfo()
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
Height = 15f;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
OsuSpriteText summary;
|
||||
Container flagContainer;
|
||||
LinkFlowContainer hostText;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.X,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Spacing = new Vector2(5f, 0f),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
flagContainer = new Container
|
||||
{
|
||||
Width = 22f,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
},
|
||||
hostText = new LinkFlowContainer
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
AutoSizeAxes = Axes.Both
|
||||
}
|
||||
},
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Colour = colours.Gray9,
|
||||
Children = new[]
|
||||
{
|
||||
summary = new OsuSpriteText
|
||||
{
|
||||
Text = "0 participants",
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
Host.BindValueChanged(host =>
|
||||
{
|
||||
hostText.Clear();
|
||||
flagContainer.Clear();
|
||||
|
||||
if (host.NewValue != null)
|
||||
{
|
||||
hostText.AddText("hosted by ");
|
||||
hostText.AddUserLink(host.NewValue, s => s.Font = s.Font.With(Typeface.Torus, weight: FontWeight.Bold, italics: true));
|
||||
|
||||
flagContainer.Child = new UpdateableFlag(host.NewValue.Country) { RelativeSizeAxes = Axes.Both };
|
||||
}
|
||||
}, true);
|
||||
|
||||
ParticipantCount.BindValueChanged(count => summary.Text = "participant".ToQuantity(count.NewValue), true);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
// 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.
|
||||
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// Displays contents in a "pill".
|
||||
/// </summary>
|
||||
public class PillContainer : Container
|
||||
{
|
||||
private const float padding = 8;
|
||||
|
||||
public readonly Drawable Background;
|
||||
|
||||
protected override Container<Drawable> Content => content;
|
||||
private readonly Container content;
|
||||
|
||||
public PillContainer()
|
||||
{
|
||||
AutoSizeAxes = Axes.X;
|
||||
Height = 16;
|
||||
|
||||
InternalChild = new CircularContainer
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
AutoSizeAxes = Axes.X,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Masking = true,
|
||||
Children = new[]
|
||||
{
|
||||
Background = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Black,
|
||||
Alpha = 0.5f
|
||||
},
|
||||
new Container
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding { Horizontal = padding },
|
||||
Child = new GridContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
ColumnDimensions = new[]
|
||||
{
|
||||
new Dimension(GridSizeMode.AutoSize, minSize: 80 - 2 * padding)
|
||||
},
|
||||
Content = new[]
|
||||
{
|
||||
new[]
|
||||
{
|
||||
new Container
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Padding = new MarginPadding { Bottom = 2 },
|
||||
Child = content = new Container
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
// 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.
|
||||
|
||||
using System.Collections.Specialized;
|
||||
using Humanizer;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
|
||||
namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// A pill that displays the playlist item count.
|
||||
/// </summary>
|
||||
public class PlaylistCountPill : OnlinePlayComposite
|
||||
{
|
||||
private OsuTextFlowContainer count;
|
||||
|
||||
public PlaylistCountPill()
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
InternalChild = new PillContainer
|
||||
{
|
||||
Child = count = new OsuTextFlowContainer(s => s.Font = OsuFont.GetFont(size: 12))
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
Playlist.BindCollectionChanged(updateCount, true);
|
||||
}
|
||||
|
||||
private void updateCount(object sender, NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
count.Clear();
|
||||
count.AddText(Playlist.Count.ToString(), s => s.Font = s.Font.With(weight: FontWeight.Bold));
|
||||
count.AddText(" ");
|
||||
count.AddText("Beatmap".ToQuantity(Playlist.Count, ShowQuantityAs.None));
|
||||
}
|
||||
}
|
||||
}
|
@ -9,18 +9,16 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
{
|
||||
public class PlaylistsFilterControl : FilterControl
|
||||
{
|
||||
private readonly Dropdown<PlaylistsCategory> dropdown;
|
||||
private readonly Dropdown<PlaylistsCategory> categoryDropdown;
|
||||
|
||||
public PlaylistsFilterControl()
|
||||
{
|
||||
AddInternal(dropdown = new SlimEnumDropdown<PlaylistsCategory>
|
||||
Filters.Add(categoryDropdown = new SlimEnumDropdown<PlaylistsCategory>
|
||||
{
|
||||
Anchor = Anchor.BottomRight,
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
RelativeSizeAxes = Axes.None,
|
||||
Width = 160,
|
||||
X = -HORIZONTAL_PADDING,
|
||||
Y = -30
|
||||
});
|
||||
}
|
||||
|
||||
@ -28,14 +26,14 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
dropdown.Current.BindValueChanged(_ => UpdateFilter());
|
||||
categoryDropdown.Current.BindValueChanged(_ => UpdateFilter());
|
||||
}
|
||||
|
||||
protected override FilterCriteria CreateCriteria()
|
||||
{
|
||||
var criteria = base.CreateCriteria();
|
||||
|
||||
switch (dropdown.Current.Value)
|
||||
switch (categoryDropdown.Current.Value)
|
||||
{
|
||||
case PlaylistsCategory.Normal:
|
||||
criteria.Category = "normal";
|
||||
|
@ -0,0 +1,80 @@
|
||||
// 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.
|
||||
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Screens.OnlinePlay.Multiplayer;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
{
|
||||
public class RankRangePill : MultiplayerRoomComposite
|
||||
{
|
||||
private OsuTextFlowContainer rankFlow;
|
||||
|
||||
public RankRangePill()
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
InternalChild = new PillContainer
|
||||
{
|
||||
Child = new FillFlowContainer
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Spacing = new Vector2(4),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new SpriteIcon
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Size = new Vector2(8),
|
||||
Icon = FontAwesome.Solid.User
|
||||
},
|
||||
rankFlow = new OsuTextFlowContainer(s => s.Font = OsuFont.GetFont(size: 12))
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override void OnRoomUpdated()
|
||||
{
|
||||
base.OnRoomUpdated();
|
||||
|
||||
rankFlow.Clear();
|
||||
|
||||
if (Room == null || Room.Users.All(u => u.User == null))
|
||||
{
|
||||
rankFlow.AddText("-");
|
||||
return;
|
||||
}
|
||||
|
||||
int minRank = Room.Users.Select(u => u.User?.Statistics.GlobalRank ?? 0).DefaultIfEmpty(0).Min();
|
||||
int maxRank = Room.Users.Select(u => u.User?.Statistics.GlobalRank ?? 0).DefaultIfEmpty(0).Max();
|
||||
|
||||
rankFlow.AddText("#");
|
||||
rankFlow.AddText(minRank.ToString("#,0"), s => s.Font = s.Font.With(weight: FontWeight.Bold));
|
||||
|
||||
rankFlow.AddText(" - ");
|
||||
|
||||
rankFlow.AddText("#");
|
||||
rankFlow.AddText(maxRank.ToString("#,0"), s => s.Font = s.Font.With(weight: FontWeight.Bold));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,278 @@
|
||||
// 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.
|
||||
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Users;
|
||||
using osu.Game.Users.Drawables;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
{
|
||||
public class RecentParticipantsList : OnlinePlayComposite
|
||||
{
|
||||
private const float avatar_size = 36;
|
||||
|
||||
private FillFlowContainer<CircularAvatar> avatarFlow;
|
||||
|
||||
private HiddenUserCount hiddenUsers;
|
||||
private OsuSpriteText totalCount;
|
||||
|
||||
public RecentParticipantsList()
|
||||
{
|
||||
AutoSizeAxes = Axes.X;
|
||||
Height = 60;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OverlayColourProvider colours)
|
||||
{
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Masking = true,
|
||||
CornerRadius = 10,
|
||||
Shear = new Vector2(0.2f, 0),
|
||||
Child = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = colours.Background4,
|
||||
}
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Spacing = new Vector2(4),
|
||||
Padding = new MarginPadding { Right = 16 },
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new SpriteIcon
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Size = new Vector2(16),
|
||||
Margin = new MarginPadding { Left = 8 },
|
||||
Icon = FontAwesome.Solid.User,
|
||||
},
|
||||
totalCount = new OsuSpriteText
|
||||
{
|
||||
Font = OsuFont.Default.With(weight: FontWeight.Bold),
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
},
|
||||
avatarFlow = new FillFlowContainer<CircularAvatar>
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Spacing = new Vector2(4),
|
||||
Margin = new MarginPadding { Left = 4 },
|
||||
},
|
||||
hiddenUsers = new HiddenUserCount
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
RecentParticipants.BindCollectionChanged(onParticipantsChanged, true);
|
||||
ParticipantCount.BindValueChanged(_ =>
|
||||
{
|
||||
updateHiddenUsers();
|
||||
totalCount.Text = ParticipantCount.Value.ToString();
|
||||
}, true);
|
||||
}
|
||||
|
||||
private int numberOfCircles = 4;
|
||||
|
||||
/// <summary>
|
||||
/// The maximum number of circles visible (including the "hidden count" circle in the overflow case).
|
||||
/// </summary>
|
||||
public int NumberOfCircles
|
||||
{
|
||||
get => numberOfCircles;
|
||||
set
|
||||
{
|
||||
numberOfCircles = value;
|
||||
|
||||
if (LoadState < LoadState.Loaded)
|
||||
return;
|
||||
|
||||
// Reinitialising the list looks janky, but this is unlikely to be used in a setting where it's visible.
|
||||
clearUsers();
|
||||
foreach (var u in RecentParticipants)
|
||||
addUser(u);
|
||||
|
||||
updateHiddenUsers();
|
||||
}
|
||||
}
|
||||
|
||||
private void onParticipantsChanged(object sender, NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
switch (e.Action)
|
||||
{
|
||||
case NotifyCollectionChangedAction.Add:
|
||||
foreach (var added in e.NewItems.OfType<User>())
|
||||
addUser(added);
|
||||
break;
|
||||
|
||||
case NotifyCollectionChangedAction.Remove:
|
||||
foreach (var removed in e.OldItems.OfType<User>())
|
||||
removeUser(removed);
|
||||
break;
|
||||
|
||||
case NotifyCollectionChangedAction.Reset:
|
||||
clearUsers();
|
||||
break;
|
||||
|
||||
case NotifyCollectionChangedAction.Replace:
|
||||
case NotifyCollectionChangedAction.Move:
|
||||
// Easiest is to just reinitialise the whole list. These are unlikely to ever be use cases.
|
||||
clearUsers();
|
||||
foreach (var u in RecentParticipants)
|
||||
addUser(u);
|
||||
break;
|
||||
}
|
||||
|
||||
updateHiddenUsers();
|
||||
}
|
||||
|
||||
private int displayedCircles => avatarFlow.Count + (hiddenUsers.Count > 0 ? 1 : 0);
|
||||
|
||||
private void addUser(User user)
|
||||
{
|
||||
if (displayedCircles < NumberOfCircles)
|
||||
avatarFlow.Add(new CircularAvatar { User = user });
|
||||
}
|
||||
|
||||
private void removeUser(User user)
|
||||
{
|
||||
avatarFlow.RemoveAll(a => a.User == user);
|
||||
}
|
||||
|
||||
private void clearUsers()
|
||||
{
|
||||
avatarFlow.Clear();
|
||||
updateHiddenUsers();
|
||||
}
|
||||
|
||||
private void updateHiddenUsers()
|
||||
{
|
||||
int hiddenCount = 0;
|
||||
if (RecentParticipants.Count > NumberOfCircles)
|
||||
hiddenCount = ParticipantCount.Value - NumberOfCircles + 1;
|
||||
|
||||
hiddenUsers.Count = hiddenCount;
|
||||
|
||||
if (displayedCircles > NumberOfCircles)
|
||||
avatarFlow.Remove(avatarFlow.Last());
|
||||
else if (displayedCircles < NumberOfCircles)
|
||||
{
|
||||
var nextUser = RecentParticipants.FirstOrDefault(u => avatarFlow.All(a => a.User != u));
|
||||
if (nextUser != null) addUser(nextUser);
|
||||
}
|
||||
}
|
||||
|
||||
private class CircularAvatar : CompositeDrawable
|
||||
{
|
||||
public User User
|
||||
{
|
||||
get => avatar.User;
|
||||
set => avatar.User = value;
|
||||
}
|
||||
|
||||
private readonly UpdateableAvatar avatar = new UpdateableAvatar(showUsernameTooltip: true) { RelativeSizeAxes = Axes.Both };
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OverlayColourProvider colours)
|
||||
{
|
||||
Size = new Vector2(avatar_size);
|
||||
|
||||
InternalChild = new CircularContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Masking = true,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Colour = colours.Background5,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
avatar
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public class HiddenUserCount : CompositeDrawable
|
||||
{
|
||||
public int Count
|
||||
{
|
||||
get => count;
|
||||
set
|
||||
{
|
||||
count = value;
|
||||
countText.Text = $"+{count}";
|
||||
|
||||
if (count > 0)
|
||||
Show();
|
||||
else
|
||||
Hide();
|
||||
}
|
||||
}
|
||||
|
||||
private int count;
|
||||
|
||||
private readonly SpriteText countText = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Font = OsuFont.Default.With(weight: FontWeight.Bold),
|
||||
};
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OverlayColourProvider colours)
|
||||
{
|
||||
Size = new Vector2(avatar_size);
|
||||
Alpha = 0;
|
||||
|
||||
InternalChild = new CircularContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Masking = true,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = colours.Background5,
|
||||
},
|
||||
countText
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,86 +0,0 @@
|
||||
// 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.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Screens.OnlinePlay.Components;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
{
|
||||
public class RoomInfo : OnlinePlayComposite
|
||||
{
|
||||
private readonly List<Drawable> statusElements = new List<Drawable>();
|
||||
private readonly OsuTextFlowContainer roomName;
|
||||
|
||||
public RoomInfo()
|
||||
{
|
||||
AutoSizeAxes = Axes.Y;
|
||||
|
||||
RoomLocalUserInfo localUserInfo;
|
||||
RoomStatusInfo statusInfo;
|
||||
ModeTypeInfo typeInfo;
|
||||
ParticipantInfo participantInfo;
|
||||
|
||||
InternalChild = new FillFlowContainer
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Spacing = new Vector2(0, 10),
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Vertical,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
roomName = new OsuTextFlowContainer(t => t.Font = OsuFont.GetFont(size: 30))
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
},
|
||||
participantInfo = new ParticipantInfo(),
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
statusInfo = new RoomStatusInfo(),
|
||||
typeInfo = new ModeTypeInfo
|
||||
{
|
||||
Anchor = Anchor.BottomRight,
|
||||
Origin = Anchor.BottomRight
|
||||
}
|
||||
}
|
||||
},
|
||||
localUserInfo = new RoomLocalUserInfo(),
|
||||
}
|
||||
};
|
||||
|
||||
statusElements.AddRange(new Drawable[]
|
||||
{
|
||||
statusInfo, typeInfo, participantInfo, localUserInfo
|
||||
});
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
if (RoomID.Value == null)
|
||||
statusElements.ForEach(e => e.FadeOut());
|
||||
RoomID.BindValueChanged(id =>
|
||||
{
|
||||
if (id.NewValue == null)
|
||||
statusElements.ForEach(e => e.FadeOut(100));
|
||||
else
|
||||
statusElements.ForEach(e => e.FadeIn(100));
|
||||
}, true);
|
||||
RoomName.BindValueChanged(name =>
|
||||
{
|
||||
roomName.Text = name.NewValue ?? "No room selected";
|
||||
}, true);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,91 +0,0 @@
|
||||
// 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.
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Screens.OnlinePlay.Components;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
{
|
||||
public class RoomInspector : OnlinePlayComposite
|
||||
{
|
||||
private const float transition_duration = 100;
|
||||
|
||||
private readonly MarginPadding contentPadding = new MarginPadding { Horizontal = 20, Vertical = 10 };
|
||||
|
||||
[Resolved]
|
||||
private BeatmapManager beatmaps { get; set; }
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
OverlinedHeader participantsHeader;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Black,
|
||||
Alpha = 0.25f
|
||||
},
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding { Horizontal = 30 },
|
||||
Child = new GridContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Content = new[]
|
||||
{
|
||||
new Drawable[]
|
||||
{
|
||||
new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Vertical,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new RoomInfo
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Margin = new MarginPadding { Vertical = 60 },
|
||||
},
|
||||
participantsHeader = new OverlinedHeader("Recent Participants"),
|
||||
new ParticipantsDisplay(Direction.Vertical)
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = ParticipantsList.TILE_SIZE * 3,
|
||||
Details = { BindTarget = participantsHeader.Details }
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
new Drawable[] { new OverlinedPlaylistHeader(), },
|
||||
new Drawable[]
|
||||
{
|
||||
new DrawableRoomPlaylist(false, false)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Items = { BindTarget = Playlist }
|
||||
},
|
||||
},
|
||||
},
|
||||
RowDimensions = new[]
|
||||
{
|
||||
new Dimension(GridSizeMode.AutoSize),
|
||||
new Dimension(GridSizeMode.AutoSize),
|
||||
new Dimension(),
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
// 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.
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
{
|
||||
public class RoomSpecialCategoryPill : OnlinePlayComposite
|
||||
{
|
||||
private SpriteText text;
|
||||
|
||||
public RoomSpecialCategoryPill()
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
InternalChild = new PillContainer
|
||||
{
|
||||
Background =
|
||||
{
|
||||
Colour = colours.Pink,
|
||||
Alpha = 1
|
||||
},
|
||||
Child = text = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Font = OsuFont.GetFont(weight: FontWeight.SemiBold, size: 12),
|
||||
Colour = Color4.Black
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
Category.BindValueChanged(c => text.Text = c.NewValue.ToString(), true);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
// 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.
|
||||
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osu.Game.Online.Rooms.RoomStatuses;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// A pill that displays the room's current status.
|
||||
/// </summary>
|
||||
public class RoomStatusPill : OnlinePlayComposite
|
||||
{
|
||||
[Resolved]
|
||||
private OsuColour colours { get; set; }
|
||||
|
||||
private PillContainer pill;
|
||||
private SpriteText statusText;
|
||||
|
||||
public RoomStatusPill()
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
InternalChild = pill = new PillContainer
|
||||
{
|
||||
Child = statusText = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Font = OsuFont.GetFont(weight: FontWeight.SemiBold, size: 12),
|
||||
Colour = Color4.Black
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
EndDate.BindValueChanged(_ => updateDisplay());
|
||||
Status.BindValueChanged(_ => updateDisplay(), true);
|
||||
|
||||
FinishTransforms(true);
|
||||
}
|
||||
|
||||
private void updateDisplay()
|
||||
{
|
||||
RoomStatus status = getDisplayStatus();
|
||||
|
||||
pill.Background.Alpha = 1;
|
||||
pill.Background.FadeColour(status.GetAppropriateColour(colours), 100);
|
||||
statusText.Text = status.Message;
|
||||
}
|
||||
|
||||
private RoomStatus getDisplayStatus()
|
||||
{
|
||||
if (EndDate.Value < DateTimeOffset.Now)
|
||||
return new RoomStatusEnded();
|
||||
|
||||
return Status.Value;
|
||||
}
|
||||
}
|
||||
}
|
@ -50,6 +50,9 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
RelativeSizeAxes = Axes.X;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
|
||||
// account for the fact we are in a scroll container and want a bit of spacing from the scroll bar.
|
||||
Padding = new MarginPadding { Right = 5 };
|
||||
|
||||
InternalChild = new OsuContextMenuContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
@ -59,7 +62,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(2),
|
||||
Spacing = new Vector2(10),
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Game.Graphics.Containers;
|
||||
@ -18,6 +19,8 @@ using osu.Game.Overlays;
|
||||
using osu.Game.Screens.OnlinePlay.Lounge.Components;
|
||||
using osu.Game.Screens.OnlinePlay.Match;
|
||||
using osu.Game.Users;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.OnlinePlay.Lounge
|
||||
{
|
||||
@ -28,11 +31,17 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
|
||||
|
||||
protected override UserActivity InitialActivity => new UserActivity.SearchingForLobby();
|
||||
|
||||
protected Container<OsuButton> Buttons { get; } = new Container<OsuButton>
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
AutoSizeAxes = Axes.Both
|
||||
};
|
||||
|
||||
private readonly IBindable<bool> initialRoomsReceived = new Bindable<bool>();
|
||||
private readonly IBindable<bool> operationInProgress = new Bindable<bool>();
|
||||
|
||||
private FilterControl filter;
|
||||
private Container content;
|
||||
private LoadingLayer loadingLayer;
|
||||
|
||||
[Resolved]
|
||||
@ -56,41 +65,71 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
content = new Container
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 100,
|
||||
Colour = Color4.Black,
|
||||
Alpha = 0.5f,
|
||||
},
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
Padding = new MarginPadding
|
||||
{
|
||||
new Container
|
||||
Top = 20,
|
||||
Left = WaveOverlayContainer.WIDTH_PADDING,
|
||||
Right = WaveOverlayContainer.WIDTH_PADDING,
|
||||
},
|
||||
Child = new GridContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
RowDimensions = new[]
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Width = 0.55f,
|
||||
Children = new Drawable[]
|
||||
new Dimension(GridSizeMode.AutoSize),
|
||||
new Dimension(GridSizeMode.Absolute, 20)
|
||||
},
|
||||
Content = new[]
|
||||
{
|
||||
new Drawable[]
|
||||
{
|
||||
scrollContainer = new OsuScrollContainer
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 70,
|
||||
Depth = -1,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
filter = CreateFilterControl(),
|
||||
Buttons.WithChild(CreateNewRoomButton().With(d =>
|
||||
{
|
||||
d.Size = new Vector2(150, 25);
|
||||
d.Action = () => Open();
|
||||
}))
|
||||
}
|
||||
}
|
||||
},
|
||||
null,
|
||||
new Drawable[]
|
||||
{
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
ScrollbarOverlapsContent = false,
|
||||
Padding = new MarginPadding(10),
|
||||
Child = roomsContainer = new RoomsContainer()
|
||||
Children = new Drawable[]
|
||||
{
|
||||
scrollContainer = new OsuScrollContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
ScrollbarOverlapsContent = false,
|
||||
Child = roomsContainer = new RoomsContainer()
|
||||
},
|
||||
loadingLayer = new LoadingLayer(true),
|
||||
}
|
||||
},
|
||||
loadingLayer = new LoadingLayer(true),
|
||||
}
|
||||
},
|
||||
new RoomInspector
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Width = 0.45f,
|
||||
},
|
||||
}
|
||||
},
|
||||
},
|
||||
filter = CreateFilterControl().With(d =>
|
||||
{
|
||||
d.RelativeSizeAxes = Axes.X;
|
||||
d.Height = 80;
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
// scroll selected room into view on selection.
|
||||
@ -116,18 +155,6 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
|
||||
}
|
||||
}
|
||||
|
||||
protected override void UpdateAfterChildren()
|
||||
{
|
||||
base.UpdateAfterChildren();
|
||||
|
||||
content.Padding = new MarginPadding
|
||||
{
|
||||
Top = filter.DrawHeight,
|
||||
Left = WaveOverlayContainer.WIDTH_PADDING - DrawableRoom.SELECTION_BORDER_WIDTH + HORIZONTAL_OVERFLOW_PADDING,
|
||||
Right = WaveOverlayContainer.WIDTH_PADDING + HORIZONTAL_OVERFLOW_PADDING,
|
||||
};
|
||||
}
|
||||
|
||||
protected override void OnFocus(FocusEvent e)
|
||||
{
|
||||
filter.TakeFocus();
|
||||
@ -199,13 +226,14 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
|
||||
/// <summary>
|
||||
/// Push a room as a new subscreen.
|
||||
/// </summary>
|
||||
public void Open(Room room) => Schedule(() =>
|
||||
/// <param name="room">An optional template to use when creating the room.</param>
|
||||
public void Open(Room room = null) => Schedule(() =>
|
||||
{
|
||||
// Handles the case where a room is clicked 3 times in quick succession
|
||||
if (!this.IsCurrentScreen())
|
||||
return;
|
||||
|
||||
OpenNewRoom(room);
|
||||
OpenNewRoom(room ?? CreateNewRoom());
|
||||
});
|
||||
|
||||
protected virtual void OpenNewRoom(Room room)
|
||||
@ -217,6 +245,14 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
|
||||
|
||||
protected abstract FilterControl CreateFilterControl();
|
||||
|
||||
protected abstract OsuButton CreateNewRoomButton();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new room.
|
||||
/// </summary>
|
||||
/// <returns>The created <see cref="Room"/>.</returns>
|
||||
protected abstract Room CreateNewRoom();
|
||||
|
||||
protected abstract RoomSubScreen CreateRoomSubScreen(Room room);
|
||||
|
||||
private void updateLoadingLayer()
|
||||
|
@ -12,6 +12,7 @@ namespace osu.Game.Screens.OnlinePlay.Match.Components
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
SpriteText.Font = SpriteText.Font.With(size: 14);
|
||||
Triangles.TriangleScale = 1.5f;
|
||||
}
|
||||
|
||||
|
@ -4,9 +4,7 @@
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online.Multiplayer;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osu.Game.Screens.OnlinePlay.Components;
|
||||
using osu.Game.Screens.OnlinePlay.Lounge;
|
||||
|
||||
@ -54,20 +52,10 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
||||
Logger.Log($"Polling adjusted (listing: {multiplayerRoomManager.TimeBetweenListingPolls.Value}, selection: {multiplayerRoomManager.TimeBetweenSelectionPolls.Value})");
|
||||
}
|
||||
|
||||
protected override Room CreateNewRoom() =>
|
||||
new Room
|
||||
{
|
||||
Name = { Value = $"{API.LocalUser}'s awesome room" },
|
||||
Category = { Value = RoomCategory.Realtime },
|
||||
Type = { Value = MatchType.HeadToHead },
|
||||
};
|
||||
|
||||
protected override string ScreenTitle => "Multiplayer";
|
||||
|
||||
protected override RoomManager CreateRoomManager() => new MultiplayerRoomManager();
|
||||
|
||||
protected override LoungeSubScreen CreateLounge() => new MultiplayerLoungeSubScreen();
|
||||
|
||||
protected override OsuButton CreateNewMultiplayerGameButton() => new CreateMultiplayerMatchButton();
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,8 @@
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.Multiplayer;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osu.Game.Screens.OnlinePlay.Lounge;
|
||||
@ -13,13 +15,25 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
||||
{
|
||||
public class MultiplayerLoungeSubScreen : LoungeSubScreen
|
||||
{
|
||||
protected override FilterControl CreateFilterControl() => new MultiplayerFilterControl();
|
||||
|
||||
protected override RoomSubScreen CreateRoomSubScreen(Room room) => new MultiplayerMatchSubScreen(room);
|
||||
[Resolved]
|
||||
private IAPIProvider api { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private MultiplayerClient client { get; set; }
|
||||
|
||||
protected override FilterControl CreateFilterControl() => new MultiplayerFilterControl();
|
||||
|
||||
protected override OsuButton CreateNewRoomButton() => new CreateMultiplayerMatchButton();
|
||||
|
||||
protected override Room CreateNewRoom() => new Room
|
||||
{
|
||||
Name = { Value = $"{api.LocalUser}'s awesome room" },
|
||||
Category = { Value = RoomCategory.Realtime },
|
||||
Type = { Value = MatchType.HeadToHead },
|
||||
};
|
||||
|
||||
protected override RoomSubScreen CreateRoomSubScreen(Room room) => new MultiplayerMatchSubScreen(room);
|
||||
|
||||
protected override void OpenNewRoom(Room room)
|
||||
{
|
||||
if (client?.IsConnected.Value != true)
|
||||
|
@ -2,6 +2,7 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
@ -42,6 +43,8 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Participants
|
||||
private ModDisplay userModsDisplay;
|
||||
private StateDisplay userStateDisplay;
|
||||
|
||||
private IconButton kickButton;
|
||||
|
||||
public ParticipantPanel(MultiplayerRoomUser user)
|
||||
{
|
||||
User = user;
|
||||
@ -64,7 +67,8 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Participants
|
||||
{
|
||||
new Dimension(GridSizeMode.Absolute, 18),
|
||||
new Dimension(GridSizeMode.AutoSize),
|
||||
new Dimension()
|
||||
new Dimension(),
|
||||
new Dimension(GridSizeMode.AutoSize),
|
||||
},
|
||||
Content = new[]
|
||||
{
|
||||
@ -157,7 +161,20 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Participants
|
||||
Margin = new MarginPadding { Right = 10 },
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
kickButton = new KickButton
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Alpha = 0,
|
||||
Margin = new MarginPadding(4),
|
||||
Action = () =>
|
||||
{
|
||||
Debug.Assert(user != null);
|
||||
|
||||
Client.KickUser(user.Id);
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
};
|
||||
@ -167,7 +184,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Participants
|
||||
{
|
||||
base.OnRoomUpdated();
|
||||
|
||||
if (Room == null)
|
||||
if (Room == null || Client.LocalUser == null)
|
||||
return;
|
||||
|
||||
const double fade_time = 50;
|
||||
@ -179,6 +196,11 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Participants
|
||||
|
||||
userStateDisplay.UpdateStatus(User.State, User.BeatmapAvailability);
|
||||
|
||||
if (Client.IsHost && !User.Equals(Client.LocalUser))
|
||||
kickButton.FadeIn(fade_time);
|
||||
else
|
||||
kickButton.FadeOut(fade_time);
|
||||
|
||||
if (Room.Host?.Equals(User) == true)
|
||||
crown.FadeIn(fade_time);
|
||||
else
|
||||
@ -211,13 +233,36 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Participants
|
||||
new OsuMenuItem("Give host", MenuItemType.Standard, () =>
|
||||
{
|
||||
// Ensure the local user is still host.
|
||||
if (Room.Host?.UserID != api.LocalUser.Value.Id)
|
||||
if (!Client.IsHost)
|
||||
return;
|
||||
|
||||
Client.TransferHost(targetUser);
|
||||
}),
|
||||
new OsuMenuItem("Kick", MenuItemType.Destructive, () =>
|
||||
{
|
||||
// Ensure the local user is still host.
|
||||
if (!Client.IsHost)
|
||||
return;
|
||||
|
||||
Client.KickUser(targetUser);
|
||||
})
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public class KickButton : IconButton
|
||||
{
|
||||
public KickButton()
|
||||
{
|
||||
Icon = FontAwesome.Solid.UserTimes;
|
||||
TooltipText = "Kick";
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
IconHoverColour = colours.Red;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,6 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
|
||||
public MultiSpectatorScreen(MultiplayerRoomUser[] users)
|
||||
: base(users.Select(u => u.UserID).ToArray())
|
||||
{
|
||||
// todo: this is a bit ugly, but not sure on a better way to handle.
|
||||
this.users = users;
|
||||
|
||||
instances = new PlayerArea[Users.Count];
|
||||
|
@ -35,6 +35,9 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
[Resolved(typeof(Room))]
|
||||
protected BindableList<PlaylistItem> Playlist { get; private set; }
|
||||
|
||||
[Resolved(typeof(Room))]
|
||||
protected Bindable<RoomCategory> Category { get; private set; }
|
||||
|
||||
[Resolved(typeof(Room))]
|
||||
protected BindableList<User> RecentParticipants { get; private set; }
|
||||
|
||||
|
@ -13,7 +13,6 @@ using osu.Framework.Logging;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Game.Beatmaps.Drawables;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Input;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.Rooms;
|
||||
@ -24,13 +23,15 @@ using osu.Game.Screens.OnlinePlay.Lounge;
|
||||
using osu.Game.Screens.OnlinePlay.Lounge.Components;
|
||||
using osu.Game.Screens.OnlinePlay.Match;
|
||||
using osu.Game.Users;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Screens.OnlinePlay
|
||||
{
|
||||
[Cached]
|
||||
public abstract class OnlinePlayScreen : OsuScreen, IHasSubScreenStack
|
||||
{
|
||||
[Cached]
|
||||
protected readonly OverlayColourProvider ColourProvider = new OverlayColourProvider(OverlayColourScheme.Plum);
|
||||
|
||||
public override bool CursorVisible => (screenStack?.CurrentScreen as IOnlinePlaySubScreen)?.CursorVisible ?? true;
|
||||
|
||||
// this is required due to PlayerLoader eventually being pushed to the main stack
|
||||
@ -38,12 +39,8 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
public override bool DisallowExternalBeatmapRulesetChanges => true;
|
||||
|
||||
private MultiplayerWaveContainer waves;
|
||||
|
||||
private OsuButton createButton;
|
||||
|
||||
private ScreenStack screenStack;
|
||||
|
||||
private LoungeSubScreen loungeSubScreen;
|
||||
private ScreenStack screenStack;
|
||||
|
||||
private readonly IBindable<bool> isIdle = new BindableBool();
|
||||
|
||||
@ -146,20 +143,8 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
}
|
||||
},
|
||||
new Header(ScreenTitle, screenStack),
|
||||
createButton = CreateNewMultiplayerGameButton().With(button =>
|
||||
{
|
||||
button.Anchor = Anchor.TopRight;
|
||||
button.Origin = Anchor.TopRight;
|
||||
button.Size = new Vector2(150, Header.HEIGHT - 20);
|
||||
button.Margin = new MarginPadding
|
||||
{
|
||||
Top = 10,
|
||||
Right = 10 + HORIZONTAL_OVERFLOW_PADDING,
|
||||
};
|
||||
button.Action = () => OpenNewRoom();
|
||||
}),
|
||||
RoomManager,
|
||||
ongoingOperationTracker,
|
||||
ongoingOperationTracker
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -292,18 +277,6 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
logo.Delay(WaveContainer.DISAPPEAR_DURATION / 2).FadeOut();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates and opens the newly-created room.
|
||||
/// </summary>
|
||||
/// <param name="room">An optional template to use when creating the room.</param>
|
||||
public void OpenNewRoom(Room room = null) => loungeSubScreen.Open(room ?? CreateNewRoom());
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new room.
|
||||
/// </summary>
|
||||
/// <returns>The created <see cref="Room"/>.</returns>
|
||||
protected abstract Room CreateNewRoom();
|
||||
|
||||
private void screenPushed(IScreen lastScreen, IScreen newScreen)
|
||||
{
|
||||
subScreenChanged(lastScreen, newScreen);
|
||||
@ -339,7 +312,6 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
((IBindable<UserActivity>)Activity).BindTo(newOsuScreen.Activity);
|
||||
|
||||
UpdatePollingRate(isIdle.Value);
|
||||
createButton.FadeTo(newScreen is LoungeSubScreen ? 1 : 0, 200);
|
||||
}
|
||||
|
||||
protected IScreen CurrentSubScreen => screenStack.CurrentScreen;
|
||||
@ -350,8 +322,6 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
|
||||
protected abstract LoungeSubScreen CreateLounge();
|
||||
|
||||
protected abstract OsuButton CreateNewMultiplayerGameButton();
|
||||
|
||||
private class MultiplayerWaveContainer : WaveContainer
|
||||
{
|
||||
protected override bool StartHidden => true;
|
||||
|
@ -3,8 +3,6 @@
|
||||
|
||||
using osu.Framework.Logging;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osu.Game.Screens.OnlinePlay.Components;
|
||||
using osu.Game.Screens.OnlinePlay.Lounge;
|
||||
using osu.Game.Screens.OnlinePlay.Match;
|
||||
@ -46,21 +44,10 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
|
||||
Logger.Log($"Polling adjusted (listing: {playlistsManager.TimeBetweenListingPolls.Value}, selection: {playlistsManager.TimeBetweenSelectionPolls.Value})");
|
||||
}
|
||||
|
||||
protected override Room CreateNewRoom()
|
||||
{
|
||||
return new Room
|
||||
{
|
||||
Name = { Value = $"{API.LocalUser}'s awesome playlist" },
|
||||
Type = { Value = MatchType.Playlists }
|
||||
};
|
||||
}
|
||||
|
||||
protected override string ScreenTitle => "Playlists";
|
||||
|
||||
protected override RoomManager CreateRoomManager() => new PlaylistsRoomManager();
|
||||
|
||||
protected override LoungeSubScreen CreateLounge() => new PlaylistsLoungeSubScreen();
|
||||
|
||||
protected override OsuButton CreateNewMultiplayerGameButton() => new CreatePlaylistsRoomButton();
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,9 @@
|
||||
// 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.
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osu.Game.Screens.OnlinePlay.Lounge;
|
||||
using osu.Game.Screens.OnlinePlay.Lounge.Components;
|
||||
@ -10,8 +13,22 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
|
||||
{
|
||||
public class PlaylistsLoungeSubScreen : LoungeSubScreen
|
||||
{
|
||||
[Resolved]
|
||||
private IAPIProvider api { get; set; }
|
||||
|
||||
protected override FilterControl CreateFilterControl() => new PlaylistsFilterControl();
|
||||
|
||||
protected override OsuButton CreateNewRoomButton() => new CreatePlaylistsRoomButton();
|
||||
|
||||
protected override Room CreateNewRoom()
|
||||
{
|
||||
return new Room
|
||||
{
|
||||
Name = { Value = $"{api.LocalUser}'s awesome playlist" },
|
||||
Type = { Value = MatchType.Playlists }
|
||||
};
|
||||
}
|
||||
|
||||
protected override RoomSubScreen CreateRoomSubScreen(Room room) => new PlaylistsRoomSubScreen(room);
|
||||
}
|
||||
}
|
||||
|
@ -962,7 +962,7 @@ namespace osu.Game.Screens.Play
|
||||
screenSuspension?.Expire();
|
||||
|
||||
// if arriving here and the results screen preparation task hasn't run, it's safe to say the user has not completed the beatmap.
|
||||
if (Score != null && prepareScoreForDisplayTask == null)
|
||||
if (prepareScoreForDisplayTask == null)
|
||||
{
|
||||
Score.ScoreInfo.Passed = false;
|
||||
// potentially should be ScoreRank.F instead? this is the best alternative for now.
|
||||
|
Reference in New Issue
Block a user