mirror of
https://github.com/ppy/osu.git
synced 2025-03-17 22:17:25 +08:00
Implement chart subsections
This commit is contained in:
parent
c2a7f2f356
commit
af174aa653
@ -0,0 +1,51 @@
|
||||
// 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.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Users;
|
||||
using static osu.Game.Users.User;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Sections.Historical
|
||||
{
|
||||
public abstract class ChartProfileSubsection : ProfileSubsection
|
||||
{
|
||||
private ProfileLineChart chart;
|
||||
|
||||
protected ChartProfileSubsection(Bindable<User> user, string headerText)
|
||||
: base(user, headerText)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override Drawable CreateContent() => new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Padding = new MarginPadding
|
||||
{
|
||||
Top = 10,
|
||||
Left = 20,
|
||||
Right = 40
|
||||
},
|
||||
Child = chart = new ProfileLineChart()
|
||||
};
|
||||
|
||||
protected override void OnUserChanged(ValueChangedEvent<User> e)
|
||||
{
|
||||
var values = GetValues(e.NewValue);
|
||||
|
||||
if (values?.Length > 1)
|
||||
{
|
||||
chart.Values = values;
|
||||
Show();
|
||||
return;
|
||||
}
|
||||
|
||||
Hide();
|
||||
}
|
||||
|
||||
protected abstract UserHistoryCount[] GetValues(User user);
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
// 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.Bindables;
|
||||
using osu.Game.Users;
|
||||
using static osu.Game.Users.User;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Sections.Historical
|
||||
{
|
||||
public class PlayHistorySubsection : ChartProfileSubsection
|
||||
{
|
||||
public PlayHistorySubsection(Bindable<User> user)
|
||||
: base(user, "Play History")
|
||||
{
|
||||
}
|
||||
|
||||
protected override UserHistoryCount[] GetValues(User user) => user.MonthlyPlaycounts;
|
||||
}
|
||||
}
|
@ -130,7 +130,9 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
|
||||
Anchor = Anchor.BottomRight,
|
||||
Origin = Anchor.CentreRight,
|
||||
RelativePositionAxes = Axes.Y,
|
||||
Margin = new MarginPadding { Right = 3 },
|
||||
Text = rollingRow.ToString("N0"),
|
||||
Font = OsuFont.GetFont(size: 12),
|
||||
Y = y
|
||||
});
|
||||
|
||||
@ -172,6 +174,7 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
|
||||
Origin = Anchor.CentreLeft,
|
||||
RelativePositionAxes = Axes.X,
|
||||
Text = new DateTime((long)rollingRow).ToString("MMM yyyy"),
|
||||
Font = OsuFont.GetFont(size: 12, weight: FontWeight.SemiBold),
|
||||
Rotation = 45,
|
||||
X = x
|
||||
});
|
||||
@ -228,7 +231,6 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
|
||||
private void load(OverlayColourProvider colourProvider)
|
||||
{
|
||||
Colour = colourProvider.Foreground1;
|
||||
Font = OsuFont.GetFont(size: 12);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,19 @@
|
||||
// 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.Bindables;
|
||||
using osu.Game.Users;
|
||||
using static osu.Game.Users.User;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Sections.Historical
|
||||
{
|
||||
public class ReplaysSubsection : ChartProfileSubsection
|
||||
{
|
||||
public ReplaysSubsection(Bindable<User> user)
|
||||
: base(user, "Replays Watched History")
|
||||
{
|
||||
}
|
||||
|
||||
protected override UserHistoryCount[] GetValues(User user) => user.ReplaysWatchedCounts;
|
||||
}
|
||||
}
|
@ -18,8 +18,10 @@ namespace osu.Game.Overlays.Profile.Sections
|
||||
{
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new PlayHistorySubsection(User),
|
||||
new PaginatedMostPlayedBeatmapContainer(User),
|
||||
new PaginatedScoreContainer(ScoreType.Recent, User, "Recent Plays (24h)", CounterVisibilityState.VisibleWhenZero),
|
||||
new ReplaysSubsection(User)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user