mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 06:43:21 +08:00
Share host/participant info displaying.
This commit is contained in:
parent
0de55776c0
commit
05b5fe8ae7
@ -1,7 +1,6 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.Linq;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Allocation;
|
||||
@ -33,11 +32,7 @@ namespace osu.Game.Screens.Multiplayer
|
||||
private readonly Box sideStrip;
|
||||
private readonly Container coverContainer, rulesetContainer, gameTypeContainer;
|
||||
private readonly OsuSpriteText name;
|
||||
private readonly Container flagContainer;
|
||||
private readonly OsuSpriteText host;
|
||||
private readonly FillFlowContainer levelRangeContainer;
|
||||
private readonly OsuSpriteText levelRangeLower;
|
||||
private readonly OsuSpriteText levelRangeHigher;
|
||||
private readonly ParticipantInfo participantInfo;
|
||||
private readonly OsuSpriteText status;
|
||||
private readonly FillFlowContainer<OsuSpriteText> beatmapInfoFlow;
|
||||
private readonly OsuSpriteText beatmapTitle;
|
||||
@ -121,93 +116,7 @@ namespace osu.Game.Screens.Multiplayer
|
||||
{
|
||||
TextSize = 18,
|
||||
},
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 20f,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.X,
|
||||
Height = 15f,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Spacing = new Vector2(5f, 0f),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
flagContainer = new Container
|
||||
{
|
||||
Width = 22f,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
},
|
||||
new Container //todo: team banners
|
||||
{
|
||||
Width = 38f,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
CornerRadius = 2f,
|
||||
Masking = true,
|
||||
Children = new[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = OsuColour.FromHex(@"ad387e"),
|
||||
},
|
||||
},
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = "hosted by",
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
TextSize = 14,
|
||||
},
|
||||
host = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
TextSize = 14,
|
||||
Font = @"Exo2.0-BoldItalic",
|
||||
},
|
||||
},
|
||||
},
|
||||
levelRangeContainer = new FillFlowContainer
|
||||
{
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Children = new[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = "#",
|
||||
TextSize = 14,
|
||||
},
|
||||
levelRangeLower = new OsuSpriteText
|
||||
{
|
||||
TextSize = 14,
|
||||
Font = @"Exo2.0-Bold",
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = " - ",
|
||||
TextSize = 14,
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = "#",
|
||||
TextSize = 14,
|
||||
},
|
||||
levelRangeHigher = new OsuSpriteText
|
||||
{
|
||||
TextSize = 14,
|
||||
Font = @"Exo2.0-Bold",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
participantInfo = new ParticipantInfo(),
|
||||
},
|
||||
},
|
||||
new FillFlowContainer
|
||||
@ -297,8 +206,7 @@ namespace osu.Game.Screens.Multiplayer
|
||||
this.textures = textures;
|
||||
this.colours = colours;
|
||||
|
||||
beatmapInfoFlow.Colour = levelRangeContainer.Colour = colours.Gray9;
|
||||
host.Colour = colours.Blue;
|
||||
beatmapInfoFlow.Colour = colours.Gray9;
|
||||
|
||||
//binded here instead of ctor because dependencies are needed
|
||||
statusBind.ValueChanged += displayStatus;
|
||||
@ -317,8 +225,7 @@ namespace osu.Game.Screens.Multiplayer
|
||||
|
||||
private void displayUser(User value)
|
||||
{
|
||||
host.Text = value.Username;
|
||||
flagContainer.Children = new[] { new DrawableFlag(value.Country?.FlagName ?? @"__") { RelativeSizeAxes = Axes.Both } };
|
||||
participantInfo.Host = value;
|
||||
}
|
||||
|
||||
private void displayStatus(RoomStatus value)
|
||||
@ -385,9 +292,7 @@ namespace osu.Game.Screens.Multiplayer
|
||||
|
||||
private void displayParticipants(User[] value)
|
||||
{
|
||||
var ranks = value.Select(u => u.GlobalRank);
|
||||
levelRangeLower.Text = ranks.Min().ToString();
|
||||
levelRangeHigher.Text = ranks.Max().ToString();
|
||||
participantInfo.Participants = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
142
osu.Game/Screens/Multiplayer/ParticipantInfo.cs
Normal file
142
osu.Game/Screens/Multiplayer/ParticipantInfo.cs
Normal file
@ -0,0 +1,142 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenTK;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Screens.Multiplayer
|
||||
{
|
||||
public class ParticipantInfo : Container
|
||||
{
|
||||
private readonly Container flagContainer;
|
||||
private readonly OsuSpriteText host;
|
||||
private readonly FillFlowContainer levelRangeContainer;
|
||||
private readonly OsuSpriteText levelRangeLower;
|
||||
private readonly OsuSpriteText levelRangeHigher;
|
||||
|
||||
public User Host
|
||||
{
|
||||
set
|
||||
{
|
||||
host.Text = value.Username;
|
||||
flagContainer.Children = new[] { new DrawableFlag(value.Country?.FlagName ?? @"__") { RelativeSizeAxes = Axes.Both } };
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<User> Participants
|
||||
{
|
||||
set
|
||||
{
|
||||
var ranks = value.Select(u => u.GlobalRank);
|
||||
levelRangeLower.Text = ranks.Min().ToString();
|
||||
levelRangeHigher.Text = ranks.Max().ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public ParticipantInfo(string rankPrefix = null)
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
Height = 15f;
|
||||
|
||||
Children = 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,
|
||||
},
|
||||
new Container //todo: team banners
|
||||
{
|
||||
Width = 38f,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
CornerRadius = 2f,
|
||||
Masking = true,
|
||||
Children = new[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = OsuColour.FromHex(@"ad387e"),
|
||||
},
|
||||
},
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = "hosted by",
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
TextSize = 14,
|
||||
},
|
||||
host = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
TextSize = 14,
|
||||
Font = @"Exo2.0-BoldItalic",
|
||||
},
|
||||
},
|
||||
},
|
||||
levelRangeContainer = new FillFlowContainer
|
||||
{
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Children = new[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = rankPrefix,
|
||||
TextSize = 14,
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = "#",
|
||||
TextSize = 14,
|
||||
},
|
||||
levelRangeLower = new OsuSpriteText
|
||||
{
|
||||
TextSize = 14,
|
||||
Font = @"Exo2.0-Bold",
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = " - ",
|
||||
TextSize = 14,
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = "#",
|
||||
TextSize = 14,
|
||||
},
|
||||
levelRangeHigher = new OsuSpriteText
|
||||
{
|
||||
TextSize = 14,
|
||||
Font = @"Exo2.0-Bold",
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
levelRangeContainer.Colour = colours.Gray9;
|
||||
host.Colour = colours.Blue;
|
||||
}
|
||||
}
|
||||
}
|
@ -30,9 +30,10 @@ namespace osu.Game.Screens.Multiplayer
|
||||
private const float ruleset_height = 30;
|
||||
|
||||
private readonly Box statusStrip;
|
||||
private readonly Container coverContainer, rulesetContainer, gameTypeContainer, flagContainer;
|
||||
private readonly FillFlowContainer topFlow, levelRangeContainer, participantsFlow;
|
||||
private readonly OsuSpriteText participants, participantsSlash, maxParticipants, name, status, beatmapTitle, beatmapDash, beatmapArtist, beatmapAuthor, host, levelRangeLower, levelRangeHigher;
|
||||
private readonly Container coverContainer, rulesetContainer, gameTypeContainer;
|
||||
private readonly FillFlowContainer topFlow, participantsFlow;
|
||||
private readonly OsuSpriteText participants, participantsSlash, maxParticipants, name, status, beatmapTitle, beatmapDash, beatmapArtist, beatmapAuthor;
|
||||
private readonly ParticipantInfo participantInfo;
|
||||
private readonly ScrollContainer participantsScroll;
|
||||
|
||||
private readonly Bindable<string> nameBind = new Bindable<string>();
|
||||
@ -252,90 +253,7 @@ namespace osu.Game.Screens.Multiplayer
|
||||
Padding = contentPadding,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.X,
|
||||
Height = 15f,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Spacing = new Vector2(5f, 0f),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
flagContainer = new Container
|
||||
{
|
||||
Width = 22f,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
},
|
||||
new Container //todo: team banners
|
||||
{
|
||||
Width = 38f,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
CornerRadius = 2f,
|
||||
Masking = true,
|
||||
Children = new[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = OsuColour.FromHex(@"ad387e"),
|
||||
},
|
||||
},
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = "hosted by",
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
TextSize = 14,
|
||||
},
|
||||
host = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
TextSize = 14,
|
||||
Font = @"Exo2.0-BoldItalic",
|
||||
},
|
||||
},
|
||||
},
|
||||
levelRangeContainer = new FillFlowContainer
|
||||
{
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Children = new[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = "Rank Range ",
|
||||
TextSize = 14,
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = "#",
|
||||
TextSize = 14,
|
||||
},
|
||||
levelRangeLower = new OsuSpriteText
|
||||
{
|
||||
TextSize = 14,
|
||||
Font = @"Exo2.0-Bold",
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = " - ",
|
||||
TextSize = 14,
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = "#",
|
||||
TextSize = 14,
|
||||
},
|
||||
levelRangeHigher = new OsuSpriteText
|
||||
{
|
||||
TextSize = 14,
|
||||
Font = @"Exo2.0-Bold",
|
||||
},
|
||||
},
|
||||
},
|
||||
participantInfo = new ParticipantInfo(@"Rank Range "),
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -372,8 +290,7 @@ namespace osu.Game.Screens.Multiplayer
|
||||
this.colours = colours;
|
||||
this.textures = textures;
|
||||
|
||||
beatmapAuthor.Colour = levelRangeContainer.Colour = colours.Gray9;
|
||||
host.Colour = colours.Blue;
|
||||
beatmapAuthor.Colour = colours.Gray9;
|
||||
|
||||
//binded here instead of ctor because dependencies are needed
|
||||
statusBind.ValueChanged += displayStatus;
|
||||
@ -399,14 +316,7 @@ namespace osu.Game.Screens.Multiplayer
|
||||
|
||||
private void displayUser(User value)
|
||||
{
|
||||
host.Text = value.Username;
|
||||
flagContainer.Children = new[]
|
||||
{
|
||||
new DrawableFlag(value.Country?.FlagName ?? @"__")
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
};
|
||||
participantInfo.Host = value;
|
||||
}
|
||||
|
||||
private void displayStatus(RoomStatus value)
|
||||
@ -489,11 +399,7 @@ namespace osu.Game.Screens.Multiplayer
|
||||
private void displayParticipants(User[] value)
|
||||
{
|
||||
participants.Text = value.Length.ToString();
|
||||
|
||||
var ranks = value.Select(u => u.GlobalRank);
|
||||
levelRangeLower.Text = ranks.Min().ToString();
|
||||
levelRangeHigher.Text = ranks.Max().ToString();
|
||||
|
||||
participantInfo.Participants = value;
|
||||
participantsFlow.Children = value.Select(u => new UserTile(u));
|
||||
}
|
||||
|
||||
|
@ -490,6 +490,7 @@
|
||||
<Compile Include="Screens\Multiplayer\RoomInspector.cs" />
|
||||
<Compile Include="Online\Multiplayer\GameType.cs" />
|
||||
<Compile Include="Screens\Multiplayer\DrawableGameType.cs" />
|
||||
<Compile Include="Screens\Multiplayer\ParticipantInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\osu-framework\osu.Framework\osu.Framework.csproj">
|
||||
|
Loading…
Reference in New Issue
Block a user