mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 03:22:55 +08:00
Update profile recent activities in line with the web design
This commit is contained in:
parent
7f59576f13
commit
786ed03868
@ -4,10 +4,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.Profile.Sections;
|
||||
using osu.Game.Overlays.Profile.Sections.Historical;
|
||||
using osu.Game.Users;
|
||||
@ -24,9 +26,11 @@ namespace osu.Game.Tests.Visual.Online
|
||||
typeof(HistoricalSection),
|
||||
typeof(PaginatedMostPlayedBeatmapContainer),
|
||||
typeof(DrawableMostPlayedBeatmap),
|
||||
typeof(DrawableProfileRow)
|
||||
};
|
||||
|
||||
[Cached]
|
||||
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Green);
|
||||
|
||||
public TestSceneHistoricalSection()
|
||||
{
|
||||
HistoricalSection section;
|
||||
|
@ -5,6 +5,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
@ -12,6 +13,7 @@ using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Online.API.Requests;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.Profile.Sections;
|
||||
using osu.Game.Overlays.Profile.Sections.Recent;
|
||||
|
||||
@ -28,6 +30,9 @@ namespace osu.Game.Tests.Visual.Online
|
||||
typeof(MedalIcon)
|
||||
};
|
||||
|
||||
[Cached]
|
||||
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Green);
|
||||
|
||||
public TestSceneUserProfileRecentSection()
|
||||
{
|
||||
Children = new Drawable[]
|
||||
|
@ -10,7 +10,7 @@ using osu.Game.Graphics.Containers;
|
||||
namespace osu.Game.Overlays.Profile.Sections
|
||||
{
|
||||
/// <summary>
|
||||
/// Display artist/title/mapper information, commonly used as the left portion of a profile or score display row (see <see cref="DrawableProfileRow"/>).
|
||||
/// Display artist/title/mapper information, commonly used as the left portion of a profile or score display row.
|
||||
/// </summary>
|
||||
public abstract class BeatmapMetadataContainer : OsuHoverContainer
|
||||
{
|
||||
|
@ -1,124 +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.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Effects;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Graphics;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Sections
|
||||
{
|
||||
public abstract class DrawableProfileRow : Container
|
||||
{
|
||||
private const int fade_duration = 200;
|
||||
|
||||
private Box underscoreLine;
|
||||
private Box coloredBackground;
|
||||
private Container background;
|
||||
|
||||
/// <summary>
|
||||
/// A visual element displayed to the left of <see cref="LeftFlowContainer"/> content.
|
||||
/// </summary>
|
||||
protected abstract Drawable CreateLeftVisual();
|
||||
|
||||
protected FillFlowContainer LeftFlowContainer { get; private set; }
|
||||
protected FillFlowContainer RightFlowContainer { get; private set; }
|
||||
|
||||
protected override Container<Drawable> Content { get; }
|
||||
|
||||
protected DrawableProfileRow()
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
Height = 60;
|
||||
|
||||
Content = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
Width = 0.97f,
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(OsuColour colour)
|
||||
{
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
background = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Masking = true,
|
||||
CornerRadius = 3,
|
||||
Alpha = 0,
|
||||
EdgeEffect = new EdgeEffectParameters
|
||||
{
|
||||
Type = EdgeEffectType.Shadow,
|
||||
Offset = new Vector2(0f, 1f),
|
||||
Radius = 1f,
|
||||
Colour = Color4.Black.Opacity(0.2f),
|
||||
},
|
||||
Child = coloredBackground = new Box { RelativeSizeAxes = Axes.Both }
|
||||
},
|
||||
Content,
|
||||
underscoreLine = new Box
|
||||
{
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Origin = Anchor.BottomCentre,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 1,
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Children = new[]
|
||||
{
|
||||
CreateLeftVisual(),
|
||||
LeftFlowContainer = new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Margin = new MarginPadding { Left = 10 },
|
||||
Direction = FillDirection.Vertical,
|
||||
},
|
||||
}
|
||||
},
|
||||
RightFlowContainer = new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight,
|
||||
Direction = FillDirection.Vertical,
|
||||
},
|
||||
};
|
||||
|
||||
coloredBackground.Colour = underscoreLine.Colour = colour.Gray4;
|
||||
}
|
||||
|
||||
protected override bool OnClick(ClickEvent e) => true;
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
{
|
||||
background.FadeIn(fade_duration, Easing.OutQuint);
|
||||
underscoreLine.FadeOut(fade_duration, Easing.OutQuint);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(HoverLostEvent e)
|
||||
{
|
||||
background.FadeOut(fade_duration, Easing.OutQuint);
|
||||
underscoreLine.FadeIn(fade_duration, Easing.OutQuint);
|
||||
base.OnHoverLost(e);
|
||||
}
|
||||
}
|
||||
}
|
@ -14,7 +14,7 @@ using osu.Game.Online.Leaderboards;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Sections.Recent
|
||||
{
|
||||
public class DrawableRecentActivity : DrawableProfileRow
|
||||
public class DrawableRecentActivity : CompositeDrawable
|
||||
{
|
||||
private IAPIProvider api;
|
||||
|
||||
@ -28,24 +28,55 @@ namespace osu.Game.Overlays.Profile.Sections.Recent
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(IAPIProvider api)
|
||||
private void load(IAPIProvider api, OverlayColourProvider colourProvider)
|
||||
{
|
||||
this.api = api;
|
||||
|
||||
LeftFlowContainer.Padding = new MarginPadding { Left = 10, Right = 160 };
|
||||
|
||||
LeftFlowContainer.Add(content = new LinkFlowContainer
|
||||
RelativeSizeAxes = Axes.X;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
AddInternal(new GridContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Y,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
});
|
||||
|
||||
RightFlowContainer.Add(new DrawableDate(activity.CreatedAt)
|
||||
{
|
||||
Font = OsuFont.GetFont(size: 13),
|
||||
Colour = OsuColour.Gray(0xAA),
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
ColumnDimensions = new[]
|
||||
{
|
||||
new Dimension(GridSizeMode.Absolute, size: 40),
|
||||
new Dimension(),
|
||||
new Dimension(GridSizeMode.AutoSize)
|
||||
},
|
||||
RowDimensions = new[]
|
||||
{
|
||||
new Dimension(GridSizeMode.AutoSize)
|
||||
},
|
||||
Content = new[]
|
||||
{
|
||||
new Drawable[]
|
||||
{
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Child = createIcon().With(icon =>
|
||||
{
|
||||
icon.Anchor = Anchor.Centre;
|
||||
icon.Origin = Anchor.Centre;
|
||||
})
|
||||
},
|
||||
content = new LinkFlowContainer
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
},
|
||||
new DrawableDate(activity.CreatedAt)
|
||||
{
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight,
|
||||
Colour = colourProvider.Foreground1,
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var formatted = createMessage();
|
||||
@ -53,36 +84,33 @@ namespace osu.Game.Overlays.Profile.Sections.Recent
|
||||
content.AddLinks(formatted.Text, formatted.Links);
|
||||
}
|
||||
|
||||
protected override Drawable CreateLeftVisual()
|
||||
private Drawable createIcon()
|
||||
{
|
||||
switch (activity.Type)
|
||||
{
|
||||
case RecentActivityType.Rank:
|
||||
return new UpdateableRank(activity.ScoreRank)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Width = 60,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 16,
|
||||
FillMode = FillMode.Fit,
|
||||
};
|
||||
|
||||
case RecentActivityType.Achievement:
|
||||
return new DelayedLoadWrapper(new MedalIcon(activity.Achievement.Slug)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
FillMode = FillMode.Fit,
|
||||
})
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Width = 60,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 20
|
||||
};
|
||||
|
||||
default:
|
||||
return new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Width = 60,
|
||||
FillMode = FillMode.Fit,
|
||||
};
|
||||
return Empty();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,8 +23,7 @@ namespace osu.Game.Overlays.Profile.Sections.Recent
|
||||
|
||||
Child = sprite = new Sprite
|
||||
{
|
||||
Height = 40,
|
||||
Width = 40,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
};
|
||||
|
@ -8,6 +8,7 @@ using osu.Framework.Bindables;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Online.API;
|
||||
using System.Collections.Generic;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Sections.Recent
|
||||
{
|
||||
@ -16,7 +17,8 @@ namespace osu.Game.Overlays.Profile.Sections.Recent
|
||||
public PaginatedRecentActivityContainer(Bindable<User> user, string header, string missing)
|
||||
: base(user, header, missing)
|
||||
{
|
||||
ItemsPerPage = 5;
|
||||
ItemsPerPage = 10;
|
||||
ItemsContainer.Spacing = new Vector2(0, 5);
|
||||
}
|
||||
|
||||
protected override APIRequest<List<APIRecentActivity>> CreateRequest() =>
|
||||
|
Loading…
Reference in New Issue
Block a user