mirror of
https://github.com/ppy/osu.git
synced 2025-02-15 14:42:56 +08:00
Implement layout for UserListCard
This commit is contained in:
parent
b7d34b399d
commit
6ea3af1951
@ -55,6 +55,8 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg",
|
||||
IsSupporter = true,
|
||||
SupportLevel = 3,
|
||||
IsOnline = false,
|
||||
LastVisit = DateTimeOffset.Now
|
||||
})
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
|
@ -14,6 +14,13 @@ using osu.Framework.Graphics.Containers;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Game.Users.Drawables;
|
||||
using osuTK;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Overlays.Profile.Header.Components;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterfaceV2.Users
|
||||
{
|
||||
@ -36,8 +43,11 @@ namespace osu.Game.Graphics.UserInterfaceV2.Users
|
||||
[Resolved(canBeNull: true)]
|
||||
private UserProfileOverlay profileOverlay { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private OsuColour colours { get; set; }
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours, OverlayColourProvider colourProvider)
|
||||
private void load(OverlayColourProvider colourProvider)
|
||||
{
|
||||
Action = () => profileOverlay?.ShowUser(User);
|
||||
|
||||
@ -62,10 +72,72 @@ namespace osu.Game.Graphics.UserInterfaceV2.Users
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
}
|
||||
},
|
||||
CreateLayout()
|
||||
});
|
||||
}
|
||||
|
||||
[NotNull]
|
||||
protected abstract Drawable CreateLayout();
|
||||
|
||||
protected UpdateableAvatar CreateAvatar() => new UpdateableAvatar
|
||||
{
|
||||
User = User,
|
||||
Masking = true,
|
||||
OpenOnClick = { Value = false }
|
||||
};
|
||||
|
||||
protected UpdateableFlag CreateFlag() => new UpdateableFlag(User.Country)
|
||||
{
|
||||
Size = new Vector2(39, 26)
|
||||
};
|
||||
|
||||
protected OsuSpriteText CreateUsername() => new OsuSpriteText
|
||||
{
|
||||
Font = OsuFont.GetFont(size: 20, weight: FontWeight.Bold, italics: true),
|
||||
Text = User.Username,
|
||||
};
|
||||
|
||||
protected SpriteIcon CreateStatusIcon() => new SpriteIcon
|
||||
{
|
||||
Icon = FontAwesome.Regular.Circle,
|
||||
Size = new Vector2(25),
|
||||
Colour = User.IsOnline ? colours.GreenLight : Color4.Black
|
||||
};
|
||||
|
||||
protected FillFlowContainer CreateStatusMessage(bool rightAlignedChildren)
|
||||
{
|
||||
var status = new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Vertical
|
||||
};
|
||||
|
||||
var alignment = rightAlignedChildren ? Anchor.x2 : Anchor.x0;
|
||||
|
||||
if (!User.IsOnline && User.LastVisit.HasValue)
|
||||
{
|
||||
status.Add(new TextFlowContainer(t => t.Font = OsuFont.GetFont(size: 15)).With(text =>
|
||||
{
|
||||
text.Anchor = Anchor.y1 | alignment;
|
||||
text.Origin = Anchor.y1 | alignment;
|
||||
text.AutoSizeAxes = Axes.Both;
|
||||
text.AddText(@"Last seen ");
|
||||
text.AddText(new DrawableDate(User.LastVisit.Value, italic: false));
|
||||
}));
|
||||
}
|
||||
|
||||
status.Add(new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.y1 | alignment,
|
||||
Origin = Anchor.y1 | alignment,
|
||||
Font = OsuFont.GetFont(size: 17),
|
||||
Text = User.IsOnline ? @"Online" : @"Offline"
|
||||
});
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
{
|
||||
BorderThickness = 2;
|
||||
|
@ -1,6 +1,8 @@
|
||||
// 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.Game.Users;
|
||||
using osuTK;
|
||||
|
||||
@ -14,5 +16,10 @@ namespace osu.Game.Graphics.UserInterfaceV2.Users
|
||||
Size = new Vector2(290, 120);
|
||||
CornerRadius = 10;
|
||||
}
|
||||
|
||||
protected override Drawable CreateLayout() => new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,9 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osuTK.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osuTK;
|
||||
using osu.Game.Overlays.Profile.Header.Components;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterfaceV2.Users
|
||||
{
|
||||
@ -24,7 +27,83 @@ namespace osu.Game.Graphics.UserInterfaceV2.Users
|
||||
private void load()
|
||||
{
|
||||
Background.Width = 0.5f;
|
||||
Background.Colour = ColourInfo.GradientHorizontal(Color4.White.Opacity(1), Color4.White);
|
||||
Background.Colour = ColourInfo.GradientHorizontal(Color4.White.Opacity(1), Color4.White.Opacity(User.IsOnline ? 0.6f : 0.7f));
|
||||
}
|
||||
|
||||
protected override Drawable CreateLayout()
|
||||
{
|
||||
FillFlowContainer details;
|
||||
|
||||
var layout = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
details = new FillFlowContainer
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Spacing = new Vector2(10, 0),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
CreateAvatar().With(avatar =>
|
||||
{
|
||||
avatar.Anchor = Anchor.CentreLeft;
|
||||
avatar.Origin = Anchor.CentreLeft;
|
||||
avatar.Size = new Vector2(40);
|
||||
avatar.Masking = false;
|
||||
}),
|
||||
CreateFlag().With(flag =>
|
||||
{
|
||||
flag.Anchor = Anchor.CentreLeft;
|
||||
flag.Origin = Anchor.CentreLeft;
|
||||
}),
|
||||
CreateUsername().With(username =>
|
||||
{
|
||||
username.Anchor = Anchor.CentreLeft;
|
||||
username.Origin = Anchor.CentreLeft;
|
||||
})
|
||||
}
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Spacing = new Vector2(10, 0),
|
||||
Margin = new MarginPadding { Right = 10 },
|
||||
Children = new Drawable[]
|
||||
{
|
||||
CreateStatusIcon().With(icon =>
|
||||
{
|
||||
icon.Anchor = Anchor.CentreRight;
|
||||
icon.Origin = Anchor.CentreRight;
|
||||
}),
|
||||
CreateStatusMessage(true).With(message =>
|
||||
{
|
||||
message.Anchor = Anchor.CentreRight;
|
||||
message.Origin = Anchor.CentreRight;
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (User.IsSupporter)
|
||||
{
|
||||
details.Add(new SupporterIcon
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Height = 20,
|
||||
SupportLevel = User.SupportLevel
|
||||
});
|
||||
}
|
||||
|
||||
return layout;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user