mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 18:33:20 +08:00
Merge pull request #15976 from smoogipoo/add-modes-to-room-panels
Add match type and queue mode to multiplayer room panels
This commit is contained in:
commit
a8c20368c0
@ -11,12 +11,14 @@ using osu.Framework.Graphics.Containers;
|
|||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
|
using osu.Game.Online.Multiplayer;
|
||||||
using osu.Game.Online.Rooms;
|
using osu.Game.Online.Rooms;
|
||||||
using osu.Game.Online.Rooms.RoomStatuses;
|
using osu.Game.Online.Rooms.RoomStatuses;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Rulesets.Osu;
|
using osu.Game.Rulesets.Osu;
|
||||||
using osu.Game.Screens.OnlinePlay.Lounge;
|
using osu.Game.Screens.OnlinePlay.Lounge;
|
||||||
using osu.Game.Screens.OnlinePlay.Lounge.Components;
|
using osu.Game.Screens.OnlinePlay.Lounge.Components;
|
||||||
|
using osu.Game.Screens.OnlinePlay.Match;
|
||||||
using osu.Game.Tests.Beatmaps;
|
using osu.Game.Tests.Beatmaps;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
@ -172,6 +174,39 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
AddAssert("password icon hidden", () => Precision.AlmostEquals(0, drawableRoom.ChildrenOfType<DrawableRoom.PasswordProtectedIcon>().Single().Alpha));
|
AddAssert("password icon hidden", () => Precision.AlmostEquals(0, drawableRoom.ChildrenOfType<DrawableRoom.PasswordProtectedIcon>().Single().Alpha));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestMultiplayerRooms()
|
||||||
|
{
|
||||||
|
AddStep("create rooms", () => Child = new FillFlowContainer
|
||||||
|
{
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Direction = FillDirection.Vertical,
|
||||||
|
Spacing = new Vector2(5),
|
||||||
|
Children = new[]
|
||||||
|
{
|
||||||
|
new DrawableMatchRoom(new Room
|
||||||
|
{
|
||||||
|
Name = { Value = "A host-only room" },
|
||||||
|
QueueMode = { Value = QueueMode.HostOnly },
|
||||||
|
Type = { Value = MatchType.HeadToHead }
|
||||||
|
}),
|
||||||
|
new DrawableMatchRoom(new Room
|
||||||
|
{
|
||||||
|
Name = { Value = "An all-players, team-versus room" },
|
||||||
|
QueueMode = { Value = QueueMode.AllPlayers },
|
||||||
|
Type = { Value = MatchType.TeamVersus }
|
||||||
|
}),
|
||||||
|
new DrawableMatchRoom(new Room
|
||||||
|
{
|
||||||
|
Name = { Value = "A round-robin room" },
|
||||||
|
QueueMode = { Value = QueueMode.AllPlayersRoundRobin },
|
||||||
|
Type = { Value = MatchType.HeadToHead }
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private DrawableRoom createLoungeRoom(Room room)
|
private DrawableRoom createLoungeRoom(Room room)
|
||||||
{
|
{
|
||||||
room.Host.Value ??= new APIUser { Username = "peppy", Id = 2 };
|
room.Host.Value ??= new APIUser { Username = "peppy", Id = 2 };
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
@ -184,20 +185,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
|||||||
AutoSizeAxes = Axes.Both,
|
AutoSizeAxes = Axes.Both,
|
||||||
Direction = FillDirection.Horizontal,
|
Direction = FillDirection.Horizontal,
|
||||||
Spacing = new Vector2(5),
|
Spacing = new Vector2(5),
|
||||||
Children = new Drawable[]
|
ChildrenEnumerable = CreateBottomDetails()
|
||||||
{
|
|
||||||
new PlaylistCountPill
|
|
||||||
{
|
|
||||||
Anchor = Anchor.CentreLeft,
|
|
||||||
Origin = Anchor.CentreLeft,
|
|
||||||
},
|
|
||||||
new StarRatingRangeDisplay
|
|
||||||
{
|
|
||||||
Anchor = Anchor.CentreLeft,
|
|
||||||
Origin = Anchor.CentreLeft,
|
|
||||||
Scale = new Vector2(0.8f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -287,6 +275,37 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
|||||||
|
|
||||||
protected virtual Drawable CreateBackground() => new OnlinePlayBackgroundSprite();
|
protected virtual Drawable CreateBackground() => new OnlinePlayBackgroundSprite();
|
||||||
|
|
||||||
|
protected virtual IEnumerable<Drawable> CreateBottomDetails()
|
||||||
|
{
|
||||||
|
var pills = new List<Drawable>();
|
||||||
|
|
||||||
|
if (Room.Type.Value != MatchType.Playlists)
|
||||||
|
{
|
||||||
|
pills.AddRange(new OnlinePlayComposite[]
|
||||||
|
{
|
||||||
|
new MatchTypePill(),
|
||||||
|
new QueueModePill(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
private class RoomNameText : OsuSpriteText
|
private class RoomNameText : OsuSpriteText
|
||||||
{
|
{
|
||||||
[Resolved(typeof(Room), nameof(Online.Rooms.Room.Name))]
|
[Resolved(typeof(Room), nameof(Online.Rooms.Room.Name))]
|
||||||
|
@ -0,0 +1,50 @@
|
|||||||
|
// 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.Bindables;
|
||||||
|
using osu.Framework.Extensions;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.Containers;
|
||||||
|
using osu.Game.Online.Rooms;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||||
|
{
|
||||||
|
public class MatchTypePill : OnlinePlayComposite
|
||||||
|
{
|
||||||
|
private OsuTextFlowContainer textFlow;
|
||||||
|
|
||||||
|
public MatchTypePill()
|
||||||
|
{
|
||||||
|
AutoSizeAxes = Axes.Both;
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
InternalChild = new PillContainer
|
||||||
|
{
|
||||||
|
Child = textFlow = new OsuTextFlowContainer(s => s.Font = OsuFont.GetFont(size: 12))
|
||||||
|
{
|
||||||
|
Anchor = Anchor.CentreLeft,
|
||||||
|
Origin = Anchor.CentreLeft,
|
||||||
|
AutoSizeAxes = Axes.Both,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
Type.BindValueChanged(onMatchTypeChanged, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onMatchTypeChanged(ValueChangedEvent<MatchType> type)
|
||||||
|
{
|
||||||
|
textFlow.Clear();
|
||||||
|
textFlow.AddText(type.NewValue.GetLocalisableDescription());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
// 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.Bindables;
|
||||||
|
using osu.Framework.Extensions;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.Containers;
|
||||||
|
using osu.Game.Online.Multiplayer;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||||
|
{
|
||||||
|
public class QueueModePill : OnlinePlayComposite
|
||||||
|
{
|
||||||
|
private OsuTextFlowContainer textFlow;
|
||||||
|
|
||||||
|
public QueueModePill()
|
||||||
|
{
|
||||||
|
AutoSizeAxes = Axes.Both;
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
InternalChild = new PillContainer
|
||||||
|
{
|
||||||
|
Child = textFlow = new OsuTextFlowContainer(s => s.Font = OsuFont.GetFont(size: 12))
|
||||||
|
{
|
||||||
|
Anchor = Anchor.CentreLeft,
|
||||||
|
Origin = Anchor.CentreLeft,
|
||||||
|
AutoSizeAxes = Axes.Both,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
QueueMode.BindValueChanged(onQueueModeChanged, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onQueueModeChanged(ValueChangedEvent<QueueMode> mode)
|
||||||
|
{
|
||||||
|
textFlow.Clear();
|
||||||
|
textFlow.AddText(mode.NewValue.GetLocalisableDescription());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user