2020-02-07 21:10:17 +00:00
|
|
|
|
// 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 System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2020-03-21 13:35:04 +00:00
|
|
|
|
using JetBrains.Annotations;
|
2021-08-29 12:00:28 +00:00
|
|
|
|
using osu.Framework.Extensions.LocalisationExtensions;
|
2021-07-17 14:20:37 +00:00
|
|
|
|
using osu.Framework.Localisation;
|
2021-11-04 09:02:44 +00:00
|
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
2020-02-07 21:10:17 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Profile.Sections.Historical
|
|
|
|
|
{
|
2020-03-09 21:50:12 +00:00
|
|
|
|
public class UserHistoryGraph : UserGraph<DateTime, long>
|
2020-02-07 21:10:17 +00:00
|
|
|
|
{
|
2021-07-17 14:20:37 +00:00
|
|
|
|
private readonly LocalisableString tooltipCounterName;
|
2021-04-12 18:51:04 +00:00
|
|
|
|
|
2020-03-21 13:35:04 +00:00
|
|
|
|
[CanBeNull]
|
2021-11-04 09:02:44 +00:00
|
|
|
|
public APIUserHistoryCount[] Values
|
2020-02-07 21:10:17 +00:00
|
|
|
|
{
|
2020-03-09 16:20:06 +00:00
|
|
|
|
set => Data = value?.Select(v => new KeyValuePair<DateTime, long>(v.Date, v.Count)).ToArray();
|
2020-02-07 21:10:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-07-17 14:20:37 +00:00
|
|
|
|
public UserHistoryGraph(LocalisableString tooltipCounterName)
|
2021-04-12 18:51:04 +00:00
|
|
|
|
{
|
|
|
|
|
this.tooltipCounterName = tooltipCounterName;
|
|
|
|
|
}
|
2020-03-09 21:50:12 +00:00
|
|
|
|
|
2020-02-12 19:19:20 +00:00
|
|
|
|
protected override float GetDataPointHeight(long playCount) => playCount;
|
|
|
|
|
|
2021-09-01 08:08:20 +00:00
|
|
|
|
protected override UserGraphTooltipContent GetTooltipContent(DateTime date, long playCount) =>
|
|
|
|
|
new UserGraphTooltipContent(
|
2021-08-31 17:45:32 +00:00
|
|
|
|
tooltipCounterName,
|
|
|
|
|
playCount.ToLocalisableString("N0"),
|
|
|
|
|
date.ToLocalisableString("MMMM yyyy"));
|
2020-02-07 21:10:17 +00:00
|
|
|
|
}
|
|
|
|
|
}
|