mirror of
https://github.com/ppy/osu.git
synced 2025-02-21 14:23:06 +08:00
historical section now shows the most played beatmaps
This commit is contained in:
parent
48b44e8e4e
commit
4281d76bcf
@ -0,0 +1,160 @@
|
|||||||
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Framework.Input;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Beatmaps.Drawables;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.Containers;
|
||||||
|
using osu.Game.Graphics.Sprites;
|
||||||
|
using OpenTK;
|
||||||
|
using OpenTK.Graphics;
|
||||||
|
|
||||||
|
namespace osu.Game.Overlays.Profile.Sections.Historical
|
||||||
|
{
|
||||||
|
public class MostPlayedBeatmapDrawable : Container
|
||||||
|
{
|
||||||
|
private readonly BeatmapInfo beatmap;
|
||||||
|
private readonly OsuHoverContainer mapperContainer;
|
||||||
|
|
||||||
|
private readonly EdgeEffectParameters edgeEffectNormal = new EdgeEffectParameters
|
||||||
|
{
|
||||||
|
Type = EdgeEffectType.Shadow,
|
||||||
|
Offset = new Vector2(0, 1f),
|
||||||
|
Radius = 2f,
|
||||||
|
Colour = Color4.Black.Opacity(0.25f),
|
||||||
|
};
|
||||||
|
|
||||||
|
private readonly EdgeEffectParameters edgeEffectHovered = new EdgeEffectParameters
|
||||||
|
{
|
||||||
|
Type = EdgeEffectType.Shadow,
|
||||||
|
Offset = new Vector2(0, 5f),
|
||||||
|
Radius = 10f,
|
||||||
|
Colour = Color4.Black.Opacity(0.25f),
|
||||||
|
};
|
||||||
|
|
||||||
|
public MostPlayedBeatmapDrawable(BeatmapInfo beatmap, int playCount)
|
||||||
|
{
|
||||||
|
this.beatmap = beatmap;
|
||||||
|
RelativeSizeAxes = Axes.X;
|
||||||
|
Height = 50;
|
||||||
|
Margin = new MarginPadding { Bottom = 10 };
|
||||||
|
Masking = true;
|
||||||
|
EdgeEffect = edgeEffectNormal;
|
||||||
|
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new Box //Background for this container, otherwise the shadow would be visible
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Colour = OsuColour.Gray(0.2f),
|
||||||
|
},
|
||||||
|
new Box //Image Background while loading
|
||||||
|
{
|
||||||
|
Size = new Vector2(80, 50),
|
||||||
|
Colour = Color4.Black,
|
||||||
|
},
|
||||||
|
new DelayedLoadWrapper(new BeatmapSetCover(beatmap.BeatmapSet, BeatmapSetCoverType.List)
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
FillMode = FillMode.Fit,
|
||||||
|
}),
|
||||||
|
new FillFlowContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Padding = new MarginPadding(10) { Left = 90 },
|
||||||
|
Direction = FillDirection.Vertical,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new Container
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new BeatmapMetadataContainer(beatmap),
|
||||||
|
new FillFlowContainer
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopRight,
|
||||||
|
Origin = Anchor.TopRight,
|
||||||
|
AutoSizeAxes = Axes.Both,
|
||||||
|
Direction = FillDirection.Horizontal,
|
||||||
|
Children = new []
|
||||||
|
{
|
||||||
|
new OsuSpriteText
|
||||||
|
{
|
||||||
|
Anchor = Anchor.BottomRight,
|
||||||
|
Origin = Anchor.BottomRight,
|
||||||
|
Text = playCount.ToString(),
|
||||||
|
TextSize = 18,
|
||||||
|
Font = @"Exo2.0-SemiBoldItalic"
|
||||||
|
},
|
||||||
|
new OsuSpriteText
|
||||||
|
{
|
||||||
|
Anchor = Anchor.BottomRight,
|
||||||
|
Origin = Anchor.BottomRight,
|
||||||
|
Text = @"times played ",
|
||||||
|
TextSize = 12,
|
||||||
|
Font = @"Exo2.0-RegularItalic"
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
new FillFlowContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Direction = FillDirection.Horizontal,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new OsuSpriteText
|
||||||
|
{
|
||||||
|
Text = @"mapped by ",
|
||||||
|
TextSize = 12,
|
||||||
|
},
|
||||||
|
mapperContainer = new OsuHoverContainer
|
||||||
|
{
|
||||||
|
AutoSizeAxes = Axes.Both,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new OsuSpriteText
|
||||||
|
{
|
||||||
|
Text = beatmap.Metadata.AuthorString,
|
||||||
|
TextSize = 12,
|
||||||
|
Font = @"Exo2.0-MediumItalic"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader(true)]
|
||||||
|
private void load(UserProfileOverlay profileOverlay)
|
||||||
|
{
|
||||||
|
if(profileOverlay != null)
|
||||||
|
mapperContainer.Action = () => profileOverlay.ShowUser(beatmap.BeatmapSet.Metadata.Author);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool OnHover(InputState state)
|
||||||
|
{
|
||||||
|
TweenEdgeEffectTo(edgeEffectHovered, 120, Easing.OutQuint);
|
||||||
|
return base.OnHover(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnHoverLost(InputState state)
|
||||||
|
{
|
||||||
|
TweenEdgeEffectTo(edgeEffectNormal, 120, Easing.OutQuint);
|
||||||
|
base.OnHoverLost(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,52 @@
|
|||||||
|
// 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 osu.Framework.Configuration;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Online.API.Requests;
|
||||||
|
using osu.Game.Users;
|
||||||
|
|
||||||
|
namespace osu.Game.Overlays.Profile.Sections.Historical
|
||||||
|
{
|
||||||
|
public class PaginatedMostPlayedBeatmapContainer : PaginatedContainer
|
||||||
|
{
|
||||||
|
public PaginatedMostPlayedBeatmapContainer(Bindable<User> user)
|
||||||
|
:base(user, "Most Played Beatmaps", "No performance records. :(")
|
||||||
|
{
|
||||||
|
ItemsPerPage = 5;
|
||||||
|
|
||||||
|
ItemsContainer.Direction = FillDirection.Vertical;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void ShowMore()
|
||||||
|
{
|
||||||
|
base.ShowMore();
|
||||||
|
|
||||||
|
var req = new GetUserMostPlayedBeatmapsRequest(User.Value.Id, BeatmapSetType.MostPlayed, VisiblePages++ * ItemsPerPage);
|
||||||
|
|
||||||
|
req.Success += beatmaps =>
|
||||||
|
{
|
||||||
|
ShowMoreButton.FadeTo(beatmaps.Count == ItemsPerPage ? 1 : 0);
|
||||||
|
ShowMoreLoading.Hide();
|
||||||
|
|
||||||
|
if (!beatmaps.Any() && VisiblePages == 1)
|
||||||
|
{
|
||||||
|
MissingText.Show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
MissingText.Hide();
|
||||||
|
|
||||||
|
foreach (var beatmap in beatmaps)
|
||||||
|
{
|
||||||
|
ItemsContainer.Add(new MostPlayedBeatmapDrawable(beatmap.GetBeatmapInfo(Rulesets), beatmap.PlayCount));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Api.Queue(req);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,9 @@
|
|||||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Online.API.Requests;
|
using osu.Game.Online.API.Requests;
|
||||||
|
using osu.Game.Overlays.Profile.Sections.Historical;
|
||||||
using osu.Game.Overlays.Profile.Sections.Ranks;
|
using osu.Game.Overlays.Profile.Sections.Ranks;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Profile.Sections
|
namespace osu.Game.Overlays.Profile.Sections
|
||||||
@ -14,7 +16,11 @@ namespace osu.Game.Overlays.Profile.Sections
|
|||||||
|
|
||||||
public HistoricalSection()
|
public HistoricalSection()
|
||||||
{
|
{
|
||||||
Child = new PaginatedScoreContainer(ScoreType.Recent, User, "Recent Plays (24h)", "No performance records. :(");
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new PaginatedMostPlayedBeatmapContainer(User),
|
||||||
|
new PaginatedScoreContainer(ScoreType.Recent, User, "Recent Plays (24h)", "No performance records. :("),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -290,6 +290,8 @@
|
|||||||
<Compile Include="Online\API\Requests\GetUserBeatmapsRequest.cs" />
|
<Compile Include="Online\API\Requests\GetUserBeatmapsRequest.cs" />
|
||||||
<Compile Include="Overlays\Profile\Sections\BeatmapMetadataContainer.cs" />
|
<Compile Include="Overlays\Profile\Sections\BeatmapMetadataContainer.cs" />
|
||||||
<Compile Include="Overlays\Profile\Sections\Beatmaps\PaginatedBeatmapContainer.cs" />
|
<Compile Include="Overlays\Profile\Sections\Beatmaps\PaginatedBeatmapContainer.cs" />
|
||||||
|
<Compile Include="Overlays\Profile\Sections\Historical\MostPlayedBeatmapDrawable.cs" />
|
||||||
|
<Compile Include="Overlays\Profile\Sections\Historical\PaginatedMostPlayedBeatmapContainer.cs" />
|
||||||
<Compile Include="Overlays\Profile\Sections\PaginatedContainer.cs" />
|
<Compile Include="Overlays\Profile\Sections\PaginatedContainer.cs" />
|
||||||
<Compile Include="Overlays\Profile\Sections\Ranks\DrawablePerformanceScore.cs" />
|
<Compile Include="Overlays\Profile\Sections\Ranks\DrawablePerformanceScore.cs" />
|
||||||
<Compile Include="Overlays\Profile\Sections\Ranks\PaginatedScoreContainer.cs" />
|
<Compile Include="Overlays\Profile\Sections\Ranks\PaginatedScoreContainer.cs" />
|
||||||
|
Loading…
Reference in New Issue
Block a user